1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadRelated(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *RelatedCount){
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;
14 wxString RelatedTypeOriginal;
16 bool FirstToken = TRUE;
17 int intSplitsFound = 0;
23 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
27 // Look for type before continuing.
29 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
30 intiter != SplitPoints.end(); ++intiter){
32 SLiter = SplitLength.find(intiter->first);
34 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
36 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
37 PropertyName = PropertyElement.GetNextToken();
38 PropertyValue = PropertyElement.GetNextToken();
40 intPrevValue = intiter->second;
44 RelatedTypeOriginal = PropertyValue;
46 if (PropertyName == wxT("TYPE")){
48 if (PropertyValue == wxT("contact")){
50 RelatedType = _("Contact");
52 } else if (PropertyValue == wxT("acquaintance")){
54 RelatedType = _("Acquaintance");
56 } else if (PropertyValue == wxT("friend")){
58 RelatedType = _("Friend");
60 } else if (PropertyValue == wxT("met")){
62 RelatedType = _("Met");
64 } else if (PropertyValue == wxT("co-worker")){
66 RelatedType = _("Co-worker");
68 } else if (PropertyValue == wxT("colleague")){
70 RelatedType = _("Colleague");
72 } else if (PropertyValue == wxT("co-resident")){
74 RelatedType = _("Co-resident");
76 } else if (PropertyValue == wxT("neighbor")){
78 RelatedType = _("Neighbour");
80 } else if (PropertyValue == wxT("child")){
82 RelatedType = _("Child");
84 } else if (PropertyValue == wxT("parent")){
86 RelatedType = _("Parent");
88 } else if (PropertyValue == wxT("sibling")){
90 RelatedType = _("Sibling");
92 } else if (PropertyValue == wxT("spouse")){
94 RelatedType = _("Spouse");
96 } else if (PropertyValue == wxT("kin")){
98 RelatedType = _("Kin");
100 } else if (PropertyValue == wxT("muse")){
102 RelatedType = _("Muse");
104 } else if (PropertyValue == wxT("crush")){
106 RelatedType = _("Crush");
108 } else if (PropertyValue == wxT("date")){
110 RelatedType = _("Date");
112 } else if (PropertyValue == wxT("sweetheart")){
114 RelatedType = _("Sweetheart");
116 } else if (PropertyValue == wxT("me")){
118 RelatedType = _("Me");
120 } else if (PropertyValue == wxT("agent")){
122 RelatedType = _("Agent");
124 } else if (PropertyValue == wxT("emergency")){
126 RelatedType = _("Emergency");
130 RelatedType = PropertyValue;
140 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
141 intiter != SplitPoints.end(); ++intiter){
143 SLiter = SplitLength.find(intiter->first);
145 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
147 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
148 PropertyName = PropertyElement.GetNextToken();
149 PropertyValue = PropertyElement.GetNextToken();
151 intPrevValue = intiter->second;
153 // Process properties.
155 size_t intPropertyValueLen = PropertyValue.Len();
157 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
159 PropertyValue.Trim();
160 PropertyValue.RemoveLast();
164 if (PropertyValue.Mid(0, 1) == wxT("\"")){
166 PropertyValue.Remove(0, 1);
170 ProcessCaptureStrings(&PropertyValue);
172 if (PropertyName == wxT("ALTID")){
174 GeneralRelatedListAltID.erase(intValueSeek);
175 GeneralRelatedListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
177 } else if (PropertyName == wxT("PID")){
179 GeneralRelatedListPID.erase(intValueSeek);
180 GeneralRelatedListPID.insert(std::make_pair(intValueSeek, PropertyValue));
182 } else if (PropertyName == wxT("PREF")){
184 intPref = wxAtoi(PropertyValue);
186 if (intPref > 0 && intPref < 101){
188 GeneralRelatedListPref.erase(intValueSeek);
189 GeneralRelatedListPref.insert(std::make_pair(intValueSeek, intPref));
194 } else if (PropertyName == wxT("LANGUAGE")){
196 GeneralRelatedListLanguage.erase(intValueSeek);
197 GeneralRelatedListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
201 // Something else we don't know about so append
202 // to the tokens variable.
204 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
206 if (FirstToken == TRUE){
208 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
213 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
223 // Split the address.
225 //std::map<int, int>::iterator SLiter;
226 intPropertyLen = wxSPropertySeg2.Len();
233 // Add the data to the General/Home/Work address variables.
237 coldata.SetId(intValueSeek);
238 coldata.SetData(intValueSeek);
239 coldata.SetText(RelatedType);
241 ProcessCaptureStrings(&wxSPropertySeg2);
243 ListCtrlIndex = lboRelated->InsertItem(coldata);
245 lboRelated->SetItem(ListCtrlIndex, 1, wxSPropertySeg2);
247 if (intPref > 0 && intPref < 101){
249 lboRelated->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
253 GeneralRelatedList.erase(intValueSeek);
254 GeneralRelatedListRelType.erase(intValueSeek);
255 GeneralRelatedListType.erase(intValueSeek);
256 GeneralRelatedListTokens.erase(intValueSeek);
257 GeneralRelatedList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
258 GeneralRelatedListRelType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));
259 GeneralRelatedListType.insert(std::make_pair(intValueSeek, RelatedTypeOriginal));
260 GeneralRelatedListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));