Home · All Classes · All Namespaces · Modules · Functions · Files

channel.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2008 Nokia Corporation
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _TelepathyQt4_channel_h_HEADER_GUARD_
00023 #define _TelepathyQt4_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/Contact>
00033 #include <TelepathyQt4/DBus>
00034 #include <TelepathyQt4/DBusProxy>
00035 #include <TelepathyQt4/OptionalInterfaceFactory>
00036 #include <TelepathyQt4/ReadinessHelper>
00037 #include <TelepathyQt4/ReadyObject>
00038 #include <TelepathyQt4/Types>
00039 #include <TelepathyQt4/SharedPtr>
00040 
00041 #include <QSet>
00042 #include <QSharedDataPointer>
00043 #include <QVariantMap>
00044 
00045 namespace Tp
00046 {
00047 
00048 class Connection;
00049 class PendingOperation;
00050 class PendingReady;
00051 
00052 class TELEPATHY_QT4_EXPORT Channel : public StatefulDBusProxy,
00053                 public OptionalInterfaceFactory<Channel>,
00054                 public ReadyObject,
00055                 public RefCounted
00056 {
00057     Q_OBJECT
00058     Q_DISABLE_COPY(Channel)
00059 
00060 public:
00061     static const Feature FeatureCore;
00062     static const Feature FeatureConferenceInitialInviteeContacts;
00063 
00064     static ChannelPtr create(const ConnectionPtr &connection,
00065             const QString &objectPath, const QVariantMap &immutableProperties);
00066 
00067     virtual ~Channel();
00068 
00069     ConnectionPtr connection() const;
00070 
00071     QVariantMap immutableProperties() const;
00072 
00073     QString channelType() 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     bool groupCanAddContactsWithMessage() const;
00087     bool groupCanAcceptContactsWithMessage() const;
00088     PendingOperation *groupAddContacts(const QList<ContactPtr> &contacts,
00089             const QString &message = QString());
00090     bool groupCanRescindContacts() const;
00091     bool groupCanRescindContactsWithMessage() const;
00092     bool groupCanRemoveContacts() const;
00093     bool groupCanRemoveContactsWithMessage() const;
00094     bool groupCanRejectContactsWithMessage() const;
00095     bool groupCanDepartWithMessage() const;
00096     PendingOperation *groupRemoveContacts(const QList<ContactPtr> &contacts,
00097             const QString &message = QString(),
00098             uint reason = ChannelGroupChangeReasonNone);
00099 
00104     Contacts groupContacts() const;
00105     Contacts groupLocalPendingContacts() const;
00106     Contacts groupRemotePendingContacts() const;
00107 
00108     class GroupMemberChangeDetails
00109     {
00110     public:
00111         GroupMemberChangeDetails();
00112         GroupMemberChangeDetails(const GroupMemberChangeDetails &other);
00113         ~GroupMemberChangeDetails();
00114 
00115         GroupMemberChangeDetails &operator=(const GroupMemberChangeDetails &other);
00116 
00117         bool isValid() const { return mPriv.constData() != 0; }
00118 
00119         bool hasActor() const;
00120         ContactPtr actor() const;
00121 
00122         bool hasReason() const { return allDetails().contains(QLatin1String("change-reason")); }
00123         uint reason() const { return qdbus_cast<uint>(allDetails().value(QLatin1String("change-reason"))); }
00124 
00125         bool hasMessage() const { return allDetails().contains(QLatin1String("message")); }
00126         QString message () const { return qdbus_cast<QString>(allDetails().value(QLatin1String("message"))); }
00127 
00128         bool hasError() const { return allDetails().contains(QLatin1String("error")); }
00129         QString error() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("error"))); }
00130 
00131         bool hasDebugMessage() const { return allDetails().contains(QLatin1String("debug-message")); }
00132         QString debugMessage() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message"))); }
00133 
00134         QVariantMap allDetails() const;
00135 
00136     private:
00137         friend class Channel;
00138 
00139         GroupMemberChangeDetails(const ContactPtr &actor, const QVariantMap &details);
00140 
00141         struct Private;
00142         friend struct Private;
00143         QSharedDataPointer<Private> mPriv;
00144     };
00145 
00146     GroupMemberChangeDetails groupLocalPendingContactChangeInfo(const ContactPtr &contact) const;
00147     GroupMemberChangeDetails groupSelfContactRemoveInfo() const;
00148 
00149     bool groupAreHandleOwnersAvailable() const;
00150     HandleOwnerMap groupHandleOwners() const;
00151 
00152     bool groupIsSelfContactTracked() const;
00153     ContactPtr groupSelfContact() const;
00154 
00155     bool hasConferenceInterface() const;
00156     Contacts conferenceInitialInviteeContacts() const;
00157     TELEPATHY_QT4_DEPRECATED bool conferenceSupportsNonMerges() const;
00158     QList<ChannelPtr> conferenceChannels() const;
00159     QList<ChannelPtr> conferenceInitialChannels() const;
00160     QHash<uint, ChannelPtr> conferenceOriginalChannels() const;
00161 
00162     bool hasMergeableConferenceInterface() const;
00163     PendingOperation *conferenceMergeChannel(const ChannelPtr &channel);
00164 
00165     bool hasSplittableInterface() const;
00166     PendingOperation *splitChannel();
00167 
00168     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00169     {
00170         return optionalInterface<Client::DBus::PropertiesInterface>(BypassInterfaceCheck);
00171     }
00172 
00173     inline Client::ChannelInterfaceAnonymityInterface *anonymityInterface(
00174             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00175     {
00176         return optionalInterface<Client::ChannelInterfaceAnonymityInterface>(check);
00177     }
00178 
00179     inline Client::ChannelInterfaceCallStateInterface *callStateInterface(
00180             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00181     {
00182         return optionalInterface<Client::ChannelInterfaceCallStateInterface>(check);
00183     }
00184 
00185     inline Client::ChannelInterfaceChatStateInterface *chatStateInterface(
00186             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00187     {
00188         return optionalInterface<Client::ChannelInterfaceChatStateInterface>(check);
00189     }
00190 
00191     inline Client::ChannelInterfaceConferenceInterface *conferenceInterface(
00192             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00193     {
00194         return optionalInterface<Client::ChannelInterfaceConferenceInterface>(check);
00195     }
00196 
00197     inline Client::ChannelInterfaceDTMFInterface *DTMFInterface(
00198             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00199     {
00200         return optionalInterface<Client::ChannelInterfaceDTMFInterface>(check);
00201     }
00202 
00203     inline Client::ChannelInterfaceHoldInterface *holdInterface(
00204             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00205     {
00206         return optionalInterface<Client::ChannelInterfaceHoldInterface>(check);
00207     }
00208 
00209     inline Client::ChannelInterfaceMediaSignallingInterface *mediaSignallingInterface(
00210             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00211     {
00212         return optionalInterface<Client::ChannelInterfaceMediaSignallingInterface>(check);
00213     }
00214 
00215     inline Client::ChannelInterfaceMessagesInterface *messagesInterface(
00216             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00217     {
00218         return optionalInterface<Client::ChannelInterfaceMessagesInterface>(check);
00219     }
00220 
00221     inline Client::ChannelInterfacePasswordInterface *passwordInterface(
00222             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00223     {
00224         return optionalInterface<Client::ChannelInterfacePasswordInterface>(check);
00225     }
00226 
00227     inline Client::ChannelInterfaceServicePointInterface *servicePointInterface(
00228             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00229     {
00230         return optionalInterface<Client::ChannelInterfaceServicePointInterface>(check);
00231     }
00232 
00233     inline Client::ChannelInterfaceTubeInterface *tubeInterface(
00234             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00235     {
00236         return optionalInterface<Client::ChannelInterfaceTubeInterface>(check);
00237     }
00238 
00239     template <class Interface>
00240     inline Interface *typeInterface(
00241             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00242     {
00243         // Check for the remote object having the correct channel type
00244         QString name(QLatin1String(Interface::staticInterfaceName()));
00245         if (check == CheckInterfaceSupported && channelType() != name)
00246             return 0;
00247 
00248         // If correct type or check bypassed, delegate to OIF
00249         return OptionalInterfaceFactory<Channel>::interface<Interface>();
00250     }
00251 
00252     inline Client::ChannelTypeContactSearchInterface *contactSearchInterface(
00253             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00254     {
00255         return typeInterface<Client::ChannelTypeContactSearchInterface>(check);
00256     }
00257 
00258     inline Client::ChannelTypeRoomListInterface *roomListInterface(
00259             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00260     {
00261         return typeInterface<Client::ChannelTypeRoomListInterface>(check);
00262     }
00263 
00264     inline Client::ChannelTypeServerTLSConnectionInterface *serverTLSConnectionInterface(
00265             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00266     {
00267         return typeInterface<Client::ChannelTypeServerTLSConnectionInterface>(check);
00268     }
00269 
00270     inline Client::ChannelTypeStreamedMediaInterface *streamedMediaInterface(
00271             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00272     {
00273         return typeInterface<Client::ChannelTypeStreamedMediaInterface>(check);
00274     }
00275 
00276     inline Client::ChannelTypeTextInterface *textInterface(
00277             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00278     {
00279         return typeInterface<Client::ChannelTypeTextInterface>(check);
00280     }
00281 
00282     inline Client::ChannelTypeFileTransferInterface *fileTransferInterface(
00283             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00284     {
00285         return typeInterface<Client::ChannelTypeFileTransferInterface>(check);
00286     }
00287 
00288     inline Client::ChannelTypeTubesInterface *tubesInterface(
00289             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00290     {
00291         return typeInterface<Client::ChannelTypeTubesInterface>(check);
00292     }
00293 
00294     inline Client::ChannelTypeStreamTubeInterface *streamTubeInterface(
00295             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00296     {
00297         return typeInterface<Client::ChannelTypeStreamTubeInterface>(check);
00298     }
00299 
00300 Q_SIGNALS:
00301     void groupFlagsChanged(uint flags, uint added, uint removed);
00302 
00303     void groupCanAddContactsChanged(bool canAddContacts);
00304     void groupCanRemoveContactsChanged(bool canRemoveContacts);
00305     void groupCanRescindContactsChanged(bool canRescindContacts);
00306 
00307     void groupMembersChanged(
00308             const Tp::Contacts &groupMembersAdded,
00309             const Tp::Contacts &groupLocalPendingMembersAdded,
00310             const Tp::Contacts &groupRemotePendingMembersAdded,
00311             const Tp::Contacts &groupMembersRemoved,
00312             const Tp::Channel::GroupMemberChangeDetails &details);
00313 
00314     void groupHandleOwnersChanged(const Tp::HandleOwnerMap &owners,
00315             const Tp::UIntList &added, const Tp::UIntList &removed);
00316 
00317     void groupSelfContactChanged();
00318 
00319     void conferenceChannelMerged(const Tp::ChannelPtr &channel);
00320     // FIXME: (API/ABI break) Remove conferenceChannelRemoved that does not take details as param.
00321     void conferenceChannelRemoved(const Tp::ChannelPtr &channel);
00322     void conferenceChannelRemoved(const Tp::ChannelPtr &channel,
00323             const Tp::Channel::GroupMemberChangeDetails &details);
00324 
00325 protected:
00326     Channel(const ConnectionPtr &connection,const QString &objectPath,
00327             const QVariantMap &immutableProperties);
00328 
00329     Client::ChannelInterface *baseInterface() const;
00330 
00331     inline Client::ChannelInterfaceGroupInterface *groupInterface(
00332             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00333     {
00334         return optionalInterface<Client::ChannelInterfaceGroupInterface>(check);
00335     }
00336 
00337     bool groupSelfHandleIsLocalPending() const;
00338 
00339     // FIXME: (API/ABI break) Remove connectNotify
00340     void connectNotify(const char *);
00341 
00342 protected Q_SLOTS:
00343     PendingOperation *groupAddSelfHandle();
00344 
00345 private Q_SLOTS:
00346     void gotMainProperties(QDBusPendingCallWatcher *watcher);
00347     void gotChannelType(QDBusPendingCallWatcher *watcher);
00348     void gotHandle(QDBusPendingCallWatcher *watcher);
00349     void gotInterfaces(QDBusPendingCallWatcher *watcher);
00350     void onClosed();
00351 
00352     void onConnectionReady(Tp::PendingOperation *op);
00353     void onConnectionInvalidated();
00354     void onConnectionDestroyed();
00355 
00356     void gotGroupProperties(QDBusPendingCallWatcher *watcher);
00357     void gotGroupFlags(QDBusPendingCallWatcher *watcher);
00358     void gotAllMembers(QDBusPendingCallWatcher *watcher);
00359     void gotLocalPendingMembersWithInfo(QDBusPendingCallWatcher *watcher);
00360     void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00361     void gotContacts(Tp::PendingOperation *op);
00362 
00363     void onGroupFlagsChanged(uint, uint);
00364     void onMembersChanged(const QString&,
00365             const Tp::UIntList&, const Tp::UIntList&,
00366             const Tp::UIntList&, const Tp::UIntList&, uint, uint);
00367     void onMembersChangedDetailed(
00368         const Tp::UIntList &added, const Tp::UIntList &removed,
00369         const Tp::UIntList &localPending, const Tp::UIntList &remotePending,
00370         const QVariantMap &details);
00371     void onHandleOwnersChanged(const Tp::HandleOwnerMap&, const Tp::UIntList&);
00372     void onSelfHandleChanged(uint);
00373 
00374     void gotConferenceProperties(QDBusPendingCallWatcher *watcher);
00375     void gotConferenceInitialInviteeContacts(Tp::PendingOperation *op);
00376     void onConferenceChannelMerged(const QDBusObjectPath &channel, uint channelSpecificHandle,
00377             const QVariantMap &properties);
00378     void onConferenceChannelMerged(const QDBusObjectPath &channel);
00379     void onConferenceChannelRemoved(const QDBusObjectPath &channel, const QVariantMap &details);
00380     void onConferenceChannelRemoved(const QDBusObjectPath &channel);
00381     void gotConferenceChannelRemovedActorContact(Tp::PendingOperation *op);
00382 
00383 private:
00384     struct Private;
00385     friend struct Private;
00386     Private *mPriv;
00387 };
00388 
00389 } // Tp
00390 
00391 Q_DECLARE_METATYPE(Tp::Channel::GroupMemberChangeDetails);
00392 
00393 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.3.13