263 } |
263 } |
264 |
264 |
265 g_list_free(contactList); |
265 g_list_free(contactList); |
266 } |
266 } |
267 |
267 |
|
268 //TODO Use native filters |
268 QList<QContactLocalId> QContactABook::contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const |
269 QList<QContactLocalId> QContactABook::contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const |
269 { |
270 { |
270 QList<QContactLocalId> rtn; |
271 Q_UNUSED(sortOrders) |
271 |
272 Q_UNUSED(filter); |
272 // do this naively for now... |
|
273 *error = QContactManager::NoError; |
273 *error = QContactManager::NoError; |
274 QContactManager::Error tempError = QContactManager::NoError; |
274 return m_localIds.keys(); |
275 QList<QContactLocalId> allIds = m_localIds.keys(); |
|
276 QList<QContact> sortedAndFiltered; |
|
277 QContact *curr = 0; |
|
278 foreach (const QContactLocalId& currId, allIds) { |
|
279 curr = getQContact(currId, &tempError); |
|
280 if (tempError != QContactManager::NoError) |
|
281 *error = tempError; |
|
282 if (QContactManagerEngine::testFilter(filter, *curr)) { |
|
283 QContactManagerEngine::addSorted(&sortedAndFiltered, *curr, sortOrders); |
|
284 } |
|
285 delete curr; |
|
286 } |
|
287 |
|
288 foreach (const QContact& contact, sortedAndFiltered) { |
|
289 rtn.append(contact.localId()); |
|
290 } |
|
291 return rtn; |
|
292 |
275 |
293 /* |
276 /* |
294 // Sorting |
277 // Sorting |
295 //NOTE Native sorting is possible thanks to g_list_sort. |
278 //NOTE Native sorting is possible thanks to g_list_sort. |
296 // It's limited just to one filter. |
279 // It's limited just to one filter. |
323 |
306 |
324 // Non native sorting |
307 // Non native sorting |
325 return QContactManagerEngine::sortContacts(contacts, sortOrders); |
308 return QContactManagerEngine::sortContacts(contacts, sortOrders); |
326 } |
309 } |
327 |
310 |
328 EBookQuery* query = convert(filter); |
311 switch(filter.type()){ |
329 |
312 case QContactFilter::DefaultFilter: { |
330 GList* l = osso_abook_aggregator_find_contacts(m_abookAgregator, query); |
313 rtn = m_localIds.keys(); |
331 if (query) |
314 } break; |
332 e_book_query_unref(query); |
315 default: { |
333 |
316 EBookQuery* query = convert(filter); |
334 while (l){ |
317 GList* l = osso_abook_aggregator_find_contacts(m_abookAgregator, query); |
335 EContact *contact = E_CONTACT(l->data); |
318 if (query) |
336 const char* data = CONST_CHAR(e_contact_get_const(contact, E_CONTACT_UID)); |
319 e_book_query_unref(query); |
337 QByteArray localId(data); |
320 |
338 m_localIds << localId; |
321 while (l){ |
339 rtn.append(m_localIds[localId]); |
322 EContact *contact = E_CONTACT(l->data); |
340 QCM5_DEBUG << "eContactID " << localId << "has been stored in m_localIDs with key" << m_localIds[localId]; |
323 const char* data = CONST_CHAR(e_contact_get_const(contact, E_CONTACT_UID)); |
341 l = g_list_delete_link(l, l); |
324 QByteArray localId(data); |
342 } |
325 m_localIds << localId; |
343 |
326 rtn.append(m_localIds[localId]); |
|
327 QCM5_DEBUG << "eContactID " << localId << "has been stored in m_localIDs with key" << m_localIds[localId]; |
|
328 l = g_list_delete_link(l, l); |
|
329 } |
|
330 } |
|
331 } |
344 *error = QContactManager::NoError; |
332 *error = QContactManager::NoError; |
345 return rtn; |
333 return rtn; |
346 */ |
334 */ |
347 } |
335 } |
|
336 #include "qcontactdetail_p.h" |
348 |
337 |
349 QContact* QContactABook::getQContact(const QContactLocalId& contactId, QContactManager::Error* error) const |
338 QContact* QContactABook::getQContact(const QContactLocalId& contactId, QContactManager::Error* error) const |
350 { |
339 { |
351 QContact *rtn; |
340 QContact *rtn; |
352 OssoABookContact* aContact = getAContact(contactId, error); |
341 OssoABookContact* aContact = getAContact(contactId, error); |
355 return new QContact; |
344 return new QContact; |
356 } |
345 } |
357 |
346 |
358 //Convert aContact => qContact |
347 //Convert aContact => qContact |
359 rtn = convert(E_CONTACT(aContact)); |
348 rtn = convert(E_CONTACT(aContact)); |
|
349 |
360 QContactId cId; |
350 QContactId cId; |
361 cId.setLocalId(contactId); |
351 cId.setLocalId(contactId); |
362 rtn->setId(cId); |
352 rtn->setId(cId); |
|
353 |
|
354 //TEST BEGIN |
|
355 |
|
356 /* |
|
357 QContactDisplayLabel dl; |
|
358 dl.setValue(QContactDisplayLabel::FieldLabel, "LABEL"); |
|
359 QContactDetailPrivate::setAccessConstraints(&dl, QContactDetail::Irremovable | QContactDetail::ReadOnly); |
|
360 rtn->d->m_details.replace(0, dl); |
|
361 */ |
|
362 //TEST END |
363 return rtn; |
363 return rtn; |
364 } |
364 } |
365 |
365 |
366 static QContactManager::Error getErrorFromStatus(const EBookStatus status){ |
366 static QContactManager::Error getErrorFromStatus(const EBookStatus status){ |
367 switch (status) { |
367 switch (status) { |
576 contact->setId(cId); |
576 contact->setId(cId); |
577 if (m_saveJobSD->uid) |
577 if (m_saveJobSD->uid) |
578 free(m_saveJobSD->uid); |
578 free(m_saveJobSD->uid); |
579 |
579 |
580 return ok; |
580 return ok; |
|
581 } |
|
582 |
|
583 const QString QContactABook::getDisplayName(const QContact& contact) const{ |
|
584 //Get Osso ABook ID for the contact (stored as GUID detail) |
|
585 const char* acontactID = NULL; |
|
586 { |
|
587 QContactGuid g = contact.detail(QContactGuid::DefinitionName); |
|
588 acontactID = qPrintable(g.guid()); |
|
589 } |
|
590 |
|
591 if (!acontactID){ |
|
592 QCM5_DEBUG << "The contact has not been saved yet and it doesn't have any GUID"; |
|
593 return QString(); |
|
594 } |
|
595 |
|
596 //Get OssoABookContact |
|
597 OssoABookContact *acontact= NULL; |
|
598 { |
|
599 GList* l= NULL; |
|
600 l = osso_abook_aggregator_lookup(m_abookAgregator, acontactID); |
|
601 |
|
602 if (g_list_length(l) == 1) { |
|
603 acontact = A_CONTACT(l->data); |
|
604 } |
|
605 g_list_free(l); |
|
606 |
|
607 } |
|
608 |
|
609 if (!acontact){ |
|
610 QCM5_DEBUG << "AContact with ID:" << acontactID << "is null"; |
|
611 return QString(); |
|
612 } |
|
613 //Get Display name; |
|
614 const char* displayName = osso_abook_contact_get_display_name(acontact); |
|
615 |
|
616 return QString::fromUtf8(displayName); |
581 } |
617 } |
582 |
618 |
583 QContactLocalId QContactABook::selfContactId(QContactManager::Error* errors) const |
619 QContactLocalId QContactABook::selfContactId(QContactManager::Error* errors) const |
584 { |
620 { |
585 QContactLocalId id; |
621 QContactLocalId id; |
666 hash[QContactDisplayLabel::DefinitionName] = "full-name"; //hack |
702 hash[QContactDisplayLabel::DefinitionName] = "full-name"; //hack |
667 hash[QContactEmailAddress::DefinitionName] = "email"; |
703 hash[QContactEmailAddress::DefinitionName] = "email"; |
668 hash[QContactName::DefinitionName] = "full-name"; |
704 hash[QContactName::DefinitionName] = "full-name"; |
669 hash[QContactNickname::DefinitionName] = "nickname"; |
705 hash[QContactNickname::DefinitionName] = "nickname"; |
670 hash[QContactNote::DefinitionName] = "note"; |
706 hash[QContactNote::DefinitionName] = "note"; |
671 hash[QContactOrganization::DefinitionName] = "title"; |
707 hash[QContactOrganization::DefinitionName] = "org"; |
672 hash[QContactPhoneNumber::DefinitionName] = "phone"; |
708 hash[QContactPhoneNumber::DefinitionName] = "phone"; |
673 hash[QContactUrl::DefinitionName] = "homepage-url"; |
709 hash[QContactUrl::DefinitionName] = "homepage-url"; |
674 } |
710 } |
675 |
711 |
676 QString eDetail = hash[f.detailDefinitionName()]; |
712 QString eDetail = hash[f.detailDefinitionName()]; |
728 QCM5_DEBUG << "Filter not supported"; |
764 QCM5_DEBUG << "Filter not supported"; |
729 query = convert(QContactInvalidFilter()); |
765 query = convert(QContactInvalidFilter()); |
730 } |
766 } |
731 |
767 |
732 //Debugging |
768 //Debugging |
733 const char *queryString = e_book_query_to_string(query); |
769 if (QCM5_DEBUG_ENABLED){ |
734 QCM5_DEBUG << "QUERY" << queryString; |
770 const char *queryString = e_book_query_to_string(query); |
735 FREE(queryString); |
771 QCM5_DEBUG << "QUERY" << queryString; |
736 |
772 FREE(queryString); |
|
773 } |
737 return query; |
774 return query; |
738 } |
775 } |
739 |
776 |
740 QContact* QContactABook::convert(EContact *eContact) const |
777 QContact* QContactABook::convert(EContact *eContact) const |
741 { |
778 { |
972 map[QContactName::FieldPrefix] = eContactName->prefixes; |
1009 map[QContactName::FieldPrefix] = eContactName->prefixes; |
973 map[QContactName::FieldSuffix] = eContactName->suffixes; |
1010 map[QContactName::FieldSuffix] = eContactName->suffixes; |
974 e_contact_name_free (eContactName); |
1011 e_contact_name_free (eContactName); |
975 } else { |
1012 } else { |
976 //Looks that Maemo use just these two fields |
1013 //Looks that Maemo use just these two fields |
977 map[QContactName::FieldFirstName] = CONST_CHAR(e_contact_get_const(eContact, E_CONTACT_GIVEN_NAME)); |
1014 map[QContactName::FieldFirstName] = QString::fromUtf8(CONST_CHAR(e_contact_get_const(eContact, E_CONTACT_GIVEN_NAME))); |
978 map[QContactName::FieldLastName] = CONST_CHAR(e_contact_get_const(eContact, E_CONTACT_FAMILY_NAME)); |
1015 map[QContactName::FieldLastName] = QString::fromUtf8(CONST_CHAR(e_contact_get_const(eContact, E_CONTACT_FAMILY_NAME))); |
979 } |
1016 } |
980 setDetailValues(map, rtn); |
1017 setDetailValues(map, rtn); |
981 return rtn; |
1018 return rtn; |
982 } |
1019 } |
983 |
1020 |
984 QContactNickname* QContactABook::getNicknameDetail(EContact *eContact) const |
1021 QContactNickname* QContactABook::getNicknameDetail(EContact *eContact) const |
985 { |
1022 { |
986 QContactNickname* rtn = new QContactNickname; |
1023 QContactNickname* rtn = new QContactNickname; |
987 QVariantMap map; |
1024 QVariantMap map; |
988 map[QContactNickname::FieldNickname] = CONST_CHAR (e_contact_get_const(eContact, E_CONTACT_NICKNAME)); |
1025 map[QContactNickname::FieldNickname] = QString::fromUtf8(CONST_CHAR(e_contact_get_const(eContact, E_CONTACT_NICKNAME))); |
989 setDetailValues(map, rtn); |
1026 setDetailValues(map, rtn); |
990 return rtn; |
1027 return rtn; |
991 } |
1028 } |
992 |
1029 |
993 QList<QContactEmailAddress*> QContactABook::getEmailDetail(EContact *eContact) const |
1030 QList<QContactEmailAddress*> QContactABook::getEmailDetail(EContact *eContact) const |
1087 QContactGender* QContactABook::getGenderDetail(EContact *eContact) const |
1124 QContactGender* QContactABook::getGenderDetail(EContact *eContact) const |
1088 { |
1125 { |
1089 QContactGender* rtn = new QContactGender; |
1126 QContactGender* rtn = new QContactGender; |
1090 QVariantMap map; |
1127 QVariantMap map; |
1091 const char* g = CONST_CHAR(osso_abook_contact_get_value(eContact, "X-GENDER")); |
1128 const char* g = CONST_CHAR(osso_abook_contact_get_value(eContact, "X-GENDER")); |
1092 QString gender = QString::fromLatin1(g); |
1129 QString gender = g; |
1093 if (gender == "male") |
1130 if (gender == "male") |
1094 gender = "Male"; |
1131 gender = "Male"; |
1095 else if (gender == "female") |
1132 else if (gender == "female") |
1096 gender = "Female"; |
1133 gender = "Female"; |
1097 else if (gender == "unspecified") |
1134 else if (gender == "unspecified") |
1118 QContactNote* QContactABook::getNoteDetail(EContact *eContact) const |
1155 QContactNote* QContactABook::getNoteDetail(EContact *eContact) const |
1119 { |
1156 { |
1120 QContactNote* rtn = new QContactNote; |
1157 QContactNote* rtn = new QContactNote; |
1121 QVariantMap map; |
1158 QVariantMap map; |
1122 const char* note = CONST_CHAR(e_contact_get(eContact, E_CONTACT_NOTE)); |
1159 const char* note = CONST_CHAR(e_contact_get(eContact, E_CONTACT_NOTE)); |
1123 map[QContactNote::FieldNote] = QString::fromLatin1(note); |
1160 map[QContactNote::FieldNote] = QString::fromUtf8(note); |
1124 FREE(note); |
1161 FREE(note); |
1125 setDetailValues(map, rtn); |
1162 setDetailValues(map, rtn); |
1126 return rtn; |
1163 return rtn; |
1127 } |
1164 } |
1128 |
1165 |
1157 |
1194 |
1158 McProfile* id = osso_abook_contact_get_profile(rosterContact); |
1195 McProfile* id = osso_abook_contact_get_profile(rosterContact); |
1159 McAccount* account = osso_abook_contact_get_account(rosterContact); |
1196 McAccount* account = osso_abook_contact_get_account(rosterContact); |
1160 |
1197 |
1161 // Avoid to look for Roster contacts into the VCard |
1198 // Avoid to look for Roster contacts into the VCard |
1162 QString accountVCard = QString::fromLatin1(mc_profile_get_vcard_field(id)); |
1199 QString accountVCard = mc_profile_get_vcard_field(id); |
1163 evcardToSkip.removeOne(accountVCard); |
1200 evcardToSkip.removeOne(accountVCard); |
1164 |
1201 |
1165 // Presence |
1202 // Presence |
1166 OssoABookPresence *presence = OSSO_ABOOK_PRESENCE (rosterContact); |
1203 OssoABookPresence *presence = OSSO_ABOOK_PRESENCE (rosterContact); |
1167 TpConnectionPresenceType presenceType = osso_abook_presence_get_presence_type (presence); |
1204 TpConnectionPresenceType presenceType = osso_abook_presence_get_presence_type (presence); |
1201 if (attributeList) { |
1238 if (attributeList) { |
1202 for (node = attributeList; node != NULL; node = g_list_next (node)) { |
1239 for (node = attributeList; node != NULL; node = g_list_next (node)) { |
1203 EVCardAttribute* attr = (EVCardAttribute*)node->data; |
1240 EVCardAttribute* attr = (EVCardAttribute*)node->data; |
1204 if (!attr) |
1241 if (!attr) |
1205 continue; |
1242 continue; |
1206 QString attributeName = QString::fromLatin1(e_vcard_attribute_get_name(attr)); |
1243 QString attributeName = e_vcard_attribute_get_name(attr); |
1207 |
1244 |
1208 // Skip attributes processed scanning roster contacts. |
1245 // Skip attributes processed scanning roster contacts. |
1209 if (!evcardToSkip.contains(attributeName)) |
1246 if (!evcardToSkip.contains(attributeName)) |
1210 continue; |
1247 continue; |
1211 |
1248 |
1215 // If the parameter list lenght is 1, X-OSSO-VALID is not specified |
1252 // If the parameter list lenght is 1, X-OSSO-VALID is not specified |
1216 bool ossoValidIsOk = (g_list_length(params) == 1) ? true : false; |
1253 bool ossoValidIsOk = (g_list_length(params) == 1) ? true : false; |
1217 |
1254 |
1218 for (nodeP = params; nodeP != NULL; nodeP = g_list_next (nodeP)) { |
1255 for (nodeP = params; nodeP != NULL; nodeP = g_list_next (nodeP)) { |
1219 EVCardAttributeParam* p = (EVCardAttributeParam*) nodeP->data; |
1256 EVCardAttributeParam* p = (EVCardAttributeParam*) nodeP->data; |
1220 QString paramName = QString::fromLatin1(e_vcard_attribute_param_get_name(p)); |
1257 QString paramName = e_vcard_attribute_param_get_name(p); |
1221 bool attrIsType = false; |
1258 bool attrIsType = false; |
1222 bool attrIsOssoValid = false; |
1259 bool attrIsOssoValid = false; |
1223 |
1260 |
1224 //If type is empty check if the attribute is "TYPE" |
1261 //If type is empty check if the attribute is "TYPE" |
1225 if (type.isEmpty()) |
1262 if (type.isEmpty()) |
1234 } |
1271 } |
1235 |
1272 |
1236 GList *values = e_vcard_attribute_param_get_values(p); |
1273 GList *values = e_vcard_attribute_param_get_values(p); |
1237 GList *node; |
1274 GList *node; |
1238 for (node = values; node != NULL; node = g_list_next (node)) { |
1275 for (node = values; node != NULL; node = g_list_next (node)) { |
1239 QString attributeParameterValue = QString::fromLatin1(CONST_CHAR(node->data)); |
1276 QString attributeParameterValue = CONST_CHAR(node->data); |
1240 if (attrIsOssoValid) { |
1277 if (attrIsOssoValid) { |
1241 ossoValidIsOk = (attributeParameterValue == "yes")? true : false; |
1278 ossoValidIsOk = (attributeParameterValue == "yes")? true : false; |
1242 if (!ossoValidIsOk) { |
1279 if (!ossoValidIsOk) { |
1243 //qWarning() << "X-OSSO-VALID is false."; |
1280 //qWarning() << "X-OSSO-VALID is false."; |
1244 break; |
1281 break; |
1266 |
1303 |
1267 QContactOrganization* QContactABook::getOrganizationDetail(EContact *eContact) const |
1304 QContactOrganization* QContactABook::getOrganizationDetail(EContact *eContact) const |
1268 { |
1305 { |
1269 QContactOrganization* rtn = new QContactOrganization; |
1306 QContactOrganization* rtn = new QContactOrganization; |
1270 QVariantMap map; |
1307 QVariantMap map; |
1271 const char* title = CONST_CHAR(e_contact_get(eContact, E_CONTACT_ORG)); |
1308 const char* org = CONST_CHAR(e_contact_get(eContact, E_CONTACT_ORG)); |
1272 map[QContactOrganization::FieldTitle] = title; |
1309 map[QContactOrganization::FieldName] = QString::fromUtf8(org); |
1273 FREE(title); |
1310 FREE(org); |
1274 setDetailValues(map, rtn); |
1311 setDetailValues(map, rtn); |
1275 return rtn; |
1312 return rtn; |
1276 } |
1313 } |
1277 |
1314 |
1278 QList<QContactPhoneNumber*> QContactABook::getPhoneDetail(EContact *eContact) const |
1315 QList<QContactPhoneNumber*> QContactABook::getPhoneDetail(EContact *eContact) const |
1288 EVCardAttribute *attr = static_cast<EVCardAttribute*>(node->data); |
1325 EVCardAttribute *attr = static_cast<EVCardAttribute*>(node->data); |
1289 GList* p = e_vcard_attribute_get_param(attr, EVC_TYPE); |
1326 GList* p = e_vcard_attribute_get_param(attr, EVC_TYPE); |
1290 |
1327 |
1291 //Set Contexts and SubTypes |
1328 //Set Contexts and SubTypes |
1292 while (p) { |
1329 while (p) { |
1293 QString value = QString::fromLatin1(CONST_CHAR(p->data)); |
1330 QString value = CONST_CHAR(p->data); |
1294 |
1331 |
1295 if (value == "HOME") |
1332 if (value == "HOME") |
1296 phoneNumber->setContexts(QContactDetail::ContextHome); |
1333 phoneNumber->setContexts(QContactDetail::ContextHome); |
1297 else if (value == "WORK") |
1334 else if (value == "WORK") |
1298 phoneNumber->setContexts(QContactDetail::ContextWork); |
1335 phoneNumber->setContexts(QContactDetail::ContextWork); |
1340 |
1377 |
1341 McProfile* id = osso_abook_contact_get_profile(rosterContact); |
1378 McProfile* id = osso_abook_contact_get_profile(rosterContact); |
1342 McAccount* account = osso_abook_contact_get_account(rosterContact); |
1379 McAccount* account = osso_abook_contact_get_account(rosterContact); |
1343 |
1380 |
1344 // Avoid to look for Roster contacts into the VCard |
1381 // Avoid to look for Roster contacts into the VCard |
1345 QString accountVCard = QString::fromLatin1(mc_profile_get_vcard_field(id)); |
1382 QString accountVCard = mc_profile_get_vcard_field(id); |
1346 evcardToSkip.removeOne(accountVCard); |
1383 evcardToSkip.removeOne(accountVCard); |
1347 |
1384 |
1348 // Presence |
1385 // Presence |
1349 OssoABookPresence *presence = OSSO_ABOOK_PRESENCE (rosterContact); |
1386 OssoABookPresence *presence = OSSO_ABOOK_PRESENCE (rosterContact); |
1350 TpConnectionPresenceType presenceType = osso_abook_presence_get_presence_type (presence); |
1387 TpConnectionPresenceType presenceType = osso_abook_presence_get_presence_type (presence); |
1365 } |
1402 } |
1366 |
1403 |
1367 QVariantMap map; // XXX FIXME |
1404 QVariantMap map; // XXX FIXME |
1368 map[QContactPresence::FieldNickname] = osso_abook_contact_get_display_name(rosterContact); |
1405 map[QContactPresence::FieldNickname] = osso_abook_contact_get_display_name(rosterContact); |
1369 map[QContactPresence::FieldPresenceState] = presenceTypeEnum; |
1406 map[QContactPresence::FieldPresenceState] = presenceTypeEnum; |
1370 map[QContactPresence::FieldPresenceStateText] = QString::fromLatin1(osso_abook_presence_get_presence_status_message(presence)); |
1407 map[QContactPresence::FieldPresenceStateText] = QString::fromUtf8(osso_abook_presence_get_presence_status_message(presence)); |
1371 map[QContactPresence::FieldLinkedDetailUris] = mc_profile_get_unique_name(id); //use the unique name as a detail uri of the online account. |
1408 map[QContactPresence::FieldLinkedDetailUris] = mc_profile_get_unique_name(id); //use the unique name as a detail uri of the online account. |
1372 map["AccountPath"] = account->name; //MCAccount name: variable part of the D-Bus object path. |
1409 map["AccountPath"] = account->name; //MCAccount name: variable part of the D-Bus object path. |
1373 |
1410 |
1374 setDetailValues(map, rtn); |
1411 setDetailValues(map, rtn); |
1375 } |
1412 } |
1386 if (attributeList) { |
1423 if (attributeList) { |
1387 for (node = attributeList; node != NULL; node = g_list_next (node)) { |
1424 for (node = attributeList; node != NULL; node = g_list_next (node)) { |
1388 EVCardAttribute* attr = (EVCardAttribute*)node->data; |
1425 EVCardAttribute* attr = (EVCardAttribute*)node->data; |
1389 if (!attr) |
1426 if (!attr) |
1390 continue; |
1427 continue; |
1391 QString attributeName = QString::fromLatin1(e_vcard_attribute_get_name(attr)); |
1428 QString attributeName = e_vcard_attribute_get_name(attr); |
1392 |
1429 |
1393 // Skip attributes processed scanning roster contacts. |
1430 // Skip attributes processed scanning roster contacts. |
1394 if (!evcardToSkip.contains(attributeName)) |
1431 if (!evcardToSkip.contains(attributeName)) |
1395 continue; |
1432 continue; |
1396 |
1433 |
1400 // If the parameter list lenght is 1, X-OSSO-VALID is not specified |
1437 // If the parameter list lenght is 1, X-OSSO-VALID is not specified |
1401 bool ossoValidIsOk = (g_list_length(params) == 1) ? true : false; |
1438 bool ossoValidIsOk = (g_list_length(params) == 1) ? true : false; |
1402 |
1439 |
1403 for (nodeP = params; nodeP != NULL; nodeP = g_list_next (nodeP)) { |
1440 for (nodeP = params; nodeP != NULL; nodeP = g_list_next (nodeP)) { |
1404 EVCardAttributeParam* p = (EVCardAttributeParam*) nodeP->data; |
1441 EVCardAttributeParam* p = (EVCardAttributeParam*) nodeP->data; |
1405 QString paramName = QString::fromLatin1(e_vcard_attribute_param_get_name(p)); |
1442 QString paramName = e_vcard_attribute_param_get_name(p); |
1406 bool attrIsType = false; |
1443 bool attrIsType = false; |
1407 bool attrIsOssoValid = false; |
1444 bool attrIsOssoValid = false; |
1408 |
1445 |
1409 //If type is empty check if the attribute is "TYPE" |
1446 //If type is empty check if the attribute is "TYPE" |
1410 if (type.isEmpty()) |
1447 if (type.isEmpty()) |
1419 } |
1456 } |
1420 |
1457 |
1421 GList *values = e_vcard_attribute_param_get_values(p); |
1458 GList *values = e_vcard_attribute_param_get_values(p); |
1422 GList *node; |
1459 GList *node; |
1423 for (node = values; node != NULL; node = g_list_next (node)) { |
1460 for (node = values; node != NULL; node = g_list_next (node)) { |
1424 QString attributeParameterValue = QString::fromLatin1(CONST_CHAR(node->data)); |
1461 QString attributeParameterValue = CONST_CHAR(node->data); |
1425 if (attrIsOssoValid) { |
1462 if (attrIsOssoValid) { |
1426 ossoValidIsOk = (attributeParameterValue == "yes")? true : false; |
1463 ossoValidIsOk = (attributeParameterValue == "yes")? true : false; |
1427 if (!ossoValidIsOk) { |
1464 if (!ossoValidIsOk) { |
1428 //qWarning() << "X-OSSO-VALID is false."; |
1465 //qWarning() << "X-OSSO-VALID is false."; |
1429 break; |
1466 break; |
1436 } |
1473 } |
1437 |
1474 |
1438 if (ossoValidIsOk && !type.isEmpty()) { |
1475 if (ossoValidIsOk && !type.isEmpty()) { |
1439 QContactPresence* rtn = new QContactPresence; |
1476 QContactPresence* rtn = new QContactPresence; |
1440 QVariantMap map; |
1477 QVariantMap map; |
1441 map[QContactPresence::FieldNickname] = QString::fromLatin1(e_vcard_attribute_get_value(attr)); |
1478 map[QContactPresence::FieldNickname] = QString::fromUtf8(e_vcard_attribute_get_value(attr)); |
1442 map[QContactPresence::FieldLinkedDetailUris] = type; // XXX FIXME |
1479 map[QContactPresence::FieldLinkedDetailUris] = type; // XXX FIXME |
1443 setDetailValues(map, rtn); |
1480 setDetailValues(map, rtn); |
1444 rtnList << rtn; |
1481 rtnList << rtn; |
1445 } |
1482 } |
1446 } |
1483 } |
1766 image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); |
1803 image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); |
1767 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(image.bits(), GDK_COLORSPACE_RGB, |
1804 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(image.bits(), GDK_COLORSPACE_RGB, |
1768 image.hasAlphaChannel(), 8, |
1805 image.hasAlphaChannel(), 8, |
1769 image.width(), image.height(), |
1806 image.width(), image.height(), |
1770 image.bytesPerLine(), 0, 0); |
1807 image.bytesPerLine(), 0, 0); |
1771 osso_abook_contact_set_pixbuf((OssoABookContact*)aContact, pixbuf, book, 0); |
1808 osso_abook_contact_set_pixbuf((OssoABookContact*)aContact, pixbuf, 0, 0); |
1772 g_object_unref(pixbuf); |
1809 g_object_unref(pixbuf); |
1773 } |
1810 } |
1774 |
1811 |
1775 void QContactABook::setAvatarDetail(const OssoABookContact* aContact, const QContactAvatar& detail) const |
1812 void QContactABook::setAvatarDetail(const OssoABookContact* aContact, const QContactAvatar& detail) const |
1776 { |
1813 { |
1790 // image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); |
1827 // image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); |
1791 // GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(image.bits(), GDK_COLORSPACE_RGB, |
1828 // GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(image.bits(), GDK_COLORSPACE_RGB, |
1792 // image.hasAlphaChannel(), 8, |
1829 // image.hasAlphaChannel(), 8, |
1793 // image.width(), image.height(), |
1830 // image.width(), image.height(), |
1794 // image.bytesPerLine(), 0, 0); |
1831 // image.bytesPerLine(), 0, 0); |
1795 // osso_abook_contact_set_pixbuf((OssoABookContact*)aContact, pixbuf, book, 0); |
1832 // osso_abook_contact_set_pixbuf((OssoABookContact*)aContact, pixbuf, 0, 0); |
1796 // g_object_unref(pixbuf); |
1833 // g_object_unref(pixbuf); |
1797 } |
1834 } |
1798 |
1835 |
1799 void QContactABook::setBirthdayDetail(const OssoABookContact* aContact, const QContactBirthday& detail) const |
1836 void QContactABook::setBirthdayDetail(const OssoABookContact* aContact, const QContactBirthday& detail) const |
1800 { |
1837 { |
1905 void QContactABook::setOrganizationDetail(const OssoABookContact* aContact, const QContactOrganization& detail) const |
1942 void QContactABook::setOrganizationDetail(const OssoABookContact* aContact, const QContactOrganization& detail) const |
1906 { |
1943 { |
1907 if (!aContact) return; |
1944 if (!aContact) return; |
1908 |
1945 |
1909 QStringList attrValues; |
1946 QStringList attrValues; |
1910 attrValues << detail.value(QContactOrganization::FieldTitle); |
1947 attrValues << detail.value(QContactOrganization::FieldName); |
1911 |
1948 |
1912 addAttributeToAContact(aContact, EVC_ORG, attrValues); |
1949 addAttributeToAContact(aContact, EVC_ORG, attrValues); |
1913 } |
1950 } |
1914 |
1951 |
1915 void QContactABook::setPhoneDetail(const OssoABookContact* aContact, const QContactPhoneNumber& detail) const |
1952 void QContactABook::setPhoneDetail(const OssoABookContact* aContact, const QContactPhoneNumber& detail) const |