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

contact-manager.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2008-2009 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2008-2009 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 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 
00092     bool canBlockContacts() const;
00093     PendingOperation *blockContacts(
00094             const QList<ContactPtr> &contacts, bool value = true);
00095 
00096     PendingContacts *contactsForHandles(const UIntList &handles,
00097             const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
00098     PendingContacts *contactsForHandles(const ReferencedHandles &handles,
00099             const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
00100 
00101     PendingContacts *contactsForIdentifiers(const QStringList &identifiers,
00102             const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
00103 
00104     PendingContacts *upgradeContacts(const QList<ContactPtr> &contacts,
00105             const QSet<Contact::Feature> &features);
00106 
00107     ContactPtr lookupContactByHandle(uint handle);
00108 
00109 Q_SIGNALS:
00110     void presencePublicationRequested(const Tp::Contacts &contacts);
00111     void groupAdded(const QString &group);
00112     void groupRemoved(const QString &group);
00113     void groupMembersChanged(const QString &group,
00114             const Tp::Contacts &groupMembersAdded,
00115             const Tp::Contacts &groupMembersRemoved);
00116 
00117 private Q_SLOTS:
00118     void onAliasesChanged(const Tp::AliasPairList &);
00119     void onAvatarUpdated(uint, const QString &);
00120     void onPresencesChanged(const Tp::SimpleContactPresences &);
00121 
00122     void onSubscribeChannelMembersChanged(
00123         const Tp::Contacts &groupMembersAdded,
00124         const Tp::Contacts &groupLocalPendingMembersAdded,
00125         const Tp::Contacts &groupRemotePendingMembersAdded,
00126         const Tp::Contacts &groupMembersRemoved,
00127         const Tp::Channel::GroupMemberChangeDetails &details);
00128     void onPublishChannelMembersChanged(
00129         const Tp::Contacts &groupMembersAdded,
00130         const Tp::Contacts &groupLocalPendingMembersAdded,
00131         const Tp::Contacts &groupRemotePendingMembersAdded,
00132         const Tp::Contacts &groupMembersRemoved,
00133         const Tp::Channel::GroupMemberChangeDetails &details);
00134     void onDenyChannelMembersChanged(
00135         const Tp::Contacts &groupMembersAdded,
00136         const Tp::Contacts &groupLocalPendingMembersAdded,
00137         const Tp::Contacts &groupRemotePendingMembersAdded,
00138         const Tp::Contacts &groupMembersRemoved,
00139         const Tp::Channel::GroupMemberChangeDetails &details);
00140 
00141     void onContactListGroupMembersChanged(
00142         const Tp::Contacts &groupMembersAdded,
00143         const Tp::Contacts &groupLocalPendingMembersAdded,
00144         const Tp::Contacts &groupRemotePendingMembersAdded,
00145         const Tp::Contacts &groupMembersRemoved,
00146         const Tp::Channel::GroupMemberChangeDetails &details);
00147     void onContactListGroupRemoved(Tp::DBusProxy *,
00148         const QString &, const QString &);
00149 
00150 private:
00151     friend class Connection;
00152     friend class PendingContacts;
00153 
00154     struct ContactListChannel
00155     {
00156         enum Type {
00157             TypeSubscribe = 0,
00158             TypePublish,
00159             TypeStored,
00160             TypeDeny,
00161             LastType
00162         };
00163 
00164         ContactListChannel()
00165             : type((Type) -1)
00166         {
00167         }
00168 
00169         ContactListChannel(Type type)
00170             : type(type)
00171         {
00172         }
00173 
00174         ~ContactListChannel()
00175         {
00176         }
00177 
00178         static QString identifierForType(Type type);
00179         static uint typeForIdentifier(const QString &identifier);
00180 
00181         Type type;
00182         ReferencedHandles handle;
00183         ChannelPtr channel;
00184     };
00185 
00186     ContactManager(const ConnectionPtr &parent);
00187     ~ContactManager();
00188 
00189     ContactPtr ensureContact(const ReferencedHandles &handle,
00190             const QSet<Contact::Feature> &features,
00191             const QVariantMap &attributes);
00192 
00193     void setContactListChannels(
00194             const QMap<uint, ContactListChannel> &contactListChannels);
00195     void setContactListGroupChannels(
00196             const QList<ChannelPtr> &contactListGroupChannels);
00197     void addContactListGroupChannel(const ChannelPtr &contactListGroupChannel);
00198 
00199     struct Private;
00200     friend struct Private;
00201     Private *mPriv;
00202 };
00203 
00204 } // Tp
00205 
00206 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.1.10