00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _TelepathyQt4_cli_channel_h_HEADER_GUARD_
00023 #define _TelepathyQt4_cli_channel_h_HEADER_GUARD_
00024
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028
00029 #include <TelepathyQt4/_gen/cli-channel.h>
00030
00031 #include <TelepathyQt4/Constants>
00032 #include <TelepathyQt4/Client/Contact>
00033 #include <TelepathyQt4/Client/DBus>
00034 #include <TelepathyQt4/Client/DBusProxy>
00035 #include <TelepathyQt4/Client/OptionalInterfaceFactory>
00036 #include <TelepathyQt4/Client/ReadinessHelper>
00037 #include <TelepathyQt4/Client/ReadyObject>
00038
00039 #include <QExplicitlySharedDataPointer>
00040 #include <QSet>
00041 #include <QSharedData>
00042 #include <QVariantMap>
00043
00044 namespace Telepathy
00045 {
00046 namespace Client
00047 {
00048
00049 class Connection;
00050 class PendingOperation;
00051 class PendingReady;
00052
00053 class Channel : public StatefulDBusProxy,
00054 private OptionalInterfaceFactory<Channel>,
00055 public ReadyObject,
00056 public QSharedData
00057 {
00058 Q_OBJECT
00059 Q_DISABLE_COPY(Channel)
00060
00061 public:
00062 static const Feature FeatureCore;
00063
00064 Channel(Connection *connection,
00065 const QString &objectPath,
00066 const QVariantMap &immutableProperties,
00067 QObject *parent = 0);
00068 ~Channel();
00069
00070 Connection *connection() const;
00071
00072 QString channelType() const;
00073 QStringList interfaces() const;
00074
00075 uint targetHandleType() const;
00076 uint targetHandle() const;
00077
00078 bool isRequested() const;
00079 ContactPtr initiatorContact() const;
00080
00081 PendingOperation *requestClose();
00082
00083 uint groupFlags() const;
00084
00085 bool groupCanAddContacts() const;
00086 PendingOperation *groupAddContacts(const QList<ContactPtr> &contacts,
00087 const QString &message = QString());
00088 bool groupCanRescindContacts() const;
00089 bool groupCanRemoveContacts() const;
00090 PendingOperation *groupRemoveContacts(const QList<ContactPtr> &contacts,
00091 const QString &message = QString(),
00092 uint reason = Telepathy::ChannelGroupChangeReasonNone);
00093
00094 Contacts groupContacts() const;
00095 Contacts groupLocalPendingContacts() const;
00096 Contacts groupRemotePendingContacts() const;
00097
00098 class GroupMemberChangeDetails
00099 {
00100 public:
00101 GroupMemberChangeDetails()
00102 : mIsValid(false) {}
00103
00104 bool isValid() const { return mIsValid; }
00105
00106 bool hasActor() const { return !mActor.isNull(); }
00107 ContactPtr actor() const { return mActor; }
00108
00109 bool hasReason() const { return mDetails.contains("change-reason"); }
00110 uint reason() const { return qdbus_cast<uint>(mDetails.value("change-reason")); }
00111
00112 bool hasMessage() const { return mDetails.contains("message"); }
00113 QString message () const { return qdbus_cast<QString>(mDetails.value("message")); }
00114
00115 bool hasError() const { return mDetails.contains("error"); }
00116 QString error() const { return qdbus_cast<QString>(mDetails.value("error")); }
00117
00118 bool hasDebugMessage() const { return mDetails.contains("debug-message"); }
00119 QString debugMessage() const { return qdbus_cast<QString>(mDetails.value("debug-message")); }
00120
00121 QVariantMap allDetails() const { return mDetails; }
00122
00123 private:
00124 friend class Channel;
00125
00126 GroupMemberChangeDetails(const ContactPtr &actor, const QVariantMap &details)
00127 : mActor(actor), mDetails(details), mIsValid(true) {}
00128
00129 ContactPtr mActor;
00130 QVariantMap mDetails;
00131 bool mIsValid;
00132 };
00133
00134 GroupMemberChangeDetails groupLocalPendingContactChangeInfo(const ContactPtr &contact) const;
00135 GroupMemberChangeDetails groupSelfContactRemoveInfo() const;
00136
00137 bool groupAreHandleOwnersAvailable() const;
00138 HandleOwnerMap groupHandleOwners() const;
00139
00140 bool groupIsSelfContactTracked() const;
00141 ContactPtr groupSelfContact() const;
00142
00143 Q_SIGNALS:
00144 void groupFlagsChanged(uint flags, uint added, uint removed);
00145
00146 void groupCanAddContactsChanged(bool canAddContacts);
00147 void groupCanRemoveContactsChanged(bool canRemoveContacts);
00148 void groupCanRescindContactsChanged(bool canRescindContacts);
00149
00150 void groupMembersChanged(
00151 const Telepathy::Client::Contacts &groupMembersAdded,
00152 const Telepathy::Client::Contacts &groupLocalPendingMembersAdded,
00153 const Telepathy::Client::Contacts &groupRemotePendingMembersAdded,
00154 const Telepathy::Client::Contacts &groupMembersRemoved,
00155 const Telepathy::Client::Channel::GroupMemberChangeDetails &details);
00156
00157 void groupHandleOwnersChanged(const Telepathy::HandleOwnerMap &owners,
00158 const Telepathy::UIntList &added, const Telepathy::UIntList &removed);
00159
00160 void groupSelfContactChanged();
00161
00162 protected:
00163 bool groupSelfHandleIsLocalPending() const;
00164
00165 protected Q_SLOTS:
00166 PendingOperation *groupAddSelfHandle();
00167
00168 public:
00169 template <class Interface>
00170 inline Interface *optionalInterface(
00171 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00172 {
00173
00174 QString name(Interface::staticInterfaceName());
00175 if (check == CheckInterfaceSupported && !interfaces().contains(name))
00176 return 0;
00177
00178
00179 return OptionalInterfaceFactory<Channel>::interface<Interface>();
00180 }
00181
00182 inline ChannelInterfaceCallStateInterface *callStateInterface(
00183 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00184 {
00185 return optionalInterface<ChannelInterfaceCallStateInterface>(check);
00186 }
00187
00188 inline ChannelInterfaceChatStateInterface *chatStateInterface(
00189 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00190 {
00191 return optionalInterface<ChannelInterfaceChatStateInterface>(check);
00192 }
00193
00194 inline ChannelInterfaceDTMFInterface *DTMFInterface(
00195 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00196 {
00197 return optionalInterface<ChannelInterfaceDTMFInterface>(check);
00198 }
00199
00200 inline ChannelInterfaceHoldInterface *holdInterface(
00201 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00202 {
00203 return optionalInterface<ChannelInterfaceHoldInterface>(check);
00204 }
00205
00206 inline ChannelInterfaceMediaSignallingInterface *mediaSignallingInterface(
00207 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00208 {
00209 return optionalInterface<ChannelInterfaceMediaSignallingInterface>(check);
00210 }
00211
00212 inline ChannelInterfaceMessagesInterface *messagesInterface(
00213 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00214 {
00215 return optionalInterface<ChannelInterfaceMessagesInterface>(check);
00216 }
00217
00218 inline ChannelInterfacePasswordInterface *passwordInterface(
00219 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00220 {
00221 return optionalInterface<ChannelInterfacePasswordInterface>(check);
00222 }
00223
00224 inline DBus::PropertiesInterface *propertiesInterface() const
00225 {
00226 return optionalInterface<DBus::PropertiesInterface>(BypassInterfaceCheck);
00227 }
00228
00229 template <class Interface>
00230 inline Interface *typeInterface(
00231 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00232 {
00233
00234 QString name(Interface::staticInterfaceName());
00235 if (check == CheckInterfaceSupported && channelType() != name)
00236 return 0;
00237
00238
00239 return OptionalInterfaceFactory<Channel>::interface<Interface>();
00240 }
00241
00242 inline ChannelTypeRoomListInterface *roomListInterface(
00243 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00244 {
00245 return typeInterface<ChannelTypeRoomListInterface>(check);
00246 }
00247
00248 inline ChannelTypeStreamedMediaInterface *streamedMediaInterface(
00249 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00250 {
00251 return typeInterface<ChannelTypeStreamedMediaInterface>(check);
00252 }
00253
00254 inline ChannelTypeTextInterface *textInterface(
00255 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00256 {
00257 return typeInterface<ChannelTypeTextInterface>(check);
00258 }
00259
00260 inline ChannelTypeTubesInterface *tubesInterface(
00261 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00262 {
00263 return typeInterface<ChannelTypeTubesInterface>(check);
00264 }
00265
00266 protected:
00267 ChannelInterface *baseInterface() const;
00268
00269 inline ChannelInterfaceGroupInterface *groupInterface(
00270 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00271 {
00272 return optionalInterface<ChannelInterfaceGroupInterface>(check);
00273 }
00274
00275 private Q_SLOTS:
00276 void gotMainProperties(QDBusPendingCallWatcher *watcher);
00277 void gotChannelType(QDBusPendingCallWatcher *watcher);
00278 void gotHandle(QDBusPendingCallWatcher *watcher);
00279 void gotInterfaces(QDBusPendingCallWatcher *watcher);
00280 void onClosed();
00281
00282 void onConnectionInvalidated();
00283 void onConnectionDestroyed();
00284
00285 void gotGroupProperties(QDBusPendingCallWatcher *watcher);
00286 void gotGroupFlags(QDBusPendingCallWatcher *watcher);
00287 void gotAllMembers(QDBusPendingCallWatcher *watcher);
00288 void gotLocalPendingMembersWithInfo(QDBusPendingCallWatcher *watcher);
00289 void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00290 void gotContacts(Telepathy::Client::PendingOperation *op);
00291
00292 void onGroupFlagsChanged(uint, uint);
00293 void onMembersChanged(const QString&,
00294 const Telepathy::UIntList&, const Telepathy::UIntList&,
00295 const Telepathy::UIntList&, const Telepathy::UIntList&, uint, uint);
00296 void onMembersChangedDetailed(
00297 const Telepathy::UIntList &added, const Telepathy::UIntList &removed,
00298 const Telepathy::UIntList &localPending, const Telepathy::UIntList &remotePending,
00299 const QVariantMap &details);
00300 void onHandleOwnersChanged(const Telepathy::HandleOwnerMap&, const Telepathy::UIntList&);
00301 void onSelfHandleChanged(uint);
00302
00303 void continueIntrospection();
00304
00305 private:
00306 struct Private;
00307 friend struct Private;
00308 Private *mPriv;
00309 };
00310
00311 typedef QExplicitlySharedDataPointer<Channel> ChannelPtr;
00312
00313 }
00314 }
00315
00316 Q_DECLARE_METATYPE(Telepathy::Client::Channel::GroupMemberChangeDetails);
00317
00318 #endif