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