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;
10 wxString PropertyName;
11 wxString PropertyValue;
12 wxString PropertyTokens;
13 wxString PropertyType;
14 bool AfterFirstToken = FALSE;
15 bool FirstToken = TRUE;
16 int intSplitsFound = 0;
18 int intPrevValue = 12;
24 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
28 // Look for type before continuing.
30 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
31 intiter != SplitPoints.end(); ++intiter){
33 SLiter = SplitLength.find(intiter->first);
35 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
37 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
38 PropertyName = PropertyElement.GetNextToken();
39 PropertyValue = PropertyElement.GetNextToken();
41 intPrevValue = intiter->second;
43 if (PropertyName == wxT("TYPE")){
45 if (PropertyValue == wxT("work")){
48 PropertyType = wxT("work");
50 } else if (PropertyValue == wxT("home")){
53 PropertyType = wxT("home");
65 // Setup blank lines for later on.
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("")));
75 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
76 intiter != SplitPoints.end(); ++intiter){
78 SLiter = SplitLength.find(intiter->first);
80 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
82 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
83 PropertyName = PropertyElement.GetNextToken();
84 PropertyValue = PropertyElement.GetNextToken();
86 intPrevValue = intiter->second;
88 // Process properties.
90 size_t intPropertyValueLen = PropertyValue.Len();
92 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
95 PropertyValue.RemoveLast();
99 if (PropertyValue.Mid(0, 1) == wxT("\"")){
101 PropertyValue.Remove(0, 1);
105 ProcessCaptureStrings(&PropertyValue);
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)); }
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)); }
119 } else if (PropertyName == wxT("PREF")){
121 intPref = wxAtoi(PropertyValue);
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)); }
129 // Something else we don't know about so append
130 // to the tokens variable.
132 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
134 if (FirstToken == TRUE){
136 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
141 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
151 // Deal with multiple categories.
159 intPropertyLen = wxSPropertySeg2.Len();
161 for (int i = 0; i <= intPropertyLen; i++){
163 if (intSplitSize == 0 && wxSPropertySeg2.Mid(i, 1) == wxT(" ")){
171 if (wxSPropertySeg2.Mid(i, 1) == wxT(",") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
173 if (AfterFirstToken == TRUE){
175 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
176 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
180 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
181 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
182 AfterFirstToken = TRUE;
194 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
195 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
199 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
200 intiter != SplitPoints.end(); ++intiter){
202 SLiter = SplitLength.find(intiter->first);
204 PropertyData = wxSPropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
206 intPrevValue = intiter->second;
208 // Process properties.
212 int intPropertyValueLen = PropertyValue.Len();
214 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
216 PropertyValue.Trim();
217 PropertyValue.RemoveLast();
223 // Add the data to the General/Home/Work address variables.
225 // Trim any whitespace from the start and end.
227 PropertyData = PropertyData.Trim(FALSE);
228 PropertyData = PropertyData.Trim(TRUE);
230 ProcessCaptureStrings(&PropertyData);
234 coldata.SetId(intValueSeek);
235 coldata.SetData(intValueSeek);
236 coldata.SetText(PropertyData);
238 ListCtrlIndex = lboCategories->InsertItem(coldata);
240 if (intPref > 0 && intPref < 101){
242 lboCategories->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
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));
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;
275 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
279 // Look for type before continuing.
281 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
282 intiter != SplitPoints.end(); ++intiter){
284 SLiter = SplitLength.find(intiter->first);
286 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
288 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
289 PropertyName = PropertyElement.GetNextToken();
290 PropertyValue = PropertyElement.GetNextToken();
292 intPrevValue = intiter->second;
294 if (PropertyName == wxT("TYPE")){
296 if (PropertyValue == wxT("work")){
300 } else if (PropertyValue == wxT("home")){
314 // Setup blank lines for later on.
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("")));
324 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
325 intiter != SplitPoints.end(); ++intiter){
327 SLiter = SplitLength.find(intiter->first);
329 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
331 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
332 PropertyName = PropertyElement.GetNextToken();
333 PropertyValue = PropertyElement.GetNextToken();
335 intPrevValue = intiter->second;
337 // Process properties.
339 size_t intPropertyValueLen = PropertyValue.Len();
341 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
343 PropertyValue.Trim();
344 PropertyValue.RemoveLast();
348 if (PropertyValue.Mid(0, 1) == wxT("\"")){
350 PropertyValue.Remove(0, 1);
354 if (PropertyName == wxT("ALTID")){
356 FreeBusyListAltID.erase(intValueSeek); FreeBusyListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
358 } else if (PropertyName == wxT("PID")){
360 FreeBusyListPID.erase(intValueSeek); FreeBusyListPID.insert(std::make_pair(intValueSeek, PropertyValue));
362 } else if (PropertyName == wxT("PREF")){
364 intPref = wxAtoi(PropertyValue);
366 FreeBusyListPref.erase(intValueSeek); FreeBusyListPref.insert(std::make_pair(intValueSeek, intPref));
368 } else if (PropertyName == wxT("MEDIATYPE")){
370 FreeBusyListMediatype.erase(intValueSeek); FreeBusyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
374 // Something else we don't know about so append
375 // to the tokens variable.
377 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
379 if (FirstToken == TRUE){
381 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
386 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
396 // Add the data to the General/Home/Work address variables.
400 coldata.SetId(intValueSeek);
401 coldata.SetData(intValueSeek);
402 coldata.SetText(wxSPropertySeg2);
404 ListCtrlIndex = lboFreeBusyAddresses->InsertItem(coldata);
406 if (intPref > 0 && intPref < 101){
408 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
412 CaptureString(&wxSPropertySeg2, FALSE);
414 FreeBusyList.erase(intValueSeek);
415 FreeBusyListType.erase(intValueSeek);
416 FreeBusyListTokens.erase(intValueSeek);
417 FreeBusyList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
421 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("")));
423 } else if (intType == 1){
425 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("home")));
426 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
428 } else if (intType == 2){
430 FreeBusyListType.insert(std::make_pair(intValueSeek, wxT("work")));
431 lboFreeBusyAddresses->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
435 FreeBusyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));