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