summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tdecore/tdeapplication.cpp81
-rw-r--r--tdecore/tdeapplication.h7
-rw-r--r--tdecore/tdehardwaredevices.cpp60
-rw-r--r--tdecore/tdehardwaredevices.h6
4 files changed, 147 insertions, 7 deletions
diff --git a/tdecore/tdeapplication.cpp b/tdecore/tdeapplication.cpp
index 857c157e8..9a5bd7a0b 100644
--- a/tdecore/tdeapplication.cpp
+++ b/tdecore/tdeapplication.cpp
@@ -175,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
@@ -242,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
*/
@@ -3632,6 +3701,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 f58bfe0c7..089f9f940 100644
--- a/tdecore/tdeapplication.h
+++ b/tdecore/tdeapplication.h
@@ -1220,6 +1220,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/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp
index bc56f8430..7fa9f3ad8 100644
--- a/tdecore/tdehardwaredevices.cpp
+++ b/tdecore/tdehardwaredevices.cpp
@@ -937,7 +937,7 @@ TQString TDEStorageDevice::mountPath() {
file.close();
}
- // While this device is not directly mounted, it could concievably be mounted via the Device Mapper
+ // While this device is not directly mounted, it could conceivably be mounted via the Device Mapper
// If so, try to retrieve the mount path...
TQStringList slaveDeviceList = holdingDevices();
for ( TQStringList::Iterator slavedevit = slaveDeviceList.begin(); slavedevit != slaveDeviceList.end(); ++slavedevit ) {
@@ -953,7 +953,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;
@@ -969,12 +969,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) {
@@ -995,7 +1020,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;
@@ -1018,12 +1043,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/tdehardwaredevices.h b/tdecore/tdehardwaredevices.h
index e7a7a3e26..531406dc5 100644
--- a/tdecore/tdehardwaredevices.h
+++ b/tdecore/tdehardwaredevices.h
@@ -513,6 +513,8 @@ class TDECORE_EXPORT TDEGenericDevice : public TQObject
friend class TDEHardwareDevices;
};
+typedef TQMap<TQString,TQString> TDEStorageMountOptions;
+
class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
{
public:
@@ -582,7 +584,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
@@ -595,7 +597,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