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