// xestiacalendar_populate.cpp - Xestia Calendar Unit Testing Suite Populate Functions
//
-// (c) 2016 Xestia Software Development.
+// (c) 2016-2017 Xestia Software Development.
//
// This file is part of Xestia Calendar.
//
void populatecaldav(){
- CalDAV PopulateCalDAV;
+ CalDAV populateCalDAV;
// Load the connection settings.
- CalDAVConnectionData ConnNormal;
- ProcessConnectionDataFileResult DataFileResult;
- bool ValidDataNormal = false;
+ CalDAVConnectionData connNormal;
+ ProcessConnectionDataFileResult dataFileResult;
+ bool validDataNormal = false;
- DataFileResult = ProcessConnectionDataFile("caldavtest.auth", &ConnNormal);
- if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){
- ValidDataNormal = true;
+ dataFileResult = ProcessConnectionDataFile("caldavtest.auth", &connNormal);
+ if (dataFileResult == PROCESSCONNECTIONDATAFILE_OK){
+ validDataNormal = true;
} else {
// Cannot read the caldavtest.auth file properly.
// Connect to the server and create
// the calendar.
- string ServerAddress = "";
- string ServerUserPass = "";
+ string serverAddress = "";
+ string serverUserPass = "";
// Setup the server address.
- string CalendarName = "Unit Testing Calendar";
- string CalendarShortName = "unittestcal";
+ string calendarName = "Unit Testing Calendar";
+ string calendarShortName = "unittestcal";
- PopulateCalDAV.SetupConnectionData(&ConnNormal);
+ populateCalDAV.SetupConnectionData(&connNormal);
- CalDAVServerResult ServerResult;
+ CalDAVServerResult serverResult;
- ServerResult = PopulateCalDAV.Connect();
+ serverResult = populateCalDAV.Connect();
- if (ServerResult.Code != CURLE_OK){
+ if (serverResult.code != CURLE_OK){
cout << "Error while connecting to the CalDAV server." << endl;
- cout << "Xestia Calendar Code: " << ServerResult.Result << endl;
- cout << "cURL Code: " << ServerResult.Code << endl;
- cout << "HTTP Code: " << ServerResult.HTTPCode << endl;
+ cout << "Xestia Calendar Code: " << serverResult.result << endl;
+ cout << "cURL Code: " << serverResult.code << endl;
+ cout << "HTTP Code: " << serverResult.httpCode << endl;
return;
}
// Get the list of calendars.
- CalDAVCalendarList CalendarList = PopulateCalDAV.GetCalendars();
+ CalDAVCalendarList calendarList = populateCalDAV.GetCalendars();
- if (CalendarList.Name.size() == 0){
+ if (calendarList.name.size() == 0){
cout << "Error while getting the list of calendars." << endl;
return;
}
- string CalendarURI = "";
+ string calendarURI = "";
// Look for the Unit testing calendar.
- for (std::map<int,string>::iterator CalNameIter = CalendarList.Name.begin();
- CalNameIter != CalendarList.Name.end(); CalNameIter++){
+ for (std::map<int,string>::iterator calNameIter = calendarList.name.begin();
+ calNameIter != calendarList.name.end(); calNameIter++){
- if (CalNameIter->second == "Unit Testing Calendar"){
- CalendarURI = CalendarList.HREF.find(CalNameIter->first)->second;
+ if (calNameIter->second == "Unit Testing Calendar"){
+ calendarURI = calendarList.href.find(calNameIter->first)->second;
break;
}
}
- if (CalendarURI == ""){
+ if (calendarURI == ""){
cout << "Error while getting the unit testing calendar URI" << endl;
return;
// Delete the previous calendar.
- ServerResult = PopulateCalDAV.DeleteCalendar(&CalendarURI);
+ serverResult = populateCalDAV.DeleteCalendar(&calendarURI);
- if (ServerResult.Code != CURLE_OK){
+ if (serverResult.code != CURLE_OK){
cout << "Error while deleting a calendar." << endl;
- cout << "Xestia Calendar Code: " << ServerResult.Result << endl;
- cout << "cURL Code: " << ServerResult.Code << endl;
- cout << "HTTP Code: " << ServerResult.HTTPCode << endl;
+ cout << "Xestia Calendar Code: " << serverResult.result << endl;
+ cout << "cURL Code: " << serverResult.code << endl;
+ cout << "HTTP Code: " << serverResult.httpCode << endl;
return;
}
// Create the calendar.
- ServerResult = PopulateCalDAV.AddCalendar(&CalendarName, &CalendarShortName);
-
- if (ServerResult.Code != CURLE_OK){
+ serverResult = populateCalDAV.AddCalendar(&calendarName, &calendarShortName);
+
+ if (serverResult.code != CURLE_OK){
cout << "Error while adding a calendar." << endl;
- cout << "Xestia Calendar Code: " << ServerResult.Result << endl;
- cout << "cURL Code: " << ServerResult.Code << endl;
- cout << "HTTP Code: " << ServerResult.HTTPCode << endl;
+ cout << "Xestia Calendar Code: " << serverResult.result << endl;
+ cout << "cURL Code: " << serverResult.code << endl;
+ cout << "HTTP Code: " << serverResult.httpCode << endl;
return;
}
// Get the list of calendars with the new calendar added.
- CalendarList = PopulateCalDAV.GetCalendars();
+ calendarList = populateCalDAV.GetCalendars();
- if (CalendarList.Name.size() == 0){
+ if (calendarList.name.size() == 0){
cout << "Error while getting the list of calendars." << endl;
return;
}
-
- CalendarURI = "";
+
+ calendarURI = "";
// Look for the Unit testing calendar.
- for (std::map<int,string>::iterator CalNameIter = CalendarList.Name.begin();
- CalNameIter != CalendarList.Name.end(); CalNameIter++){
+ for (std::map<int,string>::iterator calNameIter = calendarList.name.begin();
+ calNameIter != calendarList.name.end(); calNameIter++){
- if (CalNameIter->second == "Unit Testing Calendar"){
- CalendarURI = CalendarList.HREF.find(CalNameIter->first)->second;
+ if (calNameIter->second == "Unit Testing Calendar"){
+ calendarURI = calendarList.href.find(calNameIter->first)->second;
break;
}
}
- if (CalendarURI == ""){
+ if (calendarURI == ""){
cout << "Error while getting the unit testing calendar URI" << endl;
return;
// Create five entries.
- string EntryUUIDs[5] = { "XC-UT1", "XC-UT2", "XC-UT3", "XC-UT4", "XC-UT5" };
- string EntryFilename[5] = { "xc-ut1.ics", "xc-ut2.ics", "xc-ut3.ics", "xc-ut4.ics", "xc-ut5.ics" };
- string EntryData[5] = {
+ string entryUUIDs[5] = { "XC-UT1", "XC-UT2", "XC-UT3", "XC-UT4", "XC-UT5" };
+ string entryFilename[5] = { "xc-ut1.ics", "xc-ut2.ics", "xc-ut3.ics", "xc-ut4.ics", "xc-ut5.ics" };
+ string entryData[5] = {
"BEGIN:VCALENDAR\n"
"VERSION:2.0\n"
// Place the entries into the calendar.
- string CalendarEntryURI = "";
+ string calendarEntryURI = "";
- for (int EntrySeek = 0; EntrySeek < 5; EntrySeek++){
+ for (int entrySeek = 0; entrySeek < 5; entrySeek++){
- CalendarEntryURI = CalendarURI;
- CalendarEntryURI += EntryFilename[EntrySeek];
+ calendarEntryURI = calendarURI;
+ calendarEntryURI += entryFilename[entrySeek];
- ServerResult = PopulateCalDAV.AddEntry(&CalendarEntryURI, &EntryData[EntrySeek]);
+ serverResult = populateCalDAV.AddEntry(&calendarEntryURI, &entryData[entrySeek]);
- if (ServerResult.Code != CURLE_OK){
+ if (serverResult.code != CURLE_OK){
cout << "Error while adding an entry to the unit testing calendar." << endl;
- cout << "Xestia Calendar Code: " << ServerResult.Result << endl;
- cout << "cURL Code: " << ServerResult.Code << endl;
- cout << "HTTP Code: " << ServerResult.HTTPCode << endl;
- cout << "URI address: " << CalendarEntryURI << endl;
+ cout << "Xestia Calendar Code: " << serverResult.result << endl;
+ cout << "cURL Code: " << serverResult.code << endl;
+ cout << "HTTP Code: " << serverResult.httpCode << endl;
+ cout << "URI address: " << calendarEntryURI << endl;
return;
}
- CalendarEntryURI.clear();
+ calendarEntryURI.clear();
}