Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Split frmContactEditor-Load.cpp into 24 files to make it more manageable.
[xestiaab/.git] / source / vcard / vcard34conv.cpp
1 #include "vcard34conv.h"
2 #include "vcard.h"
3 #include "../version.h"
4 #include "../common/textprocessing.h"
5 #include <wx/file.h>
6 #include <cmath>
7 #include <map>
9 #include <wx/ffile.h>
10 #include <wx/tokenzr.h>
11 #include <wx/datetime.h>
12 #include <wx/wx.h>
14 // vcard.cpp - Deals with vCard 4.0 formatted files meeting the
15 // RFC 6350 specification.
17 vCard34Conv::vCard34Conv(){
18     vCardBegin = FALSE;
19     vCardEnd = FALSE;
20     vCardFN = FALSE;
21     vCardVersion = 0.0;
22     SettingCount = 0;
23 }
25 bool vCard34Conv::ConvertToV3(wxString Filename, wxString *wxSData){
27         wxString V3Data;
28         wxString V4Data;
29         
30         // Load the contact into the contact editor.
31         
32         wxFFile ContactFile;
33         wxString wxSContactString;
34         wxString ContactLine;
35         vCard ContactData;
37         vCard ContactDatav3;
38         
39         //wxSContactFilename = Filename;
40         
41         // Check if we are using wxWidgets version 2.8 or less and
42         // execute the required command accordingly.
43         
44 #if wxABI_VERSION < 20900
45         ContactFile.Open(Filename.c_str(), wxT("r"));
46 #else
47         ContactFile.Open(Filename, wxT("r"));
48 #endif  
49         
50         if (ContactFile.IsOpened() == FALSE){
52                 return FALSE;
53         
54         }
55         
56         ContactFile.ReadAll(&wxSContactString, wxConvAuto());
57         
58         // Split the lines.
59         
60         std::map<int, wxString> ContactFileLines;
61         std::map<int, wxString>::iterator striter;
62         
63         wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
65         int ContactLineSeek = 0;
67         while (wSTContactFileLines.HasMoreTokens() == TRUE){
69                 ContactLine = wSTContactFileLines.GetNextToken();
70                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71                 ContactLineSeek++;              
72         
73         }
75         // Get the line.
77         bool QuoteMode = FALSE;
78         bool PropertyFind = TRUE;
79         bool HasExtraNicknames = FALSE;
80         bool IgnoreGender = FALSE;
81         bool ExtraLineSeek = TRUE;
82         bool BirthdayProcessed = FALSE;
83         bool AnniversaryProcessed = FALSE;
84         bool FNProcessed = FALSE;
85         bool GenderProcessed = FALSE;
86         bool NameProcessed = FALSE;
87         bool KindProcessed = FALSE;
88         bool FNFirst = FALSE;
89         bool NicknameFirst = FALSE;
90         bool TitleFirst = FALSE;
91         bool OrganisationFirst = FALSE;
92         bool NoteFirst = FALSE;
93         bool PhotoFirst = FALSE;
94         bool LogoFirst = FALSE;
95         int intExtraNickname = 0;
96         wxString wxSProperty;
97         wxString wxSPropertySeg1;
98         wxString wxSPropertySeg2;
99         wxString wxSPropertyNextLine;
100         size_t ContactLineLen = 0;
101         int QuoteBreakPoint = 0;
102         int FNCount = 0;
103         int NameCount = 0;
104         int NicknameCount = 0;
105         int ADRCount = 0;
106         int EmailCount = 0;
107         int IMPPCount = 0;
108         int TelCount = 0;
109         int LangCount = 0;
110         int TZCount = 0;
111         int GeoCount = 0;
112         int URLCount = 0;
113         int RelatedCount = 0;
114         int TitleCount = 0;
115         int RoleCount = 0;
116         int OrgCount = 0;
117         int NoteCount = 0;
118         int CategoryCount = 0;
119         int PhotoCount = 0;
120         int LogoCount = 0;
121         int SoundCount = 0;
122         int CalAdrCount = 0;
123         int CalReqAdrCount = 0;
124         int FreeBusyCount = 0;
125         int KeyCount = 0;
126         int VendorCount = 0;
127         int XTokenCount = 0;
128         int ItemSeek = 1;
129         //int intValueSeek = 1;
130         
131         wxString strVer;
132     
133     // Setup the version string.
134         
135         strVer.Append(wxT("-//Xestia//Address Book Version "));
136         strVer.Append(wxT(XSDAB_VERSION));
137         strVer.Append(wxT("//KW"));
138         
139         ContactDatav3.AddRaw(wxT("BEGIN"), wxT("VCARD"));
140         ContactDatav3.AddRaw(wxT("VERSION"), wxT("3.0"));
141         ContactDatav3.AddRaw(wxT("PRODID"), strVer);
143         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
144          iter != ContactFileLines.end(); ++iter){
145         
146                 // Find the colon which splits the start bit from the data part.
147                 
148                 ContactLine = iter->second;
149                 
150                 while (ExtraLineSeek == TRUE){
151                 
152                         // Check if there is extra data on the next line 
153                         // (indicated by space or tab at the start) and add data.
154                 
155                         iter++;
156                         
157                         if (iter == ContactFileLines.end()){
158                         
159                                 iter--;
160                                 break;
161                         
162                         }                       
163                 
164                         wxSPropertyNextLine = iter->second;
165                         
166                 
167                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
168                 
169                                 wxSPropertyNextLine.Remove(0, 1);
170                                 //wxSPropertyNextLine.Trim(FALSE);
171                                 //ContactLine.Trim();
172                                 ContactLine.Append(wxSPropertyNextLine);
173                 
174                         } else {
175                         
176                                 iter--;
177                                 ExtraLineSeek = FALSE;
178                         
179                         }
180                 
181                 }
183                 ContactLineLen = ContactLine.Len();
184                 
185                 // Make sure we are not in quotation mode.
186                 // Make sure colon does not have \ or \\ before it.
187                 
188                 wxSProperty.Clear();
189                 
190                 for (int i = 0; i <= ContactLineLen; i++){
191                 
192                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
193                         
194                                 PropertyFind = FALSE;
195                         
196                         } else if (PropertyFind == TRUE){
197                         
198                                 wxSProperty.Append(ContactLine.Mid(i, 1));
199                         
200                         }               
201                 
202                         if (ContactLine.Mid(i, 1) == wxT("\"")){
203                         
204                                 if (QuoteMode == TRUE){
205                                 
206                                         QuoteMode = FALSE;
207                                 
208                                 } else {
209                         
210                                         QuoteMode = TRUE;
211                                         
212                                 }
213                         
214                         }
215                         
216                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
217                         
218                                 QuoteBreakPoint = i;
219                                 break;
220                         
221                         }
222                 
223                 }
224                 
225                 // Split that line at the point into two variables (ignore the colon).
226                 
227                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
228                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
229                 
230                 // Add the data into the contact editor depending on what it is.
231                 
232                 if (wxSProperty == wxT("FN")){
233                         
234                         std::map<int, int> SplitPoints;
235                         std::map<int, int> SplitLength;
236                         std::map<int, int>::iterator SLiter;                    
237                         wxString PropertyData;
238                         wxString PropertyName;
239                         wxString PropertyValue;
240                         wxString PropertyTokens;
241                         int intPrevValue = 4;
243                         //SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
244                         
245                         intPrevValue = 3;
246                         
247                         if (FNFirst == FALSE){
249                                 ContactDatav3.AddRaw(wxT("FN"), wxSPropertySeg2);
250                                 
251                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
252         
253                                 } else {
254                                 
255                                         ContactDatav3.AddRaw(wxT("X-VCARD4-FN;X-FIRST=TRUE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
256                                                                 
257                                 }
258                                 FNFirst = TRUE;
259                         
260                         } else {
261                         
262                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
264                                         ContactDatav3.AddRaw(wxT("X-VCARD4-FN"), wxSPropertySeg2);
265         
266                                 } else {
267                                 
268                                         ContactDatav3.AddRaw(wxT("X-VCARD4-FN;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
269                                                 wxSPropertySeg2);
270                                 
271                                 }
272                         
273                         }       
274                 
275                 } else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
276                 
277                         std::map<int, int> SplitPoints;
278                         std::map<int, int> SplitLength;
279                         std::map<int, int>::iterator SLiter;                    
280                         wxString PropertyData;
281                         wxString PropertyName;
282                         wxString PropertyValue;
283                         wxString PropertyTokens;
284                         int intPrevValue = 3;
286                         intPrevValue = 2;
288                         ContactDatav3.AddRaw(wxT("N"), wxSPropertySeg2);
289                         
290                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
294                         } else {
295                         
296                                 ContactDatav3.AddRaw(wxT("X-VCARD4-N;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
297                         
298                         }
299                         
300                         NameProcessed = TRUE;
301                 
302                 } else if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
303                 
304                         // Process Data.
305                 
306                         std::map<int, int> SplitPoints;
307                         std::map<int, int> SplitLength;
308                         std::map<int, int>::iterator SLiter;                    
309                         wxString PropertyData;
310                         wxString PropertyName;
311                         wxString PropertyValue;
312                         wxString PropertyTokens;
313                         int intPrevValue = 5;
315                         intPrevValue = 4;
316                 
317                         ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-KIND"), wxSPropertySeg2);
318                 
319                         KindProcessed = TRUE;
320                 
321                 } else if (wxSProperty == wxT("MEMBER")){
322                 
323                         // Process Data.
324                         
325                         std::map<int, int> SplitPoints;
326                         std::map<int, int> SplitLength;
327                         std::map<int, int>::iterator SLiter;                    
328                         wxString PropertyData;
329                         wxString PropertyName;
330                         wxString PropertyValue;
331                         wxString PropertyTokens;
332                         int intPrevValue = 7;
334                         intPrevValue = 6;
336                         ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-MEMBER"), wxSPropertySeg2);
337                 
338                 } else if (wxSProperty == wxT("NICKNAME")){
339                         
340                         std::map<int, int> SplitPoints;
341                         std::map<int, int> SplitLength;
342                         std::map<int, int>::iterator SLiter;                    
343                         wxString PropertyData;
344                         wxString PropertyName;
345                         wxString PropertyValue;
346                         wxString PropertyTokens;
347                         int intPrevValue = 10;
349                         intPrevValue = 9;
350                         
351                         if (NicknameFirst == FALSE){
353                                 ContactDatav3.AddRaw(wxT("NICKNAME"), wxSPropertySeg2);
354                                 
355                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
356         
357                                 } else {
358                                 
359                                         ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;X-FIRST=TRUE;") 
360                                                 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
361                                 
362                                 }
363                                 NicknameFirst = TRUE;
364                                 ItemSeek++;
365                         
366                         } else {
367                         
368                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
370                                         ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME"), wxSPropertySeg2);
372                                 } else {
373                                 
374                                         ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"), 
375                                                 wxSPropertySeg2);
376                                                                 
377                                 }
378                         
379                         }
380                         
382                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
383                 
384                         // Do PID/ALTID/LANG things.
385                         
386                         std::map<int, int> SplitPoints;
387                         std::map<int, int> SplitLength;
388                         std::map<int, int>::iterator SLiter;                    
389                         wxString PropertyData;
390                         wxString PropertyName;
391                         wxString PropertyValue;
392                         wxString PropertyTokens;
393                         int intPrevValue = 8;
395                         
396                         intPrevValue = 7;
397                         
398                         if (wxSPropertySeg2.Mid(1, 1) == wxT(";")){
399                         
400                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
402                                         ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\""), wxSPropertySeg2.Mid(0, 1));
403         
404                                 } else {
405                                 
406                                         ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\";") 
407                                                 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), 
408                                                 wxSPropertySeg2.Mid(0, 1));                             
409                                                                 
410                                 }
411                         
412                         } else {
414                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
416                                         ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER"), wxSPropertySeg2);
417         
418                                 } else {
419                                         
420                                         ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
421                                                                 
422                                 }
423                         
424                         }
425                         
426                         GenderProcessed = TRUE;
427                 
428                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
430                         // Process date. Preserve the remainder in the string.
431                                 
432                         std::map<int, int> SplitPoints;
433                         std::map<int, int> SplitLength;
434                         std::map<int, int>::iterator SLiter;                    
435                         wxString PropertyData;
436                         wxString PropertyName;
437                         wxString PropertyValue;
438                         wxString PropertyTokens;
439                         bool NoYear = FALSE;
440                         int intPrevValue = 6;
442                         wxString strResults;            
443                 
444                         intPrevValue = 5;
445                 
446                         // Look for type before continuing.
448                         if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
449                         
450                                 strResults.Append(wxT("1604-"));
451                                 NoYear = TRUE;
453                                 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
454                                 strResults.Append(wxSPropertySeg2.Mid(4, 2));
455                         
456                         } else {
457                         
458                                 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
459                                 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
460                                 strResults.Append(wxSPropertySeg2.Mid(6, 2));
462                         }
463                         
465                         
466                         if (NoYear == TRUE){
468                                 ContactDatav3.AddRaw(wxT("BDAY;X-APPLE-OMIT-YEAR=1604"), strResults);
469                         
470                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
472                                         ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
473         
474                                 } else {
475                                         
476                                         ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
477                                 
478                                 }
479                         
480                         } else {
481                         
482                                 ContactDatav3.AddRaw(wxT("BDAY"), strResults);
484                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
486                                         ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
488                                 } else {
489                                         
490                                         ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
491                                                                 
492                                 }
493                         
494                         }
495                         
496                         BirthdayProcessed = TRUE;
497                 
498                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
499                         
500                         // Process date. Preserve the remainder in the string.
501                                 
502                         std::map<int, int> SplitPoints;
503                         std::map<int, int> SplitLength;
504                         std::map<int, int>::iterator SLiter;                    
505                         wxString PropertyData;
506                         wxString PropertyName;
507                         wxString PropertyValue;
508                         wxString PropertyTokens;
509                         int intPrevValue = 13;
511                         wxString strResults;
512                         bool NoYear = FALSE;
513                 
514                         intPrevValue = 12;
515                 
516                         // Look for type before continuing.
517                 
518                         if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
519                         
520                                 strResults.Append(wxT("1604-"));
521                                 NoYear = TRUE;
523                                 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
524                                 strResults.Append(wxSPropertySeg2.Mid(4, 2));
525                         
526                         } else {
527                         
528                                 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
529                                 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
530                                 strResults.Append(wxSPropertySeg2.Mid(6, 2));
532                         }
533                         
534                         if (NoYear == TRUE){
536                                 ContactDatav3.AddRaw(wxT("ANNIVERSARY;X-APPLE-OMIT-YEAR=1604"), strResults);
537                         
538                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
540                                         ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
542                                 } else {
543                                         
544                                         ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
545                                                                 
546                                 }
547                         
548                         } else {
549                         
550                                 ContactDatav3.AddRaw(wxT("ANNIVERSARY"), strResults);
552                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
554                                         ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
555         
556                                 } else {
557                                         
558                                         ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
559                                 
560                                 }
561                         
562                         }
563                         
564                         AnniversaryProcessed = TRUE;
565                 
566                 } else if (wxSProperty == wxT("TZ")){
567                 
568                         std::map<int, int> SplitPoints;
569                         std::map<int, int> SplitLength;
570                         std::map<int, int>::iterator SLiter;                    
571                         wxString PropertyData;
572                         wxString PropertyName;
573                         wxString PropertyValue;
574                         wxString PropertyTokens;
575                         int intPrevValue = 4;
576                         
577                         intPrevValue = 3;
578                         
579                         // Look for type before continuing.
580                         
581                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
583                                 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ"), wxSPropertySeg2);
584         
585                         } else {
586                                         
587                                 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
588                                 
589                         }
590                 
591                 } else if (wxSProperty == wxT("ADR")){
592                         
593                         std::map<int, int> SplitPoints;
594                         std::map<int, int> SplitLength;
595                         std::map<int, int>::iterator SLiter;                    
596                         wxString PropertyData;
597                         wxString PropertyName;
598                         wxString PropertyValue;
599                         wxString PropertyTokens;
600                         wxString AddressLabel;
601                         wxString AddressLang;
602                         wxString AddressAltID;
603                         wxString AddressPID;
604                         wxString AddressTokens;
605                         wxString AddressGeo;
606                         wxString AddressTimezone;
607                         wxString AddressType;
608                         wxString AddressMediatype;
609                         wxString AddressPOBox;
610                         wxString AddressExtended;
611                         wxString AddressStreet;
612                         wxString AddressLocality;
613                         wxString AddressCity;
614                         wxString AddressRegion;
615                         wxString AddressPostalCode;
616                         wxString AddressCountry;
617                         int intPrevValue = 5;
618                         
619                         intPrevValue = 4;
620                         
621                         // TODO: Check in value for X-ABLabel and use it if it is there.
622                     
623                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
625                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
626                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
627                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR"), wxSPropertySeg2);
628         
629                         } else {
631                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
632                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
633                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
634                                                                 
635                         }
636                         
637                         ItemSeek++;
638                 
639                 } else if (wxSProperty == wxT("EMAIL")){
640                 
641                         // TODO: Continue from here! See ADR for good example (Replace initer with intPrevValue).
642                         // Remove inserted comma for Extra Tokens in frmContactEditor.cpp
644                         std::map<int, int> SplitPoints;
645                         std::map<int, int> SplitLength;
646                         std::map<int, int>::iterator SLiter;
647                         std::map<int, int>::iterator SPoint;
648                         wxString PropertyData;
649                         wxString PropertyName;
650                         wxString PropertyValue;
651                         wxString PropertyTokens;
652                         wxString AddressLabel;
653                         wxString AddressLang;
654                         wxString AddressAltID;
655                         wxString AddressPID;
656                         wxString AddressTokens;
657                         wxString AddressGeo;
658                         wxString AddressTimezone;
659                         wxString AddressType;
660                         wxString AddressMediatype;
661                         wxString AddressPOBox;
662                         wxString AddressExtended;
663                         wxString AddressStreet;
664                         wxString AddressLocality;
665                         wxString AddressCity;
666                         wxString AddressRegion;
667                         wxString AddressPostalCode;
668                         wxString AddressCountry;
669                         int intPrevValue = 7;
670                         
671                         intPrevValue = 6;
672                         
673                     // TODO: Check in value for X-ABLabel and use it if it is there.
674                     
675                     if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
676                         
677                         ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
678                         ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
679                         ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL"), wxSPropertySeg2);
680                                                 
681                     } else {
682                         
683                         ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
684                         ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
685                         ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
686                         
687                     }
688                     
689                     ItemSeek++;
690                 
691                 } else if (wxSProperty == wxT("IMPP")){
693                         std::map<int, int> SplitPoints;
694                         std::map<int, int> SplitLength;
695                         std::map<int, int>::iterator SLiter;
696                         std::map<int, int>::iterator SPoint;
697                         wxString PropertyData;
698                         wxString PropertyName;
699                         wxString PropertyValue;
700                         wxString PropertyTokens;
701                         wxString IMPPType;
702                         wxString IMPPAddress;
703                         int intPrevValue = 6;
704                         
705                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
706                         
707                         intPrevValue = 5;
708                         
709                         // TODO: Check in value for X-ABLabel and use it if it is there.
710                     
711                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
713                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
714                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
715                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP"), wxSPropertySeg2);
716         
717                         } else {
719                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
720                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
721                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
722                                                                 
723                         }
724                     
725             ItemSeek++;
726                 
727                 } else if (wxSProperty == wxT("TEL")){
728                 
729                         // Check TEL and make sure it is functioning properly.
730                 
731                         std::map<int, int> SplitPoints;
732                         std::map<int, int> SplitLength;
733                         std::map<int, int> TypeSplitPoints;
734                         std::map<int, int> TypeSplitLength;
735                         std::map<int, int>::iterator SLiter;
736                         std::map<int, int>::iterator SPoint;                    
737                         std::map<int, int>::iterator TSLiter;
738                         std::map<int, int>::iterator TSPoint;
739                         wxString PropertyData;
740                         wxString PropertyName;
741                         wxString PropertyValue;
742                         wxString PropertyTokens;
743                         wxString TelType;
744                         wxString TelNumber;
745                         wxString TelTypeUI;
746                         wxString TelTypeDetail;
747                         wxString TelTypeOut;
748                         wxString FinalFriendlyString;
749                         int intSplitsFound = 0;
750                         int intSplitSize = 0;
751                         int intPrevValue = 5;
752                         int intType = 0;
753                         int intSplitPoint = 0;
755                         intPrevValue = 4;
756                         
757                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
758                         
759                         // Look for type before continuing.
760                         
761                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
762                         intiter != SplitPoints.end(); ++intiter){
763                         
764                                 SLiter = SplitLength.find(intiter->first);
765                         
766                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
767                                 
768                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
769                                 PropertyName = PropertyElement.GetNextToken();                          
770                                 PropertyValue = PropertyElement.GetNextToken();
771                                 
772                                 intPrevValue = intiter->second;
773                                 
774                                 if (PropertyName == wxT("TYPE")){
775                                 
776                                         // Process each value in type and translate each
777                                         // part.
778                                 
779                                         // Strip out the quotes if they are there.
781                                         size_t intPropertyValueLen = PropertyValue.Len();
782                                 
783                                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
784                                         
785                                                 PropertyValue.Trim();
786                                                 PropertyValue.RemoveLast();
787                                         
788                                         }                               
789                                 
790                                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
791                                         
792                                                 PropertyValue.Remove(0, 1);
793                                         
794                                         }
795                                         
796                                         TelTypeDetail = PropertyValue;
797                                         
798                                         intSplitSize = 0;
799                                         intSplitsFound = 0;
800                                         intSplitPoint = 0;
801                                         
802                                         for (int i = 0; i <= intPropertyValueLen; i++){
803                         
804                                                 intSplitSize++;
805                         
806                                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
807                         
808                                                         if (intSplitsFound == 0){
810                                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
811                                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
812                                         
813                                                         } else {
814                                         
815                                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
816                                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
817                                         
818                                                         }                       
820                                                         intSplitsFound++;
821                                                         i++;
822                                                         intSplitPoint = i;
823                                                         intSplitSize = 0;
824                         
825                                                 }
826                         
827                                         }
828                                         
829                                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
830                                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
831                                 
832                                         int intTypeSeek = 0;
833                                 
834                                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
835                                         typeiter != TypeSplitPoints.end(); ++typeiter){
837                                                 wxString TypePropertyName;
838                                                 
839                                                 TSLiter = TypeSplitLength.find(typeiter->first);
840                                                 
841                                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
842                                                 
843                                                 if (intTypeSeek == 0){
844                                                 
845                                                 
846                                                 } else {
847                                                                                                 
848                                                         TelTypeUI.Append(wxT(","));                                                     
849                                                 
850                                                 }
851                                         
852                                                 if (TypePropertyName == wxT("home")){
853                                                 
854                                                         intType = 1;
855                                                 
856                                                 } else if (TypePropertyName == wxT("work")){
857                                                 
858                                                         intType = 2;
859                                                 
860                                                 }
861                                                 
862                                                 if (TypePropertyName == wxT("text")){                                           
864                                                         if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Text")); } else { FinalFriendlyString.Append(_("Text")); }
866                                                         TelTypeOut.Append(wxT(";"));                                            
867                                                         TelTypeOut.Append(wxT("type=TEXT"));
868                                                 
869                                                 } else if (TypePropertyName == wxT("voice")){
870                                                 
871                                                         if (!FinalFriendlyString.IsEmpty()){  FinalFriendlyString.Append(_(", Voice")); } else { FinalFriendlyString.Append(_("Voice")); }
873                                                         TelTypeOut.Append(wxT(";"));                                            
874                                                         TelTypeOut.Append(wxT("type=VOICE"));
876                                                         intTypeSeek++;
877                                                 
878                                                 } else if (TypePropertyName == wxT("fax")){
879                                                 
880                                                         if (!FinalFriendlyString.IsEmpty()){  FinalFriendlyString.Append(_(", Fax")); } else { FinalFriendlyString.Append(_("Fax")); }
881                                                 
882                                                         TelTypeOut.Append(wxT(";"));
883                                                         TelTypeOut.Append(wxT("type=FAX"));
884                                                         intTypeSeek++;
885                                                 
886                                                 } else if (TypePropertyName == wxT("cell")){
887                                                 
888                                                         if (!FinalFriendlyString.IsEmpty()){  FinalFriendlyString.Append(_(", Mobile")); } else { FinalFriendlyString.Append(_("Mobile")); }
889                                                 
890                                                         TelTypeOut.Append(wxT(";"));
891                                                         TelTypeOut.Append(wxT("type=CELL"));
892                                                         intTypeSeek++;
893                                                 
894                                                 } else if (TypePropertyName == wxT("video")){
895                                                 
896                                                         if (!FinalFriendlyString.IsEmpty()){  FinalFriendlyString.Append(_(", Video")); } else { FinalFriendlyString.Append(_("Video")); }
898                                                         TelTypeOut.Append(wxT(";"));
899                                                         TelTypeOut.Append(wxT("type=VIDEO"));
900                                                         intTypeSeek++;
901                                                 
902                                                 } else if (TypePropertyName == wxT("pager")){
903                                                 
904                                                         if (!FinalFriendlyString.IsEmpty()){  FinalFriendlyString.Append(_(", Pager")); } else { FinalFriendlyString.Append(_("Pager")); }
906                                                         TelTypeOut.Append(wxT(";"));
907                                                         TelTypeOut.Append(wxT("type=PAGER"));
908                                                         intTypeSeek++;
909                                                 
910                                                 } else if (TypePropertyName == wxT("textphone")){
911                                                 
912                                                         //if (!TelTypeOut.IsEmpty()){ TelTypeOut.Append(wxT(";")); }
913                                                 
914                                                         if (!FinalFriendlyString.IsEmpty()){  FinalFriendlyString.Append(_(", Textphone")); } else { FinalFriendlyString.Append(_("Textphone")); }
915                                                 
916                                                         TelTypeOut.Append(wxT(";"));
917                                                         TelTypeOut.Append(wxT("type=TEXTPHONE"));
918                                                         intTypeSeek++;
919                                                 
920                                                 }
921                                                 
922                                                 
923                                         
924                                         }
925                                 
926                                 }
927                                 
928                                 
929                         
930                         }
931                         
932                         wxString FinalTel;
933                         
934                         // Remove 'tel:' if it is being used.
935                         
936                         if (wxSPropertySeg2.Mid(0, 4) == wxT("tel:")){
937                         
938                                 FinalTel = wxSPropertySeg2.Mid(4);
939                         
940                         } else {
941                         
942                                 FinalTel = wxSPropertySeg2;
943                         
944                         }
945                         
946                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
947                         
948                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
949                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
950                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL"), wxSPropertySeg2);
951         
952                         } else {
954                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
955                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
956                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL;") + wxSPropertySeg1.Mid(4), wxSPropertySeg2);
957                                 
958                         }
959                         
960                         ItemSeek++;
961                 
962                 } else if (wxSProperty == wxT("LANG")){
964                         std::map<int, int> SplitPoints;
965                         std::map<int, int> SplitLength;
966                         std::map<int, int>::iterator SLiter;                    
967                         wxString PropertyData;
968                         wxString PropertyName;
969                         wxString PropertyValue;
970                         wxString PropertyTokens;
971                         int intPrevValue = 6;
972                         
973                         intPrevValue = 5;
974                         
975             if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
976                         
977                 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG"), wxSPropertySeg2);
978                         
979             } else {
980                         
981                 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
982                         
983             }
984                 
985                 } else if (wxSProperty == wxT("GEO")){
986                 
987                         std::map<int, int> SplitPoints;
988                         std::map<int, int> SplitLength;
989                         std::map<int, int>::iterator SLiter;                    
990                         wxString PropertyData;
991                         wxString PropertyName;
992                         wxString PropertyValue;
993                         wxString PropertyTokens;
994                         wxString GeoType;
995                         wxString GeoData;
996                         int intPrevValue = 5;
997                         
998                         intPrevValue = 4;
999                         
1000                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1001                         
1002                         wxString strFinalGeoValue;
1003                         wxString strFinalType;
1004                         
1005                         if (wxSPropertySeg2.Mid(0, 3) == wxT("geo")){
1006                         
1007                                 strFinalGeoValue = wxSPropertySeg2.Mid(5);
1008                                 strFinalType = wxT("geo");
1009                         
1010                         } else {
1011                         
1012                                 wxStringTokenizer wSTSplit(wxSPropertySeg2, wxT(":")); 
1013                                 strFinalType = wSTSplit.GetNextToken();
1014                                 strFinalGeoValue = wSTSplit.GetNextToken();
1015                         
1016                         }
1017                         
1018                     if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1019                         
1020                         ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType, wxSPropertySeg2);
1021                         
1022                     } else {
1023                         
1024                         ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1025                         
1026                     }
1027                 
1028                 } else if (wxSProperty == wxT("RELATED")){
1029                         
1030                         std::map<int, int> SplitPoints;
1031                         std::map<int, int> SplitLength;
1032                         std::map<int, int>::iterator SLiter;                    
1033                         wxString PropertyData;
1034                         wxString PropertyName;
1035                         wxString PropertyValue;
1036                         wxString PropertyTokens;
1037                         wxString RelatedType;
1038                         wxString RelatedTypeOriginal;                   
1039                         wxString RelatedName;
1040                         bool FirstToken = TRUE;
1041                         int intPrevValue = 9;
1042                         
1043                         intPrevValue = 8;
1044                         
1045                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1046                         
1047                         wxString strDetail;
1048                         
1049                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1050                         intiter != SplitPoints.end(); ++intiter){
1051                         
1052                                 SLiter = SplitLength.find(intiter->first);
1053                         
1054                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second - 1));
1055                                 
1056                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1057                                 PropertyName = PropertyElement.GetNextToken();                          
1058                                 PropertyValue = PropertyElement.GetNextToken();
1059                                 
1060                                 if (PropertyName == wxT("TYPE") && FirstToken == TRUE){
1061                                 
1062                                         if (PropertyValue == wxT("contact")){
1063                 
1064                                                 strDetail = _("Contact");
1065                 
1066                                         } else if (PropertyValue == wxT("acquaintance")){
1067                 
1068                                                 strDetail = _("Acquaintance");
1069                 
1070                                         } else if (PropertyValue == wxT("friend")){
1071                 
1072                                                 strDetail = _("Friend");
1073                 
1074                                         } else if (PropertyValue == wxT("met")){
1075                 
1076                                                 strDetail = _("Met");
1077                 
1078                                         } else if (PropertyValue == wxT("co-worker")){
1079                 
1080                                                 strDetail = _("Co-worker");
1081                 
1082                                         } else if (PropertyValue == wxT("colleague")){
1083                 
1084                                                 strDetail = _("Colleague");
1085                 
1086                                         } else if (PropertyValue == wxT("co-resident")){
1087                 
1088                                                 strDetail = _("Co-resident");
1089                 
1090                                         } else if (PropertyValue == wxT("neighbor")){
1091                 
1092                                                 strDetail = _("Neighbour");
1093                 
1094                                         } else if (PropertyValue == wxT("child")){
1095                 
1096                                                 strDetail = _("Child");
1097                 
1098                                         } else if (PropertyValue == wxT("parent")){
1099                 
1100                                                 strDetail = _("Parent");
1101                 
1102                                         } else if (PropertyValue == wxT("sibling")){
1103                 
1104                                                 strDetail = _("Sibling");
1105                 
1106                                         } else if (PropertyValue == wxT("spouse")){
1107                 
1108                                                 strDetail = _("Spouse");
1109                 
1110                                         } else if (PropertyValue == wxT("kin")){
1111                 
1112                                                 strDetail = _("Kin");
1113                 
1114                                         } else if (PropertyValue == wxT("muse")){
1115                 
1116                                                 strDetail = _("Muse");
1117                 
1118                                         } else if (PropertyValue == wxT("crush")){
1119                 
1120                                                 strDetail = _("Crush");
1121                 
1122                                         } else if (PropertyValue == wxT("date")){
1123                 
1124                                                 strDetail = _("Date");
1125                 
1126                                         } else if (PropertyValue == wxT("sweetheart")){
1127                 
1128                                                 strDetail = _("Sweetheart");
1129                 
1130                                         } else if (PropertyValue == wxT("me")){
1131                 
1132                                                 strDetail = _("Me");
1133                 
1134                                         } else if (PropertyValue == wxT("agent")){
1135                 
1136                                                 strDetail = _("Agent");
1137                 
1138                                         } else if (PropertyValue == wxT("emergency")){
1139                 
1140                                                 strDetail = _("Emergency");
1141                 
1142                                         } else {
1143                 
1144                                                 strDetail = PropertyValue;
1145                 
1146                                         }
1147                                         
1148                                         FirstToken = FALSE;
1149                                 
1150                                 }
1151                                 
1152                         }
1153                         
1154                         if (strDetail.IsEmpty()){
1155                         
1156                                 strDetail = _("Relation");
1157                         
1158                         }
1159                         
1160                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1161                         
1162                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1163                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1164                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED"), wxSPropertySeg2);
1165         
1166                         } else {
1168                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1169                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1170                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1171                                                                 
1172                         }
1173                         
1174                         ItemSeek++;
1175                 
1176                 } else if (wxSProperty == wxT("URL")){
1178                         std::map<int, int> SplitPoints;
1179                         std::map<int, int> SplitLength;
1180                         std::map<int, int>::iterator SLiter;                    
1181                         wxString PropertyData;
1182                         wxString PropertyName;
1183                         wxString PropertyValue;
1184                         wxString PropertyTokens;
1185                         int intPrevValue = 5;
1186                         
1187                         intPrevValue = 4;
1188                         
1189                         // Todo: Check for X-ABLabel.
1190                         
1191                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1192                         
1193                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1194                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1195                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL"), wxSPropertySeg2);
1196         
1197                         } else {
1199                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1200                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1201                                 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1202                                 
1203                         }
1204                         
1205                         ItemSeek++;
1206                 
1207                 } else if (wxSProperty == wxT("TITLE")) {
1209                         std::map<int, int> SplitPoints;
1210                         std::map<int, int> SplitLength;
1211                         std::map<int, int>::iterator SLiter;                    
1212                         wxString PropertyData;
1213                         wxString PropertyName;
1214                         wxString PropertyValue;
1215                         wxString PropertyTokens;
1216                         int intPrevValue = 7;
1217                         
1218                         intPrevValue = 6;
1219                         
1220                         // Look for type before continuing.
1221                         
1222                         if (TitleFirst == FALSE){
1224                                 ContactDatav3.AddRaw(wxT("TITLE"), wxSPropertySeg2);
1225                                 
1226                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1227         
1228                                 } else {
1229                                 
1230                                         ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;X-FIRST=TRUE;") 
1231                                                 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1232                                 
1233                                 }
1234                                 TitleFirst = TRUE;
1235                                 ItemSeek++;
1236                         
1237                         } else {
1238                         
1239                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1241                                         ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE"), wxSPropertySeg2);
1242         
1243                                 } else {
1244                                 
1245                                         ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"), 
1246                                                 wxSPropertySeg2);
1247                                 
1248                                 }
1249                         
1250                         }
1251                         
1252                 } else if (wxSProperty == wxT("ROLE")) {
1253                 
1254                         std::map<int, int> SplitPoints;
1255                         std::map<int, int> SplitLength;
1256                         std::map<int, int>::iterator SLiter;                    
1257                         wxString PropertyData;
1258                         wxString PropertyName;
1259                         wxString PropertyValue;
1260                         wxString PropertyTokens;
1261                         int intPrevValue = 6;
1262                         
1263                         intPrevValue = 5;
1264                         
1265                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1267                                 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE"), wxSPropertySeg2);
1269                         } else {
1270                                         
1271                                 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1272                                 
1273                         }
1274                         
1275                 } else if (wxSProperty == wxT("ORG")) {
1277                         std::map<int, int> SplitPoints;
1278                         std::map<int, int> SplitLength;
1279                         std::map<int, int>::iterator SLiter;                    
1280                         wxString PropertyData;
1281                         wxString PropertyName;
1282                         wxString PropertyValue;
1283                         wxString PropertyTokens;
1284                         int intPrevValue = 5;
1285                         
1286                         intPrevValue = 4;
1287                         
1288                         if (OrganisationFirst == FALSE){
1290                                 ContactDatav3.AddRaw(wxT("ORG"), wxSPropertySeg2);
1291                                 
1292                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1293         
1294                                 } else {
1295                                 
1296                                         ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;X-FIRST=TRUE;") 
1297                                                 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1298                                 
1299                                 }
1300                                 OrganisationFirst = TRUE;
1301                                 ItemSeek++;
1302                         
1303                         } else {
1304                         
1305                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1307                                         ContactDatav3.AddRaw(wxT("X-VCARD4-ORG"), wxSPropertySeg2);
1308         
1309                                 } else {
1310                                 
1311                                         ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"), 
1312                                                 wxSPropertySeg2);
1313                                 
1314                                 }
1315                         
1316                         }
1317                         
1318                 } else if (wxSProperty == wxT("NOTE")) {
1319                 
1320                         std::map<int, int> SplitPoints;
1321                         std::map<int, int> SplitLength;
1322                         std::map<int, int>::iterator SLiter;                    
1323                         wxString PropertyData;
1324                         wxString PropertyName;
1325                         wxString PropertyValue;
1326                         wxString PropertyTokens;
1327                         int intPrevValue = 6;
1328                         
1329                         intPrevValue = 5;
1330                         
1331                         if (NoteFirst == FALSE){
1333                                 ContactDatav3.AddRaw(wxT("NOTE"), wxSPropertySeg2);
1334                                 
1335                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1336         
1337                                 } else {
1338                                 
1339                                         ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;X-FIRST=TRUE;") 
1340                                                 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1341                                                                 
1342                                 }
1343                                 NoteFirst = TRUE;
1344                                 ItemSeek++;
1345                         
1346                         } else {
1347                         
1348                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1350                                         ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE"), wxSPropertySeg2);
1351         
1352                                 } else {
1353                                 
1354                                         ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"), 
1355                                                 wxSPropertySeg2);
1356                                 
1357                                 }
1358                         
1359                         }
1360                         
1361                 } else if (wxSProperty == wxT("CATEGORIES")) {
1362                 
1363                         std::map<int, int> SplitPoints;
1364                         std::map<int, int> SplitLength;
1365                         std::map<int, int>::iterator SLiter;                    
1366                         wxString PropertyData;
1367                         wxString PropertyName;
1368                         wxString PropertyValue;
1369                         wxString PropertyTokens;
1370                         wxString PropertyType;
1371                         int intPrevValue = 12;
1372                         
1373                         intPrevValue = 11;
1374                         
1375                     if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1376                         
1377                         ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES"), wxSPropertySeg2);
1378    
1379                     } else {
1380                         
1381                         ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1383                     }
1384                         
1385                 } else if (wxSProperty == wxT("PHOTO")) {
1386                 
1387                         size_t intPropertyLen = wxSPropertySeg1.Len();
1388                         std::map<int, int> SplitPoints;
1389                         std::map<int, int> SplitLength;
1390                         std::map<int, int>::iterator SLiter;                    
1391                         wxString PropertyData;
1392                         wxString PropertyName;
1393                         wxString PropertyValue;
1394                         wxString PropertyTokens;
1395                         int intSplitsFound = 0;
1396                         int intSplitSize = 0;
1397                         int intPrevValue = 7;
1398                         
1399                         intPropertyLen = wxSPropertySeg2.Len();
1400                         SplitPoints.clear();
1401                         SplitLength.clear();
1402                         intSplitsFound = 0;
1403                         intSplitSize = 0;                       
1404                         
1405                         CaptureString(&wxSPropertySeg2, FALSE);
1406                         
1407                         for (int i = 0; i <= intPropertyLen; i++){
1408                 
1409                                 intSplitSize++;
1410                         
1411                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
1412                         
1413                                         intSplitsFound++;
1414                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1415                                         
1416                                         if (intSplitsFound == 6){ 
1417                                         
1418                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1419                                                 break; 
1420                                                 
1421                                         } else {
1422                                         
1423                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1424                                         
1425                                         }
1426                                         
1427                                         intSplitSize = 0;                                       
1428                         
1429                                 }
1430                 
1431                         }
1432                         
1433                         wxString wxSPhotoURI;
1434                         wxString wxSPhotoMIME;
1435                         wxString wxSPhotoEncoding;
1436                         wxString wxSPhotoData;
1437                         std::string base64enc;
1438                         
1439                         if (intSplitsFound == 0){
1440                         
1441                         } else {
1442                         
1443                                 std::map<int, int>::iterator striter;
1444                         
1445                                 striter = SplitLength.find(1);
1446                         
1447                                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
1448                         
1449                                 while (wSTDataType.HasMoreTokens() == TRUE){
1450                                 
1451                                         wxSPhotoURI = wSTDataType.GetNextToken();
1452                                         wxSPhotoMIME = wSTDataType.GetNextToken();
1453                                         break;
1454                                 
1455                                 }                       
1456                         
1457                                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));                    
1458                         
1459                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
1460                                 
1461                                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
1462                                         wxSPhotoData = wSTDataInfo.GetNextToken();                                      
1463                                         base64enc = wxSPhotoData.mb_str();
1464                                         break;
1465                                 
1466                                 }
1467                         
1468                         }
1469                         
1470                         
1471                         if (PhotoFirst == FALSE){
1473                                 bool PhotoKeepData = FALSE;
1475                                 wxString wxSPhotoMIMEF;
1476                                 
1477                                 if (wxSPhotoMIME == wxT("image/png")){
1478                                         wxSPhotoMIMEF = wxT("PNG");
1479                                 } else if (wxSPhotoMIME == wxT("image/jpeg")){
1480                                         wxSPhotoMIMEF = wxT("JPEG");
1481                                 } else if (wxSPhotoMIME == wxT("image/gif")){
1482                                         wxSPhotoMIMEF = wxT("GIF");
1483                                 } else if (wxSPhotoMIME == wxT("image/bmp")){
1484                                         wxSPhotoMIMEF = wxT("BMP");                     
1485                                 } else {
1486                                         wxSPhotoMIMEF = wxT("UNKNOWN");
1487                                         PhotoKeepData = TRUE;
1488                                 }
1490                                 ContactDatav3.AddRaw(wxT("PHOTO;ENCODING=b;TYPE=") + wxSPhotoMIMEF, wxSPhotoData);
1492                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1493         
1494                                 } else {
1496                                         if (PhotoKeepData == TRUE){
1497                                 
1498                                                 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;") 
1499                                                         + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxSPropertySeg2);
1500                                                 
1501                                         } else {
1503                                                 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;") 
1504                                                         + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxT(""));
1505                                         
1506                                         }
1507                                 
1508                                 }
1509                                 PhotoFirst = TRUE;
1510                                 ItemSeek++;
1511                         
1512                         } else {
1513                         
1514                                 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1516                                         ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO"), wxSPropertySeg2);
1517         
1518                                 } else {
1519                                 
1520                                         ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"), 
1521                                                 wxSPropertySeg2);
1522                                 }
1523                         
1524                         }
1525                         
1526                 } else if (wxSProperty == wxT("LOGO")) {
1527                 
1528                         std::map<int, int> SplitPoints;
1529                         std::map<int, int> SplitLength;
1530                         std::map<int, int>::iterator SLiter;                    
1531                         wxString PropertyData;
1532                         wxString PropertyName;
1533                         wxString PropertyValue;
1534                         wxString PropertyTokens;
1535                         int intPrevValue = 6;
1536                         
1537                         intPrevValue = 5;
1538                         
1539                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1540                         
1541                                 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO"), wxSPropertySeg2);
1543                         } else {
1544                         
1545                                 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1546                         
1547                         }
1548                         
1549                 } else if (wxSProperty == wxT("SOUND")) {
1550                 
1551                         std::map<int, int> SplitPoints;
1552                         std::map<int, int> SplitLength;
1553                         std::map<int, int>::iterator SLiter;                    
1554                         wxString PropertyData;
1555                         wxString PropertyName;
1556                         wxString PropertyValue;
1557                         wxString PropertyTokens;
1558                         int intPrevValue = 7;
1559                         
1560                         intPrevValue = 6;
1561                         
1562                         if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1563                         
1564                                 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND"), wxSPropertySeg2);
1566                         } else {
1567                         
1568                                 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1569                         
1570                         }
1571                         
1572                 } else if (wxSProperty == wxT("CALURI")){
1573                 
1574                         std::map<int, int> SplitPoints;
1575                         std::map<int, int> SplitLength;
1576                         std::map<int, int>::iterator SLiter;                    
1577                         wxString PropertyData;
1578                         wxString PropertyName;
1579                         wxString PropertyValue;
1580                         wxString PropertyTokens;
1581                         int intPrevValue = 8;
1582             
1583                         intPrevValue = 7;
1584                         
1585             if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1586                         
1587                 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI"), wxSPropertySeg2);
1589             } else {
1590                         
1591                 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1593             }
1594                 
1595                 } else if (wxSProperty == wxT("CALADRURI")){
1597                         std::map<int, int> SplitPoints;
1598                         std::map<int, int> SplitLength;
1599                         std::map<int, int>::iterator SLiter;                    
1600                         wxString PropertyData;
1601                         wxString PropertyName;
1602                         wxString PropertyValue;
1603                         wxString PropertyTokens;
1604                         int intPrevValue = 11;
1605                         
1606                         intPrevValue = 10;
1607                         
1608                     if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1609                         
1610                         ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI"), wxSPropertySeg2);
1612                     } else {
1613                         
1614                         ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1616                     }
1617                 
1618                 } else if (wxSProperty == wxT("FBURL")){
1619                 
1620                         std::map<int, int> SplitPoints;
1621                         std::map<int, int> SplitLength;
1622                         std::map<int, int>::iterator SLiter;                    
1623                         wxString PropertyData;
1624                         wxString PropertyName;
1625                         wxString PropertyValue;
1626                         wxString PropertyTokens;
1627                         int intPrevValue = 7;
1628             
1629                         intPrevValue = 6;
1630                         
1631                     if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1632                         
1633                         ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL"), wxSPropertySeg2);
1635                     } else {
1636                         
1637                         ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1639                     }
1640                 
1641                 } else if (wxSProperty == wxT("KEY")){
1642                 
1643                         std::map<int, int> SplitPoints;
1644                         std::map<int, int> SplitLength;
1645                         std::map<int, int>::iterator SLiter;                    
1646                         wxString PropertyData;
1647                         wxString PropertyName;
1648                         wxString PropertyValue;
1649                         wxString PropertyTokens;
1650                         int intPrevValue = 5;
1651                         
1652                         intPrevValue = 4;
1653                                                 
1654             if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1655                         
1656                 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY"), wxSPropertySeg2);
1658             } else {
1659                         
1660                 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1662             }
1663                 
1664                 } else if (wxSProperty == wxT("UID")){
1665                 
1666                         ContactDatav3.AddRaw(wxT("UID"), wxSPropertySeg2);
1667                 
1668                 } else if (wxSProperty.Mid(0, 3) == wxT("VND")){
1669                 
1670                         // Split the Vendor three ways.
1671                         
1672                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
1673                         
1674                         wxString wxSVNDID;
1675                         wxString wxSVNDPropName;
1676                         
1677                         size_t intPrevValue = (wxSProperty.Len() + 1);
1679                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
1680                         
1681                                 wSTVendorDetails.GetNextToken();
1682                                 wxSVNDID = wSTVendorDetails.GetNextToken();
1683                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
1684                                 break;
1685                         
1686                         }
1688                     if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1689                         
1690                         ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty, wxSPropertySeg2);
1692                     } else {
1693                         
1694                         ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1696                     }
1697                 
1698                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
1699                         
1700                         size_t intPrevValue = (wxSProperty.Len() + 1);
1701                         
1702             if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1703                         
1704                 ContactDatav3.AddRaw(wxSProperty, wxSPropertySeg2);
1706             } else {
1707                         
1708                 ContactDatav3.AddRaw(wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1710             }
1711                         
1712                 }
1713                 
1714                 // Reset the variables.
1715                 
1716                 QuoteMode = FALSE;
1717                 PropertyFind = TRUE;
1718                 ExtraLineSeek = TRUE;
1719                 ContactLineLen = 0;
1720                 QuoteBreakPoint = 0;
1721                 ContactLine.Clear();
1722                 wxSProperty.Clear();    
1723         
1724         }
1725         
1726         ContactDatav3.AddRaw(wxT("END"), wxT("VCARD"));
1727         *wxSData = ContactDatav3.WriteString();
1728         
1729         return TRUE;
1730         
1733 bool vCard34Conv::ConvertToV4(wxString *wxSData, vCard *vCardOut){
1734         
1735         std::map<int, wxString> ContactFileLines;
1736         std::map<int, bool> ContactFileProcessed;
1737         std::map<int, bool> ContactFileProcessedWorking;
1738         std::map<int, wxString>::iterator striter;
1739         std::map<int,bool>::iterator iterbool;
1740         std::map<int,bool>::iterator iterboolsub;
1741         wxString ContactLineRec;
1743         // Process the received data.
1744         
1745         wxStringTokenizer wSTContactFileLines(*wxSData, wxT("\r\n"));
1747         int ContactLineSeek = 0;
1749         while (wSTContactFileLines.HasMoreTokens() == TRUE){
1751                 ContactLineRec = wSTContactFileLines.GetNextToken();
1752                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLineRec));
1753                 ContactFileProcessed.insert(std::make_pair(ContactLineSeek, FALSE));
1754                 ContactLineSeek++;              
1755         
1756         }
1757         
1758         bool QuoteMode = FALSE;
1759         bool PropertyFind = TRUE;
1760         bool ExtraLineSeek = TRUE;
1761         bool ExtraLineSeekSub = TRUE;
1762         bool BirthdayProcessed = FALSE;
1763         bool AnniversaryProcessed = FALSE;
1764         bool FNProcessed = FALSE;
1765         bool GenderProcessed = FALSE;
1766         bool NameProcessed = FALSE;
1767         bool FNFirst = FALSE;
1768         bool NicknameFirst = FALSE;
1769         bool TitleFirst = FALSE;
1770         bool OrganisationFirst = FALSE;
1771         bool NoteFirst = FALSE;
1772         bool PhotoFirst = FALSE;
1773         bool LogoFirst = FALSE;
1774         bool NameFirst = FALSE;
1775         bool FoundData = FALSE;
1776         int intExtraNickname = 0;
1777         wxString wxSProperty;
1778         wxString wxSPropertyVCARD4;
1779         wxString wxSPropertySeg1;
1780         wxString wxSPropertySeg2;
1781         wxString wxSPropertyNextLine;
1782         wxString ContactLine;
1783         wxString ContactLineSub;
1784         wxString PropertyName;
1785         wxString PropertyValue;
1786         wxString PropertyDataStr;
1787         size_t ContactLineLen = 0;
1788         size_t ContactLineSubLen = 0;
1789         int QuoteBreakPoint = 0;
1790         size_t intPrevValueSub = 0;
1792         std::map<wxString, wxString> PropertyData;
1793         std::map<wxString, bool> PropertyLock;
1794         std::map<wxString, wxString> TempPropertyData;
1795         std::map<wxString, bool> TempPropertyLock;
1796         std::map<int, int> TempSplitPoints;
1797         std::map<int, int> TempSplitLength;
1798         std::map<int, int>::iterator SLiter;
1800         wxString PropertFindSub;
1801         wxString wxSPropertySub;
1802         wxString wxSPropertySeg1Sub;
1803         wxString wxSPropertySeg2Sub;
1804         wxString wxSPropertyValues;
1805         wxString wxSPropertyData;
1806         wxString wxSPropertyNameConv;
1807         wxString wxSPropertyXVCard4Value;
1808         wxString ItemProcString;
1809         
1810         bool XVCard4Value = FALSE;
1811         bool VCard3Value = FALSE;
1812         bool SeekItemData = FALSE;
1813         
1814         wxString strVer;
1815     
1816         // Setup the version string.
1817         
1818         strVer.Append(wxT("-//Xestia//Address Book Version "));
1819         strVer.Append(wxT(XSDAB_VERSION));
1820         strVer.Append(wxT("//KW"));
1821         
1822         vCardOut->AddRaw(wxT("BEGIN"), wxT("VCARD"));
1823         vCardOut->AddRaw(wxT("VERSION"), wxT("4.0"));
1824         vCardOut->AddRaw(wxT("PRODID"), strVer);
1825         
1826                 // FN
1827                 // NICKNAME
1828                 // TITLE
1829                 // ORG
1830                 // NOTE
1831                 // PHOTO
1832                 
1833         // Process the properties which have X-FIRST.
1834         
1835         // Clone the ContactFileProcessed into ContactFileProcessedWorking.
1837         ContactFileProcessedWorking.insert(ContactFileProcessed.begin(), ContactFileProcessed.end());
1839         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
1840          iter != ContactFileLines.end(); ++iter){
1841          
1842                 ExtraLineSeek = TRUE;
1844                 iterbool = ContactFileProcessed.find(iter->first);
1845                 
1846                 ContactLine = iter->second;
1847                 
1848                 // Ignore certain variables as they are not needed.
1849                 
1850                 if (ContactLine == wxT("BEGIN:VCARD") || 
1851                 ContactLine == wxT("END:VCARD") || 
1852                 ContactLine.Mid(0, 8) == wxT("VERSION:") || 
1853                 ContactLine.Mid(0, 7) == wxT("PRODID:") || 
1854                 ContactLine.Mid(0, 5) == wxT("X-AIM") || 
1855                 ContactLine.Mid(0, 5) == wxT("X-MSN") || 
1856                 ContactLine.Mid(0, 5) == wxT("X-ICQ") || 
1857                 ContactLine.Mid(0, 10) == wxT("X-GADUGADU") || 
1858                 ContactLine.Mid(0, 7) == wxT("X-YAHOO") || 
1859                 ContactLine.Mid(0, 7) == wxT("X-SKYPE") || 
1860                 ContactLine.Mid(0, 8) == wxT("X-JABBER") ||
1861                 ContactLine.Mid(0, 4) == wxT("REV:")){
1862                         
1863                         iterbool->second = TRUE;
1864                         continue;
1865                         
1866                 }
1867                 
1868                 if (iterbool->second == TRUE){
1869                         
1870                         continue;
1871                         
1872                 }
1873                 
1874                 if (ContactLine.Mid(0, 1) == wxT(" ") || ContactLine.Mid(0, 1) == wxT("\t")){
1875                 
1876                         continue;
1877                 
1878                 }
1879         
1880                 if (ContactLine.Mid(0, 4) == wxT("item")){
1881                 
1882                         // Line is a itemn... so ignore.
1883                 
1884                         continue;
1885                 
1886                 }
1887                 
1888                 std::map<int,int> DataLineProcess;
1889                 std::map<int, bool>::iterator DLSLiter;
1890                 std::map<int,int> DataLineProcessOriginal;
1891                 int DataLineSeek = 0;
1892                 int DataLineSeekOrig = 0;
1894                 std::map<int,wxString>::iterator itersub = iter;
1895                 DataLineProcessOriginal.insert(std::make_pair(DataLineSeekOrig, iterbool->first));
1896                 DataLineSeekOrig++;
1898                 while (ExtraLineSeek == TRUE){
1899                 
1900                         // Check if there is extra data on the next line 
1901                         // (indicated by space or tab at the start) and add data.
1902                 
1903                         itersub++;
1905                         if (itersub == ContactFileLines.end()){
1907                                 break;
1909                         }
1911                         iterboolsub = ContactFileProcessed.find(itersub->first);
1913                         if (iterboolsub == ContactFileProcessed.end()){
1914                         
1915                                 break;
1916                         
1917                         }
1918                         
1919                         if (iterboolsub->second == TRUE){
1920                         
1921                                 continue;
1922                         
1923                         }               
1924                 
1925                         wxSPropertyNextLine = itersub->second;
1926                 
1927                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
1928                 
1929                                 wxSPropertyNextLine.Remove(0, 1);
1930                                 //wxSPropertyNextLine.Trim(FALSE);
1931                                 //ContactLine.Trim();
1932                                 ContactLine.Append(wxSPropertyNextLine);
1933                                 DataLineProcessOriginal.insert(std::make_pair(DataLineSeekOrig, iterboolsub->first));
1934                                 DataLineSeekOrig++;
1935                                 //iterboolsub->second = TRUE;
1936                 
1937                         } else {
1938                         
1939                                 ExtraLineSeek = FALSE;
1940                         
1941                         }
1942                 
1943                 }
1944                 
1945                 ContactLineLen = ContactLine.Len();
1946                 
1947                 for (int i = 0; i <= ContactLineLen; i++){
1948                 
1949                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
1950                         
1951                                 PropertyFind = FALSE;
1952                         
1953                         } else if (PropertyFind == TRUE){
1954                         
1955                                 wxSProperty.Append(ContactLine.Mid(i, 1));
1956                         
1957                         }               
1958                 
1959                         if (ContactLine.Mid(i, 1) == wxT("\"")){
1960                         
1961                                 if (QuoteMode == TRUE){
1962                                 
1963                                         QuoteMode = FALSE;
1964                                 
1965                                 } else {
1966                         
1967                                         QuoteMode = TRUE;
1968                                         
1969                                 }
1970                         
1971                         }
1972                         
1973                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
1974                         
1975                                 QuoteBreakPoint = i;
1976                                 break;
1977                         
1978                         }
1979                 
1980                 }
1982                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
1983                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
1985                 wxStringTokenizer wxSPropertySegSplit(wxSPropertySeg1, wxT(";"));
1986                 wxSProperty = wxSPropertySegSplit.GetNextToken();
1987                         
1988                 // Check what type of property it is.
1989                 
1990                 FoundData = FALSE;
1991                 
1992                 if ((wxSProperty == wxT("PHOTO") && PhotoFirst == FALSE) ||
1993                 (wxSProperty == wxT("NICKNAME") && NicknameFirst == FALSE) || 
1994                 (wxSProperty == wxT("TITLE") && TitleFirst == FALSE) || 
1995                 (wxSProperty == wxT("FN") && FNFirst == FALSE) || 
1996                 (wxSProperty == wxT("ORG") && OrganisationFirst == FALSE) ||
1997                 (wxSProperty == wxT("NOTE") && NoteFirst == FALSE)){
1998                         
1999                         wxSPropertyVCARD4 = wxT("X-VCARD4-") + wxSProperty;
2000                         intPrevValueSub = (wxSPropertyVCARD4.Len() + 2);
2001                         
2002                         for (std::map<int,wxString>::iterator itersub = ContactFileLines.begin(); 
2003                         itersub != ContactFileLines.end(); ++itersub){
2004                 
2005                                 //DataLineProcess = DataLineProcessOriginal;
2006                                 //DataLineSeek = DataLineSeekOrig;
2007                 
2008                                 ContactLineSub = itersub->second;
2009                 
2010                                 ExtraLineSeekSub = TRUE;
2012                                 iterboolsub = ContactFileProcessed.find(itersub->first);
2013                                 //std::map<int,bool>::iterator iterorig = ContactFileProcessed.find(itersub->first);
2014                                 //std::map<int,bool>::iterator itersuborig;
2015                 
2016                                 // Ignore certain variables as they are not needed.
2017                 
2018                                 if (ContactLineSub == wxT("BEGIN:VCARD") || 
2019                                 ContactLineSub == wxT("END:VCARD") || 
2020                                 ContactLineSub.Mid(0, 8) == wxT("VERSION:") || 
2021                                 ContactLineSub.Mid(0, 7) == wxT("PRODID:") || 
2022                                 ContactLineSub.Mid(0, 5) == wxT("X-AIM") || 
2023                                 ContactLineSub.Mid(0, 5) == wxT("X-MSN") || 
2024                                 ContactLineSub.Mid(0, 5) == wxT("X-ICQ") || 
2025                                 ContactLineSub.Mid(0, 10) == wxT("X-GADUGADU") || 
2026                                 ContactLineSub.Mid(0, 7) == wxT("X-YAHOO") || 
2027                                 ContactLineSub.Mid(0, 7) == wxT("X-SKYPE") || 
2028                                 ContactLineSub.Mid(0, 8) == wxT("X-JABBER") ||
2029                                 ContactLineSub.Mid(0, 4) == wxT("REV:")){
2030                         
2031                                         iterboolsub->second = TRUE;
2032                                         continue;
2033                         
2034                                 }
2035                 
2036                                 if (iterboolsub->second == TRUE){
2038                                         continue;
2039                         
2040                                 }
2041                 
2042                                 if (ContactLineSub.Mid(0, 1) == wxT(" ") || ContactLineSub.Mid(0, 1) == wxT("\t")){
2043                 
2044                                         continue;
2045                 
2046                                 }
2047         
2048                                 if (ContactLineSub.Mid(0, 4) == wxT("item")){
2049                 
2050                                         // Line is a itemn... so ignore.
2051                 
2052                                         continue;
2053                 
2054                                 }
2055                 
2056                                 //std::map<int,wxString>::iterator itersub = iter;
2057                                 
2058                                 DataLineProcess.insert(std::make_pair(DataLineSeek, itersub->first));
2059                                 DataLineSeek++;
2063                                 while (ExtraLineSeekSub == TRUE){
2065                                         if (itersub == ContactFileLines.end()){
2066                                                 ExtraLineSeekSub = FALSE;
2067                                                 continue;
2068                                         } else {
2069                                                 itersub++;
2071                                         }
2073                                         iterboolsub = ContactFileProcessedWorking.find(itersub->first);
2075                                         wxSPropertyNextLine = itersub->second;
2077                                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
2079                                                 wxSPropertyNextLine.Remove(0, 1);
2080                                                 //wxSPropertyNextLine.Trim(FALSE);
2081                                                 //ContactLine.Trim();
2082                                                 ContactLineSub.Append(wxSPropertyNextLine);
2083                                                 //iterboolsub->second = TRUE;
2084                                                 DataLineProcess.insert(std::make_pair(DataLineSeek, itersub->first));
2085                                                 DataLineSeek++;
2087                                         } else {
2089                                                 itersub--;
2090                                                 ExtraLineSeekSub = FALSE;
2092                                         }
2094                                 }
2096                                 /*while (ExtraLineSeekSub == TRUE && iterboolsub != ContactFileProcessedWorking.end()){
2097                 
2098                                         // Check if there is extra data on the next line 
2099                                         // (indicated by space or tab at the start) and add data.
2100                 
2101                                         itersub++;
2103                                         iterboolsub = ContactFileProcessedWorking.find(itersub->first);
2104                         
2105                                         if (iterboolsub->second == TRUE){
2106                         
2107                                                 continue;
2108                         
2109                                         }
2110                         
2111                                         if (itersub == ContactFileLines.end()){
2112                         
2113                                                 break;
2114                         
2115                                         }                       
2116                 
2117                                         wxSPropertyNextLine = itersub->second;
2118                 
2119                                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
2120                 
2121                                                 wxSPropertyNextLine.Remove(0, 1);
2122                                                 //wxSPropertyNextLine.Trim(FALSE);
2123                                                 //ContactLine.Trim();
2124                                                 ContactLineSub.Append(wxSPropertyNextLine);
2125                                                 //iterboolsub->second = TRUE;
2126                                                 DataLineProcess.insert(std::make_pair(DataLineSeek, itersub->first));
2127                                                 DataLineSeek++;
2128                 
2129                                         } else {
2130                         
2131                                                 itersub--;
2132                                                 ExtraLineSeekSub = FALSE;
2133                         
2134                                         }
2136                                         if (iterboolsub == ContactFileProcessedWorking.end()){
2138                                                 break;
2139                                                 ExtraLineSeekSub = FALSE;
2141                                         }
2142                 
2143                                 }*/
2144                 
2145                                 ContactLineSubLen = ContactLineSub.Len();
2146                                 PropertyFind = TRUE;
2147                                 wxSPropertySub.clear();
2148                         
2149                                 for (int i = 0; i <= ContactLineSubLen; i++){
2150                 
2151                                         if ((ContactLineSub.Mid(i, 1) == wxT(";") || ContactLineSub.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
2152                         
2153                                                 PropertyFind = FALSE;
2154                         
2155                                         } else if (PropertyFind == TRUE){
2156                         
2157                                                 wxSPropertySub.Append(ContactLineSub.Mid(i, 1));
2158                         
2159                                         }               
2160                 
2161                                         if (ContactLineSub.Mid(i, 1) == wxT("\"")){
2162                         
2163                                                 if (QuoteMode == TRUE){
2164                                  
2165                                                         QuoteMode = FALSE;
2166                                 
2167                                                 } else {
2168                         
2169                                                         QuoteMode = TRUE;
2170                                         
2171                                                 }
2172                         
2173                                         }
2174                         
2175                                         if (ContactLineSub.Mid(i, 1) == wxT(":") && ContactLineSub.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
2176                         
2177                                                 QuoteBreakPoint = i;
2178                                                 break;
2179                         
2180                                         }
2181                 
2182                                 }
2184                                 if (wxSPropertySub != wxSPropertyVCARD4){
2185                         
2186                                         wxSPropertySub.clear();
2187                                         DataLineSeek = 0;
2188                                         DataLineProcess.clear();
2189                                         continue;
2190                         
2191                                 }
2193                                 wxSPropertySeg1Sub = ContactLineSub.Mid(0, QuoteBreakPoint);
2194                                 wxSPropertySeg2Sub = ContactLineSub.Mid((QuoteBreakPoint + 1));
2196                                 // Split the property name data.
2197                         
2198                                 // Strip the X-VCARD4- from the variable.
2199                                 
2200                                 wxString wxSPropertyChopped =  wxSPropertySeg1Sub.Mid(9);
2201                         
2202                                 intPrevValueSub = (wxSProperty.Len() + 2);
2203                                 
2204                                 SplitValuesData(&wxSPropertyChopped, &TempSplitPoints, &TempSplitLength, (int)intPrevValueSub, &TempPropertyData);
2205                                 
2206                                 // Process the splitted data into temporary property data.
2208                                 // Look for certain property names and the X-FIRST
2209                                 // property name.
2210                                         
2211                                 bool ProcessData = FALSE;
2212                         
2213                                 // Check for X-FIRST.
2214                         
2215                                 for (std::map<wxString, wxString>::iterator xfiter = TempPropertyData.begin(); 
2216                                 xfiter != TempPropertyData.end(); ++xfiter){
2217                         
2218                                         PropertyName = xfiter->first;
2219                                         PropertyValue = xfiter->second;
2220                                                 
2221                                         if (PropertyName == wxT("X-FIRST") && PropertyValue == wxT("TRUE")){
2222                                 
2223                                                 ProcessData = TRUE;
2224                                                 
2225                                                 if (wxSProperty == wxT("PHOTO")){ PhotoFirst = TRUE; }
2226                                                 else if (wxSProperty == wxT("NICKNAME")){ NicknameFirst = TRUE; }
2227                                                 else if (wxSProperty == wxT("TITLE")){ TitleFirst = TRUE; }
2228                                                 else if (wxSProperty == wxT("FN")){ FNFirst = TRUE; }
2229                                                 else if (wxSProperty == wxT("ORG")){ OrganisationFirst = TRUE; }
2230                                                 else if (wxSProperty == wxT("NOTE")){ NoteFirst = TRUE; }
2231                                                 break;
2232                                 
2233                                         }
2234                         
2235                                 }
2236                         
2237                                 if (ProcessData == FALSE){
2238                         
2239                                         DataLineProcess.clear();
2240                                         DataLineSeek = 0;
2241                                         TempPropertyData.clear();
2242                         
2243                                 } else {
2244                                 
2245                                         wxT("PHOTODANCEMATCH!");
2246                         
2247                                         for (std::map<wxString, wxString>::iterator xfiter = TempPropertyData.begin(); 
2248                                         xfiter != TempPropertyData.end(); ++xfiter){
2249                         
2250                                                 PropertyName = xfiter->first;
2251                                                 PropertyValue = xfiter->second;
2252                         
2253                                                 if (PropertyName == wxT("X-FIRST")){
2254                                 
2255                                                         continue;
2256                                 
2257                                                 }
2258                                 
2259                                                 PropertyData.insert(std::make_pair(PropertyName, PropertyValue));
2260                                                 PropertyLock.insert(std::make_pair(PropertyName, FALSE));
2261                         
2262                                         }
2263                                 
2264                                         // Mark all lines as processed.
2265                                         
2266                                         for (std::map<int,int>::iterator dpiter = DataLineProcess.begin(); 
2267                                         dpiter != DataLineProcess.end(); ++dpiter){
2268                                         
2269                                                 DLSLiter = ContactFileProcessed.find(dpiter->second);
2270                                                 DLSLiter->second = TRUE;
2271                                         
2272                                         }
2273                                         
2274                                         for (std::map<int,int>::iterator dpoiter = DataLineProcessOriginal.begin(); 
2275                                         dpoiter != DataLineProcessOriginal.end(); ++dpoiter){
2276                                         
2277                                                 DLSLiter = ContactFileProcessed.find(dpoiter->second);
2278                                                 DLSLiter->second = TRUE;
2279                                         
2280                                         }
2281                                         
2282                                         DataLineProcess.clear();
2283                                         DataLineProcessOriginal.clear();
2284                                         DataLineSeek = 0;
2285                                         DataLineSeekOrig = 0;
2286                                         TempSplitPoints.clear();
2287                                         TempSplitLength.clear();
2288                                         TempPropertyData.clear();
2289                                         FoundData = TRUE;
2290                                         
2291                                         break;
2292                         
2293                                 }
2294                                 
2295                         }
2296                 
2297                 } else {
2298                 
2299                         wxSProperty.clear();
2300                         wxSPropertySub.Clear();
2301                         wxSPropertySeg1.Clear();
2302                         wxSPropertySeg2.Clear();
2303                         wxSPropertySeg1Sub.Clear();
2304                         wxSPropertySeg2Sub.Clear();
2305                         wxSPropertyValues.Clear();
2306                         wxSPropertyData.Clear();
2307                         wxSPropertyXVCard4Value.Clear();
2308                         wxSPropertyNameConv.Clear();
2309                         PropertyData.clear();
2310                         PropertyLock.clear();
2311                         ContactLine.clear();
2312                         ContactLineSub.clear();
2313                         DataLineProcess.clear();
2314                         DataLineProcessOriginal.clear();
2315                         TempSplitPoints.clear();
2316                         TempSplitLength.clear();
2317                         wxSPropertyVCARD4.clear();
2318                         DataLineSeek = 0;
2319                         DataLineSeekOrig = 0;
2320                         XVCard4Value = FALSE;
2321                         VCard3Value = FALSE;
2322                 
2323                 }
2324                 
2325                 if (FoundData == FALSE){
2326                 
2327                         wxSProperty.clear();
2328                         wxSPropertySub.Clear();
2329                         wxSPropertySeg1.Clear();
2330                         wxSPropertySeg2.Clear();
2331                         wxSPropertySeg1Sub.Clear();
2332                         wxSPropertySeg2Sub.Clear();
2333                         wxSPropertyValues.Clear();
2334                         wxSPropertyData.Clear();
2335                         wxSPropertyXVCard4Value.Clear();
2336                         wxSPropertyNameConv.Clear();
2337                         PropertyData.clear();
2338                         PropertyLock.clear();
2339                         ContactLine.clear();
2340                         ContactLineSub.clear();
2341                         DataLineProcess.clear();
2342                         DataLineProcessOriginal.clear();
2343                         TempSplitPoints.clear();
2344                         TempSplitLength.clear();
2345                         wxSPropertyVCARD4.clear();
2346                         DataLineSeek = 0;
2347                         DataLineSeekOrig = 0;
2348                         XVCard4Value = FALSE;
2349                         VCard3Value = FALSE;
2350                 
2351                 }
2352                 
2353                 ConvertV4PropertyProc(&wxSProperty, &wxSPropertySeg1, &wxSPropertySeg2, 
2354                         &wxSPropertyValues, &wxSPropertyData, &wxSPropertyXVCard4Value, 
2355                         &wxSPropertyNameConv, &PropertyData, &PropertyLock, FALSE, &VCard3Value, &XVCard4Value);
2356                 
2357                 wxString FinalPropertyData;
2358         
2359                 FinalPropertyData.Append(wxSPropertyNameConv);
2360         
2361                 for (std::map<wxString, wxString>::iterator striter = PropertyData.begin(); 
2362                 striter != PropertyData.end(); ++striter){
2364                         FinalPropertyData.Append(wxT(";"));             
2365                         FinalPropertyData.Append(striter->first);
2366                         FinalPropertyData.Append(wxT("="));
2367                         FinalPropertyData.Append(striter->second);
2368                 
2369                 }
2370                 
2371                 wxString FinalPropValue;
2372                 
2373                 if (wxSPropertyXVCard4Value.IsEmpty()){
2374                 
2375                         FinalPropValue = wxSPropertyData;
2376                 
2377                 } else {
2378                 
2379                         if (wxSPropertyXVCard4Value != wxSPropertyData){
2380                 
2381                                 FinalPropValue = wxSPropertyXVCard4Value;
2382                         
2383                         }
2384                 
2385                 }
2386                         
2387                 if (FinalPropertyData.IsEmpty() && FinalPropValue.IsEmpty()){
2388                 
2389                         continue;
2390                 
2391                 }
2392                 
2393                 vCardOut->AddRaw(FinalPropertyData, FinalPropValue);
2395                 wxSProperty.clear();
2396                 wxSPropertySub.Clear();
2397                 wxSPropertySeg1.Clear();
2398                 wxSPropertySeg2.Clear();
2399                 wxSPropertySeg1Sub.Clear();
2400                 wxSPropertySeg2Sub.Clear();
2401                 wxSPropertyValues.Clear();
2402                 wxSPropertyData.Clear();
2403                 wxSPropertyXVCard4Value.Clear();
2404                 wxSPropertyNameConv.Clear();
2405                 //FinalPropertyData.clear();
2406                 //FinalPropValue.clear();
2407                 PropertyData.clear();
2408                 PropertyLock.clear();
2409                 ContactLine.clear();
2410                 ContactLineSub.clear();
2411                 DataLineProcess.clear();
2412                 DataLineProcessOriginal.clear();
2413                 wxSPropertyVCARD4.clear();
2414                 DataLineSeek = 0;
2415                 DataLineSeekOrig = 0;
2416                 XVCard4Value = FALSE;
2417                 VCard3Value = FALSE;
2418         
2419         }
2420         
2421         // Process the non-itemn values.
2422         
2423         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
2424          iter != ContactFileLines.end(); ++iter){
2425         
2426                 ExtraLineSeek = TRUE;
2428                 iterbool = ContactFileProcessed.find(iter->first);
2429                 
2430                 ContactLine = iter->second;
2431                 
2432                 // Ignore certain variables as they are not needed.
2433                 
2434                 if (ContactLine == wxT("BEGIN:VCARD") || 
2435                 ContactLine == wxT("END:VCARD") || 
2436                 ContactLine.Mid(0, 8) == wxT("VERSION:") || 
2437                 ContactLine.Mid(0, 7) == wxT("PRODID:") || 
2438                 ContactLine.Mid(0, 5) == wxT("X-AIM") || 
2439                 ContactLine.Mid(0, 5) == wxT("X-MSN") || 
2440                 ContactLine.Mid(0, 5) == wxT("X-ICQ") || 
2441                 ContactLine.Mid(0, 10) == wxT("X-GADUGADU") || 
2442                 ContactLine.Mid(0, 7) == wxT("X-YAHOO") || 
2443                 ContactLine.Mid(0, 7) == wxT("X-SKYPE") || 
2444                 ContactLine.Mid(0, 8) == wxT("X-JABBER") ||
2445                 ContactLine.Mid(0, 4) == wxT("REV:")){
2446                         
2447                         iterbool->second = TRUE;
2448                         continue;
2449                         
2450                 }
2451                 
2452                 if (iterbool->second == TRUE){
2453                         
2454                         continue;
2455                         
2456                 }
2457                 
2458                 if (ContactLine.Mid(0, 1) == wxT(" ") || ContactLine.Mid(0, 1) == wxT("\t")){
2459                 
2460                         continue;
2461                 
2462                 }
2463         
2464                 if (ContactLine.Mid(0, 4) == wxT("item")){
2465                 
2466                         // Line is a itemn... so ignore.
2467                 
2468                         continue;
2469                 
2470                 }
2471                 
2472                 std::map<int,wxString>::iterator itersub = iter;
2474                 while (ExtraLineSeek == TRUE){
2475                 
2476                         // Check if there is extra data on the next line 
2477                         // (indicated by space or tab at the start) and add data.
2479                         if (itersub == ContactFileLines.end()){
2480                                 ExtraLineSeekSub = FALSE;
2481                                 continue;
2482                         }
2483                         else {
2484                                 itersub++;
2486                         }
2488                         iterboolsub = ContactFileProcessedWorking.find(itersub->first);
2490                         if (iterboolsub == ContactFileProcessedWorking.end()){
2491                         
2492                                 break;
2493                         
2494                         }
2495                         
2496                         if (iterboolsub->second == TRUE){
2497                         
2498                                 continue;
2499                         
2500                         }
2501                         
2502                         if (itersub == ContactFileLines.end()){
2503                         
2504                                 break;
2505                         
2506                         }                       
2507                 
2508                         wxSPropertyNextLine = itersub->second;
2509                 
2510                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
2511                 
2512                                 wxSPropertyNextLine.Remove(0, 1);
2513                                 //wxSPropertyNextLine.Trim(FALSE);
2514                                 //ContactLine.Trim();
2515                                 ContactLine.Append(wxSPropertyNextLine);
2516                                 iterboolsub->second = TRUE;
2517                 
2518                         } else {
2519                         
2520                                 ExtraLineSeek = FALSE;
2521                         
2522                         }
2523                 
2524                 }
2525                 
2526                 ContactLineLen = ContactLine.Len();
2527                 
2528                 for (int i = 0; i <= ContactLineLen; i++){
2529                 
2530                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
2531                         
2532                                 PropertyFind = FALSE;
2533                         
2534                         } else if (PropertyFind == TRUE){
2535                         
2536                                 wxSProperty.Append(ContactLine.Mid(i, 1));
2537                         
2538                         }               
2539                 
2540                         if (ContactLine.Mid(i, 1) == wxT("\"")){
2541                         
2542                                 if (QuoteMode == TRUE){
2543                                 
2544                                         QuoteMode = FALSE;
2545                                 
2546                                 } else {
2547                         
2548                                         QuoteMode = TRUE;
2549                                         
2550                                 }
2551                         
2552                         }
2553                         
2554                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
2555                         
2556                                 QuoteBreakPoint = i;
2557                                 break;
2558                         
2559                         }
2560                 
2561                 }
2563                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
2564                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
2566                 wxStringTokenizer wxSPropertySegSplit(wxSPropertySeg1, wxT(";"));
2567                 wxSProperty = wxSPropertySegSplit.GetNextToken();
2569                 std::map<int,int> DataLineProcess;
2570                 std::map<int, bool>::iterator DLSLiter;
2571                 
2572                 // Look for the X-VCARD4-(variablename) equivilant.
2573                 
2574                 wxSPropertyVCARD4 = wxT("X-VCARD4-") + wxSProperty;
2575                         
2576                 // Sort out remainder of the types.
2577                 
2578                 ConvertV4PropertyProc(&wxSProperty, &wxSPropertySeg1, &wxSPropertySeg2, 
2579                         &wxSPropertyValues, &wxSPropertyData, &wxSPropertyXVCard4Value, 
2580                         &wxSPropertyNameConv, &PropertyData, &PropertyLock, FALSE, &VCard3Value, &XVCard4Value);
2581                 
2582                 wxString FinalPropertyData;
2583         
2584                 FinalPropertyData.Append(wxSPropertyNameConv);
2585         
2586                 for (std::map<wxString, wxString>::iterator striter = PropertyData.begin(); 
2587                 striter != PropertyData.end(); ++striter){
2589                         FinalPropertyData.Append(wxT(";"));             
2590                         FinalPropertyData.Append(striter->first);
2591                         FinalPropertyData.Append(wxT("="));
2592                         FinalPropertyData.Append(striter->second);
2593                 
2594                 }
2595                 
2596                 wxString FinalPropValue;
2597                 
2598                 if (wxSPropertyXVCard4Value.IsEmpty()){
2599                 
2600                         FinalPropValue = wxSPropertyData;
2601                 
2602                 } else {
2603                 
2604                         if (wxSPropertyXVCard4Value != wxSPropertyData){
2605                 
2606                                 FinalPropValue = wxSPropertyXVCard4Value;
2607                         
2608                         }
2609                 
2610                 }
2611                 
2612                 vCardOut->AddRaw(FinalPropertyData, FinalPropValue);
2614                 wxSProperty.clear();
2615                 wxSPropertySub.Clear();
2616                 wxSPropertySeg1.Clear();
2617                 wxSPropertySeg2.Clear();
2618                 wxSPropertyValues.Clear();
2619                 wxSPropertyData.Clear();
2620                 wxSPropertyXVCard4Value.Clear();
2621                 wxSPropertyNameConv.Clear();
2622                 //FinalPropertyData.clear();
2623                 //FinalPropValue.clear();
2624                 PropertyData.clear();
2625                 PropertyLock.clear();
2626                 ContactLine.clear();
2627                 XVCard4Value = FALSE;
2628                 VCard3Value = FALSE;
2629         
2630         }
2631         
2632         int FNCount = 0;
2633         int NameCount = 0;
2634         int NicknameCount = 0;
2635         int ADRCount = 0;
2636         int EmailCount = 0;
2637         int IMPPCount = 0;
2638         int TelCount = 0;
2639         int LangCount = 0;
2640         int TZCount = 0;
2641         int GeoCount = 0;
2642         int URLCount = 0;
2643         int RelatedCount = 0;
2644         int TitleCount = 0;
2645         int RoleCount = 0;
2646         int OrgCount = 0;
2647         int NoteCount = 0;
2648         int CategoryCount = 0;
2649         int PhotoCount = 0;
2650         int LogoCount = 0;
2651         int SoundCount = 0;
2652         int CalAdrCount = 0;
2653         int CalReqAdrCount = 0;
2654         int FreeBusyCount = 0;
2655         int KeyCount = 0;
2656         int VendorCount = 0;
2657         int XTokenCount = 0;
2658         int ItemSeek = 1;
2659         int MaxItemNumber = 0;
2660         int ItemOrdered = 0;
2661         int ItemUnordered = 0;
2662         int ItemNumber = 0;
2663         size_t ItemStringSeekLen = 0;
2664         int ItemSeekSub = 0;
2665         int ItemSeekSecSub = 0;
2666         //int intValueSeek = 1;
2667         
2668         std::map<int, wxString> NumberedName;
2669         std::map<int, wxString> NumberedData;
2670         std::map<int, wxString> NumberedPropValues;
2671         std::map<int, wxString> NumberedPropOldValue;
2672         
2673         std::map<int, wxString> UnNumberedName;
2674         std::map<int, wxString> UnNumberedData;
2675         std::map<int, wxString> UnNumberedPropValues;
2676         std::map<int, wxString> UnNumberedPropOldValue;
2678         // Part 1: Get the itemn number.
2679         
2680         std::map<int,bool>::iterator iterboolsecsub;
2681         std::map<int,wxString>::iterator itersub;
2682         std::map<int, wxString> TempData;
2683         PropertyData.clear();
2684         PropertyLock.clear();
2685         wxString ItemString;
2686         wxString ItemStringSeek;
2687         wxString ItemPropName;
2688         ContactLineSeek = 0;
2689         
2690         ContactLineSub.clear();
2691         ExtraLineSeekSub = 0;
2692         wxString wxSPropertyNextLineSub;
2693         ContactLineSubLen = 0;
2694         int ItemIndex = 0;
2695         PropertFindSub.clear();
2696         wxSPropertySub.clear();
2697         wxSPropertySeg1Sub.clear();
2698         wxSPropertySeg2Sub.clear();
2699         wxSPropertyValues.clear();
2700         wxSPropertyData.clear();
2701         wxSPropertyNameConv.clear();
2702         wxSPropertyXVCard4Value.clear();
2703         ItemProcString.clear();
2704         
2705         XVCard4Value = FALSE;
2706         VCard3Value = FALSE;
2707         SeekItemData = FALSE;
2708         
2709         std::map<wxString, void*> ItemMapIndex;
2710         //std::map<wxString, wxString> ItemNameIndex;
2711         
2712         // Look for item in the initial line, process into a proper line then
2713         // look for other lines with the same item association.
2714         
2715         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
2716                 iter != ContactFileLines.end(); ++iter){
2717         
2718                 ExtraLineSeek = TRUE;
2719                 
2720                 iterbool = ContactFileProcessed.find(iter->first);
2721                 
2722                 if (iterbool->second == TRUE){
2723                 
2724                         continue;
2725                 
2726                 }
2727                 
2728                 ContactLine = iter->second;
2729                 
2730                 if (ContactLine.Mid(0, 1) == wxT(" ") || ContactLine.Mid(0, 1) == wxT("\t")){
2731                 
2732                         continue;
2733                 
2734                 }
2735                 
2736                 if (ContactLine.Mid(0, 4) != wxT("item")){
2737                 
2738                         continue;
2739                 
2740                 }
2741                 
2742                 // Get Item data.
2744                 //ContactLineSeekSub = ContactLineSeek;
2745                 std::map<int,wxString>::iterator itersub = iter;
2747                 while (ExtraLineSeek == TRUE){
2748                 
2749                         // Check if there is extra data on the next line 
2750                         // (indicated by space or tab at the start) and add data.
2751                 
2752                         itersub++;
2753                         iterboolsub = ContactFileProcessed.find(itersub->first);
2755                         if (iterboolsub == ContactFileProcessed.end()){
2756                         
2757                                 break;
2758                         
2759                         }
2760                         
2761                         if (iterboolsub->second == TRUE){
2762                         
2763                                 continue;
2764                         
2765                         }
2766                         
2767                         if (itersub == ContactFileLines.end()){
2768                         
2769                                 break;
2770                         
2771                         }                       
2772                 
2773                         wxSPropertyNextLine = itersub->second;
2774                 
2775                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
2776                 
2777                                 wxSPropertyNextLine.Remove(0, 1);
2778                                 //wxSPropertyNextLine.Trim(FALSE);
2779                                 //ContactLine.Trim();
2780                                 ContactLine.Append(wxSPropertyNextLine);
2781                                 iterboolsub->second = TRUE;
2782                 
2783                         } else {
2784                         
2785                                 ExtraLineSeek = FALSE;
2786                         
2787                         }
2788                 
2789                 }
2790                 
2791                 ContactLineLen = ContactLine.Len();
2792                 
2793                 for (int i = 0; i <= ContactLineLen; i++){
2794                 
2795                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
2796                         
2797                                 PropertyFind = FALSE;
2798                         
2799                         } else if (PropertyFind == TRUE){
2800                         
2801                                 wxSProperty.Append(ContactLine.Mid(i, 1));
2802                         
2803                         }               
2804                 
2805                         if (ContactLine.Mid(i, 1) == wxT("\"")){
2806                         
2807                                 if (QuoteMode == TRUE){
2808                                 
2809                                         QuoteMode = FALSE;
2810                                 
2811                                 } else {
2812                         
2813                                         QuoteMode = TRUE;
2814                                         
2815                                 }
2816                         
2817                         }
2818                         
2819                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
2820                         
2821                                 QuoteBreakPoint = i;
2822                                 break;
2823                         
2824                         }
2825                 
2826                 }
2828                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
2829                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
2830                 
2831                 // Go through the lines and collect the lines like itemn.
2832                 
2833                 std::map<int,wxString> *ItemListData;
2834                 ItemListData = new std::map<int,wxString>;
2835                 
2836                 wxStringTokenizer ItemData(wxSPropertySeg1, wxT("."));
2837                 
2838                 ItemString = ItemData.GetNextToken();
2839                 ItemStringSeek = wxT("item") + ItemString.Mid(4);
2840                 
2841                 wxStringTokenizer ItemPropSplit(ItemData.GetNextToken(), wxT(";"));
2842                 
2843                 ItemPropName = ItemPropSplit.GetNextToken();
2844                 
2845                 ItemStringSeekLen = ItemStringSeek.Len();
2846                 
2847                 ItemIndex = 0;
2848                 
2849                 for (std::map<int,wxString>::iterator itersec = ContactFileLines.begin();
2850                 itersec != ContactFileLines.end(); ++itersec){
2851                 
2852                         ExtraLineSeek = TRUE;
2853                 
2854                         iterboolsub = ContactFileProcessed.find(itersec->first);
2855                 
2856                         if (iterboolsub->second == TRUE){
2857                         
2858                                 continue;
2859                         
2860                         }
2861                 
2862                         ContactLineSub = itersec->second;
2863                         
2864                         wxStringTokenizer ItemProcData(ContactLineSub, wxT("."));
2865                         ItemProcString = ItemData.GetNextToken();
2866                         
2867                         if (ItemStringSeek != ContactLineSub.Mid(0, ItemStringSeekLen)){
2868                         
2869                                 continue;
2870                         
2871                         }
2872                         
2873                         ItemIndex++;
2874                         
2875                         ItemListData->insert(std::make_pair(ItemIndex, ContactLineSub));
2876                         
2877                         iterboolsub->second = TRUE;
2878                 
2879                 }
2880                 
2881                 //ItemNameIndex.insert(std::make_pair(ItemStringSeek, ItemPropName));
2882                 ItemListData->insert(std::make_pair(ItemIndex, ContactLineSub));
2883                 ItemMapIndex.insert(std::make_pair(ItemStringSeek, ItemListData));
2884                 
2885         }
2886         
2887         // Process each itemn set.
2888         
2889         for (std::map<wxString, void*>::iterator iter = ItemMapIndex.begin();
2890                 iter != ItemMapIndex.end(); ++iter){
2891                         
2892                 std::map<int, wxString> *ItemDataPtr;
2894                 ItemDataPtr = (std::map<int,wxString>*)iter->second;
2895                 
2896                 for (std::map<int,wxString>::iterator itersub = ItemDataPtr->begin();
2897                         itersub != ItemDataPtr->end(); ++itersub){
2898                         
2899                         ContactLine = itersub->second;
2900                         
2901                         ContactLineLen = ContactLine.Len();
2902                 
2903                         for (int i = 0; i <= ContactLineLen; i++){
2904                 
2905                                 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
2906                         
2907                                         PropertyFind = FALSE;
2908                         
2909                                 } else if (PropertyFind == TRUE){
2910                         
2911                                         wxSProperty.Append(ContactLine.Mid(i, 1));
2912                         
2913                                 }               
2914                 
2915                                 if (ContactLine.Mid(i, 1) == wxT("\"")){
2916                         
2917                                         if (QuoteMode == TRUE){
2918                                 
2919                                                 QuoteMode = FALSE;
2920                                 
2921                                         } else {
2922                         
2923                                                 QuoteMode = TRUE;
2924                                         
2925                                         }
2926                         
2927                                 }
2928                         
2929                                 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
2930                         
2931                                         QuoteBreakPoint = i;
2932                                         break;
2933                         
2934                                 }
2935                 
2936                         }
2937                         
2938                         wxSPropertySeg1Sub = ContactLine.Mid(0, QuoteBreakPoint);
2939                         wxSPropertySeg2Sub = ContactLine.Mid((QuoteBreakPoint + 1));
2940                         
2941                         wxStringTokenizer wxSPropertySegSplit(wxSPropertySeg1Sub, wxT(";"));
2942                         wxSProperty = wxSPropertySegSplit.GetNextToken();
2943                         
2944                         // Sort out remainder of the types.
2945                         
2946                         // Skip certain X-* IM variables as they are processed via
2947                         // IMPP.
2948                         
2949                         if (wxSProperty == wxT("X-AIM") || wxSProperty == wxT("X-MSN") || 
2950                         wxSProperty == wxT("X-ICQ") || wxSProperty == wxT("X-GADUGADU") || 
2951                         wxSProperty == wxT("X-YAHOO") || wxSProperty == wxT("X-SKYPE") || 
2952                         wxSProperty == wxT("X-JABBER")){
2953                 
2954                                 wxSProperty.clear();
2955                                 wxSPropertySub.Clear();
2956                                 wxSPropertySeg1.Clear();
2957                                 wxSPropertySeg2.Clear();
2958                                 wxSPropertyValues.Clear();
2959                                 wxSPropertyData.Clear();
2960                                 wxSPropertyXVCard4Value.Clear();
2961                                 wxSPropertyNameConv.Clear();
2962                                 //FinalPropertyData.clear();
2963                                 //FinalPropValue.clear();
2964                                 PropertyData.clear();
2965                                 PropertyLock.clear();
2966                                 ContactLine.clear();
2967                                 XVCard4Value = FALSE;
2968                                 VCard3Value = FALSE;
2969                                 continue;
2970                 
2971                         }
2972                         
2973                         ConvertV4PropertyProc(&wxSProperty, &wxSPropertySeg1Sub, &wxSPropertySeg2Sub, 
2974                         &wxSPropertyValues, &wxSPropertyData, &wxSPropertyXVCard4Value, 
2975                         &wxSPropertyNameConv, &PropertyData, &PropertyLock, TRUE, &VCard3Value, &XVCard4Value);
2976                         
2977                 }
2978                 
2979                 if (wxSPropertyNameConv.IsEmpty()){
2980                 
2981                         wxSProperty.clear();
2982                         wxSPropertySub.Clear();
2983                         wxSPropertySeg1.Clear();
2984                         wxSPropertySeg2.Clear();
2985                         wxSPropertyValues.Clear();
2986                         wxSPropertyData.Clear();
2987                         wxSPropertyXVCard4Value.Clear();
2988                         wxSPropertyNameConv.Clear();
2989                         //FinalPropertyData.clear();
2990                         //FinalPropValue.clear();
2991                         PropertyData.clear();
2992                         PropertyLock.clear();
2993                         ContactLine.clear();
2994                         XVCard4Value = FALSE;
2995                         VCard3Value = FALSE;
2996                         continue;
2997                 
2998                 }
2999                 
3000                 wxString FinalPropertyData;
3001         
3002                 FinalPropertyData.Append(wxSPropertyNameConv);
3003         
3004                 for (std::map<wxString, wxString>::iterator striter = PropertyData.begin(); 
3005                 striter != PropertyData.end(); ++striter){
3007                         FinalPropertyData.Append(wxT(";"));             
3008                         FinalPropertyData.Append(striter->first);
3009                         FinalPropertyData.Append(wxT("="));
3010                         FinalPropertyData.Append(striter->second);
3011                 
3012                 }
3013                 
3014                 wxString FinalPropValue;
3015                 
3016                 if (wxSPropertyXVCard4Value.IsEmpty()){
3017                 
3018                         FinalPropValue = wxSPropertyData;
3019                 
3020                 } else {
3021                 
3022                         if (wxSPropertyXVCard4Value != wxSPropertyData){
3023                         
3024                                 FinalPropValue = wxSPropertyData;
3025                                 
3026                         } else {
3027                 
3028                                 FinalPropValue = wxSPropertyXVCard4Value;
3029                 
3030                         }
3031                 
3032                 }
3033                 
3034                 vCardOut->AddRaw(FinalPropertyData, FinalPropValue);
3035                 
3036                 wxSProperty.clear();
3037                 wxSPropertySub.Clear();
3038                 wxSPropertySeg1Sub.Clear();
3039                 wxSPropertySeg2Sub.Clear();
3040                 wxSPropertyValues.Clear();
3041                 wxSPropertyData.Clear();
3042                 wxSPropertyXVCard4Value.Clear();
3043                 wxSPropertyNameConv.Clear();
3044                 FinalPropertyData.clear();
3045                 FinalPropValue.clear();
3046                 PropertyData.clear();
3047                 PropertyLock.clear();
3048                 ContactLine.clear();
3049                 XVCard4Value = FALSE;
3050                 VCard3Value = FALSE;
3051         
3052                 TempData.clear();
3053                 //PropertyData.clear();
3054                 //PropertyLock.clear();
3055                 
3056         }
3057         
3058         // Delete data.
3059         
3060         std::map<int, wxString> *ItemEraseData;
3061         
3062         for (std::map<wxString, void*>::iterator iter = ItemMapIndex.begin();
3063                 iter != ItemMapIndex.end(); ++iter){
3064                 
3065                 ItemEraseData = (std::map<int,wxString>*)iter->second;
3067                 delete ItemEraseData;
3068                 ItemEraseData = NULL;
3069                 
3070         }
3072         ItemMapIndex.clear();
3073         
3074         vCardOut->AddRaw(wxT("END"), wxT("VCARD"));
3076         return TRUE;
3080 void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName, 
3081         wxString *wxSPropertySeg1Ptr, wxString *wxSPropertySeg2Ptr, 
3082         wxString *wxSPropertyPropValuesOut, wxString *wxSPropertyDataOut, 
3083         wxString *wxSPropertyXVCard4Value, wxString *wxSPropertyDataNameOut,
3084         std::map<wxString,wxString> *PropertyDataMap, 
3085         std::map<wxString,bool> *PropertyLockMap,
3086         bool ProcessItemData, bool *VCardV3Value, bool *XVCardV4Value){
3088         wxString wxSProperty;
3089         wxString wxSPropertySeg1Chopped;
3090     size_t intPropertyLen;
3091     
3092         if (ProcessItemData == TRUE){
3093                 
3094                 wxStringTokenizer wxSPropertySplit(*wxSPropertyName, wxT("."));
3095         
3096                 wxSPropertySplit.GetNextToken();
3097                 wxSProperty = wxSPropertySplit.GetNextToken();
3098         
3099                 // Look for . in wxSPropertySeg1Ptr and remove all data before
3100                 // the .
3101         
3102                 int ItemSeek = wxSPropertySeg1Ptr->Find(wxT("."));
3103                 wxSPropertySeg1Chopped = wxSPropertySeg1Ptr->Mid((ItemSeek + 1));
3104                 
3105         
3106         } else {
3107         
3108                 wxSProperty = *wxSPropertyName;
3109         
3110         }
3112         
3113         // Go through each of the vCard 3.0 properties.
3114         
3115         // EMAIL
3116         
3117         if (wxSProperty == wxT("EMAIL")){
3119                 if (ProcessItemData == TRUE){
3120         
3121                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
3122                 
3123                 } else {
3124                 
3125                         intPropertyLen = wxSPropertySeg1Ptr->Len();
3126                 
3127                 }
3128                 
3129                 std::map<int, int> SplitPoints;
3130                 std::map<int, int> SplitLength;
3131                 std::map<int, int>::iterator SLiter;                    
3132                 wxString PropertyData;
3133                 wxString PropertyName;
3134                 wxString PropertyValue;
3135                 wxString PropertyTokens;
3136                 bool FirstToken = TRUE;
3137                 int intPrevValue = 7;
3138                 
3139                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
3140                 *wxSPropertyDataNameOut = wxT("EMAIL");
3141                 *VCardV3Value = TRUE;
3142                 
3143                 if (ProcessItemData == TRUE){
3144                 
3145                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
3146                         
3147                 } else {
3148                         
3149                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
3150                         
3151                 }
3152                 
3153                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3154                 intiter != SplitPoints.end(); ++intiter){
3155                 
3156                         SLiter = SplitLength.find(intiter->first);
3157                 
3158                         if (ProcessItemData == TRUE){
3159                 
3160                                 if (FirstToken == TRUE){
3161                         
3162                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
3163                                         FirstToken = FALSE;
3164                         
3165                                 } else {
3166                                 
3167                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
3168                                 
3169                                 }
3170                         
3171                         } else {                        
3172                                 
3173                                 if (FirstToken == TRUE){
3174                         
3175                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
3176                                         FirstToken = FALSE;
3177                         
3178                                 } else {
3179                                 
3180                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
3181                                 
3182                                 }
3183                         
3184                         }
3185                         
3186                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3187                         PropertyName = PropertyElement.GetNextToken();                          
3188                         PropertyValue = PropertyElement.GetNextToken();
3189                         
3190                         //ProcessCaptureStrings(&PropertyValue);
3191                         
3192                         intPrevValue = intiter->second;
3193                         
3194                         if (PropertyName == wxT("type") && PropertyValue == wxT("INTERNET")){
3195                                 continue;
3196                         }
3197                                 
3198                         if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
3199                                 
3200                                 if (ProcessItemData == FALSE){
3201                                         PropertyName = wxT("PREF");
3202                                         PropertyValue = wxT("50");
3203                                 } else {
3204                                         continue;
3205                                 }
3206                                 
3207                         }
3208                         
3209                         if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
3210                                 PropertyValue = wxT("home");
3211                         }
3212                         
3213                         if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
3214                                 PropertyValue = wxT("work");
3215                         }
3217                         if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
3218                                 PropertyName = wxT("X-TYPE");
3219                                 PropertyValue = wxT("other");
3220                         }
3221                         
3222                         // Process properties.
3223                         
3224                         if (PropertyName.IsEmpty()){
3225                         
3226                                 continue;
3227                         
3228                         }
3229                         
3230                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
3232                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3233                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3234         
3235                         } else {
3236                         
3237                                 PropertyDataMap->erase(PropertyName);
3238                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3239                                 PropertyLockMap->erase(PropertyName);
3240                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3241                         
3242                         }
3243                 
3244                 }
3245         
3246         }
3247         
3248         // ADR
3249         
3250         if (wxSProperty == wxT("ADR")){
3252                 if (ProcessItemData == TRUE){
3253         
3254                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
3255                 
3256                 } else {
3257                 
3258                         intPropertyLen = wxSPropertySeg1Ptr->Len();
3259                 
3260                 }
3261                 
3262                 std::map<int, int> SplitPoints;
3263                 std::map<int, int> SplitLength;
3264                 std::map<int, int>::iterator SLiter;                    
3265                 wxString PropertyData;
3266                 wxString PropertyName;
3267                 wxString PropertyValue;
3268                 wxString PropertyTokens;
3269                 bool FirstToken = TRUE;
3270                 int intPrevValue = 5;
3271                 
3272                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
3273                 *wxSPropertyDataNameOut = wxT("ADR");
3274                 *VCardV3Value = TRUE;
3275                 
3276                 if (ProcessItemData == TRUE){
3277                 
3278                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
3279                         
3280                 } else {
3281                         
3282                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
3283                         
3284                 }
3285                 
3286                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3287                 intiter != SplitPoints.end(); ++intiter){
3288                 
3289                         SLiter = SplitLength.find(intiter->first);
3290                 
3291                         if (ProcessItemData == TRUE){
3292                 
3293                                 if (FirstToken == TRUE){
3294                         
3295                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
3296                                         FirstToken = FALSE;
3297                         
3298                                 } else {
3299                                 
3300                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
3301                                 
3302                                 }
3303                         
3304                         } else {                        
3305                                 
3306                                 if (FirstToken == TRUE){
3307                         
3308                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
3309                                         FirstToken = FALSE;
3310                         
3311                                 } else {
3312                                 
3313                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
3314                                 
3315                                 }
3316                         
3317                         }
3318                         
3319                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3320                         PropertyName = PropertyElement.GetNextToken();                          
3321                         PropertyValue = PropertyElement.GetNextToken();
3322                         
3323                         //ProcessCaptureStrings(&PropertyValue);
3324                         
3325                         intPrevValue = intiter->second;
3326                                 
3327                         if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
3328                                 
3329                                 if (ProcessItemData == FALSE){
3330                                         PropertyName = wxT("PREF");
3331                                         PropertyValue = wxT("50");
3332                                 } else {
3333                                         continue;
3334                                 }
3335                                 
3336                         }
3337                         
3338                         if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
3339                                 PropertyValue = wxT("home");
3340                         }
3341                         
3342                         if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
3343                                 PropertyValue = wxT("work");
3344                         }
3346                         if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
3347                                 PropertyName = wxT("X-TYPE");
3348                                 PropertyValue = wxT("other");
3349                         }
3350                         
3351                         // Process properties.
3352                         
3353                         if (PropertyName.IsEmpty()){
3354                         
3355                                 continue;
3356                         
3357                         }
3358                         
3359                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
3361                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3362                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3363         
3364                         } else {
3365                         
3366                                 PropertyDataMap->erase(PropertyName);
3367                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3368                                 PropertyLockMap->erase(PropertyName);
3369                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3370                         
3371                         }
3372                 
3373                 }
3374         
3375         }
3376         
3377         // LABEL
3378         
3379         if (wxSProperty == wxT("LABEL")){
3381                 if (ProcessItemData == TRUE){
3382         
3383                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
3384                 
3385                 } else {
3386                 
3387                         intPropertyLen = wxSPropertySeg1Ptr->Len();
3388                 
3389                 }
3390                 
3391                 std::map<int, int> SplitPoints;
3392                 std::map<int, int> SplitLength;
3393                 std::map<int, int>::iterator SLiter;                    
3394                 wxString PropertyData;
3395                 wxString PropertyName;
3396                 wxString PropertyValue;
3397                 wxString PropertyTokens;
3398                 bool FirstToken = TRUE;
3399         int intPrevValue = 7;
3400                 
3401                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
3402                 *wxSPropertyDataNameOut = wxT("ADR");
3403                 *VCardV3Value = TRUE;
3404                 
3405                 if (ProcessItemData == TRUE){
3406                 
3407                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
3408                         
3409                 } else {
3410                         
3411                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
3412                         
3413                 }
3414                 
3415                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3416                 intiter != SplitPoints.end(); ++intiter){
3417                 
3418                         SLiter = SplitLength.find(intiter->first);
3419                 
3420                         if (ProcessItemData == TRUE){
3421                 
3422                                 if (FirstToken == TRUE){
3423                         
3424                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
3425                                         FirstToken = FALSE;
3426                         
3427                                 } else {
3428                                 
3429                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
3430                                 
3431                                 }
3432                         
3433                         } else {                        
3434                                 
3435                                 if (FirstToken == TRUE){
3436                         
3437                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
3438                                         FirstToken = FALSE;
3439                         
3440                                 } else {
3441                                 
3442                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
3443                                 
3444                                 }
3445                         
3446                         }
3447                         
3448                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3449                         PropertyName = PropertyElement.GetNextToken();                          
3450                         PropertyValue = PropertyElement.GetNextToken();
3451                         
3452                         //ProcessCaptureStrings(&PropertyValue);
3453                         
3454                         intPrevValue = intiter->second;
3455                                 
3456                         if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
3457                                 continue;
3458                         }
3459                         
3460                         if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
3461                                 PropertyValue = wxT("home");
3462                         }
3463                         
3464                         if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
3465                                 PropertyValue = wxT("work");
3466                         }
3468                         if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
3469                                 PropertyName = wxT("X-TYPE");
3470                                 PropertyValue = wxT("other");
3471                         }
3472                         
3473                         // Process properties.
3474                         
3475                         if (PropertyName.IsEmpty()){
3476                         
3477                                 continue;
3478                         
3479                         }
3480                         
3481                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
3483                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3484                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3485         
3486                         } else {
3487                         
3488                                 PropertyDataMap->erase(PropertyName);
3489                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3490                                 PropertyLockMap->erase(PropertyName);
3491                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3492                         
3493                         }
3494                 
3495                 }
3496                 
3497                 PropertyDataMap->insert(std::make_pair(wxT("X-LABEL"), wxT("TRUE")));
3498         
3499         }
3500         
3501         // IMPP
3502         
3503         if (wxSProperty == wxT("IMPP")){
3505                 if (ProcessItemData == TRUE){
3506         
3507                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
3508                 
3509                 } else {
3510                 
3511                         intPropertyLen = wxSPropertySeg1Ptr->Len();
3512                 
3513                 }
3514                 
3515                 std::map<int, int> SplitPoints;
3516                 std::map<int, int> SplitLength;
3517                 std::map<int, int>::iterator SLiter;                    
3518                 wxString PropertyData;
3519                 wxString PropertyName;
3520                 wxString PropertyValue;
3521                 wxString PropertyTokens;
3522                 bool FirstToken = TRUE;
3523                 int intPrevValue = 6;
3524                 
3525                 wxStringTokenizer IMPPSplit(*wxSPropertySeg2Ptr, wxT(":"));
3526                 wxString IMPPType;
3527                 wxString IMPPData;
3528                 
3529                 IMPPType = IMPPSplit.GetNextToken();
3530                 
3531                 if (IMPPSplit.HasMoreTokens()){
3532                 
3533                         IMPPData = IMPPSplit.GetNextToken();
3534                 
3535                         if (IMPPType == wxT("ymsgr")){
3536                         
3537                                 IMPPType = wxT("yahoo");
3538                         
3539                         }
3540                         
3541                         *wxSPropertySeg2Ptr = IMPPType + wxT(":") + IMPPData;
3542                 
3543                 }
3544                 
3545                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
3546                 *wxSPropertyDataNameOut = wxT("IMPP");
3547                 *VCardV3Value = TRUE;
3548                 
3549                 if (ProcessItemData == TRUE){
3550                 
3551                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
3552                         
3553                 } else {
3554                         
3555                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
3556                         
3557                 }
3558                 
3559                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3560                 intiter != SplitPoints.end(); ++intiter){
3561                 
3562                         SLiter = SplitLength.find(intiter->first);
3563                 
3564                         if (ProcessItemData == TRUE){
3565                 
3566                                 if (FirstToken == TRUE){
3567                         
3568                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
3569                                         FirstToken = FALSE;
3570                         
3571                                 } else {
3572                                 
3573                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
3574                                 
3575                                 }
3576                         
3577                         } else {                        
3578                                 
3579                                 if (FirstToken == TRUE){
3580                         
3581                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
3582                                         FirstToken = FALSE;
3583                         
3584                                 } else {
3585                                 
3586                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
3587                                 
3588                                 }
3589                         
3590                         }
3591                         
3592                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3593                         PropertyName = PropertyElement.GetNextToken();                          
3594                         PropertyValue = PropertyElement.GetNextToken();
3595                         
3596                         //ProcessCaptureStrings(&PropertyValue);
3597                         
3598                         intPrevValue = intiter->second;
3599                                 
3600                         if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
3601                                 continue;
3602                         }
3603                         
3604                         if (PropertyName == wxT("X-SERVICE-TYPE")){
3605                                 continue;
3606                         }
3607                         
3608                         if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
3609                                 PropertyValue = wxT("home");
3610                         }
3611                         
3612                         if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
3613                                 PropertyValue = wxT("work");
3614                         }
3616                         if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
3617                                 PropertyName = wxT("X-TYPE");
3618                                 PropertyValue = wxT("other");
3619                         }
3620                         
3621                         // Process properties.
3622                         
3623                         if (PropertyName.IsEmpty()){
3624                         
3625                                 continue;
3626                         
3627                         }
3628                         
3629                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
3631                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3632                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3633         
3634                         } else {
3635                         
3636                                 PropertyDataMap->erase(PropertyName);
3637                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3638                                 PropertyLockMap->erase(PropertyName);
3639                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3640                         
3641                         }
3642                 
3643                 }
3644         
3645         }
3646         
3647         // TEL
3648         
3649         if (wxSProperty == wxT("TEL")){
3651                 if (ProcessItemData == TRUE){
3652         
3653                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
3654                 
3655                 } else {
3656                 
3657                         intPropertyLen = wxSPropertySeg1Ptr->Len();
3658                 
3659                 }
3660                 
3661                 std::map<int, int> SplitPoints;
3662                 std::map<int, int> SplitLength;
3663                 std::map<int, int>::iterator SLiter;
3664                 std::map<wxString, wxString> TelType;                   
3665                 wxString PropertyData;
3666                 wxString PropertyName;
3667                 wxString PropertyValue;
3668                 wxString PropertyTokens;
3669                 bool FirstToken = TRUE;
3670                 int intPrevValue = 5;
3671                 
3672                 wxSPropertyDataOut->Append(wxT("tel:"));
3673                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
3674                 *wxSPropertyDataNameOut = wxT("TEL");
3675                 *VCardV3Value = TRUE;
3676                 
3677                 if (ProcessItemData == TRUE){
3678                 
3679                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
3680                         
3681                 } else {
3682                         
3683                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
3684                         
3685                 }
3686                 
3687                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3688                 intiter != SplitPoints.end(); ++intiter){
3689                 
3690                         SLiter = SplitLength.find(intiter->first);
3691                 
3692                         if (ProcessItemData == TRUE){
3693                 
3694                                 if (FirstToken == TRUE){
3695                         
3696                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
3697                                         FirstToken = FALSE;
3698                         
3699                                 } else {
3700                                 
3701                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
3702                                 
3703                                 }
3704                         
3705                         } else {                        
3706                                 
3707                                 if (FirstToken == TRUE){
3708                         
3709                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
3710                                         FirstToken = FALSE;
3711                         
3712                                 } else {
3713                                 
3714                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
3715                                 
3716                                 }
3717                         
3718                         }
3719                         
3720                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3721                         PropertyName = PropertyElement.GetNextToken();                          
3722                         PropertyValue = PropertyElement.GetNextToken();
3723                         
3724                         //ProcessCaptureStrings(&PropertyValue);
3725                         
3726                         intPrevValue = intiter->second;
3727                                 
3728                         if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
3729                                 continue;
3730                         }
3731                         
3732                         if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
3733                                 TelType.insert(std::make_pair(wxT("home"), wxT("home")));
3734                                 continue;
3735                         }
3736                         
3737                         if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
3738                                 TelType.insert(std::make_pair(wxT("work"), wxT("work")));
3739                                 continue;
3740                         }
3742                         if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
3743                                 PropertyName = wxT("X-TYPE");
3744                                 PropertyValue = wxT("other");
3745                         }
3746                         
3747                         // Process the telephone type options.
3748                         
3749                         // text
3750                         
3751                         if (PropertyName == wxT("type") && (PropertyValue == wxT("TEXT") || PropertyValue == wxT("text"))){
3752                                 TelType.insert(std::make_pair(wxT("text"), wxT("text")));
3753                                 continue;
3754                         }
3755                         
3756                         // voice
3757                         
3758                         if (PropertyName == wxT("type") && (PropertyValue == wxT("VOICE") || PropertyValue == wxT("voice"))){
3759                                 TelType.insert(std::make_pair(wxT("voice"), wxT("voice")));
3760                                 continue;
3761                         }
3762                         
3763                         // fax
3764                         
3765                         if (PropertyName == wxT("type") && (PropertyValue == wxT("FAX") || PropertyValue == wxT("fax"))){
3766                                 TelType.insert(std::make_pair(wxT("fax"), wxT("fax")));
3767                                 continue;
3768                         }
3769                         
3770                         // cell
3771                         
3772                         if (PropertyName == wxT("type") && (PropertyValue == wxT("CELL") || PropertyValue == wxT("cell"))){
3773                                 TelType.insert(std::make_pair(wxT("cell"), wxT("cell")));
3774                                 continue;
3775                         }
3776                         
3777                         // video
3778                         
3779                         if (PropertyName == wxT("type") && (PropertyValue == wxT("VIDEO") || PropertyValue == wxT("video"))){
3780                                 TelType.insert(std::make_pair(wxT("video"), wxT("video")));
3781                                 continue;
3782                         }
3783                         
3784                         // pager
3785                         
3786                         if (PropertyName == wxT("type") && (PropertyValue == wxT("PAGER") || PropertyValue == wxT("pager"))){
3787                                 TelType.insert(std::make_pair(wxT("pager"), wxT("pager")));
3788                                 continue;
3789                         }
3790                         
3791                         // textphone
3792                         
3793                         if (PropertyName == wxT("type") && (PropertyValue == wxT("TEXTPHONE") || PropertyValue == wxT("textphone"))){
3794                                 TelType.insert(std::make_pair(wxT("textphone"), wxT("textphone")));
3795                                 continue;
3796                         }
3797                         
3798                         if (PropertyName == wxT("type") && PropertyValue.Find(wxT(",")) != wxNOT_FOUND){
3799                                 wxStringTokenizer TypeSplit(PropertyValue, wxT(","));
3800                                 wxString TypeSplitData;
3801                                 while (TypeSplit.HasMoreTokens()){
3802                                 
3803                                         TypeSplitData = TypeSplit.GetNextToken();
3804                                         TelType.insert(std::make_pair(TypeSplitData, TypeSplitData));
3805                                         TypeSplitData.clear();
3806                                 
3807                                 }
3808                                 
3809                         }
3810                         
3811                         // Process properties.
3812                         
3813                         if (PropertyName.IsEmpty()){
3814                         
3815                                 continue;
3816                         
3817                         }
3818                         
3819                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
3821                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3822                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3823         
3824                         } else {
3825                         
3826                                 PropertyDataMap->erase(PropertyName);
3827                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3828                                 PropertyLockMap->erase(PropertyName);
3829                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3830                         
3831                         }
3832                 
3833                 }
3834                 
3835                 wxString TelFinalString;
3836                 bool TelFirstToken = TRUE;
3837                 
3838                 for (std::map<wxString, wxString>::iterator intiter = TelType.begin(); 
3839                 intiter != TelType.end(); ++intiter){
3840                 
3841                         // Process the type data into a single value. (e.g. TYPE="work,voice,cell").
3842                         
3843                         if (TelFirstToken == TRUE){
3844                         
3845                                 TelFinalString.Append(wxT("\""));
3846                                 TelFinalString.Append(intiter->first);
3847                                 TelFirstToken = FALSE;
3848                         
3849                         } else {
3850                         
3851                                 TelFinalString.Append(wxT(","));
3852                                 TelFinalString.Append(intiter->first);
3853                         
3854                         }
3855                 
3856                 }
3857                 
3858                 if (TelFirstToken == FALSE){
3859                 
3860                         TelFinalString.Append(wxT("\""));
3861                 
3862                 }
3863                 
3864                 if (!TelFinalString.IsEmpty()){
3865                 
3866                         if (PropertyDataMap->find(wxT("TYPE")) == PropertyDataMap->end()){
3868                                 PropertyDataMap->insert(std::make_pair(wxT("type"), TelFinalString));
3869                                 PropertyLockMap->insert(std::make_pair(wxT("type"), TRUE));
3870         
3871                         } else {
3872                         
3873                                 PropertyDataMap->erase(PropertyName);
3874                                 PropertyDataMap->insert(std::make_pair(wxT("type"), TelFinalString));
3875                                 PropertyLockMap->erase(PropertyName);
3876                                 PropertyLockMap->insert(std::make_pair(wxT("type"), TRUE));
3877                         
3878                         }
3879                 
3880                 }
3881         
3882         }
3883         
3884         // RELATED
3885         
3886         if (wxSProperty == wxT("X-ABRELATEDNAMES")){
3888                 if (ProcessItemData == TRUE){
3889         
3890                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
3891                 
3892                 } else {
3893                 
3894                         intPropertyLen = wxSPropertySeg1Ptr->Len();
3895                 
3896                 }
3897                 
3898                 std::map<int, int> SplitPoints;
3899                 std::map<int, int> SplitLength;
3900                 std::map<int, int>::iterator SLiter;                    
3901                 wxString PropertyData;
3902                 wxString PropertyName;
3903                 wxString PropertyValue;
3904                 wxString PropertyTokens;
3905                 bool FirstToken = TRUE;
3906                 int intPrevValue = 18;
3907                 
3908                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
3909                 *wxSPropertyDataNameOut = wxT("RELATED");
3910                 *VCardV3Value = TRUE;
3911                 
3912                 if (ProcessItemData == TRUE){
3913                 
3914                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
3915                         
3916                 } else {
3917                         
3918                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
3919                         
3920                 }
3921                 
3922                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3923                 intiter != SplitPoints.end(); ++intiter){
3924                 
3925                         SLiter = SplitLength.find(intiter->first);
3926                 
3927                         if (ProcessItemData == TRUE){
3928                 
3929                                 if (FirstToken == TRUE){
3930                         
3931                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
3932                                         FirstToken = FALSE;
3933                         
3934                                 } else {
3935                                 
3936                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
3937                                 
3938                                 }
3939                         
3940                         } else {                        
3941                                 
3942                                 if (FirstToken == TRUE){
3943                         
3944                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
3945                                         FirstToken = FALSE;
3946                         
3947                                 } else {
3948                                 
3949                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
3950                                 
3951                                 }
3952                         
3953                         }
3954                         
3955                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3956                         PropertyName = PropertyElement.GetNextToken();                          
3957                         PropertyValue = PropertyElement.GetNextToken();
3958                         
3959                         //ProcessCaptureStrings(&PropertyValue);
3960                         
3961                         intPrevValue = intiter->second;
3962                                 
3963                         if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
3964                                 continue;
3965                         }
3966                         
3967                         // Process properties.
3968                         
3969                         if (PropertyName.IsEmpty()){
3970                         
3971                                 continue;
3972                         
3973                         }
3974                         
3975                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
3977                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3978                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3979         
3980                         } else {
3981                         
3982                                 PropertyDataMap->erase(PropertyName);
3983                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
3984                                 PropertyLockMap->erase(PropertyName);
3985                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
3986                         
3987                         }
3988                 
3989                 }
3990         
3991         }
3992         
3993         // URL
3994         
3995         if (wxSProperty == wxT("URL")){
3997                 if (ProcessItemData == TRUE){
3998         
3999                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4000                 
4001                 } else {
4002                 
4003                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4004                 
4005                 }
4006                 
4007                 std::map<int, int> SplitPoints;
4008                 std::map<int, int> SplitLength;
4009                 std::map<int, int>::iterator SLiter;                    
4010                 wxString PropertyData;
4011                 wxString PropertyName;
4012                 wxString PropertyValue;
4013                 wxString PropertyTokens;
4014                 bool FirstToken = TRUE;
4015                 int intPrevValue = 5;
4016                 
4017                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
4018                 *wxSPropertyDataNameOut = wxT("URL");
4019                 *VCardV3Value = TRUE;
4020                 
4021                 if (ProcessItemData == TRUE){
4022                 
4023                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4024                         
4025                 } else {
4026                         
4027                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4028                         
4029                 }
4030                 
4031                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4032                 intiter != SplitPoints.end(); ++intiter){
4033                 
4034                         SLiter = SplitLength.find(intiter->first);
4035                 
4036                         if (ProcessItemData == TRUE){
4037                 
4038                                 if (FirstToken == TRUE){
4039                         
4040                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4041                                         FirstToken = FALSE;
4042                         
4043                                 } else {
4044                                 
4045                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4046                                 
4047                                 }
4048                         
4049                         } else {                        
4050                                 
4051                                 if (FirstToken == TRUE){
4052                         
4053                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4054                                         FirstToken = FALSE;
4055                         
4056                                 } else {
4057                                 
4058                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4059                                 
4060                                 }
4061                         
4062                         }
4063                         
4064                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4065                         PropertyName = PropertyElement.GetNextToken();                          
4066                         PropertyValue = PropertyElement.GetNextToken();
4067                         
4068                         //ProcessCaptureStrings(&PropertyValue);
4069                         
4070                         intPrevValue = intiter->second;
4071                                 
4072                         if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
4073                                 continue;
4074                         }
4075                         
4076                         if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
4077                                 PropertyValue = wxT("home");
4078                         }
4079                         
4080                         if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
4081                                 PropertyValue = wxT("work");
4082                         }
4084                         if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
4085                                 PropertyName = wxT("X-TYPE");
4086                                 PropertyValue = wxT("other");
4087                         }
4088                         
4089                         // Process properties.
4090                         
4091                         if (PropertyName.IsEmpty()){
4092                         
4093                                 continue;
4094                         
4095                         }
4096                         
4097                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4099                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4100                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4101         
4102                         } else {
4103                         
4104                                 PropertyDataMap->erase(PropertyName);
4105                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4106                                 PropertyLockMap->erase(PropertyName);
4107                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4108                         
4109                         }
4110                 
4111                 }
4112         
4113         }
4114         
4115         // TITLE
4116         
4117         if (wxSProperty == wxT("TITLE")){
4118                 
4119                 if (ProcessItemData == TRUE){
4120         
4121                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4122                 
4123                 } else {
4124                 
4125                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4126                 
4127                 }
4128                 
4129                 std::map<int, int> SplitPoints;
4130                 std::map<int, int> SplitLength;
4131                 std::map<int, int>::iterator SLiter;                    
4132                 wxString PropertyData;
4133                 wxString PropertyName;
4134                 wxString PropertyValue;
4135                 wxString PropertyTokens;
4136                 bool FirstToken = TRUE;
4137                 int intPrevValue = 7;
4138                 
4139                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
4140                 *wxSPropertyDataNameOut = wxT("TITLE");
4141                 *VCardV3Value = TRUE;
4142                 
4143                 if (ProcessItemData == TRUE){
4144                 
4145                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4146                         
4147                 } else {
4148                         
4149                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4150                         
4151                 }
4152                 
4153                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4154                 intiter != SplitPoints.end(); ++intiter){
4155                 
4156                         SLiter = SplitLength.find(intiter->first);
4157                 
4158                         if (ProcessItemData == TRUE){
4159                 
4160                                 if (FirstToken == TRUE){
4161                         
4162                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4163                                         FirstToken = FALSE;
4164                         
4165                                 } else {
4166                                 
4167                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4168                                 
4169                                 }
4170                         
4171                         } else {                        
4172                                 
4173                                 if (FirstToken == TRUE){
4174                         
4175                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4176                                         FirstToken = FALSE;
4177                         
4178                                 } else {
4179                                 
4180                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4181                                 
4182                                 }
4183                         
4184                         }
4185                         
4186                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4187                         PropertyName = PropertyElement.GetNextToken();                          
4188                         PropertyValue = PropertyElement.GetNextToken();
4189                         
4190                         //ProcessCaptureStrings(&PropertyValue);
4191                         
4192                         intPrevValue = intiter->second;
4193                         
4194                         // Process properties.
4195                         
4196                         if (PropertyName.IsEmpty()){
4197                         
4198                                 continue;
4199                         
4200                         }
4201                         
4202                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4204                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4205                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4206         
4207                         } else {
4208                         
4209                                 PropertyDataMap->erase(PropertyName);
4210                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4211                                 PropertyLockMap->erase(PropertyName);
4212                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4213                         
4214                         }
4215                 
4216                 }
4217         
4218         }
4219         
4220         // FN
4221         
4222         if (wxSProperty == wxT("FN")){
4224                 if (ProcessItemData == TRUE){
4225         
4226                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4227                 
4228                 } else {
4229                 
4230                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4231                 
4232                 }
4233                 
4234                 std::map<int, int> SplitPoints;
4235                 std::map<int, int> SplitLength;
4236                 std::map<int, int>::iterator SLiter;                    
4237                 wxString PropertyData;
4238                 wxString PropertyName;
4239                 wxString PropertyValue;
4240                 wxString PropertyTokens;
4241                 bool FirstToken = TRUE;
4242                 int intPrevValue = 4;
4243                 
4244                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
4245                 *wxSPropertyDataNameOut = wxT("FN");
4246                 *VCardV3Value = TRUE;
4247                 
4248                 if (ProcessItemData == TRUE){
4249                 
4250                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4251                         
4252                 } else {
4253                         
4254                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4255                         
4256                 }
4257                 
4258                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4259                 intiter != SplitPoints.end(); ++intiter){
4260                 
4261                         SLiter = SplitLength.find(intiter->first);
4262                 
4263                         if (ProcessItemData == TRUE){
4264                 
4265                                 if (FirstToken == TRUE){
4266                         
4267                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4268                                         FirstToken = FALSE;
4269                         
4270                                 } else {
4271                                 
4272                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4273                                 
4274                                 }
4275                         
4276                         } else {                        
4277                                 
4278                                 if (FirstToken == TRUE){
4279                         
4280                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4281                                         FirstToken = FALSE;
4282                         
4283                                 } else {
4284                                 
4285                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4286                                 
4287                                 }
4288                         
4289                         }
4290                         
4291                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4292                         PropertyName = PropertyElement.GetNextToken();                          
4293                         PropertyValue = PropertyElement.GetNextToken();
4294                         
4295                         //ProcessCaptureStrings(&PropertyValue);
4296                         
4297                         intPrevValue = intiter->second;
4298                         
4299                         // Process properties.
4300                         
4301                         if (PropertyName.IsEmpty()){
4302                         
4303                                 continue;
4304                         
4305                         }
4306                         
4307                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4309                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4310                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4311         
4312                         } else {
4313                         
4314                                 PropertyDataMap->erase(PropertyName);
4315                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4316                                 PropertyLockMap->erase(PropertyName);
4317                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4318                         
4319                         }
4320                 
4321                 }
4322         
4323         }
4324         
4325         // N
4326         
4327         if (wxSProperty == wxT("N")){
4329                 if (ProcessItemData == TRUE){
4330         
4331                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4332                 
4333                 } else {
4334                 
4335                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4336                 
4337                 }
4338                 
4339                 std::map<int, int> SplitPoints;
4340                 std::map<int, int> SplitLength;
4341                 std::map<int, int>::iterator SLiter;                    
4342                 wxString PropertyData;
4343                 wxString PropertyName;
4344                 wxString PropertyValue;
4345                 wxString PropertyTokens;
4346                 bool FirstToken = TRUE;
4347         int intPrevValue = 3;
4348         
4349                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
4350                 *wxSPropertyDataNameOut = wxT("N");
4351                 *VCardV3Value = TRUE;
4352                 
4353                 if (ProcessItemData == TRUE){
4354                 
4355                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4356                         
4357                 } else {
4358                         
4359                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4360                         
4361                 }
4362                 
4363                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4364                 intiter != SplitPoints.end(); ++intiter){
4365                 
4366                         SLiter = SplitLength.find(intiter->first);
4367                 
4368                         if (ProcessItemData == TRUE){
4369                 
4370                                 if (FirstToken == TRUE){
4371                         
4372                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4373                                         FirstToken = FALSE;
4374                         
4375                                 } else {
4376                                 
4377                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4378                                 
4379                                 }
4380                         
4381                         } else {                        
4382                                 
4383                                 if (FirstToken == TRUE){
4384                         
4385                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4386                                         FirstToken = FALSE;
4387                         
4388                                 } else {
4389                                 
4390                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4391                                 
4392                                 }
4393                         
4394                         }
4395                         
4396                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4397                         PropertyName = PropertyElement.GetNextToken();                          
4398                         PropertyValue = PropertyElement.GetNextToken();
4399                         
4400                         //ProcessCaptureStrings(&PropertyValue);
4401                         
4402                         intPrevValue = intiter->second;
4403                         
4404                         // Process properties.
4405                         
4406                         if (PropertyName.IsEmpty()){
4407                         
4408                                 continue;
4409                         
4410                         }
4411                         
4412                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4414                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4415                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4416         
4417                         } else {
4418                         
4419                                 PropertyDataMap->erase(PropertyName);
4420                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4421                                 PropertyLockMap->erase(PropertyName);
4422                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4423                         
4424                         }
4425                 
4426                 }
4427         
4428         }
4429         
4430         // UID
4432         if (wxSProperty == wxT("UID")){
4434                 if (ProcessItemData == TRUE){
4435         
4436                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4437                 
4438                 } else {
4439                 
4440                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4441                 
4442                 }
4443                 
4444                 std::map<int, int> SplitPoints;
4445                 std::map<int, int> SplitLength;
4446                 std::map<int, int>::iterator SLiter;                    
4447                 wxString PropertyData;
4448                 wxString PropertyName;
4449                 wxString PropertyValue;
4450                 wxString PropertyTokens;
4451                 bool FirstToken = TRUE;
4452                 int intPrevValue = 5;
4453                 
4454                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
4455                 *wxSPropertyDataNameOut = wxT("UID");
4456                 *VCardV3Value = TRUE;
4457                 
4458                 if (ProcessItemData == TRUE){
4459                 
4460                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4461                         
4462                 } else {
4463                         
4464                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4465                         
4466                 }
4467                 
4468                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4469                 intiter != SplitPoints.end(); ++intiter){
4470                 
4471                         SLiter = SplitLength.find(intiter->first);
4472                 
4473                         if (ProcessItemData == TRUE){
4474                 
4475                                 if (FirstToken == TRUE){
4476                         
4477                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4478                                         FirstToken = FALSE;
4479                         
4480                                 } else {
4481                                 
4482                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4483                                 
4484                                 }
4485                         
4486                         } else {                        
4487                                 
4488                                 if (FirstToken == TRUE){
4489                         
4490                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4491                                         FirstToken = FALSE;
4492                         
4493                                 } else {
4494                                 
4495                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4496                                 
4497                                 }
4498                         
4499                         }
4500                         
4501                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4502                         PropertyName = PropertyElement.GetNextToken();                          
4503                         PropertyValue = PropertyElement.GetNextToken();
4504                         
4505                         //ProcessCaptureStrings(&PropertyValue);
4506                         
4507                         intPrevValue = intiter->second;
4508                         
4509                         // Process properties.
4511                         if (PropertyName.IsEmpty()){
4512                         
4513                                 continue;
4514                         
4515                         }
4516                                                 
4517                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4519                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4520                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4521         
4522                         } else {
4523                         
4524                                 PropertyDataMap->erase(PropertyName);
4525                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4526                                 PropertyLockMap->erase(PropertyName);
4527                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4528                         
4529                         }
4530                 
4531                 }
4532         
4533         }
4534         
4535         // NICKNAME
4536         
4537         if (wxSProperty == wxT("NICKNAME")){
4539                 if (ProcessItemData == TRUE){
4540         
4541                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4542                 
4543                 } else {
4544                 
4545                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4546                 
4547                 }
4548                 
4549                 std::map<int, int> SplitPoints;
4550                 std::map<int, int> SplitLength;
4551                 std::map<int, int>::iterator SLiter;                    
4552                 wxString PropertyData;
4553                 wxString PropertyName;
4554                 wxString PropertyValue;
4555                 wxString PropertyTokens;
4556                 bool FirstToken = TRUE;
4557                 int intPrevValue = 10;
4558                 
4559                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
4560                 *wxSPropertyDataNameOut = wxT("NICKNAME");
4561                 *VCardV3Value = TRUE;
4562                 
4563                 if (ProcessItemData == TRUE){
4564                 
4565                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4566                         
4567                 } else {
4568                         
4569                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4570                         
4571                 }
4572                 
4573                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4574                 intiter != SplitPoints.end(); ++intiter){
4575                 
4576                         SLiter = SplitLength.find(intiter->first);
4577                 
4578                         if (ProcessItemData == TRUE){
4579                 
4580                                 if (FirstToken == TRUE){
4581                         
4582                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4583                                         FirstToken = FALSE;
4584                         
4585                                 } else {
4586                                 
4587                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4588                                 
4589                                 }
4590                         
4591                         } else {                        
4592                                 
4593                                 if (FirstToken == TRUE){
4594                         
4595                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4596                                         FirstToken = FALSE;
4597                         
4598                                 } else {
4599                                 
4600                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4601                                 
4602                                 }
4603                         
4604                         }
4605                         
4606                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4607                         PropertyName = PropertyElement.GetNextToken();                          
4608                         PropertyValue = PropertyElement.GetNextToken();
4609                         
4610                         //ProcessCaptureStrings(&PropertyValue);
4611                         
4612                         intPrevValue = intiter->second;
4613                         
4614                         // Process properties.
4616                         if (PropertyName.IsEmpty()){
4617                         
4618                                 continue;
4619                         
4620                         }
4621                                                 
4622                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4624                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4625                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4626         
4627                         } else {
4628                         
4629                                 PropertyDataMap->erase(PropertyName);
4630                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4631                                 PropertyLockMap->erase(PropertyName);
4632                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4633                         
4634                         }
4635                 
4636                 }
4637         
4638         }
4639         
4640         // GENDER
4641         
4642         if (wxSProperty == wxT("GENDER")){
4644                 if (ProcessItemData == TRUE){
4645         
4646                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4647                 
4648                 } else {
4649                 
4650                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4651                 
4652                 }
4653                 
4654                 std::map<int, int> SplitPoints;
4655                 std::map<int, int> SplitLength;
4656                 std::map<int, int>::iterator SLiter;                    
4657                 wxString PropertyData;
4658                 wxString PropertyName;
4659                 wxString PropertyValue;
4660                 wxString PropertyTokens;
4661                 bool FirstToken = TRUE;
4662                 int intPrevValue = 8;
4663                 
4664                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
4665                 *wxSPropertyDataNameOut = wxT("GENDER");
4666                 *VCardV3Value = TRUE;
4667                 
4668                 if (ProcessItemData == TRUE){
4669                 
4670                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4671                         
4672                 } else {
4673                         
4674                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4675                         
4676                 }
4677                 
4678                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4679                 intiter != SplitPoints.end(); ++intiter){
4680                 
4681                         SLiter = SplitLength.find(intiter->first);
4682                 
4683                         if (ProcessItemData == TRUE){
4684                 
4685                                 if (FirstToken == TRUE){
4686                         
4687                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4688                                         FirstToken = FALSE;
4689                         
4690                                 } else {
4691                                 
4692                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4693                                 
4694                                 }
4695                         
4696                         } else {                        
4697                                 
4698                                 if (FirstToken == TRUE){
4699                         
4700                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4701                                         FirstToken = FALSE;
4702                         
4703                                 } else {
4704                                 
4705                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4706                                 
4707                                 }
4708                         
4709                         }
4710                         
4711                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4712                         PropertyName = PropertyElement.GetNextToken();                          
4713                         PropertyValue = PropertyElement.GetNextToken();
4714                         
4715                         //ProcessCaptureStrings(&PropertyValue);
4716                         
4717                         intPrevValue = intiter->second;
4718                         
4719                         // Process properties.
4720                         
4721                         if (PropertyName.IsEmpty()){
4722                         
4723                                 continue;
4724                         
4725                         }
4726                         
4727                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4729                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4730                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4731         
4732                         } else {
4733                         
4734                                 PropertyDataMap->erase(PropertyName);
4735                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4736                                 PropertyLockMap->erase(PropertyName);
4737                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4738                         
4739                         }
4740                 
4741                 }
4742         
4743         }
4744         
4745         // BDAY
4746         
4747         if (wxSProperty == wxT("BDAY")){
4749                 if (ProcessItemData == TRUE){
4750         
4751                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4752                 
4753                 } else {
4754                 
4755                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4756                 
4757                 }
4758                 
4759                 std::map<int, int> SplitPoints;
4760                 std::map<int, int> SplitLength;
4761                 std::map<int, int>::iterator SLiter;                    
4762                 wxString PropertyData;
4763                 wxString PropertyName;
4764                 wxString PropertyValue;
4765                 wxString PropertyTokens;
4766                 wxString PropertyXOmitYear;
4767                 bool FirstToken = TRUE;
4768                 int intPrevValue = 6;
4769                 
4770                 *wxSPropertyDataNameOut = wxT("BDAY");
4771                 *VCardV3Value = TRUE;
4772                 
4773                 if (ProcessItemData == TRUE){
4774                 
4775                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4776                         
4777                 } else {
4778                         
4779                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4780                         
4781                 }
4782                 
4783                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4784                 intiter != SplitPoints.end(); ++intiter){
4785                 
4786                         SLiter = SplitLength.find(intiter->first);
4787                 
4788                         if (ProcessItemData == TRUE){
4789                 
4790                                 if (FirstToken == TRUE){
4791                         
4792                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4793                                         FirstToken = FALSE;
4794                         
4795                                 } else {
4796                                 
4797                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4798                                 
4799                                 }
4800                         
4801                         } else {                        
4802                                 
4803                                 if (FirstToken == TRUE){
4804                         
4805                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4806                                         FirstToken = FALSE;
4807                         
4808                                 } else {
4809                                 
4810                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4811                                 
4812                                 }
4813                         
4814                         }
4815                         
4816                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4817                         PropertyName = PropertyElement.GetNextToken();                          
4818                         PropertyValue = PropertyElement.GetNextToken();
4819                         
4820                         //ProcessCaptureStrings(&PropertyValue);
4821                         
4822                         intPrevValue = intiter->second;
4823                         
4824                         if (PropertyName == wxT("X-APPLE-OMIT-YEAR")){
4825                                 PropertyXOmitYear = PropertyValue;
4826                         }
4827                         
4828                         // Process properties.
4829                         
4830                         if (PropertyName.IsEmpty()){
4831                         
4832                                 continue;
4833                         
4834                         }
4835                         
4836                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4838                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4839                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4840         
4841                         } else {
4842                         
4843                                 PropertyDataMap->erase(PropertyName);
4844                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4845                                 PropertyLockMap->erase(PropertyName);
4846                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4847                         
4848                         }
4849                 
4850                 }
4851                 
4852                 // Convert the date from YYYY-MM-DD to YYYYMMDD or --MMDD depending on if the
4853                 // year matches the X-APPLE-OMIT-YEAR value.
4854                 
4855                 wxStringTokenizer DateSplit(*wxSPropertySeg2Ptr, wxT("-"));
4856                 
4857                 wxString DateProc;
4858                 wxString FinalDate;
4859                 
4860                 DateProc = DateSplit.GetNextToken();
4861                 
4862                 if (DateProc == PropertyXOmitYear){
4863                 
4864                         FinalDate.Append(wxT("--"));
4865                 
4866                 } else {
4867                 
4868                         FinalDate.Append(DateProc);
4869                 
4870                 }
4871                 
4872                 DateProc.clear();
4873                 DateProc = DateSplit.GetNextToken();
4874                 
4875                 FinalDate.Append(DateProc);
4877                 DateProc.clear();
4878                 DateProc = DateSplit.GetNextToken();            
4879                 
4880                 FinalDate.Append(DateProc);
4881                 
4882                 wxSPropertyDataOut->Append(FinalDate);
4883         
4884         }
4885         
4886         // ANNIVERSARY
4887         
4888         if (wxSProperty == wxT("ANNIVERSARY")){
4890                 if (ProcessItemData == TRUE){
4891         
4892                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
4893                 
4894                 } else {
4895                 
4896                         intPropertyLen = wxSPropertySeg1Ptr->Len();
4897                 
4898                 }
4899                 
4900                 std::map<int, int> SplitPoints;
4901                 std::map<int, int> SplitLength;
4902                 std::map<int, int>::iterator SLiter;                    
4903                 wxString PropertyData;
4904                 wxString PropertyName;
4905                 wxString PropertyValue;
4906                 wxString PropertyTokens;
4907                 wxString PropertyXOmitYear;
4908                 bool FirstToken = TRUE;
4909                 int intPrevValue = 13;
4910                 
4911                 *wxSPropertyDataNameOut = wxT("ANNIVERSARY");
4912                 *VCardV3Value = TRUE;
4913                 
4914                 if (ProcessItemData == TRUE){
4915                 
4916                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
4917                         
4918                 } else {
4919                         
4920                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
4921                         
4922                 }
4923                 
4924                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4925                 intiter != SplitPoints.end(); ++intiter){
4926                 
4927                         SLiter = SplitLength.find(intiter->first);
4928                 
4929                         if (ProcessItemData == TRUE){
4930                 
4931                                 if (FirstToken == TRUE){
4932                         
4933                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
4934                                         FirstToken = FALSE;
4935                         
4936                                 } else {
4937                                 
4938                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
4939                                 
4940                                 }
4941                         
4942                         } else {                        
4943                                 
4944                                 if (FirstToken == TRUE){
4945                         
4946                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
4947                                         FirstToken = FALSE;
4948                         
4949                                 } else {
4950                                 
4951                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
4952                                 
4953                                 }
4954                         
4955                         }
4956                         
4957                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4958                         PropertyName = PropertyElement.GetNextToken();                          
4959                         PropertyValue = PropertyElement.GetNextToken();
4960                         
4961                         //ProcessCaptureStrings(&PropertyValue);
4962                         
4963                         intPrevValue = intiter->second;
4964                         
4965                         if (PropertyName == wxT("X-APPLE-OMIT-YEAR")){
4966                                 PropertyXOmitYear = PropertyValue;
4967                         }
4968                         
4969                         // Process properties.
4970                         
4971                         if (PropertyName.IsEmpty()){
4972                         
4973                                 continue;
4974                         
4975                         }
4976                         
4977                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
4979                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4980                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4981         
4982                         } else {
4983                         
4984                                 PropertyDataMap->erase(PropertyName);
4985                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
4986                                 PropertyLockMap->erase(PropertyName);
4987                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
4988                         
4989                         }
4990                 
4991                 }
4992                 
4993                 // Convert the date from YYYY-MM-DD to YYYYMMDD or --MMDD depending on if the
4994                 // year matches the X-APPLE-OMIT-YEAR value.
4995                 
4996                 wxStringTokenizer DateSplit(*wxSPropertySeg2Ptr, wxT("-"));
4997                 
4998                 wxString DateProc;
4999                 wxString FinalDate;
5000                 
5001                 DateProc = DateSplit.GetNextToken();
5002                 
5003                 if (DateProc == PropertyXOmitYear){
5004                 
5005                         FinalDate.Append(wxT("--"));
5006                 
5007                 } else {
5008                 
5009                         FinalDate.Append(DateProc);
5010                 
5011                 }
5012                 
5013                 DateProc.clear();
5014                 DateProc = DateSplit.GetNextToken();
5015                 
5016                 FinalDate.Append(DateProc);
5018                 DateProc.clear();
5019                 DateProc = DateSplit.GetNextToken();            
5020                 
5021                 FinalDate.Append(DateProc);
5022                 
5023                 wxSPropertyDataOut->Append(FinalDate);
5024         
5025         }
5026         
5027         // TZ - Not sure how to process this correctly. So data
5028         // is kept as X-VCARD3-TZ for the time being.
5029         
5030         if (wxSProperty == wxT("TZ")){
5032                 if (ProcessItemData == TRUE){
5033         
5034                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5035                 
5036                 } else {
5037                 
5038                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5039                 
5040                 }
5041                 
5042                 std::map<int, int> SplitPoints;
5043                 std::map<int, int> SplitLength;
5044                 std::map<int, int>::iterator SLiter;                    
5045                 wxString PropertyData;
5046                 wxString PropertyName;
5047                 wxString PropertyValue;
5048                 wxString PropertyTokens;
5049                 wxString PropertyXOmitYear;
5050                 bool FirstToken = TRUE;
5051                 int intPrevValue = 4;
5052                 
5053                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
5054                 *wxSPropertyDataNameOut = wxT("X-VCARD3-TZ");
5055                 *VCardV3Value = TRUE;
5056                 
5057                 if (ProcessItemData == TRUE){
5058                 
5059                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5060                         
5061                 } else {
5062                         
5063                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5064                         
5065                 }
5066                 
5067                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5068                 intiter != SplitPoints.end(); ++intiter){
5069                 
5070                         SLiter = SplitLength.find(intiter->first);
5071                 
5072                         if (ProcessItemData == TRUE){
5073                 
5074                                 if (FirstToken == TRUE){
5075                         
5076                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5077                                         FirstToken = FALSE;
5078                         
5079                                 } else {
5080                                 
5081                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5082                                 
5083                                 }
5084                         
5085                         } else {                        
5086                                 
5087                                 if (FirstToken == TRUE){
5088                         
5089                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5090                                         FirstToken = FALSE;
5091                         
5092                                 } else {
5093                                 
5094                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5095                                 
5096                                 }
5097                         
5098                         }
5099                         
5100                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5101                         PropertyName = PropertyElement.GetNextToken();                          
5102                         PropertyValue = PropertyElement.GetNextToken();
5103                         
5104                         //ProcessCaptureStrings(&PropertyValue);
5105                         
5106                         intPrevValue = intiter->second;
5107                         
5108                         // Process properties.
5109                         
5110                         if (PropertyName.IsEmpty()){
5111                         
5112                                 continue;
5113                         
5114                         }
5115                         
5116                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5118                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5119                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5120         
5121                         } else {
5122                         
5123                                 PropertyDataMap->erase(PropertyName);
5124                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5125                                 PropertyLockMap->erase(PropertyName);
5126                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5127                         
5128                         }
5129                 
5130                 }
5131         
5132         }
5133         
5134         // ROLE
5135         
5136         if (wxSProperty == wxT("ROLE")){
5138                 if (ProcessItemData == TRUE){
5139         
5140                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5141                 
5142                 } else {
5143                 
5144                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5145                 
5146                 }
5147                 
5148                 std::map<int, int> SplitPoints;
5149                 std::map<int, int> SplitLength;
5150                 std::map<int, int>::iterator SLiter;                    
5151                 wxString PropertyData;
5152                 wxString PropertyName;
5153                 wxString PropertyValue;
5154                 wxString PropertyTokens;
5155                 wxString PropertyXOmitYear;
5156                 bool FirstToken = TRUE;
5157                 int intPrevValue = 6;
5158                 
5159                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
5160                 *wxSPropertyDataNameOut = wxT("ROLE");
5161                 *VCardV3Value = TRUE;
5162                 
5163                 if (ProcessItemData == TRUE){
5164                 
5165                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5166                         
5167                 } else {
5168                         
5169                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5170                         
5171                 }
5172                 
5173                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5174                 intiter != SplitPoints.end(); ++intiter){
5175                 
5176                         SLiter = SplitLength.find(intiter->first);
5177                 
5178                         if (ProcessItemData == TRUE){
5179                 
5180                                 if (FirstToken == TRUE){
5181                         
5182                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5183                                         FirstToken = FALSE;
5184                         
5185                                 } else {
5186                                 
5187                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5188                                 
5189                                 }
5190                         
5191                         } else {                        
5192                                 
5193                                 if (FirstToken == TRUE){
5194                         
5195                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5196                                         FirstToken = FALSE;
5197                         
5198                                 } else {
5199                                 
5200                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5201                                 
5202                                 }
5203                         
5204                         }
5205                         
5206                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5207                         PropertyName = PropertyElement.GetNextToken();                          
5208                         PropertyValue = PropertyElement.GetNextToken();
5209                         
5210                         //ProcessCaptureStrings(&PropertyValue);
5211                         
5212                         intPrevValue = intiter->second;
5213                         
5214                         // Process properties.
5215                         
5216                         if (PropertyName.IsEmpty()){
5217                         
5218                                 continue;
5219                         
5220                         }
5221                         
5222                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5224                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5225                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5226         
5227                         } else {
5228                         
5229                                 PropertyDataMap->erase(PropertyName);
5230                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5231                                 PropertyLockMap->erase(PropertyName);
5232                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5233                         
5234                         }
5235                 
5236                 }
5237         
5238         }
5239         
5240         // ORG
5241         
5242         if (wxSProperty == wxT("ORG")){
5244                 if (ProcessItemData == TRUE){
5245         
5246                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5247                 
5248                 } else {
5249                 
5250                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5251                 
5252                 }
5253                 
5254                 std::map<int, int> SplitPoints;
5255                 std::map<int, int> SplitLength;
5256                 std::map<int, int>::iterator SLiter;                    
5257                 wxString PropertyData;
5258                 wxString PropertyName;
5259                 wxString PropertyValue;
5260                 wxString PropertyTokens;
5261                 wxString PropertyXOmitYear;
5262                 bool FirstToken = TRUE;
5263                 int intPrevValue = 5;
5264                 
5265                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
5266                 *wxSPropertyDataNameOut = wxT("ORG");
5267                 *VCardV3Value = TRUE;
5268                 
5269                 if (ProcessItemData == TRUE){
5270                 
5271                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5272                         
5273                 } else {
5274                         
5275                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5276                         
5277                 }
5278                 
5279                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5280                 intiter != SplitPoints.end(); ++intiter){
5281                 
5282                         SLiter = SplitLength.find(intiter->first);
5283                 
5284                         if (ProcessItemData == TRUE){
5285                 
5286                                 if (FirstToken == TRUE){
5287                         
5288                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5289                                         FirstToken = FALSE;
5290                         
5291                                 } else {
5292                                 
5293                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5294                                 
5295                                 }
5296                         
5297                         } else {                        
5298                                 
5299                                 if (FirstToken == TRUE){
5300                         
5301                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5302                                         FirstToken = FALSE;
5303                         
5304                                 } else {
5305                                 
5306                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5307                                 
5308                                 }
5309                         
5310                         }
5311                         
5312                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5313                         PropertyName = PropertyElement.GetNextToken();                          
5314                         PropertyValue = PropertyElement.GetNextToken();
5315                         
5316                         //ProcessCaptureStrings(&PropertyValue);
5317                         
5318                         intPrevValue = intiter->second;
5319                         
5320                         // Process properties.
5321                         
5322                         if (PropertyName.IsEmpty()){
5323                         
5324                                 continue;
5325                         
5326                         }
5327                         
5328                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5330                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5331                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5332         
5333                         } else {
5334                         
5335                                 PropertyDataMap->erase(PropertyName);
5336                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5337                                 PropertyLockMap->erase(PropertyName);
5338                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5339                         
5340                         }
5341                 
5342                 }
5343         
5344         }
5345         
5346         // NOTE
5347         
5348         if (wxSProperty == wxT("NOTE")){
5350                 if (ProcessItemData == TRUE){
5351         
5352                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5353                 
5354                 } else {
5355                 
5356                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5357                 
5358                 }
5359                 
5360                 std::map<int, int> SplitPoints;
5361                 std::map<int, int> SplitLength;
5362                 std::map<int, int>::iterator SLiter;                    
5363                 wxString PropertyData;
5364                 wxString PropertyName;
5365                 wxString PropertyValue;
5366                 wxString PropertyTokens;
5367                 wxString PropertyXOmitYear;
5368                 bool FirstToken = TRUE;
5369                 int intPrevValue = 6;
5370                 
5371                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
5372                 *wxSPropertyDataNameOut = wxT("NOTE");
5373                 *VCardV3Value = TRUE;
5374                 
5375                 if (ProcessItemData == TRUE){
5376                 
5377                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5378                         
5379                 } else {
5380                         
5381                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5382                         
5383                 }
5384                 
5385                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5386                 intiter != SplitPoints.end(); ++intiter){
5387                 
5388                         SLiter = SplitLength.find(intiter->first);
5389                 
5390                         if (ProcessItemData == TRUE){
5391                 
5392                                 if (FirstToken == TRUE){
5393                         
5394                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5395                                         FirstToken = FALSE;
5396                         
5397                                 } else {
5398                                 
5399                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5400                                 
5401                                 }
5402                         
5403                         } else {                        
5404                                 
5405                                 if (FirstToken == TRUE){
5406                         
5407                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5408                                         FirstToken = FALSE;
5409                         
5410                                 } else {
5411                                 
5412                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5413                                 
5414                                 }
5415                         
5416                         }
5417                         
5418                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5419                         PropertyName = PropertyElement.GetNextToken();                          
5420                         PropertyValue = PropertyElement.GetNextToken();
5421                         
5422                         //ProcessCaptureStrings(&PropertyValue);
5423                         
5424                         intPrevValue = intiter->second;
5425                         
5426                         // Process properties.
5427                         
5428                         if (PropertyName.IsEmpty()){
5429                         
5430                                 continue;
5431                         
5432                         }
5433                         
5434                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5436                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5437                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5438         
5439                         } else {
5440                         
5441                                 PropertyDataMap->erase(PropertyName);
5442                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5443                                 PropertyLockMap->erase(PropertyName);
5444                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5445                         
5446                         }
5447                 
5448                 }
5449         
5450         }
5451         
5452         // PHOTO
5453         
5454         if (wxSProperty == wxT("PHOTO")){
5455                 
5456                 if (ProcessItemData == TRUE){
5457         
5458                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5459                 
5460                 } else {
5461                 
5462                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5463                 
5464                 }
5465                 
5466                 std::map<int, int> SplitPoints;
5467                 std::map<int, int> SplitLength;
5468                 std::map<int, int>::iterator SLiter;
5469                 std::map<wxString, wxString> SplitData;                         
5470                 wxString PropertyData;
5471                 wxString PropertyName;
5472                 wxString PropertyValue;
5473                 wxString PropertyTokens;
5474                 wxString PropertyXOmitYear;
5475                 int intPrevValue = 7;
5476                 
5477                 *wxSPropertyDataNameOut = wxT("PHOTO");
5478                 *VCardV3Value = TRUE;
5479                 
5480                 if (ProcessItemData == TRUE){
5481                 
5482                         SplitValuesData(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue, &SplitData);
5483                         
5484                 } else {
5485                         
5486                         SplitValuesData(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue, &SplitData);
5487                         
5488                 }
5489                 
5490                 wxString wxSMIMEType;
5491                 wxString wxSEncType;
5492                 
5493                 for (std::map<wxString, wxString>::iterator intiter = SplitData.begin();
5494                 intiter != SplitData.end(); ++intiter){
5495                 
5496                         PropertyName = intiter->first;                          
5497                         PropertyValue = intiter->second;
5499                         if (PropertyName == wxT("ENCODING") && PropertyValue == wxT("b")){
5500                                 wxSEncType = wxT("base64");
5501                                 continue;
5502                         }
5503                         
5504                         if ((PropertyName == wxT("TYPE") || PropertyName == wxT("type")) && PropertyValue == wxT("PNG")){
5505                                 wxSMIMEType = wxT("image/png");
5506                                 continue;
5507                         } else if ((PropertyName == wxT("TYPE") || PropertyName == wxT("type")) && PropertyValue == wxT("JPEG")){
5508                                 wxSMIMEType = wxT("image/jpeg");
5509                                 continue;
5510                         } else if ((PropertyName == wxT("TYPE") || PropertyName == wxT("type")) && PropertyValue == wxT("GIF")){
5511                                 wxSMIMEType = wxT("image/gif");
5512                                 continue;
5513                         } else if ((PropertyName == wxT("TYPE") || PropertyName == wxT("type")) && PropertyValue == wxT("BMP")){
5514                                 wxSMIMEType = wxT("image/bmp");
5515                                 continue;
5516                         } else if (PropertyName == wxT("TYPE") || PropertyName == wxT("type")) {
5517                                 wxSMIMEType = wxT("image/unknown");
5518                                 continue;
5519                         }
5520                         
5521                         //intPrevValue = intiter->second;
5522                         
5523                         // Process properties.
5524                         
5525                         if (PropertyName.IsEmpty()){
5526                         
5527                                 continue;
5528                         
5529                         }
5530                         
5531                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5533                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5534                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5535         
5536                         } else {
5537                         
5538                                 PropertyDataMap->erase(PropertyName);
5539                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5540                                 PropertyLockMap->erase(PropertyName);
5541                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5542                         
5543                         }
5544                 
5545                 }
5546                 
5547                 wxSPropertyDataOut->Append(wxT("data:"));
5548                 wxSPropertyDataOut->Append(wxSMIMEType);
5549                 wxSPropertyDataOut->Append(wxT(";"));
5550                 wxSPropertyDataOut->Append(wxSEncType);
5551                 wxSPropertyDataOut->Append(wxT(","));
5552                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
5553         
5554         }
5555         
5556         // SOUND
5557         
5558         if (wxSProperty == wxT("SOUND")){
5559         
5560                 if (ProcessItemData == TRUE){
5561         
5562                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5563                 
5564                 } else {
5565                 
5566                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5567                 
5568                 }
5569                 
5570                 std::map<int, int> SplitPoints;
5571                 std::map<int, int> SplitLength;
5572                 std::map<int, int>::iterator SLiter;                    
5573                 wxString PropertyData;
5574                 wxString PropertyName;
5575                 wxString PropertyValue;
5576                 wxString PropertyTokens;
5577                 wxString PropertyXOmitYear;
5578                 bool FirstToken = TRUE;
5579                 int intPrevValue = 7;
5580                 
5581                 *wxSPropertyDataNameOut = wxT("SOUND");
5582                 *VCardV3Value = TRUE;
5583                 
5584                 if (ProcessItemData == TRUE){
5585                 
5586                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5587                         
5588                 } else {
5589                         
5590                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5591                         
5592                 }
5593                 
5594                 wxString wxSMIMEType;
5595                 wxString wxSEncType;
5596                 
5597                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5598                 intiter != SplitPoints.end(); ++intiter){
5599                 
5600                         SLiter = SplitLength.find(intiter->first);
5601                 
5602                         if (ProcessItemData == TRUE){
5603                 
5604                                 if (FirstToken == TRUE){
5605                         
5606                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5607                                         FirstToken = FALSE;
5608                         
5609                                 } else {
5610                                 
5611                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5612                                 
5613                                 }
5614                         
5615                         } else {                        
5616                                 
5617                                 if (FirstToken == TRUE){
5618                         
5619                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5620                                         FirstToken = FALSE;
5621                         
5622                                 } else {
5623                                 
5624                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5625                                 
5626                                 }
5627                         
5628                         }
5629                         
5630                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5631                         PropertyName = PropertyElement.GetNextToken();                          
5632                         PropertyValue = PropertyElement.GetNextToken();
5633                         
5634                         //ProcessCaptureStrings(&PropertyValue);
5635                         
5636                         if (PropertyName == wxT("ENCODING") && PropertyValue == wxT("b")){
5637                                 wxSEncType = wxT("base64");
5638                                 continue;
5639                         }
5640                         
5641                         if ((PropertyName == wxT("TYPE") || PropertyName == wxT("type"))){
5642                                 wxSMIMEType = PropertyValue;
5643                                 continue;
5644                         }
5645                         
5646                         intPrevValue = intiter->second;
5647                         
5648                         // Process properties.
5649                         
5650                         if (PropertyName.IsEmpty()){
5651                         
5652                                 continue;
5653                         
5654                         }
5655                         
5656                         if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5658                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5659                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5660         
5661                         } else {
5662                         
5663                                 PropertyDataMap->erase(PropertyName);
5664                                 PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5665                                 PropertyLockMap->erase(PropertyName);
5666                                 PropertyLockMap->insert(std::make_pair(PropertyName, TRUE));
5667                         
5668                         }
5669                 
5670                 }
5671                 
5672                 wxSPropertyDataOut->Append(wxT("data:"));
5673                 wxSPropertyDataOut->Append(wxSMIMEType);
5674                 wxSPropertyDataOut->Append(wxT(";"));
5675                 wxSPropertyDataOut->Append(wxSEncType);
5676                 wxSPropertyDataOut->Append(wxT(","));
5677                 wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
5678         
5679         }
5680         
5681         // Look for backward compatability vCard 4.0 properties.
5682         
5683         // X-VCARD4-FN
5684         
5685         if (wxSProperty == wxT("X-VCARD4-FN")){
5686         
5687                 if (ProcessItemData == TRUE){
5688         
5689                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5690                 
5691                 } else {
5692                 
5693                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5694                                 *wxSPropertyDataNameOut = wxT("FN");
5695                 
5696                 }
5697                 
5698                 std::map<int, int> SplitPoints;
5699                 std::map<int, int> SplitLength;
5700                 std::map<int, int>::iterator SLiter;
5701                 std::map<wxString, bool>::iterator BIter;;                      
5702                 wxString PropertyData;
5703                 wxString PropertyName;
5704                 wxString PropertyValue;
5705                 wxString PropertyTokens;
5706                 bool FirstToken = TRUE;
5707                 int intPrevValue = 13;
5709                 if (ProcessItemData == TRUE){
5710                 
5711                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5712                         
5713                 } else {
5714                         
5715                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5716                         
5717                 }
5718                 
5719                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5720                 intiter != SplitPoints.end(); ++intiter){
5721                 
5722                         SLiter = SplitLength.find(intiter->first);
5723                 
5724                         if (ProcessItemData == TRUE){
5726                                 if (FirstToken == TRUE){
5727                 
5728                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5729                                         FirstToken = FALSE;
5730                                 
5731                                 } else {
5732                                 
5733                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5734                                 
5735                                 }
5736                         
5737                         } else {
5738                         
5739                                 if (FirstToken == TRUE){
5740                         
5741                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5742                                         FirstToken = FALSE;
5743                                                                 
5744                                 } else {
5745                                 
5746                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5747                                         
5748                                 }
5749                         
5750                         }
5751                         
5752                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5753                         PropertyName = PropertyElement.GetNextToken();                          
5754                         PropertyValue = PropertyElement.GetNextToken();
5755                         
5756                         //ProcessCaptureStrings(&PropertyValue);
5757                         
5758                         intPrevValue = intiter->second;
5759                         
5760                         // Process properties.
5761                         
5762                         // Check if there is a lock on the property value. If there is a lock then
5763                         // the property value cannot be changed.
5764                         
5765                         if (PropertyName.IsEmpty()){
5766                         
5767                                 continue;
5768                         
5769                         }
5770                         
5771                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
5772                         
5773                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5774                         
5775                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5776                         
5777                                 } else {
5778                         
5779                                         PropertyDataMap->erase(PropertyName);
5780                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5781                         
5782                                 }
5783                                 
5784                         }
5785                         
5786                         //wxSPropertyPropValuesOut->Append(wxT(";"));
5787                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
5788                 
5789                 }
5790                 
5791                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
5792                 *XVCardV4Value = TRUE;
5793                                 
5794         }
5795         
5796         // X-VCARD4-N
5797         
5798         if (wxSProperty == wxT("X-VCARD4-N")){
5800                 if (ProcessItemData == TRUE){
5801         
5802                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5803                 
5804                 } else {
5805                 
5806                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5807                 
5808                 }
5809                 
5810                 std::map<int, int> SplitPoints;
5811                 std::map<int, int> SplitLength;
5812                 std::map<int, int>::iterator SLiter;
5813                 std::map<wxString, bool>::iterator BIter;;                      
5814                 wxString PropertyData;
5815                 wxString PropertyName;
5816                 wxString PropertyValue;
5817                 wxString PropertyTokens;
5818         bool FirstToken = TRUE;
5819                 int intPrevValue = 12;
5821                 if (ProcessItemData == TRUE){
5822                 
5823                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5824                         
5825                 } else {
5826                         
5827                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5828                         *wxSPropertyDataNameOut = wxT("N");
5829                         
5830                 }
5831                 
5832                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5833                 intiter != SplitPoints.end(); ++intiter){
5834                 
5835                         SLiter = SplitLength.find(intiter->first);
5836                 
5837                         if (ProcessItemData == TRUE){
5839                                 if (FirstToken == TRUE){
5840                 
5841                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5842                                         FirstToken = FALSE;
5843                                 
5844                                 } else {
5845                                 
5846                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5847                                 
5848                                 }
5849                         
5850                         } else {
5851                         
5852                                 if (FirstToken == TRUE){
5853                         
5854                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5855                                         FirstToken = FALSE;
5856                                                                 
5857                                 } else {
5858                                 
5859                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5860                                         
5861                                 }
5862                         
5863                         }
5864                         
5865                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5866                         PropertyName = PropertyElement.GetNextToken();                          
5867                         PropertyValue = PropertyElement.GetNextToken();
5868                         
5869                         //ProcessCaptureStrings(&PropertyValue);
5870                         
5871                         intPrevValue = intiter->second;
5872                         
5873                         // Process properties.
5874                         
5875                         // Check if there is a lock on the property value. If there is a lock then
5876                         // the property value cannot be changed.
5877                         
5878                         if (PropertyName.IsEmpty()){
5879                         
5880                                 continue;
5881                         
5882                         }
5883                         
5884                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
5885                         
5886                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
5887                         
5888                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5889                         
5890                                 } else {
5891                         
5892                                         PropertyDataMap->erase(PropertyName);
5893                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
5894                         
5895                                 }
5896                                 
5897                         }
5898                         
5899                         //wxSPropertyPropValuesOut->Append(wxT(";"));
5900                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
5901                 
5902                 }
5903                 
5904                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
5905                 *XVCardV4Value = TRUE;
5906                                 
5907         }
5908         
5909         // X-VCARD4-NICKNAME
5910         
5911         if (wxSProperty == wxT("X-VCARD4-NICKNAME")){
5913                 if (ProcessItemData == TRUE){
5914         
5915                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
5916                 
5917                 } else {
5918                 
5919                         intPropertyLen = wxSPropertySeg1Ptr->Len();
5920                 
5921                 }
5922                 
5923                 std::map<int, int> SplitPoints;
5924                 std::map<int, int> SplitLength;
5925                 std::map<int, int>::iterator SLiter;
5926                 std::map<wxString, bool>::iterator BIter;;                      
5927                 wxString PropertyData;
5928                 wxString PropertyName;
5929                 wxString PropertyValue;
5930                 wxString PropertyTokens;
5931                 bool FirstToken = TRUE;
5932                 int intPrevValue = 19;
5934                 if (ProcessItemData == TRUE){
5935                 
5936                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
5937                         
5938                 } else {
5939                         
5940                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
5941                         *wxSPropertyDataNameOut = wxT("NICKNAME");
5942                         
5943                 }
5944                 
5945                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5946                 intiter != SplitPoints.end(); ++intiter){
5947                 
5948                         SLiter = SplitLength.find(intiter->first);
5949                 
5950                         if (ProcessItemData == TRUE){
5952                                 if (FirstToken == TRUE){
5953                 
5954                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
5955                                         FirstToken = FALSE;
5956                                 
5957                                 } else {
5958                                 
5959                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
5960                                 
5961                                 }
5962                         
5963                         } else {
5964                         
5965                                 if (FirstToken == TRUE){
5966                         
5967                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
5968                                         FirstToken = FALSE;
5969                                                                 
5970                                 } else {
5971                                 
5972                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
5973                                         
5974                                 }
5975                         
5976                         }
5977                         
5978                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5979                         PropertyName = PropertyElement.GetNextToken();                          
5980                         PropertyValue = PropertyElement.GetNextToken();
5981                         
5982                         //ProcessCaptureStrings(&PropertyValue);
5983                         
5984                         intPrevValue = intiter->second;
5985                         
5986                         // Process properties.
5987                         
5988                         // Check if there is a lock on the property value. If there is a lock then
5989                         // the property value cannot be changed.
5990                         
5991                         if (PropertyName.IsEmpty()){
5992                         
5993                                 continue;
5994                         
5995                         }
5996                         
5997                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
5998                         
5999                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6000                         
6001                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6002                         
6003                                 } else {
6004                         
6005                                         PropertyDataMap->erase(PropertyName);
6006                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6007                         
6008                                 }
6009                                 
6010                         }
6011                         
6012                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6013                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6014                 
6015                 }
6016                 
6017                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6018                 *XVCardV4Value = TRUE;
6019                                 
6020         }
6021         
6022         // X-VCARD4-GENDER
6023         
6024         if (wxSProperty == wxT("X-VCARD4-GENDER")){
6026                 if (ProcessItemData == TRUE){
6027         
6028                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6029                 
6030                 } else {
6031                 
6032                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6033                 
6034                 }
6035                 
6036                 std::map<int, int> SplitPoints;
6037                 std::map<int, int> SplitLength;
6038                 std::map<int, int>::iterator SLiter;
6039                 std::map<wxString, bool>::iterator BIter;;                      
6040                 wxString PropertyData;
6041                 wxString PropertyName;
6042                 wxString PropertyValue;
6043                 wxString PropertyTokens;
6044                 bool FirstToken = TRUE;
6045                 int intPrevValue = 17;
6047                 if (ProcessItemData == TRUE){
6048                 
6049                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6050                         
6051                 } else {
6052                         
6053                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6054                         *wxSPropertyDataNameOut = wxT("GENDER");
6055                         
6056                 }
6057                 
6058                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6059                 intiter != SplitPoints.end(); ++intiter){
6060                 
6061                         SLiter = SplitLength.find(intiter->first);
6062                 
6063                         if (ProcessItemData == TRUE){
6065                                 if (FirstToken == TRUE){
6066                 
6067                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6068                                         FirstToken = FALSE;
6069                                 
6070                                 } else {
6071                                 
6072                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6073                                 
6074                                 }
6075                         
6076                         } else {
6077                         
6078                                 if (FirstToken == TRUE){
6079                         
6080                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6081                                         FirstToken = FALSE;
6082                                                                 
6083                                 } else {
6084                                 
6085                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6086                                         
6087                                 }
6088                         
6089                         }
6090                         
6091                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6092                         PropertyName = PropertyElement.GetNextToken();                          
6093                         PropertyValue = PropertyElement.GetNextToken();
6094                         
6095                         //ProcessCaptureStrings(&PropertyValue);
6096                         
6097                         intPrevValue = intiter->second;
6098                         
6099                         // Process properties.
6100                         
6101                         // Check if there is a lock on the property value. If there is a lock then
6102                         // the property value cannot be changed.
6103                         
6104                         if (PropertyName.IsEmpty()){
6105                         
6106                                 continue;
6107                         
6108                         }
6109                         
6110                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6111                         
6112                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6113                         
6114                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6115                         
6116                                 } else {
6117                         
6118                                         PropertyDataMap->erase(PropertyName);
6119                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6120                         
6121                                 }
6122                                 
6123                         }
6124                         
6125                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6126                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6127                 
6128                 }
6129                 
6130                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6131                 *XVCardV4Value = TRUE;
6132                                 
6133         }
6134         
6135         // X-VCARD4-BDAY
6136         
6137         if (wxSProperty == wxT("X-VCARD4-BDAY")){
6139                 if (ProcessItemData == TRUE){
6140         
6141                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6142                 
6143                 } else {
6144                 
6145                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6146                 
6147                 }
6148                 
6149                 std::map<int, int> SplitPoints;
6150                 std::map<int, int> SplitLength;
6151                 std::map<int, int>::iterator SLiter;
6152                 std::map<wxString, bool>::iterator BIter;;                      
6153                 wxString PropertyData;
6154                 wxString PropertyName;
6155                 wxString PropertyValue;
6156                 wxString PropertyTokens;
6157                 bool FirstToken = TRUE;
6158                 int intPrevValue = 15;
6160                 if (ProcessItemData == TRUE){
6161                 
6162                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6163                         
6164                 } else {
6165                         
6166                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6167                         *wxSPropertyDataNameOut = wxT("BDAY");
6168                         
6169                 }
6170                 
6171                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6172                 intiter != SplitPoints.end(); ++intiter){
6173                 
6174                         SLiter = SplitLength.find(intiter->first);
6175                 
6176                         if (ProcessItemData == TRUE){
6178                                 if (FirstToken == TRUE){
6179                 
6180                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6181                                         FirstToken = FALSE;
6182                                 
6183                                 } else {
6184                                 
6185                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6186                                 
6187                                 }
6188                         
6189                         } else {
6190                         
6191                                 if (FirstToken == TRUE){
6192                         
6193                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6194                                         FirstToken = FALSE;
6195                                                                 
6196                                 } else {
6197                                 
6198                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6199                                         
6200                                 }
6201                         
6202                         }
6203                         
6204                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6205                         PropertyName = PropertyElement.GetNextToken();                          
6206                         PropertyValue = PropertyElement.GetNextToken();
6207                         
6208                         //ProcessCaptureStrings(&PropertyValue);
6209                         
6210                         intPrevValue = intiter->second;
6211                         
6212                         // Process properties.
6213                         
6214                         // Check if there is a lock on the property value. If there is a lock then
6215                         // the property value cannot be changed.
6216                         
6217                         if (PropertyName.IsEmpty()){
6218                         
6219                                 continue;
6220                         
6221                         }
6222                         
6223                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6224                         
6225                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6226                         
6227                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6228                         
6229                                 } else {
6230                         
6231                                         PropertyDataMap->erase(PropertyName);
6232                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6233                         
6234                                 }
6235                                 
6236                         }
6237                         
6238                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6239                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6240                 
6241                 }
6242                 
6243                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6244                 *XVCardV4Value = TRUE;
6245                                 
6246         }
6248         // X-VCARD4-ANNIVERSARY
6249         
6250         if (wxSProperty == wxT("X-VCARD4-ANNIVERSARY")){
6252                 if (ProcessItemData == TRUE){
6253         
6254                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6255                 
6256                 } else {
6257                 
6258                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6259                 
6260                 }
6261                 
6262                 std::map<int, int> SplitPoints;
6263                 std::map<int, int> SplitLength;
6264                 std::map<int, int>::iterator SLiter;
6265                 std::map<wxString, bool>::iterator BIter;;                      
6266                 wxString PropertyData;
6267                 wxString PropertyName;
6268                 wxString PropertyValue;
6269                 wxString PropertyTokens;
6270                 bool FirstToken = TRUE;
6271                 int intPrevValue = 22;
6273                 if (ProcessItemData == TRUE){
6274                 
6275                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6276                         
6277                 } else {
6278                         
6279                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6280                         *wxSPropertyDataNameOut = wxT("ANNIVERSARY");
6281                         
6282                 }
6283                 
6284                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6285                 intiter != SplitPoints.end(); ++intiter){
6286                 
6287                         SLiter = SplitLength.find(intiter->first);
6288                 
6289                         if (ProcessItemData == TRUE){
6291                                 if (FirstToken == TRUE){
6292                 
6293                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6294                                         FirstToken = FALSE;
6295                                 
6296                                 } else {
6297                                 
6298                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6299                                 
6300                                 }
6301                         
6302                         } else {
6303                         
6304                                 if (FirstToken == TRUE){
6305                         
6306                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6307                                         FirstToken = FALSE;
6308                                                                 
6309                                 } else {
6310                                 
6311                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6312                                         
6313                                 }
6314                         
6315                         }
6316                         
6317                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6318                         PropertyName = PropertyElement.GetNextToken();                          
6319                         PropertyValue = PropertyElement.GetNextToken();
6320                         
6321                         //ProcessCaptureStrings(&PropertyValue);
6322                         
6323                         intPrevValue = intiter->second;
6324                         
6325                         // Process properties.
6326                         
6327                         // Check if there is a lock on the property value. If there is a lock then
6328                         // the property value cannot be changed.
6329                         
6330                         if (PropertyName.IsEmpty()){
6331                         
6332                                 continue;
6333                         
6334                         }
6335                         
6336                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6337                         
6338                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6339                         
6340                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6341                         
6342                                 } else {
6343                         
6344                                         PropertyDataMap->erase(PropertyName);
6345                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6346                         
6347                                 }
6348                                 
6349                         }
6350                         
6351                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6352                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6353                 
6354                 }
6355                 
6356                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6357                 *XVCardV4Value = TRUE;
6358                                 
6359         }
6361         // X-VCARD4-TZ
6362         
6363         if (wxSProperty == wxT("X-VCARD4-TZ")){
6365                 if (ProcessItemData == TRUE){
6366         
6367                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6368                 
6369                 } else {
6370                 
6371                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6372                 
6373                 }
6374                 
6375                 std::map<int, int> SplitPoints;
6376                 std::map<int, int> SplitLength;
6377                 std::map<int, int>::iterator SLiter;
6378                 std::map<wxString, bool>::iterator BIter;;                      
6379                 wxString PropertyData;
6380                 wxString PropertyName;
6381                 wxString PropertyValue;
6382                 wxString PropertyTokens;
6383                 bool FirstToken = TRUE;
6384                 int intPrevValue = 13;
6386                 if (ProcessItemData == TRUE){
6387                 
6388                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6389                         
6390                 } else {
6391                         
6392                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6393                         *wxSPropertyDataNameOut = wxT("TZ");
6394                         
6395                 }
6396                 
6397                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6398                 intiter != SplitPoints.end(); ++intiter){
6399                 
6400                         SLiter = SplitLength.find(intiter->first);
6401                 
6402                         if (ProcessItemData == TRUE){
6404                                 if (FirstToken == TRUE){
6405                 
6406                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6407                                         FirstToken = FALSE;
6408                                 
6409                                 } else {
6410                                 
6411                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6412                                 
6413                                 }
6414                         
6415                         } else {
6416                         
6417                                 if (FirstToken == TRUE){
6418                         
6419                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6420                                         FirstToken = FALSE;
6421                                                                 
6422                                 } else {
6423                                 
6424                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6425                                         
6426                                 }
6427                         
6428                         }
6429                         
6430                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6431                         PropertyName = PropertyElement.GetNextToken();                          
6432                         PropertyValue = PropertyElement.GetNextToken();
6433                         
6434                         //ProcessCaptureStrings(&PropertyValue);
6435                         
6436                         intPrevValue = intiter->second;
6437                         
6438                         // Process properties.
6439                         
6440                         // Check if there is a lock on the property value. If there is a lock then
6441                         // the property value cannot be changed.
6442                         
6443                         if (PropertyName.IsEmpty()){
6444                         
6445                                 continue;
6446                         
6447                         }
6448                         
6449                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6450                         
6451                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6452                         
6453                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6454                         
6455                                 } else {
6456                         
6457                                         PropertyDataMap->erase(PropertyName);
6458                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6459                         
6460                                 }
6461                                 
6462                         }
6463                         
6464                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6465                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6466                 
6467                 }
6468                 
6469                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6470                 *XVCardV4Value = TRUE;
6471                                 
6472         }
6473         
6474         // X-VCARD4-ADR
6475         
6476         if (wxSProperty == wxT("X-VCARD4-ADR")){
6478                 if (ProcessItemData == TRUE){
6479         
6480                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6481                 
6482                 } else {
6483                 
6484                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6485                 
6486                 }
6487                 
6488                 std::map<int, int> SplitPoints;
6489                 std::map<int, int> SplitLength;
6490                 std::map<int, int>::iterator SLiter;
6491                 std::map<wxString, bool>::iterator BIter;;                      
6492                 wxString PropertyData;
6493                 wxString PropertyName;
6494                 wxString PropertyValue;
6495                 wxString PropertyTokens;
6496                 bool FirstToken = TRUE;
6497                 int intPrevValue = 14;
6499                 if (ProcessItemData == TRUE){
6500                 
6501                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6502                         
6503                 } else {
6504                         
6505                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6506                         *wxSPropertyDataNameOut = wxT("ADR");
6507                         
6508                 }
6509                 
6510                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6511                 intiter != SplitPoints.end(); ++intiter){
6512                 
6513                         SLiter = SplitLength.find(intiter->first);
6514                 
6515                         if (ProcessItemData == TRUE){
6517                                 if (FirstToken == TRUE){
6518                 
6519                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6520                                         FirstToken = FALSE;
6521                                 
6522                                 } else {
6523                                 
6524                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6525                                 
6526                                 }
6527                         
6528                         } else {
6529                         
6530                                 if (FirstToken == TRUE){
6531                         
6532                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6533                                         FirstToken = FALSE;
6534                                                                 
6535                                 } else {
6536                                 
6537                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6538                                         
6539                                 }
6540                         
6541                         }
6542                         
6543                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6544                         PropertyName = PropertyElement.GetNextToken();                          
6545                         PropertyValue = PropertyElement.GetNextToken();
6546                         
6547                         //ProcessCaptureStrings(&PropertyValue);
6548                         
6549                         intPrevValue = intiter->second;
6550                         
6551                         // Process properties.
6552                         
6553                         // Check if there is a lock on the property value. If there is a lock then
6554                         // the property value cannot be changed.
6555                         
6556                         if (PropertyName.IsEmpty()){
6557                         
6558                                 continue;
6559                         
6560                         }
6561                         
6562                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6563                         
6564                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6565                         
6566                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6567                         
6568                                 } else {
6569                         
6570                                         PropertyDataMap->erase(PropertyName);
6571                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6572                         
6573                                 }
6574                                 
6575                         }
6576                         
6577                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6578                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6579                 
6580                 }
6581                 
6582                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6583                 *XVCardV4Value = TRUE;
6584                                 
6585         }
6586         
6587         // X-VCARD4-EMAIL
6588         
6589         if (wxSProperty == wxT("X-VCARD4-EMAIL")){
6591                 if (ProcessItemData == TRUE){
6592         
6593                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6594                 
6595                 } else {
6596                 
6597                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6598                 
6599                 }
6600                 
6601                 std::map<int, int> SplitPoints;
6602                 std::map<int, int> SplitLength;
6603                 std::map<int, int>::iterator SLiter;
6604                 std::map<wxString, bool>::iterator BIter;;                      
6605                 wxString PropertyData;
6606                 wxString PropertyName;
6607                 wxString PropertyValue;
6608                 wxString PropertyTokens;
6609                 bool FirstToken = TRUE;
6610                 int intPrevValue = 16;
6612                 if (ProcessItemData == TRUE){
6613                 
6614                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6615                         
6616                 } else {
6617                         
6618                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6619                         *wxSPropertyDataNameOut = wxT("EMAIL");
6620                         
6621                 }
6622                 
6623                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6624                 intiter != SplitPoints.end(); ++intiter){
6625                 
6626                         SLiter = SplitLength.find(intiter->first);
6627                 
6628                         if (ProcessItemData == TRUE){
6630                                 if (FirstToken == TRUE){
6631                 
6632                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6633                                         FirstToken = FALSE;
6634                                 
6635                                 } else {
6636                                 
6637                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6638                                 
6639                                 }
6640                         
6641                         } else {
6642                         
6643                                 if (FirstToken == TRUE){
6644                         
6645                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6646                                         FirstToken = FALSE;
6647                                                                 
6648                                 } else {
6649                                 
6650                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6651                                         
6652                                 }
6653                         
6654                         }
6655                         
6656                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6657                         PropertyName = PropertyElement.GetNextToken();                          
6658                         PropertyValue = PropertyElement.GetNextToken();
6659                         
6660                         //ProcessCaptureStrings(&PropertyValue);
6661                         
6662                         intPrevValue = intiter->second;
6663                         
6664                         // Process properties.
6665                         
6666                         // Check if there is a lock on the property value. If there is a lock then
6667                         // the property value cannot be changed.
6668                         
6669                         if (PropertyName.IsEmpty()){
6670                         
6671                                 continue;
6672                         
6673                         }
6674                         
6675                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6676                         
6677                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6678                         
6679                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6680                         
6681                                 } else {
6682                         
6683                                         PropertyDataMap->erase(PropertyName);
6684                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6685                         
6686                                 }
6687                                 
6688                         }
6689                         
6690                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6691                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6692                 
6693                 }
6694                 
6695                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6696                 *XVCardV4Value = TRUE;
6697                                 
6698         }
6699         
6700         // X-VCARD4-IMPP
6701         
6702         if (wxSProperty == wxT("X-VCARD4-IMPP")){
6704                 if (ProcessItemData == TRUE){
6705         
6706                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6707                 
6708                 } else {
6709                 
6710                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6711                 
6712                 }
6713                 
6714                 std::map<int, int> SplitPoints;
6715                 std::map<int, int> SplitLength;
6716                 std::map<int, int>::iterator SLiter;
6717                 std::map<wxString, bool>::iterator BIter;;                      
6718                 wxString PropertyData;
6719                 wxString PropertyName;
6720                 wxString PropertyValue;
6721                 wxString PropertyTokens;
6722                 bool FirstToken = TRUE;
6723                 int intPrevValue = 15;
6725                 if (ProcessItemData == TRUE){
6726                 
6727                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6728                         
6729                 } else {
6730                         
6731                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6732                         *wxSPropertyDataNameOut = wxT("IMPP");
6733                         
6734                 }
6735                 
6736                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6737                 intiter != SplitPoints.end(); ++intiter){
6738                 
6739                         SLiter = SplitLength.find(intiter->first);
6740                 
6741                         if (ProcessItemData == TRUE){
6743                                 if (FirstToken == TRUE){
6744                 
6745                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6746                                         FirstToken = FALSE;
6747                                 
6748                                 } else {
6749                                 
6750                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6751                                 
6752                                 }
6753                         
6754                         } else {
6755                         
6756                                 if (FirstToken == TRUE){
6757                         
6758                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6759                                         FirstToken = FALSE;
6760                                                                 
6761                                 } else {
6762                                 
6763                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6764                                         
6765                                 }
6766                         
6767                         }
6768                         
6769                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6770                         PropertyName = PropertyElement.GetNextToken();                          
6771                         PropertyValue = PropertyElement.GetNextToken();
6772                         
6773                         //ProcessCaptureStrings(&PropertyValue);
6774                         
6775                         intPrevValue = intiter->second;
6776                         
6777                         // Process properties.
6778                         
6779                         // Check if there is a lock on the property value. If there is a lock then
6780                         // the property value cannot be changed.
6781                         
6782                         if (PropertyName.IsEmpty()){
6783                         
6784                                 continue;
6785                         
6786                         }
6787                         
6788                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6789                         
6790                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6791                         
6792                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6793                         
6794                                 } else {
6795                         
6796                                         PropertyDataMap->erase(PropertyName);
6797                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6798                         
6799                                 }
6800                                 
6801                         }
6802                         
6803                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6804                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6805                 
6806                 }
6807                 
6808                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6809                 *XVCardV4Value = TRUE;
6810                                 
6811         }
6812         
6813         // X-VCARD4-TEL
6814         
6815         if (wxSProperty == wxT("X-VCARD4-TEL")){
6817                 if (ProcessItemData == TRUE){
6818         
6819                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6820                 
6821                 } else {
6822                 
6823                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6824                 
6825                 }
6826                 
6827                 std::map<int, int> SplitPoints;
6828                 std::map<int, int> SplitLength;
6829                 std::map<int, int>::iterator SLiter;
6830                 std::map<wxString, bool>::iterator BIter;;                      
6831                 wxString PropertyData;
6832                 wxString PropertyName;
6833                 wxString PropertyValue;
6834                 wxString PropertyTokens;
6835                 bool FirstToken = TRUE;
6836                 int intPrevValue = 14;
6838                 if (ProcessItemData == TRUE){
6839                 
6840                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6841                         
6842                 } else {
6843                         
6844                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6845                         *wxSPropertyDataNameOut = wxT("TEL");
6846                         
6847                 }
6848                 
6849                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6850                 intiter != SplitPoints.end(); ++intiter){
6851                 
6852                         SLiter = SplitLength.find(intiter->first);
6853                 
6854                         if (ProcessItemData == TRUE){
6856                                 if (FirstToken == TRUE){
6857                 
6858                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6859                                         FirstToken = FALSE;
6860                                 
6861                                 } else {
6862                                 
6863                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6864                                 
6865                                 }
6866                         
6867                         } else {
6868                         
6869                                 if (FirstToken == TRUE){
6870                         
6871                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6872                                         FirstToken = FALSE;
6873                                                                 
6874                                 } else {
6875                                 
6876                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6877                                         
6878                                 }
6879                         
6880                         }
6881                         
6882                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6883                         PropertyName = PropertyElement.GetNextToken();                          
6884                         PropertyValue = PropertyElement.GetNextToken();
6885                         
6886                         //ProcessCaptureStrings(&PropertyValue);
6887                         
6888                         intPrevValue = intiter->second;
6889                         
6890                         // Process properties.
6891                         
6892                         // Check if there is a lock on the property value. If there is a lock then
6893                         // the property value cannot be changed.
6894                         
6895                         if (PropertyName.IsEmpty()){
6896                         
6897                                 continue;
6898                         
6899                         }
6900                         
6901                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
6902                         
6903                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
6904                         
6905                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6906                         
6907                                 } else {
6908                         
6909                                         PropertyDataMap->erase(PropertyName);
6910                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
6911                         
6912                                 }
6913                                 
6914                         }
6915                         
6916                         //wxSPropertyPropValuesOut->Append(wxT(";"));
6917                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
6918                 
6919                 }
6920                 
6921                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
6922                 *XVCardV4Value = TRUE;
6923                                 
6924         }
6925         
6926         // X-VCARD4-LANG
6927         
6928         if (wxSProperty == wxT("X-VCARD4-LANG")){
6930                 if (ProcessItemData == TRUE){
6931         
6932                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
6933                 
6934                 } else {
6935                 
6936                         intPropertyLen = wxSPropertySeg1Ptr->Len();
6937                 
6938                 }
6939                 
6940                 std::map<int, int> SplitPoints;
6941                 std::map<int, int> SplitLength;
6942                 std::map<int, int>::iterator SLiter;
6943                 std::map<wxString, bool>::iterator BIter;;                      
6944                 wxString PropertyData;
6945                 wxString PropertyName;
6946                 wxString PropertyValue;
6947                 wxString PropertyTokens;
6948                 bool FirstToken = TRUE;
6949                 int intPrevValue = 15;
6951                 if (ProcessItemData == TRUE){
6952                 
6953                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
6954                         
6955                 } else {
6956                         
6957                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
6958                         *wxSPropertyDataNameOut = wxT("LANG");
6959                         
6960                 }
6961                 
6962                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6963                 intiter != SplitPoints.end(); ++intiter){
6964                 
6965                         SLiter = SplitLength.find(intiter->first);
6966                 
6967                         if (ProcessItemData == TRUE){
6969                                 if (FirstToken == TRUE){
6970                 
6971                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
6972                                         FirstToken = FALSE;
6973                                 
6974                                 } else {
6975                                 
6976                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
6977                                 
6978                                 }
6979                         
6980                         } else {
6981                         
6982                                 if (FirstToken == TRUE){
6983                         
6984                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
6985                                         FirstToken = FALSE;
6986                                                                 
6987                                 } else {
6988                                 
6989                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
6990                                         
6991                                 }
6992                         
6993                         }
6994                         
6995                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6996                         PropertyName = PropertyElement.GetNextToken();                          
6997                         PropertyValue = PropertyElement.GetNextToken();
6998                         
6999                         //ProcessCaptureStrings(&PropertyValue);
7000                         
7001                         intPrevValue = intiter->second;
7002                         
7003                         // Process properties.
7004                         
7005                         // Check if there is a lock on the property value. If there is a lock then
7006                         // the property value cannot be changed.
7007                         
7008                         if (PropertyName.IsEmpty()){
7009                         
7010                                 continue;
7011                         
7012                         }
7013                         
7014                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7015                         
7016                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7017                         
7018                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7019                         
7020                                 } else {
7021                         
7022                                         PropertyDataMap->erase(PropertyName);
7023                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7024                         
7025                                 }
7026                                 
7027                         }
7028                         
7029                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7030                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7031                 
7032                 }
7033                 
7034                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7035                 *XVCardV4Value = TRUE;
7036                                 
7037         }
7038         
7039         // X-VCARD4-GEO
7040         
7041         if (wxSProperty == wxT("X-VCARD4-GEO")){
7043                 if (ProcessItemData == TRUE){
7044         
7045                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7046                 
7047                 } else {
7048                 
7049                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7050                 
7051                 }
7052                 
7053                 std::map<int, int> SplitPoints;
7054                 std::map<int, int> SplitLength;
7055                 std::map<int, int>::iterator SLiter;
7056                 std::map<wxString, bool>::iterator BIter;;                      
7057                 wxString PropertyData;
7058                 wxString PropertyName;
7059                 wxString PropertyValue;
7060                 wxString PropertyTokens;
7061                 bool FirstToken = TRUE;
7062                 int intPrevValue = 14;
7064                 if (ProcessItemData == TRUE){
7065                 
7066                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7067                         
7068                 } else {
7069                         
7070                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7071                         *wxSPropertyDataNameOut = wxT("GEO");
7072                         
7073                 }
7074                 
7075                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7076                 intiter != SplitPoints.end(); ++intiter){
7077                 
7078                         SLiter = SplitLength.find(intiter->first);
7079                 
7080                         if (ProcessItemData == TRUE){
7082                                 if (FirstToken == TRUE){
7083                 
7084                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7085                                         FirstToken = FALSE;
7086                                 
7087                                 } else {
7088                                 
7089                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7090                                 
7091                                 }
7092                         
7093                         } else {
7094                         
7095                                 if (FirstToken == TRUE){
7096                         
7097                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7098                                         FirstToken = FALSE;
7099                                                                 
7100                                 } else {
7101                                 
7102                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7103                                         
7104                                 }
7105                         
7106                         }
7107                         
7108                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7109                         PropertyName = PropertyElement.GetNextToken();                          
7110                         PropertyValue = PropertyElement.GetNextToken();
7111                         
7112                         //ProcessCaptureStrings(&PropertyValue);
7113                         
7114                         intPrevValue = intiter->second;
7115                         
7116                         // Process properties.
7117                         
7118                         // Check if there is a lock on the property value. If there is a lock then
7119                         // the property value cannot be changed.
7120                         
7121                         if (PropertyName.IsEmpty()){
7122                         
7123                                 continue;
7124                         
7125                         }
7126                         
7127                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7128                         
7129                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7130                         
7131                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7132                         
7133                                 } else {
7134                         
7135                                         PropertyDataMap->erase(PropertyName);
7136                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7137                         
7138                                 }
7139                                 
7140                         }
7141                         
7142                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7143                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7144                 
7145                 }
7146                 
7147                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7148                 *XVCardV4Value = TRUE;
7149                                 
7150         }
7151         
7152         // X-VCARD4-RELATED
7153         
7154         if (wxSProperty == wxT("X-VCARD4-RELATED")){
7156                 if (ProcessItemData == TRUE){
7157         
7158                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7159                 
7160                 } else {
7161                 
7162                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7163                 
7164                 }
7165                 
7166                 std::map<int, int> SplitPoints;
7167                 std::map<int, int> SplitLength;
7168                 std::map<int, int>::iterator SLiter;
7169                 std::map<wxString, bool>::iterator BIter;;                      
7170                 wxString PropertyData;
7171                 wxString PropertyName;
7172                 wxString PropertyValue;
7173                 wxString PropertyTokens;
7174                 bool FirstToken = TRUE;
7175                 int intPrevValue = 18;
7177                 if (ProcessItemData == TRUE){
7178                 
7179                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7180                         
7181                 } else {
7182                         
7183                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7184                         *wxSPropertyDataNameOut = wxT("RELATED");
7185                         
7186                 }
7187                 
7188                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7189                 intiter != SplitPoints.end(); ++intiter){
7190                 
7191                         SLiter = SplitLength.find(intiter->first);
7192                 
7193                         if (ProcessItemData == TRUE){
7195                                 if (FirstToken == TRUE){
7196                 
7197                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7198                                         FirstToken = FALSE;
7199                                 
7200                                 } else {
7201                                 
7202                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7203                                 
7204                                 }
7205                         
7206                         } else {
7207                         
7208                                 if (FirstToken == TRUE){
7209                         
7210                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7211                                         FirstToken = FALSE;
7212                                                                 
7213                                 } else {
7214                                 
7215                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7216                                         
7217                                 }
7218                         
7219                         }
7220                         
7221                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7222                         PropertyName = PropertyElement.GetNextToken();                          
7223                         PropertyValue = PropertyElement.GetNextToken();
7224                         
7225                         //ProcessCaptureStrings(&PropertyValue);
7226                         
7227                         intPrevValue = intiter->second;
7228                         
7229                         // Process properties.
7230                         
7231                         // Check if there is a lock on the property value. If there is a lock then
7232                         // the property value cannot be changed.
7233                         
7234                         if (PropertyName.IsEmpty()){
7235                         
7236                                 continue;
7237                         
7238                         }
7239                         
7240                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7241                         
7242                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7243                         
7244                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7245                         
7246                                 } else {
7247                         
7248                                         PropertyDataMap->erase(PropertyName);
7249                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7250                         
7251                                 }
7252                                 
7253                         }
7254                         
7255                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7256                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7257                 
7258                 }
7259                 
7260                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7261                 *XVCardV4Value = TRUE;
7262                                 
7263         }
7264         
7265         // X-VCARD4-URL
7266         
7267         if (wxSProperty == wxT("X-VCARD4-URL")){
7269                 if (ProcessItemData == TRUE){
7270         
7271                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7272                 
7273                 } else {
7274                 
7275                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7276                 
7277                 }
7278                 
7279                 std::map<int, int> SplitPoints;
7280                 std::map<int, int> SplitLength;
7281                 std::map<int, int>::iterator SLiter;
7282                 std::map<wxString, bool>::iterator BIter;;                      
7283                 wxString PropertyData;
7284                 wxString PropertyName;
7285                 wxString PropertyValue;
7286                 wxString PropertyTokens;
7287                 bool FirstToken = TRUE;
7288                 int intPrevValue = 14;
7290                 if (ProcessItemData == TRUE){
7291                 
7292                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7293                         
7294                 } else {
7295                         
7296                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7297                         *wxSPropertyDataNameOut = wxT("URL");
7298                         
7299                 }
7300                 
7301                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7302                 intiter != SplitPoints.end(); ++intiter){
7303                 
7304                         SLiter = SplitLength.find(intiter->first);
7305                 
7306                         if (ProcessItemData == TRUE){
7308                                 if (FirstToken == TRUE){
7309                 
7310                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7311                                         FirstToken = FALSE;
7312                                 
7313                                 } else {
7314                                 
7315                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7316                                 
7317                                 }
7318                         
7319                         } else {
7320                         
7321                                 if (FirstToken == TRUE){
7322                         
7323                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7324                                         FirstToken = FALSE;
7325                                                                 
7326                                 } else {
7327                                 
7328                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7329                                         
7330                                 }
7331                         
7332                         }
7333                         
7334                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7335                         PropertyName = PropertyElement.GetNextToken();                          
7336                         PropertyValue = PropertyElement.GetNextToken();
7337                         
7338                         //ProcessCaptureStrings(&PropertyValue);
7339                         
7340                         intPrevValue = intiter->second;
7341                         
7342                         // Process properties.
7343                         
7344                         // Check if there is a lock on the property value. If there is a lock then
7345                         // the property value cannot be changed.
7346                         
7347                         if (PropertyName.IsEmpty()){
7348                         
7349                                 continue;
7350                         
7351                         }
7352                         
7353                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7354                         
7355                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7356                         
7357                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7358                         
7359                                 } else {
7360                         
7361                                         PropertyDataMap->erase(PropertyName);
7362                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7363                         
7364                                 }
7365                                 
7366                         }
7367                         
7368                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7369                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7370                 
7371                 }
7372                 
7373                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7374                 *XVCardV4Value = TRUE;
7375                                 
7376         }
7377         
7378         // X-VCARD4-TITLE
7379         
7380         if (wxSProperty == wxT("X-VCARD4-TITLE")){
7382                 if (ProcessItemData == TRUE){
7383         
7384                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7385                 
7386                 } else {
7387                 
7388                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7389                 
7390                 }
7391                 
7392                 std::map<int, int> SplitPoints;
7393                 std::map<int, int> SplitLength;
7394                 std::map<int, int>::iterator SLiter;
7395                 std::map<wxString, bool>::iterator BIter;;                      
7396                 wxString PropertyData;
7397                 wxString PropertyName;
7398                 wxString PropertyValue;
7399                 wxString PropertyTokens;
7400                 bool FirstToken = TRUE;
7401                 int intPrevValue = 16;
7403                 if (ProcessItemData == TRUE){
7404                 
7405                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7406                         
7407                 } else {
7408                         
7409                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7410                         *wxSPropertyDataNameOut = wxT("TITLE");
7411                         
7412                 }
7413                 
7414                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7415                 intiter != SplitPoints.end(); ++intiter){
7416                 
7417                         SLiter = SplitLength.find(intiter->first);
7418                 
7419                         if (ProcessItemData == TRUE){
7421                                 if (FirstToken == TRUE){
7422                 
7423                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7424                                         FirstToken = FALSE;
7425                                 
7426                                 } else {
7427                                 
7428                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7429                                 
7430                                 }
7431                         
7432                         } else {
7433                         
7434                                 if (FirstToken == TRUE){
7435                         
7436                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7437                                         FirstToken = FALSE;
7438                                                                 
7439                                 } else {
7440                                 
7441                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7442                                         
7443                                 }
7444                         
7445                         }
7446                         
7447                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7448                         PropertyName = PropertyElement.GetNextToken();                          
7449                         PropertyValue = PropertyElement.GetNextToken();
7450                         
7451                         //ProcessCaptureStrings(&PropertyValue);
7452                         
7453                         intPrevValue = intiter->second;
7454                         
7455                         // Process properties.
7456                         
7457                         // Check if there is a lock on the property value. If there is a lock then
7458                         // the property value cannot be changed.
7459                         
7460                         if (PropertyName.IsEmpty()){
7461                         
7462                                 continue;
7463                         
7464                         }
7465                         
7466                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7467                         
7468                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7469                         
7470                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7471                         
7472                                 } else {
7473                         
7474                                         PropertyDataMap->erase(PropertyName);
7475                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7476                         
7477                                 }
7478                                 
7479                         }
7480                         
7481                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7482                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7483                 
7484                 }
7485                 
7486                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7487                 *XVCardV4Value = TRUE;
7488                                 
7489         }
7490         
7491         // X-VCARD4-ROLE
7492         
7493         if (wxSProperty == wxT("X-VCARD4-ROLE")){
7495                 if (ProcessItemData == TRUE){
7496         
7497                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7498                 
7499                 } else {
7500                 
7501                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7502                 
7503                 }
7504                 
7505                 std::map<int, int> SplitPoints;
7506                 std::map<int, int> SplitLength;
7507                 std::map<int, int>::iterator SLiter;
7508                 std::map<wxString, bool>::iterator BIter;;                      
7509                 wxString PropertyData;
7510                 wxString PropertyName;
7511                 wxString PropertyValue;
7512                 wxString PropertyTokens;
7513                 bool FirstToken = TRUE;
7514                 int intPrevValue = 15;
7516                 if (ProcessItemData == TRUE){
7517                 
7518                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7519                         
7520                 } else {
7521                         
7522                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7523                         *wxSPropertyDataNameOut = wxT("ROLE");
7524                         
7525                 }
7526                 
7527                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7528                 intiter != SplitPoints.end(); ++intiter){
7529                 
7530                         SLiter = SplitLength.find(intiter->first);
7531                 
7532                         if (ProcessItemData == TRUE){
7534                                 if (FirstToken == TRUE){
7535                 
7536                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7537                                         FirstToken = FALSE;
7538                                 
7539                                 } else {
7540                                 
7541                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7542                                 
7543                                 }
7544                         
7545                         } else {
7546                         
7547                                 if (FirstToken == TRUE){
7548                         
7549                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7550                                         FirstToken = FALSE;
7551                                                                 
7552                                 } else {
7553                                 
7554                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7555                                         
7556                                 }
7557                         
7558                         }
7559                         
7560                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7561                         PropertyName = PropertyElement.GetNextToken();                          
7562                         PropertyValue = PropertyElement.GetNextToken();
7563                         
7564                         //ProcessCaptureStrings(&PropertyValue);
7565                         
7566                         intPrevValue = intiter->second;
7567                         
7568                         // Process properties.
7569                         
7570                         // Check if there is a lock on the property value. If there is a lock then
7571                         // the property value cannot be changed.
7572                         
7573                         if (PropertyName.IsEmpty()){
7574                         
7575                                 continue;
7576                         
7577                         }
7578                         
7579                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7580                         
7581                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7582                         
7583                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7584                         
7585                                 } else {
7586                         
7587                                         PropertyDataMap->erase(PropertyName);
7588                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7589                         
7590                                 }
7591                                 
7592                         }
7593                         
7594                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7595                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7596                 
7597                 }
7598                 
7599                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7600                 *XVCardV4Value = TRUE;
7601                                 
7602         }
7603         
7604         // X-VCARD4-ORG
7605         
7606         if (wxSProperty == wxT("X-VCARD4-ORG")){
7608                 if (ProcessItemData == TRUE){
7609         
7610                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7611                 
7612                 } else {
7613                 
7614                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7615                 
7616                 }
7617                 
7618                 std::map<int, int> SplitPoints;
7619                 std::map<int, int> SplitLength;
7620                 std::map<int, int>::iterator SLiter;
7621                 std::map<wxString, bool>::iterator BIter;;                      
7622                 wxString PropertyData;
7623                 wxString PropertyName;
7624                 wxString PropertyValue;
7625                 wxString PropertyTokens;
7626                 bool FirstToken = TRUE;
7627                 int intPrevValue = 14;
7629                 if (ProcessItemData == TRUE){
7630                 
7631                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7632                         
7633                 } else {
7634                         
7635                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7636                         *wxSPropertyDataNameOut = wxT("ORG");
7637                         
7638                 }
7639                 
7640                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7641                 intiter != SplitPoints.end(); ++intiter){
7642                 
7643                         SLiter = SplitLength.find(intiter->first);
7644                 
7645                         if (ProcessItemData == TRUE){
7647                                 if (FirstToken == TRUE){
7648                 
7649                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7650                                         FirstToken = FALSE;
7651                                 
7652                                 } else {
7653                                 
7654                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7655                                 
7656                                 }
7657                         
7658                         } else {
7659                         
7660                                 if (FirstToken == TRUE){
7661                         
7662                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7663                                         FirstToken = FALSE;
7664                                                                 
7665                                 } else {
7666                                 
7667                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7668                                         
7669                                 }
7670                         
7671                         }
7672                         
7673                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7674                         PropertyName = PropertyElement.GetNextToken();                          
7675                         PropertyValue = PropertyElement.GetNextToken();
7676                         
7677                         //ProcessCaptureStrings(&PropertyValue);
7678                         
7679                         intPrevValue = intiter->second;
7680                         
7681                         // Process properties.
7682                         
7683                         // Check if there is a lock on the property value. If there is a lock then
7684                         // the property value cannot be changed.
7685                         
7686                         if (PropertyName.IsEmpty()){
7687                         
7688                                 continue;
7689                         
7690                         }
7691                         
7692                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7693                         
7694                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7695                         
7696                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7697                         
7698                                 } else {
7699                         
7700                                         PropertyDataMap->erase(PropertyName);
7701                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7702                         
7703                                 }
7704                                 
7705                         }
7706                         
7707                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7708                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7709                 
7710                 }
7711                 
7712                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7713                 *XVCardV4Value = TRUE;
7714                                 
7715         }
7716         
7717         // X-VCARD4-NOTE
7718         
7719         if (wxSProperty == wxT("X-VCARD4-NOTE")){
7721                 if (ProcessItemData == TRUE){
7722         
7723                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7724                 
7725                 } else {
7726                 
7727                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7728                 
7729                 }
7730                 
7731                 std::map<int, int> SplitPoints;
7732                 std::map<int, int> SplitLength;
7733                 std::map<int, int>::iterator SLiter;
7734                 std::map<wxString, bool>::iterator BIter;;                      
7735                 wxString PropertyData;
7736                 wxString PropertyName;
7737                 wxString PropertyValue;
7738                 wxString PropertyTokens;
7739                 bool FirstToken = TRUE;
7740                 int intPrevValue = 15;
7742                 if (ProcessItemData == TRUE){
7743                 
7744                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7745                         
7746                 } else {
7747                         
7748                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7749                         *wxSPropertyDataNameOut = wxT("NOTE");
7750                         
7751                 }
7752                 
7753                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7754                 intiter != SplitPoints.end(); ++intiter){
7755                 
7756                         SLiter = SplitLength.find(intiter->first);
7757                 
7758                         if (ProcessItemData == TRUE){
7760                                 if (FirstToken == TRUE){
7761                 
7762                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7763                                         FirstToken = FALSE;
7764                                 
7765                                 } else {
7766                                 
7767                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7768                                 
7769                                 }
7770                         
7771                         } else {
7772                         
7773                                 if (FirstToken == TRUE){
7774                         
7775                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7776                                         FirstToken = FALSE;
7777                                                                 
7778                                 } else {
7779                                 
7780                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7781                                         
7782                                 }
7783                         
7784                         }
7785                         
7786                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7787                         PropertyName = PropertyElement.GetNextToken();                          
7788                         PropertyValue = PropertyElement.GetNextToken();
7789                         
7790                         //ProcessCaptureStrings(&PropertyValue);
7791                         
7792                         intPrevValue = intiter->second;
7793                         
7794                         // Process properties.
7795                         
7796                         // Check if there is a lock on the property value. If there is a lock then
7797                         // the property value cannot be changed.
7798                         
7799                         if (PropertyName.IsEmpty()){
7800                         
7801                                 continue;
7802                         
7803                         }
7804                         
7805                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7806                         
7807                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7808                         
7809                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7810                         
7811                                 } else {
7812                         
7813                                         PropertyDataMap->erase(PropertyName);
7814                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7815                         
7816                                 }
7817                                 
7818                         }
7819                         
7820                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7821                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7822                 
7823                 }
7824                 
7825                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7826                 *XVCardV4Value = TRUE;
7827                                 
7828         }
7829         
7830         // X-VCARD4-CATEGORIES
7831         
7832         if (wxSProperty == wxT("X-VCARD4-CATEGORIES")){
7834                 if (ProcessItemData == TRUE){
7835         
7836                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7837                 
7838                 } else {
7839                 
7840                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7841                 
7842                 }
7843                 
7844                 std::map<int, int> SplitPoints;
7845                 std::map<int, int> SplitLength;
7846                 std::map<int, int>::iterator SLiter;
7847                 std::map<wxString, bool>::iterator BIter;;                      
7848                 wxString PropertyData;
7849                 wxString PropertyName;
7850                 wxString PropertyValue;
7851                 wxString PropertyTokens;
7852                 bool FirstToken = TRUE;
7853                 int intPrevValue = 21;
7855                 if (ProcessItemData == TRUE){
7856                 
7857                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7858                         
7859                 } else {
7860                         
7861                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7862                         *wxSPropertyDataNameOut = wxT("CATEGORIES");
7863                         
7864                 }
7865                 
7866                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7867                 intiter != SplitPoints.end(); ++intiter){
7868                 
7869                         SLiter = SplitLength.find(intiter->first);
7870                 
7871                         if (ProcessItemData == TRUE){
7873                                 if (FirstToken == TRUE){
7874                 
7875                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7876                                         FirstToken = FALSE;
7877                                 
7878                                 } else {
7879                                 
7880                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7881                                 
7882                                 }
7883                         
7884                         } else {
7885                         
7886                                 if (FirstToken == TRUE){
7887                         
7888                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
7889                                         FirstToken = FALSE;
7890                                                                 
7891                                 } else {
7892                                 
7893                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
7894                                         
7895                                 }
7896                         
7897                         }
7898                         
7899                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7900                         PropertyName = PropertyElement.GetNextToken();                          
7901                         PropertyValue = PropertyElement.GetNextToken();
7902                         
7903                         //ProcessCaptureStrings(&PropertyValue);
7904                         
7905                         intPrevValue = intiter->second;
7906                         
7907                         // Process properties.
7908                         
7909                         // Check if there is a lock on the property value. If there is a lock then
7910                         // the property value cannot be changed.
7911                         
7912                         if (PropertyName.IsEmpty()){
7913                         
7914                                 continue;
7915                         
7916                         }
7917                         
7918                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
7919                         
7920                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
7921                         
7922                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7923                         
7924                                 } else {
7925                         
7926                                         PropertyDataMap->erase(PropertyName);
7927                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
7928                         
7929                                 }
7930                                 
7931                         }
7932                         
7933                         //wxSPropertyPropValuesOut->Append(wxT(";"));
7934                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
7935                 
7936                 }
7937                 
7938                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
7939                 *XVCardV4Value = TRUE;
7940                                 
7941         }
7942         
7943         // X-VCARD4-PHOTO
7944         
7945         if (wxSProperty == wxT("X-VCARD4-PHOTO")){
7947                 if (ProcessItemData == TRUE){
7948         
7949                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
7950                 
7951                 } else {
7952                 
7953                         intPropertyLen = wxSPropertySeg1Ptr->Len();
7954                 
7955                 }
7956                 
7957                 std::map<int, int> SplitPoints;
7958                 std::map<int, int> SplitLength;
7959                 std::map<int, int>::iterator SLiter;
7960                 std::map<wxString, bool>::iterator BIter;;                      
7961                 wxString PropertyData;
7962                 wxString PropertyName;
7963                 wxString PropertyValue;
7964                 wxString PropertyTokens;
7965                 bool FirstToken = TRUE;
7966                 int intPrevValue = 16;
7968                 if (ProcessItemData == TRUE){
7969                 
7970                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
7971                         
7972                 } else {
7973                         
7974                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
7975                         *wxSPropertyDataNameOut = wxT("PHOTO");
7976                         
7977                 }
7978                 
7979                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
7980                 intiter != SplitPoints.end(); ++intiter){
7981                 
7982                         SLiter = SplitLength.find(intiter->first);
7983                 
7984                         if (ProcessItemData == TRUE){
7986                                 if (FirstToken == TRUE){
7987                 
7988                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
7989                                         FirstToken = FALSE;
7990                                 
7991                                 } else {
7992                                 
7993                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
7994                                 
7995                                 }
7996                         
7997                         } else {
7998                         
7999                                 if (FirstToken == TRUE){
8000                         
8001                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8002                                         FirstToken = FALSE;
8003                                                                 
8004                                 } else {
8005                                 
8006                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8007                                         
8008                                 }
8009                         
8010                         }
8011                         
8012                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8013                         PropertyName = PropertyElement.GetNextToken();                          
8014                         PropertyValue = PropertyElement.GetNextToken();
8015                         
8016                         //ProcessCaptureStrings(&PropertyValue);
8017                         
8018                         intPrevValue = intiter->second;
8019                         
8020                         // Process properties.
8021                         
8022                         // Check if there is a lock on the property value. If there is a lock then
8023                         // the property value cannot be changed.
8024                         
8025                         if (PropertyName.IsEmpty()){
8026                         
8027                                 continue;
8028                         
8029                         }
8030                         
8031                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8032                         
8033                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8034                         
8035                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8036                         
8037                                 } else {
8038                         
8039                                         PropertyDataMap->erase(PropertyName);
8040                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8041                         
8042                                 }
8043                                 
8044                         }
8045                         
8046                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8047                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8048                 
8049                 }
8050                 
8051                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8052                 *XVCardV4Value = TRUE;
8053                                 
8054         }
8055         
8056         // X-VCARD4-LOGO
8057         
8058         if (wxSProperty == wxT("X-VCARD4-LOGO")){
8060                 if (ProcessItemData == TRUE){
8061         
8062                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8063                 
8064                 } else {
8065                 
8066                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8067                 
8068                 }
8069                 
8070                 std::map<int, int> SplitPoints;
8071                 std::map<int, int> SplitLength;
8072                 std::map<int, int>::iterator SLiter;
8073                 std::map<wxString, bool>::iterator BIter;;                      
8074                 wxString PropertyData;
8075                 wxString PropertyName;
8076                 wxString PropertyValue;
8077                 wxString PropertyTokens;
8078                 bool FirstToken = TRUE;
8079                 int intPrevValue = 15;
8081                 if (ProcessItemData == TRUE){
8082                 
8083                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8084                         
8085                 } else {
8086                         
8087                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8088                         *wxSPropertyDataNameOut = wxT("LOGO");
8089                         
8090                 }
8091                 
8092                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8093                 intiter != SplitPoints.end(); ++intiter){
8094                 
8095                         SLiter = SplitLength.find(intiter->first);
8096                 
8097                         if (ProcessItemData == TRUE){
8099                                 if (FirstToken == TRUE){
8100                 
8101                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8102                                         FirstToken = FALSE;
8103                                 
8104                                 } else {
8105                                 
8106                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8107                                 
8108                                 }
8109                         
8110                         } else {
8111                         
8112                                 if (FirstToken == TRUE){
8113                         
8114                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8115                                         FirstToken = FALSE;
8116                                                                 
8117                                 } else {
8118                                 
8119                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8120                                         
8121                                 }
8122                         
8123                         }
8124                         
8125                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8126                         PropertyName = PropertyElement.GetNextToken();                          
8127                         PropertyValue = PropertyElement.GetNextToken();
8128                         
8129                         //ProcessCaptureStrings(&PropertyValue);
8130                         
8131                         intPrevValue = intiter->second;
8132                         
8133                         // Process properties.
8134                         
8135                         // Check if there is a lock on the property value. If there is a lock then
8136                         // the property value cannot be changed.
8137                         
8138                         if (PropertyName.IsEmpty()){
8139                         
8140                                 continue;
8141                         
8142                         }
8143                         
8144                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8145                         
8146                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8147                         
8148                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8149                         
8150                                 } else {
8151                         
8152                                         PropertyDataMap->erase(PropertyName);
8153                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8154                         
8155                                 }
8156                                 
8157                         }
8158                         
8159                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8160                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8161                 
8162                 }
8163                 
8164                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8165                 *XVCardV4Value = TRUE;
8166                                 
8167         }
8168         
8169         // X-VCARD4-SOUND
8170         
8171         if (wxSProperty == wxT("X-VCARD4-SOUND")){
8173                 if (ProcessItemData == TRUE){
8174         
8175                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8176                 
8177                 } else {
8178                 
8179                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8180                 
8181                 }
8182                 
8183                 std::map<int, int> SplitPoints;
8184                 std::map<int, int> SplitLength;
8185                 std::map<int, int>::iterator SLiter;
8186                 std::map<wxString, bool>::iterator BIter;;                      
8187                 wxString PropertyData;
8188                 wxString PropertyName;
8189                 wxString PropertyValue;
8190                 wxString PropertyTokens;
8191                 bool FirstToken = TRUE;
8192                 int intPrevValue = 16;
8194                 if (ProcessItemData == TRUE){
8195                 
8196                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8197                         
8198                 } else {
8199                         
8200                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8201                         *wxSPropertyDataNameOut = wxT("SOUND");
8202                         
8203                 }
8204                 
8205                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8206                 intiter != SplitPoints.end(); ++intiter){
8207                 
8208                         SLiter = SplitLength.find(intiter->first);
8209                 
8210                         if (ProcessItemData == TRUE){
8212                                 if (FirstToken == TRUE){
8213                 
8214                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8215                                         FirstToken = FALSE;
8216                                 
8217                                 } else {
8218                                 
8219                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8220                                 
8221                                 }
8222                         
8223                         } else {
8224                         
8225                                 if (FirstToken == TRUE){
8226                         
8227                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8228                                         FirstToken = FALSE;
8229                                                                 
8230                                 } else {
8231                                 
8232                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8233                                         
8234                                 }
8235                         
8236                         }
8237                         
8238                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8239                         PropertyName = PropertyElement.GetNextToken();                          
8240                         PropertyValue = PropertyElement.GetNextToken();
8241                         
8242                         //ProcessCaptureStrings(&PropertyValue);
8243                         
8244                         intPrevValue = intiter->second;
8245                         
8246                         // Process properties.
8247                         
8248                         // Check if there is a lock on the property value. If there is a lock then
8249                         // the property value cannot be changed.
8250                         
8251                         if (PropertyName.IsEmpty()){
8252                         
8253                                 continue;
8254                         
8255                         }
8256                         
8257                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8258                         
8259                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8260                         
8261                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8262                         
8263                                 } else {
8264                         
8265                                         PropertyDataMap->erase(PropertyName);
8266                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8267                         
8268                                 }
8269                                 
8270                         }
8271                         
8272                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8273                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8274                 
8275                 }
8276                 
8277                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8278                 *XVCardV4Value = TRUE;
8279                                 
8280         }
8281         
8282         // X-VCARD4-CALURI
8283         
8284         if (wxSProperty == wxT("X-VCARD4-CALURI")){
8286                 if (ProcessItemData == TRUE){
8287         
8288                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8289                 
8290                 } else {
8291                 
8292                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8293                 
8294                 }
8295                 
8296                 std::map<int, int> SplitPoints;
8297                 std::map<int, int> SplitLength;
8298                 std::map<int, int>::iterator SLiter;
8299                 std::map<wxString, bool>::iterator BIter;;                      
8300                 wxString PropertyData;
8301                 wxString PropertyName;
8302                 wxString PropertyValue;
8303                 wxString PropertyTokens;
8304                 bool FirstToken = TRUE;
8305                 int intPrevValue = 17;
8307                 if (ProcessItemData == TRUE){
8308                 
8309                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8310                         
8311                 } else {
8312                         
8313                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8314                         *wxSPropertyDataNameOut = wxT("CALURI");
8315                         
8316                 }
8317                 
8318                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8319                 intiter != SplitPoints.end(); ++intiter){
8320                 
8321                         SLiter = SplitLength.find(intiter->first);
8322                 
8323                         if (ProcessItemData == TRUE){
8325                                 if (FirstToken == TRUE){
8326                 
8327                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8328                                         FirstToken = FALSE;
8329                                 
8330                                 } else {
8331                                 
8332                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8333                                 
8334                                 }
8335                         
8336                         } else {
8337                         
8338                                 if (FirstToken == TRUE){
8339                         
8340                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8341                                         FirstToken = FALSE;
8342                                                                 
8343                                 } else {
8344                                 
8345                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8346                                         
8347                                 }
8348                         
8349                         }
8350                         
8351                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8352                         PropertyName = PropertyElement.GetNextToken();                          
8353                         PropertyValue = PropertyElement.GetNextToken();
8354                         
8355                         //ProcessCaptureStrings(&PropertyValue);
8356                         
8357                         intPrevValue = intiter->second;
8358                         
8359                         // Process properties.
8360                         
8361                         // Check if there is a lock on the property value. If there is a lock then
8362                         // the property value cannot be changed.
8363                         
8364                         if (PropertyName.IsEmpty()){
8365                         
8366                                 continue;
8367                         
8368                         }
8369                         
8370                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8371                         
8372                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8373                         
8374                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8375                         
8376                                 } else {
8377                         
8378                                         PropertyDataMap->erase(PropertyName);
8379                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8380                         
8381                                 }
8382                                 
8383                         }
8384                         
8385                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8386                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8387                 
8388                 }
8389                 
8390                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8391                 *XVCardV4Value = TRUE;
8392                                 
8393         }
8394         
8395         // X-VCARD4-CALADRURI
8396         
8397         if (wxSProperty == wxT("X-VCARD4-CALADRURI")){
8399                 if (ProcessItemData == TRUE){
8400         
8401                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8402                 
8403                 } else {
8404                 
8405                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8406                 
8407                 }
8408                 
8409                 std::map<int, int> SplitPoints;
8410                 std::map<int, int> SplitLength;
8411                 std::map<int, int>::iterator SLiter;
8412                 std::map<wxString, bool>::iterator BIter;;                      
8413                 wxString PropertyData;
8414                 wxString PropertyName;
8415                 wxString PropertyValue;
8416                 wxString PropertyTokens;
8417                 bool FirstToken = TRUE;
8418                 int intPrevValue = 20;
8420                 if (ProcessItemData == TRUE){
8421                 
8422                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8423                         
8424                 } else {
8425                         
8426                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8427                         *wxSPropertyDataNameOut = wxT("CALADRURI");
8428                         
8429                 }
8430                 
8431                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8432                 intiter != SplitPoints.end(); ++intiter){
8433                 
8434                         SLiter = SplitLength.find(intiter->first);
8435                 
8436                         if (ProcessItemData == TRUE){
8438                                 if (FirstToken == TRUE){
8439                 
8440                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8441                                         FirstToken = FALSE;
8442                                 
8443                                 } else {
8444                                 
8445                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8446                                 
8447                                 }
8448                         
8449                         } else {
8450                         
8451                                 if (FirstToken == TRUE){
8452                         
8453                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8454                                         FirstToken = FALSE;
8455                                                                 
8456                                 } else {
8457                                 
8458                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8459                                         
8460                                 }
8461                         
8462                         }
8463                         
8464                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8465                         PropertyName = PropertyElement.GetNextToken();                          
8466                         PropertyValue = PropertyElement.GetNextToken();
8467                         
8468                         //ProcessCaptureStrings(&PropertyValue);
8469                         
8470                         intPrevValue = intiter->second;
8471                         
8472                         // Process properties.
8473                         
8474                         // Check if there is a lock on the property value. If there is a lock then
8475                         // the property value cannot be changed.
8476                         
8477                         if (PropertyName.IsEmpty()){
8478                         
8479                                 continue;
8480                         
8481                         }
8482                         
8483                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8484                         
8485                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8486                         
8487                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8488                         
8489                                 } else {
8490                         
8491                                         PropertyDataMap->erase(PropertyName);
8492                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8493                         
8494                                 }
8495                                 
8496                         }
8497                         
8498                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8499                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8500                 
8501                 }
8502                 
8503                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8504                 *XVCardV4Value = TRUE;
8505                                 
8506         }
8507         
8508         // X-VCARD4-FBURL
8509         
8510         if (wxSProperty == wxT("X-VCARD4-FBURL")){
8512                 if (ProcessItemData == TRUE){
8513         
8514                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8515                 
8516                 } else {
8517                 
8518                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8519                 
8520                 }
8521                 
8522                 std::map<int, int> SplitPoints;
8523                 std::map<int, int> SplitLength;
8524                 std::map<int, int>::iterator SLiter;
8525                 std::map<wxString, bool>::iterator BIter;;                      
8526                 wxString PropertyData;
8527                 wxString PropertyName;
8528                 wxString PropertyValue;
8529                 wxString PropertyTokens;
8530                 bool FirstToken = TRUE;
8531                 int intPrevValue = 16;
8533                 if (ProcessItemData == TRUE){
8534                 
8535                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8536                         
8537                 } else {
8538                         
8539                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8540                         *wxSPropertyDataNameOut = wxT("FBURL");
8541                         
8542                 }
8543                 
8544                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8545                 intiter != SplitPoints.end(); ++intiter){
8546                 
8547                         SLiter = SplitLength.find(intiter->first);
8548                 
8549                         if (ProcessItemData == TRUE){
8551                                 if (FirstToken == TRUE){
8552                 
8553                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8554                                         FirstToken = FALSE;
8555                                 
8556                                 } else {
8557                                 
8558                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8559                                 
8560                                 }
8561                         
8562                         } else {
8563                         
8564                                 if (FirstToken == TRUE){
8565                         
8566                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8567                                         FirstToken = FALSE;
8568                                                                 
8569                                 } else {
8570                                 
8571                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8572                                         
8573                                 }
8574                         
8575                         }
8576                         
8577                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8578                         PropertyName = PropertyElement.GetNextToken();                          
8579                         PropertyValue = PropertyElement.GetNextToken();
8580                         
8581                         //ProcessCaptureStrings(&PropertyValue);
8582                         
8583                         intPrevValue = intiter->second;
8584                         
8585                         // Process properties.
8586                         
8587                         // Check if there is a lock on the property value. If there is a lock then
8588                         // the property value cannot be changed.
8589                         
8590                         if (PropertyName.IsEmpty()){
8591                         
8592                                 continue;
8593                         
8594                         }
8595                         
8596                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8597                         
8598                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8599                         
8600                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8601                         
8602                                 } else {
8603                         
8604                                         PropertyDataMap->erase(PropertyName);
8605                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8606                         
8607                                 }
8608                                 
8609                         }
8610                         
8611                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8612                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8613                 
8614                 }
8615                 
8616                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8617                 *XVCardV4Value = TRUE;
8618                                 
8619         }
8620         
8621         // X-VCARD4-KEY
8622         
8623         if (wxSProperty == wxT("X-VCARD4-KEY")){
8625                 if (ProcessItemData == TRUE){
8626         
8627                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8628                 
8629                 } else {
8630                 
8631                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8632                 
8633                 }
8634                 
8635                 std::map<int, int> SplitPoints;
8636                 std::map<int, int> SplitLength;
8637                 std::map<int, int>::iterator SLiter;
8638                 std::map<wxString, bool>::iterator BIter;;                      
8639                 wxString PropertyData;
8640                 wxString PropertyName;
8641                 wxString PropertyValue;
8642                 wxString PropertyTokens;
8643                 bool FirstToken = TRUE;
8644                 int intPrevValue = 14;
8646                 if (ProcessItemData == TRUE){
8647                 
8648                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8649                         
8650                 } else {
8651                         
8652                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8653                         *wxSPropertyDataNameOut = wxT("KEY");
8654                         
8655                 }
8656                 
8657                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8658                 intiter != SplitPoints.end(); ++intiter){
8659                 
8660                         SLiter = SplitLength.find(intiter->first);
8661                 
8662                         if (ProcessItemData == TRUE){
8664                                 if (FirstToken == TRUE){
8665                 
8666                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8667                                         FirstToken = FALSE;
8668                                 
8669                                 } else {
8670                                 
8671                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8672                                 
8673                                 }
8674                         
8675                         } else {
8676                         
8677                                 if (FirstToken == TRUE){
8678                         
8679                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8680                                         FirstToken = FALSE;
8681                                                                 
8682                                 } else {
8683                                 
8684                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8685                                         
8686                                 }
8687                         
8688                         }
8689                         
8690                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8691                         PropertyName = PropertyElement.GetNextToken();                          
8692                         PropertyValue = PropertyElement.GetNextToken();
8693                 
8694                         //ProcessCaptureStrings(&PropertyValue);
8695                         
8696                         intPrevValue = intiter->second;
8697                         
8698                         // Process properties.
8699                         
8700                         // Check if there is a lock on the property value. If there is a lock then
8701                         // the property value cannot be changed.
8702                         
8703                         if (PropertyName.IsEmpty()){
8704                         
8705                                 continue;
8706                         
8707                         }
8708                         
8709                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8710                         
8711                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8712                         
8713                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8714                         
8715                                 } else {
8716                         
8717                                         PropertyDataMap->erase(PropertyName);
8718                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8719                         
8720                                 }
8721                                 
8722                         }
8723                         
8724                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8725                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8726                 
8727                 }
8728                 
8729                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8730                 *XVCardV4Value = TRUE;
8731                                 
8732         }
8733         
8734         // X-VCARD4-VND-*
8735         
8736         if (wxSProperty.Mid(0, 12) == wxT("X-VCARD4-VND")){
8738                 if (ProcessItemData == TRUE){
8739         
8740                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8741                 
8742                 } else {
8743                 
8744                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8745                 
8746                 }
8747                 
8748                 std::map<int, int> SplitPoints;
8749                 std::map<int, int> SplitLength;
8750                 std::map<int, int>::iterator SLiter;
8751                 std::map<wxString, bool>::iterator BIter;;                      
8752                 wxString PropertyData;
8753                 wxString PropertyName;
8754                 wxString PropertyValue;
8755                 wxString PropertyTokens;
8756                 bool FirstToken = TRUE;
8757                 int intPrevValue = 14;
8759                 if (ProcessItemData == TRUE){
8760                 
8761                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8762                         
8763                 } else {
8764                         
8765                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8766                         *wxSPropertyDataNameOut = wxSProperty.Mid(9);
8767                         
8768                 }
8769                 
8770                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8771                 intiter != SplitPoints.end(); ++intiter){
8772                 
8773                         SLiter = SplitLength.find(intiter->first);
8774                 
8775                         if (ProcessItemData == TRUE){
8777                                 if (FirstToken == TRUE){
8778                 
8779                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8780                                         FirstToken = FALSE;
8781                                 
8782                                 } else {
8783                                 
8784                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8785                                 
8786                                 }
8787                         
8788                         } else {
8789                         
8790                                 if (FirstToken == TRUE){
8791                         
8792                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8793                                         FirstToken = FALSE;
8794                                                                 
8795                                 } else {
8796                                 
8797                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8798                                         
8799                                 }
8800                         
8801                         }
8802                         
8803                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8804                         PropertyName = PropertyElement.GetNextToken();                          
8805                         PropertyValue = PropertyElement.GetNextToken();
8806                         
8807                         //ProcessCaptureStrings(&PropertyValue);
8808                         
8809                         intPrevValue = intiter->second;
8810                         
8811                         // Process properties.
8812                         
8813                         // Check if there is a lock on the property value. If there is a lock then
8814                         // the property value cannot be changed.
8815                         
8816                         if (PropertyName.IsEmpty()){
8817                         
8818                                 continue;
8819                         
8820                         }
8821                         
8822                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8823                         
8824                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8825                         
8826                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8827                         
8828                                 } else {
8829                         
8830                                         PropertyDataMap->erase(PropertyName);
8831                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8832                         
8833                                 }
8834                                 
8835                         }
8836                         
8837                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8838                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8839                 
8840                 }
8841                 
8842                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8843                 *XVCardV4Value = TRUE;          
8844         
8845         }
8846         
8847         // X-ADDRESSBOOKSERVER-KIND
8848         
8849         if (wxSProperty == wxT("X-ADDRESSBOOKSERVER-KIND")){
8850                 
8851                 // Process Data.
8853                 if (ProcessItemData == TRUE){
8854         
8855                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8856                 
8857                 } else {
8858                 
8859                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8860                 
8861                 }
8862                 
8863                 std::map<int, int> SplitPoints;
8864                 std::map<int, int> SplitLength;
8865                 std::map<int, int>::iterator SLiter;
8866                 std::map<wxString, bool>::iterator BIter;;                      
8867                 wxString PropertyData;
8868                 wxString PropertyName;
8869                 wxString PropertyValue;
8870                 wxString PropertyTokens;
8871                 bool FirstToken = TRUE;
8872                 int intPrevValue = 26;
8874                 if (ProcessItemData == TRUE){
8875                 
8876                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8877                         
8878                 } else {
8879                         
8880                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8881                         
8882                 }
8883                 
8884                 *wxSPropertyDataNameOut = wxT("KIND");
8885                 
8886                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
8887                 intiter != SplitPoints.end(); ++intiter){
8888                 
8889                         SLiter = SplitLength.find(intiter->first);
8890                 
8891                         if (ProcessItemData == TRUE){
8893                                 if (FirstToken == TRUE){
8894                 
8895                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
8896                                         FirstToken = FALSE;
8897                                 
8898                                 } else {
8899                                 
8900                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
8901                                 
8902                                 }
8903                         
8904                         } else {
8905                         
8906                                 if (FirstToken == TRUE){
8907                         
8908                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
8909                                         FirstToken = FALSE;
8910                                                                 
8911                                 } else {
8912                                 
8913                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
8914                                         
8915                                 }
8916                         
8917                         }
8918                         
8919                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
8920                         PropertyName = PropertyElement.GetNextToken();                          
8921                         PropertyValue = PropertyElement.GetNextToken();
8922                         
8923                         //ProcessCaptureStrings(&PropertyValue);
8924                         
8925                         intPrevValue = intiter->second;
8926                         
8927                         // Process properties.
8928                         
8929                         // Check if there is a lock on the property value. If there is a lock then
8930                         // the property value cannot be changed.
8931                         
8932                         if (PropertyName.IsEmpty()){
8933                         
8934                                 continue;
8935                         
8936                         }
8937                         
8938                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
8939                         
8940                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
8941                         
8942                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8943                         
8944                                 } else {
8945                         
8946                                         PropertyDataMap->erase(PropertyName);
8947                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
8948                         
8949                                 }
8950                                 
8951                         }
8952                         
8953                         //wxSPropertyPropValuesOut->Append(wxT(";"));
8954                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
8955                 
8956                 }
8957                 
8958                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
8959                 *XVCardV4Value = TRUE;
8960                 
8961         }
8962         
8963         // X-ADDRESSBOOKSERVER-MEMBER
8964         
8965         if (wxSProperty == wxT("X-ADDRESSBOOKSERVER-MEMBER")){
8966                 
8967                 // Process Data.
8969                 if (ProcessItemData == TRUE){
8970         
8971                         intPropertyLen = wxSPropertySeg1Chopped.Len();          
8972                 
8973                 } else {
8974                 
8975                         intPropertyLen = wxSPropertySeg1Ptr->Len();
8976                 
8977                 }
8978                 
8979                 std::map<int, int> SplitPoints;
8980                 std::map<int, int> SplitLength;
8981                 std::map<int, int>::iterator SLiter;
8982                 std::map<wxString, bool>::iterator BIter;;
8983                 wxString PropertyData;
8984                 wxString PropertyName;
8985                 wxString PropertyValue;
8986                 wxString PropertyTokens;
8987                 bool FirstToken = TRUE;
8988                 int intPrevValue = 28;
8990                 if (ProcessItemData == TRUE){
8991                 
8992                         SplitValues(&wxSPropertySeg1Chopped, &SplitPoints, &SplitLength, intPrevValue);
8993                         
8994                 } else {
8995                         
8996                         SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
8997                         
8998                 }
8999                 
9000                 *wxSPropertyDataNameOut = wxT("MEMBER");
9001                 
9002                 for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
9003                 intiter != SplitPoints.end(); ++intiter){
9004                 
9005                         SLiter = SplitLength.find(intiter->first);
9006                 
9007                         if (ProcessItemData == TRUE){
9009                                 if (FirstToken == TRUE){
9010                 
9011                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue - 1), (SLiter->second));
9012                                         FirstToken = FALSE;
9013                                 
9014                                 } else {
9015                                 
9016                                         PropertyData = wxSPropertySeg1Chopped.Mid((intPrevValue), (SLiter->second));
9017                                 
9018                                 }
9019                         
9020                         } else {
9021                         
9022                                 if (FirstToken == TRUE){
9023                         
9024                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue - 1), (SLiter->second));
9025                                         FirstToken = FALSE;
9026                                                                 
9027                                 } else {
9028                                 
9029                                         PropertyData = wxSPropertySeg1Ptr->Mid((intPrevValue), (SLiter->second));
9030                                         
9031                                 }
9032                         
9033                         }
9034                         
9035                         wxStringTokenizer PropertyElement (PropertyData, wxT("="));
9036                         PropertyName = PropertyElement.GetNextToken();                          
9037                         PropertyValue = PropertyElement.GetNextToken();
9038                         
9039                         //ProcessCaptureStrings(&PropertyValue);
9040                         
9041                         intPrevValue = intiter->second;
9042                         
9043                         // Process properties.
9044                         
9045                         // Check if there is a lock on the property value. If there is a lock then
9046                         // the property value cannot be changed.
9047                         
9048                         if (PropertyName.IsEmpty()){
9049                         
9050                                 continue;
9051                         
9052                         }
9053                         
9054                         if (PropertyLockMap->find(PropertyName) == PropertyLockMap->end()){
9055                         
9056                                 if (PropertyDataMap->find(PropertyName) == PropertyDataMap->end()){
9057                         
9058                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
9059                         
9060                                 } else {
9061                         
9062                                         PropertyDataMap->erase(PropertyName);
9063                                         PropertyDataMap->insert(std::make_pair(PropertyName, PropertyValue));
9064                         
9065                                 }
9066                                 
9067                         }
9068                         
9069                         //wxSPropertyPropValuesOut->Append(wxT(";"));
9070                         //wxSPropertyPropValuesOut->Append(PropertyName + wxT("=") + PropertyValue);
9071                 
9072                 }
9073                 
9074                 wxSPropertyXVCard4Value->Append(*wxSPropertySeg2Ptr);
9075                 *XVCardV4Value = TRUE;
9076                 
9077                 
9078         }
9079         
9080         // Deal with X-ABLabel specifically.
9081         
9082         if (wxSProperty == wxT("X-ABLabel") && ProcessItemData == TRUE){
9083         
9084                 //int intPropertyLen = wxSPropertySeg1Ptr->Len();
9085         intPropertyLen = wxSPropertySeg1Ptr->Len();
9086         std::map<int, int> SplitPoints;
9087                 std::map<int, int> SplitLength;
9088                 std::map<int, int>::iterator SLiter;                    
9089                 wxString PropertyData;
9090                 wxString PropertyName;
9091                 wxString PropertyValue;
9092                 wxString PropertyTokens;
9093                 int intPrevValue = 11;
9094                 
9095                 SplitValues(wxSPropertySeg1Ptr, &SplitPoints, &SplitLength, intPrevValue);
9096                 
9097                 //EscapeString(wxSPropertySeg2Ptr, FALSE);
9098                 PropertyDataMap->insert(std::make_pair(wxT("X-ABLabel"), *wxSPropertySeg2Ptr));
9099                                 
9100         }
9104 void vCard34Conv::ProcessCaptureStringsProc(wxString *strCapture){
9106     CaptureString(strCapture, FALSE);
9110 void vCard34Conv::SplitValues(wxString *PropertyLine, 
9111         std::map<int,int> *SplitPoints, 
9112         std::map<int,int> *SplitLength, 
9113         int intSize){
9114         
9115         size_t intPropertyLen = PropertyLine->Len();
9116         int intSplitsFound = 0;
9117         int intSplitSize = 0;
9118         int intSplitSeek = 0;
9119         
9120         for (int i = intSize; i <= intPropertyLen; i++){
9122                 intSplitSize++;
9123         
9124                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
9125                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
9126            
9127                     if (intSplitsFound == 0){
9128             
9129                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
9130           
9131                     } else {
9132            
9133                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
9134             
9135                     }
9136             
9137                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
9138             
9139                     intSplitsFound++;
9140                     intSplitSeek = i;
9141                     intSplitSize = 0;
9142             
9143                 }
9145         }
9147         if (intSplitsFound == 0){
9149                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
9150                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
9152         } else {
9154                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
9155                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
9157         }
9161 void vCard34Conv::SplitValuesData(wxString *PropertyLine, 
9162         std::map<int,int> *SplitPoints, 
9163         std::map<int,int> *SplitLength, 
9164         int intSize,
9165         std::map<wxString,wxString> *SplitData){
9166         
9167         wxString DataStr;
9168         wxStringTokenizer PropertyElement;
9169         wxString PropertyName;
9170         wxString PropertyValue;
9171         size_t intPropertyLen = PropertyLine->Len();
9172         int intSplitsFound = 0;
9173         int intSplitSize = 0;
9174         int intSplitSeek = (intSize - 1);
9175         
9176         for (int i = intSize; i <= intPropertyLen; i++){
9178                 intSplitSize++;
9179         
9180                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
9181                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
9182            
9183                     if (intSplitsFound == 0){
9184             
9185                                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
9186                                 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
9187           
9188                         } else {
9190                                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
9191                                 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
9193                         }
9194                     
9195                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
9196             
9197                     intSplitsFound++;
9198                     intSplitSeek = (i + 1);
9199                     intSplitSize = 0;
9200                     
9201                     if (!DataStr.IsEmpty()){
9202                     
9203                         PropertyElement.SetString(DataStr, wxT("="));
9204                         PropertyName = PropertyElement.GetNextToken();
9205                         PropertyValue = PropertyElement.GetNextToken();
9206                         SplitData->insert(std::make_pair(PropertyName, PropertyValue));
9207                     
9208                     }
9209                     
9210                     DataStr.clear();
9211                     PropertyName.clear();
9212                     PropertyValue.clear();
9213             
9214                 }
9216         }
9218         if (intSplitsFound == 0){
9220                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
9222                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
9223                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
9225         } else {
9226                 
9227                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
9229                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
9230                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
9232         }
9234         if (!DataStr.IsEmpty()){
9235                 
9236                 PropertyElement.SetString(DataStr, wxT("="));
9237                 PropertyName = PropertyElement.GetNextToken();
9238                 PropertyValue = PropertyElement.GetNextToken();
9239                 SplitData->insert(std::make_pair(PropertyName, PropertyValue));         
9240                 
9241         }
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