Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Split frmContactEditor-Load.cpp into 24 files to make it more manageable.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadIM.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadIM(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *IMPPCount){
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;
9         std::map<int, int>::iterator SPoint;
10         wxString PropertyData;
11         wxString PropertyName;
12         wxString PropertyValue;
13         wxString PropertyTokens;
14         wxString IMPPType;
15         wxString IMPPAddress;
16         bool FirstToken = TRUE;
17         int intSplitsFound = 0;
18         int intSplitSize = 0;
19         int intPrevValue = 6;
20         int intPref = 0;
21         int intType = 0;
22         long ListCtrlIndex;
23         
24         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
25         
26         intPrevValue = 5;
27         
28         // Look for type before continuing.
29         
30         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
31         intiter != SplitPoints.end(); ++intiter){
32         
33                 SLiter = SplitLength.find(intiter->first);
34         
35                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
36                 
37                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
38                 PropertyName = PropertyElement.GetNextToken();                          
39                 PropertyValue = PropertyElement.GetNextToken();
40                 
41                 intPrevValue = intiter->second;
42                 
43                 if (PropertyName == wxT("TYPE")){
44                 
45                         if (PropertyValue == wxT("work")){
46                         
47                                 intType = 2;                                    
48                         
49                         } else if (PropertyValue == wxT("home")){
51                                 intType = 1;
52                         
53                         } else {
54                         
55                                 intType = 0;
56                         
57                         }
58                 
59                 }
60         
61         }
62         
63         // Setup blank lines for later on.
64         
65         if (intType == 0){
66         
67                 GeneralIMList.insert(std::make_pair(intValueSeek, wxT("")));
68                 GeneralIMListAltID.insert(std::make_pair(intValueSeek, wxT("")));
69                 GeneralIMListPID.insert(std::make_pair(intValueSeek, wxT("")));
70                 GeneralIMListPref.insert(std::make_pair(intValueSeek, 0));
71                 GeneralIMListTokens.insert(std::make_pair(intValueSeek, wxT("")));
72                 GeneralIMListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
74         } else if (intType == 1){
75         
76                 HomeIMList.insert(std::make_pair(intValueSeek, wxT("")));
77                 HomeIMListAltID.insert(std::make_pair(intValueSeek, wxT("")));
78                 HomeIMListPID.insert(std::make_pair(intValueSeek, wxT("")));
79                 HomeIMListPref.insert(std::make_pair(intValueSeek, 0));
80                 HomeIMListTokens.insert(std::make_pair(intValueSeek, wxT("")));
81                 HomeIMListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
82         
83         } else if (intType == 2){
85                 BusinessIMList.insert(std::make_pair(intValueSeek, wxT("")));
86                 BusinessIMListAltID.insert(std::make_pair(intValueSeek, wxT("")));
87                 BusinessIMListPID.insert(std::make_pair(intValueSeek, wxT("")));
88                 BusinessIMListPref.insert(std::make_pair(intValueSeek, 0));
89                 BusinessIMListTokens.insert(std::make_pair(intValueSeek, wxT("")));
90                 BusinessIMListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
91         
92         }
93         
94         intPrevValue = 5;
95         
96         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
97         intiter != SplitPoints.end(); ++intiter){
98         
99                 SLiter = SplitLength.find(intiter->first);
100         
101                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
102                 
103                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
104                 PropertyName = PropertyElement.GetNextToken();                          
105                 PropertyValue = PropertyElement.GetNextToken();
106                 
107                 ProcessCaptureStrings(&PropertyValue);
108                 
109                 intPrevValue = intiter->second;
110                 
111                 // Process properties.
112                 
113                 if (PropertyName == wxT("ALTID")){
115                         if (intType == 0){ GeneralIMListAltID.erase(intValueSeek); GeneralIMListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
116                         else if (intType == 1){ HomeIMListAltID.erase(intValueSeek); HomeIMListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
117                         else if (intType == 2){ BusinessIMListAltID.erase(intValueSeek); BusinessIMListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
118                 
119                 } else if (PropertyName == wxT("PID")){
121                         if (intType == 0){ GeneralIMListPID.erase(intValueSeek); GeneralIMListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
122                         else if (intType == 1){ HomeIMListPID.erase(intValueSeek); HomeIMListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
123                         else if (intType == 2){ BusinessIMListPID.erase(intValueSeek); BusinessIMListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
124                 
125                 } else if (PropertyName == wxT("PREF")){
126                         
127                         intPref = wxAtoi(PropertyValue);
128                         
129                         if (intPref > 0 && intPref < 101){
130                 
131                                 if (intType == 0){ GeneralIMListPref.erase(intValueSeek); GeneralIMListPref.insert(std::make_pair(intValueSeek, intPref)); }
132                                 else if (intType == 1){ HomeIMListPref.erase(intValueSeek); HomeIMListPref.insert(std::make_pair(intValueSeek, intPref)); }
133                                 else if (intType == 2){ BusinessIMListPref.erase(intValueSeek); BusinessIMListPref.insert(std::make_pair(intValueSeek, intPref)); }
134                                 
135                         }
136                 
137                 } else if (PropertyName == wxT("MEDIATYPE")){
139                         if (intType == 0){ GeneralIMListMediatype.erase(intValueSeek); GeneralIMListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
140                         else if (intType == 1){ HomeIMListMediatype.erase(intValueSeek); HomeIMListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
141                         else if (intType == 2){ BusinessIMListMediatype.erase(intValueSeek); BusinessIMListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
142                 
143                 } else {
144                 
145                         // Something else we don't know about so append
146                         // to the tokens variable.
147                         
148                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
149                         
150                                 if (FirstToken == TRUE){
151                                 
152                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
153                                         FirstToken = FALSE;
154                                 
155                                 } else {
156                                 
157                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
158                                 
159                                 }
160                         
161                         }
162                 
163                 }
164         
165         }                       
166         
167         // Split the address. 
169         //std::map<int, int>::iterator SLiter;
170         intPropertyLen = wxSPropertySeg2.Len();
171         SplitPoints.clear();
172         SplitLength.clear();
173         intSplitsFound = 0;
174         intSplitSize = 0;
175         intPrevValue = 0;
176         
177         for (int i = 0; i <= intPropertyLen; i++){
179                 intSplitSize++;
180         
181                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
182         
183                         intSplitsFound++;
184                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
185                         
186                         if (intSplitsFound == 1){ 
187                         
188                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
189                                 break; 
190                                 
191                         }
192                         
193                         intSplitSize = 0;                                       
194         
195                 }
197         }
198         
199         // Split the data into several parts.                   
200         
201         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
202         intiter != SplitPoints.end(); ++intiter){
203         
204                 if (intiter->first == 1){
205                 
206                         // Deal with PO Box.
207                         
208                         SLiter = SplitLength.find(1);
209                                                                 
210                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
211                         IMPPType = wxSPropertySeg2.Mid(0, SLiter->second);
212                         intPrevValue = intiter->second;
213                         
214                         IMPPAddress = wxSPropertySeg2.Mid(intPrevValue);                                        
215                 
216                 }
217         
218         }       
219         
220         // Check what IM type it is.
221         
222         if (IMPPType == wxT("aim")){
224                 IMPPType = wxT("AIM");
226         } else if (IMPPType == wxT("gg")){
228                 IMPPType = wxT("Gadu-Gadu");
230         } else if (IMPPType == wxT("icq")){
232                 IMPPType = wxT("ICQ");
234         } else if (IMPPType == wxT("skype")){
236                 IMPPType = wxT("Skype");
238         } else if (IMPPType == wxT("xmpp")){
240                 IMPPType = wxT("XMPP");
242         } else if (IMPPType == wxT("yahoo")){
244                 IMPPType = wxT("Yahoo");
246         } else {
248                 // Do nothing.
250         }                       
251         
252         // Add the data to the General/Home/Work address variables.
253         
254         ProcessCaptureStrings(&wxSPropertySeg2);
255         
256         wxListItem coldata;
258         coldata.SetId(intValueSeek);
259         coldata.SetData(intValueSeek);
260         coldata.SetText(IMPPType);
262         if (intType == 0){
263         
264                 ListCtrlIndex = lboIM->InsertItem(coldata);
265                 
266                 lboIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
267                 
268                 if (intPref > 0 && intPref < 101){
269                 
270                         lboIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
271                         
272                 }                               
273                 
274                 GeneralIMList.erase(intValueSeek);
275                 GeneralIMListType.erase(intValueSeek);
276                 GeneralIMListTokens.erase(intValueSeek);
277                 GeneralIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
278                 GeneralIMListType.insert(std::make_pair(intValueSeek, wxT("")));
279                 GeneralIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
280         
281         } else if (intType == 1){ 
282         
283                 ListCtrlIndex = lboHomeIM->InsertItem(coldata);
285                 lboHomeIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
287                 if (intPref > 0 && intPref < 101){
288                 
289                         lboHomeIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
290                         
291                 }
293                 HomeIMList.erase(intValueSeek);
294                 HomeIMListType.erase(intValueSeek);
295                 HomeIMListTokens.erase(intValueSeek);                           
296                 HomeIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
297                 HomeIMListType.insert(std::make_pair(intValueSeek, wxT("home")));
298                 HomeIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
299         
300         } else if (intType == 2){ 
301         
302                 ListCtrlIndex = lboBusinessIM->InsertItem(coldata);
304                 lboBusinessIM->SetItem(ListCtrlIndex, 1, IMPPAddress);
306                 if (intPref > 0 && intPref < 101){
307                 
308                         lboBusinessIM->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
309                         
310                 }
312                 BusinessIMList.erase(intValueSeek);
313                 BusinessIMListType.erase(intValueSeek);
314                 BusinessIMListTokens.erase(intValueSeek);                               
315                 BusinessIMList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
316                 BusinessIMListType.insert(std::make_pair(intValueSeek, wxT("work")));
317                 BusinessIMListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                              
318         
319         }
320         
321         *IMPPCount++;
322         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