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