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-LoadTimeZone.cpp
1 #include "frmContactEditor.h"
2                         
3 void frmContactEditor::LoadTimeZone(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *TZCount){
4                         
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                         bool FirstToken = TRUE;                 
14                         int intSplitsFound = 0;
15                         int intSplitSize = 0;
16                         int intPrevValue = 4;
17                         int intPref = 0;                        
18                         int intType = 0;
19                         long ListCtrlIndex;
20                         
21                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
22                         
23                         intPrevValue = 3;
24                         
25                         // Look for type before continuing.
26                         
27                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
28                         intiter != SplitPoints.end(); ++intiter){
29                         
30                                 SLiter = SplitLength.find(intiter->first);
31                         
32                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
33                                 
34                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
35                                 PropertyName = PropertyElement.GetNextToken();                          
36                                 PropertyValue = PropertyElement.GetNextToken();
37                                 
38                                 intPrevValue = intiter->second;
39                                 
40                                 if (PropertyName == wxT("TYPE")){
41                                 
42                                         if (PropertyValue == wxT("work")){
43                                         
44                                                 intType = 2;                                    
45                                         
46                                         } else if (PropertyValue == wxT("home")){
48                                                 intType = 1;
49                                         
50                                         } else {
51                                         
52                                                 intType = 0;
53                                         
54                                         }
55                                 
56                                 }
57                         
58                         }
59                         
60                         // Setup blank lines for later on.
61                         
62                         if (intType == 0){
63                         
64                                 GeneralTZList.insert(std::make_pair(intValueSeek, wxT("")));
65                                 GeneralTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
66                                 GeneralTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
67                                 GeneralTZListPref.insert(std::make_pair(intValueSeek, 0));
68                                 GeneralTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
69                                 GeneralTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
71                         } else if (intType == 1){
72                         
73                                 HomeTZList.insert(std::make_pair(intValueSeek, wxT("")));
74                                 HomeTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
75                                 HomeTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
76                                 HomeTZListPref.insert(std::make_pair(intValueSeek, 0));
77                                 HomeTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));                              
78                                 HomeTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
79                         
80                         } else if (intType == 2){
82                                 BusinessTZList.insert(std::make_pair(intValueSeek, wxT("")));
83                                 BusinessTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
84                                 BusinessTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
85                                 BusinessTZListPref.insert(std::make_pair(intValueSeek, 0));
86                                 BusinessTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));                          
87                                 BusinessTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
88                         
89                         }
90                         
91                         intPrevValue = 3;
92                         
93                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
94                         intiter != SplitPoints.end(); ++intiter){
95                         
96                                 SLiter = SplitLength.find(intiter->first);
97                         
98                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
99                                 
100                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
101                                 PropertyName = PropertyElement.GetNextToken();                          
102                                 PropertyValue = PropertyElement.GetNextToken();
103                                 
104                                 intPrevValue = intiter->second;
105                                 
106                                 size_t intPropertyValueLen = PropertyValue.Len();
107                                 
108                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
109                                         
110                                         PropertyValue.Trim();
111                                         PropertyValue.RemoveLast();
112                                         
113                                 }                               
114                                 
115                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
116                                         
117                                         PropertyValue.Remove(0, 1);
118                                         
119                                 }                               
120                                 
121                                 ProcessCaptureStrings(&PropertyValue);
122                                 
123                                 // Process properties.
124                                 
125                                 if (PropertyName == wxT("ALTID")){
127                                         if (intType == 0){ GeneralTZListAltID.erase(intValueSeek); GeneralTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128                                         else if (intType == 1){ HomeTZListAltID.erase(intValueSeek); HomeTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129                                         else if (intType == 2){ BusinessTZListAltID.erase(intValueSeek); BusinessTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
130                                 
131                                 } else if (PropertyName == wxT("PID")){
133                                         if (intType == 0){ GeneralTZListPID.erase(intValueSeek); GeneralTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134                                         else if (intType == 1){ HomeTZListPID.erase(intValueSeek); HomeTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
135                                         else if (intType == 2){ BusinessTZListPID.erase(intValueSeek); BusinessTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
136                                 
137                                 } else if (PropertyName == wxT("MEDIATYPE")){
138                                 
139                                         if (intType == 0){ GeneralTZListMediatype.erase(intValueSeek); GeneralTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
140                                         else if (intType == 1){ HomeTZListMediatype.erase(intValueSeek); HomeTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
141                                         else if (intType == 2){ BusinessTZListMediatype.erase(intValueSeek); BusinessTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
142                                 
143                                 } else if (PropertyName == wxT("PREF")){
144                                         
145                                         intPref = wxAtoi(PropertyValue);
146                                 
147                                         if (intPref > 0 && intPref < 101){
148                                 
149                                                 if (intType == 0){ GeneralTZListPref.erase(intValueSeek); GeneralTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
150                                                 else if (intType == 1){ HomeTZListPref.erase(intValueSeek); HomeTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
151                                                 else if (intType == 2){ BusinessTZListPref.erase(intValueSeek); BusinessTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
152                                         
153                                         }
154                                 
155                                 } else {
156                                 
157                                         // Something else we don't know about so append
158                                         // to the tokens variable.
159                                         
160                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
161                                         
162                                                 if (FirstToken == TRUE){
163                                                 
164                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
165                                                         FirstToken = FALSE;
166                                                 
167                                                 } else {
168                                                 
169                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
170                                                 
171                                                 }
172                                         
173                                         }
174                                 
175                                 }
176                         
177                         }                       
178                         
179                         // Split the address. 
180                 
181                         //std::map<int, int>::iterator SLiter;
182                         intPropertyLen = wxSPropertySeg2.Len();
183                         SplitPoints.clear();
184                         SplitLength.clear();
185                         intSplitsFound = 0;
186                         intSplitSize = 0;
187                         intPrevValue = 0;
188                         
189                         for (int i = 0; i <= intPropertyLen; i++){
190                 
191                                 intSplitSize++;
192                         
193                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
194                         
195                                         intSplitsFound++;
196                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
197                                         
198                                         if (intSplitsFound == 6){ 
199                                         
200                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
201                                                 break; 
202                                                 
203                                         } else {
204                                         
205                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
206                                         
207                                         }
208                                         
209                                         intSplitSize = 0;                                       
210                         
211                                 }
212                 
213                         }       
214                         
215                         // Add the data to the General/Home/Work address variables.
216                         
217                         ProcessCaptureStrings(&wxSPropertySeg2);                        
218                         
219                         wxListItem coldata;
220                 
221                         coldata.SetId(intValueSeek);
222                         coldata.SetData(intValueSeek);
223                         coldata.SetText(wxSPropertySeg2);
224                         
225                         if (intType == 0){
226                         
227                                 ListCtrlIndex = lboTimezones->InsertItem(coldata);
228                                 
229                                 if (intPref > 0 && intPref < 101){
230                                 
231                                         lboTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
232                                         
233                                 }
234                                 
235                                 GeneralTZList.erase(intValueSeek);
236                                 GeneralTZListType.erase(intValueSeek);
237                                 GeneralTZListTokens.erase(intValueSeek);
238                                 GeneralTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
239                                 GeneralTZListType.insert(std::make_pair(intValueSeek, wxT("")));
240                                 GeneralTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
241                         
242                         } else if (intType == 1){ 
243                         
244                                 ListCtrlIndex = lboHomeTimezones->InsertItem(coldata);
246                                 if (intPref > 0 && intPref < 101){
247                                 
248                                         lboHomeTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
249                                         
250                                 }
252                                 HomeTZList.erase(intValueSeek);
253                                 HomeTZListType.erase(intValueSeek);
254                                 HomeTZListTokens.erase(intValueSeek);                           
255                                 HomeTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
256                                 HomeTZListType.insert(std::make_pair(intValueSeek, wxT("home")));
257                                 HomeTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
258                         
259                         } else if (intType == 2){ 
260                         
261                                 ListCtrlIndex = lboBusinessTimezones->InsertItem(coldata);
263                                 if (intPref > 0 && intPref < 101){
264                                 
265                                         lboBusinessTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
266                                         
267                                 }
269                                 BusinessTZList.erase(intValueSeek);
270                                 BusinessTZListType.erase(intValueSeek);
271                                 BusinessTZListTokens.erase(intValueSeek);                               
272                                 BusinessTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
273                                 BusinessTZListType.insert(std::make_pair(intValueSeek, wxT("work")));
274                                 BusinessTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                              
275                         
276                         }
277                 
278                         TZCount++;
279                         intValueSeek++; 
280                         
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