1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadRole(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *RoleCount){
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 GeneralRoleList.insert(std::make_pair(intValueSeek, wxT("")));
62 GeneralRoleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63 GeneralRoleListPID.insert(std::make_pair(intValueSeek, wxT("")));
64 GeneralRoleListPref.insert(std::make_pair(intValueSeek, 0));
65 GeneralRoleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
66 GeneralRoleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
68 } else if (intType == 1){
70 HomeRoleList.insert(std::make_pair(intValueSeek, wxT("")));
71 HomeRoleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
72 HomeRoleListPID.insert(std::make_pair(intValueSeek, wxT("")));
73 HomeRoleListPref.insert(std::make_pair(intValueSeek, 0));
74 HomeRoleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
75 HomeRoleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
77 } else if (intType == 2){
79 BusinessRoleList.insert(std::make_pair(intValueSeek, wxT("")));
80 BusinessRoleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
81 BusinessRoleListPID.insert(std::make_pair(intValueSeek, wxT("")));
82 BusinessRoleListPref.insert(std::make_pair(intValueSeek, 0));
83 BusinessRoleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
84 BusinessRoleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
90 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
91 intiter != SplitPoints.end(); ++intiter){
93 SLiter = SplitLength.find(intiter->first);
95 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
97 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
98 PropertyName = PropertyElement.GetNextToken();
99 PropertyValue = PropertyElement.GetNextToken();
101 intPrevValue = intiter->second;
103 // Process properties.
105 size_t intPropertyValueLen = PropertyValue.Len();
107 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
109 PropertyValue.Trim();
110 PropertyValue.RemoveLast();
114 if (PropertyValue.Mid(0, 1) == wxT("\"")){
116 PropertyValue.Remove(0, 1);
120 ProcessCaptureStrings(&PropertyValue);
122 if (PropertyName == wxT("ALTID")){
124 if (intType == 0){ GeneralRoleListAltID.erase(intValueSeek); GeneralRoleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
125 else if (intType == 1){ HomeRoleListAltID.erase(intValueSeek); HomeRoleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
126 else if (intType == 2){ BusinessRoleListAltID.erase(intValueSeek); BusinessRoleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128 } else if (PropertyName == wxT("PID")){
130 if (intType == 0){ GeneralRoleListPID.erase(intValueSeek); GeneralRoleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131 else if (intType == 1){ HomeRoleListPID.erase(intValueSeek); HomeRoleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
132 else if (intType == 2){ BusinessRoleListPID.erase(intValueSeek); BusinessRoleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134 } else if (PropertyName == wxT("PREF")){
136 intPref = wxAtoi(PropertyValue);
138 if (intType == 0){ GeneralRoleListPref.erase(intValueSeek); GeneralRoleListPref.insert(std::make_pair(intValueSeek, intPref)); }
139 else if (intType == 1){ HomeRoleListPref.erase(intValueSeek); HomeRoleListPref.insert(std::make_pair(intValueSeek, intPref)); }
140 else if (intType == 2){ BusinessRoleListPref.erase(intValueSeek); BusinessRoleListPref.insert(std::make_pair(intValueSeek, intPref)); }
142 } else if (PropertyName == wxT("LANGUAGE")){
144 if (intType == 0){ GeneralRoleListLanguage.erase(intValueSeek); GeneralRoleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
145 else if (intType == 1){ HomeRoleListLanguage.erase(intValueSeek); HomeRoleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
146 else if (intType == 2){ BusinessRoleListLanguage.erase(intValueSeek); BusinessRoleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
150 // Something else we don't know about so append
151 // to the tokens variable.
153 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
155 if (FirstToken == TRUE){
157 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
162 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
172 // Add the data to the General/Home/Work address variables.
174 ProcessCaptureStrings(&wxSPropertySeg2);
178 coldata.SetId(intValueSeek);
179 coldata.SetData(intValueSeek);
180 coldata.SetText(wxSPropertySeg2);
184 ListCtrlIndex = lboRoles->InsertItem(coldata);
186 if (intPref > 0 && intPref < 101){
188 lboRoles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
192 GeneralRoleList.erase(intValueSeek);
193 GeneralRoleListType.erase(intValueSeek);
194 GeneralRoleListTokens.erase(intValueSeek);
195 GeneralRoleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
196 GeneralRoleListType.insert(std::make_pair(intValueSeek, wxT("")));
197 GeneralRoleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
199 } else if (intType == 1){
201 ListCtrlIndex = lboHomeRoles->InsertItem(coldata);
203 if (intPref > 0 && intPref < 101){
205 lboHomeRoles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
209 HomeRoleList.erase(intValueSeek);
210 HomeRoleListType.erase(intValueSeek);
211 HomeRoleListTokens.erase(intValueSeek);
212 HomeRoleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
213 HomeRoleListType.insert(std::make_pair(intValueSeek, wxT("home")));
214 HomeRoleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
216 } else if (intType == 2){
218 ListCtrlIndex = lboBusinessRoles->InsertItem(coldata);
220 if (intPref > 0 && intPref < 101){
222 lboBusinessRoles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
226 BusinessRoleList.erase(intValueSeek);
227 BusinessRoleListType.erase(intValueSeek);
228 BusinessRoleListTokens.erase(intValueSeek);
229 BusinessRoleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
230 BusinessRoleListType.insert(std::make_pair(intValueSeek, wxT("work")));
231 BusinessRoleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));