File indexing completed on 2023-10-01 08:41:44

0001 /*
0002  * This file is part of telepathy-common-internals
0003  *
0004  * Copyright (C) 2012 David Edmundson <kde@davidedmundson.co.uk>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #ifndef GLOBALCONTACTMANAGER_H
0022 #define GLOBALCONTACTMANAGER_H
0023 
0024 #include <QObject>
0025 
0026 #include <TelepathyQt/Types>
0027 #include <TelepathyQt/ContactManager>
0028 
0029 #include <KTp/ktpcommoninternals_export.h>
0030 #include <KTp/contact.h>
0031 
0032 namespace KTp {
0033 
0034 class GlobalContactManagerPrivate;
0035 
0036 class KTPCOMMONINTERNALS_EXPORT GlobalContactManager : public QObject
0037 {
0038     Q_OBJECT
0039 public:
0040     explicit GlobalContactManager(const Tp::AccountManagerPtr &accountManager, QObject *parent = nullptr);
0041     ~GlobalContactManager() override;
0042 
0043     Tp::Contacts allKnownContacts() const;
0044     Tp::AccountPtr accountForConnection(const Tp::ConnectionPtr &connection) const;
0045     Tp::AccountPtr accountForContact(const Tp::ContactPtr &contact) const;
0046     Tp::AccountPtr accountForAccountId(const QString &accountId) const;
0047     Tp::AccountPtr accountForAccountPath(const QString &accountPath) const;
0048     KTp::ContactPtr contactForContactId(const QString &accountPath, const QString &contactId);
0049 
0050 Q_SIGNALS:
0051     void allKnownContactsChanged(const Tp::Contacts &contactsAdded, const Tp::Contacts &contactsRemoved);
0052     void presencePublicationRequested(const Tp::Contacts);
0053 
0054 private Q_SLOTS:
0055     void onAccountManagerReady(Tp::PendingOperation *op);
0056     void onNewAccount(const Tp::AccountPtr &account);
0057     void onConnectionChanged(const Tp::ConnectionPtr &connection);
0058     void onConnectionReady(Tp::PendingOperation *op);
0059     void onContactManagerStateChanged(Tp::ContactListState state);
0060 
0061 private:
0062     void onContactManagerStateChanged(const Tp::ContactManagerPtr &contactManager, Tp::ContactListState state);
0063 
0064     GlobalContactManagerPrivate *d;
0065 };
0066 }
0067 
0068 #endif // GLOBALCONTACTLIST_H