|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #ifndef LOGSCONTACT_H |
|
18 #define LOGSCONTACT_H |
|
19 |
|
20 #include <QObject> |
|
21 #include <qtcontacts.h> |
|
22 #include <logsexport.h> |
|
23 |
|
24 //forward declarations |
|
25 class XQServiceRequest; |
|
26 class LogsDbConnector; |
|
27 class LogsEvent; |
|
28 |
|
29 QTM_USE_NAMESPACE |
|
30 |
|
31 /** |
|
32 * LogsContact can be used to modify or create a contact in phonebook |
|
33 * |
|
34 */ |
|
35 class LogsContact : public QObject |
|
36 { |
|
37 Q_OBJECT |
|
38 |
|
39 public: |
|
40 enum RequestType { |
|
41 TypeLogsContactOpen, //contact is in phonebook, can open it |
|
42 TypeLogsContactSave //contact isn't in phonebook, can save it |
|
43 }; |
|
44 |
|
45 public: |
|
46 |
|
47 explicit LogsContact(LogsEvent& event, LogsDbConnector& dbConnector); |
|
48 explicit LogsContact(const QString& number, |
|
49 LogsDbConnector& dbConnector, |
|
50 unsigned int contactId = 0); |
|
51 LOGSENGINE_EXPORT ~LogsContact(); |
|
52 |
|
53 /** |
|
54 * Returns allowed request type |
|
55 */ |
|
56 LOGSENGINE_EXPORT RequestType allowedRequestType(); |
|
57 |
|
58 bool isContactRequestAllowed(); |
|
59 |
|
60 public slots: |
|
61 |
|
62 /** |
|
63 * Launch phonebook view for modification of the contact. Will proceed |
|
64 * only if allowedRequestType() is TypeLogsContactOpen, otherwise returns false. |
|
65 * Emits openCompleted() signal, when contact modifications are done. |
|
66 * @return true if opening was called successfully |
|
67 */ |
|
68 LOGSENGINE_EXPORT bool open(); |
|
69 |
|
70 /** |
|
71 * Launch phonebook view for creation of a new contact. |
|
72 * Emits saveCompleted() signal, when contact saving is done. |
|
73 * @return true if adding was called successfully |
|
74 */ |
|
75 LOGSENGINE_EXPORT bool addNew(); |
|
76 |
|
77 /** |
|
78 * Launch phonebook view for updating of existing contact. |
|
79 * Emits saveCompeted() signal, when contact saving is done. |
|
80 * @return true if updating was called successfully |
|
81 */ |
|
82 LOGSENGINE_EXPORT bool updateExisting(); |
|
83 |
|
84 |
|
85 signals: |
|
86 |
|
87 /** |
|
88 * Indicates that contact modification completed |
|
89 * @param modified true if contact was modified, false - otherwise |
|
90 */ |
|
91 void openCompleted(bool modified); |
|
92 |
|
93 /** |
|
94 * Indicates that contact saving completed |
|
95 * @param modified true if contact was saved, false - otherwise |
|
96 */ |
|
97 void saveCompleted(bool modified); |
|
98 |
|
99 |
|
100 private slots: |
|
101 |
|
102 void handleRequestCompleted(const QVariant& result); |
|
103 |
|
104 |
|
105 private: |
|
106 |
|
107 /** |
|
108 * Finds contact from phonebook |
|
109 * @return contact |
|
110 */ |
|
111 QContact contact(); |
|
112 |
|
113 /** |
|
114 * Checks whether contact is in phonebook |
|
115 * @return true if contact is in phonebook |
|
116 */ |
|
117 bool isContactInPhonebook(); |
|
118 |
|
119 bool save(QString message); |
|
120 |
|
121 bool requestFetchService(QString message, |
|
122 const QList<QVariant> &arguments, |
|
123 bool sync = false ); |
|
124 |
|
125 |
|
126 private: //data |
|
127 |
|
128 LogsDbConnector& mDbConnector; |
|
129 QContact mContact; |
|
130 |
|
131 XQServiceRequest* mService; |
|
132 RequestType mCurrentRequest; |
|
133 QString mNumber; |
|
134 unsigned int mContactId; |
|
135 bool mSaveAsOnlineAccount; |
|
136 |
|
137 private: |
|
138 |
|
139 friend class UT_LogsContact; |
|
140 |
|
141 }; |
|
142 |
|
143 #endif // LOGSCONTACT_H |