Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
323475c242c36001e4161382a75bf42a845bace9
[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                 if (FirstToken == TRUE){
516                                 
517                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
518                         FirstToken = FALSE;
519                                 
520                 } else {
521                                 
522                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
523                                 
524                 }
525         
526         }       
527         
528         CaptureString(&PropertySeg2, FALSE);
529         
530         Revision = PropertySeg2;
531         
532         if (!PropertyTokens.IsEmpty()){
533         
534                 RevisionTokens = PropertyTokens;
535         
536         }
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543         size_t intPropertyLen = PropertySeg1.Len();
544         std::map<int, int> SplitPoints;
545         std::map<int, int> SplitLength;
546         std::map<int, int>::iterator SLiter;                    
547         wxString PropertyData;
548         wxString PropertyName;
549         wxString PropertyValue;
550         wxString PropertyTokens;
551         bool FirstToken = TRUE;
552         bool PropertyMatched = FALSE;
553         int intSplitsFound = 0;
554         int intSplitSize = 0;
555         int intPrevValue = 8;
556         int intPref = 0;                        
557         int intType = 0;
558         
559         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
560         
561         intPrevValue = 7;
562         
563         PropertyType PropType = PROPERTY_NONE;
564         
565         // Look for type before continuing.                     
567         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
569         intPrevValue = 7;
571         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
572         intiter != SplitPoints.end(); ++intiter){
573         
574                 SLiter = SplitLength.find(intiter->first);
575         
576                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
577                 
578                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
579                 PropertyName = PropertyElement.GetNextToken();                          
580                 PropertyValue = PropertyElement.GetNextToken();
581                 
582                 intPrevValue = intiter->second;
583                 
584                 // Process properties.
585                 
586                 size_t intPropertyValueLen = PropertyValue.Len();
587                 
588                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
589                         
590                         PropertyValue.Trim();
591                         PropertyValue.RemoveLast();
592                         
593                 }                               
594                 
595                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
596                         
597                         PropertyValue.Remove(0, 1);
598                         
599                 }                       
600                 
601                 CaptureString(&PropertyValue, FALSE);
602                 
603                 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
604                 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
605                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
606                 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
607                 
608                 if (PropertyMatched == TRUE){
609                 
610                         PropertyMatched = FALSE;
611                         continue;
612                 
613                 }
614                 
615                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
616                         
617                         if (FirstToken == TRUE){
618                                 
619                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
620                                 FirstToken = FALSE;
621                         
622                         } else {
623                         
624                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
625                         
626                         }
627                 
628                 }
629         
630         }       
631         
632         intPropertyLen = PropertySeg2.Len();
633         SplitPoints.clear();
634         SplitLength.clear();
635         intSplitsFound = 0;
636         intSplitSize = 0;
637         intPrevValue = 0;
638         
639         CaptureString(&PropertySeg2, FALSE);
640         
641         // Add the data to the General/Home/Work address variables.
642                 
643         switch(PropType){
644                 case PROPERTY_NONE:
645                         break;
646                 case PROPERTY_HOME:
647                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
648                         break;
649                 case PROPERTY_WORK:
650                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
651                         break;
652         }
653         
654         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
655         
656         if (!PropertyTokens.IsEmpty()){
657         
658                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
659         
660         }
664 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
666         std::map<int, int> SplitPoints;
667         std::map<int, int> SplitLength;
669         int intPrevValue = 5;
670         int intPref = 0;                        
671         int intType = 0;
672         
673         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
675         intPrevValue = 4;
676         
677         wxString PropertyName;
678         wxString PropertyValue;
679         wxString PropertyData;
680         wxString PropertyTokens;
681         std::map<int,int>::iterator SLiter;
682         bool FirstToken = TRUE;
683         bool PropertyMatched = FALSE;
684         
685         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
686         intiter != SplitPoints.end(); ++intiter){
687         
688                 SLiter = SplitLength.find(intiter->first);
689         
690                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
691                 
692                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
693                 PropertyName = PropertyElement.GetNextToken();                          
694                 PropertyValue = PropertyElement.GetNextToken();
695                 
696                 intPrevValue = intiter->second;
697                 
698                 CaptureString(&PropertyValue, FALSE);
699         
700                 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
701                 
702                 if (PropertyMatched == TRUE){
703                 
704                         PropertyMatched = FALSE;
705                         continue;
706                 
707                 }
708                 
709         }
711         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
715 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
717         std::map<int, int> SplitPoints;
718         std::map<int, int> SplitLength;
720         int intPrevValue = 8;
721         int intPref = 0;                        
722         int intType = 0;
723         
724         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
726         intPrevValue = 7;
727         
728         wxString PropertyName;
729         wxString PropertyValue;
730         wxString PropertyData;
731         wxString PropertyTokens;
732         std::map<int,int>::iterator SLiter;
733         bool FirstToken = TRUE;
734         bool PropertyMatched = FALSE;
735         
736         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
737         intiter != SplitPoints.end(); ++intiter){
738         
739                 SLiter = SplitLength.find(intiter->first);
740         
741                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
742                 
743                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
744                 PropertyName = PropertyElement.GetNextToken();                          
745                 PropertyValue = PropertyElement.GetNextToken();
746                 
747                 intPrevValue = intiter->second;
748                 
749                 CaptureString(&PropertyValue, FALSE);
750         
751                 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
752                 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
753                 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
754                 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
755                 
756                 if (PropertyMatched == TRUE){
757                 
758                         PropertyMatched = FALSE;
759                         continue;
760                 
761                 }
762                 
763                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
764                         
765                         if (FirstToken == TRUE){
766                                 
767                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
768                                 FirstToken = FALSE;
769                                 
770                         } else {
771                         
772                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
773                                 
774                         }
775                         
776                 }
777                 
778         }
780         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
782         if (!PropertyTokens.IsEmpty()){
783         
784                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
785         
786         }
791 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
793         std::map<int, int> SplitPoints;
794         std::map<int, int> SplitLength;
796         int intPrevValue = 4;
797         int intPref = 0;                        
798         int intType = 0;
799         
800         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
802         intPrevValue = 3;
803         
804         wxString PropertyName;
805         wxString PropertyValue;
806         wxString PropertyData;
807         wxString PropertyTokens;
808         std::map<int,int>::iterator SLiter;
809         bool FirstToken = TRUE;
810         bool PropertyMatched = FALSE;
811         
812         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
813         intiter != SplitPoints.end(); ++intiter){
814         
815                 SLiter = SplitLength.find(intiter->first);
816         
817                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
818                 
819                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
820                 PropertyName = PropertyElement.GetNextToken();                          
821                 PropertyValue = PropertyElement.GetNextToken();
822                 
823                 intPrevValue = intiter->second;
824                 
825                 CaptureString(&PropertyValue, FALSE);
826                 
827                 if (PropertyName == wxT("TYPE")){
829                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
830                                 PropertyValue == wxT("work") ){
832                                 FullNamesListType.erase(*FNCount);
833                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
834                 
835                         }
836                         
837                         PropertyMatched = TRUE;
838                 
839                 }
840                 
841                 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
842                 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
843                 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
844                 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
845                 
846                 if (PropertyMatched == TRUE){
847                 
848                         PropertyMatched = FALSE;
849                         continue;
850                 
851                 }
852                 
853                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
854                         
855                         if (FirstToken == TRUE){
856                                 
857                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
858                                 FirstToken = FALSE;
859                                 
860                         } else {
861                         
862                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
863                                 
864                         }
865                         
866                 } 
867         
868         }
870         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
872         if (!PropertyTokens.IsEmpty()){
873         
874                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
875         
876         }
880 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
882         std::map<int, int> SplitPoints;
883         std::map<int, int> SplitLength;
885         int intPrevValue = 3;
886         int intPref = 0;                        
887         int intType = 0;
888         
889         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
890         
891         intPrevValue = 2;
892         
893         wxString PropertyName;
894         wxString PropertyValue;
895         wxString PropertyData;
896         wxString PropertyTokens;
897         std::map<int,int>::iterator SLiter;
898         bool FirstToken = TRUE;
899         
900         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
901         intiter != SplitPoints.end(); ++intiter){
902         
903                 SLiter = SplitLength.find(intiter->first);
904         
905                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
906                 
907                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
908                 PropertyName = PropertyElement.GetNextToken();                          
909                 PropertyValue = PropertyElement.GetNextToken();
910                 
911                 intPrevValue = intiter->second;
912                 
913                 CaptureString(&PropertyValue, FALSE);
914                 
915                 if (PropertyName == wxT("ALTID")){
917                         NameAltID = PropertyValue;
918                 
919                 } else if (PropertyName == wxT("LANGUAGE")){
920                 
921                         NameLanguage = PropertyValue;
922                 
923                 } else if (PropertyName == wxT("SORT-AS")){
924                 
925                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
926                                 PropertyValue.Len() >= 3){
927                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
928                         }
929                 
930                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
931                         
932                         if (FirstToken == TRUE){
933                                 
934                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
935                                 FirstToken = FALSE;
936                                 
937                         } else {
938                         
939                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
940                                 
941                         }
942                         
943                 }
944         
945         }
946         
947         // Split the name data.
948         
949         int intSplitSeek = 0;           
950         int intSplitsFound = 0;
951         int intSplitSize = 0;
952         int intPropertyLen = PropertySeg2.Len();
953         
954         std::map<int,wxString> NameValues;
955         intPrevValue = 0;                                       
956         
957         for (int i = 0; i <= intPropertyLen; i++){
958         
959                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
960                         
961                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
962                         
963                         intSplitSeek = i;
964                         intSplitSeek++;
965                         
966                         if (intSplitsFound == 4){
967                         
968                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
969                                 break;
970                         
971                         }
972                         
973                         intSplitSize = 0;
974                         continue;
975         
976                 }
977                 
978                 intSplitSize++;
980         }
981         
982         // Split the data into several parts.
983                         
984         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
985         iter != NameValues.end(); ++iter){
986         
987                 if (iter->first == 1){
988                 
989                         // Deal with family name.
990                         
991                         NameSurname = iter->second;
992                 
993                 } else if (iter->first == 2){
994                 
995                         // Deal with given names.
996                         
997                         NameForename = iter->second;
998                 
999                 } else if (iter->first == 3){
1000                 
1001                         // Deal with additional names.
1002                         
1003                         NameOtherNames = iter->second;
1004                 
1005                 } else if (iter->first == 4){
1006                 
1007                         // Deal with honorifix prefixes and suffixes.
1009                         NameTitle = iter->second;
1010                 
1011                         iter++;
1012                         
1013                         if (iter == NameValues.end()){
1014                         
1015                                 break;
1016                         
1017                         }
1018                 
1019                         NameSuffix = iter->second;
1020                 
1021                 }
1022         
1023         }
1024         
1025         // Add the name token data.
1026         
1027         if (!PropertyTokens.IsEmpty()){
1028         
1029                 NameTokens = PropertyTokens;
1030         
1031         }
1035 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1037         size_t intPropertyLen = PropertySeg1.Len();
1038         std::map<int, int> SplitPoints;
1039         std::map<int, int> SplitLength;
1040         std::map<int, int>::iterator SLiter;                    
1041         wxString PropertyData;
1042         wxString PropertyName;
1043         wxString PropertyValue;
1044         wxString PropertyTokens;
1045         bool FirstToken = TRUE;
1046         int intSplitsFound = 0;
1047         int intSplitSize = 0;
1048         int intPrevValue = 14;
1049         int intPref = 0;                        
1050         int intType = 0;
1051         
1052         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1053         
1054         intPrevValue = 13;
1056         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1057         intiter != SplitPoints.end(); ++intiter){
1058         
1059                 SLiter = SplitLength.find(intiter->first);
1060         
1061                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1062                 
1063                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1064                 PropertyName = PropertyElement.GetNextToken();                          
1065                 PropertyValue = PropertyElement.GetNextToken();
1066                 
1067                 intPrevValue = intiter->second;
1068                 
1069                 // Process properties.
1070                                 
1071                 CaptureString(&PropertyValue, FALSE);
1072                                         
1073                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1074                                                         
1075                         if (FirstToken == TRUE){
1076                                 
1077                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1078                                 FirstToken = FALSE;
1079                                 
1080                         } else {
1081                                 
1082                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1083                                 
1084                         }
1085                 
1086                 }
1087         
1088         }       
1089         
1090         CaptureString(&PropertySeg2, FALSE);
1091         
1092         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1093         
1094         if (!PropertyTokens.IsEmpty()){
1095         
1096                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1097         
1098         }
1102 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1104         std::map<int, int> SplitPoints;
1105         std::map<int, int> SplitLength;
1107         int intPrevValue = 10;
1108         int intPref = 0;                        
1109         
1110         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1111         
1112         intPrevValue = 9;
1113         
1114         PropertyType PropType = PROPERTY_NONE;
1115         
1116         // Look for type before continuing.
1117         
1118         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1119         
1120         intPrevValue = 9;
1121         
1122         std::map<int, wxString> *NicknamesList = NULL;
1123         std::map<int, wxString> *NicknamesListType = NULL;
1124         std::map<int, wxString> *NicknamesListLanguage = NULL;
1125         std::map<int, wxString> *NicknamesListAltID = NULL;
1126         std::map<int, wxString> *NicknamesListPID = NULL;
1127         std::map<int, wxString> *NicknamesListTokens = NULL;            
1128         std::map<int, int> *NicknamesListPref = NULL;
1129         
1130         switch(PropType){
1131                 case PROPERTY_NONE:
1132                         NicknamesList = &GeneralNicknamesList;
1133                         NicknamesListType = &GeneralNicknamesListType;
1134                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1135                         NicknamesListAltID = &GeneralNicknamesListAltID;
1136                         NicknamesListPID = &GeneralNicknamesListPID;
1137                         NicknamesListTokens = &GeneralNicknamesListTokens;
1138                         NicknamesListPref = &GeneralNicknamesListPref;
1139                         break;
1140                 case PROPERTY_HOME:
1141                         NicknamesList = &HomeNicknamesList;
1142                         NicknamesListType = &HomeNicknamesListType;
1143                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1144                         NicknamesListAltID = &HomeNicknamesListAltID;
1145                         NicknamesListPID = &HomeNicknamesListPID;
1146                         NicknamesListTokens = &HomeNicknamesListTokens;
1147                         NicknamesListPref = &HomeNicknamesListPref;
1148                         break;
1149                 case PROPERTY_WORK:
1150                         NicknamesList = &BusinessNicknamesList;
1151                         NicknamesListType = &BusinessNicknamesListType;
1152                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1153                         NicknamesListAltID = &BusinessNicknamesListAltID;
1154                         NicknamesListPID = &BusinessNicknamesListPID;
1155                         NicknamesListTokens = &BusinessNicknamesListTokens;
1156                         NicknamesListPref = &BusinessNicknamesListPref;
1157                         break;
1158         }
1159         
1160         std::map<int, int>::iterator SLiter;    
1161         wxString PropertyData;
1162         wxString PropertyName;
1163         wxString PropertyValue;
1164         wxString PropertyTokens;
1165         bool FirstToken = TRUE;
1166         bool PropertyMatched = FALSE;
1167         
1168         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1169         intiter != SplitPoints.end(); ++intiter){
1170         
1171                 SLiter = SplitLength.find(intiter->first);
1172         
1173                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1174                 
1175                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1176                 PropertyName = PropertyElement.GetNextToken();                          
1177                 PropertyValue = PropertyElement.GetNextToken();
1178                 
1179                 intPrevValue = intiter->second;
1180                 
1181                 CaptureString(&PropertyValue, FALSE);
1182                 
1183                 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1184                 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1185                 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1186                 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1187                 
1188                 if (PropertyMatched == TRUE){
1189                 
1190                         PropertyMatched = FALSE;
1191                         continue;
1192                 
1193                 }
1194                 
1195                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1196         
1197                         if (FirstToken == TRUE){
1198                 
1199                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1200                                 FirstToken = FALSE;
1201                 
1202                         } else {
1203                 
1204                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1205                 
1206                         }
1207         
1208                 }
1209                 
1210         }
1211         
1212         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1213         
1214         // Add the name token data.
1215         
1216         if (!PropertyTokens.IsEmpty()){
1217         
1218                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1219         
1220         }
1224 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1226         std::map<int, int> SplitPoints;
1227         std::map<int, int> SplitLength;
1228         std::map<int, int>::iterator SLiter;                    
1229         wxString PropertyData;
1230         wxString PropertyName;
1231         wxString PropertyValue;
1232         wxString PropertyTokens;
1233         bool FirstToken = TRUE;
1234         int intPrevValue = 8;
1236         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1238         intPrevValue = 7;                       
1239         
1240         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1241         intiter != SplitPoints.end(); ++intiter){
1242         
1243                 SLiter = SplitLength.find(intiter->first);
1244         
1245                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1246                 
1247                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1248                 PropertyName = PropertyElement.GetNextToken();                          
1249                 PropertyValue = PropertyElement.GetNextToken();
1250                 
1251                 intPrevValue = intiter->second;
1252                 
1253                 // Process properties.
1254                 
1255                 size_t intPropertyValueLen = PropertyValue.Len();
1256                 
1257                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1258                         
1259                         PropertyValue.Trim();
1260                         PropertyValue.RemoveLast();
1261                         
1262                 }                               
1263                 
1264                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1265                         
1266                         PropertyValue.Remove(0, 1);
1267                         
1268                 }                               
1269                 
1270                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1272                         if (FirstToken == TRUE){
1273         
1274                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1275                                 FirstToken = FALSE;
1276         
1277                         } else {
1278         
1279                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1280         
1281                         }
1283                 }
1284         
1285         }       
1287         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1288         
1289         wxString GenderComponent;
1290         
1291         if (GenderData.CountTokens() >= 2){
1292         
1293                 Gender = GenderData.GetNextToken();
1294                 GenderDetails = GenderData.GetString();
1295         
1296                 CaptureString(&GenderDetails, FALSE);
1297                                                 
1298         } else {
1299         
1300                 Gender = GenderData.GetNextToken();
1301         
1302         }
1303         
1304         if (!PropertyTokens.IsEmpty()){
1305         
1306                 GenderTokens = PropertyTokens;
1307         
1308         }
1312 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1314         // Process date. Preserve the remainder in the string.
1316         std::map<int, int> SplitPoints;
1317         std::map<int, int> SplitLength;
1318         std::map<int, int>::iterator SLiter;                    
1319         wxString PropertyData;
1320         wxString PropertyName;
1321         wxString PropertyValue;
1322         wxString PropertyTokens;
1323         bool BirthdayText = FALSE;
1324         int intPrevValue = 6;
1326         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1328         intPrevValue = 5;
1330         // Look for type before continuing.
1332         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1333         intiter != SplitPoints.end(); ++intiter){
1335                 SLiter = SplitLength.find(intiter->first);
1337                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1338         
1339                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1340                 PropertyName = PropertyElement.GetNextToken();                          
1341                 PropertyValue = PropertyElement.GetNextToken();
1342         
1343                 intPrevValue = intiter->second;
1344         
1345                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1346         
1347                         CaptureString(&PropertySeg2, FALSE);
1348                         Birthday = PropertySeg2;
1349                         BirthdayText = TRUE;
1350         
1351                 }
1353         }
1355         // Setup blank lines for later on.
1356         
1357         intPrevValue = 5;
1358         bool FirstToken = TRUE;
1360         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1361         intiter != SplitPoints.end(); ++intiter){
1363                 SLiter = SplitLength.find(intiter->first);
1365                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1366         
1367                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1368                 PropertyName = PropertyElement.GetNextToken();                          
1369                 PropertyValue = PropertyElement.GetNextToken();
1370         
1371                 intPrevValue = intiter->second;
1372         
1373                 // Process properties.
1374         
1375                 CaptureString(&PropertyValue, FALSE);
1376         
1377                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1378                 
1379                         PropertyValue.Trim();
1380                         PropertyValue.RemoveLast();
1381                 
1382                 }                               
1383         
1384                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1385                 
1386                         PropertyValue.Remove(0, 1);
1387                 
1388                 }                               
1389         
1390                 if (PropertyName == wxT("ALTID")){
1392                         BirthdayAltID = PropertyValue;
1393         
1394                 } else if (PropertyName == wxT("CALSCALE")){
1395         
1396                         BirthdayCalScale = PropertyValue;
1397         
1398                 } else if (PropertyName != wxT("VALUE")) {
1399         
1400                         // Something else we don't know about so append
1401                         // to the tokens variable.
1402                 
1403                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1404                 
1405                                 if (FirstToken == TRUE){
1406         
1407                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1408                                         FirstToken = FALSE;
1409         
1410                                 } else {
1411         
1412                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1413         
1414                                 }
1415                                 
1416                         }
1417                         
1418                 }
1420         }       
1422         // Add the data to the variables and form.
1423         
1424         if (BirthdayText == FALSE){
1425         
1426                 Birthday = PropertySeg2;
1428         }
1429         
1430         if (!PropertyTokens.IsEmpty()){
1431         
1432                 BirthdayTokens = PropertyTokens;
1434         }
1438 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1440         // Process date. Preserve the remainder in the string.
1442         std::map<int, int> SplitPoints;
1443         std::map<int, int> SplitLength;
1444         std::map<int, int>::iterator SLiter;                    
1445         wxString PropertyData;
1446         wxString PropertyName;
1447         wxString PropertyValue;
1448         wxString PropertyTokens;
1449         bool AnniversaryText = FALSE;
1450         int intPrevValue = 13;
1452         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1454         intPrevValue = 12;
1456         // Look for type before continuing.
1458         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1459         intiter != SplitPoints.end(); ++intiter){
1461                 SLiter = SplitLength.find(intiter->first);
1463                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1464         
1465                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1466                 PropertyName = PropertyElement.GetNextToken();                          
1467                 PropertyValue = PropertyElement.GetNextToken();
1468         
1469                 intPrevValue = intiter->second;
1470         
1471                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1472         
1473                         CaptureString(&PropertySeg2, FALSE);
1474                         Anniversary = PropertySeg2;
1475                         AnniversaryText = TRUE;
1476         
1477                 }
1479         }
1481         // Setup blank lines for later on.
1482         
1483         intPrevValue = 12;
1484         bool FirstToken = TRUE;
1486         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1487         intiter != SplitPoints.end(); ++intiter){
1489                 SLiter = SplitLength.find(intiter->first);
1491                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1492         
1493                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1494                 PropertyName = PropertyElement.GetNextToken();                          
1495                 PropertyValue = PropertyElement.GetNextToken();
1496         
1497                 intPrevValue = intiter->second;
1498         
1499                 // Process properties.
1500         
1501                 CaptureString(&PropertyValue, FALSE);
1502         
1503                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1504                 
1505                         PropertyValue.Trim();
1506                         PropertyValue.RemoveLast();
1507                 
1508                 }                               
1509         
1510                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1511                 
1512                         PropertyValue.Remove(0, 1);
1513                 
1514                 }                               
1515         
1516                 if (PropertyName == wxT("ALTID")){
1518                         AnniversaryAltID = PropertyValue;
1519         
1520                 } else if (PropertyName == wxT("CALSCALE")){
1521         
1522                         AnniversaryCalScale = PropertyValue;
1523         
1524                 } else if (PropertyName != wxT("VALUE")) {
1525         
1526                         // Something else we don't know about so append
1527                         // to the tokens variable.
1528                 
1529                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1530                 
1531                                 if (FirstToken == TRUE){
1532         
1533                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1534                                         FirstToken = FALSE;
1535         
1536                                 } else {
1537         
1538                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1539         
1540                                 }
1541                                 
1542                         }
1543                         
1544                 }
1546         }       
1548         // Add the data to the variables and form.
1549         
1550         if (AnniversaryText == FALSE){
1551         
1552                 Anniversary = PropertySeg2;
1554         }
1555         
1556         if (!PropertyTokens.IsEmpty()){
1557         
1558                 AnniversaryTokens = PropertyTokens;
1560         }
1564 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1566         std::map<int, int> SplitPoints;
1567         std::map<int, int> SplitLength;
1569         int intPrevValue = 4;
1570         int intPref = 0;                        
1571         
1572         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1573         
1574         intPrevValue = 3;
1575         
1576         PropertyType PropType = PROPERTY_NONE;
1577         
1578         // Look for type before continuing.
1579         
1580         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1581         
1582         intPrevValue = 3;
1583         
1584         std::map<int, wxString> *TZList = NULL;
1585         std::map<int, wxString> *TZListType = NULL;
1586         std::map<int, wxString> *TZListMediatype = NULL;
1587         std::map<int, wxString> *TZListAltID = NULL;
1588         std::map<int, wxString> *TZListPID = NULL;
1589         std::map<int, wxString> *TZListTokens = NULL;           
1590         std::map<int, int> *TZListPref = NULL;
1591         
1592         switch(PropType){
1593                 case PROPERTY_NONE:
1594                         TZList = &GeneralTZList;
1595                         TZListType = &GeneralTZListType;
1596                         TZListMediatype = &GeneralTZListMediatype;
1597                         TZListAltID = &GeneralTZListAltID;
1598                         TZListPID = &GeneralTZListPID;
1599                         TZListTokens = &GeneralTZListTokens;
1600                         TZListPref = &GeneralTZListPref;
1601                         break;
1602                 case PROPERTY_HOME:
1603                         TZList = &HomeTZList;
1604                         TZListType = &HomeTZListType;
1605                         TZListMediatype = &HomeTZListMediatype;
1606                         TZListAltID = &HomeTZListAltID;
1607                         TZListPID = &HomeTZListPID;
1608                         TZListTokens = &HomeTZListTokens;
1609                         TZListPref = &HomeTZListPref;
1610                         break;
1611                 case PROPERTY_WORK:
1612                         TZList = &BusinessTZList;
1613                         TZListType = &BusinessTZListType;
1614                         TZListMediatype = &BusinessTZListMediatype;
1615                         TZListAltID = &BusinessTZListAltID;
1616                         TZListPID = &BusinessTZListPID;
1617                         TZListTokens = &BusinessTZListTokens;
1618                         TZListPref = &BusinessTZListPref;
1619                         break;
1620         }
1621         
1622         std::map<int, int>::iterator SLiter;    
1623         wxString PropertyData;
1624         wxString PropertyName;
1625         wxString PropertyValue;
1626         wxString PropertyTokens;
1627         bool FirstToken = TRUE;
1628         bool PropertyMatched = FALSE;
1629         
1630         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1631         intiter != SplitPoints.end(); ++intiter){
1632         
1633                 SLiter = SplitLength.find(intiter->first);
1634         
1635                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1636                 
1637                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1638                 PropertyName = PropertyElement.GetNextToken();                          
1639                 PropertyValue = PropertyElement.GetNextToken();
1640                 
1641                 intPrevValue = intiter->second;
1642                 
1643                 CaptureString(&PropertyValue, FALSE);
1645                 ProcessStringValue(&PropertyName, "ALTID", TZListAltID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1646                 ProcessStringValue(&PropertyName, "PID", TZListPID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1647                 ProcessStringValue(&PropertyName, "MEDIATYPE", TZListMediatype, &PropertyValue, TimeZoneCount, &PropertyMatched);
1648                 ProcessIntegerValue(&PropertyName, "PREF", TZListPref, &PropertyValue, TimeZoneCount, &PropertyMatched);
1649                 
1650                 if (PropertyMatched == TRUE){
1651                 
1652                         PropertyMatched = FALSE;
1653                         continue;
1654                 
1655                 }
1657                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1658         
1659                         if (FirstToken == TRUE){
1660                 
1661                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1662                                 FirstToken = FALSE;
1663                 
1664                         } else {
1665                 
1666                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1667                 
1668                         }
1669         
1670                 }
1671                 
1672         }
1673         
1674         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1675         
1676         // Add the name token data.
1677         
1678         if (!PropertyTokens.IsEmpty()){
1679         
1680                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1681         
1682         }
1687 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1689         size_t intPropertyLen = PropertySeg1.Len();
1690         std::map<int, int> SplitPoints;
1691         std::map<int, int> SplitLength;
1692         std::map<int, int>::iterator SLiter;                    
1693         wxString PropertyData;
1694         wxString PropertyName;
1695         wxString PropertyValue;
1696         wxString PropertyTokens;
1697         wxString AddressLabel;
1698         wxString AddressLang;
1699         wxString AddressAltID;
1700         wxString AddressPID;
1701         wxString AddressTokens;
1702         wxString AddressGeo;
1703         wxString AddressTimezone;
1704         wxString AddressType;
1705         wxString AddressMediatype;
1706         wxString AddressPOBox;
1707         wxString AddressExtended;
1708         wxString AddressStreet;
1709         wxString AddressLocality;
1710         wxString AddressCity;
1711         wxString AddressRegion;
1712         wxString AddressPostalCode;
1713         wxString AddressCountry;
1714         bool FirstToken = TRUE;                 
1715         int intSplitsFound = 0;
1716         int intSplitSize = 0;
1717         int intPrevValue = 5;
1718         int intPref = 0;                        
1719         int intType = 0;
1720         long ListCtrlIndex;
1721         bool PropertyMatched = FALSE;
1722         
1723         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1724         
1725         intPrevValue = 4;
1726         
1727         PropertyType PropType = PROPERTY_NONE;
1728                 
1729         // Look for type before continuing.
1730         
1731         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1732         
1733         intPrevValue = 4;
1734         
1735         std::map<int, wxString> *AddressList = NULL;
1736         std::map<int, wxString> *AddressListTown = NULL;
1737         std::map<int, wxString> *AddressListCounty = NULL;
1738         std::map<int, wxString> *AddressListPostCode = NULL;
1739         std::map<int, wxString> *AddressListCountry = NULL;
1740         std::map<int, wxString> *AddressListLabel = NULL;
1741         std::map<int, wxString> *AddressListLang = NULL;                
1742         std::map<int, wxString> *AddressListAltID = NULL;
1743         std::map<int, wxString> *AddressListPID = NULL;
1744         std::map<int, wxString> *AddressListTokens = NULL;
1745         std::map<int, wxString> *AddressListGeo = NULL;
1746         std::map<int, wxString> *AddressListTimezone = NULL;            
1747         std::map<int, wxString> *AddressListType = NULL;
1748         std::map<int, wxString> *AddressListMediatype = NULL;
1749         std::map<int, int> *AddressListPref = NULL;
1751         switch(PropType){
1752                 case PROPERTY_NONE:
1753                         AddressList = &GeneralAddressList;
1754                         AddressListTown = &GeneralAddressListTown;
1755                         AddressListCounty = &GeneralAddressListCounty;
1756                         AddressListPostCode = &GeneralAddressListPostCode;
1757                         AddressListCountry = &GeneralAddressListCountry;
1758                         AddressListLabel = &GeneralAddressListLabel;
1759                         AddressListLang = &GeneralAddressListLang;              
1760                         AddressListAltID = &GeneralAddressListAltID;
1761                         AddressListPID = &GeneralAddressListPID;
1762                         AddressListTokens = &GeneralAddressListTokens;
1763                         AddressListGeo = &GeneralAddressListGeo;
1764                         AddressListTimezone = &GeneralAddressListTimezone;
1765                         AddressListType = &GeneralAddressListType;
1766                         AddressListMediatype = &GeneralAddressListMediatype;
1767                         AddressListPref = &GeneralAddressListPref;              
1768                         break;
1769                 case PROPERTY_HOME:
1770                         AddressList = &HomeAddressList;
1771                         AddressListTown = &HomeAddressListTown;
1772                         AddressListCounty = &HomeAddressListCounty;
1773                         AddressListPostCode = &HomeAddressListPostCode;
1774                         AddressListCountry = &HomeAddressListCountry;
1775                         AddressListLabel = &HomeAddressListLabel;
1776                         AddressListLang = &HomeAddressListLang;         
1777                         AddressListAltID = &HomeAddressListAltID;
1778                         AddressListPID = &HomeAddressListPID;
1779                         AddressListTokens = &HomeAddressListTokens;
1780                         AddressListGeo = &HomeAddressListGeo;
1781                         AddressListTimezone = &HomeAddressListTimezone;
1782                         AddressListType = &HomeAddressListType;
1783                         AddressListMediatype = &HomeAddressListMediatype;
1784                         AddressListPref = &HomeAddressListPref;
1785                         break;
1786                 case PROPERTY_WORK:
1787                         AddressList = &BusinessAddressList;
1788                         AddressListTown = &BusinessAddressListTown;
1789                         AddressListCounty = &BusinessAddressListCounty;
1790                         AddressListPostCode = &BusinessAddressListPostCode;
1791                         AddressListCountry = &BusinessAddressListCountry;
1792                         AddressListLabel = &BusinessAddressListLabel;
1793                         AddressListLang = &BusinessAddressListLang;             
1794                         AddressListAltID = &BusinessAddressListAltID;
1795                         AddressListPID = &BusinessAddressListPID;
1796                         AddressListTokens = &BusinessAddressListTokens;
1797                         AddressListGeo = &BusinessAddressListGeo;
1798                         AddressListTimezone = &BusinessAddressListTimezone;
1799                         AddressListType = &BusinessAddressListType;
1800                         AddressListMediatype = &BusinessAddressListMediatype;
1801                         AddressListPref = &BusinessAddressListPref;
1802                         break;
1803         }
1804         
1805         intPrevValue = 4;
1806         
1807         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1808         intiter != SplitPoints.end(); ++intiter){
1809         
1810                 SLiter = SplitLength.find(intiter->first);
1811         
1812                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1813                 
1814                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1815                 PropertyName = PropertyElement.GetNextToken();                          
1816                 PropertyValue = PropertyElement.GetNextToken();
1817                 
1818                 intPrevValue = intiter->second;
1819                 
1820                 CaptureString(&PropertyValue, FALSE);
1821                 
1822                 // Process properties.
1823                 
1824                 ProcessStringValue(&PropertyName, "LABEL", AddressListLabel, &PropertyValue, AddressCount, &PropertyMatched);
1825                 ProcessStringValue(&PropertyName, "LANGUAGE", AddressListLang, &PropertyValue, AddressCount, &PropertyMatched);
1826                 ProcessStringValue(&PropertyName, "ALTID", AddressListAltID, &PropertyValue, AddressCount, &PropertyMatched);
1827                 ProcessStringValue(&PropertyName, "PID", AddressListPID, &PropertyValue, AddressCount, &PropertyMatched);
1828                 ProcessStringValue(&PropertyName, "GEO", AddressListGeo, &PropertyValue, AddressCount, &PropertyMatched);
1829                 ProcessStringValue(&PropertyName, "TZ", AddressListTimezone, &PropertyValue, AddressCount, &PropertyMatched);
1830                 ProcessStringValue(&PropertyName, "MEDIATYPE", AddressListMediatype, &PropertyValue, AddressCount, &PropertyMatched);
1831                 ProcessIntegerValue(&PropertyName, "PREF", AddressListPref, &PropertyValue, AddressCount, &PropertyMatched);
1832                 
1833                 if (PropertyMatched == TRUE){
1834                 
1835                         PropertyMatched = FALSE;
1836                         continue;
1837                 
1838                 }
1839                 
1840                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1841                 
1842                         if (FirstToken == TRUE){
1843                         
1844                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1845                                 FirstToken = FALSE;
1846                         
1847                         } else {
1848                         
1849                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1850                         
1851                         }
1852                         
1853                 }
1854         
1855         }                       
1856         
1857         // Split the address. 
1859         //std::map<int, int>::iterator SLiter;
1860         intPropertyLen = PropertySeg2.Len();
1861         SplitPoints.clear();
1862         SplitLength.clear();
1863         intSplitsFound = 0;
1864         intSplitSize = 0;
1865         intPrevValue = 0;
1866         
1867         for (int i = 0; i <= intPropertyLen; i++){
1869                 intSplitSize++;
1870         
1871                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1872         
1873                         intSplitsFound++;
1874                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1875                         
1876                         if (intSplitsFound == 6){ 
1877                         
1878                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1879                                 break; 
1880                                 
1881                         } else {
1882                         
1883                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1884                         
1885                         }
1886                         
1887                         intSplitSize = 0;                                       
1888         
1889                 }
1891         }
1892         
1893         // Split the data into several parts.                   
1894         
1895         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1896         intiter != SplitPoints.end(); ++intiter){
1897                         
1898                 if (intiter->first == 1){
1899                 
1900                         // Deal with PO Box.
1901                         
1902                         SLiter = SplitLength.find(1);
1903                                                                 
1904                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1905                         intPrevValue = intiter->second;
1906                 
1907                 } else if (intiter->first == 2){
1908                 
1909                         // Deal with extended address.
1910                         
1911                         SLiter = SplitLength.find(2);
1912                         
1913                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1914                         intPrevValue = intiter->second;
1915                 
1916                 } else if (intiter->first == 3){
1917                 
1918                         // Deal with street address.
1919                         
1920                         SLiter = SplitLength.find(3);
1921                                                                 
1922                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1923                         intPrevValue = intiter->second;
1924                 
1925                 } else if (intiter->first == 4){
1926                 
1927                         // Deal with locality
1929                         SLiter = SplitLength.find(4);
1930                         
1931                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1932                         intPrevValue = intiter->second;
1933                 
1934                 } else if (intiter->first == 5){
1935                 
1936                         // Deal with region.
1938                         SLiter = SplitLength.find(5);
1939                         
1940                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1941                         intPrevValue = intiter->second;
1942                         
1943                 
1944                 } else if (intiter->first == 6){
1945                 
1946                         // Deal with post code.
1948                         SLiter = SplitLength.find(6);
1949                         
1950                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1951                         intPrevValue = intiter->second;
1952                         
1953                         // Deal with country.
1954                                                 
1955                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1957                         break;
1958                 
1959                 }
1960         
1961         }       
1962         
1963         // Add the data to the General/Home/Work address variables.
1964         
1965         CaptureString(&AddressStreet, FALSE); 
1966         CaptureString(&AddressLocality, FALSE);
1967         CaptureString(&AddressRegion, FALSE);
1968         CaptureString(&AddressPostalCode, FALSE);
1969         CaptureString(&AddressCountry, FALSE);
1970                 
1971         if (!PropertyTokens.IsEmpty()){
1972         
1973                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1974         
1975         }
1977         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1978         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1979         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1980         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1981         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1983         switch(PropType){
1984                 case PROPERTY_NONE:
1985                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1986                         break;
1987                 case PROPERTY_HOME:
1988                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1989                         break;
1990                 case PROPERTY_WORK:
1991                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1992                         break;
1993         }
1994         
1995         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1999 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2001         std::map<int, int> SplitPoints;
2002         std::map<int, int> SplitLength;
2004         int intPrevValue = 7;
2005         int intPref = 0;                        
2006         
2007         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2008         
2009         intPrevValue = 6;
2010         
2011         PropertyType PropType = PROPERTY_NONE;
2012                 
2013         // Look for type before continuing.
2014         
2015         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2016         
2017         std::map<int, wxString> *EmailList = NULL;
2018         std::map<int, wxString> *EmailListType = NULL;
2019         std::map<int, wxString> *EmailListAltID = NULL;
2020         std::map<int, wxString> *EmailListPID = NULL;
2021         std::map<int, wxString> *EmailListTokens = NULL;                
2022         std::map<int, int> *EmailListPref = NULL;
2024         switch(PropType){
2025                 case PROPERTY_NONE:
2026                         EmailList = &GeneralEmailList;
2027                         EmailListType = &GeneralEmailListType;
2028                         EmailListAltID = &GeneralEmailListAltID;
2029                         EmailListPID = &GeneralEmailListPID;
2030                         EmailListTokens = &GeneralEmailListTokens;              
2031                         EmailListPref = &GeneralEmailListPref;  
2032                         break;
2033                 case PROPERTY_HOME:
2034                         EmailList = &HomeEmailList;
2035                         EmailListType = &HomeEmailListType;
2036                         EmailListAltID = &HomeEmailListAltID;
2037                         EmailListPID = &HomeEmailListPID;
2038                         EmailListTokens = &HomeEmailListTokens;         
2039                         EmailListPref = &HomeEmailListPref;     
2040                         break;
2041                 case PROPERTY_WORK:
2042                         EmailList = &BusinessEmailList;
2043                         EmailListType = &BusinessEmailListType;
2044                         EmailListAltID = &BusinessEmailListAltID;
2045                         EmailListPID = &BusinessEmailListPID;
2046                         EmailListTokens = &BusinessEmailListTokens;             
2047                         EmailListPref = &BusinessEmailListPref; 
2048                         break;
2049         }
2050         
2051         intPrevValue = 6;
2052         
2053         std::map<int,int>::iterator SLiter;
2054         wxString PropertyData;
2055         wxString PropertyName;
2056         wxString PropertyValue;
2057         wxString PropertyTokens;
2058         bool FirstToken = TRUE;
2059         bool PropertyMatched = FALSE;
2060         
2061         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2062         intiter != SplitPoints.end(); ++intiter){
2063         
2064                 SLiter = SplitLength.find(intiter->first);
2065         
2066                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2067                 
2068                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2069                 PropertyName = PropertyElement.GetNextToken();                          
2070                 PropertyValue = PropertyElement.GetNextToken();
2071                 
2072                 intPrevValue = intiter->second;
2073                 
2074                 CaptureString(&PropertyValue, FALSE);
2075                 
2076                 // Process properties.
2077                 
2078                 ProcessStringValue(&PropertyName, "ALTID", EmailListAltID, &PropertyValue, EmailCount, &PropertyMatched);
2079                 ProcessStringValue(&PropertyName, "PID", EmailListPID, &PropertyValue, EmailCount, &PropertyMatched);
2080                 ProcessIntegerValue(&PropertyName, "PREF", EmailListPref, &PropertyValue, EmailCount, &PropertyMatched);
2081                 
2082                 if (PropertyMatched == TRUE){
2083                 
2084                         PropertyMatched = FALSE;
2085                         continue;
2086                 
2087                 }
2088                 
2089                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2090                         
2091                         if (FirstToken == TRUE){
2092                         
2093                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2094                                 FirstToken = FALSE;
2095                         
2096                         } else {
2097                         
2098                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2099                         
2100                         }
2101                         
2102                 }
2103         
2104         }
2105         
2106         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2107         
2108         // Add the name token data.
2109         
2110         if (!PropertyTokens.IsEmpty()){
2111         
2112                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2113         
2114         }       
2119 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2121         std::map<int, int> SplitPoints;
2122         std::map<int, int> SplitLength;
2124         int intPrevValue = 6;
2125         int intPref = 0;                        
2126         
2127         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2128         
2129         intPrevValue = 5;
2130         
2131         PropertyType PropType = PROPERTY_NONE;
2132                 
2133         // Look for type before continuing.
2134         
2135         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2136         
2137         std::map<int, wxString> *IMList = NULL;
2138         std::map<int, wxString> *IMListType = NULL;
2139         std::map<int, wxString> *IMListAltID = NULL;
2140         std::map<int, wxString> *IMListPID = NULL;
2141         std::map<int, wxString> *IMListTokens = NULL;
2142         std::map<int, wxString> *IMListMediatype = NULL;        
2143         std::map<int, int> *IMListPref = NULL;
2145         switch(PropType){
2146                 case PROPERTY_NONE:
2147                         IMList = &GeneralIMList;
2148                         IMListType = &GeneralIMListType;
2149                         IMListAltID = &GeneralIMListAltID;
2150                         IMListPID = &GeneralIMListPID;
2151                         IMListTokens = &GeneralIMListTokens;
2152                         IMListMediatype = &GeneralIMListMediatype;
2153                         IMListPref = &GeneralIMListPref;        
2154                         break;
2155                 case PROPERTY_HOME:
2156                         IMList = &HomeIMList;
2157                         IMListType = &HomeIMListType;
2158                         IMListAltID = &HomeIMListAltID;
2159                         IMListPID = &HomeIMListPID;
2160                         IMListTokens = &HomeIMListTokens;
2161                         IMListMediatype = &HomeIMListMediatype;         
2162                         IMListPref = &HomeIMListPref;   
2163                         break;
2164                 case PROPERTY_WORK:
2165                         IMList = &BusinessIMList;
2166                         IMListType = &BusinessIMListType;
2167                         IMListAltID = &BusinessIMListAltID;
2168                         IMListPID = &BusinessIMListPID;
2169                         IMListTokens = &BusinessIMListTokens;   
2170                         IMListMediatype = &BusinessIMListMediatype;     
2171                         IMListPref = &BusinessIMListPref;       
2172                         break;
2173         }
2174         
2175         intPrevValue = 5;
2176         
2177         std::map<int,int>::iterator SLiter;
2178         wxString PropertyData;
2179         wxString PropertyName;
2180         wxString PropertyValue;
2181         wxString PropertyTokens;
2182         bool FirstToken = TRUE;
2183         bool PropertyMatched = FALSE;
2184         
2185         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2186         intiter != SplitPoints.end(); ++intiter){
2187         
2188                 SLiter = SplitLength.find(intiter->first);
2189         
2190                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2191                 
2192                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2193                 PropertyName = PropertyElement.GetNextToken();                          
2194                 PropertyValue = PropertyElement.GetNextToken();
2195                 
2196                 intPrevValue = intiter->second;
2197                 
2198                 CaptureString(&PropertyValue, FALSE);
2199                 
2200                 ProcessStringValue(&PropertyName, "ALTID", IMListAltID, &PropertyValue, IMCount, &PropertyMatched);
2201                 ProcessStringValue(&PropertyName, "PID", IMListPID, &PropertyValue, IMCount, &PropertyMatched);
2202                 ProcessStringValue(&PropertyName, "MEDIATYPE", IMListMediatype, &PropertyValue, IMCount, &PropertyMatched);
2203                 ProcessIntegerValue(&PropertyName, "PREF", IMListPref, &PropertyValue, IMCount, &PropertyMatched);
2204                 
2205                 // Process properties.
2206                 
2207                 if (PropertyMatched == TRUE){
2208                         
2209                         PropertyMatched = FALSE;
2210                         continue;
2211                 
2212                 }
2213                 
2214                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2215                 
2216                         if (FirstToken == TRUE){
2217                         
2218                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2219                                 FirstToken = FALSE;
2220                         
2221                         } else {
2222                         
2223                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2224                         
2225                         }
2226                 
2227                 }
2228         
2229         }
2230                 
2231         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2232         
2233         // Add the name token data.
2234         
2235         if (!PropertyTokens.IsEmpty()){
2236         
2237                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2238         
2239         }
2243 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2245         std::map<int, int> SplitPoints;
2246         std::map<int, int> SplitLength;
2247         std::map<int, int>::iterator SLiter;
2248         
2249         int intPref = 0;
2250         
2251         PropertyType PropType = PROPERTY_NONE;
2252                 
2253         // Look for type before continuing.
2254         
2255         wxString TelTypeUI;
2256         wxString TelTypeDetail;
2257         wxString PropertyData;
2258         wxString PropertyName;
2259         wxString PropertyValue;
2260         wxString PropertyTokens;
2261         
2262         std::map<int,int> TypeSplitPoints;
2263         std::map<int,int> TypeSplitLength;
2264         std::map<int,int>::iterator TSLiter;
2265         
2266         int intSplitSize = 0;
2267         int intSplitsFound = 0;
2268         int intSplitPoint = 0;
2269         int intType = 0;
2270         int intPrevValue = 5;
2271                 
2272         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2273         
2274         intPrevValue = 4;
2275         
2276         // Look for type before continuing.
2277         
2278         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2279         intiter != SplitPoints.end(); ++intiter){
2280         
2281                 SLiter = SplitLength.find(intiter->first);
2282         
2283                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2284                 
2285                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2286                 PropertyName = PropertyElement.GetNextToken();                          
2287                 PropertyValue = PropertyElement.GetNextToken();
2288                 
2289                 intPrevValue = intiter->second;
2291                 if (PropertyName == wxT("TYPE")){
2292                 
2293                         // Process each value in type and translate each
2294                         // part.
2295                 
2296                         // Strip out the quotes if they are there.
2297                 
2298                         size_t intPropertyValueLen = PropertyValue.Len();
2299                 
2300                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2301                         
2302                                 PropertyValue.Trim();
2303                                 PropertyValue.RemoveLast();
2304                         
2305                         }                               
2306                 
2307                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2308                         
2309                                 PropertyValue.Remove(0, 1);
2310                         
2311                         }
2312                         
2313                         TelTypeDetail = PropertyValue;
2314                         
2315                         intSplitSize = 0;
2316                         intSplitsFound = 0;
2317                         intSplitPoint = 0;
2318                         
2319                         for (int i = 0; i <= intPropertyValueLen; i++){
2320         
2321                                 intSplitSize++;
2322         
2323                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2324         
2325                                         if (intSplitsFound == 0){
2327                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2328                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2329                         
2330                                         } else {
2331                         
2332                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2333                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2334                         
2335                                         }                       
2337                                         intSplitsFound++;
2338                                         i++;
2339                                         intSplitPoint = i;
2340                                         intSplitSize = 0;
2341         
2342                                 }
2343         
2344                         }
2345                         
2346                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2347                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2348                 
2349                         int intTypeSeek = 0;
2350                 
2351                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2352                         typeiter != TypeSplitPoints.end(); ++typeiter){
2353                         
2354                                 wxString TypePropertyName;
2355                                 
2356                                 TSLiter = TypeSplitLength.find(typeiter->first);
2357                                 
2358                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2359                                 
2360                                 if (intTypeSeek == 0){
2361                                 
2362                                 
2363                                 } else {
2364                                                                                 
2365                                         TelTypeUI.Append(wxT(","));                                                     
2366                                 
2367                                 }
2368                         
2369                                 if (TypePropertyName == wxT("home")){
2370                                 
2371                                         PropType = PROPERTY_HOME;
2372                                 
2373                                 } else if (TypePropertyName == wxT("work")){
2374                                 
2375                                         PropType = PROPERTY_WORK;
2376                                                                         
2377                                 }
2378                                 
2379                                 
2380                                 if (TypePropertyName == wxT("text")){
2381                                 
2382                                         TelTypeUI.Append(_("text"));
2383                                         intTypeSeek++;
2384                                 
2385                                 } else if (TypePropertyName == wxT("voice")){
2386                                 
2387                                         TelTypeUI.Append(_("voice"));
2388                                         intTypeSeek++;
2389                                 
2390                                 } else if (TypePropertyName == wxT("fax")){
2391                                 
2392                                         TelTypeUI.Append(_("fax"));
2393                                         intTypeSeek++;
2394                                 
2395                                 } else if (TypePropertyName == wxT("cell")){
2396                                 
2397                                         TelTypeUI.Append(_("mobile"));
2398                                         intTypeSeek++;
2399                                 
2400                                 } else if (TypePropertyName == wxT("video")){
2401                                 
2402                                         TelTypeUI.Append(_("video"));
2403                                         intTypeSeek++;
2404                                 
2405                                 } else if (TypePropertyName == wxT("pager")){
2406                                 
2407                                         TelTypeUI.Append(_("pager"));
2408                                         intTypeSeek++;
2409                                 
2410                                 } else if (TypePropertyName == wxT("textphone")){
2411                                 
2412                                         TelTypeUI.Append(_("textphone"));
2413                                         intTypeSeek++;
2414                                 
2415                                 }
2416                         
2417                         }
2418                 
2419                 }
2420                 
2421         }
2422         
2423         std::map<int, wxString> *TelephoneList = NULL;
2424         std::map<int, wxString> *TelephoneListType = NULL;
2425         std::map<int, wxString> *TelephoneListAltID = NULL;
2426         std::map<int, wxString> *TelephoneListPID = NULL;
2427         std::map<int, wxString> *TelephoneListTokens = NULL;
2428         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2429         std::map<int, int> *TelephoneListPref = NULL;
2431         switch(PropType){
2432                 case PROPERTY_NONE:
2433                         TelephoneList = &GeneralTelephoneList;
2434                         TelephoneListType = &GeneralTelephoneListType;
2435                         TelephoneListAltID = &GeneralTelephoneListAltID;
2436                         TelephoneListPID = &GeneralTelephoneListPID;
2437                         TelephoneListTokens = &GeneralTelephoneListTokens;
2438                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2439                         TelephoneListPref = &GeneralTelephoneListPref;  
2440                         break;
2441                 case PROPERTY_HOME:
2442                         TelephoneList = &HomeTelephoneList;
2443                         TelephoneListType = &HomeTelephoneListType;
2444                         TelephoneListAltID = &HomeTelephoneListAltID;
2445                         TelephoneListPID = &HomeTelephoneListPID;
2446                         TelephoneListTokens = &HomeTelephoneListTokens;
2447                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2448                         TelephoneListPref = &HomeTelephoneListPref;     
2449                         break;
2450                 case PROPERTY_WORK:
2451                         TelephoneList = &BusinessTelephoneList;
2452                         TelephoneListType = &BusinessTelephoneListType;
2453                         TelephoneListAltID = &BusinessTelephoneListAltID;
2454                         TelephoneListPID = &BusinessTelephoneListPID;
2455                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2456                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2457                         TelephoneListPref = &BusinessTelephoneListPref; 
2458                         break;
2459         }
2460                 
2461         // Process the properties.
2462         
2463         bool FirstToken = TRUE;
2464         
2465         intPrevValue = 5;
2466         SplitPoints.clear();
2467         SplitLength.clear();
2469         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2471         intPrevValue = 4;
2472         
2473         bool PropertyMatched = FALSE;
2474         
2475         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2476         intiter != SplitPoints.end(); ++intiter){
2477         
2478                 SLiter = SplitLength.find(intiter->first);
2479         
2480                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2481                 
2482                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2483                 PropertyName = PropertyElement.GetNextToken();                          
2484                 PropertyValue = PropertyElement.GetNextToken();
2485                 
2486                 intPrevValue = intiter->second;
2487                 
2488                 CaptureString(&PropertyValue, FALSE);
2489                 
2490                 // Process properties.
2491                 
2492                 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2493                 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2494                 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2495                 
2496                 if (PropertyMatched == TRUE){
2497                 
2498                         PropertyMatched = FALSE;
2499                         continue;
2500                 
2501                 }
2503                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2504                 
2505                         if (FirstToken == TRUE){
2506                         
2507                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2508                                 FirstToken = FALSE;
2509                         
2510                         } else {
2511                         
2512                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2513                         
2514                         }
2515                 
2516                 }
2517         
2518         }
2519                 
2520         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2521         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2522         
2523         // Add the name token data.
2524         
2525         if (!PropertyTokens.IsEmpty()){
2526         
2527                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2528         
2529         }
2533 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2535         std::map<int, int> SplitPoints;
2536         std::map<int, int> SplitLength;
2538         int intPrevValue = 6;
2539         int intPref = 0;                        
2540         
2541         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2542         
2543         intPrevValue = 5;
2544         
2545         PropertyType PropType = PROPERTY_NONE;
2546                 
2547         // Look for type before continuing.
2548         
2549         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2550         
2551         std::map<int, wxString> *LanguageList = NULL;
2552         std::map<int, wxString> *LanguageListType = NULL;
2553         std::map<int, wxString> *LanguageListAltID = NULL;
2554         std::map<int, wxString> *LanguageListPID = NULL;
2555         std::map<int, wxString> *LanguageListTokens = NULL;
2556         std::map<int, int> *LanguageListPref = NULL;
2558         switch(PropType){
2559                 case PROPERTY_NONE:
2560                         LanguageList = &GeneralLanguageList;
2561                         LanguageListType = &GeneralLanguageListType;
2562                         LanguageListAltID = &GeneralLanguageListAltID;
2563                         LanguageListPID = &GeneralLanguageListPID;
2564                         LanguageListTokens = &GeneralLanguageListTokens;
2565                         LanguageListPref = &GeneralLanguageListPref;    
2566                         break;
2567                 case PROPERTY_HOME:
2568                         LanguageList = &HomeLanguageList;
2569                         LanguageListType = &HomeLanguageListType;
2570                         LanguageListAltID = &HomeLanguageListAltID;
2571                         LanguageListPID = &HomeLanguageListPID;
2572                         LanguageListTokens = &HomeLanguageListTokens;   
2573                         LanguageListPref = &HomeLanguageListPref;       
2574                         break;
2575                 case PROPERTY_WORK:
2576                         LanguageList = &BusinessLanguageList;
2577                         LanguageListType = &BusinessLanguageListType;
2578                         LanguageListAltID = &BusinessLanguageListAltID;
2579                         LanguageListPID = &BusinessLanguageListPID;
2580                         LanguageListTokens = &BusinessLanguageListTokens;       
2581                         LanguageListPref = &BusinessLanguageListPref;
2582                         break;
2583         }
2584         
2585         intPrevValue = 5;
2586         
2587         std::map<int,int>::iterator SLiter;
2588         wxString PropertyData;
2589         wxString PropertyName;
2590         wxString PropertyValue;
2591         wxString PropertyTokens;
2592         bool FirstToken = TRUE;
2593         bool PropertyMatched = FALSE;
2594         
2595         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2596         intiter != SplitPoints.end(); ++intiter){
2597         
2598                 SLiter = SplitLength.find(intiter->first);
2599         
2600                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2601                 
2602                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2603                 PropertyName = PropertyElement.GetNextToken();                          
2604                 PropertyValue = PropertyElement.GetNextToken();
2605                 
2606                 intPrevValue = intiter->second;
2607                 
2608                 CaptureString(&PropertyValue, FALSE);
2609                 
2610                 // Process properties.
2611                 
2612                 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2613                 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2614                 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2616                 if (PropertyMatched == TRUE){
2617                 
2618                         PropertyMatched = FALSE;
2619                         continue;
2620                 
2621                 }
2622                 
2623                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2624                 
2625                         if (FirstToken == TRUE){
2626                         
2627                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2628                                 FirstToken = FALSE;
2629                         
2630                         } else {
2631                         
2632                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2633                         
2634                         }
2635                 
2636                 }
2637         
2638         }
2639                 
2640         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2641         
2642         // Add the name token data.
2643         
2644         if (!PropertyTokens.IsEmpty()){
2645         
2646                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2647         
2648         }
2652 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2654         std::map<int, int> SplitPoints;
2655         std::map<int, int> SplitLength;
2657         int intPrevValue = 5;
2658         int intPref = 0;                        
2659         
2660         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2661         
2662         intPrevValue = 4;
2663         
2664         PropertyType PropType = PROPERTY_NONE;
2665                 
2666         // Look for type before continuing.
2667         
2668         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2669         
2670         std::map<int, wxString> *GeopositionList = NULL;
2671         std::map<int, wxString> *GeopositionListType = NULL;
2672         std::map<int, wxString> *GeopositionListAltID = NULL;
2673         std::map<int, wxString> *GeopositionListPID = NULL;
2674         std::map<int, wxString> *GeopositionListTokens = NULL;
2675         std::map<int, wxString> *GeopositionListMediatype = NULL;
2676         std::map<int, int> *GeopositionListPref = NULL;
2678         switch(PropType){
2679                 case PROPERTY_NONE:
2680                         GeopositionList = &GeneralGeographyList;
2681                         GeopositionListType = &GeneralGeographyListType;
2682                         GeopositionListAltID = &GeneralGeographyListAltID;
2683                         GeopositionListPID = &GeneralGeographyListPID;
2684                         GeopositionListTokens = &GeneralGeographyListTokens;
2685                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2686                         GeopositionListPref = &GeneralGeographyListPref;        
2687                         break;
2688                 case PROPERTY_HOME:
2689                         GeopositionList = &HomeGeographyList;
2690                         GeopositionListType = &HomeGeographyListType;
2691                         GeopositionListAltID = &HomeGeographyListAltID;
2692                         GeopositionListPID = &HomeGeographyListPID;
2693                         GeopositionListTokens = &HomeGeographyListTokens;
2694                         GeopositionListMediatype = &HomeGeographyListMediatype;
2695                         GeopositionListPref = &HomeGeographyListPref;   
2696                         break;
2697                 case PROPERTY_WORK:
2698                         GeopositionList = &BusinessGeographyList;
2699                         GeopositionListType = &BusinessGeographyListType;
2700                         GeopositionListAltID = &BusinessGeographyListAltID;
2701                         GeopositionListPID = &BusinessGeographyListPID;
2702                         GeopositionListTokens = &BusinessGeographyListTokens;
2703                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2704                         GeopositionListPref = &BusinessGeographyListPref;
2705                         break;
2706         }
2707         
2708         intPrevValue = 4;
2709         
2710         std::map<int,int>::iterator SLiter;
2711         wxString PropertyData;
2712         wxString PropertyName;
2713         wxString PropertyValue;
2714         wxString PropertyTokens;
2715         bool FirstToken = TRUE;
2716         bool PropertyMatched = FALSE;
2717         
2718         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2719         intiter != SplitPoints.end(); ++intiter){
2720         
2721                 SLiter = SplitLength.find(intiter->first);
2722         
2723                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2724                 
2725                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2726                 PropertyName = PropertyElement.GetNextToken();                          
2727                 PropertyValue = PropertyElement.GetNextToken();
2728                 
2729                 intPrevValue = intiter->second;
2730                 
2731                 CaptureString(&PropertyValue, FALSE);
2732                 
2733                 // Process properties.
2734                 
2735                 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2736                 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2737                 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2738                 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2739                 
2740                 if (PropertyMatched == TRUE){
2741                 
2742                         PropertyMatched = FALSE;
2743                         continue;
2744                 
2745                 }
2746                 
2747                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2748                 
2749                         if (FirstToken == TRUE){
2750                         
2751                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2752                                 FirstToken = FALSE;
2753                         
2754                         } else {
2755                         
2756                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2757                         
2758                         }
2759                 
2760                 }
2761         
2762         }
2763                 
2764         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2765         
2766         // Add the name token data.
2767         
2768         if (!PropertyTokens.IsEmpty()){
2769         
2770                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2771         
2772         }
2776 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2778         size_t intPropertyLen = PropertySeg1.Len();
2779         std::map<int, int> SplitPoints;
2780         std::map<int, int> SplitLength;
2781         std::map<int, int>::iterator SLiter;                    
2782         wxString PropertyData;
2783         wxString PropertyName;
2784         wxString PropertyValue;
2785         wxString PropertyTokens;
2786         wxString RelatedType;
2787         wxString RelatedTypeOriginal;                   
2788         wxString RelatedName;
2789         bool FirstToken = TRUE;                 
2790         int intSplitsFound = 0;
2791         int intSplitSize = 0;
2792         int intPrevValue = 9;
2793         int intPref = 0;
2794         long ListCtrlIndex;
2795         
2796         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2797         
2798         intPrevValue = 8;
2799         
2800         // Look for type before continuing.
2801         
2802         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2803         intiter != SplitPoints.end(); ++intiter){
2804         
2805                 SLiter = SplitLength.find(intiter->first);
2806         
2807                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2808                 
2809                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2810                 PropertyName = PropertyElement.GetNextToken();                          
2811                 PropertyValue = PropertyElement.GetNextToken();
2812                 
2813                 intPrevValue = intiter->second;
2814                 
2815                 // Process these.
2816                 
2817                 RelatedTypeOriginal = PropertyValue;
2818                 
2819                 if (PropertyName == wxT("TYPE")){
2820                 
2821                         if (PropertyValue == wxT("contact")){
2823                                 RelatedType = _("Contact");
2825                         } else if (PropertyValue == wxT("acquaintance")){
2827                                 RelatedType = _("Acquaintance");
2829                         } else if (PropertyValue == wxT("friend")){
2831                                 RelatedType = _("Friend");
2833                         } else if (PropertyValue == wxT("met")){
2835                                 RelatedType = _("Met");
2837                         } else if (PropertyValue == wxT("co-worker")){
2839                                 RelatedType = _("Co-worker");
2841                         } else if (PropertyValue == wxT("colleague")){
2843                                 RelatedType = _("Colleague");
2845                         } else if (PropertyValue == wxT("co-resident")){
2847                                 RelatedType = _("Co-resident");
2849                         } else if (PropertyValue == wxT("neighbor")){
2851                                 RelatedType = _("Neighbour");
2853                         } else if (PropertyValue == wxT("child")){
2855                                 RelatedType = _("Child");
2857                         } else if (PropertyValue == wxT("parent")){
2859                                 RelatedType = _("Parent");
2861                         } else if (PropertyValue == wxT("sibling")){
2863                                 RelatedType = _("Sibling");
2865                         } else if (PropertyValue == wxT("spouse")){
2867                                 RelatedType = _("Spouse");
2869                         } else if (PropertyValue == wxT("kin")){
2871                                 RelatedType = _("Kin");
2873                         } else if (PropertyValue == wxT("muse")){
2875                                 RelatedType = _("Muse");
2877                         } else if (PropertyValue == wxT("crush")){
2879                                 RelatedType = _("Crush");
2881                         } else if (PropertyValue == wxT("date")){
2883                                 RelatedType = _("Date");
2885                         } else if (PropertyValue == wxT("sweetheart")){
2887                                 RelatedType = _("Sweetheart");
2889                         } else if (PropertyValue == wxT("me")){
2891                                 RelatedType = _("Me");
2893                         } else if (PropertyValue == wxT("agent")){
2895                                 RelatedType = _("Agent");
2897                         } else if (PropertyValue == wxT("emergency")){
2899                                 RelatedType = _("Emergency");
2901                         } else {
2903                                 RelatedType = PropertyValue;
2905                         }
2906                 
2907                 }
2908         
2909         }
2910         
2911         intPrevValue = 8;                       
2912         
2913         bool PropertyMatched = FALSE;
2914         
2915         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2916         intiter != SplitPoints.end(); ++intiter){
2917         
2918                 SLiter = SplitLength.find(intiter->first);
2919         
2920                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2921                 
2922                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2923                 PropertyName = PropertyElement.GetNextToken();                          
2924                 PropertyValue = PropertyElement.GetNextToken();
2925                 
2926                 intPrevValue = intiter->second;
2927                 
2928                 // Process properties.
2929                 
2930                 size_t intPropertyValueLen = PropertyValue.Len();
2931                 
2932                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2933                         
2934                         PropertyValue.Trim();
2935                         PropertyValue.RemoveLast();
2936                         
2937                 }                               
2938                 
2939                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2940                         
2941                         PropertyValue.Remove(0, 1);
2942                         
2943                 }
2944                 
2945                 CaptureString(&PropertyValue, FALSE);
2946                         
2947                 ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched);
2948                 ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched);
2949                 ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched);
2950                 ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched);
2952                 if (PropertyMatched == TRUE){
2953                 
2954                         PropertyMatched = FALSE;
2955                         continue;
2956                 
2957                 }
2959                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2960         
2961                         if (FirstToken == TRUE){
2962                 
2963                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2964                                 FirstToken = FALSE;
2965                 
2966                         } else {
2967                 
2968                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2969                 
2970                         }
2971         
2972                 }
2973         
2974         }                                       
2975         
2976         // Add the data to the General/Home/Work address variables.
2977                                 
2978         GeneralRelatedList.erase(*RelatedCount);
2979         GeneralRelatedListRelType.erase(*RelatedCount);
2980         GeneralRelatedListType.erase(*RelatedCount);
2981         GeneralRelatedListTokens.erase(*RelatedCount);
2982         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2983         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2984         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2985         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2989 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2991         std::map<int, int> SplitPoints;
2992         std::map<int, int> SplitLength;
2993         std::map<int, int>::iterator SLiter;                    
2994         wxString PropertyData;
2995         wxString PropertyName;
2996         wxString PropertyValue;
2997         wxString PropertyTokens;
2998         bool FirstToken = TRUE;
2999         int intPrevValue = 5;
3000         int intPref = 0;                        
3001         int intType = 0;
3002         long ListCtrlIndex;
3003         
3004         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3005         
3006         intPrevValue = 4;
3007         
3008         PropertyType PropType = PROPERTY_NONE;
3009                 
3010         // Look for type before continuing.
3011         
3012         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3013         
3014         // Setup the pointers.
3015         
3016         std::map<int, wxString> *WebsiteList = NULL;
3017         std::map<int, wxString> *WebsiteListAltID = NULL;
3018         std::map<int, wxString> *WebsiteListPID = NULL;
3019         std::map<int, wxString> *WebsiteListType = NULL;
3020         std::map<int, wxString> *WebsiteListTokens = NULL;
3021         std::map<int, wxString> *WebsiteListMediatype = NULL;
3022         std::map<int, int> *WebsiteListPref = NULL;
3023         
3024         // Setup blank lines for later on.
3025         
3026         switch(PropType){
3027                 case PROPERTY_NONE:
3028                         WebsiteList = &GeneralWebsiteList;
3029                         WebsiteListType = &GeneralWebsiteListType;
3030                         WebsiteListAltID = &GeneralWebsiteListAltID;
3031                         WebsiteListPID = &GeneralWebsiteListPID;
3032                         WebsiteListTokens = &GeneralWebsiteListTokens;
3033                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3034                         WebsiteListPref = &GeneralWebsiteListPref;      
3035                         break;
3036                 case PROPERTY_HOME:
3037                         WebsiteList = &HomeWebsiteList;
3038                         WebsiteListType = &HomeWebsiteListType;
3039                         WebsiteListAltID = &HomeWebsiteListAltID;
3040                         WebsiteListPID = &HomeWebsiteListPID;
3041                         WebsiteListTokens = &HomeWebsiteListTokens;
3042                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3043                         WebsiteListPref = &HomeWebsiteListPref; 
3044                         break;
3045                 case PROPERTY_WORK:
3046                         WebsiteList = &BusinessWebsiteList;
3047                         WebsiteListType = &BusinessWebsiteListType;
3048                         WebsiteListAltID = &BusinessWebsiteListAltID;
3049                         WebsiteListPID = &BusinessWebsiteListPID;
3050                         WebsiteListTokens = &BusinessWebsiteListTokens;
3051                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3052                         WebsiteListPref = &BusinessWebsiteListPref;
3053                         break;
3054         }
3055         
3056         intPrevValue = 4;
3057         bool PropertyMatched = FALSE;
3058         
3059         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3060         intiter != SplitPoints.end(); ++intiter){
3061         
3062                 SLiter = SplitLength.find(intiter->first);
3063         
3064                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3065                 
3066                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3067                 PropertyName = PropertyElement.GetNextToken();                          
3068                 PropertyValue = PropertyElement.GetNextToken();
3069                 
3070                 intPrevValue = intiter->second;
3071                 
3072                 // Process properties.
3073                 
3074                 size_t intPropertyValueLen = PropertyValue.Len();
3075                 
3076                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3077                         
3078                         PropertyValue.Trim();
3079                         PropertyValue.RemoveLast();
3080                         
3081                 }                               
3082                 
3083                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3084                         
3085                         PropertyValue.Remove(0, 1);
3086                         
3087                 }
3088                 
3089                 CaptureString(&PropertyValue, FALSE);
3090                 
3091                 ProcessStringValue(&PropertyName, "ALTID", WebsiteListAltID, &PropertyValue, URLCount, &PropertyMatched);
3092                 ProcessStringValue(&PropertyName, "PID", WebsiteListPID, &PropertyValue, URLCount, &PropertyMatched);
3093                 ProcessStringValue(&PropertyName, "MEDIATYPE", WebsiteListMediatype, &PropertyValue, URLCount, &PropertyMatched);
3094                 ProcessIntegerValue(&PropertyName, "PREF", WebsiteListPref, &PropertyValue, URLCount, &PropertyMatched);
3095                 
3096                 if (PropertyMatched == TRUE){
3097                 
3098                         PropertyMatched = FALSE;
3099                         continue;
3100                 
3101                 }
3102                 
3103                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3104         
3105                         if (FirstToken == TRUE){
3106                 
3107                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3108                                 FirstToken = FALSE;
3109                 
3110                         } else {
3111                 
3112                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3113                 
3114                         }
3115         
3116                 }
3117         
3118         }
3119         
3120         // Add the data to the General/Home/Work address variables.
3121         
3122         CaptureString(&PropertySeg2, FALSE);
3123                         
3124         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3125         
3126         if (!PropertyTokens.IsEmpty()){
3127         
3128                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3129                         
3130         }
3131         
3134 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3136         std::map<int, int> SplitPoints;
3137         std::map<int, int> SplitLength;
3138         std::map<int, int>::iterator SLiter;                    
3139         wxString PropertyData;
3140         wxString PropertyName;
3141         wxString PropertyValue;
3142         wxString PropertyTokens;
3143         bool FirstToken = TRUE;
3144         int intPrevValue = 7;
3145         int intPref = 0;                        
3146         int intType = 0;
3147         long ListCtrlIndex;
3148         
3149         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3150         
3151         intPrevValue = 6;
3152         
3153         PropertyType PropType = PROPERTY_NONE;
3154                 
3155         // Look for type before continuing.
3156         
3157         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3158         
3159         // Setup the pointers.
3160         
3161         std::map<int, wxString> *TitleList = NULL;
3162         std::map<int, wxString> *TitleListAltID = NULL;
3163         std::map<int, wxString> *TitleListPID = NULL;
3164         std::map<int, wxString> *TitleListType = NULL;
3165         std::map<int, wxString> *TitleListTokens = NULL;
3166         std::map<int, wxString> *TitleListLanguage = NULL;
3167         std::map<int, int> *TitleListPref = NULL;
3168         
3169         // Setup blank lines for later on.
3170         
3171         switch(PropType){
3172                 case PROPERTY_NONE:
3173                         TitleList = &GeneralTitleList;
3174                         TitleListType = &GeneralTitleListType;
3175                         TitleListAltID = &GeneralTitleListAltID;
3176                         TitleListPID = &GeneralTitleListPID;
3177                         TitleListTokens = &GeneralTitleListTokens;
3178                         TitleListLanguage = &GeneralTitleListLanguage;
3179                         TitleListPref = &GeneralTitleListPref;  
3180                         break;
3181                 case PROPERTY_HOME:
3182                         TitleList = &HomeTitleList;
3183                         TitleListType = &HomeTitleListType;
3184                         TitleListAltID = &HomeTitleListAltID;
3185                         TitleListPID = &HomeTitleListPID;
3186                         TitleListTokens = &HomeTitleListTokens;
3187                         TitleListLanguage = &HomeTitleListLanguage;
3188                         TitleListPref = &HomeTitleListPref;     
3189                         break;
3190                 case PROPERTY_WORK:
3191                         TitleList = &BusinessTitleList;
3192                         TitleListType = &BusinessTitleListType;
3193                         TitleListAltID = &BusinessTitleListAltID;
3194                         TitleListPID = &BusinessTitleListPID;
3195                         TitleListTokens = &BusinessTitleListTokens;
3196                         TitleListLanguage = &BusinessTitleListLanguage; 
3197                         TitleListPref = &BusinessTitleListPref;
3198                         break;
3199         }
3201         intPrevValue = 6;
3202                 
3203         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3204         intiter != SplitPoints.end(); ++intiter){
3205         
3206                 SLiter = SplitLength.find(intiter->first);
3207         
3208                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3209                 
3210                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3211                 PropertyName = PropertyElement.GetNextToken();                          
3212                 PropertyValue = PropertyElement.GetNextToken();
3213                 
3214                 intPrevValue = intiter->second;
3215                 
3216                 // Process properties.
3217                 
3218                 size_t intPropertyValueLen = PropertyValue.Len();
3219                 
3220                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3221                         
3222                         PropertyValue.Trim();
3223                         PropertyValue.RemoveLast();
3224                         
3225                 }                               
3226                 
3227                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3228                         
3229                         PropertyValue.Remove(0, 1);
3230                         
3231                 }                               
3232                 
3233                 CaptureString(&PropertyValue, FALSE);
3234                 
3235                 if (PropertyName == wxT("ALTID")){
3236                 
3237                         TitleListAltID->erase(*TitleCount);
3238                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3239                 
3240                 } else if (PropertyName == wxT("PID")){
3242                         TitleListPID->erase(*TitleCount);
3243                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3244                 
3245                 } else if (PropertyName == wxT("PREF")){
3247                         ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3248                         
3249                 } else if (PropertyName == wxT("LANGUAGE")){
3250                 
3251                         TitleListLanguage->erase(*TitleCount);
3252                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3253                 
3254                 } else {
3255                 
3256                         // Something else we don't know about so append
3257                         // to the tokens variable.
3258                 
3259                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3260                 
3261                                 if (FirstToken == TRUE){
3262                         
3263                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3264                                         FirstToken = FALSE;
3265                         
3266                                 } else {
3267                         
3268                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3269                         
3270                                 }
3271                 
3272                         }
3273                 
3274                 }
3275         
3276         }
3277         
3278         // Add the data to the General/Home/Work address variables.
3279         
3280         CaptureString(&PropertySeg2, FALSE);
3282         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3283         
3284         if (!PropertyTokens.IsEmpty()){
3285         
3286                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3287                         
3288         }
3292 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3294         std::map<int, int> SplitPoints;
3295         std::map<int, int> SplitLength;
3296         std::map<int, int>::iterator SLiter;                    
3297         wxString PropertyData;
3298         wxString PropertyName;
3299         wxString PropertyValue;
3300         wxString PropertyTokens;
3301         bool FirstToken = TRUE;
3302         int intPrevValue = 6;
3303         int intPref = 0;                        
3304         int intType = 0;
3305         long ListCtrlIndex;
3306         
3307         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3308         
3309         intPrevValue = 5;
3310         
3311         PropertyType PropType = PROPERTY_NONE;
3312                 
3313         // Look for type before continuing.
3314         
3315         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3316         
3317         // Setup the pointers.
3318         
3319         std::map<int, wxString> *RoleList = NULL;
3320         std::map<int, wxString> *RoleListAltID = NULL;
3321         std::map<int, wxString> *RoleListPID = NULL;
3322         std::map<int, wxString> *RoleListType = NULL;
3323         std::map<int, wxString> *RoleListTokens = NULL;
3324         std::map<int, wxString> *RoleListLanguage = NULL;
3325         std::map<int, int> *RoleListPref = NULL;
3326         
3327         // Setup blank lines for later on.
3328         
3329         switch(PropType){
3330                 case PROPERTY_NONE:
3331                         RoleList = &GeneralRoleList;
3332                         RoleListType = &GeneralRoleListType;
3333                         RoleListAltID = &GeneralRoleListAltID;
3334                         RoleListPID = &GeneralRoleListPID;
3335                         RoleListTokens = &GeneralRoleListTokens;
3336                         RoleListLanguage = &GeneralRoleListLanguage;
3337                         RoleListPref = &GeneralRoleListPref;    
3338                         break;
3339                 case PROPERTY_HOME:
3340                         RoleList = &HomeRoleList;
3341                         RoleListType = &HomeRoleListType;
3342                         RoleListAltID = &HomeRoleListAltID;
3343                         RoleListPID = &HomeRoleListPID;
3344                         RoleListTokens = &HomeRoleListTokens;
3345                         RoleListLanguage = &HomeRoleListLanguage;
3346                         RoleListPref = &HomeRoleListPref;       
3347                         break;
3348                 case PROPERTY_WORK:
3349                         RoleList = &BusinessRoleList;
3350                         RoleListType = &BusinessRoleListType;
3351                         RoleListAltID = &BusinessRoleListAltID;
3352                         RoleListPID = &BusinessRoleListPID;
3353                         RoleListTokens = &BusinessRoleListTokens;
3354                         RoleListLanguage = &BusinessRoleListLanguage;   
3355                         RoleListPref = &BusinessRoleListPref;
3356                         break;
3357         }
3359         intPrevValue = 5;
3360                 
3361         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3362         intiter != SplitPoints.end(); ++intiter){
3363         
3364                 SLiter = SplitLength.find(intiter->first);
3365         
3366                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3367                 
3368                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3369                 PropertyName = PropertyElement.GetNextToken();                          
3370                 PropertyValue = PropertyElement.GetNextToken();
3371                 
3372                 intPrevValue = intiter->second;
3373                 
3374                 // Process properties.
3375                 
3376                 size_t intPropertyValueLen = PropertyValue.Len();
3377                 
3378                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3379                         
3380                         PropertyValue.Trim();
3381                         PropertyValue.RemoveLast();
3382                         
3383                 }                               
3384                 
3385                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3386                         
3387                         PropertyValue.Remove(0, 1);
3388                         
3389                 }                               
3390                 
3391                 CaptureString(&PropertyValue, FALSE);
3392                 
3393                 if (PropertyName == wxT("ALTID")){
3394                 
3395                         RoleListAltID->erase(*RoleCount);
3396                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3397                 
3398                 } else if (PropertyName == wxT("PID")){
3400                         RoleListPID->erase(*RoleCount);
3401                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3402                 
3403                 } else if (PropertyName == wxT("PREF")){
3405                         ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3406                                 
3407                 } else if (PropertyName == wxT("LANGUAGE")){
3408                 
3409                         RoleListLanguage->erase(*RoleCount);
3410                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3411                 
3412                 } else {
3413                 
3414                         // Something else we don't know about so append
3415                         // to the tokens variable.
3416                 
3417                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3418                 
3419                                 if (FirstToken == TRUE){
3420                         
3421                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3422                                         FirstToken = FALSE;
3423                         
3424                                 } else {
3425                         
3426                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3427                         
3428                                 }
3429                 
3430                         }
3431                 
3432                 }
3433         
3434         }
3435         
3436         // Add the data to the General/Home/Work address variables.
3437         
3438         CaptureString(&PropertySeg2, FALSE);
3440         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3441         
3442         if (!PropertyTokens.IsEmpty()){
3443         
3444                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3445                         
3446         }
3450 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3452         std::map<int, int> SplitPoints;
3453         std::map<int, int> SplitLength;
3454         std::map<int, int>::iterator SLiter;                    
3455         wxString PropertyData;
3456         wxString PropertyName;
3457         wxString PropertyValue;
3458         wxString PropertyTokens;
3459         bool FirstToken = TRUE;
3460         int intPrevValue = 5;
3461         int intPref = 0;                        
3462         int intType = 0;
3463         long ListCtrlIndex;
3464         
3465         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3466         
3467         intPrevValue = 4;
3468         
3469         PropertyType PropType = PROPERTY_NONE;
3470                 
3471         // Look for type before continuing.
3472         
3473         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3474         
3475         // Setup the pointers.
3476         
3477         std::map<int, wxString> *OrganisationsList = NULL;
3478         std::map<int, wxString> *OrganisationsListAltID = NULL;
3479         std::map<int, wxString> *OrganisationsListPID = NULL;
3480         std::map<int, wxString> *OrganisationsListType = NULL;
3481         std::map<int, wxString> *OrganisationsListTokens = NULL;
3482         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3483         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3484         std::map<int, int> *OrganisationsListPref = NULL;
3485         
3486         // Setup blank lines for later on.
3487         
3488         switch(PropType){
3489                 case PROPERTY_NONE:
3490                         OrganisationsList = &GeneralOrganisationsList;
3491                         OrganisationsListType = &GeneralOrganisationsListType;
3492                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3493                         OrganisationsListPID = &GeneralOrganisationsListPID;
3494                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3495                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3496                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3497                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3498                         break;
3499                 case PROPERTY_HOME:
3500                         OrganisationsList = &HomeOrganisationsList;
3501                         OrganisationsListType = &HomeOrganisationsListType;
3502                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3503                         OrganisationsListPID = &HomeOrganisationsListPID;
3504                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3505                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3506                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3507                         OrganisationsListPref = &HomeOrganisationsListPref;     
3508                         break;
3509                 case PROPERTY_WORK:
3510                         OrganisationsList = &BusinessOrganisationsList;
3511                         OrganisationsListType = &BusinessOrganisationsListType;
3512                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3513                         OrganisationsListPID = &BusinessOrganisationsListPID;
3514                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3515                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3516                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3517                         OrganisationsListPref = &BusinessOrganisationsListPref;
3518                         break;
3519         }
3521         intPrevValue = 4;
3522                 
3523         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3524         intiter != SplitPoints.end(); ++intiter){
3525         
3526                 SLiter = SplitLength.find(intiter->first);
3527         
3528                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3529                 
3530                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3531                 PropertyName = PropertyElement.GetNextToken();                          
3532                 PropertyValue = PropertyElement.GetNextToken();
3533                 
3534                 intPrevValue = intiter->second;
3535                 
3536                 // Process properties.
3537                 
3538                 size_t intPropertyValueLen = PropertyValue.Len();
3539                 
3540                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3541                         
3542                         PropertyValue.Trim();
3543                         PropertyValue.RemoveLast();
3544                         
3545                 }                               
3546                 
3547                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3548                         
3549                         PropertyValue.Remove(0, 1);
3550                         
3551                 }                               
3552                 
3553                 CaptureString(&PropertyValue, FALSE);
3554                 
3555                 if (PropertyName == wxT("ALTID")){
3556                 
3557                         OrganisationsListAltID->erase(*OrganisationCount);
3558                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3559                 
3560                 } else if (PropertyName == wxT("PID")){
3562                         OrganisationsListPID->erase(*OrganisationCount);
3563                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3564                 
3565                 } else if (PropertyName == wxT("SORT-AS")){
3567                         OrganisationsListSortAs->erase(*OrganisationCount);
3568                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3569                 
3570                 } else if (PropertyName == wxT("PREF")){
3572                         ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3573                         
3574                 } else if (PropertyName == wxT("LANGUAGE")){
3575                 
3576                         OrganisationsListLanguage->erase(*OrganisationCount);
3577                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3578                 
3579                 } else {
3580                 
3581                         // Something else we don't know about so append
3582                         // to the tokens variable.
3583                 
3584                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3585                 
3586                                 if (FirstToken == TRUE){
3587                         
3588                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3589                                         FirstToken = FALSE;
3590                         
3591                                 } else {
3592                         
3593                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3594                         
3595                                 }
3596                 
3597                         }
3598                 
3599                 }
3600         
3601         }
3602         
3603         // Add the data to the General/Home/Work address variables.
3604         
3605         CaptureString(&PropertySeg2, FALSE);
3607         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3608         
3609         if (!PropertyTokens.IsEmpty()){
3610         
3611                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3612                         
3613         }
3617 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3619         std::map<int, int> SplitPoints;
3620         std::map<int, int> SplitLength;
3621         std::map<int, int>::iterator SLiter;                    
3622         wxString PropertyData;
3623         wxString PropertyName;
3624         wxString PropertyValue;
3625         wxString PropertyTokens;
3626         bool FirstToken = TRUE;
3627         int intPrevValue = 6;
3628         int intPref = 0;                        
3629         int intType = 0;
3630         long ListCtrlIndex;
3631         
3632         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3633         
3634         intPrevValue = 5;
3635         
3636         PropertyType PropType = PROPERTY_NONE;
3637                 
3638         // Look for type before continuing.
3639         
3640         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3641         
3642         // Setup the pointers.
3643         
3644         std::map<int, wxString> *NoteList = NULL;
3645         std::map<int, wxString> *NoteListAltID = NULL;
3646         std::map<int, wxString> *NoteListPID = NULL;
3647         std::map<int, wxString> *NoteListType = NULL;
3648         std::map<int, wxString> *NoteListTokens = NULL;
3649         std::map<int, wxString> *NoteListLanguage = NULL;
3650         std::map<int, int> *NoteListPref = NULL;
3651         
3652         // Setup blank lines for later on.
3653         
3654         switch(PropType){
3655                 case PROPERTY_NONE:
3656                         NoteList = &GeneralNoteList;
3657                         NoteListType = &GeneralNoteListType;
3658                         NoteListAltID = &GeneralNoteListAltID;
3659                         NoteListPID = &GeneralNoteListPID;
3660                         NoteListTokens = &GeneralNoteListTokens;
3661                         NoteListLanguage = &GeneralNoteListLanguage;
3662                         NoteListPref = &GeneralNoteListPref;    
3663                         break;
3664                 case PROPERTY_HOME:
3665                         NoteList = &HomeNoteList;
3666                         NoteListType = &HomeNoteListType;
3667                         NoteListAltID = &HomeNoteListAltID;
3668                         NoteListPID = &HomeNoteListPID;
3669                         NoteListTokens = &HomeNoteListTokens;
3670                         NoteListLanguage = &HomeNoteListLanguage;
3671                         NoteListPref = &HomeNoteListPref;       
3672                         break;
3673                 case PROPERTY_WORK:
3674                         NoteList = &BusinessNoteList;
3675                         NoteListType = &BusinessNoteListType;
3676                         NoteListAltID = &BusinessNoteListAltID;
3677                         NoteListPID = &BusinessNoteListPID;
3678                         NoteListTokens = &BusinessNoteListTokens;
3679                         NoteListLanguage = &BusinessNoteListLanguage;   
3680                         NoteListPref = &BusinessNoteListPref;
3681                         break;
3682         }
3684         intPrevValue = 5;
3685                 
3686         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3687         intiter != SplitPoints.end(); ++intiter){
3688         
3689                 SLiter = SplitLength.find(intiter->first);
3690         
3691                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3692                 
3693                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3694                 PropertyName = PropertyElement.GetNextToken();                          
3695                 PropertyValue = PropertyElement.GetNextToken();
3696                 
3697                 intPrevValue = intiter->second;
3698                 
3699                 // Process properties.
3700                 
3701                 size_t intPropertyValueLen = PropertyValue.Len();
3702                 
3703                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3704                         
3705                         PropertyValue.Trim();
3706                         PropertyValue.RemoveLast();
3707                         
3708                 }                               
3709                 
3710                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3711                         
3712                         PropertyValue.Remove(0, 1);
3713                         
3714                 }                               
3715                 
3716                 CaptureString(&PropertyValue, FALSE);
3717                 
3718                 if (PropertyName == wxT("ALTID")){
3719                 
3720                         NoteListAltID->erase(*NoteCount);
3721                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3722                 
3723                 } else if (PropertyName == wxT("PID")){
3725                         NoteListPID->erase(*NoteCount);
3726                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3727                 
3728                 } else if (PropertyName == wxT("PREF")){
3730                         ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3731                 
3732                 } else if (PropertyName == wxT("LANGUAGE")){
3733                 
3734                         NoteListLanguage->erase(*NoteCount);
3735                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3736                 
3737                 } else {
3738                 
3739                         // Something else we don't know about so append
3740                         // to the tokens variable.
3741                 
3742                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3743                 
3744                                 if (FirstToken == TRUE){
3745                         
3746                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3747                                         FirstToken = FALSE;
3748                         
3749                                 } else {
3750                         
3751                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3752                         
3753                                 }
3754                 
3755                         }
3756                 
3757                 }
3758         
3759         }
3760         
3761         // Add the data to the General/Home/Work address variables.
3762         
3763         CaptureString(&PropertySeg2, FALSE);
3765         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3766         
3767         if (!PropertyTokens.IsEmpty()){
3768         
3769                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3770                         
3771         }
3775 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3777         std::map<int, int> SplitPoints;
3778         std::map<int, int> SplitLength;
3779         std::map<int, int>::iterator SLiter;                    
3780         wxString PropertyData;
3781         wxString PropertyName;
3782         wxString PropertyValue;
3783         wxString PropertyTokens;
3784         bool FirstToken = TRUE;
3785         int intPrevValue = 12;
3786         int intPref = 0;                        
3787         int intType = 0;
3788         long ListCtrlIndex;
3789         
3790         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3791         
3792         intPrevValue = 11;
3793         
3794         PropertyType PropType = PROPERTY_NONE;
3795                 
3796         // Look for type before continuing.
3797         
3798         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3799         
3800         // Setup blank lines for later on.
3801         
3802         switch(PropType){
3803                 case PROPERTY_NONE:
3804                         break;
3805                 case PROPERTY_HOME:
3806                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3807                         break;
3808                 case PROPERTY_WORK:
3809                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3810                         break;
3811         }
3813         intPrevValue = 11;
3814                 
3815         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3816         intiter != SplitPoints.end(); ++intiter){
3817         
3818                 SLiter = SplitLength.find(intiter->first);
3819         
3820                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3821                 
3822                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3823                 PropertyName = PropertyElement.GetNextToken();                          
3824                 PropertyValue = PropertyElement.GetNextToken();
3825                 
3826                 intPrevValue = intiter->second;
3827                 
3828                 // Process properties.
3829                 
3830                 size_t intPropertyValueLen = PropertyValue.Len();
3831                 
3832                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3833                         
3834                         PropertyValue.Trim();
3835                         PropertyValue.RemoveLast();
3836                         
3837                 }                               
3838                 
3839                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3840                         
3841                         PropertyValue.Remove(0, 1);
3842                         
3843                 }                               
3844                 
3845                 CaptureString(&PropertyValue, FALSE);
3846                 
3847                 if (PropertyName == wxT("ALTID")){
3848                 
3849                         CategoriesListAltID.erase(*CategoryCount);
3850                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3851                 
3852                 } else if (PropertyName == wxT("PID")){
3854                         CategoriesListPID.erase(*CategoryCount);
3855                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3856                 
3857                 } else if (PropertyName == wxT("PREF")){
3859                         ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3860                         
3861                 } else if (PropertyName == wxT("LANGUAGE")){
3862                 
3863                         CategoriesListLanguage.erase(*CategoryCount);
3864                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3865                 
3866                 } else {
3867                 
3868                         // Something else we don't know about so append
3869                         // to the tokens variable.
3870                 
3871                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3872                 
3873                                 if (FirstToken == TRUE){
3874                         
3875                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3876                                         FirstToken = FALSE;
3877                         
3878                                 } else {
3879                         
3880                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3881                         
3882                                 }
3883                 
3884                         }
3885                 
3886                 }
3887         
3888         }
3889         
3890         // Deal with multiple categories.
3891         
3892         int intOrigCatCount = *CategoryCount;
3893         bool FirstCategoryProcessed = TRUE;
3894         bool AfterFirstToken = FALSE;
3895         int intSplitSize = 0;
3896         int intSplitsFound = 0;
3897         int intSplitSeek = 0;
3898         int intPropertyLen = PropertySeg2.Len();
3899         
3900         SplitPoints.clear();
3901         SplitLength.clear();
3902         intPrevValue = 0;
3903         
3904         for (int i = 0; i <= intPropertyLen; i++){
3905         
3906                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3907         
3908                         continue;
3909                 
3910                 }
3911         
3912                 intSplitSize++;
3913         
3914                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3915         
3916                         if (AfterFirstToken == TRUE){
3917                 
3918                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3919                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3920                         
3921                         } else {
3922                         
3923                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3924                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3925                                 AfterFirstToken = TRUE;
3927                         }
3929                         intSplitsFound++;
3930                         intSplitSeek = i;
3931                         intSplitSize = 0;                               
3932         
3933                 }                       
3934         
3935         }
3936         
3937         if (SplitPoints.size() > 0){
3938         
3939                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3940                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3941         
3942         }
3943         
3944         if (SplitPoints.size() == 0){
3945         
3946                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3947         
3948                 if (!PropertyTokens.IsEmpty()){
3949                 
3950                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3951                 
3952                 }
3953         
3954         }
3955         
3956         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3957         intiter != SplitPoints.end(); ++intiter){
3958         
3959                 SLiter = SplitLength.find(intiter->first);
3960         
3961                 intPrevValue = intiter->second;
3962         
3963                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3964                 
3965                 // Add the data to the General/Home/Work address variables.
3966         
3967                 // Trim any whitespace from the start and end.
3968         
3969                 PropertyData = PropertyData.Trim(FALSE);
3970                 PropertyData = PropertyData.Trim(TRUE); 
3971         
3972                 CaptureString(&PropertyData, FALSE);
3973                 
3974                 if (FirstCategoryProcessed == TRUE){
3975                 
3976                         FirstCategoryProcessed = FALSE;
3977                         
3978                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3979         
3980                         if (!PropertyTokens.IsEmpty()){
3981                 
3982                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3983                 
3984                         }
3985                         
3986                         continue;
3987                 
3988                 } else {
3990                         (*CategoryCount)++;
3991                         
3992                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3993                 
3994                         if (!PropertyTokens.IsEmpty()){
3995                 
3996                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3997                 
3998                         }
3999                 
4000                 }
4001                 
4002                 // Copy the properties to each of the categories (if it exists).
4003                 
4004                 if (!PropertyTokens.IsEmpty()){
4005                 
4006                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4007                 
4008                 }
4009                 
4010                 // Check if ALTID was used.
4011                 
4012                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4013                 
4014                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4015                 
4016                 }
4017                 
4018                 // Check if PID was used.
4019                 
4020                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4021                 
4022                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4023                 
4024                 }
4025         
4026                 // Check if PREF was used.
4027         
4028                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4029                 
4030                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4031                 
4032                 }
4033                 
4034                 // Check if LANGUAGE was used.
4035                 
4036                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4037                 
4038                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4039                 
4040                 }
4041                 
4042                 // Check if TYPE was used.
4043                 
4044                 switch(PropType){
4045                         case PROPERTY_NONE:
4046                                 break;
4047                         case PROPERTY_HOME:
4048                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4049                                 break;
4050                         case PROPERTY_WORK:
4051                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4052                                 break;
4053                 }
4054         
4055         }
4059 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4061         size_t intPropertyLen = PropertySeg1.Len();
4062         std::map<int, int> SplitPoints;
4063         std::map<int, int> SplitLength;
4064         std::map<int, int>::iterator SLiter;                    
4065         wxString PropertyData;
4066         wxString PropertyName;
4067         wxString PropertyValue;
4068         wxString PropertyTokens;
4069         bool FirstToken = TRUE;
4070         int intSplitsFound = 0;
4071         int intSplitSize = 0;
4072         int intPrevValue = 7;
4073         int intPref = 0;                        
4074         int intType = 0;
4075         
4076         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4077         
4078         intPrevValue = 6;
4079         
4080         PropertyType PropType = PROPERTY_NONE;
4081                 
4082         // Look for type before continuing.
4083         
4084         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4086         intPrevValue = 6;
4088         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4089         intiter != SplitPoints.end(); ++intiter){
4090         
4091                 SLiter = SplitLength.find(intiter->first);
4092         
4093                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4094                 
4095                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4096                 PropertyName = PropertyElement.GetNextToken();                          
4097                 PropertyValue = PropertyElement.GetNextToken();
4098                 
4099                 intPrevValue = intiter->second;
4100                 
4101                 // Process properties.
4102                 
4103                 size_t intPropertyValueLen = PropertyValue.Len();
4104                 
4105                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4106                         
4107                         PropertyValue.Trim();
4108                         PropertyValue.RemoveLast();
4109                         
4110                 }                               
4111                 
4112                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4113                         
4114                         PropertyValue.Remove(0, 1);
4115                         
4116                 }
4117                 
4118                 CaptureString(&PropertyValue, FALSE);
4119                 
4120                 if (PropertyName == wxT("ALTID")){
4122                         PicturesListAltID.erase(*PhotoCount);
4123                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4124                 
4125                 } else if (PropertyName == wxT("PID")){
4127                         PicturesListPID.erase(*PhotoCount);
4128                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4129                 
4130                 } else if (PropertyName == wxT("PREF")){
4132                         ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4133                 
4134                 } else if (PropertyName == wxT("MEDIATYPE")){
4135                 
4136                         PicturesListMediatype.erase(*PhotoCount);
4137                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4138                                         
4139                 } else {
4140                 
4141                         // Something else we don't know about so append
4142                         // to the tokens variable.
4143                         
4144                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4145                         
4146                                 if (FirstToken == TRUE){
4147                                 
4148                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4149                                         FirstToken = FALSE;
4150                                 
4151                                 } else {
4152                                 
4153                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4154                                 
4155                                 }
4156                         
4157                         }
4158                 
4159                 }
4160         
4161         }       
4162         
4163         intPropertyLen = PropertySeg2.Len();
4164         SplitPoints.clear();
4165         SplitLength.clear();
4166         intSplitsFound = 0;
4167         intSplitSize = 0;
4168         intPrevValue = 0;                       
4169         
4170         CaptureString(&PropertySeg2, FALSE);
4171         
4172         for (int i = 0; i <= intPropertyLen; i++){
4174                 intSplitSize++;
4175         
4176                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4177         
4178                         intSplitsFound++;
4179                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4180                         
4181                         if (intSplitsFound == 6){ 
4182                         
4183                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4184                                 break; 
4185                                 
4186                         } else {
4187                         
4188                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4189                         
4190                         }
4191                         
4192                         intSplitSize = 0;                                       
4193         
4194                 }
4196         }
4197         
4198         wxString wxSPhotoURI;
4199         wxString wxSPhotoMIME;
4200         wxString wxSPhotoEncoding;
4201         wxString wxSPhotoData;
4202         std::string base64enc;
4203         
4204         if (intSplitsFound == 0){
4205         
4206         } else {
4207         
4208                 std::map<int, int>::iterator striter;
4209         
4210                 striter = SplitLength.find(1);
4211         
4212                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4213         
4214                 while (wSTDataType.HasMoreTokens() == TRUE){
4215                 
4216                         wxSPhotoURI = wSTDataType.GetNextToken();
4217                         wxSPhotoMIME = wSTDataType.GetNextToken();
4218                         break;
4219                 
4220                 }                       
4221         
4222                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4223         
4224                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4225                 
4226                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4227                         wxSPhotoData = wSTDataInfo.GetNextToken();
4228                         base64enc = wxSPhotoData.mb_str();
4229                         break;
4230                 
4231                 }
4232         
4233         }
4234         
4235         // Add the data to the General/Home/Work address variables.
4236         
4237         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4238         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4239         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4240         
4241         switch(PropType){
4242                 case PROPERTY_NONE:
4243                         break;
4244                 case PROPERTY_HOME:
4245                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4246                         break;
4247                 case PROPERTY_WORK:
4248                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4249                         break;
4250         }
4251         
4252         if (!PropertyTokens.IsEmpty()){
4254                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4255         
4256         }
4260 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4262         size_t intPropertyLen = PropertySeg1.Len();
4263         std::map<int, int> SplitPoints;
4264         std::map<int, int> SplitLength;
4265         std::map<int, int>::iterator SLiter;                    
4266         wxString PropertyData;
4267         wxString PropertyName;
4268         wxString PropertyValue;
4269         wxString PropertyTokens;
4270         bool FirstToken = TRUE;
4271         int intSplitsFound = 0;
4272         int intSplitSize = 0;
4273         int intPrevValue = 6;
4274         int intPref = 0;                        
4275         int intType = 0;
4276         
4277         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4278         
4279         intPrevValue = 5;
4280         
4281         PropertyType PropType = PROPERTY_NONE;
4282                 
4283         // Look for type before continuing.
4284         
4285         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4287         intPrevValue = 5;
4289         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4290         intiter != SplitPoints.end(); ++intiter){
4291         
4292                 SLiter = SplitLength.find(intiter->first);
4293         
4294                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4295                 
4296                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4297                 PropertyName = PropertyElement.GetNextToken();                          
4298                 PropertyValue = PropertyElement.GetNextToken();
4299                 
4300                 intPrevValue = intiter->second;
4301                 
4302                 // Process properties.
4303                 
4304                 size_t intPropertyValueLen = PropertyValue.Len();
4305                 
4306                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4307                         
4308                         PropertyValue.Trim();
4309                         PropertyValue.RemoveLast();
4310                         
4311                 }                               
4312                 
4313                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4314                         
4315                         PropertyValue.Remove(0, 1);
4316                         
4317                 }
4318                 
4319                 CaptureString(&PropertyValue, FALSE);
4320                 
4321                 if (PropertyName == wxT("ALTID")){
4323                         LogosListAltID.erase(*LogoCount);
4324                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4325                 
4326                 } else if (PropertyName == wxT("PID")){
4328                         LogosListPID.erase(*LogoCount);
4329                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4330                 
4331                 } else if (PropertyName == wxT("PREF")){
4333                         ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4334                 
4335                 } else if (PropertyName == wxT("MEDIATYPE")){
4336                 
4337                         LogosListMediatype.erase(*LogoCount);
4338                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4339                                         
4340                 } else {
4341                 
4342                         // Something else we don't know about so append
4343                         // to the tokens variable.
4344                         
4345                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4346                         
4347                                 if (FirstToken == TRUE){
4348                                 
4349                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4350                                         FirstToken = FALSE;
4351                                 
4352                                 } else {
4353                                 
4354                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4355                                 
4356                                 }
4357                         
4358                         }
4359                 
4360                 }
4361         
4362         }       
4363         
4364         intPropertyLen = PropertySeg2.Len();
4365         SplitPoints.clear();
4366         SplitLength.clear();
4367         intSplitsFound = 0;
4368         intSplitSize = 0;
4369         intPrevValue = 0;                       
4370         
4371         CaptureString(&PropertySeg2, FALSE);
4372         
4373         for (int i = 0; i <= intPropertyLen; i++){
4375                 intSplitSize++;
4376         
4377                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4378         
4379                         intSplitsFound++;
4380                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4381                         
4382                         if (intSplitsFound == 6){ 
4383                         
4384                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4385                                 break; 
4386                                 
4387                         } else {
4388                         
4389                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4390                         
4391                         }
4392                         
4393                         intSplitSize = 0;                                       
4394         
4395                 }
4397         }
4398         
4399         wxString wxSPhotoURI;
4400         wxString wxSPhotoMIME;
4401         wxString wxSPhotoEncoding;
4402         wxString wxSPhotoData;
4403         std::string base64enc;
4404         
4405         if (intSplitsFound == 0){
4406         
4407         } else {
4408         
4409                 std::map<int, int>::iterator striter;
4410         
4411                 striter = SplitLength.find(1);
4412         
4413                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4414         
4415                 while (wSTDataType.HasMoreTokens() == TRUE){
4416                 
4417                         wxSPhotoURI = wSTDataType.GetNextToken();
4418                         wxSPhotoMIME = wSTDataType.GetNextToken();
4419                         break;
4420                 
4421                 }                       
4422         
4423                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4424         
4425                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4426                 
4427                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4428                         wxSPhotoData = wSTDataInfo.GetNextToken();
4429                         base64enc = wxSPhotoData.mb_str();
4430                         break;
4431                 
4432                 }
4433         
4434         }
4435         
4436         // Add the data to the General/Home/Work address variables.
4437         
4438         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4439         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4440         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4441         
4442         switch(PropType){
4443                 case PROPERTY_NONE:
4444                         break;
4445                 case PROPERTY_HOME:
4446                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4447                         break;
4448                 case PROPERTY_WORK:
4449                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4450                         break;
4451         }
4452         
4453         if (!PropertyTokens.IsEmpty()){
4455                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4456         
4457         }
4461 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4463         size_t intPropertyLen = PropertySeg1.Len();
4464         std::map<int, int> SplitPoints;
4465         std::map<int, int> SplitLength;
4466         std::map<int, int>::iterator SLiter;                    
4467         wxString PropertyData;
4468         wxString PropertyName;
4469         wxString PropertyValue;
4470         wxString PropertyTokens;
4471         bool FirstToken = TRUE;
4472         int intSplitsFound = 0;
4473         int intSplitSize = 0;
4474         int intPrevValue = 7;
4475         int intPref = 0;                        
4476         int intType = 0;
4477         
4478         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4479         
4480         intPrevValue = 6;
4481         
4482         PropertyType PropType = PROPERTY_NONE;
4483         
4484         // Look for type before continuing.                     
4486         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4488         intPrevValue = 6;
4490         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4491         intiter != SplitPoints.end(); ++intiter){
4492         
4493                 SLiter = SplitLength.find(intiter->first);
4494         
4495                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4496                 
4497                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4498                 PropertyName = PropertyElement.GetNextToken();                          
4499                 PropertyValue = PropertyElement.GetNextToken();
4500                 
4501                 intPrevValue = intiter->second;
4502                 
4503                 // Process properties.
4504                 
4505                 size_t intPropertyValueLen = PropertyValue.Len();
4506                 
4507                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4508                         
4509                         PropertyValue.Trim();
4510                         PropertyValue.RemoveLast();
4511                         
4512                 }                               
4513                 
4514                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4515                         
4516                         PropertyValue.Remove(0, 1);
4517                         
4518                 }                       
4519                 
4520                 CaptureString(&PropertyValue, FALSE);
4521                 
4522                 if (PropertyName == wxT("ALTID")){
4524                         SoundsListAltID.erase(*SoundCount);
4525                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4526                 
4527                 } else if (PropertyName == wxT("PID")){
4529                         SoundsListPID.erase(*SoundCount);
4530                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4531                 
4532                 } else if (PropertyName == wxT("PREF")){
4534                         ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4535                 
4536                 } else if (PropertyName == wxT("MEDIATYPE")){
4537                 
4538                         SoundsListMediatype.erase(*SoundCount);
4539                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4541                 } else if (PropertyName == wxT("LANGUAGE")){
4542                 
4543                         SoundsListLanguage.erase(*SoundCount);
4544                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4546                 } else {
4547                 
4548                         // Something else we don't know about so append
4549                         // to the tokens variable.
4550                         
4551                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4552                         
4553                                 if (FirstToken == TRUE){
4554                                 
4555                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4556                                         FirstToken = FALSE;
4557                                 
4558                                 } else {
4559                                 
4560                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4561                                 
4562                                 }
4563                         
4564                         }
4565                 
4566                 }
4567         
4568         }       
4569         
4570         intPropertyLen = PropertySeg2.Len();
4571         SplitPoints.clear();
4572         SplitLength.clear();
4573         intSplitsFound = 0;
4574         intSplitSize = 0;
4575         intPrevValue = 0;
4576         
4577         CaptureString(&PropertySeg2, FALSE);
4578         
4579         for (int i = 0; i <= intPropertyLen; i++){
4581                 intSplitSize++;
4582         
4583                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4584         
4585                         intSplitsFound++;
4586                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4587                         
4588                         if (intSplitsFound == 6){ 
4589                         
4590                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4591                                 break; 
4592                                 
4593                         } else {
4594                         
4595                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4596                         
4597                         }
4598                         
4599                         intSplitSize = 0;                                       
4600         
4601                 }
4603         }
4604         
4605         wxString wxSSoundURI;
4606         wxString wxSSoundMIME;
4607         wxString wxSSoundEncoding;
4608         wxString wxSSoundData;
4609         std::string base64enc;
4610         
4611         if (intSplitsFound == 0){
4612         
4613         } else {
4614         
4615                 std::map<int, int>::iterator striter;
4616         
4617                 striter = SplitLength.find(1);
4618         
4619                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4620         
4621                 while (wSTDataType.HasMoreTokens() == TRUE){
4622                 
4623                         wxSSoundURI = wSTDataType.GetNextToken();
4624                         wxSSoundMIME = wSTDataType.GetNextToken();
4625                         break;
4626                 
4627                 }                       
4628         
4629                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4630         
4631                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4632                 
4633                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4634                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4635                         base64enc = wxSSoundData.mb_str();
4636                         break;
4637                 
4638                 }
4639         
4640         }
4641         
4642         // Add the data to the General/Home/Work address variables.
4643                 
4644         switch(PropType){
4645                 case PROPERTY_NONE:
4646                         break;
4647                 case PROPERTY_HOME:
4648                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4649                         break;
4650                 case PROPERTY_WORK:
4651                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4652                         break;
4653         }
4654         
4655         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4656         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4657         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4658         
4659         if (!PropertyTokens.IsEmpty()){
4660         
4661                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4662         
4663         }
4664         
4667 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4669         size_t intPropertyLen = PropertySeg1.Len();
4670         std::map<int, int> SplitPoints;
4671         std::map<int, int> SplitLength;
4672         std::map<int, int>::iterator SLiter;                    
4673         wxString PropertyData;
4674         wxString PropertyName;
4675         wxString PropertyValue;
4676         wxString PropertyTokens;
4677         bool FirstToken = TRUE;
4678         int intSplitsFound = 0;
4679         int intSplitSize = 0;
4680         int intPrevValue = 8;
4681         int intPref = 0;                        
4682         int intType = 0;
4683         
4684         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4685         
4686         intPrevValue = 7;
4687         
4688         PropertyType PropType = PROPERTY_NONE;
4689         
4690         // Look for type before continuing.                     
4692         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4694         intPrevValue = 7;
4696         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4697         intiter != SplitPoints.end(); ++intiter){
4698         
4699                 SLiter = SplitLength.find(intiter->first);
4700         
4701                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4702                 
4703                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4704                 PropertyName = PropertyElement.GetNextToken();                          
4705                 PropertyValue = PropertyElement.GetNextToken();
4706                 
4707                 intPrevValue = intiter->second;
4708                 
4709                 // Process properties.
4710                 
4711                 size_t intPropertyValueLen = PropertyValue.Len();
4712                 
4713                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4714                         
4715                         PropertyValue.Trim();
4716                         PropertyValue.RemoveLast();
4717                         
4718                 }                               
4719                 
4720                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4721                         
4722                         PropertyValue.Remove(0, 1);
4723                         
4724                 }                       
4725                 
4726                 CaptureString(&PropertyValue, FALSE);
4727                 
4728                 if (PropertyName == wxT("ALTID")){
4730                         CalendarListAltID.erase(*CalURICount);
4731                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4732                 
4733                 } else if (PropertyName == wxT("PID")){
4735                         CalendarListPID.erase(*CalURICount);
4736                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4737                 
4738                 } else if (PropertyName == wxT("PREF")){
4740                         ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4741                 
4742                 } else if (PropertyName == wxT("MEDIATYPE")){
4743                 
4744                         CalendarListMediatype.erase(*CalURICount);
4745                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4747                 } else {
4748                 
4749                         // Something else we don't know about so append
4750                         // to the tokens variable.
4751                         
4752                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4753                         
4754                                 if (FirstToken == TRUE){
4755                                 
4756                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4757                                         FirstToken = FALSE;
4758                                 
4759                                 } else {
4760                                 
4761                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4762                                 
4763                                 }
4764                         
4765                         }
4766                 
4767                 }
4768         
4769         }       
4770         
4771         intPropertyLen = PropertySeg2.Len();
4772         SplitPoints.clear();
4773         SplitLength.clear();
4774         intSplitsFound = 0;
4775         intSplitSize = 0;
4776         intPrevValue = 0;
4777         
4778         CaptureString(&PropertySeg2, FALSE);
4779         
4780         // Add the data to the General/Home/Work address variables.
4781                 
4782         switch(PropType){
4783                 case PROPERTY_NONE:
4784                         break;
4785                 case PROPERTY_HOME:
4786                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4787                         break;
4788                 case PROPERTY_WORK:
4789                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4790                         break;
4791         }
4792         
4793         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4794         
4795         if (!PropertyTokens.IsEmpty()){
4796         
4797                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4798         
4799         }
4803 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4805         size_t intPropertyLen = PropertySeg1.Len();
4806         std::map<int, int> SplitPoints;
4807         std::map<int, int> SplitLength;
4808         std::map<int, int>::iterator SLiter;                    
4809         wxString PropertyData;
4810         wxString PropertyName;
4811         wxString PropertyValue;
4812         wxString PropertyTokens;
4813         bool FirstToken = TRUE;
4814         int intSplitsFound = 0;
4815         int intSplitSize = 0;
4816         int intPrevValue = 8;
4817         int intPref = 0;                        
4818         int intType = 0;
4819         
4820         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4821         
4822         intPrevValue = 7;
4823         
4824         PropertyType PropType = PROPERTY_NONE;
4825         
4826         // Look for type before continuing.                     
4828         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4830         intPrevValue = 7;
4832         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4833         intiter != SplitPoints.end(); ++intiter){
4834         
4835                 SLiter = SplitLength.find(intiter->first);
4836         
4837                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4838                 
4839                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4840                 PropertyName = PropertyElement.GetNextToken();                          
4841                 PropertyValue = PropertyElement.GetNextToken();
4842                 
4843                 intPrevValue = intiter->second;
4844                 
4845                 // Process properties.
4846                 
4847                 size_t intPropertyValueLen = PropertyValue.Len();
4848                 
4849                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4850                         
4851                         PropertyValue.Trim();
4852                         PropertyValue.RemoveLast();
4853                         
4854                 }                               
4855                 
4856                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4857                         
4858                         PropertyValue.Remove(0, 1);
4859                         
4860                 }                       
4861                 
4862                 CaptureString(&PropertyValue, FALSE);
4863                 
4864                 if (PropertyName == wxT("ALTID")){
4866                         CalendarRequestListAltID.erase(*CalAdrURICount);
4867                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4868                 
4869                 } else if (PropertyName == wxT("PID")){
4871                         CalendarRequestListPID.erase(*CalAdrURICount);
4872                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4873                 
4874                 } else if (PropertyName == wxT("PREF")){
4876                         ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
4877                 
4878                 } else if (PropertyName == wxT("MEDIATYPE")){
4879                 
4880                         CalendarRequestListMediatype.erase(*CalAdrURICount);
4881                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4883                 } else {
4884                 
4885                         // Something else we don't know about so append
4886                         // to the tokens variable.
4887                         
4888                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4889                         
4890                                 if (FirstToken == TRUE){
4891                                 
4892                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4893                                         FirstToken = FALSE;
4894                                 
4895                                 } else {
4896                                 
4897                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4898                                 
4899                                 }
4900                         
4901                         }
4902                 
4903                 }
4904         
4905         }       
4906         
4907         intPropertyLen = PropertySeg2.Len();
4908         SplitPoints.clear();
4909         SplitLength.clear();
4910         intSplitsFound = 0;
4911         intSplitSize = 0;
4912         intPrevValue = 0;
4913         
4914         CaptureString(&PropertySeg2, FALSE);
4915         
4916         // Add the data to the General/Home/Work address variables.
4917                 
4918         switch(PropType){
4919                 case PROPERTY_NONE:
4920                         break;
4921                 case PROPERTY_HOME:
4922                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4923                         break;
4924                 case PROPERTY_WORK:
4925                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4926                         break;
4927         }
4928         
4929         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4930         
4931         if (!PropertyTokens.IsEmpty()){
4932         
4933                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4934         
4935         }       
4936         
4939 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4941         size_t intPropertyLen = PropertySeg1.Len();
4942         std::map<int, int> SplitPoints;
4943         std::map<int, int> SplitLength;
4944         std::map<int, int>::iterator SLiter;                    
4945         wxString PropertyData;
4946         wxString PropertyName;
4947         wxString PropertyValue;
4948         wxString PropertyTokens;
4949         bool FirstToken = TRUE;
4950         int intSplitsFound = 0;
4951         int intSplitSize = 0;
4952         int intPrevValue = 7;
4953         int intPref = 0;                        
4954         int intType = 0;
4955         
4956         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4957         
4958         intPrevValue = 6;
4959         
4960         PropertyType PropType = PROPERTY_NONE;
4961         
4962         // Look for type before continuing.                     
4964         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4966         intPrevValue = 6;
4968         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4969         intiter != SplitPoints.end(); ++intiter){
4970         
4971                 SLiter = SplitLength.find(intiter->first);
4972         
4973                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4974                 
4975                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4976                 PropertyName = PropertyElement.GetNextToken();                          
4977                 PropertyValue = PropertyElement.GetNextToken();
4978                 
4979                 intPrevValue = intiter->second;
4980                 
4981                 // Process properties.
4982                 
4983                 size_t intPropertyValueLen = PropertyValue.Len();
4984                 
4985                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4986                         
4987                         PropertyValue.Trim();
4988                         PropertyValue.RemoveLast();
4989                         
4990                 }                               
4991                 
4992                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4993                         
4994                         PropertyValue.Remove(0, 1);
4995                         
4996                 }                       
4997                 
4998                 CaptureString(&PropertyValue, FALSE);
4999                 
5000                 if (PropertyName == wxT("ALTID")){
5002                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5003                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5004                 
5005                 } else if (PropertyName == wxT("PID")){
5007                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5008                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5009                 
5010                 } else if (PropertyName == wxT("PREF")){
5012                         ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5013                 
5014                 } else if (PropertyName == wxT("MEDIATYPE")){
5015                 
5016                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5017                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5019                 } else {
5020                 
5021                         // Something else we don't know about so append
5022                         // to the tokens variable.
5023                         
5024                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5025                         
5026                                 if (FirstToken == TRUE){
5027                                 
5028                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5029                                         FirstToken = FALSE;
5030                                 
5031                                 } else {
5032                                 
5033                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5034                                 
5035                                 }
5036                         
5037                         }
5038                 
5039                 }
5040         
5041         }       
5042         
5043         intPropertyLen = PropertySeg2.Len();
5044         SplitPoints.clear();
5045         SplitLength.clear();
5046         intSplitsFound = 0;
5047         intSplitSize = 0;
5048         intPrevValue = 0;
5049         
5050         CaptureString(&PropertySeg2, FALSE);
5051         
5052         // Add the data to the General/Home/Work address variables.
5053                 
5054         switch(PropType){
5055                 case PROPERTY_NONE:
5056                         break;
5057                 case PROPERTY_HOME:
5058                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5059                         break;
5060                 case PROPERTY_WORK:
5061                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5062                         break;
5063         }
5064         
5065         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5066         
5067         if (!PropertyTokens.IsEmpty()){
5068         
5069                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5070         
5071         }
5075 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5077         size_t intPropertyLen = PropertySeg1.Len();
5078         std::map<int, int> SplitPoints;
5079         std::map<int, int> SplitLength;
5080         std::map<int, int>::iterator SLiter;                    
5081         wxString PropertyData;
5082         wxString PropertyName;
5083         wxString PropertyValue;
5084         wxString PropertyTokens;
5085         bool FirstToken = TRUE;
5086         int intSplitsFound = 0;
5087         int intSplitSize = 0;
5088         int intPrevValue = 5;
5089         int intPref = 0;                        
5090         int intType = 0;
5091         long ListCtrlIndex;
5092         
5093         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5094         
5095         intPrevValue = 4;
5096         
5097         PropertyType PropType = PROPERTY_NONE;
5098         
5099         // Look for type before continuing.
5101         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5103         intPrevValue = 4;
5105         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5106         intiter != SplitPoints.end(); ++intiter){
5107         
5108                 SLiter = SplitLength.find(intiter->first);
5109         
5110                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5111                 
5112                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5113                 PropertyName = PropertyElement.GetNextToken();                          
5114                 PropertyValue = PropertyElement.GetNextToken();
5115                 
5116                 intPrevValue = intiter->second;
5117                 
5118                 // Process properties.
5119                 
5120                 size_t intPropertyValueLen = PropertyValue.Len();
5121                 
5122                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5123                         
5124                         PropertyValue.Trim();
5125                         PropertyValue.RemoveLast();
5126                         
5127                 }                               
5128                 
5129                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5130                         
5131                         PropertyValue.Remove(0, 1);
5132                         
5133                 }                               
5134                 
5135                 if (PropertyName == wxT("ALTID")){
5137                         KeyListAltID.erase(*KeyCount);
5138                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5139                 
5140                 } else if (PropertyName == wxT("PID")){
5142                         KeyListPID.erase(*KeyCount);
5143                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5144                 
5145                 } else if (PropertyName == wxT("PREF")){
5147                         ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5148                 
5149                 } else {
5150                 
5151                         // Something else we don't know about so append
5152                         // to the tokens variable.
5153                         
5154                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5155                         
5156                                 if (FirstToken == TRUE){
5157                                 
5158                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5159                                         FirstToken = FALSE;
5160                                 
5161                                 } else {
5162                                 
5163                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5164                                 
5165                                 }
5166                         
5167                         }
5168                 
5169                 }
5170         
5171         }                               
5172         
5173         intPropertyLen = PropertySeg2.Len();
5174         SplitPoints.clear();
5175         SplitLength.clear();
5176         intSplitsFound = 0;
5177         intSplitSize = 0;
5178         intPrevValue = 0;                       
5179         
5180         for (int i = 0; i <= intPropertyLen; i++){
5182                 intSplitSize++;
5183         
5184                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5185         
5186                         intSplitsFound++;
5187                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5188                         
5189                         if (intSplitsFound == 6){ 
5190                         
5191                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5192                                 break; 
5193                                 
5194                         } else {
5195                         
5196                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5197                         
5198                         }
5199                         
5200                         intSplitSize = 0;                                       
5201         
5202                 }
5204         }
5205         
5206         wxString wxSKeyURI;
5207         wxString wxSKeyMIME;
5208         wxString wxSKeyEncoding;
5209         wxString wxSKeyData;
5210         std::string base64enc;
5211         
5212         if (intSplitsFound == 0){
5213         
5214         } else {
5215         
5216                 std::map<int, int>::iterator striter;
5217         
5218                 striter = SplitLength.find(1);
5219         
5220                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5221         
5222                 while (wSTDataType.HasMoreTokens() == TRUE){
5223                 
5224                         wxSKeyURI = wSTDataType.GetNextToken();
5225                         wxSKeyMIME = wSTDataType.GetNextToken();
5226                         break;
5227                 
5228                 }                       
5229         
5230                 if (wxSKeyURI == wxT("data")){
5231                 
5232                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5233         
5234                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5235                 
5236                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5237                                 wxSKeyData = wSTDataInfo.GetNextToken();
5238                                 break;
5239                 
5240                         }
5241                 
5242                 }
5243         
5244         }
5245         
5246         // Add the data to the General/Home/Work address variables.
5247         
5248         if (wxSKeyURI == wxT("data")){
5249                 
5250                 KeyListDataEncType.erase(*KeyCount);
5251                 KeyListKeyType.erase(*KeyCount);
5252                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5253                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5254                 
5255                 KeyList.erase(*KeyCount);
5256                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5257         
5258         } else {
5259                 
5260                 KeyList.erase(*KeyCount);
5261                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5262         
5263         }
5264         
5265         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5266                 
5267         switch (PropType){
5268                 case PROPERTY_NONE:
5269                         break;
5270                 case PROPERTY_HOME: 
5271                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5272                         break;
5273                 case PROPERTY_WORK: 
5274                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5275                         break;
5276         }
5278         if (!PropertyTokens.IsEmpty()){
5280                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5282         }
5286 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5288         // Split the Vendor three ways.
5289         
5290         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5291         
5292         wxString wxSVNDID;
5293         wxString wxSVNDPropName;
5294         long ListCtrlIndex;                     
5296         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5297         
5298                 wSTVendorDetails.GetNextToken();
5299                 wxSVNDID = wSTVendorDetails.GetNextToken();
5300                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5301                 break;
5302         
5303         }
5304         
5305         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5306         
5307                 // Add the data to the vendor variables.
5308         
5309                 VendorList.erase(*VendorCount);
5310                 VendorListPEN.erase(*VendorCount);
5311                 VendorListElement.erase(*VendorCount);
5312         
5313                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5314                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5315                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5316         
5317         }
5321 void ProcessStringValue(wxString *PropertyName,
5322         wxString PropertyNameMatch,
5323         std::map<int,wxString> *MapPtr,
5324         wxString *PropertyValue,
5325         int *ItemCount,
5326         bool *PropertyMatched){
5327         
5328         if (*PropertyName == PropertyNameMatch){
5329                 MapPtr->erase(*ItemCount);
5330                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5331                 *PropertyMatched = TRUE;
5332         }
5333         
5336 void ProcessIntegerValue(wxString *PropertyName,
5337         wxString PropertyNameMatch,
5338         std::map<int,int> *PrefPtr, 
5339         wxString *PropertyValue, 
5340         int *ItemCount,
5341         bool *PropertyMatched){
5343         if (*PropertyName == PropertyNameMatch){
5344                 *PropertyMatched = TRUE;
5345         } else {
5346                 return;
5347         }
5349         int PriorityNumber = 0; 
5350         bool ValidNumber = TRUE;
5351                         
5352         try{
5353                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5354         }
5355                         
5356         catch(std::invalid_argument &e){
5357                 ValidNumber = FALSE;
5358         }
5360         if (ValidNumber == TRUE){
5362                 PrefPtr->erase(*ItemCount);
5363                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5365         }
5369 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
5370         wxString *PropertyValue, 
5371         int *ItemCount){
5373         int PriorityNumber = 0; 
5374         bool ValidNumber = TRUE;
5375                         
5376         try{
5377                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5378         }
5379                         
5380         catch(std::invalid_argument &e){
5381                 ValidNumber = FALSE;
5382         }
5384         if (ValidNumber == TRUE){
5386                 PrefPtr->erase(*ItemCount);
5387                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5389         }
5393 void SplitValues(wxString *PropertyLine, 
5394         std::map<int,int> *SplitPoints, 
5395         std::map<int,int> *SplitLength, 
5396         int intSize){
5397         
5398         size_t intPropertyLen = PropertyLine->Len();
5399         int intSplitsFound = 0;
5400         int intSplitSize = 0;
5401         int intSplitSeek = 0;
5402         
5403         for (int i = intSize; i <= intPropertyLen; i++){
5405                 intSplitSize++;
5406         
5407                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5408                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5409            
5410                     if (intSplitsFound == 0){
5411             
5412                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5413           
5414                     } else {
5415            
5416                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5417             
5418                     }
5419             
5420                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5421             
5422                     intSplitsFound++;
5423                     intSplitSeek = i;
5424                     intSplitSize = 0;
5425             
5426                 }
5428         }
5430         if (intSplitsFound == 0){
5432                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5433                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5435         } else {
5437                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5438                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5440         }
5444 void CheckType(wxString *PropertySeg1, 
5445         std::map<int,int> *SplitPoints, 
5446         std::map<int,int> *SplitLength, 
5447         int *intPrevValue, 
5448         PropertyType *PropType){
5449         
5450         wxString PropertyData;
5451         wxString PropertyName;
5452         wxString PropertyValue;
5453         std::map<int,int>::iterator SLiter;
5454         
5455         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5456         intiter != SplitPoints->end(); ++intiter){
5457         
5458                 SLiter = SplitLength->find(intiter->first);
5459         
5460                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5461                 
5462                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5463                 PropertyName = PropertyElement.GetNextToken();                          
5464                 PropertyValue = PropertyElement.GetNextToken();
5465                 
5466                 *intPrevValue = intiter->second;
5467                 
5468                 if (PropertyName == wxT("TYPE")){
5469                                 
5470                         if (PropertyValue == wxT("work")){
5471                         
5472                                 *PropType = PROPERTY_WORK;
5473                                                         
5474                         } else if (PropertyValue == wxT("home")){
5476                                 *PropType = PROPERTY_HOME;
5477                                                         
5478                         } else {
5479                         
5480                                 *PropType = PROPERTY_NONE;
5481                         
5482                         }
5483                 
5484                         return;
5485                 
5486                 }
5487         
5488         }
5489         
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