Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit tests for the SOURCE vCard property for ContactDa...
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
22         
23         if (!wxFileExists(Filename)){
24         
25                 return CONTACTLOAD_FILEMISSING;
26         
27         }
28         
29         wxFile ContactFile;
30         
31         if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
32         
33                 return CONTACTLOAD_FILEERROR;
34         
35         }
36         
37         // Check that the vCard is a valid vCard 4.0 file.
39         vCard vCard4FormatCheck;
40         
41         vCard4FormatCheck.LoadFile(Filename);
42         
43         if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
44         
45                 return CONTACTLOAD_FILEINVALIDFORMAT;
46         
47         }
49         // Check that the vCard meets the base specification.
50         
51         if (!vCard4FormatCheck.MeetBaseSpecification()){
52         
53                 return CONTACTLOAD_FILEBASESPECFAIL;
54         
55         }
56         
57         wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
58         
59         std::map<int, wxString> ContactFileLines;
61         int ContactLineSeek = 0;
63         while (wSTContactFileLines.HasMoreTokens() == TRUE){
65                 wxString ContactLine = wSTContactFileLines.GetNextToken();
66                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
67                 ContactLineSeek++;              
68         
69         }
70         
71         wxString wxSPropertyNextLine;
72         
73         bool ExtraLineSeek = TRUE;
74         bool QuoteMode = FALSE;
75         bool PropertyFind = TRUE;
76         bool KindProcessed = FALSE;
77         bool NameProcessed = FALSE;
78         bool GenderProcessed = FALSE;
79         bool BirthdayProcessed = FALSE;
80         bool AnniversaryProcessed = FALSE;
81         bool UIDProcessed = FALSE;
82         int ContactLineLen = 0;
83         int QuoteBreakPoint = 0;
84         int SourceCount = 0;
85         int GroupCount = 0;
86         int FNCount = 0;
87         int NicknameCount = 0;
88         int TimeZoneCount = 0;
89         int AddressCount = 0;
90         int EmailCount = 0;
91         int IMCount = 0;
92         int TelephoneCount = 0;
93         int LanguageCount = 0;
94         int GeographicCount = 0;
95         int RelatedCount = 0;
96         int URLCount = 0;
97         int TitleCount = 0;
98         int RoleCount = 0;
99         int OrganisationCount = 0;
100         int NoteCount = 0;
101         int CategoryCount = 0;
102         int PhotoCount = 0;
103         int LogoCount = 0;
104         int SoundCount = 0;
105         int CalendarCount = 0;
106         int CalendarAddressCount = 0;
107         int FreeBusyAddressCount = 0;
108         int KeyCount = 0;
109         int VendorCount = 0;
110         int XTokenCount = 0;
111         wxString ContactLine;
112         wxString PropertyLine;
113         wxString PropertySeg1;
114         wxString PropertySeg2;
115         wxString PropertyNextLine;
116         wxString Property;
117         
118         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
119          iter != ContactFileLines.end(); ++iter){
121                 ExtraLineSeek = TRUE;
122                 QuoteMode = FALSE;
123                 PropertyFind = TRUE;
124                 ContactLineLen = 0;
125                 QuoteBreakPoint = 0;
126                 ContactLine.Clear();
127                 PropertyLine.Clear();
128                 PropertySeg1.Clear();
129                 PropertySeg2.Clear();
130                 Property.Clear();
131          
132                 ContactLine = iter->second;
133                 
134                 while (ExtraLineSeek == TRUE){
135                 
136                         // Check if there is extra data on the next line 
137                         // (indicated by space or tab at the start) and add data.
138                 
139                         iter++;
140                         
141                         if (iter == ContactFileLines.end()){
142                         
143                                 iter--;
144                                 break;
145                         
146                         }                       
147                 
148                         PropertyNextLine = iter->second;
149                 
150                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
151                 
152                                 PropertyNextLine.Remove(0, 1);
153                                 ContactLine.Append(PropertyNextLine);
154                 
155                         } else {
156                         
157                                 iter--;
158                                 ExtraLineSeek = FALSE;
159                         
160                         }
161                 
162                 }
164                 ContactLineLen = ContactLine.Len();
165                 
166                 // Make sure we are not in quotation mode.
167                 // Make sure colon does not have \ or \\ before it.
168                 
169                 for (int i = 0; i <= ContactLineLen; i++){
170                 
171                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
172                         
173                                 PropertyFind = FALSE;
174                         
175                         } else if (PropertyFind == TRUE){
176                         
177                                 Property.Append(ContactLine.Mid(i, 1));
178                         
179                         }               
180                 
181                         if (ContactLine.Mid(i, 1) == wxT("\"")){
182                         
183                                 if (QuoteMode == TRUE){
184                                 
185                                         QuoteMode = FALSE;
186                                 
187                                 } else {
188                         
189                                         QuoteMode = TRUE;
190                                         
191                                 }
192                         
193                         }
194                         
195                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
196                         
197                                 QuoteBreakPoint = i;
198                                 break;
199                         
200                         }
201                 
202                 }
203                 
204                 // Split that line at the point into two variables (ignore the colon).
205                 
206                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
207                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
208                 
209                  if (Property == wxT("KIND") && KindProcessed == FALSE){
210                                 
211                         ProcessKind(PropertySeg2);
212                 
213                 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
214                 
215                         UIDToken = PropertySeg2;
216                         UIDProcessed = TRUE;
217                 
218                 } else if (Property == wxT("SOURCE")){
219                 
220                         ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
221                         SourceCount++;
222                 
223                 } else if (Property == wxT("MEMBER")){
225                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
226                         GroupCount++;   
227                 
228                 } else if (Property == wxT("FN")){
229                 
230                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
231                         FNCount++;
232                 
233                 } else if (Property == wxT("N") && NameProcessed == FALSE){
234                 
235                         ProcessN(PropertySeg1, PropertySeg2);
236                         NameProcessed = TRUE;
237                 
238                 } else if (Property == wxT("NICKNAME")){
239                                                 
240                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
241                         NicknameCount++;
242                         
243                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
244                 
245                         ProcessGender(PropertySeg1, PropertySeg2);
246                         GenderProcessed = TRUE;
247                 
248                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
249                 
250                         ProcessBirthday(PropertySeg1, PropertySeg2);
251                         BirthdayProcessed = TRUE;
252                 
253                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
254                 
255                         ProcessAnniversary(PropertySeg1, PropertySeg2);
256                         AnniversaryProcessed = TRUE;
257                 
258                 } else if (Property == wxT("TZ")){
259                 
260                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
261                         TimeZoneCount++;
262                 
263                 } else if (Property == wxT("ADR")){
264                 
265                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
266                         AddressCount++;
267                 
268                 } else if (Property == wxT("EMAIL")){
269                                         
270                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
271                         EmailCount++;
272                 
273                 } else if (Property == wxT("IMPP")){
274                 
275                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
276                         IMCount++;
277                         
278                 } else if (Property == wxT("TEL")){
279                                 
280                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
281                         TelephoneCount++;
282                 
283                 } else if (Property == wxT("LANG")){
284                 
285                         // See frmContactEditor-LoadLanguage.cpp
286                         
287                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
288                         LanguageCount++;
289                 
290                 } else if (Property == wxT("GEO")){
291                 
292                         // See frmContactEditor-LoadGeo.cpp
293                         
294                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
295                         GeographicCount++;
296                 
297                 } else if (Property == wxT("RELATED")){
298                         
299                         // See fromContactEditor-LoadRelated.cpp
300                         
301                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
302                         RelatedCount++;
303                         
304                 } else if (Property == wxT("URL")){
306                         // See frmContactEditor-LoadURL.cpp
307                 
308                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
309                         URLCount++;
310                 
311                 } else if (Property == wxT("TITLE")) {
312                 
313                         // See frmContactEditor-LoadTitle.cpp
314                         
315                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
316                         TitleCount++;
317                         
318                 } else if (Property == wxT("ROLE")) {
319                 
320                         // See frmContactEditor-LoadTitle.cpp
321                         
322                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
323                         RoleCount++;
324                         
325                 } else if (Property == wxT("ORG")) {
326                 
327                         // See frmContactEditor-LoadOrg.cpp
328                         
329                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
330                         OrganisationCount++;
331                         
332                 } else if (Property == wxT("NOTE")) {
334                         // See frmContactEditor-LoadNote.cpp
336                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
337                         NoteCount++;    
338                         
339                 } else if (Property == wxT("CATEGORIES")) {
340                 
341                         // See frmContactEditor-LoadCategory.cpp
342                 
343                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
344                         CategoryCount++;
345                         
346                 } else if (Property == wxT("PHOTO")) {
347                 
348                         // See frmContactEditor-LoadPhoto.cpp
349                         
350                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
351                         PhotoCount++;
353                 } else if (Property == wxT("LOGO")) {
354                 
355                         // See frmContactEditor-LoadPhoto.cpp
356                         
357                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
358                         LogoCount++;
360                 } else if (Property == wxT("LOGO")) {
361                 
362                         // See frmContactEditor-LoadPhoto.cpp
363                         
364                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
365                         LogoCount++;
367                 } else if (Property == wxT("SOUND")) {
368                 
369                         // See frmContactEditor-LoadSound.cpp
370                         
371                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
372                         SoundCount++;
373                         
374                 } else if (Property == wxT("CALURI")){
376                         // See frmContactEditor-LoadCalendar.cpp
377                         
378                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
379                         CalendarCount++;
380                 
381                 } else if (Property == wxT("CALADRURI")){
382                 
383                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
384                         CalendarAddressCount++;
385                 
386                 } else if (Property == wxT("FBURL")){
388                         // See frmContactEditor-LoadCalendar.cpp
390                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
391                         FreeBusyAddressCount++;
393                 } else if (Property == wxT("KEY")){
394                 
395                         // See frmContactEditor-LoadKey.cpp
396                         
397                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
398                         KeyCount++;
399                 
400                 } else if (Property.Mid(0, 3) == wxT("VND")){
401                 
402                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
403                         VendorCount++;
404                 
405                 } else if (Property.Mid(0, 2) == wxT("X-")){
406                         
407                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
408                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
409                         XTokenCount++;
410                 
411                 }
412                 
413         }
414         
415         return CONTACTLOAD_OK;
419 void ContactDataObject::ProcessKind(wxString KindType){
421         if (KindType == wxT("individual")){
422                         
423                 ContactKind = CONTACTKIND_INDIVIDUAL;
424                         
425         } else if (KindType == wxT("group")){
426                         
427                 ContactKind = CONTACTKIND_GROUP;
428                         
429         } else if (KindType == wxT("org")){
430                         
431                 ContactKind = CONTACTKIND_ORGANISATION;
432                         
433         } else if (KindType == wxT("location")){
434                         
435                 ContactKind = CONTACTKIND_LOCATION;
436                         
437         } else {
438                         
439                 ContactKind = CONTACTKIND_NONE;                 
440         }
444 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
446         size_t intPropertyLen = PropertySeg1.Len();
447         std::map<int, int> SplitPoints;
448         std::map<int, int> SplitLength;
449         std::map<int, int>::iterator SLiter;                    
450         wxString PropertyData;
451         wxString PropertyName;
452         wxString PropertyValue;
453         wxString PropertyTokens;
454         bool FirstToken = TRUE;
455         int intSplitsFound = 0;
456         int intSplitSize = 0;
457         int intPrevValue = 8;
458         int intPref = 0;                        
459         int intType = 0;
460         
461         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
462         
463         intPrevValue = 7;
464         
465         PropertyType PropType = PROPERTY_NONE;
466         
467         // Look for type before continuing.                     
469         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
471         intPrevValue = 7;
473         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
474         intiter != SplitPoints.end(); ++intiter){
475         
476                 SLiter = SplitLength.find(intiter->first);
477         
478                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
479                 
480                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
481                 PropertyName = PropertyElement.GetNextToken();                          
482                 PropertyValue = PropertyElement.GetNextToken();
483                 
484                 intPrevValue = intiter->second;
485                 
486                 // Process properties.
487                 
488                 size_t intPropertyValueLen = PropertyValue.Len();
489                 
490                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
491                         
492                         PropertyValue.Trim();
493                         PropertyValue.RemoveLast();
494                         
495                 }                               
496                 
497                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
498                         
499                         PropertyValue.Remove(0, 1);
500                         
501                 }                       
502                 
503                 CaptureString(&PropertyValue, FALSE);
504                 
505                 if (PropertyName == wxT("ALTID")){
507                         SourceListAltID.erase(*SourceCount);
508                         SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
509                 
510                 } else if (PropertyName == wxT("PID")){
512                         SourceListPID.erase(*SourceCount);
513                         SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
514                 
515                 } else if (PropertyName == wxT("PREF")){
516                         
517                         int PriorityNumber = 0;
518                         bool ValidNumber = TRUE;
519                         
520                         try{
521                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
522                         }
523                         
524                         catch(std::invalid_argument &e){
525                                 ValidNumber = FALSE;
526                         }
528                         if (ValidNumber == TRUE){
530                                 SourceListPref.erase(*SourceCount);
531                                 SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
533                         }
534                 
535                 } else if (PropertyName == wxT("MEDIATYPE")){
536                 
537                         SourceListMediatype.erase(*SourceCount);
538                         SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
540                 } else {
541                 
542                         // Something else we don't know about so append
543                         // to the tokens variable.
544                         
545                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
546                         
547                                 if (FirstToken == TRUE){
548                                 
549                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
550                                         FirstToken = FALSE;
551                                 
552                                 } else {
553                                 
554                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
555                                 
556                                 }
557                         
558                         }
559                 
560                 }
561         
562         }       
563         
564         intPropertyLen = PropertySeg2.Len();
565         SplitPoints.clear();
566         SplitLength.clear();
567         intSplitsFound = 0;
568         intSplitSize = 0;
569         intPrevValue = 0;
570         
571         CaptureString(&PropertySeg2, FALSE);
572         
573         // Add the data to the General/Home/Work address variables.
574                 
575         switch(PropType){
576                 case PROPERTY_NONE:
577                         break;
578                 case PROPERTY_HOME:
579                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
580                         break;
581                 case PROPERTY_WORK:
582                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
583                         break;
584         }
585         
586         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
587         
588         if (!PropertyTokens.IsEmpty()){
589         
590                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
591         
592         }
596 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
598         std::map<int, int> SplitPoints;
599         std::map<int, int> SplitLength;
601         int intPrevValue = 8;
602         int intPref = 0;                        
603         int intType = 0;
604         
605         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
607         intPrevValue = 7;
608         
609         wxString PropertyName;
610         wxString PropertyValue;
611         wxString PropertyData;
612         wxString PropertyTokens;
613         std::map<int,int>::iterator SLiter;
614         bool FirstToken = TRUE;
615         
616         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
617         intiter != SplitPoints.end(); ++intiter){
618         
619                 SLiter = SplitLength.find(intiter->first);
620         
621                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
622                 
623                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
624                 PropertyName = PropertyElement.GetNextToken();                          
625                 PropertyValue = PropertyElement.GetNextToken();
626                 
627                 intPrevValue = intiter->second;
628                 
629                 CaptureString(&PropertyValue, FALSE);
630         
631                 if (PropertyName == wxT("ALTID")){
633                         GroupsListAltID.erase(*GroupCount);
634                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
635                 
636                 } else if (PropertyName == wxT("PID")){
638                         GroupsListPID.erase(*GroupCount);
639                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
640                 
641                 } else if (PropertyName == wxT("PREF")){
643                         int PriorityNumber = 0;
644                         bool ValidNumber = TRUE;
645                         
646                         try{
647                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
648                         }
649                         
650                         catch(std::invalid_argument &e){
651                                 ValidNumber = FALSE;
652                         }
654                         if (ValidNumber == TRUE){
656                                 GroupsListPref.erase(*GroupCount);
657                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
658                 
659                         }
660                 
661                 } else if (PropertyName == wxT("MEDIATYPE")){
663                         GroupsListMediaType.erase(*GroupCount);
664                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
665                 
666                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
667                         
668                         if (FirstToken == TRUE){
669                                 
670                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
671                                 FirstToken = FALSE;
672                                 
673                         } else {
674                         
675                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
676                                 
677                         }
678                         
679                 }
680                 
681         }
683         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
685         if (!PropertyTokens.IsEmpty()){
686         
687                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
688         
689         }
694 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
696         std::map<int, int> SplitPoints;
697         std::map<int, int> SplitLength;
699         int intPrevValue = 4;
700         int intPref = 0;                        
701         int intType = 0;
702         
703         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
705         intPrevValue = 3;
706         
707         wxString PropertyName;
708         wxString PropertyValue;
709         wxString PropertyData;
710         wxString PropertyTokens;
711         std::map<int,int>::iterator SLiter;
712         bool FirstToken = TRUE;
713         
714         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
715         intiter != SplitPoints.end(); ++intiter){
716         
717                 SLiter = SplitLength.find(intiter->first);
718         
719                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
720                 
721                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
722                 PropertyName = PropertyElement.GetNextToken();                          
723                 PropertyValue = PropertyElement.GetNextToken();
724                 
725                 intPrevValue = intiter->second;
726                 
727                 CaptureString(&PropertyValue, FALSE);
728                 
729                 if (PropertyName == wxT("TYPE")){
731                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
732                                 PropertyValue == wxT("work") ){
734                                 FullNamesListType.erase(*FNCount);
735                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
736                 
737                         }
738                 
739                 } else if (PropertyName == wxT("LANGUAGE")){
741                         FullNamesListLanguage.erase(*FNCount);
742                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
743                 
744                 } else if (PropertyName == wxT("ALTID")){
745                 
746                         FullNamesListAltID.erase(*FNCount);
747                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
748                 
749                 } else if (PropertyName == wxT("PID")){
751                         FullNamesListPID.erase(*FNCount);
752                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
753                 
754                 } else if (PropertyName == wxT("PREF")){
756                         int PriorityNumber = 0;
757                         bool ValidNumber = TRUE;
758                         
759                         try{
760                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
761                         }
762                         
763                         catch(std::invalid_argument &e){
764                                 ValidNumber = FALSE;
765                         }
767                         if (ValidNumber == TRUE){
769                                 FullNamesListPref.erase(*FNCount);
770                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
772                         }
773                 
774                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
775                         
776                         if (FirstToken == TRUE){
777                                 
778                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
779                                 FirstToken = FALSE;
780                                 
781                         } else {
782                         
783                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
784                                 
785                         }
786                         
787                 } 
788         
789         }
791         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
793         if (!PropertyTokens.IsEmpty()){
794         
795                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
796         
797         }
801 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
803         std::map<int, int> SplitPoints;
804         std::map<int, int> SplitLength;
806         int intPrevValue = 3;
807         int intPref = 0;                        
808         int intType = 0;
809         
810         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
811         
812         intPrevValue = 2;
813         
814         wxString PropertyName;
815         wxString PropertyValue;
816         wxString PropertyData;
817         wxString PropertyTokens;
818         std::map<int,int>::iterator SLiter;
819         bool FirstToken = TRUE;
820         
821         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
822         intiter != SplitPoints.end(); ++intiter){
823         
824                 SLiter = SplitLength.find(intiter->first);
825         
826                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
827                 
828                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
829                 PropertyName = PropertyElement.GetNextToken();                          
830                 PropertyValue = PropertyElement.GetNextToken();
831                 
832                 intPrevValue = intiter->second;
833                 
834                 CaptureString(&PropertyValue, FALSE);
835                 
836                 if (PropertyName == wxT("ALTID")){
838                         NameAltID = PropertyValue;
839                 
840                 } else if (PropertyName == wxT("LANGUAGE")){
841                 
842                         NameLanguage = PropertyValue;
843                 
844                 } else if (PropertyName == wxT("SORT-AS")){
845                 
846                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
847                                 PropertyValue.Len() >= 3){
848                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
849                         }
850                 
851                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
852                         
853                         if (FirstToken == TRUE){
854                                 
855                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
856                                 FirstToken = FALSE;
857                                 
858                         } else {
859                         
860                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
861                                 
862                         }
863                         
864                 }
865         
866         }
867         
868         // Split the name data.
869         
870         int intSplitSeek = 0;           
871         int intSplitsFound = 0;
872         int intSplitSize = 0;
873         int intPropertyLen = PropertySeg2.Len();
874         
875         std::map<int,wxString> NameValues;
876         intPrevValue = 0;                                       
877         
878         for (int i = 0; i <= intPropertyLen; i++){
879         
880                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
881                         
882                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
883                         
884                         intSplitSeek = i;
885                         intSplitSeek++;
886                         
887                         if (intSplitsFound == 4){
888                         
889                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
890                                 break;
891                         
892                         }
893                         
894                         intSplitSize = 0;
895                         continue;
896         
897                 }
898                 
899                 intSplitSize++;
901         }
902         
903         // Split the data into several parts.
904                         
905         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
906         iter != NameValues.end(); ++iter){
907         
908                 if (iter->first == 1){
909                 
910                         // Deal with family name.
911                         
912                         NameSurname = iter->second;
913                 
914                 } else if (iter->first == 2){
915                 
916                         // Deal with given names.
917                         
918                         NameForename = iter->second;
919                 
920                 } else if (iter->first == 3){
921                 
922                         // Deal with additional names.
923                         
924                         NameOtherNames = iter->second;
925                 
926                 } else if (iter->first == 4){
927                 
928                         // Deal with honorifix prefixes and suffixes.
930                         NameTitle = iter->second;
931                 
932                         iter++;
933                         
934                         if (iter == NameValues.end()){
935                         
936                                 break;
937                         
938                         }
939                 
940                         NameSuffix = iter->second;
941                 
942                 }
943         
944         }
945         
946         // Add the name token data.
947         
948         if (!PropertyTokens.IsEmpty()){
949         
950                 NameTokens = PropertyTokens;
951         
952         }
956 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
958         std::map<int, int> SplitPoints;
959         std::map<int, int> SplitLength;
961         int intPrevValue = 10;
962         int intPref = 0;                        
963         
964         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
965         
966         intPrevValue = 9;
967         
968         PropertyType PropType = PROPERTY_NONE;
969         
970         // Look for type before continuing.
971         
972         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
973         
974         intPrevValue = 9;
975         
976         std::map<int, wxString> *NicknamesList = NULL;
977         std::map<int, wxString> *NicknamesListType = NULL;
978         std::map<int, wxString> *NicknamesListLanguage = NULL;
979         std::map<int, wxString> *NicknamesListAltID = NULL;
980         std::map<int, wxString> *NicknamesListPID = NULL;
981         std::map<int, wxString> *NicknamesListTokens = NULL;            
982         std::map<int, int> *NicknamesListPref = NULL;
983         
984         switch(PropType){
985                 case PROPERTY_NONE:
986                         NicknamesList = &GeneralNicknamesList;
987                         NicknamesListType = &GeneralNicknamesListType;
988                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
989                         NicknamesListAltID = &GeneralNicknamesListAltID;
990                         NicknamesListPID = &GeneralNicknamesListPID;
991                         NicknamesListTokens = &GeneralNicknamesListTokens;
992                         NicknamesListPref = &GeneralNicknamesListPref;
993                         break;
994                 case PROPERTY_HOME:
995                         NicknamesList = &HomeNicknamesList;
996                         NicknamesListType = &HomeNicknamesListType;
997                         NicknamesListLanguage = &HomeNicknamesListLanguage;
998                         NicknamesListAltID = &HomeNicknamesListAltID;
999                         NicknamesListPID = &HomeNicknamesListPID;
1000                         NicknamesListTokens = &HomeNicknamesListTokens;
1001                         NicknamesListPref = &HomeNicknamesListPref;
1002                         break;
1003                 case PROPERTY_WORK:
1004                         NicknamesList = &BusinessNicknamesList;
1005                         NicknamesListType = &BusinessNicknamesListType;
1006                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1007                         NicknamesListAltID = &BusinessNicknamesListAltID;
1008                         NicknamesListPID = &BusinessNicknamesListPID;
1009                         NicknamesListTokens = &BusinessNicknamesListTokens;
1010                         NicknamesListPref = &BusinessNicknamesListPref;
1011                         break;
1012         }
1013         
1014         std::map<int, int>::iterator SLiter;    
1015         wxString PropertyData;
1016         wxString PropertyName;
1017         wxString PropertyValue;
1018         wxString PropertyTokens;
1019         bool FirstToken = TRUE;
1020         
1021         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1022         intiter != SplitPoints.end(); ++intiter){
1023         
1024                 SLiter = SplitLength.find(intiter->first);
1025         
1026                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1027                 
1028                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1029                 PropertyName = PropertyElement.GetNextToken();                          
1030                 PropertyValue = PropertyElement.GetNextToken();
1031                 
1032                 intPrevValue = intiter->second;
1033                 
1034                 CaptureString(&PropertyValue, FALSE);
1035                 
1036                 if (PropertyName == wxT("ALTID")){
1038                         NicknamesListAltID->erase(*NicknameCount);
1039                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1040                 
1041                 } else if (PropertyName == wxT("PID")){
1043                         NicknamesListPID->erase(*NicknameCount);
1044                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
1046                 } else if (PropertyName == wxT("PREF")){
1048                         int PriorityNumber = 0;
1049                         bool ValidNumber = TRUE;
1050                         
1051                         try{
1052                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1053                         }
1054                         
1055                         catch(std::invalid_argument &e){
1056                                 ValidNumber = FALSE;
1057                         }
1059                         if (ValidNumber == TRUE){
1061                                 NicknamesListPref->erase(*NicknameCount);
1062                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1064                         }
1065                 
1066                 } else if (PropertyName == wxT("LANGUAGE")){
1068                         NicknamesListLanguage->erase(*NicknameCount);
1069                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
1071                 } else {
1072                 
1073                         // Something else we don't know about so append
1074                         // to the tokens variable.
1075                 
1076                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1077                 
1078                                 if (FirstToken == TRUE){
1079                         
1080                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1081                                         FirstToken = FALSE;
1082                         
1083                                 } else {
1084                         
1085                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1086                         
1087                                 }
1088                 
1089                         }
1090                 
1091                 }
1092                 
1093         }
1094         
1095         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1096         
1097         // Add the name token data.
1098         
1099         if (!PropertyTokens.IsEmpty()){
1100         
1101                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1102         
1103         }
1107 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1109         std::map<int, int> SplitPoints;
1110         std::map<int, int> SplitLength;
1111         std::map<int, int>::iterator SLiter;                    
1112         wxString PropertyData;
1113         wxString PropertyName;
1114         wxString PropertyValue;
1115         wxString PropertyTokens;
1116         bool FirstToken = TRUE;
1117         int intPrevValue = 8;
1119         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1121         intPrevValue = 7;                       
1122         
1123         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1124         intiter != SplitPoints.end(); ++intiter){
1125         
1126                 SLiter = SplitLength.find(intiter->first);
1127         
1128                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1129                 
1130                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1131                 PropertyName = PropertyElement.GetNextToken();                          
1132                 PropertyValue = PropertyElement.GetNextToken();
1133                 
1134                 intPrevValue = intiter->second;
1135                 
1136                 // Process properties.
1137                 
1138                 size_t intPropertyValueLen = PropertyValue.Len();
1139                 
1140                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1141                         
1142                         PropertyValue.Trim();
1143                         PropertyValue.RemoveLast();
1144                         
1145                 }                               
1146                 
1147                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1148                         
1149                         PropertyValue.Remove(0, 1);
1150                         
1151                 }                               
1152                 
1153                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1155                         if (FirstToken == TRUE){
1156         
1157                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1158                                 FirstToken = FALSE;
1159         
1160                         } else {
1161         
1162                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1163         
1164                         }
1166                 }
1167         
1168         }       
1170         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1171         
1172         wxString GenderComponent;
1173         
1174         if (GenderData.CountTokens() >= 2){
1175         
1176                 Gender = GenderData.GetNextToken();
1177                 GenderDetails = GenderData.GetString();
1178         
1179                 CaptureString(&GenderDetails, FALSE);
1180                                                 
1181         } else {
1182         
1183                 Gender = GenderData.GetNextToken();
1184         
1185         }
1186         
1187         if (!PropertyTokens.IsEmpty()){
1188         
1189                 GenderTokens = PropertyTokens;
1190         
1191         }
1195 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1197         // Process date. Preserve the remainder in the string.
1199         std::map<int, int> SplitPoints;
1200         std::map<int, int> SplitLength;
1201         std::map<int, int>::iterator SLiter;                    
1202         wxString PropertyData;
1203         wxString PropertyName;
1204         wxString PropertyValue;
1205         wxString PropertyTokens;
1206         bool BirthdayText = FALSE;
1207         int intPrevValue = 6;
1209         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1211         intPrevValue = 5;
1213         // Look for type before continuing.
1215         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1216         intiter != SplitPoints.end(); ++intiter){
1218                 SLiter = SplitLength.find(intiter->first);
1220                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1221         
1222                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1223                 PropertyName = PropertyElement.GetNextToken();                          
1224                 PropertyValue = PropertyElement.GetNextToken();
1225         
1226                 intPrevValue = intiter->second;
1227         
1228                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1229         
1230                         CaptureString(&PropertySeg2, FALSE);
1231                         Birthday = PropertySeg2;
1232                         BirthdayText = TRUE;
1233         
1234                 }
1236         }
1238         // Setup blank lines for later on.
1239         
1240         intPrevValue = 5;
1241         bool FirstToken = TRUE;
1243         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1244         intiter != SplitPoints.end(); ++intiter){
1246                 SLiter = SplitLength.find(intiter->first);
1248                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1249         
1250                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1251                 PropertyName = PropertyElement.GetNextToken();                          
1252                 PropertyValue = PropertyElement.GetNextToken();
1253         
1254                 intPrevValue = intiter->second;
1255         
1256                 // Process properties.
1257         
1258                 CaptureString(&PropertyValue, FALSE);
1259         
1260                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1261                 
1262                         PropertyValue.Trim();
1263                         PropertyValue.RemoveLast();
1264                 
1265                 }                               
1266         
1267                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1268                 
1269                         PropertyValue.Remove(0, 1);
1270                 
1271                 }                               
1272         
1273                 if (PropertyName == wxT("ALTID")){
1275                         BirthdayAltID = PropertyValue;
1276         
1277                 } else if (PropertyName == wxT("CALSCALE")){
1278         
1279                         BirthdayCalScale = PropertyValue;
1280         
1281                 } else if (PropertyName != wxT("VALUE")) {
1282         
1283                         // Something else we don't know about so append
1284                         // to the tokens variable.
1285                 
1286                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1287                 
1288                                 if (FirstToken == TRUE){
1289         
1290                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1291                                         FirstToken = FALSE;
1292         
1293                                 } else {
1294         
1295                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1296         
1297                                 }
1298                                 
1299                         }
1300                         
1301                 }
1303         }       
1305         // Add the data to the variables and form.
1306         
1307         if (BirthdayText == FALSE){
1308         
1309                 Birthday = PropertySeg2;
1311         }
1312         
1313         if (!PropertyTokens.IsEmpty()){
1314         
1315                 BirthdayTokens = PropertyTokens;
1317         }
1321 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1323         // Process date. Preserve the remainder in the string.
1325         std::map<int, int> SplitPoints;
1326         std::map<int, int> SplitLength;
1327         std::map<int, int>::iterator SLiter;                    
1328         wxString PropertyData;
1329         wxString PropertyName;
1330         wxString PropertyValue;
1331         wxString PropertyTokens;
1332         bool AnniversaryText = FALSE;
1333         int intPrevValue = 13;
1335         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1337         intPrevValue = 12;
1339         // Look for type before continuing.
1341         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1342         intiter != SplitPoints.end(); ++intiter){
1344                 SLiter = SplitLength.find(intiter->first);
1346                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1347         
1348                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1349                 PropertyName = PropertyElement.GetNextToken();                          
1350                 PropertyValue = PropertyElement.GetNextToken();
1351         
1352                 intPrevValue = intiter->second;
1353         
1354                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1355         
1356                         CaptureString(&PropertySeg2, FALSE);
1357                         Anniversary = PropertySeg2;
1358                         AnniversaryText = TRUE;
1359         
1360                 }
1362         }
1364         // Setup blank lines for later on.
1365         
1366         intPrevValue = 12;
1367         bool FirstToken = TRUE;
1369         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1370         intiter != SplitPoints.end(); ++intiter){
1372                 SLiter = SplitLength.find(intiter->first);
1374                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1375         
1376                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1377                 PropertyName = PropertyElement.GetNextToken();                          
1378                 PropertyValue = PropertyElement.GetNextToken();
1379         
1380                 intPrevValue = intiter->second;
1381         
1382                 // Process properties.
1383         
1384                 CaptureString(&PropertyValue, FALSE);
1385         
1386                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1387                 
1388                         PropertyValue.Trim();
1389                         PropertyValue.RemoveLast();
1390                 
1391                 }                               
1392         
1393                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1394                 
1395                         PropertyValue.Remove(0, 1);
1396                 
1397                 }                               
1398         
1399                 if (PropertyName == wxT("ALTID")){
1401                         AnniversaryAltID = PropertyValue;
1402         
1403                 } else if (PropertyName == wxT("CALSCALE")){
1404         
1405                         AnniversaryCalScale = PropertyValue;
1406         
1407                 } else if (PropertyName != wxT("VALUE")) {
1408         
1409                         // Something else we don't know about so append
1410                         // to the tokens variable.
1411                 
1412                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1413                 
1414                                 if (FirstToken == TRUE){
1415         
1416                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1417                                         FirstToken = FALSE;
1418         
1419                                 } else {
1420         
1421                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1422         
1423                                 }
1424                                 
1425                         }
1426                         
1427                 }
1429         }       
1431         // Add the data to the variables and form.
1432         
1433         if (AnniversaryText == FALSE){
1434         
1435                 Anniversary = PropertySeg2;
1437         }
1438         
1439         if (!PropertyTokens.IsEmpty()){
1440         
1441                 AnniversaryTokens = PropertyTokens;
1443         }
1447 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1449         std::map<int, int> SplitPoints;
1450         std::map<int, int> SplitLength;
1452         int intPrevValue = 4;
1453         int intPref = 0;                        
1454         
1455         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1456         
1457         intPrevValue = 3;
1458         
1459         PropertyType PropType = PROPERTY_NONE;
1460         
1461         // Look for type before continuing.
1462         
1463         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1464         
1465         intPrevValue = 3;
1466         
1467         std::map<int, wxString> *TZList = NULL;
1468         std::map<int, wxString> *TZListType = NULL;
1469         std::map<int, wxString> *TZListMediatype = NULL;
1470         std::map<int, wxString> *TZListAltID = NULL;
1471         std::map<int, wxString> *TZListPID = NULL;
1472         std::map<int, wxString> *TZListTokens = NULL;           
1473         std::map<int, int> *TZListPref = NULL;
1474         
1475         switch(PropType){
1476                 case PROPERTY_NONE:
1477                         TZList = &GeneralTZList;
1478                         TZListType = &GeneralTZListType;
1479                         TZListMediatype = &GeneralTZListMediatype;
1480                         TZListAltID = &GeneralTZListAltID;
1481                         TZListPID = &GeneralTZListPID;
1482                         TZListTokens = &GeneralTZListTokens;
1483                         TZListPref = &GeneralTZListPref;
1484                         break;
1485                 case PROPERTY_HOME:
1486                         TZList = &HomeTZList;
1487                         TZListType = &HomeTZListType;
1488                         TZListMediatype = &HomeTZListMediatype;
1489                         TZListAltID = &HomeTZListAltID;
1490                         TZListPID = &HomeTZListPID;
1491                         TZListTokens = &HomeTZListTokens;
1492                         TZListPref = &HomeTZListPref;
1493                         break;
1494                 case PROPERTY_WORK:
1495                         TZList = &BusinessTZList;
1496                         TZListType = &BusinessTZListType;
1497                         TZListMediatype = &BusinessTZListMediatype;
1498                         TZListAltID = &BusinessTZListAltID;
1499                         TZListPID = &BusinessTZListPID;
1500                         TZListTokens = &BusinessTZListTokens;
1501                         TZListPref = &BusinessTZListPref;
1502                         break;
1503         }
1504         
1505         std::map<int, int>::iterator SLiter;    
1506         wxString PropertyData;
1507         wxString PropertyName;
1508         wxString PropertyValue;
1509         wxString PropertyTokens;
1510         bool FirstToken = TRUE;
1511         
1512         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1513         intiter != SplitPoints.end(); ++intiter){
1514         
1515                 SLiter = SplitLength.find(intiter->first);
1516         
1517                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1518                 
1519                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1520                 PropertyName = PropertyElement.GetNextToken();                          
1521                 PropertyValue = PropertyElement.GetNextToken();
1522                 
1523                 intPrevValue = intiter->second;
1524                 
1525                 CaptureString(&PropertyValue, FALSE);
1527                 if (PropertyName == wxT("ALTID")){
1529                         TZListAltID->erase(*TimeZoneCount);
1530                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1531                 
1532                 } else if (PropertyName == wxT("PID")){
1534                         TZListPID->erase(*TimeZoneCount);
1535                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1537                 } else if (PropertyName == wxT("PREF")){
1539                         int PriorityNumber = 0;
1540                         bool ValidNumber = TRUE;
1541                         
1542                         try{
1543                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1544                         }
1545                         
1546                         catch(std::invalid_argument &e){
1547                                 ValidNumber = FALSE;
1548                         }
1550                         if (ValidNumber == TRUE){
1552                                 TZListPref->erase(*TimeZoneCount);
1553                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1555                         }
1556                 
1557                 } else if (PropertyName == wxT("MEDIATYPE")){
1559                         TZListMediatype->erase(*TimeZoneCount);
1560                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1562                 } else {
1563                 
1564                         // Something else we don't know about so append
1565                         // to the tokens variable.
1566                 
1567                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1568                 
1569                                 if (FirstToken == TRUE){
1570                         
1571                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1572                                         FirstToken = FALSE;
1573                         
1574                                 } else {
1575                         
1576                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1577                         
1578                                 }
1579                 
1580                         }
1581                 
1582                 }
1583                 
1584         }
1585         
1586         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1587         
1588         // Add the name token data.
1589         
1590         if (!PropertyTokens.IsEmpty()){
1591         
1592                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1593         
1594         }
1599 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1601         size_t intPropertyLen = PropertySeg1.Len();
1602         std::map<int, int> SplitPoints;
1603         std::map<int, int> SplitLength;
1604         std::map<int, int>::iterator SLiter;                    
1605         wxString PropertyData;
1606         wxString PropertyName;
1607         wxString PropertyValue;
1608         wxString PropertyTokens;
1609         wxString AddressLabel;
1610         wxString AddressLang;
1611         wxString AddressAltID;
1612         wxString AddressPID;
1613         wxString AddressTokens;
1614         wxString AddressGeo;
1615         wxString AddressTimezone;
1616         wxString AddressType;
1617         wxString AddressMediatype;
1618         wxString AddressPOBox;
1619         wxString AddressExtended;
1620         wxString AddressStreet;
1621         wxString AddressLocality;
1622         wxString AddressCity;
1623         wxString AddressRegion;
1624         wxString AddressPostalCode;
1625         wxString AddressCountry;
1626         bool FirstToken = TRUE;                 
1627         int intSplitsFound = 0;
1628         int intSplitSize = 0;
1629         int intPrevValue = 5;
1630         int intPref = 0;                        
1631         int intType = 0;
1632         long ListCtrlIndex;
1633         
1634         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1635         
1636         intPrevValue = 4;
1637         
1638         PropertyType PropType = PROPERTY_NONE;
1639                 
1640         // Look for type before continuing.
1641         
1642         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1643         
1644         intPrevValue = 4;
1645         
1646         std::map<int, wxString> *AddressList = NULL;
1647         std::map<int, wxString> *AddressListTown = NULL;
1648         std::map<int, wxString> *AddressListCounty = NULL;
1649         std::map<int, wxString> *AddressListPostCode = NULL;
1650         std::map<int, wxString> *AddressListCountry = NULL;
1651         std::map<int, wxString> *AddressListLabel = NULL;
1652         std::map<int, wxString> *AddressListLang = NULL;                
1653         std::map<int, wxString> *AddressListAltID = NULL;
1654         std::map<int, wxString> *AddressListPID = NULL;
1655         std::map<int, wxString> *AddressListTokens = NULL;
1656         std::map<int, wxString> *AddressListGeo = NULL;
1657         std::map<int, wxString> *AddressListTimezone = NULL;            
1658         std::map<int, wxString> *AddressListType = NULL;
1659         std::map<int, wxString> *AddressListMediatype = NULL;
1660         std::map<int, int> *AddressListPref = NULL;
1662         switch(PropType){
1663                 case PROPERTY_NONE:
1664                         AddressList = &GeneralAddressList;
1665                         AddressListTown = &GeneralAddressListTown;
1666                         AddressListCounty = &GeneralAddressListCounty;
1667                         AddressListPostCode = &GeneralAddressListPostCode;
1668                         AddressListCountry = &GeneralAddressListCountry;
1669                         AddressListLabel = &GeneralAddressListLabel;
1670                         AddressListLang = &GeneralAddressListLang;              
1671                         AddressListAltID = &GeneralAddressListAltID;
1672                         AddressListPID = &GeneralAddressListPID;
1673                         AddressListTokens = &GeneralAddressListTokens;
1674                         AddressListGeo = &GeneralAddressListGeo;
1675                         AddressListTimezone = &GeneralAddressListTimezone;
1676                         AddressListType = &GeneralAddressListType;
1677                         AddressListMediatype = &GeneralAddressListMediatype;
1678                         AddressListPref = &GeneralAddressListPref;              
1679                         break;
1680                 case PROPERTY_HOME:
1681                         AddressList = &HomeAddressList;
1682                         AddressListTown = &HomeAddressListTown;
1683                         AddressListCounty = &HomeAddressListCounty;
1684                         AddressListPostCode = &HomeAddressListPostCode;
1685                         AddressListCountry = &HomeAddressListCountry;
1686                         AddressListLabel = &HomeAddressListLabel;
1687                         AddressListLang = &HomeAddressListLang;         
1688                         AddressListAltID = &HomeAddressListAltID;
1689                         AddressListPID = &HomeAddressListPID;
1690                         AddressListTokens = &HomeAddressListTokens;
1691                         AddressListGeo = &HomeAddressListGeo;
1692                         AddressListTimezone = &HomeAddressListTimezone;
1693                         AddressListType = &HomeAddressListType;
1694                         AddressListMediatype = &HomeAddressListMediatype;
1695                         AddressListPref = &HomeAddressListPref;
1696                         break;
1697                 case PROPERTY_WORK:
1698                         AddressList = &BusinessAddressList;
1699                         AddressListTown = &BusinessAddressListTown;
1700                         AddressListCounty = &BusinessAddressListCounty;
1701                         AddressListPostCode = &BusinessAddressListPostCode;
1702                         AddressListCountry = &BusinessAddressListCountry;
1703                         AddressListLabel = &BusinessAddressListLabel;
1704                         AddressListLang = &BusinessAddressListLang;             
1705                         AddressListAltID = &BusinessAddressListAltID;
1706                         AddressListPID = &BusinessAddressListPID;
1707                         AddressListTokens = &BusinessAddressListTokens;
1708                         AddressListGeo = &BusinessAddressListGeo;
1709                         AddressListTimezone = &BusinessAddressListTimezone;
1710                         AddressListType = &BusinessAddressListType;
1711                         AddressListMediatype = &BusinessAddressListMediatype;
1712                         AddressListPref = &BusinessAddressListPref;
1713                         break;
1714         }
1715         
1716         intPrevValue = 4;
1717         
1718         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1719         intiter != SplitPoints.end(); ++intiter){
1720         
1721                 SLiter = SplitLength.find(intiter->first);
1722         
1723                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1724                 
1725                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1726                 PropertyName = PropertyElement.GetNextToken();                          
1727                 PropertyValue = PropertyElement.GetNextToken();
1728                 
1729                 intPrevValue = intiter->second;
1730                 
1731                 CaptureString(&PropertyValue, FALSE);
1732                 
1733                 // Process properties.
1734                 
1735                 if (PropertyName == wxT("LABEL")){
1736                 
1737                         AddressListLabel->erase(*AddressCount);
1738                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1739                                 
1740                 } else if (PropertyName == wxT("LANGUAGE")){
1741                 
1742                         AddressListLang->erase(*AddressCount);
1743                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1744                 
1745                 } else if (PropertyName == wxT("ALTID")){
1747                         AddressListAltID->erase(*AddressCount);
1748                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1749                 
1750                 } else if (PropertyName == wxT("PID")){
1752                         AddressListPID->erase(*AddressCount);
1753                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1754                 
1755                 } else if (PropertyName == wxT("GEO")){
1756                 
1757                         AddressListGeo->erase(*AddressCount);
1758                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1759                 
1760                 } else if (PropertyName == wxT("TZ")){
1762                         AddressListTimezone->erase(*AddressCount);
1763                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1764                 
1765                 } else if (PropertyName == wxT("MEDIATYPE")){
1767                         AddressListMediatype->erase(*AddressCount);
1768                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1769                 
1770                 } else if (PropertyName == wxT("PREF")){
1771                         
1772                         int PriorityNumber = 0;
1773                         bool ValidNumber = TRUE;
1774                         
1775                         try{
1776                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1777                         }
1778                         
1779                         catch(std::invalid_argument &e){
1780                                 ValidNumber = FALSE;
1781                         }
1783                         if (ValidNumber == TRUE){
1785                                 AddressListPref->erase(*AddressCount);
1786                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1788                         }
1789                 
1790                 } else {
1791                 
1792                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1793                         
1794                                 if (FirstToken == TRUE){
1795                                 
1796                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1797                                         FirstToken = FALSE;
1798                                 
1799                                 } else {
1800                                 
1801                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1802                                 
1803                                 }
1804                         
1805                         }
1806                 
1807                 }
1808         
1809         }                       
1810         
1811         // Split the address. 
1813         //std::map<int, int>::iterator SLiter;
1814         intPropertyLen = PropertySeg2.Len();
1815         SplitPoints.clear();
1816         SplitLength.clear();
1817         intSplitsFound = 0;
1818         intSplitSize = 0;
1819         intPrevValue = 0;
1820         
1821         for (int i = 0; i <= intPropertyLen; i++){
1823                 intSplitSize++;
1824         
1825                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1826         
1827                         intSplitsFound++;
1828                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1829                         
1830                         if (intSplitsFound == 6){ 
1831                         
1832                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1833                                 break; 
1834                                 
1835                         } else {
1836                         
1837                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1838                         
1839                         }
1840                         
1841                         intSplitSize = 0;                                       
1842         
1843                 }
1845         }
1846         
1847         // Split the data into several parts.                   
1848         
1849         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1850         intiter != SplitPoints.end(); ++intiter){
1851                         
1852                 if (intiter->first == 1){
1853                 
1854                         // Deal with PO Box.
1855                         
1856                         SLiter = SplitLength.find(1);
1857                                                                 
1858                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1859                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1860                         intPrevValue = intiter->second;
1861                 
1862                 } else if (intiter->first == 2){
1863                 
1864                         // Deal with extended address.
1865                         
1866                         SLiter = SplitLength.find(2);
1867                         
1868                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1869                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1870                         intPrevValue = intiter->second;
1871                 
1872                 } else if (intiter->first == 3){
1873                 
1874                         // Deal with street address.
1875                         
1876                         SLiter = SplitLength.find(3);
1877                                                                 
1878                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1879                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1880                         intPrevValue = intiter->second;
1881                 
1882                 } else if (intiter->first == 4){
1883                 
1884                         // Deal with locality
1886                         SLiter = SplitLength.find(4);
1887                         
1888                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1889                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1890                         intPrevValue = intiter->second;
1891                         
1892                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1893                 
1894                 } else if (intiter->first == 5){
1895                 
1896                         // Deal with region.
1898                         SLiter = SplitLength.find(5);
1899                         
1900                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1901                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1902                         intPrevValue = intiter->second;
1903                         
1904                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1905                 
1906                 } else if (intiter->first == 6){
1907                 
1908                         // Deal with post code.
1910                         SLiter = SplitLength.find(6);
1911                         
1912                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1913                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1914                         intPrevValue = intiter->second;
1915                         
1916                         // Deal with country.
1917                                                 
1918                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1919                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1920                         
1921                         break;
1922                 
1923                 }
1924         
1925         }       
1926         
1927         // Add the data to the General/Home/Work address variables.
1928         
1929         CaptureString(&AddressStreet, FALSE); 
1930         CaptureString(&AddressLocality, FALSE);
1931         CaptureString(&AddressRegion, FALSE);
1932         CaptureString(&AddressPostalCode, FALSE);
1933         CaptureString(&AddressCountry, FALSE);
1934                 
1935         if (!PropertyTokens.IsEmpty()){
1936         
1937                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1938         
1939         }
1941         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1942         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1943         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1944         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1945         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1947         switch(PropType){
1948                 case PROPERTY_NONE:
1949                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1950                         break;
1951                 case PROPERTY_HOME:
1952                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1953                         break;
1954                 case PROPERTY_WORK:
1955                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1956                         break;
1957         }
1958         
1959         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1963 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1965         std::map<int, int> SplitPoints;
1966         std::map<int, int> SplitLength;
1968         int intPrevValue = 7;
1969         int intPref = 0;                        
1970         
1971         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1972         
1973         intPrevValue = 6;
1974         
1975         PropertyType PropType = PROPERTY_NONE;
1976                 
1977         // Look for type before continuing.
1978         
1979         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1980         
1981         std::map<int, wxString> *EmailList = NULL;
1982         std::map<int, wxString> *EmailListType = NULL;
1983         std::map<int, wxString> *EmailListAltID = NULL;
1984         std::map<int, wxString> *EmailListPID = NULL;
1985         std::map<int, wxString> *EmailListTokens = NULL;                
1986         std::map<int, int> *EmailListPref = NULL;
1988         switch(PropType){
1989                 case PROPERTY_NONE:
1990                         EmailList = &GeneralEmailList;
1991                         EmailListType = &GeneralEmailListType;
1992                         EmailListAltID = &GeneralEmailListAltID;
1993                         EmailListPID = &GeneralEmailListPID;
1994                         EmailListTokens = &GeneralEmailListTokens;              
1995                         EmailListPref = &GeneralEmailListPref;  
1996                         break;
1997                 case PROPERTY_HOME:
1998                         EmailList = &HomeEmailList;
1999                         EmailListType = &HomeEmailListType;
2000                         EmailListAltID = &HomeEmailListAltID;
2001                         EmailListPID = &HomeEmailListPID;
2002                         EmailListTokens = &HomeEmailListTokens;         
2003                         EmailListPref = &HomeEmailListPref;     
2004                         break;
2005                 case PROPERTY_WORK:
2006                         EmailList = &BusinessEmailList;
2007                         EmailListType = &BusinessEmailListType;
2008                         EmailListAltID = &BusinessEmailListAltID;
2009                         EmailListPID = &BusinessEmailListPID;
2010                         EmailListTokens = &BusinessEmailListTokens;             
2011                         EmailListPref = &BusinessEmailListPref; 
2012                         break;
2013         }
2014         
2015         intPrevValue = 6;
2016         
2017         std::map<int,int>::iterator SLiter;
2018         wxString PropertyData;
2019         wxString PropertyName;
2020         wxString PropertyValue;
2021         wxString PropertyTokens;
2022         bool FirstToken = TRUE;
2023         
2024         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2025         intiter != SplitPoints.end(); ++intiter){
2026         
2027                 SLiter = SplitLength.find(intiter->first);
2028         
2029                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2030                 
2031                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2032                 PropertyName = PropertyElement.GetNextToken();                          
2033                 PropertyValue = PropertyElement.GetNextToken();
2034                 
2035                 intPrevValue = intiter->second;
2036                 
2037                 CaptureString(&PropertyValue, FALSE);
2038                 
2039                 // Process properties.
2040                 
2041                 if (PropertyName == wxT("ALTID")){
2043                         EmailListAltID->erase(*EmailCount);
2044                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2045                 
2046                 } else if (PropertyName == wxT("PID")){
2048                         EmailListPID->erase(*EmailCount);
2049                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2050                 
2051                 } else if (PropertyName == wxT("PREF")){
2052                         
2053                         int PriorityNumber = 0;
2054                         bool ValidNumber = TRUE;
2055                         
2056                         try{
2057                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2058                         }
2059                         
2060                         catch(std::invalid_argument &e){
2061                                 ValidNumber = FALSE;
2062                         }
2064                         if (ValidNumber == TRUE){
2066                                 EmailListPref->erase(*EmailCount);
2067                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2069                         }
2070                 
2071                 } else {
2072                 
2073                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2074                         
2075                                 if (FirstToken == TRUE){
2076                                 
2077                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2078                                         FirstToken = FALSE;
2079                                 
2080                                 } else {
2081                                 
2082                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2083                                 
2084                                 }
2085                         
2086                         }
2087                 
2088                 }
2089         
2090         }
2091         
2092         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2093         
2094         // Add the name token data.
2095         
2096         if (!PropertyTokens.IsEmpty()){
2097         
2098                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2099         
2100         }       
2105 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2107         std::map<int, int> SplitPoints;
2108         std::map<int, int> SplitLength;
2110         int intPrevValue = 6;
2111         int intPref = 0;                        
2112         
2113         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2114         
2115         intPrevValue = 5;
2116         
2117         PropertyType PropType = PROPERTY_NONE;
2118                 
2119         // Look for type before continuing.
2120         
2121         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2122         
2123         std::map<int, wxString> *IMList = NULL;
2124         std::map<int, wxString> *IMListType = NULL;
2125         std::map<int, wxString> *IMListAltID = NULL;
2126         std::map<int, wxString> *IMListPID = NULL;
2127         std::map<int, wxString> *IMListTokens = NULL;
2128         std::map<int, wxString> *IMListMediatype = NULL;        
2129         std::map<int, int> *IMListPref = NULL;
2131         switch(PropType){
2132                 case PROPERTY_NONE:
2133                         IMList = &GeneralIMList;
2134                         IMListType = &GeneralIMListType;
2135                         IMListAltID = &GeneralIMListAltID;
2136                         IMListPID = &GeneralIMListPID;
2137                         IMListTokens = &GeneralIMListTokens;
2138                         IMListMediatype = &GeneralIMListMediatype;
2139                         IMListPref = &GeneralIMListPref;        
2140                         break;
2141                 case PROPERTY_HOME:
2142                         IMList = &HomeIMList;
2143                         IMListType = &HomeIMListType;
2144                         IMListAltID = &HomeIMListAltID;
2145                         IMListPID = &HomeIMListPID;
2146                         IMListTokens = &HomeIMListTokens;
2147                         IMListMediatype = &HomeIMListMediatype;         
2148                         IMListPref = &HomeIMListPref;   
2149                         break;
2150                 case PROPERTY_WORK:
2151                         IMList = &BusinessIMList;
2152                         IMListType = &BusinessIMListType;
2153                         IMListAltID = &BusinessIMListAltID;
2154                         IMListPID = &BusinessIMListPID;
2155                         IMListTokens = &BusinessIMListTokens;   
2156                         IMListMediatype = &BusinessIMListMediatype;     
2157                         IMListPref = &BusinessIMListPref;       
2158                         break;
2159         }
2160         
2161         intPrevValue = 5;
2162         
2163         std::map<int,int>::iterator SLiter;
2164         wxString PropertyData;
2165         wxString PropertyName;
2166         wxString PropertyValue;
2167         wxString PropertyTokens;
2168         bool FirstToken = TRUE;
2169         
2170         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2171         intiter != SplitPoints.end(); ++intiter){
2172         
2173                 SLiter = SplitLength.find(intiter->first);
2174         
2175                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2176                 
2177                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2178                 PropertyName = PropertyElement.GetNextToken();                          
2179                 PropertyValue = PropertyElement.GetNextToken();
2180                 
2181                 intPrevValue = intiter->second;
2182                 
2183                 CaptureString(&PropertyValue, FALSE);
2184                 
2185                 // Process properties.
2186                 
2187                 if (PropertyName == wxT("ALTID")){
2189                         IMListAltID->erase(*IMCount);
2190                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2191                 
2192                 } else if (PropertyName == wxT("PID")){
2194                         IMListPID->erase(*IMCount);
2195                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2196                 
2197                 } else if (PropertyName == wxT("MEDIATYPE")){
2199                         IMListMediatype->erase(*IMCount);
2200                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2201                 
2202                 } else if (PropertyName == wxT("PREF")){
2203                         
2204                         int PriorityNumber = 0;
2205                         bool ValidNumber = TRUE;
2206                         
2207                         try{
2208                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2209                         }
2210                         
2211                         catch(std::invalid_argument &e){
2212                                 ValidNumber = FALSE;
2213                         }
2215                         if (ValidNumber == TRUE){
2217                                 IMListPref->erase(*IMCount);
2218                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2220                         }
2221                 
2222                 } else {
2223                 
2224                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2225                         
2226                                 if (FirstToken == TRUE){
2227                                 
2228                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2229                                         FirstToken = FALSE;
2230                                 
2231                                 } else {
2232                                 
2233                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2234                                 
2235                                 }
2236                         
2237                         }
2238                 
2239                 }
2240         
2241         }
2242                 
2243         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2244         
2245         // Add the name token data.
2246         
2247         if (!PropertyTokens.IsEmpty()){
2248         
2249                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2250         
2251         }
2255 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2257         std::map<int, int> SplitPoints;
2258         std::map<int, int> SplitLength;
2259         std::map<int, int>::iterator SLiter;
2260         
2261         int intPref = 0;
2262         
2263         PropertyType PropType = PROPERTY_NONE;
2264                 
2265         // Look for type before continuing.
2266         
2267         wxString TelTypeUI;
2268         wxString TelTypeDetail;
2269         wxString PropertyData;
2270         wxString PropertyName;
2271         wxString PropertyValue;
2272         wxString PropertyTokens;
2273         
2274         std::map<int,int> TypeSplitPoints;
2275         std::map<int,int> TypeSplitLength;
2276         std::map<int,int>::iterator TSLiter;
2277         
2278         int intSplitSize = 0;
2279         int intSplitsFound = 0;
2280         int intSplitPoint = 0;
2281         int intType = 0;
2282         int intPrevValue = 5;
2283                 
2284         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2285         
2286         intPrevValue = 4;
2287         
2288         // Look for type before continuing.
2289         
2290         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2291         intiter != SplitPoints.end(); ++intiter){
2292         
2293                 SLiter = SplitLength.find(intiter->first);
2294         
2295                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2296                 
2297                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2298                 PropertyName = PropertyElement.GetNextToken();                          
2299                 PropertyValue = PropertyElement.GetNextToken();
2300                 
2301                 intPrevValue = intiter->second;
2303                 if (PropertyName == wxT("TYPE")){
2304                 
2305                         // Process each value in type and translate each
2306                         // part.
2307                 
2308                         // Strip out the quotes if they are there.
2309                 
2310                         size_t intPropertyValueLen = PropertyValue.Len();
2311                 
2312                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2313                         
2314                                 PropertyValue.Trim();
2315                                 PropertyValue.RemoveLast();
2316                         
2317                         }                               
2318                 
2319                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2320                         
2321                                 PropertyValue.Remove(0, 1);
2322                         
2323                         }
2324                         
2325                         TelTypeDetail = PropertyValue;
2326                         
2327                         intSplitSize = 0;
2328                         intSplitsFound = 0;
2329                         intSplitPoint = 0;
2330                         
2331                         for (int i = 0; i <= intPropertyValueLen; i++){
2332         
2333                                 intSplitSize++;
2334         
2335                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2336         
2337                                         if (intSplitsFound == 0){
2339                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2340                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2341                         
2342                                         } else {
2343                         
2344                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2345                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2346                         
2347                                         }                       
2349                                         intSplitsFound++;
2350                                         i++;
2351                                         intSplitPoint = i;
2352                                         intSplitSize = 0;
2353         
2354                                 }
2355         
2356                         }
2357                         
2358                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2359                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2360                 
2361                         int intTypeSeek = 0;
2362                 
2363                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2364                         typeiter != TypeSplitPoints.end(); ++typeiter){
2365                         
2366                                 wxString TypePropertyName;
2367                                 
2368                                 TSLiter = TypeSplitLength.find(typeiter->first);
2369                                 
2370                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2371                                 
2372                                 if (intTypeSeek == 0){
2373                                 
2374                                 
2375                                 } else {
2376                                                                                 
2377                                         TelTypeUI.Append(wxT(","));                                                     
2378                                 
2379                                 }
2380                         
2381                                 if (TypePropertyName == wxT("home")){
2382                                 
2383                                         PropType = PROPERTY_HOME;
2384                                 
2385                                 } else if (TypePropertyName == wxT("work")){
2386                                 
2387                                         PropType = PROPERTY_WORK;
2388                                                                         
2389                                 }
2390                                 
2391                                 
2392                                 if (TypePropertyName == wxT("text")){
2393                                 
2394                                         TelTypeUI.Append(_("text"));
2395                                         intTypeSeek++;
2396                                 
2397                                 } else if (TypePropertyName == wxT("voice")){
2398                                 
2399                                         TelTypeUI.Append(_("voice"));
2400                                         intTypeSeek++;
2401                                 
2402                                 } else if (TypePropertyName == wxT("fax")){
2403                                 
2404                                         TelTypeUI.Append(_("fax"));
2405                                         intTypeSeek++;
2406                                 
2407                                 } else if (TypePropertyName == wxT("cell")){
2408                                 
2409                                         TelTypeUI.Append(_("mobile"));
2410                                         intTypeSeek++;
2411                                 
2412                                 } else if (TypePropertyName == wxT("video")){
2413                                 
2414                                         TelTypeUI.Append(_("video"));
2415                                         intTypeSeek++;
2416                                 
2417                                 } else if (TypePropertyName == wxT("pager")){
2418                                 
2419                                         TelTypeUI.Append(_("pager"));
2420                                         intTypeSeek++;
2421                                 
2422                                 } else if (TypePropertyName == wxT("textphone")){
2423                                 
2424                                         TelTypeUI.Append(_("textphone"));
2425                                         intTypeSeek++;
2426                                 
2427                                 }
2428                         
2429                         }
2430                 
2431                 }
2432                 
2433         }
2434         
2435         std::map<int, wxString> *TelephoneList = NULL;
2436         std::map<int, wxString> *TelephoneListType = NULL;
2437         std::map<int, wxString> *TelephoneListAltID = NULL;
2438         std::map<int, wxString> *TelephoneListPID = NULL;
2439         std::map<int, wxString> *TelephoneListTokens = NULL;
2440         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2441         std::map<int, int> *TelephoneListPref = NULL;
2443         switch(PropType){
2444                 case PROPERTY_NONE:
2445                         TelephoneList = &GeneralTelephoneList;
2446                         TelephoneListType = &GeneralTelephoneListType;
2447                         TelephoneListAltID = &GeneralTelephoneListAltID;
2448                         TelephoneListPID = &GeneralTelephoneListPID;
2449                         TelephoneListTokens = &GeneralTelephoneListTokens;
2450                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2451                         TelephoneListPref = &GeneralTelephoneListPref;  
2452                         break;
2453                 case PROPERTY_HOME:
2454                         TelephoneList = &HomeTelephoneList;
2455                         TelephoneListType = &HomeTelephoneListType;
2456                         TelephoneListAltID = &HomeTelephoneListAltID;
2457                         TelephoneListPID = &HomeTelephoneListPID;
2458                         TelephoneListTokens = &HomeTelephoneListTokens;
2459                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2460                         TelephoneListPref = &HomeTelephoneListPref;     
2461                         break;
2462                 case PROPERTY_WORK:
2463                         TelephoneList = &BusinessTelephoneList;
2464                         TelephoneListType = &BusinessTelephoneListType;
2465                         TelephoneListAltID = &BusinessTelephoneListAltID;
2466                         TelephoneListPID = &BusinessTelephoneListPID;
2467                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2468                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2469                         TelephoneListPref = &BusinessTelephoneListPref; 
2470                         break;
2471         }
2472                 
2473         // Process the properties.
2474         
2475         bool FirstToken = TRUE;
2476         
2477         intPrevValue = 5;
2478         SplitPoints.clear();
2479         SplitLength.clear();
2481         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2483         intPrevValue = 4;
2484         
2485         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2486         intiter != SplitPoints.end(); ++intiter){
2487         
2488                 SLiter = SplitLength.find(intiter->first);
2489         
2490                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2491                 
2492                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2493                 PropertyName = PropertyElement.GetNextToken();                          
2494                 PropertyValue = PropertyElement.GetNextToken();
2495                 
2496                 intPrevValue = intiter->second;
2497                 
2498                 CaptureString(&PropertyValue, FALSE);
2499                 
2500                 // Process properties.
2501                 
2502                 if (PropertyName == wxT("ALTID")){
2504                         TelephoneListAltID->erase(*TelephoneCount);
2505                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2506                 
2507                 } else if (PropertyName == wxT("PID")){
2509                         TelephoneListPID->erase(*TelephoneCount);
2510                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2511                 
2512                 } else if (PropertyName == wxT("PREF")){
2513                         
2514                         int PriorityNumber = 0;
2515                         bool ValidNumber = TRUE;
2516                         
2517                         try{
2518                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2519                         }
2520                         
2521                         catch(std::invalid_argument &e){
2522                                 ValidNumber = FALSE;
2523                         }
2525                         if (ValidNumber == TRUE){
2527                                 TelephoneListPref->erase(*TelephoneCount);
2528                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2530                         }
2531                 
2532                 } else {
2533                 
2534                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2535                         
2536                                 if (FirstToken == TRUE){
2537                                 
2538                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2539                                         FirstToken = FALSE;
2540                                 
2541                                 } else {
2542                                 
2543                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2544                                 
2545                                 }
2546                         
2547                         }
2548                 
2549                 }
2550         
2551         }
2552                 
2553         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2554         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2555         
2556         // Add the name token data.
2557         
2558         if (!PropertyTokens.IsEmpty()){
2559         
2560                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2561         
2562         }
2566 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2568         std::map<int, int> SplitPoints;
2569         std::map<int, int> SplitLength;
2571         int intPrevValue = 6;
2572         int intPref = 0;                        
2573         
2574         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2575         
2576         intPrevValue = 5;
2577         
2578         PropertyType PropType = PROPERTY_NONE;
2579                 
2580         // Look for type before continuing.
2581         
2582         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2583         
2584         std::map<int, wxString> *LanguageList = NULL;
2585         std::map<int, wxString> *LanguageListType = NULL;
2586         std::map<int, wxString> *LanguageListAltID = NULL;
2587         std::map<int, wxString> *LanguageListPID = NULL;
2588         std::map<int, wxString> *LanguageListTokens = NULL;
2589         std::map<int, int> *LanguageListPref = NULL;
2591         switch(PropType){
2592                 case PROPERTY_NONE:
2593                         LanguageList = &GeneralLanguageList;
2594                         LanguageListType = &GeneralLanguageListType;
2595                         LanguageListAltID = &GeneralLanguageListAltID;
2596                         LanguageListPID = &GeneralLanguageListPID;
2597                         LanguageListTokens = &GeneralLanguageListTokens;
2598                         LanguageListPref = &GeneralLanguageListPref;    
2599                         break;
2600                 case PROPERTY_HOME:
2601                         LanguageList = &HomeLanguageList;
2602                         LanguageListType = &HomeLanguageListType;
2603                         LanguageListAltID = &HomeLanguageListAltID;
2604                         LanguageListPID = &HomeLanguageListPID;
2605                         LanguageListTokens = &HomeLanguageListTokens;   
2606                         LanguageListPref = &HomeLanguageListPref;       
2607                         break;
2608                 case PROPERTY_WORK:
2609                         LanguageList = &BusinessLanguageList;
2610                         LanguageListType = &BusinessLanguageListType;
2611                         LanguageListAltID = &BusinessLanguageListAltID;
2612                         LanguageListPID = &BusinessLanguageListPID;
2613                         LanguageListTokens = &BusinessLanguageListTokens;       
2614                         LanguageListPref = &BusinessLanguageListPref;
2615                         break;
2616         }
2617         
2618         intPrevValue = 5;
2619         
2620         std::map<int,int>::iterator SLiter;
2621         wxString PropertyData;
2622         wxString PropertyName;
2623         wxString PropertyValue;
2624         wxString PropertyTokens;
2625         bool FirstToken = TRUE;
2626         
2627         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2628         intiter != SplitPoints.end(); ++intiter){
2629         
2630                 SLiter = SplitLength.find(intiter->first);
2631         
2632                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2633                 
2634                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2635                 PropertyName = PropertyElement.GetNextToken();                          
2636                 PropertyValue = PropertyElement.GetNextToken();
2637                 
2638                 intPrevValue = intiter->second;
2639                 
2640                 CaptureString(&PropertyValue, FALSE);
2641                 
2642                 // Process properties.
2643                 
2644                 if (PropertyName == wxT("ALTID")){
2646                         LanguageListAltID->erase(*LanguageCount);
2647                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2648                 
2649                 } else if (PropertyName == wxT("PID")){
2651                         LanguageListPID->erase(*LanguageCount);
2652                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2653                 
2654                 } else if (PropertyName == wxT("PREF")){
2655                         
2656                         int PriorityNumber = 0;
2657                         bool ValidNumber = TRUE;
2658                         
2659                         try{
2660                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2661                         }
2662                         
2663                         catch(std::invalid_argument &e){
2664                                 ValidNumber = FALSE;
2665                         }
2667                         if (ValidNumber == TRUE){
2669                                 LanguageListPref->erase(*LanguageCount);
2670                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2672                         }
2673                 
2674                 } else {
2675                 
2676                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2677                         
2678                                 if (FirstToken == TRUE){
2679                                 
2680                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2681                                         FirstToken = FALSE;
2682                                 
2683                                 } else {
2684                                 
2685                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2686                                 
2687                                 }
2688                         
2689                         }
2690                 
2691                 }
2692         
2693         }
2694                 
2695         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2696         
2697         // Add the name token data.
2698         
2699         if (!PropertyTokens.IsEmpty()){
2700         
2701                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2702         
2703         }
2707 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2709         std::map<int, int> SplitPoints;
2710         std::map<int, int> SplitLength;
2712         int intPrevValue = 5;
2713         int intPref = 0;                        
2714         
2715         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2716         
2717         intPrevValue = 4;
2718         
2719         PropertyType PropType = PROPERTY_NONE;
2720                 
2721         // Look for type before continuing.
2722         
2723         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2724         
2725         std::map<int, wxString> *GeopositionList = NULL;
2726         std::map<int, wxString> *GeopositionListType = NULL;
2727         std::map<int, wxString> *GeopositionListAltID = NULL;
2728         std::map<int, wxString> *GeopositionListPID = NULL;
2729         std::map<int, wxString> *GeopositionListTokens = NULL;
2730         std::map<int, wxString> *GeopositionListMediatype = NULL;
2731         std::map<int, int> *GeopositionListPref = NULL;
2733         switch(PropType){
2734                 case PROPERTY_NONE:
2735                         GeopositionList = &GeneralGeographyList;
2736                         GeopositionListType = &GeneralGeographyListType;
2737                         GeopositionListAltID = &GeneralGeographyListAltID;
2738                         GeopositionListPID = &GeneralGeographyListPID;
2739                         GeopositionListTokens = &GeneralGeographyListTokens;
2740                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2741                         GeopositionListPref = &GeneralGeographyListPref;        
2742                         break;
2743                 case PROPERTY_HOME:
2744                         GeopositionList = &HomeGeographyList;
2745                         GeopositionListType = &HomeGeographyListType;
2746                         GeopositionListAltID = &HomeGeographyListAltID;
2747                         GeopositionListPID = &HomeGeographyListPID;
2748                         GeopositionListTokens = &HomeGeographyListTokens;
2749                         GeopositionListMediatype = &HomeGeographyListMediatype;
2750                         GeopositionListPref = &HomeGeographyListPref;   
2751                         break;
2752                 case PROPERTY_WORK:
2753                         GeopositionList = &BusinessGeographyList;
2754                         GeopositionListType = &BusinessGeographyListType;
2755                         GeopositionListAltID = &BusinessGeographyListAltID;
2756                         GeopositionListPID = &BusinessGeographyListPID;
2757                         GeopositionListTokens = &BusinessGeographyListTokens;
2758                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2759                         GeopositionListPref = &BusinessGeographyListPref;
2760                         break;
2761         }
2762         
2763         intPrevValue = 4;
2764         
2765         std::map<int,int>::iterator SLiter;
2766         wxString PropertyData;
2767         wxString PropertyName;
2768         wxString PropertyValue;
2769         wxString PropertyTokens;
2770         bool FirstToken = TRUE;
2771         
2772         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2773         intiter != SplitPoints.end(); ++intiter){
2774         
2775                 SLiter = SplitLength.find(intiter->first);
2776         
2777                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2778                 
2779                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2780                 PropertyName = PropertyElement.GetNextToken();                          
2781                 PropertyValue = PropertyElement.GetNextToken();
2782                 
2783                 intPrevValue = intiter->second;
2784                 
2785                 CaptureString(&PropertyValue, FALSE);
2786                 
2787                 // Process properties.
2788                 
2789                 if (PropertyName == wxT("ALTID")){
2791                         GeopositionListAltID->erase(*GeographicCount);
2792                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2793                 
2794                 } else if (PropertyName == wxT("PID")){
2796                         GeopositionListPID->erase(*GeographicCount);
2797                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2798                 
2799                 } else if (PropertyName == wxT("MEDIATYPE")){
2801                         GeopositionListMediatype->erase(*GeographicCount);
2802                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2803                 
2804                 } else if (PropertyName == wxT("PREF")){
2805                         
2806                         int PriorityNumber = 0;
2807                         bool ValidNumber = TRUE;
2808                         
2809                         try{
2810                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2811                         }
2812                         
2813                         catch(std::invalid_argument &e){
2814                                 ValidNumber = FALSE;
2815                         }
2817                         if (ValidNumber == TRUE){
2819                                 GeopositionListPref->erase(*GeographicCount);
2820                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2822                         }
2823                 
2824                 } else {
2825                 
2826                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2827                         
2828                                 if (FirstToken == TRUE){
2829                                 
2830                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2831                                         FirstToken = FALSE;
2832                                 
2833                                 } else {
2834                                 
2835                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2836                                 
2837                                 }
2838                         
2839                         }
2840                 
2841                 }
2842         
2843         }
2844                 
2845         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2846         
2847         // Add the name token data.
2848         
2849         if (!PropertyTokens.IsEmpty()){
2850         
2851                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2852         
2853         }
2857 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2859         size_t intPropertyLen = PropertySeg1.Len();
2860         std::map<int, int> SplitPoints;
2861         std::map<int, int> SplitLength;
2862         std::map<int, int>::iterator SLiter;                    
2863         wxString PropertyData;
2864         wxString PropertyName;
2865         wxString PropertyValue;
2866         wxString PropertyTokens;
2867         wxString RelatedType;
2868         wxString RelatedTypeOriginal;                   
2869         wxString RelatedName;
2870         bool FirstToken = TRUE;                 
2871         int intSplitsFound = 0;
2872         int intSplitSize = 0;
2873         int intPrevValue = 9;
2874         int intPref = 0;
2875         long ListCtrlIndex;
2876         
2877         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2878         
2879         intPrevValue = 8;
2880         
2881         // Look for type before continuing.
2882         
2883         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2884         intiter != SplitPoints.end(); ++intiter){
2885         
2886                 SLiter = SplitLength.find(intiter->first);
2887         
2888                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2889                 
2890                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2891                 PropertyName = PropertyElement.GetNextToken();                          
2892                 PropertyValue = PropertyElement.GetNextToken();
2893                 
2894                 intPrevValue = intiter->second;
2895                 
2896                 // Process these.
2897                 
2898                 RelatedTypeOriginal = PropertyValue;
2899                 
2900                 if (PropertyName == wxT("TYPE")){
2901                 
2902                         if (PropertyValue == wxT("contact")){
2904                                 RelatedType = _("Contact");
2906                         } else if (PropertyValue == wxT("acquaintance")){
2908                                 RelatedType = _("Acquaintance");
2910                         } else if (PropertyValue == wxT("friend")){
2912                                 RelatedType = _("Friend");
2914                         } else if (PropertyValue == wxT("met")){
2916                                 RelatedType = _("Met");
2918                         } else if (PropertyValue == wxT("co-worker")){
2920                                 RelatedType = _("Co-worker");
2922                         } else if (PropertyValue == wxT("colleague")){
2924                                 RelatedType = _("Colleague");
2926                         } else if (PropertyValue == wxT("co-resident")){
2928                                 RelatedType = _("Co-resident");
2930                         } else if (PropertyValue == wxT("neighbor")){
2932                                 RelatedType = _("Neighbour");
2934                         } else if (PropertyValue == wxT("child")){
2936                                 RelatedType = _("Child");
2938                         } else if (PropertyValue == wxT("parent")){
2940                                 RelatedType = _("Parent");
2942                         } else if (PropertyValue == wxT("sibling")){
2944                                 RelatedType = _("Sibling");
2946                         } else if (PropertyValue == wxT("spouse")){
2948                                 RelatedType = _("Spouse");
2950                         } else if (PropertyValue == wxT("kin")){
2952                                 RelatedType = _("Kin");
2954                         } else if (PropertyValue == wxT("muse")){
2956                                 RelatedType = _("Muse");
2958                         } else if (PropertyValue == wxT("crush")){
2960                                 RelatedType = _("Crush");
2962                         } else if (PropertyValue == wxT("date")){
2964                                 RelatedType = _("Date");
2966                         } else if (PropertyValue == wxT("sweetheart")){
2968                                 RelatedType = _("Sweetheart");
2970                         } else if (PropertyValue == wxT("me")){
2972                                 RelatedType = _("Me");
2974                         } else if (PropertyValue == wxT("agent")){
2976                                 RelatedType = _("Agent");
2978                         } else if (PropertyValue == wxT("emergency")){
2980                                 RelatedType = _("Emergency");
2982                         } else {
2984                                 RelatedType = PropertyValue;
2986                         }
2987                 
2988                 }
2989         
2990         }
2991         
2992         intPrevValue = 8;                       
2993         
2994         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2995         intiter != SplitPoints.end(); ++intiter){
2996         
2997                 SLiter = SplitLength.find(intiter->first);
2998         
2999                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3000                 
3001                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3002                 PropertyName = PropertyElement.GetNextToken();                          
3003                 PropertyValue = PropertyElement.GetNextToken();
3004                 
3005                 intPrevValue = intiter->second;
3006                 
3007                 // Process properties.
3008                 
3009                 size_t intPropertyValueLen = PropertyValue.Len();
3010                 
3011                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3012                         
3013                         PropertyValue.Trim();
3014                         PropertyValue.RemoveLast();
3015                         
3016                 }                               
3017                 
3018                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3019                         
3020                         PropertyValue.Remove(0, 1);
3021                         
3022                 }
3023                 
3024                 CaptureString(&PropertyValue, FALSE);
3025                         
3026                 if (PropertyName == wxT("ALTID")){
3028                         GeneralRelatedListAltID.erase(*RelatedCount);
3029                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3030                 
3031                 } else if (PropertyName == wxT("PID")){
3033                         GeneralRelatedListPID.erase(*RelatedCount);
3034                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3035                 
3036                 } else if (PropertyName == wxT("PREF")){
3037                         
3038                         int PriorityNumber = 0;
3039                         bool ValidNumber = TRUE;
3040                         
3041                         try{
3042                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3043                         }
3044                         
3045                         catch(std::invalid_argument &e){
3046                                 ValidNumber = FALSE;
3047                         }
3049                         if (ValidNumber == TRUE){
3051                                 GeneralRelatedListPref.erase(*RelatedCount);
3052                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3054                         }
3055                 
3056                 } else if (PropertyName == wxT("LANGUAGE")){
3057                 
3058                         GeneralRelatedListLanguage.erase(*RelatedCount);
3059                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3060                 
3061                 } else if (PropertyName != wxT("TYPE")) {
3062                 
3063                         // Something else we don't know about so append
3064                         // to the tokens variable.
3065                 
3066                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3067                 
3068                                 if (FirstToken == TRUE){
3069                         
3070                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3071                                         FirstToken = FALSE;
3072                         
3073                                 } else {
3074                         
3075                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3076                         
3077                                 }
3078                 
3079                         }
3080                 
3081                 }
3082         
3083         }                                       
3084         
3085         // Add the data to the General/Home/Work address variables.
3086                                 
3087         GeneralRelatedList.erase(*RelatedCount);
3088         GeneralRelatedListRelType.erase(*RelatedCount);
3089         GeneralRelatedListType.erase(*RelatedCount);
3090         GeneralRelatedListTokens.erase(*RelatedCount);
3091         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3092         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3093         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3094         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3098 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3100         std::map<int, int> SplitPoints;
3101         std::map<int, int> SplitLength;
3102         std::map<int, int>::iterator SLiter;                    
3103         wxString PropertyData;
3104         wxString PropertyName;
3105         wxString PropertyValue;
3106         wxString PropertyTokens;
3107         bool FirstToken = TRUE;
3108         int intPrevValue = 5;
3109         int intPref = 0;                        
3110         int intType = 0;
3111         long ListCtrlIndex;
3112         
3113         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3114         
3115         intPrevValue = 4;
3116         
3117         PropertyType PropType = PROPERTY_NONE;
3118                 
3119         // Look for type before continuing.
3120         
3121         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3122         
3123         // Setup the pointers.
3124         
3125         std::map<int, wxString> *WebsiteList = NULL;
3126         std::map<int, wxString> *WebsiteListAltID = NULL;
3127         std::map<int, wxString> *WebsiteListPID = NULL;
3128         std::map<int, wxString> *WebsiteListType = NULL;
3129         std::map<int, wxString> *WebsiteListTokens = NULL;
3130         std::map<int, wxString> *WebsiteListMediatype = NULL;
3131         std::map<int, int> *WebsiteListPref = NULL;
3132         
3133         // Setup blank lines for later on.
3134         
3135         switch(PropType){
3136                 case PROPERTY_NONE:
3137                         WebsiteList = &GeneralWebsiteList;
3138                         WebsiteListType = &GeneralWebsiteListType;
3139                         WebsiteListAltID = &GeneralWebsiteListAltID;
3140                         WebsiteListPID = &GeneralWebsiteListPID;
3141                         WebsiteListTokens = &GeneralWebsiteListTokens;
3142                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3143                         WebsiteListPref = &GeneralWebsiteListPref;      
3144                         break;
3145                 case PROPERTY_HOME:
3146                         WebsiteList = &HomeWebsiteList;
3147                         WebsiteListType = &HomeWebsiteListType;
3148                         WebsiteListAltID = &HomeWebsiteListAltID;
3149                         WebsiteListPID = &HomeWebsiteListPID;
3150                         WebsiteListTokens = &HomeWebsiteListTokens;
3151                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3152                         WebsiteListPref = &HomeWebsiteListPref; 
3153                         break;
3154                 case PROPERTY_WORK:
3155                         WebsiteList = &BusinessWebsiteList;
3156                         WebsiteListType = &BusinessWebsiteListType;
3157                         WebsiteListAltID = &BusinessWebsiteListAltID;
3158                         WebsiteListPID = &BusinessWebsiteListPID;
3159                         WebsiteListTokens = &BusinessWebsiteListTokens;
3160                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3161                         WebsiteListPref = &BusinessWebsiteListPref;
3162                         break;
3163         }
3164         
3165         intPrevValue = 4;
3166         
3167         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3168         intiter != SplitPoints.end(); ++intiter){
3169         
3170                 SLiter = SplitLength.find(intiter->first);
3171         
3172                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3173                 
3174                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3175                 PropertyName = PropertyElement.GetNextToken();                          
3176                 PropertyValue = PropertyElement.GetNextToken();
3177                 
3178                 intPrevValue = intiter->second;
3179                 
3180                 // Process properties.
3181                 
3182                 size_t intPropertyValueLen = PropertyValue.Len();
3183                 
3184                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3185                         
3186                         PropertyValue.Trim();
3187                         PropertyValue.RemoveLast();
3188                         
3189                 }                               
3190                 
3191                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3192                         
3193                         PropertyValue.Remove(0, 1);
3194                         
3195                 }
3196                 
3197                 CaptureString(&PropertyValue, FALSE);
3198                 
3199                 if (PropertyName == wxT("ALTID")){
3201                         WebsiteListAltID->erase(*URLCount);
3202                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3203                 
3204                 } else if (PropertyName == wxT("PID")){
3206                         WebsiteListPID->erase(*URLCount);
3207                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3208                         
3209                 } else if (PropertyName == wxT("PREF")){
3210                         
3211                         int PriorityNumber = 0;
3212                         bool ValidNumber = TRUE;
3213                         
3214                         try{
3215                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3216                         }
3217                         
3218                         catch(std::invalid_argument &e){
3219                                 ValidNumber = FALSE;
3220                         }
3222                         if (ValidNumber == TRUE){
3224                                 WebsiteListPref->erase(*URLCount);
3225                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3227                         }
3228                                         
3229                 } else if (PropertyName == wxT("MEDIATYPE")){
3230                 
3231                         WebsiteListMediatype->erase(*URLCount);
3232                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3233                 
3234                 } else {
3235                 
3236                         // Something else we don't know about so append
3237                         // to the tokens variable.
3238                 
3239                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3240                 
3241                                 if (FirstToken == TRUE){
3242                         
3243                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3244                                         FirstToken = FALSE;
3245                         
3246                                 } else {
3247                         
3248                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3249                         
3250                                 }
3251                 
3252                         }
3253                 
3254                 }
3255         
3256         }
3257         
3258         // Add the data to the General/Home/Work address variables.
3259         
3260         CaptureString(&PropertySeg2, FALSE);
3261                         
3262         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3263         
3264         if (!PropertyTokens.IsEmpty()){
3265         
3266                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3267                         
3268         }
3269         
3272 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3274         std::map<int, int> SplitPoints;
3275         std::map<int, int> SplitLength;
3276         std::map<int, int>::iterator SLiter;                    
3277         wxString PropertyData;
3278         wxString PropertyName;
3279         wxString PropertyValue;
3280         wxString PropertyTokens;
3281         bool FirstToken = TRUE;
3282         int intPrevValue = 7;
3283         int intPref = 0;                        
3284         int intType = 0;
3285         long ListCtrlIndex;
3286         
3287         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3288         
3289         intPrevValue = 6;
3290         
3291         PropertyType PropType = PROPERTY_NONE;
3292                 
3293         // Look for type before continuing.
3294         
3295         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3296         
3297         // Setup the pointers.
3298         
3299         std::map<int, wxString> *TitleList = NULL;
3300         std::map<int, wxString> *TitleListAltID = NULL;
3301         std::map<int, wxString> *TitleListPID = NULL;
3302         std::map<int, wxString> *TitleListType = NULL;
3303         std::map<int, wxString> *TitleListTokens = NULL;
3304         std::map<int, wxString> *TitleListLanguage = NULL;
3305         std::map<int, int> *TitleListPref = NULL;
3306         
3307         // Setup blank lines for later on.
3308         
3309         switch(PropType){
3310                 case PROPERTY_NONE:
3311                         TitleList = &GeneralTitleList;
3312                         TitleListType = &GeneralTitleListType;
3313                         TitleListAltID = &GeneralTitleListAltID;
3314                         TitleListPID = &GeneralTitleListPID;
3315                         TitleListTokens = &GeneralTitleListTokens;
3316                         TitleListLanguage = &GeneralTitleListLanguage;
3317                         TitleListPref = &GeneralTitleListPref;  
3318                         break;
3319                 case PROPERTY_HOME:
3320                         TitleList = &HomeTitleList;
3321                         TitleListType = &HomeTitleListType;
3322                         TitleListAltID = &HomeTitleListAltID;
3323                         TitleListPID = &HomeTitleListPID;
3324                         TitleListTokens = &HomeTitleListTokens;
3325                         TitleListLanguage = &HomeTitleListLanguage;
3326                         TitleListPref = &HomeTitleListPref;     
3327                         break;
3328                 case PROPERTY_WORK:
3329                         TitleList = &BusinessTitleList;
3330                         TitleListType = &BusinessTitleListType;
3331                         TitleListAltID = &BusinessTitleListAltID;
3332                         TitleListPID = &BusinessTitleListPID;
3333                         TitleListTokens = &BusinessTitleListTokens;
3334                         TitleListLanguage = &BusinessTitleListLanguage; 
3335                         TitleListPref = &BusinessTitleListPref;
3336                         break;
3337         }
3339         intPrevValue = 6;
3340                 
3341         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3342         intiter != SplitPoints.end(); ++intiter){
3343         
3344                 SLiter = SplitLength.find(intiter->first);
3345         
3346                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3347                 
3348                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3349                 PropertyName = PropertyElement.GetNextToken();                          
3350                 PropertyValue = PropertyElement.GetNextToken();
3351                 
3352                 intPrevValue = intiter->second;
3353                 
3354                 // Process properties.
3355                 
3356                 size_t intPropertyValueLen = PropertyValue.Len();
3357                 
3358                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3359                         
3360                         PropertyValue.Trim();
3361                         PropertyValue.RemoveLast();
3362                         
3363                 }                               
3364                 
3365                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3366                         
3367                         PropertyValue.Remove(0, 1);
3368                         
3369                 }                               
3370                 
3371                 CaptureString(&PropertyValue, FALSE);
3372                 
3373                 if (PropertyName == wxT("ALTID")){
3374                 
3375                         TitleListAltID->erase(*TitleCount);
3376                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3377                 
3378                 } else if (PropertyName == wxT("PID")){
3380                         TitleListPID->erase(*TitleCount);
3381                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3382                 
3383                 } else if (PropertyName == wxT("PREF")){
3384                                 
3385                         int PriorityNumber = 0;
3386                         bool ValidNumber = TRUE;
3387                         
3388                         try{
3389                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3390                         }
3391                         
3392                         catch(std::invalid_argument &e){
3393                                 ValidNumber = FALSE;
3394                         }
3396                         if (ValidNumber == TRUE){
3398                                 TitleListPref->erase(*TitleCount);
3399                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3401                         }
3402                                         
3403                 } else if (PropertyName == wxT("LANGUAGE")){
3404                 
3405                         TitleListLanguage->erase(*TitleCount);
3406                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3407                 
3408                 } else {
3409                 
3410                         // Something else we don't know about so append
3411                         // to the tokens variable.
3412                 
3413                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3414                 
3415                                 if (FirstToken == TRUE){
3416                         
3417                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3418                                         FirstToken = FALSE;
3419                         
3420                                 } else {
3421                         
3422                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3423                         
3424                                 }
3425                 
3426                         }
3427                 
3428                 }
3429         
3430         }
3431         
3432         // Add the data to the General/Home/Work address variables.
3433         
3434         CaptureString(&PropertySeg2, FALSE);
3436         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3437         
3438         if (!PropertyTokens.IsEmpty()){
3439         
3440                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3441                         
3442         }
3446 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3448         std::map<int, int> SplitPoints;
3449         std::map<int, int> SplitLength;
3450         std::map<int, int>::iterator SLiter;                    
3451         wxString PropertyData;
3452         wxString PropertyName;
3453         wxString PropertyValue;
3454         wxString PropertyTokens;
3455         bool FirstToken = TRUE;
3456         int intPrevValue = 6;
3457         int intPref = 0;                        
3458         int intType = 0;
3459         long ListCtrlIndex;
3460         
3461         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3462         
3463         intPrevValue = 5;
3464         
3465         PropertyType PropType = PROPERTY_NONE;
3466                 
3467         // Look for type before continuing.
3468         
3469         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3470         
3471         // Setup the pointers.
3472         
3473         std::map<int, wxString> *RoleList = NULL;
3474         std::map<int, wxString> *RoleListAltID = NULL;
3475         std::map<int, wxString> *RoleListPID = NULL;
3476         std::map<int, wxString> *RoleListType = NULL;
3477         std::map<int, wxString> *RoleListTokens = NULL;
3478         std::map<int, wxString> *RoleListLanguage = NULL;
3479         std::map<int, int> *RoleListPref = NULL;
3480         
3481         // Setup blank lines for later on.
3482         
3483         switch(PropType){
3484                 case PROPERTY_NONE:
3485                         RoleList = &GeneralRoleList;
3486                         RoleListType = &GeneralRoleListType;
3487                         RoleListAltID = &GeneralRoleListAltID;
3488                         RoleListPID = &GeneralRoleListPID;
3489                         RoleListTokens = &GeneralRoleListTokens;
3490                         RoleListLanguage = &GeneralRoleListLanguage;
3491                         RoleListPref = &GeneralRoleListPref;    
3492                         break;
3493                 case PROPERTY_HOME:
3494                         RoleList = &HomeRoleList;
3495                         RoleListType = &HomeRoleListType;
3496                         RoleListAltID = &HomeRoleListAltID;
3497                         RoleListPID = &HomeRoleListPID;
3498                         RoleListTokens = &HomeRoleListTokens;
3499                         RoleListLanguage = &HomeRoleListLanguage;
3500                         RoleListPref = &HomeRoleListPref;       
3501                         break;
3502                 case PROPERTY_WORK:
3503                         RoleList = &BusinessRoleList;
3504                         RoleListType = &BusinessRoleListType;
3505                         RoleListAltID = &BusinessRoleListAltID;
3506                         RoleListPID = &BusinessRoleListPID;
3507                         RoleListTokens = &BusinessRoleListTokens;
3508                         RoleListLanguage = &BusinessRoleListLanguage;   
3509                         RoleListPref = &BusinessRoleListPref;
3510                         break;
3511         }
3513         intPrevValue = 5;
3514                 
3515         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3516         intiter != SplitPoints.end(); ++intiter){
3517         
3518                 SLiter = SplitLength.find(intiter->first);
3519         
3520                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3521                 
3522                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3523                 PropertyName = PropertyElement.GetNextToken();                          
3524                 PropertyValue = PropertyElement.GetNextToken();
3525                 
3526                 intPrevValue = intiter->second;
3527                 
3528                 // Process properties.
3529                 
3530                 size_t intPropertyValueLen = PropertyValue.Len();
3531                 
3532                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3533                         
3534                         PropertyValue.Trim();
3535                         PropertyValue.RemoveLast();
3536                         
3537                 }                               
3538                 
3539                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3540                         
3541                         PropertyValue.Remove(0, 1);
3542                         
3543                 }                               
3544                 
3545                 CaptureString(&PropertyValue, FALSE);
3546                 
3547                 if (PropertyName == wxT("ALTID")){
3548                 
3549                         RoleListAltID->erase(*RoleCount);
3550                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3551                 
3552                 } else if (PropertyName == wxT("PID")){
3554                         RoleListPID->erase(*RoleCount);
3555                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3556                 
3557                 } else if (PropertyName == wxT("PREF")){
3558                                 
3559                         int PriorityNumber = 0;
3560                         bool ValidNumber = TRUE;
3561                         
3562                         try{
3563                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3564                         }
3565                         
3566                         catch(std::invalid_argument &e){
3567                                 ValidNumber = FALSE;
3568                         }
3570                         if (ValidNumber == TRUE){
3572                                 RoleListPref->erase(*RoleCount);
3573                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3575                         }
3576                                         
3577                 } else if (PropertyName == wxT("LANGUAGE")){
3578                 
3579                         RoleListLanguage->erase(*RoleCount);
3580                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3581                 
3582                 } else {
3583                 
3584                         // Something else we don't know about so append
3585                         // to the tokens variable.
3586                 
3587                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3588                 
3589                                 if (FirstToken == TRUE){
3590                         
3591                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3592                                         FirstToken = FALSE;
3593                         
3594                                 } else {
3595                         
3596                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3597                         
3598                                 }
3599                 
3600                         }
3601                 
3602                 }
3603         
3604         }
3605         
3606         // Add the data to the General/Home/Work address variables.
3607         
3608         CaptureString(&PropertySeg2, FALSE);
3610         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3611         
3612         if (!PropertyTokens.IsEmpty()){
3613         
3614                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3615                         
3616         }
3620 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3622         std::map<int, int> SplitPoints;
3623         std::map<int, int> SplitLength;
3624         std::map<int, int>::iterator SLiter;                    
3625         wxString PropertyData;
3626         wxString PropertyName;
3627         wxString PropertyValue;
3628         wxString PropertyTokens;
3629         bool FirstToken = TRUE;
3630         int intPrevValue = 5;
3631         int intPref = 0;                        
3632         int intType = 0;
3633         long ListCtrlIndex;
3634         
3635         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3636         
3637         intPrevValue = 4;
3638         
3639         PropertyType PropType = PROPERTY_NONE;
3640                 
3641         // Look for type before continuing.
3642         
3643         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3644         
3645         // Setup the pointers.
3646         
3647         std::map<int, wxString> *OrganisationsList = NULL;
3648         std::map<int, wxString> *OrganisationsListAltID = NULL;
3649         std::map<int, wxString> *OrganisationsListPID = NULL;
3650         std::map<int, wxString> *OrganisationsListType = NULL;
3651         std::map<int, wxString> *OrganisationsListTokens = NULL;
3652         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3653         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3654         std::map<int, int> *OrganisationsListPref = NULL;
3655         
3656         // Setup blank lines for later on.
3657         
3658         switch(PropType){
3659                 case PROPERTY_NONE:
3660                         OrganisationsList = &GeneralOrganisationsList;
3661                         OrganisationsListType = &GeneralOrganisationsListType;
3662                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3663                         OrganisationsListPID = &GeneralOrganisationsListPID;
3664                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3665                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3666                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3667                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3668                         break;
3669                 case PROPERTY_HOME:
3670                         OrganisationsList = &HomeOrganisationsList;
3671                         OrganisationsListType = &HomeOrganisationsListType;
3672                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3673                         OrganisationsListPID = &HomeOrganisationsListPID;
3674                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3675                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3676                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3677                         OrganisationsListPref = &HomeOrganisationsListPref;     
3678                         break;
3679                 case PROPERTY_WORK:
3680                         OrganisationsList = &BusinessOrganisationsList;
3681                         OrganisationsListType = &BusinessOrganisationsListType;
3682                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3683                         OrganisationsListPID = &BusinessOrganisationsListPID;
3684                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3685                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3686                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3687                         OrganisationsListPref = &BusinessOrganisationsListPref;
3688                         break;
3689         }
3691         intPrevValue = 4;
3692                 
3693         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3694         intiter != SplitPoints.end(); ++intiter){
3695         
3696                 SLiter = SplitLength.find(intiter->first);
3697         
3698                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3699                 
3700                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3701                 PropertyName = PropertyElement.GetNextToken();                          
3702                 PropertyValue = PropertyElement.GetNextToken();
3703                 
3704                 intPrevValue = intiter->second;
3705                 
3706                 // Process properties.
3707                 
3708                 size_t intPropertyValueLen = PropertyValue.Len();
3709                 
3710                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3711                         
3712                         PropertyValue.Trim();
3713                         PropertyValue.RemoveLast();
3714                         
3715                 }                               
3716                 
3717                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3718                         
3719                         PropertyValue.Remove(0, 1);
3720                         
3721                 }                               
3722                 
3723                 CaptureString(&PropertyValue, FALSE);
3724                 
3725                 if (PropertyName == wxT("ALTID")){
3726                 
3727                         OrganisationsListAltID->erase(*OrganisationCount);
3728                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3729                 
3730                 } else if (PropertyName == wxT("PID")){
3732                         OrganisationsListPID->erase(*OrganisationCount);
3733                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3734                 
3735                 } else if (PropertyName == wxT("SORT-AS")){
3737                         OrganisationsListSortAs->erase(*OrganisationCount);
3738                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3739                 
3740                 } else if (PropertyName == wxT("PREF")){
3741                                 
3742                         int PriorityNumber = 0;
3743                         bool ValidNumber = TRUE;
3744                         
3745                         try{
3746                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3747                         }
3748                         
3749                         catch(std::invalid_argument &e){
3750                                 ValidNumber = FALSE;
3751                         }
3753                         if (ValidNumber == TRUE){
3755                                 OrganisationsListPref->erase(*OrganisationCount);
3756                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3758                         }
3759                                         
3760                 } else if (PropertyName == wxT("LANGUAGE")){
3761                 
3762                         OrganisationsListLanguage->erase(*OrganisationCount);
3763                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3764                 
3765                 } else {
3766                 
3767                         // Something else we don't know about so append
3768                         // to the tokens variable.
3769                 
3770                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3771                 
3772                                 if (FirstToken == TRUE){
3773                         
3774                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3775                                         FirstToken = FALSE;
3776                         
3777                                 } else {
3778                         
3779                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3780                         
3781                                 }
3782                 
3783                         }
3784                 
3785                 }
3786         
3787         }
3788         
3789         // Add the data to the General/Home/Work address variables.
3790         
3791         CaptureString(&PropertySeg2, FALSE);
3793         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3794         
3795         if (!PropertyTokens.IsEmpty()){
3796         
3797                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3798                         
3799         }
3803 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3805         std::map<int, int> SplitPoints;
3806         std::map<int, int> SplitLength;
3807         std::map<int, int>::iterator SLiter;                    
3808         wxString PropertyData;
3809         wxString PropertyName;
3810         wxString PropertyValue;
3811         wxString PropertyTokens;
3812         bool FirstToken = TRUE;
3813         int intPrevValue = 6;
3814         int intPref = 0;                        
3815         int intType = 0;
3816         long ListCtrlIndex;
3817         
3818         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3819         
3820         intPrevValue = 5;
3821         
3822         PropertyType PropType = PROPERTY_NONE;
3823                 
3824         // Look for type before continuing.
3825         
3826         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3827         
3828         // Setup the pointers.
3829         
3830         std::map<int, wxString> *NoteList = NULL;
3831         std::map<int, wxString> *NoteListAltID = NULL;
3832         std::map<int, wxString> *NoteListPID = NULL;
3833         std::map<int, wxString> *NoteListType = NULL;
3834         std::map<int, wxString> *NoteListTokens = NULL;
3835         std::map<int, wxString> *NoteListLanguage = NULL;
3836         std::map<int, int> *NoteListPref = NULL;
3837         
3838         // Setup blank lines for later on.
3839         
3840         switch(PropType){
3841                 case PROPERTY_NONE:
3842                         NoteList = &GeneralNoteList;
3843                         NoteListType = &GeneralNoteListType;
3844                         NoteListAltID = &GeneralNoteListAltID;
3845                         NoteListPID = &GeneralNoteListPID;
3846                         NoteListTokens = &GeneralNoteListTokens;
3847                         NoteListLanguage = &GeneralNoteListLanguage;
3848                         NoteListPref = &GeneralNoteListPref;    
3849                         break;
3850                 case PROPERTY_HOME:
3851                         NoteList = &HomeNoteList;
3852                         NoteListType = &HomeNoteListType;
3853                         NoteListAltID = &HomeNoteListAltID;
3854                         NoteListPID = &HomeNoteListPID;
3855                         NoteListTokens = &HomeNoteListTokens;
3856                         NoteListLanguage = &HomeNoteListLanguage;
3857                         NoteListPref = &HomeNoteListPref;       
3858                         break;
3859                 case PROPERTY_WORK:
3860                         NoteList = &BusinessNoteList;
3861                         NoteListType = &BusinessNoteListType;
3862                         NoteListAltID = &BusinessNoteListAltID;
3863                         NoteListPID = &BusinessNoteListPID;
3864                         NoteListTokens = &BusinessNoteListTokens;
3865                         NoteListLanguage = &BusinessNoteListLanguage;   
3866                         NoteListPref = &BusinessNoteListPref;
3867                         break;
3868         }
3870         intPrevValue = 5;
3871                 
3872         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3873         intiter != SplitPoints.end(); ++intiter){
3874         
3875                 SLiter = SplitLength.find(intiter->first);
3876         
3877                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3878                 
3879                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3880                 PropertyName = PropertyElement.GetNextToken();                          
3881                 PropertyValue = PropertyElement.GetNextToken();
3882                 
3883                 intPrevValue = intiter->second;
3884                 
3885                 // Process properties.
3886                 
3887                 size_t intPropertyValueLen = PropertyValue.Len();
3888                 
3889                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3890                         
3891                         PropertyValue.Trim();
3892                         PropertyValue.RemoveLast();
3893                         
3894                 }                               
3895                 
3896                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3897                         
3898                         PropertyValue.Remove(0, 1);
3899                         
3900                 }                               
3901                 
3902                 CaptureString(&PropertyValue, FALSE);
3903                 
3904                 if (PropertyName == wxT("ALTID")){
3905                 
3906                         NoteListAltID->erase(*NoteCount);
3907                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3908                 
3909                 } else if (PropertyName == wxT("PID")){
3911                         NoteListPID->erase(*NoteCount);
3912                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3913                 
3914                 } else if (PropertyName == wxT("PREF")){
3915                                 
3916                         int PriorityNumber = 0;
3917                         bool ValidNumber = TRUE;
3918                         
3919                         try{
3920                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3921                         }
3922                         
3923                         catch(std::invalid_argument &e){
3924                                 ValidNumber = FALSE;
3925                         }
3927                         if (ValidNumber == TRUE){
3929                                 NoteListPref->erase(*NoteCount);
3930                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3932                         }
3933                                         
3934                 } else if (PropertyName == wxT("LANGUAGE")){
3935                 
3936                         NoteListLanguage->erase(*NoteCount);
3937                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3938                 
3939                 } else {
3940                 
3941                         // Something else we don't know about so append
3942                         // to the tokens variable.
3943                 
3944                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3945                 
3946                                 if (FirstToken == TRUE){
3947                         
3948                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3949                                         FirstToken = FALSE;
3950                         
3951                                 } else {
3952                         
3953                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3954                         
3955                                 }
3956                 
3957                         }
3958                 
3959                 }
3960         
3961         }
3962         
3963         // Add the data to the General/Home/Work address variables.
3964         
3965         CaptureString(&PropertySeg2, FALSE);
3967         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3968         
3969         if (!PropertyTokens.IsEmpty()){
3970         
3971                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3972                         
3973         }
3977 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3979         std::map<int, int> SplitPoints;
3980         std::map<int, int> SplitLength;
3981         std::map<int, int>::iterator SLiter;                    
3982         wxString PropertyData;
3983         wxString PropertyName;
3984         wxString PropertyValue;
3985         wxString PropertyTokens;
3986         bool FirstToken = TRUE;
3987         int intPrevValue = 12;
3988         int intPref = 0;                        
3989         int intType = 0;
3990         long ListCtrlIndex;
3991         
3992         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3993         
3994         intPrevValue = 11;
3995         
3996         PropertyType PropType = PROPERTY_NONE;
3997                 
3998         // Look for type before continuing.
3999         
4000         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4001         
4002         // Setup blank lines for later on.
4003         
4004         switch(PropType){
4005                 case PROPERTY_NONE:
4006                         break;
4007                 case PROPERTY_HOME:
4008                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4009                         break;
4010                 case PROPERTY_WORK:
4011                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4012                         break;
4013         }
4015         intPrevValue = 11;
4016                 
4017         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4018         intiter != SplitPoints.end(); ++intiter){
4019         
4020                 SLiter = SplitLength.find(intiter->first);
4021         
4022                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4023                 
4024                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4025                 PropertyName = PropertyElement.GetNextToken();                          
4026                 PropertyValue = PropertyElement.GetNextToken();
4027                 
4028                 intPrevValue = intiter->second;
4029                 
4030                 // Process properties.
4031                 
4032                 size_t intPropertyValueLen = PropertyValue.Len();
4033                 
4034                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4035                         
4036                         PropertyValue.Trim();
4037                         PropertyValue.RemoveLast();
4038                         
4039                 }                               
4040                 
4041                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4042                         
4043                         PropertyValue.Remove(0, 1);
4044                         
4045                 }                               
4046                 
4047                 CaptureString(&PropertyValue, FALSE);
4048                 
4049                 if (PropertyName == wxT("ALTID")){
4050                 
4051                         CategoriesListAltID.erase(*CategoryCount);
4052                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4053                 
4054                 } else if (PropertyName == wxT("PID")){
4056                         CategoriesListPID.erase(*CategoryCount);
4057                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4058                 
4059                 } else if (PropertyName == wxT("PREF")){
4060                                 
4061                         int PriorityNumber = 0;
4062                         bool ValidNumber = TRUE;
4063                         
4064                         try{
4065                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4066                         }
4067                         
4068                         catch(std::invalid_argument &e){
4069                                 ValidNumber = FALSE;
4070                         }
4072                         if (ValidNumber == TRUE){
4074                                 CategoriesListPref.erase(*CategoryCount);
4075                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4077                         }
4078                                         
4079                 } else if (PropertyName == wxT("LANGUAGE")){
4080                 
4081                         CategoriesListLanguage.erase(*CategoryCount);
4082                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4083                 
4084                 } else {
4085                 
4086                         // Something else we don't know about so append
4087                         // to the tokens variable.
4088                 
4089                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4090                 
4091                                 if (FirstToken == TRUE){
4092                         
4093                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4094                                         FirstToken = FALSE;
4095                         
4096                                 } else {
4097                         
4098                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4099                         
4100                                 }
4101                 
4102                         }
4103                 
4104                 }
4105         
4106         }
4107         
4108         // Deal with multiple categories.
4109         
4110         int intOrigCatCount = *CategoryCount;
4111         bool FirstCategoryProcessed = TRUE;
4112         bool AfterFirstToken = FALSE;
4113         int intSplitSize = 0;
4114         int intSplitsFound = 0;
4115         int intSplitSeek = 0;
4116         int intPropertyLen = PropertySeg2.Len();
4117         
4118         SplitPoints.clear();
4119         SplitLength.clear();
4120         intPrevValue = 0;
4121         
4122         for (int i = 0; i <= intPropertyLen; i++){
4123         
4124                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4125         
4126                         continue;
4127                 
4128                 }
4129         
4130                 intSplitSize++;
4131         
4132                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4133         
4134                         if (AfterFirstToken == TRUE){
4135                 
4136                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4137                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4138                         
4139                         } else {
4140                         
4141                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4142                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4143                                 AfterFirstToken = TRUE;
4145                         }
4147                         intSplitsFound++;
4148                         intSplitSeek = i;
4149                         intSplitSize = 0;                               
4150         
4151                 }                       
4152         
4153         }
4154         
4155         if (SplitPoints.size() > 0){
4156         
4157                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4158                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4159         
4160         }
4161         
4162         if (SplitPoints.size() == 0){
4163         
4164                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4165         
4166                 if (!PropertyTokens.IsEmpty()){
4167                 
4168                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4169                 
4170                 }
4171         
4172         }
4173         
4174         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4175         intiter != SplitPoints.end(); ++intiter){
4176         
4177                 SLiter = SplitLength.find(intiter->first);
4178         
4179                 intPrevValue = intiter->second;
4180         
4181                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4182                 
4183                 // Add the data to the General/Home/Work address variables.
4184         
4185                 // Trim any whitespace from the start and end.
4186         
4187                 PropertyData = PropertyData.Trim(FALSE);
4188                 PropertyData = PropertyData.Trim(TRUE); 
4189         
4190                 CaptureString(&PropertyData, FALSE);
4191                 
4192                 if (FirstCategoryProcessed == TRUE){
4193                 
4194                         FirstCategoryProcessed = FALSE;
4195                         
4196                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4197         
4198                         if (!PropertyTokens.IsEmpty()){
4199                 
4200                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4201                 
4202                         }
4203                         
4204                         continue;
4205                 
4206                 } else {
4208                         (*CategoryCount)++;
4209                         
4210                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4211                 
4212                         if (!PropertyTokens.IsEmpty()){
4213                 
4214                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4215                 
4216                         }
4217                 
4218                 }
4219                 
4220                 // Copy the properties to each of the categories (if it exists).
4221                 
4222                 if (!PropertyTokens.IsEmpty()){
4223                 
4224                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4225                 
4226                 }
4227                 
4228                 // Check if ALTID was used.
4229                 
4230                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4231                 
4232                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4233                 
4234                 }
4235                 
4236                 // Check if PID was used.
4237                 
4238                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4239                 
4240                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4241                 
4242                 }
4243         
4244                 // Check if PREF was used.
4245         
4246                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4247                 
4248                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4249                 
4250                 }
4251                 
4252                 // Check if LANGUAGE was used.
4253                 
4254                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4255                 
4256                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4257                 
4258                 }
4259                 
4260                 // Check if TYPE was used.
4261                 
4262                 switch(PropType){
4263                         case PROPERTY_NONE:
4264                                 break;
4265                         case PROPERTY_HOME:
4266                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4267                                 break;
4268                         case PROPERTY_WORK:
4269                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4270                                 break;
4271                 }
4272         
4273         }
4277 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4279         size_t intPropertyLen = PropertySeg1.Len();
4280         std::map<int, int> SplitPoints;
4281         std::map<int, int> SplitLength;
4282         std::map<int, int>::iterator SLiter;                    
4283         wxString PropertyData;
4284         wxString PropertyName;
4285         wxString PropertyValue;
4286         wxString PropertyTokens;
4287         bool FirstToken = TRUE;
4288         int intSplitsFound = 0;
4289         int intSplitSize = 0;
4290         int intPrevValue = 7;
4291         int intPref = 0;                        
4292         int intType = 0;
4293         
4294         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4295         
4296         intPrevValue = 6;
4297         
4298         PropertyType PropType = PROPERTY_NONE;
4299                 
4300         // Look for type before continuing.
4301         
4302         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4304         intPrevValue = 6;
4306         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4307         intiter != SplitPoints.end(); ++intiter){
4308         
4309                 SLiter = SplitLength.find(intiter->first);
4310         
4311                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4312                 
4313                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4314                 PropertyName = PropertyElement.GetNextToken();                          
4315                 PropertyValue = PropertyElement.GetNextToken();
4316                 
4317                 intPrevValue = intiter->second;
4318                 
4319                 // Process properties.
4320                 
4321                 size_t intPropertyValueLen = PropertyValue.Len();
4322                 
4323                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4324                         
4325                         PropertyValue.Trim();
4326                         PropertyValue.RemoveLast();
4327                         
4328                 }                               
4329                 
4330                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4331                         
4332                         PropertyValue.Remove(0, 1);
4333                         
4334                 }
4335                 
4336                 CaptureString(&PropertyValue, FALSE);
4337                 
4338                 if (PropertyName == wxT("ALTID")){
4340                         PicturesListAltID.erase(*PhotoCount);
4341                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4342                 
4343                 } else if (PropertyName == wxT("PID")){
4345                         PicturesListPID.erase(*PhotoCount);
4346                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4347                 
4348                 } else if (PropertyName == wxT("PREF")){
4349                         
4350                         int PriorityNumber = 0;
4351                         bool ValidNumber = TRUE;
4352                         
4353                         try{
4354                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4355                         }
4356                         
4357                         catch(std::invalid_argument &e){
4358                                 ValidNumber = FALSE;
4359                         }
4361                         if (ValidNumber == TRUE){
4363                                 PicturesListPref.erase(*PhotoCount);
4364                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4366                         }
4367                 
4368                 } else if (PropertyName == wxT("MEDIATYPE")){
4369                 
4370                         PicturesListMediatype.erase(*PhotoCount);
4371                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4372                                         
4373                 } else {
4374                 
4375                         // Something else we don't know about so append
4376                         // to the tokens variable.
4377                         
4378                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4379                         
4380                                 if (FirstToken == TRUE){
4381                                 
4382                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4383                                         FirstToken = FALSE;
4384                                 
4385                                 } else {
4386                                 
4387                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4388                                 
4389                                 }
4390                         
4391                         }
4392                 
4393                 }
4394         
4395         }       
4396         
4397         intPropertyLen = PropertySeg2.Len();
4398         SplitPoints.clear();
4399         SplitLength.clear();
4400         intSplitsFound = 0;
4401         intSplitSize = 0;
4402         intPrevValue = 0;                       
4403         
4404         CaptureString(&PropertySeg2, FALSE);
4405         
4406         for (int i = 0; i <= intPropertyLen; i++){
4408                 intSplitSize++;
4409         
4410                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4411         
4412                         intSplitsFound++;
4413                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4414                         
4415                         if (intSplitsFound == 6){ 
4416                         
4417                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4418                                 break; 
4419                                 
4420                         } else {
4421                         
4422                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4423                         
4424                         }
4425                         
4426                         intSplitSize = 0;                                       
4427         
4428                 }
4430         }
4431         
4432         wxString wxSPhotoURI;
4433         wxString wxSPhotoMIME;
4434         wxString wxSPhotoEncoding;
4435         wxString wxSPhotoData;
4436         std::string base64enc;
4437         
4438         if (intSplitsFound == 0){
4439         
4440         } else {
4441         
4442                 std::map<int, int>::iterator striter;
4443         
4444                 striter = SplitLength.find(1);
4445         
4446                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4447         
4448                 while (wSTDataType.HasMoreTokens() == TRUE){
4449                 
4450                         wxSPhotoURI = wSTDataType.GetNextToken();
4451                         wxSPhotoMIME = wSTDataType.GetNextToken();
4452                         break;
4453                 
4454                 }                       
4455         
4456                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4457         
4458                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4459                 
4460                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4461                         wxSPhotoData = wSTDataInfo.GetNextToken();
4462                         base64enc = wxSPhotoData.mb_str();
4463                         break;
4464                 
4465                 }
4466         
4467         }
4468         
4469         // Add the data to the General/Home/Work address variables.
4470         
4471         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4472         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4473         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4474         
4475         switch(PropType){
4476                 case PROPERTY_NONE:
4477                         break;
4478                 case PROPERTY_HOME:
4479                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4480                         break;
4481                 case PROPERTY_WORK:
4482                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4483                         break;
4484         }
4485         
4486         if (!PropertyTokens.IsEmpty()){
4488                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4489         
4490         }
4494 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4496         size_t intPropertyLen = PropertySeg1.Len();
4497         std::map<int, int> SplitPoints;
4498         std::map<int, int> SplitLength;
4499         std::map<int, int>::iterator SLiter;                    
4500         wxString PropertyData;
4501         wxString PropertyName;
4502         wxString PropertyValue;
4503         wxString PropertyTokens;
4504         bool FirstToken = TRUE;
4505         int intSplitsFound = 0;
4506         int intSplitSize = 0;
4507         int intPrevValue = 6;
4508         int intPref = 0;                        
4509         int intType = 0;
4510         
4511         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4512         
4513         intPrevValue = 5;
4514         
4515         PropertyType PropType = PROPERTY_NONE;
4516                 
4517         // Look for type before continuing.
4518         
4519         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4521         intPrevValue = 5;
4523         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4524         intiter != SplitPoints.end(); ++intiter){
4525         
4526                 SLiter = SplitLength.find(intiter->first);
4527         
4528                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4529                 
4530                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4531                 PropertyName = PropertyElement.GetNextToken();                          
4532                 PropertyValue = PropertyElement.GetNextToken();
4533                 
4534                 intPrevValue = intiter->second;
4535                 
4536                 // Process properties.
4537                 
4538                 size_t intPropertyValueLen = PropertyValue.Len();
4539                 
4540                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4541                         
4542                         PropertyValue.Trim();
4543                         PropertyValue.RemoveLast();
4544                         
4545                 }                               
4546                 
4547                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4548                         
4549                         PropertyValue.Remove(0, 1);
4550                         
4551                 }
4552                 
4553                 CaptureString(&PropertyValue, FALSE);
4554                 
4555                 if (PropertyName == wxT("ALTID")){
4557                         LogosListAltID.erase(*LogoCount);
4558                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4559                 
4560                 } else if (PropertyName == wxT("PID")){
4562                         LogosListPID.erase(*LogoCount);
4563                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4564                 
4565                 } else if (PropertyName == wxT("PREF")){
4566                         
4567                         int PriorityNumber = 0;
4568                         bool ValidNumber = TRUE;
4569                         
4570                         try{
4571                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4572                         }
4573                         
4574                         catch(std::invalid_argument &e){
4575                                 ValidNumber = FALSE;
4576                         }
4578                         if (ValidNumber == TRUE){
4580                                 LogosListPref.erase(*LogoCount);
4581                                 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4583                         }
4584                 
4585                 } else if (PropertyName == wxT("MEDIATYPE")){
4586                 
4587                         LogosListMediatype.erase(*LogoCount);
4588                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4589                                         
4590                 } else {
4591                 
4592                         // Something else we don't know about so append
4593                         // to the tokens variable.
4594                         
4595                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4596                         
4597                                 if (FirstToken == TRUE){
4598                                 
4599                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4600                                         FirstToken = FALSE;
4601                                 
4602                                 } else {
4603                                 
4604                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4605                                 
4606                                 }
4607                         
4608                         }
4609                 
4610                 }
4611         
4612         }       
4613         
4614         intPropertyLen = PropertySeg2.Len();
4615         SplitPoints.clear();
4616         SplitLength.clear();
4617         intSplitsFound = 0;
4618         intSplitSize = 0;
4619         intPrevValue = 0;                       
4620         
4621         CaptureString(&PropertySeg2, FALSE);
4622         
4623         for (int i = 0; i <= intPropertyLen; i++){
4625                 intSplitSize++;
4626         
4627                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4628         
4629                         intSplitsFound++;
4630                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4631                         
4632                         if (intSplitsFound == 6){ 
4633                         
4634                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4635                                 break; 
4636                                 
4637                         } else {
4638                         
4639                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4640                         
4641                         }
4642                         
4643                         intSplitSize = 0;                                       
4644         
4645                 }
4647         }
4648         
4649         wxString wxSPhotoURI;
4650         wxString wxSPhotoMIME;
4651         wxString wxSPhotoEncoding;
4652         wxString wxSPhotoData;
4653         std::string base64enc;
4654         
4655         if (intSplitsFound == 0){
4656         
4657         } else {
4658         
4659                 std::map<int, int>::iterator striter;
4660         
4661                 striter = SplitLength.find(1);
4662         
4663                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4664         
4665                 while (wSTDataType.HasMoreTokens() == TRUE){
4666                 
4667                         wxSPhotoURI = wSTDataType.GetNextToken();
4668                         wxSPhotoMIME = wSTDataType.GetNextToken();
4669                         break;
4670                 
4671                 }                       
4672         
4673                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4674         
4675                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4676                 
4677                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4678                         wxSPhotoData = wSTDataInfo.GetNextToken();
4679                         base64enc = wxSPhotoData.mb_str();
4680                         break;
4681                 
4682                 }
4683         
4684         }
4685         
4686         // Add the data to the General/Home/Work address variables.
4687         
4688         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4689         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4690         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4691         
4692         switch(PropType){
4693                 case PROPERTY_NONE:
4694                         break;
4695                 case PROPERTY_HOME:
4696                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4697                         break;
4698                 case PROPERTY_WORK:
4699                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4700                         break;
4701         }
4702         
4703         if (!PropertyTokens.IsEmpty()){
4705                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4706         
4707         }
4711 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4713         size_t intPropertyLen = PropertySeg1.Len();
4714         std::map<int, int> SplitPoints;
4715         std::map<int, int> SplitLength;
4716         std::map<int, int>::iterator SLiter;                    
4717         wxString PropertyData;
4718         wxString PropertyName;
4719         wxString PropertyValue;
4720         wxString PropertyTokens;
4721         bool FirstToken = TRUE;
4722         int intSplitsFound = 0;
4723         int intSplitSize = 0;
4724         int intPrevValue = 7;
4725         int intPref = 0;                        
4726         int intType = 0;
4727         
4728         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4729         
4730         intPrevValue = 6;
4731         
4732         PropertyType PropType = PROPERTY_NONE;
4733         
4734         // Look for type before continuing.                     
4736         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4738         intPrevValue = 6;
4740         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4741         intiter != SplitPoints.end(); ++intiter){
4742         
4743                 SLiter = SplitLength.find(intiter->first);
4744         
4745                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4746                 
4747                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4748                 PropertyName = PropertyElement.GetNextToken();                          
4749                 PropertyValue = PropertyElement.GetNextToken();
4750                 
4751                 intPrevValue = intiter->second;
4752                 
4753                 // Process properties.
4754                 
4755                 size_t intPropertyValueLen = PropertyValue.Len();
4756                 
4757                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4758                         
4759                         PropertyValue.Trim();
4760                         PropertyValue.RemoveLast();
4761                         
4762                 }                               
4763                 
4764                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4765                         
4766                         PropertyValue.Remove(0, 1);
4767                         
4768                 }                       
4769                 
4770                 CaptureString(&PropertyValue, FALSE);
4771                 
4772                 if (PropertyName == wxT("ALTID")){
4774                         SoundsListAltID.erase(*SoundCount);
4775                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4776                 
4777                 } else if (PropertyName == wxT("PID")){
4779                         SoundsListPID.erase(*SoundCount);
4780                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4781                 
4782                 } else if (PropertyName == wxT("PREF")){
4783                         
4784                         int PriorityNumber = 0;
4785                         bool ValidNumber = TRUE;
4786                         
4787                         try{
4788                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4789                         }
4790                         
4791                         catch(std::invalid_argument &e){
4792                                 ValidNumber = FALSE;
4793                         }
4795                         if (ValidNumber == TRUE){
4797                                 SoundsListPref.erase(*SoundCount);
4798                                 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4800                         }
4801                 
4802                 } else if (PropertyName == wxT("MEDIATYPE")){
4803                 
4804                         SoundsListMediatype.erase(*SoundCount);
4805                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4807                 } else if (PropertyName == wxT("LANGUAGE")){
4808                 
4809                         SoundsListLanguage.erase(*SoundCount);
4810                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4812                 } else {
4813                 
4814                         // Something else we don't know about so append
4815                         // to the tokens variable.
4816                         
4817                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4818                         
4819                                 if (FirstToken == TRUE){
4820                                 
4821                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4822                                         FirstToken = FALSE;
4823                                 
4824                                 } else {
4825                                 
4826                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4827                                 
4828                                 }
4829                         
4830                         }
4831                 
4832                 }
4833         
4834         }       
4835         
4836         intPropertyLen = PropertySeg2.Len();
4837         SplitPoints.clear();
4838         SplitLength.clear();
4839         intSplitsFound = 0;
4840         intSplitSize = 0;
4841         intPrevValue = 0;
4842         
4843         CaptureString(&PropertySeg2, FALSE);
4844         
4845         for (int i = 0; i <= intPropertyLen; i++){
4847                 intSplitSize++;
4848         
4849                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4850         
4851                         intSplitsFound++;
4852                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4853                         
4854                         if (intSplitsFound == 6){ 
4855                         
4856                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4857                                 break; 
4858                                 
4859                         } else {
4860                         
4861                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4862                         
4863                         }
4864                         
4865                         intSplitSize = 0;                                       
4866         
4867                 }
4869         }
4870         
4871         wxString wxSSoundURI;
4872         wxString wxSSoundMIME;
4873         wxString wxSSoundEncoding;
4874         wxString wxSSoundData;
4875         std::string base64enc;
4876         
4877         if (intSplitsFound == 0){
4878         
4879         } else {
4880         
4881                 std::map<int, int>::iterator striter;
4882         
4883                 striter = SplitLength.find(1);
4884         
4885                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4886         
4887                 while (wSTDataType.HasMoreTokens() == TRUE){
4888                 
4889                         wxSSoundURI = wSTDataType.GetNextToken();
4890                         wxSSoundMIME = wSTDataType.GetNextToken();
4891                         break;
4892                 
4893                 }                       
4894         
4895                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4896         
4897                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4898                 
4899                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4900                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4901                         base64enc = wxSSoundData.mb_str();
4902                         break;
4903                 
4904                 }
4905         
4906         }
4907         
4908         // Add the data to the General/Home/Work address variables.
4909                 
4910         switch(PropType){
4911                 case PROPERTY_NONE:
4912                         break;
4913                 case PROPERTY_HOME:
4914                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4915                         break;
4916                 case PROPERTY_WORK:
4917                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4918                         break;
4919         }
4920         
4921         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4922         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4923         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4924         
4925         if (!PropertyTokens.IsEmpty()){
4926         
4927                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4928         
4929         }
4930         
4933 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4935         size_t intPropertyLen = PropertySeg1.Len();
4936         std::map<int, int> SplitPoints;
4937         std::map<int, int> SplitLength;
4938         std::map<int, int>::iterator SLiter;                    
4939         wxString PropertyData;
4940         wxString PropertyName;
4941         wxString PropertyValue;
4942         wxString PropertyTokens;
4943         bool FirstToken = TRUE;
4944         int intSplitsFound = 0;
4945         int intSplitSize = 0;
4946         int intPrevValue = 8;
4947         int intPref = 0;                        
4948         int intType = 0;
4949         
4950         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4951         
4952         intPrevValue = 7;
4953         
4954         PropertyType PropType = PROPERTY_NONE;
4955         
4956         // Look for type before continuing.                     
4958         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4960         intPrevValue = 7;
4962         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4963         intiter != SplitPoints.end(); ++intiter){
4964         
4965                 SLiter = SplitLength.find(intiter->first);
4966         
4967                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4968                 
4969                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4970                 PropertyName = PropertyElement.GetNextToken();                          
4971                 PropertyValue = PropertyElement.GetNextToken();
4972                 
4973                 intPrevValue = intiter->second;
4974                 
4975                 // Process properties.
4976                 
4977                 size_t intPropertyValueLen = PropertyValue.Len();
4978                 
4979                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4980                         
4981                         PropertyValue.Trim();
4982                         PropertyValue.RemoveLast();
4983                         
4984                 }                               
4985                 
4986                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4987                         
4988                         PropertyValue.Remove(0, 1);
4989                         
4990                 }                       
4991                 
4992                 CaptureString(&PropertyValue, FALSE);
4993                 
4994                 if (PropertyName == wxT("ALTID")){
4996                         CalendarListAltID.erase(*CalURICount);
4997                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4998                 
4999                 } else if (PropertyName == wxT("PID")){
5001                         CalendarListPID.erase(*CalURICount);
5002                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5003                 
5004                 } else if (PropertyName == wxT("PREF")){
5005                         
5006                         int PriorityNumber = 0;
5007                         bool ValidNumber = TRUE;
5008                         
5009                         try{
5010                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5011                         }
5012                         
5013                         catch(std::invalid_argument &e){
5014                                 ValidNumber = FALSE;
5015                         }
5017                         if (ValidNumber == TRUE){
5019                                 CalendarListPref.erase(*CalURICount);
5020                                 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5022                         }
5023                 
5024                 } else if (PropertyName == wxT("MEDIATYPE")){
5025                 
5026                         CalendarListMediatype.erase(*CalURICount);
5027                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5029                 } else {
5030                 
5031                         // Something else we don't know about so append
5032                         // to the tokens variable.
5033                         
5034                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5035                         
5036                                 if (FirstToken == TRUE){
5037                                 
5038                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5039                                         FirstToken = FALSE;
5040                                 
5041                                 } else {
5042                                 
5043                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5044                                 
5045                                 }
5046                         
5047                         }
5048                 
5049                 }
5050         
5051         }       
5052         
5053         intPropertyLen = PropertySeg2.Len();
5054         SplitPoints.clear();
5055         SplitLength.clear();
5056         intSplitsFound = 0;
5057         intSplitSize = 0;
5058         intPrevValue = 0;
5059         
5060         CaptureString(&PropertySeg2, FALSE);
5061         
5062         // Add the data to the General/Home/Work address variables.
5063                 
5064         switch(PropType){
5065                 case PROPERTY_NONE:
5066                         break;
5067                 case PROPERTY_HOME:
5068                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5069                         break;
5070                 case PROPERTY_WORK:
5071                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5072                         break;
5073         }
5074         
5075         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5076         
5077         if (!PropertyTokens.IsEmpty()){
5078         
5079                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5080         
5081         }
5085 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5087         size_t intPropertyLen = PropertySeg1.Len();
5088         std::map<int, int> SplitPoints;
5089         std::map<int, int> SplitLength;
5090         std::map<int, int>::iterator SLiter;                    
5091         wxString PropertyData;
5092         wxString PropertyName;
5093         wxString PropertyValue;
5094         wxString PropertyTokens;
5095         bool FirstToken = TRUE;
5096         int intSplitsFound = 0;
5097         int intSplitSize = 0;
5098         int intPrevValue = 8;
5099         int intPref = 0;                        
5100         int intType = 0;
5101         
5102         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5103         
5104         intPrevValue = 7;
5105         
5106         PropertyType PropType = PROPERTY_NONE;
5107         
5108         // Look for type before continuing.                     
5110         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5112         intPrevValue = 7;
5114         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5115         intiter != SplitPoints.end(); ++intiter){
5116         
5117                 SLiter = SplitLength.find(intiter->first);
5118         
5119                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5120                 
5121                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5122                 PropertyName = PropertyElement.GetNextToken();                          
5123                 PropertyValue = PropertyElement.GetNextToken();
5124                 
5125                 intPrevValue = intiter->second;
5126                 
5127                 // Process properties.
5128                 
5129                 size_t intPropertyValueLen = PropertyValue.Len();
5130                 
5131                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5132                         
5133                         PropertyValue.Trim();
5134                         PropertyValue.RemoveLast();
5135                         
5136                 }                               
5137                 
5138                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5139                         
5140                         PropertyValue.Remove(0, 1);
5141                         
5142                 }                       
5143                 
5144                 CaptureString(&PropertyValue, FALSE);
5145                 
5146                 if (PropertyName == wxT("ALTID")){
5148                         CalendarRequestListAltID.erase(*CalAdrURICount);
5149                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5150                 
5151                 } else if (PropertyName == wxT("PID")){
5153                         CalendarRequestListPID.erase(*CalAdrURICount);
5154                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5155                 
5156                 } else if (PropertyName == wxT("PREF")){
5157                         
5158                         int PriorityNumber = 0;
5159                         bool ValidNumber = TRUE;
5160                         
5161                         try{
5162                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5163                         }
5164                         
5165                         catch(std::invalid_argument &e){
5166                                 ValidNumber = FALSE;
5167                         }
5169                         if (ValidNumber == TRUE){
5171                                 CalendarRequestListPref.erase(*CalAdrURICount);
5172                                 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5174                         }
5175                 
5176                 } else if (PropertyName == wxT("MEDIATYPE")){
5177                 
5178                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5179                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5181                 } else {
5182                 
5183                         // Something else we don't know about so append
5184                         // to the tokens variable.
5185                         
5186                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5187                         
5188                                 if (FirstToken == TRUE){
5189                                 
5190                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5191                                         FirstToken = FALSE;
5192                                 
5193                                 } else {
5194                                 
5195                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5196                                 
5197                                 }
5198                         
5199                         }
5200                 
5201                 }
5202         
5203         }       
5204         
5205         intPropertyLen = PropertySeg2.Len();
5206         SplitPoints.clear();
5207         SplitLength.clear();
5208         intSplitsFound = 0;
5209         intSplitSize = 0;
5210         intPrevValue = 0;
5211         
5212         CaptureString(&PropertySeg2, FALSE);
5213         
5214         // Add the data to the General/Home/Work address variables.
5215                 
5216         switch(PropType){
5217                 case PROPERTY_NONE:
5218                         break;
5219                 case PROPERTY_HOME:
5220                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5221                         break;
5222                 case PROPERTY_WORK:
5223                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5224                         break;
5225         }
5226         
5227         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5228         
5229         if (!PropertyTokens.IsEmpty()){
5230         
5231                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5232         
5233         }       
5234         
5237 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5239         size_t intPropertyLen = PropertySeg1.Len();
5240         std::map<int, int> SplitPoints;
5241         std::map<int, int> SplitLength;
5242         std::map<int, int>::iterator SLiter;                    
5243         wxString PropertyData;
5244         wxString PropertyName;
5245         wxString PropertyValue;
5246         wxString PropertyTokens;
5247         bool FirstToken = TRUE;
5248         int intSplitsFound = 0;
5249         int intSplitSize = 0;
5250         int intPrevValue = 7;
5251         int intPref = 0;                        
5252         int intType = 0;
5253         
5254         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5255         
5256         intPrevValue = 6;
5257         
5258         PropertyType PropType = PROPERTY_NONE;
5259         
5260         // Look for type before continuing.                     
5262         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5264         intPrevValue = 6;
5266         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5267         intiter != SplitPoints.end(); ++intiter){
5268         
5269                 SLiter = SplitLength.find(intiter->first);
5270         
5271                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5272                 
5273                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5274                 PropertyName = PropertyElement.GetNextToken();                          
5275                 PropertyValue = PropertyElement.GetNextToken();
5276                 
5277                 intPrevValue = intiter->second;
5278                 
5279                 // Process properties.
5280                 
5281                 size_t intPropertyValueLen = PropertyValue.Len();
5282                 
5283                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5284                         
5285                         PropertyValue.Trim();
5286                         PropertyValue.RemoveLast();
5287                         
5288                 }                               
5289                 
5290                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5291                         
5292                         PropertyValue.Remove(0, 1);
5293                         
5294                 }                       
5295                 
5296                 CaptureString(&PropertyValue, FALSE);
5297                 
5298                 if (PropertyName == wxT("ALTID")){
5300                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5301                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5302                 
5303                 } else if (PropertyName == wxT("PID")){
5305                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5306                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5307                 
5308                 } else if (PropertyName == wxT("PREF")){
5309                         
5310                         int PriorityNumber = 0;
5311                         bool ValidNumber = TRUE;
5312                         
5313                         try{
5314                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5315                         }
5316                         
5317                         catch(std::invalid_argument &e){
5318                                 ValidNumber = FALSE;
5319                         }
5321                         if (ValidNumber == TRUE){
5323                                 FreeBusyListPref.erase(*FreeBusyAddressCount);
5324                                 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5326                         }
5327                 
5328                 } else if (PropertyName == wxT("MEDIATYPE")){
5329                 
5330                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5331                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5333                 } else {
5334                 
5335                         // Something else we don't know about so append
5336                         // to the tokens variable.
5337                         
5338                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5339                         
5340                                 if (FirstToken == TRUE){
5341                                 
5342                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5343                                         FirstToken = FALSE;
5344                                 
5345                                 } else {
5346                                 
5347                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5348                                 
5349                                 }
5350                         
5351                         }
5352                 
5353                 }
5354         
5355         }       
5356         
5357         intPropertyLen = PropertySeg2.Len();
5358         SplitPoints.clear();
5359         SplitLength.clear();
5360         intSplitsFound = 0;
5361         intSplitSize = 0;
5362         intPrevValue = 0;
5363         
5364         CaptureString(&PropertySeg2, FALSE);
5365         
5366         // Add the data to the General/Home/Work address variables.
5367                 
5368         switch(PropType){
5369                 case PROPERTY_NONE:
5370                         break;
5371                 case PROPERTY_HOME:
5372                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5373                         break;
5374                 case PROPERTY_WORK:
5375                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5376                         break;
5377         }
5378         
5379         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5380         
5381         if (!PropertyTokens.IsEmpty()){
5382         
5383                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5384         
5385         }
5389 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5391         size_t intPropertyLen = PropertySeg1.Len();
5392         std::map<int, int> SplitPoints;
5393         std::map<int, int> SplitLength;
5394         std::map<int, int>::iterator SLiter;                    
5395         wxString PropertyData;
5396         wxString PropertyName;
5397         wxString PropertyValue;
5398         wxString PropertyTokens;
5399         bool FirstToken = TRUE;
5400         int intSplitsFound = 0;
5401         int intSplitSize = 0;
5402         int intPrevValue = 5;
5403         int intPref = 0;                        
5404         int intType = 0;
5405         long ListCtrlIndex;
5406         
5407         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5408         
5409         intPrevValue = 4;
5410         
5411         PropertyType PropType = PROPERTY_NONE;
5412         
5413         // Look for type before continuing.
5415         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5417         intPrevValue = 4;
5419         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5420         intiter != SplitPoints.end(); ++intiter){
5421         
5422                 SLiter = SplitLength.find(intiter->first);
5423         
5424                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5425                 
5426                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5427                 PropertyName = PropertyElement.GetNextToken();                          
5428                 PropertyValue = PropertyElement.GetNextToken();
5429                 
5430                 intPrevValue = intiter->second;
5431                 
5432                 // Process properties.
5433                 
5434                 size_t intPropertyValueLen = PropertyValue.Len();
5435                 
5436                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5437                         
5438                         PropertyValue.Trim();
5439                         PropertyValue.RemoveLast();
5440                         
5441                 }                               
5442                 
5443                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5444                         
5445                         PropertyValue.Remove(0, 1);
5446                         
5447                 }                               
5448                 
5449                 if (PropertyName == wxT("ALTID")){
5451                         KeyListAltID.erase(*KeyCount);
5452                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5453                 
5454                 } else if (PropertyName == wxT("PID")){
5456                         KeyListPID.erase(*KeyCount);
5457                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5458                 
5459                 } else if (PropertyName == wxT("PREF")){
5460                         
5461                         int PriorityNumber = 0;
5462                         bool ValidNumber = TRUE;
5463                         
5464                         try{
5465                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5466                         }
5467                         
5468                         catch(std::invalid_argument &e){
5469                                 ValidNumber = FALSE;
5470                         }
5472                         if (ValidNumber == TRUE){
5474                                 KeyListPref.erase(*KeyCount);
5475                                 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5477                         }
5478                 
5479                 } else {
5480                 
5481                         // Something else we don't know about so append
5482                         // to the tokens variable.
5483                         
5484                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5485                         
5486                                 if (FirstToken == TRUE){
5487                                 
5488                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5489                                         FirstToken = FALSE;
5490                                 
5491                                 } else {
5492                                 
5493                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5494                                 
5495                                 }
5496                         
5497                         }
5498                 
5499                 }
5500         
5501         }                               
5502         
5503         intPropertyLen = PropertySeg2.Len();
5504         SplitPoints.clear();
5505         SplitLength.clear();
5506         intSplitsFound = 0;
5507         intSplitSize = 0;
5508         intPrevValue = 0;                       
5509         
5510         for (int i = 0; i <= intPropertyLen; i++){
5512                 intSplitSize++;
5513         
5514                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5515         
5516                         intSplitsFound++;
5517                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5518                         
5519                         if (intSplitsFound == 6){ 
5520                         
5521                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5522                                 break; 
5523                                 
5524                         } else {
5525                         
5526                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5527                         
5528                         }
5529                         
5530                         intSplitSize = 0;                                       
5531         
5532                 }
5534         }
5535         
5536         wxString wxSKeyURI;
5537         wxString wxSKeyMIME;
5538         wxString wxSKeyEncoding;
5539         wxString wxSKeyData;
5540         std::string base64enc;
5541         
5542         if (intSplitsFound == 0){
5543         
5544         } else {
5545         
5546                 std::map<int, int>::iterator striter;
5547         
5548                 striter = SplitLength.find(1);
5549         
5550                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5551         
5552                 while (wSTDataType.HasMoreTokens() == TRUE){
5553                 
5554                         wxSKeyURI = wSTDataType.GetNextToken();
5555                         wxSKeyMIME = wSTDataType.GetNextToken();
5556                         break;
5557                 
5558                 }                       
5559         
5560                 if (wxSKeyURI == wxT("data")){
5561                 
5562                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5563         
5564                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5565                 
5566                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5567                                 wxSKeyData = wSTDataInfo.GetNextToken();
5568                                 break;
5569                 
5570                         }
5571                 
5572                 }
5573         
5574         }
5575         
5576         // Add the data to the General/Home/Work address variables.
5577         
5578         if (wxSKeyURI == wxT("data")){
5579                 
5580                 KeyListDataEncType.erase(*KeyCount);
5581                 KeyListKeyType.erase(*KeyCount);
5582                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5583                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5584                 
5585                 KeyList.erase(*KeyCount);
5586                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5587         
5588         } else {
5589                 
5590                 KeyList.erase(*KeyCount);
5591                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5592         
5593         }
5594         
5595         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5596                 
5597         switch (PropType){
5598                 case PROPERTY_NONE:
5599                         break;
5600                 case PROPERTY_HOME: 
5601                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5602                         break;
5603                 case PROPERTY_WORK: 
5604                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5605                         break;
5606         }
5608         if (!PropertyTokens.IsEmpty()){
5610                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5612         }
5616 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5618         // Split the Vendor three ways.
5619         
5620         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5621         
5622         wxString wxSVNDID;
5623         wxString wxSVNDPropName;
5624         long ListCtrlIndex;                     
5626         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5627         
5628                 wSTVendorDetails.GetNextToken();
5629                 wxSVNDID = wSTVendorDetails.GetNextToken();
5630                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5631                 break;
5632         
5633         }
5634         
5635         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5636         
5637                 // Add the data to the vendor variables.
5638         
5639                 VendorList.erase(*VendorCount);
5640                 VendorListPEN.erase(*VendorCount);
5641                 VendorListElement.erase(*VendorCount);
5642         
5643                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5644                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5645                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5646         
5647         }
5651 void SplitValues(wxString *PropertyLine, 
5652         std::map<int,int> *SplitPoints, 
5653         std::map<int,int> *SplitLength, 
5654         int intSize){
5655         
5656         size_t intPropertyLen = PropertyLine->Len();
5657         int intSplitsFound = 0;
5658         int intSplitSize = 0;
5659         int intSplitSeek = 0;
5660         
5661         for (int i = intSize; i <= intPropertyLen; i++){
5663                 intSplitSize++;
5664         
5665                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5666                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5667            
5668                     if (intSplitsFound == 0){
5669             
5670                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5671           
5672                     } else {
5673            
5674                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5675             
5676                     }
5677             
5678                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5679             
5680                     intSplitsFound++;
5681                     intSplitSeek = i;
5682                     intSplitSize = 0;
5683             
5684                 }
5686         }
5688         if (intSplitsFound == 0){
5690                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5691                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5693         } else {
5695                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5696                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5698         }
5702 void CheckType(wxString *PropertySeg1, 
5703         std::map<int,int> *SplitPoints, 
5704         std::map<int,int> *SplitLength, 
5705         int *intPrevValue, 
5706         PropertyType *PropType){
5707         
5708         wxString PropertyData;
5709         wxString PropertyName;
5710         wxString PropertyValue;
5711         std::map<int,int>::iterator SLiter;
5712         
5713         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5714         intiter != SplitPoints->end(); ++intiter){
5715         
5716                 SLiter = SplitLength->find(intiter->first);
5717         
5718                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5719                 
5720                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5721                 PropertyName = PropertyElement.GetNextToken();                          
5722                 PropertyValue = PropertyElement.GetNextToken();
5723                 
5724                 *intPrevValue = intiter->second;
5725                 
5726                 if (PropertyName == wxT("TYPE")){
5727                                 
5728                         if (PropertyValue == wxT("work")){
5729                         
5730                                 *PropType = PROPERTY_WORK;
5731                                                         
5732                         } else if (PropertyValue == wxT("home")){
5734                                 *PropType = PROPERTY_HOME;
5735                                                         
5736                         } else {
5737                         
5738                                 *PropType = PROPERTY_NONE;
5739                         
5740                         }
5741                 
5742                         return;
5743                 
5744                 }
5745         
5746         }
5747         
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