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