Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
7e35538f97ca691d3cee32cf4707d683e1c8be8e
[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 geopositiosn (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 websites (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         // Process the titles (TITLE).
267         
268         LoadData(&ContactEditorData.GeneralTitleList,
269                 &ContactEditorData.GeneralTitleListPref,
270                 lboTitles,
271                 &ContactEditorData.HomeTitleList,
272                 &ContactEditorData.HomeTitleListPref,
273                 lboHomeTitles,
274                 &ContactEditorData.BusinessTitleList,
275                 &ContactEditorData.BusinessTitleListPref,
276                 lboBusinessTitles,
277                 &TitleCount);
279         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
280          iter != ContactFileLines.end(); ++iter){
281         
282                 // Find the colon which splits the start bit from the data part.
283                 
284                 ContactLine = iter->second;
285                 
286                 while (ExtraLineSeek == TRUE){
287                 
288                         // Check if there is extra data on the next line 
289                         // (indicated by space or tab at the start) and add data.
290                 
291                         iter++;
292                         
293                         if (iter == ContactFileLines.end()){
294                         
295                                 iter--;
296                                 break;
297                         
298                         }                       
299                 
300                         wxSPropertyNextLine = iter->second;
301                         
302                 
303                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
304                 
305                                 wxSPropertyNextLine.Remove(0, 1);
306                                 //wxSPropertyNextLine.Trim(FALSE);
307                                 //ContactLine.Trim();
308                                 ContactLine.Append(wxSPropertyNextLine);
309                 
310                         } else {
311                         
312                                 iter--;
313                                 ExtraLineSeek = FALSE;
314                         
315                         }
316                 
317                 }
319                 ContactLineLen = ContactLine.Len();
320                 
321                 // Make sure we are not in quotation mode.
322                 // Make sure colon does not have \ or \\ before it.
323                 
324                 for (int i = 0; i <= ContactLineLen; i++){
325                 
326                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
327                         
328                                 PropertyFind = FALSE;
329                         
330                         } else if (PropertyFind == TRUE){
331                         
332                                 wxSProperty.Append(ContactLine.Mid(i, 1));
333                         
334                         }               
335                 
336                         if (ContactLine.Mid(i, 1) == wxT("\"")){
337                         
338                                 if (QuoteMode == TRUE){
339                                 
340                                         QuoteMode = FALSE;
341                                 
342                                 } else {
343                         
344                                         QuoteMode = TRUE;
345                                         
346                                 }
347                         
348                         }
349                         
350                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
351                         
352                                 QuoteBreakPoint = i;
353                                 break;
354                         
355                         }
356                 
357                 }
358                 
359                 // Split that line at the point into two variables (ignore the colon).
360                 
361                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
362                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
363                 
364                 // Add the data into the contact editor depending on what it is.                                
365                 
366                 if (wxSProperty == wxT("VERSION") && VersionProcessed == FALSE){
367                 
368                         // Check if version is 4.0, otherwise don't
369                         // load.
370                         
371                         if (wxSPropertySeg2 != wxT("4.0")){
372                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
373                                         _("Contact not supported"), wxICON_ERROR);
374                                 this->Close();
375                                 return FALSE;
376                         }
377                         
378                         VersionProcessed = TRUE;
379                 
380                 }/* if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
381                 
382                         // See frmContactEditor-LoadGroup.cpp
383                 
384                         LoadKind(wxSPropertySeg2);
385                 
386                 }/* else if (wxSProperty == wxT("MEMBER")){
388                         // See frmContactEditor-LoadGroup.cpp
390                         LoadMember(wxSPropertySeg2, &GroupCount);               
391                 
392                 }*/ else if (wxSProperty == wxT("FN")){
393                 
394                         // See frmContactEditor-LoadName.cpp
395                 
396                         LoadFN(wxSPropertySeg1, wxSPropertySeg2, &FNCount, &FNProcessed, &ContactData);
397                 
398                 }/* else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
399                 
400                         // See frmContactEditor-LoadName.cpp
401                 
402                         LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData);
403                 
404                 } else if (wxSProperty == wxT("NICKNAME")){
405                         
406                         // See frmContactEditor-LoadNickname.cpp
407                         
408                         LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData);
409                         
410                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
411                 
412                         // See frmContactEditor-LoadGender.cpp
413                 
414                         LoadGender(wxSPropertySeg1, wxSPropertySeg2, &GenderProcessed, &ContactData);
415                 
416                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
418                         // See frmContactEditor-LoadBADays.cpp
420                         LoadBDay(wxSPropertySeg1, wxSPropertySeg2, &BirthdayProcessed);
421                 
422                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
423                         
424                         // See frmContactEditor-LoadBADays.cpp
425                         
426                         LoadAnniversary(wxSPropertySeg1, wxSPropertySeg2, &AnniversaryProcessed);
427                 
428                 } else if (wxSProperty == wxT("TZ")){
429                 
430                         // See frmContactEditor-LoadTimeZone.cpp
431                 
432                         LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount);       
433                 
434                 }  else if (wxSProperty == wxT("ADR")){
435                         
436                         // See frmContactEditor-LoadAddress.cpp
437                 
438                         LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount);
439                 
440                 } else if (wxSProperty == wxT("EMAIL")){
441                 
442                         // See frmContactEditor-LoadEmail.cpp
443                         
444                         LoadEmail(wxSPropertySeg1, wxSPropertySeg2, &EmailCount);       
445                 
446                 }*/ else if (wxSProperty == wxT("IMPP")){
447                 
448                         // See frmContactEditor-LoadIM.cpp
449                 
450                         LoadIM(wxSPropertySeg1, wxSPropertySeg2, &IMPPCount);
451                 
452                 } else if (wxSProperty == wxT("TEL")){
453                 
454                         // See frmContactEditor-LoadTelephone.cpp
455                 
456                         LoadTelephone(wxSPropertySeg1, wxSPropertySeg2, &TelCount);
457                 
458                 }/* else if (wxSProperty == wxT("LANG")){
459                 
460                         // See frmContactEditor-LoadLanguage.cpp
461                         
462                         LoadLanguage(wxSPropertySeg1, wxSPropertySeg2, &LangCount);
463                 
464                 } else if (wxSProperty == wxT("GEO")){
465                 
466                         // See frmContactEditor-LoadGeo.cpp
467                         
468                         LoadGeo(wxSPropertySeg1, wxSPropertySeg2, &GeoCount);   
469                 
470                 }*/ else if (wxSProperty == wxT("RELATED")){
471                         
472                         // See fromContactEditor-LoadRelated.cpp
473                         
474                         LoadRelated(wxSPropertySeg1, wxSPropertySeg2, &RelatedCount);           
475                 
476                 }/* else if (wxSProperty == wxT("URL")){
478                         // See frmContactEditor-LoadURL.cpp
479                 
480                         LoadURL(wxSPropertySeg1, wxSPropertySeg2, &URLCount);
481                 
482                 } else if (wxSProperty == wxT("TITLE")) {
483                 
484                         // See frmContactEditor-LoadTitle.cpp
485                         
486                         LoadTitle(wxSPropertySeg1, wxSPropertySeg2, &TitleCount);
487                         
488                 }*/ else if (wxSProperty == wxT("ROLE")) {
490                         // See frmContactEditor-LoadRole.cpp
491                 
492                         LoadRole(wxSPropertySeg1, wxSPropertySeg2, &RoleCount);
493                         
494                 } else if (wxSProperty == wxT("ORG")) {
495                 
496                         // See frmContactEditor-LoadOrg.cpp
497                         
498                         LoadOrg(wxSPropertySeg1, wxSPropertySeg2, &OrgCount);
499                         
500                 } else if (wxSProperty == wxT("NOTE")) {
502                         // See frmContactEditor-LoadNote.cpp
504                         LoadNote(wxSPropertySeg1, wxSPropertySeg2, &NoteCount); 
505                         
506                 } else if (wxSProperty == wxT("CATEGORIES")) {
507                 
508                         // See frmContactEditor-LoadCategory.cpp
509                 
510                         LoadCategory(wxSPropertySeg1, wxSPropertySeg2, &CategoryCount); 
511                         
512                 } else if (wxSProperty == wxT("PHOTO")) {
513                 
514                         // See frmContactEditor-LoadPhoto.cpp
515                         
516                         LoadPhoto(wxSPropertySeg1, wxSPropertySeg2, &PhotoCount);
518                 } else if (wxSProperty == wxT("LOGO")) {
519                 
520                         // See frmContactEditor-LoadLogo.cpp
521                 
522                         LoadLogo(wxSPropertySeg1, wxSPropertySeg2, &LogoCount);
523                         
524                 } else if (wxSProperty == wxT("SOUND")) {
525                 
526                         // See frmContactEditor-LoadSound.cpp
527                         
528                         LoadSound(wxSPropertySeg1, wxSPropertySeg2, &SoundCount);
529                         
530                 } else if (wxSProperty == wxT("CALURI")){
532                         // See frmContactEditor-LoadCalendar.cpp
533                         
534                         LoadCalURI(wxSPropertySeg1, wxSPropertySeg2, &CalAdrCount);
535                 
536                 } else if (wxSProperty == wxT("CALADRURI")){
538                         // See frmContactEditor-LoadCalendar.cpp
539                         
540                         LoadCalAdrURI(wxSPropertySeg1, wxSPropertySeg2, &CalReqAdrCount);
541                 
542                 } else if (wxSProperty == wxT("FBURL")){
544                         // See frmContactEditor-LoadCalendar.cpp
546                         LoadCalFreeBusy(wxSPropertySeg1, wxSPropertySeg2, &FreeBusyCount);
548                 } else if (wxSProperty == wxT("KEY")){
549                 
550                         // See frmContactEditor-LoadKey.cpp
551                         
552                         LoadKey(wxSPropertySeg1, wxSPropertySeg2, &KeyCount);
553                 
554                 }/* else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
555                 
556                         UIDToken = wxSPropertySeg2;
557                         UIDProcessed = TRUE;
558                 
559                 }*/ else if (wxSProperty.Mid(0, 3) == wxT("VND")){
560                 
561                         // Split the Vendor three ways.
562                         
563                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
564                         
565                         wxString wxSVNDID;
566                         wxString wxSVNDPropName;
567                         long ListCtrlIndex;                     
569                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
570                         
571                                 wSTVendorDetails.GetNextToken();
572                                 wxSVNDID = wSTVendorDetails.GetNextToken();
573                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
574                                 break;
575                         
576                         }
577                         
578                         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
579                         
580                                 // Setup the values for later processing.
581                         
582                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
583                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
584                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
585                         
586                                 // Add the data to the vendor variables.
587                         
588                                 wxListItem coldata;
589                 
590                                 coldata.SetId(intValueSeek);
591                                 coldata.SetData(intValueSeek);
592                                 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
594                                 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
595                                 
596                                 VendorList.erase(intValueSeek);
597                                 VendorListPEN.erase(intValueSeek);
598                                 VendorListElement.erase(intValueSeek);
599                         
600                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
601                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
602                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));                         
603                         
604                                 VendorCount++;
605                                 intValueSeek++;
606                         
607                         }       
608                 
609                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
610                 
611                         long ListCtrlIndex;
612                         
613                         XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
614                         XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
615                         
616                         // Add to the form.
617                         
618                         wxListItem coldata;
619                 
620                         coldata.SetId(intValueSeek);
621                         coldata.SetData(intValueSeek);
622                         coldata.SetText(wxSPropertySeg1.Mid(2));
624                         ListCtrlIndex = lboXToken->InsertItem(coldata);
625                         
626                         XTokenCount++;
627                         intValueSeek++;
628                         
629                 
630                 }
631                 
632                 // Reset the variables.
633                 
634                 QuoteMode = FALSE;
635                 PropertyFind = TRUE;
636                 ExtraLineSeek = TRUE;
637                 ContactLineLen = 0;
638                 QuoteBreakPoint = 0;
639                 ContactLine.Clear();
640                 wxSProperty.Clear();    
641         
642         }
643         
644         FMTimer.SetFilename(Filename);
645         FMTimer.Start(10000, FALSE);
646         
647         EditMode = TRUE;
648         
649         return TRUE;
652 void frmContactEditor::SplitValues(wxString *PropertyLine, 
653         std::map<int,int> *SplitPoints, 
654         std::map<int,int> *SplitLength, 
655         int intSize){
656         
657         size_t intPropertyLen = PropertyLine->Len();
658         int intSplitsFound = 0;
659         int intSplitSize = 0;
660         int intSplitSeek = 0;
661         
662         for (int i = intSize; i <= intPropertyLen; i++){
664                 intSplitSize++;
665         
666                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
667                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
668            
669                     if (intSplitsFound == 0){
670             
671                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
672           
673                     } else {
674            
675                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
676             
677                     }
678             
679                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
680             
681                     intSplitsFound++;
682                     intSplitSeek = i;
683                     intSplitSize = 0;
684             
685                 }
687         }
689         if (intSplitsFound == 0){
691                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
692                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
694         } else {
696                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
697                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
699         }
703 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
704                 std::map<int, int> *GeneralListPref,
705                 wxListCtrl *GeneralListCtrl,
706                 std::map<int, wxString> *HomeList,
707                 std::map<int, int> *HomeListPref,
708                 wxListCtrl *HomeListCtrl,
709                 std::map<int, wxString> *BusinessList,
710                 std::map<int, int> *BusinessListPref,
711                 wxListCtrl *BusinessListCtrl,
712                 int *DataCount){
714         long ListCtrlIndex = -1;
716         // Deal with the general addresses.
717         
718         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
719                 Iter != GeneralList->end();
720                 Iter++){
721         
722                 wxListItem coldata;
724                 coldata.SetId(*DataCount);
725                 coldata.SetData(*DataCount);
726                 coldata.SetText(Iter->second);
727                 
728                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
730                 if (MapDataExists(DataCount, GeneralListPref)){
731                 
732                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
733                 
734                 }
735         
736                 (*DataCount)++;
737         
738         }
739         
740         // Deal with the home addresses.
741         
742         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
743                 Iter != HomeList->end();
744                 Iter++){
745         
746                 wxListItem coldata;
748                 coldata.SetId(*DataCount);
749                 coldata.SetData(*DataCount);
750                 coldata.SetText(Iter->second);
751                 
752                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
754                 if (MapDataExists(DataCount, HomeListPref)){
755                 
756                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
757                 
758                 }
759         
760                 (*DataCount)++;
761         
762         }
763         
764         // Deal with the work addresses.
765         
766         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
767                 Iter != BusinessList->end();
768                 Iter++){
769         
770                 wxListItem coldata;
772                 coldata.SetId(*DataCount);
773                 coldata.SetData(*DataCount);
774                 coldata.SetText(Iter->second);
775                 
776                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
777                                 
778                 if (MapDataExists(DataCount, BusinessListPref)){
779                 
780                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
781                 
782                 }
783         
784                 (*DataCount)++;
785         
786         }
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