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 
00079     ChannelGroupFlags groupFlags() const;
00080 
00081     bool groupCanAddContacts() const;
00082     bool groupCanAddContactsWithMessage() const;
00083     bool groupCanAcceptContactsWithMessage() const;
00084     PendingOperation *groupAddContacts(const QList<ContactPtr> &contacts,
00085             const QString &message = QString());
00086     bool groupCanRescindContacts() const;
00087     bool groupCanRescindContactsWithMessage() const;
00088     bool groupCanRemoveContacts() const;
00089     bool groupCanRemoveContactsWithMessage() const;
00090     bool groupCanRejectContactsWithMessage() const;
00091     bool groupCanDepartWithMessage() const;
00092     PendingOperation *groupRemoveContacts(const QList<ContactPtr> &contacts,
00093             const QString &message = QString(),
00094             ChannelGroupChangeReason reason = ChannelGroupChangeReasonNone);
00095 
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         ChannelGroupChangeReason reason() const { return (ChannelGroupChangeReason) 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 isConference() const;
00152     Contacts conferenceInitialInviteeContacts() const;
00153     QList<ChannelPtr> conferenceChannels() const;
00154     QList<ChannelPtr> conferenceInitialChannels() const;
00155     QHash<uint, ChannelPtr> conferenceOriginalChannels() const;
00156 
00157     bool supportsConferenceMerging() const;
00158     PendingOperation *conferenceMergeChannel(const ChannelPtr &channel);
00159 
00160     bool supportsConferenceSplitting() const;
00161     PendingOperation *conferenceSplitChannel();
00162 
00163 Q_SIGNALS:
00164     void groupFlagsChanged(Tp::ChannelGroupFlags flags,
00165             Tp::ChannelGroupFlags added, Tp::ChannelGroupFlags removed);
00166 
00167     void groupCanAddContactsChanged(bool canAddContacts);
00168     void groupCanRemoveContactsChanged(bool canRemoveContacts);
00169     void groupCanRescindContactsChanged(bool canRescindContacts);
00170 
00171     void groupMembersChanged(
00172             const Tp::Contacts &groupMembersAdded,
00173             const Tp::Contacts &groupLocalPendingMembersAdded,
00174             const Tp::Contacts &groupRemotePendingMembersAdded,
00175             const Tp::Contacts &groupMembersRemoved,
00176             const Tp::Channel::GroupMemberChangeDetails &details);
00177 
00178     void groupHandleOwnersChanged(const Tp::HandleOwnerMap &owners,
00179             const Tp::UIntList &added, const Tp::UIntList &removed);
00180 
00181     void groupSelfContactChanged();
00182 
00183     void conferenceChannelMerged(const Tp::ChannelPtr &channel);
00184     void conferenceChannelRemoved(const Tp::ChannelPtr &channel,
00185             const Tp::Channel::GroupMemberChangeDetails &details);
00186 
00187 protected:
00188     Channel(const ConnectionPtr &connection,const QString &objectPath,
00189             const QVariantMap &immutableProperties, const Feature &coreFeature);
00190 
00191     Client::ChannelInterface *baseInterface() const;
00192 
00193     bool groupSelfHandleIsLocalPending() const;
00194 
00195 protected Q_SLOTS:
00196     PendingOperation *groupAddSelfHandle();
00197 
00198 private Q_SLOTS:
00199     void gotMainProperties(QDBusPendingCallWatcher *watcher);
00200     void gotChannelType(QDBusPendingCallWatcher *watcher);
00201     void gotHandle(QDBusPendingCallWatcher *watcher);
00202     void gotInterfaces(QDBusPendingCallWatcher *watcher);
00203     void onClosed();
00204 
00205     void onConnectionReady(Tp::PendingOperation *op);
00206     void onConnectionInvalidated();
00207     void onConnectionDestroyed();
00208 
00209     void gotGroupProperties(QDBusPendingCallWatcher *watcher);
00210     void gotGroupFlags(QDBusPendingCallWatcher *watcher);
00211     void gotAllMembers(QDBusPendingCallWatcher *watcher);
00212     void gotLocalPendingMembersWithInfo(QDBusPendingCallWatcher *watcher);
00213     void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00214     void gotContacts(Tp::PendingOperation *op);
00215 
00216     void onGroupFlagsChanged(uint added, uint removed);
00217     void onMembersChanged(const QString &message,
00218             const Tp::UIntList &added, const Tp::UIntList &removed,
00219             const Tp::UIntList &localPending, const Tp::UIntList &remotePending,
00220             uint actor, uint reason);
00221     void onMembersChangedDetailed(
00222             const Tp::UIntList &added, const Tp::UIntList &removed,
00223             const Tp::UIntList &localPending, const Tp::UIntList &remotePending,
00224             const QVariantMap &details);
00225     void onHandleOwnersChanged(const Tp::HandleOwnerMap &added, const Tp::UIntList &removed);
00226     void onSelfHandleChanged(uint selfHandle);
00227 
00228     void gotConferenceProperties(QDBusPendingCallWatcher *watcher);
00229     void gotConferenceInitialInviteeContacts(Tp::PendingOperation *op);
00230     void onConferenceChannelMerged(const QDBusObjectPath &channel, uint channelSpecificHandle,
00231             const QVariantMap &properties);
00232     void onConferenceChannelMerged(const QDBusObjectPath &channel);
00233     void onConferenceChannelRemoved(const QDBusObjectPath &channel, const QVariantMap &details);
00234     void onConferenceChannelRemoved(const QDBusObjectPath &channel);
00235     void gotConferenceChannelRemovedActorContact(Tp::PendingOperation *op);
00236 
00237 private:
00238     struct Private;
00239     friend struct Private;
00240     Private *mPriv;
00241 };
00242 
00243 } // Tp
00244 
00245 Q_DECLARE_METATYPE(Tp::Channel::GroupMemberChangeDetails);
00246 
00247 #endif


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