1 #include "CalendarTask.h"
5 CalendarObjectValidResult CalendarTaskObject::ValidObject(){
7 bool ValidBegin = false;
9 bool ValidDateTimeStamp = false;
10 bool ValidUniqueID = false;
14 // Look for BEGIN:VTODO.
16 for (vector<string>::iterator iter = ObjectName.begin();
17 iter != ObjectName.end(); iter++){
19 if (ObjectName[SeekCount] == "BEGIN" &&
20 ObjectData[SeekCount] == "VTODO"){
22 if (ValidBegin == false){
25 return CALENDAROBJECTVALID_INVALIDFORMAT;
30 if (ObjectName[SeekCount] == "END" &&
31 ObjectData[SeekCount] == "VTODO" &&
34 return CALENDAROBJECTVALID_INVALIDFORMAT;
46 for (vector<string>::iterator iter = ObjectName.begin();
47 iter != ObjectName.end(); iter++){
50 PropertyName = ObjectName[SeekCount].substr(0,7);
53 catch(const out_of_range& oor){
57 if (PropertyName == "DTSTAMP"){
59 if (ValidDateTimeStamp == false){
60 ValidDateTimeStamp = true;
62 return CALENDAROBJECTVALID_INVALIDFORMAT;
75 for (vector<string>::iterator iter = ObjectName.begin();
76 iter != ObjectName.end(); iter++){
79 PropertyName = ObjectName[SeekCount].substr(0,3);
82 catch(const out_of_range& oor){
86 if (PropertyName == "UID"){
88 if (ValidUniqueID == false){
91 return CALENDAROBJECTVALID_INVALIDFORMAT;
102 // Look for END:VTODO.
104 for (vector<string>::iterator iter = ObjectName.begin();
105 iter != ObjectName.end(); iter++){
107 if (ObjectName[SeekCount] == "END" &&
108 ObjectData[SeekCount] == "VTODO"){
110 if (ValidEnd == false){
113 return CALENDAROBJECTVALID_INVALIDFORMAT;
122 // Check if the VTODO is valid.
124 if (ValidBegin == true &&
126 ValidDateTimeStamp == true &&
127 ValidUniqueID == true){
129 return CALENDAROBJECTVALID_OK;
133 return CALENDAROBJECTVALID_INVALIDFORMAT;
139 void CalendarTaskObject::ProcessData(){
143 multimap<string,string> DataReceived;
144 map<string,string> PropertyData;
145 string *PropertyNameData = nullptr;
146 int ObjectSeekCount = 0;
148 // Get the Date Time Stamp (DTSTAMP).
150 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
152 // Process the data from DTSTAMP.
154 if (DataReceived.begin() != DataReceived.end()){
157 DateTimeStampTokens = DataReceived.begin()->first.substr(8);
160 catch(const out_of_range &oor){
161 // Do nothing as there is no data.
164 DateTimeStampData = DataReceived.begin()->second;
168 // Get the Unique ID (UID).
170 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
172 // Process the data from UID.
174 if (DataReceived.begin() != DataReceived.end()){
177 UniqueIDTokens = DataReceived.begin()->first.substr(4);
180 catch(const out_of_range &oor){
181 // Do nothing as there is no data.
184 UniqueID = DataReceived.begin()->second;
188 // Process the data from CLASS.
190 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CLASS");
192 if (DataReceived.begin() != DataReceived.end()){
195 ClassDataTokens = DataReceived.begin()->first.substr(6);
198 catch(const out_of_range &oor){
199 // Do nothing as there is no data.
202 ClassData = DataReceived.begin()->second;
206 // Process the data from COMPLETED.
208 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "COMPLETED");
210 if (DataReceived.begin() != DataReceived.end()){
213 CompletedDataTokens = DataReceived.begin()->first.substr(10);
216 catch(const out_of_range &oor){
217 // Do nothing as there is no data.
220 CompletedData = DataReceived.begin()->second;
224 // Process the data from CREATED.
226 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CREATED");
228 if (DataReceived.begin() != DataReceived.end()){
231 DateTimeCreatedTokens = DataReceived.begin()->first.substr(8);
234 catch(const out_of_range &oor){
235 // Do nothing as there is no data.
238 DateTimeCreatedData = DataReceived.begin()->second;
242 // Process the data from DESCRIPTION.
244 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DESCRIPTION");
246 if (DataReceived.begin() != DataReceived.end()){
248 bool TokenData = false;
249 string PropertyTokens;
251 PropertyNameData = (string*)&DataReceived.begin()->first;
253 PropertyData = SplitValues(*PropertyNameData);
255 for(map<string,string>::iterator iter = PropertyData.begin();
256 iter != PropertyData.end(); iter++){
258 if (iter->first == "ALTREP"){
260 DescriptionListAltRep.clear();
261 DescriptionListAltRep.push_back(iter->second);
263 } else if (iter->first == "LANGUAGE"){
265 DescriptionListLanguage.clear();
266 DescriptionListLanguage.push_back(iter->second);
270 if (TokenData == false){
273 PropertyTokens += ";";
276 PropertyTokens += iter->first;
277 PropertyTokens += "=";
278 PropertyTokens += iter->second;
284 if (PropertyTokens.size() > 0){
285 DescriptionListTokens.clear();
286 DescriptionListTokens.push_back(PropertyTokens);
289 DescriptionList.clear();
290 DescriptionList.push_back(DataReceived.begin()->second);
294 // Get the Date Time Start value.
296 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTART");
298 // Process the data from DTSTART.
300 if (DataReceived.begin() != DataReceived.end()){
302 bool TokenData = false;
303 string PropertyTokens;
305 PropertyNameData = (string*)&DataReceived.begin()->first;
307 PropertyData = SplitValues(*PropertyNameData);
309 for(map<string,string>::iterator iter = PropertyData.begin();
310 iter != PropertyData.end(); iter++){
312 if (iter->first == "VALUE"){
314 DateTimeStartDataValue = iter->second;
316 } else if (iter->first == "TZID"){
318 DateTimeStartDataTimeZoneID = iter->second;
322 if (TokenData == false){
325 PropertyTokens += ";";
328 PropertyTokens += iter->first;
329 PropertyTokens += "=";
330 PropertyTokens += iter->second;
336 if (PropertyTokens.size() > 0){
337 DateTimeStartDataTokens = PropertyTokens;
340 DateTimeStartData = DataReceived.begin()->second;
344 // Process the data from GEO.
346 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "GEO");
348 if (DataReceived.begin() != DataReceived.end()){
351 GeographicTokens = DataReceived.begin()->first.substr(4);
354 catch(const out_of_range &oor){
355 // Do nothing as there is no data.
358 GeographicData = DataReceived.begin()->second;
362 // Process the data from LAST-MODIFIED.
364 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LAST-MODIFIED");
366 if (DataReceived.begin() != DataReceived.end()){
369 LastModifiedTokens = DataReceived.begin()->first.substr(14);
372 catch(const out_of_range &oor){
373 // Do nothing as there is no data.
376 LastModifiedData = DataReceived.begin()->second;
380 // Process the data from LOCATION.
382 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LOCATION");
384 if (DataReceived.begin() != DataReceived.end()){
386 bool TokenData = false;
387 string PropertyTokens;
389 PropertyNameData = (string*)&DataReceived.begin()->first;
391 PropertyData = SplitValues(*PropertyNameData);
393 for(map<string,string>::iterator iter = PropertyData.begin();
394 iter != PropertyData.end(); iter++){
396 if (iter->first == "ALTREP"){
398 LocationDataAltRep = iter->second;
400 } else if (iter->first == "LANGUAGE"){
402 LocationDataLanguage = iter->second;
406 if (TokenData == false){
409 PropertyTokens += ";";
412 PropertyTokens += iter->first;
413 PropertyTokens += "=";
414 PropertyTokens += iter->second;
420 if (PropertyTokens.size() > 0){
422 LocationDataTokens = PropertyTokens;
426 LocationData = DataReceived.begin()->second;
430 // Process the data from ORGANIZER.
432 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "ORGANIZER");
434 if (DataReceived.begin() != DataReceived.end()){
436 bool TokenData = false;
437 string PropertyTokens;
439 PropertyNameData = (string*)&DataReceived.begin()->first;
441 PropertyData = SplitValues(*PropertyNameData);
443 for(map<string,string>::iterator iter = PropertyData.begin();
444 iter != PropertyData.end(); iter++){
446 if (iter->first == "CN"){
448 OrganiserDataCommonName = iter->second;
450 } else if (iter->first == "DIR"){
452 OrganiserDataDirectoryEntry = iter->second;
454 } else if (iter->first == "SENT-BY"){
456 OrganiserDataSentByParam = iter->second;
458 } else if (iter->first == "LANGUAGE"){
460 OrganiserDataLanguage = iter->second;
464 if (TokenData == false){
467 PropertyTokens += ";";
470 PropertyTokens += iter->first;
471 PropertyTokens += "=";
472 PropertyTokens += iter->second;
478 if (PropertyTokens.size() > 0){
480 OrganiserDataTokens = PropertyTokens;
484 OrganiserData = DataReceived.begin()->second;