Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Win32: implement further UTF8 support
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 4 Feb 2018 05:29:51 +0000 (05:29 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 4 Feb 2018 05:29:51 +0000 (05:29 +0000)
12 files changed:
projects/msw/xestiacal.vcxproj
source/common/file.cpp
source/common/file.h
source/forms/main/frmMain.cpp
source/forms/preferences/frmPreferences.cpp
source/libraries/CalendarDataStorage/CalendarDataStorage.cpp
source/libraries/CalendarDataStorage/CalendarDataStorage.h
source/objects/calendarlist/CalendarList.cpp
source/objects/calendarobject/CalendarObject-Save.cpp
source/objects/calendarobject/CalendarObject.cpp
source/objects/calendarobject/CalendarObject.h
source/widgets/XCCalendarDay.cpp

index 45c2117..87e9dcf 100644 (file)
       <AdditionalIncludeDirectories>.\..\..\lib\vc_x64_lib\mswud;.\..\..\include;.;.\..\..\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>wxmsw30ud_core.lib;wxbase30ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>wxmsw30ud_core.lib;wxbase30ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;Shlwapi.dll;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>vc_mswud_x64\minimal.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>.\..\..\lib\vc_x64_lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalIncludeDirectories>.\..\..\lib\vc_x64_dll\mswu;.\..\..\include;.;.\..\..\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>wxmsw30u_core.lib;wxbase30u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>wxmsw30u_core.lib;wxbase30u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;Shlwapi.dll;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>vc_mswu_x64\minimal.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>K:\LibraryBuild\Win7\lib\vc_x64_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalIncludeDirectories>.\..\..\lib\vc_x64_dll\mswud;.\..\..\include;.;.\..\..\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>wxmsw30ud_core.lib;wxmsw30ud_html.lib;wxbase30ud.lib;wxmsw30ud_adv.lib;sqlite3.lib;libcurl.lib;libxml2.dll.a;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;security.lib;cryptui.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>wxmsw30ud_core.lib;wxmsw30ud_html.lib;wxbase30ud.lib;wxmsw30ud_adv.lib;sqlite3.lib;libcurl.lib;libxml2.dll.a;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;security.lib;cryptui.lib;crypt32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>vc_mswuddll_x64\xestiacal.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SQLITE_64BIT);$(SFML_64BIT)\lib;$(LIBXML2_64BIT)\lib;$(CURL_64BIT)\builds\\libcurl-vc-x64-release-dll-zlib-dll-ipv6-sspi-winssl\lib;$(WXWIDGETS_64BIT_DEBUG)\lib\vc_x64_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalIncludeDirectories>.\..\..\lib\vc_x64_dll\mswu;.\..\..\include;.;.\..\..\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>wxmsw30u_core.lib;wxmsw30u_html.lib;wxbase30u.lib;wxmsw30u_adv.lib;sqlite3.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>wxmsw30u_core.lib;wxmsw30u_html.lib;wxbase30u.lib;wxmsw30u_adv.lib;sqlite3.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>vc_mswudll_x64\xestiacal.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SQLITE_64BIT);$(SFML_64BIT)\lib;$(LIBXML2_64BIT)\lib;$(CURL_64BIT)\builds\libcurl-vc-x64-release-dll-zlib-static-ipv6-sspi-winssl\lib;$(WXWIDGETS_64BIT)\lib\vc_x64_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
