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-LoadSound.cpp
1 #include "frmContactEditor.h"
2 #include "../common/base64.h"
4 void frmContactEditor::LoadSound(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *SoundCount){
6                         size_t intPropertyLen = wxSPropertySeg1.Len();
7                         std::map<int, int> SplitPoints;
8                         std::map<int, int> SplitLength;
9                         std::map<int, int>::iterator SLiter;                    
10                         wxString PropertyData;
11                         wxString PropertyName;
12                         wxString PropertyValue;
13                         wxString PropertyTokens;
14                         bool FirstToken = TRUE;
15                         int intSplitsFound = 0;
16                         int intSplitSize = 0;
17                         int intPrevValue = 7;
18                         int intPref = 0;                        
19                         int intType = 0;
20                         long ListCtrlIndex;
21                         
22                         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
23                         
24                         intPrevValue = 6;
25                         
26                         // Look for type before continuing.                     
27                         
28                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
29                         intiter != SplitPoints.end(); ++intiter){
30                         
31                                 SLiter = SplitLength.find(intiter->first);
32                         
33                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
34                                 
35                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
36                                 PropertyName = PropertyElement.GetNextToken();                          
37                                 PropertyValue = PropertyElement.GetNextToken();
38                                 
39                                 intPrevValue = intiter->second;
40                                 
41                                 if (PropertyName == wxT("TYPE")){
42                                 
43                                         if (PropertyValue == wxT("work")){
44                                         
45                                                 intType = 2;                                    
46                                         
47                                         } else if (PropertyValue == wxT("home")){
49                                                 intType = 1;
50                                         
51                                         } else {
52                                         
53                                                 intType = 0;
54                                         
55                                         }
56                                 
57                                 }
58                         
59                         }
60                         
61                         // Setup blank lines for later on.
62                         
63                         SoundsList.insert(std::make_pair(intValueSeek, ""));
64                         SoundsListType.insert(std::make_pair(intValueSeek, wxT("")));
65                         SoundsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
66                         SoundsListPID.insert(std::make_pair(intValueSeek, wxT("")));
67                         SoundsListPref.insert(std::make_pair(intValueSeek, 0));
68                         SoundsListAudioEncType.insert(std::make_pair(intValueSeek, wxT("")));
69                         SoundsListAudioType.insert(std::make_pair(intValueSeek, wxT("")));                      
70                         SoundsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
71                         SoundsListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
73                         intPrevValue = 6;
75                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
76                         intiter != SplitPoints.end(); ++intiter){
77                         
78                                 SLiter = SplitLength.find(intiter->first);
79                         
80                                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
81                                 
82                                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
83                                 PropertyName = PropertyElement.GetNextToken();                          
84                                 PropertyValue = PropertyElement.GetNextToken();
85                                 
86                                 intPrevValue = intiter->second;
87                                 
88                                 // Process properties.
89                                 
90                                 size_t intPropertyValueLen = PropertyValue.Len();
91                                 
92                                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
93                                         
94                                         PropertyValue.Trim();
95                                         PropertyValue.RemoveLast();
96                                         
97                                 }                               
98                                 
99                                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
100                                         
101                                         PropertyValue.Remove(0, 1);
102                                         
103                                 }                       
104                                 
105                                 ProcessCaptureStrings(&PropertyValue);
106                                 
107                                 if (PropertyName == wxT("ALTID")){
109                                         if (intType == 0){ SoundsListAltID.erase(intValueSeek); SoundsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
110                                         else if (intType == 1){ SoundsListAltID.erase(intValueSeek); SoundsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
111                                         else if (intType == 2){ SoundsListAltID.erase(intValueSeek); SoundsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
112                                 
113                                 } else if (PropertyName == wxT("PID")){
115                                         if (intType == 0){ SoundsListPID.erase(intValueSeek); SoundsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
116                                         else if (intType == 1){ SoundsListPID.erase(intValueSeek); SoundsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
117                                         else if (intType == 2){ SoundsListPID.erase(intValueSeek); SoundsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
118                                 
119                                 } else if (PropertyName == wxT("PREF")){
120                                         
121                                         intPref = wxAtoi(PropertyValue);
122                                 
123                                         if (intType == 0){ SoundsListPref.erase(intValueSeek); SoundsListPref.insert(std::make_pair(intValueSeek, intPref)); }
124                                         else if (intType == 1){ SoundsListPref.erase(intValueSeek); SoundsListPref.insert(std::make_pair(intValueSeek, intPref)); }
125                                         else if (intType == 2){ SoundsListPref.erase(intValueSeek); SoundsListPref.insert(std::make_pair(intValueSeek, intPref)); }
126                                 
127                                 } else if (PropertyName == wxT("MEDIATYPE")){
128                                 
129                                         if (intType == 0){ SoundsListMediatype.erase(intValueSeek); SoundsListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
130                                         else if (intType == 1){ SoundsListMediatype.erase(intValueSeek); SoundsListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
131                                         else if (intType == 2){ SoundsListMediatype.erase(intValueSeek); SoundsListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
132                                 
133                                 } else {
134                                 
135                                         // Something else we don't know about so append
136                                         // to the tokens variable.
137                                         
138                                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
139                                         
140                                                 if (FirstToken == TRUE){
141                                                 
142                                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
143                                                         FirstToken = FALSE;
144                                                 
145                                                 } else {
146                                                 
147                                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
148                                                 
149                                                 }
150                                         
151                                         }
152                                 
153                                 }
154                         
155                         }       
156                         
157                         intPropertyLen = wxSPropertySeg2.Len();
158                         SplitPoints.clear();
159                         SplitLength.clear();
160                         intSplitsFound = 0;
161                         intSplitSize = 0;
162                         intPrevValue = 0;
163                         
164                         ProcessCaptureStrings(&wxSPropertySeg2);        
165                         
166                         for (int i = 0; i <= intPropertyLen; i++){
167                 
168                                 intSplitSize++;
169                         
170                                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
171                         
172                                         intSplitsFound++;
173                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
174                                         
175                                         if (intSplitsFound == 6){ 
176                                         
177                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
178                                                 break; 
179                                                 
180                                         } else {
181                                         
182                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
183                                         
184                                         }
185                                         
186                                         intSplitSize = 0;                                       
187                         
188                                 }
189                 
190                         }
191                         
192                         wxString wxSSoundURI;
193                         wxString wxSSoundMIME;
194                         wxString wxSSoundEncoding;
195                         wxString wxSSoundData;
196                         std::string base64enc;
197                         
198                         if (intSplitsFound == 0){
199                         
200                         } else {
201                         
202                                 std::map<int, int>::iterator striter;
203                         
204                                 striter = SplitLength.find(1);
205                         
206                                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
207                         
208                                 while (wSTDataType.HasMoreTokens() == TRUE){
209                                 
210                                         wxSSoundURI = wSTDataType.GetNextToken();
211                                         wxSSoundMIME = wSTDataType.GetNextToken();
212                                         break;
213                                 
214                                 }                       
215                         
216                                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));                    
217                         
218                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
219                                 
220                                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
221                                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
222                                         base64enc = wxSSoundData.mb_str();
223                                         break;
224                                 
225                                 }
226                         
227                         }
228                         
229                         // Add the data to the General/Home/Work address variables.
230                         
231                         wxListItem coldata;
232                 
233                         coldata.SetId(intValueSeek);
234                         coldata.SetData(intValueSeek);
235                         coldata.SetText(_("Sound"));
236                         
237                         ListCtrlIndex = lboSounds->InsertItem(coldata);
238                                 
239                         if (intPref > 0 && intPref < 101){
240                                 
241                                 lboSounds->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
242                         
243                         }
244                                 
245                         SoundsList.erase(intValueSeek);
246                         SoundsListType.erase(intValueSeek);
247                         SoundsListTokens.erase(intValueSeek);
248                         SoundsListAudioType.erase(intValueSeek);
249                         SoundsListAudioEncType.erase(intValueSeek);
250                         SoundsList.insert(std::make_pair(intValueSeek, base64enc));
251                         SoundsListAudioType.insert(std::make_pair(intValueSeek, wxSSoundMIME));
252                         SoundsListAudioEncType.insert(std::make_pair(intValueSeek, wxSSoundEncoding));
253                         
254                         if (intType == 0){
255                         
256                                 SoundsListType.insert(std::make_pair(intValueSeek, wxT("")));
257                         
258                         } else if (intType == 1){
259                         
260                                 SoundsListType.insert(std::make_pair(intValueSeek, wxT("home")));
261                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Home"));                 
262                         
263                         } else if (intType == 2){
264                         
265                                 SoundsListType.insert(std::make_pair(intValueSeek, wxT("work")));
266                                 lboLogos->SetItem(ListCtrlIndex, 1, _("Work"));
267                         
268                         }
269                         
270                         SoundsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
271                         
272                         SoundCount++;
273                         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