1 /*
2  * This file is part of telepathy-common-internals
3  *
4  * Copyright (C) 2012 David Edmundson <kde@davidedmundson.co.uk>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 #ifndef GLOBALCONTACTMANAGER_H
22 #define GLOBALCONTACTMANAGER_H
23 
24 #include <QObject>
25 
26 #include <TelepathyQt/Types>
27 #include <TelepathyQt/ContactManager>
28 
29 #include <KTp/ktpcommoninternals_export.h>
30 #include <KTp/contact.h>
31 
32 namespace KTp {
33 
34 class GlobalContactManagerPrivate;
35 
36 class KTPCOMMONINTERNALS_EXPORT GlobalContactManager : public QObject
37 {
38     Q_OBJECT
39 public:
40     explicit GlobalContactManager(const Tp::AccountManagerPtr &accountManager, QObject *parent = nullptr);
41     ~GlobalContactManager() override;
42 
43     Tp::Contacts allKnownContacts() const;
44     Tp::AccountPtr accountForConnection(const Tp::ConnectionPtr &connection) const;
45     Tp::AccountPtr accountForContact(const Tp::ContactPtr &contact) const;
46     Tp::AccountPtr accountForAccountId(const QString &accountId) const;
47     Tp::AccountPtr accountForAccountPath(const QString &accountPath) const;
48     KTp::ContactPtr contactForContactId(const QString &accountPath, const QString &contactId);
49 
50 Q_SIGNALS:
51     void allKnownContactsChanged(const Tp::Contacts &contactsAdded, const Tp::Contacts &contactsRemoved);
52     void presencePublicationRequested(const Tp::Contacts);
53 
54 private Q_SLOTS:
55     void onAccountManagerReady(Tp::PendingOperation *op);
56     void onNewAccount(const Tp::AccountPtr &account);
57     void onConnectionChanged(const Tp::ConnectionPtr &connection);
58     void onConnectionReady(Tp::PendingOperation *op);
59     void onContactManagerStateChanged(Tp::ContactListState state);
60 
61 private:
62     void onContactManagerStateChanged(const Tp::ContactManagerPtr &contactManager, Tp::ContactListState state);
63 
64     GlobalContactManagerPrivate *d;
65 };
66 }
67 
68 #endif // GLOBALCONTACTLIST_H
69