X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fforms%2Fmain%2FfrmMain.cpp;h=f7e2c1fa85426040f0cca258ee8439833c7c5e05;hp=9c420ffe6870dae897b62b8cd67aa0fc6551a271;hb=49789773e2797383c866dca470fb99e80cb49e41;hpb=ca1d24d80ec04ae64a7540cf8bca61c053f2a193 diff --git a/source/forms/main/frmMain.cpp b/source/forms/main/frmMain.cpp index 9c420ff..f7e2c1f 100644 --- a/source/forms/main/frmMain.cpp +++ b/source/forms/main/frmMain.cpp @@ -199,7 +199,7 @@ void frmMain::LoadAccountData(){ for (int accountSeek = 0; accountSeek < accountCount; accountSeek++){ - CDSAccountResult addResult = calendarData.AddAccount(string(preferences->accounts.GetAccountName(accountSeek).mb_str()), accountSeek); + CDSAccountResult addResult = calendarData.AddAccount(string(preferences->accounts.GetAccountName(accountSeek).ToUTF8()), accountSeek); } @@ -207,15 +207,15 @@ void frmMain::LoadAccountData(){ for (int accountSeek = 0; accountSeek < accountCount; accountSeek++){ - CDSGetAccountInfo accountInfo = calendarData.GetAccount(string(preferences->accounts.GetAccountName(accountSeek).mb_str())); + CDSGetAccountInfo accountInfo = calendarData.GetAccount(string(preferences->accounts.GetAccountName(accountSeek).ToUTF8())); // Build the path. - string calendarListFilename = string(GetUserDir().mb_str()); + string calendarListFilename = string(GetUserDir().ToUTF8()); calendarListFilename += "accounts/"; - calendarListFilename += string(preferences->accounts.GetAccountDirectory(accountSeek).mb_str()); + calendarListFilename += string(preferences->accounts.GetAccountDirectory(accountSeek).ToUTF8()); calendarListFilename += "."; - calendarListFilename += string(preferences->accounts.GetAccountType(accountSeek).mb_str()); + calendarListFilename += string(preferences->accounts.GetAccountType(accountSeek).ToUTF8()); // Get the list of calendars. @@ -235,14 +235,14 @@ void frmMain::LoadAccountData(){ // Set the calendar ID. - CDSGetCalendarInfo calendarInfo = calendarData.GetCalendar(string(preferences->accounts.GetAccountName(accountSeek).mb_str()), calendarList.calendarShortName[calendarSeek]); + CDSGetCalendarInfo calendarInfo = calendarData.GetCalendar(string(preferences->accounts.GetAccountName(accountSeek).ToUTF8()), calendarList.calendarShortName[calendarSeek]); calendarList.calendarStorageID[calendarSeek] = calendarInfo.calendarID; // Find the entries and load each entry. - string calendarListDirectory = calendarListFilename; + wxString calendarListDirectory = wxString(calendarListFilename.c_str(), wxConvUTF8); calendarListDirectory += "/"; - calendarListDirectory += calendarList.calendarShortName[calendarSeek]; + calendarListDirectory += wxString(calendarList.calendarShortName[calendarSeek].c_str(), wxConvUTF8); calendarListDirectory += "/"; wxDir entryListDirectory(calendarListDirectory); @@ -253,8 +253,8 @@ void frmMain::LoadAccountData(){ while (continueProcessing){ string entryListFullFilename; - entryListFullFilename += calendarListDirectory; - entryListFullFilename += string(entryListFilename.mb_str()); + entryListFullFilename += string(calendarListDirectory.ToUTF8()); + entryListFullFilename += string(entryListFilename.ToUTF8()); continueProcessing = entryListDirectory.GetNext(&entryListFilename); CDSAddEntryResult addEventResult = calendarData.AddEvent(calendarInfo.calendarID, entryListFullFilename); @@ -434,7 +434,7 @@ void frmMain::DeleteCalendar( wxCommandEvent& event ) CDSGetCalendarInfo calendarInfo = calendarData.GetCalendar(calendarEventInfo->calendarID); - if (wxMessageBox(wxString::Format("Are you sure you want to delete the calendar %s from the %s account?", calendarInfo.calendarName, calendarInfo.accountName), "Delete calendar", wxYES_NO|wxICON_QUESTION) == wxNO){ + if (wxMessageBox(wxString::Format("Are you sure you want to delete the calendar %s from the %s account?", wxString(calendarInfo.calendarName.c_str(), wxConvUTF8), wxString(calendarInfo.accountName.c_str(), wxConvUTF8)), "Delete calendar", wxYES_NO|wxICON_QUESTION) == wxNO){ return; } @@ -448,13 +448,13 @@ void frmMain::DeleteCalendar( wxCommandEvent& event ) // Get the account configuration file and delete the calendar information. - CDSGetAccountInfo accountInfo = calendarData.GetAccount(calendarInfo.accountName); + CDSGetAccountInfo accountInfo = calendarData.GetAccount(calendarInfo.accountName.c_str()); string accountDirectoryPath = string(GetUserDir().mb_str()); accountDirectoryPath += "accounts/"; - accountDirectoryPath += string(preferences->accounts.GetAccountDirectory(calendarEventInfo->accountPreferencesID).mb_str()); + accountDirectoryPath += string(preferences->accounts.GetAccountDirectory(calendarEventInfo->accountPreferencesID).ToUTF8()); accountDirectoryPath += "."; - accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarEventInfo->accountPreferencesID).mb_str()); + accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarEventInfo->accountPreferencesID).ToUTF8()); accountDirectoryPath += "/"; string calendarListFilenameFull = accountDirectoryPath; @@ -463,37 +463,42 @@ void frmMain::DeleteCalendar( wxCommandEvent& event ) string calendarDirectoryPath = accountDirectoryPath; calendarDirectoryPath += calendarInfo.calendarTextID; - wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull)); - - //calendarListFile->SetPath(wxString(calendarInfo.calendarTextID)); - calendarListFile->DeleteGroup(wxString(calendarInfo.calendarTextID)); + wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull.c_str(), wxConvUTF8)); // Delete the calendar directory. - wxDir entryListDirectory((wxString)calendarDirectoryPath.c_str()); + wxDir entryListDirectory(wxString(calendarDirectoryPath.c_str(), wxConvUTF8)); wxString entryListFilename; bool continueProcessing = entryListDirectory.GetFirst(&entryListFilename, "*", wxDIR_NO_FOLLOW|wxDIR_FILES); - + while (continueProcessing){ string entryListFullFilename; - entryListFullFilename += calendarDirectoryPath; + entryListFullFilename += wxString(calendarDirectoryPath.c_str(), wxConvUTF8); entryListFullFilename += "/"; entryListFullFilename += string(entryListFilename.mb_str()); - wxRemoveFile(wxString(entryListFullFilename.c_str())); + wxRemoveFile(wxString(entryListFullFilename.c_str(), wxConvUTF8)); continueProcessing = entryListDirectory.GetNext(&entryListFilename); } - - wxRmdir(calendarDirectoryPath); + + entryListDirectory.Close(); + + // Delete the calendar from the account calendar list. + + calendarListFile->DeleteGroup(wxString(calendarInfo.calendarTextID)); // Delete the calendar from the calendar data storage. calendarData.DeleteCalendar(calendarEventInfo->calendarID); + // Delete the calendar directory. + + wxRmDir(wxString(calendarDirectoryPath.c_str(), wxConvUTF8)); + delete calendarListFile; calendarListFile = nullptr; @@ -561,7 +566,7 @@ void frmMain::DeleteEvent( wxCommandEvent& event ){ CDSGetCalendarEntryInfo eventDeleteData = calendarData.GetEvent(eventInfo->eventID); CDSGetCalendarInfo calendarDeleteData = calendarData.GetCalendar(eventInfo->calendarID); - if (wxMessageBox(wxString::Format("Are you sure you want to delete the event %s from the %s calendar?", eventDeleteData.entryName, calendarDeleteData.calendarName), "Delete event", wxYES_NO|wxICON_QUESTION) == wxNO){ + if (wxMessageBox(wxString::Format("Are you sure you want to delete the event %s from the %s calendar?", wxString(eventDeleteData.entryName.c_str(), wxConvUTF8), wxString(calendarDeleteData.calendarName.c_str(), wxConvUTF8)), "Delete event", wxYES_NO|wxICON_QUESTION) == wxNO){ return; } @@ -574,7 +579,7 @@ void frmMain::DeleteEvent( wxCommandEvent& event ){ // Get the filename and delete the entry. - wxRemoveFile(wxString(eventDeleteData.entryFilename.c_str())); + wxRemoveFile(wxString(eventDeleteData.entryFilename.c_str(), wxConvUTF8)); // Delete the entry from the calendar data storage. @@ -616,15 +621,15 @@ void frmMain::ProcessCalendar( wxCommandEvent& event ) // Get the account name. - CDSGetAccountInfo accountInfo = calendarData.GetAccount(calendarInfo->accountName); + CDSGetAccountInfo accountInfo = calendarData.GetAccount(calendarInfo->accountName.c_str()); // Build the account directory path. string accountDirectoryPath = string(GetUserDir().mb_str()); accountDirectoryPath += "accounts/"; - accountDirectoryPath += string(preferences->accounts.GetAccountDirectory(calendarInfo->accountPreferencesID).mb_str()); + accountDirectoryPath += string(preferences->accounts.GetAccountDirectory(calendarInfo->accountPreferencesID).ToUTF8()); accountDirectoryPath += "."; - accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarInfo->accountPreferencesID).mb_str()); + accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarInfo->accountPreferencesID).ToUTF8()); accountDirectoryPath += "/"; // Generate a UUID for the new calendar. @@ -652,9 +657,9 @@ void frmMain::ProcessCalendar( wxCommandEvent& event ) string calendarListFilenameFull = accountDirectoryPath; calendarListFilenameFull += "calendarlist.db"; - wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull)); + wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull.c_str(), wxConvUTF8)); - wxString calendarDescription = wxString(calendarInfo->calendarDescription); + wxString calendarDescription = wxString(calendarInfo->calendarDescription.c_str(), wxConvUTF8); calendarDescription.Replace("\n", "\\n", true); @@ -662,13 +667,13 @@ void frmMain::ProcessCalendar( wxCommandEvent& event ) // not editing a calendar. calendarListFile->SetPath(wxString(calendarUUID)); - calendarListFile->Write(wxT("name"), wxString(calendarInfo->calendarName)); + calendarListFile->Write(wxT("name"), wxString(calendarInfo->calendarName.c_str(), wxConvUTF8)); calendarListFile->Write(wxT("description"), calendarDescription); calendarListFile->Write(wxT("colour"), wxString(calendarInfo->calendarColour)); if (calendarInfo->editMode == false){ - wxMkDir(wxString(calendarPath), wxS_DIR_DEFAULT); + wxMkDir(wxString(calendarPath.c_str(), wxConvUTF8), wxS_DIR_DEFAULT); calendarData.AddCalendar(accountInfo.accountID, calendarInfo->calendarName, calendarUUID, calendarInfo->calendarColour, calendarInfo->calendarDescription); } else {