aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar wodim2017-05-24 12:10:49 +0200
committerGravatar GitHub2017-05-24 12:10:49 +0200
commit8b81b079117e37d8e09d110bdffd3e6eaf2a3543 (patch)
treedf3940628d12129edd67f9ce8f4282129fbb8956 /src/modules
parentBuild also in debug mode for windows (#2192) (diff)
downloadKVIrc-8b81b079117e37d8e09d110bdffd3e6eaf2a3543.tar.gz
KVIrc-8b81b079117e37d8e09d110bdffd3e6eaf2a3543.tar.bz2
KVIrc-8b81b079117e37d8e09d110bdffd3e6eaf2a3543.zip
Make Windows code Unicode-aware (#2219)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/addon/WebAddonInterfaceDialog.cpp2
-rw-r--r--src/modules/file/libkvifile.cpp12
-rw-r--r--src/modules/filetransferwindow/FileTransferWindow.cpp2
-rw-r--r--src/modules/mediaplayer/MpAmipInterface.cpp2
-rw-r--r--src/modules/mediaplayer/MpWinampInterface.cpp12
-rw-r--r--src/modules/options/OptionsWidget_textEncoding.cpp2
-rw-r--r--src/modules/setup/SetupWizard.cpp10
-rw-r--r--src/modules/snd/libkvisnd.cpp2
-rw-r--r--src/modules/system/libkvisystem.cpp24
-rw-r--r--src/modules/theme/WebThemeInterfaceDialog.cpp2
10 files changed, 30 insertions, 40 deletions
diff --git a/src/modules/addon/WebAddonInterfaceDialog.cpp b/src/modules/addon/WebAddonInterfaceDialog.cpp
index ab639093c..8eabd0268 100644
--- a/src/modules/addon/WebAddonInterfaceDialog.cpp
+++ b/src/modules/addon/WebAddonInterfaceDialog.cpp
@@ -43,7 +43,7 @@ WebAddonInterfaceDialog::WebAddonInterfaceDialog(QWidget * par)
setPackagePageUrl(
QString::fromLatin1("http://www.kvirc.de/app/addons.php?version=" KVI_VERSION "&lang=%1")
- .arg(QString::fromUtf8(KviLocale::instance()->localeName().ptr())));
+ .arg(KviLocale::instance()->localeName()));
}
WebAddonInterfaceDialog::~WebAddonInterfaceDialog()
= default;
diff --git a/src/modules/file/libkvifile.cpp b/src/modules/file/libkvifile.cpp
index b37e02dd4..84d7d5d37 100644
--- a/src/modules/file/libkvifile.cpp
+++ b/src/modules/file/libkvifile.cpp
@@ -1478,19 +1478,25 @@ static bool file_kvs_fnc_diskSpace(KviKvsModuleFunctionCall * c)
if(szPath.isEmpty())
szPath = ".";
- const char * pcPath = szPath.toUtf8().data();
long long int fTotal;
long long int fFree;
// this for win
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
ULARGE_INTEGER free, total;
- GetDiskFreeSpaceExA((LPCTSTR)pcPath, NULL, &total, &free);
+ if (GetDiskFreeSpaceEx(szPath.toStdWString().c_str(), NULL, &total, &free) == 0) {
+ c->warning(__tr2qs("An error occurred retrieving the amount of free space in '%Q'"), &szPath);
+ return true;
+ }
fFree = free.QuadPart;
fTotal = total.QuadPart;
#else
// this one for linux and macos
+ auto pcPath = szPath.toUtf8();
struct statvfs stFileSystem;
- statvfs(pcPath, &stFileSystem);
+ if (statvfs(pcPath.data(), &stFileSystem) == -1) {
+ c->warning(__tr2qs("An error occurred retrieving the amount of free space in '%Q'"), &szPath);
+ return true;
+ }
fFree = stFileSystem.f_bavail * stFileSystem.f_bsize;
fTotal = stFileSystem.f_blocks * stFileSystem.f_bsize;
#endif
diff --git a/src/modules/filetransferwindow/FileTransferWindow.cpp b/src/modules/filetransferwindow/FileTransferWindow.cpp
index d41f0db52..d802c2bc1 100644
--- a/src/modules/filetransferwindow/FileTransferWindow.cpp
+++ b/src/modules/filetransferwindow/FileTransferWindow.cpp
@@ -666,7 +666,7 @@ void FileTransferWindow::openLocalFile()
if(tmp.isEmpty())
return;
tmp.replace("/", "\\");
- ShellExecute(0, "open", tmp.toLocal8Bit().data(), NULL, NULL, SW_SHOWNORMAL); //You have to link the shell32.lib
+ ShellExecute(0, TEXT("open"), tmp.toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL); //You have to link the shell32.lib
#else
// G&N end
#ifdef COMPILE_KDE4_SUPPORT
diff --git a/src/modules/mediaplayer/MpAmipInterface.cpp b/src/modules/mediaplayer/MpAmipInterface.cpp
index ddea46685..640c9fc8f 100644
--- a/src/modules/mediaplayer/MpAmipInterface.cpp
+++ b/src/modules/mediaplayer/MpAmipInterface.cpp
@@ -77,7 +77,7 @@ MP_AC_DYNPTR(int, ac_eval, const char * cmd COMMA() char * result);
static bool loadAmipDll()
{
- amip_dll = LoadLibrary("ac.dll");
+ amip_dll = LoadLibrary(TEXT("ac.dll"));
if(!amip_dll)
return false;
diff --git a/src/modules/mediaplayer/MpWinampInterface.cpp b/src/modules/mediaplayer/MpWinampInterface.cpp
index 88846bf01..0d08cc4b5 100644
--- a/src/modules/mediaplayer/MpWinampInterface.cpp
+++ b/src/modules/mediaplayer/MpWinampInterface.cpp
@@ -175,7 +175,7 @@ static QTextCodec * mediaplayer_get_codec()
static HWND find_winamp(KviWinampInterface * i)
{
- HWND hWnd = FindWindow("Winamp v1.x", NULL);
+ HWND hWnd = FindWindow(TEXT("Winamp v1.x"), NULL);
if(!hWnd)
{
// try to start the process ?
@@ -429,11 +429,11 @@ bool KviWinampInterface::jumpTo(kvs_int_t & iPos)
bool KviWinampInterface::hide()
{
HWND hWinamp = find_winamp(this);
- HWND hWinampPE = FindWindow("Winamp PE", NULL); /*Playlist*/
- HWND hWinampEQ = FindWindow("Winamp EQ", NULL); /*Equalizer*/
- HWND hWinampMB = FindWindow("Winamp MB", NULL); /*MiniBrowser*/
- HWND hWinampGen = FindWindow("Winamp Gen", NULL); /*Library*/
- HWND hWinampVideo = FindWindow("Winamp Video", NULL); /*Video*/
+ HWND hWinampPE = FindWindow(TEXT("Winamp PE"), NULL); /*Playlist*/
+ HWND hWinampEQ = FindWindow(TEXT("Winamp EQ"), NULL); /*Equalizer*/
+ HWND hWinampMB = FindWindow(TEXT("Winamp MB"), NULL); /*MiniBrowser*/
+ HWND hWinampGen = FindWindow(TEXT("Winamp Gen"), NULL); /*Library*/
+ HWND hWinampVideo = FindWindow(TEXT("Winamp Video"), NULL); /*Video*/
if(hWinamp)
{
ShowWindow(hWinamp, SW_HIDE);
diff --git a/src/modules/options/OptionsWidget_textEncoding.cpp b/src/modules/options/OptionsWidget_textEncoding.cpp
index f6bd526f9..249e14784 100644
--- a/src/modules/options/OptionsWidget_textEncoding.cpp
+++ b/src/modules/options/OptionsWidget_textEncoding.cpp
@@ -122,7 +122,7 @@ OptionsWidget_textEncoding::OptionsWidget_textEncoding(QWidget * parent)
szTmp.replace("kvirc_", "");
szTmp.replace(".mo", "");
m_pForcedLocaleCombo->insertItem(m_pForcedLocaleCombo->count(), szTmp);
- if(KviQString::equalCI(szTmp, m_szLanguage))
+ if(QString::compare(szTmp, m_szLanguage, Qt::CaseInsensitive) == 0)
iMatch = i + 2;
i++;
}
diff --git a/src/modules/setup/SetupWizard.cpp b/src/modules/setup/SetupWizard.cpp
index 93ab3857f..8ae48632f 100644
--- a/src/modules/setup/SetupWizard.cpp
+++ b/src/modules/setup/SetupWizard.cpp
@@ -544,7 +544,7 @@ SetupWizard::SetupWizard()
HKEY hKey;
QString szMircDir;
- if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "ChatFile\\DefaultIcon", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+ if(RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("ChatFile\\DefaultIcon"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
if(RegQueryValueEx(hKey, 0, 0, 0, (LPBYTE)buffer, &len) == ERROR_SUCCESS)
{
@@ -802,11 +802,11 @@ void SetupWizard::makeLink()
// Dig in the registry looking up the Desktop path
if(RegOpenKeyEx(HKEY_CURRENT_USER,
- "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
+ TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"),
0, KEY_QUERY_VALUE, &hCU)
== ERROR_SUCCESS)
{
- RegQueryValueEx(hCU, "Desktop", NULL, &lpType,
+ RegQueryValueEx(hCU, TEXT("Desktop"), NULL, &lpType,
(unsigned char *)&szLink, &ulSize);
RegCloseKey(hCU);
}
@@ -839,9 +839,9 @@ void SetupWizard::makeLink()
{
WORD wsz[MAX_PATH];
// Set the path to the shell link target.
- psl->SetPath(QTextCodec::codecForLocale()->fromUnicode(szKvircExec).data());
+ psl->SetPath(szKvircExec.toStdWString().c_str());
// Set the description of the shell link.
- psl->SetDescription("kvirc");
+ psl->SetDescription(TEXT("kvirc"));
// Ensure string is ANSI.
MultiByteToWideChar(CP_ACP, 0, QTextCodec::codecForLocale()->fromUnicode(szLinkTarget).data(), -1, (LPWSTR)wsz, MAX_PATH);
// Save the link via the IPersistFile::Save method.
diff --git a/src/modules/snd/libkvisnd.cpp b/src/modules/snd/libkvisnd.cpp
index 1e0cc2f95..a324b91a9 100644
--- a/src/modules/snd/libkvisnd.cpp
+++ b/src/modules/snd/libkvisnd.cpp
@@ -288,7 +288,7 @@ void KviSoundPlayer::cleanupPhonon()
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
bool KviSoundPlayer::playWinmm(const QString & szFileName)
{
- sndPlaySound(szFileName.toLocal8Bit().data(), SND_ASYNC | SND_NODEFAULT);
+ sndPlaySound(szFileName.toStdWString().c_str(), SND_ASYNC | SND_NODEFAULT);
return true;
}
diff --git a/src/modules/system/libkvisystem.cpp b/src/modules/system/libkvisystem.cpp
index 3f7402508..42adb10b1 100644
--- a/src/modules/system/libkvisystem.cpp
+++ b/src/modules/system/libkvisystem.cpp
@@ -208,10 +208,7 @@ static bool system_kvs_fnc_getenv(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER("variable", KVS_PT_NONEMPTYSTRING, 0, szVariable)
KVSM_PARAMETERS_END(c)
- QByteArray szVar = szVariable.toLocal8Bit();
-
- char * b = KviEnvironment::getVariable(szVar.data());
- c->returnValue()->setString(b ? QString::fromLocal8Bit(b) : QString());
+ c->returnValue()->setString(KviEnvironment::getVariable(szVariable));
return true;
}
@@ -651,23 +648,10 @@ static bool system_kvs_cmd_setenv(KviKvsModuleCommandCall * c)
KVSM_PARAMETER("value", KVS_PT_STRING, KVS_PF_OPTIONAL, szValue)
KVSM_PARAMETERS_END(c)
- QByteArray szVar = szVariable.toLocal8Bit();
- QByteArray szVal = szValue.toLocal8Bit();
-
- if(szVal.isEmpty())
- KviEnvironment::unsetVariable(szVar.data());
+ if(szValue.isEmpty())
+ KviEnvironment::unsetVariable(szVariable);
else
- {
- /*#ifdef COMPILE_ON_WINDOWS
- QString Var,Val,VarAndVal;
- Val = szVar.data();
- Var = szVal.data();
- VarAndVal = Var+"="+Val;
- putenv(VarAndVal);
-#else*/ // <-- this stuff is implicit in KviEnvironment::setVariable: that's why we have the kvi_ version.
- KviEnvironment::setVariable(szVar.data(), szVal.data());
- /*#endif*/
- }
+ KviEnvironment::setVariable(szVariable, szValue);
return true;
}
diff --git a/src/modules/theme/WebThemeInterfaceDialog.cpp b/src/modules/theme/WebThemeInterfaceDialog.cpp
index 8e03fbf49..24c611c78 100644
--- a/src/modules/theme/WebThemeInterfaceDialog.cpp
+++ b/src/modules/theme/WebThemeInterfaceDialog.cpp
@@ -49,7 +49,7 @@ WebThemeInterfaceDialog::WebThemeInterfaceDialog(QWidget * par)
setPackagePageUrl(
QString::fromLatin1("http://www.kvirc.de/app/themes.php?version=" KVI_VERSION "&lang=%1")
- .arg(QString::fromUtf8(KviLocale::instance()->localeName().ptr())));
+ .arg(KviLocale::instance()->localeName()));
}
WebThemeInterfaceDialog::~WebThemeInterfaceDialog()
= default;