1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadOrg(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *OrgCount){
5 std::map<int, int> SplitPoints;
6 std::map<int, int> SplitLength;
7 std::map<int, int>::iterator SLiter;
10 wxString PropertyValue;
11 wxString PropertyTokens;
12 bool FirstToken = TRUE;
18 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
22 // Look for type before continuing.
24 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
25 intiter != SplitPoints.end(); ++intiter){
27 SLiter = SplitLength.find(intiter->first);
29 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
31 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
32 PropertyName = PropertyElement.GetNextToken();
33 PropertyValue = PropertyElement.GetNextToken();
35 intPrevValue = intiter->second;
37 if (PropertyName == wxT("TYPE")){
39 if (PropertyValue == wxT("work")){
43 } else if (PropertyValue == wxT("home")){
57 // Setup blank lines for later on.
61 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
62 GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63 GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
64 GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
65 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
66 GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
67 GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
69 } else if (intType == 1){
71 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
72 HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
73 HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
74 HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
75 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
76 HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
77 HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
79 } else if (intType == 2){
81 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
82 BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
83 BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
84 BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
85 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
86 BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
87 BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
93 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
94 intiter != SplitPoints.end(); ++intiter){
96 SLiter = SplitLength.find(intiter->first);
98 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
100 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
101 PropertyName = PropertyElement.GetNextToken();
102 PropertyValue = PropertyElement.GetNextToken();
104 intPrevValue = intiter->second;
106 // Process properties.
108 size_t intPropertyValueLen = PropertyValue.Len();
110 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
112 PropertyValue.Trim();
113 PropertyValue.RemoveLast();
117 if (PropertyValue.Mid(0, 1) == wxT("\"")){
119 PropertyValue.Remove(0, 1);
123 ProcessCaptureStrings(&PropertyValue);
125 if (PropertyName == wxT("ALTID")){
127 if (intType == 0){ GeneralOrganisationsListAltID.erase(intValueSeek); GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128 else if (intType == 1){ HomeOrganisationsListAltID.erase(intValueSeek); HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129 else if (intType == 2){ BusinessOrganisationsListAltID.erase(intValueSeek); BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131 } else if (PropertyName == wxT("PID")){
133 if (intType == 0){ GeneralOrganisationsListPID.erase(intValueSeek); GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134 else if (intType == 1){ HomeOrganisationsListPID.erase(intValueSeek); HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
135 else if (intType == 2){ BusinessOrganisationsListPID.erase(intValueSeek); BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
137 } else if (PropertyName == wxT("PREF")){
139 intPref = wxAtoi(PropertyValue);
141 if (intType == 0){ GeneralOrganisationsListPref.erase(intValueSeek); GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
142 else if (intType == 1){ HomeOrganisationsListPref.erase(intValueSeek); HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
143 else if (intType == 2){ BusinessOrganisationsListPref.erase(intValueSeek); BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
145 } else if (PropertyName == wxT("LANGUAGE")){
147 if (intType == 0){ GeneralOrganisationsListLanguage.erase(intValueSeek); GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
148 else if (intType == 1){ HomeOrganisationsListLanguage.erase(intValueSeek); HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
149 else if (intType == 2){ BusinessOrganisationsListLanguage.erase(intValueSeek); BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
151 } else if (PropertyName == wxT("SORT-AS")){
153 if (intType == 0){ GeneralOrganisationsListSortAs.erase(intValueSeek); GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
154 else if (intType == 1){ HomeOrganisationsListSortAs.erase(intValueSeek); HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
155 else if (intType == 2){ BusinessOrganisationsListSortAs.erase(intValueSeek); BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
159 // Something else we don't know about so append
160 // to the tokens variable.
162 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
164 if (FirstToken == TRUE){
166 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
171 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
181 // Add the data to the General/Home/Work address variables.
185 ProcessCaptureStrings(&wxSPropertySeg2);
187 coldata.SetId(intValueSeek);
188 coldata.SetData(intValueSeek);
189 coldata.SetText(wxSPropertySeg2);
193 ListCtrlIndex = lboOrganisations->InsertItem(coldata);
195 if (intPref > 0 && intPref < 101){
197 lboOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
201 GeneralOrganisationsList.erase(intValueSeek);
202 GeneralOrganisationsListType.erase(intValueSeek);
203 GeneralOrganisationsListTokens.erase(intValueSeek);
204 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
205 GeneralOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("")));
206 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
208 } else if (intType == 1){
210 ListCtrlIndex = lboHomeOrganisations->InsertItem(coldata);
212 if (intPref > 0 && intPref < 101){
214 lboHomeOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
218 HomeOrganisationsList.erase(intValueSeek);
219 HomeOrganisationsListType.erase(intValueSeek);
220 HomeOrganisationsListTokens.erase(intValueSeek);
221 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
222 HomeOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("home")));
223 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
225 } else if (intType == 2){
227 ListCtrlIndex = lboBusinessOrganisations->InsertItem(coldata);
229 if (intPref > 0 && intPref < 101){
231 lboBusinessOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
235 BusinessOrganisationsList.erase(intValueSeek);
236 BusinessOrganisationsListType.erase(intValueSeek);
237 BusinessOrganisationsListTokens.erase(intValueSeek);
238 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
239 BusinessOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("work")));
240 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));