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 <TelepathyQt4/Channel>
00030 #include <TelepathyQt4/Contact>
00031 #include <TelepathyQt4/Feature>
00032 #include <TelepathyQt4/Object>
00033 #include <TelepathyQt4/ReferencedHandles>
00034 #include <TelepathyQt4/Types>
00035 
00036 #include <QList>
00037 #include <QSet>
00038 #include <QString>
00039 #include <QStringList>
00040 #include <QVariantMap>
00041 
00042 namespace Tp
00043 {
00044 
00045 class Connection;
00046 class PendingContacts;
00047 class PendingOperation;
00048 
00049 class TELEPATHY_QT4_EXPORT ContactManager : public Object
00050 {
00051     Q_OBJECT
00052     Q_DISABLE_COPY(ContactManager)
00053 
00054 public:
00055     virtual ~ContactManager();
00056 
00057     ConnectionPtr connection() const;
00058 
00059     Features supportedFeatures() const;
00060 
00061     Contacts allKnownContacts() const;
00062     QStringList allKnownGroups() const;
00063 
00064     PendingOperation *addGroup(const QString &group);
00065     PendingOperation *removeGroup(const QString &group);
00066 
00067     Contacts groupContacts(const QString &group) const;
00068     PendingOperation *addContactsToGroup(const QString &group,
00069             const QList<ContactPtr> &contacts);
00070     PendingOperation *removeContactsFromGroup(const QString &group,
00071             const QList<ContactPtr> &contacts);
00072 
00073     bool canRequestPresenceSubscription() const;
00074     bool subscriptionRequestHasMessage() const;
00075     PendingOperation *requestPresenceSubscription(
00076             const QList<ContactPtr> &contacts,
00077             const QString &message = QString());
00078     bool canRemovePresenceSubscription() const;
00079     bool subscriptionRemovalHasMessage() const;
00080     bool canRescindPresenceSubscriptionRequest() const;
00081     bool subscriptionRescindingHasMessage() const;
00082     PendingOperation *removePresenceSubscription(
00083             const QList<ContactPtr> &contacts,
00084             const QString &message = QString());
00085     bool canAuthorizePresencePublication() const;
00086     bool publicationAuthorizationHasMessage() const;
00087     PendingOperation *authorizePresencePublication(
00088             const QList<ContactPtr> &contacts,
00089             const QString &message = QString());
00090     bool publicationRejectionHasMessage() const;
00091     bool canRemovePresencePublication() const;
00092     bool publicationRemovalHasMessage() const;
00093     PendingOperation *removePresencePublication(
00094             const QList<ContactPtr> &contacts,
00095             const QString &message = QString());
00096     PendingOperation *removeContacts(
00097             const QList<ContactPtr> &contacts,
00098             const QString &message = QString());
00099 
00100     bool canBlockContacts() const;
00101     PendingOperation *blockContacts(
00102             const QList<ContactPtr> &contacts, bool value = true);
00103 
00104     PendingContacts *contactsForHandles(const UIntList &handles,
00105             const Features &features = Features());
00106     PendingContacts *contactsForHandles(const ReferencedHandles &handles,
00107             const Features &features = Features());
00108 
00109     PendingContacts *contactsForIdentifiers(const QStringList &identifiers,
00110             const Features &features = Features());
00111 
00112     PendingContacts *upgradeContacts(const QList<ContactPtr> &contacts,
00113             const Features &features);
00114 
00115     ContactPtr lookupContactByHandle(uint handle);
00116 
00117     void requestContactAvatar(Contact *contact);
00118 
00119 Q_SIGNALS:
00120     void presencePublicationRequested(const Tp::Contacts &contacts);
00121     // deprecated - carry redundant data which can be got (meaningfully) from the Contacts
00122     // themselves (note: multiple contacts, but just a single message/details!)
00123     void presencePublicationRequested(const Tp::Contacts &contacts, const QString &message);
00124     void presencePublicationRequested(const Tp::Contacts &contacts,
00125         const Tp::Channel::GroupMemberChangeDetails &details);
00126 
00127     void groupAdded(const QString &group);
00128     void groupRenamed(const QString &oldGroup, const QString &newGroup);
00129     void groupRemoved(const QString &group);
00130 
00131     void groupMembersChanged(const QString &group,
00132             const Tp::Contacts &groupMembersAdded,
00133             const Tp::Contacts &groupMembersRemoved,
00134             const Tp::Channel::GroupMemberChangeDetails &details);
00135 
00136     void allKnownContactsChanged(const Tp::Contacts &contactsAdded,
00137             const Tp::Contacts &contactsRemoved,
00138             const Tp::Channel::GroupMemberChangeDetails &details);
00139 
00140 protected:
00141     // FIXME: (API/ABI break) Remove connectNotify
00142     void connectNotify(const char *);
00143 
00144 private Q_SLOTS:
00145     void onAliasesChanged(const Tp::AliasPairList &);
00146     void doRequestAvatars();
00147     void onAvatarUpdated(uint, const QString &);
00148     void onAvatarRetrieved(uint, const QString &, const QByteArray &, const QString &);
00149     void onPresencesChanged(const Tp::SimpleContactPresences &);
00150     void onCapabilitiesChanged(const Tp::ContactCapabilitiesMap &);
00151     void onLocationUpdated(uint, const QVariantMap &);
00152     void onContactInfoChanged(uint, const Tp::ContactInfoFieldList &);
00153 
00154     void onContactListNewContactsConstructed(Tp::PendingOperation *op);
00155     void onContactListGroupsChanged(const Tp::UIntList &contacts,
00156             const QStringList &added, const QStringList &removed);
00157     void onContactListGroupsCreated(const QStringList &names);
00158     void onContactListGroupRenamed(const QString &oldName, const QString &newName);
00159     void onContactListGroupsRemoved(const QStringList &names);
00160 
00161     void onModifyFinished(Tp::PendingOperation *op);
00162     void onModifyFinishSignaled();
00163 
00164     void onStoredChannelMembersChangedFallback(
00165         const Tp::Contacts &groupMembersAdded,
00166         const Tp::Contacts &groupLocalPendingMembersAdded,
00167         const Tp::Contacts &groupRemotePendingMembersAdded,
00168         const Tp::Contacts &groupMembersRemoved,
00169         const Tp::Channel::GroupMemberChangeDetails &details);
00170     void onSubscribeChannelMembersChangedFallback(
00171         const Tp::Contacts &groupMembersAdded,
00172         const Tp::Contacts &groupLocalPendingMembersAdded,
00173         const Tp::Contacts &groupRemotePendingMembersAdded,
00174         const Tp::Contacts &groupMembersRemoved,
00175         const Tp::Channel::GroupMemberChangeDetails &details);
00176     void onPublishChannelMembersChangedFallback(
00177         const Tp::Contacts &groupMembersAdded,
00178         const Tp::Contacts &groupLocalPendingMembersAdded,
00179         const Tp::Contacts &groupRemotePendingMembersAdded,
00180         const Tp::Contacts &groupMembersRemoved,
00181         const Tp::Channel::GroupMemberChangeDetails &details);
00182     void onDenyChannelMembersChanged(
00183         const Tp::Contacts &groupMembersAdded,
00184         const Tp::Contacts &groupLocalPendingMembersAdded,
00185         const Tp::Contacts &groupRemotePendingMembersAdded,
00186         const Tp::Contacts &groupMembersRemoved,
00187         const Tp::Channel::GroupMemberChangeDetails &details);
00188 
00189     void onContactListGroupMembersChangedFallback(
00190         const Tp::Contacts &groupMembersAdded,
00191         const Tp::Contacts &groupLocalPendingMembersAdded,
00192         const Tp::Contacts &groupRemotePendingMembersAdded,
00193         const Tp::Contacts &groupMembersRemoved,
00194         const Tp::Channel::GroupMemberChangeDetails &details);
00195     void onContactListGroupRemovedFallback(Tp::DBusProxy *proxy,
00196         const QString &errorName, const QString &errorMessage);
00197 
00198 private:
00199     friend class Connection;
00200     friend class PendingContacts;
00201 
00202     struct ContactListChannel
00203     {
00204         enum Type {
00205             TypeSubscribe = 0,
00206             TypePublish,
00207             TypeStored,
00208             TypeDeny,
00209             LastType
00210         };
00211 
00212         ContactListChannel()
00213             : type((Type) -1)
00214         {
00215         }
00216 
00217         ContactListChannel(Type type)
00218             : type(type)
00219         {
00220         }
00221 
00222         ~ContactListChannel()
00223         {
00224         }
00225 
00226         static QString identifierForType(Type type);
00227         static uint typeForIdentifier(const QString &identifier);
00228 
00229         Type type;
00230         ReferencedHandles handle;
00231         ChannelPtr channel;
00232     };
00233 
00234     ContactManager(Connection *parent);
00235 
00236     ContactPtr ensureContact(const ReferencedHandles &handle,
00237             const Features &features,
00238             const QVariantMap &attributes);
00239 
00240     void setUseFallbackContactList(bool value);
00241 
00242     void setContactListProperties(const QVariantMap &props);
00243     void setContactListContacts(const ContactAttributesMap &attrs);
00244     void updateContactListContacts(const ContactSubscriptionMap &changes,
00245             const UIntList &removals);
00246     void setContactListGroupsProperties(const QVariantMap &props);
00247 
00248     void setContactListChannels(
00249             const QMap<uint, ContactListChannel> &contactListChannels);
00250 
00251     void setContactListGroupChannelsFallback(
00252             const QList<ChannelPtr> &contactListGroupChannels);
00253     void addContactListGroupChannelFallback(
00254             const ChannelPtr &contactListGroupChannel);
00255 
00256     void resetContactListChannels();
00257 
00258     static QString featureToInterface(const Feature &feature);
00259 
00260     struct Private;
00261     friend struct Private;
00262     Private *mPriv;
00263 };
00264 
00265 } // Tp
00266 
00267 #endif


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