Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Implemented UTF8 support in DeleteCalendar function
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 28 Jan 2018 14:41:56 +0000 (14:41 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 28 Jan 2018 15:41:47 +0000 (15:41 +0000)
source/forms/main/frmMain.cpp

index 9c420ff..2f826de 100644 (file)
@@ -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,11 +448,11 @@ 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 += "/";
@@ -465,35 +465,40 @@ void frmMain::DeleteCalendar( wxCommandEvent& event )
        
        wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull));
        
-       //calendarListFile->SetPath(wxString(calendarInfo.calendarTextID));
-       calendarListFile->DeleteGroup(wxString(calendarInfo.calendarTextID));
-       
        // 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;
        
@@ -616,13 +621,13 @@ 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 += "/";
@@ -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 {
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