| 1 |
/* |
| 2 |
* Copyright (C) 2015 Canonical, Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#ifndef SIMCARDCONTACTS_H |
| 18 |
#define SIMCARDCONTACTS_H |
| 19 |
|
| 20 |
#include <QObject> |
| 21 |
#include <QMutex> |
| 22 |
|
| 23 |
#include <qofonomanager.h> |
| 24 |
#include <qofonophonebook.h> |
| 25 |
#include <qofonomodem.h> |
| 26 |
|
| 27 |
class SimCardContacts : public QObject |
| 28 |
{ |
| 29 |
Q_OBJECT |
| 30 |
Q_PROPERTY(QString contacts READ contacts NOTIFY contactsChanged) |
| 31 |
Q_PROPERTY(QUrl vcardFile READ vcardFile NOTIFY contactsChanged) |
| 32 |
Q_PROPERTY(bool hasContacts READ hasContacts NOTIFY contactsChanged) |
| 33 |
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged) |
| 34 |
|
| 35 |
public: |
| 36 |
SimCardContacts(QObject *parent=0); |
| 37 |
~SimCardContacts(); |
| 38 |
|
| 39 |
QString contacts() const; |
| 40 |
QUrl vcardFile() const; |
| 41 |
bool hasContacts() const; |
| 42 |
bool busy() const; |
| 43 |
|
| 44 |
Q_INVOKABLE void unlockModem(const QString &modemPath); |
| 45 |
|
| 46 |
Q_SIGNALS: |
| 47 |
void contactsChanged(); |
| 48 |
void importFail(); |
| 49 |
void busyChanged(); |
| 50 |
|
| 51 |
private Q_SLOTS: |
| 52 |
void onPhoneBookIsValidChanged(bool isValid); |
| 53 |
void onPhoneBookImported(const QString &vcardData); |
| 54 |
void onPhoneBookImportFail(); |
| 55 |
void onManagerChanged(); |
| 56 |
void onModemsChanged(); |
| 57 |
void reload(); |
| 58 |
|
| 59 |
private: |
| 60 |
QScopedPointer<QOfonoManager> m_ofonoManager; |
| 61 |
QSet<QOfonoPhonebook*> m_pendingPhoneBooks; |
| 62 |
QSet<QOfonoModem*> m_availableModems; |
| 63 |
QTemporaryFile *m_dataFile; |
| 64 |
QStringList m_vcards; |
| 65 |
QMutex m_importing; |
| 66 |
QTimer m_modemsChangedTimer; |
| 67 |
bool m_importingFlag; |
| 68 |
|
| 69 |
bool hasPhoneBook(QOfonoModem *modem); |
| 70 |
void writeData(); |
| 71 |
void reloadContactsFromModem(QOfonoModem* modem); |
| 72 |
void cancel(); |
| 73 |
void startImport(); |
| 74 |
void importDone(); |
| 75 |
bool importPhoneBook(QOfonoModem *modem); |
| 76 |
void importPhoneBook(QOfonoPhonebook *phoneBook); |
| 77 |
}; |
| 78 |
|
| 79 |
#endif |