forked from bicomsystems/outcall2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContactManager.h
134 lines (90 loc) · 2.66 KB
/
ContactManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef CONTACTMANAGER_H
#define CONTACTMANAGER_H
#include "ContactDialog.h"
#include "SyncContactsThread.h"
#include <QHash>
#include <QSqlDatabase>
#include <QTimer>
class QString;
class SyncContactsThread;
class QTimer;
class AddOutlookContactThread : public QThread {
Q_OBJECT
public:
AddOutlookContactThread(QString numbers, QString fullName = "");
void stop();
signals:
void addingContactThreadFinished(bool bOK, QString info);
protected:
void run();
public slots:
private:
HINSTANCE m_hOutlookDLLInstance;
QString m_numbers;
QString m_fullName;
bool m_bStop;
};
class ViewOutlookContactThread : public QThread {
Q_OBJECT
public:
ViewOutlookContactThread(QString fullName, QString numbers = "");
void stop();
signals:
void viewingContactThreadFinished(bool bOK, QString info);
protected:
void run();
private:
HINSTANCE m_hOutlookDLLInstance;
QString m_numbers;
QString m_fullName;
bool m_bStop;
};
class Contact {
public:
Contact();
void addNumber(const QString &type, const QString &number);
QString name;
QString formattedDescription;
QHash<QString, QString> numbers;
};
class ContactManager : public QObject
{
Q_OBJECT
public:
explicit ContactManager(QObject *parent = 0);
~ContactManager();
void openContactDialog(QString name, QHash<QString, QString> numbers);
void activateDialog() const;
QString getDBPath() const;
QList<Contact*> getContacts();
void refreshContacts();
void stopSyncing();
Contact* findContact(QString name);
Contact* findContactByPhoneNumber(QString number);
void startRefreshTimer();
void addOutlookContact(QString numbers = "", QString fullName = "");
void viewOutlookContact(QString fullName, QString numbers = "");
protected:
void loadContacts();
void createDBTable(QString table, QString query);
private slots:
void loadingContactsThreadFinished(bool bOK, QString info);
void loadContactsThreadStarted();
void addingContactThreadFinished(bool bOK, QString info);
void onRefreshContactsTimer();
signals:
void contactsLoaded(QList<Contact*> &contacts);
void syncing(bool status);
private:
QSqlDatabase m_db;
SyncContactsThread m_LoadContactsThread;
QString DBPath;
QHash<QString, Contact*> m_contacts; // name -> Contact
QHash<QString, Contact*> m_PhoneNumbers; // number -> Contact (formatted phone numbers because of the performance)
QTimer m_RefreshContactsTimer;
ContactDialog *m_contactDialog;
QMutex m_LoadContactsMutex;
friend class SyncContactsThread;
};
extern ContactManager *g_pContactManager;
#endif // CONTACTMANAGER_H