File indexing completed on 2023-10-03 04:18:20
0001 /* 0002 Copyright (C) 2014 David Edmundson <kde@davidedmundson.co.uk> 0003 Copyright (C) 2014 Alexandr Akulich <akulichalexander@gmail.com> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Lesser General Public 0007 License as published by the Free Software Foundation; either 0008 version 2.1 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Lesser General Public License for more details. 0014 0015 You should have received a copy of the GNU Lesser General Public 0016 License along with this library; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 */ 0019 0020 #ifndef CONTACTCACHE_H 0021 #define CONTACTCACHE_H 0022 0023 #include <QObject> 0024 #include <QSqlDatabase> 0025 #include <QStringList> 0026 #include <TelepathyQt/Types> 0027 0028 namespace Tp { 0029 class PendingOperation; 0030 } 0031 0032 QT_BEGIN_NAMESPACE 0033 class QSqlQuery; 0034 QT_END_NAMESPACE 0035 0036 class ContactCache : public QObject 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 ContactCache(QObject *parent = 0); 0042 0043 private Q_SLOTS: 0044 void onAccountManagerReady(Tp::PendingOperation *op); 0045 void onNewAccount(const Tp::AccountPtr &account); 0046 void onAccountRemoved(); 0047 void onContactManagerStateChanged(); 0048 void onAccountConnectionChanged(const Tp::ConnectionPtr &connection); 0049 void onAllKnownContactsChanged(const Tp::Contacts &added, const Tp::Contacts &removed); 0050 0051 private: 0052 void connectToAccount(const Tp::AccountPtr &account); 0053 bool accountIsInteresting(const Tp::AccountPtr &account) const; 0054 void syncContactsOfAccount(const Tp::AccountPtr &account); 0055 void checkContactManagerState(const Tp::ContactManagerPtr &contactManager); 0056 0057 int askIdFromGroup(const QString &groupName); 0058 void bindContactToQuery(QSqlQuery *query, const Tp::ContactPtr &contact); 0059 QSqlDatabase m_db; 0060 QStringList m_groups; 0061 }; 0062 0063 #endif // CONTACTCACHE_H