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