Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
7ff2d76e101df628777cf73d3f56da1261300566
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
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 "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
22         
23         if (!wxFileExists(Filename)){
24         
25                 return CONTACTLOAD_FILEMISSING;
26         
27         }
28         
29         wxFile ContactFile;
30         
31         if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
32         
33                 return CONTACTLOAD_FILEERROR;
34         
35         }
36         
37         // Check that the vCard is a valid vCard 4.0 file.
39         vCard vCard4FormatCheck;
40         
41         vCard4FormatCheck.LoadFile(Filename);
42         
43         if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
44         
45                 return CONTACTLOAD_FILEINVALIDFORMAT;
46         
47         }
49         // Check that the vCard meets the base specification.
50         
51         if (!vCard4FormatCheck.MeetBaseSpecification()){
52         
53                 return CONTACTLOAD_FILEBASESPECFAIL;
54         
55         }
56         
57         wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
58         
59         std::map<int, wxString> ContactFileLines;
61         int ContactLineSeek = 0;
63         while (wSTContactFileLines.HasMoreTokens() == TRUE){
65                 wxString ContactLine = wSTContactFileLines.GetNextToken();
66                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
67                 ContactLineSeek++;              
68         
69         }
70         
71         wxString wxSPropertyNextLine;
72         
73         bool ExtraLineSeek = TRUE;
74         bool QuoteMode = FALSE;
75         bool PropertyFind = TRUE;
76         bool KindProcessed = FALSE;
77         bool NameProcessed = FALSE;
78         int ContactLineLen = 0;
79         int QuoteBreakPoint = 0;
80         int GroupCount = 0;
81         int FNCount = 0;
82         int NicknameCount = 0;
83         wxString ContactLine;
84         wxString PropertyLine;
85         wxString PropertySeg1;
86         wxString PropertySeg2;
87         wxString PropertyNextLine;
88         wxString Property;
89         
90         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
91          iter != ContactFileLines.end(); ++iter){
93                 ExtraLineSeek = TRUE;
94                 QuoteMode = FALSE;
95                 PropertyFind = TRUE;
96                 ContactLineLen = 0;
97                 QuoteBreakPoint = 0;
98                 ContactLine.Clear();
99                 PropertyLine.Clear();
100                 PropertySeg1.Clear();
101                 PropertySeg2.Clear();
102                 Property.Clear();
103          
104                 ContactLine = iter->second;
105                 
106                 while (ExtraLineSeek == TRUE){
107                 
108                         // Check if there is extra data on the next line 
109                         // (indicated by space or tab at the start) and add data.
110                 
111                         iter++;
112                         
113                         if (iter == ContactFileLines.end()){
114                         
115                                 iter--;
116                                 break;
117                         
118                         }                       
119                 
120                         PropertyNextLine = iter->second;
121                 
122                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
123                 
124                                 PropertyNextLine.Remove(0, 1);
125                                 ContactLine.Append(PropertyNextLine);
126                 
127                         } else {
128                         
129                                 iter--;
130                                 ExtraLineSeek = FALSE;
131                         
132                         }
133                 
134                 }
136                 ContactLineLen = ContactLine.Len();
137                 
138                 // Make sure we are not in quotation mode.
139                 // Make sure colon does not have \ or \\ before it.
140                 
141                 for (int i = 0; i <= ContactLineLen; i++){
142                 
143                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
144                         
145                                 PropertyFind = FALSE;
146                         
147                         } else if (PropertyFind == TRUE){
148                         
149                                 Property.Append(ContactLine.Mid(i, 1));
150                         
151                         }               
152                 
153                         if (ContactLine.Mid(i, 1) == wxT("\"")){
154                         
155                                 if (QuoteMode == TRUE){
156                                 
157                                         QuoteMode = FALSE;
158                                 
159                                 } else {
160                         
161                                         QuoteMode = TRUE;
162                                         
163                                 }
164                         
165                         }
166                         
167                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
168                         
169                                 QuoteBreakPoint = i;
170                                 break;
171                         
172                         }
173                 
174                 }
175                 
176                 // Split that line at the point into two variables (ignore the colon).
177                 
178                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
179                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
180                 
181                  if (Property == wxT("KIND") && KindProcessed == FALSE){
182                                 
183                         ProcessKind(PropertySeg2);
184                 
185                 } else if (Property == wxT("MEMBER")){
187                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
188                         GroupCount++;   
189                 
190                 } else if (Property == wxT("FN")){
191                 
192                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
193                         FNCount++;
194                 
195                 } else if (Property == wxT("N") && NameProcessed == FALSE){
196                 
197                         ProcessN(PropertySeg1, PropertySeg2);
198                         NameProcessed = TRUE;
199                 
200                 } else if (Property == wxT("NICKNAME")){
201                                                 
202                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
203                         NicknameCount++;
204                         
205                 }
206                 
207         }
208         
209         return CONTACTLOAD_OK;
213 void ContactDataObject::ProcessKind(wxString KindType){
215         if (KindType == wxT("individual")){
216                         
217                 ContactKind = CONTACTKIND_INDIVIDUAL;
218                         
219         } else if (KindType == wxT("group")){
220                         
221                 ContactKind = CONTACTKIND_GROUP;
222                         
223         } else if (KindType == wxT("org")){
224                         
225                 ContactKind = CONTACTKIND_ORGANISATION;
226                         
227         } else if (KindType == wxT("location")){
228                         
229                 ContactKind = CONTACTKIND_LOCATION;
230                         
231         } else {
232                         
233                 ContactKind = CONTACTKIND_NONE;                 
234         }
238 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
240         std::map<int, int> SplitPoints;
241         std::map<int, int> SplitLength;
243         int intPrevValue = 8;
244         int intPref = 0;                        
245         int intType = 0;
246         
247         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
249         intPrevValue = 7;
250         
251         wxString PropertyName;
252         wxString PropertyValue;
253         wxString PropertyData;
254         wxString PropertyTokens;
255         std::map<int,int>::iterator SLiter;
256         bool FirstToken = TRUE;
257         
258         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
259         intiter != SplitPoints.end(); ++intiter){
260         
261                 SLiter = SplitLength.find(intiter->first);
262         
263                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
264                 
265                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
266                 PropertyName = PropertyElement.GetNextToken();                          
267                 PropertyValue = PropertyElement.GetNextToken();
268                 
269                 intPrevValue = intiter->second;
270                 
271                 CaptureString(&PropertyValue, FALSE);
272         
273                 if (PropertyName == wxT("ALTID")){
275                         GroupsListAltID.erase(*GroupCount);
276                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
277                 
278                 } else if (PropertyName == wxT("PID")){
280                         GroupsListPID.erase(*GroupCount);
281                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
282                 
283                 } else if (PropertyName == wxT("PREF")){
285                         int PriorityNumber = 0;
286                         bool ValidNumber = TRUE;
287                         
288                         try{
289                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
290                         }
291                         
292                         catch(std::invalid_argument &e){
293                                 ValidNumber = FALSE;
294                         }
296                         if (ValidNumber == TRUE){
298                                 GroupsListPref.erase(*GroupCount);
299                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
300                 
301                         }
302                 
303                 } else if (PropertyName == wxT("MEDIATYPE")){
305                         GroupsListMediaType.erase(*GroupCount);
306                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
307                 
308                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
309                         
310                         if (FirstToken == TRUE){
311                                 
312                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
313                                 FirstToken = FALSE;
314                                 
315                         } else {
316                         
317                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
318                                 
319                         }
320                         
321                 }
322                 
323         }
325         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
327         if (!PropertyTokens.IsEmpty()){
328         
329                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
330         
331         }
336 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
338         std::map<int, int> SplitPoints;
339         std::map<int, int> SplitLength;
341         int intPrevValue = 4;
342         int intPref = 0;                        
343         int intType = 0;
344         
345         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
347         intPrevValue = 3;
348         
349         wxString PropertyName;
350         wxString PropertyValue;
351         wxString PropertyData;
352         wxString PropertyTokens;
353         std::map<int,int>::iterator SLiter;
354         bool FirstToken = TRUE;
355         
356         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
357         intiter != SplitPoints.end(); ++intiter){
358         
359                 SLiter = SplitLength.find(intiter->first);
360         
361                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
362                 
363                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
364                 PropertyName = PropertyElement.GetNextToken();                          
365                 PropertyValue = PropertyElement.GetNextToken();
366                 
367                 intPrevValue = intiter->second;
368                 
369                 CaptureString(&PropertyValue, FALSE);
370                 
371                 if (PropertyName == wxT("TYPE")){
373                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
374                                 PropertyValue == wxT("work") ){
376                                 FullNamesListType.erase(*FNCount);
377                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
378                 
379                         }
380                 
381                 } else if (PropertyName == wxT("LANGUAGE")){
383                         FullNamesListLanguage.erase(*FNCount);
384                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
385                 
386                 } else if (PropertyName == wxT("ALTID")){
387                 
388                         FullNamesListAltID.erase(*FNCount);
389                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
390                 
391                 } else if (PropertyName == wxT("PID")){
393                         FullNamesListPID.erase(*FNCount);
394                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
395                 
396                 } else if (PropertyName == wxT("PREF")){
398                         int PriorityNumber = 0;
399                         bool ValidNumber = TRUE;
400                         
401                         try{
402                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
403                         }
404                         
405                         catch(std::invalid_argument &e){
406                                 ValidNumber = FALSE;
407                         }
409                         if (ValidNumber == TRUE){
411                                 FullNamesListPref.erase(*FNCount);
412                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
414                         }
415                 
416                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
417                         
418                         if (FirstToken == TRUE){
419                                 
420                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
421                                 FirstToken = FALSE;
422                                 
423                         } else {
424                         
425                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
426                                 
427                         }
428                         
429                 } 
430         
431         }
433         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
435         if (!PropertyTokens.IsEmpty()){
436         
437                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
438         
439         }
443 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
445         std::map<int, int> SplitPoints;
446         std::map<int, int> SplitLength;
448         int intPrevValue = 3;
449         int intPref = 0;                        
450         int intType = 0;
451         
452         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
453         
454         intPrevValue = 2;
455         
456         wxString PropertyName;
457         wxString PropertyValue;
458         wxString PropertyData;
459         wxString PropertyTokens;
460         std::map<int,int>::iterator SLiter;
461         bool FirstToken = TRUE;
462         
463         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
464         intiter != SplitPoints.end(); ++intiter){
465         
466                 SLiter = SplitLength.find(intiter->first);
467         
468                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
469                 
470                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
471                 PropertyName = PropertyElement.GetNextToken();                          
472                 PropertyValue = PropertyElement.GetNextToken();
473                 
474                 intPrevValue = intiter->second;
475                 
476                 CaptureString(&PropertyValue, FALSE);
477                 
478                 if (PropertyName == wxT("ALTID")){
480                         NameAltID = PropertyValue;
481                 
482                 } else if (PropertyName == wxT("LANGUAGE")){
483                 
484                         NameLanguage = PropertyValue;
485                 
486                 } else if (PropertyName == wxT("SORT-AS")){
487                 
488                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
489                                 PropertyValue.Len() >= 3){
490                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
491                         }
492                 
493                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
494                         
495                         if (FirstToken == TRUE){
496                                 
497                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
498                                 FirstToken = FALSE;
499                                 
500                         } else {
501                         
502                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
503                                 
504                         }
505                         
506                 }
507         
508         }
509         
510         // Split the name data.
511         
512         int intSplitSeek = 0;           
513         int intSplitsFound = 0;
514         int intSplitSize = 0;
515         int intPropertyLen = PropertySeg2.Len();
516         
517         std::map<int,wxString> NameValues;
518         intPrevValue = 0;                                       
519         
520         for (int i = 0; i <= intPropertyLen; i++){
521         
522                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
523                         
524                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
525                         
526                         intSplitSeek = i;
527                         intSplitSeek++;
528                         
529                         if (intSplitsFound == 4){
530                         
531                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
532                                 break;
533                         
534                         }
535                         
536                         intSplitSize = 0;
537                         continue;
538         
539                 }
540                 
541                 intSplitSize++;
543         }
544         
545         // Split the data into several parts.
546                         
547         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
548         iter != NameValues.end(); ++iter){
549         
550                 if (iter->first == 1){
551                 
552                         // Deal with family name.
553                         
554                         NameSurname = iter->second;
555                 
556                 } else if (iter->first == 2){
557                 
558                         // Deal with given names.
559                         
560                         NameForename = iter->second;
561                 
562                 } else if (iter->first == 3){
563                 
564                         // Deal with additional names.
565                         
566                         NameOtherNames = iter->second;
567                 
568                 } else if (iter->first == 4){
569                 
570                         // Deal with honorifix prefixes and suffixes.
572                         NameTitle = iter->second;
573                 
574                         iter++;
575                         
576                         if (iter == NameValues.end()){
577                         
578                                 break;
579                         
580                         }
581                 
582                         NameSuffix = iter->second;
583                 
584                 }
585         
586         }
587         
588         // Add the name token data.
589         
590         if (!PropertyTokens.IsEmpty()){
591         
592                 NameTokens = PropertyTokens;
593         
594         }
598 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
600         std::map<int, int> SplitPoints;
601         std::map<int, int> SplitLength;
603         int intPrevValue = 10;
604         int intPref = 0;                        
605         
606         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
607         
608         intPrevValue = 9;
609         
610         PropertyType PropType;
611         
612         // Look for type before continuing.
613         
614         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
615         
616         intPrevValue = 9;
617         
618         std::map<int, wxString> *NicknamesList = NULL;
619         std::map<int, wxString> *NicknamesListType = NULL;
620         std::map<int, wxString> *NicknamesListLanguage = NULL;
621         std::map<int, wxString> *NicknamesListAltID = NULL;
622         std::map<int, wxString> *NicknamesListPID = NULL;
623         std::map<int, wxString> *NicknamesListTokens = NULL;            
624         std::map<int, int> *NicknamesListPref = NULL;
625         
626         switch(PropType){
627                 case PROPERTY_NONE:
628                         NicknamesList = &GeneralNicknamesList;
629                         NicknamesListType = &GeneralNicknamesListType;
630                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
631                         NicknamesListAltID = &GeneralNicknamesListAltID;
632                         NicknamesListPID = &GeneralNicknamesListPID;
633                         NicknamesListTokens = &GeneralNicknamesListTokens;
634                         NicknamesListPref = &GeneralNicknamesListPref;
635                         break;
636                 case PROPERTY_HOME:
637                         NicknamesList = &HomeNicknamesList;
638                         NicknamesListType = &HomeNicknamesListType;
639                         NicknamesListLanguage = &HomeNicknamesListLanguage;
640                         NicknamesListAltID = &HomeNicknamesListAltID;
641                         NicknamesListPID = &HomeNicknamesListPID;
642                         NicknamesListTokens = &HomeNicknamesListTokens;
643                         NicknamesListPref = &HomeNicknamesListPref;
644                         break;
645                 case PROPERTY_WORK:
646                         NicknamesList = &BusinessNicknamesList;
647                         NicknamesListType = &BusinessNicknamesListType;
648                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
649                         NicknamesListAltID = &BusinessNicknamesListAltID;
650                         NicknamesListPID = &BusinessNicknamesListPID;
651                         NicknamesListTokens = &BusinessNicknamesListTokens;
652                         NicknamesListPref = &BusinessNicknamesListPref;
653                         break;
654         }
655         
656         std::map<int, int>::iterator SLiter;    
657         wxString PropertyData;
658         wxString PropertyName;
659         wxString PropertyValue;
660         wxString PropertyTokens;
661         bool FirstToken = TRUE;
662         
663         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
664         intiter != SplitPoints.end(); ++intiter){
665         
666                 SLiter = SplitLength.find(intiter->first);
667         
668                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
669                 
670                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
671                 PropertyName = PropertyElement.GetNextToken();                          
672                 PropertyValue = PropertyElement.GetNextToken();
673                 
674                 intPrevValue = intiter->second;
675                 
676                 CaptureString(&PropertyValue, FALSE);
677                 
678                 if (PropertyName == wxT("ALTID")){
680                         NicknamesListAltID->erase(*NicknameCount);
681                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
682                 
683                 } else if (PropertyName == wxT("PID")){
685                         NicknamesListPID->erase(*NicknameCount);
686                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
688                 } else if (PropertyName == wxT("PREF")){
690                         int PriorityNumber = 0;
691                         bool ValidNumber = TRUE;
692                         
693                         try{
694                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
695                         }
696                         
697                         catch(std::invalid_argument &e){
698                                 ValidNumber = FALSE;
699                         }
701                         if (ValidNumber == TRUE){
703                                 NicknamesListPref->erase(*NicknameCount);
704                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
706                         }
707                 
708                 } else if (PropertyName == wxT("LANGUAGE")){
710                         NicknamesListLanguage->erase(*NicknameCount);
711                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
713                 } else {
714                 
715                         // Something else we don't know about so append
716                         // to the tokens variable.
717                 
718                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
719                 
720                                 if (FirstToken == TRUE){
721                         
722                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
723                                         FirstToken = FALSE;
724                         
725                                 } else {
726                         
727                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
728                         
729                                 }
730                 
731                         }
732                 
733                 }
734                 
735         }
736         
737         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
738         
739         // Add the name token data.
740         
741         if (!PropertyTokens.IsEmpty()){
742         
743                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
744         
745         }
749 void SplitValues(wxString *PropertyLine, 
750         std::map<int,int> *SplitPoints, 
751         std::map<int,int> *SplitLength, 
752         int intSize){
753         
754         size_t intPropertyLen = PropertyLine->Len();
755         int intSplitsFound = 0;
756         int intSplitSize = 0;
757         int intSplitSeek = 0;
758         
759         for (int i = intSize; i <= intPropertyLen; i++){
761                 intSplitSize++;
762         
763                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
764                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
765            
766                     if (intSplitsFound == 0){
767             
768                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
769           
770                     } else {
771            
772                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
773             
774                     }
775             
776                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
777             
778                     intSplitsFound++;
779                     intSplitSeek = i;
780                     intSplitSize = 0;
781             
782                 }
784         }
786         if (intSplitsFound == 0){
788                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
789                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
791         } else {
793                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
794                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
796         }
800 void CheckType(wxString *PropertySeg1, 
801         std::map<int,int> *SplitPoints, 
802         std::map<int,int> *SplitLength, 
803         int *intPrevValue, 
804         PropertyType *PropType){
805         
806         wxString PropertyData;
807         wxString PropertyName;
808         wxString PropertyValue;
809         std::map<int,int>::iterator SLiter;
810         
811         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
812         intiter != SplitPoints->end(); ++intiter){
813         
814                 SLiter = SplitLength->find(intiter->first);
815         
816                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
817                 
818                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
819                 PropertyName = PropertyElement.GetNextToken();                          
820                 PropertyValue = PropertyElement.GetNextToken();
821                 
822                 *intPrevValue = intiter->second;
823                 
824                 if (PropertyName == wxT("TYPE")){
825                                 
826                         if (PropertyValue == wxT("work")){
827                         
828                                 *PropType = PROPERTY_WORK;
829                                                         
830                         } else if (PropertyValue == wxT("home")){
832                                 *PropType = PROPERTY_HOME;
833                                                         
834                         } else {
835                         
836                                 *PropType = PROPERTY_NONE;
837                         
838                         }
839                 
840                         return;
841                 
842                 }
843         
844         }
845         
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