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

# contact-manager.h

    00001 /*
    00002  * This file is part of TelepathyQt4
    00003  *
    00004  * Copyright (C) 2008-2010 Collabora Ltd. <http://www.collabora.co.uk/>
    00005  * Copyright (C) 2008-2010 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_contact_manager_h_HEADER_GUARD_
    00023 #define _TelepathyQt4_contact_manager_h_HEADER_GUARD_
    00024
    00025 #ifndef IN_TELEPATHY_QT4_HEADER
    00026 #error IN_TELEPATHY_QT4_HEADER
    00027 #endif
    00028
    00029 #include <QObject>
    00030
    00031 #include <QList>
    00032 #include <QSet>
    00033
    00034 #include <TelepathyQt4/Types>
    00035 #include <TelepathyQt4/Contact>
    00036 #include <TelepathyQt4/Channel>
    00037 #include <TelepathyQt4/ReferencedHandles>
    00038
    00039 namespace Tp
    00040 {
    00041
    00042 class Connection;
    00043 class PendingContacts;
    00044 class PendingOperation;
    00045
    00046 class TELEPATHY_QT4_EXPORT ContactManager : public QObject
    00047 {
    00048     Q_OBJECT
    00049     Q_DISABLE_COPY(ContactManager)
    00050
    00051 public:
    00052     ConnectionPtr connection() const;
    00053
    00054     QSet<Contact::Feature> supportedFeatures() const;
    00055
    00056     Contacts allKnownContacts() const;
    00057     QStringList allKnownGroups() const;
    00058
    00059     PendingOperation *addGroup(const QString &group);
    00060     PendingOperation *removeGroup(const QString &group);
    00061
    00062     Contacts groupContacts(const QString &group) const;
    00063     PendingOperation *addContactsToGroup(const QString &group,
    00064             const QList<ContactPtr> &contacts);
    00065     PendingOperation *removeContactsFromGroup(const QString &group,
    00066             const QList<ContactPtr> &contacts);
    00067
    00068     bool canRequestPresenceSubscription() const;
    00069     bool subscriptionRequestHasMessage() const;
    00070     PendingOperation *requestPresenceSubscription(
    00071             const QList<ContactPtr> &contacts,
    00072             const QString &message = QString());
    00073     bool canRemovePresenceSubscription() const;
    00074     bool subscriptionRemovalHasMessage() const;
    00075     bool canRescindPresenceSubscriptionRequest() const;
    00076     bool subscriptionRescindingHasMessage() const;
    00077     PendingOperation *removePresenceSubscription(
    00078             const QList<ContactPtr> &contacts,
    00079             const QString &message = QString());
    00080     bool canAuthorizePresencePublication() const;
    00081     bool publicationAuthorizationHasMessage() const;
    00082     PendingOperation *authorizePresencePublication(
    00083             const QList<ContactPtr> &contacts,
    00084             const QString &message = QString());
    00085     bool publicationRejectionHasMessage() const;
    00086     bool canRemovePresencePublication() const;
    00087     bool publicationRemovalHasMessage() const;
    00088     PendingOperation *removePresencePublication(
    00089             const QList<ContactPtr> &contacts,
    00090             const QString &message = QString());
    00091     PendingOperation *removeContacts(
    00092             const QList<ContactPtr> &contacts,
    00093             const QString &message = QString());
    00094
    00095     bool canBlockContacts() const;
    00096     PendingOperation *blockContacts(
    00097             const QList<ContactPtr> &contacts, bool value = true);
    00098
    00099     PendingContacts *contactsForHandles(const UIntList &handles,
    00100             const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
    00101     PendingContacts *contactsForHandles(const ReferencedHandles &handles,
    00102             const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
    00103
    00104     PendingContacts *contactsForIdentifiers(const QStringList &identifiers,
    00105             const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
    00106
    00107     PendingContacts *upgradeContacts(const QList<ContactPtr> &contacts,
    00108             const QSet<Contact::Feature> &features);
    00109
    00110     ContactPtr lookupContactByHandle(uint handle);
    00111
    00112     void requestContactAvatar(Contact *contact);
    00113
    00114 Q_SIGNALS:
    00115     // FIXME: (API/ABI break) Remove presencePublicationRequested that does not take details as
    00116     //                        param
    00117     void presencePublicationRequested(const Tp::Contacts &contacts);
    00118     void presencePublicationRequested(const Tp::Contacts &contacts,
    00119         const Tp::Channel::GroupMemberChangeDetails &details);
    00120
    00121     void groupAdded(const QString &group);
    00122     void groupRemoved(const QString &group);
    00123     // FIXME: (API/ABI break) Remove groupMembersChanged that does not take details as
    00124     //                        param
    00125     void groupMembersChanged(const QString &group,
    00126             const Tp::Contacts &groupMembersAdded,
    00127             const Tp::Contacts &groupMembersRemoved);
    00128     void groupMembersChanged(const QString &group,
    00129             const Tp::Contacts &groupMembersAdded,
    00130             const Tp::Contacts &groupMembersRemoved,
    00131             const Tp::Channel::GroupMemberChangeDetails &details);
    00132
    00133     // FIXME: (API/ABI break) Remove allKnownContactsChanged that does not take details as
    00134     //                        param
    00135     void allKnownContactsChanged(const Tp::Contacts &contactsAdded,
    00136             const Tp::Contacts &contactsRemoved);
    00137     void allKnownContactsChanged(const Tp::Contacts &contactsAdded,
    00138             const Tp::Contacts &contactsRemoved,
    00139             const Tp::Channel::GroupMemberChangeDetails &details);
    00140
    00141 protected:
    00142     // FIXME: (API/ABI break) Remove connectNotify
    00143     void connectNotify(const char *);
    00144
    00145 private Q_SLOTS:
    00146     void onAliasesChanged(const Tp::AliasPairList &);
    00147     void onAvatarUpdated(uint, const QString &);
    00148     void onAvatarRetrieved(uint, const QString &, const QByteArray &, const QString &);
    00149     void doRequestAvatars();
    00150     void onPresencesChanged(const Tp::SimpleContactPresences &);
    00151     void onCapabilitiesChanged(const Tp::ContactCapabilitiesMap &);
    00152     void onLocationUpdated(uint, const QVariantMap &);
    00153     void onContactInfoChanged(uint, const Tp::ContactInfoFieldList &);
    00154
    00155     void onStoredChannelMembersChanged(
    00156         const Tp::Contacts &groupMembersAdded,
    00157         const Tp::Contacts &groupLocalPendingMembersAdded,
    00158         const Tp::Contacts &groupRemotePendingMembersAdded,
    00159         const Tp::Contacts &groupMembersRemoved,
    00160         const Tp::Channel::GroupMemberChangeDetails &details);
    00161     void onSubscribeChannelMembersChanged(
    00162         const Tp::Contacts &groupMembersAdded,
    00163         const Tp::Contacts &groupLocalPendingMembersAdded,
    00164         const Tp::Contacts &groupRemotePendingMembersAdded,
    00165         const Tp::Contacts &groupMembersRemoved,
    00166         const Tp::Channel::GroupMemberChangeDetails &details);
    00167     void onPublishChannelMembersChanged(
    00168         const Tp::Contacts &groupMembersAdded,
    00169         const Tp::Contacts &groupLocalPendingMembersAdded,
    00170         const Tp::Contacts &groupRemotePendingMembersAdded,
    00171         const Tp::Contacts &groupMembersRemoved,
    00172         const Tp::Channel::GroupMemberChangeDetails &details);
    00173     void onDenyChannelMembersChanged(
    00174         const Tp::Contacts &groupMembersAdded,
    00175         const Tp::Contacts &groupLocalPendingMembersAdded,
    00176         const Tp::Contacts &groupRemotePendingMembersAdded,
    00177         const Tp::Contacts &groupMembersRemoved,
    00178         const Tp::Channel::GroupMemberChangeDetails &details);
    00179
    00180     void onContactListGroupMembersChanged(
    00181         const Tp::Contacts &groupMembersAdded,
    00182         const Tp::Contacts &groupLocalPendingMembersAdded,
    00183         const Tp::Contacts &groupRemotePendingMembersAdded,
    00184         const Tp::Contacts &groupMembersRemoved,
    00185         const Tp::Channel::GroupMemberChangeDetails &details);
    00186     void onContactListGroupRemoved(Tp::DBusProxy *,
    00187         const QString &, const QString &);
    00188
    00189 private:
    00190     friend class Connection;
    00191     friend class PendingContacts;
    00192
    00193     struct ContactListChannel
    00194     {
    00195         enum Type {
    00196             TypeSubscribe = 0,
    00197             TypePublish,
    00198             TypeStored,
    00199             TypeDeny,
    00200             LastType
    00201         };
    00202
    00203         ContactListChannel()
    00204             : type((Type) -1)
    00205         {
    00206         }
    00207
    00208         ContactListChannel(Type type)
    00209             : type(type)
    00210         {
    00211         }
    00212
    00213         ~ContactListChannel()
    00214         {
    00215         }
    00216
    00217         static QString identifierForType(Type type);
    00218         static uint typeForIdentifier(const QString &identifier);
    00219
    00220         Type type;
    00221         ReferencedHandles handle;
    00222         ChannelPtr channel;
    00223     };
    00224
    00225     ContactManager(Connection *parent);
    00226     ~ContactManager();
    00227
    00228     ContactPtr ensureContact(const ReferencedHandles &handle,
    00229             const QSet<Contact::Feature> &features,
    00230             const QVariantMap &attributes);
    00231
    00232     void setContactListChannels(
    00233             const QMap<uint, ContactListChannel> &contactListChannels);
    00234     void setContactListGroupChannels(
    00235             const QList<ChannelPtr> &contactListGroupChannels);
    00236     void addContactListGroupChannel(const ChannelPtr &contactListGroupChannel);
    00237
    00238     struct Private;
    00239     friend struct Private;
    00240     Private *mPriv;
    00241 };
    00242
    00243 } // Tp
    00244
    00245 #endif