00001
00023 #ifndef _TelepathyQt4_contact_manager_h_HEADER_GUARD_
00024 #define _TelepathyQt4_contact_manager_h_HEADER_GUARD_
00025
00026 #ifndef IN_TELEPATHY_QT4_HEADER
00027 #error IN_TELEPATHY_QT4_HEADER
00028 #endif
00029
00030 #include <TelepathyQt4/Channel>
00031 #include <TelepathyQt4/Contact>
00032 #include <TelepathyQt4/Feature>
00033 #include <TelepathyQt4/Object>
00034 #include <TelepathyQt4/ReferencedHandles>
00035 #include <TelepathyQt4/Types>
00036
00037 #include <QList>
00038 #include <QSet>
00039 #include <QString>
00040 #include <QStringList>
00041 #include <QVariantMap>
00042
00043 namespace Tp
00044 {
00045
00046 class Connection;
00047 class PendingContacts;
00048 class PendingOperation;
00049
00050 class TELEPATHY_QT4_EXPORT ContactManager : public Object
00051 {
00052 Q_OBJECT
00053 Q_DISABLE_COPY(ContactManager)
00054
00055 public:
00056 virtual ~ContactManager();
00057
00058 ConnectionPtr connection() const;
00059
00060 Features supportedFeatures() const;
00061
00062 ContactListState state() const;
00063
00064 Contacts allKnownContacts() const;
00065 QStringList allKnownGroups() const;
00066
00067 PendingOperation *addGroup(const QString &group);
00068 PendingOperation *removeGroup(const QString &group);
00069
00070 Contacts groupContacts(const QString &group) const;
00071 PendingOperation *addContactsToGroup(const QString &group,
00072 const QList<ContactPtr> &contacts);
00073 PendingOperation *removeContactsFromGroup(const QString &group,
00074 const QList<ContactPtr> &contacts);
00075
00076 bool canRequestPresenceSubscription() const;
00077 bool subscriptionRequestHasMessage() const;
00078 PendingOperation *requestPresenceSubscription(
00079 const QList<ContactPtr> &contacts,
00080 const QString &message = QString());
00081 bool canRemovePresenceSubscription() const;
00082 bool subscriptionRemovalHasMessage() const;
00083 bool canRescindPresenceSubscriptionRequest() const;
00084 bool subscriptionRescindingHasMessage() const;
00085 PendingOperation *removePresenceSubscription(
00086 const QList<ContactPtr> &contacts,
00087 const QString &message = QString());
00088 bool canAuthorizePresencePublication() const;
00089 bool publicationAuthorizationHasMessage() const;
00090 PendingOperation *authorizePresencePublication(
00091 const QList<ContactPtr> &contacts,
00092 const QString &message = QString());
00093 bool publicationRejectionHasMessage() const;
00094 bool canRemovePresencePublication() const;
00095 bool publicationRemovalHasMessage() const;
00096 PendingOperation *removePresencePublication(
00097 const QList<ContactPtr> &contacts,
00098 const QString &message = QString());
00099 PendingOperation *removeContacts(
00100 const QList<ContactPtr> &contacts,
00101 const QString &message = QString());
00102
00103 bool canBlockContacts() const;
00104 PendingOperation *blockContacts(
00105 const QList<ContactPtr> &contacts, bool value = true);
00106
00107 PendingContacts *contactsForHandles(const UIntList &handles,
00108 const Features &features = Features());
00109 PendingContacts *contactsForHandles(const ReferencedHandles &handles,
00110 const Features &features = Features());
00111 PendingContacts *contactsForHandles(const HandleIdentifierMap &handles,
00112 const Features &features = Features());
00113
00114 PendingContacts *contactsForIdentifiers(const QStringList &identifiers,
00115 const Features &features = Features());
00116
00117 PendingContacts *upgradeContacts(const QList<ContactPtr> &contacts,
00118 const Features &features);
00119
00120 ContactPtr lookupContactByHandle(uint handle);
00121
00122 void requestContactAvatar(Contact *contact);
00123
00124 Q_SIGNALS:
00125 void stateChanged(Tp::ContactListState state);
00126
00127 void presencePublicationRequested(const Tp::Contacts &contacts);
00128
00129
00130 void presencePublicationRequested(const Tp::Contacts &contacts, const QString &message);
00131 void presencePublicationRequested(const Tp::Contacts &contacts,
00132 const Tp::Channel::GroupMemberChangeDetails &details);
00133
00134 void groupAdded(const QString &group);
00135 void groupRenamed(const QString &oldGroup, const QString &newGroup);
00136 void groupRemoved(const QString &group);
00137
00138 void groupMembersChanged(const QString &group,
00139 const Tp::Contacts &groupMembersAdded,
00140 const Tp::Contacts &groupMembersRemoved,
00141 const Tp::Channel::GroupMemberChangeDetails &details);
00142
00143 void allKnownContactsChanged(const Tp::Contacts &contactsAdded,
00144 const Tp::Contacts &contactsRemoved,
00145 const Tp::Channel::GroupMemberChangeDetails &details);
00146
00147 protected:
00148
00149 void connectNotify(const char *);
00150
00151 private Q_SLOTS:
00152 TELEPATHY_QT4_NO_EXPORT void onAliasesChanged(const Tp::AliasPairList &);
00153 TELEPATHY_QT4_NO_EXPORT void doRequestAvatars();
00154 TELEPATHY_QT4_NO_EXPORT void onAvatarUpdated(uint, const QString &);
00155 TELEPATHY_QT4_NO_EXPORT void onAvatarRetrieved(uint, const QString &, const QByteArray &, const QString &);
00156 TELEPATHY_QT4_NO_EXPORT void onPresencesChanged(const Tp::SimpleContactPresences &);
00157 TELEPATHY_QT4_NO_EXPORT void onCapabilitiesChanged(const Tp::ContactCapabilitiesMap &);
00158 TELEPATHY_QT4_NO_EXPORT void onLocationUpdated(uint, const QVariantMap &);
00159 TELEPATHY_QT4_NO_EXPORT void onContactInfoChanged(uint, const Tp::ContactInfoFieldList &);
00160 TELEPATHY_QT4_NO_EXPORT void doRefreshInfo();
00161
00162 private:
00163 class PendingRefreshContactInfo;
00164 class Roster;
00165 friend class Connection;
00166 friend class Contact;
00167 friend class PendingContacts;
00168 friend class PendingRefreshContactInfo;
00169 friend class Roster;
00170
00171 TELEPATHY_QT4_NO_EXPORT ContactManager(Connection *parent);
00172
00173 TELEPATHY_QT4_NO_EXPORT ContactPtr ensureContact(const ReferencedHandles &handle,
00174 const Features &features,
00175 const QVariantMap &attributes);
00176 TELEPATHY_QT4_NO_EXPORT ContactPtr ensureContact(uint bareHandle,
00177 const QString &id, const Features &features);
00178
00179 TELEPATHY_QT4_NO_EXPORT static QString featureToInterface(const Feature &feature);
00180 TELEPATHY_QT4_NO_EXPORT void ensureTracking(const Feature &feature);
00181
00182 TELEPATHY_QT4_NO_EXPORT PendingOperation *introspectRoster();
00183 TELEPATHY_QT4_NO_EXPORT PendingOperation *introspectRosterGroups();
00184 TELEPATHY_QT4_NO_EXPORT void resetRoster();
00185
00186 TELEPATHY_QT4_NO_EXPORT PendingOperation *refreshContactInfo(Contact *contact);
00187
00188 struct Private;
00189 friend struct Private;
00190 Private *mPriv;
00191 };
00192
00193 }
00194
00195 #endif