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