[telepathy-qt4/master] FileTransferChannelCreationProperties: Added class to be used by Account::createFileTransfer.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Thu Sep 17 13:06:50 PDT 2009
---
TelepathyQt4/FileTransferChannelCreationProperties | 13 ++
TelepathyQt4/Makefile.am | 2 +
.../file-transfer-channel-creation-properties.cpp | 168 ++++++++++++++++++++
.../file-transfer-channel-creation-properties.h | 90 +++++++++++
4 files changed, 273 insertions(+), 0 deletions(-)
create mode 100644 TelepathyQt4/FileTransferChannelCreationProperties
create mode 100644 TelepathyQt4/file-transfer-channel-creation-properties.cpp
create mode 100644 TelepathyQt4/file-transfer-channel-creation-properties.h
diff --git a/TelepathyQt4/FileTransferChannelCreationProperties b/TelepathyQt4/FileTransferChannelCreationProperties
new file mode 100644
index 0000000..c6aaad7
--- /dev/null
+++ b/TelepathyQt4/FileTransferChannelCreationProperties
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt4_FileTransferChannelCreationProperties_HEADER_GUARD_
+#define _TelepathyQt4_FileTransferChannelCreationProperties_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#define IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/file-transfer-channel-creation-properties.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index f483a6f..0ddffeb 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -73,6 +73,7 @@ libtelepathy_qt4_la_SOURCES = \
debug-internal.h \
feature.cpp \
file-transfer-channel.cpp \
+ file-transfer-channel-creation-properties.cpp \
incoming-file-transfer-channel.cpp \
key-file.cpp \
manager-file.cpp \
@@ -290,6 +291,7 @@ tpqt4include_HEADERS = \
debug.h \
feature.h \
file-transfer-channel.h \
+ file-transfer-channel-creation-properties.h \
incoming-file-transfer-channel.h \
key-file.h \
manager-file.h \
diff --git a/TelepathyQt4/file-transfer-channel-creation-properties.cpp b/TelepathyQt4/file-transfer-channel-creation-properties.cpp
new file mode 100644
index 0000000..fd3107b
--- /dev/null
+++ b/TelepathyQt4/file-transfer-channel-creation-properties.cpp
@@ -0,0 +1,168 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <TelepathyQt4/FileTransferChannelCreationProperties>
+
+#include <QSharedData>
+
+namespace Tp
+{
+
+struct FileTransferChannelCreationProperties::Private : public QSharedData
+{
+ Private(const QString &suggestedFileName, const QString &contentType,
+ qulonglong size)
+ : suggestedFileName(suggestedFileName),
+ contentType(contentType),
+ size(size),
+ hasContentHash(false), contentHashType(FileHashTypeNone),
+ hasDescription(false),
+ hasLastModificationTime(false)
+ {
+ }
+
+ /* mandatory parameters */
+ QString suggestedFileName;
+ QString contentType;
+ qulonglong size;
+
+ /* optional parameters */
+ bool hasContentHash;
+ FileHashType contentHashType;
+ QString contentHash;
+
+ bool hasDescription;
+ QString description;
+
+ bool hasLastModificationTime;
+ QDateTime lastModificationTime;
+};
+
+FileTransferChannelCreationProperties::FileTransferChannelCreationProperties(
+ const QString &suggestedFileName, const QString &contentType,
+ qulonglong size)
+ : mPriv(new Private(suggestedFileName, contentType, size))
+{
+}
+
+FileTransferChannelCreationProperties::FileTransferChannelCreationProperties(
+ const FileTransferChannelCreationProperties &other)
+ : mPriv(other.mPriv)
+{
+}
+
+
+FileTransferChannelCreationProperties::~FileTransferChannelCreationProperties()
+{
+}
+
+FileTransferChannelCreationProperties &FileTransferChannelCreationProperties::operator=(
+ const FileTransferChannelCreationProperties &other)
+{
+ if (this != &other) {
+ mPriv = other.mPriv;
+ }
+ return *this;
+}
+
+bool FileTransferChannelCreationProperties::operator==(
+ const FileTransferChannelCreationProperties &other) const
+{
+ return mPriv == other.mPriv;
+}
+
+FileTransferChannelCreationProperties &FileTransferChannelCreationProperties::setContentHash(
+ FileHashType contentHashType, const QString &contentHash)
+{
+ mPriv->hasContentHash = (contentHashType != FileHashTypeNone);
+ mPriv->contentHashType = contentHashType;
+ mPriv->contentHash = contentHash;
+ return *this;
+}
+
+FileTransferChannelCreationProperties &FileTransferChannelCreationProperties::setDescription(
+ const QString &description)
+{
+ mPriv->hasDescription = (!description.isEmpty());
+ mPriv->description = description;
+ return *this;
+}
+
+FileTransferChannelCreationProperties &FileTransferChannelCreationProperties::setLastModificationTime(
+ const QDateTime &lastModificationTime)
+{
+ mPriv->hasLastModificationTime = (lastModificationTime.isValid());
+ mPriv->lastModificationTime = lastModificationTime;
+ return *this;
+}
+
+QString FileTransferChannelCreationProperties::suggestedFileName() const
+{
+ return mPriv->suggestedFileName;
+}
+
+QString FileTransferChannelCreationProperties::contentType() const
+{
+ return mPriv->contentType;
+}
+
+qulonglong FileTransferChannelCreationProperties::size() const
+{
+ return mPriv->size;
+}
+
+bool FileTransferChannelCreationProperties::hasContentHash() const
+{
+ return mPriv->hasContentHash;
+
+}
+
+FileHashType FileTransferChannelCreationProperties::contentHashType() const
+{
+ return mPriv->contentHashType;
+}
+
+QString FileTransferChannelCreationProperties::contentHash() const
+{
+ return mPriv->contentHash;
+}
+
+bool FileTransferChannelCreationProperties::hasDescription() const
+{
+ return mPriv->hasDescription;
+}
+
+QString FileTransferChannelCreationProperties::description() const
+{
+ return mPriv->description;
+}
+
+bool FileTransferChannelCreationProperties::hasLastModificationTime() const
+{
+ return mPriv->hasLastModificationTime;
+}
+
+QDateTime FileTransferChannelCreationProperties::lastModificationTime() const
+{
+ return mPriv->lastModificationTime;
+}
+
+} // Tp
diff --git a/TelepathyQt4/file-transfer-channel-creation-properties.h b/TelepathyQt4/file-transfer-channel-creation-properties.h
new file mode 100644
index 0000000..6532c95
--- /dev/null
+++ b/TelepathyQt4/file-transfer-channel-creation-properties.h
@@ -0,0 +1,90 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _TelepathyQt4_file_transfer_channel_creation_properties_h_HEADER_GUARD_
+#define _TelepathyQt4_file_transfer_channel_creation_properties_h_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#error IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/Constants>
+
+#include <QDateTime>
+#include <QSharedDataPointer>
+#include <QString>
+
+namespace Tp
+{
+
+class FileTransferChannelCreationProperties
+{
+public:
+ FileTransferChannelCreationProperties(const QString &suggestedFileName,
+ const QString &contentType, qulonglong size);
+ FileTransferChannelCreationProperties(
+ const FileTransferChannelCreationProperties &other);
+ ~FileTransferChannelCreationProperties();
+
+ FileTransferChannelCreationProperties &operator=(
+ const FileTransferChannelCreationProperties &other);
+ bool operator==(
+ const FileTransferChannelCreationProperties &other) const;
+ inline bool operator!=(
+ const FileTransferChannelCreationProperties &other) const
+ {
+ return !(*this == other);
+ }
+
+ FileTransferChannelCreationProperties &setContentHash(
+ FileHashType contentHashType, const QString &contentHash);
+ FileTransferChannelCreationProperties &setDescription(
+ const QString &description);
+ FileTransferChannelCreationProperties &setLastModificationTime(
+ const QDateTime &lastModificationTime);
+
+private:
+ friend class Account;
+
+ /* mandatory parameters */
+ QString suggestedFileName() const;
+ QString contentType() const;
+ qulonglong size() const;
+
+ /* optional parameters */
+ bool hasContentHash() const;
+ FileHashType contentHashType() const;
+ QString contentHash() const;
+
+ bool hasDescription() const;
+ QString description() const;
+
+ bool hasLastModificationTime() const;
+ QDateTime lastModificationTime() const;
+
+ struct Private;
+ friend struct Private;
+ QSharedDataPointer<Private> mPriv;
+};
+
+} // Tp
+
+#endif
--
1.5.6.5
More information about the telepathy-commits
mailing list