Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented GEO and URL to use ContactDataObject.
[xestiaab/.git] / source / contacteditor / frmContactEditor-Load.cpp
1 // frmContactEditor-Load.cpp - frmContactEditor load contact subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <map>
21 #include <wx/ffile.h>
22 #include <wx/tokenzr.h>
23 #include <wx/datetime.h>
24 #include <wx/dir.h>
26 #include "frmContactEditor.h"
28 #include "../enums.h"
29 #include "../version.h"
30 #include "../vcard/vcard.h"
31 #include "../common/textprocessing.h"
32 #include "../common/dirs.h"
33 #include "cdo/ContactDataObject.h"
35 bool frmContactEditor::LoadContact(wxString Filename){
37         // Load the contact into the contact editor.
38         
39         wxFFile ContactFile;
40         wxString wxSContactString;
41         wxString ContactLine;
42         vCard ContactData;
43         XABViewMode XVMData;
44         if (StartupEditMode == FALSE){
45                 XVMData = MainPtr->GetViewMode();
46         }
47         
48         wxSContactFilename = Filename;
49         
50         // Check if we are using wxWidgets version 2.8 or less and
51         // execute the required command accordingly.
52         
53 #if wxABI_VERSION < 20900
54         ContactFile.Open(Filename.c_str(), wxT("r"));
55 #else
56         ContactFile.Open(Filename, wxT("r"));
57 #endif  
58         
59         if (ContactFile.IsOpened() == FALSE){
60         
61                 return FALSE;
62         
63         }
64         
65         ContactEditorData.LoadFile(Filename);
66         
67         ContactFile.ReadAll(&wxSContactString, wxConvAuto());
68         
69         // Split the lines.
70         
71         std::map<int, wxString> ContactFileLines;
72         std::map<int, wxString>::iterator striter;
73         
74         wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
76         int ContactLineSeek = 0;
78         while (wSTContactFileLines.HasMoreTokens() == TRUE){
80                 ContactLine = wSTContactFileLines.GetNextToken();
81                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
82                 ContactLineSeek++;              
83         
84         }
86         // Get the line.
88         bool QuoteMode = FALSE;
89         bool PropertyFind = TRUE;
90         bool HasExtraNicknames = FALSE;
91         bool IgnoreGender = FALSE;
92         bool ExtraLineSeek = TRUE;
93         //bool BirthdayProcessed = FALSE;
94         //bool AnniversaryProcessed = FALSE;
95         bool FNProcessed = FALSE;
96         bool GenderProcessed = FALSE;
97         bool NameProcessed = FALSE;
98         //bool UIDProcessed = FALSE;
99         //bool KindProcessed = FALSE;
100         bool ETagFound = FALSE;
101         bool ETagOrigFound = FALSE;
102         bool VersionProcessed = FALSE;
103         int intExtraNickname = 0;
104         wxString wxSProperty;
105         wxString wxSPropertySeg1;
106         wxString wxSPropertySeg2;
107         wxString wxSPropertyNextLine;
108         size_t ContactLineLen = 0;
109         int QuoteBreakPoint = 0;
110         int FNCount = 0;
111         int NameCount = 0;
112         int NicknameCount = 0;
113         int ADRCount = 0;
114         int EmailCount = 0;
115         int IMPPCount = 0;
116         int TelCount = 0;
117         int LangCount = 0;
118         int TZCount = 0;
119         int GeoCount = 0;
120         int URLCount = 0;
121         int RelatedCount = 0;
122         int TitleCount = 0;
123         int RoleCount = 0;
124         int OrgCount = 0;
125         int NoteCount = 0;
126         int CategoryCount = 0;
127         int GroupCount = 0;
128         int PhotoCount = 0;
129         int LogoCount = 0;
130         int SoundCount = 0;
131         int CalAdrCount = 0;
132         int CalReqAdrCount = 0;
133         int FreeBusyCount = 0;
134         int KeyCount = 0;
135         int VendorCount = 0;
136         int XTokenCount = 0;
137         //int intValueSeek = 1;
139         // Process the unique ID (UID)
140         
141         UIDToken = ContactEditorData.UIDToken;
143         // Process the contact type (KIND) (frmContactEditor-LoadGroup.cpp)
145         LoadKind(&ContactEditorData.ContactKind);
147         // Process the Birthday (BDAY) (frmContactEditor-LoadBADays.cpp)
148         
149         LoadBirthday(&ContactEditorData.Birthday, &ContactEditorData.BirthdayText);
151         // Process the Anniversary (ANNIVERSARY) (frmContactEditor-LoadBADays.cpp)
152         
153         LoadAnniversary(&ContactEditorData.Anniversary, &ContactEditorData.AnniversaryText);
155         // Process the Gender (GENDER) (frmContactEditor-LoadGender.cpp)
156         
157         LoadGender(&ContactEditorData.Gender, &ContactEditorData.GenderDetails);
158         
159         // Process the Name (N) (frmContactEditor-LoadName.cpp)
160         
161         LoadName(&ContactEditorData.NameTitle, &ContactEditorData.NameForename,
162                 &ContactEditorData.NameSurname, &ContactEditorData.NameOtherNames,
163                 &ContactEditorData.NameSuffix);
164                 
165         // Process the group members (MEMBER) (frmContactEditor-LoadGroup.cpp)
166                 
167         LoadMember(&ContactEditorData.GroupsList);
169         // Process the addresses (ADR) (frmContactEditor-LoadAddress.cpp)
170         
171         LoadAddress(&ContactEditorData.GeneralAddressList,
172                 &ContactEditorData.GeneralAddressListTown,
173                 &ContactEditorData.GeneralAddressListCounty,
174                 &ContactEditorData.GeneralAddressListPostCode,
175                 &ContactEditorData.GeneralAddressListPref,
176                 &ContactEditorData.HomeAddressList,
177                 &ContactEditorData.HomeAddressListTown,
178                 &ContactEditorData.HomeAddressListCounty,
179                 &ContactEditorData.HomeAddressListPostCode,
180                 &ContactEditorData.HomeAddressListPref,
181                 &ContactEditorData.BusinessAddressList,
182                 &ContactEditorData.BusinessAddressListTown,
183                 &ContactEditorData.BusinessAddressListCounty,
184                 &ContactEditorData.BusinessAddressListPostCode,
185                 &ContactEditorData.BusinessAddressListPref,
186                 &ADRCount);
188         // Process the timezones (TZ).
189         
190         LoadData(&ContactEditorData.GeneralTZList,
191                 &ContactEditorData.GeneralTZListPref,
192                 lboTimezones,
193                 &ContactEditorData.HomeTZList,
194                 &ContactEditorData.HomeTZListPref,
195                 lboHomeTimezones,
196                 &ContactEditorData.BusinessTZList,
197                 &ContactEditorData.BusinessTZListPref,
198                 lboBusinessTimezones,
199                 &TZCount);
200                 
201         // Process the emails (EMAIL).
202         
203         LoadData(&ContactEditorData.GeneralEmailList,
204                 &ContactEditorData.GeneralEmailListPref,
205                 lboEmails,
206                 &ContactEditorData.HomeEmailList,
207                 &ContactEditorData.HomeEmailListPref,
208                 lboHomeEmails,
209                 &ContactEditorData.BusinessEmailList,
210                 &ContactEditorData.BusinessEmailListPref,
211                 lboBusinessEmail,
212                 &EmailCount);
214         // Process the nicknames (NICKNAME).
215         
216         LoadData(&ContactEditorData.GeneralNicknamesList,
217                 &ContactEditorData.GeneralNicknamesListPref,
218                 lboNicknames,
219                 &ContactEditorData.HomeNicknamesList,
220                 &ContactEditorData.HomeNicknamesListPref,
221                 lboHomeNicknames,
222                 &ContactEditorData.BusinessNicknamesList,
223                 &ContactEditorData.BusinessNicknamesListPref,
224                 lboBusinessNicknames,
225                 &NicknameCount);
226                 
227         // Process the languages (LANG).
228         
229         LoadData(&ContactEditorData.GeneralLanguageList,
230                 &ContactEditorData.GeneralLanguageListPref,
231                 lboLanguages,
232                 &ContactEditorData.HomeLanguageList,
233                 &ContactEditorData.HomeLanguageListPref,
234                 lboHomeLanguages,
235                 &ContactEditorData.BusinessLanguageList,
236                 &ContactEditorData.BusinessLanguageListPref,
237                 lboBusinessLanguages,
238                 &LangCount);
239                 
240         // Process the geoposition (GEO).
241         
242         LoadData(&ContactEditorData.GeneralGeographyList,
243                 &ContactEditorData.GeneralGeographyListPref,
244                 lboGeoposition,
245                 &ContactEditorData.HomeGeographyList,
246                 &ContactEditorData.HomeGeographyListPref,
247                 lboHomeGeoposition,
248                 &ContactEditorData.BusinessGeographyList,
249                 &ContactEditorData.BusinessGeographyListPref,
250                 lboBusinessGeoposition,
251                 &GeoCount);
252                 
253         // Process the website (URL).
254         
255         LoadData(&ContactEditorData.GeneralWebsiteList,
256                 &ContactEditorData.GeneralWebsiteListPref,
257                 lboWebsites,
258                 &ContactEditorData.HomeWebsiteList,
259                 &ContactEditorData.HomeWebsiteListPref,
260                 lboHomeWebsites,
261                 &ContactEditorData.BusinessWebsiteList,
262                 &ContactEditorData.BusinessWebsiteListPref,
263                 lboBusinessWebsites,
264                 &URLCount);
266         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
267          iter != ContactFileLines.end(); ++iter){
268         
269                 // Find the colon which splits the start bit from the data part.
270                 
271                 ContactLine = iter->second;
272                 
273                 while (ExtraLineSeek == TRUE){
274                 
275                         // Check if there is extra data on the next line 
276                         // (indicated by space or tab at the start) and add data.
277                 
278                         iter++;
279                         
280                         if (iter == ContactFileLines.end()){
281                         
282                                 iter--;
283                                 break;
284                         
285                         }                       
286                 
287                         wxSPropertyNextLine = iter->second;
288                         
289                 
290                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
291                 
292                                 wxSPropertyNextLine.Remove(0, 1);
293                                 //wxSPropertyNextLine.Trim(FALSE);
294                                 //ContactLine.Trim();
295                                 ContactLine.Append(wxSPropertyNextLine);
296                 
297                         } else {
298                         
299                                 iter--;
300                                 ExtraLineSeek = FALSE;
301                         
302                         }
303                 
304                 }
306                 ContactLineLen = ContactLine.Len();
307                 
308                 // Make sure we are not in quotation mode.
309                 // Make sure colon does not have \ or \\ before it.
310                 
311                 for (int i = 0; i <= ContactLineLen; i++){
312                 
313                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
314                         
315                                 PropertyFind = FALSE;
316                         
317                         } else if (PropertyFind == TRUE){
318                         
319                                 wxSProperty.Append(ContactLine.Mid(i, 1));
320                         
321                         }               
322                 
323                         if (ContactLine.Mid(i, 1) == wxT("\"")){
324                         
325                                 if (QuoteMode == TRUE){
326                                 
327                                         QuoteMode = FALSE;
328                                 
329                                 } else {
330                         
331                                         QuoteMode = TRUE;
332                                         
333                                 }
334                         
335                         }
336                         
337                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
338                         
339                                 QuoteBreakPoint = i;
340                                 break;
341                         
342                         }
343                 
344                 }
345                 
346                 // Split that line at the point into two variables (ignore the colon).
347                 
348                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
349                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
350                 
351                 // Add the data into the contact editor depending on what it is.                                
352                 
353                 if (wxSProperty == wxT("VERSION") && VersionProcessed == FALSE){
354                 
355                         // Check if version is 4.0, otherwise don't
356                         // load.
357                         
358                         if (wxSPropertySeg2 != wxT("4.0")){
359                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
360                                         _("Contact not supported"), wxICON_ERROR);
361                                 this->Close();
362                                 return FALSE;
363                         }
364                         
365                         VersionProcessed = TRUE;
366                 
367                 }/* if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
368                 
369                         // See frmContactEditor-LoadGroup.cpp
370                 
371                         LoadKind(wxSPropertySeg2);
372                 
373                 }/* else if (wxSProperty == wxT("MEMBER")){
375                         // See frmContactEditor-LoadGroup.cpp
377                         LoadMember(wxSPropertySeg2, &GroupCount);               
378                 
379                 }*/ else if (wxSProperty == wxT("FN")){
380                 
381                         // See frmContactEditor-LoadName.cpp
382                 
383                         LoadFN(wxSPropertySeg1, wxSPropertySeg2, &FNCount, &FNProcessed, &ContactData);
384                 
385                 }/* else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
386                 
387                         // See frmContactEditor-LoadName.cpp
388                 
389                         LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData);
390                 
391                 } else if (wxSProperty == wxT("NICKNAME")){
392                         
393                         // See frmContactEditor-LoadNickname.cpp
394                         
395                         LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData);
396                         
397                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
398                 
399                         // See frmContactEditor-LoadGender.cpp
400                 
401                         LoadGender(wxSPropertySeg1, wxSPropertySeg2, &GenderProcessed, &ContactData);
402                 
403                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
405                         // See frmContactEditor-LoadBADays.cpp
407                         LoadBDay(wxSPropertySeg1, wxSPropertySeg2, &BirthdayProcessed);
408                 
409                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
410                         
411                         // See frmContactEditor-LoadBADays.cpp
412                         
413                         LoadAnniversary(wxSPropertySeg1, wxSPropertySeg2, &AnniversaryProcessed);
414                 
415                 } else if (wxSProperty == wxT("TZ")){
416                 
417                         // See frmContactEditor-LoadTimeZone.cpp
418                 
419                         LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount);       
420                 
421                 }  else if (wxSProperty == wxT("ADR")){
422                         
423                         // See frmContactEditor-LoadAddress.cpp
424                 
425                         LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount);
426                 
427                 } else if (wxSProperty == wxT("EMAIL")){
428                 
429                         // See frmContactEditor-LoadEmail.cpp
430                         
431                         LoadEmail(wxSPropertySeg1, wxSPropertySeg2, &EmailCount);       
432                 
433                 }*/ else if (wxSProperty == wxT("IMPP")){
434                 
435                         // See frmContactEditor-LoadIM.cpp
436                 
437                         LoadIM(wxSPropertySeg1, wxSPropertySeg2, &IMPPCount);
438                 
439                 } else if (wxSProperty == wxT("TEL")){
440                 
441                         // See frmContactEditor-LoadTelephone.cpp
442                 
443                         LoadTelephone(wxSPropertySeg1, wxSPropertySeg2, &TelCount);
444                 
445                 }/* else if (wxSProperty == wxT("LANG")){
446                 
447                         // See frmContactEditor-LoadLanguage.cpp
448                         
449                         LoadLanguage(wxSPropertySeg1, wxSPropertySeg2, &LangCount);
450                 
451                 } else if (wxSProperty == wxT("GEO")){
452                 
453                         // See frmContactEditor-LoadGeo.cpp
454                         
455                         LoadGeo(wxSPropertySeg1, wxSPropertySeg2, &GeoCount);   
456                 
457                 }*/ else if (wxSProperty == wxT("RELATED")){
458                         
459                         // See fromContactEditor-LoadRelated.cpp
460                         
461                         LoadRelated(wxSPropertySeg1, wxSPropertySeg2, &RelatedCount);           
462                 
463                 }/* else if (wxSProperty == wxT("URL")){
465                         // See frmContactEditor-LoadURL.cpp
466                 
467                         LoadURL(wxSPropertySeg1, wxSPropertySeg2, &URLCount);
468                 
469                 }*/ else if (wxSProperty == wxT("TITLE")) {
470                 
471                         // See frmContactEditor-LoadTitle.cpp
472                         
473                         LoadTitle(wxSPropertySeg1, wxSPropertySeg2, &TitleCount);
474                         
475                 } else if (wxSProperty == wxT("ROLE")) {
477                         // See frmContactEditor-LoadRole.cpp
478                 
479                         LoadRole(wxSPropertySeg1, wxSPropertySeg2, &RoleCount);
480                         
481                 } else if (wxSProperty == wxT("ORG")) {
482                 
483                         // See frmContactEditor-LoadOrg.cpp
484                         
485                         LoadOrg(wxSPropertySeg1, wxSPropertySeg2, &OrgCount);
486                         
487                 } else if (wxSProperty == wxT("NOTE")) {
489                         // See frmContactEditor-LoadNote.cpp
491                         LoadNote(wxSPropertySeg1, wxSPropertySeg2, &NoteCount); 
492                         
493                 } else if (wxSProperty == wxT("CATEGORIES")) {
494                 
495                         // See frmContactEditor-LoadCategory.cpp
496                 
497                         LoadCategory(wxSPropertySeg1, wxSPropertySeg2, &CategoryCount); 
498                         
499                 } else if (wxSProperty == wxT("PHOTO")) {
500                 
501                         // See frmContactEditor-LoadPhoto.cpp
502                         
503                         LoadPhoto(wxSPropertySeg1, wxSPropertySeg2, &PhotoCount);
505                 } else if (wxSProperty == wxT("LOGO")) {
506                 
507                         // See frmContactEditor-LoadLogo.cpp
508                 
509                         LoadLogo(wxSPropertySeg1, wxSPropertySeg2, &LogoCount);
510                         
511                 } else if (wxSProperty == wxT("SOUND")) {
512                 
513                         // See frmContactEditor-LoadSound.cpp
514                         
515                         LoadSound(wxSPropertySeg1, wxSPropertySeg2, &SoundCount);
516                         
517                 } else if (wxSProperty == wxT("CALURI")){
519                         // See frmContactEditor-LoadCalendar.cpp
520                         
521                         LoadCalURI(wxSPropertySeg1, wxSPropertySeg2, &CalAdrCount);
522                 
523                 } else if (wxSProperty == wxT("CALADRURI")){
525                         // See frmContactEditor-LoadCalendar.cpp
526                         
527                         LoadCalAdrURI(wxSPropertySeg1, wxSPropertySeg2, &CalReqAdrCount);
528                 
529                 } else if (wxSProperty == wxT("FBURL")){
531                         // See frmContactEditor-LoadCalendar.cpp
533                         LoadCalFreeBusy(wxSPropertySeg1, wxSPropertySeg2, &FreeBusyCount);
535                 } else if (wxSProperty == wxT("KEY")){
536                 
537                         // See frmContactEditor-LoadKey.cpp
538                         
539                         LoadKey(wxSPropertySeg1, wxSPropertySeg2, &KeyCount);
540                 
541                 }/* else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
542                 
543                         UIDToken = wxSPropertySeg2;
544                         UIDProcessed = TRUE;
545                 
546                 }*/ else if (wxSProperty.Mid(0, 3) == wxT("VND")){
547                 
548                         // Split the Vendor three ways.
549                         
550                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
551                         
552                         wxString wxSVNDID;
553                         wxString wxSVNDPropName;
554                         long ListCtrlIndex;                     
556                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
557                         
558                                 wSTVendorDetails.GetNextToken();
559                                 wxSVNDID = wSTVendorDetails.GetNextToken();
560                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
561                                 break;
562                         
563                         }
564                         
565                         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
566                         
567                                 // Setup the values for later processing.
568                         
569                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
570                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
571                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
572                         
573                                 // Add the data to the vendor variables.
574                         
575                                 wxListItem coldata;
576                 
577                                 coldata.SetId(intValueSeek);
578                                 coldata.SetData(intValueSeek);
579                                 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
581                                 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
582                                 
583                                 VendorList.erase(intValueSeek);
584                                 VendorListPEN.erase(intValueSeek);
585                                 VendorListElement.erase(intValueSeek);
586                         
587                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
588                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
589                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));                         
590                         
591                                 VendorCount++;
592                                 intValueSeek++;
593                         
594                         }       
595                 
596                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
597                 
598                         long ListCtrlIndex;
599                         
600                         XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
601                         XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
602                         
603                         // Add to the form.
604                         
605                         wxListItem coldata;
606                 
607                         coldata.SetId(intValueSeek);
608                         coldata.SetData(intValueSeek);
609                         coldata.SetText(wxSPropertySeg1.Mid(2));
611                         ListCtrlIndex = lboXToken->InsertItem(coldata);
612                         
613                         XTokenCount++;
614                         intValueSeek++;
615                         
616                 
617                 }
618                 
619                 // Reset the variables.
620                 
621                 QuoteMode = FALSE;
622                 PropertyFind = TRUE;
623                 ExtraLineSeek = TRUE;
624                 ContactLineLen = 0;
625                 QuoteBreakPoint = 0;
626                 ContactLine.Clear();
627                 wxSProperty.Clear();    
628         
629         }
630         
631         FMTimer.SetFilename(Filename);
632         FMTimer.Start(10000, FALSE);
633         
634         EditMode = TRUE;
635         
636         return TRUE;
639 void frmContactEditor::SplitValues(wxString *PropertyLine, 
640         std::map<int,int> *SplitPoints, 
641         std::map<int,int> *SplitLength, 
642         int intSize){
643         
644         size_t intPropertyLen = PropertyLine->Len();
645         int intSplitsFound = 0;
646         int intSplitSize = 0;
647         int intSplitSeek = 0;
648         
649         for (int i = intSize; i <= intPropertyLen; i++){
651                 intSplitSize++;
652         
653                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
654                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
655            
656                     if (intSplitsFound == 0){
657             
658                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
659           
660                     } else {
661            
662                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
663             
664                     }
665             
666                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
667             
668                     intSplitsFound++;
669                     intSplitSeek = i;
670                     intSplitSize = 0;
671             
672                 }
674         }
676         if (intSplitsFound == 0){
678                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
679                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
681         } else {
683                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
684                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
686         }
690 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
691                 std::map<int, int> *GeneralListPref,
692                 wxListCtrl *GeneralListCtrl,
693                 std::map<int, wxString> *HomeList,
694                 std::map<int, int> *HomeListPref,
695                 wxListCtrl *HomeListCtrl,
696                 std::map<int, wxString> *BusinessList,
697                 std::map<int, int> *BusinessListPref,
698                 wxListCtrl *BusinessListCtrl,
699                 int *DataCount){
701         long ListCtrlIndex = -1;
703         // Deal with the general addresses.
704         
705         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
706                 Iter != GeneralList->end();
707                 Iter++){
708         
709                 wxListItem coldata;
711                 coldata.SetId(*DataCount);
712                 coldata.SetData(*DataCount);
713                 coldata.SetText(Iter->second);
714                 
715                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
717                 if (MapDataExists(DataCount, GeneralListPref)){
718                 
719                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
720                 
721                 }
722         
723                 (*DataCount)++;
724         
725         }
726         
727         // Deal with the home addresses.
728         
729         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
730                 Iter != HomeList->end();
731                 Iter++){
732         
733                 wxListItem coldata;
735                 coldata.SetId(*DataCount);
736                 coldata.SetData(*DataCount);
737                 coldata.SetText(Iter->second);
738                 
739                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
741                 if (MapDataExists(DataCount, HomeListPref)){
742                 
743                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
744                 
745                 }
746         
747                 (*DataCount)++;
748         
749         }
750         
751         // Deal with the work addresses.
752         
753         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
754                 Iter != BusinessList->end();
755                 Iter++){
756         
757                 wxListItem coldata;
759                 coldata.SetId(*DataCount);
760                 coldata.SetData(*DataCount);
761                 coldata.SetText(Iter->second);
762                 
763                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
764                                 
765                 if (MapDataExists(DataCount, BusinessListPref)){
766                 
767                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
768                 
769                 }
770         
771                 (*DataCount)++;
772         
773         }
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