Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Extra commit for -e command switch support.
[xestiaab/.git] / source / contacteditor / frmContactEditor-Save.cpp
1 #include "frmContactEditor.h"
2 #include "../enums.h"
3 #include "../version.h"
4 #include "../vcard/vcard.h"
5 #include "../vcard/vcard34conv.h"
6 #include "../common/textprocessing.h"
7 #include "../common/preferences.h"
8 #include "../common/uuid.h"
9 #include "../common/dirs.h"
11 void frmContactEditor::SaveContact( wxCommandEvent& event )
12 {
13     
14     // Check if Display As combo box has a value in it.
15     // Do not go any further if there is no value.
16     
17     wxString cmbDisplayAsValue = cmbDisplayAs->GetValue();
18     
19     if (cmbDisplayAsValue.IsEmpty()){
20         
21         wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
22         return;
23         
24     }
25     
26     // Save the updated contact data.
27     
28     vCard ContactData;
29     wxString FilenameFinal;
30     bool ReplaceContact = FALSE;
31     
32     if (StartupEditMode == TRUE){
33     
34         if (cmbType->GetCurrentSelection() == 1 ||
35             cmbType->GetCurrentSelection() == 3 ||
36             cmbType->GetCurrentSelection() == 4){
37         
38             if (IsGroup == TRUE){
39             
40                 // Mark contact for replacing.
41             
42                 ReplaceContact = TRUE;
43                 IsGroup = FALSE;
44             
45             }
46         
47         } else if (cmbType->GetCurrentSelection() == 2){
48         
49                 if (IsGroup == FALSE){
50             
51                 // Mark contact for replacing.
52             
53                 ReplaceContact = TRUE;
54                 IsGroup = TRUE;
55             
56             }
57         
58         }
59     
60         if (ReplaceContact == TRUE){
61         
62             wxString wxDelSplitFilename;
63             wxString wxDelFinalFilename;
64             wxString wxSDelDataURL;
65             wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
66             while(wSTDelFilename.HasMoreTokens()){
67             
68                 wxDelSplitFilename = wSTDelFilename.GetNextToken();
69             
70             }
71         
72             wxSDelDataURL = wxDelSplitFilename;
73         
74             // Delete the contact from the server as it will be useless in certain
75             // address book clients.
76         
77             ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
78         
79             // Clear the filename so the trigger to recreate the UID is done.
80         
81             wxSContactFilename.Clear();
82             EditMode = FALSE;
83         
84         }
85     
86     }
87     
88     if (wxSContactFilename.IsEmpty()){
89         
90         // Generate a random UUID.
91         
92         UIDToken = GenerateUUID();
93         UIDToken = UIDToken.MakeUpper();
94         
95         // Setup the filename.
96         
97         FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
98         
99 #if defined(__HAIKU__)
100         
101         //preffilename = wxT("noo");
102         
103 #elif defined(__WIN32__)
104         
105         FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
106         FilenameFinal.Append(UIDToken);
107         FilenameFinal.Append(wxT(".vcf"));
108         wxSContactFilename = FilenameFinal;
109         
110 #else
111         
112         FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
113         FilenameFinal.Append(UIDToken);
114         FilenameFinal.Append(wxT(".vcf"));
115         wxSContactFilename = FilenameFinal;
116         
117 #endif
118         
119     } else {
120         
121         if (UIDToken.IsEmpty()){
122             
123             // UID Token is empty. (Shouldn't be).
124             // Generate a new UID Token.
125             
126             /*boost::uuids::uuid ContactUUID = boost::uuids::random_generator()();
127              std::string sstContactUUID = boost::uuids::to_string(ContactUUID);
128              wxString strContactUUID(sstContactUUID.c_str(), wxConvUTF8);
129              UIDToken = strContactUUID;*/
130             UIDToken = GenerateUUID();
131             UIDToken = UIDToken.MakeUpper();
132             
133         }
134         FilenameFinal = wxSContactFilename;
135         
136     }
137     
138     // Setup the data and write it into the account folder.
139     
140     // Begin preperations to write the contact to a file.
141     
142     bool boolValue = FALSE;
143     bool boolValue2 = FALSE;
144     bool FNFirst = TRUE;
145     bool NNGeneralFirst = TRUE;
146     bool NNHomeFirst = TRUE;
147     bool NNWorkFirst = TRUE;
148     int intFNCount = 0;
149     std::map<int,int>::iterator intiter;
150     std::map<int,wxString>::iterator striter;
151     
152     ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE);
153     ContactData.Add(wxT("VERSION"), wxT("4.0"), FALSE);
154     
155     // Setup the version string.
156     
157     strValue.Append(wxT("-//Xestia//Address Book Version "));
158     strValue.Append(wxT(XSDAB_VERSION));
159     strValue.Append(wxT("//KW"));
160     
161     ContactData.Add(wxT("PRODID"), strValue, FALSE);
162     
163     // Setup the name.
164     
165     strValue.Clear();
166     
167     // Setup the name field.
168     
169     strValue = txtSurname->GetValue() + wxT(";") +
170     txtForename->GetValue() + wxT(";") +
171     txtOtherNames->GetValue() + wxT(";") +
172     txtTitle->GetValue() + wxT(";") +
173     txtSuffix->GetValue();
174     
175     strValue2 = ContactData.Convert(cmbDisplayAs->GetValue(), FALSE);
176     strValue2.Trim();
177     
178     if (NameTokens.IsEmpty()){
179         ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\""), strValue, FALSE);
180     } else {
181         ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\";") + NameTokens, strValue, FALSE);
182     }
183     
184     if (cmbType->GetCurrentSelection() == 1){
185         
186         ContactData.AddRaw(wxT("KIND"), wxT("individual"));
187         
188     } else if (cmbType->GetCurrentSelection() == 2){
189         
190         ContactData.AddRaw(wxT("KIND"), wxT("group"));
191         
192         // Go through each of the members and write them out.
193         
194         for (std::map<int, wxString>::iterator itemiter = GroupsList.begin();
195              itemiter != GroupsList.end(); ++itemiter){
196             
197             ContactData.Add(wxT("MEMBER:urn:uuid"), itemiter->second, FALSE);
198             
199         }
200         
201     } else if (cmbType->GetCurrentSelection() == 3){
202         
203         ContactData.AddRaw(wxT("KIND"), wxT("org"));
204         
205     } else if (cmbType->GetCurrentSelection() == 4){
206         
207         ContactData.AddRaw(wxT("KIND"), wxT("location"));
208         
209     }
210     
211     
212     // Setup the nicknames (General, Home & Business).
213     
214     strValue.Clear();
215     strValue2.Clear();
216     strValue3.Clear();
217     
218     boolValue = FALSE;
219     boolValue2 = FALSE;
220     intValue2 = 0;
221     intValue  = 0;
222     
223     // Setup the gender.
224     
225     if (cmbGender->GetCurrentSelection() != 0){
226         
227         switch(cmbGender->GetCurrentSelection()){
228                 
229             case 1:
230                 
231                 strValue = wxT("M");
232                 break;
233                 
234             case 2:
235                 
236                 strValue = wxT("F");
237                 break;
238                 
239             case 3:
240                 
241                 strValue = wxT("O");
242                 break;
243                 
244             case 4:
245                 
246                 strValue = wxT("N");
247                 break;
248                 
249             case 5:
250                 
251                 strValue = wxT("U");
252                 break;
253                 
254         }
255         
256     }
257     
258     if (!txtGenderDescription->IsEmpty()){
259         
260         strValue2 = txtGenderDescription->GetValue();
261         
262     }
263     
264     if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
265         
266         EscapeString(&strValue2, FALSE);
267         
268         if (!GenderTokens.IsEmpty()){
269             
270             if (!strValue2.IsEmpty()){
271                 
272                 ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue + wxT(";") + strValue2);
273                 
274             } else {
275                 
276                 ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue);
277                 
278             }
279             
280         } else {
281             
282             if (!strValue2.IsEmpty()){
283                 
284                 ContactData.AddRaw(wxT("GENDER"), strValue + wxT(";") + strValue2);
285                 
286             } else {
287                 
288                 ContactData.AddRaw(wxT("GENDER"), strValue);
289                 
290             }
291             
292         }
293         
294     }
295     
296     strValue.Clear();
297     strValue2.Clear();
298     strValue3.Clear();
299     
300     boolValue = FALSE;
301     boolValue2 = FALSE;
302     intValue2 = 0;
303     intValue  = 0;
304     
305     // Process Label.
306     
307     strValue3 = BirthdayAltID;
308     
309     if (!strValue3.IsEmpty()){
310         
311         strValue3.Trim();
312         strValue3.Trim();
313         boolValue2 = TRUE;
314         strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
315         
316         boolValue = TRUE;
317         
318     }
319     
320     //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
321     //strValue2 =
322     
323     // Process Language.
324     
325     strValue3 = BirthdayCalScale;
326     
327     if (!strValue3.IsEmpty()){
328         
329         strValue3.Trim();
330         strValue3.Trim();
331         
332         if (boolValue2 == TRUE){
333             
334             strValue2.Append(wxT(";"));
335             
336         } else {
337             
338             boolValue2 = TRUE;
339             
340         }
341         
342         strValue2.Append(wxT("CALSCALE=") + strValue3);
343         
344         boolValue = TRUE;
345         
346     }
347     
348     // Process Tokens.
349     
350     strValue2 = BirthdayTokens;
351     
352     // Get the birthday and write it.
353     
354     ResetSaveProcessData();
355     
356     if (!txtBirthday->IsEmpty()){
357         
358         strValue = txtBirthday->GetValue();
359         
360         if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
361             
362             if (!strValue2.IsEmpty()){
363                 
364                 EscapeString(&strValue2, FALSE);
365                 EscapeString(&strValue, FALSE);
366                 
367                 ContactData.AddRaw(wxT("BDAY;VALUE=text;") + strValue2 + wxT(";"), strValue);
368                 
369             } else {
370                 
371                 EscapeString(&strValue, FALSE);
372                 
373                 ContactData.AddRaw(wxT("BDAY;VALUE=text"), strValue);
374                 
375             }
376             
377         }
378         
379     } else {
380         
381         // Deal with date.
382         
383         // Get Day, Month & Year.
384         
385         wxDateTime BirthdayDate;
386         wxDateTime::Month BirthdayMonth;
387         int BirthdayDay;
388         int BirthdayYear;
389         wxString DataBeforeT;
390         wxString DataAfterT;
391         wxString FinalBirthdayString;
392         bool ProcessDataAfterT = FALSE;
393         
394         BirthdayDate = dapBirthday->GetValue();
395         
396         if (BirthdayDate.IsValid()){
397             
398             BirthdayDay = BirthdayDate.GetDay();
399             BirthdayMonth = BirthdayDate.GetMonth();
400             BirthdayYear = BirthdayDate.GetYear();
401             
402             // Look for T and replace data before this.
403             
404             wxStringTokenizer wSTDate(Birthday, wxT("T"));
405             
406             while (wSTDate.HasMoreTokens()){
407                 
408                 if (ProcessDataAfterT == FALSE){
409                     
410                     DataBeforeT = wSTDate.GetNextToken();
411                     ProcessDataAfterT = TRUE;
412                     
413                 } else {
414                     
415                     DataAfterT = wSTDate.GetNextToken();
416                     break;
417                     
418                 }
419                 
420             }
421             
422             // If there is not T then replace altogether.
423             
424             wxString FinalBirthdayDay;
425             wxString FinalBirthdayMonth;
426             wxString FinalBirthdayYear;
427             
428             if (BirthdayDay < 10){
429                 
430                 FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
431                 
432             } else {
433                 
434                 FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
435                 
436             }
437             
438             if (((int)BirthdayMonth + 1) < 10){
439                 
440                 FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
441                 
442             } else {
443                 
444                 FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
445                 
446             }
447             
448             if (BirthdayYear == 0){
449                 
450                 FinalBirthdayYear = wxT("--");
451                 
452             } else {
453                 
454                 FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
455                 
456             }
457             
458             if (!DataAfterT.IsEmpty()){
459                 
460                 FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
461                 
462             } else {
463                 
464                 FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
465                 
466             }
467             
468             if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){
469                 
470                 if (!strValue2.IsEmpty()){
471                     
472                     EscapeString(&strValue2, FALSE);
473                     EscapeString(&strValue, FALSE);
474                     
475                     ContactData.AddRaw(wxT("BDAY") + strValue2 + wxT(";"), FinalBirthdayString);
476                     
477                 } else {
478                     
479                     EscapeString(&strValue, FALSE);
480                     
481                     ContactData.AddRaw(wxT("BDAY"), FinalBirthdayString);
482                     
483                 }
484                 
485             }
486             
487         }
488         
489     }
490     
491     ResetSaveProcessData();
492     
493     // Process Label.
494     
495     strValue3 = AnniversaryAltID;
496     
497     if (!strValue3.IsEmpty()){
498         
499         strValue3.Trim();
500         strValue3.Trim();
501         boolValue2 = TRUE;
502         strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
503         
504         boolValue = TRUE;
505         
506     }
507     
508     //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
509     //strValue2 =
510     
511     // Process Language.
512     
513     strValue3 = AnniversaryCalScale;
514     
515     if (!strValue3.IsEmpty()){
516         
517         strValue3.Trim();
518         strValue3.Trim();
519         
520         if (boolValue2 == TRUE){
521             
522             strValue2.Append(wxT(";"));
523             
524         } else {
525             
526             boolValue2 = TRUE;
527             
528         }
529         
530         strValue2.Append(wxT("CALSCALE=") + strValue3);
531         
532         boolValue = TRUE;
533         
534     }
535     
536     // Process Tokens.
537     
538     strValue2 = AnniversaryTokens;
539     
540     // Deal with ANNIVERSARY.
541     
542     if (!txtAnniversary->IsEmpty()){
543         
544         strValue = txtAnniversary->GetValue();
545         
546         if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
547             
548             if (!strValue2.IsEmpty()){
549                 
550                 EscapeString(&strValue2, FALSE);
551                 EscapeString(&strValue, FALSE);
552                 
553                 ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text;") + strValue2 + wxT(";"), strValue);
554                 
555             } else {
556                 
557                 EscapeString(&strValue, FALSE);
558                 
559                 ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text"), strValue);
560                 
561             }
562             
563         }
564         
565     } else {
566         
567         // Look for T and replace data before this.
568         
569         // Get Day, Month & Year.
570         
571         wxDateTime AnniversaryDate;
572         wxDateTime::Month AnniversaryMonth;
573         int AnniversaryDay;
574         int AnniversaryYear;
575         wxString DataBeforeT;
576         wxString DataAfterT;
577         wxString FinalAnniversaryString;
578         bool ProcessDataAfterT = FALSE;
579         
580         AnniversaryDate = dapAnniversary->GetValue();
581         
582         if (AnniversaryDate.IsValid()){
583             
584             AnniversaryDay = AnniversaryDate.GetDay();
585             AnniversaryMonth = AnniversaryDate.GetMonth();
586             AnniversaryYear = AnniversaryDate.GetYear();
587             
588             // Look for T and replace data before this.
589             
590             wxStringTokenizer wSTDate(Anniversary, wxT("T"));
591             
592             while (wSTDate.HasMoreTokens()){
593                 
594                 if (ProcessDataAfterT == FALSE){
595                     
596                     DataBeforeT = wSTDate.GetNextToken();
597                     ProcessDataAfterT = TRUE;
598                     
599                 } else {
600                     
601                     DataAfterT = wSTDate.GetNextToken();
602                     break;
603                     
604                 }
605                 
606             }
607             
608             // If there is not T then replace altogether.
609             
610             wxString FinalAnniversaryDay;
611             wxString FinalAnniversaryMonth;
612             wxString FinalAnniversaryYear;
613             
614             if (AnniversaryDay < 10){
615                 
616                 FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
617                 
618             } else {
619                 
620                 FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
621                 
622             }
623             
624             if (((int)AnniversaryMonth + 1) < 10){
625                 
626                 FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
627                 
628             } else {
629                 
630                 FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
631                 
632             }
633             
634             if (AnniversaryYear == 0){
635                 
636                 FinalAnniversaryYear = wxT("--");
637                 
638             } else {
639                 
640                 FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
641                 
642             }
643             
644             if (!DataAfterT.IsEmpty()){
645                 
646                 FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
647                 
648             } else {
649                 
650                 FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
651                 
652             }
653             
654             if (!FinalAnniversaryString.IsEmpty() || !strValue2.IsEmpty()){
655                 
656                 if (!strValue2.IsEmpty()){
657                     
658                     EscapeString(&strValue2, FALSE);
659                     EscapeString(&strValue, FALSE);
660                     
661                     ContactData.AddRaw(wxT("ANNIVERSARY") + strValue2 + wxT(";"), FinalAnniversaryString);
662                     
663                 } else {
664                     
665                     EscapeString(&strValue, FALSE);
666                     
667                     ContactData.AddRaw(wxT("ANNIVERSARY"), FinalAnniversaryString);
668                     
669                 }
670                 
671             }
672             
673         }
674         
675     }
676     
677     // Setup the addresses (General, Home, Business).
678     
679     //intValue = GeneralAddressList.size();
680     ResetSaveProcessData();
681     
682     for (std::map<int,wxString>::iterator iter = GeneralAddressList.begin();
683          iter != GeneralAddressList.end(); ++iter){
684         
685         int intSeekValue = iter->first;
686         
687         wxString strAddressString;
688         wxString strAddressFinalValue;
689         std::map<int, wxString>::iterator iterValue;
690         
691         strAddressString.Append(wxT(";;"));
692         
693         // Get Address
694         
695         iterValue = GeneralAddressList.find(intSeekValue);
696         strAddressFinalValue = iterValue->second;
697         ProcessCaptureStrings(&strAddressFinalValue);
698         strAddressString.Append(strAddressFinalValue + wxT(";"));
699         strAddressFinalValue.Clear();
700         
701         // Get Town
702         
703         iterValue = GeneralAddressListTown.find(intSeekValue);
704         strAddressFinalValue = iterValue->second;
705         ProcessCaptureStrings(&strAddressFinalValue);
706         strAddressString.Append(strAddressFinalValue + wxT(";"));
707         strAddressFinalValue.Clear();
708         
709         // Get County
710         
711         iterValue = GeneralAddressListCounty.find(intSeekValue);
712         strAddressFinalValue = iterValue->second;
713         ProcessCaptureStrings(&strAddressFinalValue);
714         strAddressString.Append(strAddressFinalValue + wxT(";"));
715         strAddressFinalValue.Clear();
716         
717         // Get Post Code
718         
719         iterValue = GeneralAddressListPostCode.find(intSeekValue);
720         strAddressFinalValue = iterValue->second;
721         ProcessCaptureStrings(&strAddressFinalValue);
722         strAddressString.Append(strAddressFinalValue + wxT(";"));
723         strAddressFinalValue.Clear();
724         
725         // Get Country
726         
727         iterValue = GeneralAddressListCountry.find(intSeekValue);
728         strAddressFinalValue = iterValue->second;
729         ProcessCaptureStrings(&strAddressFinalValue);
730         strAddressString.Append(strAddressFinalValue);
731         strAddressFinalValue.Clear();
732         
733         ProcessSaveData(wxT("ADR"), &strValue2, &boolValue2, &boolValue,
734                         &iter, &strAddressString, &ContactData,
735                         wxT("LABEL"), &GeneralAddressListLabel,
736                         wxT("LANGUAGE"), &GeneralAddressListLang,
737                         wxT("ALTID"), &GeneralAddressListAltID,
738                         wxT("PID"), &GeneralAddressListPID,
739                         wxT("GEO"), &GeneralAddressListGeo,
740                         wxT("TZ"), &GeneralAddressListTimezone,
741                         wxT("MEDIATYPE"), &GeneralAddressListMediatype,
742                         wxT("PREF"), &GeneralAddressListPref,
743                         wxT(""), &GeneralAddressListTokens );
744         
745         ResetSaveProcessData();
746         
747     }
748     
749     ResetSaveProcessData();
750     
751     for (std::map<int,wxString>::iterator iter = HomeAddressList.begin();
752          iter != HomeAddressList.end(); ++iter){
753         
754         int intSeekValue = iter->first;
755         
756         wxString strAddressString;
757         wxString strAddressFinalValue;
758         std::map<int, wxString>::iterator iterValue;
759         
760         strAddressString.Append(wxT(";;"));
761         
762         // Get Address
763         
764         iterValue = HomeAddressList.find(intSeekValue);
765         strAddressFinalValue = iterValue->second;
766         ProcessCaptureStrings(&strAddressFinalValue);
767         
768         strAddressString.Append(strAddressFinalValue + wxT(";"));
769         
770         // Get Town
771         
772         iterValue = HomeAddressListTown.find(intSeekValue);
773         strAddressFinalValue = iterValue->second;
774         ProcessCaptureStrings(&strAddressFinalValue);
775         
776         strAddressString.Append(strAddressFinalValue + wxT(";"));
777         
778         // Get County
779         
780         iterValue = HomeAddressListCounty.find(intSeekValue);
781         strAddressFinalValue = iterValue->second;
782         ProcessCaptureStrings(&strAddressFinalValue);
783         
784         strAddressString.Append(strAddressFinalValue + wxT(";"));
785         
786         // Get Post Code
787         
788         iterValue = HomeAddressListPostCode.find(intSeekValue);
789         strAddressFinalValue = iterValue->second;
790         ProcessCaptureStrings(&strAddressFinalValue);
791         
792         strAddressString.Append(strAddressFinalValue + wxT(";"));
793         
794         // Get Country
795         
796         iterValue = HomeAddressListCountry.find(intSeekValue);
797         strAddressFinalValue = iterValue->second;
798         ProcessCaptureStrings(&strAddressFinalValue);
799         
800         strAddressString.Append(strAddressFinalValue);
801         
802         ProcessSaveData(wxT("ADR;TYPE=home"), &strValue2, &boolValue2, &boolValue,
803                         &iter, &strAddressString, &ContactData,
804                         wxT("LABEL"), &HomeAddressListLabel,
805                         wxT("LANGUAGE"), &HomeAddressListLang,
806                         wxT("ALTID"), &HomeAddressListAltID,
807                         wxT("PID"), &HomeAddressListPID,
808                         wxT("GEO"), &HomeAddressListGeo,
809                         wxT("TZ"), &HomeAddressListTimezone,
810                         wxT("MEDIATYPE"), &HomeAddressListMediatype,
811                         wxT("PREF"), &HomeAddressListPref,
812                         wxT(""), &HomeAddressListTokens );
813         
814         ResetSaveProcessData();
815         
816     }
817     
818     ResetSaveProcessData();
819     
820     for (std::map<int,wxString>::iterator iter = BusinessAddressList.begin();
821          iter != BusinessAddressList.end(); ++iter){
822         
823         int intSeekValue = iter->first;
824         
825         wxString strAddressString;
826         wxString strAddressFinalValue;
827         std::map<int, wxString>::iterator iterValue;
828         
829         strAddressString.Append(wxT(";;"));
830         
831         // Get Address
832         
833         iterValue = BusinessAddressList.find(intSeekValue);
834         strAddressFinalValue = iterValue->second;
835         ProcessCaptureStrings(&strAddressFinalValue);
836         
837         strAddressString.Append(strAddressFinalValue + wxT(";"));
838         
839         // Get Town
840         
841         iterValue = BusinessAddressListTown.find(intSeekValue);
842         strAddressFinalValue = iterValue->second;
843         ProcessCaptureStrings(&strAddressFinalValue);
844         
845         strAddressString.Append(strAddressFinalValue + wxT(";"));
846         
847         // Get County
848         
849         iterValue = BusinessAddressListCounty.find(intSeekValue);
850         strAddressFinalValue = iterValue->second;
851         ProcessCaptureStrings(&strAddressFinalValue);
852         
853         strAddressString.Append(strAddressFinalValue + wxT(";"));
854         
855         // Get Post Code
856         
857         iterValue = BusinessAddressListPostCode.find(intSeekValue);
858         strAddressFinalValue = iterValue->second;
859         ProcessCaptureStrings(&strAddressFinalValue);
860         
861         strAddressString.Append(strAddressFinalValue + wxT(";"));
862         
863         // Get Country
864         
865         iterValue = BusinessAddressListCountry.find(intSeekValue);
866         strAddressFinalValue = iterValue->second;
867         ProcessCaptureStrings(&strAddressFinalValue);
868         
869         strAddressString.Append(strAddressFinalValue);
870         
871         ProcessSaveData(wxT("ADR;TYPE=work"), &strValue2, &boolValue2, &boolValue,
872                         &iter, &strAddressString, &ContactData,
873                         wxT("LABEL"), &BusinessAddressListLabel,
874                         wxT("LANGUAGE"), &BusinessAddressListLang,
875                         wxT("ALTID"), &BusinessAddressListAltID,
876                         wxT("PID"), &BusinessAddressListPID,
877                         wxT("GEO"), &BusinessAddressListGeo,
878                         wxT("TZ"), &BusinessAddressListTimezone,
879                         wxT("MEDIATYPE"), &BusinessAddressListMediatype,
880                         wxT("PREF"), &BusinessAddressListPref,
881                         wxT(""), &BusinessAddressListTokens );
882         
883         ResetSaveProcessData();
884         
885     }
886     
887     // Sort out nicknames (if any).
888     
889     for (std::map<int,wxString>::iterator iter = GeneralNicknamesList.begin();
890          iter != GeneralNicknamesList.end(); ++iter){
891         
892         intValue2 = iter->first;
893         
894         // Process Alternative ID.
895         
896         ProcessSaveData(wxT("NICKNAME"), &strValue2, &boolValue2, &boolValue,
897                         &iter, &GeneralNicknamesList, &ContactData,
898                         wxT("LANGUAGE"), &GeneralNicknamesListLanguage,
899                         wxT("ALTID"), &GeneralNicknamesListAltID,
900                         wxT("PID"), &GeneralNicknamesListPID,
901                         wxT("PREF"), &GeneralNicknamesListPref,
902                         wxT(""), &GeneralNicknamesListTokens );
903         
904         ResetSaveProcessData();
905         
906     }
907     
908     ResetSaveProcessData();
909     
910     for (std::map<int,wxString>::iterator iter = HomeNicknamesList.begin();
911          iter != HomeNicknamesList.end(); ++iter){
912         
913         ProcessSaveData(wxT("NICKNAME;TYPE=home"), &strValue2, &boolValue2, &boolValue,
914                         &iter, &HomeNicknamesList, &ContactData,
915                         wxT("LANGUAGE"), &HomeNicknamesListLanguage,
916                         wxT("ALTID"), &HomeNicknamesListAltID,
917                         wxT("PID"), &HomeNicknamesListPID,
918                         wxT("PREF"), &HomeNicknamesListPref,
919                         wxT(""), &HomeNicknamesListTokens );
920         
921         ResetSaveProcessData();
922         
923     }
924     
925     ResetSaveProcessData();
926     
927     for (std::map<int,wxString>::iterator iter = BusinessNicknamesList.begin();
928          iter != BusinessNicknamesList.end(); ++iter){
929         
930         ProcessSaveData(wxT("NICKNAME;TYPE=work"), &strValue2, &boolValue2, &boolValue,
931                         &iter, &BusinessNicknamesList, &ContactData,
932                         wxT("LANGUAGE"), &BusinessNicknamesListLanguage,
933                         wxT("ALTID"), &BusinessNicknamesListAltID,
934                         wxT("PID"), &BusinessNicknamesListPID,
935                         wxT("PREF"), &BusinessNicknamesListPref,
936                         wxT(""), &BusinessNicknamesListTokens );
937         
938         ResetSaveProcessData();
939         
940     }
941     
942     ResetSaveProcessData();
943     
944     // Sort out email (general, home and business).
945     
946     for (std::map<int,wxString>::iterator iter = GeneralEmailList.begin();
947          iter != GeneralEmailList.end(); ++iter){
948         
949         //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
950         //strValue2 =
951         
952         wxString strAddressFinalValue;
953         std::map<int, wxString>::iterator iterValue;
954         
955         ProcessSaveData(wxT("EMAIL"), &strValue2, &boolValue2, &boolValue,
956                         &iter, &GeneralEmailList, &ContactData,
957                         wxT("ALTID"), &GeneralEmailListAltID,
958                         wxT("PID"), &GeneralEmailListPID,
959                         wxT("PREF"), &GeneralEmailListPref,
960                         wxT(""), &GeneralEmailListTokens );
961         
962         ResetSaveProcessData();
963         
964     }
965     
966     ResetSaveProcessData();
967     
968     for (std::map<int,wxString>::iterator iter = HomeEmailList.begin();
969          iter != HomeEmailList.end(); ++iter){
970         
971         //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
972         //strValue2 =
973         
974         ProcessSaveData(wxT("EMAIL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
975                         &iter, &HomeEmailList, &ContactData,
976                         wxT("ALTID"), &HomeEmailListAltID,
977                         wxT("PID"), &HomeEmailListPID,
978                         wxT("PREF"), &HomeEmailListPref,
979                         wxT(""), &HomeEmailListTokens );
980         
981         ResetSaveProcessData();
982         
983     }
984     
985     ResetSaveProcessData();
986     
987     for (std::map<int,wxString>::iterator iter = BusinessEmailList.begin();
988          iter != BusinessEmailList.end(); ++iter){
989         
990         //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
991         //strValue2 =
992         
993         ProcessSaveData(wxT("EMAIL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
994                         &iter, &BusinessEmailList, &ContactData,
995                         wxT("ALTID"), &BusinessEmailListAltID,
996                         wxT("PID"), &BusinessEmailListPID,
997                         wxT("PREF"), &BusinessEmailListPref,
998                         wxT(""), &BusinessEmailListTokens );
999         
1000         ResetSaveProcessData();
1001         
1002     }
1003     
1004     ResetSaveProcessData();
1005     
1006     for (std::map<int,wxString>::iterator iter = GeneralIMList.begin();
1007          iter != GeneralIMList.end(); ++iter){
1008         
1009         intValue2 = iter->first;
1010         
1011         // Process Alternative ID.
1012         
1013         ProcessSaveData(wxT("IMPP"), &strValue2, &boolValue2, &boolValue,
1014                         &iter, &GeneralIMList, &ContactData,
1015                         wxT("ALTID"), &GeneralIMListAltID,
1016                         wxT("PID"), &GeneralIMListPID,
1017                         wxT("MEDIATYPE"), &GeneralIMListMediatype,
1018                         wxT("PREF"), &GeneralIMListPref,
1019                         wxT(""), &GeneralIMListTokens );
1020         
1021         ResetSaveProcessData();
1022         
1023     }
1024     
1025     ResetSaveProcessData();
1026     
1027     for (std::map<int,wxString>::iterator iter = HomeIMList.begin();
1028          iter != HomeIMList.end(); ++iter){
1029         
1030         ProcessSaveData(wxT("IMPP;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1031                         &iter, &HomeIMList, &ContactData,
1032                         wxT("ALTID"), &HomeIMListAltID,
1033                         wxT("PID"), &HomeIMListPID,
1034                         wxT("MEDIATYPE"), &HomeIMListMediatype,
1035                         wxT("PREF"), &HomeIMListPref,
1036                         wxT(""), &HomeIMListTokens );
1037         
1038         ResetSaveProcessData();
1039         
1040     }
1041     
1042     ResetSaveProcessData();
1043     
1044     for (std::map<int,wxString>::iterator iter = BusinessIMList.begin();
1045          iter != BusinessIMList.end(); ++iter){
1046         
1047         ProcessSaveData(wxT("IMPP;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1048                         &iter, &BusinessIMList, &ContactData,
1049                         wxT("ALTID"), &BusinessIMListAltID,
1050                         wxT("PID"), &BusinessIMListPID,
1051                         wxT("MEDIATYPE"), &BusinessIMListMediatype,
1052                         wxT("PREF"), &BusinessIMListPref,
1053                         wxT(""), &BusinessIMListTokens );
1054         
1055         ResetSaveProcessData();
1056         
1057     }
1058     
1059     ResetSaveProcessData();
1060     
1061     for (std::map<int,wxString>::iterator iter = GeneralTelephoneList.begin();
1062          iter != GeneralTelephoneList.end(); ++iter){
1063         
1064         wxString strAddressFinalValue = iter->second;
1065         
1066         ProcessCaptureStrings(&strAddressFinalValue);
1067         
1068         strAddressFinalValue.insert(0, wxT("tel:"));
1069         
1070         ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1071                         &iter, &strAddressFinalValue, &ContactData,
1072                         wxT("ALTID"), &GeneralTelephoneListAltID,
1073                         wxT("PID"), &GeneralTelephoneListPID,
1074                         wxT("TYPE"), &GeneralTelephoneListType,
1075                         wxT("PREF"), &GeneralTelephoneListPref,
1076                         wxT(""), &GeneralTelephoneListTokens );
1077         
1078         ResetSaveProcessData();
1079         
1080     }
1081     
1082     ResetSaveProcessData();
1083     
1084     for (std::map<int,wxString>::iterator iter = HomeTelephoneList.begin();
1085          iter != HomeTelephoneList.end(); ++iter){
1086         
1087         wxString strAddressFinalValue = iter->second;
1088         
1089         ProcessCaptureStrings(&strAddressFinalValue);
1090         
1091         strAddressFinalValue.insert(0, wxT("tel:"));
1092         
1093         ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1094                         &iter, &strAddressFinalValue, &ContactData,
1095                         wxT("ALTID"), &HomeTelephoneListAltID,
1096                         wxT("PID"), &HomeTelephoneListPID,
1097                         wxT("TYPE"), &HomeTelephoneListType,
1098                         wxT("PREF"), &HomeTelephoneListPref,
1099                         wxT(""), &HomeTelephoneListTokens );
1100         
1101         ResetSaveProcessData();
1102         
1103     }
1104     
1105     ResetSaveProcessData();
1106     
1107     for (std::map<int,wxString>::iterator iter = BusinessTelephoneList.begin();
1108          iter != BusinessTelephoneList.end(); ++iter){
1109         
1110         wxString strAddressFinalValue = iter->second;
1111         
1112         ProcessCaptureStrings(&strAddressFinalValue);
1113         
1114         strAddressFinalValue.insert(0, wxT("tel:"));
1115         
1116         ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1117                         &iter, &strAddressFinalValue, &ContactData,
1118                         wxT("ALTID"), &BusinessTelephoneListAltID,
1119                         wxT("PID"), &BusinessTelephoneListPID,
1120                         wxT("TYPE"), &BusinessTelephoneListType,
1121                         wxT("PREF"), &BusinessTelephoneListPref,
1122                         wxT(""), &BusinessTelephoneListTokens );
1123         
1124         ResetSaveProcessData();
1125         
1126     }
1127     
1128     ResetSaveProcessData();
1129     
1130     for (std::map<int,wxString>::iterator iter = GeneralLanguageList.begin();
1131          iter != GeneralLanguageList.end(); ++iter){
1132         
1133         intValue2 = iter->first;
1134         
1135         ProcessSaveData(wxT("LANG"), &strValue2, &boolValue2, &boolValue,
1136                         &iter, &GeneralLanguageList, &ContactData,
1137                         wxT("ALTID"), &GeneralLanguageListAltID,
1138                         wxT("PID"), &GeneralLanguageListPID,
1139                         wxT("PREF"), &GeneralLanguageListPref,
1140                         wxT(""), &GeneralLanguageListTokens );
1141         
1142         ResetSaveProcessData();
1143         
1144     }
1145     
1146     ResetSaveProcessData();
1147     
1148     for (std::map<int,wxString>::iterator iter = HomeLanguageList.begin();
1149          iter != HomeLanguageList.end(); ++iter){
1150         
1151         ProcessSaveData(wxT("LANG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1152                         &iter, &HomeLanguageList, &ContactData,
1153                         wxT("ALTID"), &HomeLanguageListAltID,
1154                         wxT("PID"), &HomeLanguageListPID,
1155                         wxT("PREF"), &HomeLanguageListPref,
1156                         wxT(""), &HomeLanguageListTokens );
1157         
1158         ResetSaveProcessData();
1159         
1160     }
1161     
1162     ResetSaveProcessData();
1163     
1164     for (std::map<int,wxString>::iterator iter = BusinessLanguageList.begin();
1165          iter != BusinessLanguageList.end(); ++iter){
1166         
1167         ProcessSaveData(wxT("LANG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1168                         &iter, &BusinessLanguageList, &ContactData,
1169                         wxT("ALTID"), &BusinessLanguageListAltID,
1170                         wxT("PID"), &BusinessLanguageListPID,
1171                         wxT("PREF"), &BusinessLanguageListPref,
1172                         wxT(""), &BusinessLanguageListTokens );
1173         
1174         ResetSaveProcessData();
1175         
1176     }
1177     
1178     ResetSaveProcessData();
1179     
1180     for (std::map<int,wxString>::iterator iter = GeneralTZList.begin();
1181          iter != GeneralTZList.end(); ++iter){
1182         
1183         ProcessSaveData(wxT("TZ"), &strValue2, &boolValue2, &boolValue,
1184                         &iter, &GeneralTZList, &ContactData,
1185                         wxT("ALTID"), &GeneralTZListAltID,
1186                         wxT("PID"), &GeneralTZListPID,
1187                         wxT("MEDIATYPE"), &GeneralTZListMediatype,
1188                         wxT("PREF"), &GeneralTZListPref,
1189                         wxT(""), &GeneralTZListTokens );
1190         
1191         ResetSaveProcessData();
1192         
1193     }
1194     
1195     ResetSaveProcessData();
1196     
1197     for (std::map<int,wxString>::iterator iter = HomeTZList.begin();
1198          iter != HomeTZList.end(); ++iter){
1199         
1200         ProcessSaveData(wxT("TZ;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1201                         &iter, &HomeTZList, &ContactData,
1202                         wxT("ALTID"), &HomeTZListAltID,
1203                         wxT("PID"), &HomeTZListPID,
1204                         wxT("MEDIATYPE"), &HomeTZListMediatype,
1205                         wxT("PREF"), &HomeTZListPref,
1206                         wxT(""), &HomeTZListTokens );
1207         
1208         ResetSaveProcessData();
1209         
1210     }
1211     
1212     ResetSaveProcessData();
1213     
1214     for (std::map<int,wxString>::iterator iter = BusinessTZList.begin();
1215          iter != BusinessTZList.end(); ++iter){
1216         
1217         ProcessSaveData(wxT("TZ;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1218                         &iter, &BusinessTZList, &ContactData,
1219                         wxT("ALTID"), &BusinessTZListAltID,
1220                         wxT("PID"), &BusinessTZListPID,
1221                         wxT("MEDIATYPE"), &BusinessTZListMediatype,
1222                         wxT("PREF"), &BusinessTZListPref,
1223                         wxT(""), &BusinessTZListTokens );
1224         
1225         ResetSaveProcessData();
1226         
1227     }
1228     
1229     ResetSaveProcessData();
1230     
1231     for (std::map<int,wxString>::iterator iter = GeneralGeographyList.begin();
1232          iter != GeneralGeographyList.end(); ++iter){
1233         
1234         wxString strAddressFinalValue = iter->second;
1235         
1236         ProcessCaptureStrings(&strAddressFinalValue);
1237         
1238         strAddressFinalValue.insert(0, wxT("geo:"));
1239         
1240         ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue,
1241                         &iter, &strAddressFinalValue, &ContactData,
1242                         wxT("ALTID"), &GeneralGeographyListAltID,
1243                         wxT("PID"), &GeneralGeographyListPID,
1244                         wxT("MEDIATYPE"), &GeneralGeographyListMediatype,
1245                         wxT("PREF"), &GeneralGeographyListPref,
1246                         wxT(""), &GeneralGeographyListTokens );
1247         
1248         ResetSaveProcessData();
1249         
1250     }
1251     
1252     ResetSaveProcessData();
1253     
1254     for (std::map<int,wxString>::iterator iter = HomeGeographyList.begin();
1255          iter != HomeGeographyList.end(); ++iter){
1256         
1257         wxString strAddressFinalValue = iter->second;
1258         
1259         ProcessCaptureStrings(&strAddressFinalValue);
1260         
1261         strAddressFinalValue.insert(0, wxT("geo:"));
1262         
1263         ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1264                         &iter, &HomeGeographyList, &ContactData,
1265                         wxT("ALTID"), &HomeGeographyListAltID,
1266                         wxT("PID"), &HomeGeographyListPID,
1267                         wxT("MEDIATYPE"), &HomeGeographyListMediatype,
1268                         wxT("PREF"), &HomeGeographyListPref,
1269                         wxT(""), &HomeGeographyListTokens );
1270         
1271         ResetSaveProcessData();
1272         
1273     }
1274     
1275     ResetSaveProcessData();
1276     
1277     for (std::map<int,wxString>::iterator iter = BusinessGeographyList.begin();
1278          iter != BusinessGeographyList.end(); ++iter){
1279         
1280         wxString strAddressFinalValue = iter->second;
1281         
1282         ProcessCaptureStrings(&strAddressFinalValue);
1283         
1284         strAddressFinalValue.insert(0, wxT("geo:"));
1285         
1286         ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1287                         &iter, &BusinessGeographyList, &ContactData,
1288                         wxT("ALTID"), &BusinessGeographyListAltID,
1289                         wxT("PID"), &BusinessGeographyListPID,
1290                         wxT("MEDIATYPE"), &BusinessGeographyListMediatype,
1291                         wxT("PREF"), &BusinessGeographyListPref,
1292                         wxT(""), &BusinessGeographyListTokens );
1293         
1294         ResetSaveProcessData();
1295         
1296     }
1297     
1298     ResetSaveProcessData();
1299     
1300     for (std::map<int,wxString>::iterator iter = GeneralRelatedList.begin();
1301          iter != GeneralRelatedList.end(); ++iter){
1302         
1303         ProcessSaveData(wxT("RELATED"), &strValue2, &boolValue2, &boolValue,
1304                         &iter, &GeneralRelatedList, &ContactData,
1305                         wxT("ALTID"), &GeneralRelatedListAltID,
1306                         wxT("PID"), &GeneralRelatedListPID,
1307                         wxT("LANGUAGE"), &GeneralRelatedListLanguage,
1308                         wxT("TYPE"), &GeneralRelatedListRelType,
1309                         wxT("PREF"), &GeneralRelatedListPref,
1310                         wxT(""), &GeneralRelatedListTokens );
1311         
1312         ResetSaveProcessData();
1313         
1314     }
1315     
1316     ResetSaveProcessData();
1317     
1318     for (std::map<int,wxString>::iterator iter = GeneralWebsiteList.begin();
1319          iter != GeneralWebsiteList.end(); ++iter){
1320         
1321         ProcessSaveData(wxT("URL"), &strValue2, &boolValue2, &boolValue,
1322                         &iter, &GeneralWebsiteList, &ContactData,
1323                         wxT("ALTID"), &GeneralWebsiteListAltID,
1324                         wxT("PID"), &GeneralWebsiteListPID,
1325                         wxT("MEDIATYPE"), &GeneralWebsiteListMediatype,
1326                         wxT("PREF"), &GeneralWebsiteListPref,
1327                         wxT(""), &GeneralWebsiteListTokens );
1328         
1329         ResetSaveProcessData();
1330         
1331     }
1332     
1333     ResetSaveProcessData();
1334     
1335     for (std::map<int,wxString>::iterator iter = HomeWebsiteList.begin();
1336          iter != HomeWebsiteList.end(); ++iter){
1337         
1338         ProcessSaveData(wxT("URL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1339                         &iter, &HomeWebsiteList, &ContactData,
1340                         wxT("ALTID"), &HomeWebsiteListAltID,
1341                         wxT("PID"), &HomeWebsiteListPID,
1342                         wxT("MEDIATYPE"), &HomeWebsiteListMediatype,
1343                         wxT("PREF"), &HomeWebsiteListPref,
1344                         wxT(""), &HomeWebsiteListTokens );
1345         
1346         ResetSaveProcessData();
1347         
1348     }
1349     
1350     ResetSaveProcessData();
1351     
1352     for (std::map<int,wxString>::iterator iter = BusinessWebsiteList.begin();
1353          iter != BusinessWebsiteList.end(); ++iter){
1354         
1355         ProcessSaveData(wxT("URL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1356                         &iter, &BusinessWebsiteList, &ContactData,
1357                         wxT("ALTID"), &BusinessWebsiteListAltID,
1358                         wxT("PID"), &BusinessWebsiteListPID,
1359                         wxT("MEDIATYPE"), &BusinessWebsiteListMediatype,
1360                         wxT("PREF"), &BusinessWebsiteListPref,
1361                         wxT(""), &BusinessWebsiteListTokens );
1362         
1363         ResetSaveProcessData();
1364         
1365     }
1366     
1367     ResetSaveProcessData();
1368     
1369     for (std::map<int,wxString>::iterator iter = GeneralTitleList.begin();
1370          iter != GeneralTitleList.end(); ++iter){
1371         
1372         ProcessSaveData(wxT("TITLE"), &strValue2, &boolValue2, &boolValue,
1373                         &iter, &GeneralTitleList, &ContactData,
1374                         wxT("ALTID"), &GeneralTitleListAltID,
1375                         wxT("PID"), &GeneralTitleListPID,
1376                         wxT("LANGUAGE"), &GeneralTitleListLanguage,
1377                         wxT("PREF"), &GeneralTitleListPref,
1378                         wxT(""), &GeneralTitleListTokens );
1379         
1380         ResetSaveProcessData();
1381         
1382     }
1383     
1384     ResetSaveProcessData();
1385     
1386     for (std::map<int,wxString>::iterator iter = HomeTitleList.begin();
1387          iter != HomeTitleList.end(); ++iter){
1388         
1389         ProcessSaveData(wxT("TITLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1390                         &iter, &HomeTitleList, &ContactData,
1391                         wxT("ALTID"), &HomeTitleListAltID,
1392                         wxT("PID"), &HomeTitleListPID,
1393                         wxT("LANGUAGE"), &HomeTitleListLanguage,
1394                         wxT("PREF"), &HomeTitleListPref,
1395                         wxT(""), &HomeTitleListTokens );
1396         
1397         ResetSaveProcessData();
1398         
1399     }
1400     
1401     ResetSaveProcessData();
1402     
1403     for (std::map<int,wxString>::iterator iter = BusinessTitleList.begin();
1404          iter != BusinessTitleList.end(); ++iter){
1405         
1406         ProcessSaveData(wxT("TITLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1407                         &iter, &BusinessTitleList, &ContactData,
1408                         wxT("ALTID"), &BusinessTitleListAltID,
1409                         wxT("PID"), &BusinessTitleListPID,
1410                         wxT("LANGUAGE"), &BusinessTitleListLanguage,
1411                         wxT("PREF"), &BusinessTitleListPref,
1412                         wxT(""), &BusinessTitleListTokens );
1413         
1414         ResetSaveProcessData();
1415         
1416     }
1417     
1418     ResetSaveProcessData();
1419     
1420     for (std::map<int,wxString>::iterator iter = GeneralRoleList.begin();
1421          iter != GeneralRoleList.end(); ++iter){
1422         
1423         ProcessSaveData(wxT("ROLE"), &strValue2, &boolValue2, &boolValue,
1424                         &iter, &GeneralRoleList, &ContactData,
1425                         wxT("ALTID"), &GeneralRoleListAltID,
1426                         wxT("PID"), &GeneralRoleListPID,
1427                         wxT("LANGUAGE"), &GeneralRoleListLanguage,
1428                         wxT("PREF"), &GeneralRoleListPref,
1429                         wxT(""), &GeneralRoleListTokens );
1430         
1431         ResetSaveProcessData();
1432         
1433     }
1434     
1435     ResetSaveProcessData();
1436     
1437     for (std::map<int,wxString>::iterator iter = HomeRoleList.begin();
1438          iter != HomeRoleList.end(); ++iter){
1439         
1440         ProcessSaveData(wxT("ROLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1441                         &iter, &HomeRoleList, &ContactData,
1442                         wxT("ALTID"), &HomeRoleListAltID,
1443                         wxT("PID"), &HomeRoleListPID,
1444                         wxT("LANGUAGE"), &HomeRoleListLanguage,
1445                         wxT("PREF"), &HomeRoleListPref,
1446                         wxT(""), &HomeRoleListTokens );
1447         
1448         ResetSaveProcessData();
1449         
1450     }
1451     
1452     ResetSaveProcessData();
1453     
1454     for (std::map<int,wxString>::iterator iter = BusinessRoleList.begin();
1455          iter != BusinessRoleList.end(); ++iter){
1456         
1457         ProcessSaveData(wxT("ROLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1458                         &iter, &BusinessRoleList, &ContactData,
1459                         wxT("ALTID"), &BusinessRoleListAltID,
1460                         wxT("PID"), &BusinessRoleListPID,
1461                         wxT("LANGUAGE"), &BusinessRoleListLanguage,
1462                         wxT("PREF"), &BusinessRoleListPref,
1463                         wxT(""), &BusinessRoleListTokens );
1464         
1465         ResetSaveProcessData();
1466         
1467     }
1468     
1469     ResetSaveProcessData();
1470     
1471     for (std::map<int,wxString>::iterator iter = GeneralOrganisationsList.begin();
1472          iter != GeneralOrganisationsList.end(); ++iter){
1473         
1474         ProcessSaveData(wxT("ORG"), &strValue2, &boolValue2, &boolValue,
1475                         &iter, &GeneralOrganisationsList, &ContactData,
1476                         wxT("ALTID"), &GeneralOrganisationsListAltID,
1477                         wxT("PID"), &GeneralOrganisationsListPID,
1478                         wxT("LANGUAGE"), &GeneralOrganisationsListLanguage,
1479                         wxT("SORT-AS"), &GeneralOrganisationsListSortAs,
1480                         wxT("PREF"), &GeneralOrganisationsListPref,
1481                         wxT(""), &GeneralOrganisationsListTokens );
1482         
1483         ResetSaveProcessData();
1484         
1485     }
1486     
1487     ResetSaveProcessData();
1488     
1489     for (std::map<int,wxString>::iterator iter = HomeOrganisationsList.begin();
1490          iter != HomeOrganisationsList.end(); ++iter){
1491         
1492         ProcessSaveData(wxT("ORG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1493                         &iter, &HomeOrganisationsList, &ContactData,
1494                         wxT("ALTID"), &HomeOrganisationsListAltID,
1495                         wxT("PID"), &HomeOrganisationsListPID,
1496                         wxT("LANGUAGE"), &HomeOrganisationsListLanguage,
1497                         wxT("SORT-AS"), &HomeOrganisationsListSortAs,
1498                         wxT("PREF"), &HomeOrganisationsListPref,
1499                         wxT(""), &HomeOrganisationsListTokens );
1500         
1501         ResetSaveProcessData();
1502         
1503     }
1504     
1505     ResetSaveProcessData();
1506     
1507     for (std::map<int,wxString>::iterator iter = BusinessOrganisationsList.begin();
1508          iter != BusinessOrganisationsList.end(); ++iter){
1509         
1510         ProcessSaveData(wxT("ORG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1511                         &iter, &BusinessOrganisationsList, &ContactData,
1512                         wxT("ALTID"), &BusinessOrganisationsListAltID,
1513                         wxT("PID"), &BusinessOrganisationsListPID,
1514                         wxT("LANGUAGE"), &BusinessOrganisationsListLanguage,
1515                         wxT("SORT-AS"), &BusinessOrganisationsListSortAs,
1516                         wxT("PREF"), &BusinessOrganisationsListPref,
1517                         wxT(""), &BusinessOrganisationsListTokens );
1518         
1519         ResetSaveProcessData();
1520         
1521     }
1522     
1523     ResetSaveProcessData();
1524     
1525     for (std::map<int,wxString>::iterator iter = GeneralNoteList.begin();
1526          iter != GeneralNoteList.end(); ++iter){
1527         
1528         ProcessSaveData(wxT("NOTE"), &strValue2, &boolValue2, &boolValue,
1529                         &iter, &GeneralNoteList, &ContactData,
1530                         wxT("ALTID"), &GeneralNoteListAltID,
1531                         wxT("PID"), &GeneralNoteListPID,
1532                         wxT("LANGUAGE"), &GeneralNoteListLanguage,
1533                         wxT("PREF"), &GeneralNoteListPref,
1534                         wxT(""), &GeneralNoteListTokens );
1535         
1536         ResetSaveProcessData();
1537         
1538     }
1539     
1540     ResetSaveProcessData();
1541     
1542     for (std::map<int,wxString>::iterator iter = HomeNoteList.begin();
1543          iter != HomeNoteList.end(); ++iter){
1544         
1545         ProcessSaveData(wxT("NOTE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1546                         &iter, &HomeNoteList, &ContactData,
1547                         wxT("ALTID"), &HomeNoteListAltID,
1548                         wxT("PID"), &HomeNoteListPID,
1549                         wxT("LANGUAGE"), &HomeNoteListLanguage,
1550                         wxT("PREF"), &HomeNoteListPref,
1551                         wxT(""), &HomeNoteListTokens );
1552         
1553         ResetSaveProcessData();
1554         
1555     }
1556     
1557     ResetSaveProcessData();
1558     
1559     for (std::map<int,wxString>::iterator iter = BusinessNoteList.begin();
1560          iter != BusinessNoteList.end(); ++iter){
1561         
1562         ProcessSaveData(wxT("NOTE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1563                         &iter, &BusinessNoteList, &ContactData,
1564                         wxT("ALTID"), &BusinessNoteListAltID,
1565                         wxT("PID"), &BusinessNoteListPID,
1566                         wxT("LANGUAGE"), &BusinessNoteListLanguage,
1567                         wxT("PREF"), &BusinessNoteListPref,
1568                         wxT(""), &BusinessNoteListTokens );
1569         
1570         ResetSaveProcessData();
1571         
1572     }
1573     
1574     ResetSaveProcessData();
1575     
1576     for (std::map<int,wxString>::iterator iter = CategoriesList.begin();
1577          iter != CategoriesList.end(); ++iter){
1578         
1579         ProcessSaveData(wxT("CATEGORIES"), &strValue2, &boolValue2, &boolValue,
1580                         &iter, &CategoriesList, &ContactData,
1581                         wxT("ALTID"), &CategoriesListAltID,
1582                         wxT("PID"), &CategoriesListPID,
1583                         wxT("TYPE"), &CategoriesListType,
1584                         wxT("PREF"), &CategoriesListPref,
1585                         wxT(""), &CategoriesListTokens );
1586         
1587         ResetSaveProcessData();
1588         
1589     }
1590     
1591     // Pictures.
1592     
1593     for (std::map<int, std::string>::iterator iter = PicturesList.begin();
1594          iter != PicturesList.end(); ++iter){
1595         
1596         int intValueIndex = iter->first;
1597         
1598         std::map<int, std::string>::iterator stdstriter;
1599         std::map<int, wxString>::iterator enciter;
1600         
1601         striter = PicturesListPictureType.find(intValueIndex);
1602         enciter = PicturesListPicEncType.find(intValueIndex);
1603         
1604         ProcessSaveData(wxT("PHOTO"), &strValue2, &boolValue2, &boolValue,
1605                         &iter, &PicturesList, &striter,
1606                         &enciter, &ContactData,
1607                         wxT("ALTID"), &PicturesListAltID,
1608                         wxT("PID"), &PicturesListPID,
1609                         wxT("TYPE"), &PicturesListType,
1610                         wxT("PREF"), &PicturesListPref,
1611                         wxT(""), &PicturesListTokens);
1612         
1613         ResetSaveProcessData();
1614         
1615     }
1616     
1617     ResetSaveProcessData();
1618     
1619     // Logos.
1620     
1621     for (std::map<int, std::string>::iterator iter = LogosList.begin();
1622          iter != LogosList.end(); ++iter){
1623         
1624         int intValueIndex = iter->first;
1625         
1626         std::map<int, std::string>::iterator stdstriter;
1627         std::map<int, wxString>::iterator enciter;
1628         
1629         striter = LogosListPictureType.find(intValueIndex);
1630         enciter = LogosListPicEncType.find(intValueIndex);
1631         
1632         ProcessSaveData(wxT("LOGO"), &strValue2, &boolValue2, &boolValue,
1633                         &iter, &LogosList, &striter,
1634                         &enciter, &ContactData,
1635                         wxT("ALTID"), &LogosListAltID,
1636                         wxT("PID"), &LogosListPID,
1637                         wxT("TYPE"), &LogosListType,
1638                         wxT("PREF"), &LogosListPref,
1639                         wxT(""), &LogosListTokens );
1640         
1641         ResetSaveProcessData();
1642         
1643     }
1644     
1645     ResetSaveProcessData();
1646     
1647     // Sounds.
1648     
1649     for (std::map<int, std::string>::iterator iter = SoundsList.begin();
1650          iter != SoundsList.end(); ++iter){
1651         
1652         int intValueIndex = iter->first;
1653         
1654         std::map<int, std::string>::iterator stdstriter;
1655         std::map<int, wxString>::iterator enciter;
1656         
1657         striter = SoundsListAudioType.find(intValueIndex);
1658         enciter = SoundsListAudioEncType.find(intValueIndex);
1659         
1660         ProcessSaveData(wxT("SOUND"), &strValue2, &boolValue2, &boolValue,
1661                         &iter, &SoundsList, &striter,
1662                         &enciter, &ContactData,
1663                         wxT("ALTID"), &SoundsListAltID,
1664                         wxT("PID"), &SoundsListPID,
1665                         wxT("TYPE"), &SoundsListType,
1666                         wxT("PREF"), &SoundsListPref,
1667                         wxT(""), &SoundsListTokens );
1668         
1669         ResetSaveProcessData();
1670         
1671     }
1672     
1673     ResetSaveProcessData();
1674     
1675     for (std::map<int,wxString>::iterator iter = CalendarList.begin();
1676          iter != CalendarList.end(); ++iter){
1677         
1678         ProcessSaveData(wxT("CALURI"), &strValue2, &boolValue2, &boolValue,
1679                         &iter, &CalendarList, &ContactData,
1680                         wxT("ALTID"), &CalendarListAltID,
1681                         wxT("PID"), &CalendarListPID,
1682                         wxT("MEDIATYPE"), &CalendarListMediatype,
1683                         wxT("TYPE"), &CalendarListType,
1684                         wxT("PREF"), &CalendarListPref,
1685                         wxT(""), &CalendarListTokens );
1686         
1687         ResetSaveProcessData();
1688         
1689     }
1690     
1691     ResetSaveProcessData();
1692     
1693     for (std::map<int,wxString>::iterator iter = CalendarRequestList.begin();
1694          iter != CalendarRequestList.end(); ++iter){
1695         
1696         ProcessSaveData(wxT("CALADRURI"), &strValue2, &boolValue2, &boolValue,
1697                         &iter, &CalendarRequestList, &ContactData,
1698                         wxT("ALTID"), &CalendarRequestListAltID,
1699                         wxT("PID"), &CalendarRequestListPID,
1700                         wxT("MEDIATYPE"), &CalendarRequestListMediatype,
1701                         wxT("TYPE"), &CalendarRequestListType,
1702                         wxT("PREF"), &CalendarRequestListPref,
1703                         wxT(""), &CalendarRequestListTokens );
1704         
1705         ResetSaveProcessData();
1706         
1707     }
1708     
1709     ResetSaveProcessData();
1710     
1711     for (std::map<int,wxString>::iterator iter = FreeBusyList.begin();
1712          iter != FreeBusyList.end(); ++iter){
1713         
1714         ProcessSaveData(wxT("FBURL"), &strValue2, &boolValue2, &boolValue,
1715                         &iter, &FreeBusyList, &ContactData,
1716                         wxT("ALTID"), &FreeBusyListAltID,
1717                         wxT("PID"), &FreeBusyListPID,
1718                         wxT("MEDIATYPE"), &FreeBusyListMediatype,
1719                         wxT("TYPE"), &FreeBusyListType,
1720                         wxT("PREF"), &FreeBusyListPref,
1721                         wxT(""), &FreeBusyListTokens );
1722         
1723         ResetSaveProcessData();
1724         
1725     }
1726     
1727     for (std::map<int, wxString>::iterator iter = KeyList.begin();
1728          iter != KeyList.end(); ++iter){
1729         
1730         intValue2 = iter->first;
1731         
1732         // Process Alternative ID.
1733         
1734         striter = KeyListAltID.find(intValue2);
1735         
1736         if (striter->first == intValue2){
1737             
1738             strValue3 = striter->second;
1739             
1740             if (!strValue3.IsEmpty()){
1741                 
1742                 strValue3.Trim();
1743                 strValue3.Trim();
1744                 
1745                 if (boolValue2 == TRUE){
1746                     
1747                     strValue2.Append(wxT(";"));
1748                     
1749                 } else {
1750                     
1751                     boolValue2 = TRUE;
1752                     
1753                 }
1754                 
1755                 strValue2.Append(wxT("ALTID=") + strValue3);
1756                 
1757                 boolValue = TRUE;
1758                 
1759             }
1760             
1761         }
1762         
1763         // Process PID.
1764         
1765         striter = KeyListPID.find(intValue2);
1766         
1767         if (striter->first == intValue2){
1768             
1769             strValue3 = striter->second;
1770             
1771             if (!strValue3.IsEmpty()){
1772                 
1773                 strValue3.Trim();
1774                 strValue3.Trim();
1775                 
1776                 if (boolValue2 == TRUE){
1777                     
1778                     strValue2.Append(wxT(";"));
1779                     
1780                 } else {
1781                     
1782                     boolValue2 = TRUE;
1783                     
1784                 }
1785                 
1786                 strValue2.Append(wxT("PID=") + strValue3);
1787                 
1788                 boolValue = TRUE;
1789                 
1790             }
1791             
1792         }
1793         
1794         // Process Type.
1795         
1796         striter = KeyListType.find(intValue2);
1797         
1798         if (striter->first == intValue2){
1799             
1800             strValue3 = striter->second;
1801             
1802             if (!strValue3.IsEmpty()){
1803                 
1804                 strValue3.Trim();
1805                 strValue3.Trim();
1806                 
1807                 if (boolValue2 == TRUE){
1808                     
1809                     strValue2.Append(wxT(";"));
1810                     
1811                 } else {
1812                     
1813                     boolValue2 = TRUE;
1814                     
1815                 }
1816                 
1817                 strValue2.Append(wxT("TYPE=") + strValue3);
1818                 
1819                 boolValue = TRUE;
1820                 
1821             }
1822             
1823         }
1824         
1825         intiter = KeyListPref.find(intValue2);
1826         
1827         if (intiter->first == intValue2){
1828             
1829             intValue3 = intiter->second;
1830             
1831             if (intValue3){
1832                 
1833                 if (boolValue2 == TRUE){
1834                     
1835                     strValue2.Append(wxT(";"));
1836                     
1837                 } else {
1838                     
1839                     boolValue2 = TRUE;
1840                     
1841                 }
1842                 
1843                 strValue2.Append(wxT("PREF=") + wxString::Format(wxT("%i"), intValue3));
1844                 
1845                 boolValue = TRUE;
1846                 
1847             }
1848             
1849         }       
1850         
1851         // Process Tokens.
1852         
1853         striter = KeyListTokens.find(intValue2);
1854         
1855         if (striter->first == intValue2){
1856             
1857             strValue3 = striter->second;
1858             
1859             if (!strValue3.IsEmpty()){
1860                 
1861                 strValue3.Trim();
1862                 strValue3.Trim();
1863                 
1864                 if (boolValue2 == TRUE){
1865                     
1866                     strValue2.Append(wxT(";"));
1867                     
1868                 } else {
1869                     
1870                     boolValue2 = TRUE;
1871                     
1872                 }
1873                 
1874                 strValue2.Append(strValue3);
1875                 
1876                 boolValue = TRUE;
1877                 
1878             }
1879             
1880         }       
1881         
1882         // Get the key information.
1883         
1884         std::map<int, wxString>::iterator enciter;
1885         
1886         striter = KeyListDataType.find(intValue2);      
1887         //enciter = KeyListAudioEncType.find(intValue2);
1888         
1889         wxString strValueData;
1890         
1891         strValueData = iter->second;    
1892         //strValueData.insert(0, wxT("data:") + striter->second + wxT(";") + enciter->second + wxT(","));
1893         strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,"));       
1894         
1895         
1896         // Add to the vCard.
1897         
1898         if (boolValue == TRUE){
1899             
1900             ContactData.AddRaw(wxT("KEY;") + strValue2, strValueData);
1901             
1902         } else {
1903             
1904             ContactData.Add(wxT("KEY"), strValueData, TRUE);
1905             
1906         }
1907         
1908         ResetSaveProcessData();   
1909         
1910     }
1911     
1912     // Vendor specific items.
1913     
1914     ResetSaveProcessData();   
1915     
1916     for (std::map<int,wxString>::iterator iter = VendorList.begin();
1917          iter != VendorList.end(); ++iter){
1918         
1919         intValue2 = iter->first;        
1920         
1921         // Get the IANA PEN number.
1922         
1923         striter = VendorListPEN.find(intValue2);
1924         
1925         if (striter->first == intValue2){
1926             
1927             strValue2 = striter->second;
1928             
1929         }
1930         
1931         // Get the element name.
1932         
1933         striter = VendorListElement.find(intValue2);
1934         
1935         if (striter->first == intValue2){
1936             
1937             strValue3 = striter->second;
1938             
1939         }
1940         
1941         // Get the address.
1942         
1943         striter = VendorList.find(intValue2);
1944         
1945         if (striter->first == intValue2){
1946             
1947             strValue = striter->second;
1948             
1949         }
1950         
1951         // Add to the vCard.
1952         
1953         if (boolValue == TRUE){
1954             
1955             ContactData.AddRaw(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue);
1956             
1957         } else {
1958             
1959             ContactData.Add(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue, FALSE);
1960             
1961         }
1962         
1963         ResetSaveProcessData();
1964         
1965     }              
1966     
1967     ResetSaveProcessData();  
1968     
1969     // X-Tokens.
1970     
1971     for (std::map<int,wxString>::iterator iter = XTokenList.begin();
1972          iter != XTokenList.end(); ++iter){
1973         
1974         intValue2 = iter->first;        
1975         
1976         // Get the element name.
1977         
1978         striter = XTokenListTokens.find(intValue2);
1979         
1980         if (striter->first == intValue2){
1981             
1982             strValue2 = striter->second;
1983             
1984         }       
1985         
1986         // Get the address.
1987         
1988         striter = XTokenList.find(intValue2);
1989         
1990         if (striter->first == intValue2){
1991             
1992             strValue = striter->second;
1993             
1994         }
1995         
1996         // Add to the vCard.
1997         
1998         if (boolValue == TRUE){
1999             
2000             ContactData.AddRaw(wxT("X-") + strValue2, strValue);
2001             
2002         } else {
2003             
2004             ContactData.Add(wxT("X-") + strValue2, strValue, FALSE);
2005             
2006         }
2007         
2008         ResetSaveProcessData();
2009         
2010     }
2011     
2012     ResetSaveProcessData();
2013     
2014     if (FullNamesList.size() == 0){
2015         
2016         wxString FullName = cmbDisplayAs->GetValue();
2017         FullNamesList.insert(std::make_pair(0, FullName));
2018         FullNamesListAltID.insert(std::make_pair(0, wxT("")));
2019         FullNamesListPID.insert(std::make_pair(0, wxT("")));
2020         FullNamesListType.insert(std::make_pair(0, wxT("")));
2021         FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
2022         FullNamesListPref.insert(std::make_pair(0, 0));
2023         FullNamesListTokens.insert(std::make_pair(0, wxT("")));
2024         FNFirst = FALSE;
2025         
2026     }
2027     
2028     for (std::map<int, wxString>::iterator iter = FullNamesList.begin();
2029          iter != FullNamesList.end(); ++iter){
2030         
2031         if (FNFirst == TRUE){
2032             
2033             iter->second = cmbDisplayAs->GetValue();
2034             FNFirst = FALSE;
2035             
2036         }
2037         
2038         std::map<int,wxString>::iterator mapS;
2039         
2040         mapS = FullNamesListTokens.find(iter->first);
2041         
2042         ProcessSaveData(wxT("FN"), &strValue2, &boolValue2, &boolValue, 
2043                         &iter, &FullNamesList, &ContactData,
2044                         wxT("ALTID"), &FullNamesListAltID,
2045                         wxT("PID"), &FullNamesListPID,
2046                         wxT("TYPE"), &FullNamesListType,
2047                         wxT("LANGUAGE"), &FullNamesListLanguage,
2048                         wxT("PREF"), &FullNamesListPref,
2049                         wxT(""), &FullNamesListTokens );
2050         
2051         // Get the address.
2052         
2053         ResetSaveProcessData();    
2054         
2055     }
2056     
2057     //ContactData.Add(wxT("FN"), cmbDisplayAs->GetValue(), FALSE);
2058     
2059     // Insert revision (REV) date.
2060     
2061     // Get today's date and time.
2062     
2063     wxDateTime DateTimeNow = wxDateTime::Now();
2064     
2065     wxString DateRev;
2066     
2067     // Set year, month and date.
2068     
2069     int intYear = DateTimeNow.GetYear();
2070     int intMonth = DateTimeNow.GetMonth();
2071     int intDay = DateTimeNow.GetDay();
2072     
2073     DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intYear));
2074     
2075     if (intMonth < 10){
2076         
2077         DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMonth));
2078         
2079     } else {
2080         
2081         DateRev.Append(wxString::Format(wxT("%i"), intMonth));
2082         
2083     }
2084     
2085     if (intDay < 10){
2086         
2087         DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intDay));
2088         
2089     } else {
2090         
2091         DateRev.Append(wxString::Format(wxT("%i"), intDay));
2092         
2093     }
2094     
2095     //DateRev.Append(wx);
2096     //DateRev.Append(wx);
2097     //DateRev.Append(wx);
2098     DateRev.Append(wxT("T"));
2099     
2100     // Set hour, minute and second.
2101     
2102     int intHour = DateTimeNow.GetHour();
2103     int intMinute = DateTimeNow.GetMinute();
2104     int intSecond = DateTimeNow.GetSecond();
2105     
2106     if (intHour < 10){
2107         
2108         DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intHour));
2109         
2110     } else {
2111         
2112         DateRev.Append(wxString::Format(wxT("%i"), intHour));    
2113         
2114     }
2115     
2116     if (intMinute < 10){
2117         
2118         DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMinute));
2119         
2120     } else {
2121         
2122         DateRev.Append(wxString::Format(wxT("%i"), intMinute));
2123         
2124     }
2125     
2126     if (intSecond < 10){
2127         
2128         DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intSecond));
2129         
2130     } else {
2131         
2132         DateRev.Append(wxString::Format(wxT("%i"), intSecond));
2133         
2134     }
2135     
2136     //   DateRev.Append(wx);
2137     //   DateRev.Append(wx);
2138     //   DateRev.Append(wxString DateTimeNow->);
2139     DateRev.Append(wxT("Z"));    
2140     
2141     ContactData.Add(wxT("UID"), UIDToken, FALSE);
2142     
2143     // End the vCard File.
2144     
2145     ContactData.Add(wxT("END"), wxT("VCARD"), FALSE);
2146     
2147     FMTimer.Stop();
2148     ContactData.WriteFile(FilenameFinal);
2149     
2150     vCard34Conv ConvFileFun;
2151     
2152     wxString wxSData;
2153     
2154     ConvFileFun.ConvertToV3(FilenameFinal, &wxSData);
2155     
2156     wxString AccountDirPrefix;
2157     wxString AccountDir;
2158     wxString PrefDir;
2159     
2160 #if defined(__HAIKU__)
2161     
2162     //preffilename = wxT("noo");
2164 #elif defined(__APPLE__)
2165     
2166     PrefDir = GetUserPrefDir();
2167     
2168     wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
2169     
2170 #elif defined(__WIN32__)
2171     
2172     PrefDir = GetUserPrefDir();
2173     
2174     wxStringTokenizer wSTFilename(wxSContactFilename, wxT("\\"));
2175     
2176 #else
2177     
2178     PrefDir = GetUserPrefDir();
2179     
2180     wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
2181     
2182 #endif
2183     
2184     XABPreferences PrefData(PrefDir);
2185     
2186     wxString AccountType;
2187     
2188     for (int i = 0; i < PrefData.accounts.GetCount(); i++){
2189         
2190         AccountDir = PrefData.accounts.GetAccountDirectory(i) + wxT(".carddav");
2191         
2192         if (AccountDir == wxSContactAccount){
2193             
2194             AccountDirPrefix = PrefData.accounts.GetAccountDirPrefix(i);
2195             AccountDirPrefix.Trim();
2196             AccountType = PrefData.accounts.GetAccountType(i);
2197             break;
2198             
2199         }
2200         
2201     }
2202     
2203     wxString wxSplitFilename;
2204     wxString wxSDataURL;
2205     
2206     while(wSTFilename.HasMoreTokens()){
2207         
2208         wxSplitFilename = wSTFilename.GetNextToken();
2209         
2210     }
2211     
2212     wxSDataURL = wxSplitFilename;
2213     //wxSDataURL.Append(wxSplitFilename);
2214     
2215     // Find out if the filename exists in the table.
2216     
2217     if (AccountType == wxT("CardDAV") || AccountType == wxT("carddav")){
2218         
2219         wxString ETagResult;
2220         wxString ETagOriginal;
2221         
2222         ETagDB *ETagDBPtr = NULL;
2223         
2224         ETagDBPtr = ETagTmrPtr->GetPointer(wxSContactAccount);
2225         
2226         wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
2227         wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
2228         
2229         if (wxSETagOrig.IsEmpty()){
2230             
2231             // Generate the ETag.
2232             
2233             wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
2234             
2235         }
2236         
2237         if (wxSETag.IsEmpty()){
2238             
2239             // Update empty ETag.
2240             
2241             wxSETag = wxSETagOrig;
2242             ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag, wxSETagOrig);
2243             
2244         }
2245         else {
2246             
2247             // Don't change original ETag.
2248             
2249             wxSETag = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
2250             ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag);
2251             
2252         }
2253         
2254         if (EditMode == FALSE){
2255             
2256             ActMgrPtr->AddTask(0, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
2257             EditMode = TRUE;
2258             FMTimer.SetFilename(FilenameFinal);
2259             FMTimer.UpdateTimestamp();
2260             FMTimer.Start(10000, FALSE);
2261             
2262             wxCommandEvent reloadevent(RELOADCONTACTLIST);
2263             reloadevent.SetString(wxSContactAccount);
2264             wxPostEvent(this->GetParent(), reloadevent);
2265             
2266         }
2267         else {
2268             
2269             ActMgrPtr->AddTask(1, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
2270             FMTimer.UpdateTimestamp();
2271             FMTimer.Start(10000, FALSE);
2272             
2273         }
2274         
2275     }
2276     
2277     // Send a notification to update the main window
2278     // with the new details.
2279     
2280     UCNotif *ucd;
2281     ucd = new UCNotif;
2282     
2283     // TODO: Workout nickname settings by priority and
2284     // type.
2285     
2286     ucd->ContactAccount = wxSContactAccount;
2287     ucd->ContactFilename = FilenameFinal;
2288     ucd->ContactName = cmbDisplayAs->GetValue();
2289     ucd->ContactNameArray = ContactData.GetName();
2290     
2291     for (std::map<int,wxString>::iterator gniter = GeneralNicknamesList.begin();
2292          gniter != GeneralNicknamesList.end(); gniter++){
2293         
2294         ucd->ContactNickname = gniter->second;
2295         break;
2296         
2297     }
2298     
2299     wxCommandEvent event2(CE_UPDATECONTACTLIST);
2300     event2.SetClientData(ucd);
2301     wxPostEvent(MainPtr, event2);
2302     
2305 void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
2307     
2308     // Save the updated contact data and close the form.
2309     
2310     wxCommandEvent NullEvent;
2311     this->SaveContact(NullEvent);
2312     this->Close();
2313     
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy