summaryrefslogtreecommitdiffstats
path: root/kioslave/media/mounthelper
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 20:21:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 20:21:27 +0000
commit10e41144596fc9ced40fc349d9ecd099b1c2ea19 (patch)
tree88ab04e475ff5a4cd889cb082f5760b6e0bf5e4e /kioslave/media/mounthelper
parent4aed2c8219774f5d797760606b8489a92ddc5163 (diff)
downloadtdebase-10e41144596fc9ced40fc349d9ecd099b1c2ea19.tar.gz
tdebase-10e41144596fc9ced40fc349d9ecd099b1c2ea19.zip
Initial import of Trinity 3.5.11 to kdebase
Extends krandrtray, adds iccconfig kcontrol module, adds run dialog autocomplete and lots of bugfixes Will need to check for commit warnings and repair as encountered Also needs full compile test git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1061475 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kioslave/media/mounthelper')
-rw-r--r--kioslave/media/mounthelper/Makefile.am4
-rw-r--r--kioslave/media/mounthelper/decryptdialog.ui201
-rw-r--r--kioslave/media/mounthelper/dialog.cpp68
-rw-r--r--kioslave/media/mounthelper/dialog.h61
-rw-r--r--kioslave/media/mounthelper/kio_media_mounthelper.cpp89
-rw-r--r--kioslave/media/mounthelper/kio_media_mounthelper.h10
6 files changed, 419 insertions, 14 deletions
diff --git a/kioslave/media/mounthelper/Makefile.am b/kioslave/media/mounthelper/Makefile.am
index 9080ba81a..9c03ba688 100644
--- a/kioslave/media/mounthelper/Makefile.am
+++ b/kioslave/media/mounthelper/Makefile.am
@@ -3,10 +3,10 @@ bin_PROGRAMS = kio_media_mounthelper
INCLUDES = -I$(srcdir)/../libmediacommon $(all_includes)
AM_LDFLAGS = $(all_libraries)
-kio_media_mounthelper_SOURCES = kio_media_mounthelper.cpp
+kio_media_mounthelper_SOURCES = kio_media_mounthelper.cpp decryptdialog.ui dialog.cpp
kio_media_mounthelper_LDFLAGS = $(KDE_RPATH) $(all_libraries)
-kio_media_mounthelper_LDADD = ../libmediacommon/libmediacommon.la $(LIB_KIO)
+kio_media_mounthelper_LDADD = ../libmediacommon/libmediacommon.la $(LIB_KIO) $(LIB_KDEUI)
METASOURCES = AUTO
diff --git a/kioslave/media/mounthelper/decryptdialog.ui b/kioslave/media/mounthelper/decryptdialog.ui
new file mode 100644
index 000000000..15790c8ef
--- /dev/null
+++ b/kioslave/media/mounthelper/decryptdialog.ui
@@ -0,0 +1,201 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>DecryptDialog</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>DecryptDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>207</width>
+ <height>172</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Decrypting Storage Device</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>encryptedIcon</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ <property name="alignment">
+ <set>AlignTop</set>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>descLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;p&gt;&lt;b&gt;%1&lt;/b&gt; is an encrypted storage device.&lt;/p&gt;
+&lt;p&gt;Please enter the password to decrypt the storage device.&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Password:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>passwordEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>passwordEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0">
+ <property name="name">
+ <cstring>errorBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Error</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>errorLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kioslave/media/mounthelper/dialog.cpp b/kioslave/media/mounthelper/dialog.cpp
new file mode 100644
index 000000000..74bcfb388
--- /dev/null
+++ b/kioslave/media/mounthelper/dialog.cpp
@@ -0,0 +1,68 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2007 Jan Klötzke <jan kloetzke at freenet de>
+ *
+ * Based on kryptomedia- Another KDE cryto media application.
+ * Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "dialog.h"
+
+Dialog::Dialog(QString url, QString iconName) :
+ KDialogBase(NULL, "Dialog", true, "Decrypt Storage Device", (Cancel|User1), User1, false, KGuiItem(i18n("Decrypt"), "decrypted" ))
+{
+ decryptDialog = new DecryptDialog(this);
+
+ decryptDialog->errorBox->hide();
+ decryptDialog->descLabel->setText(decryptDialog->descLabel->text().arg(url));
+ decryptDialog->descLabel->adjustSize();
+ decryptDialog->adjustSize();
+
+ enableButton( User1, false );
+
+ QPixmap pixmap = KGlobal::iconLoader()->loadIcon(iconName, KIcon::NoGroup, KIcon::SizeLarge);
+ decryptDialog->encryptedIcon->setPixmap( pixmap );
+
+ connect(decryptDialog->passwordEdit, SIGNAL (textChanged(const QString &)), this, SLOT (slotPasswordChanged(const QString &)));
+
+ setMainWidget(decryptDialog);
+}
+
+Dialog::~Dialog()
+{
+ delete decryptDialog;
+}
+
+QString Dialog::getPassword()
+{
+ return decryptDialog->passwordEdit->text();
+}
+
+void Dialog::slotDialogError(QString errorMsg)
+{
+ kdDebug() << __func__ << "(" << errorMsg << " )" << endl;
+
+ decryptDialog->errorLabel->setText(QString("<b>%1</b>").arg(errorMsg));
+ decryptDialog->errorBox->show();
+}
+
+void Dialog::slotPasswordChanged(const QString &text)
+{
+ enableButton( User1, !text.isEmpty() );
+}
+
+#include "dialog.moc"
diff --git a/kioslave/media/mounthelper/dialog.h b/kioslave/media/mounthelper/dialog.h
new file mode 100644
index 000000000..1f544c370
--- /dev/null
+++ b/kioslave/media/mounthelper/dialog.h
@@ -0,0 +1,61 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2007 Jan Klötzke <jan kloetzke at freenet de>
+ *
+ * Based on kryptomedia- Another KDE cryto media application.
+ * Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef DIALOG_H_
+#define DIALOG_H_
+
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <kiconloader.h>
+
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+
+#include "decryptdialog.h"
+
+class KryptoMedia;
+
+class Dialog : public KDialogBase
+{
+
+Q_OBJECT
+
+public:
+ Dialog(QString url, QString iconName);
+ ~Dialog();
+
+ QString getPassword();
+
+public slots:
+ void slotDialogError(QString errorMsg);
+ void slotPasswordChanged(const QString &text);
+
+private:
+ DecryptDialog *decryptDialog;
+};
+
+#endif // DIALOG_H_
+
diff --git a/kioslave/media/mounthelper/kio_media_mounthelper.cpp b/kioslave/media/mounthelper/kio_media_mounthelper.cpp
index 12743847f..5dae9e0d3 100644
--- a/kioslave/media/mounthelper/kio_media_mounthelper.cpp
+++ b/kioslave/media/mounthelper/kio_media_mounthelper.cpp
@@ -32,7 +32,9 @@
#include <kglobal.h>
#include <kprocess.h>
#include <kstartupinfo.h>
+#include <kmimetype.h>
+#include "dialog.h"
#include "kio_media_mounthelper.h"
const Medium MountHelper::findMedium(const KURL &url)
@@ -63,7 +65,7 @@ MountHelper::MountHelper() : KApplication()
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- m_errorStr = "";
+ m_errorStr = QString::null;
KURL url(args->url(0));
const Medium medium = findMedium(url);
@@ -89,7 +91,37 @@ MountHelper::MountHelper() : KApplication()
m_isCdrom = medium.mimeType().find("dvd")!=-1
|| medium.mimeType().find("cd")!=-1;
- if (args->isSet("u"))
+ if (args->isSet("d"))
+ {
+ if (!medium.isEncrypted())
+ {
+ m_errorStr = i18n("%1 is not an encrypted media.").arg(url.prettyURL());
+ QTimer::singleShot(0, this, SLOT(error()) );
+ return;
+ }
+ if (!medium.needDecryption())
+ {
+ m_errorStr = i18n("%1 is already decrypted.").arg(url.prettyURL());
+ QTimer::singleShot(0, this, SLOT(error()) );
+ return;
+ }
+
+ QString iconName = medium.iconName();
+ if (iconName.isEmpty())
+ {
+ QString mime = medium.mimeType();
+ iconName = KMimeType::mimeType(mime)->icon(mime, false);
+ }
+
+ m_mediumId = medium.id();
+ dialog = new Dialog(url.prettyURL(), iconName);
+ dialog->show();
+
+ connect(dialog, SIGNAL (user1Clicked()), this, SLOT (slotSendPassword()));
+ connect(dialog, SIGNAL (cancelClicked()), this, SLOT (slotCancel()));
+ connect(this, SIGNAL (signalPasswordError(QString)), dialog, SLOT (slotDialogError(QString)));
+ }
+ else if (args->isSet("u"))
{
DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call( "unmount", medium.id());
@@ -103,6 +135,8 @@ MountHelper::MountHelper() : KApplication()
}
else if (args->isSet("s") || args->isSet("e"))
{
+ DCOPRef mediamanager("kded", "mediamanager");
+
/*
* We want to call mediamanager unmount before invoking eject. That's
* because unmount would provide an informative error message in case of
@@ -114,17 +148,24 @@ MountHelper::MountHelper() : KApplication()
*/
if (medium.isMounted())
{
- DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call( "unmount", medium.id());
if (reply.isValid())
reply.get(m_errorStr);
- if (m_errorStr.isNull())
- invokeEject(device, true);
- else
- error();
- m_device = device;
- } else
- invokeEject(device, true);
+ }
+
+ /* If this is a decrypted volume and there is no error yet
+ * we try to teardown the decryption */
+ if (m_errorStr.isNull() && medium.isEncrypted() && !medium.clearDeviceUdi().isNull())
+ {
+ DCOPReply reply = mediamanager.call( "undecrypt", medium.id());
+ if (reply.isValid())
+ reply.get(m_errorStr);
+ }
+
+ if (m_errorStr.isNull())
+ invokeEject(device, true);
+ else
+ error();
}
else
{
@@ -167,7 +208,9 @@ void MountHelper::ejectFinished(KProcess* proc)
else
m_errorStr = i18n("The device was successfully unmounted, but could not be ejected");
}
- QTimer::singleShot(0, this, SLOT(error()));
+//X Comment this because the error is useless as long as the unmount is successfull.
+//X QTimer::singleShot(0, this, SLOT(error()));
+ ::exit(0);
}
}
@@ -177,8 +220,32 @@ void MountHelper::error()
::exit(1);
}
+void MountHelper::slotSendPassword()
+{
+ DCOPRef mediamanager("kded", "mediamanager");
+
+ DCOPReply reply = mediamanager.call( "decrypt", m_mediumId, dialog->getPassword() );
+ if (!reply.isValid()) {
+ m_errorStr = i18n("The KDE mediamanager is not running.");
+ error();
+ } else {
+ QString errorMsg = reply;
+ if (errorMsg.isNull()) {
+ exit(0);
+ } else {
+ emit signalPasswordError(errorMsg);
+ }
+ }
+}
+
+void MountHelper::slotCancel()
+{
+ exit(0);
+}
+
static KCmdLineOptions options[] =
{
+ { "d", I18N_NOOP("Decrypt given URL"), 0 },
{ "u", I18N_NOOP("Unmount given URL"), 0 },
{ "m", I18N_NOOP("Mount given URL (default)"), 0 },
{ "e", I18N_NOOP("Eject given URL via kdeeject"), 0},
diff --git a/kioslave/media/mounthelper/kio_media_mounthelper.h b/kioslave/media/mounthelper/kio_media_mounthelper.h
index 478d802f9..ed5884d4f 100644
--- a/kioslave/media/mounthelper/kio_media_mounthelper.h
+++ b/kioslave/media/mounthelper/kio_media_mounthelper.h
@@ -28,6 +28,8 @@
#include "medium.h"
+class Dialog;
+
class MountHelper : public KApplication
{
Q_OBJECT
@@ -38,12 +40,18 @@ private:
const Medium findMedium(const KURL &url);
void invokeEject(const QString &device, bool quiet=false);
QString m_errorStr;
- QString m_device;
bool m_isCdrom;
+ QString m_mediumId;
+ Dialog *dialog;
private slots:
+ void slotSendPassword();
+ void slotCancel();
void ejectFinished(KProcess* proc);
void error();
+
+signals:
+ void signalPasswordError(QString errorMsg);
};
#endif