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-LoadEmail.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadEmail(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *EmailCount){
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 AddressLabel;
15         wxString AddressLang;
16         wxString AddressAltID;
17         wxString AddressPID;
18         wxString AddressTokens;
19         wxString AddressGeo;
20         wxString AddressTimezone;
21         wxString AddressType;
22         wxString AddressMediatype;
23         wxString AddressPOBox;
24         wxString AddressExtended;
25         wxString AddressStreet;
26         wxString AddressLocality;
27         wxString AddressCity;
28         wxString AddressRegion;
29         wxString AddressPostalCode;
30         wxString AddressCountry;
31         bool FirstToken = TRUE;
32         int intSplitsFound = 0;
33         int intSplitSize = 0;
34         int intPrevValue = 7;
35         int intPref = 0;                        
36         int intType = 0;
37         long ListCtrlIndex;
38         
39         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
40         
41         intPrevValue = 6;
42         
43         // Look for type before continuing.
44         
45         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
46         intiter != SplitPoints.end(); ++intiter){
47         
48                 SLiter = SplitLength.find(intiter->first);
49         
50                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
51                 
52                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
53                 PropertyName = PropertyElement.GetNextToken();                          
54                 PropertyValue = PropertyElement.GetNextToken();
55                 
56                 intPrevValue = intiter->second;
57                 
58                 if (PropertyName == wxT("TYPE")){
59                 
60                         if (PropertyValue == wxT("work")){
61                         
62                                 intType = 2;                                    
63                         
64                         } else if (PropertyValue == wxT("home")){
66                                 intType = 1;
67                         
68                         } else {
69                         
70                                 intType = 0;
71                         
72                         }
73                 
74                 }
75         
76         }
77         
78         // Setup blank lines for later on.
79         
80         if (intType == 0){
81         
82                 GeneralEmailList.insert(std::make_pair(intValueSeek, wxT("")));
83                 GeneralEmailListAltID.insert(std::make_pair(intValueSeek, wxT("")));
84                 GeneralEmailListPID.insert(std::make_pair(intValueSeek, wxT("")));
85                 GeneralEmailListPref.insert(std::make_pair(intValueSeek, 0));
86                 GeneralEmailListTokens.insert(std::make_pair(intValueSeek, wxT("")));
88         } else if (intType == 1){
89         
90                 HomeEmailList.insert(std::make_pair(intValueSeek, wxT("")));
91                 HomeEmailListAltID.insert(std::make_pair(intValueSeek, wxT("")));
92                 HomeEmailListPID.insert(std::make_pair(intValueSeek, wxT("")));
93                 HomeEmailListPref.insert(std::make_pair(intValueSeek, 0));
94                 HomeEmailListTokens.insert(std::make_pair(intValueSeek, wxT("")));
95         
96         } else if (intType == 2){
98                 BusinessEmailList.insert(std::make_pair(intValueSeek, wxT("")));
99                 BusinessEmailListAltID.insert(std::make_pair(intValueSeek, wxT("")));
100                 BusinessEmailListPID.insert(std::make_pair(intValueSeek, wxT("")));
101                 BusinessEmailListPref.insert(std::make_pair(intValueSeek, 0));
102                 BusinessEmailListTokens.insert(std::make_pair(intValueSeek, wxT("")));
103         
104         }
105         
106         intPrevValue = 6;                       
107         
108         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
109         intiter != SplitPoints.end(); ++intiter){
110         
111                 SLiter = SplitLength.find(intiter->first);
112         
113                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
114                 
115                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
116                 PropertyName = PropertyElement.GetNextToken();                          
117                 PropertyValue = PropertyElement.GetNextToken();
118                 
119                 intPrevValue = intiter->second;
120                 
121                 ProcessCaptureStrings(&PropertyValue);
122                 
123                 // Process properties.
124                 
125                 if (PropertyName == wxT("ALTID")){
127                         if (intType == 0){ GeneralEmailListAltID.erase(intValueSeek); GeneralEmailListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128                         else if (intType == 1){ HomeEmailListAltID.erase(intValueSeek); HomeEmailListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129                         else if (intType == 2){ BusinessEmailListAltID.erase(intValueSeek); BusinessEmailListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
130                 
131                 } else if (PropertyName == wxT("PID")){
133                         if (intType == 0){ GeneralEmailListPID.erase(intValueSeek); GeneralEmailListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134                         else if (intType == 1){ HomeEmailListPID.erase(intValueSeek); HomeEmailListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
135                         else if (intType == 2){ BusinessEmailListPID.erase(intValueSeek); BusinessEmailListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
136                 
137                 } else if (PropertyName == wxT("PREF")){
138                         
139                         intPref = wxAtoi(PropertyValue);
140                         
141                         if (intPref > 0 && intPref < 101){
142                 
143                                 if (intType == 0){ GeneralEmailListPref.erase(intValueSeek); GeneralEmailListPref.insert(std::make_pair(intValueSeek, intPref)); }
144                                 else if (intType == 1){ HomeEmailListPref.erase(intValueSeek); HomeEmailListPref.insert(std::make_pair(intValueSeek, intPref)); }
145                                 else if (intType == 2){ BusinessEmailListPref.erase(intValueSeek); BusinessEmailListPref.insert(std::make_pair(intValueSeek, intPref)); }
146                                 
147                         }
148                 
149                 } else {
150                 
151                         // Something else we don't know about so append
152                         // to the tokens variable.
153                         
154                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
155                         
156                                 if (FirstToken == TRUE){
157                                 
158                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
159                                         FirstToken = FALSE;
160                                 
161                                 } else {
162                                 
163                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
164                                 
165                                 }
166                         
167                         }
168                 
169                 }
170         
171         } 
173         //std::map<int, int>::iterator SLiter;
174         intPropertyLen = wxSPropertySeg2.Len();
175         SplitPoints.clear();
176         SplitLength.clear();
177         intSplitsFound = 0;
178         intSplitSize = 0;
179         intPrevValue = 0;       
180         
181         // Add the data to the General/Home/Work email variables.
182         
183         ProcessCaptureStrings(&wxSPropertySeg2);
184         
185         wxListItem coldata;
187         coldata.SetId(intValueSeek);
188         coldata.SetData(intValueSeek);
189         coldata.SetText(wxSPropertySeg2);
190         
191         if (intType == 0){
192         
194         
195                 ListCtrlIndex = lboEmails->InsertItem(coldata);
196                 
197                 if (intPref > 0 && intPref < 101){
198                 
199                         lboEmails->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
200                         
201                 }
202                 
203                 GeneralEmailList.erase(intValueSeek);
204                 GeneralEmailListType.erase(intValueSeek);
205                 GeneralEmailListTokens.erase(intValueSeek);
206                 GeneralEmailList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
207                 GeneralEmailListType.insert(std::make_pair(intValueSeek, wxT("")));
208                 GeneralEmailListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
209         
210         } else if (intType == 1){ 
211         
212                 ListCtrlIndex = lboHomeEmails->InsertItem(coldata);
214                 if (intPref > 0 && intPref < 101){
215                 
216                         lboHomeEmails->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
217                         
218                 }
220                 HomeEmailList.erase(intValueSeek);
221                 HomeEmailListType.erase(intValueSeek);
222                 HomeEmailListTokens.erase(intValueSeek);                                
223                 HomeEmailList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
224                 HomeEmailListType.insert(std::make_pair(intValueSeek, wxT("home")));
225                 HomeEmailListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
226         
227         } else if (intType == 2){ 
228         
229                 ListCtrlIndex = lboBusinessEmail->InsertItem(coldata);
231                 if (intPref > 0 && intPref < 101){
232                 
233                         lboBusinessEmail->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
234                         
235                 }
237                 BusinessEmailList.erase(intValueSeek);
238                 BusinessEmailListType.erase(intValueSeek);
239                 BusinessEmailListTokens.erase(intValueSeek);                            
240                 BusinessEmailList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
241                 BusinessEmailListType.insert(std::make_pair(intValueSeek, wxT("work")));
242                 BusinessEmailListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                           
243         
244         }
245         
246         EmailCount++;
247         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