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 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 
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);
00128     void allKnownContactsChanged(const Tp::Contacts &contactsAdded,
00129             const Tp::Contacts &contactsRemoved);
00130 
00131 private Q_SLOTS:
00132     void onAliasesChanged(const Tp::AliasPairList &);
00133     void onAvatarUpdated(uint, const QString &);
00134     void onPresencesChanged(const Tp::SimpleContactPresences &);
00135     void onCapabilitiesChanged(const Tp::ContactCapabilitiesMap &);
00136     void onLocationUpdated(uint, const QVariantMap &);
00137     void onContactInfoChanged(uint, const Tp::ContactInfoFieldList &);
00138 
00139     void onSubscribeChannelMembersChanged(
00140         const Tp::Contacts &groupMembersAdded,
00141         const Tp::Contacts &groupLocalPendingMembersAdded,
00142         const Tp::Contacts &groupRemotePendingMembersAdded,
00143         const Tp::Contacts &groupMembersRemoved,
00144         const Tp::Channel::GroupMemberChangeDetails &details);
00145     void onPublishChannelMembersChanged(
00146         const Tp::Contacts &groupMembersAdded,
00147         const Tp::Contacts &groupLocalPendingMembersAdded,
00148         const Tp::Contacts &groupRemotePendingMembersAdded,
00149         const Tp::Contacts &groupMembersRemoved,
00150         const Tp::Channel::GroupMemberChangeDetails &details);
00151     void onDenyChannelMembersChanged(
00152         const Tp::Contacts &groupMembersAdded,
00153         const Tp::Contacts &groupLocalPendingMembersAdded,
00154         const Tp::Contacts &groupRemotePendingMembersAdded,
00155         const Tp::Contacts &groupMembersRemoved,
00156         const Tp::Channel::GroupMemberChangeDetails &details);
00157 
00158     void onContactListGroupMembersChanged(
00159         const Tp::Contacts &groupMembersAdded,
00160         const Tp::Contacts &groupLocalPendingMembersAdded,
00161         const Tp::Contacts &groupRemotePendingMembersAdded,
00162         const Tp::Contacts &groupMembersRemoved,
00163         const Tp::Channel::GroupMemberChangeDetails &details);
00164     void onContactListGroupRemoved(Tp::DBusProxy *,
00165         const QString &, const QString &);
00166 
00167 private:
00168     friend class Connection;
00169     friend class PendingContacts;
00170 
00171     struct ContactListChannel
00172     {
00173         enum Type {
00174             TypeSubscribe = 0,
00175             TypePublish,
00176             TypeStored,
00177             TypeDeny,
00178             LastType
00179         };
00180 
00181         ContactListChannel()
00182             : type((Type) -1)
00183         {
00184         }
00185 
00186         ContactListChannel(Type type)
00187             : type(type)
00188         {
00189         }
00190 
00191         ~ContactListChannel()
00192         {
00193         }
00194 
00195         static QString identifierForType(Type type);
00196         static uint typeForIdentifier(const QString &identifier);
00197 
00198         Type type;
00199         ReferencedHandles handle;
00200         ChannelPtr channel;
00201     };
00202 
00203     ContactManager(const ConnectionPtr &parent);
00204     ~ContactManager();
00205 
00206     ContactPtr ensureContact(const ReferencedHandles &handle,
00207             const QSet<Contact::Feature> &features,
00208             const QVariantMap &attributes);
00209 
00210     void setContactListChannels(
00211             const QMap<uint, ContactListChannel> &contactListChannels);
00212     void setContactListGroupChannels(
00213             const QList<ChannelPtr> &contactListGroupChannels);
00214     void addContactListGroupChannel(const ChannelPtr &contactListGroupChannel);
00215 
00216     struct Private;
00217     friend struct Private;
00218     Private *mPriv;
00219 };
00220 
00221 } // Tp
00222 
00223 #endif


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