Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
utf8: Implemented further UTF8 support
[xestiacalendar/.git] / source / forms / main / frmMain.cpp
index 9c420ff..11246ae 100644 (file)
@@ -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,7 +207,7 @@ 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.
                
@@ -240,9 +240,9 @@ void frmMain::LoadAccountData(){
                        
                        // 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,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