index 076752d..9e4e448 100644 (file)
@@ -22,7 +22,7 @@ using namespace std;
 
 bool FileExists(std::string filename){
        
-#if defined (__WIN32__)
+#if defined (WIN32)
 
 #else 
 
@@ -36,4 +36,24 @@ bool FileExists(std::string filename){
        
        return true;
        
+}
+
+bool FileExists(std::wstring filename) {
+
+#if defined (WIN32)
+
+       return PathFileExists(filename.c_str());
+
+#else 
+
+       struct stat bufferData;
+
+       if (stat(filename.c_str(), &bufferData) == -1) {
+               return false;
+       }
+
+#endif
+
+       return true;
+
 }
\ No newline at end of file
index 63cc2ca..69303d7 100644 (file)
 
 #include <string>
 #include <iostream>
-#if defined (__WIN32__)
-
+#if defined (WIN32)
+#include <windows.h>
+#include <Shlwapi.h>
 #else
 #include <sys/stat.h>
 #endif
 
 bool FileExists(std::string filename);
+bool FileExists(std::wstring filename);
 
 #endif
\ No newline at end of file
index 11246ae..f7e2c1f 100644 (file)
@@ -211,11 +211,11 @@ void frmMain::LoadAccountData(){
        
                // 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,7 +235,7 @@ 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.
@@ -629,7 +629,7 @@ void frmMain::ProcessCalendar( wxCommandEvent& event )
        accountDirectoryPath += "accounts/";
        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.
index 8157bbb..b9919c7 100644 (file)
@@ -324,9 +324,7 @@ void frmPreferences::DeleteAccount( wxCommandEvent& event )
        
                if (!accountDirFull.IsEmpty()){
        
-                       accountDirDelFull.Append(wxString::FromUTF8(getenv("HOME")));
-                       accountDirDelFull.Append(wxT("/.xestiacal/accounts/"));
-                       accountDirDelFull.Append(accountDirFull);
+                       accountDirDelFull.Append(GetAccountDir(accountDirFull, false));
        
                        DeleteDirectory(accountDirDelFull);
        
index 5842631..5b24853 100644 (file)
@@ -986,9 +986,9 @@ CDSAddEntryResult CalendarDataStorage::AddEvent(int calendarID, std::string file
        
        // Load the event file.
        
-       CalendarEventObject eventData;
+       CalendarEventObject eventData;  
        CalendarObjectLoadResult eventLoadResult = eventData.LoadFile(filename);
-       
+
        // Check the result of the event file load.
        
        switch (eventLoadResult){
index 402aee8..1e934df 100644 (file)
 #include "../../common/colour.h"
 #include "../../common/random.h"
 
+#if defined(WIN32)
+#include <Windows.h>
+#endif
+
 enum CDSAccountResult{
        CDSACCOUNT_UNITTESTFAIL = -1,
        CDSACCOUNT_OK,
index 8d4f1b5..403270c 100644 (file)
@@ -46,13 +46,13 @@ XCAccountCalendarList::XCAccountCalendarList(string calendarListFilename){
                
                calendarListFile->SetPath(accountName);
 
-               calendarShortName.push_back(string(accountName.mb_str()));
+               calendarShortName.push_back(string(accountName.ToUTF8()));
                
                calendarListFile->Read(wxT("name"), &valueData);
-               calendarName.push_back(string(valueData.mb_str()));
+               calendarName.push_back(string(valueData.ToUTF8()));
 
                calendarListFile->Read(wxT("description"), &valueData);
-               calendarDescription.push_back(string(valueData.mb_str()));
+               calendarDescription.push_back(string(valueData.ToUTF8()));
 
                calendarListFile->Read(wxT("colour"), &valueData);
                colourData = string(valueData.mb_str());
index 0cbe83e..0d72b46 100644 (file)
@@ -28,7 +28,25 @@ CalendarObjectSaveResult CalendarObject::SaveFile(string saveFilename){
        
        // Open the file.
        
+#ifndef WIN32
+
        fileStream.open(saveFilename, ofstream::out);
+
+#else
+
+       wstring saveFilename_utf16;
+
+       int len = MultiByteToWideChar(CP_UTF8, 0, &saveFilename[0], (int)saveFilename.size(), NULL, 0);
+
+       if (len > 0)
+       {
+               saveFilename_utf16.resize(len);
+               MultiByteToWideChar(CP_UTF8, 0, &saveFilename[0], (int)saveFilename.size(), &saveFilename_utf16[0], len);
+       }
+
+       fileStream.open(saveFilename_utf16, ofstream::out);
+
+#endif
        
        if (fileStream.rdstate() & ofstream::failbit){
                return CALENDAROBJECTSAVE_CANNOTOPEN;
@@ -45,8 +63,10 @@ CalendarObjectSaveResult CalendarObject::SaveFile(string saveFilename){
        
        saveResult = SaveString(&saveStringData);
        
-       fileStream.write(saveStringData.c_str(), saveStringData.size());
+       //fileStream.write(saveStringData.c_str(), saveStringData.size());
        
+       fileStream << saveStringData.c_str();
+
        fileStream.close();
        
        return saveResult;
index 6cfe78b..76cb4e6 100644 (file)
@@ -26,15 +26,37 @@ CalendarObjectLoadResult CalendarObject::LoadFile(std::string loadFilename){
        // Check if the file exists and return 
        // CALENDAROBJECTLOAD_CANNOTOPEN if not.
        
-       if (!FileExists(loadFilename)){
-               return CALENDAROBJECTLOAD_MISSING;
-       }
-       
        ifstream fileStream;
        string receivedStringData = "";
        
+#ifndef WIN32
+
+       if (!FileExists(loadFilename)) {
+               return CALENDAROBJECTLOAD_MISSING;
+       }
+
        fileStream.open(loadFilename, ifstream::in);
-       
+
+#else
+
+       wstring loadFilename_utf16;
+
+       int len = MultiByteToWideChar(CP_UTF8, 0, &loadFilename[0], (int)loadFilename.size(), NULL, 0);
+
+       if (len > 0)
+       {
+               loadFilename_utf16.resize(len);
+               MultiByteToWideChar(CP_UTF8, 0, &loadFilename[0], (int)loadFilename.size(), &loadFilename_utf16[0], len);
+       }
+
+       if (!FileExists(loadFilename_utf16)) {
+               return CALENDAROBJECTLOAD_MISSING;
+       }
+
+       fileStream.open(loadFilename_utf16, ifstream::in);
+
+#endif
+
        if (fileStream.rdstate() & ifstream::failbit){
                return CALENDAROBJECTLOAD_CANNOTOPEN;
        }
index a99b796..1b03eee 100644 (file)
 #include "../../common/text.h"
 #include "../../version.h"
 
+#if defined(WIN32)
+#include <Windows.h>
+#endif
+
 using namespace std;
 
 enum CalendarObjectLoadResult {
index 656ad75..64bd1b4 100644 (file)
@@ -524,7 +524,6 @@ void XCCalendarDay::DeleteCalendarEntries(wxCommandEvent &calendarData){
        
        this->Refresh();
        mainPanel->Layout();
-       eventListFrame->Layout();
        eventListFrameSizer->Layout();
        
        for (auto deleteIter : deleteEntriesList){
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