From: <svn...@op...> - 2009-04-06 22:11:24
|
Author: henrik Date: Tue Apr 7 00:11:18 2009 New Revision: 5551 URL: http://www.opensync.org/changeset/5551 Log: 1) Currently DisplayName=FirstName+<SPACE>+LastName. Correction so the <SPACE> is only inserted if the both FirstName and LastName are not empty. 2) Only add attributes which have attributeType==ATTRIBUTE_EQUAL. Before we could have two emails with PREF set. Modified: plugins/mozilla-sync/trunk/src/thunderbird-card.cpp plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/1 plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/2 plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/3 Modified: plugins/mozilla-sync/trunk/src/thunderbird-card.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Mon Apr 6 22:21:25 2009 (r5550) +++ plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Tue Apr 7 00:11:18 2009 (r5551) @@ -489,6 +489,8 @@ rv=myCard->GetPropertyAsAString("LastName", ln); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::GetPropertyAsAString LastName"); +// TODO: if ( (nFirstName>0) && (nLastName>0) ) + nsString dn; dn.Assign(fn); dn.Append(0x20); @@ -507,10 +509,16 @@ PRUint32 nFirstName=NS_strlen(pruFirstName); PRUint32 nLastName=NS_strlen(pruLastName); PRUnichar *pruDisplayName = (PRUnichar*) NS_Alloc((nFirstName + nLastName + 2) * sizeof(PRUnichar)); - memcpy(pruDisplayName, pruFirstName, nFirstName * sizeof(PRUnichar)); - pruDisplayName[nFirstName] = 0x20; //Space - memcpy(pruDisplayName+nFirstName+1, pruLastName, nLastName * sizeof(PRUnichar)); - pruDisplayName[nFirstName + nLastName + 1] = 0; + PRUint32 nSpace=0; + if (nFirstName>0) { + memcpy(pruDisplayName, pruFirstName, nFirstName * sizeof(PRUnichar)); + if (nLastName>0) { + pruDisplayName[nFirstName] = 0x20; //Space + nSpace=1; + } + } + memcpy(pruDisplayName+nFirstName+nSpace, pruLastName, nLastName * sizeof(PRUnichar)); + pruDisplayName[nFirstName + nLastName + nSpace] = 0; rv=myCard->SetCardValue("DisplayName", pruDisplayName); MOZ_ERROR_CHECK_FALSE(rv, "nsIAbCard::SetCardValue DisplayName"); NS_Free(pruFirstName); @@ -749,10 +757,12 @@ for (pXmlAttributeDef=&(pXmlGroupDef->xmlAttributeDef[0]); pXmlAttributeDef->attributeType; pXmlAttributeDef++) { - rc = xmlTextWriterWriteAttribute(writer, - BAD_CAST pXmlAttributeDef->szAttribute, - BAD_CAST pXmlAttributeDef->szValue); - RC_ERROR_CHECK(buf,"xmlTextWriterWriteAttribute: Error at xmlTextWriterWriteAttribute\n"); + + if (pXmlAttributeDef->attributeType==ATTRIBUTE_EQUAL) + rc = xmlTextWriterWriteAttribute(writer, + BAD_CAST pXmlAttributeDef->szAttribute, + BAD_CAST pXmlAttributeDef->szValue); + RC_ERROR_CHECK(buf,"xmlTextWriterWriteAttribute: Error at xmlTextWriterWriteAttribute\n"); } } Modified: plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/1 ============================================================================== --- plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/1 Mon Apr 6 22:21:25 2009 (r5550) +++ plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/1 Tue Apr 7 00:11:18 2009 (r5551) @@ -5,7 +5,7 @@ ADR;WORK:;first work address second line;first work street 1;first work cit y;FFFF;11111111;first work country EMAIL;PREF:on...@ex... -EMAIL;PREF:fi...@ex... +EMAIL:fi...@ex... FN:one first N:first;one;;; ORG:first organization;first department @@ -15,4 +15,4 @@ TEL;FAX:111333 TITLE:first title URL:first.example.com -END:VCARD \ No newline at end of file +END:VCARD Modified: plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/2 ============================================================================== --- plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/2 Mon Apr 6 22:21:25 2009 (r5550) +++ plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/2 Tue Apr 7 00:11:18 2009 (r5551) @@ -6,7 +6,7 @@ ADR;WORK:;second work address second line;second work street 1;secondwork c ity;SSSS;22222222;second work country EMAIL;PREF:tw...@ex... -EMAIL;PREF:se...@ex... +EMAIL:se...@ex... FN:two second N:second;two;;; ORG:second organization;second department Modified: plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/3 ============================================================================== --- plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/3 Mon Apr 6 22:21:25 2009 (r5550) +++ plugins/mozilla-sync/trunk/tests/blackbox_test_abook_vcard_base/3 Tue Apr 7 00:11:18 2009 (r5551) @@ -5,7 +5,7 @@ ADR;WORK:;third work address second line;third work street 3;third work cit y;TTTT;33333333;third work country EMAIL;PREF:th...@ex... -EMAIL;PREF:th...@ex... +EMAIL:th...@ex... FN:three third N:third;three;;; ORG:third organization;third department @@ -15,4 +15,4 @@ TEL;FAX:333333 TITLE:third title URL:third.example.com -END:VCARD \ No newline at end of file +END:VCARD |