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-LoadCalendar.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadCalURI(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *CalAdrCount){
5         std::map<int, int> SplitPoints;
6         std::map<int, int> SplitLength;
7         std::map<int, int>::iterator SLiter;                    
8         wxString PropertyData;
9         wxString PropertyName;
10         wxString PropertyValue;
11         wxString PropertyTokens;
12         bool FirstToken = TRUE;
13         int intPrevValue = 8;
14         int intPref = 0;                        
15         int intType = 0;
16         long ListCtrlIndex;
17         
18         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
19         
20         intPrevValue = 7;
21         
22         // Look for type before continuing.
23         
24         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
25         intiter != SplitPoints.end(); ++intiter){
26         
27                 SLiter = SplitLength.find(intiter->first);
28         
29                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
30                 
31                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
32                 PropertyName = PropertyElement.GetNextToken();                          
33                 PropertyValue = PropertyElement.GetNextToken();
34                 
35                 intPrevValue = intiter->second;
36                 
37                 if (PropertyName == wxT("TYPE")){
38                 
39                         if (PropertyValue == wxT("work")){
40                         
41                                 intType = 2;                                    
42                         
43                         } else if (PropertyValue == wxT("home")){
45                                 intType = 1;
46                         
47                         } else {
48                         
49                                 intType = 0;
50                         
51                         }
52                 
53                 }
54         
55         }
56         
57         // Setup blank lines for later on.
58         
59         CalendarList.insert(std::make_pair(intValueSeek, wxT("")));
60         CalendarListAltID.insert(std::make_pair(intValueSeek, wxT("")));
61         CalendarListPID.insert(std::make_pair(intValueSeek, wxT("")));
62         CalendarListPref.insert(std::make_pair(intValueSeek, 0));
63         CalendarListTokens.insert(std::make_pair(intValueSeek, wxT("")));
65         intPrevValue = 6;
66         
67         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
68         intiter != SplitPoints.end(); ++intiter){
69         
70                 SLiter = SplitLength.find(intiter->first);
71         
72                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
73                 
74                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
75                 PropertyName = PropertyElement.GetNextToken();                          
76                 PropertyValue = PropertyElement.GetNextToken();
77                 
78                 intPrevValue = intiter->second;
79                 
80                 // Process properties.
81                 
82                 size_t intPropertyValueLen = PropertyValue.Len();
83                 
84                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
85                         
86                         PropertyValue.Trim();
87                         PropertyValue.RemoveLast();
88                         
89                 }                               
90                 
91                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
92                         
93                         PropertyValue.Remove(0, 1);
94                         
95                 }                               
96                 
97                 if (PropertyName == wxT("ALTID")){
99                         CalendarListAltID.erase(intValueSeek); CalendarListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
100                 
101                 } else if (PropertyName == wxT("PID")){
103                         CalendarListPID.erase(intValueSeek); CalendarListPID.insert(std::make_pair(intValueSeek, PropertyValue));
104                 
105                 } else if (PropertyName == wxT("PREF")){
106                         
107                         intPref = wxAtoi(PropertyValue);
108                 
109                         CalendarListPref.erase(intValueSeek); CalendarListPref.insert(std::make_pair(intValueSeek, intPref));
110                 
111                 } else if (PropertyName == wxT("MEDIATYPE")){
112                 
113                         CalendarListMediatype.erase(intValueSeek); CalendarListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
114                 
115                 } else {
116                 
117                         // Something else we don't know about so append
118                         // to the tokens variable.
119                 
120                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
121                 
122                                 if (FirstToken == TRUE){
123                         
124                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
125                                         FirstToken = FALSE;
126                         
127                                 } else {
128                         
129                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
130                         
131                                 }
132                 
133                         }
134                 
135                 }
136         
137         }       
138         
139         // Add the data to the General/Home/Work address variables.
140         
141         wxListItem coldata;
143         coldata.SetId(intValueSeek);
144         coldata.SetData(intValueSeek);
145         coldata.SetText(wxSPropertySeg2);
147         ListCtrlIndex = lboCalendarAddresses->InsertItem(coldata);
148                 
149         if (intPref > 0 && intPref < 101){
150                 
151                 lboCalendarAddresses->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
152                         
153         }
154         
155         CaptureString(&wxSPropertySeg2, FALSE);
156                 
157         CalendarList.erase(intValueSeek);
158         CalendarListType.erase(intValueSeek);
159         CalendarListTokens.erase(intValueSeek);
160         CalendarList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
161         
162         if (intType == 0){
163         
164                 CalendarListType.insert(std::make_pair(intValueSeek, wxT("")));                         
165         
166         } else if (intType == 1){
167         
168                 CalendarListType.insert(std::make_pair(intValueSeek, wxT("home")));
169                 lboCalendarAddresses->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
170         
171         } else if (intType == 2){
172         
173                 CalendarListType.insert(std::make_pair(intValueSeek, wxT("work")));
174                 lboCalendarAddresses->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
175         
176         }
177         
178         CalendarListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
179         
180         CalAdrCount++;
181         intValueSeek++;
182         
185 void frmContactEditor::LoadCalAdrURI(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *CalReqAdrCount){
187         std::map<int, int> SplitPoints;
188         std::map<int, int> SplitLength;
189         std::map<int, int>::iterator SLiter;                    
190         wxString PropertyData;
191         wxString PropertyName;
192         wxString PropertyValue;
193         wxString PropertyTokens;
194         bool FirstToken = TRUE;
195         int intPrevValue = 11;
196         int intPref = 0;                        
197         int intType = 0;
198         long ListCtrlIndex;
199         
200         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
201         
202         intPrevValue = 10;
203         
204         // Look for type before continuing.
205         
206         
207         
208         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
209         intiter != SplitPoints.end(); ++intiter){
210         
211                 SLiter = SplitLength.find(intiter->first);
212         
213                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
214                 
215                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
216                 PropertyName = PropertyElement.GetNextToken();                          
217                 PropertyValue = PropertyElement.GetNextToken();
218                 
219                 intPrevValue = intiter->second;
220                 
221                 if (PropertyName == wxT("TYPE")){
222                 
223                         if (PropertyValue == wxT("work")){
224                         
225                                 intType = 2;                                    
226                         
227                         } else if (PropertyValue == wxT("home")){
229                                 intType = 1;
230                         
231                         } else {
232                         
233                                 intType = 0;
234                         
235                         }
236                 
237                 }
238         
239         }
240         
241         // Setup blank lines for later on.
242         
243         CalendarRequestList.insert(std::make_pair(intValueSeek, wxT("")));
244         CalendarRequestListAltID.insert(std::make_pair(intValueSeek, wxT("")));
245         CalendarRequestListPID.insert(std::make_pair(intValueSeek, wxT("")));
246         CalendarRequestListPref.insert(std::make_pair(intValueSeek, 0));
247         CalendarRequestListTokens.insert(std::make_pair(intValueSeek, wxT("")));
248         
249         intPrevValue = 10;
250         
251         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
252         intiter != SplitPoints.end(); ++intiter){
253         
254                 SLiter = SplitLength.find(intiter->first);
255         
256                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
257                 
258                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
259                 PropertyName = PropertyElement.GetNextToken();                          
260                 PropertyValue = PropertyElement.GetNextToken();
261                 
262                 intPrevValue = intiter->second;
263                 
264                 // Process properties.
265                 
266                 size_t intPropertyValueLen = PropertyValue.Len();
267                 
268                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
269                         
270                         PropertyValue.Trim();
271                         PropertyValue.RemoveLast();
272                         
273                 }                               
274                 
275                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
276                         
277                         PropertyValue.Remove(0, 1);
278                         
279                 }                               
280                 
281                 if (PropertyName == wxT("ALTID")){
283                         CalendarRequestListAltID.erase(intValueSeek); CalendarRequestListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
284                 
285                 } else if (PropertyName == wxT("PID")){
287                         CalendarRequestListPID.erase(intValueSeek); CalendarRequestListPID.insert(std::make_pair(intValueSeek, PropertyValue));
288                 
289                 } else if (PropertyName == wxT("PREF")){
290                         
291                         intPref = wxAtoi(PropertyValue);
292                 
293                         CalendarRequestListPref.erase(intValueSeek); CalendarRequestListPref.insert(std::make_pair(intValueSeek, intPref));
294                 
295                 } else if (PropertyName == wxT("MEDIATYPE")){
296                 
297                         CalendarRequestListMediatype.erase(intValueSeek); CalendarRequestListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
298                 
299                 } else {
300                 
301                         // Something else we don't know about so append
302                         // to the tokens variable.
303                 
304                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
305                 
306                                 if (FirstToken == TRUE){
307                         
308                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
309                                         FirstToken = FALSE;
310                         
311                                 } else {
312                         
313                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
314                         
315                                 }
316                 
317                         }
318                 
319                 }
320         
321         }       
322         
323         // Add the data to the General/Home/Work address variables.
324         
325         wxListItem coldata;
327         coldata.SetId(intValueSeek);
328         coldata.SetData(intValueSeek);
329         coldata.SetText(wxSPropertySeg2);
331         ListCtrlIndex = lboCalendarRequestAddress->InsertItem(coldata);
332                 
333         if (intPref > 0 && intPref < 101){
334                 
335                 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
336                         
337         }
338                 
339         CaptureString(&wxSPropertySeg2, FALSE);                         
340                 
341         CalendarRequestList.erase(intValueSeek);
342         CalendarRequestListType.erase(intValueSeek);
343         CalendarRequestListTokens.erase(intValueSeek);
344         CalendarRequestList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));                      
345         
346         if (intType == 0){
347         
348                 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("")));                          
349         
350         } else if (intType == 1){
351         
352                 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("home")));
353                 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
354         
355         } else if (intType == 2){
356         
357                 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("work")));
358                 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
359         
360         }
361         
362         CalendarRequestListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
363         
364         CalReqAdrCount++;
365         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