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