Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Split frmContactEditor-Load.cpp into 24 files to make it more manageable.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadCategory.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadCategory(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *CategoryCount){
5         size_t intPropertyLen = wxSPropertySeg1.Len();
6         std::map<int, int> SplitPoints;
7         std::map<int, int> SplitLength;
8         std::map<int, int>::iterator SLiter;                    
9         wxString PropertyData;
10         wxString PropertyName;
11         wxString PropertyValue;
12         wxString PropertyTokens;
13         wxString PropertyType;
14         bool AfterFirstToken = FALSE;
15         bool FirstToken = TRUE;                 
16         int intSplitsFound = 0;
17         int intSplitSize = 0;
18         int intPrevValue = 12;
19         int intPref = 0;                        
20         int intType = 0;
21         int intSplitSeek = 0;
22         long ListCtrlIndex;
23         
24         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
25         
26         intPrevValue = 11;
27         
28         // Look for type before continuing.
29         
30         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
31         intiter != SplitPoints.end(); ++intiter){
32         
33                 SLiter = SplitLength.find(intiter->first);
34         
35                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
36                 
37                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
38                 PropertyName = PropertyElement.GetNextToken();                          
39                 PropertyValue = PropertyElement.GetNextToken();
40                 
41                 intPrevValue = intiter->second;
42                 
43                 if (PropertyName == wxT("TYPE")){
44                 
45                         if (PropertyValue == wxT("work")){
46                         
47                                 intType = 2;
48                                 PropertyType = wxT("work");                             
49                         
50                         } else if (PropertyValue == wxT("home")){
52                                 intType = 1;
53                                 PropertyType = wxT("home");                                             
54                         
55                         } else {
56                         
57                                 intType = 0;
58                         
59                         }
60                 
61                 }
62         
63         }
64         
65         // Setup blank lines for later on.
66         
67         CategoriesList.insert(std::make_pair(intValueSeek, wxT("")));
68         CategoriesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
69         CategoriesListPID.insert(std::make_pair(intValueSeek, wxT("")));
70         CategoriesListPref.insert(std::make_pair(intValueSeek, 0));
71         CategoriesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
72         
73         intPrevValue = 11;
74         
75         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
76         intiter != SplitPoints.end(); ++intiter){
77         
78                 SLiter = SplitLength.find(intiter->first);
79         
80                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
81                 
82                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
83                 PropertyName = PropertyElement.GetNextToken();                          
84                 PropertyValue = PropertyElement.GetNextToken();
85                 
86                 intPrevValue = intiter->second;
87                 
88                 // Process properties.
89                 
90                 size_t intPropertyValueLen = PropertyValue.Len();
91                 
92                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
93                         
94                         PropertyValue.Trim();
95                         PropertyValue.RemoveLast();
96                         
97                 }                               
98                 
99                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
100                         
101                         PropertyValue.Remove(0, 1);
102                         
103                 }
104                 
105                 ProcessCaptureStrings(&PropertyValue);
106                 
107                 if (PropertyName == wxT("ALTID")){
109                         if (intType == 0){ CategoriesListAltID.erase(intValueSeek); CategoriesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
110                         else if (intType == 1){ CategoriesListAltID.erase(intValueSeek); CategoriesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
111                         else if (intType == 2){ CategoriesListAltID.erase(intValueSeek); CategoriesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
112                 
113                 } else if (PropertyName == wxT("PID")){
115                         if (intType == 0){ CategoriesListPID.erase(intValueSeek); CategoriesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
116                         else if (intType == 1){ CategoriesListPID.erase(intValueSeek); CategoriesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
117                         else if (intType == 2){ CategoriesListPID.erase(intValueSeek); CategoriesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
118                 
119                 } else if (PropertyName == wxT("PREF")){
120                         
121                         intPref = wxAtoi(PropertyValue);
122                 
123                         if (intType == 0){ CategoriesListPref.erase(intValueSeek); CategoriesListPref.insert(std::make_pair(intValueSeek, intPref)); }
124                         else if (intType == 1){ CategoriesListPref.erase(intValueSeek); CategoriesListPref.insert(std::make_pair(intValueSeek, intPref)); }
125                         else if (intType == 2){ CategoriesListPref.erase(intValueSeek); CategoriesListPref.insert(std::make_pair(intValueSeek, intPref)); }
126                 
127                 } else {
128                 
129                         // Something else we don't know about so append
130                         // to the tokens variable.
131                 
132                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
133                 
134                                 if (FirstToken == TRUE){
135                         
136                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
137                                         FirstToken = FALSE;
138                         
139                                 } else {
140                         
141                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
142                         
143                                 }
144                 
145                         }
146                 
147                 }
148         
149         }                       
150         
151         // Deal with multiple categories.
152         
153         SplitPoints.clear();
154         SplitLength.clear();
155         intSplitSize = 0;
156         intSplitsFound = 0;
157         intSplitSeek = 0;
158         intPrevValue = 0;
159         intPropertyLen = wxSPropertySeg2.Len(); 
160         
161         for (int i = 0; i <= intPropertyLen; i++){
162         
163                 if (intSplitSize == 0 && wxSPropertySeg2.Mid(i, 1) == wxT(" ")){
164         
165                         continue;
166                 
167                 }
168         
169                 intSplitSize++;
170         
171                 if (wxSPropertySeg2.Mid(i, 1) == wxT(",") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
172         
173                         if (AfterFirstToken == TRUE){
174         
175                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
176                                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
177                         
178                         } else {
179                         
180                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
181                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));                                 
182                                 AfterFirstToken = TRUE;
183                         
184                         }
186                         intSplitsFound++;
187                         intSplitSeek = i;
188                         intSplitSize = 0;                                       
189         
190                 }                       
191         
192         }
193         
194         SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
195         SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                       
196         
197         intPrevValue = 0;
198         
199         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
200         intiter != SplitPoints.end(); ++intiter){
201         
202                 SLiter = SplitLength.find(intiter->first);
203         
204                 PropertyData = wxSPropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
205                 
206                 intPrevValue = intiter->second;
207                 
208                 // Process properties.
209                 
210                 /*
211                 
212                 int intPropertyValueLen = PropertyValue.Len();                          
213                 
214                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
215                         
216                         PropertyValue.Trim();
217                         PropertyValue.RemoveLast();
218                         
219                 }
220                 
221                 */
222                 
223                 // Add the data to the General/Home/Work address variables.
224         
225                 // Trim any whitespace from the start and end.
226         
227                 PropertyData = PropertyData.Trim(FALSE);
228                 PropertyData = PropertyData.Trim(TRUE);                         
229         
230                 ProcessCaptureStrings(&PropertyData);
231         
232                 wxListItem coldata;
234                 coldata.SetId(intValueSeek);
235                 coldata.SetData(intValueSeek);
236                 coldata.SetText(PropertyData);
237         
238                 ListCtrlIndex = lboCategories->InsertItem(coldata);
239                 
240                 if (intPref > 0 && intPref < 101){
241                 
242                         lboCategories->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
243                         
244                 }
245                 
246                 CategoriesList.erase(intValueSeek);
247                 CategoriesListType.erase(intValueSeek);
248                 CategoriesListTokens.erase(intValueSeek);
249                 CategoriesList.insert(std::make_pair(intValueSeek, PropertyData));
250                 CategoriesListType.insert(std::make_pair(intValueSeek, PropertyType));
251                 CategoriesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
252         
253                 CategoryCount++;
254                 intValueSeek++;                         
255         
256         }
260 void frmContactEditor::LoadCalFreeBusy(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *FreeBusyCount){
262         std::map<int, int> SplitPoints;
263         std::map<int, int> SplitLength;
264         std::map<int, int>::iterator SLiter;                    
265         wxString PropertyData;
266         wxString PropertyName;
267         wxString PropertyValue;
268         wxString PropertyTokens;
269         bool FirstToken = TRUE;
270         int intPrevValue = 7;
271         int intPref = 0;                        
272         int intType = 0;
273         long ListCtrlIndex;
274         
275         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
276         
277         intPrevValue = 6;
278         
279         // Look for type before continuing.
280         
281         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
282         intiter != SplitPoints.end(); ++intiter){
283         
284                 SLiter = SplitLength.find(intiter->first);
285         
286                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
287                 
288                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
289                 PropertyName = PropertyElement.GetNextToken();                          
290                 PropertyValue = PropertyElement.GetNextToken();
291                 
292                 intPrevValue = intiter->second;
293                 
294                 if (PropertyName == wxT("TYPE")){
295                 
296                         if (PropertyValue == wxT("work")){
297                         
298                                 intType = 2;                                    
299                         
300                         } else if (PropertyValue == wxT("home")){
302                                 intType = 1;
303                         
304                         } else {
305                         
306                                 intType = 0;
307                         
308                         }
309                 
310                 }
311         
312         }
313         
314         // Setup blank lines for later on.
315         
316         FreeBusyList.insert(std::make_pair(intValueSeek, wxT("")));
317         FreeBusyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
318         FreeBusyListPID.insert(std::make_pair(intValueSeek, wxT("")));
319         FreeBusyListPref.insert(std::make_pair(intValueSeek, 0));
320         FreeBusyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
321         
322         intPrevValue = 6;
323         
324         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
325         intiter != SplitPoints.end(); ++intiter){
326         
327                 SLiter = SplitLength.find(intiter->first);
328         
329                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
330                 
331                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
332                 PropertyName = PropertyElement.GetNextToken();                          
333                 PropertyValue = PropertyElement.GetNextToken();
334                 
335                 intPrevValue = intiter->second;
336                 
337                 // Process properties.
338                 
339                 size_t intPropertyValueLen = PropertyValue.Len();
340                 
341                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
342                         
343                         PropertyValue.Trim();
344                         PropertyValue.RemoveLast();
345                         
346                 }                               
347                 
348                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
349                         
350                         PropertyValue.Remove(0, 1);
351                         
352                 }                               
353                 
354                 if (PropertyName == wxT("ALTID")){
356                         FreeBusyListAltID.erase(intValueSeek); FreeBusyListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
357                 
358                 } else if (PropertyName == wxT("PID")){
360                         FreeBusyListPID.erase(intValueSeek); FreeBusyListPID.insert(std::make_pair(intValueSeek, PropertyValue));
361                 
362                 } else if (PropertyName == wxT("PREF")){
363                         
364                         intPref = wxAtoi(PropertyValue);
365                 
366                         FreeBusyListPref.erase(intValueSeek); FreeBusyListPref.insert(std::make_pair(intValueSeek, intPref));
367                 
368                 } else if (PropertyName == wxT("MEDIATYPE")){
369                 
370                         FreeBusyListMediatype.erase(intValueSeek); FreeBusyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
371                 
372                 } else {
373                 
374                         // Something else we don't know about so append
375                         // to the tokens variable.
376                 
377                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
378                 
379                                 if (FirstToken == TRUE){
380                         
381                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
382                                         FirstToken = FALSE;
383                         
384                                 } else {
385                         
386                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
387                         
388                                 }
389                 
390                         }
391                 
392                 }
393         
394         }       
395         
396         // Add the data to the General/Home/Work address variables.
397         
398         wxListItem coldata;
400         coldata.SetId(intValueSeek);
401         coldata.SetData(intValueSeek);
402         coldata.SetText(wxSPropertySeg2);
404         ListCtrlIndex = lboFreeBusyAddresses->InsertItem(coldata);
405                 
406         if (intPref > 0 && intPref < 101){
407                 
408                 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
409                         
410         }
411         
412         CaptureString(&wxSPropertySeg2, FALSE);                 
413                 
414         FreeBusyList.erase(intValueSeek);
415         FreeBusyListType.erase(intValueSeek);
416         FreeBusyListTokens.erase(intValueSeek);
417         FreeBusyList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
418         
419         if (intType == 0){
420         
421                 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("")));                         
422         
423         } else if (intType == 1){
424         
425                 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("home")));
426                 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
427         
428         } else if (intType == 2){
429         
430                 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("work")));
431                 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
432         
433         }
434         
435         FreeBusyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
436         
437         FreeBusyCount++;
438         intValueSeek++;
439         
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