00001
00023 #ifndef _TelepathyQt_channel_h_HEADER_GUARD_
00024 #define _TelepathyQt_channel_h_HEADER_GUARD_
00025
00026 #ifndef IN_TP_QT_HEADER
00027 #error IN_TP_QT_HEADER
00028 #endif
00029
00030 #include <TelepathyQt/_gen/cli-channel.h>
00031
00032 #include <TelepathyQt/Constants>
00033 #include <TelepathyQt/DBus>
00034 #include <TelepathyQt/DBusProxy>
00035 #include <TelepathyQt/OptionalInterfaceFactory>
00036 #include <TelepathyQt/ReadinessHelper>
00037 #include <TelepathyQt/SharedPtr>
00038 #include <TelepathyQt/Types>
00039
00040 #include <QSet>
00041 #include <QSharedDataPointer>
00042 #include <QVariantMap>
00043
00044 namespace Tp
00045 {
00046
00047 class Connection;
00048 class PendingOperation;
00049 class PendingReady;
00050
00051 class TP_QT_EXPORT Channel : public StatefulDBusProxy,
00052 public OptionalInterfaceFactory<Channel>
00053 {
00054 Q_OBJECT
00055 Q_DISABLE_COPY(Channel)
00056
00057 public:
00058 static const Feature FeatureCore;
00059 static const Feature FeatureConferenceInitialInviteeContacts;
00060
00061 static ChannelPtr create(const ConnectionPtr &connection,
00062 const QString &objectPath, const QVariantMap &immutableProperties);
00063
00064 virtual ~Channel();
00065
00066 ConnectionPtr connection() const;
00067
00068 QVariantMap immutableProperties() const;
00069
00070 QString channelType() const;
00071
00072 HandleType targetHandleType() const;
00073 uint targetHandle() const;
00074 QString targetId() const;
00075 ContactPtr targetContact() const;
00076
00077 bool isRequested() const;
00078 ContactPtr initiatorContact() const;
00079
00080 PendingOperation *requestClose();
00081 PendingOperation *requestLeave(const QString &message = QString(),
00082 ChannelGroupChangeReason reason = ChannelGroupChangeReasonNone);
00083
00084 ChannelGroupFlags groupFlags() const;
00085
00086 bool groupCanAddContacts() const;
00087 bool groupCanAddContactsWithMessage() const;
00088 bool groupCanAcceptContactsWithMessage() const;
00089 PendingOperation *groupAddContacts(const QList<ContactPtr> &contacts,
00090 const QString &message = QString());
00091 bool groupCanRescindContacts() const;
00092 bool groupCanRescindContactsWithMessage() const;
00093 bool groupCanRemoveContacts() const;
00094 bool groupCanRemoveContactsWithMessage() const;
00095 bool groupCanRejectContactsWithMessage() const;
00096 bool groupCanDepartWithMessage() const;
00097 PendingOperation *groupRemoveContacts(const QList<ContactPtr> &contacts,
00098 const QString &message = QString(),
00099 ChannelGroupChangeReason reason = ChannelGroupChangeReasonNone);
00100
00101 Contacts groupContacts(bool includeSelfContact = true) const;
00102 Contacts groupLocalPendingContacts(bool includeSelfContact = true) const;
00103 Contacts groupRemotePendingContacts(bool includeSelfContact = true) const;
00104
00105 class GroupMemberChangeDetails
00106 {
00107 public:
00108 GroupMemberChangeDetails();
00109 GroupMemberChangeDetails(const GroupMemberChangeDetails &other);
00110 ~GroupMemberChangeDetails();
00111
00112 GroupMemberChangeDetails &operator=(const GroupMemberChangeDetails &other);
00113
00114 bool isValid() const { return mPriv.constData() != 0; }
00115
00116 bool hasActor() const;
00117 ContactPtr actor() const;
00118
00119 bool hasReason() const { return allDetails().contains(QLatin1String("change-reason")); }
00120 ChannelGroupChangeReason reason() const { return (ChannelGroupChangeReason) qdbus_cast<uint>(allDetails().value(QLatin1String("change-reason"))); }
00121
00122 bool hasMessage() const { return allDetails().contains(QLatin1String("message")); }
00123 QString message () const { return qdbus_cast<QString>(allDetails().value(QLatin1String("message"))); }
00124
00125 bool hasError() const { return allDetails().contains(QLatin1String("error")); }
00126 QString error() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("error"))); }
00127
00128 bool hasDebugMessage() const { return allDetails().contains(QLatin1String("debug-message")); }
00129 QString debugMessage() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message"))); }
00130
00131 QVariantMap allDetails() const;
00132
00133 private:
00134 friend class Channel;
00135 friend class Contact;
00136 friend class ContactManager;
00137
00138 TP_QT_NO_EXPORT GroupMemberChangeDetails(const ContactPtr &actor, const QVariantMap &details);
00139
00140 struct Private;
00141 friend struct Private;
00142 QSharedDataPointer<Private> mPriv;
00143 };
00144
00145 GroupMemberChangeDetails groupLocalPendingContactChangeInfo(const ContactPtr &contact) const;
00146 GroupMemberChangeDetails groupSelfContactRemoveInfo() const;
00147
00148 bool groupAreHandleOwnersAvailable() const;
00149 HandleOwnerMap groupHandleOwners() const;
00150
00151 bool groupIsSelfContactTracked() const;
00152 ContactPtr groupSelfContact() const;
00153
00154 bool isConference() const;
00155 Contacts conferenceInitialInviteeContacts() const;
00156 QList<ChannelPtr> conferenceChannels() const;
00157 QList<ChannelPtr> conferenceInitialChannels() const;
00158 QHash<uint, ChannelPtr> conferenceOriginalChannels() const;
00159
00160 bool supportsConferenceMerging() const;
00161 PendingOperation *conferenceMergeChannel(const ChannelPtr &channel);
00162
00163 bool supportsConferenceSplitting() const;
00164 PendingOperation *conferenceSplitChannel();
00165
00166 Q_SIGNALS:
00167 void groupFlagsChanged(Tp::ChannelGroupFlags flags,
00168 Tp::ChannelGroupFlags added, Tp::ChannelGroupFlags removed);
00169
00170 void groupCanAddContactsChanged(bool canAddContacts);
00171 void groupCanRemoveContactsChanged(bool canRemoveContacts);
00172 void groupCanRescindContactsChanged(bool canRescindContacts);
00173
00174 void groupMembersChanged(
00175 const Tp::Contacts &groupMembersAdded,
00176 const Tp::Contacts &groupLocalPendingMembersAdded,
00177 const Tp::Contacts &groupRemotePendingMembersAdded,
00178 const Tp::Contacts &groupMembersRemoved,
00179 const Tp::Channel::GroupMemberChangeDetails &details);
00180
00181 void groupHandleOwnersChanged(const Tp::HandleOwnerMap &owners,
00182 const Tp::UIntList &added, const Tp::UIntList &removed);
00183
00184 void groupSelfContactChanged();
00185
00186 void conferenceChannelMerged(const Tp::ChannelPtr &channel);
00187 void conferenceChannelRemoved(const Tp::ChannelPtr &channel,
00188 const Tp::Channel::GroupMemberChangeDetails &details);
00189
00190 protected:
00191 Channel(const ConnectionPtr &connection,const QString &objectPath,
00192 const QVariantMap &immutableProperties, const Feature &coreFeature);
00193
00194 Client::ChannelInterface *baseInterface() const;
00195
00196 bool groupSelfHandleIsLocalPending() const;
00197
00198 protected Q_SLOTS:
00199 PendingOperation *groupAddSelfHandle();
00200
00201 private Q_SLOTS:
00202 TP_QT_NO_EXPORT void gotMainProperties(QDBusPendingCallWatcher *watcher);
00203 TP_QT_NO_EXPORT void gotChannelType(QDBusPendingCallWatcher *watcher);
00204 TP_QT_NO_EXPORT void gotHandle(QDBusPendingCallWatcher *watcher);
00205 TP_QT_NO_EXPORT void gotInterfaces(QDBusPendingCallWatcher *watcher);
00206 TP_QT_NO_EXPORT void onClosed();
00207
00208 TP_QT_NO_EXPORT void onConnectionReady(Tp::PendingOperation *op);
00209 TP_QT_NO_EXPORT void onConnectionInvalidated();
00210
00211 TP_QT_NO_EXPORT void gotGroupProperties(QDBusPendingCallWatcher *watcher);
00212 TP_QT_NO_EXPORT void gotGroupFlags(QDBusPendingCallWatcher *watcher);
00213 TP_QT_NO_EXPORT void gotAllMembers(QDBusPendingCallWatcher *watcher);
00214 TP_QT_NO_EXPORT void gotLocalPendingMembersWithInfo(QDBusPendingCallWatcher *watcher);
00215 TP_QT_NO_EXPORT void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00216 TP_QT_NO_EXPORT void gotContacts(Tp::PendingOperation *op);
00217
00218 TP_QT_NO_EXPORT void onGroupFlagsChanged(uint added, uint removed);
00219 TP_QT_NO_EXPORT void onMembersChanged(const QString &message,
00220 const Tp::UIntList &added, const Tp::UIntList &removed,
00221 const Tp::UIntList &localPending, const Tp::UIntList &remotePending,
00222 uint actor, uint reason);
00223 TP_QT_NO_EXPORT void onMembersChangedDetailed(
00224 const Tp::UIntList &added, const Tp::UIntList &removed,
00225 const Tp::UIntList &localPending, const Tp::UIntList &remotePending,
00226 const QVariantMap &details);
00227 TP_QT_NO_EXPORT void onHandleOwnersChanged(const Tp::HandleOwnerMap &added, const Tp::UIntList &removed);
00228 TP_QT_NO_EXPORT void onSelfHandleChanged(uint selfHandle);
00229
00230 TP_QT_NO_EXPORT void gotConferenceProperties(QDBusPendingCallWatcher *watcher);
00231 TP_QT_NO_EXPORT void gotConferenceInitialInviteeContacts(Tp::PendingOperation *op);
00232 TP_QT_NO_EXPORT void onConferenceChannelMerged(const QDBusObjectPath &channel, uint channelSpecificHandle,
00233 const QVariantMap &properties);
00234 TP_QT_NO_EXPORT void onConferenceChannelMerged(const QDBusObjectPath &channel);
00235 TP_QT_NO_EXPORT void onConferenceChannelRemoved(const QDBusObjectPath &channel, const QVariantMap &details);
00236 TP_QT_NO_EXPORT void onConferenceChannelRemoved(const QDBusObjectPath &channel);
00237 TP_QT_NO_EXPORT void gotConferenceChannelRemovedActorContact(Tp::PendingOperation *op);
00238
00239 private:
00240 class PendingLeave;
00241 friend class PendingLeave;
00242
00243 struct Private;
00244 friend struct Private;
00245 Private *mPriv;
00246 };
00247
00248 }
00249
00250 Q_DECLARE_METATYPE(Tp::Channel::GroupMemberChangeDetails);
00251
00252 #endif