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     ContactListState state() const;
00062 
00063     Contacts allKnownContacts() const;
00064     QStringList allKnownGroups() const;
00065 
00066     PendingOperation *addGroup(const QString &group);
00067     PendingOperation *removeGroup(const QString &group);
00068 
00069     Contacts groupContacts(const QString &group) const;
00070     PendingOperation *addContactsToGroup(const QString &group,
00071             const QList<ContactPtr> &contacts);
00072     PendingOperation *removeContactsFromGroup(const QString &group,
00073             const QList<ContactPtr> &contacts);
00074 
00075     bool canRequestPresenceSubscription() const;
00076     bool subscriptionRequestHasMessage() const;
00077     PendingOperation *requestPresenceSubscription(
00078             const QList<ContactPtr> &contacts,
00079             const QString &message = QString());
00080     bool canRemovePresenceSubscription() const;
00081     bool subscriptionRemovalHasMessage() const;
00082     bool canRescindPresenceSubscriptionRequest() const;
00083     bool subscriptionRescindingHasMessage() const;
00084     PendingOperation *removePresenceSubscription(
00085             const QList<ContactPtr> &contacts,
00086             const QString &message = QString());
00087     bool canAuthorizePresencePublication() const;
00088     bool publicationAuthorizationHasMessage() const;
00089     PendingOperation *authorizePresencePublication(
00090             const QList<ContactPtr> &contacts,
00091             const QString &message = QString());
00092     bool publicationRejectionHasMessage() const;
00093     bool canRemovePresencePublication() const;
00094     bool publicationRemovalHasMessage() const;
00095     PendingOperation *removePresencePublication(
00096             const QList<ContactPtr> &contacts,
00097             const QString &message = QString());
00098     PendingOperation *removeContacts(
00099             const QList<ContactPtr> &contacts,
00100             const QString &message = QString());
00101 
00102     bool canBlockContacts() const;
00103     PendingOperation *blockContacts(
00104             const QList<ContactPtr> &contacts, bool value = true);
00105 
00106     PendingContacts *contactsForHandles(const UIntList &handles,
00107             const Features &features = Features());
00108     PendingContacts *contactsForHandles(const ReferencedHandles &handles,
00109             const Features &features = Features());
00110 
00111     PendingContacts *contactsForIdentifiers(const QStringList &identifiers,
00112             const Features &features = Features());
00113 
00114     PendingContacts *upgradeContacts(const QList<ContactPtr> &contacts,
00115             const Features &features);
00116 
00117     ContactPtr lookupContactByHandle(uint handle);
00118 
00119     void requestContactAvatar(Contact *contact);
00120 
00121 Q_SIGNALS:
00122     void stateChanged(Tp::ContactListState state);
00123 
00124     void presencePublicationRequested(const Tp::Contacts &contacts);
00125     // deprecated - carry redundant data which can be retrieved (meaningfully) from the Contacts
00126     // themselves (note: multiple contacts, but just a single message/details!)
00127     void presencePublicationRequested(const Tp::Contacts &contacts, const QString &message);
00128     void presencePublicationRequested(const Tp::Contacts &contacts,
00129         const Tp::Channel::GroupMemberChangeDetails &details);
00130 
00131     void groupAdded(const QString &group);
00132     void groupRenamed(const QString &oldGroup, const QString &newGroup);
00133     void groupRemoved(const QString &group);
00134 
00135     void groupMembersChanged(const QString &group,
00136             const Tp::Contacts &groupMembersAdded,
00137             const Tp::Contacts &groupMembersRemoved,
00138             const Tp::Channel::GroupMemberChangeDetails &details);
00139 
00140     void allKnownContactsChanged(const Tp::Contacts &contactsAdded,
00141             const Tp::Contacts &contactsRemoved,
00142             const Tp::Channel::GroupMemberChangeDetails &details);
00143 
00144 protected:
00145     // FIXME: (API/ABI break) Remove connectNotify
00146     void connectNotify(const char *);
00147 
00148 private Q_SLOTS:
00149     void onAliasesChanged(const Tp::AliasPairList &);
00150     void doRequestAvatars();
00151     void onAvatarUpdated(uint, const QString &);
00152     void onAvatarRetrieved(uint, const QString &, const QByteArray &, const QString &);
00153     void onPresencesChanged(const Tp::SimpleContactPresences &);
00154     void onCapabilitiesChanged(const Tp::ContactCapabilitiesMap &);
00155     void onLocationUpdated(uint, const QVariantMap &);
00156     void onContactInfoChanged(uint, const Tp::ContactInfoFieldList &);
00157 
00158 private:
00159     class Roster;
00160     friend class Connection;
00161     friend class PendingContacts;
00162     friend class Roster;
00163 
00164     ContactManager(Connection *parent);
00165 
00166     ContactPtr ensureContact(const ReferencedHandles &handle,
00167             const Features &features,
00168             const QVariantMap &attributes);
00169 
00170     void ensureTracking(const Feature &feature);
00171     static QString featureToInterface(const Feature &feature);
00172 
00173     PendingOperation *introspectRoster();
00174     PendingOperation *introspectRosterGroups();
00175     void resetRoster();
00176 
00177     struct Private;
00178     friend struct Private;
00179     Private *mPriv;
00180 };
00181 
00182 } // Tp
00183 
00184 #endif


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