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


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