[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra] /: Don't use utsname on Windows but native api instead (also use Q_OS_* instead of Q_WS_*
From: Andrius da Costa Ribas <andriusmao () gmail ! com>
Date: 2013-11-30 19:14:33
Message-ID: E1Vmpzt-0002Dv-Ge () scm ! kde ! org
[Download RAW message or body]
Git commit 3d4cbcc3f12cb50b8176352574a2d0315f0fdfb9 by Andrius da Costa Ribas.
Committed on 30/11/2013 at 18:07.
Pushed by andriusr into branch 'master'.
Don't use utsname on Windows but native api instead (also use Q_OS_* instead of \
Q_WS_*).
M +36 -4 kexi/main/KexiUserFeedbackAgent.cpp
M +37 -0 sheets/functions/information.cpp
http://commits.kde.org/calligra/3d4cbcc3f12cb50b8176352574a2d0315f0fdfb9
diff --git a/kexi/main/KexiUserFeedbackAgent.cpp \
b/kexi/main/KexiUserFeedbackAgent.cpp index 26a11b1..b07407e 100644
--- a/kexi/main/KexiUserFeedbackAgent.cpp
+++ b/kexi/main/KexiUserFeedbackAgent.cpp
@@ -33,7 +33,11 @@
#include <QProcess>
#include <QUuid>
-#if defined HAVE_UNAME || defined Q_WS_WIN
+#if defined Q_OS_WIN
+#include <windows.h>
+#endif
+
+#if defined HAVE_UNAME
# include <sys/utsname.h>
#endif
@@ -114,21 +118,49 @@ void KexiUserFeedbackAgent::Private::updateData()
}
p.close();
}
-#elif defined(Q_WS_MAC)
+#elif defined(Q_OS_MAC)
ADD("os", "mac", SystemInfoArea);
-#elif defined(Q_WS_WIN)
+#elif defined(Q_OS_WIN)
ADD("os", "windows", SystemInfoArea);
#else
//! @todo BSD?
ADD("os", "other", SystemInfoArea);
#endif
-#if defined HAVE_UNAME || defined Q_WS_WIN
+#if defined HAVE_UNAME
struct utsname buf;
if (uname(&buf) == 0) {
ADD("os_release", buf.release, SystemInfoArea);
ADD("os_machine", buf.machine, SystemInfoArea);
}
+#elif defined(Q_OS_WIN)
+ OSVERSIONINFO versionInfo;
+ SYSTEM_INFO sysInfo;
+ char* releaseStr;
+ releaseStr = new char[6]; // "xx.xx\0"
+
+ versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&versionInfo);
+ GetSystemInfo(&sysInfo);
+
+ snprintf(releaseStr, 6, "%2d.%2d", versionInfo.dwMajorVersion, \
versionInfo.dwMinorVersion); + ADD("os_release", releaseStr, SystemInfoArea);
+
+ delete [6] releaseStr;
+
+ switch(sysInfo.wProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ ADD("os_machine", "x86_64", SystemInfoArea);
+ break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ ADD("os_machine", "ia64", SystemInfoArea);
+ break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ ADD("os_machine", "x86", SystemInfoArea);
+ break;
+ default:
+ ADD("os_machine", "unknown", SystemInfoArea);
+ }
#endif
QSize screen(QApplication::desktop()->screenGeometry(
diff --git a/sheets/functions/information.cpp b/sheets/functions/information.cpp
index f255234..6dd51e2 100644
--- a/sheets/functions/information.cpp
+++ b/sheets/functions/information.cpp
@@ -23,7 +23,11 @@
#include "InformationModule.h"
#include <calligraversion.h>
+#ifdef Q_OS_WIN
+#include <windows.h>
+#else
#include <sys/utsname.h>
+#endif
#include <QDir>
#include <kdebug.h>
@@ -225,9 +229,13 @@ Value func_info(valVector args, ValueCalc *calc, FuncExtra *)
return Value::errorVALUE();
if (type == "system") {
+#ifndef Q_OS_WIN
struct utsname name;
if (uname(&name) >= 0)
return Value(QString(name.sysname));
+#else
+ return Value(QString("Windows"));
+#endif
}
if (type == "totmem")
@@ -235,12 +243,41 @@ Value func_info(valVector args, ValueCalc *calc, FuncExtra *)
return Value::errorVALUE();
if (type == "osversion") {
+#ifndef Q_OS_WIN
struct utsname name;
if (uname(&name) >= 0) {
QString os = QString("%1 %2 (%3)").arg(name.sysname).
arg(name.release).arg(name.machine);
return Value(os);
}
+#else
+ OSVERSIONINFO versionInfo;
+ SYSTEM_INFO sysInfo;
+ QString architecture;
+
+ versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ GetVersionEx(&versionInfo);
+ GetSystemInfo(&sysInfo);
+
+ switch(sysInfo.wProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ architecture = QString("x86_64");
+ break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ architecture = QString("ia64");
+ break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ architecture = QString("x86");
+ break;
+ default:
+ architecture = QString("unknown");
+ }
+
+ QString os = QString("Windows %1.%2 \
(%3)").arg(versionInfo.dwMajorVersion).arg(versionInfo.dwMinorVersion).arg(architecture);
+
+ return Value(os);
+#endif
}
return Value::errorVALUE();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic