diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-02-22 17:37:54 +0200 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-03-21 16:40:10 +0200 |
commit | 85755b41410c0c90e505c970e305a750042ef1ac (patch) | |
tree | 04add9688d1a0769ea213bd77309bd84ba8e5587 | |
parent | 1e53279abb0c7fa23b65faa03e008cc1e3f29675 (diff) |
Account: add methods to ensure/create Call channels
-rw-r--r-- | TelepathyQt/account.cpp | 470 | ||||
-rw-r--r-- | TelepathyQt/account.h | 66 | ||||
-rw-r--r-- | TelepathyQt/call-channel.h | 1 |
3 files changed, 536 insertions, 1 deletions
diff --git a/TelepathyQt/account.cpp b/TelepathyQt/account.cpp index c61accbd..65335046 100644 --- a/TelepathyQt/account.cpp +++ b/TelepathyQt/account.cpp @@ -143,6 +143,88 @@ QVariantMap textChatroomRequest(const QString &roomName) return request; } +QVariantMap callCommonRequest(bool withAudio, const QString &audioName, + bool withVideo, const QString &videoName) +{ + QVariantMap request; + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"), + TP_QT_IFACE_CHANNEL_TYPE_CALL); + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"), + (uint) Tp::HandleTypeContact); + + if (withAudio) { + request.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio"), + true); + if (!audioName.isEmpty()) { + request.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudioName"), + audioName); + } + } + + if (withVideo) { + request.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo"), + true); + if (!audioName.isEmpty()) { + request.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideoName"), + audioName); + } + } + + return request; +} + +QVariantMap audioCallRequest(const QString &contactIdentifier, const QString &contentName) +{ + QVariantMap request = callCommonRequest(true, contentName, false, QString()); + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID"), + contactIdentifier); + return request; +} + +QVariantMap audioCallRequest(const Tp::ContactPtr &contact, const QString &contentName) +{ + QVariantMap request = callCommonRequest(true, contentName, false, QString()); + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"), + contact ? contact->handle().at(0) : (uint) 0); + return request; +} + +QVariantMap videoCallRequest(const QString &contactIdentifier, const QString &contentName) +{ + QVariantMap request = callCommonRequest(false, QString(), true, contentName); + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID"), + contactIdentifier); + return request; +} + +QVariantMap videoCallRequest(const Tp::ContactPtr &contact, const QString &contentName) +{ + QVariantMap request = callCommonRequest(false, QString(), true, contentName); + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"), + contact ? contact->handle().at(0) : (uint) 0); + return request; +} + +QVariantMap audioVideoCallRequest(const QString &contactIdentifier, + const QString &audioName, + const QString &videoName) +{ + QVariantMap request = callCommonRequest(true, audioName, true, videoName); + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID"), + contactIdentifier); + return request; +} + +QVariantMap audioVideoCallRequest(const Tp::ContactPtr &contact, + const QString &audioName, + const QString &videoName) +{ + QVariantMap request = callCommonRequest(true, audioName, true, videoName); + request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"), + contact ? contact->handle().at(0) : (uint) 0); + return request; +} + QVariantMap streamedMediaCallCommonRequest() { QVariantMap request; @@ -2148,6 +2230,224 @@ PendingChannelRequest *Account::ensureTextChatroom( } /** + * Start a request to ensure that an audio call channel with the given + * contact \a contactIdentifier exists, creating it if necessary. + * + * See ensureChannel() for more details. + * + * \param contactIdentifier The identifier of the contact to call. + * \param initialAudioContentName The name of the initial CallContent that will + * be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \param preferredHandler Either the well-known bus name (starting with + * org.freedesktop.Telepathy.Client.) of the preferred + * handler for this channel, or an empty string to + * indicate that any handler would be acceptable. + * \param hints Arbitrary metadata which will be relayed to the handler if supported, + * as indicated by supportsRequestHints(). + * \return A PendingChannelRequest which will emit PendingChannelRequest::finished + * when the request has been made. + * \sa ensureChannel(), createChannel() + */ +PendingChannelRequest *Account::ensureAudioCall( + const QString &contactIdentifier, + const QString &initialAudioContentName, + const QDateTime &userActionTime, + const QString &preferredHandler, + const ChannelRequestHints &hints) +{ + QVariantMap request = audioCallRequest(contactIdentifier, initialAudioContentName); + + return new PendingChannelRequest(AccountPtr(this), request, userActionTime, + preferredHandler, false, hints); +} + +/** + * Start a request to ensure that an audio call channel with the given + * contact \a contact exists, creating it if necessary. + * + * See ensureChannel() for more details. + * + * \param contact The contact to call. + * \param initialAudioContentName The name of the initial audio CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \param preferredHandler Either the well-known bus name (starting with + * org.freedesktop.Telepathy.Client.) of the preferred + * handler for this channel, or an empty string to + * indicate that any handler would be acceptable. + * \param hints Arbitrary metadata which will be relayed to the handler if supported, + * as indicated by supportsRequestHints(). + * \return A PendingChannelRequest which will emit PendingChannelRequest::finished + * when the request has been made. + * \sa ensureChannel(), createChannel() + */ +PendingChannelRequest* Account::ensureAudioCall( + const ContactPtr &contact, + const QString &initialAudioContentName, + const QDateTime &userActionTime, + const QString &preferredHandler, + const ChannelRequestHints &hints) +{ + QVariantMap request = audioCallRequest(contact, initialAudioContentName); + + return new PendingChannelRequest(AccountPtr(this), request, userActionTime, + preferredHandler, false, hints); +} + +/** + * Start a request to ensure that a video call channel with the given + * contact \a contactIdentifier exists, creating it if necessary. + * + * See ensureChannel() for more details. + * + * \param contactIdentifier The identifier of the contact to call. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \param preferredHandler Either the well-known bus name (starting with + * org.freedesktop.Telepathy.Client.) of the preferred + * handler for this channel, or an empty string to + * indicate that any handler would be acceptable. + * \param hints Arbitrary metadata which will be relayed to the handler if supported, + * as indicated by supportsRequestHints(). + * \return A PendingChannelRequest which will emit PendingChannelRequest::finished + * when the request has been made. + * \sa ensureChannel(), createChannel() + */ +PendingChannelRequest *Account::ensureVideoCall( + const QString &contactIdentifier, + const QString &initialVideoContentName, + const QDateTime &userActionTime, + const QString &preferredHandler, + const ChannelRequestHints &hints) +{ + QVariantMap request = videoCallRequest(contactIdentifier, initialVideoContentName); + + return new PendingChannelRequest(AccountPtr(this), request, userActionTime, + preferredHandler, false, hints); +} + +/** + * Start a request to ensure that a video call channel with the given + * contact \a contact exists, creating it if necessary. + * + * See ensureChannel() for more details. + * + * \param contact The contact to call. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \param preferredHandler Either the well-known bus name (starting with + * org.freedesktop.Telepathy.Client.) of the preferred + * handler for this channel, or an empty string to + * indicate that any handler would be acceptable. + * \param hints Arbitrary metadata which will be relayed to the handler if supported, + * as indicated by supportsRequestHints(). + * \return A PendingChannelRequest which will emit PendingChannelRequest::finished + * when the request has been made. + * \sa ensureChannel(), createChannel() + */ +PendingChannelRequest *Account::ensureVideoCall( + const ContactPtr &contact, + const QString &initialVideoContentName, + const QDateTime &userActionTime, + const QString &preferredHandler, + const ChannelRequestHints &hints) +{ + QVariantMap request = videoCallRequest(contact, initialVideoContentName); + + return new PendingChannelRequest(AccountPtr(this), request, userActionTime, + preferredHandler, false, hints); +} + +/** + * Start a request to ensure that an audio/video call channel with the given + * contact \a contactIdentifier exists, creating it if necessary. + * + * See ensureChannel() for more details. + * + * \param contactIdentifier The identifier of the contact to call. + * \param initialAudioContentName The name of the initial audio CallContent that + * will be automatically added on the channel. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \param preferredHandler Either the well-known bus name (starting with + * org.freedesktop.Telepathy.Client.) of the preferred + * handler for this channel, or an empty string to + * indicate that any handler would be acceptable. + * \param hints Arbitrary metadata which will be relayed to the handler if supported, + * as indicated by supportsRequestHints(). + * \return A PendingChannelRequest which will emit PendingChannelRequest::finished + * when the request has been made. + * \sa ensureChannel(), createChannel() + */ +PendingChannelRequest *Account::ensureAudioVideoCall( + const QString &contactIdentifier, + const QString &initialAudioContentName, + const QString &initialVideoContentName, + const QDateTime &userActionTime, + const QString &preferredHandler, + const ChannelRequestHints &hints) +{ + QVariantMap request = audioVideoCallRequest(contactIdentifier, + initialAudioContentName, initialVideoContentName); + + return new PendingChannelRequest(AccountPtr(this), request, userActionTime, + preferredHandler, false, hints); +} + +/** + * Start a request to ensure that an audio/video call channel with the given + * contact \a contact exists, creating it if necessary. + * + * See ensureChannel() for more details. + * + * \param contact The contact to call. + * \param initialAudioContentName The name of the initial audio CallContent that + * will be automatically added on the channel. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \param preferredHandler Either the well-known bus name (starting with + * org.freedesktop.Telepathy.Client.) of the preferred + * handler for this channel, or an empty string to + * indicate that any handler would be acceptable. + * \param hints Arbitrary metadata which will be relayed to the handler if supported, + * as indicated by supportsRequestHints(). + * \return A PendingChannelRequest which will emit PendingChannelRequest::finished + * when the request has been made. + * \sa ensureChannel(), createChannel() + */ +PendingChannelRequest *Account::ensureAudioVideoCall( + const ContactPtr &contact, + const QString &initialAudioContentName, + const QString &initialVideoContentName, + const QDateTime &userActionTime, + const QString &preferredHandler, + const ChannelRequestHints &hints) +{ + QVariantMap request = audioVideoCallRequest(contact, + initialAudioContentName, initialVideoContentName); + + return new PendingChannelRequest(AccountPtr(this), request, userActionTime, + preferredHandler, false, hints); +} + +/** * Start a request to ensure that a media channel with the given * contact \a contactIdentifier exists, creating it if necessary. * @@ -2815,6 +3115,176 @@ PendingChannel *Account::ensureAndHandleTextChatroom( } /** + * Start a request to ensure that an audio call channel with the given + * contact \a contactIdentifier exists, creating it if necessary. + * This initially just creates a PendingChannel object, + * which can be used to track the success or failure of the request. + * + * \param contactIdentifier The identifier of the contact to call. + * \param initialAudioContentName The name of the initial audio CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \return A PendingChannel which will emit PendingChannel::finished + * successfully, when the Channel is available for handling using + * PendingChannel::channel(), or with an error if one has been encountered. + * \sa ensureAndHandleChannel(), createAndHandleChannel() + */ +PendingChannel *Account::ensureAndHandleAudioCall( + const QString &contactIdentifier, + const QString &initialAudioContentName, + const QDateTime &userActionTime) +{ + QVariantMap request = audioCallRequest(contactIdentifier, initialAudioContentName); + + return ensureAndHandleChannel(request, userActionTime); +} + +/** + * Start a request to ensure that an audio call channel with the given + * contact \a contact exists, creating it if necessary. + * This initially just creates a PendingChannel object, + * which can be used to track the success or failure of the request. + * + * \param contact The contact to call. + * \param initialAudioContentName The name of the initial audio CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \return A PendingChannel which will emit PendingChannel::finished + * successfully, when the Channel is available for handling using + * PendingChannel::channel(), or with an error if one has been encountered. + * \sa ensureAndHandleChannel(), createAndHandleChannel() + */ +PendingChannel *Account::ensureAndHandleAudioCall( + const ContactPtr &contact, + const QString &initialAudioContentName, + const QDateTime &userActionTime) +{ + QVariantMap request = audioCallRequest(contact, initialAudioContentName); + + return ensureAndHandleChannel(request, userActionTime); +} + +/** + * Start a request to ensure that a video call channel with the given + * contact \a contactIdentifier exists, creating it if necessary. + * This initially just creates a PendingChannel object, + * which can be used to track the success or failure of the request. + * + * \param contactIdentifier The identifier of the contact to call. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \return A PendingChannel which will emit PendingChannel::finished + * successfully, when the Channel is available for handling using + * PendingChannel::channel(), or with an error if one has been encountered. + * \sa ensureAndHandleChannel(), createAndHandleChannel() + */ +PendingChannel *Account::ensureAndHandleVideoCall( + const QString &contactIdentifier, + const QString &initialVideoContentName, + const QDateTime &userActionTime) +{ + QVariantMap request = videoCallRequest(contactIdentifier, initialVideoContentName); + + return ensureAndHandleChannel(request, userActionTime); +} + +/** + * Start a request to ensure that a video call channel with the given + * contact \a contact exists, creating it if necessary. + * This initially just creates a PendingChannel object, + * which can be used to track the success or failure of the request. + * + * \param contact The contact to call. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \return A PendingChannel which will emit PendingChannel::finished + * successfully, when the Channel is available for handling using + * PendingChannel::channel(), or with an error if one has been encountered. + * \sa ensureAndHandleChannel(), createAndHandleChannel() + */ +PendingChannel *Account::ensureAndHandleVideoCall( + const ContactPtr &contact, + const QString &initialVideoContentName, + const QDateTime &userActionTime) +{ + QVariantMap request = videoCallRequest(contact, initialVideoContentName); + + return ensureAndHandleChannel(request, userActionTime); +} + +/** + * Start a request to ensure that an audio/video call channel with the given + * contact \a contactIdentifier exists, creating it if necessary. + * This initially just creates a PendingChannel object, + * which can be used to track the success or failure of the request. + * + * \param contactIdentifier The identifier of the contact to call. + * \param initialAudioContentName The name of the initial audio CallContent that + * will be automatically added on the channel. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \return A PendingChannel which will emit PendingChannel::finished + * successfully, when the Channel is available for handling using + * PendingChannel::channel(), or with an error if one has been encountered. + * \sa ensureAndHandleChannel(), createAndHandleChannel() + */ +PendingChannel *Account::ensureAndHandleAudioVideoCall( + const QString &contactIdentifier, + const QString &initialAudioContentName, + const QString &initialVideoContentName, + const QDateTime &userActionTime) +{ + QVariantMap request = audioVideoCallRequest(contactIdentifier, + initialAudioContentName, initialVideoContentName); + + return ensureAndHandleChannel(request, userActionTime); +} + +/** + * Start a request to ensure that an audio/video call channel with the given + * contact \a contact exists, creating it if necessary. + * This initially just creates a PendingChannel object, + * which can be used to track the success or failure of the request. + * + * \param contact The contact to call. + * \param initialAudioContentName The name of the initial audio CallContent that + * will be automatically added on the channel. + * \param initialVideoContentName The name of the initial video CallContent that + * will be automatically added on the channel. + * \param userActionTime The time at which user action occurred, or QDateTime() + * if this channel request is for some reason not + * involving user action. + * \return A PendingChannel which will emit PendingChannel::finished + * successfully, when the Channel is available for handling using + * PendingChannel::channel(), or with an error if one has been encountered. + * \sa ensureAndHandleChannel(), createAndHandleChannel() + */ +PendingChannel *Account::ensureAndHandleAudioVideoCall( + const ContactPtr &contact, + const QString &initialAudioContentName, + const QString &initialVideoContentName, + const QDateTime &userActionTime) +{ + QVariantMap request = audioVideoCallRequest(contact, + initialAudioContentName, initialVideoContentName); + + return ensureAndHandleChannel(request, userActionTime); +} + +/** * Start a request to ensure that a media channel with the given * contact \a contactIdentifier exists, creating it if necessary. * This initially just creates a PendingChannel object, diff --git a/TelepathyQt/account.h b/TelepathyQt/account.h index 5b72181a..17ae730d 100644 --- a/TelepathyQt/account.h +++ b/TelepathyQt/account.h @@ -220,6 +220,45 @@ public: const QString &preferredHandler = QString(), const ChannelRequestHints &hints = ChannelRequestHints()); + PendingChannelRequest *ensureAudioCall( + const QString &contactIdentifier, + const QString &initialAudioContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime(), + const QString &preferredHandler = QString(), + const ChannelRequestHints &hints = ChannelRequestHints()); + PendingChannelRequest *ensureAudioCall( + const ContactPtr &contact, + const QString &initialAudioContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime(), + const QString &preferredHandler = QString(), + const ChannelRequestHints &hints = ChannelRequestHints()); + PendingChannelRequest *ensureVideoCall( + const QString &contactIdentifier, + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime(), + const QString &preferredHandler = QString(), + const ChannelRequestHints &hints = ChannelRequestHints()); + PendingChannelRequest *ensureVideoCall( + const ContactPtr &contact, + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime(), + const QString &preferredHandler = QString(), + const ChannelRequestHints &hints = ChannelRequestHints()); + PendingChannelRequest *ensureAudioVideoCall( + const QString &contactIdentifier, + const QString &initialAudioContentName = QString(), + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime(), + const QString &preferredHandler = QString(), + const ChannelRequestHints &hints = ChannelRequestHints()); + PendingChannelRequest *ensureAudioVideoCall( + const ContactPtr &contact, + const QString &initialAudioContentName = QString(), + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime(), + const QString &preferredHandler = QString(), + const ChannelRequestHints &hints = ChannelRequestHints()); + PendingChannelRequest *ensureStreamedMediaCall( const QString &contactIdentifier, const QDateTime &userActionTime = QDateTime::currentDateTime(), @@ -338,6 +377,33 @@ public: const QString &roomName, const QDateTime &userActionTime = QDateTime::currentDateTime()); + PendingChannel *ensureAndHandleAudioCall( + const QString &contactIdentifier, + const QString &initialAudioContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime()); + PendingChannel *ensureAndHandleAudioCall( + const ContactPtr &contact, + const QString &initialAudioContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime()); + PendingChannel *ensureAndHandleVideoCall( + const QString &contactIdentifier, + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime()); + PendingChannel *ensureAndHandleVideoCall( + const ContactPtr &contact, + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime()); + PendingChannel *ensureAndHandleAudioVideoCall( + const QString &contactIdentifier, + const QString &initialAudioContentName = QString(), + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime()); + PendingChannel *ensureAndHandleAudioVideoCall( + const ContactPtr &contact, + const QString &initialAudioContentName = QString(), + const QString &initialVideoContentName = QString(), + const QDateTime &userActionTime = QDateTime::currentDateTime()); + PendingChannel *ensureAndHandleStreamedMediaCall( const QString &contactIdentifier, const QDateTime &userActionTime = QDateTime::currentDateTime()); diff --git a/TelepathyQt/call-channel.h b/TelepathyQt/call-channel.h index 909900bb..66b54e18 100644 --- a/TelepathyQt/call-channel.h +++ b/TelepathyQt/call-channel.h @@ -71,7 +71,6 @@ public: static const Feature FeatureLocalHoldState; // TODO: FeatureCallMembers - // TODO: add helpers to ensure/create call channel using Account static CallChannelPtr create(const ConnectionPtr &connection, const QString &objectPath, const QVariantMap &immutableProperties); |