diff options
Diffstat (limited to 'TelepathyQt/base-channel.cpp')
-rw-r--r-- | TelepathyQt/base-channel.cpp | 349 |
1 files changed, 349 insertions, 0 deletions
diff --git a/TelepathyQt/base-channel.cpp b/TelepathyQt/base-channel.cpp index 720d58ed..c13e8f04 100644 --- a/TelepathyQt/base-channel.cpp +++ b/TelepathyQt/base-channel.cpp @@ -779,6 +779,355 @@ QString BaseChannelMessagesInterface::sendMessage(const Tp::MessagePartList &mes return token; } +// Chan.T.FileTransfer +// The BaseChannelFileTransferType code is fully or partially generated by the TelepathyQt-Generator. +struct TP_QT_NO_EXPORT BaseChannelFileTransferType::Private { + Private(BaseChannelFileTransferType *parent, + const QString &contentType, + const QString &filename, + qulonglong size, + uint contentHashType, + const QString &contentHash, + const QString &description, + const QDateTime &date, + const Tp::SupportedSocketMap &availableSocketTypes) + : state(Tp::FileTransferStatePending), + contentType(contentType), + filename(filename), + size(size), + contentHashType(contentHashType), + contentHash(contentHash), + description(description), + date(date), + availableSocketTypes(availableSocketTypes), + transferredBytes(0), + initialOffset(0), + adaptee(new BaseChannelFileTransferType::Adaptee(parent)) + { + } + + uint state; + QString contentType; + QString filename; + qulonglong size; + uint contentHashType; + QString contentHash; + QString description; + QDateTime date; + Tp::SupportedSocketMap availableSocketTypes; + qulonglong transferredBytes; + qulonglong initialOffset; + QString uri; + QString fileCollection; + AcceptFileCallback acceptFileCB; + ProvideFileCallback provideFileCB; + BaseChannelFileTransferType::Adaptee *adaptee; +}; + +BaseChannelFileTransferType::Adaptee::Adaptee(BaseChannelFileTransferType *interface) + : QObject(interface), + mInterface(interface) +{ +} + +BaseChannelFileTransferType::Adaptee::~Adaptee() +{ +} + +uint BaseChannelFileTransferType::Adaptee::state() const +{ + return mInterface->state(); +} + +QString BaseChannelFileTransferType::Adaptee::contentType() const +{ + return mInterface->contentType(); +} + +QString BaseChannelFileTransferType::Adaptee::filename() const +{ + return mInterface->filename(); +} + +qulonglong BaseChannelFileTransferType::Adaptee::size() const +{ + return mInterface->size(); +} + +uint BaseChannelFileTransferType::Adaptee::contentHashType() const +{ + return mInterface->contentHashType(); +} + +QString BaseChannelFileTransferType::Adaptee::contentHash() const +{ + return mInterface->contentHash(); +} + +QString BaseChannelFileTransferType::Adaptee::description() const +{ + return mInterface->description(); +} + +qlonglong BaseChannelFileTransferType::Adaptee::date() const +{ + return mInterface->date().toTime_t(); +} + +Tp::SupportedSocketMap BaseChannelFileTransferType::Adaptee::availableSocketTypes() const +{ + return mInterface->availableSocketTypes(); +} + +qulonglong BaseChannelFileTransferType::Adaptee::transferredBytes() const +{ + return mInterface->transferredBytes(); +} + +qulonglong BaseChannelFileTransferType::Adaptee::initialOffset() const +{ + return mInterface->initialOffset(); +} + +QString BaseChannelFileTransferType::Adaptee::uri() const +{ + return mInterface->uri(); +} + +QString BaseChannelFileTransferType::Adaptee::fileCollection() const +{ + return mInterface->fileCollection(); +} + +void BaseChannelFileTransferType::Adaptee::acceptFile(uint addressType, uint accessControl, const QDBusVariant &accessControlParam, qulonglong offset, + const Tp::Service::ChannelTypeFileTransferAdaptor::AcceptFileContextPtr &context) +{ + qDebug() << "BaseChannelFileTransferType::Adaptee::acceptFile"; + DBusError error; + QDBusVariant address = mInterface->acceptFile(addressType, accessControl, accessControlParam, offset, &error); + if (error.isValid()) { + context->setFinishedWithError(error.name(), error.message()); + return; + } + context->setFinished(address); +} + +void BaseChannelFileTransferType::Adaptee::provideFile(uint addressType, uint accessControl, const QDBusVariant &accessControlParam, + const Tp::Service::ChannelTypeFileTransferAdaptor::ProvideFileContextPtr &context) +{ + qDebug() << "BaseChannelFileTransferType::Adaptee::provideFile"; + DBusError error; + QDBusVariant address = mInterface->provideFile(addressType, accessControl, accessControlParam, &error); + if (error.isValid()) { + context->setFinishedWithError(error.name(), error.message()); + return; + } + context->setFinished(address); +} + +/** + * \class BaseChannelFileTransferType + * \ingroup servicecm + * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel> + * + * \brief Base class for implementations of Channel.Type.FileTransfer + */ + +/** + * Class constructor. + */ +BaseChannelFileTransferType::BaseChannelFileTransferType(const QString &contentType, + const QString &filename, + qulonglong size, + uint contentHashType, + const QString &contentHash, + const QString &description, + const QDateTime &date, + const Tp::SupportedSocketMap &availableSocketTypes) + : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER), + mPriv(new Private(this, contentType, filename, size, contentHashType, contentHash, description, date, availableSocketTypes)) +{ +} + +/** + * Class destructor. + */ +BaseChannelFileTransferType::~BaseChannelFileTransferType() +{ + delete mPriv; +} + +/** + * Return the immutable properties of this interface. + * + * Immutable properties cannot change after the interface has been registered + * on a service on the bus with registerInterface(). + * + * \return The immutable properties of this interface. + */ +QVariantMap BaseChannelFileTransferType::immutableProperties() const +{ + QVariantMap map; + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".ContentType"), + QVariant::fromValue(contentType())); + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Filename"), + QVariant::fromValue(filename())); + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Size"), + QVariant::fromValue(size())); + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".ContentHashType"), + QVariant::fromValue(contentHashType())); + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".ContentHash"), + QVariant::fromValue(contentHash())); + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Description"), + QVariant::fromValue(description())); + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".Date"), + QVariant::fromValue(date().toTime_t())); + map.insert(TP_QT_IFACE_CHANNEL_TYPE_FILE_TRANSFER + QLatin1String(".AvailableSocketTypes"), + QVariant::fromValue(availableSocketTypes())); + return map; +} + +uint BaseChannelFileTransferType::state() const +{ + return mPriv->state; +} + +void BaseChannelFileTransferType::setState(uint state, uint reason) +{ + mPriv->state = state; + QMetaObject::invokeMethod(mPriv->adaptee, "fileTransferStateChanged", Q_ARG(uint, state), Q_ARG(uint, reason)); //Can simply use emit in Qt5 +} + +QString BaseChannelFileTransferType::contentType() const +{ + return mPriv->contentType; +} + +QString BaseChannelFileTransferType::filename() const +{ + return mPriv->filename; +} + +qulonglong BaseChannelFileTransferType::size() const +{ + return mPriv->size; +} + +uint BaseChannelFileTransferType::contentHashType() const +{ + return mPriv->contentHashType; +} + +QString BaseChannelFileTransferType::contentHash() const +{ + return mPriv->contentHash; +} + +QString BaseChannelFileTransferType::description() const +{ + return mPriv->description; +} + +QDateTime BaseChannelFileTransferType::date() const +{ + return mPriv->date; +} + +Tp::SupportedSocketMap BaseChannelFileTransferType::availableSocketTypes() const +{ + return mPriv->availableSocketTypes; +} + +qulonglong BaseChannelFileTransferType::transferredBytes() const +{ + return mPriv->transferredBytes; +} + +void BaseChannelFileTransferType::setTransferredBytes(qulonglong count) +{ + mPriv->transferredBytes = count; + QMetaObject::invokeMethod(mPriv->adaptee, "transferredBytesChanged", Q_ARG(qulonglong, count)); //Can simply use emit in Qt5 +} + +qulonglong BaseChannelFileTransferType::initialOffset() const +{ + return mPriv->initialOffset; +} + +void BaseChannelFileTransferType::setInitialOffset(qulonglong initialOffset) +{ + mPriv->initialOffset = initialOffset; +} + +QString BaseChannelFileTransferType::uri() const +{ + return mPriv->uri; +} + +void BaseChannelFileTransferType::setUri(const QString &uri) +{ + mPriv->uri = uri; +} + +QString BaseChannelFileTransferType::fileCollection() const +{ + return mPriv->fileCollection; +} + +void BaseChannelFileTransferType::setFileCollection(const QString &fileCollection) +{ + mPriv->fileCollection = fileCollection; +} + +void BaseChannelFileTransferType::createAdaptor() +{ + (void) new Tp::Service::ChannelTypeFileTransferAdaptor(dbusObject()->dbusConnection(), + mPriv->adaptee, dbusObject()); +} + +void BaseChannelFileTransferType::setAcceptFileCallback(const AcceptFileCallback &cb) +{ + mPriv->acceptFileCB = cb; +} + +QDBusVariant BaseChannelFileTransferType::acceptFile(uint addressType, uint accessControl, const QDBusVariant &accessControlParam, qulonglong offset, DBusError *error) +{ + if (!mPriv->acceptFileCB.isValid()) { + error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); + return QDBusVariant(); + } + return mPriv->acceptFileCB(addressType, accessControl, accessControlParam, offset, error); +} + +void BaseChannelFileTransferType::setProvideFileCallback(const ProvideFileCallback &cb) +{ + mPriv->provideFileCB = cb; +} + +QDBusVariant BaseChannelFileTransferType::provideFile(uint addressType, uint accessControl, const QDBusVariant &accessControlParam, DBusError *error) +{ + if (!mPriv->provideFileCB.isValid()) { + error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); + return QDBusVariant(); + } + return mPriv->provideFileCB(addressType, accessControl, accessControlParam, error); +} + +void BaseChannelFileTransferType::fileTransferStateChanged(uint state, uint reason) +{ + QMetaObject::invokeMethod(mPriv->adaptee, "fileTransferStateChanged", Q_ARG(uint, state), Q_ARG(uint, reason)); //Can simply use emit in Qt5 +} + +void BaseChannelFileTransferType::initialOffsetDefined(qulonglong initialOffset) +{ + QMetaObject::invokeMethod(mPriv->adaptee, "initialOffsetDefined", Q_ARG(qulonglong, initialOffset)); //Can simply use emit in Qt5 +} + +void BaseChannelFileTransferType::uriDefined(const QString &uri) +{ + QMetaObject::invokeMethod(mPriv->adaptee, "uriDefined", Q_ARG(QString, uri)); //Can simply use emit in Qt5 +} + // Chan.T.RoomList // The BaseChannelRoomListType code is fully or partially generated by the TelepathyQt-Generator. struct TP_QT_NO_EXPORT BaseChannelRoomListType::Private { |