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