20 ContactsEngine::~ContactsEngine() |
20 ContactsEngine::~ContactsEngine() |
21 { |
21 { |
22 |
22 |
23 } |
23 } |
24 |
24 |
25 //void ContactsEngine::createManager() |
25 void ContactsEngine::createManagerSF() |
26 //{ |
26 { |
27 // // this->m_manager = new QContactManager("symbian"); |
27 // let's try the default. |
28 // // let's try the default. |
28 this->m_manager_sf = new QContactManager("memory"); |
29 // this->m_manager = new QContactManager(); |
29 // Debugger confirms this is hit, Qt Simulator doesn't display QMessageBox but |
30 //} |
30 // the associated control window shows it is the top level window. |
|
31 // emit this->errorOccurred(this->errorString(this->m_manager_sf->error())); |
|
32 } |
|
33 |
|
34 QString ContactsEngine::errorString(QContactManager::Error aErr) |
|
35 { |
|
36 QString err; |
|
37 switch(aErr) |
|
38 { |
|
39 case QContactManager::NoError: |
|
40 err = "No Error"; |
|
41 break; |
|
42 case QContactManager::DoesNotExistError: |
|
43 err = "Does Not Exist Error "; |
|
44 break; |
|
45 case QContactManager::AlreadyExistsError: |
|
46 err = "Already Exists Error"; |
|
47 break; |
|
48 case QContactManager::InvalidDetailError: |
|
49 err = "Invalid Detail Error"; |
|
50 break; |
|
51 case QContactManager::InvalidRelationshipError: |
|
52 err = "Invalid Relationship Error"; |
|
53 break; |
|
54 case QContactManager::LockedError: |
|
55 err = "Locked Error"; |
|
56 break; |
|
57 case QContactManager::DetailAccessError: |
|
58 err = "Detail Access Error"; |
|
59 break; |
|
60 case QContactManager::PermissionsError: |
|
61 err = "Permissions Error"; |
|
62 break; |
|
63 case QContactManager::OutOfMemoryError: |
|
64 err = "Out Of Memory Error"; |
|
65 break; |
|
66 case QContactManager::NotSupportedError: |
|
67 err = "Not Supported Error"; |
|
68 break; |
|
69 case QContactManager::BadArgumentError: |
|
70 err = "Bad Argument Error"; |
|
71 break; |
|
72 case QContactManager::UnspecifiedError: |
|
73 err = "Unspecified Error"; |
|
74 break; |
|
75 case QContactManager::VersionMismatchError: |
|
76 err = "Version Mismatch Error"; |
|
77 break; |
|
78 case QContactManager::LimitReachedError: |
|
79 err = "Limit Reached Error"; |
|
80 break; |
|
81 case QContactManager::InvalidContactTypeError: |
|
82 err = "Invalid Contact Type Error"; |
|
83 break; |
|
84 default: |
|
85 err = "Unknown Error"; |
|
86 break; |
|
87 } |
|
88 return err; |
|
89 } |
31 |
90 |
32 void ContactsEngine::createManager() |
91 void ContactsEngine::createManager() |
33 { |
92 { |
34 // adapted from http://wiki.forum.nokia.com/index.php/Finding_contact_manager_in_Qt |
93 // adapted from http://wiki.forum.nokia.com/index.php/Finding_contact_manager_in_Qt |
35 |
94 |
107 address->setLocality("Foster City"); // RFC 2426 - defines the difference locality and region. |
166 address->setLocality("Foster City"); // RFC 2426 - defines the difference locality and region. |
108 address->setStreet("1040 East Hillsdale Boulevard"); |
167 address->setStreet("1040 East Hillsdale Boulevard"); |
109 address->setPostcode("94404"); |
168 address->setPostcode("94404"); |
110 contact->saveDetail(address); |
169 contact->saveDetail(address); |
111 |
170 |
112 this->m_manager->saveContact(contact); |
171 this->m_manager_sf->saveContact(contact); |
|
172 qDebug() << "cm sf status: " << this->errorString(this->m_manager_sf->error()); |
|
173 |
113 // Note that the caller retains ownership of the detail. |
174 // Note that the caller retains ownership of the detail. |
114 delete dept; |
175 delete dept; |
115 while (!departmentName.isEmpty()) |
176 while (!departmentName.isEmpty()) |
116 departmentName.takeFirst(); |
177 departmentName.takeFirst(); |
117 delete number; |
178 delete number; |
139 address->setLocality("Foster City"); |
200 address->setLocality("Foster City"); |
140 address->setStreet("1030 East Hillsdale Boulevard"); |
201 address->setStreet("1030 East Hillsdale Boulevard"); |
141 address->setPostcode("94404"); |
202 address->setPostcode("94404"); |
142 contact->saveDetail(address); |
203 contact->saveDetail(address); |
143 |
204 |
144 this->m_manager->saveContact(contact); |
205 this->m_manager_sf->saveContact(contact); |
|
206 qDebug() << "cm sf status: " << this->errorString(this->m_manager_sf->error()); |
|
207 |
145 delete dept; |
208 delete dept; |
146 while (!departmentName.isEmpty()) |
209 while (!departmentName.isEmpty()) |
147 departmentName.takeFirst(); |
210 departmentName.takeFirst(); |
148 delete number; |
211 delete number; |
149 delete address; |
212 delete address; |
169 address->setLocality("Foster City"); |
232 address->setLocality("Foster City"); |
170 address->setStreet("1055 foster city blvd"); |
233 address->setStreet("1055 foster city blvd"); |
171 address->setPostcode("94404"); |
234 address->setPostcode("94404"); |
172 contact->saveDetail(address); |
235 contact->saveDetail(address); |
173 |
236 |
174 this->m_manager->saveContact(contact); |
237 this->m_manager_sf->saveContact(contact); |
|
238 qDebug() << "cm sf status: " << this->errorString(this->m_manager_sf->error()); |
|
239 |
175 delete dept; |
240 delete dept; |
176 while (!departmentName.isEmpty()) |
241 while (!departmentName.isEmpty()) |
177 departmentName.takeFirst(); |
242 departmentName.takeFirst(); |
178 delete number; |
243 delete number; |
179 delete address; |
244 delete address; |
199 address->setLocality("Menlo Park"); |
264 address->setLocality("Menlo Park"); |
200 address->setStreet("170 Middlefield Road"); |
265 address->setStreet("170 Middlefield Road"); |
201 address->setPostcode("94025"); |
266 address->setPostcode("94025"); |
202 contact->saveDetail(address); |
267 contact->saveDetail(address); |
203 |
268 |
204 this->m_manager->saveContact(contact); |
269 this->m_manager_sf->saveContact(contact); |
|
270 qDebug() << "cm sf status: " << this->errorString(this->m_manager_sf->error()); |
|
271 |
205 delete dept; |
272 delete dept; |
206 while (!departmentName.isEmpty()) |
273 while (!departmentName.isEmpty()) |
207 departmentName.takeFirst(); |
274 departmentName.takeFirst(); |
208 delete number; |
275 delete number; |
209 delete address; |
276 delete address; |
230 address->setLocality("Menlo Park"); |
297 address->setLocality("Menlo Park"); |
231 address->setStreet("701 Laurel Street"); |
298 address->setStreet("701 Laurel Street"); |
232 address->setPostcode("94025"); |
299 address->setPostcode("94025"); |
233 contact->saveDetail(address); |
300 contact->saveDetail(address); |
234 |
301 |
235 this->m_manager->saveContact(contact); |
302 this->m_manager_sf->saveContact(contact); |
|
303 qDebug() << "cm sf status: " << this->errorString(this->m_manager_sf->error()); |
|
304 |
236 delete dept; |
305 delete dept; |
237 while (!departmentName.isEmpty()) |
306 while (!departmentName.isEmpty()) |
238 departmentName.takeFirst(); |
307 departmentName.takeFirst(); |
239 delete number; |
308 delete number; |
240 delete address; |
309 delete address; |
300 QStringList mgrs = QContactManager::availableManagers(); |
369 QStringList mgrs = QContactManager::availableManagers(); |
301 qDebug() << "Enumerate available Contact Managers:" << endl; |
370 qDebug() << "Enumerate available Contact Managers:" << endl; |
302 foreach(QString m, mgrs) |
371 foreach(QString m, mgrs) |
303 { |
372 { |
304 qDebug() << "\tmgr: " << m << endl; |
373 qDebug() << "\tmgr: " << m << endl; |
305 this->dumpContactMgr(); |
|
306 } |
374 } |
307 qDebug() << endl; |
375 qDebug() << endl; |
308 } |
376 } |
309 |
377 |
310 // dump the current contact manager. |
378 // dump the current contact manager. |
311 void ContactsEngine::dumpContactMgr() |
379 void ContactsEngine::dumpContactMgr() |
312 { |
380 { |
313 qDebug() << "Dump Contact Manager:" << endl; |
381 qDebug() << "Dump Contact Manager(default):" << endl; |
314 if (this->m_manager) { |
382 if (this->m_manager) { |
315 qDebug() << "\tname: " << this->m_manager->managerName() << endl; |
383 qDebug() << "\tname: " << this->m_manager->managerName() << endl; |
316 qDebug() << "\tURI: " << this->m_manager->managerUri() << endl; |
384 qDebug() << "\tURI: " << this->m_manager->managerUri() << endl; |
317 qDebug() << "\tVersion: " << this->m_manager->managerVersion() << endl; |
385 qDebug() << "\tVersion: " << this->m_manager->managerVersion() << endl; |
318 qDebug() << "\tCount:" << this->m_manager->contacts().count() << endl; |
386 qDebug() << "\tCount:" << this->m_manager->contacts().count() << endl; |
319 } else { |
387 } else { |
320 qDebug() << "\t Contact Manager set to zero." << endl; |
388 qDebug() << "\t Contact Manager(default) set to zero." << endl; |
|
389 } |
|
390 qDebug() << endl; |
|
391 qDebug() << "Dump Contact Manager(SF Staff):" << endl; |
|
392 if (this->m_manager_sf) { |
|
393 qDebug() << "\tname: " << this->m_manager_sf->managerName() << endl; |
|
394 qDebug() << "\tURI: " << this->m_manager_sf->managerUri() << endl; |
|
395 qDebug() << "\tVersion: " << this->m_manager_sf->managerVersion() << endl; |
|
396 qDebug() << "\tCount:" << this->m_manager_sf->contacts().count() << endl; |
|
397 } else { |
|
398 qDebug() << "\t Contact Manager(SF Staff) set to zero." << endl; |
321 } |
399 } |
322 qDebug() << endl; |
400 qDebug() << endl; |
323 } |
401 } |
324 |
402 |
325 QVariant ContactsEngine::data(const QModelIndex &index, int role) const |
403 QVariant ContactsEngine::data(const QModelIndex &index, int role) const |