1 // ContactDataObject-Save.cpp - Client Data Object.
3 // (c) 2012-2016 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
20 #include "../../version.h"
22 ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
24 ContactSaveStatus SaveDataStatus = CONTACTSAVE_UNITTESTFAIL;
26 // Write the header for the vCard data file.
28 SaveData->Append("BEGIN:VCARD\n");
29 SaveData->Append("VERSION:4.0\n");
31 // Write the product ID.
35 SaveData->Append("PRODID:-//Xestia//Address Book Unit Testing//KW\n");
39 SaveData->Append(wxT("PRODID:-//Xestia//Address Book Version "));
40 SaveData->Append(wxT(XSDAB_VERSION));
41 SaveData->Append(wxT("//KW\n"));
45 wxString ProcessData = "";
49 if (UIDToken.size() > 0){
51 ProcessData.Append("UID:");
52 ProcessData.Append(UIDToken);
53 ProcessData.Append("\n");
54 SaveData->Append(ProcessData);
63 case CONTACTKIND_NONE:
65 case CONTACTKIND_INDIVIDUAL:
66 SaveData->Append("KIND:individual\n");
68 case CONTACTKIND_GROUP:
69 SaveData->Append("KIND:group\n");
71 case CONTACTKIND_ORGANISATION:
72 SaveData->Append("KIND:org\n");
74 case CONTACTKIND_LOCATION:
75 SaveData->Append("KIND:location\n");
86 for (std::map<int, wxString>::iterator XMLIter = XMLList.begin();
87 XMLIter != XMLList.end(); XMLIter++){
89 ProcessData.Append("XML");
91 if (XMLListAltID[XMLIter->first].size() > 0){
93 ProcessData.Append(";ALTID=");
94 ProcessData.Append(XMLListAltID[XMLIter->first]);
98 ProcessData.Append(":");
99 ProcessData.Append(XMLIter->second);
100 ProcessData.Append("\n");
102 ProcessData = OutputText(&ProcessData);
104 SaveData->Append(ProcessData);
111 SaveSource(&SourceList, &SourceListAltID,
112 &SourceListPID, &SourceListType,
113 &SourceListMediatype, &SourceListPref,
114 &SourceListTokens, SaveData);
116 // Process CLIENTPIDMAP.
118 for (std::map<int, wxString>::iterator CPIDIter = ClientPIDList.begin();
119 CPIDIter != ClientPIDList.end(); CPIDIter++){
121 ProcessData.Append("CLIENTPIDMAP");
123 if (ClientPIDListTokens[CPIDIter->first].size() > 0){
125 ProcessData.Append(";");
126 ProcessData.Append(ClientPIDListTokens[CPIDIter->first]);
130 ProcessData.Append(":");
131 ProcessData.Append(CPIDIter->second);
132 ProcessData.Append("\n");
134 ProcessData = OutputText(&ProcessData);
136 SaveData->Append(ProcessData);
143 for (std::map<int, wxString>::iterator FNIter = FullNamesList.begin();
144 FNIter != FullNamesList.end(); FNIter++){
146 ProcessData.Append("FN");
148 // Check if there is a value for TYPE.
150 if (FullNamesListType[FNIter->first].size() > 0){
152 ProcessData.Append(";TYPE=");
153 ProcessData.Append(FullNamesListType[FNIter->first]);
157 // Check if there is a value for LANGUAGE.
159 if (FullNamesListLanguage[FNIter->first].size() > 0){
161 ProcessData.Append(";LANGUAGE=");
162 ProcessData.Append(FullNamesListLanguage[FNIter->first]);
166 // Check if there is a value for ALTID.
168 if (FullNamesListAltID[FNIter->first].size() > 0){
170 ProcessData.Append(";ALTID=");
171 ProcessData.Append(FullNamesListAltID[FNIter->first]);
175 // Check if there is a value for PID.
177 if (FullNamesListPID[FNIter->first].size() > 0){
179 ProcessData.Append(";PID=");
180 ProcessData.Append(FullNamesListPID[FNIter->first]);
184 // Check if there is a value for PREF.
186 if (FullNamesListPref[FNIter->first] > 0){
188 ProcessData.Append(";PREF=");
189 ProcessData.Append(wxString::Format("%i", FullNamesListPref[FNIter->first]));
193 // Check if there is a value for tokens.
195 if (FullNamesListTokens[FNIter->first].size() > 0){
197 ProcessData.Append(";");
198 ProcessData.Append(FullNamesListTokens[FNIter->first]);
202 ProcessData.Append(":");
203 ProcessData.Append(FNIter->second);
204 ProcessData.Append("\n");
206 ProcessData = OutputText(&ProcessData);
208 SaveData->Append(ProcessData);
215 SaveNickname(&GeneralNicknamesList, &GeneralNicknamesListAltID,
216 &GeneralNicknamesListPID, &GeneralNicknamesListType,
217 &GeneralNicknamesListLanguage, &GeneralNicknamesListPref,
218 &GeneralNicknamesListTokens, SaveData, "");
219 SaveNickname(&HomeNicknamesList, &HomeNicknamesListAltID,
220 &HomeNicknamesListPID, &HomeNicknamesListType,
221 &HomeNicknamesListLanguage, &HomeNicknamesListPref,
222 &HomeNicknamesListTokens, SaveData, "home");
223 SaveNickname(&BusinessNicknamesList, &BusinessNicknamesListAltID,
224 &BusinessNicknamesListPID, &BusinessNicknamesListType,
225 &BusinessNicknamesListLanguage, &BusinessNicknamesListPref,
226 &BusinessNicknamesListTokens, SaveData, "work");
230 SaveTitle(&GeneralTitleList, &GeneralTitleListLanguage,
231 &GeneralTitleListAltID, &GeneralTitleListPID,
232 &GeneralTitleListType, &GeneralTitleListPref,
233 &GeneralTitleListTokens, SaveData, "");
234 SaveTitle(&HomeTitleList, &HomeTitleListLanguage,
235 &HomeTitleListAltID, &HomeTitleListPID,
236 &HomeTitleListType, &HomeTitleListPref,
237 &HomeTitleListTokens, SaveData, "home");
238 SaveTitle(&BusinessTitleList, &BusinessTitleListLanguage,
239 &BusinessTitleListAltID, &BusinessTitleListPID,
240 &BusinessTitleListType, &BusinessTitleListPref,
241 &BusinessTitleListTokens, SaveData, "work");
245 SaveTimezone(&GeneralTZList, &GeneralTZListAltID,
246 &GeneralTZListPID, &GeneralTZListType,
247 &GeneralTZListMediatype, &GeneralTZListPref,
248 &GeneralTZListTokens, SaveData, "");
249 SaveTimezone(&HomeTZList, &HomeTZListAltID,
250 &HomeTZListPID, &HomeTZListType,
251 &HomeTZListMediatype, &HomeTZListPref,
252 &HomeTZListTokens, SaveData, "home");
253 SaveTimezone(&BusinessTZList, &BusinessTZListAltID,
254 &BusinessTZListPID, &BusinessTZListType,
255 &BusinessTZListMediatype, &BusinessTZListPref,
256 &BusinessTZListTokens, SaveData, "work");
260 SaveAddress(&GeneralAddressList, &GeneralAddressListTown,
261 &GeneralAddressListCounty, &GeneralAddressListPostCode,
262 &GeneralAddressListCountry, &GeneralAddressListLabel,
263 &GeneralAddressListLang, &GeneralAddressListAltID,
264 &GeneralAddressListPID, &GeneralAddressListGeo,
265 &GeneralAddressListTimezone, &GeneralAddressListType,
266 &GeneralAddressListMediatype, &GeneralAddressListPref,
267 &GeneralAddressListTokens, SaveData, "");
268 SaveAddress(&HomeAddressList, &HomeAddressListTown,
269 &HomeAddressListCounty, &HomeAddressListPostCode,
270 &HomeAddressListCountry, &HomeAddressListLabel,
271 &HomeAddressListLang, &HomeAddressListAltID,
272 &HomeAddressListPID, &HomeAddressListGeo,
273 &HomeAddressListTimezone, &HomeAddressListType,
274 &HomeAddressListMediatype, &HomeAddressListPref,
275 &HomeAddressListTokens, SaveData, "home");
276 SaveAddress(&BusinessAddressList, &BusinessAddressListTown,
277 &BusinessAddressListCounty, &BusinessAddressListPostCode,
278 &BusinessAddressListCountry, &BusinessAddressListLabel,
279 &BusinessAddressListLang, &BusinessAddressListAltID,
280 &BusinessAddressListPID, &BusinessAddressListGeo,
281 &BusinessAddressListTimezone, &BusinessAddressListType,
282 &BusinessAddressListMediatype, &BusinessAddressListPref,
283 &BusinessAddressListTokens, SaveData, "work");
287 SaveEmail(&GeneralEmailList, &GeneralEmailListAltID,
288 &GeneralEmailListPID, &GeneralEmailListType,
289 &GeneralEmailListPref, &GeneralEmailListTokens,
291 SaveEmail(&HomeEmailList, &HomeEmailListAltID,
292 &HomeEmailListPID, &HomeEmailListType,
293 &HomeEmailListPref, &HomeEmailListTokens,
295 SaveEmail(&BusinessEmailList, &BusinessEmailListAltID,
296 &BusinessEmailListPID, &BusinessEmailListType,
297 &BusinessEmailListPref, &BusinessEmailListTokens,
300 // TODO: Process IMPP.
302 // TODO: Process TEL.
306 SaveLanguage(&GeneralLanguageList, &GeneralLanguageListAltID,
307 &GeneralLanguageListPID, &GeneralLanguageListType,
308 &GeneralLanguageListPref, &GeneralLanguageListTokens,
310 SaveLanguage(&HomeLanguageList, &HomeLanguageListAltID,
311 &HomeLanguageListPID, &HomeLanguageListType,
312 &HomeLanguageListPref, &HomeLanguageListTokens,
314 SaveLanguage(&BusinessLanguageList, &BusinessLanguageListAltID,
315 &BusinessLanguageListPID, &BusinessLanguageListType,
316 &BusinessLanguageListPref, &BusinessLanguageListTokens,
321 SaveGeoposition(&GeneralGeographyList, &GeneralGeographyListAltID,
322 &GeneralGeographyListPID, &GeneralGeographyListType,
323 &GeneralGeographyListMediatype, &GeneralGeographyListDataType,
324 &GeneralGeographyListPref, &GeneralGeographyListTokens,
326 SaveGeoposition(&HomeGeographyList, &HomeGeographyListAltID,
327 &HomeGeographyListPID, &HomeGeographyListType,
328 &HomeGeographyListMediatype, &HomeGeographyListDataType,
329 &HomeGeographyListPref, &HomeGeographyListTokens,
331 SaveGeoposition(&BusinessGeographyList, &BusinessGeographyListAltID,
332 &BusinessGeographyListPID, &BusinessGeographyListType,
333 &BusinessGeographyListMediatype, &BusinessGeographyListDataType,
334 &BusinessGeographyListPref, &BusinessGeographyListTokens,
341 for (std::map<int, wxString>::iterator RelatedIter = GeneralRelatedList.begin();
342 RelatedIter != GeneralRelatedList.end(); RelatedIter++){
344 ProcessData.Append("RELATED");
346 // Check if there is a value for TYPE.
348 if (GeneralRelatedListRelType[RelatedIter->first].size() > 0){
350 wxString RelatedType = "";
352 ProcessData.Append(";TYPE=");
354 if (GeneralRelatedListRelType[RelatedIter->first] == _("Contact")){
356 RelatedType = wxT("contact");
358 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Acquaintance")){
360 RelatedType = wxT("acquaintance");
362 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Friend")){
364 RelatedType = wxT("friend");
366 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Met")){
368 RelatedType = wxT("met");
370 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Co-worker")){
372 RelatedType = wxT("co-worker");
374 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Colleague")){
376 RelatedType = wxT("colleague");
378 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Co-resident")){
380 RelatedType = wxT("co-resident");
382 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Neighbour")){
384 RelatedType = wxT("neighbor");
386 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Child")){
388 RelatedType = wxT("child");
390 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Parent")){
392 RelatedType = wxT("parent");
394 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Sibling")){
396 RelatedType = wxT("sibling");
398 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Spouse")){
400 RelatedType = wxT("spouse");
402 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Kin")){
404 RelatedType = wxT("kin");
406 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Muse")){
408 RelatedType = wxT("muse");
410 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Crush")){
412 RelatedType = wxT("crush");
414 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Date")){
416 RelatedType = wxT("date");
418 } else if (GeneralRelatedListRelType[RelatedIter->first]== _("Sweetheart")){
420 RelatedType = wxT("sweetheart");
422 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Me")){
424 RelatedType = wxT("me");
426 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Agent")){
428 RelatedType = wxT("agent");
430 } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Emergency")){
432 RelatedType = wxT("emergency");
436 RelatedType = GeneralRelatedListRelType[RelatedIter->first];
440 ProcessData.Append(RelatedType);
444 // Check if there is a value for LANGUAGE.
446 if (GeneralRelatedListLanguage[RelatedIter->first].size() > 0){
448 ProcessData.Append(";LANGUAGE=");
449 ProcessData.Append(GeneralRelatedListLanguage[RelatedIter->first]);
453 // Check if there is a value for ALTID.
455 if (GeneralRelatedListAltID[RelatedIter->first].size() > 0){
457 ProcessData.Append(";ALTID=");
458 ProcessData.Append(GeneralRelatedListAltID[RelatedIter->first]);
462 // Check if there is a value for PID.
464 if (GeneralRelatedListPID[RelatedIter->first].size() > 0){
466 ProcessData.Append(";PID=");
467 ProcessData.Append(GeneralRelatedListPID[RelatedIter->first]);
471 // Check if there is a value for PREF.
473 if (GeneralRelatedListPref[RelatedIter->first] > 0){
475 ProcessData.Append(";PREF=");
476 ProcessData.Append(wxString::Format("%i", GeneralRelatedListPref[RelatedIter->first]));
480 // Check if there is a value for tokens.
482 if (GeneralRelatedListTokens[RelatedIter->first].size() > 0){
484 ProcessData.Append(";");
485 ProcessData.Append(GeneralRelatedListTokens[RelatedIter->first]);
489 ProcessData.Append(":");
490 ProcessData.Append(RelatedIter->second);
491 ProcessData.Append("\n");
493 ProcessData = OutputText(&ProcessData);
495 SaveData->Append(ProcessData);
502 SaveURL(&GeneralWebsiteList, &GeneralWebsiteListAltID,
503 &GeneralWebsiteListPID, &GeneralWebsiteListType,
504 &GeneralWebsiteListMediatype, &GeneralWebsiteListPref,
505 &GeneralWebsiteListTokens, SaveData, "");
506 SaveURL(&HomeWebsiteList, &HomeWebsiteListAltID,
507 &HomeWebsiteListPID, &HomeWebsiteListType,
508 &HomeWebsiteListMediatype, &HomeWebsiteListPref,
509 &HomeWebsiteListTokens, SaveData, "home");
510 SaveURL(&BusinessWebsiteList, &BusinessWebsiteListAltID,
511 &BusinessWebsiteListPID, &BusinessWebsiteListType,
512 &BusinessWebsiteListMediatype, &BusinessWebsiteListPref,
513 &BusinessWebsiteListTokens, SaveData, "work");
517 SaveRole(&GeneralRoleList, &GeneralRoleListLanguage,
518 &GeneralRoleListAltID, &GeneralRoleListPID,
519 &GeneralRoleListType, &GeneralRoleListPref,
520 &GeneralRoleListTokens, SaveData, "");
521 SaveRole(&HomeRoleList, &HomeRoleListLanguage,
522 &HomeRoleListAltID, &HomeRoleListPID,
523 &HomeRoleListType, &HomeRoleListPref,
524 &HomeRoleListTokens, SaveData, "home");
525 SaveRole(&BusinessRoleList, &BusinessRoleListLanguage,
526 &BusinessRoleListAltID, &BusinessRoleListPID,
527 &BusinessRoleListType, &BusinessRoleListPref,
528 &BusinessRoleListTokens, SaveData, "work");
532 SaveOrganisation(&GeneralOrganisationsList, &GeneralOrganisationsListAltID,
533 &GeneralOrganisationsListPID, &GeneralOrganisationsListLanguage,
534 &GeneralOrganisationsListSortAs, &GeneralOrganisationsListType,
535 &GeneralOrganisationsListPref, &GeneralOrganisationsListTokens,
537 SaveOrganisation(&HomeOrganisationsList, &HomeOrganisationsListAltID,
538 &HomeOrganisationsListPID, &HomeOrganisationsListLanguage,
539 &HomeOrganisationsListSortAs, &HomeOrganisationsListType,
540 &HomeOrganisationsListPref, &HomeOrganisationsListTokens,
542 SaveOrganisation(&BusinessOrganisationsList, &BusinessOrganisationsListAltID,
543 &BusinessOrganisationsListPID, &BusinessOrganisationsListLanguage,
544 &BusinessOrganisationsListSortAs, &BusinessOrganisationsListType,
545 &BusinessOrganisationsListPref, &BusinessOrganisationsListTokens,
550 SaveNote(&GeneralNoteList, &GeneralNoteListLanguage,
551 &GeneralNoteListAltID, &GeneralNoteListPID,
552 &GeneralNoteListType, &GeneralNoteListPref,
553 &GeneralNoteListTokens, SaveData, "");
554 SaveNote(&HomeNoteList, &HomeNoteListLanguage,
555 &HomeNoteListAltID, &HomeNoteListPID,
556 &HomeNoteListType, &HomeNoteListPref,
557 &HomeNoteListTokens, SaveData, "home");
558 SaveNote(&BusinessNoteList, &BusinessNoteListLanguage,
559 &BusinessNoteListAltID, &BusinessNoteListPID,
560 &BusinessNoteListType, &BusinessNoteListPref,
561 &BusinessNoteListTokens, SaveData, "work");
563 // Write the end part of the vCard data file.
565 SaveData->Append("END:VCARD");
567 SaveDataStatus = CONTACTSAVE_OK;
569 return SaveDataStatus;
573 void ContactDataObject::SaveTitle(map<int, wxString> *TitleList, map<int, wxString> *TitleListLanguage,
574 map<int, wxString> *TitleListAltID, map<int, wxString> *TitleListPID,
575 map<int, wxString> *TitleListType, map<int, int> *TitleListPref,
576 map<int, wxString> *TitleListTokens, wxString *SaveData, wxString DataType){
578 wxString ProcessData = "";
580 for (std::map<int, wxString>::iterator TitleIter = TitleList->begin();
581 TitleIter != TitleList->end(); TitleIter++){
583 ProcessData.Append("TITLE");
585 // Check if there is a value for TYPE.
587 if (DataType.size() > 0){
589 ProcessData.Append(";TYPE=");
590 ProcessData.Append(DataType);
594 // Check if there is a value for ALTID.
596 if ((*TitleListAltID)[TitleIter->first].size() > 0){
598 ProcessData.Append(";ALTID=");
599 ProcessData.Append((*TitleListAltID)[TitleIter->first]);
603 // Check if there is a value for LANGUAGE.
605 if ((*TitleListLanguage)[TitleIter->first].size() > 0){
607 ProcessData.Append(";LANGUAGE=");
608 ProcessData.Append((*TitleListLanguage)[TitleIter->first]);
612 // Check if there is a value for PID.
614 if ((*TitleListPID)[TitleIter->first].size() > 0){
616 ProcessData.Append(";PID=");
617 ProcessData.Append((*TitleListPID)[TitleIter->first]);
621 // Check if there is a value for PREF.
623 if ((*TitleListPref)[TitleIter->first] > 0){
625 ProcessData.Append(";PREF=");
626 ProcessData.Append(wxString::Format("%i", (*TitleListPref)[TitleIter->first]));
630 // Check if there is a value for tokens.
632 if ((*TitleListTokens)[TitleIter->first].size() > 0){
634 ProcessData.Append(";");
635 ProcessData.Append((*TitleListTokens)[TitleIter->first]);
639 ProcessData.Append(":");
640 ProcessData.Append(TitleIter->second);
641 ProcessData.Append("\n");
643 ProcessData = OutputText(&ProcessData);
645 SaveData->Append(ProcessData);
652 void ContactDataObject::SaveSource(map<int, wxString> *SourceList, map<int, wxString> *SourceListAltID,
653 map<int, wxString> *SourceListPID, map<int, wxString> *SourceListType,
654 map<int, wxString> *SourceListMediatype, map<int, int> *SourceListPref,
655 map<int, wxString> *SourceListTokens, wxString *SaveData){
657 wxString ProcessData = "";
659 for (std::map<int, wxString>::iterator SourceIter = SourceList->begin();
660 SourceIter != SourceList->end(); SourceIter++){
662 ProcessData.Append("SOURCE");
664 // Check if there is a value for TYPE.
666 if ((*SourceListType)[SourceIter->first].size() > 0){
668 ProcessData.Append(";TYPE=");
669 ProcessData.Append((*SourceListType)[SourceIter->first]);
673 // Check if there is a value for ALTID.
675 if ((*SourceListAltID)[SourceIter->first].size() > 0){
677 ProcessData.Append(";ALTID=");
678 ProcessData.Append((*SourceListAltID)[SourceIter->first]);
682 // Check if there is a value for MEDIATYPE.
684 if ((*SourceListMediatype)[SourceIter->first].size() > 0){
686 ProcessData.Append(";MEDIATYPE=");
687 ProcessData.Append((*SourceListMediatype)[SourceIter->first]);
691 // Check if there is a value for PID.
693 if ((*SourceListPID)[SourceIter->first].size() > 0){
695 ProcessData.Append(";PID=");
696 ProcessData.Append((*SourceListPID)[SourceIter->first]);
700 // Check if there is a value for PREF.
702 if ((*SourceListPref)[SourceIter->first] > 0){
704 ProcessData.Append(";PREF=");
705 ProcessData.Append(wxString::Format("%i", (*SourceListPref)[SourceIter->first]));
709 // Check if there is a value for tokens.
711 if ((*SourceListTokens)[SourceIter->first].size() > 0){
713 ProcessData.Append(";");
714 ProcessData.Append((*SourceListTokens)[SourceIter->first]);
718 ProcessData.Append(":");
719 ProcessData.Append(SourceIter->second);
720 ProcessData.Append("\n");
722 ProcessData = OutputText(&ProcessData);
724 SaveData->Append(ProcessData);
731 void ContactDataObject::SaveNickname(map<int, wxString> *NicknameList, map<int, wxString> *NicknameListAltID,
732 map<int, wxString> *NicknameListPID, map<int, wxString> *NicknameListType,
733 map<int, wxString> *NicknameListLanguage, map<int, int> *NicknameListPref,
734 map<int, wxString> *NicknameListTokens, wxString *SaveData, wxString DataType){
736 wxString ProcessData = "";
738 for (std::map<int, wxString>::iterator NicknameIter = NicknameList->begin();
739 NicknameIter != NicknameList->end(); NicknameIter++){
741 ProcessData.Append("NICKNAME");
743 // Check if there is a value for TYPE.
745 if (DataType.size() > 0){
747 ProcessData.Append(";TYPE=");
748 ProcessData.Append(DataType);
752 // Check if there is a value for ALTID.
754 if ((*NicknameListAltID)[NicknameIter->first].size() > 0){
756 ProcessData.Append(";ALTID=");
757 ProcessData.Append((*NicknameListAltID)[NicknameIter->first]);
761 // Check if there is a value for MEDIATYPE.
763 if ((*NicknameListLanguage)[NicknameIter->first].size() > 0){
765 ProcessData.Append(";LANGUAGE=");
766 ProcessData.Append((*NicknameListLanguage)[NicknameIter->first]);
770 // Check if there is a value for PID.
772 if ((*NicknameListPID)[NicknameIter->first].size() > 0){
774 ProcessData.Append(";PID=");
775 ProcessData.Append((*NicknameListPID)[NicknameIter->first]);
779 // Check if there is a value for PREF.
781 if ((*NicknameListPref)[NicknameIter->first] > 0){
783 ProcessData.Append(";PREF=");
784 ProcessData.Append(wxString::Format("%i", (*NicknameListPref)[NicknameIter->first]));
788 // Check if there is a value for tokens.
790 if ((*NicknameListTokens)[NicknameIter->first].size() > 0){
792 ProcessData.Append(";");
793 ProcessData.Append((*NicknameListTokens)[NicknameIter->first]);
797 ProcessData.Append(":");
798 ProcessData.Append(NicknameIter->second);
799 ProcessData.Append("\n");
801 ProcessData = OutputText(&ProcessData);
803 SaveData->Append(ProcessData);
810 void ContactDataObject::SaveTimezone(map<int, wxString> *TZList, map<int, wxString> *TZListAltID,
811 map<int, wxString> *TZListPID, map<int, wxString> *TZListType,
812 map<int, wxString> *TZListMediatype, map<int, int> *TZListPref,
813 map<int, wxString> *TZListTokens, wxString *SaveData, wxString DataType){
815 wxString ProcessData = "";
817 for (std::map<int, wxString>::iterator TZIter = TZList->begin();
818 TZIter != TZList->end(); TZIter++){
820 ProcessData.Append("TZ");
822 // Check if there is a value for TYPE.
824 if (DataType.size() > 0){
826 ProcessData.Append(";TYPE=");
827 ProcessData.Append(DataType);
831 // Check if there is a value for ALTID.
833 if ((*TZListAltID)[TZIter->first].size() > 0){
835 ProcessData.Append(";ALTID=");
836 ProcessData.Append((*TZListAltID)[TZIter->first]);
840 // Check if there is a value for MEDIATYPE.
842 if ((*TZListMediatype)[TZIter->first].size() > 0){
844 ProcessData.Append(";MEDIATYPE=");
845 ProcessData.Append((*TZListMediatype)[TZIter->first]);
849 // Check if there is a value for PID.
851 if ((*TZListPID)[TZIter->first].size() > 0){
853 ProcessData.Append(";PID=");
854 ProcessData.Append((*TZListPID)[TZIter->first]);
858 // Check if there is a value for PREF.
860 if ((*TZListPref)[TZIter->first] > 0){
862 ProcessData.Append(";PREF=");
863 ProcessData.Append(wxString::Format("%i", (*TZListPref)[TZIter->first]));
867 // Check if there is a value for tokens.
869 if ((*TZListTokens)[TZIter->first].size() > 0){
871 ProcessData.Append(";");
872 ProcessData.Append((*TZListTokens)[TZIter->first]);
876 ProcessData.Append(":");
877 ProcessData.Append(TZIter->second);
878 ProcessData.Append("\n");
880 ProcessData = OutputText(&ProcessData);
882 SaveData->Append(ProcessData);
889 void ContactDataObject::SaveAddress(map<int, wxString> *AddressList, map<int, wxString> *AddressListTown,
890 map<int, wxString> *AddressListCounty, map<int, wxString> *AddressListPostCode,
891 map<int, wxString> *AddressListCountry, map<int, wxString> *AddressListLabel,
892 map<int, wxString> *AddressListLang, map<int, wxString> *AddressListAltID,
893 map<int, wxString> *AddressListPID, map<int, wxString> *AddressListGeo,
894 map<int, wxString> *AddressListTimezone, map<int, wxString> *AddressListType,
895 map<int, wxString> *AddressListMediatype, map<int, int> *AddressListPref,
896 map<int, wxString> *AddressListTokens, wxString *SaveData, wxString DataType){
898 wxString ProcessData = "";
900 for (std::map<int, wxString>::iterator AddressIter = AddressList->begin();
901 AddressIter != AddressList->end(); AddressIter++){
903 ProcessData.Append("ADR");
905 // Check if there is a value for TYPE.
907 if (DataType.size() > 0){
909 ProcessData.Append(";TYPE=");
910 ProcessData.Append(DataType);
914 // Check if there is a value for ALTID.
916 if ((*AddressListAltID)[AddressIter->first].size() > 0){
918 ProcessData.Append(";ALTID=");
919 ProcessData.Append((*AddressListAltID)[AddressIter->first]);
923 // Check if there is a value for GEO.
925 if ((*AddressListGeo)[AddressIter->first].size() > 0){
927 ProcessData.Append(";GEO=\"");
928 ProcessData.Append((*AddressListGeo)[AddressIter->first]);
929 ProcessData.Append("\"");
933 // Check if there is a value for LABEL.
935 if ((*AddressListLabel)[AddressIter->first].size() > 0){
937 wxString AddressProcessed = "";
938 AddressProcessed = (*AddressListLabel)[AddressIter->first];
940 AddressProcessed.Replace("\n", "\\n", true);
942 ProcessData.Append(";LABEL=");
943 ProcessData.Append(AddressProcessed);
947 // Check if there is a value for LANGUAGE.
949 if ((*AddressListLang)[AddressIter->first].size() > 0){
951 ProcessData.Append(";LANGUAGE=");
952 ProcessData.Append((*AddressListLang)[AddressIter->first]);
956 // Check if there is a value for MEDIATYPE.
958 if ((*AddressListMediatype)[AddressIter->first].size() > 0){
960 ProcessData.Append(";MEDIATYPE=");
961 ProcessData.Append((*AddressListMediatype)[AddressIter->first]);
965 // Check if there is a value for PID.
967 if ((*AddressListPID)[AddressIter->first].size() > 0){
969 ProcessData.Append(";PID=");
970 ProcessData.Append((*AddressListPID)[AddressIter->first]);
974 // Check if there is a value for PREF.
976 if ((*AddressListPref)[AddressIter->first] > 0){
978 ProcessData.Append(";PREF=");
979 ProcessData.Append(wxString::Format("%i", (*AddressListPref)[AddressIter->first]));
983 // Check if there is a value for TZ.
985 if ((*AddressListTimezone)[AddressIter->first].size() > 0){
987 ProcessData.Append(";TZ=");
988 ProcessData.Append((*AddressListTimezone)[AddressIter->first]);
992 // Check if there is a value for tokens.
994 if ((*AddressListTokens)[AddressIter->first].size() > 0){
996 ProcessData.Append(";");
997 ProcessData.Append((*AddressListTokens)[AddressIter->first]);
1001 // Build the address.
1003 ProcessData.Append(":;;");
1004 ProcessData.Append((*AddressList)[AddressIter->first]);
1005 ProcessData.Append(";");
1006 ProcessData.Append((*AddressListTown)[AddressIter->first]);
1007 ProcessData.Append(";");
1008 ProcessData.Append((*AddressListCounty)[AddressIter->first]);
1009 ProcessData.Append(";");
1010 ProcessData.Append((*AddressListPostCode)[AddressIter->first]);
1011 ProcessData.Append(";");
1012 ProcessData.Append((*AddressListCountry)[AddressIter->first]);
1013 ProcessData.Append("\n");
1015 ProcessData = OutputText(&ProcessData);
1017 SaveData->Append(ProcessData);
1018 ProcessData.clear();
1024 void ContactDataObject::SaveEmail(map<int, wxString> *EmailList, map<int, wxString> *EmailListAltID,
1025 map<int, wxString> *EmailListPID, map<int, wxString> *EmailListType,
1026 map<int, int> *EmailListPref, map<int, wxString> *EmailListTokens,
1027 wxString *SaveData, wxString DataType){
1029 wxString ProcessData = "";
1031 for (std::map<int, wxString>::iterator EmailIter = EmailList->begin();
1032 EmailIter != EmailList->end(); EmailIter++){
1034 ProcessData.Append("EMAIL");
1036 // Check if there is a value for TYPE.
1038 if (DataType.size() > 0){
1040 ProcessData.Append(";TYPE=");
1041 ProcessData.Append(DataType);
1045 // Check if there is a value for ALTID.
1047 if ((*EmailListAltID)[EmailIter->first].size() > 0){
1049 ProcessData.Append(";ALTID=");
1050 ProcessData.Append((*EmailListAltID)[EmailIter->first]);
1054 // Check if there is a value for PID.
1056 if ((*EmailListPID)[EmailIter->first].size() > 0){
1058 ProcessData.Append(";PID=");
1059 ProcessData.Append((*EmailListPID)[EmailIter->first]);
1063 // Check if there is a value for PREF.
1065 if ((*EmailListPref)[EmailIter->first] > 0){
1067 ProcessData.Append(";PREF=");
1068 ProcessData.Append(wxString::Format("%i", (*EmailListPref)[EmailIter->first]));
1072 // Check if there is a value for tokens.
1074 if ((*EmailListTokens)[EmailIter->first].size() > 0){
1076 ProcessData.Append(";");
1077 ProcessData.Append((*EmailListTokens)[EmailIter->first]);
1081 ProcessData.Append(":");
1082 ProcessData.Append(EmailIter->second);
1083 ProcessData.Append("\n");
1085 ProcessData = OutputText(&ProcessData);
1087 SaveData->Append(ProcessData);
1088 ProcessData.clear();
1094 void ContactDataObject::SaveLanguage(map<int, wxString> *LanguageList, map<int, wxString> *LanguageListAltID,
1095 map<int, wxString> *LanguageListPID, map<int, wxString> *LanguageListType,
1096 map<int, int> *LangaugeListPref, map<int, wxString> *LanguageListTokens,
1097 wxString *SaveData, wxString DataType){
1099 wxString ProcessData = "";
1101 for (std::map<int, wxString>::iterator LanguageIter = LanguageList->begin();
1102 LanguageIter != LanguageList->end(); LanguageIter++){
1104 ProcessData.Append("LANG");
1106 // Check if there is a value for TYPE.
1108 if (DataType.size() > 0){
1110 ProcessData.Append(";TYPE=");
1111 ProcessData.Append(DataType);
1115 // Check if there is a value for ALTID.
1117 if ((*LanguageListAltID)[LanguageIter->first].size() > 0){
1119 ProcessData.Append(";ALTID=");
1120 ProcessData.Append((*LanguageListAltID)[LanguageIter->first]);
1124 // Check if there is a value for PID.
1126 if ((*LanguageListPID)[LanguageIter->first].size() > 0){
1128 ProcessData.Append(";PID=");
1129 ProcessData.Append((*LanguageListPID)[LanguageIter->first]);
1133 // Check if there is a value for PREF.
1135 if ((*LangaugeListPref)[LanguageIter->first] > 0){
1137 ProcessData.Append(";PREF=");
1138 ProcessData.Append(wxString::Format("%i", (*LangaugeListPref)[LanguageIter->first]));
1142 // Check if there is a value for tokens.
1144 if ((*LanguageListTokens)[LanguageIter->first].size() > 0){
1146 ProcessData.Append(";");
1147 ProcessData.Append((*LanguageListTokens)[LanguageIter->first]);
1151 ProcessData.Append(":");
1152 ProcessData.Append(LanguageIter->second);
1153 ProcessData.Append("\n");
1155 ProcessData = OutputText(&ProcessData);
1157 SaveData->Append(ProcessData);
1158 ProcessData.clear();
1164 void ContactDataObject::SaveGeoposition(map<int, wxString> *GeographyList, map<int, wxString> *GeographyListAltID,
1165 map<int, wxString> *GeographyListPID, map<int, wxString> *GeographyListType,
1166 map<int, wxString> *GeographyListMediatype, map<int, wxString> *GeographyListDataType,
1167 map<int, int> *GeographyListPref, map<int, wxString> *GeographyListTokens,
1168 wxString *SaveData, wxString DataType){
1170 wxString ProcessData = "";
1172 for (std::map<int, wxString>::iterator GeographyIter = GeographyList->begin();
1173 GeographyIter != GeographyList->end(); GeographyIter++){
1175 ProcessData.Append("GEO");
1177 // Check if there is a value for TYPE.
1179 if (DataType.size() > 0){
1181 ProcessData.Append(";TYPE=");
1182 ProcessData.Append(DataType);
1186 // Check if there is a value for ALTID.
1188 if ((*GeographyListAltID)[GeographyIter->first].size() > 0){
1190 ProcessData.Append(";ALTID=");
1191 ProcessData.Append((*GeographyListAltID)[GeographyIter->first]);
1195 // Check if there is a value for MEDIATYPE.
1197 if ((*GeographyListMediatype)[GeographyIter->first].size() > 0){
1199 ProcessData.Append(";MEDIATYPE=");
1200 ProcessData.Append((*GeographyListMediatype)[GeographyIter->first]);
1204 // Check if there is a value for PID.
1206 if ((*GeographyListPID)[GeographyIter->first].size() > 0){
1208 ProcessData.Append(";PID=");
1209 ProcessData.Append((*GeographyListPID)[GeographyIter->first]);
1213 // Check if there is a value for PREF.
1215 if ((*GeographyListPref)[GeographyIter->first] > 0){
1217 ProcessData.Append(";PREF=");
1218 ProcessData.Append(wxString::Format("%i", (*GeographyListPref)[GeographyIter->first]));
1222 // Check if there is a value for tokens.
1224 if ((*GeographyListTokens)[GeographyIter->first].size() > 0){
1226 ProcessData.Append(";");
1227 ProcessData.Append((*GeographyListTokens)[GeographyIter->first]);
1231 ProcessData.Append(":");
1232 ProcessData.Append((*GeographyListDataType)[GeographyIter->first]);
1233 ProcessData.Append(":");
1234 ProcessData.Append(GeographyIter->second);
1235 ProcessData.Append("\n");
1237 ProcessData = OutputText(&ProcessData);
1239 SaveData->Append(ProcessData);
1240 ProcessData.clear();
1246 void ContactDataObject::SaveURL(map<int, wxString> *WebsiteList, map<int, wxString> *WebsiteListAltID,
1247 map<int, wxString> *WebsiteListPID, map<int, wxString> *WebsiteListType,
1248 map<int, wxString> *WebsiteListMediatype, map<int, int> *WebsiteListPref,
1249 map<int, wxString> *WebsiteListTokens, wxString *SaveData, wxString DataType){
1251 wxString ProcessData = "";
1253 for (std::map<int, wxString>::iterator WebsiteIter = WebsiteList->begin();
1254 WebsiteIter != WebsiteList->end(); WebsiteIter++){
1256 ProcessData.Append("URL");
1258 // Check if there is a value for TYPE.
1260 if (DataType.size() > 0){
1262 ProcessData.Append(";TYPE=");
1263 ProcessData.Append(DataType);
1267 // Check if there is a value for ALTID.
1269 if ((*WebsiteListAltID)[WebsiteIter->first].size() > 0){
1271 ProcessData.Append(";ALTID=");
1272 ProcessData.Append((*WebsiteListAltID)[WebsiteIter->first]);
1276 // Check if there is a value for MEDIATYPE.
1278 if ((*WebsiteListMediatype)[WebsiteIter->first].size() > 0){
1280 ProcessData.Append(";MEDIATYPE=");
1281 ProcessData.Append((*WebsiteListMediatype)[WebsiteIter->first]);
1285 // Check if there is a value for PID.
1287 if ((*WebsiteListPID)[WebsiteIter->first].size() > 0){
1289 ProcessData.Append(";PID=");
1290 ProcessData.Append((*WebsiteListPID)[WebsiteIter->first]);
1294 // Check if there is a value for PREF.
1296 if ((*WebsiteListPref)[WebsiteIter->first] > 0){
1298 ProcessData.Append(";PREF=");
1299 ProcessData.Append(wxString::Format("%i", (*WebsiteListPref)[WebsiteIter->first]));
1303 // Check if there is a value for tokens.
1305 if ((*WebsiteListTokens)[WebsiteIter->first].size() > 0){
1307 ProcessData.Append(";");
1308 ProcessData.Append((*WebsiteListTokens)[WebsiteIter->first]);
1312 ProcessData.Append(":");
1313 ProcessData.Append(WebsiteIter->second);
1314 ProcessData.Append("\n");
1316 ProcessData = OutputText(&ProcessData);
1318 SaveData->Append(ProcessData);
1319 ProcessData.clear();
1325 void ContactDataObject::SaveRole(map<int, wxString> *RoleList, map<int, wxString> *RoleListLanguage,
1326 map<int, wxString> *RoleListAltID, map<int, wxString> *RoleListPID,
1327 map<int, wxString> *RoleListType, map<int, int> *RoleListPref,
1328 map<int, wxString> *RoleListTokens, wxString *SaveData, wxString DataType){
1330 wxString ProcessData = "";
1332 for (std::map<int, wxString>::iterator RoleIter = RoleList->begin();
1333 RoleIter != RoleList->end(); RoleIter++){
1335 ProcessData.Append("ROLE");
1337 // Check if there is a value for TYPE.
1339 if (DataType.size() > 0){
1341 ProcessData.Append(";TYPE=");
1342 ProcessData.Append(DataType);
1346 // Check if there is a value for ALTID.
1348 if ((*RoleListAltID)[RoleIter->first].size() > 0){
1350 ProcessData.Append(";ALTID=");
1351 ProcessData.Append((*RoleListAltID)[RoleIter->first]);
1355 // Check if there is a value for LANGUAGE.
1357 if ((*RoleListLanguage)[RoleIter->first].size() > 0){
1359 ProcessData.Append(";LANGUAGE=");
1360 ProcessData.Append((*RoleListLanguage)[RoleIter->first]);
1364 // Check if there is a value for PID.
1366 if ((*RoleListPID)[RoleIter->first].size() > 0){
1368 ProcessData.Append(";PID=");
1369 ProcessData.Append((*RoleListPID)[RoleIter->first]);
1373 // Check if there is a value for PREF.
1375 if ((*RoleListPref)[RoleIter->first] > 0){
1377 ProcessData.Append(";PREF=");
1378 ProcessData.Append(wxString::Format("%i", (*RoleListPref)[RoleIter->first]));
1382 // Check if there is a value for tokens.
1384 if ((*RoleListTokens)[RoleIter->first].size() > 0){
1386 ProcessData.Append(";");
1387 ProcessData.Append((*RoleListTokens)[RoleIter->first]);
1391 ProcessData.Append(":");
1392 ProcessData.Append(RoleIter->second);
1393 ProcessData.Append("\n");
1395 ProcessData = OutputText(&ProcessData);
1397 SaveData->Append(ProcessData);
1398 ProcessData.clear();
1404 void ContactDataObject::SaveOrganisation(map<int, wxString> *OrganisationList, map<int, wxString> *OrganisationListAltID,
1405 map<int, wxString> *OrganisationListPID, map<int, wxString> *OrganisationListLanguage,
1406 map<int, wxString> *OrganisationListSortAs, map<int, wxString> *OrganisationListType,
1407 map<int, int> *OrganisationListPref, map<int, wxString> *OrganisationListTokens,
1408 wxString *SaveData, wxString DataType){
1410 wxString ProcessData = "";
1412 for (std::map<int, wxString>::iterator OrganisationIter = OrganisationList->begin();
1413 OrganisationIter != OrganisationList->end(); OrganisationIter++){
1415 ProcessData.Append("ORG");
1417 // Check if there is a value for TYPE.
1419 if (DataType.size() > 0){
1421 ProcessData.Append(";TYPE=");
1422 ProcessData.Append(DataType);
1426 // Check if there is a value for ALTID.
1428 if ((*OrganisationListAltID)[OrganisationIter->first].size() > 0){
1430 ProcessData.Append(";ALTID=");
1431 ProcessData.Append((*OrganisationListAltID)[OrganisationIter->first]);
1435 // Check if there is a value for LANGUAGE.
1437 if ((*OrganisationListLanguage)[OrganisationIter->first].size() > 0){
1439 ProcessData.Append(";LANGUAGE=");
1440 ProcessData.Append((*OrganisationListLanguage)[OrganisationIter->first]);
1444 // Check if there is a value for PID.
1446 if ((*OrganisationListPID)[OrganisationIter->first].size() > 0){
1448 ProcessData.Append(";PID=");
1449 ProcessData.Append((*OrganisationListPID)[OrganisationIter->first]);
1453 // Check if there is a value for PREF.
1455 if ((*OrganisationListPref)[OrganisationIter->first] > 0){
1457 ProcessData.Append(";PREF=");
1458 ProcessData.Append(wxString::Format("%i", (*OrganisationListPref)[OrganisationIter->first]));
1462 // Check if there is a value for SORT-AS.
1464 if ((*OrganisationListSortAs)[OrganisationIter->first].size() > 0){
1466 ProcessData.Append(";SORT-AS=\"");
1467 ProcessData.Append((*OrganisationListSortAs)[OrganisationIter->first]);
1468 ProcessData.Append("\"");
1472 // Check if there is a value for tokens.
1474 if ((*OrganisationListTokens)[OrganisationIter->first].size() > 0){
1476 ProcessData.Append(";");
1477 ProcessData.Append((*OrganisationListTokens)[OrganisationIter->first]);
1481 ProcessData.Append(":");
1482 ProcessData.Append(OrganisationIter->second);
1483 ProcessData.Append("\n");
1485 ProcessData = OutputText(&ProcessData);
1487 SaveData->Append(ProcessData);
1488 ProcessData.clear();
1494 void ContactDataObject::SaveNote(map<int, wxString> *NoteList, map<int, wxString> *NoteListLanguage,
1495 map<int, wxString> *NoteListAltID, map<int, wxString> *NoteListPID,
1496 map<int, wxString> *NoteListType, map<int, int> *NoteListPref,
1497 map<int, wxString> *NoteListTokens, wxString *SaveData, wxString DataType){
1499 wxString ProcessData = "";
1501 for (std::map<int, wxString>::iterator NoteIter = NoteList->begin();
1502 NoteIter != NoteList->end(); NoteIter++){
1504 ProcessData.Append("NOTE");
1506 // Check if there is a value for TYPE.
1508 if (DataType.size() > 0){
1510 ProcessData.Append(";TYPE=");
1511 ProcessData.Append(DataType);
1515 // Check if there is a value for ALTID.
1517 if ((*NoteListAltID)[NoteIter->first].size() > 0){
1519 ProcessData.Append(";ALTID=");
1520 ProcessData.Append((*NoteListAltID)[NoteIter->first]);
1524 // Check if there is a value for LANGUAGE.
1526 if ((*NoteListLanguage)[NoteIter->first].size() > 0){
1528 ProcessData.Append(";LANGUAGE=");
1529 ProcessData.Append((*NoteListLanguage)[NoteIter->first]);
1533 // Check if there is a value for PID.
1535 if ((*NoteListPID)[NoteIter->first].size() > 0){
1537 ProcessData.Append(";PID=");
1538 ProcessData.Append((*NoteListPID)[NoteIter->first]);
1542 // Check if there is a value for PREF.
1544 if ((*NoteListPref)[NoteIter->first] > 0){
1546 ProcessData.Append(";PREF=");
1547 ProcessData.Append(wxString::Format("%i", (*NoteListPref)[NoteIter->first]));
1551 // Check if there is a value for tokens.
1553 if ((*NoteListTokens)[NoteIter->first].size() > 0){
1555 ProcessData.Append(";");
1556 ProcessData.Append((*NoteListTokens)[NoteIter->first]);
1560 ProcessData.Append(":");
1561 ProcessData.Append(NoteIter->second);
1562 ProcessData.Replace("\n", "\\n", true);
1563 ProcessData.Append("\n");
1565 ProcessData = OutputText(&ProcessData);
1567 SaveData->Append(ProcessData);
1568 ProcessData.clear();