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_cli_contact_manager_h_HEADER_GUARD_
00023 #define _TelepathyQt4_cli_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 
00050     public:
00051 
00052         ConnectionPtr connection() const;
00053 
00054         QSet<Contact::Feature> supportedFeatures() const;
00055 
00056         Contacts allKnownContacts() const;
00057 
00058         bool canRequestPresenceSubscription() const;
00059         bool subscriptionRequestHasMessage() const;
00060         PendingOperation *requestPresenceSubscription(
00061                 const QList<ContactPtr> &contacts, const QString &message = QString());
00062         bool canRemovePresenceSubscription() const;
00063         bool subscriptionRemovalHasMessage() const;
00064         bool canRescindPresenceSubscriptionRequest() const;
00065         bool subscriptionRescindingHasMessage() const;
00066         PendingOperation *removePresenceSubscription(
00067                 const QList<ContactPtr> &contacts, const QString &message = QString());
00068         bool canAuthorizePresencePublication() const;
00069         bool publicationAuthorizationHasMessage() const;
00070         PendingOperation *authorizePresencePublication(
00071                 const QList<ContactPtr> &contacts, const QString &message = QString());
00072         bool publicationRejectionHasMessage() const;
00073         bool canRemovePresencePublication() const;
00074         bool publicationRemovalHasMessage() const;
00075         PendingOperation *removePresencePublication(
00076                 const QList<ContactPtr> &contacts, const QString &message = QString());
00077 
00078         bool canBlockContacts() const;
00079         PendingOperation *blockContacts(
00080                 const QList<ContactPtr> &contacts, bool value = true);
00081 
00082         PendingContacts *contactsForHandles(const UIntList &handles,
00083                 const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
00084         PendingContacts *contactsForHandles(const ReferencedHandles &handles,
00085                 const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
00086 
00087         PendingContacts *contactsForIdentifiers(const QStringList &identifiers,
00088                 const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
00089 
00090         PendingContacts *upgradeContacts(const QList<ContactPtr> &contacts,
00091                 const QSet<Contact::Feature> &features);
00092 
00093         ContactPtr lookupContactByHandle(uint handle);
00094 
00095     Q_SIGNALS:
00096         void presencePublicationRequested(const Tp::Contacts &contacts);
00097 
00098     private Q_SLOTS:
00099         void onAliasesChanged(const Tp::AliasPairList &);
00100         void onAvatarUpdated(uint, const QString &);
00101         void onPresencesChanged(const Tp::SimpleContactPresences &);
00102 
00103         void onSubscribeChannelMembersChanged(
00104             const Tp::Contacts &groupMembersAdded,
00105             const Tp::Contacts &groupLocalPendingMembersAdded,
00106             const Tp::Contacts &groupRemotePendingMembersAdded,
00107             const Tp::Contacts &groupMembersRemoved,
00108             const Tp::Channel::GroupMemberChangeDetails &details);
00109         void onPublishChannelMembersChanged(
00110             const Tp::Contacts &groupMembersAdded,
00111             const Tp::Contacts &groupLocalPendingMembersAdded,
00112             const Tp::Contacts &groupRemotePendingMembersAdded,
00113             const Tp::Contacts &groupMembersRemoved,
00114             const Tp::Channel::GroupMemberChangeDetails &details);
00115         void onDenyChannelMembersChanged(
00116             const Tp::Contacts &groupMembersAdded,
00117             const Tp::Contacts &groupLocalPendingMembersAdded,
00118             const Tp::Contacts &groupRemotePendingMembersAdded,
00119             const Tp::Contacts &groupMembersRemoved,
00120             const Tp::Channel::GroupMemberChangeDetails &details);
00121 
00122     private:
00123         struct ContactListChannel
00124         {
00125             enum Type {
00126                 TypeSubscribe = 0,
00127                 TypePublish,
00128                 TypeStored,
00129                 TypeDeny,
00130                 LastType
00131             };
00132 
00133             ContactListChannel()
00134                 : type((Type) -1)
00135             {
00136             }
00137 
00138             ContactListChannel(Type type)
00139                 : type(type)
00140             {
00141             }
00142 
00143             ~ContactListChannel()
00144             {
00145             }
00146 
00147             static QString identifierForType(Type type);
00148             static uint typeForIdentifier(const QString &identifier);
00149 
00150             Type type;
00151             ReferencedHandles handle;
00152             ChannelPtr channel;
00153         };
00154 
00155         ContactManager(const ConnectionPtr &parent);
00156         ~ContactManager();
00157 
00158         ContactPtr ensureContact(const ReferencedHandles &handle,
00159                 const QSet<Contact::Feature> &features, const QVariantMap &attributes);
00160 
00161         void setContactListChannels(const QMap<uint, ContactListChannel> &contactListsChannels);
00162 
00163         struct Private;
00164         friend struct Private;
00165         friend class Connection;
00166         friend class PendingContacts;
00167         Private *mPriv;
00168 };
00169 
00170 } // Tp
00171 
00172 #endif


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