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-LoadGeo.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadGeo(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *GeoCount){
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 GeoType;
14         wxString GeoData;
15         bool FirstToken = TRUE;                 
16         int intSplitsFound = 0;
17         int intSplitSize = 0;
18         int intPrevValue = 5;
19         int intPref = 0;                        
20         int intType = 0;
21         long ListCtrlIndex;
22         
23         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
24         
25         intPrevValue = 4;
26         
27         // Look for type before continuing.
28         
29         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
30         intiter != SplitPoints.end(); ++intiter){
31         
32                 SLiter = SplitLength.find(intiter->first);
33         
34                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
35                 
36                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
37                 PropertyName = PropertyElement.GetNextToken();                          
38                 PropertyValue = PropertyElement.GetNextToken();
39                 
40                 intPrevValue = intiter->second;
41                 
42                 if (PropertyName == wxT("TYPE")){
43                 
44                         if (PropertyValue == wxT("work")){
45                         
46                                 intType = 2;                                    
47                         
48                         } else if (PropertyValue == wxT("home")){
50                                 intType = 1;
51                         
52                         } else {
53                         
54                                 intType = 0;
55                         
56                         }
57                 
58                 }
59         
60         }
61         
62         // Setup blank lines for later on.
63         
64         if (intType == 0){
65         
66                 GeneralGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
67                 GeneralGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
68                 GeneralGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
69                 GeneralGeographyListPref.insert(std::make_pair(intValueSeek, 0));
70                 GeneralGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
72         } else if (intType == 1){
73         
74                 HomeGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
75                 HomeGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
76                 HomeGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
77                 HomeGeographyListPref.insert(std::make_pair(intValueSeek, 0));
78                 HomeGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
79         
80         } else if (intType == 2){
82                 BusinessGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
83                 BusinessGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
84                 BusinessGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
85                 BusinessGeographyListPref.insert(std::make_pair(intValueSeek, 0));
86                 BusinessGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
87         
88         }
89         
90         intPrevValue = 4;                       
91         
92         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
93         intiter != SplitPoints.end(); ++intiter){
94         
95                 SLiter = SplitLength.find(intiter->first);
96         
97                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
98                 
99                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
100                 PropertyName = PropertyElement.GetNextToken();                          
101                 PropertyValue = PropertyElement.GetNextToken();
102                 
103                 intPrevValue = intiter->second;
104                 
105                 // Process properties.
106                 
107                 size_t intPropertyValueLen = PropertyValue.Len();
108                 
109                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
110                         
111                         PropertyValue.Trim();
112                         PropertyValue.RemoveLast();
113                         
114                 }                               
115                 
116                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
117                         
118                         PropertyValue.Remove(0, 1);
119                         
120                 }       
122                 ProcessCaptureStrings(&PropertyValue);
123                 
124                 if (PropertyName == wxT("ALTID")){
126                         if (intType == 0){ GeneralGeographyListAltID.erase(intValueSeek); GeneralGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
127                         else if (intType == 1){ HomeGeographyListAltID.erase(intValueSeek); HomeGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128                         else if (intType == 2){ BusinessGeographyListAltID.erase(intValueSeek); BusinessGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129                 
130                 } else if (PropertyName == wxT("PID")){
132                         if (intType == 0){ GeneralGeographyListPID.erase(intValueSeek); GeneralGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
133                         else if (intType == 1){ HomeGeographyListPID.erase(intValueSeek); HomeGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134                         else if (intType == 2){ BusinessGeographyListPID.erase(intValueSeek); BusinessGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
135                 
136                 } else if (PropertyName == wxT("MEDIATYPE")){
137                 
138                         if (intType == 0){ GeneralGeographyListMediatype.erase(intValueSeek); GeneralGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
139                         else if (intType == 1){ HomeGeographyListMediatype.erase(intValueSeek); HomeGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
140                         else if (intType == 2){ BusinessGeographyListMediatype.erase(intValueSeek); BusinessGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
141                 
142                 } else if (PropertyName == wxT("PREF")){
143                         
144                         intPref = wxAtoi(PropertyValue);
145                 
146                         if (intPref > 0 && intPref < 101){
147                 
148                                 if (intType == 0){ GeneralGeographyListPref.erase(intValueSeek); GeneralGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
149                                 else if (intType == 1){ HomeGeographyListPref.erase(intValueSeek); HomeGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
150                                 else if (intType == 2){ BusinessGeographyListPref.erase(intValueSeek); BusinessGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
151                         
152                         }
153                 
154                 } else {
155                 
156                         // Something else we don't know about so append
157                         // to the tokens variable.
158                 
159                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
160                 
161                                 if (FirstToken == TRUE){
162                         
163                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
164                                         FirstToken = FALSE;
165                         
166                                 } else {
167                         
168                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
169                         
170                                 }
171                 
172                         }
173                 
174                 }
175         
176         }                                       
177         
178         // Split the address. 
180         //std::map<int, int>::iterator SLiter;
181         intPropertyLen = wxSPropertySeg2.Len();
182         SplitPoints.clear();
183         SplitLength.clear();
184         intSplitsFound = 0;
185         intSplitSize = 0;
186         intPrevValue = 0;
187         
188         for (int i = 0; i <= intPropertyLen; i++){
190                 intSplitSize++;
191         
192                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
193         
194                         intSplitsFound++;
195                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
196                         
197                         if (intSplitsFound == 1){ 
198                         
199                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
200                                 break; 
201                                 
202                         }
203                         
204                         intSplitSize = 0;                                       
205         
206                 }
208         }                       
209         
210         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
211         intiter != SplitPoints.end(); ++intiter){
212         
213                 if (intiter->first == 1){
214                 
215                         // Deal with PO Box.
216                         
217                         SLiter = SplitLength.find(1);
218                                                                 
219                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
220                         GeoType = wxSPropertySeg2.Mid(0, SLiter->second);
221                         intPrevValue = intiter->second;
222                         
223                         GeoData = wxSPropertySeg2.Mid(intPrevValue);                                    
224                 
225                 }
226         
227         }
228         
229         ProcessCaptureStrings(&wxSPropertySeg2);
230         
231         wxListItem coldata;
233         coldata.SetId(intValueSeek);
234         coldata.SetData(intValueSeek);
236         
237         if (intType == 0){
238         
239                 /*
240         
241                 ListCtrlIndex = lboTimezones->InsertItem(coldata);
242                 
243                 if (intPref > 0 && intPref < 101){
244                 
245                         lboTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
246                         
247                 }
248                 
249                 */
250                 /*
251                 txtGeopositioning->SetValue(GeoData);
252                 */
253                 
254                 GeneralGeographyList.erase(intValueSeek);
255                 GeneralGeographyListType.erase(intValueSeek);
256                 GeneralGeographyListTokens.erase(intValueSeek);
257                 GeneralGeographyList.insert(std::make_pair(intValueSeek, GeoData));
258                 GeneralGeographyListType.insert(std::make_pair(intValueSeek, wxT("")));
259                 GeneralGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
260                 
261                 CaptureString(&GeoData, FALSE);
262                 coldata.SetText(GeoData);
263                 ListCtrlIndex = lboGeoposition->InsertItem(coldata);
264                 
265                 if (intPref > 0 && intPref < 101){
266                 
267                         lboGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
268                         
269                 }
270         
271         } else if (intType == 1){                       
272         
273                 /*
274         
275                 ListCtrlIndex = lboHomeTimezones->InsertItem(coldata);
277                 if (intPref > 0 && intPref < 101){
278                 
279                         lboHomeTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
280                         
281                 }
282                 
283                 */
284                 
285                 /*
286                 txtHomeGeopositioning->SetValue(GeoData);
287                 */
289                 HomeGeographyList.erase(intValueSeek);
290                 HomeGeographyListType.erase(intValueSeek);
291                 HomeGeographyListTokens.erase(intValueSeek);                            
292                 HomeGeographyList.insert(std::make_pair(intValueSeek, GeoData));
293                 HomeGeographyListType.insert(std::make_pair(intValueSeek, wxT("home")));
294                 HomeGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
295                 
296                 CaptureString(&GeoData, FALSE);
297                 coldata.SetText(GeoData);
298                 ListCtrlIndex = lboHomeGeoposition->InsertItem(coldata);
299                 
300                 if (intPref > 0 && intPref < 101){
301                 
302                         lboHomeGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
303                         
304                 }
305         
306         } else if (intType == 2){ 
307         
308                 ListCtrlIndex = lboBusinessGeoposition->InsertItem(coldata);                    
309         
310                 /*
311         
312                 ListCtrlIndex = lboBusinessTimezones->InsertItem(coldata);
314                 if (intPref > 0 && intPref < 101){
315                 
316                         lboBusinessTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
317                         
318                 }
319                 
320                 */
321                 
322                 /*
323                 txtBusinessGeopositioning->SetValue(GeoData);
324                 */
326                 BusinessGeographyList.erase(intValueSeek);
327                 BusinessGeographyListType.erase(intValueSeek);
328                 BusinessGeographyListTokens.erase(intValueSeek);                                
329                 BusinessGeographyList.insert(std::make_pair(intValueSeek, GeoData));
330                 BusinessGeographyListType.insert(std::make_pair(intValueSeek, wxT("work")));
331                 BusinessGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
332                 
333                 CaptureString(&GeoData, FALSE);
334                 coldata.SetText(GeoData);
335                 ListCtrlIndex = lboBusinessGeoposition->InsertItem(coldata);
336                 
337                 if (intPref > 0 && intPref < 101){
338                 
339                         lboBusinessGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
340                         
341                 }
342         
343         }
344         
345         GeoCount++;
346         intValueSeek++;
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