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