Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented CATEGORIES with 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 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);
278                 
279         // Process the roles (ROLE).
280         
281         LoadData(&ContactEditorData.GeneralRoleList,
282                 &ContactEditorData.GeneralRoleListPref,
283                 lboRoles,
284                 &ContactEditorData.HomeRoleList,
285                 &ContactEditorData.HomeRoleListPref,
286                 lboHomeRoles,
287                 &ContactEditorData.BusinessRoleList,
288                 &ContactEditorData.BusinessRoleListPref,
289                 lboBusinessRoles,
290                 &RoleCount);
292         // Process the roles (ORG).
293         
294         LoadData(&ContactEditorData.GeneralOrganisationsList,
295                 &ContactEditorData.GeneralOrganisationsListPref,
296                 lboOrganisations,
297                 &ContactEditorData.HomeOrganisationsList,
298                 &ContactEditorData.HomeOrganisationsListPref,
299                 lboHomeOrganisations,
300                 &ContactEditorData.BusinessOrganisationsList,
301                 &ContactEditorData.BusinessOrganisationsListPref,
302                 lboBusinessOrganisations,
303                 &OrgCount);
304                 
305         // Process the notes (NOTE).
306                 
307         LoadData(&ContactEditorData.GeneralNoteList,
308                 &ContactEditorData.GeneralNoteListPref,
309                 lboNotes,
310                 &ContactEditorData.HomeNoteList,
311                 &ContactEditorData.HomeNoteListPref,
312                 lboHomeNotes,
313                 &ContactEditorData.BusinessNoteList,
314                 &ContactEditorData.BusinessNoteListPref,
315                 lboBusinessNotes,
316                 &NoteCount);
317                 
318         // Process the categories (CATEGORIES).
320         LoadData(&ContactEditorData.CategoriesList,
321                 &ContactEditorData.CategoriesListPref,
322                 lboCategories,
323                 &CategoryCount);
325         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
326          iter != ContactFileLines.end(); ++iter){
327         
328                 // Find the colon which splits the start bit from the data part.
329                 
330                 ContactLine = iter->second;
331                 
332                 while (ExtraLineSeek == TRUE){
333                 
334                         // Check if there is extra data on the next line 
335                         // (indicated by space or tab at the start) and add data.
336                 
337                         iter++;
338                         
339                         if (iter == ContactFileLines.end()){
340                         
341                                 iter--;
342                                 break;
343                         
344                         }                       
345                 
346                         wxSPropertyNextLine = iter->second;
347                         
348                 
349                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
350                 
351                                 wxSPropertyNextLine.Remove(0, 1);
352                                 //wxSPropertyNextLine.Trim(FALSE);
353                                 //ContactLine.Trim();
354                                 ContactLine.Append(wxSPropertyNextLine);
355                 
356                         } else {
357                         
358                                 iter--;
359                                 ExtraLineSeek = FALSE;
360                         
361                         }
362                 
363                 }
365                 ContactLineLen = ContactLine.Len();
366                 
367                 // Make sure we are not in quotation mode.
368                 // Make sure colon does not have \ or \\ before it.
369                 
370                 for (int i = 0; i <= ContactLineLen; i++){
371                 
372                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
373                         
374                                 PropertyFind = FALSE;
375                         
376                         } else if (PropertyFind == TRUE){
377                         
378                                 wxSProperty.Append(ContactLine.Mid(i, 1));
379                         
380                         }               
381                 
382                         if (ContactLine.Mid(i, 1) == wxT("\"")){
383                         
384                                 if (QuoteMode == TRUE){
385                                 
386                                         QuoteMode = FALSE;
387                                 
388                                 } else {
389                         
390                                         QuoteMode = TRUE;
391                                         
392                                 }
393                         
394                         }
395                         
396                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
397                         
398                                 QuoteBreakPoint = i;
399                                 break;
400                         
401                         }
402                 
403                 }
404                 
405                 // Split that line at the point into two variables (ignore the colon).
406                 
407                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
408                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
409                 
410                 // Add the data into the contact editor depending on what it is.                                
411                 
412                 if (wxSProperty == wxT("VERSION") && VersionProcessed == FALSE){
413                 
414                         // Check if version is 4.0, otherwise don't
415                         // load.
416                         
417                         if (wxSPropertySeg2 != wxT("4.0")){
418                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
419                                         _("Contact not supported"), wxICON_ERROR);
420                                 this->Close();
421                                 return FALSE;
422                         }
423                         
424                         VersionProcessed = TRUE;
425                 
426                 }/* if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
427                 
428                         // See frmContactEditor-LoadGroup.cpp
429                 
430                         LoadKind(wxSPropertySeg2);
431                 
432                 }/* else if (wxSProperty == wxT("MEMBER")){
434                         // See frmContactEditor-LoadGroup.cpp
436                         LoadMember(wxSPropertySeg2, &GroupCount);               
437                 
438                 }*/ else if (wxSProperty == wxT("FN")){
439                 
440                         // See frmContactEditor-LoadName.cpp
441                 
442                         LoadFN(wxSPropertySeg1, wxSPropertySeg2, &FNCount, &FNProcessed, &ContactData);
443                 
444                 }/* else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
445                 
446                         // See frmContactEditor-LoadName.cpp
447                 
448                         LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData);
449                 
450                 } else if (wxSProperty == wxT("NICKNAME")){
451                         
452                         // See frmContactEditor-LoadNickname.cpp
453                         
454                         LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData);
455                         
456                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
457                 
458                         // See frmContactEditor-LoadGender.cpp
459                 
460                         LoadGender(wxSPropertySeg1, wxSPropertySeg2, &GenderProcessed, &ContactData);
461                 
462                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
464                         // See frmContactEditor-LoadBADays.cpp
466                         LoadBDay(wxSPropertySeg1, wxSPropertySeg2, &BirthdayProcessed);
467                 
468                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
469                         
470                         // See frmContactEditor-LoadBADays.cpp
471                         
472                         LoadAnniversary(wxSPropertySeg1, wxSPropertySeg2, &AnniversaryProcessed);
473                 
474                 } else if (wxSProperty == wxT("TZ")){
475                 
476                         // See frmContactEditor-LoadTimeZone.cpp
477                 
478                         LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount);       
479                 
480                 }  else if (wxSProperty == wxT("ADR")){
481                         
482                         // See frmContactEditor-LoadAddress.cpp
483                 
484                         LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount);
485                 
486                 } else if (wxSProperty == wxT("EMAIL")){
487                 
488                         // See frmContactEditor-LoadEmail.cpp
489                         
490                         LoadEmail(wxSPropertySeg1, wxSPropertySeg2, &EmailCount);       
491                 
492                 }*/ else if (wxSProperty == wxT("IMPP")){
493                 
494                         // See frmContactEditor-LoadIM.cpp
495                 
496                         LoadIM(wxSPropertySeg1, wxSPropertySeg2, &IMPPCount);
497                 
498                 } else if (wxSProperty == wxT("TEL")){
499                 
500                         // See frmContactEditor-LoadTelephone.cpp
501                 
502                         LoadTelephone(wxSPropertySeg1, wxSPropertySeg2, &TelCount);
503                 
504                 }/* else if (wxSProperty == wxT("LANG")){
505                 
506                         // See frmContactEditor-LoadLanguage.cpp
507                         
508                         LoadLanguage(wxSPropertySeg1, wxSPropertySeg2, &LangCount);
509                 
510                 } else if (wxSProperty == wxT("GEO")){
511                 
512                         // See frmContactEditor-LoadGeo.cpp
513                         
514                         LoadGeo(wxSPropertySeg1, wxSPropertySeg2, &GeoCount);   
515                 
516                 }*/ else if (wxSProperty == wxT("RELATED")){
517                         
518                         // See fromContactEditor-LoadRelated.cpp
519                         
520                         LoadRelated(wxSPropertySeg1, wxSPropertySeg2, &RelatedCount);           
521                 
522                 }/* else if (wxSProperty == wxT("URL")){
524                         // See frmContactEditor-LoadURL.cpp
525                 
526                         LoadURL(wxSPropertySeg1, wxSPropertySeg2, &URLCount);
527                 
528                 } else if (wxSProperty == wxT("TITLE")) {
529                 
530                         // See frmContactEditor-LoadTitle.cpp
531                         
532                         LoadTitle(wxSPropertySeg1, wxSPropertySeg2, &TitleCount);
533                         
534                 } else if (wxSProperty == wxT("ROLE")) {
536                         // See frmContactEditor-LoadRole.cpp
537                 
538                         LoadRole(wxSPropertySeg1, wxSPropertySeg2, &RoleCount);
539                         
540                 } else if (wxSProperty == wxT("ORG")) {
541                 
542                         // See frmContactEditor-LoadOrg.cpp
543                         
544                         LoadOrg(wxSPropertySeg1, wxSPropertySeg2, &OrgCount);
545                         
546                 } else if (wxSProperty == wxT("NOTE")) {
548                         // See frmContactEditor-LoadNote.cpp
550                         LoadNote(wxSPropertySeg1, wxSPropertySeg2, &NoteCount); 
551                         
552                 } else if (wxSProperty == wxT("CATEGORIES")) {
553                 
554                         // See frmContactEditor-LoadCategory.cpp
555                 
556                         LoadCategory(wxSPropertySeg1, wxSPropertySeg2, &CategoryCount); 
557                         
558                 }*/ else if (wxSProperty == wxT("PHOTO")) {
559                 
560                         // See frmContactEditor-LoadPhoto.cpp
561                         
562                         LoadPhoto(wxSPropertySeg1, wxSPropertySeg2, &PhotoCount);
564                 } else if (wxSProperty == wxT("LOGO")) {
565                 
566                         // See frmContactEditor-LoadLogo.cpp
567                 
568                         LoadLogo(wxSPropertySeg1, wxSPropertySeg2, &LogoCount);
569                         
570                 } else if (wxSProperty == wxT("SOUND")) {
571                 
572                         // See frmContactEditor-LoadSound.cpp
573                         
574                         LoadSound(wxSPropertySeg1, wxSPropertySeg2, &SoundCount);
575                         
576                 } else if (wxSProperty == wxT("CALURI")){
578                         // See frmContactEditor-LoadCalendar.cpp
579                         
580                         LoadCalURI(wxSPropertySeg1, wxSPropertySeg2, &CalAdrCount);
581                 
582                 } else if (wxSProperty == wxT("CALADRURI")){
584                         // See frmContactEditor-LoadCalendar.cpp
585                         
586                         LoadCalAdrURI(wxSPropertySeg1, wxSPropertySeg2, &CalReqAdrCount);
587                 
588                 } else if (wxSProperty == wxT("FBURL")){
590                         // See frmContactEditor-LoadCalendar.cpp
592                         LoadCalFreeBusy(wxSPropertySeg1, wxSPropertySeg2, &FreeBusyCount);
594                 } else if (wxSProperty == wxT("KEY")){
595                 
596                         // See frmContactEditor-LoadKey.cpp
597                         
598                         LoadKey(wxSPropertySeg1, wxSPropertySeg2, &KeyCount);
599                 
600                 }/* else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
601                 
602                         UIDToken = wxSPropertySeg2;
603                         UIDProcessed = TRUE;
604                 
605                 }*/ else if (wxSProperty.Mid(0, 3) == wxT("VND")){
606                 
607                         // Split the Vendor three ways.
608                         
609                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
610                         
611                         wxString wxSVNDID;
612                         wxString wxSVNDPropName;
613                         long ListCtrlIndex;                     
615                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
616                         
617                                 wSTVendorDetails.GetNextToken();
618                                 wxSVNDID = wSTVendorDetails.GetNextToken();
619                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
620                                 break;
621                         
622                         }
623                         
624                         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
625                         
626                                 // Setup the values for later processing.
627                         
628                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
629                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
630                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
631                         
632                                 // Add the data to the vendor variables.
633                         
634                                 wxListItem coldata;
635                 
636                                 coldata.SetId(intValueSeek);
637                                 coldata.SetData(intValueSeek);
638                                 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
640                                 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
641                                 
642                                 VendorList.erase(intValueSeek);
643                                 VendorListPEN.erase(intValueSeek);
644                                 VendorListElement.erase(intValueSeek);
645                         
646                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
647                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
648                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));                         
649                         
650                                 VendorCount++;
651                                 intValueSeek++;
652                         
653                         }       
654                 
655                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
656                 
657                         long ListCtrlIndex;
658                         
659                         XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
660                         XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
661                         
662                         // Add to the form.
663                         
664                         wxListItem coldata;
665                 
666                         coldata.SetId(intValueSeek);
667                         coldata.SetData(intValueSeek);
668                         coldata.SetText(wxSPropertySeg1.Mid(2));
670                         ListCtrlIndex = lboXToken->InsertItem(coldata);
671                         
672                         XTokenCount++;
673                         intValueSeek++;
674                         
675                 
676                 }
677                 
678                 // Reset the variables.
679                 
680                 QuoteMode = FALSE;
681                 PropertyFind = TRUE;
682                 ExtraLineSeek = TRUE;
683                 ContactLineLen = 0;
684                 QuoteBreakPoint = 0;
685                 ContactLine.Clear();
686                 wxSProperty.Clear();    
687         
688         }
689         
690         FMTimer.SetFilename(Filename);
691         FMTimer.Start(10000, FALSE);
692         
693         EditMode = TRUE;
694         
695         return TRUE;
698 void frmContactEditor::SplitValues(wxString *PropertyLine, 
699         std::map<int,int> *SplitPoints, 
700         std::map<int,int> *SplitLength, 
701         int intSize){
702         
703         size_t intPropertyLen = PropertyLine->Len();
704         int intSplitsFound = 0;
705         int intSplitSize = 0;
706         int intSplitSeek = 0;
707         
708         for (int i = intSize; i <= intPropertyLen; i++){
710                 intSplitSize++;
711         
712                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
713                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
714            
715                     if (intSplitsFound == 0){
716             
717                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
718           
719                     } else {
720            
721                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
722             
723                     }
724             
725                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
726             
727                     intSplitsFound++;
728                     intSplitSeek = i;
729                     intSplitSize = 0;
730             
731                 }
733         }
735         if (intSplitsFound == 0){
737                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
738                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
740         } else {
742                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
743                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
745         }
749 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
750                 std::map<int, int> *GeneralListPref,
751                 wxListCtrl *GeneralListCtrl,
752                 std::map<int, wxString> *HomeList,
753                 std::map<int, int> *HomeListPref,
754                 wxListCtrl *HomeListCtrl,
755                 std::map<int, wxString> *BusinessList,
756                 std::map<int, int> *BusinessListPref,
757                 wxListCtrl *BusinessListCtrl,
758                 int *DataCount){
760         long ListCtrlIndex = -1;
762         // Deal with the general items.
763         
764         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
765                 Iter != GeneralList->end();
766                 Iter++){
767         
768                 wxListItem coldata;
770                 coldata.SetId(*DataCount);
771                 coldata.SetData(*DataCount);
772                 coldata.SetText(Iter->second);
773                 
774                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
776                 if (MapDataExists(DataCount, GeneralListPref)){
777                 
778                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
779                 
780                 }
781         
782                 (*DataCount)++;
783         
784         }
785         
786         // Deal with the home items.
787         
788         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
789                 Iter != HomeList->end();
790                 Iter++){
791         
792                 wxListItem coldata;
794                 coldata.SetId(*DataCount);
795                 coldata.SetData(*DataCount);
796                 coldata.SetText(Iter->second);
797                 
798                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
800                 if (MapDataExists(DataCount, HomeListPref)){
801                 
802                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
803                 
804                 }
805         
806                 (*DataCount)++;
807         
808         }
809         
810         // Deal with the work items.
811         
812         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
813                 Iter != BusinessList->end();
814                 Iter++){
815         
816                 wxListItem coldata;
818                 coldata.SetId(*DataCount);
819                 coldata.SetData(*DataCount);
820                 coldata.SetText(Iter->second);
821                 
822                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
823                                 
824                 if (MapDataExists(DataCount, BusinessListPref)){
825                 
826                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
827                 
828                 }
829         
830                 (*DataCount)++;
831         
832         }
836 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
837                 std::map<int,int> *ItemListPref,
838                 wxListCtrl *ItemCtrl,
839                 int *DataCount){
841         long ListCtrlIndex = -1;
843         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
844                 Iter != ItemList->end();
845                 Iter++){
846         
847                 wxListItem coldata;
849                 coldata.SetId(*DataCount);
850                 coldata.SetData(*DataCount);
851                 coldata.SetText(Iter->second);
852                 
853                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
854                                 
855                 if (MapDataExists(DataCount, ItemListPref)){
856                 
857                         ItemCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
858                 
859                 }
860         
861                 (*DataCount)++;
862         
863         }
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