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 retrieved (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 private:
00155     class Roster;
00156     friend class Connection;
00157     friend class PendingContacts;
00158     friend class Roster;
00159 
00160     ContactManager(Connection *parent);
00161 
00162     ContactPtr ensureContact(const ReferencedHandles &handle,
00163             const Features &features,
00164             const QVariantMap &attributes);
00165 
00166     void ensureTracking(const Feature &feature);
00167     static QString featureToInterface(const Feature &feature);
00168 
00169     PendingOperation *introspectRoster();
00170     PendingOperation *introspectRosterGroups();
00171     void resetRoster();
00172 
00173     struct Private;
00174     friend struct Private;
00175     Private *mPriv;
00176 };
00177 
00178 } // Tp
00179 
00180 #endif


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