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