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 
00100     Contacts groupContacts() const;
00101     Contacts groupLocalPendingContacts() const;
00102     Contacts groupRemotePendingContacts() const;
00103 
00104     class GroupMemberChangeDetails
00105     {
00106     public:
00107         GroupMemberChangeDetails();
00108         GroupMemberChangeDetails(const GroupMemberChangeDetails &other);
00109         ~GroupMemberChangeDetails();
00110 
00111         GroupMemberChangeDetails &operator=(const GroupMemberChangeDetails &other);
00112 
00113         bool isValid() const { return mPriv.constData() != 0; }
00114 
00115         bool hasActor() const;
00116         ContactPtr actor() const;
00117 
00118         bool hasReason() const { return allDetails().contains(QLatin1String("change-reason")); }
00119         uint reason() const { return qdbus_cast<uint>(allDetails().value(QLatin1String("change-reason"))); }
00120 
00121         bool hasMessage() const { return allDetails().contains(QLatin1String("message")); }
00122         QString message () const { return qdbus_cast<QString>(allDetails().value(QLatin1String("message"))); }
00123 
00124         bool hasError() const { return allDetails().contains(QLatin1String("error")); }
00125         QString error() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("error"))); }
00126 
00127         bool hasDebugMessage() const { return allDetails().contains(QLatin1String("debug-message")); }
00128         QString debugMessage() const { return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message"))); }
00129 
00130         QVariantMap allDetails() const;
00131 
00132     private:
00133         friend class Channel;
00134 
00135         GroupMemberChangeDetails(const ContactPtr &actor, const QVariantMap &details);
00136 
00137         struct Private;
00138         friend struct Private;
00139         QSharedDataPointer<Private> mPriv;
00140     };
00141 
00142     GroupMemberChangeDetails groupLocalPendingContactChangeInfo(const ContactPtr &contact) const;
00143     GroupMemberChangeDetails groupSelfContactRemoveInfo() const;
00144 
00145     bool groupAreHandleOwnersAvailable() const;
00146     HandleOwnerMap groupHandleOwners() const;
00147 
00148     bool groupIsSelfContactTracked() const;
00149     ContactPtr groupSelfContact() const;
00150 
00151     bool hasConferenceInterface() const;
00152     Contacts conferenceInitialInviteeContacts() const;
00153     bool conferenceSupportsNonMerges() const;
00154     QList<ChannelPtr> conferenceChannels() const;
00155     QList<ChannelPtr> conferenceInitialChannels() const;
00156 
00157     bool hasMergeableConferenceInterface() const;
00158     PendingOperation *conferenceMergeChannel(const ChannelPtr &channel);
00159 
00160     bool hasSplittableInterface() const;
00161     PendingOperation *splitChannel();
00162 
00163     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00164     {
00165         return optionalInterface<Client::DBus::PropertiesInterface>(BypassInterfaceCheck);
00166     }
00167 
00168     inline Client::ChannelInterfaceAnonymityInterface *anonymityInterface(
00169             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00170     {
00171         return optionalInterface<Client::ChannelInterfaceAnonymityInterface>(check);
00172     }
00173 
00174     inline Client::ChannelInterfaceCallStateInterface *callStateInterface(
00175             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00176     {
00177         return optionalInterface<Client::ChannelInterfaceCallStateInterface>(check);
00178     }
00179 
00180     inline Client::ChannelInterfaceChatStateInterface *chatStateInterface(
00181             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00182     {
00183         return optionalInterface<Client::ChannelInterfaceChatStateInterface>(check);
00184     }
00185 
00186     inline Client::ChannelInterfaceDTMFInterface *DTMFInterface(
00187             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00188     {
00189         return optionalInterface<Client::ChannelInterfaceDTMFInterface>(check);
00190     }
00191 
00192     inline Client::ChannelInterfaceHoldInterface *holdInterface(
00193             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00194     {
00195         return optionalInterface<Client::ChannelInterfaceHoldInterface>(check);
00196     }
00197 
00198     inline Client::ChannelInterfaceMediaSignallingInterface *mediaSignallingInterface(
00199             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00200     {
00201         return optionalInterface<Client::ChannelInterfaceMediaSignallingInterface>(check);
00202     }
00203 
00204     inline Client::ChannelInterfaceMessagesInterface *messagesInterface(
00205             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00206     {
00207         return optionalInterface<Client::ChannelInterfaceMessagesInterface>(check);
00208     }
00209 
00210     inline Client::ChannelInterfacePasswordInterface *passwordInterface(
00211             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00212     {
00213         return optionalInterface<Client::ChannelInterfacePasswordInterface>(check);
00214     }
00215 
00216     inline Client::ChannelInterfaceServicePointInterface *servicePointInterface(
00217             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00218     {
00219         return optionalInterface<Client::ChannelInterfaceServicePointInterface>(check);
00220     }
00221 
00222     inline Client::ChannelInterfaceTubeInterface *tubeInterface(
00223             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00224     {
00225         return optionalInterface<Client::ChannelInterfaceTubeInterface>(check);
00226     }
00227 
00228     template <class Interface>
00229     inline Interface *typeInterface(
00230             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00231     {
00232         // Check for the remote object having the correct channel type
00233         QString name(QLatin1String(Interface::staticInterfaceName()));
00234         if (check == CheckInterfaceSupported && channelType() != name)
00235             return 0;
00236 
00237         // If correct type or check bypassed, delegate to OIF
00238         return OptionalInterfaceFactory<Channel>::interface<Interface>();
00239     }
00240 
00241     inline Client::ChannelTypeRoomListInterface *roomListInterface(
00242             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00243     {
00244         return typeInterface<Client::ChannelTypeRoomListInterface>(check);
00245     }
00246 
00247     inline Client::ChannelTypeStreamedMediaInterface *streamedMediaInterface(
00248             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00249     {
00250         return typeInterface<Client::ChannelTypeStreamedMediaInterface>(check);
00251     }
00252 
00253     inline Client::ChannelTypeTextInterface *textInterface(
00254             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00255     {
00256         return typeInterface<Client::ChannelTypeTextInterface>(check);
00257     }
00258 
00259     inline Client::ChannelTypeFileTransferInterface *fileTransferInterface(
00260             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00261     {
00262         return typeInterface<Client::ChannelTypeFileTransferInterface>(check);
00263     }
00264 
00265     inline Client::ChannelTypeTubesInterface *tubesInterface(
00266             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00267     {
00268         return typeInterface<Client::ChannelTypeTubesInterface>(check);
00269     }
00270 
00271     inline Client::ChannelTypeStreamTubeInterface *streamTubeInterface(
00272             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00273     {
00274         return typeInterface<Client::ChannelTypeStreamTubeInterface>(check);
00275     }
00276 
00277 Q_SIGNALS:
00278     void groupFlagsChanged(uint flags, uint added, uint removed);
00279 
00280     void groupCanAddContactsChanged(bool canAddContacts);
00281     void groupCanRemoveContactsChanged(bool canRemoveContacts);
00282     void groupCanRescindContactsChanged(bool canRescindContacts);
00283 
00284     void groupMembersChanged(
00285             const Tp::Contacts &groupMembersAdded,
00286             const Tp::Contacts &groupLocalPendingMembersAdded,
00287             const Tp::Contacts &groupRemotePendingMembersAdded,
00288             const Tp::Contacts &groupMembersRemoved,
00289             const Tp::Channel::GroupMemberChangeDetails &details);
00290 
00291     void groupHandleOwnersChanged(const Tp::HandleOwnerMap &owners,
00292             const Tp::UIntList &added, const Tp::UIntList &removed);
00293 
00294     void groupSelfContactChanged();
00295 
00296     void conferenceChannelMerged(const Tp::ChannelPtr &channel);
00297     void conferenceChannelRemoved(const Tp::ChannelPtr &channel);
00298 
00299 protected:
00300     Channel(const ConnectionPtr &connection,const QString &objectPath,
00301             const QVariantMap &immutableProperties);
00302 
00303     Client::ChannelInterface *baseInterface() const;
00304 
00305     inline Client::ChannelInterfaceGroupInterface *groupInterface(
00306             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00307     {
00308         return optionalInterface<Client::ChannelInterfaceGroupInterface>(check);
00309     }
00310 
00311     bool groupSelfHandleIsLocalPending() const;
00312 
00313 protected Q_SLOTS:
00314     PendingOperation *groupAddSelfHandle();
00315 
00316 private Q_SLOTS:
00317     void gotMainProperties(QDBusPendingCallWatcher *watcher);
00318     void gotChannelType(QDBusPendingCallWatcher *watcher);
00319     void gotHandle(QDBusPendingCallWatcher *watcher);
00320     void gotInterfaces(QDBusPendingCallWatcher *watcher);
00321     void onClosed();
00322 
00323     void onConnectionReady(Tp::PendingOperation *op);
00324     void onConnectionInvalidated();
00325     void onConnectionDestroyed();
00326 
00327     void gotGroupProperties(QDBusPendingCallWatcher *watcher);
00328     void gotGroupFlags(QDBusPendingCallWatcher *watcher);
00329     void gotAllMembers(QDBusPendingCallWatcher *watcher);
00330     void gotLocalPendingMembersWithInfo(QDBusPendingCallWatcher *watcher);
00331     void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00332     void gotContacts(Tp::PendingOperation *op);
00333 
00334     void onGroupFlagsChanged(uint, uint);
00335     void onMembersChanged(const QString&,
00336             const Tp::UIntList&, const Tp::UIntList&,
00337             const Tp::UIntList&, const Tp::UIntList&, uint, uint);
00338     void onMembersChangedDetailed(
00339         const Tp::UIntList &added, const Tp::UIntList &removed,
00340         const Tp::UIntList &localPending, const Tp::UIntList &remotePending,
00341         const QVariantMap &details);
00342     void onHandleOwnersChanged(const Tp::HandleOwnerMap&, const Tp::UIntList&);
00343     void onSelfHandleChanged(uint);
00344 
00345     void gotConferenceProperties(QDBusPendingCallWatcher *watcher);
00346     void gotConferenceInitialInviteeContacts(Tp::PendingOperation *op);
00347     void onConferenceChannelMerged(const QDBusObjectPath &channel);
00348     void onConferenceChannelRemoved(const QDBusObjectPath &channel);
00349 
00350 private:
00351     struct Private;
00352     friend struct Private;
00353     Private *mPriv;
00354 };
00355 
00356 } // Tp
00357 
00358 Q_DECLARE_METATYPE(Tp::Channel::GroupMemberChangeDetails);
00359 
00360 #endif


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