summaryrefslogtreecommitdiffstats
path: root/tdecore
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2013-08-11 02:35:58 +0400
committerAlexander Golubev <fatzer2@gmail.com>2013-08-11 02:35:58 +0400
commitb7ff6c33309224a4e598a0691e7cb2dc353a6ace (patch)
treebc003a5aeba3b0980b5098985f6c28ba965b8b52 /tdecore
parent34f10b970c1e644842ef737b5504591997e37d59 (diff)
parent411486cc50448e91b53d28119ccec54c5c2305cd (diff)
downloadtdelibs-b7ff6c33309224a4e598a0691e7cb2dc353a6ace.tar.gz
tdelibs-b7ff6c33309224a4e598a0691e7cb2dc353a6ace.zip
Merge branch 'master' into HEAD
Conflicts: tdecore/CMakeLists.txt tdecore/tdehardwaredevices.h tdecore/tdehw/tdehardwaredevices.cpp
Diffstat (limited to 'tdecore')
-rw-r--r--tdecore/CMakeLists.txt1
-rw-r--r--tdecore/tdeapplication.cpp143
-rw-r--r--tdecore/tdeapplication.h26
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp10
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp58
-rw-r--r--tdecore/tdehw/tdestoragedevice.h6
6 files changed, 236 insertions, 8 deletions
diff --git a/tdecore/CMakeLists.txt b/tdecore/CMakeLists.txt
index 59bccf568..6a9e605a3 100644
--- a/tdecore/CMakeLists.txt
+++ b/tdecore/CMakeLists.txt
@@ -40,6 +40,7 @@ link_directories(
${TQT_LIBRARY_DIRS}
${LIBIDN_LIBRARY_DIRS}
${GAMIN_LIBDIR}
+ ${LIBART_LIBRARY_DIRS}
)
##### headers ###################################
diff --git a/tdecore/tdeapplication.cpp b/tdecore/tdeapplication.cpp
index 58b010e4e..34bd8aadd 100644
--- a/tdecore/tdeapplication.cpp
+++ b/tdecore/tdeapplication.cpp
@@ -35,7 +35,14 @@
#undef QT_NO_TRANSLATION
#undef TQT_NO_TRANSLATION
#include <tqtranslator.h>
+
+// FIXME
+// FOR BINARY COMPATIBILITY ONLY
+// REMOVE WHEN PRACTICAL!
+#define TDEAPPLICATION_BINARY_COMPAT_HACK 1
#include "tdeapplication.h"
+#undef TDEAPPLICATION_BINARY_COMPAT_HACK
+
#define QT_NO_TRANSLATION
#define TQT_NO_TRANSLATION
#include <tqdir.h>
@@ -168,6 +175,14 @@ typedef void* IceIOErrorHandler;
#include <tqimage.h>
#endif
+#if defined Q_WS_X11
+#include <sys/ioctl.h>
+#include <linux/vt.h>
+extern "C" {
+extern int getfd(const char *fnam);
+}
+#endif
+
#include "kappdcopiface.h"
// exported for tdm kfrontend
@@ -235,6 +250,67 @@ void TDEApplication_init_windows(bool GUIenabled);
class QAssistantClient;
#endif
+#ifdef Q_WS_X11
+// --------------------------------------------------------------------------------------
+// Get the VT number X is running on
+// (code taken from GDM, daemon/getvt.c, GPLv2+)
+// --------------------------------------------------------------------------------------
+int get_x_vtnum(Display *dpy)
+{
+ Atom prop;
+ Atom actualtype;
+ int actualformat;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *buf;
+ int num;
+
+ prop = XInternAtom (dpy, "XFree86_VT", False);
+ if (prop == None)
+ return -1;
+
+ if (XGetWindowProperty (dpy, DefaultRootWindow (dpy), prop, 0, 1,
+ False, AnyPropertyType, &actualtype, &actualformat,
+ &nitems, &bytes_after, &buf)) {
+ return -1;
+ }
+
+ if (nitems != 1) {
+ XFree (buf);
+ return -1;
+ }
+
+ switch (actualtype) {
+ case XA_CARDINAL:
+ case XA_INTEGER:
+ case XA_WINDOW:
+ switch (actualformat) {
+ case 8:
+ num = (*(uint8_t *)(void *)buf);
+ break;
+ case 16:
+ num = (*(uint16_t *)(void *)buf);
+ break;
+ case 32:
+ num = (*(uint32_t *)(void *)buf);
+ break;
+ default:
+ XFree (buf);
+ return -1;
+ }
+ break;
+ default:
+ XFree (buf);
+ return -1;
+ }
+
+ XFree (buf);
+
+ return num;
+}
+// --------------------------------------------------------------------------------------
+#endif // Q_WS_X11
+
/*
Private data to make keeping binary compatibility easier
*/
@@ -622,6 +698,34 @@ static SmcConn tmpSmcConnection = 0;
static TQTime* smModificationTime = 0;
TDEApplication::TDEApplication( int& argc, char** argv, const TQCString& rAppName,
+ bool allowStyles, bool GUIenabled, bool SMenabled ) :
+ TQApplication( argc, argv, GUIenabled, SMenabled ), TDEInstance(rAppName),
+#ifdef Q_WS_X11
+ display(0L),
+ argb_visual(false),
+#endif
+ d (new TDEApplicationPrivate())
+{
+ aIconPixmap.pm.icon = 0L;
+ aIconPixmap.pm.miniIcon = 0L;
+ read_app_startup_id();
+ if (!GUIenabled)
+ allowStyles = false;
+ useStyles = allowStyles;
+ Q_ASSERT (!rAppName.isEmpty());
+ setName(rAppName);
+
+ installSigpipeHandler();
+ TDECmdLineArgs::initIgnore(argc, argv, rAppName.data());
+ parseCommandLine( );
+ init(GUIenabled);
+ d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
+}
+
+// FIXME
+// FOR BINARY COMPATIBILITY ONLY
+// REMOVE WHEN PRACTICAL!
+TDEApplication::TDEApplication( int& argc, char** argv, const TQCString& rAppName,
bool allowStyles, bool GUIenabled ) :
TQApplication( argc, argv, GUIenabled ), TDEInstance(rAppName),
#ifdef Q_WS_X11
@@ -646,6 +750,33 @@ TDEApplication::TDEApplication( int& argc, char** argv, const TQCString& rAppNam
d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
}
+TDEApplication::TDEApplication( bool allowStyles, bool GUIenabled, bool SMenabled ) :
+// TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), TRUE ), // Qt4 requires that there always be a GUI
+ TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), GUIenabled, SMenabled ), // We need to be able to run command line apps
+ TDEInstance( TDECmdLineArgs::about),
+#ifdef Q_WS_X11
+ display(0L),
+ argb_visual(false),
+#endif
+ d (new TDEApplicationPrivate)
+{
+ aIconPixmap.pm.icon = 0L;
+ aIconPixmap.pm.miniIcon = 0L;
+ read_app_startup_id();
+ if (!GUIenabled)
+ allowStyles = false;
+ useStyles = allowStyles;
+ setName( instanceName() );
+
+ installSigpipeHandler();
+ parseCommandLine( );
+ init(GUIenabled);
+ d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
+}
+
+// FIXME
+// FOR BINARY COMPATIBILITY ONLY
+// REMOVE WHEN PRACTICAL!
TDEApplication::TDEApplication( bool allowStyles, bool GUIenabled ) :
// TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), TRUE ), // Qt4 requires that there always be a GUI
TQApplication( *TDECmdLineArgs::tqt_argc(), *TDECmdLineArgs::tqt_argv(), GUIenabled ), // We need to be able to run command line apps
@@ -3597,6 +3728,18 @@ TQ_ButtonState TDEApplication::keyboardMouseState()
return static_cast< ButtonState >( ret );
}
+#if defined Q_WS_X11
+int TDEApplication::currentX11VT()
+{
+ return get_x_vtnum(TQPaintDevice::x11AppDisplay());
+}
+#else // Q_WS_X11
+int TDEApplication::currentX11VT()
+{
+ return -1;
+}
+#endif // Q_WS_X11
+
void TDEApplication::installSigpipeHandler()
{
#ifdef Q_OS_UNIX
diff --git a/tdecore/tdeapplication.h b/tdecore/tdeapplication.h
index 5ab8d7ee7..c22e9edbb 100644
--- a/tdecore/tdeapplication.h
+++ b/tdecore/tdeapplication.h
@@ -128,7 +128,14 @@ public:
* @param GUIenabled Set to false to disable all GUI stuff. This implies
* no styles either.
*/
+ TDEApplication( bool allowStyles=true, bool GUIenabled=true, bool SMenabled=true);
+
+#ifdef TDEAPPLICATION_BINARY_COMPAT_HACK
+ // FIXME
+ // FOR BINARY COMPATIBILITY ONLY
+ // REMOVE WHEN PRACTICAL!
TDEApplication( bool allowStyles=true, bool GUIenabled=true);
+#endif // TDEAPPLICATION_BINARY_COMPAT_HACK
#ifdef Q_WS_X11
/**
@@ -257,8 +264,16 @@ public:
*/
// REMOVE FOR KDE 4.0 - using it only gives crashing applications because
// TDECmdLineArgs::init isn't called
- TDEApplication(int& argc, char** argv,
- const TQCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED;
+ TDEApplication(int& argc, char** argv,
+ const TQCString& rAppName, bool allowStyles=true, bool GUIenabled=true, bool SMenabled=true) KDE_DEPRECATED;
+
+#ifdef TDEAPPLICATION_BINARY_COMPAT_HACK
+ // FIXME
+ // FOR BINARY COMPATIBILITY ONLY
+ // REMOVE WHEN PRACTICAL!
+ TDEApplication(int& argc, char** argv,
+ const TQCString& rAppName, bool allowStyles, bool GUIenabled) KDE_DEPRECATED;
+#endif // TDEAPPLICATION_BINARY_COMPAT_HACK
/**
* Add Qt and KDE command line options to TDECmdLineArgs.
@@ -1212,6 +1227,13 @@ public:
*/
static uint mouseState() KDE_DEPRECATED;
+ /**
+ * Returns the VT that the current X server is running on, or -1 if this information is unavailable.
+ *
+ * @since 14.0.0
+ */
+ static int currentX11VT();
+
public slots:
/**
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index 08646d17d..b82977d96 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -65,6 +65,7 @@
#include "tdeeventdevice.h"
#include "tdeinputdevice.h"
+// Compile-time configuration
#include "config.h"
// BEGIN BLOCK
@@ -2558,6 +2559,15 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
if (nodename == "alarm") {
bdevice->internalSetAlarmEnergy(line.toDouble()/1000000.0);
}
+ if (nodename == "charge_full") {
+ bdevice->internalSetMaximumEnergy(line.toDouble()/1000000.0);
+ }
+ if (nodename == "charge_full_design") {
+ bdevice->internalSetMaximumDesignEnergy(line.toDouble()/1000000.0);
+ }
+ if (nodename == "charge_now") {
+ bdevice->internalSetEnergy(line.toDouble()/1000000.0);
+ }
if (nodename == "energy_full") {
bdevice->internalSetMaximumEnergy(line.toDouble()/1000000.0);
}
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index ac80b8856..f13146b00 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -592,7 +592,7 @@ TQString TDEStorageDevice::mountPath() {
return TQString::null;
}
-TQString TDEStorageDevice::mountDevice(TQString mediaName, TQString mountOptions, TQString* errRet, int* retcode) {
+TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) {
int internal_retcode;
if (!retcode) {
retcode = &internal_retcode;
@@ -608,12 +608,37 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TQString mountOptions
KTempFile passwordFile(TQString::null, "tmp", 0600);
passwordFile.setAutoDelete(true);
+ TQString optionString;
+ if (mountOptions["ro"] == "true") {
+ optionString.append(" -r");
+ }
+
+ if (mountOptions["atime"] != "true") {
+ optionString.append(" -A");
+ }
+
+ if (mountOptions["utf8"] == "true") {
+ optionString.append(" -c utf8");
+ }
+
+ if (mountOptions["sync"] == "true") {
+ optionString.append(" -s");
+ }
+
+ if (mountOptions.contains("filesystem")) {
+ optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"]));
+ }
+
+ if (mountOptions.contains("locale")) {
+ optionString.append(TQString(" -c %1").arg(mountOptions["locale"]));
+ }
+
TQString passFileName = passwordFile.name();
TQString devNode = deviceNode();
passFileName.replace("'", "'\\''");
devNode.replace("'", "'\\''");
mediaName.replace("'", "'\\''");
- TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(mountOptions).arg(devNode).arg(mediaName);
+ TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
FILE *exepipe = popen(command.ascii(), "r");
if (exepipe) {
@@ -634,7 +659,7 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TQString mountOptions
return ret;
}
-TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName, TQString mountOptions, TQString* errRet, int* retcode) {
+TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) {
int internal_retcode;
if (!retcode) {
retcode = &internal_retcode;
@@ -657,12 +682,37 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me
pwFile->writeBlock(passphrase.ascii(), passphrase.length());
pwFile->flush();
+ TQString optionString;
+ if (mountOptions["ro"] == "true") {
+ optionString.append(" -r");
+ }
+
+ if (mountOptions["atime"] != "true") {
+ optionString.append(" -A");
+ }
+
+ if (mountOptions["utf8"] == "true") {
+ optionString.append(" -c utf8");
+ }
+
+ if (mountOptions["sync"] == "true") {
+ optionString.append(" -s");
+ }
+
+ if (mountOptions.contains("filesystem")) {
+ optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"]));
+ }
+
+ if (mountOptions.contains("locale")) {
+ optionString.append(TQString(" -c %1").arg(mountOptions["locale"]));
+ }
+
TQString passFileName = passwordFile.name();
TQString devNode = deviceNode();
passFileName.replace("'", "'\\''");
devNode.replace("'", "'\\''");
mediaName.replace("'", "'\\''");
- TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(mountOptions).arg(devNode).arg(mediaName);
+ TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
FILE *exepipe = popen(command.ascii(), "r");
if (exepipe) {
diff --git a/tdecore/tdehw/tdestoragedevice.h b/tdecore/tdehw/tdestoragedevice.h
index 0f33b03dc..7c80f5ea5 100644
--- a/tdecore/tdehw/tdestoragedevice.h
+++ b/tdecore/tdehw/tdestoragedevice.h
@@ -105,6 +105,8 @@ inline TDEDiskDeviceStatus operator~(TDEDiskDeviceStatus a)
}
};
+typedef TQMap<TQString,TQString> TDEStorageMountOptions;
+
class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
{
public:
@@ -174,7 +176,7 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
*
* @return a TQString with the mount path, if successful
*/
- TQString mountDevice(TQString mediaName=TQString::null, TQString mountOptions=TQString::null, TQString* errRet=0, int* retcode=0);
+ TQString mountDevice(TQString mediaName=TQString::null, TDEStorageMountOptions mountOptions=TDEStorageMountOptions(), TQString* errRet=0, int* retcode=0);
/**
* Mounts the encrypted device if the correct passphrase is given
@@ -187,7 +189,7 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
*
* @return a TQString with the mount path, if successful
*/
- TQString mountEncryptedDevice(TQString passphrase, TQString mediaName=TQString::null, TQString mountOptions=TQString::null, TQString* errRet=0, int* retcode=0);
+ TQString mountEncryptedDevice(TQString passphrase, TQString mediaName=TQString::null, TDEStorageMountOptions mountOptions=TDEStorageMountOptions(), TQString* errRet=0, int* retcode=0);
/**
* Unmounts the device