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


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