Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / contacteditor / frmContactEditor-Load.cpp
1 #include <map>
3 #include <wx/ffile.h>
4 #include <wx/tokenzr.h>
5 #include <wx/datetime.h>
6 #include <wx/dir.h>
8 #include "frmContactEditor.h"
10 #include "../enums.h"
11 #include "../version.h"
12 #include "../vcard/vcard.h"
13 #include "../common/textprocessing.h"
14 #include "../common/dirs.h"
16 bool frmContactEditor::LoadContact(wxString Filename){
18         // Load the contact into the contact editor.
19         
20         wxFFile ContactFile;
21         wxString wxSContactString;
22         wxString ContactLine;
23         vCard ContactData;
24         XABViewMode XVMData = MainPtr->GetViewMode();
25         
26         wxSContactFilename = Filename;
27         
28         // Check if we are using wxWidgets version 2.8 or less and
29         // execute the required command accordingly.
30         
31 #if wxABI_VERSION < 20900
32         ContactFile.Open(Filename.c_str(), wxT("r"));
33 #else
34         ContactFile.Open(Filename, wxT("r"));
35 #endif  
36         
37         if (ContactFile.IsOpened() == FALSE){
38         
39                 return FALSE;
40         
41         }
42         
43         ContactFile.ReadAll(&wxSContactString, wxConvAuto());
44         
45         // Split the lines.
46         
47         std::map<int, wxString> ContactFileLines;
48         std::map<int, wxString>::iterator striter;
49         
50         wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
52         int ContactLineSeek = 0;
54         while (wSTContactFileLines.HasMoreTokens() == TRUE){
56                 ContactLine = wSTContactFileLines.GetNextToken();
57                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
58                 ContactLineSeek++;              
59         
60         }
62         // Get the line.
64         bool QuoteMode = FALSE;
65         bool PropertyFind = TRUE;
66         bool HasExtraNicknames = FALSE;
67         bool IgnoreGender = FALSE;
68         bool ExtraLineSeek = TRUE;
69         bool BirthdayProcessed = FALSE;
70         bool AnniversaryProcessed = FALSE;
71         bool FNProcessed = FALSE;
72         bool GenderProcessed = FALSE;
73         bool NameProcessed = FALSE;
74         bool UIDProcessed = FALSE;
75         bool KindProcessed = FALSE;
76         bool ETagFound = FALSE;
77         bool ETagOrigFound = FALSE;
78         int intExtraNickname = 0;
79         wxString wxSProperty;
80         wxString wxSPropertySeg1;
81         wxString wxSPropertySeg2;
82         wxString wxSPropertyNextLine;
83         int ContactLineLen = 0;
84         int QuoteBreakPoint = 0;
85         int FNCount = 0;
86         int NameCount = 0;
87         int NicknameCount = 0;
88         int ADRCount = 0;
89         int EmailCount = 0;
90         int IMPPCount = 0;
91         int TelCount = 0;
92         int LangCount = 0;
93         int TZCount = 0;
94         int GeoCount = 0;
95         int URLCount = 0;
96         int RelatedCount = 0;
97         int TitleCount = 0;
98         int RoleCount = 0;
99         int OrgCount = 0;
100         int NoteCount = 0;
101         int CategoryCount = 0;
102         int GroupCount = 0;
103         int PhotoCount = 0;
104         int LogoCount = 0;
105         int SoundCount = 0;
106         int CalAdrCount = 0;
107         int CalReqAdrCount = 0;
108         int FreeBusyCount = 0;
109         int KeyCount = 0;
110         int VendorCount = 0;
111         int XTokenCount = 0;
112         //int intValueSeek = 1;
114         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
115          iter != ContactFileLines.end(); ++iter){
116         
117                 // Find the colon which splits the start bit from the data part.
118                 
119                 ContactLine = iter->second;
120                 
121                 while (ExtraLineSeek == TRUE){
122                 
123                         // Check if there is extra data on the next line 
124                         // (indicated by space or tab at the start) and add data.
125                 
126                         iter++;
127                         
128                         if (iter == ContactFileLines.end()){
129                         
130                                 iter--;
131                                 break;
132                         
133                         }                       
134                 
135                         wxSPropertyNextLine = iter->second;
136                         
137                 
138                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
139                 
140                                 wxSPropertyNextLine.Remove(0, 1);
141                                 //wxSPropertyNextLine.Trim(FALSE);
142                                 //ContactLine.Trim();
143                                 ContactLine.Append(wxSPropertyNextLine);
144                 
145                         } else {
146                         
147                                 iter--;
148                                 ExtraLineSeek = FALSE;
149                         
150                         }
151                 
152                 }
154                 ContactLineLen = ContactLine.Len();
155                 
156                 // Make sure we are not in quotation mode.
157                 // Make sure colon does not have \ or \\ before it.
158                 
159                 for (int i = 0; i <= ContactLineLen; i++){
160                 
161                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
162                         
163                                 PropertyFind = FALSE;
164                         
165                         } else if (PropertyFind == TRUE){
166                         
167                                 wxSProperty.Append(ContactLine.Mid(i, 1));
168                         
169                         }               
170                 
171                         if (ContactLine.Mid(i, 1) == wxT("\"")){
172                         
173                                 if (QuoteMode == TRUE){
174                                 
175                                         QuoteMode = FALSE;
176                                 
177                                 } else {
178                         
179                                         QuoteMode = TRUE;
180                                         
181                                 }
182                         
183                         }
184                         
185                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
186                         
187                                 QuoteBreakPoint = i;
188                                 break;
189                         
190                         }
191                 
192                 }
193                 
194                 // Split that line at the point into two variables (ignore the colon).
195                 
196                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
197                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
198                 
199                 // Add the data into the contact editor depending on what it is.                                
200                 
201                 if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
202                 
203                         int intPropertyLen = wxSPropertySeg1.Len();
204                         std::map<int, int> SplitPoints;
205                         std::map<int, int> SplitLength;
206                         std::map<int, int>::iterator SLiter;                    
207                         wxString PropertyData;
208                         wxString PropertyName;
209                         wxString PropertyValue;
210                         wxString PropertyTokens;
211                         bool AfterFirstToken = FALSE;
212                         bool FirstToken = TRUE;                 
213                         int intSplitsFound = 0;
214                         int intSplitSize = 0;
215                         int intPrevValue = 6;
216                         int intPref = 0;                        
217                         int intType = 0;
218                         int intSplitSeek = 0;
219                 
220                         if (wxSPropertySeg2 == wxT("individual")){
221                         
222                                 cmbType->SetSelection(1);
223                         
224                         } else if (wxSPropertySeg2 == wxT("group")){
225                         
226                                 cmbType->SetSelection(2);
227                                 IsGroup = TRUE;
228                         
229                         } else if (wxSPropertySeg2 == wxT("org")){
230                         
231                                 cmbType->SetSelection(3);
232                         
233                         } else if (wxSPropertySeg2 == wxT("location")){
234                         
235                                 cmbType->SetSelection(4);
236                         
237                         } else {
238                         
239                                 cmbType->SetSelection(0);
240                         
241                         }
242                         
243                         wxCommandEvent nullevent;
244                         
245                         UpdateMembersTab(nullevent);
246                 
247                 } else if (wxSProperty == wxT("MEMBER")){
249                         int intPropertyLen = wxSPropertySeg1.Len();
250                         std::map<int, int> SplitPoints;
251                         std::map<int, int> SplitLength;
252                         std::map<int, int>::iterator SLiter;                    
253                         wxString PropertyData;
254                         wxString PropertyName;
255                         wxString PropertyValue;
256                         wxString PropertyTokens;
257                         bool AfterFirstToken = FALSE;
258                         bool FirstToken = TRUE;                 
259                         int intSplitsFound = 0;
260                         int intSplitSize = 0;
261                         int intPrevValue = 8;
262                         int intPref = 0;                        
263                         int intType = 0;
264                         int intSplitSeek = 0;
265                 
266                         // Go through the list of contacts for the account and find the matching UID.
267                         // If contact with UID doesn't match then say (unknown contact).
268                         
269                         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
271                         //wxString vcardfilenamewxs;
272                         wxString vCardFilename;
273                         wxString vCardFilenameFull;
274                         wxString vCardDataString;
275                         //wxStringTokenizer vcardfileline;
276                         wxString lwxs;
277                         wxString setname, setvalue;
278                         //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
279                         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
280                         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
281                         int ContactIndex = 0;
282     
283                         wxDir vcardaccdir(AccountDirFinal);
284     
285                         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
286                         while(ProcFiles){
287     
288                                 if (vCardFilename.Right(4) == wxT(".vcf") || 
289                                     vCardFilename.Right(4) == wxT(".VCF") || 
290                                     vCardFilename.Right(5) == wxT(".vcard") || 
291                                     vCardFilename.Right(5) == wxT(".VCARD")){
292         
293                                     vCard Person;
294                 
295                                     vCardFilenameFull.Append(AccountDirFinal);
296                                     vCardFilenameFull.Append(wxT("/"));
297                                     vCardFilenameFull.Append(vCardFilename);
298                 
299                                     Person.LoadFile(vCardFilenameFull);
300                 
301                                     if (wxSPropertySeg2.Left(9) == wxT("urn:uuid:")){
302                 
303                                         wxString NewPropValue;
304                                         NewPropValue = wxSPropertySeg2.Mid(9, wxString::npos);
305                                         wxSPropertySeg2 = NewPropValue;
307                                     }
308                 
309                                     if (Person.MeetBaseSpecification()){
310         
311                                         wxString KindStatus = Person.Get(wxT("KIND"));
312                 
313                                         if (KindStatus == wxT("group")){
314                 
315                                                 vCardFilename.Clear();
316                                                 vCardFilenameFull.Clear();
317                                                 vCardDataString.Clear();
318                                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
319                                                 continue;
320                 
321                                         }
322                 
323                                         wxString PersonName = Person.Get(wxT("N"));
324                                         wxString PersonUID = Person.Get(wxT("UID"));
325                                         wxString PersonFilename = vCardFilenameFull;
326                                         
327                                         if (PersonUID != wxSPropertySeg2){
328                                         
329                                                 vCardFilename.Clear();
330                                                 vCardFilenameFull.Clear();
331                                                 vCardDataString.Clear();
332                                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
333                                                 continue;
334                                         
335                                         }
336                 
337                                         //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
338                                         //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
339         
340                                         if (XVMData.SortMode == 1){
342                                             // Split the name into sections.
343                         
344                                             vCardDataString = Person.Get(wxT("N"));
346                                             vCardName NameData = Person.GetName();
347                     
348                                             vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
349                     
350                                         } else if (XVMData.SortMode == 2){
351                     
352                                             // Split the name into sections.
353                     
354                                             vCardName NameData = Person.GetName();    
355                     
356                                             vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
357                     
358                                         } else if (XVMData.SortMode == 3){
359                     
360                                             // Check and make sure that the top most nickname is used.
361                     
362                                             vCardDataString = Person.Get(wxT("NICKNAME"));
363                     
364                                             if (vCardDataString.IsEmpty()){
365                         
366                                                 vCardDataString = wxT("(no nickname)");
367                         
368                                             }
369                     
370                                         } else if (XVMData.SortMode == 4){
371                     
372                                             vCardDataString = Person.Get(wxT("FN"));
373                     
374                                         }
375         
376                                         if (XVMData.AscendingMode == TRUE){
377                                             vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
378                                         } else {
379                                             vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
380                                         }
381                 
382                                     } else {
383         
384                                     }
385             
386             
387         
388                                 }
389         
390                                 vCardFilename.Clear();
391                                 vCardFilenameFull.Clear();
392                                 vCardDataString.Clear();
393                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
394         
395                             }
396     
397                             if (XVMData.AscendingMode == TRUE){
398              
399                                 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
400                                 iter != vCardNamesAsc.end(); ++iter){
402                                         wxListItem ItemData;
403                                         
404                                         ItemData.SetId(0);
405                                         ItemData.SetText(iter->first);
406                         
407                                         lboGroups->InsertItem(ItemData);
408                                         
409                                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
410                         
411                                 }
412                 
413                 
414                             } else {
415                 
416                                 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
417                                 iter != vCardNamesDsc.end(); ++iter){
419                                         wxListItem ItemData;
420                                         
421                                         ItemData.SetId(0);
422                                         ItemData.SetText(iter->first);
423                         
424                                         lboGroups->InsertItem(ItemData);
426                                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
428                                 }
430                             }
431                         
432                         GroupCount++;
433                         intValueSeek++;
434                 
435                 } else if (wxSProperty == wxT("FN")){
436                 
437                         /*
438                 
439                         NameDisplayAs = wxSPropertySeg2;
440                         cmbDisplayAs->SetValue(ContactData.Convert(wxSPropertySeg2, TRUE));
441                         
442                         */
443                         
444                         int intPropertyLen = wxSPropertySeg1.Len();
445                         std::map<int, int> SplitPoints;
446                         std::map<int, int> SplitLength;
447                         std::map<int, int>::iterator SLiter;                    
448                         wxString PropertyData;
449                         wxString PropertyName;
450                         wxString PropertyValue;
451                         wxString PropertyTokens;
452                         bool AfterFirstToken = FALSE;
453                         bool FirstToken = TRUE;                 
454                         int intSplitsFound = 0;
455                         int intSplitSize = 0;
456                         int intPrevValue = 4;
457                         int intPref = 0;                        
458                         int intType = 0;
459                         int intSplitSeek = 0;
460                         
461                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
462                         
463                         intPrevValue = 3;
464                         
465                         // Look for type before continuing.             
466                         
467                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
468                         intiter != SplitPoints.end(); ++intiter){
469                         
470                                 SLiter = SplitLength.find(intiter->first);
471                         
472                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
473                                 
474                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
475                                 PropertyName = PropertyElement.GetNextToken();                          
476                                 PropertyValue = PropertyElement.GetNextToken();
477                                 
478                                 intPrevValue = intiter->second;
479                                 
480                                 if (PropertyName == wxT("TYPE")){
481                                 
482                                         if (PropertyValue == wxT("work")){
483                                         
484                                                 intType = 2;                                    
485                                         
486                                         } else if (PropertyValue == wxT("home")){
488                                                 intType = 1;
489                                         
490                                         } else {
491                                         
492                                                 intType = 0;
493                                         
494                                         }
495                                 
496                                 }
497                         
498                         }
499                         
500                         // Setup blank lines for later on.
502                         FullNamesList.insert(std::make_pair(intValueSeek, wxT("")));
503                         FullNamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
504                         FullNamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
505                         FullNamesListPref.insert(std::make_pair(intValueSeek, 0));
506                         FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
507                         FullNamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
508                         FullNamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));              
509                         
510                         intPrevValue = 3;
511                         
512                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
513                         intiter != SplitPoints.end(); ++intiter){
514                         
515                                 SLiter = SplitLength.find(intiter->first);
516                         
517                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
518                                 
519                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
520                                 PropertyName = PropertyElement.GetNextToken();                          
521                                 PropertyValue = PropertyElement.GetNextToken();
522                                 
523                                 ProcessCaptureStrings(&PropertyValue);
524                                 
525                                 intPrevValue = intiter->second;
526                                 
527                                 // Process properties.
528                                 
529                                 if (PropertyName == wxT("ALTID")){
531                                         FullNamesListAltID.erase(intValueSeek); FullNamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
532                                 
533                                 } else if (PropertyName == wxT("PID")){
535                                         FullNamesListPID.erase(intValueSeek); FullNamesListPID.insert(std::make_pair(intValueSeek, PropertyValue));
536                                 
537                                 } else if (PropertyName == wxT("PREF")){
538                                         
539                                         intPref = wxAtoi(PropertyValue);
540                                         
541                                         if (intPref > 0 && intPref < 101){
542                                 
543                                                 FullNamesListPref.erase(intValueSeek); FullNamesListPref.insert(std::make_pair(intValueSeek, intPref));
544                                                 
545                                         }
546                                 
547                                 } else if (PropertyName == wxT("LANG")){
549                                         FullNamesListLanguage.erase(intValueSeek); FullNamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
550                                 
551                                 } else {
552                                 
553                                         // Something else we don't know about so append
554                                         // to the tokens variable.
555                                         
556                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
557                                         
558                                                 if (FirstToken == TRUE){
559                                                 
560                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
561                                                         FirstToken = FALSE;
562                                                 
563                                                 } else {
564                                                 
565                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
566                                                 
567                                                 }
568                                         
569                                         }
570                                 
571                                 }
572                         
573                         }                       
574                         
575                         // Split the address.           
576                 
577                         //std::map<int, int>::iterator SLiter;
578                         intPropertyLen = wxSPropertySeg2.Len();
579                         SplitPoints.clear();
580                         SplitLength.clear();
581                         intSplitsFound = 0;
582                         intSplitSize = 0;
583                         intPrevValue = 0;
584                         
585                         for (int i = 0; i <= intPropertyLen; i++){
586                 
587                                 intSplitSize++;
588                         
589                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
590                         
591                                         intSplitsFound++;
592                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
593                                         
594                                         if (intSplitsFound == 1){ 
595                                         
596                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
597                                                 break; 
598                                                 
599                                         }
600                                         
601                                         intSplitSize = 0;                                       
602                         
603                                 }
604                 
605                         }                       
606                         
607                         // Add the data to the General/Home/Work address variables.
608                         
609                         /*
610                         
611                         wxListItem coldata;
612                 
613                         coldata.SetId(intValueSeek);
614                         coldata.SetData(intValueSeek);
615                         coldata.SetText(IMPPType);
616                         
617                         */
618                         
619                         //ProcessCaptureStrings(wxsPropertySeg2);
620                         
621                         ProcessCaptureStrings(&wxSPropertySeg2);
622                         
623                         FullNamesList.erase(intValueSeek);
624                         FullNamesListType.erase(intValueSeek);
625                         FullNamesListTokens.erase(intValueSeek);
626                         FullNamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
627                         FullNamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
628                         
629                         if (intType == 0){
630                         
631                                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
632                         
633                         } else if (intType == 1){
634                         
635                                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("home")));                    
636                         
637                         } else if (intType == 2){
638                         
639                                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("work")));                    
640                         
641                         }
642                         
643                         if (FNProcessed == FALSE){
644                         
645                                 NameDisplayAs = wxSPropertySeg2;
646                                 cmbDisplayAs->SetValue(ContactData.Convert(wxSPropertySeg2, TRUE));
647                                 FNProcessed = TRUE;
648                                 
649                         }
650                         
651                         /*if (intType == 0){
652                         
653                                 ListCtrlIndex = lboIM->InsertItem(coldata);
654                                 
655                                 lboIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
656                                 
657                                 if (intPref > 0 && intPref < 101){
658                                 
659                                         lboIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
660                                         
661                                 }                               
662                                 
663                                 GeneralIMList.erase(intValueSeek);
664                                 GeneralIMListType.erase(intValueSeek);
665                                 GeneralIMListTokens.erase(intValueSeek);
666                                 GeneralIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
667                                 GeneralIMListType.insert(std::make_pair(intValueSeek, wxT("")));
668                                 GeneralIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
669                         
670                         } else if (intType == 1){ 
671                         
672                                 ListCtrlIndex = lboHomeIM->InsertItem(coldata);
674                                 lboHomeIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
676                                 if (intPref > 0 && intPref < 101){
677                                 
678                                         lboHomeIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
679                                         
680                                 }
682                                 HomeIMList.erase(intValueSeek);
683                                 HomeIMListType.erase(intValueSeek);
684                                 HomeIMListTokens.erase(intValueSeek);                           
685                                 HomeIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
686                                 HomeIMListType.insert(std::make_pair(intValueSeek, wxT("home")));
687                                 HomeIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
688                         
689                         } else if (intType == 2){ 
690                         
691                                 ListCtrlIndex = lboBusinessIM->InsertItem(coldata);
693                                 lboBusinessIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
695                                 if (intPref > 0 && intPref < 101){
696                                 
697                                         lboBusinessIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
698                                         
699                                 }
701                                 BusinessIMList.erase(intValueSeek);
702                                 BusinessIMListType.erase(intValueSeek);
703                                 BusinessIMListTokens.erase(intValueSeek);                               
704                                 BusinessIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
705                                 BusinessIMListType.insert(std::make_pair(intValueSeek, wxT("work")));
706                                 BusinessIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                              
707                         
708                         }*/
709                         
710                         FNCount++;
711                         intValueSeek++;                         
712                 
713                 } else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
714                 
715                         int intPropertyLen = wxSPropertySeg1.Len();
716                         std::map<int, int> SplitPoints;
717                         std::map<int, int> SplitLength;
718                         std::map<int, int>::iterator SLiter;                    
719                         wxString PropertyData;
720                         wxString PropertyName;
721                         wxString PropertyValue;
722                         wxString PropertyTokens;
723                         bool AfterFirstToken = FALSE;
724                         bool FirstToken = TRUE;                 
725                         int intSplitsFound = 0;
726                         int intSplitSize = 0;
727                         int intPrevValue = 3;
728                         int intPref = 0;                        
729                         int intType = 0;
730                         int intSplitSeek = 0;
731                         
732                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
733                         
734                         // Look for type before continuing.             
735                         
736                         intPrevValue = 2;                       
737                         
738                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
739                         intiter != SplitPoints.end(); ++intiter){
740                         
741                                 SLiter = SplitLength.find(intiter->first);
742                         
743                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
744                                 
745                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
746                                 PropertyName = PropertyElement.GetNextToken();                          
747                                 PropertyValue = PropertyElement.GetNextToken();
748                                 
749                                 intPrevValue = intiter->second;
750                         
751                         }
752                         
753                         intPrevValue = 2;
754                         
755                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
756                         intiter != SplitPoints.end(); ++intiter){
757                         
758                                 SLiter = SplitLength.find(intiter->first);
759                         
760                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
761                                 
762                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
763                                 PropertyName = PropertyElement.GetNextToken();                          
764                                 PropertyValue = PropertyElement.GetNextToken();
765                                 
766                                 ProcessCaptureStrings(&PropertyValue);
767                                 
768                                 intPrevValue = intiter->second;
769                                 
770                                 // Process properties.
771                                 
772                                 if (PropertyName == wxT("ALTID")){
774                                         NameAltID = PropertyValue;
775                                 
776                                 } else if (PropertyName == wxT("LANG")){
778                                         NameLanguage = PropertyValue;
779                                 
780                                 } else if (PropertyName == wxT("SORT-AS")){
781                                 
782                                         NameDisplayAs = PropertyValue;
783                                 
784                                 } else {
785                                 
786                                         // Something else we don't know about so append
787                                         // to the tokens variable.
788                                         
789                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
790                                         
791                                                 if (FirstToken == TRUE){
792                                                 
793                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
794                                                         FirstToken = FALSE;
795                                                 
796                                                 } else {
797                                                 
798                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
799                                                 
800                                                 }
801                                         
802                                         }
803                                 
804                                 }
805                         
806                         }
807                         
808                         intPropertyLen = wxSPropertySeg2.Len();
809                         SplitPoints.clear();
810                         SplitLength.clear();
811                         intSplitSeek = 0;               
812                         intSplitsFound = 0;
813                         intSplitSize = 0;
814                         intPrevValue = 0;                                       
815                         
816                         for (int i = 0; i <= intPropertyLen; i++){
817                 
818                                 intSplitSize++;
819                         
820                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
821                         
822                                         intSplitsFound++;
823                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
824                                         
825                                         if (intSplitsFound == 4){ 
826                                         
827                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
828                                                 break; 
829                                                 
830                                         } else {
831                                         
832                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
833                                         
834                                         }
835                                         
836                                         intSplitSize = 0;                                       
837                         
838                                 }
839                 
840                         }
841                         
842                         // Split the data into several parts.
843                                         
844                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
845                         intiter != SplitPoints.end(); ++intiter){
846                         
847                                 if (intiter->first == 1){
848                                 
849                                         // Deal with family name.
850                                         
851                                         SLiter = SplitLength.find(1);
852                                                                                 
853                                         txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
854                                         
855                                         intPrevValue = intiter->second;
856                                         NameSurname = wxSPropertySeg2.Mid(0, SLiter->second);                                   
857                                 
858                                 } else if (intiter->first == 2){
859                                 
860                                         // Deal with given names.
861                                         
862                                         SLiter = SplitLength.find(2);
863                                                                                 
864                                         txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
865                                         intPrevValue = intiter->second;
866                                         NameForename = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
867                                 
868                                 } else if (intiter->first == 3){
869                                 
870                                         // Deal with additional names.
871                                         
872                                         SLiter = SplitLength.find(3);
873                                                                                 
874                                         txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
875                                         intPrevValue = intiter->second;
876                                         NameOtherNames = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
877                                 
878                                 } else if (intiter->first == 4){
879                                 
880                                         // Deal with honorifix prefixes and suffixes.
882                                         SLiter = SplitLength.find(4);
883                                                                                 
884                                         txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
885                                         intPrevValue = intiter->second;
886                                         NameTitle = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
887                                 
888                                         txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
889                                         NameSuffix = wxSPropertySeg2.Mid(intPrevValue);
890                                 
891                                 }
892                         
893                         }
894                         
895                         NameTokens = PropertyTokens;
896                         NameProcessed = TRUE;
897                 
898                 } else if (wxSProperty == wxT("NICKNAME")){
899                         
900                         int intPropertyLen = wxSPropertySeg1.Len();
901                         std::map<int, int> SplitPoints;
902                         std::map<int, int> SplitLength;
903                         std::map<int, int>::iterator SLiter;                    
904                         wxString PropertyData;
905                         wxString PropertyName;
906                         wxString PropertyValue;
907                         wxString PropertyTokens;
908                         bool AfterFirstToken = FALSE;
909                         bool FirstToken = TRUE;                 
910                         int intSplitsFound = 0;
911                         int intSplitSize = 0;
912                         int intPrevValue = 10;
913                         int intPref = 0;                        
914                         int intType = 0;
915                         int intSplitSeek = 0;
916                         long ListCtrlIndex;
917                         
918                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
920                         intPrevValue = 9;
921                         
922                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
923                         intiter != SplitPoints.end(); ++intiter){
924                         
925                                 SLiter = SplitLength.find(intiter->first);
926                         
927                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
928                                 
929                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
930                                 PropertyName = PropertyElement.GetNextToken();                          
931                                 PropertyValue = PropertyElement.GetNextToken();
932                                 
933                                 intPrevValue = intiter->second;
934                                 
935                                 if (PropertyName == wxT("TYPE")){
936                                 
937                                         if (PropertyValue == wxT("work")){
938                                         
939                                                 intType = 2;                                    
940                                         
941                                         } else if (PropertyValue == wxT("home")){
943                                                 intType = 1;
944                                         
945                                         } else {
946                                         
947                                                 intType = 0;
948                                         
949                                         }
950                                 
951                                 }
952                         
953                         }
954                         
955                         // Setup blank lines for later on.
956                         
957                         if (intType == 0){
958                         
959                                 GeneralNicknamesList.insert(std::make_pair(intValueSeek, wxT("")));
960                                 GeneralNicknamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
961                                 GeneralNicknamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
962                                 GeneralNicknamesListPref.insert(std::make_pair(intValueSeek, 0));
963                                 GeneralNicknamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
964                                 GeneralNicknamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
966                         } else if (intType == 1){
967                         
968                                 HomeNicknamesList.insert(std::make_pair(intValueSeek, wxT("")));
969                                 HomeNicknamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
970                                 HomeNicknamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
971                                 HomeNicknamesListPref.insert(std::make_pair(intValueSeek, 0));
972                                 HomeNicknamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
973                                 HomeNicknamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                                
974                         
975                         } else if (intType == 2){
977                                 BusinessNicknamesList.insert(std::make_pair(intValueSeek, wxT("")));
978                                 BusinessNicknamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
979                                 BusinessNicknamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
980                                 BusinessNicknamesListPref.insert(std::make_pair(intValueSeek, 0));
981                                 BusinessNicknamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
982                                 BusinessNicknamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                            
983                         
984                         }
985                         
986                         intPrevValue = 9;
987                         
988                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
989                         intiter != SplitPoints.end(); ++intiter){
990                         
991                                 SLiter = SplitLength.find(intiter->first);
992                         
993                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
994                                 
995                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
996                                 PropertyName = PropertyElement.GetNextToken();                          
997                                 PropertyValue = PropertyElement.GetNextToken();
998                                 
999                                 intPrevValue = intiter->second;
1000                                 
1001                                 ProcessCaptureStrings(&PropertyValue);
1002                                 
1003                                 // Process properties.
1004                                 
1005                                 int intPropertyValueLen = PropertyValue.Len();                          
1006                                 
1007                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1008                                         
1009                                         PropertyValue.Trim();
1010                                         PropertyValue.RemoveLast();
1011                                         
1012                                 }                               
1013                                 
1014                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1015                                         
1016                                         PropertyValue.Remove(0, 1);
1017                                         
1018                                 }                               
1019                                 
1020                                 if (PropertyName == wxT("ALTID")){
1022                                         if (intType == 0){ GeneralNicknamesListAltID.erase(intValueSeek); GeneralNicknamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1023                                         else if (intType == 1){ HomeNicknamesListAltID.erase(intValueSeek); HomeNicknamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1024                                         else if (intType == 2){ BusinessNicknamesListAltID.erase(intValueSeek); BusinessNicknamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1025                                 
1026                                 } else if (PropertyName == wxT("PID")){
1028                                         if (intType == 0){ GeneralNicknamesListPID.erase(intValueSeek); GeneralNicknamesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1029                                         else if (intType == 1){ HomeNicknamesListPID.erase(intValueSeek); HomeNicknamesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1030                                         else if (intType == 2){ BusinessNicknamesListPID.erase(intValueSeek); BusinessNicknamesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1031                                 
1032                                 } else if (PropertyName == wxT("PREF")){
1033                                         
1034                                         intPref = wxAtoi(PropertyValue);
1035                                 
1036                                         if (intType == 0){ GeneralNicknamesListPref.erase(intValueSeek); GeneralNicknamesListPref.insert(std::make_pair(intValueSeek, intPref)); }
1037                                         else if (intType == 1){ HomeNicknamesListPref.erase(intValueSeek); HomeNicknamesListPref.insert(std::make_pair(intValueSeek, intPref)); }
1038                                         else if (intType == 2){ BusinessNicknamesListPref.erase(intValueSeek); BusinessNicknamesListPref.insert(std::make_pair(intValueSeek, intPref)); }
1039                                 
1040                                 } else if (PropertyName == wxT("LANGUAGE")){
1041                                 
1042                                         if (intType == 0){ GeneralNicknamesListLanguage.erase(intValueSeek); GeneralNicknamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
1043                                         else if (intType == 1){ HomeNicknamesListLanguage.erase(intValueSeek); HomeNicknamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
1044                                         else if (intType == 2){ BusinessNicknamesListLanguage.erase(intValueSeek); BusinessNicknamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
1045                                 
1046                                 } else {
1047                                 
1048                                         // Something else we don't know about so append
1049                                         // to the tokens variable.
1050                                 
1051                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1052                                 
1053                                                 if (FirstToken == TRUE){
1054                                         
1055                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1056                                                         FirstToken = FALSE;
1057                                         
1058                                                 } else {
1059                                         
1060                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1061                                         
1062                                                 }
1063                                 
1064                                         }
1065                                 
1066                                 }
1067                         
1068                         }
1069                         
1070                         // Add the data to the General/Home/Work address variables.
1071                         
1072                         ProcessCaptureStrings(&wxSPropertySeg2);
1073                         
1074                         wxListItem coldata;
1075                 
1076                         coldata.SetId(intValueSeek);
1077                         coldata.SetData(intValueSeek);
1078                         coldata.SetText(wxSPropertySeg2);
1079                         
1080                         if (intType == 0){
1081                         
1082                                 ListCtrlIndex = lboNicknames->InsertItem(coldata);
1083                                 
1084                                 if (intPref > 0 && intPref < 101){
1085                                 
1086                                         lboNicknames->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
1087                                         
1088                                 }
1089                                 
1090                                 GeneralNicknamesList.erase(intValueSeek);
1091                                 GeneralNicknamesListType.erase(intValueSeek);
1092                                 GeneralNicknamesListTokens.erase(intValueSeek);
1093                                 GeneralNicknamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
1094                                 GeneralNicknamesListType.insert(std::make_pair(intValueSeek, wxT("")));
1095                                 GeneralNicknamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
1096                         
1097                         } else if (intType == 1){ 
1098                         
1099                                 ListCtrlIndex = lboHomeNicknames->InsertItem(coldata);
1101                                 if (intPref > 0 && intPref < 101){
1102                                 
1103                                         lboHomeNicknames->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
1104                                         
1105                                 }
1107                                 HomeNicknamesList.erase(intValueSeek);
1108                                 HomeNicknamesListType.erase(intValueSeek);
1109                                 HomeNicknamesListTokens.erase(intValueSeek);                            
1110                                 HomeNicknamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
1111                                 HomeNicknamesListType.insert(std::make_pair(intValueSeek, wxT("home")));
1112                                 HomeNicknamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
1113                         
1114                         } else if (intType == 2){ 
1115                         
1116                                 ListCtrlIndex = lboBusinessNicknames->InsertItem(coldata);
1118                                 if (intPref > 0 && intPref < 101){
1119                                 
1120                                         lboBusinessNicknames->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
1121                                         
1122                                 }
1124                                 BusinessNicknamesList.erase(intValueSeek);
1125                                 BusinessNicknamesListType.erase(intValueSeek);
1126                                 BusinessNicknamesListTokens.erase(intValueSeek);                                
1127                                 BusinessNicknamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
1128                                 BusinessNicknamesListType.insert(std::make_pair(intValueSeek, wxT("work")));
1129                                 BusinessNicknamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                               
1130                         
1131                         }
1132                 
1133                         NicknameCount++;
1134                         intValueSeek++; 
1135                         
1136                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
1137                 
1138                         int intPropertyLen = wxSPropertySeg1.Len();
1139                         std::map<int, int> SplitPoints;
1140                         std::map<int, int> SplitLength;
1141                         std::map<int, int>::iterator SLiter;                    
1142                         wxString PropertyData;
1143                         wxString PropertyName;
1144                         wxString PropertyValue;
1145                         wxString PropertyTokens;
1146                         bool AfterFirstToken = FALSE;
1147                         bool FirstToken = TRUE;;
1148                         int intSplitsFound = 0;
1149                         int intSplitSize = 0;
1150                         int intPrevValue = 8;
1151                         int intPref = 0;                        
1152                         int intType = 0;
1153                         int intSplitSeek = 0;
1154                 
1155                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1156                         
1157                         intPrevValue = 7;                       
1158                         
1159                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1160                         intiter != SplitPoints.end(); ++intiter){
1161                         
1162                                 SLiter = SplitLength.find(intiter->first);
1163                         
1164                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
1165                                 
1166                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1167                                 PropertyName = PropertyElement.GetNextToken();                          
1168                                 PropertyValue = PropertyElement.GetNextToken();
1169                                 
1170                                 intPrevValue = intiter->second;
1171                                 
1172                                 // Process properties.
1173                                 
1174                                 int intPropertyValueLen = PropertyValue.Len();                          
1175                                 
1176                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1177                                         
1178                                         PropertyValue.Trim();
1179                                         PropertyValue.RemoveLast();
1180                                         
1181                                 }                               
1182                                 
1183                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1184                                         
1185                                         PropertyValue.Remove(0, 1);
1186                                         
1187                                 }                               
1188                                 
1189                                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1190                 
1191                                         if (FirstToken == TRUE){
1192                         
1193                                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1194                                                 FirstToken = FALSE;
1195                         
1196                                         } else {
1197                         
1198                                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1199                         
1200                                         }
1201                 
1202                                 }
1203                         
1204                         }       
1205                 
1206                         wxStringTokenizer GenderDetails (wxSPropertySeg2, wxT(";"));
1207                         
1208                         wxString GenderComponent;
1209                         wxString GenderIdentity;
1210                         
1211                         if (GenderDetails.CountTokens() >= 2){
1212                         
1213                                 GenderComponent = GenderDetails.GetNextToken();
1214                                 GenderIdentity = GenderDetails.GetString();
1215                         
1216                                 ProcessCaptureStrings(&GenderIdentity);
1217                         
1218                                 txtGenderDescription->SetValue(ContactData.Convert(GenderIdentity, TRUE));
1219                                                                 
1220                         } else {
1221                         
1222                                 GenderComponent = GenderDetails.GetNextToken();
1223                         
1224                         }
1225                                 
1226                         if (GenderComponent == wxT("M")){
1227                                 
1228                                 // Gender is Male.
1229                                         
1230                                 cmbGender->SetSelection(1);
1231                                 
1232                         } else if (GenderComponent == wxT("F")){
1233                                 
1234                                 // Gender is Female.
1235                                         
1236                                 cmbGender->SetSelection(2);                                     
1237                                 
1238                         } else if (GenderComponent == wxT("O")){
1239                                 
1240                                 // Gender is Other.
1241                                         
1242                                 cmbGender->SetSelection(3);
1243                                 
1244                         } else if (GenderComponent == wxT("N")){
1245                                 
1246                                 // Gender is None/Not Applicable.
1247                                 
1248                                 cmbGender->SetSelection(4);                                     
1249                                 
1250                         } else if (GenderComponent == wxT("U")){
1251                                 
1252                                 // Gender is Unknown.
1253                                         
1254                                 cmbGender->SetSelection(5);                                     
1255                                 
1256                         }
1257                         
1258                         GenderTokens = PropertyTokens;
1259                         GenderProcessed = TRUE;
1260                 
1261                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
1263                         // Process date. Preserve the remainder in the string.
1264                                 
1265                         int intPropertyLen = wxSPropertySeg1.Len();
1266                         std::map<int, int> SplitPoints;
1267                         std::map<int, int> SplitLength;
1268                         std::map<int, int>::iterator SLiter;                    
1269                         wxString PropertyData;
1270                         wxString PropertyName;
1271                         wxString PropertyValue;
1272                         wxString PropertyTokens;
1273                         bool AfterFirstToken = FALSE;
1274                         bool BirthdayText = FALSE;
1275                         bool FirstToken = TRUE;                         
1276                         int intSplitsFound = 0;
1277                         int intSplitSize = 0;
1278                         int intPrevValue = 6;
1279                         int intPref = 0;                        
1280                         int intType = 0;
1281                         int intSplitSeek = 0;
1282                 
1283                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1284                 
1285                         intPrevValue = 5;
1286                 
1287                         // Look for type before continuing.
1288                 
1289                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1290                         intiter != SplitPoints.end(); ++intiter){
1291                 
1292                                 SLiter = SplitLength.find(intiter->first);
1293                 
1294                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
1295                         
1296                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1297                                 PropertyName = PropertyElement.GetNextToken();                          
1298                                 PropertyValue = PropertyElement.GetNextToken();
1299                         
1300                                 intPrevValue = intiter->second;
1301                         
1302                                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1303                         
1304                                         ProcessCaptureStrings(&wxSPropertySeg2);
1305                                         txtBirthday->SetValue(wxSPropertySeg2);
1306                                         Birthday = wxSPropertySeg2;
1307                                         BirthdayText = TRUE;
1308                         
1309                                 }
1310                 
1311                         }
1312                 
1313                         // Setup blank lines for later on.
1314                         
1315                         intPrevValue = 5;
1316                 
1317                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1318                         intiter != SplitPoints.end(); ++intiter){
1319                 
1320                                 SLiter = SplitLength.find(intiter->first);
1321                 
1322                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
1323                         
1324                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1325                                 PropertyName = PropertyElement.GetNextToken();                          
1326                                 PropertyValue = PropertyElement.GetNextToken();
1327                         
1328                                 intPrevValue = intiter->second;
1329                         
1330                                 // Process properties.
1331                         
1332                                 ProcessCaptureStrings(&PropertyValue);
1333                         
1334                                 int intPropertyValueLen = PropertyValue.Len();                          
1335                         
1336                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1337                                 
1338                                         PropertyValue.Trim();
1339                                         PropertyValue.RemoveLast();
1340                                 
1341                                 }                               
1342                         
1343                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1344                                 
1345                                         PropertyValue.Remove(0, 1);
1346                                 
1347                                 }                               
1348                         
1349                                 if (PropertyName == wxT("ALTID")){
1351                                         BirthdayAltID = PropertyValue;
1352                         
1353                                 } else if (PropertyName == wxT("CALSCALE")){
1354                         
1355                                         BirthdayCalScale = PropertyValue;
1356                         
1357                                 } else if (PropertyName != wxT("VALUE")) {
1358                         
1359                                         // Something else we don't know about so append
1360                                         // to the tokens variable.
1361                                 
1362                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1363                                 
1364                                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1365                                                 
1366                                         }
1367                                         
1368                                 }
1369                 
1370                         }       
1371                 
1372                         // Add the data to the variables and form.
1373                         
1374                         if (BirthdayText == FALSE){
1375                         
1376                                 Birthday = wxSPropertySeg2;
1377                                 int DateYear = 0;
1378                                 wxDateTime::Month DateMonth;
1379                                 unsigned int DateDay;
1380                                 
1381                                 wxString wxSData;
1382                                 
1383                                 if (Birthday.Mid(0, 2) == wxT("--")){
1384                                 
1385                                         // Skip year.
1386                                 
1387                                 } else {
1388                                 
1389                                         DateYear = wxAtoi(Birthday.Mid(0,4));
1390                                 
1391                                 }
1392                                 
1393                                 DateMonth = (wxDateTime::Month)(wxAtoi(Birthday.Mid(4,2)) - 1);
1394                                 DateDay = wxAtoi(Birthday.Mid(6,2));
1395                         
1396                                 wxDateTime BDayDate(DateDay,DateMonth,DateYear);
1397                         
1398                                 /*BDayDate.SetDay(DateDay);
1399                                 BDayDate.SetMonth(wxDateTime::Month::Jan);
1400                                 BDayDate.SetYear(DateYear);*/
1401                         
1402                                 dapBirthday->SetValue(BDayDate);                                
1403                         
1404                         }
1405                         
1406                         BirthdayTokens = PropertyTokens;
1407                         
1408                         BirthdayProcessed = TRUE;
1409                 
1410                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
1411                         
1412                         // Process date. Preserve the remainder in the string.
1413                                 
1414                         int intPropertyLen = wxSPropertySeg1.Len();
1415                         std::map<int, int> SplitPoints;
1416                         std::map<int, int> SplitLength;
1417                         std::map<int, int>::iterator SLiter;                    
1418                         wxString PropertyData;
1419                         wxString PropertyName;
1420                         wxString PropertyValue;
1421                         wxString PropertyTokens;
1422                         bool AfterFirstToken = FALSE;
1423                         bool AnniversaryText = FALSE;
1424                         bool FirstToken = TRUE;                         
1425                         int intSplitsFound = 0;
1426                         int intSplitSize = 0;
1427                         int intPrevValue = 13;
1428                         int intPref = 0;                        
1429                         int intType = 0;
1430                         int intSplitSeek = 0;
1431                 
1432                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1433                 
1434                         intPrevValue = 12;
1435                 
1436                         // Look for type before continuing.
1437                 
1438                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1439                         intiter != SplitPoints.end(); ++intiter){
1440                 
1441                                 SLiter = SplitLength.find(intiter->first);
1442                 
1443                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
1444                         
1445                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1446                                 PropertyName = PropertyElement.GetNextToken();                          
1447                                 PropertyValue = PropertyElement.GetNextToken();
1448                         
1449                                 intPrevValue = intiter->second;
1450                         
1451                                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1452                         
1453                                         ProcessCaptureStrings(&wxSPropertySeg2);
1454                                         txtAnniversary->SetValue(wxSPropertySeg2);
1455                                         Anniversary = wxSPropertySeg2;
1456                                         AnniversaryText = TRUE;
1457                         
1458                                 }
1459                 
1460                         }
1461                 
1462                         // Setup blank lines for later on.
1463                 
1464                         intPrevValue = 12;
1465                 
1466                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1467                         intiter != SplitPoints.end(); ++intiter){
1468                 
1469                                 SLiter = SplitLength.find(intiter->first);
1470                 
1471                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
1472                         
1473                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1474                                 PropertyName = PropertyElement.GetNextToken();                          
1475                                 PropertyValue = PropertyElement.GetNextToken();
1476                         
1477                                 intPrevValue = intiter->second;
1478                         
1479                                 // Process properties.
1480                         
1481                                 int intPropertyValueLen = PropertyValue.Len();                          
1482                         
1483                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1484                                 
1485                                         PropertyValue.Trim();
1486                                         PropertyValue.RemoveLast();
1487                                 
1488                                 }                               
1489                         
1490                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1491                                 
1492                                         PropertyValue.Remove(0, 1);
1493                                 
1494                                 }
1495                                 
1496                                 ProcessCaptureStrings(&PropertyValue);          
1497                         
1498                                 if (PropertyName == wxT("ALTID")){
1500                                         AnniversaryAltID = PropertyValue;
1501                         
1502                                 } else if (PropertyName == wxT("CALSCALE")){
1503                         
1504                                         AnniversaryCalScale = PropertyValue;
1505                         
1506                                 } else if (PropertyName != wxT("VALUE")) {
1507                         
1508                                         // Something else we don't know about so append
1509                                         // to the tokens variable.
1510                                         
1511                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1512                                 
1513                                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1514                                                 
1515                                         }
1516                         
1517                                 }
1518                 
1519                         }       
1520                 
1521                         // Add the data to the variables and form.
1522                         
1523                         if (AnniversaryText == FALSE){
1524                         
1525                                 Anniversary = wxSPropertySeg2;
1526                                 int DateYear = 0;
1527                                 wxDateTime::Month DateMonth;
1528                                 int DateDay;
1529                                 
1530                                 wxString wxSData;
1531                                 
1532                                 if (Anniversary.Mid(0, 2) == wxT("--")){
1533                                 
1534                                         // Skip year.
1535                                 
1536                                 } else {
1537                                 
1538                                         DateYear = wxAtoi(Anniversary.Mid(0,4));
1539                                 
1540                                 }
1541                                 
1542                                 DateMonth = (wxDateTime::Month)(wxAtoi(Anniversary.Mid(4,2)) - 1);
1543                                 DateDay = wxAtoi(Anniversary.Mid(6,2));                                 
1544                         
1545                                 wxDateTime ADayDate(DateDay,DateMonth,DateYear);
1546                         
1547                                 dapAnniversary->SetValue(ADayDate);
1548                         
1549                         }
1550                         
1551                         AnniversaryTokens = PropertyTokens;
1552                         
1553                         AnniversaryProcessed = TRUE;
1554                 
1555                 } else if (wxSProperty == wxT("TZ")){
1556                 
1557                         int intPropertyLen = wxSPropertySeg1.Len();
1558                         std::map<int, int> SplitPoints;
1559                         std::map<int, int> SplitLength;
1560                         std::map<int, int>::iterator SLiter;                    
1561                         wxString PropertyData;
1562                         wxString PropertyName;
1563                         wxString PropertyValue;
1564                         wxString PropertyTokens;
1565                         bool AfterFirstToken = FALSE;
1566                         bool FirstToken = TRUE;                 
1567                         int intSplitsFound = 0;
1568                         int intSplitSize = 0;
1569                         int intPrevValue = 4;
1570                         int intPref = 0;                        
1571                         int intType = 0;
1572                         int intSplitSeek = 0;
1573                         long ListCtrlIndex;
1574                         
1575                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1576                         
1577                         intPrevValue = 3;
1578                         
1579                         // Look for type before continuing.
1580                         
1581                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1582                         intiter != SplitPoints.end(); ++intiter){
1583                         
1584                                 SLiter = SplitLength.find(intiter->first);
1585                         
1586                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
1587                                 
1588                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1589                                 PropertyName = PropertyElement.GetNextToken();                          
1590                                 PropertyValue = PropertyElement.GetNextToken();
1591                                 
1592                                 intPrevValue = intiter->second;
1593                                 
1594                                 if (PropertyName == wxT("TYPE")){
1595                                 
1596                                         if (PropertyValue == wxT("work")){
1597                                         
1598                                                 intType = 2;                                    
1599                                         
1600                                         } else if (PropertyValue == wxT("home")){
1602                                                 intType = 1;
1603                                         
1604                                         } else {
1605                                         
1606                                                 intType = 0;
1607                                         
1608                                         }
1609                                 
1610                                 }
1611                         
1612                         }
1613                         
1614                         // Setup blank lines for later on.
1615                         
1616                         if (intType == 0){
1617                         
1618                                 GeneralTZList.insert(std::make_pair(intValueSeek, wxT("")));
1619                                 GeneralTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
1620                                 GeneralTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
1621                                 GeneralTZListPref.insert(std::make_pair(intValueSeek, 0));
1622                                 GeneralTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
1623                                 GeneralTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
1625                         } else if (intType == 1){
1626                         
1627                                 HomeTZList.insert(std::make_pair(intValueSeek, wxT("")));
1628                                 HomeTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
1629                                 HomeTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
1630                                 HomeTZListPref.insert(std::make_pair(intValueSeek, 0));
1631                                 HomeTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));                              
1632                                 HomeTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
1633                         
1634                         } else if (intType == 2){
1636                                 BusinessTZList.insert(std::make_pair(intValueSeek, wxT("")));
1637                                 BusinessTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
1638                                 BusinessTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
1639                                 BusinessTZListPref.insert(std::make_pair(intValueSeek, 0));
1640                                 BusinessTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));                          
1641                                 BusinessTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
1642                         
1643                         }
1644                         
1645                         intPrevValue = 3;
1646                         
1647                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1648                         intiter != SplitPoints.end(); ++intiter){
1649                         
1650                                 SLiter = SplitLength.find(intiter->first);
1651                         
1652                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
1653                                 
1654                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1655                                 PropertyName = PropertyElement.GetNextToken();                          
1656                                 PropertyValue = PropertyElement.GetNextToken();
1657                                 
1658                                 intPrevValue = intiter->second;
1659                                 
1660                                 int intPropertyValueLen = PropertyValue.Len();                          
1661                                 
1662                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1663                                         
1664                                         PropertyValue.Trim();
1665                                         PropertyValue.RemoveLast();
1666                                         
1667                                 }                               
1668                                 
1669                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1670                                         
1671                                         PropertyValue.Remove(0, 1);
1672                                         
1673                                 }                               
1674                                 
1675                                 ProcessCaptureStrings(&PropertyValue);
1676                                 
1677                                 // Process properties.
1678                                 
1679                                 if (PropertyName == wxT("ALTID")){
1681                                         if (intType == 0){ GeneralTZListAltID.erase(intValueSeek); GeneralTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1682                                         else if (intType == 1){ HomeTZListAltID.erase(intValueSeek); HomeTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1683                                         else if (intType == 2){ BusinessTZListAltID.erase(intValueSeek); BusinessTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1684                                 
1685                                 } else if (PropertyName == wxT("PID")){
1687                                         if (intType == 0){ GeneralTZListPID.erase(intValueSeek); GeneralTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1688                                         else if (intType == 1){ HomeTZListPID.erase(intValueSeek); HomeTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1689                                         else if (intType == 2){ BusinessTZListPID.erase(intValueSeek); BusinessTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
1690                                 
1691                                 } else if (PropertyName == wxT("MEDIATYPE")){
1692                                 
1693                                         if (intType == 0){ GeneralTZListMediatype.erase(intValueSeek); GeneralTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
1694                                         else if (intType == 1){ HomeTZListMediatype.erase(intValueSeek); HomeTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
1695                                         else if (intType == 2){ BusinessTZListMediatype.erase(intValueSeek); BusinessTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
1696                                 
1697                                 } else if (PropertyName == wxT("PREF")){
1698                                         
1699                                         intPref = wxAtoi(PropertyValue);
1700                                 
1701                                         if (intPref > 0 && intPref < 101){
1702                                 
1703                                                 if (intType == 0){ GeneralTZListPref.erase(intValueSeek); GeneralTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
1704                                                 else if (intType == 1){ HomeTZListPref.erase(intValueSeek); HomeTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
1705                                                 else if (intType == 2){ BusinessTZListPref.erase(intValueSeek); BusinessTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
1706                                         
1707                                         }
1708                                 
1709                                 } else {
1710                                 
1711                                         // Something else we don't know about so append
1712                                         // to the tokens variable.
1713                                         
1714                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1715                                         
1716                                                 if (FirstToken == TRUE){
1717                                                 
1718                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1719                                                         FirstToken = FALSE;
1720                                                 
1721                                                 } else {
1722                                                 
1723                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1724                                                 
1725                                                 }
1726                                         
1727                                         }
1728                                 
1729                                 }
1730                         
1731                         }                       
1732                         
1733                         // Split the address. 
1734                 
1735                         //std::map<int, int>::iterator SLiter;
1736                         intPropertyLen = wxSPropertySeg2.Len();
1737                         SplitPoints.clear();
1738                         SplitLength.clear();
1739                         intSplitsFound = 0;
1740                         intSplitSize = 0;
1741                         intPrevValue = 0;
1742                         
1743                         for (int i = 0; i <= intPropertyLen; i++){
1744                 
1745                                 intSplitSize++;
1746                         
1747                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1748                         
1749                                         intSplitsFound++;
1750                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1751                                         
1752                                         if (intSplitsFound == 6){ 
1753                                         
1754                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1755                                                 break; 
1756                                                 
1757                                         } else {
1758                                         
1759                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1760                                         
1761                                         }
1762                                         
1763                                         intSplitSize = 0;                                       
1764                         
1765                                 }
1766                 
1767                         }       
1768                         
1769                         // Add the data to the General/Home/Work address variables.
1770                         
1771                         ProcessCaptureStrings(&wxSPropertySeg2);                        
1772                         
1773                         wxListItem coldata;
1774                 
1775                         coldata.SetId(intValueSeek);
1776                         coldata.SetData(intValueSeek);
1777                         coldata.SetText(wxSPropertySeg2);
1778                         
1779                         if (intType == 0){
1780                         
1781                                 ListCtrlIndex = lboTimezones->InsertItem(coldata);
1782                                 
1783                                 if (intPref > 0 && intPref < 101){
1784                                 
1785                                         lboTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
1786                                         
1787                                 }
1788                                 
1789                                 GeneralTZList.erase(intValueSeek);
1790                                 GeneralTZListType.erase(intValueSeek);
1791                                 GeneralTZListTokens.erase(intValueSeek);
1792                                 GeneralTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
1793                                 GeneralTZListType.insert(std::make_pair(intValueSeek, wxT("")));
1794                                 GeneralTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
1795                         
1796                         } else if (intType == 1){ 
1797                         
1798                                 ListCtrlIndex = lboHomeTimezones->InsertItem(coldata);
1800                                 if (intPref > 0 && intPref < 101){
1801                                 
1802                                         lboHomeTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
1803                                         
1804                                 }
1806                                 HomeTZList.erase(intValueSeek);
1807                                 HomeTZListType.erase(intValueSeek);
1808                                 HomeTZListTokens.erase(intValueSeek);                           
1809                                 HomeTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
1810                                 HomeTZListType.insert(std::make_pair(intValueSeek, wxT("home")));
1811                                 HomeTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
1812                         
1813                         } else if (intType == 2){ 
1814                         
1815                                 ListCtrlIndex = lboBusinessTimezones->InsertItem(coldata);
1817                                 if (intPref > 0 && intPref < 101){
1818                                 
1819                                         lboBusinessTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
1820                                         
1821                                 }
1823                                 BusinessTZList.erase(intValueSeek);
1824                                 BusinessTZListType.erase(intValueSeek);
1825                                 BusinessTZListTokens.erase(intValueSeek);                               
1826                                 BusinessTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
1827                                 BusinessTZListType.insert(std::make_pair(intValueSeek, wxT("work")));
1828                                 BusinessTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                              
1829                         
1830                         }
1831                 
1832                         TZCount++;
1833                         intValueSeek++;         
1834                 
1835                 } else if (wxSProperty == wxT("ADR")){
1836                         
1837                         int intPropertyLen = wxSPropertySeg1.Len();
1838                         std::map<int, int> SplitPoints;
1839                         std::map<int, int> SplitLength;
1840                         std::map<int, int>::iterator SLiter;                    
1841                         wxString PropertyData;
1842                         wxString PropertyName;
1843                         wxString PropertyValue;
1844                         wxString PropertyTokens;
1845                         wxString AddressLabel;
1846                         wxString AddressLang;
1847                         wxString AddressAltID;
1848                         wxString AddressPID;
1849                         wxString AddressTokens;
1850                         wxString AddressGeo;
1851                         wxString AddressTimezone;
1852                         wxString AddressType;
1853                         wxString AddressMediatype;
1854                         wxString AddressPOBox;
1855                         wxString AddressExtended;
1856                         wxString AddressStreet;
1857                         wxString AddressLocality;
1858                         wxString AddressCity;
1859                         wxString AddressRegion;
1860                         wxString AddressPostalCode;
1861                         wxString AddressCountry;
1862                         bool AfterFirstToken = FALSE;
1863                         bool FirstToken = TRUE;                 
1864                         int intSplitsFound = 0;
1865                         int intSplitSize = 0;
1866                         int intPrevValue = 5;
1867                         int intPref = 0;                        
1868                         int intType = 0;
1869                         int intSplitSeek = 0;
1870                         long ListCtrlIndex;
1871                         
1872                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1873                         
1874                         intPrevValue = 4;
1875                         
1876                         // Look for type before continuing.
1877                         
1878                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1879                         intiter != SplitPoints.end(); ++intiter){
1880                         
1881                                 SLiter = SplitLength.find(intiter->first);
1882                         
1883                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
1884                                 
1885                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1886                                 PropertyName = PropertyElement.GetNextToken();                          
1887                                 PropertyValue = PropertyElement.GetNextToken();
1888                                 
1889                                 intPrevValue = intiter->second;
1890                                 
1891                                 if (PropertyName == wxT("TYPE")){
1892                                 
1893                                         if (PropertyValue == wxT("work")){
1894                                         
1895                                                 intType = 2;                                    
1896                                         
1897                                         } else if (PropertyValue == wxT("home")){
1899                                                 intType = 1;
1900                                         
1901                                         } else {
1902                                         
1903                                                 intType = 0;
1904                                         
1905                                         }
1906                                 
1907                                 }
1908                         
1909                         }
1910                         
1911                         // Setup blank lines for later on.
1912                         
1913                         if (intType == 0){
1914                         
1915                                 GeneralAddressList.insert(std::make_pair(intValueSeek, wxT("")));
1916                                 GeneralAddressListTown.insert(std::make_pair(intValueSeek, wxT("")));
1917                                 GeneralAddressListCounty.insert(std::make_pair(intValueSeek, wxT("")));
1918                                 GeneralAddressListPostCode.insert(std::make_pair(intValueSeek, wxT("")));
1919                                 GeneralAddressListCountry.insert(std::make_pair(intValueSeek, wxT("")));
1920                                 GeneralAddressListLabel.insert(std::make_pair(intValueSeek, wxT("")));
1921                                 GeneralAddressListLang.insert(std::make_pair(intValueSeek, wxT("")));
1922                                 GeneralAddressListAltID.insert(std::make_pair(intValueSeek, wxT("")));
1923                                 GeneralAddressListPID.insert(std::make_pair(intValueSeek, wxT("")));
1924                                 GeneralAddressListGeo.insert(std::make_pair(intValueSeek, wxT("")));
1925                                 GeneralAddressListTimezone.insert(std::make_pair(intValueSeek, wxT("")));
1926                                 GeneralAddressListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
1927                                 GeneralAddressListPref.insert(std::make_pair(intValueSeek, 0));
1928                                 GeneralAddressListTokens.insert(std::make_pair(intValueSeek, wxT("")));
1930                         } else if (intType == 1){
1931                         
1932                                 HomeAddressList.insert(std::make_pair(intValueSeek, wxT("")));
1933                                 HomeAddressListTown.insert(std::make_pair(intValueSeek, wxT("")));
1934                                 HomeAddressListCounty.insert(std::make_pair(intValueSeek, wxT("")));
1935                                 HomeAddressListPostCode.insert(std::make_pair(intValueSeek, wxT("")));
1936                                 HomeAddressListCountry.insert(std::make_pair(intValueSeek, wxT("")));
1937                                 HomeAddressListLabel.insert(std::make_pair(intValueSeek, wxT("")));
1938                                 HomeAddressListLang.insert(std::make_pair(intValueSeek, wxT("")));
1939                                 HomeAddressListAltID.insert(std::make_pair(intValueSeek, wxT("")));
1940                                 HomeAddressListPID.insert(std::make_pair(intValueSeek, wxT("")));
1941                                 HomeAddressListGeo.insert(std::make_pair(intValueSeek, wxT("")));
1942                                 HomeAddressListTimezone.insert(std::make_pair(intValueSeek, wxT("")));
1943                                 HomeAddressListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
1944                                 HomeAddressListPref.insert(std::make_pair(intValueSeek, 0));
1945                                 HomeAddressListTokens.insert(std::make_pair(intValueSeek, wxT("")));
1946                         
1947                         } else if (intType == 2){
1949                                 BusinessAddressList.insert(std::make_pair(intValueSeek, wxT("")));
1950                                 BusinessAddressListTown.insert(std::make_pair(intValueSeek, wxT("")));
1951                                 BusinessAddressListCounty.insert(std::make_pair(intValueSeek, wxT("")));
1952                                 BusinessAddressListPostCode.insert(std::make_pair(intValueSeek, wxT("")));
1953                                 BusinessAddressListCountry.insert(std::make_pair(intValueSeek, wxT("")));
1954                                 BusinessAddressListLabel.insert(std::make_pair(intValueSeek, wxT("")));
1955                                 BusinessAddressListLang.insert(std::make_pair(intValueSeek, wxT("")));
1956                                 BusinessAddressListAltID.insert(std::make_pair(intValueSeek, wxT("")));
1957                                 BusinessAddressListPID.insert(std::make_pair(intValueSeek, wxT("")));
1958                                 BusinessAddressListGeo.insert(std::make_pair(intValueSeek, wxT("")));
1959                                 BusinessAddressListTimezone.insert(std::make_pair(intValueSeek, wxT("")));
1960                                 BusinessAddressListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
1961                                 BusinessAddressListPref.insert(std::make_pair(intValueSeek, 0));
1962                                 BusinessAddressListTokens.insert(std::make_pair(intValueSeek, wxT("")));
1963                         
1964                         }
1965                         
1966                         intPrevValue = 4;
1967                         
1968                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1969                         intiter != SplitPoints.end(); ++intiter){
1970                         
1971                                 SLiter = SplitLength.find(intiter->first);
1972                         
1973                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
1974                                 
1975                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1976                                 PropertyName = PropertyElement.GetNextToken();                          
1977                                 PropertyValue = PropertyElement.GetNextToken();
1978                                 
1979                                 intPrevValue = intiter->second;
1980                                 
1981                                 ProcessCaptureStrings(&PropertyValue);
1982                                 
1983                                 // Process properties.
1984                                 
1985                                 if (PropertyName == wxT("LABEL")){
1986                                 
1987                                         if (intType == 0){ GeneralAddressListLabel.erase(intValueSeek); GeneralAddressListLabel.insert(std::make_pair(intValueSeek, PropertyValue)); }
1988                                         else if (intType == 1){ HomeAddressListLabel.erase(intValueSeek); HomeAddressListLabel.insert(std::make_pair(intValueSeek, PropertyValue)); }
1989                                         else if (intType == 2){ BusinessAddressListLabel.erase(intValueSeek); BusinessAddressListLabel.insert(std::make_pair(intValueSeek, PropertyValue));}
1990                                 
1991                                 } else if (PropertyName == wxT("LANGUAGE")){
1992                                 
1993                                         if (intType == 0){ GeneralAddressListLang.erase(intValueSeek); GeneralAddressListLang.insert(std::make_pair(intValueSeek, PropertyValue)); }
1994                                         else if (intType == 1){ HomeAddressListLang.erase(intValueSeek); HomeAddressListLang.insert(std::make_pair(intValueSeek, PropertyValue)); }
1995                                         else if (intType == 2){ BusinessAddressListLang.erase(intValueSeek); BusinessAddressListLang.insert(std::make_pair(intValueSeek, PropertyValue)); }                             
1996                                 
1997                                 } else if (PropertyName == wxT("ALTID")){
1999                                         if (intType == 0){ GeneralAddressListAltID.erase(intValueSeek); GeneralAddressListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2000                                         else if (intType == 1){ HomeAddressListAltID.erase(intValueSeek); HomeAddressListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2001                                         else if (intType == 2){ BusinessAddressListAltID.erase(intValueSeek); BusinessAddressListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2002                                 
2003                                 } else if (PropertyName == wxT("PID")){
2005                                         if (intType == 0){ GeneralAddressListPID.erase(intValueSeek); GeneralAddressListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2006                                         else if (intType == 1){ HomeAddressListPID.erase(intValueSeek); HomeAddressListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2007                                         else if (intType == 2){ BusinessAddressListPID.erase(intValueSeek); BusinessAddressListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2008                                 
2009                                 } else if (PropertyName == wxT("GEO")){
2010                                 
2011                                         if (intType == 0){ GeneralAddressListGeo.erase(intValueSeek); GeneralAddressListGeo.insert(std::make_pair(intValueSeek, PropertyValue)); }
2012                                         else if (intType == 1){ HomeAddressListGeo.erase(intValueSeek); HomeAddressListGeo.insert(std::make_pair(intValueSeek, PropertyValue)); }
2013                                         else if (intType == 2){ BusinessAddressListGeo.erase(intValueSeek); BusinessAddressListGeo.insert(std::make_pair(intValueSeek, PropertyValue)); }
2014                                 
2015                                 } else if (PropertyName == wxT("TZ")){
2017                                         if (intType == 0){ GeneralAddressListTimezone.erase(intValueSeek); GeneralAddressListTimezone.insert(std::make_pair(intValueSeek, PropertyValue)); }
2018                                         else if (intType == 1){ HomeAddressListTimezone.erase(intValueSeek); HomeAddressListTimezone.insert(std::make_pair(intValueSeek, PropertyValue)); }
2019                                         else if (intType == 2){ BusinessAddressListTimezone.erase(intValueSeek); BusinessAddressListTimezone.insert(std::make_pair(intValueSeek, PropertyValue)); }
2020                                 
2021                                 } else if (PropertyName == wxT("MEDIATYPE")){
2023                                         if (intType == 0){ GeneralAddressListMediatype.erase(intValueSeek); GeneralAddressListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
2024                                         else if (intType == 1){ HomeAddressListMediatype.erase(intValueSeek); HomeAddressListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
2025                                         else if (intType == 2){ BusinessAddressListMediatype.erase(intValueSeek); BusinessAddressListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
2026                                 
2027                                 } else if (PropertyName == wxT("PREF")){
2028                                         
2029                                         intPref = wxAtoi(PropertyValue);
2030                                         
2031                                         if (intPref > 0 && intPref < 101){
2032                                                                 
2033                                                 if (intType == 0){ GeneralAddressListPref.erase(intValueSeek); GeneralAddressListPref.insert(std::make_pair(intValueSeek, intPref)); }
2034                                                 else if (intType == 1){ HomeAddressListPref.erase(intValueSeek); HomeAddressListPref.insert(std::make_pair(intValueSeek, intPref)); }
2035                                                 else if (intType == 2){ BusinessAddressListPref.erase(intValueSeek); BusinessAddressListPref.insert(std::make_pair(intValueSeek, intPref)); }
2036                                                 
2037                                         }
2038                                 
2039                                 } else {
2040                                 
2041                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2042                                         
2043                                                 if (FirstToken == TRUE){
2044                                                 
2045                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2046                                                         FirstToken = FALSE;
2047                                                 
2048                                                 } else {
2049                                                 
2050                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2051                                                 
2052                                                 }
2053                                         
2054                                         }
2055                                 
2056                                 }
2057                         
2058                         }                       
2059                         
2060                         // Split the address. 
2061                 
2062                         //std::map<int, int>::iterator SLiter;
2063                         intPropertyLen = wxSPropertySeg2.Len();
2064                         SplitPoints.clear();
2065                         SplitLength.clear();
2066                         intSplitsFound = 0;
2067                         intSplitSize = 0;
2068                         intPrevValue = 0;
2069                         
2070                         for (int i = 0; i <= intPropertyLen; i++){
2071                 
2072                                 intSplitSize++;
2073                         
2074                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2075                         
2076                                         intSplitsFound++;
2077                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2078                                         
2079                                         if (intSplitsFound == 6){ 
2080                                         
2081                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2082                                                 break; 
2083                                                 
2084                                         } else {
2085                                         
2086                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2087                                         
2088                                         }
2089                                         
2090                                         intSplitSize = 0;                                       
2091                         
2092                                 }
2093                 
2094                         }
2095                         
2096                         // Split the data into several parts.                   
2097                         
2098                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2099                         intiter != SplitPoints.end(); ++intiter){
2100                                         
2101                                 if (intiter->first == 1){
2102                                 
2103                                         // Deal with PO Box.
2104                                         
2105                                         SLiter = SplitLength.find(1);
2106                                                                                 
2107                                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2108                                         AddressPOBox = wxSPropertySeg2.Mid(0, SLiter->second);
2109                                         intPrevValue = intiter->second;
2110                                 
2111                                 } else if (intiter->first == 2){
2112                                 
2113                                         // Deal with extended address.
2114                                         
2115                                         SLiter = SplitLength.find(2);
2116                                         
2117                                         AddressExtended = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
2118                                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2119                                         intPrevValue = intiter->second;
2120                                 
2121                                 } else if (intiter->first == 3){
2122                                 
2123                                         // Deal with street address.
2124                                         
2125                                         SLiter = SplitLength.find(3);
2126                                                                                 
2127                                         AddressStreet = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
2128                                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2129                                         intPrevValue = intiter->second;
2130                                 
2131                                 } else if (intiter->first == 4){
2132                                 
2133                                         // Deal with locality
2135                                         SLiter = SplitLength.find(4);
2136                                         
2137                                         AddressLocality = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
2138                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2139                                         intPrevValue = intiter->second;
2140                                         
2141                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2142                                 
2143                                 } else if (intiter->first == 5){
2144                                 
2145                                         // Deal with region.
2147                                         SLiter = SplitLength.find(5);
2148                                         
2149                                         AddressRegion = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
2150                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2151                                         intPrevValue = intiter->second;
2152                                         
2153                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2154                                 
2155                                 } else if (intiter->first == 6){
2156                                 
2157                                         // Deal with post code.
2159                                         SLiter = SplitLength.find(6);
2160                                         
2161                                         AddressPostalCode = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
2162                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2163                                         intPrevValue = intiter->second;
2164                                         
2165                                         // Deal with country.
2166                                         
2167                                         AddressCountry = wxSPropertySeg2.Mid(intPrevValue);
2168                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2169                                 
2170                                 }
2171                         
2172                         }       
2173                         
2174                         // Add the data to the General/Home/Work address variables.
2175                         
2176                         ProcessCaptureStrings(&AddressStreet, &AddressLocality, &AddressRegion, &AddressPostalCode, &AddressCountry);
2177                         
2178                         wxListItem coldata;
2179                 
2180                         coldata.SetId(intValueSeek);
2181                         coldata.SetData(intValueSeek);
2182                         coldata.SetText(AddressStreet);
2183                         
2184                         if (intType == 0){
2185                         
2186                                 ListCtrlIndex = lboAddresses->InsertItem(coldata);
2187                                 lboAddresses->SetItem(ListCtrlIndex, 1, AddressLocality);
2188                                 lboAddresses->SetItem(ListCtrlIndex, 2, AddressRegion);
2189                                 lboAddresses->SetItem(ListCtrlIndex, 3, AddressPostalCode);
2190                                 
2191                                 if (intPref > 0 && intPref < 101){
2192                                 
2193                                         lboAddresses->SetItem(ListCtrlIndex, 4, wxString::Format(wxT("%i"), intPref));
2194                                         
2195                                 }
2196                                 
2197                                 GeneralAddressList.erase(intValueSeek);
2198                                 GeneralAddressListTown.erase(intValueSeek);
2199                                 GeneralAddressListCounty.erase(intValueSeek);
2200                                 GeneralAddressListPostCode.erase(intValueSeek);
2201                                 GeneralAddressListCountry.erase(intValueSeek);
2202                                 GeneralAddressListType.erase(intValueSeek);
2203                                 GeneralAddressListTokens.erase(intValueSeek);
2204                                 GeneralAddressList.insert(std::make_pair(intValueSeek, AddressStreet));
2205                                 GeneralAddressListTown.insert(std::make_pair(intValueSeek, AddressLocality));
2206                                 GeneralAddressListCounty.insert(std::make_pair(intValueSeek, AddressRegion));
2207                                 GeneralAddressListPostCode.insert(std::make_pair(intValueSeek, AddressPostalCode));
2208                                 GeneralAddressListCountry.insert(std::make_pair(intValueSeek, AddressCountry));
2209                                 GeneralAddressListType.insert(std::make_pair(intValueSeek, wxT("")));
2210                                 GeneralAddressListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
2211                         
2212                         } else if (intType == 1){ 
2213                         
2214                                 ListCtrlIndex = lboHomeAddresses->InsertItem(coldata);
2215                                 lboHomeAddresses->SetItem(ListCtrlIndex, 1, AddressLocality);
2216                                 lboHomeAddresses->SetItem(ListCtrlIndex, 2, AddressRegion);
2217                                 lboHomeAddresses->SetItem(ListCtrlIndex, 3, AddressPostalCode);
2219                                 if (intPref > 0 && intPref < 101){
2220                                 
2221                                         lboHomeAddresses->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
2222                                         
2223                                 }
2225                                 HomeAddressList.erase(intValueSeek);
2226                                 HomeAddressListTown.erase(intValueSeek);
2227                                 HomeAddressListCounty.erase(intValueSeek);
2228                                 HomeAddressListPostCode.erase(intValueSeek);
2229                                 HomeAddressListCountry.erase(intValueSeek);
2230                                 HomeAddressListType.erase(intValueSeek);
2231                                 HomeAddressListTokens.erase(intValueSeek);                              
2232                                 HomeAddressList.insert(std::make_pair(intValueSeek, AddressStreet));
2233                                 HomeAddressListTown.insert(std::make_pair(intValueSeek, AddressLocality));
2234                                 HomeAddressListCounty.insert(std::make_pair(intValueSeek, AddressRegion));
2235                                 HomeAddressListPostCode.insert(std::make_pair(intValueSeek, AddressPostalCode));
2236                                 HomeAddressListCountry.insert(std::make_pair(intValueSeek, AddressCountry));
2237                                 HomeAddressListType.insert(std::make_pair(intValueSeek, wxT("home")));
2238                                 HomeAddressListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
2239                         
2240                         } else if (intType == 2){ 
2241                         
2242                                 ListCtrlIndex = lboBusinessAddresses->InsertItem(coldata);
2243                                 lboBusinessAddresses->SetItem(ListCtrlIndex, 1, AddressLocality);
2244                                 lboBusinessAddresses->SetItem(ListCtrlIndex, 2, AddressRegion);
2245                                 lboBusinessAddresses->SetItem(ListCtrlIndex, 3, AddressPostalCode);
2247                                 if (intPref > 0 && intPref < 101){
2248                                 
2249                                         lboBusinessAddresses->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
2250                                         
2251                                 }
2252                                 
2253                                 BusinessAddressList.erase(intValueSeek);
2254                                 BusinessAddressListTown.erase(intValueSeek);
2255                                 BusinessAddressListCounty.erase(intValueSeek);
2256                                 BusinessAddressListPostCode.erase(intValueSeek);
2257                                 BusinessAddressListCountry.erase(intValueSeek);
2258                                 BusinessAddressListType.erase(intValueSeek);
2259                                 BusinessAddressListTokens.erase(intValueSeek);
2260                                 BusinessAddressList.insert(std::make_pair(intValueSeek, AddressStreet));
2261                                 BusinessAddressListTown.insert(std::make_pair(intValueSeek, AddressLocality));
2262                                 BusinessAddressListCounty.insert(std::make_pair(intValueSeek, AddressRegion));
2263                                 BusinessAddressListPostCode.insert(std::make_pair(intValueSeek, AddressPostalCode));
2264                                 BusinessAddressListCountry.insert(std::make_pair(intValueSeek, AddressCountry));
2265                                 BusinessAddressListType.insert(std::make_pair(intValueSeek, wxT("work")));
2266                                 BusinessAddressListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                         
2267                         
2268                         }
2269                         
2270                         ADRCount++;
2271                         intValueSeek++;
2272                 
2273                 } else if (wxSProperty == wxT("EMAIL")){
2274                 
2275                         int intPropertyLen = wxSPropertySeg1.Len();
2276                         std::map<int, int> SplitPoints;
2277                         std::map<int, int> SplitLength;
2278                         std::map<int, int>::iterator SLiter;
2279                         std::map<int, int>::iterator SPoint;
2280                         wxString PropertyData;
2281                         wxString PropertyName;
2282                         wxString PropertyValue;
2283                         wxString PropertyTokens;
2284                         wxString AddressLabel;
2285                         wxString AddressLang;
2286                         wxString AddressAltID;
2287                         wxString AddressPID;
2288                         wxString AddressTokens;
2289                         wxString AddressGeo;
2290                         wxString AddressTimezone;
2291                         wxString AddressType;
2292                         wxString AddressMediatype;
2293                         wxString AddressPOBox;
2294                         wxString AddressExtended;
2295                         wxString AddressStreet;
2296                         wxString AddressLocality;
2297                         wxString AddressCity;
2298                         wxString AddressRegion;
2299                         wxString AddressPostalCode;
2300                         wxString AddressCountry;
2301                         bool AfterFirstProperty = FALSE;
2302                         bool FirstToken = TRUE;                 
2303                         int intSplitSeek = 0;
2304                         int intSplitsFound = 0;
2305                         int intSplitSize = 0;
2306                         int intPrevValue = 7;
2307                         int intPref = 0;                        
2308                         int intType = 0;
2309                         int intSplitPoint = 0;
2310                         long ListCtrlIndex;
2311                         
2312                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2313                         
2314                         intPrevValue = 6;
2315                         
2316                         // Look for type before continuing.
2317                         
2318                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2319                         intiter != SplitPoints.end(); ++intiter){
2320                         
2321                                 SLiter = SplitLength.find(intiter->first);
2322                         
2323                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
2324                                 
2325                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2326                                 PropertyName = PropertyElement.GetNextToken();                          
2327                                 PropertyValue = PropertyElement.GetNextToken();
2328                                 
2329                                 intPrevValue = intiter->second;
2330                                 
2331                                 if (PropertyName == wxT("TYPE")){
2332                                 
2333                                         if (PropertyValue == wxT("work")){
2334                                         
2335                                                 intType = 2;                                    
2336                                         
2337                                         } else if (PropertyValue == wxT("home")){
2339                                                 intType = 1;
2340                                         
2341                                         } else {
2342                                         
2343                                                 intType = 0;
2344                                         
2345                                         }
2346                                 
2347                                 }
2348                         
2349                         }
2350                         
2351                         // Setup blank lines for later on.
2352                         
2353                         if (intType == 0){
2354                         
2355                                 GeneralEmailList.insert(std::make_pair(intValueSeek, wxT("")));
2356                                 GeneralEmailListAltID.insert(std::make_pair(intValueSeek, wxT("")));
2357                                 GeneralEmailListPID.insert(std::make_pair(intValueSeek, wxT("")));
2358                                 GeneralEmailListPref.insert(std::make_pair(intValueSeek, 0));
2359                                 GeneralEmailListTokens.insert(std::make_pair(intValueSeek, wxT("")));
2361                         } else if (intType == 1){
2362                         
2363                                 HomeEmailList.insert(std::make_pair(intValueSeek, wxT("")));
2364                                 HomeEmailListAltID.insert(std::make_pair(intValueSeek, wxT("")));
2365                                 HomeEmailListPID.insert(std::make_pair(intValueSeek, wxT("")));
2366                                 HomeEmailListPref.insert(std::make_pair(intValueSeek, 0));
2367                                 HomeEmailListTokens.insert(std::make_pair(intValueSeek, wxT("")));
2368                         
2369                         } else if (intType == 2){
2371                                 BusinessEmailList.insert(std::make_pair(intValueSeek, wxT("")));
2372                                 BusinessEmailListAltID.insert(std::make_pair(intValueSeek, wxT("")));
2373                                 BusinessEmailListPID.insert(std::make_pair(intValueSeek, wxT("")));
2374                                 BusinessEmailListPref.insert(std::make_pair(intValueSeek, 0));
2375                                 BusinessEmailListTokens.insert(std::make_pair(intValueSeek, wxT("")));
2376                         
2377                         }
2378                         
2379                         intPrevValue = 6;                       
2380                         
2381                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2382                         intiter != SplitPoints.end(); ++intiter){
2383                         
2384                                 SLiter = SplitLength.find(intiter->first);
2385                         
2386                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
2387                                 
2388                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2389                                 PropertyName = PropertyElement.GetNextToken();                          
2390                                 PropertyValue = PropertyElement.GetNextToken();
2391                                 
2392                                 intPrevValue = intiter->second;
2393                                 
2394                                 ProcessCaptureStrings(&PropertyValue);
2395                                 
2396                                 // Process properties.
2397                                 
2398                                 if (PropertyName == wxT("ALTID")){
2400                                         if (intType == 0){ GeneralEmailListAltID.erase(intValueSeek); GeneralEmailListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2401                                         else if (intType == 1){ HomeEmailListAltID.erase(intValueSeek); HomeEmailListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2402                                         else if (intType == 2){ BusinessEmailListAltID.erase(intValueSeek); BusinessEmailListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2403                                 
2404                                 } else if (PropertyName == wxT("PID")){
2406                                         if (intType == 0){ GeneralEmailListPID.erase(intValueSeek); GeneralEmailListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2407                                         else if (intType == 1){ HomeEmailListPID.erase(intValueSeek); HomeEmailListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2408                                         else if (intType == 2){ BusinessEmailListPID.erase(intValueSeek); BusinessEmailListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2409                                 
2410                                 } else if (PropertyName == wxT("PREF")){
2411                                         
2412                                         intPref = wxAtoi(PropertyValue);
2413                                         
2414                                         if (intPref > 0 && intPref < 101){
2415                                 
2416                                                 if (intType == 0){ GeneralEmailListPref.erase(intValueSeek); GeneralEmailListPref.insert(std::make_pair(intValueSeek, intPref)); }
2417                                                 else if (intType == 1){ HomeEmailListPref.erase(intValueSeek); HomeEmailListPref.insert(std::make_pair(intValueSeek, intPref)); }
2418                                                 else if (intType == 2){ BusinessEmailListPref.erase(intValueSeek); BusinessEmailListPref.insert(std::make_pair(intValueSeek, intPref)); }
2419                                                 
2420                                         }
2421                                 
2422                                 } else {
2423                                 
2424                                         // Something else we don't know about so append
2425                                         // to the tokens variable.
2426                                         
2427                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2428                                         
2429                                                 if (FirstToken == TRUE){
2430                                                 
2431                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2432                                                         FirstToken = FALSE;
2433                                                 
2434                                                 } else {
2435                                                 
2436                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2437                                                 
2438                                                 }
2439                                         
2440                                         }
2441                                 
2442                                 }
2443                         
2444                         } 
2445                 
2446                         //std::map<int, int>::iterator SLiter;
2447                         intPropertyLen = wxSPropertySeg2.Len();
2448                         SplitPoints.clear();
2449                         SplitLength.clear();
2450                         intSplitsFound = 0;
2451                         intSplitSize = 0;
2452                         intPrevValue = 0;       
2453                         
2454                         // Add the data to the General/Home/Work email variables.
2455                         
2456                         ProcessCaptureStrings(&wxSPropertySeg2);
2457                         
2458                         wxListItem coldata;
2459                 
2460                         coldata.SetId(intValueSeek);
2461                         coldata.SetData(intValueSeek);
2462                         coldata.SetText(wxSPropertySeg2);
2463                         
2464                         if (intType == 0){
2465                         
2467                         
2468                                 ListCtrlIndex = lboEmails->InsertItem(coldata);
2469                                 
2470                                 if (intPref > 0 && intPref < 101){
2471                                 
2472                                         lboEmails->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
2473                                         
2474                                 }
2475                                 
2476                                 GeneralEmailList.erase(intValueSeek);
2477                                 GeneralEmailListType.erase(intValueSeek);
2478                                 GeneralEmailListTokens.erase(intValueSeek);
2479                                 GeneralEmailList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
2480                                 GeneralEmailListType.insert(std::make_pair(intValueSeek, wxT("")));
2481                                 GeneralEmailListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
2482                         
2483                         } else if (intType == 1){ 
2484                         
2485                                 ListCtrlIndex = lboHomeEmails->InsertItem(coldata);
2487                                 if (intPref > 0 && intPref < 101){
2488                                 
2489                                         lboHomeEmails->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
2490                                         
2491                                 }
2493                                 HomeEmailList.erase(intValueSeek);
2494                                 HomeEmailListType.erase(intValueSeek);
2495                                 HomeEmailListTokens.erase(intValueSeek);                                
2496                                 HomeEmailList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
2497                                 HomeEmailListType.insert(std::make_pair(intValueSeek, wxT("home")));
2498                                 HomeEmailListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
2499                         
2500                         } else if (intType == 2){ 
2501                         
2502                                 ListCtrlIndex = lboBusinessEmail->InsertItem(coldata);
2504                                 if (intPref > 0 && intPref < 101){
2505                                 
2506                                         lboBusinessEmail->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
2507                                         
2508                                 }
2510                                 BusinessEmailList.erase(intValueSeek);
2511                                 BusinessEmailListType.erase(intValueSeek);
2512                                 BusinessEmailListTokens.erase(intValueSeek);                            
2513                                 BusinessEmailList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
2514                                 BusinessEmailListType.insert(std::make_pair(intValueSeek, wxT("work")));
2515                                 BusinessEmailListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                           
2516                         
2517                         }
2518                         
2519                         EmailCount++;
2520                         intValueSeek++;         
2521                 
2522                 } else if (wxSProperty == wxT("IMPP")){
2523                 
2524                         int intPropertyLen = wxSPropertySeg1.Len();
2525                         std::map<int, int> SplitPoints;
2526                         std::map<int, int> SplitLength;
2527                         std::map<int, int>::iterator SLiter;
2528                         std::map<int, int>::iterator SPoint;
2529                         wxString PropertyData;
2530                         wxString PropertyName;
2531                         wxString PropertyValue;
2532                         wxString PropertyTokens;
2533                         wxString IMPPType;
2534                         wxString IMPPAddress;
2535                         bool AfterFirstProperty = FALSE;
2536                         bool FirstToken = TRUE;                 
2537                         int intSplitSeek = 0;
2538                         int intSplitsFound = 0;
2539                         int intSplitSize = 0;
2540                         int intPrevValue = 6;
2541                         int intPref = 0;
2542                         int intType = 0;
2543                         int intSplitPoint = 0;
2544                         long ListCtrlIndex;
2545                         
2546                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2547                         
2548                         intPrevValue = 5;
2549                         
2550                         // Look for type before continuing.
2551                         
2552                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2553                         intiter != SplitPoints.end(); ++intiter){
2554                         
2555                                 SLiter = SplitLength.find(intiter->first);
2556                         
2557                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
2558                                 
2559                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2560                                 PropertyName = PropertyElement.GetNextToken();                          
2561                                 PropertyValue = PropertyElement.GetNextToken();
2562                                 
2563                                 intPrevValue = intiter->second;
2564                                 
2565                                 if (PropertyName == wxT("TYPE")){
2566                                 
2567                                         if (PropertyValue == wxT("work")){
2568                                         
2569                                                 intType = 2;                                    
2570                                         
2571                                         } else if (PropertyValue == wxT("home")){
2573                                                 intType = 1;
2574                                         
2575                                         } else {
2576                                         
2577                                                 intType = 0;
2578                                         
2579                                         }
2580                                 
2581                                 }
2582                         
2583                         }
2584                         
2585                         // Setup blank lines for later on.
2586                         
2587                         if (intType == 0){
2588                         
2589                                 GeneralIMList.insert(std::make_pair(intValueSeek, wxT("")));
2590                                 GeneralIMListAltID.insert(std::make_pair(intValueSeek, wxT("")));
2591                                 GeneralIMListPID.insert(std::make_pair(intValueSeek, wxT("")));
2592                                 GeneralIMListPref.insert(std::make_pair(intValueSeek, 0));
2593                                 GeneralIMListTokens.insert(std::make_pair(intValueSeek, wxT("")));
2594                                 GeneralIMListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
2596                         } else if (intType == 1){
2597                         
2598                                 HomeIMList.insert(std::make_pair(intValueSeek, wxT("")));
2599                                 HomeIMListAltID.insert(std::make_pair(intValueSeek, wxT("")));
2600                                 HomeIMListPID.insert(std::make_pair(intValueSeek, wxT("")));
2601                                 HomeIMListPref.insert(std::make_pair(intValueSeek, 0));
2602                                 HomeIMListTokens.insert(std::make_pair(intValueSeek, wxT("")));
2603                                 HomeIMListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
2604                         
2605                         } else if (intType == 2){
2607                                 BusinessIMList.insert(std::make_pair(intValueSeek, wxT("")));
2608                                 BusinessIMListAltID.insert(std::make_pair(intValueSeek, wxT("")));
2609                                 BusinessIMListPID.insert(std::make_pair(intValueSeek, wxT("")));
2610                                 BusinessIMListPref.insert(std::make_pair(intValueSeek, 0));
2611                                 BusinessIMListTokens.insert(std::make_pair(intValueSeek, wxT("")));
2612                                 BusinessIMListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
2613                         
2614                         }
2615                         
2616                         intPrevValue = 5;
2617                         
2618                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2619                         intiter != SplitPoints.end(); ++intiter){
2620                         
2621                                 SLiter = SplitLength.find(intiter->first);
2622                         
2623                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
2624                                 
2625                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2626                                 PropertyName = PropertyElement.GetNextToken();                          
2627                                 PropertyValue = PropertyElement.GetNextToken();
2628                                 
2629                                 ProcessCaptureStrings(&PropertyValue);
2630                                 
2631                                 intPrevValue = intiter->second;
2632                                 
2633                                 // Process properties.
2634                                 
2635                                 if (PropertyName == wxT("ALTID")){
2637                                         if (intType == 0){ GeneralIMListAltID.erase(intValueSeek); GeneralIMListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2638                                         else if (intType == 1){ HomeIMListAltID.erase(intValueSeek); HomeIMListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2639                                         else if (intType == 2){ BusinessIMListAltID.erase(intValueSeek); BusinessIMListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2640                                 
2641                                 } else if (PropertyName == wxT("PID")){
2643                                         if (intType == 0){ GeneralIMListPID.erase(intValueSeek); GeneralIMListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2644                                         else if (intType == 1){ HomeIMListPID.erase(intValueSeek); HomeIMListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2645                                         else if (intType == 2){ BusinessIMListPID.erase(intValueSeek); BusinessIMListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
2646                                 
2647                                 } else if (PropertyName == wxT("PREF")){
2648                                         
2649                                         intPref = wxAtoi(PropertyValue);
2650                                         
2651                                         if (intPref > 0 && intPref < 101){
2652                                 
2653                                                 if (intType == 0){ GeneralIMListPref.erase(intValueSeek); GeneralIMListPref.insert(std::make_pair(intValueSeek, intPref)); }
2654                                                 else if (intType == 1){ HomeIMListPref.erase(intValueSeek); HomeIMListPref.insert(std::make_pair(intValueSeek, intPref)); }
2655                                                 else if (intType == 2){ BusinessIMListPref.erase(intValueSeek); BusinessIMListPref.insert(std::make_pair(intValueSeek, intPref)); }
2656                                                 
2657                                         }
2658                                 
2659                                 } else if (PropertyName == wxT("MEDIATYPE")){
2661                                         if (intType == 0){ GeneralIMListMediatype.erase(intValueSeek); GeneralIMListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
2662                                         else if (intType == 1){ HomeIMListMediatype.erase(intValueSeek); HomeIMListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
2663                                         else if (intType == 2){ BusinessIMListMediatype.erase(intValueSeek); BusinessIMListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
2664                                 
2665                                 } else {
2666                                 
2667                                         // Something else we don't know about so append
2668                                         // to the tokens variable.
2669                                         
2670                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2671                                         
2672                                                 if (FirstToken == TRUE){
2673                                                 
2674                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2675                                                         FirstToken = FALSE;
2676                                                 
2677                                                 } else {
2678                                                 
2679                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2680                                                 
2681                                                 }
2682                                         
2683                                         }
2684                                 
2685                                 }
2686                         
2687                         }                       
2688                         
2689                         // Split the address. 
2690                 
2691                         //std::map<int, int>::iterator SLiter;
2692                         intPropertyLen = wxSPropertySeg2.Len();
2693                         SplitPoints.clear();
2694                         SplitLength.clear();
2695                         intSplitsFound = 0;
2696                         intSplitSize = 0;
2697                         intPrevValue = 0;
2698                         
2699                         for (int i = 0; i <= intPropertyLen; i++){
2700                 
2701                                 intSplitSize++;
2702                         
2703                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2704                         
2705                                         intSplitsFound++;
2706                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2707                                         
2708                                         if (intSplitsFound == 1){ 
2709                                         
2710                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2711                                                 break; 
2712                                                 
2713                                         }
2714                                         
2715                                         intSplitSize = 0;                                       
2716                         
2717                                 }
2718                 
2719                         }
2720                         
2721                         // Split the data into several parts.                   
2722                         
2723                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2724                         intiter != SplitPoints.end(); ++intiter){
2725                         
2726                                 if (intiter->first == 1){
2727                                 
2728                                         // Deal with PO Box.
2729                                         
2730                                         SLiter = SplitLength.find(1);
2731                                                                                 
2732                                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2733                                         IMPPType = wxSPropertySeg2.Mid(0, SLiter->second);
2734                                         intPrevValue = intiter->second;
2735                                         
2736                                         IMPPAddress = wxSPropertySeg2.Mid(intPrevValue);                                        
2737                                 
2738                                 }
2739                         
2740                         }       
2741                         
2742                         // Check what IM type it is.
2743                         
2744                         if (IMPPType == wxT("aim")){
2745                 
2746                                 IMPPType = wxT("AIM");
2747                 
2748                         } else if (IMPPType == wxT("gg")){
2749                 
2750                                 IMPPType = wxT("Gadu-Gadu");
2751                 
2752                         } else if (IMPPType == wxT("icq")){
2753                 
2754                                 IMPPType = wxT("ICQ");
2755                 
2756                         } else if (IMPPType == wxT("skype")){
2757                 
2758                                 IMPPType = wxT("Skype");
2759                 
2760                         } else if (IMPPType == wxT("xmpp")){
2761                 
2762                                 IMPPType = wxT("XMPP");
2763                 
2764                         } else if (IMPPType == wxT("yahoo")){
2765                 
2766                                 IMPPType = wxT("Yahoo");
2767                 
2768                         } else {
2769                 
2770                                 // Do nothing.
2771                 
2772                         }                       
2773                         
2774                         // Add the data to the General/Home/Work address variables.
2775                         
2776                         ProcessCaptureStrings(&wxSPropertySeg2);
2777                         
2778                         wxListItem coldata;
2779                 
2780                         coldata.SetId(intValueSeek);
2781                         coldata.SetData(intValueSeek);
2782                         coldata.SetText(IMPPType);
2784                         if (intType == 0){
2785                         
2786                                 ListCtrlIndex = lboIM->InsertItem(coldata);
2787                                 
2788                                 lboIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
2789                                 
2790                                 if (intPref > 0 && intPref < 101){
2791                                 
2792                                         lboIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
2793                                         
2794                                 }                               
2795                                 
2796                                 GeneralIMList.erase(intValueSeek);
2797                                 GeneralIMListType.erase(intValueSeek);
2798                                 GeneralIMListTokens.erase(intValueSeek);
2799                                 GeneralIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
2800                                 GeneralIMListType.insert(std::make_pair(intValueSeek, wxT("")));
2801                                 GeneralIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
2802                         
2803                         } else if (intType == 1){ 
2804                         
2805                                 ListCtrlIndex = lboHomeIM->InsertItem(coldata);
2807                                 lboHomeIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
2809                                 if (intPref > 0 && intPref < 101){
2810                                 
2811                                         lboHomeIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
2812                                         
2813                                 }
2815                                 HomeIMList.erase(intValueSeek);
2816                                 HomeIMListType.erase(intValueSeek);
2817                                 HomeIMListTokens.erase(intValueSeek);                           
2818                                 HomeIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
2819                                 HomeIMListType.insert(std::make_pair(intValueSeek, wxT("home")));
2820                                 HomeIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
2821                         
2822                         } else if (intType == 2){ 
2823                         
2824                                 ListCtrlIndex = lboBusinessIM->InsertItem(coldata);
2826                                 lboBusinessIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
2828                                 if (intPref > 0 && intPref < 101){
2829                                 
2830                                         lboBusinessIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
2831                                         
2832                                 }
2834                                 BusinessIMList.erase(intValueSeek);
2835                                 BusinessIMListType.erase(intValueSeek);
2836                                 BusinessIMListTokens.erase(intValueSeek);                               
2837                                 BusinessIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
2838                                 BusinessIMListType.insert(std::make_pair(intValueSeek, wxT("work")));
2839                                 BusinessIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                              
2840                         
2841                         }
2842                         
2843                         IMPPCount++;
2844                         intValueSeek++; 
2845                 
2846                 } else if (wxSProperty == wxT("TEL")){
2847                 
2848                         // Check TEL and make sure it is functioning properly.
2849                 
2850                         int intPropertyLen = wxSPropertySeg1.Len();
2851                         std::map<int, int> SplitPoints;
2852                         std::map<int, int> SplitLength;
2853                         std::map<int, int> TypeSplitPoints;
2854                         std::map<int, int> TypeSplitLength;
2855                         std::map<int, int>::iterator SLiter;
2856                         std::map<int, int>::iterator SPoint;                    
2857                         std::map<int, int>::iterator TSLiter;
2858                         std::map<int, int>::iterator TSPoint;
2859                         wxString PropertyData;
2860                         wxString PropertyName;
2861                         wxString PropertyValue;
2862                         wxString PropertyTokens;
2863                         wxString TelType;
2864                         wxString TelNumber;
2865                         wxString TelTypeUI;
2866                         wxString TelTypeDetail;
2867                         bool AfterFirstProperty = FALSE;
2868                         bool FirstToken = TRUE;                 
2869                         int intSplitSeek = 0;
2870                         int intSplitsFound = 0;
2871                         int intSplitSize = 0;
2872                         int intPrevValue = 5;
2873                         int intPref = 0;                        
2874                         int intType = 0;
2875                         int intSplitPoint = 0;
2876                         long ListCtrlIndex;
2877                         
2878                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2879                         
2880                         intPrevValue = 4;
2881                         
2882                         // Look for type before continuing.
2883                         
2884                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2885                         intiter != SplitPoints.end(); ++intiter){
2886                         
2887                                 SLiter = SplitLength.find(intiter->first);
2888                         
2889                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
2890                                 
2891                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2892                                 PropertyName = PropertyElement.GetNextToken();                          
2893                                 PropertyValue = PropertyElement.GetNextToken();
2894                                 
2895                                 intPrevValue = intiter->second;
2896                                 
2897                                 if (PropertyName == wxT("TYPE")){
2898                                 
2899                                         // Process each value in type and translate each
2900                                         // part.
2901                                 
2902                                         // Strip out the quotes if they are there.
2903                                 
2904                                         int intPropertyValueLen = PropertyValue.Len();                          
2905                                 
2906                                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2907                                         
2908                                                 PropertyValue.Trim();
2909                                                 PropertyValue.RemoveLast();
2910                                         
2911                                         }                               
2912                                 
2913                                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2914                                         
2915                                                 PropertyValue.Remove(0, 1);
2916                                         
2917                                         }
2918                                         
2919                                         TelTypeDetail = PropertyValue;
2920                                         
2921                                         intSplitSize = 0;
2922                                         intSplitsFound = 0;
2923                                         intSplitPoint = 0;
2924                                         
2925                                         for (int i = 0; i <= intPropertyValueLen; i++){
2926                         
2927                                                 intSplitSize++;
2928                         
2929                                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2930                         
2931                                                         if (intSplitsFound == 0){
2933                                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2934                                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2935                                         
2936                                                         } else {
2937                                         
2938                                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2939                                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2940                                         
2941                                                         }                       
2943                                                         intSplitsFound++;
2944                                                         i++;
2945                                                         intSplitPoint = i;
2946                                                         intSplitSize = 0;
2947                         
2948                                                 }
2949                         
2950                                         }
2951                                         
2952                                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2953                                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2954                                 
2955                                         int intTypeSeek = 0;
2956                                 
2957                                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2958                                         typeiter != TypeSplitPoints.end(); ++typeiter){
2959                                         
2960                                                 wxString TypePropertyName;
2961                                                 
2962                                                 TSLiter = TypeSplitLength.find(typeiter->first);
2963                                                 
2964                                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2965                                                 
2966                                                 if (intTypeSeek == 0){
2967                                                 
2968                                                 
2969                                                 } else {
2970                                                                                                 
2971                                                         TelTypeUI.Append(wxT(","));                                                     
2972                                                 
2973                                                 }
2974                                         
2975                                                 if (TypePropertyName == wxT("home")){
2976                                                 
2977                                                         intType = 1;
2978                                                 
2979                                                 } else if (TypePropertyName == wxT("work")){
2980                                                 
2981                                                         intType = 2;
2982                                                 
2983                                                 }
2984                                                 
2985                                                 
2986                                                 if (TypePropertyName == wxT("text")){
2987                                                 
2988                                                         TelTypeUI.Append(_("text"));
2989                                                         intTypeSeek++;
2990                                                 
2991                                                 } else if (TypePropertyName == wxT("voice")){
2992                                                 
2993                                                         TelTypeUI.Append(_("voice"));
2994                                                         intTypeSeek++;
2995                                                 
2996                                                 } else if (TypePropertyName == wxT("fax")){
2997                                                 
2998                                                         TelTypeUI.Append(_("fax"));
2999                                                         intTypeSeek++;
3000                                                 
3001                                                 } else if (TypePropertyName == wxT("cell")){
3002                                                 
3003                                                         TelTypeUI.Append(_("mobile"));
3004                                                         intTypeSeek++;
3005                                                 
3006                                                 } else if (TypePropertyName == wxT("video")){
3007                                                 
3008                                                         TelTypeUI.Append(_("video"));
3009                                                         intTypeSeek++;
3010                                                 
3011                                                 } else if (TypePropertyName == wxT("pager")){
3012                                                 
3013                                                         TelTypeUI.Append(_("pager"));
3014                                                         intTypeSeek++;
3015                                                 
3016                                                 } else if (TypePropertyName == wxT("textphone")){
3017                                                 
3018                                                         TelTypeUI.Append(_("textphone"));
3019                                                         intTypeSeek++;
3020                                                 
3021                                                 }
3022                                         
3023                                         }
3024                                 
3025                                 }
3026                                 
3027                                 
3028                         
3029                         }
3030                         
3031                         // Setup blank lines for later on.
3032                         
3033                         if (intType == 0){
3034                         
3035                                 GeneralTelephoneList.insert(std::make_pair(intValueSeek, wxT("")));
3036                                 GeneralTelephoneListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3037                                 GeneralTelephoneListPID.insert(std::make_pair(intValueSeek, wxT("")));
3038                                 GeneralTelephoneListPref.insert(std::make_pair(intValueSeek, 0));
3039                                 GeneralTelephoneListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3041                         } else if (intType == 1){
3042                         
3043                                 HomeTelephoneList.insert(std::make_pair(intValueSeek, wxT("")));
3044                                 HomeTelephoneListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3045                                 HomeTelephoneListPID.insert(std::make_pair(intValueSeek, wxT("")));
3046                                 HomeTelephoneListPref.insert(std::make_pair(intValueSeek, 0));
3047                                 HomeTelephoneListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3048                         
3049                         } else if (intType == 2){
3051                                 BusinessTelephoneList.insert(std::make_pair(intValueSeek, wxT("")));
3052                                 BusinessTelephoneListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3053                                 BusinessTelephoneListPID.insert(std::make_pair(intValueSeek, wxT("")));
3054                                 BusinessTelephoneListPref.insert(std::make_pair(intValueSeek, 0));
3055                                 BusinessTelephoneListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3056                         
3057                         }
3058                         
3059                         intPrevValue = 4;
3060                         
3061                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3062                         intiter != SplitPoints.end(); ++intiter){
3063                         
3064                                 SLiter = SplitLength.find(intiter->first);
3065                         
3066                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
3067                                 
3068                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3069                                 PropertyName = PropertyElement.GetNextToken();                          
3070                                 PropertyValue = PropertyElement.GetNextToken();
3071                                 
3072                                 intPrevValue = intiter->second;
3073                                 
3074                                 int 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                                 ProcessCaptureStrings(&PropertyValue);
3090                                 
3091                                 // Process properties.
3092                                 
3093                                 if (PropertyName == wxT("ALTID")){
3095                                         if (intType == 0){ GeneralTelephoneListAltID.erase(intValueSeek); GeneralTelephoneListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3096                                         else if (intType == 1){ HomeTelephoneListAltID.erase(intValueSeek); HomeTelephoneListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3097                                         else if (intType == 2){ BusinessTelephoneListAltID.erase(intValueSeek); BusinessTelephoneListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3098                                 
3099                                 } else if (PropertyName == wxT("PID")){
3101                                         if (intType == 0){ GeneralTelephoneListPID.erase(intValueSeek); GeneralTelephoneListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3102                                         else if (intType == 1){ HomeTelephoneListPID.erase(intValueSeek); HomeTelephoneListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3103                                         else if (intType == 2){ BusinessTelephoneListPID.erase(intValueSeek); BusinessTelephoneListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3104                                 
3105                                 } else if (PropertyName == wxT("PREF")){
3106                                         
3107                                         intPref = wxAtoi(PropertyValue);
3108                                         
3109                                         if (intPref > 0 && intPref < 101){
3110                                 
3111                                                 if (intType == 0){ GeneralTelephoneListPref.erase(intValueSeek); GeneralTelephoneListPref.insert(std::make_pair(intValueSeek, intPref)); }
3112                                                 else if (intType == 1){ HomeTelephoneListPref.erase(intValueSeek); HomeTelephoneListPref.insert(std::make_pair(intValueSeek, intPref)); }
3113                                                 else if (intType == 2){ BusinessTelephoneListPref.erase(intValueSeek); BusinessTelephoneListPref.insert(std::make_pair(intValueSeek, intPref)); }
3114                                                 
3115                                         }
3116                                 
3117                                 } else {
3118                                 
3119                                         // Something else we don't know about so append
3120                                         // to the tokens variable.
3121                                         
3122                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3123                                         
3124                                                 if (FirstToken == TRUE){
3125                                                 
3126                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3127                                                         FirstToken = FALSE;
3128                                                 
3129                                                 } else {
3130                                                 
3131                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3132                                                 
3133                                                 }
3134                                         
3135                                         }
3136                                 
3137                                 }
3138                         
3139                         }                       
3140                         
3141                         // Split the address. 
3142                 
3143                         //std::map<int, int>::iterator SLiter;
3144                         intPropertyLen = wxSPropertySeg2.Len();
3145                         SplitPoints.clear();
3146                         SplitLength.clear();
3147                         intSplitsFound = 0;
3148                         intSplitSize = 0;
3149                         intPrevValue = 0;
3150                         
3151                         for (int i = 0; i <= intPropertyLen; i++){
3152                 
3153                                 intSplitSize++;
3154                         
3155                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3156                         
3157                                         intSplitsFound++;
3158                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3159                                         
3160                                         if (intSplitsFound == 1){ 
3161                                         
3162                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3163                                                 break; 
3164                                                 
3165                                         }
3166                                         
3167                                         intSplitSize = 0;                                       
3168                         
3169                                 }
3170                 
3171                         }
3172                         
3173                         // Split the data into several parts.                   
3174                         
3175                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3176                         intiter != SplitPoints.end(); ++intiter){
3177                         
3178                                 if (intiter->first == 1){
3179                                 
3180                                         // Deal with PO Box.
3181                                         
3182                                         SLiter = SplitLength.find(1);
3183                                                                                 
3184                                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
3185                                         TelType = wxSPropertySeg2.Mid(0, SLiter->second);
3186                                         intPrevValue = intiter->second;
3187                                         
3188                                         TelNumber = wxSPropertySeg2.Mid(intPrevValue);                                  
3189                                 
3190                                 }
3191                         
3192                         }                       
3193                         
3194                         // Add the data to the General/Home/Work address variables.
3195                         
3196                         ProcessCaptureStrings(&PropertyValue);
3197                         wxListItem coldata;
3198                 
3199                         coldata.SetId(intValueSeek);
3200                         coldata.SetData(intValueSeek);
3201                         coldata.SetText(TelNumber);
3202                         
3203                         if (intType == 0){
3204                         
3205                                 ListCtrlIndex = lboTelephone->InsertItem(coldata);
3206                                 
3207                                 lboTelephone->SetItem(ListCtrlIndex, 1, TelTypeUI);
3208                                 
3209                                 if (intPref > 0 && intPref < 101){
3210                                 
3211                                         lboTelephone->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
3212                                         
3213                                 }                               
3214                                 
3215                                 GeneralTelephoneList.erase(intValueSeek);
3216                                 GeneralTelephoneListType.erase(intValueSeek);
3217                                 GeneralTelephoneListTokens.erase(intValueSeek);
3218                                 GeneralTelephoneList.insert(std::make_pair(intValueSeek, TelNumber));
3219                                 GeneralTelephoneListType.insert(std::make_pair(intValueSeek, TelTypeDetail));
3220                                 GeneralTelephoneListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
3221                         
3222                         } else if (intType == 1){ 
3223                         
3224                                 ListCtrlIndex = lboHomeTelephone->InsertItem(coldata);
3226                                 lboHomeTelephone->SetItem(ListCtrlIndex, 1, TelTypeUI);
3228                                 if (intPref > 0 && intPref < 101){
3229                                 
3230                                         lboHomeTelephone->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
3231                                         
3232                                 }
3234                                 HomeTelephoneList.erase(intValueSeek);
3235                                 HomeTelephoneListType.erase(intValueSeek);
3236                                 HomeTelephoneListTokens.erase(intValueSeek);                            
3237                                 HomeTelephoneList.insert(std::make_pair(intValueSeek, TelNumber));
3238                                 HomeTelephoneListType.insert(std::make_pair(intValueSeek, TelTypeDetail));
3239                                 HomeTelephoneListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
3240                         
3241                         } else if (intType == 2){ 
3242                         
3243                                 ListCtrlIndex = lboBusinessTelephone->InsertItem(coldata);
3245                                 lboBusinessTelephone->SetItem(ListCtrlIndex, 1, TelTypeUI);
3247                                 if (intPref > 0 && intPref < 101){
3248                                 
3249                                         lboBusinessTelephone->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
3250                                         
3251                                 }
3253                                 BusinessTelephoneList.erase(intValueSeek);
3254                                 BusinessTelephoneListType.erase(intValueSeek);
3255                                 BusinessTelephoneListTokens.erase(intValueSeek);                                
3256                                 BusinessTelephoneList.insert(std::make_pair(intValueSeek, TelNumber));
3257                                 BusinessTelephoneListType.insert(std::make_pair(intValueSeek, TelTypeDetail));
3258                                 BusinessTelephoneListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                               
3259                         
3260                         }
3261                         
3262                         TelCount++;
3263                         intValueSeek++;
3264                 
3265                 } else if (wxSProperty == wxT("LANG")){
3266                 
3267                         int intPropertyLen = wxSPropertySeg1.Len();
3268                         std::map<int, int> SplitPoints;
3269                         std::map<int, int> SplitLength;
3270                         std::map<int, int>::iterator SLiter;                    
3271                         wxString PropertyData;
3272                         wxString PropertyName;
3273                         wxString PropertyValue;
3274                         wxString PropertyTokens;
3275                         bool AfterFirstToken = FALSE;
3276                         bool FirstToken = TRUE;                 
3277                         int intSplitsFound = 0;
3278                         int intSplitSize = 0;
3279                         int intPrevValue = 6;
3280                         int intPref = 0;                        
3281                         int intType = 0;
3282                         int intSplitSeek = 0;
3283                         long ListCtrlIndex;
3284                         
3285                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3286                         
3287                         intPrevValue = 5;
3288                         
3289                         // Look for type before continuing.
3290                         
3291                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3292                         intiter != SplitPoints.end(); ++intiter){
3293                         
3294                                 SLiter = SplitLength.find(intiter->first);
3295                         
3296                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
3297                                 
3298                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3299                                 PropertyName = PropertyElement.GetNextToken();                          
3300                                 PropertyValue = PropertyElement.GetNextToken();
3301                                 
3302                                 intPrevValue = intiter->second;
3303                                 
3304                                 if (PropertyName == wxT("TYPE")){
3305                                 
3306                                         if (PropertyValue == wxT("work")){
3307                                         
3308                                                 intType = 2;                                    
3309                                         
3310                                         } else if (PropertyValue == wxT("home")){
3312                                                 intType = 1;
3313                                         
3314                                         } else {
3315                                         
3316                                                 intType = 0;
3317                                         
3318                                         }
3319                                 
3320                                 }
3321                         
3322                         }
3323                         
3324                         // Setup blank lines for later on.
3325                         
3326                         if (intType == 0){
3327                         
3328                                 GeneralLanguageList.insert(std::make_pair(intValueSeek, wxT("")));
3329                                 GeneralLanguageListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3330                                 GeneralLanguageListPID.insert(std::make_pair(intValueSeek, wxT("")));
3331                                 GeneralLanguageListPref.insert(std::make_pair(intValueSeek, 0));
3332                                 GeneralLanguageListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3334                         } else if (intType == 1){
3335                         
3336                                 HomeLanguageList.insert(std::make_pair(intValueSeek, wxT("")));
3337                                 HomeLanguageListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3338                                 HomeLanguageListPID.insert(std::make_pair(intValueSeek, wxT("")));
3339                                 HomeLanguageListPref.insert(std::make_pair(intValueSeek, 0));
3340                                 HomeLanguageListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3341                         
3342                         } else if (intType == 2){
3344                                 BusinessLanguageList.insert(std::make_pair(intValueSeek, wxT("")));
3345                                 BusinessLanguageListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3346                                 BusinessLanguageListPID.insert(std::make_pair(intValueSeek, wxT("")));
3347                                 BusinessLanguageListPref.insert(std::make_pair(intValueSeek, 0));
3348                                 BusinessLanguageListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3349                         
3350                         }
3351                         
3352                         intPrevValue = 5;                       
3353                         
3354                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3355                         intiter != SplitPoints.end(); ++intiter){
3356                         
3357                                 SLiter = SplitLength.find(intiter->first);
3358                         
3359                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
3360                                 
3361                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3362                                 PropertyName = PropertyElement.GetNextToken();                          
3363                                 PropertyValue = PropertyElement.GetNextToken();
3364                                 
3365                                 intPrevValue = intiter->second;
3366                                 
3367                                 // Process properties.
3368                                 
3369                                 int intPropertyValueLen = PropertyValue.Len();                          
3370                                 
3371                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3372                                         
3373                                         PropertyValue.Trim();
3374                                         PropertyValue.RemoveLast();
3375                                         
3376                                 }                               
3377                                 
3378                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3379                                         
3380                                         PropertyValue.Remove(0, 1);
3381                                         
3382                                 }
3383                                 
3384                                 ProcessCaptureStrings(&PropertyValue);                          
3385                                 
3386                                 if (PropertyName == wxT("ALTID")){
3388                                         if (intType == 0){ GeneralLanguageListAltID.erase(intValueSeek); GeneralLanguageListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3389                                         else if (intType == 1){ HomeLanguageListAltID.erase(intValueSeek); HomeLanguageListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3390                                         else if (intType == 2){ BusinessLanguageListAltID.erase(intValueSeek); BusinessLanguageListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3391                                 
3392                                 } else if (PropertyName == wxT("PID")){
3394                                         if (intType == 0){ GeneralLanguageListPID.erase(intValueSeek); GeneralLanguageListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3395                                         else if (intType == 1){ HomeLanguageListPID.erase(intValueSeek); HomeLanguageListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3396                                         else if (intType == 2){ BusinessLanguageListPID.erase(intValueSeek); BusinessLanguageListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3397                                 
3398                                 } else if (PropertyName == wxT("PREF")){
3399                                         
3400                                         intPref = wxAtoi(PropertyValue);
3401                                 
3402                                         if (intType == 0){ GeneralLanguageListPref.erase(intValueSeek); GeneralLanguageListPref.insert(std::make_pair(intValueSeek, intPref)); }
3403                                         else if (intType == 1){ HomeLanguageListPref.erase(intValueSeek); HomeLanguageListPref.insert(std::make_pair(intValueSeek, intPref)); }
3404                                         else if (intType == 2){ BusinessLanguageListPref.erase(intValueSeek); BusinessLanguageListPref.insert(std::make_pair(intValueSeek, intPref)); }
3405                                 
3406                                 } else {
3407                                 
3408                                         // Something else we don't know about so append
3409                                         // to the tokens variable.
3410                                 
3411                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3412                                 
3413                                                 if (FirstToken == TRUE){
3414                                         
3415                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3416                                                         FirstToken = FALSE;
3417                                         
3418                                                 } else {
3419                                         
3420                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3421                                         
3422                                                 }
3423                                 
3424                                         }
3425                                 
3426                                 }
3427                         
3428                         }       
3429                         
3430                         // Add the data to the General/Home/Work address variables.
3431                         
3432                         ProcessCaptureStrings(&wxSPropertySeg2);
3433                         
3434                         wxListItem coldata;
3435                 
3436                         coldata.SetId(intValueSeek);
3437                         coldata.SetData(intValueSeek);
3438                         coldata.SetText(wxSPropertySeg2);
3439                         
3440                         if (intType == 0){
3441                         
3442                                 ListCtrlIndex = lboLanguages->InsertItem(coldata);
3443                                 
3444                                 if (intPref > 0 && intPref < 101){
3445                                 
3446                                         lboLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3447                                         
3448                                 }
3449                                 
3450                                 GeneralLanguageList.erase(intValueSeek);
3451                                 GeneralLanguageListType.erase(intValueSeek);
3452                                 GeneralLanguageListTokens.erase(intValueSeek);
3453                                 GeneralLanguageList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
3454                                 GeneralLanguageListType.insert(std::make_pair(intValueSeek, wxT("")));
3455                                 GeneralLanguageListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
3456                         
3457                         } else if (intType == 1){ 
3458                         
3459                                 ListCtrlIndex = lboHomeLanguages->InsertItem(coldata);
3461                                 if (intPref > 0 && intPref < 101){
3462                                 
3463                                         lboHomeLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3464                                         
3465                                 }
3467                                 HomeLanguageList.erase(intValueSeek);
3468                                 HomeLanguageListType.erase(intValueSeek);
3469                                 HomeLanguageListTokens.erase(intValueSeek);                             
3470                                 HomeLanguageList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
3471                                 HomeLanguageListType.insert(std::make_pair(intValueSeek, wxT("home")));
3472                                 HomeLanguageListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
3473                         
3474                         } else if (intType == 2){ 
3475                         
3476                                 ListCtrlIndex = lboBusinessLanguages->InsertItem(coldata);
3478                                 if (intPref > 0 && intPref < 101){
3479                                 
3480                                         lboBusinessLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3481                                         
3482                                 }
3484                                 BusinessLanguageList.erase(intValueSeek);
3485                                 BusinessLanguageListType.erase(intValueSeek);
3486                                 BusinessLanguageListTokens.erase(intValueSeek);                         
3487                                 BusinessLanguageList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
3488                                 BusinessLanguageListType.insert(std::make_pair(intValueSeek, wxT("work")));
3489                                 BusinessLanguageListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                                
3490                         
3491                         }
3492                         
3493                         LangCount++;
3494                         intValueSeek++;
3495                 
3496                 } else if (wxSProperty == wxT("GEO")){
3497                 
3498                         int intPropertyLen = wxSPropertySeg1.Len();
3499                         std::map<int, int> SplitPoints;
3500                         std::map<int, int> SplitLength;
3501                         std::map<int, int>::iterator SLiter;                    
3502                         wxString PropertyData;
3503                         wxString PropertyName;
3504                         wxString PropertyValue;
3505                         wxString PropertyTokens;
3506                         wxString GeoType;
3507                         wxString GeoData;                       
3508                         bool AfterFirstToken = FALSE;
3509                         bool FirstToken = TRUE;                 
3510                         int intSplitsFound = 0;
3511                         int intSplitSize = 0;
3512                         int intPrevValue = 5;
3513                         int intPref = 0;                        
3514                         int intType = 0;
3515                         int intSplitSeek = 0;
3516                         long ListCtrlIndex;
3517                         
3518                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3519                         
3520                         intPrevValue = 4;
3521                         
3522                         // Look for type before continuing.
3523                         
3524                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3525                         intiter != SplitPoints.end(); ++intiter){
3526                         
3527                                 SLiter = SplitLength.find(intiter->first);
3528                         
3529                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
3530                                 
3531                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3532                                 PropertyName = PropertyElement.GetNextToken();                          
3533                                 PropertyValue = PropertyElement.GetNextToken();
3534                                 
3535                                 intPrevValue = intiter->second;
3536                                 
3537                                 if (PropertyName == wxT("TYPE")){
3538                                 
3539                                         if (PropertyValue == wxT("work")){
3540                                         
3541                                                 intType = 2;                                    
3542                                         
3543                                         } else if (PropertyValue == wxT("home")){
3545                                                 intType = 1;
3546                                         
3547                                         } else {
3548                                         
3549                                                 intType = 0;
3550                                         
3551                                         }
3552                                 
3553                                 }
3554                         
3555                         }
3556                         
3557                         // Setup blank lines for later on.
3558                         
3559                         if (intType == 0){
3560                         
3561                                 GeneralGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
3562                                 GeneralGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3563                                 GeneralGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
3564                                 GeneralGeographyListPref.insert(std::make_pair(intValueSeek, 0));
3565                                 GeneralGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3567                         } else if (intType == 1){
3568                         
3569                                 HomeGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
3570                                 HomeGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3571                                 HomeGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
3572                                 HomeGeographyListPref.insert(std::make_pair(intValueSeek, 0));
3573                                 HomeGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3574                         
3575                         } else if (intType == 2){
3577                                 BusinessGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
3578                                 BusinessGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
3579                                 BusinessGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
3580                                 BusinessGeographyListPref.insert(std::make_pair(intValueSeek, 0));
3581                                 BusinessGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
3582                         
3583                         }
3584                         
3585                         intPrevValue = 4;                       
3586                         
3587                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3588                         intiter != SplitPoints.end(); ++intiter){
3589                         
3590                                 SLiter = SplitLength.find(intiter->first);
3591                         
3592                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
3593                                 
3594                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3595                                 PropertyName = PropertyElement.GetNextToken();                          
3596                                 PropertyValue = PropertyElement.GetNextToken();
3597                                 
3598                                 intPrevValue = intiter->second;
3599                                 
3600                                 // Process properties.
3601                                 
3602                                 int intPropertyValueLen = PropertyValue.Len();                          
3603                                 
3604                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3605                                         
3606                                         PropertyValue.Trim();
3607                                         PropertyValue.RemoveLast();
3608                                         
3609                                 }                               
3610                                 
3611                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3612                                         
3613                                         PropertyValue.Remove(0, 1);
3614                                         
3615                                 }       
3617                                 ProcessCaptureStrings(&PropertyValue);
3618                                 
3619                                 if (PropertyName == wxT("ALTID")){
3621                                         if (intType == 0){ GeneralGeographyListAltID.erase(intValueSeek); GeneralGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3622                                         else if (intType == 1){ HomeGeographyListAltID.erase(intValueSeek); HomeGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3623                                         else if (intType == 2){ BusinessGeographyListAltID.erase(intValueSeek); BusinessGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3624                                 
3625                                 } else if (PropertyName == wxT("PID")){
3627                                         if (intType == 0){ GeneralGeographyListPID.erase(intValueSeek); GeneralGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3628                                         else if (intType == 1){ HomeGeographyListPID.erase(intValueSeek); HomeGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3629                                         else if (intType == 2){ BusinessGeographyListPID.erase(intValueSeek); BusinessGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
3630                                 
3631                                 } else if (PropertyName == wxT("MEDIATYPE")){
3632                                 
3633                                         if (intType == 0){ GeneralGeographyListMediatype.erase(intValueSeek); GeneralGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
3634                                         else if (intType == 1){ HomeGeographyListMediatype.erase(intValueSeek); HomeGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
3635                                         else if (intType == 2){ BusinessGeographyListMediatype.erase(intValueSeek); BusinessGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
3636                                 
3637                                 } else if (PropertyName == wxT("PREF")){
3638                                         
3639                                         intPref = wxAtoi(PropertyValue);
3640                                 
3641                                         if (intPref > 0 && intPref < 101){
3642                                 
3643                                                 if (intType == 0){ GeneralGeographyListPref.erase(intValueSeek); GeneralGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
3644                                                 else if (intType == 1){ HomeGeographyListPref.erase(intValueSeek); HomeGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
3645                                                 else if (intType == 2){ BusinessGeographyListPref.erase(intValueSeek); BusinessGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
3646                                         
3647                                         }
3648                                 
3649                                 } else {
3650                                 
3651                                         // Something else we don't know about so append
3652                                         // to the tokens variable.
3653                                 
3654                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3655                                 
3656                                                 if (FirstToken == TRUE){
3657                                         
3658                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3659                                                         FirstToken = FALSE;
3660                                         
3661                                                 } else {
3662                                         
3663                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3664                                         
3665                                                 }
3666                                 
3667                                         }
3668                                 
3669                                 }
3670                         
3671                         }                                       
3672                         
3673                         // Split the address. 
3674                 
3675                         //std::map<int, int>::iterator SLiter;
3676                         intPropertyLen = wxSPropertySeg2.Len();
3677                         SplitPoints.clear();
3678                         SplitLength.clear();
3679                         intSplitsFound = 0;
3680                         intSplitSize = 0;
3681                         intPrevValue = 0;
3682                         
3683                         for (int i = 0; i <= intPropertyLen; i++){
3684                 
3685                                 intSplitSize++;
3686                         
3687                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3688                         
3689                                         intSplitsFound++;
3690                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3691                                         
3692                                         if (intSplitsFound == 1){ 
3693                                         
3694                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3695                                                 break; 
3696                                                 
3697                                         }
3698                                         
3699                                         intSplitSize = 0;                                       
3700                         
3701                                 }
3702                 
3703                         }                       
3704                         
3705                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3706                         intiter != SplitPoints.end(); ++intiter){
3707                         
3708                                 if (intiter->first == 1){
3709                                 
3710                                         // Deal with PO Box.
3711                                         
3712                                         SLiter = SplitLength.find(1);
3713                                                                                 
3714                                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
3715                                         GeoType = wxSPropertySeg2.Mid(0, SLiter->second);
3716                                         intPrevValue = intiter->second;
3717                                         
3718                                         GeoData = wxSPropertySeg2.Mid(intPrevValue);                                    
3719                                 
3720                                 }
3721                         
3722                         }
3723                         
3724                         ProcessCaptureStrings(&wxSPropertySeg2);
3725                         
3726                         wxListItem coldata;
3727                 
3728                         coldata.SetId(intValueSeek);
3729                         coldata.SetData(intValueSeek);
3731                         
3732                         if (intType == 0){
3733                         
3734                                 /*
3735                         
3736                                 ListCtrlIndex = lboTimezones->InsertItem(coldata);
3737                                 
3738                                 if (intPref > 0 && intPref < 101){
3739                                 
3740                                         lboTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3741                                         
3742                                 }
3743                                 
3744                                 */
3745                                 /*
3746                                 txtGeopositioning->SetValue(GeoData);
3747                                 */
3748                                 
3749                                 GeneralGeographyList.erase(intValueSeek);
3750                                 GeneralGeographyListType.erase(intValueSeek);
3751                                 GeneralGeographyListTokens.erase(intValueSeek);
3752                                 GeneralGeographyList.insert(std::make_pair(intValueSeek, GeoData));
3753                                 GeneralGeographyListType.insert(std::make_pair(intValueSeek, wxT("")));
3754                                 GeneralGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
3755                                 
3756                                 CaptureString(&GeoData, FALSE);
3757                                 coldata.SetText(GeoData);
3758                                 ListCtrlIndex = lboGeoposition->InsertItem(coldata);
3759                                 
3760                                 if (intPref > 0 && intPref < 101){
3761                                 
3762                                         lboGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3763                                         
3764                                 }
3765                         
3766                         } else if (intType == 1){                       
3767                         
3768                                 /*
3769                         
3770                                 ListCtrlIndex = lboHomeTimezones->InsertItem(coldata);
3772                                 if (intPref > 0 && intPref < 101){
3773                                 
3774                                         lboHomeTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3775                                         
3776                                 }
3777                                 
3778                                 */
3779                                 
3780                                 /*
3781                                 txtHomeGeopositioning->SetValue(GeoData);
3782                                 */
3784                                 HomeGeographyList.erase(intValueSeek);
3785                                 HomeGeographyListType.erase(intValueSeek);
3786                                 HomeGeographyListTokens.erase(intValueSeek);                            
3787                                 HomeGeographyList.insert(std::make_pair(intValueSeek, GeoData));
3788                                 HomeGeographyListType.insert(std::make_pair(intValueSeek, wxT("home")));
3789                                 HomeGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
3790                                 
3791                                 CaptureString(&GeoData, FALSE);
3792                                 coldata.SetText(GeoData);
3793                                 ListCtrlIndex = lboHomeGeoposition->InsertItem(coldata);
3794                                 
3795                                 if (intPref > 0 && intPref < 101){
3796                                 
3797                                         lboHomeGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3798                                         
3799                                 }
3800                         
3801                         } else if (intType == 2){ 
3802                         
3803                                 ListCtrlIndex = lboBusinessGeoposition->InsertItem(coldata);                    
3804                         
3805                                 /*
3806                         
3807                                 ListCtrlIndex = lboBusinessTimezones->InsertItem(coldata);
3809                                 if (intPref > 0 && intPref < 101){
3810                                 
3811                                         lboBusinessTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3812                                         
3813                                 }
3814                                 
3815                                 */
3816                                 
3817                                 /*
3818                                 txtBusinessGeopositioning->SetValue(GeoData);
3819                                 */
3821                                 BusinessGeographyList.erase(intValueSeek);
3822                                 BusinessGeographyListType.erase(intValueSeek);
3823                                 BusinessGeographyListTokens.erase(intValueSeek);                                
3824                                 BusinessGeographyList.insert(std::make_pair(intValueSeek, GeoData));
3825                                 BusinessGeographyListType.insert(std::make_pair(intValueSeek, wxT("work")));
3826                                 BusinessGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
3827                                 
3828                                 CaptureString(&GeoData, FALSE);
3829                                 coldata.SetText(GeoData);
3830                                 ListCtrlIndex = lboBusinessGeoposition->InsertItem(coldata);
3831                                 
3832                                 if (intPref > 0 && intPref < 101){
3833                                 
3834                                         lboBusinessGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
3835                                         
3836                                 }
3837                         
3838                         }
3839                         
3840                         GeoCount++;
3841                         intValueSeek++;         
3842                 
3843                 } else if (wxSProperty == wxT("RELATED")){
3844                         
3845                         int intPropertyLen = wxSPropertySeg1.Len();
3846                         std::map<int, int> SplitPoints;
3847                         std::map<int, int> SplitLength;
3848                         std::map<int, int>::iterator SLiter;                    
3849                         wxString PropertyData;
3850                         wxString PropertyName;
3851                         wxString PropertyValue;
3852                         wxString PropertyTokens;
3853                         wxString RelatedType;
3854                         wxString RelatedTypeOriginal;                   
3855                         wxString RelatedName;           
3856                         bool AfterFirstToken = FALSE;
3857                         bool FirstToken = TRUE;                 
3858                         int intSplitsFound = 0;
3859                         int intSplitSize = 0;
3860                         int intPrevValue = 9;
3861                         int intPref = 0;                        
3862                         int intType = 0;
3863                         int intSplitSeek = 0;
3864                         long ListCtrlIndex;
3865                         
3866                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3867                         
3868                         intPrevValue = 8;
3869                         
3870                         // Look for type before continuing.
3871                         
3872                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3873                         intiter != SplitPoints.end(); ++intiter){
3874                         
3875                                 SLiter = SplitLength.find(intiter->first);
3876                         
3877                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
3878                                 
3879                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3880                                 PropertyName = PropertyElement.GetNextToken();                          
3881                                 PropertyValue = PropertyElement.GetNextToken();
3882                                 
3883                                 intPrevValue = intiter->second;
3884                                 
3885                                 // Process these.
3886                                 
3887                                 RelatedTypeOriginal = PropertyValue;
3888                                 
3889                                 if (PropertyName == wxT("TYPE")){
3890                                 
3891                                         if (PropertyValue == wxT("contact")){
3892                 
3893                                                 RelatedType = _("Contact");
3894                 
3895                                         } else if (PropertyValue == wxT("acquaintance")){
3896                 
3897                                                 RelatedType = _("Acquaintance");
3898                 
3899                                         } else if (PropertyValue == wxT("friend")){
3900                 
3901                                                 RelatedType = _("Friend");
3902                 
3903                                         } else if (PropertyValue == wxT("met")){
3904                 
3905                                                 RelatedType = _("Met");
3906                 
3907                                         } else if (PropertyValue == wxT("co-worker")){
3908                 
3909                                                 RelatedType = _("Co-worker");
3910                 
3911                                         } else if (PropertyValue == wxT("colleague")){
3912                 
3913                                                 RelatedType = _("Colleague");
3914                 
3915                                         } else if (PropertyValue == wxT("co-resident")){
3916                 
3917                                                 RelatedType = _("Co-resident");
3918                 
3919                                         } else if (PropertyValue == wxT("neighbor")){
3920                 
3921                                                 RelatedType = _("Neighbour");
3922                 
3923                                         } else if (PropertyValue == wxT("child")){
3924                 
3925                                                 RelatedType = _("Child");
3926                 
3927                                         } else if (PropertyValue == wxT("parent")){
3928                 
3929                                                 RelatedType = _("Parent");
3930                 
3931                                         } else if (PropertyValue == wxT("sibling")){
3932                 
3933                                                 RelatedType = _("Sibling");
3934                 
3935                                         } else if (PropertyValue == wxT("spouse")){
3936                 
3937                                                 RelatedType = _("Spouse");
3938                 
3939                                         } else if (PropertyValue == wxT("kin")){
3940                 
3941                                                 RelatedType = _("Kin");
3942                 
3943                                         } else if (PropertyValue == wxT("muse")){
3944                 
3945                                                 RelatedType = _("Muse");
3946                 
3947                                         } else if (PropertyValue == wxT("crush")){
3948                 
3949                                                 RelatedType = _("Crush");
3950                 
3951                                         } else if (PropertyValue == wxT("date")){
3952                 
3953                                                 RelatedType = _("Date");
3954                 
3955                                         } else if (PropertyValue == wxT("sweetheart")){
3956                 
3957                                                 RelatedType = _("Sweetheart");
3958                 
3959                                         } else if (PropertyValue == wxT("me")){
3960                 
3961                                                 RelatedType = _("Me");
3962                 
3963                                         } else if (PropertyValue == wxT("agent")){
3964                 
3965                                                 RelatedType = _("Agent");
3966                 
3967                                         } else if (PropertyValue == wxT("emergency")){
3968                 
3969                                                 RelatedType = _("Emergency");
3970                 
3971                                         } else {
3972                 
3973                                                 RelatedType = PropertyValue;
3974                 
3975                                         }
3976                                 
3977                                 }
3978                         
3979                         }
3980                         
3981                         intPrevValue = 8;                       
3982                         
3983                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3984                         intiter != SplitPoints.end(); ++intiter){
3985                         
3986                                 SLiter = SplitLength.find(intiter->first);
3987                         
3988                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
3989                                 
3990                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3991                                 PropertyName = PropertyElement.GetNextToken();                          
3992                                 PropertyValue = PropertyElement.GetNextToken();
3993                                 
3994                                 intPrevValue = intiter->second;
3995                                 
3996                                 // Process properties.
3997                                 
3998                                 int intPropertyValueLen = PropertyValue.Len();                          
3999                                 
4000                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4001                                         
4002                                         PropertyValue.Trim();
4003                                         PropertyValue.RemoveLast();
4004                                         
4005                                 }                               
4006                                 
4007                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4008                                         
4009                                         PropertyValue.Remove(0, 1);
4010                                         
4011                                 }
4012                                 
4013                                 ProcessCaptureStrings(&PropertyValue);                  
4014                                 
4015                                 if (PropertyName == wxT("ALTID")){
4017                                         GeneralRelatedListAltID.erase(intValueSeek);
4018                                         GeneralRelatedListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
4019                                 
4020                                 } else if (PropertyName == wxT("PID")){
4022                                         GeneralRelatedListPID.erase(intValueSeek);
4023                                         GeneralRelatedListPID.insert(std::make_pair(intValueSeek, PropertyValue));
4024                                 
4025                                 } else if (PropertyName == wxT("PREF")){
4026                                         
4027                                         intPref = wxAtoi(PropertyValue);
4028                                 
4029                                         if (intPref > 0 && intPref < 101){
4030                                 
4031                                                 GeneralRelatedListPref.erase(intValueSeek);
4032                                                 GeneralRelatedListPref.insert(std::make_pair(intValueSeek, intPref));
4034                                         
4035                                         }
4036                                 
4037                                 } else if (PropertyName == wxT("LANGUAGE")){
4038                                 
4039                                         GeneralRelatedListLanguage.erase(intValueSeek);
4040                                         GeneralRelatedListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
4041                                 
4042                                 } else {
4043                                 
4044                                         // Something else we don't know about so append
4045                                         // to the tokens variable.
4046                                 
4047                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4048                                 
4049                                                 if (FirstToken == TRUE){
4050                                         
4051                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4052                                                         FirstToken = FALSE;
4053                                         
4054                                                 } else {
4055                                         
4056                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4057                                         
4058                                                 }
4059                                 
4060                                         }
4061                                 
4062                                 }
4063                         
4064                         }                                       
4065                         
4066                         // Split the address. 
4067                 
4068                         //std::map<int, int>::iterator SLiter;
4069                         intPropertyLen = wxSPropertySeg2.Len();
4070                         SplitPoints.clear();
4071                         SplitLength.clear();
4072                         intSplitsFound = 0;
4073                         intSplitSize = 0;
4074                         intPrevValue = 0;
4075                         
4076                         // Add the data to the General/Home/Work address variables.
4077                         
4078                         wxListItem coldata;
4079                 
4080                         coldata.SetId(intValueSeek);
4081                         coldata.SetData(intValueSeek);
4082                         coldata.SetText(RelatedType);
4083                         
4084                         ProcessCaptureStrings(&wxSPropertySeg2);
4086                         ListCtrlIndex = lboRelated->InsertItem(coldata);
4088                         lboRelated->SetItem(ListCtrlIndex, 1, wxSPropertySeg2);
4090                         if (intPref > 0 && intPref < 101){
4091                                 
4092                                 lboRelated->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
4093                                         
4094                         }
4095                                 
4096                         GeneralRelatedList.erase(intValueSeek);
4097                         GeneralRelatedListRelType.erase(intValueSeek);
4098                         GeneralRelatedListType.erase(intValueSeek);
4099                         GeneralRelatedListTokens.erase(intValueSeek);
4100                         GeneralRelatedList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4101                         GeneralRelatedListRelType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));                    
4102                         GeneralRelatedListType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));
4103                         GeneralRelatedListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
4104                         
4105                         RelatedCount++;
4106                         intValueSeek++;                 
4107                 
4108                 } else if (wxSProperty == wxT("URL")){
4109                 
4110                         int intPropertyLen = wxSPropertySeg1.Len();
4111                         std::map<int, int> SplitPoints;
4112                         std::map<int, int> SplitLength;
4113                         std::map<int, int>::iterator SLiter;                    
4114                         wxString PropertyData;
4115                         wxString PropertyName;
4116                         wxString PropertyValue;
4117                         wxString PropertyTokens;
4118                         bool AfterFirstToken = FALSE;
4119                         bool FirstToken = TRUE;                 
4120                         int intSplitsFound = 0;
4121                         int intSplitSize = 0;
4122                         int intPrevValue = 5;
4123                         int intPref = 0;                        
4124                         int intType = 0;
4125                         int intSplitSeek = 0;
4126                         long ListCtrlIndex;
4127                         
4128                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4129                         
4130                         intPrevValue = 4;
4131                         
4132                         // Look for type before continuing.
4133                         
4134                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4135                         intiter != SplitPoints.end(); ++intiter){
4136                         
4137                                 SLiter = SplitLength.find(intiter->first);
4138                         
4139                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4140                                 
4141                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4142                                 PropertyName = PropertyElement.GetNextToken();                          
4143                                 PropertyValue = PropertyElement.GetNextToken();
4144                                 
4145                                 intPrevValue = intiter->second;
4146                                 
4147                                 if (PropertyName == wxT("TYPE")){
4148                                 
4149                                         if (PropertyValue == wxT("work")){
4150                                         
4151                                                 intType = 2;                                    
4152                                         
4153                                         } else if (PropertyValue == wxT("home")){
4155                                                 intType = 1;
4156                                         
4157                                         } else {
4158                                         
4159                                                 intType = 0;
4160                                         
4161                                         }
4162                                 
4163                                 }
4164                         
4165                         }
4166                         
4167                         // Setup blank lines for later on.
4168                         
4169                         if (intType == 0){
4170                         
4171                                 GeneralWebsiteList.insert(std::make_pair(intValueSeek, wxT("")));
4172                                 GeneralWebsiteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4173                                 GeneralWebsiteListPID.insert(std::make_pair(intValueSeek, wxT("")));
4174                                 GeneralWebsiteListPref.insert(std::make_pair(intValueSeek, 0));
4175                                 GeneralWebsiteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4177                         } else if (intType == 1){
4178                         
4179                                 HomeWebsiteList.insert(std::make_pair(intValueSeek, wxT("")));
4180                                 HomeWebsiteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4181                                 HomeWebsiteListPID.insert(std::make_pair(intValueSeek, wxT("")));
4182                                 HomeWebsiteListPref.insert(std::make_pair(intValueSeek, 0));
4183                                 HomeWebsiteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4184                         
4185                         } else if (intType == 2){
4187                                 BusinessWebsiteList.insert(std::make_pair(intValueSeek, wxT("")));
4188                                 BusinessWebsiteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4189                                 BusinessWebsiteListPID.insert(std::make_pair(intValueSeek, wxT("")));
4190                                 BusinessWebsiteListPref.insert(std::make_pair(intValueSeek, 0));
4191                                 BusinessWebsiteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4192                         
4193                         }
4194                         
4195                         intPrevValue = 4;
4196                         
4197                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4198                         intiter != SplitPoints.end(); ++intiter){
4199                         
4200                                 SLiter = SplitLength.find(intiter->first);
4201                         
4202                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4203                                 
4204                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4205                                 PropertyName = PropertyElement.GetNextToken();                          
4206                                 PropertyValue = PropertyElement.GetNextToken();
4207                                 
4208                                 intPrevValue = intiter->second;
4209                                 
4210                                 // Process properties.
4211                                 
4212                                 int intPropertyValueLen = PropertyValue.Len();                          
4213                                 
4214                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4215                                         
4216                                         PropertyValue.Trim();
4217                                         PropertyValue.RemoveLast();
4218                                         
4219                                 }                               
4220                                 
4221                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4222                                         
4223                                         PropertyValue.Remove(0, 1);
4224                                         
4225                                 }
4226                                 
4227                                 ProcessCaptureStrings(&PropertyValue);          
4228                                 
4229                                 if (PropertyName == wxT("ALTID")){
4231                                         if (intType == 0){ GeneralWebsiteListAltID.erase(intValueSeek); GeneralWebsiteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4232                                         else if (intType == 1){ HomeWebsiteListAltID.erase(intValueSeek); HomeWebsiteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4233                                         else if (intType == 2){ BusinessWebsiteListAltID.erase(intValueSeek); BusinessWebsiteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4234                                 
4235                                 } else if (PropertyName == wxT("PID")){
4237                                         if (intType == 0){ GeneralWebsiteListPID.erase(intValueSeek); GeneralWebsiteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4238                                         else if (intType == 1){ HomeWebsiteListPID.erase(intValueSeek); HomeWebsiteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4239                                         else if (intType == 2){ BusinessWebsiteListPID.erase(intValueSeek); BusinessWebsiteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4240                                 
4241                                 } else if (PropertyName == wxT("PREF")){
4242                                         
4243                                         intPref = wxAtoi(PropertyValue);
4244                                 
4245                                         if (intType == 0){ GeneralWebsiteListPref.erase(intValueSeek); GeneralWebsiteListPref.insert(std::make_pair(intValueSeek, intPref)); }
4246                                         else if (intType == 1){ HomeWebsiteListPref.erase(intValueSeek); HomeWebsiteListPref.insert(std::make_pair(intValueSeek, intPref)); }
4247                                         else if (intType == 2){ BusinessWebsiteListPref.erase(intValueSeek); BusinessWebsiteListPref.insert(std::make_pair(intValueSeek, intPref)); }
4248                                 
4249                                 } else if (PropertyName == wxT("MEDIATYPE")){
4250                                 
4251                                         if (intType == 0){ GeneralWebsiteListMediatype.erase(intValueSeek); GeneralWebsiteListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
4252                                         else if (intType == 1){ HomeWebsiteListMediatype.erase(intValueSeek); HomeWebsiteListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
4253                                         else if (intType == 2){ BusinessWebsiteListMediatype.erase(intValueSeek); BusinessWebsiteListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
4254                                 
4255                                 } else {
4256                                 
4257                                         // Something else we don't know about so append
4258                                         // to the tokens variable.
4259                                 
4260                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4261                                 
4262                                                 if (FirstToken == TRUE){
4263                                         
4264                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4265                                                         FirstToken = FALSE;
4266                                         
4267                                                 } else {
4268                                         
4269                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4270                                         
4271                                                 }
4272                                 
4273                                         }
4274                                 
4275                                 }
4276                         
4277                         }
4278                         
4279                         // Add the data to the General/Home/Work address variables.
4280                         
4281                         ProcessCaptureStrings(&wxSPropertySeg2);
4282                         
4283                         wxListItem coldata;
4284                 
4285                         coldata.SetId(intValueSeek);
4286                         coldata.SetData(intValueSeek);
4287                         coldata.SetText(wxSPropertySeg2);
4288                         
4289                         if (intType == 0){
4290                         
4291                                 ListCtrlIndex = lboWebsites->InsertItem(coldata);
4292                                 
4293                                 if (intPref > 0 && intPref < 101){
4294                                 
4295                                         lboWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4296                                         
4297                                 }
4298                                 
4299                                 GeneralWebsiteList.erase(intValueSeek);
4300                                 GeneralWebsiteListType.erase(intValueSeek);
4301                                 GeneralWebsiteListTokens.erase(intValueSeek);
4302                                 GeneralWebsiteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4303                                 GeneralWebsiteListType.insert(std::make_pair(intValueSeek, wxT("")));
4304                                 GeneralWebsiteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
4305                         
4306                         } else if (intType == 1){ 
4307                         
4308                                 ListCtrlIndex = lboHomeWebsites->InsertItem(coldata);
4310                                 if (intPref > 0 && intPref < 101){
4311                                 
4312                                         lboHomeWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4313                                         
4314                                 }
4316                                 HomeWebsiteList.erase(intValueSeek);
4317                                 HomeWebsiteListType.erase(intValueSeek);
4318                                 HomeWebsiteListTokens.erase(intValueSeek);                              
4319                                 HomeWebsiteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4320                                 HomeWebsiteListType.insert(std::make_pair(intValueSeek, wxT("home")));
4321                                 HomeWebsiteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
4322                         
4323                         } else if (intType == 2){ 
4324                         
4325                                 ListCtrlIndex = lboBusinessWebsites->InsertItem(coldata);
4327                                 if (intPref > 0 && intPref < 101){
4328                                 
4329                                         lboBusinessWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4330                                         
4331                                 }
4333                                 BusinessWebsiteList.erase(intValueSeek);
4334                                 BusinessWebsiteListType.erase(intValueSeek);
4335                                 BusinessWebsiteListTokens.erase(intValueSeek);                          
4336                                 BusinessWebsiteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4337                                 BusinessWebsiteListType.insert(std::make_pair(intValueSeek, wxT("work")));
4338                                 BusinessWebsiteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                         
4339                         
4340                         }
4341                         
4342                         URLCount++;
4343                         intValueSeek++;
4344                 
4345                 } else if (wxSProperty == wxT("TITLE")) {
4346                 
4347                         int intPropertyLen = wxSPropertySeg1.Len();
4348                         std::map<int, int> SplitPoints;
4349                         std::map<int, int> SplitLength;
4350                         std::map<int, int>::iterator SLiter;                    
4351                         wxString PropertyData;
4352                         wxString PropertyName;
4353                         wxString PropertyValue;
4354                         wxString PropertyTokens;
4355                         bool AfterFirstToken = FALSE;
4356                         bool FirstToken = TRUE;                 
4357                         int intSplitsFound = 0;
4358                         int intSplitSize = 0;
4359                         int intPrevValue = 7;
4360                         int intPref = 0;                        
4361                         int intType = 0;
4362                         int intSplitSeek = 0;
4363                         long ListCtrlIndex;
4364                         
4365                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4366                         
4367                         intPrevValue = 6;
4368                         
4369                         // Look for type before continuing.
4370                         
4371                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4372                         intiter != SplitPoints.end(); ++intiter){
4373                         
4374                                 SLiter = SplitLength.find(intiter->first);
4375                         
4376                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4377                                 
4378                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4379                                 PropertyName = PropertyElement.GetNextToken();                          
4380                                 PropertyValue = PropertyElement.GetNextToken();
4381                                 
4382                                 intPrevValue = intiter->second;
4383                                 
4384                                 if (PropertyName == wxT("TYPE")){
4385                                 
4386                                         if (PropertyValue == wxT("work")){
4387                                         
4388                                                 intType = 2;                                    
4389                                         
4390                                         } else if (PropertyValue == wxT("home")){
4392                                                 intType = 1;
4393                                         
4394                                         } else {
4395                                         
4396                                                 intType = 0;
4397                                         
4398                                         }
4399                                 
4400                                 }
4401                         
4402                         }
4403                         
4404                         // Setup blank lines for later on.
4405                         
4406                         if (intType == 0){
4407                         
4408                                 GeneralTitleList.insert(std::make_pair(intValueSeek, wxT("")));
4409                                 GeneralTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4410                                 GeneralTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
4411                                 GeneralTitleListPref.insert(std::make_pair(intValueSeek, 0));
4412                                 GeneralTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4413                                 GeneralTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
4415                         } else if (intType == 1){
4416                         
4417                                 HomeTitleList.insert(std::make_pair(intValueSeek, wxT("")));
4418                                 HomeTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4419                                 HomeTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
4420                                 HomeTitleListPref.insert(std::make_pair(intValueSeek, 0));
4421                                 HomeTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4422                                 HomeTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                            
4423                         
4424                         } else if (intType == 2){
4426                                 BusinessTitleList.insert(std::make_pair(intValueSeek, wxT("")));
4427                                 BusinessTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4428                                 BusinessTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
4429                                 BusinessTitleListPref.insert(std::make_pair(intValueSeek, 0));
4430                                 BusinessTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4431                                 BusinessTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                                
4432                         
4433                         }
4434                         
4435                         intPrevValue = 6;
4436                         
4437                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4438                         intiter != SplitPoints.end(); ++intiter){
4439                         
4440                                 SLiter = SplitLength.find(intiter->first);
4441                         
4442                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4443                                 
4444                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4445                                 PropertyName = PropertyElement.GetNextToken();                          
4446                                 PropertyValue = PropertyElement.GetNextToken();
4447                                 
4448                                 intPrevValue = intiter->second;
4449                                 
4450                                 // Process properties.
4451                                 
4452                                 int intPropertyValueLen = PropertyValue.Len();                          
4453                                 
4454                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4455                                         
4456                                         PropertyValue.Trim();
4457                                         PropertyValue.RemoveLast();
4458                                         
4459                                 }                               
4460                                 
4461                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4462                                         
4463                                         PropertyValue.Remove(0, 1);
4464                                         
4465                                 }                               
4466                                 
4467                                 ProcessCaptureStrings(&PropertyValue);
4468                                 
4469                                 if (PropertyName == wxT("ALTID")){
4471                                         if (intType == 0){ GeneralTitleListAltID.erase(intValueSeek); GeneralTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4472                                         else if (intType == 1){ HomeTitleListAltID.erase(intValueSeek); HomeTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4473                                         else if (intType == 2){ BusinessTitleListAltID.erase(intValueSeek); BusinessTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4474                                 
4475                                 } else if (PropertyName == wxT("PID")){
4477                                         if (intType == 0){ GeneralTitleListPID.erase(intValueSeek); GeneralTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4478                                         else if (intType == 1){ HomeTitleListPID.erase(intValueSeek); HomeTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4479                                         else if (intType == 2){ BusinessTitleListPID.erase(intValueSeek); BusinessTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4480                                 
4481                                 } else if (PropertyName == wxT("PREF")){
4482                                         
4483                                         intPref = wxAtoi(PropertyValue);
4484                                 
4485                                         if (intType == 0){ GeneralTitleListPref.erase(intValueSeek); GeneralTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
4486                                         else if (intType == 1){ HomeTitleListPref.erase(intValueSeek); HomeTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
4487                                         else if (intType == 2){ BusinessTitleListPref.erase(intValueSeek); BusinessTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
4488                                 
4489                                 } else if (PropertyName == wxT("LANGUAGE")){
4490                                 
4491                                         if (intType == 0){ GeneralTitleListLanguage.erase(intValueSeek); GeneralTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4492                                         else if (intType == 1){ HomeTitleListLanguage.erase(intValueSeek); HomeTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4493                                         else if (intType == 2){ BusinessTitleListLanguage.erase(intValueSeek); BusinessTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4494                                 
4495                                 } else {
4496                                 
4497                                         // Something else we don't know about so append
4498                                         // to the tokens variable.
4499                                 
4500                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4501                                 
4502                                                 if (FirstToken == TRUE){
4503                                         
4504                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4505                                                         FirstToken = FALSE;
4506                                         
4507                                                 } else {
4508                                         
4509                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4510                                         
4511                                                 }
4512                                 
4513                                         }
4514                                 
4515                                 }
4516                         
4517                         }
4518                         
4519                         // Add the data to the General/Home/Work address variables.
4520                         
4521                         ProcessCaptureStrings(&wxSPropertySeg2);
4522                         
4523                         wxListItem coldata;
4524                 
4525                         coldata.SetId(intValueSeek);
4526                         coldata.SetData(intValueSeek);
4527                         coldata.SetText(wxSPropertySeg2);
4528                         
4529                         if (intType == 0){
4530                         
4531                                 ListCtrlIndex = lboTitles->InsertItem(coldata);
4532                                 
4533                                 if (intPref > 0 && intPref < 101){
4534                                 
4535                                         lboTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4536                                         
4537                                 }
4538                                 
4539                                 GeneralTitleList.erase(intValueSeek);
4540                                 GeneralTitleListType.erase(intValueSeek);
4541                                 GeneralTitleListTokens.erase(intValueSeek);
4542                                 GeneralTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4543                                 GeneralTitleListType.insert(std::make_pair(intValueSeek, wxT("")));
4544                                 GeneralTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
4545                         
4546                         } else if (intType == 1){ 
4547                         
4548                                 ListCtrlIndex = lboHomeTitles->InsertItem(coldata);
4550                                 if (intPref > 0 && intPref < 101){
4551                                 
4552                                         lboHomeTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4553                                         
4554                                 }
4556                                 HomeTitleList.erase(intValueSeek);
4557                                 HomeTitleListType.erase(intValueSeek);
4558                                 HomeTitleListTokens.erase(intValueSeek);                                
4559                                 HomeTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4560                                 HomeTitleListType.insert(std::make_pair(intValueSeek, wxT("home")));
4561                                 HomeTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
4562                         
4563                         } else if (intType == 2){ 
4564                         
4565                                 ListCtrlIndex = lboBusinessTitles->InsertItem(coldata);
4567                                 if (intPref > 0 && intPref < 101){
4568                                 
4569                                         lboBusinessTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4570                                         
4571                                 }
4573                                 BusinessTitleList.erase(intValueSeek);
4574                                 BusinessTitleListType.erase(intValueSeek);
4575                                 BusinessTitleListTokens.erase(intValueSeek);                            
4576                                 BusinessTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4577                                 BusinessTitleListType.insert(std::make_pair(intValueSeek, wxT("work")));
4578                                 BusinessTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                           
4579                         
4580                         }
4581                         
4582                         TitleCount++;
4583                         intValueSeek++;
4584                         
4585                 } else if (wxSProperty == wxT("ROLE")) {
4586                 
4587                         int intPropertyLen = wxSPropertySeg1.Len();
4588                         std::map<int, int> SplitPoints;
4589                         std::map<int, int> SplitLength;
4590                         std::map<int, int>::iterator SLiter;                    
4591                         wxString PropertyData;
4592                         wxString PropertyName;
4593                         wxString PropertyValue;
4594                         wxString PropertyTokens;
4595                         bool AfterFirstToken = FALSE;
4596                         bool FirstToken = TRUE;                 
4597                         int intSplitsFound = 0;
4598                         int intSplitSize = 0;
4599                         int intPrevValue = 6;
4600                         int intPref = 0;                        
4601                         int intType = 0;
4602                         int intSplitSeek = 0;
4603                         long ListCtrlIndex;
4604                         
4605                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4606                         
4607                         intPrevValue = 5;
4608                         
4609                         // Look for type before continuing.
4610                         
4611                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4612                         intiter != SplitPoints.end(); ++intiter){
4613                         
4614                                 SLiter = SplitLength.find(intiter->first);
4615                         
4616                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4617                                 
4618                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4619                                 PropertyName = PropertyElement.GetNextToken();                          
4620                                 PropertyValue = PropertyElement.GetNextToken();
4621                                 
4622                                 intPrevValue = intiter->second;
4623                                 
4624                                 if (PropertyName == wxT("TYPE")){
4625                                 
4626                                         if (PropertyValue == wxT("work")){
4627                                         
4628                                                 intType = 2;                                    
4629                                         
4630                                         } else if (PropertyValue == wxT("home")){
4632                                                 intType = 1;
4633                                         
4634                                         } else {
4635                                         
4636                                                 intType = 0;
4637                                         
4638                                         }
4639                                 
4640                                 }
4641                         
4642                         }
4643                         
4644                         // Setup blank lines for later on.
4645                         
4646                         if (intType == 0){
4647                         
4648                                 GeneralRoleList.insert(std::make_pair(intValueSeek, wxT("")));
4649                                 GeneralRoleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4650                                 GeneralRoleListPID.insert(std::make_pair(intValueSeek, wxT("")));
4651                                 GeneralRoleListPref.insert(std::make_pair(intValueSeek, 0));
4652                                 GeneralRoleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4653                                 GeneralRoleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
4655                         } else if (intType == 1){
4656                         
4657                                 HomeRoleList.insert(std::make_pair(intValueSeek, wxT("")));
4658                                 HomeRoleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4659                                 HomeRoleListPID.insert(std::make_pair(intValueSeek, wxT("")));
4660                                 HomeRoleListPref.insert(std::make_pair(intValueSeek, 0));
4661                                 HomeRoleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4662                                 HomeRoleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                             
4663                         
4664                         } else if (intType == 2){
4666                                 BusinessRoleList.insert(std::make_pair(intValueSeek, wxT("")));
4667                                 BusinessRoleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4668                                 BusinessRoleListPID.insert(std::make_pair(intValueSeek, wxT("")));
4669                                 BusinessRoleListPref.insert(std::make_pair(intValueSeek, 0));
4670                                 BusinessRoleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4671                                 BusinessRoleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                         
4672                         
4673                         }
4674                         
4675                         intPrevValue = 5;
4676                         
4677                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4678                         intiter != SplitPoints.end(); ++intiter){
4679                         
4680                                 SLiter = SplitLength.find(intiter->first);
4681                         
4682                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4683                                 
4684                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4685                                 PropertyName = PropertyElement.GetNextToken();                          
4686                                 PropertyValue = PropertyElement.GetNextToken();
4687                                 
4688                                 intPrevValue = intiter->second;
4689                                 
4690                                 // Process properties.
4691                                 
4692                                 int intPropertyValueLen = PropertyValue.Len();                          
4693                                 
4694                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4695                                         
4696                                         PropertyValue.Trim();
4697                                         PropertyValue.RemoveLast();
4698                                         
4699                                 }                               
4700                                 
4701                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4702                                         
4703                                         PropertyValue.Remove(0, 1);
4704                                         
4705                                 }                               
4706                                 
4707                                 ProcessCaptureStrings(&PropertyValue);
4708                                 
4709                                 if (PropertyName == wxT("ALTID")){
4711                                         if (intType == 0){ GeneralRoleListAltID.erase(intValueSeek); GeneralRoleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4712                                         else if (intType == 1){ HomeRoleListAltID.erase(intValueSeek); HomeRoleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4713                                         else if (intType == 2){ BusinessRoleListAltID.erase(intValueSeek); BusinessRoleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4714                                 
4715                                 } else if (PropertyName == wxT("PID")){
4717                                         if (intType == 0){ GeneralRoleListPID.erase(intValueSeek); GeneralRoleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4718                                         else if (intType == 1){ HomeRoleListPID.erase(intValueSeek); HomeRoleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4719                                         else if (intType == 2){ BusinessRoleListPID.erase(intValueSeek); BusinessRoleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4720                                 
4721                                 } else if (PropertyName == wxT("PREF")){
4722                                         
4723                                         intPref = wxAtoi(PropertyValue);
4724                                 
4725                                         if (intType == 0){ GeneralRoleListPref.erase(intValueSeek); GeneralRoleListPref.insert(std::make_pair(intValueSeek, intPref)); }
4726                                         else if (intType == 1){ HomeRoleListPref.erase(intValueSeek); HomeRoleListPref.insert(std::make_pair(intValueSeek, intPref)); }
4727                                         else if (intType == 2){ BusinessRoleListPref.erase(intValueSeek); BusinessRoleListPref.insert(std::make_pair(intValueSeek, intPref)); }
4728                                 
4729                                 } else if (PropertyName == wxT("LANGUAGE")){
4730                                 
4731                                         if (intType == 0){ GeneralRoleListLanguage.erase(intValueSeek); GeneralRoleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4732                                         else if (intType == 1){ HomeRoleListLanguage.erase(intValueSeek); HomeRoleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4733                                         else if (intType == 2){ BusinessRoleListLanguage.erase(intValueSeek); BusinessRoleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4734                                 
4735                                 } else {
4736                                 
4737                                         // Something else we don't know about so append
4738                                         // to the tokens variable.
4739                                 
4740                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4741                                 
4742                                                 if (FirstToken == TRUE){
4743                                         
4744                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4745                                                         FirstToken = FALSE;
4746                                         
4747                                                 } else {
4748                                         
4749                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4750                                         
4751                                                 }
4752                                 
4753                                         }
4754                                 
4755                                 }
4756                         
4757                         }
4758                         
4759                         // Add the data to the General/Home/Work address variables.
4760                         
4761                         ProcessCaptureStrings(&wxSPropertySeg2);
4762                         
4763                         wxListItem coldata;
4764                 
4765                         coldata.SetId(intValueSeek);
4766                         coldata.SetData(intValueSeek);
4767                         coldata.SetText(wxSPropertySeg2);
4768                         
4769                         if (intType == 0){
4770                         
4771                                 ListCtrlIndex = lboRoles->InsertItem(coldata);
4772                                 
4773                                 if (intPref > 0 && intPref < 101){
4774                                 
4775                                         lboRoles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4776                                         
4777                                 }
4778                                 
4779                                 GeneralRoleList.erase(intValueSeek);
4780                                 GeneralRoleListType.erase(intValueSeek);
4781                                 GeneralRoleListTokens.erase(intValueSeek);
4782                                 GeneralRoleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4783                                 GeneralRoleListType.insert(std::make_pair(intValueSeek, wxT("")));
4784                                 GeneralRoleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
4785                         
4786                         } else if (intType == 1){ 
4787                         
4788                                 ListCtrlIndex = lboHomeRoles->InsertItem(coldata);
4790                                 if (intPref > 0 && intPref < 101){
4791                                 
4792                                         lboHomeRoles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4793                                         
4794                                 }
4796                                 HomeRoleList.erase(intValueSeek);
4797                                 HomeRoleListType.erase(intValueSeek);
4798                                 HomeRoleListTokens.erase(intValueSeek);                         
4799                                 HomeRoleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4800                                 HomeRoleListType.insert(std::make_pair(intValueSeek, wxT("home")));
4801                                 HomeRoleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
4802                         
4803                         } else if (intType == 2){ 
4804                         
4805                                 ListCtrlIndex = lboBusinessRoles->InsertItem(coldata);
4807                                 if (intPref > 0 && intPref < 101){
4808                                 
4809                                         lboBusinessRoles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
4810                                         
4811                                 }
4813                                 BusinessRoleList.erase(intValueSeek);
4814                                 BusinessRoleListType.erase(intValueSeek);
4815                                 BusinessRoleListTokens.erase(intValueSeek);                             
4816                                 BusinessRoleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
4817                                 BusinessRoleListType.insert(std::make_pair(intValueSeek, wxT("work")));
4818                                 BusinessRoleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                            
4819                         
4820                         }
4821                         
4822                         RoleCount++;
4823                         intValueSeek++;
4824                         
4825                 } else if (wxSProperty == wxT("ORG")) {
4826                 
4827                         int intPropertyLen = wxSPropertySeg1.Len();
4828                         std::map<int, int> SplitPoints;
4829                         std::map<int, int> SplitLength;
4830                         std::map<int, int>::iterator SLiter;                    
4831                         wxString PropertyData;
4832                         wxString PropertyName;
4833                         wxString PropertyValue;
4834                         wxString PropertyTokens;
4835                         bool AfterFirstToken = FALSE;
4836                         bool FirstToken = TRUE;                 
4837                         int intSplitsFound = 0;
4838                         int intSplitSize = 0;
4839                         int intPrevValue = 5;
4840                         int intPref = 0;
4841                         int intType = 0;
4842                         int intSplitSeek = 0;
4843                         long ListCtrlIndex;
4844                         
4845                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4846                         
4847                         intPrevValue = 4;
4848                         
4849                         // Look for type before continuing.
4850                         
4851                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4852                         intiter != SplitPoints.end(); ++intiter){
4853                         
4854                                 SLiter = SplitLength.find(intiter->first);
4855                         
4856                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4857                                 
4858                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4859                                 PropertyName = PropertyElement.GetNextToken();                          
4860                                 PropertyValue = PropertyElement.GetNextToken();
4861                                 
4862                                 intPrevValue = intiter->second;
4863                                 
4864                                 if (PropertyName == wxT("TYPE")){
4865                                 
4866                                         if (PropertyValue == wxT("work")){
4867                                         
4868                                                 intType = 2;                                    
4869                                         
4870                                         } else if (PropertyValue == wxT("home")){
4872                                                 intType = 1;
4873                                         
4874                                         } else {
4875                                         
4876                                                 intType = 0;
4877                                         
4878                                         }
4879                                 
4880                                 }
4881                         
4882                         }
4883                         
4884                         // Setup blank lines for later on.
4885                         
4886                         if (intType == 0){
4887                         
4888                                 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
4889                                 GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4890                                 GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
4891                                 GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
4892                                 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4893                                 GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
4894                                 GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
4896                         } else if (intType == 1){
4897                         
4898                                 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
4899                                 HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4900                                 HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
4901                                 HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
4902                                 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4903                                 HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
4904                                 HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
4905                         
4906                         } else if (intType == 2){
4908                                 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
4909                                 BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
4910                                 BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
4911                                 BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
4912                                 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
4913                                 BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
4914                                 BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));                          
4915                         
4916                         }
4917                         
4918                         intPrevValue = 4;
4919                         
4920                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4921                         intiter != SplitPoints.end(); ++intiter){
4922                         
4923                                 SLiter = SplitLength.find(intiter->first);
4924                         
4925                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
4926                                 
4927                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4928                                 PropertyName = PropertyElement.GetNextToken();                          
4929                                 PropertyValue = PropertyElement.GetNextToken();
4930                                 
4931                                 intPrevValue = intiter->second;
4932                                 
4933                                 // Process properties.
4934                                 
4935                                 int intPropertyValueLen = PropertyValue.Len();                          
4936                                 
4937                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4938                                         
4939                                         PropertyValue.Trim();
4940                                         PropertyValue.RemoveLast();
4941                                         
4942                                 }                               
4943                                 
4944                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4945                                         
4946                                         PropertyValue.Remove(0, 1);
4947                                         
4948                                 }
4949                                 
4950                                 ProcessCaptureStrings(&PropertyValue);
4951                                 
4952                                 if (PropertyName == wxT("ALTID")){
4954                                         if (intType == 0){ GeneralOrganisationsListAltID.erase(intValueSeek); GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4955                                         else if (intType == 1){ HomeOrganisationsListAltID.erase(intValueSeek); HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4956                                         else if (intType == 2){ BusinessOrganisationsListAltID.erase(intValueSeek); BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4957                                 
4958                                 } else if (PropertyName == wxT("PID")){
4960                                         if (intType == 0){ GeneralOrganisationsListPID.erase(intValueSeek); GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4961                                         else if (intType == 1){ HomeOrganisationsListPID.erase(intValueSeek); HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4962                                         else if (intType == 2){ BusinessOrganisationsListPID.erase(intValueSeek); BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
4963                                 
4964                                 } else if (PropertyName == wxT("PREF")){
4965                                         
4966                                         intPref = wxAtoi(PropertyValue);
4967                                 
4968                                         if (intType == 0){ GeneralOrganisationsListPref.erase(intValueSeek); GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
4969                                         else if (intType == 1){ HomeOrganisationsListPref.erase(intValueSeek); HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
4970                                         else if (intType == 2){ BusinessOrganisationsListPref.erase(intValueSeek); BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
4971                                 
4972                                 } else if (PropertyName == wxT("LANGUAGE")){
4973                                 
4974                                         if (intType == 0){ GeneralOrganisationsListLanguage.erase(intValueSeek); GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4975                                         else if (intType == 1){ HomeOrganisationsListLanguage.erase(intValueSeek); HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4976                                         else if (intType == 2){ BusinessOrganisationsListLanguage.erase(intValueSeek); BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
4977                                 
4978                                 } else if (PropertyName == wxT("SORT-AS")){
4979                                 
4980                                         if (intType == 0){ GeneralOrganisationsListSortAs.erase(intValueSeek); GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
4981                                         else if (intType == 1){ HomeOrganisationsListSortAs.erase(intValueSeek); HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
4982                                         else if (intType == 2){ BusinessOrganisationsListSortAs.erase(intValueSeek); BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
4983                                 
4984                                 } else {
4985                                 
4986                                         // Something else we don't know about so append
4987                                         // to the tokens variable.
4988                                 
4989                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4990                                 
4991                                                 if (FirstToken == TRUE){
4992                                         
4993                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4994                                                         FirstToken = FALSE;
4995                                         
4996                                                 } else {
4997                                         
4998                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4999                                         
5000                                                 }
5001                                 
5002                                         }
5003                                 
5004                                 }
5005                         
5006                         }                       
5007                         
5008                         // Add the data to the General/Home/Work address variables.
5009                         
5010                         wxListItem coldata;
5011                 
5012                         ProcessCaptureStrings(&wxSPropertySeg2);
5013                 
5014                         coldata.SetId(intValueSeek);
5015                         coldata.SetData(intValueSeek);
5016                         coldata.SetText(wxSPropertySeg2);
5017                         
5018                         if (intType == 0){
5019                         
5020                                 ListCtrlIndex = lboOrganisations->InsertItem(coldata);
5021                                 
5022                                 if (intPref > 0 && intPref < 101){
5023                                 
5024                                         lboOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
5025                                         
5026                                 }
5027                                 
5028                                 GeneralOrganisationsList.erase(intValueSeek);
5029                                 GeneralOrganisationsListType.erase(intValueSeek);
5030                                 GeneralOrganisationsListTokens.erase(intValueSeek);
5031                                 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
5032                                 GeneralOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("")));
5033                                 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
5034                         
5035                         } else if (intType == 1){ 
5036                         
5037                                 ListCtrlIndex = lboHomeOrganisations->InsertItem(coldata);
5039                                 if (intPref > 0 && intPref < 101){
5040                                 
5041                                         lboHomeOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
5042                                         
5043                                 }
5045                                 HomeOrganisationsList.erase(intValueSeek);
5046                                 HomeOrganisationsListType.erase(intValueSeek);
5047                                 HomeOrganisationsListTokens.erase(intValueSeek);                                
5048                                 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
5049                                 HomeOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("home")));
5050                                 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
5051                         
5052                         } else if (intType == 2){ 
5053                         
5054                                 ListCtrlIndex = lboBusinessOrganisations->InsertItem(coldata);
5056                                 if (intPref > 0 && intPref < 101){
5057                                 
5058                                         lboBusinessOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
5059                                         
5060                                 }
5062                                 BusinessOrganisationsList.erase(intValueSeek);
5063                                 BusinessOrganisationsListType.erase(intValueSeek);
5064                                 BusinessOrganisationsListTokens.erase(intValueSeek);                            
5065                                 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
5066                                 BusinessOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("work")));
5067                                 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                           
5068                         
5069                         }
5070                         
5071                         OrgCount++;
5072                         intValueSeek++;
5073                         
5074                 } else if (wxSProperty == wxT("NOTE")) {
5075                 
5076                         int intPropertyLen = wxSPropertySeg1.Len();
5077                         std::map<int, int> SplitPoints;
5078                         std::map<int, int> SplitLength;
5079                         std::map<int, int>::iterator SLiter;                    
5080                         wxString PropertyData;
5081                         wxString PropertyName;
5082                         wxString PropertyValue;
5083                         wxString PropertyTokens;
5084                         bool AfterFirstToken = FALSE;
5085                         bool FirstToken = TRUE;                 
5086                         int intSplitsFound = 0;
5087                         int intSplitSize = 0;
5088                         int intPrevValue = 6;
5089                         int intPref = 0;                        
5090                         int intType = 0;
5091                         int intSplitSeek = 0;
5092                         long ListCtrlIndex;
5093                         
5094                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5095                         
5096                         intPrevValue = 5;
5097                         
5098                         // Look for type before continuing.
5099                         
5100                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5101                         intiter != SplitPoints.end(); ++intiter){
5102                         
5103                                 SLiter = SplitLength.find(intiter->first);
5104                         
5105                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
5106                                 
5107                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5108                                 PropertyName = PropertyElement.GetNextToken();                          
5109                                 PropertyValue = PropertyElement.GetNextToken();
5110                                 
5111                                 intPrevValue = intiter->second;
5112                                 
5113                                 if (PropertyName == wxT("TYPE")){
5114                                 
5115                                         if (PropertyValue == wxT("work")){
5116                                         
5117                                                 intType = 2;                                    
5118                                         
5119                                         } else if (PropertyValue == wxT("home")){
5121                                                 intType = 1;
5122                                         
5123                                         } else {
5124                                         
5125                                                 intType = 0;
5126                                         
5127                                         }
5128                                 
5129                                 }
5130                         
5131                         }
5132                         
5133                         // Setup blank lines for later on.
5134                         
5135                         if (intType == 0){
5136                         
5137                                 GeneralNoteList.insert(std::make_pair(intValueSeek, wxT("")));
5138                                 GeneralNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
5139                                 GeneralNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
5140                                 GeneralNoteListPref.insert(std::make_pair(intValueSeek, 0));
5141                                 GeneralNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
5142                                 GeneralNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
5144                         } else if (intType == 1){
5145                         
5146                                 HomeNoteList.insert(std::make_pair(intValueSeek, wxT("")));
5147                                 HomeNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
5148                                 HomeNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
5149                                 HomeNoteListPref.insert(std::make_pair(intValueSeek, 0));
5150                                 HomeNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
5151                                 HomeNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
5152                         
5153                         } else if (intType == 2){
5155                                 BusinessNoteList.insert(std::make_pair(intValueSeek, wxT("")));
5156                                 BusinessNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
5157                                 BusinessNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
5158                                 BusinessNoteListPref.insert(std::make_pair(intValueSeek, 0));
5159                                 BusinessNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
5160                                 BusinessNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
5161                         
5162                         }
5163                         
5164                         intPrevValue = 5;                       
5165                         
5166                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5167                         intiter != SplitPoints.end(); ++intiter){
5168                         
5169                                 SLiter = SplitLength.find(intiter->first);
5170                         
5171                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
5172                                 
5173                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5174                                 PropertyName = PropertyElement.GetNextToken();                          
5175                                 PropertyValue = PropertyElement.GetNextToken();
5176                                 
5177                                 intPrevValue = intiter->second;
5178                                 
5179                                 // Process properties.
5180                                 
5181                                 int intPropertyValueLen = PropertyValue.Len();                          
5182                                 
5183                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5184                                         
5185                                         PropertyValue.Trim();
5186                                         PropertyValue.RemoveLast();
5187                                         
5188                                 }                               
5189                                 
5190                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5191                                         
5192                                         PropertyValue.Remove(0, 1);
5193                                         
5194                                 }
5195                                 
5196                                 ProcessCaptureStrings(&PropertyValue);                          
5197                                 
5198                                 if (PropertyName == wxT("ALTID")){
5200                                         if (intType == 0){ GeneralNoteListAltID.erase(intValueSeek); GeneralNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5201                                         else if (intType == 1){ HomeNoteListAltID.erase(intValueSeek); HomeNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5202                                         else if (intType == 2){ BusinessNoteListAltID.erase(intValueSeek); BusinessNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5203                                 
5204                                 } else if (PropertyName == wxT("PID")){
5206                                         if (intType == 0){ GeneralNoteListPID.erase(intValueSeek); GeneralNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5207                                         else if (intType == 1){ HomeNoteListPID.erase(intValueSeek); HomeNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5208                                         else if (intType == 2){ BusinessNoteListPID.erase(intValueSeek); BusinessNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5209                                 
5210                                 } else if (PropertyName == wxT("PREF")){
5211                                         
5212                                         intPref = wxAtoi(PropertyValue);
5213                                 
5214                                         if (intType == 0){ GeneralNoteListPref.erase(intValueSeek); GeneralNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
5215                                         else if (intType == 1){ HomeNoteListPref.erase(intValueSeek); HomeNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
5216                                         else if (intType == 2){ BusinessNoteListPref.erase(intValueSeek); BusinessNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
5217                                 
5218                                 } else if (PropertyName == wxT("LANGUAGE")){
5219                                 
5220                                         if (intType == 0){ GeneralNoteListLanguage.erase(intValueSeek); GeneralNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
5221                                         else if (intType == 1){ HomeNoteListLanguage.erase(intValueSeek); HomeNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
5222                                         else if (intType == 2){ BusinessNoteListLanguage.erase(intValueSeek); BusinessNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
5223                                 
5224                                 } else {
5225                                 
5226                                         // Something else we don't know about so append
5227                                         // to the tokens variable.
5228                                 
5229                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5230                                 
5231                                                 if (FirstToken == TRUE){
5232                                         
5233                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5234                                                         FirstToken = FALSE;
5235                                         
5236                                                 } else {
5237                                         
5238                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5239                                         
5240                                                 }
5241                                 
5242                                         }
5243                                 
5244                                 }
5245                         
5246                         }
5247                         
5248                         // Add the data to the General/Home/Work address variables.
5249                         
5250                         ProcessCaptureStrings(&wxSPropertySeg2);
5251                         
5252                         wxListItem coldata;
5253                 
5254                         coldata.SetId(intValueSeek);
5255                         coldata.SetData(intValueSeek);
5256                         
5257                         if (intType == 0){
5258                         
5259                                 GeneralNoteList.erase(intValueSeek);
5260                                 GeneralNoteListType.erase(intValueSeek);
5261                                 GeneralNoteListTokens.erase(intValueSeek);
5262                                 GeneralNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
5263                                 GeneralNoteListType.insert(std::make_pair(intValueSeek, wxT("")));
5264                                 GeneralNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                     
5265                         
5266                                 //CaptureString(&wxSPropertySeg2, FALSE);
5267         
5268                                 coldata.SetText(wxSPropertySeg2);
5269                         
5270                                 ListCtrlIndex = lboNotes->InsertItem(coldata);
5271                                 
5272                                 if (intPref > 0 && intPref < 101){
5273                                 
5274                                         lboNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
5275                                         
5276                                 }
5277                         
5278                         } else if (intType == 1){ 
5279                         
5280                                 HomeNoteList.erase(intValueSeek);
5281                                 HomeNoteListType.erase(intValueSeek);
5282                                 HomeNoteListTokens.erase(intValueSeek);                         
5283                                 HomeNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
5284                                 HomeNoteListType.insert(std::make_pair(intValueSeek, wxT("home")));
5285                                 HomeNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                        
5286                         
5287                                 CaptureString(&wxSPropertySeg2, FALSE);
5288         
5289                                 coldata.SetText(wxSPropertySeg2);                       
5290                         
5291                                 ListCtrlIndex = lboHomeNotes->InsertItem(coldata);
5293                                 if (intPref > 0 && intPref < 101){
5294                                 
5295                                         lboHomeNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
5296                                         
5297                                 }
5298                         
5299                         } else if (intType == 2){ 
5300                         
5301                                 BusinessNoteList.erase(intValueSeek);
5302                                 BusinessNoteListType.erase(intValueSeek);
5303                                 BusinessNoteListTokens.erase(intValueSeek);                             
5304                                 BusinessNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
5305                                 BusinessNoteListType.insert(std::make_pair(intValueSeek, wxT("work")));
5306                                 BusinessNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                    
5307                         
5308                                 CaptureString(&wxSPropertySeg2, FALSE);
5309         
5310                                 coldata.SetText(wxSPropertySeg2);
5311                         
5312                                 ListCtrlIndex = lboBusinessNotes->InsertItem(coldata);
5314                                 if (intPref > 0 && intPref < 101){
5315                                 
5316                                         lboBusinessNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
5317                                         
5318                                 }                               
5319                         
5320                         }
5321                         
5322                         NoteCount++;
5323                         intValueSeek++;
5324                         
5325                 } else if (wxSProperty == wxT("CATEGORIES")) {
5326                 
5327                         int intPropertyLen = wxSPropertySeg1.Len();
5328                         std::map<int, int> SplitPoints;
5329                         std::map<int, int> SplitLength;
5330                         std::map<int, int>::iterator SLiter;                    
5331                         wxString PropertyData;
5332                         wxString PropertyName;
5333                         wxString PropertyValue;
5334                         wxString PropertyTokens;
5335                         wxString PropertyType;
5336                         bool AfterFirstToken = FALSE;
5337                         bool FirstToken = TRUE;                 
5338                         int intSplitsFound = 0;
5339                         int intSplitSize = 0;
5340                         int intPrevValue = 12;
5341                         int intPref = 0;                        
5342                         int intType = 0;
5343                         int intSplitSeek = 0;
5344                         long ListCtrlIndex;
5345                         
5346                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5347                         
5348                         intPrevValue = 11;
5349                         
5350                         // Look for type before continuing.
5351                         
5352                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5353                         intiter != SplitPoints.end(); ++intiter){
5354                         
5355                                 SLiter = SplitLength.find(intiter->first);
5356                         
5357                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
5358                                 
5359                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5360                                 PropertyName = PropertyElement.GetNextToken();                          
5361                                 PropertyValue = PropertyElement.GetNextToken();
5362                                 
5363                                 intPrevValue = intiter->second;
5364                                 
5365                                 if (PropertyName == wxT("TYPE")){
5366                                 
5367                                         if (PropertyValue == wxT("work")){
5368                                         
5369                                                 intType = 2;
5370                                                 PropertyType = wxT("work");                             
5371                                         
5372                                         } else if (PropertyValue == wxT("home")){
5374                                                 intType = 1;
5375                                                 PropertyType = wxT("home");                                             
5376                                         
5377                                         } else {
5378                                         
5379                                                 intType = 0;
5380                                         
5381                                         }
5382                                 
5383                                 }
5384                         
5385                         }
5386                         
5387                         // Setup blank lines for later on.
5388                         
5389                         CategoriesList.insert(std::make_pair(intValueSeek, wxT("")));
5390                         CategoriesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
5391                         CategoriesListPID.insert(std::make_pair(intValueSeek, wxT("")));
5392                         CategoriesListPref.insert(std::make_pair(intValueSeek, 0));
5393                         CategoriesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
5394                         
5395                         intPrevValue = 11;
5396                         
5397                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5398                         intiter != SplitPoints.end(); ++intiter){
5399                         
5400                                 SLiter = SplitLength.find(intiter->first);
5401                         
5402                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
5403                                 
5404                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5405                                 PropertyName = PropertyElement.GetNextToken();                          
5406                                 PropertyValue = PropertyElement.GetNextToken();
5407                                 
5408                                 intPrevValue = intiter->second;
5409                                 
5410                                 // Process properties.
5411                                 
5412                                 int intPropertyValueLen = PropertyValue.Len();                          
5413                                 
5414                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5415                                         
5416                                         PropertyValue.Trim();
5417                                         PropertyValue.RemoveLast();
5418                                         
5419                                 }                               
5420                                 
5421                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5422                                         
5423                                         PropertyValue.Remove(0, 1);
5424                                         
5425                                 }
5426                                 
5427                                 ProcessCaptureStrings(&PropertyValue);
5428                                 
5429                                 if (PropertyName == wxT("ALTID")){
5431                                         if (intType == 0){ CategoriesListAltID.erase(intValueSeek); CategoriesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5432                                         else if (intType == 1){ CategoriesListAltID.erase(intValueSeek); CategoriesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5433                                         else if (intType == 2){ CategoriesListAltID.erase(intValueSeek); CategoriesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5434                                 
5435                                 } else if (PropertyName == wxT("PID")){
5437                                         if (intType == 0){ CategoriesListPID.erase(intValueSeek); CategoriesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5438                                         else if (intType == 1){ CategoriesListPID.erase(intValueSeek); CategoriesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5439                                         else if (intType == 2){ CategoriesListPID.erase(intValueSeek); CategoriesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5440                                 
5441                                 } else if (PropertyName == wxT("PREF")){
5442                                         
5443                                         intPref = wxAtoi(PropertyValue);
5444                                 
5445                                         if (intType == 0){ CategoriesListPref.erase(intValueSeek); CategoriesListPref.insert(std::make_pair(intValueSeek, intPref)); }
5446                                         else if (intType == 1){ CategoriesListPref.erase(intValueSeek); CategoriesListPref.insert(std::make_pair(intValueSeek, intPref)); }
5447                                         else if (intType == 2){ CategoriesListPref.erase(intValueSeek); CategoriesListPref.insert(std::make_pair(intValueSeek, intPref)); }
5448                                 
5449                                 } else {
5450                                 
5451                                         // Something else we don't know about so append
5452                                         // to the tokens variable.
5453                                 
5454                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5455                                 
5456                                                 if (FirstToken == TRUE){
5457                                         
5458                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5459                                                         FirstToken = FALSE;
5460                                         
5461                                                 } else {
5462                                         
5463                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5464                                         
5465                                                 }
5466                                 
5467                                         }
5468                                 
5469                                 }
5470                         
5471                         }                       
5472                         
5473                         // Deal with multiple categories.
5474                         
5475                         SplitPoints.clear();
5476                         SplitLength.clear();
5477                         intSplitSize = 0;
5478                         intSplitsFound = 0;
5479                         intSplitSeek = 0;
5480                         intPrevValue = 0;
5481                         intPropertyLen = wxSPropertySeg2.Len(); 
5482                         
5483                         for (int i = 0; i <= intPropertyLen; i++){
5484                         
5485                                 if (intSplitSize == 0 && wxSPropertySeg2.Mid(i, 1) == wxT(" ")){
5486                         
5487                                         continue;
5488                                 
5489                                 }
5490                         
5491                                 intSplitSize++;
5492                         
5493                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(",") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5494                         
5495                                         if (AfterFirstToken == TRUE){
5496                         
5497                                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5498                                                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
5499                                         
5500                                         } else {
5501                                         
5502                                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5503                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));                                 
5504                                                 AfterFirstToken = TRUE;
5505                                         
5506                                         }
5508                                         intSplitsFound++;
5509                                         intSplitSeek = i;
5510                                         intSplitSize = 0;                                       
5511                         
5512                                 }                       
5513                         
5514                         }
5515                         
5516                         SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5517                         SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                       
5518                         
5519                         intPrevValue = 0;
5520                         
5521                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5522                         intiter != SplitPoints.end(); ++intiter){
5523                         
5524                                 SLiter = SplitLength.find(intiter->first);
5525                         
5526                                 PropertyData = wxSPropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
5527                                 
5528                                 intPrevValue = intiter->second;
5529                                 
5530                                 // Process properties.
5531                                 
5532                                 /*
5533                                 
5534                                 int intPropertyValueLen = PropertyValue.Len();                          
5535                                 
5536                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5537                                         
5538                                         PropertyValue.Trim();
5539                                         PropertyValue.RemoveLast();
5540                                         
5541                                 }
5542                                 
5543                                 */
5544                                 
5545                                 // Add the data to the General/Home/Work address variables.
5546                         
5547                                 // Trim any whitespace from the start and end.
5548                         
5549                                 PropertyData = PropertyData.Trim(FALSE);
5550                                 PropertyData = PropertyData.Trim(TRUE);                         
5551                         
5552                                 ProcessCaptureStrings(&PropertyData);
5553                         
5554                                 wxListItem coldata;
5555                 
5556                                 coldata.SetId(intValueSeek);
5557                                 coldata.SetData(intValueSeek);
5558                                 coldata.SetText(PropertyData);
5559                         
5560                                 ListCtrlIndex = lboCategories->InsertItem(coldata);
5561                                 
5562                                 if (intPref > 0 && intPref < 101){
5563                                 
5564                                         lboCategories->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
5565                                         
5566                                 }
5567                                 
5568                                 CategoriesList.erase(intValueSeek);
5569                                 CategoriesListType.erase(intValueSeek);
5570                                 CategoriesListTokens.erase(intValueSeek);
5571                                 CategoriesList.insert(std::make_pair(intValueSeek, PropertyData));
5572                                 CategoriesListType.insert(std::make_pair(intValueSeek, PropertyType));
5573                                 CategoriesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
5574                         
5575                                 CategoryCount++;
5576                                 intValueSeek++;                         
5577                         
5578                         }       
5579                         
5580                 } else if (wxSProperty == wxT("PHOTO")) {
5581                 
5582                         int intPropertyLen = wxSPropertySeg1.Len();
5583                         std::map<int, int> SplitPoints;
5584                         std::map<int, int> SplitLength;
5585                         std::map<int, int>::iterator SLiter;                    
5586                         wxString PropertyData;
5587                         wxString PropertyName;
5588                         wxString PropertyValue;
5589                         wxString PropertyTokens;
5590                         bool FirstToken = TRUE;
5591                         int intSplitsFound = 0;
5592                         int intSplitSize = 0;
5593                         int intPrevValue = 7;
5594                         int intPref = 0;                        
5595                         int intType = 0;
5596                         int intSplitSeek = 0;
5597                         long ListCtrlIndex;
5598                         
5599                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5600                         
5601                         intPrevValue = 6;
5602                         
5603                         // Look for type before continuing.                     
5604                         
5605                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5606                         intiter != SplitPoints.end(); ++intiter){
5607                         
5608                                 SLiter = SplitLength.find(intiter->first);
5609                         
5610                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
5611                                 
5612                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5613                                 PropertyName = PropertyElement.GetNextToken();                          
5614                                 PropertyValue = PropertyElement.GetNextToken();
5615                                 
5616                                 intPrevValue = intiter->second;
5617                                 
5618                                 if (PropertyName == wxT("TYPE")){
5619                                 
5620                                         if (PropertyValue == wxT("work")){
5621                                         
5622                                                 intType = 2;                                    
5623                                         
5624                                         } else if (PropertyValue == wxT("home")){
5626                                                 intType = 1;
5627                                         
5628                                         } else {
5629                                         
5630                                                 intType = 0;
5631                                         
5632                                         }
5633                                 
5634                                 }
5635                         
5636                         }
5637                         
5638                         // Setup blank lines for later on.
5639                         
5640                         PicturesList.insert(std::make_pair(intValueSeek, ""));
5641                         PicturesListType.insert(std::make_pair(intValueSeek, wxT("")));
5642                         PicturesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
5643                         PicturesListPID.insert(std::make_pair(intValueSeek, wxT("")));
5644                         PicturesListPref.insert(std::make_pair(intValueSeek, 0));
5645                         PicturesListPicEncType.insert(std::make_pair(intValueSeek, wxT("")));
5646                         PicturesListPictureType.insert(std::make_pair(intValueSeek, wxT("")));                  
5647                         PicturesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
5648                         PicturesListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
5650                         intPrevValue = 6;
5652                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5653                         intiter != SplitPoints.end(); ++intiter){
5654                         
5655                                 SLiter = SplitLength.find(intiter->first);
5656                         
5657                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
5658                                 
5659                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5660                                 PropertyName = PropertyElement.GetNextToken();                          
5661                                 PropertyValue = PropertyElement.GetNextToken();
5662                                 
5663                                 intPrevValue = intiter->second;
5664                                 
5665                                 // Process properties.
5666                                 
5667                                 int intPropertyValueLen = PropertyValue.Len();                          
5668                                 
5669                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5670                                         
5671                                         PropertyValue.Trim();
5672                                         PropertyValue.RemoveLast();
5673                                         
5674                                 }                               
5675                                 
5676                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5677                                         
5678                                         PropertyValue.Remove(0, 1);
5679                                         
5680                                 }
5681                                 
5682                                 ProcessCaptureStrings(&PropertyValue);          
5683                                 
5684                                 if (PropertyName == wxT("ALTID")){
5686                                         if (intType == 0){ PicturesListAltID.erase(intValueSeek); PicturesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5687                                         else if (intType == 1){ PicturesListAltID.erase(intValueSeek); PicturesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5688                                         else if (intType == 2){ PicturesListAltID.erase(intValueSeek); PicturesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5689                                 
5690                                 } else if (PropertyName == wxT("PID")){
5692                                         if (intType == 0){ PicturesListPID.erase(intValueSeek); PicturesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5693                                         else if (intType == 1){ PicturesListPID.erase(intValueSeek); PicturesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5694                                         else if (intType == 2){ PicturesListPID.erase(intValueSeek); PicturesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5695                                 
5696                                 } else if (PropertyName == wxT("PREF")){
5697                                         
5698                                         intPref = wxAtoi(PropertyValue);
5699                                 
5700                                         if (intType == 0){ PicturesListPref.erase(intValueSeek); PicturesListPref.insert(std::make_pair(intValueSeek, intPref)); }
5701                                         else if (intType == 1){ PicturesListPref.erase(intValueSeek); PicturesListPref.insert(std::make_pair(intValueSeek, intPref)); }
5702                                         else if (intType == 2){ PicturesListPref.erase(intValueSeek); PicturesListPref.insert(std::make_pair(intValueSeek, intPref)); }
5703                                 
5704                                 } else if (PropertyName == wxT("MEDIATYPE")){
5705                                 
5706                                         if (intType == 0){ PicturesListMediatype.erase(intValueSeek); PicturesListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
5707                                         else if (intType == 1){ PicturesListMediatype.erase(intValueSeek); PicturesListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
5708                                         else if (intType == 2){ PicturesListMediatype.erase(intValueSeek); PicturesListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
5709                                 
5710                                 } else {
5711                                 
5712                                         // Something else we don't know about so append
5713                                         // to the tokens variable.
5714                                         
5715                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5716                                         
5717                                                 if (FirstToken == TRUE){
5718                                                 
5719                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5720                                                         FirstToken = FALSE;
5721                                                 
5722                                                 } else {
5723                                                 
5724                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5725                                                 
5726                                                 }
5727                                         
5728                                         }
5729                                 
5730                                 }
5731                         
5732                         }       
5733                         
5734                         intPropertyLen = wxSPropertySeg2.Len();
5735                         SplitPoints.clear();
5736                         SplitLength.clear();
5737                         intSplitsFound = 0;
5738                         intSplitSize = 0;
5739                         intPrevValue = 0;                       
5740                         
5741                         ProcessCaptureStrings(&wxSPropertySeg2);
5742                         
5743                         for (int i = 0; i <= intPropertyLen; i++){
5744                 
5745                                 intSplitSize++;
5746                         
5747                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
5748                         
5749                                         intSplitsFound++;
5750                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5751                                         
5752                                         if (intSplitsFound == 6){ 
5753                                         
5754                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5755                                                 break; 
5756                                                 
5757                                         } else {
5758                                         
5759                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5760                                         
5761                                         }
5762                                         
5763                                         intSplitSize = 0;                                       
5764                         
5765                                 }
5766                 
5767                         }
5768                         
5769                         wxString wxSPhotoURI;
5770                         wxString wxSPhotoMIME;
5771                         wxString wxSPhotoEncoding;
5772                         wxString wxSPhotoData;
5773                         std::string base64enc;
5774                         
5775                         if (intSplitsFound = 0){
5776                         
5777                         } else {
5778                         
5779                                 std::map<int, int>::iterator striter;
5780                         
5781                                 striter = SplitLength.find(1);
5782                         
5783                                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
5784                         
5785                                 while (wSTDataType.HasMoreTokens() == TRUE){
5786                                 
5787                                         wxSPhotoURI = wSTDataType.GetNextToken();
5788                                         wxSPhotoMIME = wSTDataType.GetNextToken();
5789                                         break;
5790                                 
5791                                 }                       
5792                         
5793                                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));                    
5794                         
5795                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5796                                 
5797                                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
5798                                         wxSPhotoData = wSTDataInfo.GetNextToken();                                      
5799                                         base64enc = wxSPhotoData.mb_str();
5800                                         break;
5801                                 
5802                                 }
5803                         
5804                         }
5805                         
5806                         // Add the data to the General/Home/Work address variables.
5807                         
5808                         wxListItem coldata;
5809                 
5810                         coldata.SetId(intValueSeek);
5811                         coldata.SetData(intValueSeek);
5812                         coldata.SetText(_("Picture"));
5813                         
5814                         ListCtrlIndex = lboPictures->InsertItem(coldata);
5815                                 
5816                         if (intPref > 0 && intPref < 101){
5817                                 
5818                                 lboPictures->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
5819                         
5820                         }
5821                                 
5822                         PicturesList.erase(intValueSeek);
5823                         PicturesListType.erase(intValueSeek);
5824                         PicturesListTokens.erase(intValueSeek);
5825                         PicturesListPictureType.erase(intValueSeek);
5826                         PicturesListPicEncType.erase(intValueSeek);
5827                         PicturesList.insert(std::make_pair(intValueSeek, base64enc));
5828                         PicturesListPictureType.insert(std::make_pair(intValueSeek, wxSPhotoMIME));
5829                         PicturesListPicEncType.insert(std::make_pair(intValueSeek, wxSPhotoEncoding));
5830                         
5831                         if (intType == 0){
5832                         
5833                                 PicturesListType.insert(std::make_pair(intValueSeek, wxT("")));
5834                         
5835                         } else if (intType == 1){
5836                         
5837                                 PicturesListType.insert(std::make_pair(intValueSeek, wxT("home")));
5838                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Home"));                 
5839                         
5840                         } else if (intType == 2){
5841                         
5842                                 PicturesListType.insert(std::make_pair(intValueSeek, wxT("work")));
5843                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Work"));
5844                         
5845                         }
5846                         
5847                         PicturesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
5848                         
5849                         PhotoCount++;
5850                         intValueSeek++;
5851                         
5852                 } else if (wxSProperty == wxT("LOGO")) {
5853                 
5854                         int intPropertyLen = wxSPropertySeg1.Len();
5855                         std::map<int, int> SplitPoints;
5856                         std::map<int, int> SplitLength;
5857                         std::map<int, int>::iterator SLiter;                    
5858                         wxString PropertyData;
5859                         wxString PropertyName;
5860                         wxString PropertyValue;
5861                         wxString PropertyTokens;
5862                         bool FirstToken = TRUE;
5863                         int intSplitsFound = 0;
5864                         int intSplitSize = 0;
5865                         int intPrevValue = 6;
5866                         int intPref = 0;                        
5867                         int intType = 0;
5868                         int intSplitSeek = 0;
5869                         long ListCtrlIndex;
5870                         
5871                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5872                         
5873                         intPrevValue = 5;
5874                         
5875                         // Look for type before continuing.                     
5876                         
5877                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5878                         intiter != SplitPoints.end(); ++intiter){
5879                         
5880                                 SLiter = SplitLength.find(intiter->first);
5881                         
5882                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
5883                                 
5884                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5885                                 PropertyName = PropertyElement.GetNextToken();                          
5886                                 PropertyValue = PropertyElement.GetNextToken();
5887                                 
5888                                 intPrevValue = intiter->second;
5889                                 
5890                                 if (PropertyName == wxT("TYPE")){
5891                                 
5892                                         if (PropertyValue == wxT("work")){
5893                                         
5894                                                 intType = 2;
5895                                         
5896                                         } else if (PropertyValue == wxT("home")){
5898                                                 intType = 1;
5899                                         
5900                                         } else {
5901                                         
5902                                                 intType = 0;
5903                                         
5904                                         }
5905                                 
5906                                 }
5907                         
5908                         }
5909                         
5910                         // Setup blank lines for later on.
5911                         
5912                         LogosList.insert(std::make_pair(intValueSeek, ""));
5913                         LogosListType.insert(std::make_pair(intValueSeek, wxT("")));
5914                         LogosListAltID.insert(std::make_pair(intValueSeek, wxT("")));
5915                         LogosListPID.insert(std::make_pair(intValueSeek, wxT("")));
5916                         LogosListPref.insert(std::make_pair(intValueSeek, 0));
5917                         LogosListPicEncType.insert(std::make_pair(intValueSeek, wxT("")));
5918                         LogosListPictureType.insert(std::make_pair(intValueSeek, wxT("")));                     
5919                         LogosListTokens.insert(std::make_pair(intValueSeek, wxT("")));
5920                         LogosListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
5922                         intPrevValue = 5;
5924                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5925                         intiter != SplitPoints.end(); ++intiter){
5926                         
5927                                 SLiter = SplitLength.find(intiter->first);
5928                         
5929                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
5930                                 
5931                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5932                                 PropertyName = PropertyElement.GetNextToken();                          
5933                                 PropertyValue = PropertyElement.GetNextToken();
5934                                 
5935                                 intPrevValue = intiter->second;
5936                                 
5937                                 // Process properties.
5938                                 
5939                                 int intPropertyValueLen = PropertyValue.Len();                          
5940                                 
5941                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5942                                         
5943                                         PropertyValue.Trim();
5944                                         PropertyValue.RemoveLast();
5945                                         
5946                                 }                               
5947                                 
5948                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5949                                         
5950                                         PropertyValue.Remove(0, 1);
5951                                         
5952                                 }
5953                                 
5954                                 ProcessCaptureStrings(&PropertyValue);  
5955                                 
5956                                 if (PropertyName == wxT("ALTID")){
5958                                         if (intType == 0){ LogosListAltID.erase(intValueSeek); LogosListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5959                                         else if (intType == 1){ LogosListAltID.erase(intValueSeek); LogosListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5960                                         else if (intType == 2){ LogosListAltID.erase(intValueSeek); LogosListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5961                                 
5962                                 } else if (PropertyName == wxT("PID")){
5964                                         if (intType == 0){ LogosListPID.erase(intValueSeek); LogosListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5965                                         else if (intType == 1){ LogosListPID.erase(intValueSeek); LogosListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5966                                         else if (intType == 2){ LogosListPID.erase(intValueSeek); LogosListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
5967                                 
5968                                 } else if (PropertyName == wxT("PREF")){
5969                                         
5970                                         intPref = wxAtoi(PropertyValue);
5971                                 
5972                                         if (intType == 0){ LogosListPref.erase(intValueSeek); LogosListPref.insert(std::make_pair(intValueSeek, intPref)); }
5973                                         else if (intType == 1){ LogosListPref.erase(intValueSeek); LogosListPref.insert(std::make_pair(intValueSeek, intPref)); }
5974                                         else if (intType == 2){ LogosListPref.erase(intValueSeek); LogosListPref.insert(std::make_pair(intValueSeek, intPref)); }
5975                                 
5976                                 } else if (PropertyName == wxT("MEDIATYPE")){
5977                                 
5978                                         if (intType == 0){ LogosListMediatype.erase(intValueSeek); LogosListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
5979                                         else if (intType == 1){ LogosListMediatype.erase(intValueSeek); LogosListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
5980                                         else if (intType == 2){ LogosListMediatype.erase(intValueSeek); LogosListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
5981                                 
5982                                 } else {
5983                                 
5984                                         // Something else we don't know about so append
5985                                         // to the tokens variable.
5986                                         
5987                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5988                                         
5989                                                 if (FirstToken == TRUE){
5990                                                 
5991                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5992                                                         FirstToken = FALSE;
5993                                                 
5994                                                 } else {
5995                                                 
5996                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5997                                                 
5998                                                 }
5999                                         
6000                                         }
6001                                 
6002                                 }
6003                         
6004                         }       
6005                         
6006                         intPropertyLen = wxSPropertySeg2.Len();
6007                         SplitPoints.clear();
6008                         SplitLength.clear();
6009                         intSplitsFound = 0;
6010                         intSplitSize = 0;
6011                         intPrevValue = 0;
6012                         
6013                         wxString wxSPhotoURI;
6014                         wxString wxSPhotoMIME;
6015                         wxString wxSPhotoEncoding;
6016                         wxString wxSPhotoData;
6017                         std::string base64enc;
6018                         
6019                         ProcessCaptureStrings(&wxSPropertySeg2);
6020                         
6021                         if (intSplitsFound = 0){
6022                         
6023                         } else {
6024                         
6025                                 std::map<int, int>::iterator striter;
6026                         
6027                                 striter = SplitLength.find(1);
6028                         
6029                                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
6030                         
6031                                 while (wSTDataType.HasMoreTokens() == TRUE){
6032                                 
6033                                         wxSPhotoURI = wSTDataType.GetNextToken();
6034                                         wxSPhotoMIME = wSTDataType.GetNextToken();
6035                                         break;
6036                                 
6037                                 }                       
6038                         
6039                                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));                    
6040                         
6041                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
6042                                 
6043                                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
6044                                         wxSPhotoData = wSTDataInfo.GetNextToken();                                      
6045                                         base64enc = wxSPhotoData.mb_str();
6046                                         break;
6047                                 
6048                                 }
6049                         
6050                         }
6051                         
6052                         // Add the data to the General/Home/Work address variables.
6053                         
6054                         wxListItem coldata;
6055                 
6056                         coldata.SetId(intValueSeek);
6057                         coldata.SetData(intValueSeek);
6058                         coldata.SetText(_("Picture"));
6059                         
6060                         ListCtrlIndex = lboLogos->InsertItem(coldata);
6061                                 
6062                         if (intPref > 0 && intPref < 101){
6063                                 
6064                                 lboLogos->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
6065                         
6066                         }
6067                                 
6068                         LogosList.erase(intValueSeek);
6069                         LogosListType.erase(intValueSeek);
6070                         LogosListTokens.erase(intValueSeek);
6071                         LogosListPictureType.erase(intValueSeek);
6072                         LogosListPicEncType.erase(intValueSeek);
6073                         LogosList.insert(std::make_pair(intValueSeek, base64enc));
6074                         LogosListPictureType.insert(std::make_pair(intValueSeek, wxSPhotoMIME));
6075                         LogosListPicEncType.insert(std::make_pair(intValueSeek, wxSPhotoEncoding));
6076                         
6077                         if (intType == 0){
6078                         
6079                                 LogosListType.insert(std::make_pair(intValueSeek, wxT("")));
6080                         
6081                         } else if (intType == 1){
6082                         
6083                                 LogosListType.insert(std::make_pair(intValueSeek, wxT("home")));
6084                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Home"));
6085                         
6086                         } else if (intType == 2){
6087                         
6088                                 LogosListType.insert(std::make_pair(intValueSeek, wxT("work")));
6089                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Work"));                         
6090                         
6091                         }
6092                         
6093                         LogosListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
6094                         
6095                         LogoCount++;
6096                         intValueSeek++;
6097                         
6098                 } else if (wxSProperty == wxT("SOUND")) {
6099                 
6100                         int intPropertyLen = wxSPropertySeg1.Len();
6101                         std::map<int, int> SplitPoints;
6102                         std::map<int, int> SplitLength;
6103                         std::map<int, int>::iterator SLiter;                    
6104                         wxString PropertyData;
6105                         wxString PropertyName;
6106                         wxString PropertyValue;
6107                         wxString PropertyTokens;
6108                         bool FirstToken = TRUE;
6109                         int intSplitsFound = 0;
6110                         int intSplitSize = 0;
6111                         int intPrevValue = 7;
6112                         int intPref = 0;                        
6113                         int intType = 0;
6114                         int intSplitSeek = 0;
6115                         long ListCtrlIndex;
6116                         
6117                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
6118                         
6119                         intPrevValue = 6;
6120                         
6121                         // Look for type before continuing.                     
6122                         
6123                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6124                         intiter != SplitPoints.end(); ++intiter){
6125                         
6126                                 SLiter = SplitLength.find(intiter->first);
6127                         
6128                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6129                                 
6130                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6131                                 PropertyName = PropertyElement.GetNextToken();                          
6132                                 PropertyValue = PropertyElement.GetNextToken();
6133                                 
6134                                 intPrevValue = intiter->second;
6135                                 
6136                                 if (PropertyName == wxT("TYPE")){
6137                                 
6138                                         if (PropertyValue == wxT("work")){
6139                                         
6140                                                 intType = 2;                                    
6141                                         
6142                                         } else if (PropertyValue == wxT("home")){
6144                                                 intType = 1;
6145                                         
6146                                         } else {
6147                                         
6148                                                 intType = 0;
6149                                         
6150                                         }
6151                                 
6152                                 }
6153                         
6154                         }
6155                         
6156                         // Setup blank lines for later on.
6157                         
6158                         SoundsList.insert(std::make_pair(intValueSeek, ""));
6159                         SoundsListType.insert(std::make_pair(intValueSeek, wxT("")));
6160                         SoundsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
6161                         SoundsListPID.insert(std::make_pair(intValueSeek, wxT("")));
6162                         SoundsListPref.insert(std::make_pair(intValueSeek, 0));
6163                         SoundsListAudioEncType.insert(std::make_pair(intValueSeek, wxT("")));
6164                         SoundsListAudioType.insert(std::make_pair(intValueSeek, wxT("")));                      
6165                         SoundsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
6166                         SoundsListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
6168                         intPrevValue = 6;
6170                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6171                         intiter != SplitPoints.end(); ++intiter){
6172                         
6173                                 SLiter = SplitLength.find(intiter->first);
6174                         
6175                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6176                                 
6177                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6178                                 PropertyName = PropertyElement.GetNextToken();                          
6179                                 PropertyValue = PropertyElement.GetNextToken();
6180                                 
6181                                 intPrevValue = intiter->second;
6182                                 
6183                                 // Process properties.
6184                                 
6185                                 int intPropertyValueLen = PropertyValue.Len();                          
6186                                 
6187                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
6188                                         
6189                                         PropertyValue.Trim();
6190                                         PropertyValue.RemoveLast();
6191                                         
6192                                 }                               
6193                                 
6194                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
6195                                         
6196                                         PropertyValue.Remove(0, 1);
6197                                         
6198                                 }                       
6199                                 
6200                                 ProcessCaptureStrings(&PropertyValue);
6201                                 
6202                                 if (PropertyName == wxT("ALTID")){
6204                                         if (intType == 0){ SoundsListAltID.erase(intValueSeek); SoundsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
6205                                         else if (intType == 1){ SoundsListAltID.erase(intValueSeek); SoundsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
6206                                         else if (intType == 2){ SoundsListAltID.erase(intValueSeek); SoundsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
6207                                 
6208                                 } else if (PropertyName == wxT("PID")){
6210                                         if (intType == 0){ SoundsListPID.erase(intValueSeek); SoundsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
6211                                         else if (intType == 1){ SoundsListPID.erase(intValueSeek); SoundsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
6212                                         else if (intType == 2){ SoundsListPID.erase(intValueSeek); SoundsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
6213                                 
6214                                 } else if (PropertyName == wxT("PREF")){
6215                                         
6216                                         intPref = wxAtoi(PropertyValue);
6217                                 
6218                                         if (intType == 0){ SoundsListPref.erase(intValueSeek); SoundsListPref.insert(std::make_pair(intValueSeek, intPref)); }
6219                                         else if (intType == 1){ SoundsListPref.erase(intValueSeek); SoundsListPref.insert(std::make_pair(intValueSeek, intPref)); }
6220                                         else if (intType == 2){ SoundsListPref.erase(intValueSeek); SoundsListPref.insert(std::make_pair(intValueSeek, intPref)); }
6221                                 
6222                                 } else if (PropertyName == wxT("MEDIATYPE")){
6223                                 
6224                                         if (intType == 0){ SoundsListMediatype.erase(intValueSeek); SoundsListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
6225                                         else if (intType == 1){ SoundsListMediatype.erase(intValueSeek); SoundsListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
6226                                         else if (intType == 2){ SoundsListMediatype.erase(intValueSeek); SoundsListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
6227                                 
6228                                 } else {
6229                                 
6230                                         // Something else we don't know about so append
6231                                         // to the tokens variable.
6232                                         
6233                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
6234                                         
6235                                                 if (FirstToken == TRUE){
6236                                                 
6237                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
6238                                                         FirstToken = FALSE;
6239                                                 
6240                                                 } else {
6241                                                 
6242                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
6243                                                 
6244                                                 }
6245                                         
6246                                         }
6247                                 
6248                                 }
6249                         
6250                         }       
6251                         
6252                         intPropertyLen = wxSPropertySeg2.Len();
6253                         SplitPoints.clear();
6254                         SplitLength.clear();
6255                         intSplitsFound = 0;
6256                         intSplitSize = 0;
6257                         intPrevValue = 0;
6258                         
6259                         ProcessCaptureStrings(&wxSPropertySeg2);        
6260                         
6261                         for (int i = 0; i <= intPropertyLen; i++){
6262                 
6263                                 intSplitSize++;
6264                         
6265                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
6266                         
6267                                         intSplitsFound++;
6268                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
6269                                         
6270                                         if (intSplitsFound == 6){ 
6271                                         
6272                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
6273                                                 break; 
6274                                                 
6275                                         } else {
6276                                         
6277                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
6278                                         
6279                                         }
6280                                         
6281                                         intSplitSize = 0;                                       
6282                         
6283                                 }
6284                 
6285                         }
6286                         
6287                         wxString wxSSoundURI;
6288                         wxString wxSSoundMIME;
6289                         wxString wxSSoundEncoding;
6290                         wxString wxSSoundData;
6291                         std::string base64enc;
6292                         
6293                         if (intSplitsFound = 0){
6294                         
6295                         } else {
6296                         
6297                                 std::map<int, int>::iterator striter;
6298                         
6299                                 striter = SplitLength.find(1);
6300                         
6301                                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
6302                         
6303                                 while (wSTDataType.HasMoreTokens() == TRUE){
6304                                 
6305                                         wxSSoundURI = wSTDataType.GetNextToken();
6306                                         wxSSoundMIME = wSTDataType.GetNextToken();
6307                                         break;
6308                                 
6309                                 }                       
6310                         
6311                                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));                    
6312                         
6313                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
6314                                 
6315                                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
6316                                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
6317                                         base64enc = wxSSoundData.mb_str();
6318                                         break;
6319                                 
6320                                 }
6321                         
6322                         }
6323                         
6324                         // Add the data to the General/Home/Work address variables.
6325                         
6326                         wxListItem coldata;
6327                 
6328                         coldata.SetId(intValueSeek);
6329                         coldata.SetData(intValueSeek);
6330                         coldata.SetText(_("Sound"));
6331                         
6332                         ListCtrlIndex = lboSounds->InsertItem(coldata);
6333                                 
6334                         if (intPref > 0 && intPref < 101){
6335                                 
6336                                 lboSounds->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
6337                         
6338                         }
6339                                 
6340                         SoundsList.erase(intValueSeek);
6341                         SoundsListType.erase(intValueSeek);
6342                         SoundsListTokens.erase(intValueSeek);
6343                         SoundsListAudioType.erase(intValueSeek);
6344                         SoundsListAudioEncType.erase(intValueSeek);
6345                         SoundsList.insert(std::make_pair(intValueSeek, base64enc));
6346                         SoundsListAudioType.insert(std::make_pair(intValueSeek, wxSSoundMIME));
6347                         SoundsListAudioEncType.insert(std::make_pair(intValueSeek, wxSSoundEncoding));
6348                         
6349                         if (intType == 0){
6350                         
6351                                 SoundsListType.insert(std::make_pair(intValueSeek, wxT("")));
6352                         
6353                         } else if (intType == 1){
6354                         
6355                                 SoundsListType.insert(std::make_pair(intValueSeek, wxT("home")));
6356                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Home"));                 
6357                         
6358                         } else if (intType == 2){
6359                         
6360                                 SoundsListType.insert(std::make_pair(intValueSeek, wxT("work")));
6361                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Work"));
6362                         
6363                         }
6364                         
6365                         SoundsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
6366                         
6367                         SoundCount++;
6368                         intValueSeek++;
6369                         
6370                 } else if (wxSProperty == wxT("CALURI")){
6371                 
6372                         int intPropertyLen = wxSPropertySeg1.Len();
6373                         std::map<int, int> SplitPoints;
6374                         std::map<int, int> SplitLength;
6375                         std::map<int, int>::iterator SLiter;                    
6376                         wxString PropertyData;
6377                         wxString PropertyName;
6378                         wxString PropertyValue;
6379                         wxString PropertyTokens;
6380                         bool AfterFirstToken = FALSE;
6381                         bool FirstToken = TRUE;                 
6382                         int intSplitsFound = 0;
6383                         int intSplitSize = 0;
6384                         int intPrevValue = 8;
6385                         int intPref = 0;                        
6386                         int intType = 0;
6387                         int intSplitSeek = 0;
6388                         long ListCtrlIndex;
6389                         
6390                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
6391                         
6392                         intPrevValue = 7;
6393                         
6394                         // Look for type before continuing.
6395                         
6396                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6397                         intiter != SplitPoints.end(); ++intiter){
6398                         
6399                                 SLiter = SplitLength.find(intiter->first);
6400                         
6401                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6402                                 
6403                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6404                                 PropertyName = PropertyElement.GetNextToken();                          
6405                                 PropertyValue = PropertyElement.GetNextToken();
6406                                 
6407                                 intPrevValue = intiter->second;
6408                                 
6409                                 if (PropertyName == wxT("TYPE")){
6410                                 
6411                                         if (PropertyValue == wxT("work")){
6412                                         
6413                                                 intType = 2;                                    
6414                                         
6415                                         } else if (PropertyValue == wxT("home")){
6417                                                 intType = 1;
6418                                         
6419                                         } else {
6420                                         
6421                                                 intType = 0;
6422                                         
6423                                         }
6424                                 
6425                                 }
6426                         
6427                         }
6428                         
6429                         // Setup blank lines for later on.
6430                         
6431                         CalendarList.insert(std::make_pair(intValueSeek, wxT("")));
6432                         CalendarListAltID.insert(std::make_pair(intValueSeek, wxT("")));
6433                         CalendarListPID.insert(std::make_pair(intValueSeek, wxT("")));
6434                         CalendarListPref.insert(std::make_pair(intValueSeek, 0));
6435                         CalendarListTokens.insert(std::make_pair(intValueSeek, wxT("")));
6437                         intPrevValue = 6;
6438                         
6439                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6440                         intiter != SplitPoints.end(); ++intiter){
6441                         
6442                                 SLiter = SplitLength.find(intiter->first);
6443                         
6444                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6445                                 
6446                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6447                                 PropertyName = PropertyElement.GetNextToken();                          
6448                                 PropertyValue = PropertyElement.GetNextToken();
6449                                 
6450                                 intPrevValue = intiter->second;
6451                                 
6452                                 // Process properties.
6453                                 
6454                                 int intPropertyValueLen = PropertyValue.Len();                          
6455                                 
6456                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
6457                                         
6458                                         PropertyValue.Trim();
6459                                         PropertyValue.RemoveLast();
6460                                         
6461                                 }                               
6462                                 
6463                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
6464                                         
6465                                         PropertyValue.Remove(0, 1);
6466                                         
6467                                 }                               
6468                                 
6469                                 if (PropertyName == wxT("ALTID")){
6471                                         CalendarListAltID.erase(intValueSeek); CalendarListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
6472                                 
6473                                 } else if (PropertyName == wxT("PID")){
6475                                         CalendarListPID.erase(intValueSeek); CalendarListPID.insert(std::make_pair(intValueSeek, PropertyValue));
6476                                 
6477                                 } else if (PropertyName == wxT("PREF")){
6478                                         
6479                                         intPref = wxAtoi(PropertyValue);
6480                                 
6481                                         CalendarListPref.erase(intValueSeek); CalendarListPref.insert(std::make_pair(intValueSeek, intPref));
6482                                 
6483                                 } else if (PropertyName == wxT("MEDIATYPE")){
6484                                 
6485                                         CalendarListMediatype.erase(intValueSeek); CalendarListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
6486                                 
6487                                 } else {
6488                                 
6489                                         // Something else we don't know about so append
6490                                         // to the tokens variable.
6491                                 
6492                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
6493                                 
6494                                                 if (FirstToken == TRUE){
6495                                         
6496                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
6497                                                         FirstToken = FALSE;
6498                                         
6499                                                 } else {
6500                                         
6501                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
6502                                         
6503                                                 }
6504                                 
6505                                         }
6506                                 
6507                                 }
6508                         
6509                         }       
6510                         
6511                         // Add the data to the General/Home/Work address variables.
6512                         
6513                         wxListItem coldata;
6514                 
6515                         coldata.SetId(intValueSeek);
6516                         coldata.SetData(intValueSeek);
6517                         coldata.SetText(wxSPropertySeg2);
6519                         ListCtrlIndex = lboCalendarAddresses->InsertItem(coldata);
6520                                 
6521                         if (intPref > 0 && intPref < 101){
6522                                 
6523                                 lboCalendarAddresses->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
6524                                         
6525                         }
6526                         
6527                         CaptureString(&wxSPropertySeg2, FALSE);
6528                                 
6529                         CalendarList.erase(intValueSeek);
6530                         CalendarListType.erase(intValueSeek);
6531                         CalendarListTokens.erase(intValueSeek);
6532                         CalendarList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
6533                         
6534                         if (intType == 0){
6535                         
6536                                 CalendarListType.insert(std::make_pair(intValueSeek, wxT("")));                         
6537                         
6538                         } else if (intType == 1){
6539                         
6540                                 CalendarListType.insert(std::make_pair(intValueSeek, wxT("home")));
6541                                 lboCalendarAddresses->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
6542                         
6543                         } else if (intType == 2){
6544                         
6545                                 CalendarListType.insert(std::make_pair(intValueSeek, wxT("work")));
6546                                 lboCalendarAddresses->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
6547                         
6548                         }
6549                         
6550                         CalendarListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
6551                         
6552                         CalAdrCount++;
6553                         intValueSeek++;
6554                 
6555                 } else if (wxSProperty == wxT("CALADRURI")){
6556                 
6557                         int intPropertyLen = wxSPropertySeg1.Len();
6558                         std::map<int, int> SplitPoints;
6559                         std::map<int, int> SplitLength;
6560                         std::map<int, int>::iterator SLiter;                    
6561                         wxString PropertyData;
6562                         wxString PropertyName;
6563                         wxString PropertyValue;
6564                         wxString PropertyTokens;
6565                         bool AfterFirstToken = FALSE;
6566                         bool FirstToken = TRUE;                 
6567                         int intSplitsFound = 0;
6568                         int intSplitSize = 0;
6569                         int intPrevValue = 11;
6570                         int intPref = 0;                        
6571                         int intType = 0;
6572                         int intSplitSeek = 0;
6573                         long ListCtrlIndex;
6574                         
6575                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
6576                         
6577                         intPrevValue = 10;
6578                         
6579                         // Look for type before continuing.
6580                         
6581                         
6582                         
6583                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6584                         intiter != SplitPoints.end(); ++intiter){
6585                         
6586                                 SLiter = SplitLength.find(intiter->first);
6587                         
6588                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6589                                 
6590                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6591                                 PropertyName = PropertyElement.GetNextToken();                          
6592                                 PropertyValue = PropertyElement.GetNextToken();
6593                                 
6594                                 intPrevValue = intiter->second;
6595                                 
6596                                 if (PropertyName == wxT("TYPE")){
6597                                 
6598                                         if (PropertyValue == wxT("work")){
6599                                         
6600                                                 intType = 2;                                    
6601                                         
6602                                         } else if (PropertyValue == wxT("home")){
6604                                                 intType = 1;
6605                                         
6606                                         } else {
6607                                         
6608                                                 intType = 0;
6609                                         
6610                                         }
6611                                 
6612                                 }
6613                         
6614                         }
6615                         
6616                         // Setup blank lines for later on.
6617                         
6618                         CalendarRequestList.insert(std::make_pair(intValueSeek, wxT("")));
6619                         CalendarRequestListAltID.insert(std::make_pair(intValueSeek, wxT("")));
6620                         CalendarRequestListPID.insert(std::make_pair(intValueSeek, wxT("")));
6621                         CalendarRequestListPref.insert(std::make_pair(intValueSeek, 0));
6622                         CalendarRequestListTokens.insert(std::make_pair(intValueSeek, wxT("")));
6623                         
6624                         intPrevValue = 10;
6625                         
6626                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6627                         intiter != SplitPoints.end(); ++intiter){
6628                         
6629                                 SLiter = SplitLength.find(intiter->first);
6630                         
6631                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6632                                 
6633                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6634                                 PropertyName = PropertyElement.GetNextToken();                          
6635                                 PropertyValue = PropertyElement.GetNextToken();
6636                                 
6637                                 intPrevValue = intiter->second;
6638                                 
6639                                 // Process properties.
6640                                 
6641                                 int intPropertyValueLen = PropertyValue.Len();                          
6642                                 
6643                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
6644                                         
6645                                         PropertyValue.Trim();
6646                                         PropertyValue.RemoveLast();
6647                                         
6648                                 }                               
6649                                 
6650                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
6651                                         
6652                                         PropertyValue.Remove(0, 1);
6653                                         
6654                                 }                               
6655                                 
6656                                 if (PropertyName == wxT("ALTID")){
6658                                         CalendarRequestListAltID.erase(intValueSeek); CalendarRequestListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
6659                                 
6660                                 } else if (PropertyName == wxT("PID")){
6662                                         CalendarRequestListPID.erase(intValueSeek); CalendarRequestListPID.insert(std::make_pair(intValueSeek, PropertyValue));
6663                                 
6664                                 } else if (PropertyName == wxT("PREF")){
6665                                         
6666                                         intPref = wxAtoi(PropertyValue);
6667                                 
6668                                         CalendarRequestListPref.erase(intValueSeek); CalendarRequestListPref.insert(std::make_pair(intValueSeek, intPref));
6669                                 
6670                                 } else if (PropertyName == wxT("MEDIATYPE")){
6671                                 
6672                                         CalendarRequestListMediatype.erase(intValueSeek); CalendarRequestListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
6673                                 
6674                                 } else {
6675                                 
6676                                         // Something else we don't know about so append
6677                                         // to the tokens variable.
6678                                 
6679                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
6680                                 
6681                                                 if (FirstToken == TRUE){
6682                                         
6683                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
6684                                                         FirstToken = FALSE;
6685                                         
6686                                                 } else {
6687                                         
6688                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
6689                                         
6690                                                 }
6691                                 
6692                                         }
6693                                 
6694                                 }
6695                         
6696                         }       
6697                         
6698                         // Add the data to the General/Home/Work address variables.
6699                         
6700                         wxListItem coldata;
6701                 
6702                         coldata.SetId(intValueSeek);
6703                         coldata.SetData(intValueSeek);
6704                         coldata.SetText(wxSPropertySeg2);
6706                         ListCtrlIndex = lboCalendarRequestAddress->InsertItem(coldata);
6707                                 
6708                         if (intPref > 0 && intPref < 101){
6709                                 
6710                                 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
6711                                         
6712                         }
6713                                 
6714                         CaptureString(&wxSPropertySeg2, FALSE);                         
6715                                 
6716                         CalendarRequestList.erase(intValueSeek);
6717                         CalendarRequestListType.erase(intValueSeek);
6718                         CalendarRequestListTokens.erase(intValueSeek);
6719                         CalendarRequestList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));                      
6720                         
6721                         if (intType == 0){
6722                         
6723                                 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("")));                          
6724                         
6725                         } else if (intType == 1){
6726                         
6727                                 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("home")));
6728                                 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
6729                         
6730                         } else if (intType == 2){
6731                         
6732                                 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("work")));
6733                                 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
6734                         
6735                         }
6736                         
6737                         CalendarRequestListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
6738                         
6739                         CalReqAdrCount++;
6740                         intValueSeek++;
6741                 
6742                 } else if (wxSProperty == wxT("FBURL")){
6743                 
6744                         int intPropertyLen = wxSPropertySeg1.Len();
6745                         std::map<int, int> SplitPoints;
6746                         std::map<int, int> SplitLength;
6747                         std::map<int, int>::iterator SLiter;                    
6748                         wxString PropertyData;
6749                         wxString PropertyName;
6750                         wxString PropertyValue;
6751                         wxString PropertyTokens;
6752                         bool AfterFirstToken = FALSE;
6753                         bool FirstToken = TRUE;                 
6754                         int intSplitsFound = 0;
6755                         int intSplitSize = 0;
6756                         int intPrevValue = 7;
6757                         int intPref = 0;                        
6758                         int intType = 0;
6759                         int intSplitSeek = 0;
6760                         long ListCtrlIndex;
6761                         
6762                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
6763                         
6764                         intPrevValue = 6;
6765                         
6766                         // Look for type before continuing.
6767                         
6768                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6769                         intiter != SplitPoints.end(); ++intiter){
6770                         
6771                                 SLiter = SplitLength.find(intiter->first);
6772                         
6773                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6774                                 
6775                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6776                                 PropertyName = PropertyElement.GetNextToken();                          
6777                                 PropertyValue = PropertyElement.GetNextToken();
6778                                 
6779                                 intPrevValue = intiter->second;
6780                                 
6781                                 if (PropertyName == wxT("TYPE")){
6782                                 
6783                                         if (PropertyValue == wxT("work")){
6784                                         
6785                                                 intType = 2;                                    
6786                                         
6787                                         } else if (PropertyValue == wxT("home")){
6789                                                 intType = 1;
6790                                         
6791                                         } else {
6792                                         
6793                                                 intType = 0;
6794                                         
6795                                         }
6796                                 
6797                                 }
6798                         
6799                         }
6800                         
6801                         // Setup blank lines for later on.
6802                         
6803                         FreeBusyList.insert(std::make_pair(intValueSeek, wxT("")));
6804                         FreeBusyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
6805                         FreeBusyListPID.insert(std::make_pair(intValueSeek, wxT("")));
6806                         FreeBusyListPref.insert(std::make_pair(intValueSeek, 0));
6807                         FreeBusyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
6808                         
6809                         intPrevValue = 6;
6810                         
6811                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6812                         intiter != SplitPoints.end(); ++intiter){
6813                         
6814                                 SLiter = SplitLength.find(intiter->first);
6815                         
6816                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6817                                 
6818                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6819                                 PropertyName = PropertyElement.GetNextToken();                          
6820                                 PropertyValue = PropertyElement.GetNextToken();
6821                                 
6822                                 intPrevValue = intiter->second;
6823                                 
6824                                 // Process properties.
6825                                 
6826                                 int intPropertyValueLen = PropertyValue.Len();                          
6827                                 
6828                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
6829                                         
6830                                         PropertyValue.Trim();
6831                                         PropertyValue.RemoveLast();
6832                                         
6833                                 }                               
6834                                 
6835                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
6836                                         
6837                                         PropertyValue.Remove(0, 1);
6838                                         
6839                                 }                               
6840                                 
6841                                 if (PropertyName == wxT("ALTID")){
6843                                         FreeBusyListAltID.erase(intValueSeek); FreeBusyListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
6844                                 
6845                                 } else if (PropertyName == wxT("PID")){
6847                                         FreeBusyListPID.erase(intValueSeek); FreeBusyListPID.insert(std::make_pair(intValueSeek, PropertyValue));
6848                                 
6849                                 } else if (PropertyName == wxT("PREF")){
6850                                         
6851                                         intPref = wxAtoi(PropertyValue);
6852                                 
6853                                         FreeBusyListPref.erase(intValueSeek); FreeBusyListPref.insert(std::make_pair(intValueSeek, intPref));
6854                                 
6855                                 } else if (PropertyName == wxT("MEDIATYPE")){
6856                                 
6857                                         FreeBusyListMediatype.erase(intValueSeek); FreeBusyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
6858                                 
6859                                 } else {
6860                                 
6861                                         // Something else we don't know about so append
6862                                         // to the tokens variable.
6863                                 
6864                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
6865                                 
6866                                                 if (FirstToken == TRUE){
6867                                         
6868                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
6869                                                         FirstToken = FALSE;
6870                                         
6871                                                 } else {
6872                                         
6873                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
6874                                         
6875                                                 }
6876                                 
6877                                         }
6878                                 
6879                                 }
6880                         
6881                         }       
6882                         
6883                         // Add the data to the General/Home/Work address variables.
6884                         
6885                         wxListItem coldata;
6886                 
6887                         coldata.SetId(intValueSeek);
6888                         coldata.SetData(intValueSeek);
6889                         coldata.SetText(wxSPropertySeg2);
6891                         ListCtrlIndex = lboFreeBusyAddresses->InsertItem(coldata);
6892                                 
6893                         if (intPref > 0 && intPref < 101){
6894                                 
6895                                 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
6896                                         
6897                         }
6898                         
6899                         CaptureString(&wxSPropertySeg2, FALSE);                 
6900                                 
6901                         FreeBusyList.erase(intValueSeek);
6902                         FreeBusyListType.erase(intValueSeek);
6903                         FreeBusyListTokens.erase(intValueSeek);
6904                         FreeBusyList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
6905                         
6906                         if (intType == 0){
6907                         
6908                                 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("")));                         
6909                         
6910                         } else if (intType == 1){
6911                         
6912                                 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("home")));
6913                                 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
6914                         
6915                         } else if (intType == 2){
6916                         
6917                                 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("work")));
6918                                 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
6919                         
6920                         }
6921                         
6922                         FreeBusyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
6923                         
6924                         FreeBusyCount++;
6925                         intValueSeek++;
6926                 } else if (wxSProperty == wxT("KEY")){
6927                 
6928                         int intPropertyLen = wxSPropertySeg1.Len();
6929                         std::map<int, int> SplitPoints;
6930                         std::map<int, int> SplitLength;
6931                         std::map<int, int>::iterator SLiter;                    
6932                         wxString PropertyData;
6933                         wxString PropertyName;
6934                         wxString PropertyValue;
6935                         wxString PropertyTokens;
6936                         bool AfterFirstToken = FALSE;
6937                         bool FirstToken = TRUE;
6938                         int intSplitsFound = 0;
6939                         int intSplitSize = 0;
6940                         int intPrevValue = 5;
6941                         int intPref = 0;                        
6942                         int intType = 0;
6943                         int intSplitSeek = 0;
6944                         long ListCtrlIndex;
6945                         
6946                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
6947                         
6948                         intPrevValue = 4;
6949                         
6950                         // Look for type before continuing.
6951                         
6952                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6953                         intiter != SplitPoints.end(); ++intiter){
6954                         
6955                                 SLiter = SplitLength.find(intiter->first);
6956                         
6957                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
6958                                 
6959                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
6960                                 PropertyName = PropertyElement.GetNextToken();                          
6961                                 PropertyValue = PropertyElement.GetNextToken();
6962                                 
6963                                 intPrevValue = intiter->second;
6964                                 
6965                                 if (PropertyName == wxT("TYPE")){
6966                                 
6967                                         if (PropertyValue == wxT("work")){
6968                                         
6969                                                 intType = 2;                                    
6970                                         
6971                                         } else if (PropertyValue == wxT("home")){
6973                                                 intType = 1;
6974                                         
6975                                         } else {
6976                                         
6977                                                 intType = 0;
6978                                         
6979                                         }
6980                                 
6981                                 }
6982                         
6983                         }
6984                         
6985                         // Setup blank lines for later on.
6986                         
6987                         KeyList.insert(std::make_pair(intValueSeek, wxT("")));
6988                         KeyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
6989                         KeyListPID.insert(std::make_pair(intValueSeek, wxT("")));
6990                         KeyListPref.insert(std::make_pair(intValueSeek, 0));
6991                         KeyListKeyType.insert(std::make_pair(intValueSeek, FALSE));
6992                         KeyListDataType.insert(std::make_pair(intValueSeek, wxT("")));
6993                         KeyListDataEncType.insert(std::make_pair(intValueSeek, wxT("")));
6994                         KeyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
6996                         intPrevValue = 4;
6998                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
6999                         intiter != SplitPoints.end(); ++intiter){
7000                         
7001                                 SLiter = SplitLength.find(intiter->first);
7002                         
7003                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
7004                                 
7005                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
7006                                 PropertyName = PropertyElement.GetNextToken();                          
7007                                 PropertyValue = PropertyElement.GetNextToken();
7008                                 
7009                                 intPrevValue = intiter->second;
7010                                 
7011                                 // Process properties.
7012                                 
7013                                 int intPropertyValueLen = PropertyValue.Len();                          
7014                                 
7015                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
7016                                         
7017                                         PropertyValue.Trim();
7018                                         PropertyValue.RemoveLast();
7019                                         
7020                                 }                               
7021                                 
7022                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
7023                                         
7024                                         PropertyValue.Remove(0, 1);
7025                                         
7026                                 }                               
7027                                 
7028                                 if (PropertyName == wxT("ALTID")){
7030                                         KeyListAltID.erase(intValueSeek); KeyListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
7031                                 
7032                                 } else if (PropertyName == wxT("PID")){
7034                                         KeyListPID.erase(intValueSeek); KeyListPID.insert(std::make_pair(intValueSeek, PropertyValue));
7035                                 
7036                                 } else if (PropertyName == wxT("PREF")){
7037                                         
7038                                         intPref = wxAtoi(PropertyValue);
7039                                 
7040                                         KeyListPref.erase(intValueSeek); KeyListPref.insert(std::make_pair(intValueSeek, intPref));
7041                                 
7042                                 } else {
7043                                 
7044                                         // Something else we don't know about so append
7045                                         // to the tokens variable.
7046                                         
7047                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
7048                                         
7049                                                 if (FirstToken == TRUE){
7050                                                 
7051                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
7052                                                         FirstToken = FALSE;
7053                                                 
7054                                                 } else {
7055                                                 
7056                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
7057                                                 
7058                                                 }
7059                                         
7060                                         }
7061                                 
7062                                 }
7063                         
7064                         }                               
7065                         
7066                         intPropertyLen = wxSPropertySeg2.Len();
7067                         SplitPoints.clear();
7068                         SplitLength.clear();
7069                         intSplitsFound = 0;
7070                         intSplitSize = 0;
7071                         intPrevValue = 0;                       
7072                         
7073                         for (int i = 0; i <= intPropertyLen; i++){
7074                 
7075                                 intSplitSize++;
7076                         
7077                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
7078                         
7079                                         intSplitsFound++;
7080                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
7081                                         
7082                                         if (intSplitsFound == 6){ 
7083                                         
7084                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
7085                                                 break; 
7086                                                 
7087                                         } else {
7088                                         
7089                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
7090                                         
7091                                         }
7092                                         
7093                                         intSplitSize = 0;                                       
7094                         
7095                                 }
7096                 
7097                         }
7098                         
7099                         wxString wxSKeyURI;
7100                         wxString wxSKeyMIME;
7101                         wxString wxSKeyEncoding;
7102                         wxString wxSKeyData;
7103                         std::string base64enc;
7104                         
7105                         if (intSplitsFound = 0){
7106                         
7107                         } else {
7108                         
7109                                 std::map<int, int>::iterator striter;
7110                         
7111                                 striter = SplitLength.find(1);
7112                         
7113                                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
7114                         
7115                                 while (wSTDataType.HasMoreTokens() == TRUE){
7116                                 
7117                                         wxSKeyURI = wSTDataType.GetNextToken();
7118                                         wxSKeyMIME = wSTDataType.GetNextToken();
7119                                         break;
7120                                 
7121                                 }                       
7122                         
7123                                 if (wxSKeyURI == wxT("data")){
7124                                 
7125                                                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 2)), wxT(","));                    
7126                         
7127                                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
7128                                 
7129                                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
7130                                                 wxSKeyData = wSTDataInfo.GetNextToken();
7131                                                 break;
7132                                 
7133                                         }
7134                                 
7135                                 }
7136                         
7137                         }
7138                         
7139                         // Add the data to the General/Home/Work address variables.
7140                         
7141                         wxListItem coldata;
7142                 
7143                         coldata.SetId(intValueSeek);
7144                         coldata.SetData(intValueSeek);
7145                         
7146                         if (wxSKeyURI == wxT("data")){
7147                         
7148                                 if (wxSKeyMIME == wxT("application/pgp-keys")){
7149                         
7150                                         coldata.SetText(_("PGP Key"));
7151                                 
7152                                 } else {
7153                                 
7154                                         coldata.SetText(_("Key"));
7155                                 
7156                                 }
7157                                 
7158                                 KeyListDataEncType.erase(intValueSeek);
7159                                 KeyListKeyType.erase(intValueSeek);
7160                                 KeyListDataEncType.insert(std::make_pair(intValueSeek, wxSKeyEncoding));
7161                                 KeyListKeyType.insert(std::make_pair(intValueSeek, TRUE));
7162                                 
7163                                 KeyList.erase(intValueSeek);
7164                                 KeyList.insert(std::make_pair(intValueSeek, wxSKeyData));
7165                         
7166                         } else {
7167                         
7168                                 coldata.SetText(wxSPropertySeg2);
7169                                 
7170                                 KeyList.erase(intValueSeek);
7171                                 KeyList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
7172                         
7173                         }
7174                         
7175                         ListCtrlIndex = lboKeys->InsertItem(coldata);
7176                                 
7177                         if (intPref > 0 && intPref < 101){
7178                                 
7179                                 lboKeys->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
7180                         
7181                         }
7182                                 
7184                         KeyListType.erase(intValueSeek);
7185                         KeyListTokens.erase(intValueSeek);
7186                         KeyListDataType.erase(intValueSeek);
7188                         KeyListDataType.insert(std::make_pair(intValueSeek, wxSKeyMIME));
7189                                 
7190                         if (intType = 0){
7191                         
7192                                 KeyListType.insert(std::make_pair(intValueSeek, wxT("")));
7193                         
7194                         } else if (intType = 1){
7195                         
7196                                 KeyListType.insert(std::make_pair(intValueSeek, wxT("home")));
7197                         
7198                         } else if (intType = 2){
7199                         
7200                                 KeyListType.insert(std::make_pair(intValueSeek, wxT("work")));
7201                         
7202                         }
7203                         
7204                         KeyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
7205                         
7206                         KeyCount++;
7207                         intValueSeek++;
7208                 
7209                 } else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
7210                 
7211                         UIDToken = wxSPropertySeg2;
7212                         UIDProcessed = TRUE;
7213                 
7214                 } else if (wxSProperty.Mid(0, 3) == wxT("VND")){
7215                 
7216                         // Split the Vendor three ways.
7217                         
7218                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
7219                         
7220                         wxString wxSVNDID;
7221                         wxString wxSVNDPropName;
7222                         long ListCtrlIndex;                     
7224                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
7225                         
7226                                 wSTVendorDetails.GetNextToken();
7227                                 wxSVNDID = wSTVendorDetails.GetNextToken();
7228                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
7229                                 break;
7230                         
7231                         }
7232                         
7233                         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
7234                         
7235                                 // Setup the values for later processing.
7236                         
7237                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
7238                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
7239                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
7240                         
7241                                 // Add the data to the vendor variables.
7242                         
7243                                 wxListItem coldata;
7244                 
7245                                 coldata.SetId(intValueSeek);
7246                                 coldata.SetData(intValueSeek);
7247                                 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
7249                                 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
7250                                 
7251                                 VendorList.erase(intValueSeek);
7252                                 VendorListPEN.erase(intValueSeek);
7253                                 VendorListElement.erase(intValueSeek);
7254                         
7255                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
7256                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
7257                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));                         
7258                         
7259                                 VendorCount++;
7260                                 intValueSeek++;
7261                         
7262                         }       
7263                 
7264                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
7265                 
7266                         long ListCtrlIndex;
7267                         
7268                         XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
7269                         XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
7270                         
7271                         // Add to the form.
7272                         
7273                         wxListItem coldata;
7274                 
7275                         coldata.SetId(intValueSeek);
7276                         coldata.SetData(intValueSeek);
7277                         coldata.SetText(wxSPropertySeg1.Mid(2));
7279                         ListCtrlIndex = lboXToken->InsertItem(coldata);
7280                         
7281                         XTokenCount++;
7282                         intValueSeek++;
7283                         
7284                 
7285                 }
7286                 
7287                 // Reset the variables.
7288                 
7289                 QuoteMode = FALSE;
7290                 PropertyFind = TRUE;
7291                 ExtraLineSeek = TRUE;
7292                 ContactLineLen = 0;
7293                 QuoteBreakPoint = 0;
7294                 ContactLine.Clear();
7295                 wxSProperty.Clear();    
7296         
7297         }
7298         
7299         FMTimer.SetFilename(Filename);
7300         FMTimer.Start(10000, FALSE);
7301         
7302         EditMode = TRUE;
7303         
7304         return TRUE;
7307 void frmContactEditor::SplitValues(wxString *PropertyLine, 
7308         std::map<int,int> *SplitPoints, 
7309         std::map<int,int> *SplitLength, 
7310         int intSize){
7311         
7312         int intPropertyLen = PropertyLine->Len();               
7313         int intSplitsFound = 0;
7314         int intSplitSize = 0;
7315         int intSplitSeek = 0;
7316         
7317         for (int i = intSize; i <= intPropertyLen; i++){
7319                 intSplitSize++;
7320         
7321                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
7322                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
7323            
7324                     if (intSplitsFound == 0){
7325             
7326                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
7327           
7328                     } else {
7329            
7330                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
7331             
7332                     }
7333             
7334                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
7335             
7336                     intSplitsFound++;
7337                     intSplitSeek = i;
7338                     intSplitSize = 0;
7339             
7340                 }
7342         }
7344         if (intSplitsFound == 0){
7346                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
7347                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
7349         } else {
7351                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
7352                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
7354         }
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