summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media
diff options
context:
space:
mode:
Diffstat (limited to 'tdeioslave/media')
-rw-r--r--tdeioslave/media/Makefile.am4
-rw-r--r--tdeioslave/media/configure.in.in176
-rw-r--r--tdeioslave/media/contrib/README8
-rw-r--r--tdeioslave/media/libmediacommon/mediamanagersettings.kcfg14
-rw-r--r--tdeioslave/media/libmediacommon/medium.cpp225
-rw-r--r--tdeioslave/media/libmediacommon/medium.h105
-rw-r--r--tdeioslave/media/libmediacommon/notifieraction.cpp3
-rw-r--r--tdeioslave/media/mediaimpl.cpp35
-rw-r--r--tdeioslave/media/mediaimpl.h2
-rw-r--r--tdeioslave/media/mediamanager/CMakeLists.txt12
-rw-r--r--tdeioslave/media/mediamanager/Makefile.am17
-rw-r--r--tdeioslave/media/mediamanager/dialog.cpp4
-rw-r--r--tdeioslave/media/mediamanager/dialog.h2
-rw-r--r--tdeioslave/media/mediamanager/fstabbackend.cpp21
-rw-r--r--tdeioslave/media/mediamanager/fstabbackend.h2
-rw-r--r--tdeioslave/media/mediamanager/halbackend.cpp1961
-rw-r--r--tdeioslave/media/mediamanager/halbackend.h233
-rw-r--r--tdeioslave/media/mediamanager/linuxcdpolling.cpp22
-rw-r--r--tdeioslave/media/mediamanager/linuxcdpolling.h2
-rw-r--r--tdeioslave/media/mediamanager/medialist.cpp50
-rw-r--r--tdeioslave/media/mediamanager/medialist.h4
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.cpp322
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.h16
-rw-r--r--tdeioslave/media/mediamanager/removablebackend.cpp11
-rw-r--r--tdeioslave/media/mediamanager/removablebackend.h2
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp660
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.h28
-rw-r--r--tdeioslave/media/medianotifier/CMakeLists.txt1
-rw-r--r--tdeioslave/media/medianotifier/medianotifier.cpp22
-rw-r--r--tdeioslave/media/medianotifier/medianotifier.h2
-rw-r--r--tdeioslave/media/medianotifier/notificationdialog.cpp39
-rw-r--r--tdeioslave/media/medianotifier/notificationdialog.h2
-rw-r--r--tdeioslave/media/mimetypes/cd-r_encrypted_locked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/cd-r_encrypted_unlocked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/cd-rw_encrypted_locked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/cd-rw_encrypted_unlocked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/cdrom_encrypted_locked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/cdrom_encrypted_unlocked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/dvd_encrypted_locked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/dvd_encrypted_unlocked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/hdd_encrypted_locked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/hdd_encrypted_unlocked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/removable_encrypted_locked.desktop1
-rw-r--r--tdeioslave/media/mimetypes/removable_encrypted_unlocked.desktop1
-rw-r--r--tdeioslave/media/mounthelper/CMakeLists.txt3
-rw-r--r--tdeioslave/media/mounthelper/dialog.cpp13
-rw-r--r--tdeioslave/media/mounthelper/dialog.h5
-rw-r--r--tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp398
-rw-r--r--tdeioslave/media/mounthelper/tdeio_media_mounthelper.h28
-rw-r--r--tdeioslave/media/mounthelper/unlockdialog.ui42
-rw-r--r--tdeioslave/media/propsdlgplugin/media_propsdlgplugin.desktop2
-rw-r--r--tdeioslave/media/propsdlgplugin/propertiespage.cpp28
-rw-r--r--tdeioslave/media/propsdlgplugin/propertiespage.h2
-rw-r--r--tdeioslave/media/propsdlgplugin/propertiespagegui.ui8
-rw-r--r--tdeioslave/media/propsdlgplugin/propsdlgshareplugin.cpp6
-rw-r--r--tdeioslave/media/propsdlgplugin/propsdlgshareplugin.h2
-rw-r--r--tdeioslave/media/services/CMakeLists.txt4
-rw-r--r--tdeioslave/media/services/Makefile.am2
-rw-r--r--tdeioslave/media/services/media_decrypt.desktop11
-rw-r--r--tdeioslave/media/services/media_eject.desktop6
-rw-r--r--tdeioslave/media/services/media_lock.desktop10
-rw-r--r--tdeioslave/media/services/media_mount.desktop8
-rw-r--r--tdeioslave/media/services/media_realfolder.desktop10
-rw-r--r--tdeioslave/media/services/media_safelyremove.desktop6
-rw-r--r--tdeioslave/media/services/media_unlock.desktop10
-rw-r--r--tdeioslave/media/services/media_unmount.desktop6
-rw-r--r--tdeioslave/media/tdecmodule/main.cpp8
-rw-r--r--tdeioslave/media/tdecmodule/main.h2
-rw-r--r--tdeioslave/media/tdecmodule/managermodule.cpp40
-rw-r--r--tdeioslave/media/tdecmodule/managermodule.h2
-rw-r--r--tdeioslave/media/tdecmodule/managermoduleview.ui34
-rw-r--r--tdeioslave/media/tdecmodule/notifiermodule.cpp24
-rw-r--r--tdeioslave/media/tdecmodule/notifiermodule.h2
-rw-r--r--tdeioslave/media/tdecmodule/serviceconfigdialog.cpp8
-rw-r--r--tdeioslave/media/tdecmodule/serviceconfigdialog.h2
-rw-r--r--tdeioslave/media/tdefile-plugin/tdefile_media.desktop2
-rw-r--r--tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp13
-rw-r--r--tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h2
-rw-r--r--tdeioslave/media/tdeio_media.cpp4
-rw-r--r--tdeioslave/media/tdeio_media.h2
80 files changed, 1262 insertions, 3512 deletions
diff --git a/tdeioslave/media/Makefile.am b/tdeioslave/media/Makefile.am
index a5551fb2e..2ce7900b4 100644
--- a/tdeioslave/media/Makefile.am
+++ b/tdeioslave/media/Makefile.am
@@ -1,7 +1,3 @@
-if include_media_halbackend
-PROPSDLGPLUGINDIR = propsdlgplugin
-endif
-
SUBDIRS = libmediacommon . mediamanager medianotifier mounthelper \
tdefile-plugin tdecmodule mimetypes services $(PROPSDLGPLUGINDIR)
diff --git a/tdeioslave/media/configure.in.in b/tdeioslave/media/configure.in.in
index 413848b64..a6718eb16 100644
--- a/tdeioslave/media/configure.in.in
+++ b/tdeioslave/media/configure.in.in
@@ -6,179 +6,3 @@ AC_CHECK_HEADER(linux/cdrom.h,
LINUXCDPOLLING=yes
AC_SUBST(LINUXCDPOLLING)
])
-
-
-AC_ARG_WITH(hal,AC_HELP_STRING([--with-hal],[Enable HAL support [default=check]]),[hal_test="$withval"],[hal_test="yes"])
-
-if test "x$hal_test" = "xyes" ; then
-
-########### Check for the HAL
- AC_MSG_CHECKING(for the HAL)
-
- hal_inc=NOTFOUND
- hal_lib=NOTFOUND
- hal=NOTFOUND
-
- search_incs="$kde_includes $kde_extra_includes /usr/include /usr/include/hal /usr/local/include /usr/local/include/hal"
- AC_FIND_FILE(libhal.h libhal-storage.h, $search_incs, hal_incdir)
-
- if test -r $hal_incdir/libhal.h && test -r $hal_incdir/libhal-storage.h && grep LibHalVolume $hal_incdir/libhal-storage.h > /dev/null 2>&1; then
- HAL_INCS="-I$hal_incdir"
- hal_inc=FOUND
- fi
-
- search_libs="$kde_libraries $kde_extra_libs /usr/lib$tdelibsuff /usr/local/lib$tdelibsuff"
- AC_FIND_FILE(libhal.so libhal-storage.so, $search_libs, hal_libdir)
-
- if test -r $hal_libdir/libhal.so && test -r $hal_libdir/libhal-storage.so ; then
- HAL_LIBS="-L$hal_libdir -lhal -lhal-storage"
- hal_lib=FOUND
- fi
-
- if test "$hal_inc" != FOUND || test "$hal_lib" != FOUND; then
- KDE_PKG_CHECK_MODULES( HAL, hal > 0.5, [ HAL_INCS=$HAL_CFLAGS; hal_inc=FOUND; hal_lib=FOUND; ] , AC_MSG_RESULT(Nothing found on PKG_CONFIG_PATH) )
- fi
-
- if test "$hal_inc" = FOUND && test "$hal_lib" = FOUND ; then
- AC_MSG_RESULT(headers $HAL_INCS libraries $HAL_LIBS)
- hal=FOUND
- else
- AC_MSG_RESULT(searched but not found)
- fi
-
-
- AC_SUBST(HAL_INCS)
- AC_SUBST(HAL_LIBS)
-
-
-########### Check for DBus
-
- AC_MSG_CHECKING(for DBus)
-
- dbus_inc=NOTFOUND
- dbus_lib=NOTFOUND
- dbus=NOTFOUND
-
- search_incs="$kde_includes $kde_extra_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
- AC_FIND_FILE(dbus/dbus.h, $search_incs, dbus_incdir)
-
- search_incs_arch_deps="$kde_includes $kde_extra_includes /usr/lib$tdelibsuff/dbus-1.0/include /usr/local/lib$tdelibsuff/dbus-1.0/include"
- AC_FIND_FILE(dbus/dbus-arch-deps.h, $search_incs_arch_deps, dbus_incdir_arch_deps)
-
- if test -r $dbus_incdir/dbus/dbus.h && test -r $dbus_incdir_arch_deps/dbus/dbus-arch-deps.h ; then
- DBUS_INCS="-I$dbus_incdir -I$dbus_incdir_arch_deps"
- dbus_inc=FOUND
- fi
-
- search_libs="$kde_libraries $kde_extra_libs /usr/lib$tdelibsuff /usr/local/lib$tdelibsuff"
- AC_FIND_FILE(libdbus-1.so, $search_libs, dbus_libdir)
-
- if test -r $dbus_libdir/libdbus-1.so ; then
- DBUS_LIBS="-L$dbus_libdir -ldbus-1"
- dbus_lib=FOUND
- fi
-
- if test $dbus_inc != FOUND || test $dbus_lib != FOUND ; then
- KDE_PKG_CHECK_MODULES( DBUS, "dbus-1", [ DBUS_INCS=$DBUS_CFLAGS; dbus_inc=FOUND; dbus_lib=FOUND; ] , AC_MSG_RESULT( Nothing found on PKG_CONFIG_PATH ) )
- fi
-
- dbus_bus_var=`pkg-config --variable=system_bus_default_address dbus-1 2>/dev/null`
- if test -z "$dbus_bus_var"; then
- dbus_bus_var="unix:path=/var/run/dbus/system_bus_socket"
- fi
- AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS, "$dbus_bus_var", [Define the unix domain path for dbus system bus])
-
- if test $dbus_inc = FOUND && test $dbus_lib = FOUND ; then
- AC_MSG_RESULT(headers $DBUS_INCS libraries $DBUS_LIBS)
- dbus=FOUND
- else
- AC_MSG_RESULT(searched but not found)
- fi
-
- AC_SUBST(DBUS_INCS)
- AC_SUBST(DBUS_LIBS)
-
-########### Check for DBus-Qt3 bindings
-
- AC_MSG_CHECKING(for DBus-Qt3 bindings)
-
- dbusqt_inc=NOTFOUND
- dbusqt_lib=NOTFOUND
- dbusqt=NOTFOUND
-
- search_incs="$kde_includes $kde_extra_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
- AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir)
-
- if test -r $dbusqt_incdir/dbus/connection.h ; then
- have_qt_patch=0
- grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \
- > /dev/null 2>&1 && have_qt_patch=1
- if test $have_qt_patch = 1 ; then
- DBUSTQT_INCS="-I$dbusqt_incdir"
- dbusqt_inc=FOUND
- fi
- fi
-
- search_libs="$kde_libraries $kde_extra_libs /usr/lib$tdelibsuff /usr/local/lib$tdelibsuff"
- AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir)
-
- if test -r $dbusqt_libdir/libdbus-qt-1.so ; then
- DBUSTQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1"
- dbusqt_lib=FOUND
- fi
-
- if test $dbusqt_inc != FOUND || test $dbusqt_lib != FOUND ; then
-
- search_incs="`pkg-config --cflags dbus-1 |sed 's/-I//g'`"
- AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir)
- if test -r $dbusqt_incdir/dbus/connection.h ; then
- have_qt_patch=0
- grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \
- > /dev/null 2>&1 && have_qt_patch=1
- if test $have_qt_patch = 1 ; then
- DBUSTQT_INCS="-I$dbusqt_incdir"
- dbusqt_inc=FOUND
- fi
- fi
-
- search_libs="`pkg-config --libs dbus-1 --libs-only-L | sed 's/-L//g'`"
- AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir)
-
- if test -r $dbusqt_libdir/libdbus-qt-1.so ; then
- DBUSTQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1"
- dbusqt_lib=FOUND
- fi
-
- fi
-
-
- if test $dbusqt_inc = FOUND && test $dbusqt_lib = FOUND ; then
- AC_MSG_RESULT(headers $dbusqt_incdir libraries $dbusqt_libdir)
- dbusqt=FOUND
- else
- AC_MSG_RESULT(searched but not found)
- fi
-
- AC_SUBST(DBUSTQT_INCS)
- AC_SUBST(DBUSTQT_LIBS)
-fi
-
-########### Check if media HAL backend sould be compiled
-
-AC_MSG_CHECKING(if the HAL backend for media:/ should be compiled)
-
-HALBACKEND=no
-if test "x$hal" = "xFOUND" && test "x$dbus" = "xFOUND" && test "x$dbusqt" = "xFOUND" ; then
- AC_DEFINE_UNQUOTED([COMPILE_HALBACKEND],1, [media HAL backend compilation])
- HALBACKEND=yes
- AC_SUBST(HALBACKEND)
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-
-AM_CONDITIONAL(include_media_linuxcdpolling, test "$LINUXCDPOLLING" = "yes")
-AM_CONDITIONAL(include_media_halbackend, test "$HALBACKEND" = yes)
-
-AC_CHECK_FUNCS(statvfs)
-
diff --git a/tdeioslave/media/contrib/README b/tdeioslave/media/contrib/README
index 8f6041578..4e330e073 100644
--- a/tdeioslave/media/contrib/README
+++ b/tdeioslave/media/contrib/README
@@ -1,11 +1,5 @@
Those scripts are an example on how to allow media:/ to use
-hotplugging events if you don't use HAL. They're targeting
-"Linux 2.6 + hotplug + udev" platforms, but we can surely make
-something equivalent for Linux 2.4, FreeBSD...
-
-They are just examples, the packagers will surely develop their
-own version (I'm currently using them on Debian Sid, Linux 2.6.9
-though).
+hotplugging events.
1) mediamanager_usbstorage.dev
This file only needs to be copied to /etc/dev.d/default
diff --git a/tdeioslave/media/libmediacommon/mediamanagersettings.kcfg b/tdeioslave/media/libmediacommon/mediamanagersettings.kcfg
index 32725c1bb..8136ecd79 100644
--- a/tdeioslave/media/libmediacommon/mediamanagersettings.kcfg
+++ b/tdeioslave/media/libmediacommon/mediamanagersettings.kcfg
@@ -4,11 +4,6 @@
<kcfg>
<kcfgfile name="mediamanagerrc"/>
<group name="Global">
- <entry name="HalBackendEnabled" type="Bool">
- <label>Enable HAL backend</label>
- <whatsthis>When HAL (Hardware Abstraction Layer) support is enabled, TDE will use it to gather information on the storage media available in your system.</whatsthis>
- <default>true</default>
- </entry>
<entry name="TdeHardwareBackendEnabled" type="Bool">
<label>Enable TDE hardware library backend</label>
<whatsthis>When TDE hardware library support is enabled, TDE will use it to gather information on the storage media available in your system.</whatsthis>
@@ -25,8 +20,13 @@
<default>true</default>
</entry>
<entry name="NotificationPopupsEnabled" type="Bool">
- <label>Enable notification popups</label>
- <whatsthis>Deselect this if you do not want action request popups to be generated when devices are plugged in.</whatsthis>
+ <label>Enable notification dialogs popups</label>
+ <whatsthis>Deselect this if you do not want action request dialog popups to be generated when devices are plugged in.</whatsthis>
+ <default>true</default>
+ </entry>
+ <entry name="DeviceMonitorPopupsEnabled" type="Bool">
+ <label>Enable device monitor notification popups</label>
+ <whatsthis>Deselect this if you do not want device monitoring popups to be generated when devices are added, modified or removed.</whatsthis>
<default>true</default>
</entry>
</group>
diff --git a/tdeioslave/media/libmediacommon/medium.cpp b/tdeioslave/media/libmediacommon/medium.cpp
index 77e32ba0f..797c409b4 100644
--- a/tdeioslave/media/libmediacommon/medium.cpp
+++ b/tdeioslave/media/libmediacommon/medium.cpp
@@ -23,68 +23,58 @@
const TQString Medium::SEPARATOR = "---";
+void Medium::initMedium()
+{
+ m_properties.clear();
+ m_properties += TQString::null; // ID
+ m_properties += TQString::null; // UUID
+ m_properties += TQString::null; // NAME
+ m_properties += TQString::null; // LABEL
+ m_properties += TQString::null; // USER_LABEL
+ m_properties += "false"; // MOUNTABLE
+ m_properties += TQString::null; // DEVICE_NODE
+ m_properties += TQString::null; // MOUNT_POINT
+ m_properties += TQString::null; // FS_TYPE
+ m_properties += "false"; // MOUNTED
+ m_properties += TQString::null; // BASE_URL
+ m_properties += TQString::null; // MIME_TYPE
+ m_properties += TQString::null; // ICON_NAME
+ m_properties += "false"; // ENCRYPTED
+ m_properties += TQString::null; // CLEAR_DEVICE_UDI
+ m_properties += "false"; // HIDDEN
+ m_properties += "false"; // SOFT_HIDDEN
+ m_properties += "false"; // LOCKED
+}
+
Medium::Medium(const TQString id, TQString uuid, const TQString name)
{
- m_properties+= id; /* ID */
- m_properties+= uuid; /* UUID */
- m_properties+= name; /* NAME */
- m_properties+= name; /* LABEL */
- m_properties+= TQString::null; /* USER_LABEL */
-
- m_properties+= "false"; /* MOUNTABLE */
- m_properties+= TQString::null; /* DEVICE_NODE */
- m_properties+= TQString::null; /* MOUNT_POINT */
- m_properties+= TQString::null; /* FS_TYPE */
- m_properties+= "false"; /* MOUNTED */
- m_properties+= TQString::null; /* BASE_URL */
- m_properties+= TQString::null; /* MIME_TYPE */
- m_properties+= TQString::null; /* ICON_NAME */
- m_properties+= "false"; /* ENCRYPTED */
- m_properties+= TQString::null; /* CLEAR_DEVICE_UDI */
- m_properties+= "false"; /* HIDDEN */
- m_properties+= "false"; /* SOFT_HIDDEN */
-
- loadUserLabel();
-
- m_halmounted = false;
+ initMedium();
+ if (!id.isEmpty() && !uuid.isEmpty())
+ {
+ m_properties[ID] = id;
+ m_properties[UUID] = uuid;
+ m_properties[NAME] = name;
+ m_properties[LABEL] = name;
+ loadUserLabel();
+ }
}
Medium::Medium()
{
- m_properties+= TQString::null; /* ID */
- m_properties+= TQString::null; /* UUID */
- m_properties+= TQString::null; /* NAME */
- m_properties+= TQString::null; /* LABEL */
- m_properties+= TQString::null; /* USER_LABEL */
-
- m_properties+= TQString::null; /* MOUNTABLE */
- m_properties+= TQString::null; /* DEVICE_NODE */
- m_properties+= TQString::null; /* MOUNT_POINT */
- m_properties+= TQString::null; /* FS_TYPE */
- m_properties+= TQString::null; /* MOUNTED */
- m_properties+= TQString::null; /* BASE_URL */
- m_properties+= TQString::null; /* MIME_TYPE */
- m_properties+= TQString::null; /* ICON_NAME */
- m_properties+= TQString::null; /* ENCRYPTED */
- m_properties+= TQString::null; /* CLEAR_DEVICE_UDI */
- m_properties+= "false"; /* HIDDEN */
- m_properties+= "false"; /* SOFT_HIDDEN */
-
- m_halmounted = false;
+ initMedium();
}
const Medium Medium::create(const TQStringList &properties)
{
Medium m;
- if ( properties.size() >= PROPERTIES_COUNT )
+ if (properties.size() >= PROPERTIES_COUNT)
{
m.m_properties[ID] = properties[ID];
m.m_properties[UUID] = properties[UUID];
m.m_properties[NAME] = properties[NAME];
m.m_properties[LABEL] = properties[LABEL];
m.m_properties[USER_LABEL] = properties[USER_LABEL];
-
m.m_properties[MOUNTABLE] = properties[MOUNTABLE];
m.m_properties[DEVICE_NODE] = properties[DEVICE_NODE];
m.m_properties[MOUNT_POINT] = properties[MOUNT_POINT];
@@ -97,6 +87,7 @@ const Medium Medium::create(const TQStringList &properties)
m.m_properties[CLEAR_DEVICE_UDI] = properties[CLEAR_DEVICE_UDI];
m.m_properties[HIDDEN] = properties[HIDDEN];
m.m_properties[SOFT_HIDDEN] = properties[SOFT_HIDDEN];
+ m.m_properties[LOCKED] = properties[LOCKED];
}
return m;
@@ -106,13 +97,12 @@ Medium::MList Medium::createList(const TQStringList &properties)
{
MList l;
- if ( properties.size() % (PROPERTIES_COUNT+1) == 0)
+ if (properties.size() % (PROPERTIES_COUNT+1) == 0)
{
- int media_count = properties.size()/(PROPERTIES_COUNT+1);
-
+ int media_count = properties.size() / (PROPERTIES_COUNT + 1);
TQStringList props = properties;
- for(int i=0; i<media_count; i++)
+ for (int i=0; i < media_count; i++)
{
const Medium m = create(props);
l.append(m);
@@ -127,7 +117,6 @@ Medium::MList Medium::createList(const TQStringList &properties)
return l;
}
-
void Medium::setName(const TQString &name)
{
m_properties[NAME] = name;
@@ -138,35 +127,22 @@ void Medium::setLabel(const TQString &label)
m_properties[LABEL] = label;
}
-void Medium::setEncrypted(bool state)
-{
- m_properties[ENCRYPTED] = ( state ? "true" : "false" );
-}
-
-void Medium::setHidden(bool state)
-{
- m_properties[HIDDEN] = ( state ? "true" : "false" );
-}
-
-void Medium::setSoftHidden(bool state)
-{
- m_properties[SOFT_HIDDEN] = ( state ? "true" : "false" );
-}
-
void Medium::setUserLabel(const TQString &label)
{
TDEConfig cfg("mediamanagerrc");
cfg.setGroup("UserLabels");
TQString entry_name = m_properties[UUID];
-
- if ( label.isNull() )
- {
- cfg.deleteEntry(entry_name);
- }
- else
+ if (!entry_name.isEmpty())
{
- cfg.writeEntry(entry_name, label);
+ if (label.isEmpty())
+ {
+ cfg.deleteEntry(entry_name);
+ }
+ else
+ {
+ cfg.writeEntry(entry_name, label);
+ }
}
m_properties[USER_LABEL] = label;
@@ -178,10 +154,9 @@ void Medium::loadUserLabel()
cfg.setGroup("UserLabels");
TQString entry_name = m_properties[UUID];
-
- if ( cfg.hasKey(entry_name) )
+ if (!entry_name.isEmpty())
{
- m_properties[USER_LABEL] = cfg.readEntry(entry_name);
+ m_properties[USER_LABEL] = cfg.readEntry(entry_name, TQString::null);
}
else
{
@@ -189,48 +164,52 @@ void Medium::loadUserLabel()
}
}
-
-bool Medium::mountableState(bool mounted)
+void Medium::setMountable(bool mountable)
{
- if ( m_properties[DEVICE_NODE].isEmpty()
- || ( mounted && m_properties[MOUNT_POINT].isEmpty() ) )
+ m_properties[MOUNTABLE] = mountable ? "true" : "false";
+ if (!mountable)
{
- return false;
+ setMountPoint(TQString::null);
+ setMounted(false);
}
+}
- m_properties[MOUNTABLE] = "true";
- m_properties[MOUNTED] = ( mounted ? "true" : "false" );
+void Medium::setDeviceNode(const TQString &deviceNode)
+{
+ m_properties[DEVICE_NODE] = deviceNode;
+}
- return true;
+void Medium::setMountPoint(const TQString &mountPoint)
+{
+ if (isMountable())
+ {
+ m_properties[MOUNT_POINT] = mountPoint;
+ }
+ else
+ {
+ m_properties[MOUNT_POINT] = TQString::null;
+ }
}
-void Medium::mountableState(const TQString &deviceNode,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted)
+void Medium::setFsType(const TQString &fsType)
{
- m_properties[MOUNTABLE] = "true";
- m_properties[DEVICE_NODE] = deviceNode;
- m_properties[MOUNT_POINT] = mountPoint;
m_properties[FS_TYPE] = fsType;
- m_properties[MOUNTED] = ( mounted ? "true" : "false" );
}
-void Medium::mountableState(const TQString &deviceNode,
- const TQString &clearDeviceUdi,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted)
+void Medium::setMounted(bool mounted)
{
- m_properties[MOUNTABLE] = "true";
- m_properties[DEVICE_NODE] = deviceNode;
- m_properties[CLEAR_DEVICE_UDI] = clearDeviceUdi;
- m_properties[MOUNT_POINT] = mountPoint;
- m_properties[FS_TYPE] = fsType;
- m_properties[MOUNTED] = ( mounted ? "true" : "false" );
+ if (isMountable())
+ {
+ m_properties[MOUNTED] = mounted ? "true" : "false";
+ }
+ else
+ {
+ m_properties[MOUNTED] = "false";
+ }
}
-void Medium::unmountableState(const TQString &baseURL)
+void Medium::setBaseURL(const TQString &baseURL)
{
- m_properties[MOUNTABLE] = "false";
m_properties[BASE_URL] = baseURL;
}
@@ -244,33 +223,51 @@ void Medium::setIconName(const TQString &iconName)
m_properties[ICON_NAME] = iconName;
}
-bool Medium::needMounting() const
+void Medium::setEncrypted(bool encrypted)
+{
+ m_properties[ENCRYPTED] = encrypted ? "true" : "false";
+ if (!encrypted)
+ {
+ setLocked(false);
+ }
+}
+
+void Medium::setClearDeviceUdi(const TQString &clearDeviceUdi)
{
- return isMountable() && !isMounted();
+ m_properties[CLEAR_DEVICE_UDI] = clearDeviceUdi;
}
-bool Medium::needDecryption() const
+void Medium::setHidden(bool state)
{
- return isEncrypted() && clearDeviceUdi().isEmpty();
+ m_properties[HIDDEN] = state ? "true" : "false";
+}
+
+void Medium::setSoftHidden(bool state)
+{
+ m_properties[SOFT_HIDDEN] = state ? "true" : "false";
+}
+
+void Medium::setLocked(bool locked)
+{
+ m_properties[LOCKED] = locked ? "true" : "false";
}
KURL Medium::prettyBaseURL() const
{
- if ( !baseURL().isEmpty() )
- return baseURL();
+ if (!baseURL().isEmpty())
+ {
+ return baseURL();
+ }
- return KURL( mountPoint() );
+ return KURL(mountPoint());
}
TQString Medium::prettyLabel() const
{
- if ( !userLabel().isEmpty() )
+ if (!userLabel().isEmpty())
{
return userLabel();
}
- else
- {
- return label();
- }
-}
+ return label();
+}
diff --git a/tdeioslave/media/libmediacommon/medium.h b/tdeioslave/media/libmediacommon/medium.h
index bf465fd09..3c9677c21 100644
--- a/tdeioslave/media/libmediacommon/medium.h
+++ b/tdeioslave/media/libmediacommon/medium.h
@@ -29,24 +29,25 @@ class Medium
public:
typedef TQValueList<Medium> MList;
- static const uint ID = 0;
- static const uint UUID = 1;
- static const uint NAME = 2;
- static const uint LABEL = 3;
- static const uint USER_LABEL = 4;
- static const uint MOUNTABLE = 5;
- static const uint DEVICE_NODE = 6;
- static const uint MOUNT_POINT = 7;
- static const uint FS_TYPE = 8;
- static const uint MOUNTED = 9;
- static const uint BASE_URL = 10;
- static const uint MIME_TYPE = 11;
- static const uint ICON_NAME = 12;
- static const uint ENCRYPTED = 13;
- static const uint CLEAR_DEVICE_UDI = 14;
- static const uint HIDDEN = 15;
- static const uint SOFT_HIDDEN = 16;
- static const uint PROPERTIES_COUNT = 17;
+ static const uint ID = 0;
+ static const uint UUID = 1;
+ static const uint NAME = 2;
+ static const uint LABEL = 3;
+ static const uint USER_LABEL = 4;
+ static const uint MOUNTABLE = 5;
+ static const uint DEVICE_NODE = 6;
+ static const uint MOUNT_POINT = 7;
+ static const uint FS_TYPE = 8;
+ static const uint MOUNTED = 9;
+ static const uint BASE_URL = 10;
+ static const uint MIME_TYPE = 11;
+ static const uint ICON_NAME = 12;
+ static const uint ENCRYPTED = 13;
+ static const uint CLEAR_DEVICE_UDI = 14;
+ static const uint HIDDEN = 15;
+ static const uint SOFT_HIDDEN = 16;
+ static const uint LOCKED = 17;
+ static const uint PROPERTIES_COUNT = 18;
static const TQString SEPARATOR;
Medium(const TQString id, TQString uuid, const TQString name);
@@ -60,71 +61,67 @@ public:
TQString name() const { return m_properties[NAME]; }
TQString label() const { return m_properties[LABEL]; }
TQString userLabel() const { return m_properties[USER_LABEL]; }
- bool isMountable() const { return m_properties[MOUNTABLE]=="true"; }
+ bool isMountable() const { return m_properties[MOUNTABLE] == "true"; }
TQString deviceNode() const { return m_properties[DEVICE_NODE]; }
TQString mountPoint() const { return m_properties[MOUNT_POINT]; }
TQString fsType() const { return m_properties[FS_TYPE]; }
- bool isMounted() const { return m_properties[MOUNTED]=="true"; }
+ bool isMounted() const { return m_properties[MOUNTED] == "true"; }
TQString baseURL() const { return m_properties[BASE_URL]; }
TQString mimeType() const { return m_properties[MIME_TYPE]; }
TQString iconName() const { return m_properties[ICON_NAME]; }
- bool isEncrypted() const { return m_properties[ENCRYPTED]=="true"; };
+ bool isEncrypted() const { return m_properties[ENCRYPTED] == "true"; };
TQString clearDeviceUdi() const { return m_properties[CLEAR_DEVICE_UDI]; };
- bool hidden() const { return m_properties[HIDDEN]=="true"; };
- bool softHidden() const { return m_properties[SOFT_HIDDEN]=="true"; };
+ bool hidden() const { return m_properties[HIDDEN] == "true"; };
+ bool softHidden() const { return m_properties[SOFT_HIDDEN] == "true"; };
+ bool isLocked() const { return m_properties[LOCKED] == "true"; };
- bool needMounting() const;
- bool needDecryption() const;
+ bool needMounting() const { return isMountable() && !isMounted(); };
+ bool needUnlocking() const { return isEncrypted() && isLocked(); }
KURL prettyBaseURL() const;
TQString prettyLabel() const;
void setName(const TQString &name);
void setLabel(const TQString &label);
void setUserLabel(const TQString &label);
- void setEncrypted(bool state);
- void setHidden(bool state);
- void setSoftHidden(bool state);
-
- bool mountableState(bool mounted);
- void mountableState(const TQString &deviceNode,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted);
- void mountableState(const TQString &deviceNode,
- const TQString &clearDeviceUdi,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted);
- void unmountableState(const TQString &baseURL = TQString::null);
-
+ void setMountable(bool mountable);
+ void setDeviceNode(const TQString &deviceNode);
+ void setMountPoint(const TQString &mountPoint);
+ void setFsType(const TQString &fsType);
+ void setMounted(bool mounted);
+ void setBaseURL(const TQString &baseURL);
void setMimeType(const TQString &mimeType);
void setIconName(const TQString &iconName);
- void setHalMounted(bool flag) const { m_halmounted = flag; }
- bool halMounted() const { return m_halmounted; }
+ void setEncrypted(bool encrypted);
+ void setClearDeviceUdi(const TQString &clearDeviceUdi);
+ void setHidden(bool state);
+ void setSoftHidden(bool state);
+ void setLocked(bool locked);
-//private:
Medium();
private:
+ void initMedium();
void loadUserLabel();
TQStringList m_properties;
- mutable bool m_halmounted;
-friend class TQValueListNode<const Medium>;
+ friend class TQValueListNode<const Medium>;
};
namespace MediaManagerUtils {
- static inline TQMap<TQString,TQString> splitOptions(const TQStringList & options)
- {
- TQMap<TQString,TQString> valids;
-
- for (TQStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
+ static inline TQMap<TQString,TQString> splitOptions(const TQStringList &options)
{
- TQString key = (*it).left((*it).find('='));
- TQString value = (*it).mid((*it).find('=') + 1);
- valids[key] = value;
+ TQMap<TQString,TQString> valids;
+
+ for (TQStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
+ {
+ int pos = (*it).find('=');
+ TQString key = (*it).left(pos);
+ TQString value = (*it).mid(pos + 1);
+ valids[key] = value;
+ }
+ return valids;
}
- return valids;
- }
}
#endif
diff --git a/tdeioslave/media/libmediacommon/notifieraction.cpp b/tdeioslave/media/libmediacommon/notifieraction.cpp
index 5222b9e65..8eaafcd81 100644
--- a/tdeioslave/media/libmediacommon/notifieraction.cpp
+++ b/tdeioslave/media/libmediacommon/notifieraction.cpp
@@ -57,8 +57,7 @@ TQPixmap NotifierAction::pixmap() const
}
else
{
- TQString path = TDEGlobal::iconLoader()->iconPath( m_iconName, -32 );
- return TQPixmap( path );
+ return TDEGlobal::iconLoader()->loadIcon(m_iconName, TDEIcon::NoGroup, TDEIcon::SizeSmall);
}
}
diff --git a/tdeioslave/media/mediaimpl.cpp b/tdeioslave/media/mediaimpl.cpp
index b92757f90..510437072 100644
--- a/tdeioslave/media/mediaimpl.cpp
+++ b/tdeioslave/media/mediaimpl.cpp
@@ -127,7 +127,6 @@ bool MediaImpl::statMediumByLabel(const TQString &label, TDEIO::UDSEntry &entry)
return statMedium(name, entry);
}
-
bool MediaImpl::listMedia(TQValueList<TDEIO::UDSEntry> &list)
{
kdDebug(1219) << "MediaImpl::listMedia" << endl;
@@ -149,7 +148,7 @@ bool MediaImpl::listMedia(TQValueList<TDEIO::UDSEntry> &list)
Medium::MList::const_iterator it = media.begin();
Medium::MList::const_iterator end = media.end();
- for(; it!=end; ++it)
+ for(; it != end; ++it)
{
if (!(*it).hidden()) {
entry.clear();
@@ -231,15 +230,6 @@ bool MediaImpl::ensureMediumMounted(Medium &medium)
return false;
}
-#ifdef COMPILE_HALBACKEND
- if ( medium.isEncrypted() && medium.clearDeviceUdi().isEmpty() )
- {
- m_lastErrorCode = TDEIO::ERR_COULD_NOT_MOUNT;
- m_lastErrorMessage = i18n("The drive is encrypted.");
- return false;
- }
-#endif // COMPILE_HALBACKEND
-
if ( medium.needMounting() )
{
m_lastErrorCode = 0;
@@ -252,10 +242,10 @@ bool MediaImpl::ensureMediumMounted(Medium &medium)
medium.deviceNode(),
medium.mountPoint());
job->setAutoWarningHandlingEnabled(false);
- connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ),
- this, TQT_SLOT( slotMountResult( TDEIO::Job * ) ) );
- connect( job, TQT_SIGNAL( warning( TDEIO::Job *, const TQString & ) ),
- this, TQT_SLOT( slotWarning( TDEIO::Job *, const TQString & ) ) );
+ connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ),
+ this, TQ_SLOT( slotMountResult( TDEIO::Job * ) ) );
+ connect( job, TQ_SIGNAL( warning( TDEIO::Job *, const TQString & ) ),
+ this, TQ_SLOT( slotWarning( TDEIO::Job *, const TQString & ) ) );
*/
kapp->dcopClient()
->connectDCOPSignal("kded", "mediamanager",
@@ -366,14 +356,19 @@ void MediaImpl::slotStatResult(TDEIO::Job *job)
TDEIO::UDSEntry MediaImpl::extractUrlInfos(const KURL &url)
{
+ if (url.isEmpty())
+ {
+ return TDEIO::UDSEntry();
+ }
+
m_entryBuffer.clear();
TDEIO::StatJob *job = TDEIO::stat(url, false);
job->setAutoWarningHandlingEnabled( false );
- connect( job, TQT_SIGNAL( result(TDEIO::Job *) ),
- this, TQT_SLOT( slotStatResult(TDEIO::Job *) ) );
- connect( job, TQT_SIGNAL( warning( TDEIO::Job *, const TQString & ) ),
- this, TQT_SLOT( slotWarning( TDEIO::Job *, const TQString & ) ) );
+ connect( job, TQ_SIGNAL( result(TDEIO::Job *) ),
+ this, TQ_SLOT( slotStatResult(TDEIO::Job *) ) );
+ connect( job, TQ_SIGNAL( warning( TDEIO::Job *, const TQString & ) ),
+ this, TQ_SLOT( slotWarning( TDEIO::Job *, const TQString & ) ) );
tqApp->eventLoop()->enterLoop();
TDEIO::UDSEntry::iterator it = m_entryBuffer.begin();
@@ -449,7 +444,7 @@ void MediaImpl::createMediumEntry(TDEIO::UDSEntry& entry,
else
{
KURL url = medium.prettyBaseURL();
- entry+= extractUrlInfos(url);
+ entry += extractUrlInfos(url);
}
}
diff --git a/tdeioslave/media/mediaimpl.h b/tdeioslave/media/mediaimpl.h
index 1080d6783..a7416f0e5 100644
--- a/tdeioslave/media/mediaimpl.h
+++ b/tdeioslave/media/mediaimpl.h
@@ -32,7 +32,7 @@
class MediaImpl : public TQObject, public DCOPObject
{
-Q_OBJECT
+TQ_OBJECT
K_DCOP
public:
MediaImpl();
diff --git a/tdeioslave/media/mediamanager/CMakeLists.txt b/tdeioslave/media/mediamanager/CMakeLists.txt
index fd0c0f09b..b052bff87 100644
--- a/tdeioslave/media/mediamanager/CMakeLists.txt
+++ b/tdeioslave/media/mediamanager/CMakeLists.txt
@@ -16,13 +16,10 @@ include_directories(
${CMAKE_BINARY_DIR}
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
- ${HAL_INCLUDE_DIRS}
- ${DBUS_TQT_INCLUDE_DIRS}
)
link_directories(
${TQT_LIBRARY_DIRS}
- ${DBUS_TQT_LIBRARY_DIRS}
)
@@ -45,11 +42,6 @@ tde_create_translated_desktop(
set( target kded_mediamanager )
-if( WITH_HAL )
- set( HAL_MEDIA_BACKEND halbackend.cpp linuxcdpolling.cpp )
- set( HAL_MEDIA_LIBRARIES ${HAL_LIBRARIES} -lhal-storage ${DBUS_TQT_LIBRARIES} )
-endif( )
-
if( WITH_TDEHWLIB )
set( TDEHWBACKEND tdehardwarebackend.cpp )
endif( WITH_TDEHWLIB )
@@ -60,7 +52,7 @@ tde_add_kpart( ${target} AUTOMOC
backendbase.cpp fstabbackend.cpp removablebackend.cpp
unlockdialog.ui dialog.cpp
mediadirnotify.cpp mediadirnotify.skel
- ${HAL_MEDIA_BACKEND} ${TDEHWBACKEND}
- LINK mediacommon-static tdeinit_kded-shared ${HAL_MEDIA_LIBRARIES}
+ ${TDEHWBACKEND}
+ LINK mediacommon-static tdeinit_kded-shared ${TDEHW_LIBRARIES}
DESTINATION ${PLUGIN_INSTALL_DIR}
)
diff --git a/tdeioslave/media/mediamanager/Makefile.am b/tdeioslave/media/mediamanager/Makefile.am
index 489226e8e..87a20cb89 100644
--- a/tdeioslave/media/mediamanager/Makefile.am
+++ b/tdeioslave/media/mediamanager/Makefile.am
@@ -1,18 +1,7 @@
kde_module_LTLIBRARIES = kded_mediamanager.la
-if include_media_halbackend
-HALBACKEND_INCS = $(HAL_INCS) $(DBUS_INCS) $(DBUSTQT_INCS)
-endif
-
METASOURCES = AUTO
-INCLUDES = -I$(srcdir)/../libmediacommon -I../libmediacommon $(HALBACKEND_INCS) $(all_includes)
-
-if include_media_halbackend
-HALBACKEND_LIB = libhalbackend.la
-libhalbackend_la_SOURCES = halbackend.cpp
-libhalbackend_la_LDFLAGS = -avoid-version $(all_libraries) -no-undefined
-libhalbackend_la_LIBADD = $(HAL_LIBS) $(DBUS_LIBS) $(DBUSTQT_LIBS)
-endif
+INCLUDES = -I$(srcdir)/../libmediacommon -I../libmediacommon $(all_includes)
if include_media_linuxcdpolling
LINUXCDPOLLING_LIB = liblinuxcdpolling.la
@@ -20,11 +9,11 @@ liblinuxcdpolling_la_SOURCES = linuxcdpolling.cpp
liblinuxcdpolling_la_LDFLAGS = -avoid-version $(all_libraries) -no-undefined
endif
-noinst_LTLIBRARIES = $(LINUXCDPOLLING_LIB) $(HALBACKEND_LIB)
+noinst_LTLIBRARIES = $(LINUXCDPOLLING_LIB)
kded_mediamanager_la_SOURCES = mediamanager.cpp mediamanager.skel medialist.cpp backendbase.cpp fstabbackend.cpp removablebackend.cpp mediadirnotify.cpp mediadirnotify.skel
kded_mediamanager_la_LDFLAGS = $(all_libraries) -module -avoid-version
-kded_mediamanager_la_LIBADD = $(LIB_TDESYCOCA) ../libmediacommon/libmediacommon.la $(HALBACKEND_LIB) $(LINUXCDPOLLING_LIB)
+kded_mediamanager_la_LIBADD = $(LIB_TDESYCOCA) ../libmediacommon/libmediacommon.la $(LINUXCDPOLLING_LIB)
servicesdir = $(kde_servicesdir)/kded
diff --git a/tdeioslave/media/mediamanager/dialog.cpp b/tdeioslave/media/mediamanager/dialog.cpp
index 5f655ccce..ddfd041a0 100644
--- a/tdeioslave/media/mediamanager/dialog.cpp
+++ b/tdeioslave/media/mediamanager/dialog.cpp
@@ -23,7 +23,7 @@
#include "dialog.h"
Dialog::Dialog(TQString url, TQString iconName) :
- KDialogBase(NULL, "Unlock", true, "Unlock Storage Device", (Cancel|User1), User1, false, KGuiItem(i18n("Unlock"), "unlocked" ))
+ KDialogBase(NULL, "Unlock", true, i18n("Unlock Storage Device"), (Cancel|User1), User1, false, KGuiItem(i18n("Unlock"), "unlocked" ))
{
unlockDialog = new UnlockDialog(this);
@@ -37,7 +37,7 @@ Dialog::Dialog(TQString url, TQString iconName) :
TQPixmap pixmap = TDEGlobal::iconLoader()->loadIcon(iconName, TDEIcon::NoGroup, TDEIcon::SizeLarge);
unlockDialog->encryptedIcon->setPixmap( pixmap );
- connect(unlockDialog->passwordEdit, TQT_SIGNAL (textChanged(const TQString &)), this, TQT_SLOT (slotPasswordChanged(const TQString &)));
+ connect(unlockDialog->passwordEdit, TQ_SIGNAL (textChanged(const TQString &)), this, TQ_SLOT (slotPasswordChanged(const TQString &)));
setMainWidget(unlockDialog);
}
diff --git a/tdeioslave/media/mediamanager/dialog.h b/tdeioslave/media/mediamanager/dialog.h
index 8444ec7dd..1e3dd145c 100644
--- a/tdeioslave/media/mediamanager/dialog.h
+++ b/tdeioslave/media/mediamanager/dialog.h
@@ -41,7 +41,7 @@ class KryptoMedia;
class Dialog : public KDialogBase
{
-Q_OBJECT
+TQ_OBJECT
public:
Dialog(TQString url, TQString iconName);
diff --git a/tdeioslave/media/mediamanager/fstabbackend.cpp b/tdeioslave/media/mediamanager/fstabbackend.cpp
index 8eca21771..2bd528c19 100644
--- a/tdeioslave/media/mediamanager/fstabbackend.cpp
+++ b/tdeioslave/media/mediamanager/fstabbackend.cpp
@@ -61,8 +61,8 @@ FstabBackend::FstabBackend(MediaList &list, bool networkSharesOnly)
KDirWatch::self()->addFile(MTAB);
KDirWatch::self()->addFile(FSTAB);
- connect( KDirWatch::self(), TQT_SIGNAL( dirty(const TQString&) ),
- this, TQT_SLOT( slotDirty(const TQString&) ) );
+ connect( KDirWatch::self(), TQ_SIGNAL( dirty(const TQString&) ),
+ this, TQ_SLOT( slotDirty(const TQString&) ) );
handleFstabChange(false);
handleMtabChange(false);
@@ -70,8 +70,8 @@ FstabBackend::FstabBackend(MediaList &list, bool networkSharesOnly)
KDirWatch::self()->startScan();
#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
- connect( &m_mtabTimer, TQT_SIGNAL( timeout() ),
- this, TQT_SLOT( handleMtabChange() ) );
+ connect( &m_mtabTimer, TQ_SIGNAL( timeout() ),
+ this, TQ_SLOT( handleMtabChange() ) );
m_mtabTimer.start(250);
#endif
}
@@ -160,7 +160,6 @@ bool inExclusionPattern(KMountPoint *mount, bool networkSharesOnly)
|| mount->mountPoint().find("/sys") == 0
// We might want to display only network shares
- // since HAL doesn't handle them
|| ( networkSharesOnly
&& mount->mountType().find( "smb" ) == -1
&& mount->mountType().find( "cifs" ) == -1
@@ -220,7 +219,11 @@ void FstabBackend::handleMtabChange(bool allowNotification)
Medium *m = new Medium(id, name);
- m->mountableState(dev, mp, fs, true);
+ m->setMountable(true);
+ m->setDeviceNode(dev);
+ m->setMountPoint(mp);
+ m->setFsType(fs);
+ m->setMounted(true);
TQString mime, icon, label;
guess(dev, mp, fs, true, mime, icon, label);
@@ -293,7 +296,11 @@ void FstabBackend::handleFstabChange(bool allowNotification)
Medium *m = new Medium(id, id, name);
- m->mountableState(dev, mp, fs, false);
+ m->setMountable(true);
+ m->setDeviceNode(dev);
+ m->setMountPoint(mp);
+ m->setFsType(fs);
+ m->setMounted(false);
TQString mime, icon, label;
guess(dev, mp, fs, false, mime, icon, label);
diff --git a/tdeioslave/media/mediamanager/fstabbackend.h b/tdeioslave/media/mediamanager/fstabbackend.h
index 0aed11333..0f4b3b85e 100644
--- a/tdeioslave/media/mediamanager/fstabbackend.h
+++ b/tdeioslave/media/mediamanager/fstabbackend.h
@@ -31,7 +31,7 @@
class FstabBackend : public TQObject, public BackendBase
{
-Q_OBJECT
+TQ_OBJECT
public:
FstabBackend(MediaList &list, bool networkSharesOnly = false);
diff --git a/tdeioslave/media/mediamanager/halbackend.cpp b/tdeioslave/media/mediamanager/halbackend.cpp
deleted file mode 100644
index 157f89212..000000000
--- a/tdeioslave/media/mediamanager/halbackend.cpp
+++ /dev/null
@@ -1,1961 +0,0 @@
-/* This file is part of the KDE Project
- Copyright (c) 2004-2005 Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
- Copyright (c) 2006 Valentine Sinitsyn <e_val@inbox.ru>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- 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 "halbackend.h"
-#include "linuxcdpolling.h"
-
-#include <stdlib.h>
-#include <locale.h>
-
-#include <tdeapplication.h>
-#include <tdemessagebox.h>
-#include <tqeventloop.h>
-#include <tqfile.h>
-#include <tdelocale.h>
-#include <kurl.h>
-#include <kdebug.h>
-#include <kprocess.h>
-#include <tdeconfig.h>
-#include <tqstylesheet.h>
-#include <kmountpoint.h>
-#include <tdemessagebox.h>
-#include <tdeio/job.h>
-#include <kprotocolinfo.h>
-#include <kstandarddirs.h>
-#include <kprocess.h>
-
-#define MOUNT_MEDIA_SUFFIX (medium->isEncrypted() ? \
- (TQString("_encrypted") + (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt) ? "_unlocked" : "_locked")) : \
- (medium->isMounted() ? TQString("_mounted") : TQString("_unmounted")))
-
-#define MOUNTED_ICON_SUFFIX (medium->isEncrypted() ? \
- (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt) ? "-unlocked" : "-locked") : \
- (medium->isMounted() ? TQString("-mounted") : TQString("-unmounted")))
-
-/* Static instance of this class, for static HAL callbacks */
-static HALBackend* s_HALBackend;
-
-/* A macro function to convert HAL string properties to TQString */
-TQString libhal_device_get_property_QString(LibHalContext *ctx, const char* udi, const char *key)
-{
- char* _ppt_string;
- TQString _ppt_QString;
- _ppt_string = libhal_device_get_property_string(ctx, udi, key, NULL);
- if ( _ppt_string )
- _ppt_QString = _ppt_string;
- libhal_free_string(_ppt_string);
- return _ppt_QString;
-}
-
-/* Constructor */
-HALBackend::HALBackend(MediaList &list, TQObject* parent)
- : TQObject()
- , BackendBase(list)
- , m_halContext(NULL)
- , m_halStoragePolicy(NULL)
- , m_parent(parent)
-{
- s_HALBackend = this;
-}
-
-/* Destructor */
-HALBackend::~HALBackend()
-{
- /* Close HAL connection */
- if (m_halContext)
- {
- const TQPtrList<Medium> medlist = m_mediaList.list();
- TQPtrListIterator<Medium> it (medlist);
- for ( const Medium *current_medium = it.current(); current_medium; current_medium = ++it)
- {
- if( !current_medium->id().startsWith( "/org/kde" ))
- unmount(current_medium->id());
- }
-
-
- /* Remove all the registered media first */
- int numDevices;
- char** halDeviceList = libhal_get_all_devices( m_halContext, &numDevices, NULL );
-
- if ( halDeviceList )
- {
- for ( int i = 0; i < numDevices; i++ )
- {
- m_mediaList.removeMedium( halDeviceList[i], false );
- }
- }
-
- libhal_free_string_array( halDeviceList );
-
- DBusError error;
- dbus_error_init(&error);
- libhal_ctx_shutdown(m_halContext, &error);
- libhal_ctx_free(m_halContext);
- }
-
- if (m_halStoragePolicy)
- libhal_storage_policy_free(m_halStoragePolicy);
-}
-
-/* Connect to the HAL */
-bool HALBackend::InitHal()
-{
- kdDebug(1219) << "Context new" << endl;
- m_halContext = libhal_ctx_new();
- if (!m_halContext)
- {
- kdDebug(1219) << "Failed to initialize HAL!" << endl;
- return false;
- }
-
- // Main loop integration
- kdDebug(1219) << "Main loop integration" << endl;
- DBusError error;
- dbus_error_init(&error);
- dbus_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
-
- if (!dbus_connection || dbus_error_is_set(&error)) {
- dbus_error_free(&error);
- libhal_ctx_free(m_halContext);
- m_halContext = NULL;
- return false;
- }
-
- dbus_connection_set_exit_on_disconnect (dbus_connection, FALSE);
-
- MainLoopIntegration(dbus_connection);
- libhal_ctx_set_dbus_connection(m_halContext, dbus_connection);
-
- // HAL callback functions
- kdDebug(1219) << "Callback functions" << endl;
- libhal_ctx_set_device_added(m_halContext, HALBackend::hal_device_added);
- libhal_ctx_set_device_removed(m_halContext, HALBackend::hal_device_removed);
- libhal_ctx_set_device_new_capability (m_halContext, NULL);
- libhal_ctx_set_device_lost_capability (m_halContext, NULL);
- libhal_ctx_set_device_property_modified (m_halContext, HALBackend::hal_device_property_modified);
- libhal_ctx_set_device_condition(m_halContext, HALBackend::hal_device_condition);
-
- kdDebug(1219) << "Context Init" << endl;
- if (!libhal_ctx_init(m_halContext, &error))
- {
- if (dbus_error_is_set(&error))
- dbus_error_free(&error);
- libhal_ctx_free(m_halContext);
- m_halContext = NULL;
- kdDebug(1219) << "Failed to init HAL context!" << endl;
- return false;
- }
-
- /** @todo customize watch policy */
- kdDebug(1219) << "Watch properties" << endl;
- if (!libhal_device_property_watch_all(m_halContext, &error))
- {
- kdDebug(1219) << "Failed to watch HAL properties!" << endl;
- return false;
- }
-
- /* libhal-storage initialization */
- kdDebug(1219) << "Storage Policy" << endl;
- m_halStoragePolicy = libhal_storage_policy_new();
- /** @todo define libhal-storage icon policy */
-
- /* List devices at startup */
- return ListDevices();
-}
-
-/* List devices (at startup)*/
-bool HALBackend::ListDevices()
-{
- kdDebug(1219) << "ListDevices" << endl;
-
- int numDevices;
- char** halDeviceList = libhal_get_all_devices(m_halContext, &numDevices, NULL);
-
- if (!halDeviceList)
- return false;
-
- kdDebug(1219) << "HALBackend::ListDevices : " << numDevices << " devices found" << endl;
- for (int i = 0; i < numDevices; i++)
- AddDevice(halDeviceList[i], false);
-
- libhal_free_string_array( halDeviceList );
-
- return true;
-}
-
-/* Create a media instance for the HAL device "udi".
- This functions checks whether the device is worth listing */
-void HALBackend::AddDevice(const char *udi, bool allowNotification)
-{
- /* We don't deal with devices that do not expose their capabilities.
- If we don't check this, we will get a lot of warning messages from libhal */
- if (!libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL))
- return;
-
- /* If the device is already listed, do not process.
- This should not happen, but who knows... */
- /** @todo : refresh properties instead ? */
- if (m_mediaList.findById(udi))
- return;
-
- if (libhal_device_get_property_bool(m_halContext, "/org/freedesktop/Hal/devices/computer", "storage.disable_volume_handling", NULL))
- allowNotification=false;
-
- /* Add volume block devices */
- if (libhal_device_query_capability(m_halContext, udi, "volume", NULL))
- {
- /* We only list volumes that...
- * - are encrypted with LUKS or
- * - have a filesystem or
- * - have an audio track
- */
- if ( ( libhal_device_get_property_QString(m_halContext, udi, "volume.fsusage") != "crypto" ||
- libhal_device_get_property_QString(m_halContext, udi, "volume.fstype") != "crypto_LUKS"
- ) &&
- libhal_device_get_property_QString(m_halContext, udi, "volume.fsusage") != "filesystem" &&
- !libhal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio", NULL) &&
- !libhal_device_get_property_bool(m_halContext, udi, "volume.disc.is_blank", NULL) )
- return;
-
- /* Query drive udi */
- TQString driveUdi = libhal_device_get_property_QString(m_halContext, udi, "block.storage_device");
- if ( driveUdi.isNull() ) // no storage - no fun
- return;
-
- // if the device is locked do not act upon it
- if (libhal_device_get_property_bool(m_halContext, driveUdi.ascii(), "info.locked", NULL))
- allowNotification=false;
-
- // if the device is locked do not act upon it
- if (libhal_device_get_property_bool(m_halContext, driveUdi.ascii(), "storage.partition_table_changed", NULL))
- allowNotification=false;
-
- /** @todo check exclusion list **/
-
- /* Special handling for clear crypto volumes */
- LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, udi);
- if (!halVolume)
- return;
- const char* backingVolumeUdi = libhal_volume_crypto_get_backing_volume_udi(halVolume);
- if ( backingVolumeUdi != NULL )
- {
- /* The crypto drive was unlocked and may now be mounted... */
- kdDebug(1219) << "HALBackend::AddDevice : ClearVolume appeared for " << backingVolumeUdi << endl;
- ResetProperties(backingVolumeUdi, allowNotification);
- libhal_volume_free(halVolume);
- return;
- }
- libhal_volume_free(halVolume);
-
- /* Create medium */
- Medium* medium = new Medium(udi, udi, "");
- setVolumeProperties(medium);
-
- if ( isInFstab( medium ).isNull() )
- {
- // if it's not mountable by user and not by HAL, don't show it at all
- if ( ( libhal_device_get_property_QString(m_halContext, udi, "volume.fsusage") == "filesystem" &&
- !libhal_device_get_property_bool(m_halContext, udi, "volume.is_mounted", NULL ) ) &&
- ( libhal_device_get_property_bool(m_halContext, udi, "volume.ignore", NULL ) ) )
- {
- delete medium;
- return;
- }
- }
-
- // instert medium into list
- m_mediaList.addMedium(medium, allowNotification);
-
- // finally check for automount
- TQMap<TQString,TQString> options = MediaManagerUtils::splitOptions(mountoptions(udi));
- kdDebug() << "automount " << options["automount"] << endl;
- if (options["automount"] == "true" && allowNotification ) {
- TQString error = mount(medium);
- if (!error.isEmpty())
- kdDebug() << "error " << error << endl;
- }
-
- return;
- }
-
- /* Floppy & zip drives */
- if (libhal_device_query_capability(m_halContext, udi, "storage", NULL))
- if ((libhal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "floppy") ||
- (libhal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip") ||
- (libhal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "jaz"))
- {
- if (! libhal_device_get_property_bool(m_halContext, udi, "storage.removable.media_available", NULL) )
- allowNotification = false;
- /* Create medium */
- Medium* medium = new Medium(udi, udi, "");
- // if the storage has a volume, we ignore it
- if ( setFloppyProperties(medium) )
- m_mediaList.addMedium(medium, allowNotification);
- else
- delete medium;
- return;
- }
-
- /* Camera handled by gphoto2*/
- if (libhal_device_query_capability(m_halContext, udi, "camera", NULL) &&
- ((libhal_device_get_property_QString(m_halContext, udi, "camera.access_method")=="ptp") ||
-
- (libhal_device_property_exists(m_halContext, udi, "camera.libgphoto2.support", NULL) &&
- libhal_device_get_property_bool(m_halContext, udi, "camera.libgphoto2.support", NULL)))
- )
- {
- /* Create medium */
- Medium* medium = new Medium(udi, udi, "");
- setCameraProperties(medium);
- m_mediaList.addMedium(medium, allowNotification);
- return;
- }
-}
-
-void HALBackend::RemoveDevice(const char *udi)
-{
- const Medium *medium = m_mediaList.findByClearUdi(udi);
- if (medium) {
- ResetProperties(medium->id().ascii());
- } else {
- m_mediaList.removeMedium(udi, true);
- }
-}
-
-void HALBackend::ModifyDevice(const char *udi, const char* key)
-{
- kdDebug(1219) << "HALBackend::ModifyDevice for '" << udi << "' on '" << key << "'\n";
-
- const char* mediumUdi = findMediumUdiFromUdi(udi);
- if (!mediumUdi)
- return;
- bool allowNotification = false;
- if (strcmp(key, "storage.removable.media_available") == 0)
- allowNotification = libhal_device_get_property_bool(m_halContext, udi, key, NULL);
- ResetProperties(mediumUdi, allowNotification);
-}
-
-void HALBackend::DeviceCondition(const char* udi, const char* condition)
-{
- TQString conditionName = TQString(condition);
- kdDebug(1219) << "Processing device condition " << conditionName << " for " << udi << endl;
-
- if (conditionName == "EjectPressed") {
- const Medium* medium = m_mediaList.findById(udi);
- if (!medium) {
- /* the ejectpressed appears on the drive and we need to find the volume */
- const TQPtrList<Medium> medlist = m_mediaList.list();
- TQPtrListIterator<Medium> it (medlist);
- for ( const Medium *current_medium = it.current(); current_medium; current_medium = ++it)
- {
- if( current_medium->id().startsWith( "/org/kde" ))
- continue;
- TQString driveUdi = libhal_device_get_property_QString(m_halContext, current_medium->id().latin1(), "block.storage_device");
- if (driveUdi == udi)
- {
- medium = current_medium;
- break;
- }
- }
- }
- if (medium) {
- TDEProcess p;
- p << "tdeio_media_mounthelper" << "-e" << medium->name();
- p.start(TDEProcess::DontCare);
- }
- }
-
- const char* mediumUdi = findMediumUdiFromUdi(udi);
- kdDebug() << "findMedumUdiFromUdi " << udi << " returned " << mediumUdi << endl;
- if (!mediumUdi)
- return;
-
- /* TODO: Warn the user that (s)he should unmount devices before unplugging */
- if (conditionName == "VolumeUnmountForced")
- ResetProperties(mediumUdi);
-
- /* Reset properties after mounting */
- if (conditionName == "VolumeMount")
- ResetProperties(mediumUdi);
-
- /* Reset properties after unmounting */
- if (conditionName == "VolumeUnmount")
- ResetProperties(mediumUdi);
-
-}
-
-void HALBackend::MainLoopIntegration(DBusConnection *dbusConnection)
-{
- m_dBusQtConnection = new DBusQt::Connection(m_parent);
- m_dBusQtConnection->dbus_connection_setup_with_qt_main(dbusConnection);
-}
-
-/******************************************
- ** Properties attribution **
- ******************************************/
-
-/* Return the medium udi that should be updated when recieving a call for
- device udi */
-const char* HALBackend::findMediumUdiFromUdi(const char* udi)
-{
- /* Easy part : this Udi is already registered as a device */
- const Medium* medium = m_mediaList.findById(udi);
- if (medium)
- return medium->id().ascii();
-
- /* Hard part : this is a volume whose drive is registered */
- if (libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL))
- if (libhal_device_query_capability(m_halContext, udi, "volume", NULL))
- {
- /* check if this belongs to an encrypted volume */
- LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, udi);
- if (!halVolume) return NULL;
- const char* backingUdi = libhal_volume_crypto_get_backing_volume_udi(halVolume);
- if (backingUdi != NULL) {
- const char* result = findMediumUdiFromUdi(backingUdi);
- libhal_volume_free(halVolume);
- return result;
- }
- libhal_volume_free(halVolume);
-
- /* this is a volume whose drive is registered */
- TQString driveUdi = libhal_device_get_property_QString(m_halContext, udi, "block.storage_device");
- return findMediumUdiFromUdi(driveUdi.ascii());
- }
-
- return NULL;
-}
-
-void HALBackend::ResetProperties(const char* mediumUdi, bool allowNotification)
-{
- kdDebug(1219) << "HALBackend::setProperties" << endl;
- if ( TQString::fromLatin1( mediumUdi ).startsWith( "/org/kde/" ) )
- {
- const Medium *cmedium = m_mediaList.findById(mediumUdi);
- if ( cmedium )
- {
- Medium m( *cmedium );
- if ( setFstabProperties( &m ) ) {
- kdDebug() << "setFstabProperties worked" << endl;
- m_mediaList.changeMediumState(m, allowNotification);
- }
- return;
- }
- }
-
- Medium* m = new Medium(mediumUdi, mediumUdi, "");
-
- if (libhal_device_query_capability(m_halContext, mediumUdi, "volume", NULL))
- setVolumeProperties(m);
- if (libhal_device_query_capability(m_halContext, mediumUdi, "storage", NULL))
- setFloppyProperties(m);
- if (libhal_device_query_capability(m_halContext, mediumUdi, "camera", NULL))
- setCameraProperties(m);
-
- m_mediaList.changeMediumState(*m, allowNotification);
-
- delete m;
-}
-
-void HALBackend::setVolumeProperties(Medium* medium)
-{
- kdDebug(1219) << "HALBackend::setVolumeProperties for " << medium->id() << endl;
-
- const char* udi = medium->id().ascii();
- /* Check if the device still exists */
- if (!libhal_device_exists(m_halContext, udi, NULL))
- return;
-
- /* Get device information from libhal-storage */
- LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, udi);
- if (!halVolume)
- return;
- TQString driveUdi = libhal_volume_get_storage_device_udi(halVolume);
- LibHalDrive* halDrive = 0;
- if ( !driveUdi.isNull() )
- halDrive = libhal_drive_from_udi(m_halContext, driveUdi.ascii());
- if (!halDrive) {
- // at times HAL sends an UnmountForced event before the device is removed
- libhal_volume_free(halVolume);
- return;
- }
-
- medium->setName(
- generateName(libhal_volume_get_device_file(halVolume)) );
-
- LibHalVolume* halClearVolume = NULL;
- if ( libhal_device_get_property_QString(m_halContext, udi, "volume.fsusage") == "crypto" )
- {
- kdDebug(1219) << "HALBackend::setVolumeProperties : crypto volume" << endl;
-
- medium->setEncrypted(true);
- char* clearUdi = libhal_volume_crypto_get_clear_volume_udi(m_halContext, halVolume);
- TQString clearUdiString;
- if (clearUdi != NULL) {
- kdDebug(1219) << "HALBackend::setVolumeProperties : crypto clear volume avail - " << clearUdi << endl;
- halClearVolume = libhal_volume_from_udi(m_halContext, clearUdi);
- // ignore if halClearVolume is NULL -> just not unlocked in this case
- clearUdiString = clearUdi;
- libhal_free_string(clearUdi);
- }
-
- if (halClearVolume)
- medium->mountableState(
- libhal_volume_get_device_file(halVolume), /* Device node */
- clearUdiString,
- libhal_volume_get_mount_point(halClearVolume), /* Mount point */
- libhal_volume_get_fstype(halClearVolume), /* Filesystem type */
- libhal_volume_is_mounted(halClearVolume) ); /* Mounted ? */
- else
- medium->mountableState(
- libhal_volume_get_device_file(halVolume), /* Device node */
- TQString::null,
- TQString::null, /* Mount point */
- TQString::null, /* Filesystem type */
- false ); /* Mounted ? */
- }
- else
- {
- kdDebug(1219) << "HALBackend::setVolumeProperties : normal volume" << endl;
- medium->mountableState(
- libhal_volume_get_device_file(halVolume), /* Device node */
- TQString::fromUtf8(libhal_volume_get_mount_point(halVolume)), /* Mount point */
- libhal_volume_get_fstype(halVolume), /* Filesystem type */
- libhal_volume_is_mounted(halVolume) ); /* Mounted ? */
- }
-
-
- char* name = libhal_volume_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy);
- TQString volume_name = TQString::fromUtf8(name);
- TQString media_name = volume_name;
- /* media_name contains something like "501M Removable Media" or "Blank CD-R"
- The former needs special handling for correct translation
- */
- if (media_name.find(TQRegExp("^[0-9]+\\.?[0-9]*[KMGT] (Removable )?Media$")) > -1) {
- TQString pattern = media_name.section(" ", 1);
- media_name.replace(pattern, i18n(pattern.utf8()));
- medium->setLabel(media_name);
- } else {
- medium->setLabel(i18n(media_name.utf8()));
- }
-
- free(name);
-
- TQString mimeType;
- if (libhal_volume_is_disc(halVolume))
- {
- mimeType = "media/cdrom" + MOUNT_MEDIA_SUFFIX;
-
- LibHalVolumeDiscType discType = libhal_volume_get_disc_type(halVolume);
- if ((discType == LIBHAL_VOLUME_DISC_TYPE_CDROM) ||
- (discType == LIBHAL_VOLUME_DISC_TYPE_CDR) ||
- (discType == LIBHAL_VOLUME_DISC_TYPE_CDRW))
- {
- if (libhal_volume_disc_is_blank(halVolume))
- {
- mimeType = "media/blankcd";
- medium->unmountableState("");
- }
- else
- {
- mimeType = "media/cdwriter" + MOUNT_MEDIA_SUFFIX;
- }
- }
- else if ((discType == LIBHAL_VOLUME_DISC_TYPE_DVDROM) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRAM) ||
- (discType == LIBHAL_VOLUME_DISC_TYPE_DVDR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRW) ||
- (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW) )
- {
- if (libhal_volume_disc_is_blank(halVolume))
- {
- mimeType = "media/blankdvd";
- medium->unmountableState("");
- }
- else
- {
- mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
- }
- }
- else if ((discType == LIBHAL_VOLUME_DISC_TYPE_BDROM) || (discType == LIBHAL_VOLUME_DISC_TYPE_BDR) ||
- (discType == LIBHAL_VOLUME_DISC_TYPE_BDRE) || (discType == LIBHAL_VOLUME_DISC_TYPE_HDDVDROM) ||
- (discType == LIBHAL_VOLUME_DISC_TYPE_HDDVDR) || (discType == LIBHAL_VOLUME_DISC_TYPE_HDDVDRW) )
- {
- if (libhal_volume_disc_is_blank(halVolume))
- {
- mimeType = "media/blankbluray";
- medium->unmountableState("");
- }
- else
- {
- mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
- }
- }
-
- if (libhal_volume_disc_has_audio(halVolume) && !libhal_volume_disc_has_data(halVolume))
- {
- mimeType = "media/audiocd";
- medium->unmountableState( "audiocd:/?device=" + TQString(libhal_volume_get_device_file(halVolume)) );
- }
-
- medium->setIconName(TQString::null);
-
- /* check if the disc id a vcd or a video dvd */
- if (libhal_device_get_property_bool(m_halContext, udi, "volume.disc.is_vcd", NULL))
- {
- mimeType = "media/vcd";
- }
- else if (libhal_device_get_property_bool(m_halContext, udi, "volume.disc.is_svcd", NULL))
- {
- mimeType = "media/svcd";
- }
- else if (libhal_device_get_property_bool(m_halContext, udi, "volume.disc.is_videodvd", NULL))
- {
- mimeType = "media/dvdvideo";
- }
-
- }
- else
- {
- mimeType = "media/hdd" + MOUNT_MEDIA_SUFFIX;
- medium->setIconName(TQString::null); // reset icon
- if (libhal_drive_is_hotpluggable(halDrive))
- {
- mimeType = "media/removable" + MOUNT_MEDIA_SUFFIX;
- medium->needMounting();
- switch (libhal_drive_get_type(halDrive)) {
- case LIBHAL_DRIVE_TYPE_COMPACT_FLASH:
- medium->setIconName("media-flash-compact_flash" + MOUNTED_ICON_SUFFIX);
- break;
- case LIBHAL_DRIVE_TYPE_MEMORY_STICK:
- medium->setIconName("media-flash-memory_stick" + MOUNTED_ICON_SUFFIX);
- break;
- case LIBHAL_DRIVE_TYPE_SMART_MEDIA:
- medium->setIconName("media-flash-smart_media" + MOUNTED_ICON_SUFFIX);
- break;
- case LIBHAL_DRIVE_TYPE_SD_MMC:
- medium->setIconName("media-flash-sd_mmc" + MOUNTED_ICON_SUFFIX);
- break;
- case LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER:
- {
- medium->setIconName("ipod" + MOUNTED_ICON_SUFFIX);
-
- if (libhal_device_get_property_QString(m_halContext, driveUdi.latin1(), "info.product") == "iPod" &&
- KProtocolInfo::isKnownProtocol( TQString("ipod") ) )
- {
- medium->unmountableState( "ipod:/" );
- medium->mountableState( libhal_volume_is_mounted(halVolume) );
- }
- break;
- }
- case LIBHAL_DRIVE_TYPE_CAMERA:
- {
- mimeType = "media/camera" + MOUNT_MEDIA_SUFFIX;
- const char *physdev = libhal_drive_get_physical_device_udi(halDrive);
- // get model from camera
- if (physdev && libhal_device_query_capability(m_halContext, physdev, "camera", NULL))
- {
- if (libhal_device_property_exists(m_halContext, physdev, "usb_device.product", NULL))
- medium->setLabel(libhal_device_get_property_QString(m_halContext, physdev, "usb_device.product"));
- else if (libhal_device_property_exists(m_halContext, physdev, "usb.product", NULL))
- medium->setLabel(libhal_device_get_property_QString(m_halContext, physdev, "usb.product"));
- }
- break;
- }
- case LIBHAL_DRIVE_TYPE_TAPE:
- medium->setIconName("media-tape" + MOUNTED_ICON_SUFFIX);
- break;
- default:
- medium->setIconName(TQString::null);
- }
-
- if (medium->isMounted() && TQFile::exists(medium->mountPoint() + "/dcim"))
- {
- mimeType = "media/camera" + MOUNT_MEDIA_SUFFIX;
- }
- }
- }
- medium->setMimeType(mimeType);
-
- libhal_drive_free(halDrive);
- libhal_volume_free(halVolume);
-}
-
-bool HALBackend::setFstabProperties( Medium *medium )
-{
- TQString mp = isInFstab(medium);
-
- if (!mp.isNull() && !medium->id().startsWith( "/org/kde" ) )
- {
- // now that we know it's in fstab, we have to find out if it's mounted
- KMountPoint::List mtab = KMountPoint::currentMountPoints();
-
- KMountPoint::List::iterator it = mtab.begin();
- KMountPoint::List::iterator end = mtab.end();
-
- bool mounted = false;
-
- for (; it!=end; ++it)
- {
- if ((*it)->mountedFrom() == medium->deviceNode() && (*it)->mountPoint() == mp )
- {
- mounted = true;
- break;
- }
- }
-
- kdDebug() << mp << " " << mounted << " " << medium->deviceNode() << " " << endl;
- TQString fstype = medium->fsType();
- if ( fstype.isNull() )
- fstype = "auto";
-
- medium->mountableState(
- medium->deviceNode(),
- mp, /* Mount point */
- fstype, /* Filesystem type */
- mounted ); /* Mounted ? */
-
- return true;
- }
-
- return false;
-
-}
-
-// Handle floppies and zip drives
-bool HALBackend::setFloppyProperties(Medium* medium)
-{
- kdDebug(1219) << "HALBackend::setFloppyProperties for " << medium->id() << endl;
-
- const char* udi = medium->id().ascii();
- /* Check if the device still exists */
- if (!libhal_device_exists(m_halContext, udi, NULL))
- return false;
-
- LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, udi);
- if (!halDrive)
- return false;
-
- TQString drive_type = libhal_device_get_property_QString(m_halContext, udi, "storage.drive_type");
-
- if (drive_type == "zip") {
- int numVolumes;
- char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes);
- libhal_free_string_array(volumes);
- kdDebug(1219) << " found " << numVolumes << " volumes" << endl;
- if (numVolumes)
- {
- libhal_drive_free(halDrive);
- return false;
- }
- }
-
- medium->setName( generateName(libhal_drive_get_device_file(halDrive)) );
- medium->setLabel(i18n("Unknown Drive"));
-
- // HAL hates floppies - so we have to do it twice ;(
- medium->mountableState(libhal_drive_get_device_file(halDrive), TQString::null, TQString::null, false);
- setFloppyMountState(medium);
-
- if (drive_type == "floppy")
- {
- if (medium->isMounted()) // don't use _SUFFIX here as it accesses the volume
- medium->setMimeType("media/floppy_mounted" );
- else
- medium->setMimeType("media/floppy_unmounted");
- medium->setLabel(i18n("Floppy Drive"));
- }
- else if (drive_type == "zip")
- {
- if (medium->isMounted())
- medium->setMimeType("media/zip_mounted" );
- else
- medium->setMimeType("media/zip_unmounted");
- medium->setLabel(i18n("Zip Drive"));
- }
-
- /** @todo And mimtype for JAZ drives ? */
-
- medium->setIconName(TQString::null);
-
- libhal_drive_free(halDrive);
-
- return true;
-}
-
-void HALBackend::setFloppyMountState( Medium *medium )
-{
- if ( !medium->id().startsWith( "/org/kde" ) )
- {
- KMountPoint::List mtab = KMountPoint::currentMountPoints();
- KMountPoint::List::iterator it = mtab.begin();
- KMountPoint::List::iterator end = mtab.end();
-
- TQString fstype;
- TQString mountpoint;
- for (; it!=end; ++it)
- {
- if ((*it)->mountedFrom() == medium->deviceNode() )
- {
- fstype = (*it)->mountType().isNull() ? (*it)->mountType() : "auto";
- mountpoint = (*it)->mountPoint();
- medium->mountableState( medium->deviceNode(), mountpoint, fstype, true );
- return;
- }
- }
- }
-}
-
-void HALBackend::setCameraProperties(Medium* medium)
-{
- kdDebug(1219) << "HALBackend::setCameraProperties for " << medium->id() << endl;
-
- const char* udi = medium->id().ascii();
- /* Check if the device still exists */
- if (!libhal_device_exists(m_halContext, udi, NULL))
- return;
-
- /** @todo find name */
- medium->setName("camera");
-
- TQString device = "camera:/";
-
- char *cam = libhal_device_get_property_string(m_halContext, udi, "camera.libgphoto2.name", NULL);
- DBusError error;
- dbus_error_init(&error);
- if (cam &&
- libhal_device_property_exists(m_halContext, udi, "usb.linux.device_number", NULL) &&
- libhal_device_property_exists(m_halContext, udi, "usb.bus_number", NULL))
- device.sprintf("camera://%s@[usb:%03d,%03d]/", cam,
- libhal_device_get_property_int(m_halContext, udi, "usb.bus_number", &error),
- libhal_device_get_property_int(m_halContext, udi, "usb.linux.device_number", &error));
-
- libhal_free_string(cam);
-
- /** @todo find the rest of this URL */
- medium->unmountableState(device);
- medium->setMimeType("media/gphoto2camera");
- medium->setIconName(TQString::null);
- if (libhal_device_property_exists(m_halContext, udi, "usb_device.product", NULL))
- medium->setLabel(libhal_device_get_property_QString(m_halContext, udi, "usb_device.product"));
- else if (libhal_device_property_exists(m_halContext, udi, "usb.product", NULL))
- medium->setLabel(libhal_device_get_property_QString(m_halContext, udi, "usb.product"));
- else
- medium->setLabel(i18n("Camera"));
-}
-
-TQString HALBackend::generateName(const TQString &devNode)
-{
- return KURL(devNode).fileName();
-}
-
-/******************************************
- ** HAL CALL-BACKS **
- ******************************************/
-
-void HALBackend::hal_device_added(LibHalContext *ctx, const char *udi)
-{
- kdDebug(1219) << "HALBackend::hal_device_added " << udi << endl;
- Q_UNUSED(ctx);
- s_HALBackend->AddDevice(udi);
-}
-
-void HALBackend::hal_device_removed(LibHalContext *ctx, const char *udi)
-{
- kdDebug(1219) << "HALBackend::hal_device_removed " << udi << endl;
- Q_UNUSED(ctx);
- s_HALBackend->RemoveDevice(udi);
-}
-
-void HALBackend::hal_device_property_modified(LibHalContext *ctx, const char *udi,
- const char *key, dbus_bool_t is_removed, dbus_bool_t is_added)
-{
- kdDebug(1219) << "HALBackend::hal_property_modified " << udi << " -- " << key << endl;
- Q_UNUSED(ctx);
- Q_UNUSED(is_removed);
- Q_UNUSED(is_added);
- s_HALBackend->ModifyDevice(udi, key);
-}
-
-void HALBackend::hal_device_condition(LibHalContext *ctx, const char *udi,
- const char *condition_name,
- const char* message
- )
-{
- kdDebug(1219) << "HALBackend::hal_device_condition " << udi << " -- " << condition_name << endl;
- Q_UNUSED(ctx);
- Q_UNUSED(message);
- s_HALBackend->DeviceCondition(udi, condition_name);
-}
-
-TQStringList HALBackend::getHALmountoptions(TQString udi)
-{
- const char* _ppt_string;
- LibHalVolume* volume;
- LibHalDrive* drive;
-
- TQString _ppt_TQString;
-
- volume = libhal_volume_from_udi( m_halContext, udi.latin1() );
- if( volume )
- drive = libhal_drive_from_udi( m_halContext, libhal_volume_get_storage_device_udi( volume ) );
- else
- drive = libhal_drive_from_udi( m_halContext, udi.latin1() );
-
- if( !drive )
- return TQString::null;
-
- if( volume )
- _ppt_string = libhal_volume_policy_get_mount_options ( drive, volume, NULL );
- else
- _ppt_string = libhal_drive_policy_get_mount_options ( drive, NULL );
-
- _ppt_TQString = TQString(_ppt_string ? _ppt_string : "");
-
- return TQStringList::split(",",_ppt_TQString);
-}
-
-TQStringList HALBackend::mountoptions(const TQString &name)
-{
- const Medium* medium = m_mediaList.findById(name);
- if (!medium)
- return TQStringList(); // we don't know about that one
- if (!isInFstab(medium).isNull())
- return TQStringList(); // not handled by HAL - fstab entry
-
- TQString volume_udi = name;
- if (medium->isEncrypted()) {
- // see if we have a clear volume
- LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, medium->id().latin1());
- if (halVolume) {
- char* clearUdi = libhal_volume_crypto_get_clear_volume_udi(m_halContext, halVolume);
- if (clearUdi != NULL) {
- volume_udi = clearUdi;
- libhal_free_string(clearUdi);
- } else {
- // if not unlocked yet then no mountoptions
- return TQStringList();
- }
- libhal_volume_free(halVolume);
- } else {
- // strange...
- return TQStringList();
- }
- }
-
- TDEConfig config("mediamanagerrc");
-
- bool use_defaults = true;
- if (config.hasGroup(name))
- {
- config.setGroup(name);
- use_defaults = config.readBoolEntry("use_defaults", false);
- }
-
- if (use_defaults)
- config.setGroup("DefaultOptions");
-
- char ** array = libhal_device_get_property_strlist(m_halContext, volume_udi.latin1(), "volume.mount.valid_options", NULL);
- TQMap<TQString,bool> valids;
-
- for (int index = 0; array && array[index]; ++index) {
- TQString t = array[index];
- if (t.endsWith("="))
- t = t.left(t.length() - 1);
- valids[t] = true;
- kdDebug() << "valid " << t << endl;
- }
- libhal_free_string_array(array);
- TQStringList result;
- TQString tmp;
-
- result << TQString("use_defaults=%1").arg(use_defaults ? "true" : "false");
-
- TQString fstype = libhal_device_get_property_QString(m_halContext, volume_udi.latin1(), "volume.fstype");
- if (fstype.isNull())
- fstype = libhal_device_get_property_QString(m_halContext, volume_udi.latin1(), "volume.policy.mount_filesystem");
-
- TQString drive_udi = libhal_device_get_property_QString(m_halContext, volume_udi.latin1(), "block.storage_device");
-
- bool removable = false;
- if ( !drive_udi.isNull() )
- removable = libhal_device_get_property_bool(m_halContext, drive_udi.latin1(), "storage.removable", NULL)
- || libhal_device_get_property_bool(m_halContext, drive_udi.latin1(), "storage.hotpluggable", NULL);
-
- bool value;
- if (use_defaults)
- {
- value = config.readBoolEntry("automount", false);
- }
- else
- {
- QString current_group = config.group();
- config.setGroup(drive_udi);
- value = config.readBoolEntry("automount", false);
- config.setGroup(current_group);
- }
-
- if (libhal_device_get_property_bool(m_halContext, volume_udi.latin1(), "volume.disc.is_blank", NULL)
- || libhal_device_get_property_bool(m_halContext, volume_udi.latin1(), "volume.disc.is_vcd", NULL)
- || libhal_device_get_property_bool(m_halContext, volume_udi.latin1(), "volume.disc.is_svcd", NULL)
- || libhal_device_get_property_bool(m_halContext, volume_udi.latin1(), "volume.disc.is_videodvd", NULL)
- || libhal_device_get_property_bool(m_halContext, volume_udi.latin1(), "volume.disc.has_audio", NULL))
- value = false;
-
- result << TQString("automount=%1").arg(value ? "true" : "false");
-
- if (valids.contains("ro"))
- {
- value = config.readBoolEntry("ro", false);
- tmp = TQString("ro=%1").arg(value ? "true" : "false");
- if (fstype != "iso9660") // makes no sense
- result << tmp;
- }
-
- if (valids.contains("quiet"))
- {
- value = config.readBoolEntry("quiet", false);
- tmp = TQString("quiet=%1").arg(value ? "true" : "false");
- if (fstype != "iso9660") // makes no sense
- result << tmp;
- }
-
- if (valids.contains("flush"))
- {
- value = config.readBoolEntry("flush", fstype.endsWith("fat"));
- tmp = TQString("flush=%1").arg(value ? "true" : "false");
- result << tmp;
- }
-
- if (valids.contains("uid"))
- {
- value = config.readBoolEntry("uid", true);
- tmp = TQString("uid=%1").arg(value ? "true" : "false");
- result << tmp;
- }
-
- if (valids.contains("utf8"))
- {
- value = config.readBoolEntry("utf8", true);
- tmp = TQString("utf8=%1").arg(value ? "true" : "false");
- result << tmp;
- }
-
- if (valids.contains("shortname"))
- {
- TQString svalue = config.readEntry("shortname", "lower").lower();
- if (svalue == "windows nt")
- result << "shortname=winnt";
- else if (svalue == "windows 95")
- result << "shortname=win95";
- else if (svalue == "mixed")
- result << "shortname=mixed";
- else
- result << "shortname=lower";
- }
-
- // pass our locale to the ntfs-3g driver so it can translate local characters
- if (valids.contains("locale") && fstype == "ntfs-3g")
- {
- // have to obtain LC_CTYPE as returned by the `locale` command
- // check in the same order as `locale` does
- char *cType;
- if ( (cType = getenv("LC_ALL")) || (cType = getenv("LC_CTYPE")) || (cType = getenv("LANG")) ) {
- result << TQString("locale=%1").arg(cType);
- }
- }
-
- if (valids.contains("sync"))
- {
- value = config.readBoolEntry("sync", ( valids.contains("flush") && !fstype.endsWith("fat") ) && removable);
- tmp = TQString("sync=%1").arg(value ? "true" : "false");
- if (fstype != "iso9660") // makes no sense
- result << tmp;
- }
-
- if (valids.contains("noatime"))
- {
- value = config.readBoolEntry("atime", !fstype.endsWith("fat"));
- tmp = TQString("atime=%1").arg(value ? "true" : "false");
- if (fstype != "iso9660") // makes no sense
- result << tmp;
- }
-
- TQString mount_point = libhal_device_get_property_QString(m_halContext, volume_udi.latin1(), "volume.mount_point");
- if (mount_point.isEmpty())
- mount_point = libhal_device_get_property_QString(m_halContext, volume_udi.latin1(), "volume.policy.desired_mount_point");
-
- mount_point = config.readEntry("mountpoint", mount_point);
-
- if (!mount_point.startsWith("/"))
- mount_point = "/media/" + mount_point;
-
- result << TQString("mountpoint=%1").arg(mount_point);
- result << TQString("filesystem=%1").arg(fstype);
-
- if (valids.contains("data"))
- {
- TQString svalue = config.readEntry("journaling").lower();
- if (svalue == "ordered")
- result << "journaling=ordered";
- else if (svalue == "writeback")
- result << "journaling=writeback";
- else if (svalue == "data")
- result << "journaling=data";
- else
- result << "journaling=ordered";
- }
-
- return result;
-}
-
-bool HALBackend::setMountoptions(const TQString &name, const TQStringList &options )
-{
- kdDebug() << "setMountoptions " << name << " " << options << endl;
-
- TDEConfig config("mediamanagerrc");
- config.setGroup(name);
-
- TQMap<TQString,TQString> valids = MediaManagerUtils::splitOptions(options);
-
- const char *names[] = { "use_defaults", "ro", "quiet", "atime", "uid", "utf8", "flush", "sync", 0 };
- for (int index = 0; names[index]; ++index)
- if (valids.contains(names[index]))
- config.writeEntry(names[index], valids[names[index]] == "true");
-
- if (valids.contains("shortname"))
- config.writeEntry("shortname", valids["shortname"]);
-
- if (valids.contains("journaling"))
- config.writeEntry("journaling", valids["journaling"]);
-
- if (!mountoptions(name).contains(TQString("mountpoint=%1").arg(valids["mountpoint"])))
- config.writeEntry("mountpoint", valids["mountpoint"]);
-
- if (valids.contains("automount")) {
- TQString drive_udi = libhal_device_get_property_QString(m_halContext, name.latin1(), "block.storage_device");
- config.setGroup(drive_udi);
- config.writeEntry("automount", valids["automount"]);
- }
-
- return true;
-}
-
-TQString startKdeSudoProcess(const TQString& tdesudoPath, const TQString& command,
- const TQString& dialogCaption, const TQString& dialogComment)
-{
- TDEProcess tdesudoProcess;
-
- tdesudoProcess << tdesudoPath
- << "-d"
- << "--noignorebutton"
- << "--caption" << dialogCaption
- << "--comment" << dialogComment
- << "-c" << command;
-
- // @todo handle tdesudo output
- tdesudoProcess.start(TDEProcess::Block);
-
- return TQString();
-}
-
-TQString startKdeSuProcess(const TQString& tdesuPath, const TQString& command,
- const TQString& dialogCaption)
-{
- TDEProcess tdesuProcess;
-
- tdesuProcess << tdesuPath
- << "-d"
- << "--noignorebutton"
- << "--caption" << dialogCaption
- << "-c" << command;
-
- // @todo handle tdesu output
- tdesuProcess.start(TDEProcess::Block);
-
- return TQString();
-}
-
-TQString startPrivilegedProcess(const TQString& command, const TQString& dialogCaption, const TQString& dialogComment)
-{
- TQString error;
-
- TQString tdesudoPath = TDEStandardDirs::findExe("tdesudo");
-
- if (!tdesudoPath.isEmpty())
- error = startKdeSudoProcess(tdesudoPath, command, dialogCaption, dialogComment);
- else {
- TQString tdesuPath = TDEStandardDirs::findExe("tdesu");
-
- if (!tdesuPath.isEmpty())
- error = startKdeSuProcess(tdesuPath, command, dialogCaption);
- }
-
- return error;
-}
-
-TQString privilegedMount(const char* udi, const char* mountPoint, const char** options, int numberOfOptions)
-{
- TQString error;
-
- kdDebug() << "run privileged mount for " << udi << endl;
-
- TQString dbusSendPath = TDEStandardDirs::findExe("dbus-send");
-
- // @todo return error message
- if (dbusSendPath.isEmpty())
- return TQString();
-
- TQString mountOptions;
- TQTextOStream optionsStream(&mountOptions);
- for (int optionIndex = 0; optionIndex < numberOfOptions; optionIndex++) {
- optionsStream << options[optionIndex];
- if (optionIndex < numberOfOptions - 1)
- optionsStream << ",";
- }
-
- TQString command;
- TQTextOStream(&command) << dbusSendPath
- << " --system --print-reply --dest=org.freedesktop.Hal " << udi
- << " org.freedesktop.Hal.Device.Volume.Mount string:" << mountPoint
- << " string: array:string:" << mountOptions;
-
- kdDebug() << "command: " << command << endl;
-
- error = startPrivilegedProcess(command,
- i18n("Authenticate"),
- i18n("<big><b>System policy prevents mounting internal media</b></big><br/>Authentication is required to perform this action. Please enter your password to verify."));
-
- return error;
-}
-
-TQString privilegedUnmount(const char* udi)
-{
- TQString error;
-
- kdDebug() << "run privileged unmount for " << udi << endl;
-
- TQString dbusSendPath = TDEStandardDirs::findExe("dbus-send");
-
- // @todo return error message
- if (dbusSendPath.isEmpty())
- return TQString();
-
- TQString command;
- TQTextOStream(&command) << dbusSendPath
- << " --system --print-reply --dest=org.freedesktop.Hal " << udi
- << " org.freedesktop.Hal.Device.Volume.Unmount array:string:force";
-
- kdDebug() << "command: " << command << endl;
-
- error = startPrivilegedProcess(command,
- i18n("Authenticate"),
- i18n("<big><b>System policy prevents unmounting media mounted by other users</b></big><br/>Authentication is required to perform this action. Please enter your password to verify."));
-
- return error;
-}
-
-static TQString mount_priv(const char *udi, const char *mount_point, const char **poptions, int noptions,
- DBusConnection *dbus_connection)
-{
- DBusMessage *dmesg, *reply;
- DBusError error;
-
- const char *fstype = "";
- if (!(dmesg = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
- "org.freedesktop.Hal.Device.Volume",
- "Mount"))) {
- kdDebug() << "mount failed for " << udi << ": could not create dbus message\n";
- return i18n("Internal Error");
- }
-
- if (!dbus_message_append_args (dmesg, DBUS_TYPE_STRING, &mount_point, DBUS_TYPE_STRING, &fstype,
- DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &poptions, noptions,
- DBUS_TYPE_INVALID))
- {
- kdDebug() << "mount failed for " << udi << ": could not append args to dbus message\n";
- dbus_message_unref (dmesg);
- return i18n("Internal Error");
- }
-
- TQString qerror;
-
- dbus_error_init (&error);
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, dmesg, -1, &error)))
- {
- TQString qerror = error.message;
- kdError() << "mount failed for " << udi << ": " << error.name << " - " << qerror << endl;
- if ( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.UnknownFilesystemType"))
- qerror = i18n("Invalid filesystem type");
- else if ( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied"))
- qerror = i18n("Permission denied<p>Please ensure that:<br>1. You have permission to access this device.<br>2. This device node is not listed in /etc/fstab.</p>");
- else if ( !strcmp(error.name, "org.freedesktop.Hal.Device.PermissionDeniedByPolicy"))
- qerror = privilegedMount(udi, mount_point, poptions, noptions);
- else if ( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.AlreadyMounted"))
- qerror = i18n("Device is already mounted.");
- else if ( !strcmp(error.name, "org.freedesktop.Hal.Device.Volume.InvalidMountpoint") && strlen(mount_point)) {
- dbus_message_unref (dmesg);
- dbus_error_free (&error);
- return mount_priv(udi, "", poptions, noptions, dbus_connection);
- }
- dbus_message_unref (dmesg);
- dbus_error_free (&error);
- return qerror;
- }
-
- kdDebug() << "mount queued for " << udi << endl;
-
- dbus_message_unref (dmesg);
- dbus_message_unref (reply);
-
- return qerror;
-
-}
-
-TQString HALBackend::listUsingProcesses(const Medium* medium)
-{
- TQString proclist, fullmsg;
- TQString fuserpath = TDEStandardDirs::findExe("fuser", TQString("/sbin:/usr/sbin:") + getenv( "PATH" ));
- FILE *fuser = NULL;
-
- uint counter = 0;
- if (!fuserpath.isEmpty()) {
- TQString cmdline = TQString("/usr/bin/env %1 -vm %2 2>&1").arg(fuserpath, TDEProcess::quote(medium->mountPoint()));
- fuser = popen(cmdline.latin1(), "r");
- }
- if (fuser) {
- proclist += "<pre>";
- TQTextIStream is(fuser);
- TQString tmp;
- while (!is.atEnd()) {
- tmp = is.readLine();
- tmp = TQStyleSheet::escape(tmp) + "\n";
-
- proclist += tmp;
- if (counter++ > 10)
- {
- proclist += "...";
- break;
- }
- }
- proclist += "</pre>";
- (void)pclose( fuser );
- }
- if (counter) {
- fullmsg = i18n("Moreover, programs still using the device "
- "have been detected. They are listed below. You have to "
- "close them or change their working directory before "
- "attempting to unmount the device again.");
- fullmsg += "<br>" + proclist;
- return fullmsg;
- } else {
- return TQString::null;
- }
-}
-
-TQString HALBackend::killUsingProcesses(const Medium* medium)
-{
- TQString proclist, fullmsg;
- TQString fuserpath = TDEStandardDirs::findExe("fuser", TQString("/sbin:/usr/sbin:") + getenv( "PATH" ));
- FILE *fuser = NULL;
-
- uint counter = 0;
- if (!fuserpath.isEmpty()) {
- TQString cmdline = TQString("/usr/bin/env %1 -vmk %2 2>&1").arg(fuserpath, TDEProcess::quote(medium->mountPoint()));
- fuser = popen(cmdline.latin1(), "r");
- }
- if (fuser) {
- proclist += "<pre>";
- TQTextIStream is(fuser);
- TQString tmp;
- while (!is.atEnd()) {
- tmp = is.readLine();
- tmp = TQStyleSheet::escape(tmp) + "\n";
-
- proclist += tmp;
- if (counter++ > 10)
- {
- proclist += "...";
- break;
- }
- }
- proclist += "</pre>";
- (void)pclose( fuser );
- }
- if (counter) {
- fullmsg = i18n("Programs that were still using the device "
- "have been forcibly terminated. They are listed below.");
- fullmsg += "<br>" + proclist;
- return fullmsg;
- } else {
- return TQString::null;
- }
-}
-
-void HALBackend::slotResult(TDEIO::Job *job)
-{
- kdDebug() << "slotResult " << mount_jobs[job] << endl;
-
- struct mount_job_data *data = mount_jobs[job];
- TQString& qerror = data->errorMessage;
- const Medium* medium = data->medium;
-
- if (job->error() == TDEIO::ERR_COULD_NOT_UNMOUNT) {
- TQString proclist(listUsingProcesses(medium));
-
- qerror = "<qt>";
- qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
- "currently mounted at <b>%4</b> could not be unmounted. ").arg(
- "system:/media/" + medium->name(),
- medium->deviceNode(),
- medium->prettyLabel(),
- medium->prettyBaseURL().pathOrURL()) + "</p>";
- qerror += "<p>" + i18n("The following error was returned by umount command:");
- qerror += "</p><pre>" + job->errorText() + "</pre>";
-
- if (!proclist.isEmpty()) {
- qerror += proclist;
- }
- qerror += "</qt>";
- } else if (job->error()) {
- qerror = job->errorText();
- }
-
- ResetProperties( medium->id().latin1() );
- mount_jobs.remove(job);
-
- /* Job completed. Notify the caller */
- data->error = job->error();
- data->completed = true;
- kapp->eventLoop()->exitLoop();
-}
-
-TQString HALBackend::isInFstab(const Medium *medium)
-{
- KMountPoint::List fstab = KMountPoint::possibleMountPoints(KMountPoint::NeedMountOptions|KMountPoint::NeedRealDeviceName);
-
- KMountPoint::List::iterator it = fstab.begin();
- KMountPoint::List::iterator end = fstab.end();
-
- for (; it!=end; ++it)
- {
- TQString reald = (*it)->realDeviceName();
- if ( reald.endsWith( "/" ) )
- reald = reald.left( reald.length() - 1 );
- kdDebug() << "isInFstab -" << medium->deviceNode() << "- -" << reald << "- -" << (*it)->mountedFrom() << "-" << endl;
- if ((*it)->mountedFrom() == medium->deviceNode() || ( !medium->deviceNode().isEmpty() && reald == medium->deviceNode() ) )
- {
- TQStringList opts = (*it)->mountOptions();
- if (opts.contains("user") || opts.contains("users"))
- return (*it)->mountPoint();
- }
- }
-
- return TQString::null;
-}
-
-TQStringVariantMap HALBackend::mount(const Medium *medium)
-{
- TQStringVariantMap result;
- if (medium->isMounted()) {
- result["result"] = true;
- return result;
- }
-
- TQString mountPoint = isInFstab(medium);
- if (!mountPoint.isNull())
- {
- struct mount_job_data data;
- data.completed = false;
- data.medium = medium;
-
- kdDebug() << "triggering user mount " << medium->deviceNode() << " " << mountPoint << " " << medium->id() << endl;
- TDEIO::Job *job = TDEIO::mount( false, 0, medium->deviceNode(), mountPoint );
- connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
- mount_jobs[job] = &data;
- // The caller expects the device to be mounted when the function
- // completes. Thus block until the job completes.
- while (!data.completed) {
- kapp->eventLoop()->enterLoop();
- }
- if (!data.error) {
- result["result"] = true;
- return result;
- }
- else {
- result["errStr"] = data.errorMessage; // Return the error message (if any) to the caller
- result["result"] = false;
- return result;
- }
- }
-
- kdDebug() << "mounting " << medium->id() << "..." << endl;
-
- TQStringList soptions;
- TQMap<TQString,TQString> valids = MediaManagerUtils::splitOptions(mountoptions(medium->id()));
- if (valids["flush"] == "true")
- soptions << "flush";
-
- if ((valids["uid"] == "true") && (medium->fsType() != "ntfs"))
- {
- soptions << TQString("uid=%1").arg(getuid());
- }
-
- if (valids["ro"] == "true")
- soptions << "ro";
-
- if (valids["atime"] != "true")
- soptions << "noatime";
-
- if (valids["quiet"] == "true")
- soptions << "quiet";
-
- if (valids["utf8"] == "true")
- soptions << "utf8";
-
- if (valids["sync"] == "true")
- soptions << "sync";
-
- if (medium->fsType() == "ntfs") {
- TQString fsLocale("locale=");
- fsLocale += setlocale(LC_ALL, "");
- soptions << fsLocale;
- }
-
- TQString mount_point = valids["mountpoint"];
- if (mount_point.startsWith("/media/"))
- mount_point = mount_point.mid(7);
-
- if (valids.contains("shortname"))
- {
- soptions << TQString("shortname=%1").arg(valids["shortname"]);
- }
-
- if (valids.contains("locale"))
- {
- soptions << TQString("locale=%1").arg(valids["locale"]);
- }
-
- if (valids.contains("journaling"))
- {
- TQString option = valids["journaling"];
- if (option == "data")
- soptions << TQString("data=journal");
- else if (option == "writeback")
- soptions << TQString("data=writeback");
- else
- soptions << TQString("data=ordered");
- }
-
- TQStringList hal_mount_options = getHALmountoptions(medium->id());
- for (TQValueListIterator<TQString> it=hal_mount_options.begin();it!=hal_mount_options.end();it++)
- {
- soptions << *it;
- kdDebug()<<"HALOption: "<<*it<<endl;
- if ((*it).startsWith("iocharset="))
- {
- soptions.remove("utf8");
- kdDebug()<<"\"iocharset=\" found. Removing \"utf8\" from options."<<endl;
- }
- }
-
- const char **options = new const char*[soptions.size() + 1];
- uint noptions = 0;
- for (TQStringList::ConstIterator it = soptions.begin(); it != soptions.end(); ++it, ++noptions)
- {
- options[noptions] = (*it).latin1();
- kdDebug()<<"Option: "<<*it<<endl;
- }
- options[noptions] = NULL;
-
- TQString qerror;
- if (!medium->isEncrypted()) {
- // normal volume
- qerror = mount_priv(medium->id().latin1(), mount_point.utf8(), options, noptions, dbus_connection);
- } else {
- // see if we have a clear volume
- error = i18n("Cannot mount encrypted locked drives!");
- LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, medium->id().latin1());
- if (halVolume) {
- char* clearUdi = libhal_volume_crypto_get_clear_volume_udi(m_halContext, halVolume);
- if (clearUdi != NULL) {
- qerror = mount_priv(clearUdi, mount_point.utf8(), options, noptions, dbus_connection);
- libhal_free_string(clearUdi);
- }
- libhal_volume_free(halVolume);
- }
- }
-
- if (!qerror.isEmpty()) {
- kdError() << "mounting " << medium->id() << " returned " << qerror << endl;
- result["errStr"] = qerror;
- result["result"] = false;
- return result;
- }
-
- medium->setHalMounted(true);
- ResetProperties(medium->id().latin1());
-
- result["result"] = true;
- return result;
-}
-
-TQStringVariantMap HALBackend::mount(const TQString &id)
-{
- const Medium *medium = m_mediaList.findById(id);
- if (!medium) {
- TQStringVariantMap result;
- result["errStr"] = i18n("No such medium: %1").arg(id);
- result["result"] = false;
- return result;
- }
- return mount(medium);
-}
-
-TQStringVariantMap HALBackend::unmount(const TQString &id)
-{
- TQStringVariantMap result;
-
- const Medium* medium = m_mediaList.findById(id);
- if (!medium)
- {
- // now we get fancy: if the udi is no volume, it _might_ be a device with only one
- // volume on it (think CDs) - so we're so nice to the caller to unmount that volume
- LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, id.latin1());
- if (halDrive)
- {
- int numVolumes;
- char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes);
- if (numVolumes == 1)
- medium = m_mediaList.findById(volumes[0]);
- }
- }
-
- if (!medium) {
- result["errStr"] = i18n("No such medium: %1").arg(id);
- result["result"] = false;
- return result;
- }
-
- if (!medium->isMounted()) {
- result["result"] = true;
- return result;
- }
-
- TQString mountPoint = isInFstab(medium);
- if (!mountPoint.isNull())
- {
- struct mount_job_data data;
- data.completed = false;
- data.medium = medium;
-
- kdDebug() << "triggering user unmount " << medium->deviceNode() << " " << mountPoint << endl;
- TDEIO::Job *job = TDEIO::unmount( medium->mountPoint(), false );
- connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
- mount_jobs[job] = &data;
- // The caller expects the device to be unmounted when the function
- // completes. Thus block until the job completes.
- while (!data.completed) {
- kapp->eventLoop()->enterLoop();
- }
- if (!data.error) {
- result["result"] = true;
- return result;
- }
- else {
- result["errStr"] = data.errorMessage; // Return the error message (if any) to the caller
- result["result"] = false;
- return result;
- }
- }
-
- DBusMessage *dmesg, *reply;
- DBusError error;
- const char *options[2];
- TQString udi = TQString::null;
-
- if (!medium->isEncrypted()) {
- // normal volume
- udi = medium->id();
- } else {
- // see if we have a clear volume
- LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, medium->id().latin1());
- if (halVolume) {
- char *clearUdi = libhal_volume_crypto_get_clear_volume_udi(m_halContext, halVolume);
- udi = clearUdi;
- libhal_free_string(clearUdi);
- libhal_volume_free(halVolume);
- }
- }
- if (udi.isNull()) {
- kdDebug() << "unmount failed: no udi" << endl;
- result["errStr"] = i18n("Internal error");
- result["result"] = false;
- return result;
- }
-
- kdDebug() << "unmounting " << udi << "..." << endl;
-
- dbus_error_init(&error);
- DBusConnection *dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (dbus_error_is_set(&error))
- {
- dbus_error_free(&error);
- result["errStr"] = i18n("Unknown error");
- result["result"] = false;
- return result;
- }
-
- if (!(dmesg = dbus_message_new_method_call ("org.freedesktop.Hal", udi.latin1(),
- "org.freedesktop.Hal.Device.Volume",
- "Unmount"))) {
- kdDebug() << "unmount failed for " << udi << ": could not create dbus message\n";
- result["errStr"] = i18n("Internal error");
- result["result"] = false;
- return result;
- }
-
- options[0] = "force";
- options[1] = 0;
-
- if (!dbus_message_append_args (dmesg, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &options, 0,
- DBUS_TYPE_INVALID))
- {
- kdDebug() << "unmount failed for " << udi << ": could not append args to dbus message\n";
- dbus_message_unref (dmesg);
- result["errStr"] = i18n("Internal error");
- result["result"] = false;
- return result;
- }
-
- char thisunmounthasfailed = 0;
- dbus_error_init (&error);
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, dmesg, -1, &error)))
- {
- thisunmounthasfailed = 1;
- TQString qerror, reason, origqerror;
-
- if (!strcmp(error.name, "org.freedesktop.Hal.Device.PermissionDeniedByPolicy")) {
- qerror = privilegedUnmount(udi.latin1());
-
- if (qerror.isEmpty()) {
- dbus_message_unref(dmesg);
- dbus_error_free(&error);
- result["result"] = true;
- return result;
- }
-
- // @todo handle unmount error message
- }
-
- kdDebug() << "unmount failed for " << udi << ": " << error.name << " " << error.message << endl;
- qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
- "currently mounted at <b>%4</b> could not be unmounted. ").arg(
- "system:/media/" + medium->name(),
- medium->deviceNode(),
- medium->prettyLabel(),
- medium->prettyBaseURL().pathOrURL()) + "</p>";
- qerror += "<p>" + i18n("Unmounting failed due to the following error:") + "</p>";
- if (!strcmp(error.name, "org.freedesktop.Hal.Device.Volume.Busy")) {
- reason = i18n("Device is Busy:");
- thisunmounthasfailed = 2;
- } else if (!strcmp(error.name, "org.freedesktop.Hal.Device.Volume.NotMounted")) {
- // this is faking. The error is that the device wasn't mounted by hal (but by the system)
- reason = i18n("Permission denied<p>Please ensure that:<br>1. You have permission to access this device.<br>2. This device was originally mounted using TDE.</p>");
- } else {
- reason = error.message;
- }
- qerror += "<p><b>" + reason + "</b></p>";
- origqerror = qerror;
-
- // Include list of processes (if any) using the device in the error message
- reason = listUsingProcesses(medium);
- if (!reason.isEmpty()) {
- qerror += reason;
- if (thisunmounthasfailed == 2) { // Failed as BUSY
- if (KMessageBox::warningYesNo(0, i18n("%1<p><b>Would you like to forcibly terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg(qerror)) == KMessageBox::Yes) {
- qerror = origqerror;
- reason = killUsingProcesses(medium);
- qerror = HALBackend::unmount(udi);
- if (qerror.isNull()) {
- thisunmounthasfailed = 0;
- }
- }
- }
- }
-
- if (thisunmounthasfailed != 0) {
- dbus_message_unref (dmesg);
- dbus_error_free (&error);
- result["errStr"] = qerror;
- result["result"] = false;
- return result;
- }
- }
-
- kdDebug() << "unmount queued for " << udi << endl;
-
- dbus_message_unref (dmesg);
- if (reply) {
- dbus_message_unref (reply);
- }
-
- medium->setHalMounted(false);
- ResetProperties(medium->id().latin1());
-
- while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
-
- result["result"] = true;
- return result;
-}
-
-TQStringVariantMap HALBackend::unlock(const TQString &id, const TQString &password)
-{
- TQStringVariantMap result;
-
- const Medium *medium = m_mediaList.findById(id);
- if (!medium) {
- result["errStr"] = i18n("No such medium: %1").arg(id);
- result["result"] = false;
- return result;
- }
-
- if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) {
- result["result"] = true;
- return result;
- }
-
- const char *udi = medium->id().latin1();
- DBusMessage *msg = NULL;
- DBusMessage *reply = NULL;
- DBusError error;
-
- kdDebug() << "Setting up " << udi << " for crypto\n" <<endl;
-
- msg = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
- "org.freedesktop.Hal.Device.Volume.Crypto",
- "Setup");
- if (msg == NULL) {
- kdDebug() << "unlock failed for " << udi << ": could not create dbus message\n";
- result["errStr"] = i18n("Internal error");
- result["result"] = false;
- return result;
- }
-
- TQCString pwdUtf8 = password.utf8();
- const char *pwd_utf8 = pwdUtf8;
- if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &pwd_utf8, DBUS_TYPE_INVALID)) {
- kdDebug() << "unlock failed for " << udi << ": could not append args to dbus message\n";
- dbus_message_unref (msg);
- result["errStr"] = i18n("Internal error");
- result["result"] = false;
- return result;
- }
-
- dbus_error_init (&error);
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
- dbus_error_is_set (&error))
- {
- TQString qerror = i18n("Internal Error");
- kdDebug() << "unlock failed for " << udi << ": " << error.name << " " << error.message << endl;
- if (strcmp (error.name, "org.freedesktop.Hal.Device.Volume.Crypto.SetupPasswordError") == 0) {
- qerror = i18n("Wrong password");
- }
- dbus_error_free (&error);
- dbus_message_unref (msg);
- while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
- result["errStr"] = qerror;
- result["result"] = false;
- return result;
- }
-
- dbus_message_unref (msg);
- dbus_message_unref (reply);
-
- while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
-
- result["result"] = true;
- return result;
-}
-
-TQStringVariantMap HALBackend::lock(const TQString &id)
-{
- TQStringVariantMap result;
-
- const Medium *medium = m_mediaList.findById(id);
- if (!medium) {
- result["errStr"] = i18n("No such medium: %1").arg(id);
- result["result"] = false;
- return result;
- }
-
- if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) {
- result["result"] = true;
- return result;
- }
-
- const char *udi = medium->id().latin1();
- DBusMessage *msg = NULL;
- DBusMessage *reply = NULL;
- DBusError error;
-
- kdDebug() << "Tear down " << udi << "\n" <<endl;
-
- msg = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
- "org.freedesktop.Hal.Device.Volume.Crypto",
- "Teardown");
- if (msg == NULL) {
- kdDebug() << "lock failed for " << udi << ": could not create dbus message\n";
- result["errStr"] = i18n("Internal error");
- result["result"] = false;
- return result;
- }
-
- if (!dbus_message_append_args (msg, DBUS_TYPE_INVALID)) {
- kdDebug() << "lock failed for " << udi << ": could not append args to dbus message\n";
- dbus_message_unref (msg);
- result["errStr"] = i18n("Internal error");
- result["result"] = false;
- return result;
- }
-
- dbus_error_init (&error);
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, -1, &error)) ||
- dbus_error_is_set (&error))
- {
- TQString qerror = i18n("Internal Error");
- kdDebug() << "lock failed for " << udi << ": " << error.name << " " << error.message << endl;
- dbus_error_free (&error);
- dbus_message_unref (msg);
- while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
- result["errStr"] = qerror;
- result["result"] = false;
- return result;
- }
-
- dbus_message_unref (msg);
- dbus_message_unref (reply);
-
- ResetProperties(udi);
-
- while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
-
- result["result"] = true;
- return result;
-}
-
-#include "halbackend.moc"
diff --git a/tdeioslave/media/mediamanager/halbackend.h b/tdeioslave/media/mediamanager/halbackend.h
deleted file mode 100644
index ed512fa7b..000000000
--- a/tdeioslave/media/mediamanager/halbackend.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/* This file is part of the KDE Project
- Copyright (c) 2004-2005 Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- 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.
-*/
-
-/**
-* This is a media:/ backend for the freedesktop Hardware Abstraction Layer
-* Usage : create an instance of HALBackend, then call InitHal(). A false
-* result from the later function means that something went wrong and that
-* the backend shall not be used.
-*
-* @author Jérôme Lodewyck <jerome dot lodewyck at normalesup dot org>
-* @short media:/ backend for the HAL
-*/
-
-#ifndef _HALBACKEND_H_
-#define _HALBACKEND_H_
-
-#include "backendbase.h"
-
-#include <tqobject.h>
-#include <tqstringlist.h>
-#include <tqstring.h>
-#include <tqregexp.h>
-
-#include <config.h>
-
-/* We acknowledge the the dbus API is unstable */
-#define DBUS_API_SUBJECT_TO_CHANGE
-/* DBus-Qt bindings */
-#include <dbus/connection.h>
-/* HAL libraries */
-#include <libhal.h>
-#include <libhal-storage.h>
-
-namespace TDEIO {
- class Job;
-}
-
-class HALBackend : public TQObject, public BackendBase
-{
-Q_OBJECT
-
-public:
- /**
- * Constructor
- */
- HALBackend(MediaList &list, TQObject* parent);
-
- /**
- * Destructor
- */
- ~HALBackend();
-
- /**
- * Perform HAL initialization.
- *
- * @return true if succeded. If not, rely on some other backend
- */
- bool InitHal();
-
- /**
- * List all devices and append them to the media device list (called only once, at startup).
- *
- * @return true if succeded, false otherwise
- */
- bool ListDevices();
-
- TQStringList mountoptions(const TQString &id);
-
- bool setMountoptions(const TQString &id, const TQStringList &options);
-
- TQStringVariantMap mount(const TQString &id);
- TQStringVariantMap mount(const Medium *medium);
- TQStringVariantMap unmount(const TQString &id);
- TQStringVariantMap unlock(const TQString &id, const TQString &password);
- TQStringVariantMap lock(const TQString &id);
-
-private:
- /**
- * Append a device in the media list. This function will check if the device
- * is worth listing.
- *
- * @param udi Universal Device Id
- * @param allowNotification Indicates if this event will be notified to the user
- */
- void AddDevice(const char* udi, bool allowNotification=true);
-
- /**
- * Remove a device from the device list
- *
- * @param udi Universal Device Id
- */
- void RemoveDevice(const char* udi);
-
- /**
- * A device has changed, update it
- *
- * @param udi Universal Device Id
- */
- void ModifyDevice(const char *udi, const char* key);
-
- /**
- * HAL informed that a special action has occured
- * (e.g. device unplugged without unmounting)
- *
- * @param udi Universal Device Id
- */
- void DeviceCondition(const char *udi, const char *condition);
-
- /**
- * Integrate the DBus connection within qt main loop
- */
- void MainLoopIntegration(DBusConnection *dbusConnection);
-
-/* Set media properties */
-private:
- /**
- * Reset properties for the given medium
- */
- void ResetProperties(const char* MediumUdi, bool allowNotification=false);
-
- /**
- * Find the medium that is concerned with device udi
- */
- const char* findMediumUdiFromUdi(const char* udi);
-
- void setVolumeProperties(Medium* medium);
- bool setFloppyProperties(Medium* medium);
- void setFloppyMountState( Medium* medium );
- bool setFstabProperties(Medium* medium);
- void setCameraProperties(Medium* medium);
- TQString generateName(const TQString &devNode);
- static TQString isInFstab(const Medium *medium);
- static TQString listUsingProcesses(const Medium *medium);
- static TQString killUsingProcesses(const Medium *medium);
-
-private slots:
- void slotResult(TDEIO::Job *job);
-
-/* Hal call-backs -- from gvm*/
-public:
- /** Invoked when a device is added to the Global Device List.
- *
- * @param ctx LibHal context
- * @param udi Universal Device Id
- */
- static void hal_device_added(LibHalContext *ctx, const char *udi);
-
- /** Invoked when a device is removed from the Global Device List.
- *
- * @param ctx LibHal context
- * @param udi Universal Device Id
- */
- static void hal_device_removed(LibHalContext *ctx, const char *udi);
-
- /** Invoked when a property of a device in the Global Device List is
- * changed, and we have we have subscribed to changes for that device.
- *
- * @param ctx LibHal context
- * @param udi Univerisal Device Id
- * @param key Key of property
- */
- static void hal_device_property_modified(LibHalContext *ctx, const char *udi, const char *key,
- dbus_bool_t is_removed, dbus_bool_t is_added);
-
- /** Type for callback when a non-continuos condition occurs on a device
- *
- * @param udi Univerisal Device Id
- * @param condition_name Name of the condition
- * @param message D-BUS message with variable parameters depending on condition
- */
- static void hal_device_condition(LibHalContext *ctx, const char *udi,
- const char *condition_name,
- const char* message
- );
-
- TQStringList getHALmountoptions(TQString udi);
-/* HAL and DBus structures */
-private:
- /**
- * The HAL context connecting the whole application to the HAL
- */
- LibHalContext* m_halContext;
-
- /**
- * libhal-storage HAL policy, e.g. for icon names
- */
- LibHalStoragePolicy* m_halStoragePolicy;
-
- /**
- * The DBus-Qt bindings connection for mainloop integration
- */
- DBusQt::Connection* m_dBusQtConnection;
-
- /**
- * Object for the kded module
- */
- TQObject* m_parent;
-
- DBusConnection *dbus_connection;
-
- /**
- * Data structure for fstab mount/unmount jobs
- */
- struct mount_job_data {
- // [in] Medium, which is being mounted/unmounted by the job
- const Medium* medium;
- // [in,out] Should be set to true when the job completes
- bool completed;
- // [out] TDEIO::Error if an error occured during operation. Otherwise, 0
- int error;
- // [out] Error message to be displayed to the user
- TQString errorMessage;
- };
-
- TQMap<TDEIO::Job *, struct mount_job_data*> mount_jobs;
-};
-
-#endif /* _HALBACKEND_H_ */
diff --git a/tdeioslave/media/mediamanager/linuxcdpolling.cpp b/tdeioslave/media/mediamanager/linuxcdpolling.cpp
index eccdf1f34..66074f40e 100644
--- a/tdeioslave/media/mediamanager/linuxcdpolling.cpp
+++ b/tdeioslave/media/mediamanager/linuxcdpolling.cpp
@@ -176,19 +176,19 @@ private:
LinuxCDPolling::LinuxCDPolling(MediaList &list)
: TQObject(), BackendBase(list)
{
- connect(&m_mediaList, TQT_SIGNAL(mediumAdded(const TQString &,
+ connect(&m_mediaList, TQ_SIGNAL(mediumAdded(const TQString &,
const TQString &, bool)),
- this, TQT_SLOT(slotMediumAdded(const TQString &)) );
+ this, TQ_SLOT(slotMediumAdded(const TQString &)) );
- connect(&m_mediaList, TQT_SIGNAL(mediumRemoved(const TQString &,
+ connect(&m_mediaList, TQ_SIGNAL(mediumRemoved(const TQString &,
const TQString &, bool)),
- this, TQT_SLOT(slotMediumRemoved(const TQString &)) );
+ this, TQ_SLOT(slotMediumRemoved(const TQString &)) );
- connect(&m_mediaList, TQT_SIGNAL(mediumStateChanged(const TQString &,
+ connect(&m_mediaList, TQ_SIGNAL(mediumStateChanged(const TQString &,
const TQString &, bool, bool)),
- this, TQT_SLOT(slotMediumStateChanged(const TQString &)) );
+ this, TQ_SLOT(slotMediumStateChanged(const TQString &)) );
- connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout()));
+ connect(&m_timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotTimeout()));
}
LinuxCDPolling::~LinuxCDPolling()
@@ -514,7 +514,7 @@ bool LinuxCDPolling::hasDirectory(const TQCString &devNode, const TQCString &dir
close(fd);
return false;
}
- if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
+ if (TQ_BYTE_ORDER != TQ_LITTLE_ENDIAN)
bs = ((bs << 8) & 0xFF00) | ((bs >> 8) & 0xFF);
// read in size of path table
@@ -524,7 +524,7 @@ bool LinuxCDPolling::hasDirectory(const TQCString &devNode, const TQCString &dir
close(fd);
return false;
}
- if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
+ if (TQ_BYTE_ORDER != TQ_LITTLE_ENDIAN)
ts = ((ts << 8) & 0xFF00) | ((ts >> 8) & 0xFF);
// read in which block path table is in
@@ -534,7 +534,7 @@ bool LinuxCDPolling::hasDirectory(const TQCString &devNode, const TQCString &dir
close(fd);
return false;
}
- if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
+ if (TQ_BYTE_ORDER != TQ_LITTLE_ENDIAN)
tl = ((tl << 24) & 0xFF000000) | ((tl << 8) & 0xFF0000) |
((tl >> 8) & 0xFF00) | ((tl >> 24) & 0xFF);
@@ -559,7 +559,7 @@ bool LinuxCDPolling::hasDirectory(const TQCString &devNode, const TQCString &dir
ret = false;
break;
}
- if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
+ if (TQ_BYTE_ORDER != TQ_LITTLE_ENDIAN)
parent = ((parent << 8) & 0xFF00) | ((parent >> 8) & 0xFF);
// read the name
diff --git a/tdeioslave/media/mediamanager/linuxcdpolling.h b/tdeioslave/media/mediamanager/linuxcdpolling.h
index fc4947470..070ad5eea 100644
--- a/tdeioslave/media/mediamanager/linuxcdpolling.h
+++ b/tdeioslave/media/mediamanager/linuxcdpolling.h
@@ -49,7 +49,7 @@ class PollingThread;
class LinuxCDPolling : public TQObject, public BackendBase
{
-Q_OBJECT
+TQ_OBJECT
public:
diff --git a/tdeioslave/media/mediamanager/medialist.cpp b/tdeioslave/media/mediamanager/medialist.cpp
index b06824d0c..8ea9aec50 100644
--- a/tdeioslave/media/mediamanager/medialist.cpp
+++ b/tdeioslave/media/mediamanager/medialist.cpp
@@ -128,42 +128,43 @@ bool MediaList::changeMediumState(const Medium &medium, bool allowNotification)
{
kdDebug(1219) << "MediaList::changeMediumState(const Medium &) for id " << medium.id() << endl;
- if ( !m_idMap.contains(medium.id()) ) return false;
+ if (!m_idMap.contains(medium.id())) return false;
Medium *m = m_idMap[medium.id()];
- if ( medium.isMountable() )
+ m->setEncrypted(medium.isEncrypted());
+ m->setLocked(medium.isLocked());
+ m->setMountable(medium.isMountable());
+ if (medium.isMountable())
{
- TQString device_node = medium.deviceNode();
- TQString clear_device_udi = medium.clearDeviceUdi();
- TQString mount_point = medium.mountPoint();
- TQString fs_type = medium.fsType();
- bool mounted = medium.isMounted();
-
- m->mountableState( device_node, clear_device_udi, mount_point, fs_type, mounted );
+ m->setDeviceNode(medium.deviceNode());
+ m->setClearDeviceUdi(medium.clearDeviceUdi());
+ m->setMountPoint(medium.mountPoint());
+ m->setFsType(medium.fsType());
+ m->setMounted(medium.isMounted());
}
else
{
- m->unmountableState( medium.baseURL() );
+ m->setBaseURL(medium.baseURL());
}
-
if (!medium.mimeType().isEmpty())
{
- m->setMimeType( medium.mimeType() );
+ m->setMimeType(medium.mimeType());
}
if (!medium.iconName().isEmpty())
{
- m->setIconName( medium.iconName() );
+ m->setIconName(medium.iconName());
}
if (!medium.label().isEmpty())
{
- m->setLabel( medium.label() );
+ m->setLabel(medium.label());
}
m->setHidden(medium.hidden());
+ m->setSoftHidden(medium.softHidden());
emit mediumStateChanged(m->id(), m->name(), !m->needMounting(), allowNotification);
return true;
@@ -184,7 +185,8 @@ bool MediaList::changeMediumState(const TQString &id,
Medium *medium = m_idMap[id];
- medium->unmountableState( baseURL );
+ medium->setMountable(false);
+ medium->setBaseURL(baseURL);
if (!mimeType.isEmpty())
{
@@ -225,7 +227,16 @@ bool MediaList::changeMediumState(const TQString &id,
Medium *medium = m_idMap[id];
- medium->mountableState( deviceNode, mountPoint, fsType, mounted );
+ if (medium->deviceNode().isEmpty() || !medium->isMountable())
+ {
+ return false;
+ }
+
+ medium->setMountable(true);
+ medium->setDeviceNode(deviceNode);
+ medium->setMountPoint(mountPoint);
+ medium->setFsType(fsType);
+ medium->setMounted(mounted);
if (!mimeType.isEmpty())
{
@@ -262,7 +273,12 @@ bool MediaList::changeMediumState(const TQString &id, bool mounted,
Medium *medium = m_idMap[id];
- if ( !medium->mountableState( mounted ) ) return false;
+ if (medium->deviceNode().isEmpty() || !medium->isMountable())
+ {
+ return false;
+ }
+
+ medium->setMounted(mounted);
if (!mimeType.isEmpty())
{
diff --git a/tdeioslave/media/mediamanager/medialist.h b/tdeioslave/media/mediamanager/medialist.h
index f4b088526..a92d1b6c0 100644
--- a/tdeioslave/media/mediamanager/medialist.h
+++ b/tdeioslave/media/mediamanager/medialist.h
@@ -23,9 +23,9 @@
#include "medium.h"
-class MediaList : public QObject
+class MediaList : public TQObject
{
-Q_OBJECT
+TQ_OBJECT
public:
MediaList();
diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp
index 7a8262eec..66c456a24 100644
--- a/tdeioslave/media/mediamanager/mediamanager.cpp
+++ b/tdeioslave/media/mediamanager/mediamanager.cpp
@@ -36,10 +36,6 @@
#include "tdehardwarebackend.h"
#endif // COMPILE_TDEHARDWAREBACKEND
-#ifdef COMPILE_HALBACKEND
-#include "halbackend.h"
-#endif //COMPILE_HALBACKEND
-
#ifdef COMPILE_LINUXCDPOLLING
#include "linuxcdpolling.h"
#endif //COMPILE_LINUXCDPOLLING
@@ -47,15 +43,15 @@
MediaManager::MediaManager(const TQCString &obj)
: KDEDModule(obj), m_dirNotify(m_mediaList)
{
- connect( &m_mediaList, TQT_SIGNAL(mediumAdded(const TQString&, const TQString&, bool)),
- TQT_SLOT(slotMediumAdded(const TQString&, const TQString&, bool)) );
- connect( &m_mediaList, TQT_SIGNAL(mediumRemoved(const TQString&, const TQString&, bool)),
- TQT_SLOT(slotMediumRemoved(const TQString&, const TQString&, bool)) );
+ connect( &m_mediaList, TQ_SIGNAL(mediumAdded(const TQString&, const TQString&, bool)),
+ TQ_SLOT(slotMediumAdded(const TQString&, const TQString&, bool)) );
+ connect( &m_mediaList, TQ_SIGNAL(mediumRemoved(const TQString&, const TQString&, bool)),
+ TQ_SLOT(slotMediumRemoved(const TQString&, const TQString&, bool)) );
connect( &m_mediaList,
- TQT_SIGNAL(mediumStateChanged(const TQString&, const TQString&, bool, bool)),
- TQT_SLOT(slotMediumChanged(const TQString&, const TQString&, bool, bool)) );
+ TQ_SIGNAL(mediumStateChanged(const TQString&, const TQString&, bool, bool)),
+ TQ_SLOT(slotMediumChanged(const TQString&, const TQString&, bool, bool)) );
- TQTimer::singleShot( 10, this, TQT_SLOT( loadBackends() ) );
+ TQTimer::singleShot( 10, this, TQ_SLOT( loadBackends() ) );
}
MediaManager::~MediaManager()
@@ -80,33 +76,9 @@ void MediaManager::loadBackends()
}
mp_removableBackend = 0L;
- m_halbackend = 0L;
m_tdebackend = 0L;
m_fstabbackend = 0L;
-#ifdef COMPILE_HALBACKEND
- if ( MediaManagerSettings::self()->halBackendEnabled() )
- {
- m_mediaList.blockSignals(false);
- m_halbackend = new HALBackend(m_mediaList, this);
- if (m_halbackend->InitHal())
- {
- m_backends.append( m_halbackend );
- m_fstabbackend = new FstabBackend(m_mediaList, true);
- m_backends.append( m_fstabbackend );
- // No need to load something else...
- m_mediaList.blockSignals(false);
- return;
- }
- else
- {
- delete m_halbackend;
- m_halbackend = 0;
- m_mediaList.blockSignals(true);
- }
- }
-#endif // COMPILE_HALBACKEND
-
#ifdef COMPILE_TDEHARDWAREBACKEND
if ( MediaManagerSettings::self()->tdeHardwareBackendEnabled() )
{
@@ -136,39 +108,22 @@ void MediaManager::loadBackends()
m_mediaList.blockSignals(false);
}
-
-TQStringList MediaManager::fullList()
-{
- TQPtrList<Medium> list = m_mediaList.list();
-
- TQStringList result;
-
- TQPtrList<Medium>::const_iterator it = list.begin();
- TQPtrList<Medium>::const_iterator end = list.end();
- for (; it!=end; ++it)
- {
- result+= (*it)->properties();
- result+= Medium::SEPARATOR;
- }
-
- return result;
-}
-
-TQStringList MediaManager::properties(const TQString &name)
+const Medium* MediaManager::getMediumByName(const TQString &name)
{
const Medium *m = m_mediaList.findByName(name);
-
if (!m)
{
KURL u(name);
- kdDebug() << "Media::prop " << name << " " << u.isValid() << endl;
+ kdDebug() << "Media::getMediumByName " << name << " " << u.isValid() << endl;
if (u.isValid())
{
if (u.protocol() == "system")
{
TQString path = u.path();
if (path.startsWith("/media/"))
+ {
path = path.mid(strlen("/media/"));
+ }
m = m_mediaList.findByName(path);
kdDebug() << "findByName " << path << m << endl;
}
@@ -189,170 +144,162 @@ TQStringList MediaManager::properties(const TQString &name)
{
path = TDEStandardDirs::realFilePath(u.path());
kdDebug() << "comparing " << (*it)->mountPoint() << " " << path << " " << (*it)->deviceNode() << endl;
- if ((*it)->mountPoint() == path || (*it)->deviceNode() == path) {
- m = *it;
- break;
+ if ((*it)->mountPoint() == path || (*it)->deviceNode() == path)
+ {
+ m = *it;
+ break;
}
}
}
}
}
+ return m;
+}
+
+TQStringList MediaManager::fullList()
+{
+ TQPtrList<Medium> list = m_mediaList.list();
+
+ TQStringList result;
+
+ TQPtrList<Medium>::const_iterator it = list.begin();
+ TQPtrList<Medium>::const_iterator end = list.end();
+ for (; it!=end; ++it)
+ {
+ result+= (*it)->properties();
+ result+= Medium::SEPARATOR;
+ }
+
+ return result;
+}
- if (m) {
+TQStringList MediaManager::properties(const TQString &name)
+{
+ const Medium *m = getMediumByName(name);
+ if (m)
+ {
return m->properties();
}
- else {
+ else
+ {
return TQStringList();
}
}
TQStringList MediaManager::mountoptions(const TQString &name)
{
-#ifdef COMPILE_HALBACKEND
- if (!m_halbackend)
- return TQStringList();
- return m_halbackend->mountoptions(name);
-#else // COMPILE_HALBACKEND
- #ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend)
- return TQStringList();
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (m_tdebackend)
+ {
return m_tdebackend->mountoptions(name);
- #else // COMPILE_TDEHARDWAREBACKEND
- return TQStringList();
- #endif // COMPILE_TDEHARDWAREBACKEND
-#endif // COMPILE_HALBACKEND
+ }
+#endif
+ return TQStringList();
}
bool MediaManager::setMountoptions(const TQString &name, const TQStringList &options)
{
-#ifdef COMPILE_HALBACKEND
- if (!m_halbackend)
- return false;
- return m_halbackend->setMountoptions(name, options);
-#else // COMPILE_HALBACKEND
- #ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend)
- return false;
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (m_tdebackend)
+ {
return m_tdebackend->setMountoptions(name, options);
- #else // COMPILE_TDEHARDWAREBACKEND
- return false;
- #endif // COMPILE_TDEHARDWAREBACKEND
-#endif // COMPILE_HALBACKEND
+ }
+#endif
+ return false;
}
TQStringVariantMap MediaManager::mount(const TQString &uid)
{
- TQStringVariantMap result;
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->mount(uid);
}
- return m_tdebackend->mount(uid);
-#elif defined COMPILE_HALBACKEND
- if (!m_halbackend) {
- result["errStr"] = i18n("Feature only available with HAL");
- result["result"] = false;
- return result;
- }
- return m_halbackend->mount(uid);
#else
- if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_fstabbackend)
+ {
+ return m_fstabbackend->mount(uid);
}
- return m_fstabbackend->mount(uid);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware or fstab backend");
+ result["result"] = false;
+ return result;
}
TQStringVariantMap MediaManager::unmount(const TQString &uid)
{
- TQStringVariantMap result;
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->unmount(uid);
}
- return m_tdebackend->unmount(uid);
-#elif defined COMPILE_HALBACKEND
- if (!m_halbackend) {
- result["errStr"] = i18n("Feature only available with HAL");
- result["result"] = false;
- return result;
- }
- return m_halbackend->unmount(uid);
#else
- if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_fstabbackend)
+ {
+ return m_fstabbackend->unmount(uid);
}
- return m_fstabbackend->unmount(uid);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware or fstab backend");
+ result["result"] = false;
+ return result;
}
TQStringVariantMap MediaManager::unlock(const TQString &uid, const TQString &password)
{
- TQStringVariantMap result;
-/*
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
- }
- return m_tdebackend->unlock(uid, password);
-#elif defined COMPILE_HALBACKEND
-*/
-#if defined COMPILE_HALBACKEND
- if (!m_halbackend) {
- result["errStr"] = i18n("Feature only available with HAL");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->unlock(uid, password);
}
- return m_halbackend->unlock(uid, password);
-
-#else
-// if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
- result["result"] = false;
- return result;
-// }
-// return m_fstabbackend->unlock(uid, password);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
}
-TQStringVariantMap MediaManager::lock(const TQString &uid)
+TQStringVariantMap MediaManager::lock(const TQString &uid, bool releaseHolders)
{
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (m_tdebackend)
+ {
+ return m_tdebackend->lock(uid, releaseHolders);
+ }
+#endif
TQStringVariantMap result;
-/*
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
+}
+
+TQStringVariantMap MediaManager::eject(const TQString &uid)
+{
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->eject(uid);
}
- return m_tdebackend->lock(uid);
-#elif defined COMPILE_HALBACKEND
-*/
-#if defined COMPILE_HALBACKEND
- if (!m_halbackend) {
- result["errStr"] = i18n("Feature only available with HAL");
- result["result"] = false;
- return result;
+#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
+}
+
+TQStringVariantMap MediaManager::safeRemove(const TQString &uid)
+{
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (m_tdebackend)
+ {
+ return m_tdebackend->safeRemove(uid);
}
- return m_halbackend->lock(uid);
-#else
-// if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
- result["result"] = false;
- return result;
-// }
-// return m_fstabbackend->lock(uid);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
}
TQStringVariantMap MediaManager::mountByNode(const TQString &deviceNode)
@@ -391,7 +338,7 @@ TQStringVariantMap MediaManager::unlockByNode(const TQString &deviceNode, const
return unlock(medium->id(), password);
}
-TQStringVariantMap MediaManager::lockByNode(const TQString &deviceNode)
+TQStringVariantMap MediaManager::lockByNode(const TQString &deviceNode, bool releaseHolders)
{
const Medium *medium = m_mediaList.findByNode(deviceNode);
if (!medium) {
@@ -400,7 +347,44 @@ TQStringVariantMap MediaManager::lockByNode(const TQString &deviceNode)
result["result"] = false;
return result;
}
- return lock(medium->id());
+ return lock(medium->id(), releaseHolders);
+}
+
+TQStringVariantMap MediaManager::ejectByNode(const TQString &deviceNode)
+{
+ const Medium *medium = m_mediaList.findByNode(deviceNode);
+ if (!medium) {
+ TQStringVariantMap result;
+ result["errStr"] = i18n("No such medium: %1").arg(deviceNode);
+ result["result"] = false;
+ return result;
+ }
+ return eject(medium->id());
+}
+
+TQStringVariantMap MediaManager::safeRemoveByNode(const TQString &deviceNode)
+{
+ const Medium *medium = m_mediaList.findByNode(deviceNode);
+ if (!medium) {
+ TQStringVariantMap result;
+ result["errStr"] = i18n("No such medium: %1").arg(deviceNode);
+ result["result"] = false;
+ return result;
+ }
+ return safeRemove(medium->id());
+}
+
+TQString MediaManager::mimeType(const TQString &name)
+{
+ const Medium *m = getMediumByName(name);
+ if (m)
+ {
+ return m->mimeType();
+ }
+ else
+ {
+ return TQString::null;
+ }
}
TQString MediaManager::nameForLabel(const TQString &label)
diff --git a/tdeioslave/media/mediamanager/mediamanager.h b/tdeioslave/media/mediamanager/mediamanager.h
index d8a31d8e1..1fe873f98 100644
--- a/tdeioslave/media/mediamanager/mediamanager.h
+++ b/tdeioslave/media/mediamanager/mediamanager.h
@@ -29,18 +29,19 @@
#include "removablebackend.h"
#include "mediadirnotify.h"
-class HALBackend;
class TDEBackend;
class FstabBackend;
class MediaManager : public KDEDModule
{
-Q_OBJECT
+TQ_OBJECT
K_DCOP
public:
MediaManager(const TQCString &obj);
~MediaManager();
+ const Medium* getMediumByName(const TQString &name);
+
k_dcop:
TQStringList fullList();
TQStringList properties(const TQString &name);
@@ -50,19 +51,23 @@ k_dcop:
TQStringVariantMap mount(const TQString &uid);
TQStringVariantMap unmount(const TQString &uid);
TQStringVariantMap unlock(const TQString &uid, const TQString &password);
- TQStringVariantMap lock(const TQString &uid);
+ TQStringVariantMap lock(const TQString &uid, bool releaseHolders);
+ TQStringVariantMap eject(const TQString &uid);
+ TQStringVariantMap safeRemove(const TQString &uid);
TQStringVariantMap mountByNode(const TQString &deviceNode);
TQStringVariantMap unmountByNode(const TQString &deviceNode);
TQStringVariantMap unlockByNode(const TQString &deviceNode, const TQString &password);
- TQStringVariantMap lockByNode(const TQString &deviceNode);
+ TQStringVariantMap lockByNode(const TQString &deviceNode, bool releaseHolders);
+ TQStringVariantMap ejectByNode(const TQString &deviceNode);
+ TQStringVariantMap safeRemoveByNode(const TQString &deviceNode);
+ TQString mimeType(const TQString &name);
TQString nameForLabel(const TQString &label);
ASYNC setUserLabel(const TQString &name, const TQString &label);
ASYNC reloadBackends();
- // Removable media handling (for people not having HAL)
bool removablePlug(const TQString &devNode, const TQString &label);
bool removableUnplug(const TQString &devNode);
bool removableCamera(const TQString &devNode);
@@ -91,7 +96,6 @@ private:
MediaList m_mediaList;
TQValueList<BackendBase*> m_backends;
RemovableBackend *mp_removableBackend;
- HALBackend *m_halbackend;
TDEBackend *m_tdebackend;
MediaDirNotify m_dirNotify;
FstabBackend *m_fstabbackend;
diff --git a/tdeioslave/media/mediamanager/removablebackend.cpp b/tdeioslave/media/mediamanager/removablebackend.cpp
index 54df3d6f1..a9207cd92 100644
--- a/tdeioslave/media/mediamanager/removablebackend.cpp
+++ b/tdeioslave/media/mediamanager/removablebackend.cpp
@@ -37,8 +37,8 @@ RemovableBackend::RemovableBackend(MediaList &list)
{
KDirWatch::self()->addFile(MTAB);
- connect( KDirWatch::self(), TQT_SIGNAL( dirty(const TQString&) ),
- this, TQT_SLOT( slotDirty(const TQString&) ) );
+ connect( KDirWatch::self(), TQ_SIGNAL( dirty(const TQString&) ),
+ this, TQ_SLOT( slotDirty(const TQString&) ) );
KDirWatch::self()->startScan();
}
@@ -63,8 +63,11 @@ bool RemovableBackend::plug(const TQString &devNode, const TQString &label)
if (!m_removableIds.contains(id))
{
Medium *medium = new Medium(id, id, name);
- medium->mountableState(devNode, TQString::null,
- TQString::null, false);
+ medium->setMountable(true);
+ medium->setDeviceNode(devNode);
+ medium->setMountPoint(TQString::null);
+ medium->setFsType(TQString::null);
+ medium->setMounted(false);
TQStringList words = TQStringList::split(" ", label);
diff --git a/tdeioslave/media/mediamanager/removablebackend.h b/tdeioslave/media/mediamanager/removablebackend.h
index fa16a391b..256497d9a 100644
--- a/tdeioslave/media/mediamanager/removablebackend.h
+++ b/tdeioslave/media/mediamanager/removablebackend.h
@@ -26,7 +26,7 @@
class RemovableBackend : public TQObject, public BackendBase
{
-Q_OBJECT
+TQ_OBJECT
public:
RemovableBackend(MediaList &list);
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
index c399d280d..a5900c883 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -49,16 +49,15 @@
TDEBackend::TDEBackend(MediaList &list, TQObject* parent)
: TQObject()
, BackendBase(list)
- , m_unlockDialog(0)
, m_parent(parent)
{
// Initialize the TDE device manager
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
// Connect device monitoring signals/slots
- connect(hwdevices, TQT_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQT_SLOT(AddDeviceHandler(TDEGenericDevice*)));
- connect(hwdevices, TQT_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQT_SLOT(RemoveDeviceHandler(TDEGenericDevice*)));
- connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(ModifyDeviceHandler(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQ_SLOT(AddDeviceHandler(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(RemoveDeviceHandler(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(ModifyDeviceHandler(TDEGenericDevice*)));
// List devices at startup
ListDevices();
@@ -139,29 +138,30 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
bool allowDialogNotification = allowNotification;
TDEConfig config("mediamanagerrc");
config.setGroup("Global");
- if (!config.readBoolEntry("NotificationPopupsEnabled", false)) {
+ if (!config.readBoolEntry("NotificationPopupsEnabled", true)) {
allowDialogNotification = false;
}
// Add volume block devices
if (sdevice->isDiskOfType(TDEDiskDeviceType::HDD)) {
/* We only list volumes that...
- * - are encrypted with LUKS or
+ * - are encrypted or
* - have a filesystem or
* - have an audio track
*/
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
- /* We also don't display devices that underlie other devices;
- * e.g. the raw partition of a device mapper volume
- */
- else if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)
- || (sdevice->fileSystemUsage().upper() == "RAID")) {
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
//
}
else {
@@ -169,16 +169,6 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
Medium* medium = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
setVolumeProperties(medium);
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- medium->setHidden(true);
- }
- else {
- medium->setHidden(false);
- }
- }
-
// Hide udev hidden devices by default but allow the user to override if desired via Show Hidden Files
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden)) {
medium->setSoftHidden(true);
@@ -266,33 +256,29 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
}
/* We only list volumes that...
- * - are encrypted with LUKS or
+ * - are encrypted or
* - have a filesystem or
- * - are a floppy disk
+ * - have an audio track
*/
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::Floppy))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
+ }
else {
// Create medium
Medium* medium = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
-
setFloppyProperties(medium);
-
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- medium->setHidden(true);
- }
- else {
- medium->setHidden(false);
- }
- }
-
m_mediaList.addMedium(medium, allowDialogNotification);
kdDebug(1219) << "TDEBackend::AddDevice inserted floppy medium for " << sdevice->uniqueID() << endl;
@@ -334,8 +320,7 @@ void TDEBackend::ModifyDevice(TDEStorageDevice * sdevice)
{
kdDebug(1219) << "TDEBackend::ModifyDevice for " << sdevice->uniqueID() << endl;
- bool allowNotification = false;
- ResetProperties(sdevice, allowNotification);
+ ResetProperties(sdevice, false);
}
void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotification, bool overrideIgnoreList)
@@ -359,24 +344,28 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
Medium* m = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
// Keep these conditions in sync with ::AddDevice above, OR ELSE!!!
- // BEGIN
if (sdevice->isDiskOfType(TDEDiskDeviceType::HDD)) {
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ /* We only list volumes that...
+ * - are encrypted or
+ * - have a filesystem or
+ * - have an audio track
+ */
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
+ //
+ }
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
}
else {
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- m->setHidden(true);
- }
- else {
- m->setHidden(false);
- }
- }
setVolumeProperties(m);
}
}
@@ -416,25 +405,27 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
(sdevice->isDiskOfType(TDEDiskDeviceType::Zip)) ||
(sdevice->isDiskOfType(TDEDiskDeviceType::Jaz))
) {
-
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::Floppy))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ /* We only list volumes that...
+ * - are encrypted or
+ * - have a filesystem or
+ * - have an audio track
+ */
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
+ }
else {
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- m->setHidden(true);
- }
- else {
- m->setHidden(false);
- }
- }
-
setFloppyProperties(m);
}
}
@@ -443,8 +434,6 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
setCameraProperties(m);
}
- // END
-
if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) && (!(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Inserted)))) {
kdDebug(1219) << "TDEBackend::ResetProperties for " << sdevice->uniqueID() << " device was removed from system" << endl;
RemoveDevice(sdevice);
@@ -462,27 +451,40 @@ void TDEBackend::setVolumeProperties(Medium* medium)
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- TDEStorageDevice * sdevice = hwdevices->findDiskByUID(medium->id());
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
return;
}
medium->setName(generateName(sdevice->deviceNode()));
- if ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) || (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) {
medium->setEncrypted(true);
+ medium->setLocked(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
}
else {
medium->setEncrypted(false);
}
- // USAGE: mountableState(Device node, Mount point, Filesystem type, Mounted ?)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ // Encrypted disks or device underlying other devices are not mountable
+ medium->setMountable(false);
+ }
+ else {
+ medium->setMountable(true);
+ }
+
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
TQString diskLabel = sdevice->diskLabel();
bool useDefaultLabel = diskLabel.isNull();
if (useDefaultLabel) {
diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
}
+ diskLabel += " (" + sdevice->deviceNode() + ")";
TQString mimeType;
@@ -518,14 +520,15 @@ void TDEBackend::setVolumeProperties(Medium* medium)
// Default
mimeType = "media/cdrom" + MOUNT_MEDIA_SUFFIX;
if (useDefaultLabel) {
- diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
+ diskLabel = i18n("%1 Removable Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::CDROM)) {
mimeType = "media/cdrom" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-ROM");
}
}
@@ -534,7 +537,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-r" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-R");
}
}
@@ -543,7 +547,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-RW");
}
}
@@ -552,7 +557,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Magneto-Optical CD");
}
}
@@ -561,7 +567,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Mount Ranier CD-RW");
}
}
@@ -570,7 +577,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Mount Ranier CD-RW-W");
}
}
@@ -579,7 +587,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-ROM");
}
}
@@ -588,7 +597,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-RAM");
}
}
@@ -597,7 +607,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-R");
}
}
@@ -606,7 +617,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-RW");
}
}
@@ -615,7 +627,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD-R");
}
}
@@ -624,7 +637,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD-RW");
}
}
@@ -633,7 +647,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD+R");
}
}
@@ -642,7 +657,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD+RW");
}
}
@@ -651,7 +667,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD+R");
}
}
@@ -660,7 +677,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD+RW");
}
}
@@ -669,7 +687,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-ROM");
}
}
@@ -678,7 +697,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-R");
}
}
@@ -687,7 +707,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-RW");
}
}
@@ -696,7 +717,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-ROM");
}
}
@@ -705,7 +727,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-R");
}
}
@@ -714,14 +737,16 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-RW");
}
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio)) {
mimeType = "media/audiocd";
- medium->unmountableState("audiocd:/?device=" + sdevice->deviceNode());
+ medium->setMountable(false);
+ medium->setBaseURL("audiocd:/?device=" + sdevice->deviceNode());
diskLabel = i18n("Audio CD");
}
@@ -746,12 +771,11 @@ void TDEBackend::setVolumeProperties(Medium* medium)
diskLabel = i18n("%1 Fixed Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
- if (sdevice->isDiskOfType(TDEDiskDeviceType::USB)
- || sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)
- || sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::USB) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) {
mimeType = "media/removable" + MOUNT_MEDIA_SUFFIX;
if (useDefaultLabel) {
- diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
+ diskLabel = i18n("%1 Removable Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
}
@@ -769,9 +793,10 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::MediaDevice)) {
medium->setIconName("ipod" + MOUNTED_ICON_SUFFIX);
- if (sdevice->vendorModel().upper().contains("IPOD") && KProtocolInfo::isKnownProtocol( TQString("ipod") ) ) {
- medium->unmountableState( "ipod:/" );
- medium->mountableState(!sdevice->mountPath().isNull());
+ if (sdevice->vendorModel().upper().contains("IPOD") && KProtocolInfo::isKnownProtocol(TQString("ipod"))) {
+ medium->setBaseURL("ipod:/");
+ medium->setMountable(true);
+ medium->setMounted(!sdevice->mountPath().isEmpty());
}
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::Tape)) {
@@ -782,15 +807,6 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
}
- if (!medium->needMounting()) {
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)) {
- // Encrypted base devices must be set to this mimetype or they won't open when the base device node is passed to the tdeioslave
- mimeType = "media/removable_mounted";
- }
- }
- }
-
medium->setLabel(diskLabel);
medium->setMimeType(mimeType);
}
@@ -813,22 +829,38 @@ bool TDEBackend::setFloppyProperties(Medium* medium)
// Any more?
if ((sdevice->isDiskOfType(TDEDiskDeviceType::Zip)) || (sdevice->isDiskOfType(TDEDiskDeviceType::Jaz))) {
medium->setName(generateName(sdevice->deviceNode()));
- if ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) || (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) {
medium->setEncrypted(true);
+ medium->setLocked(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
}
else {
medium->setEncrypted(false);
}
- // USAGE: mountableState(Device node, Mount point, Filesystem type, Mounted ?)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ // Encrypted disks or device underlying other devices are not mountable
+ medium->setMountable(false);
+ }
+ else {
+ medium->setMountable(true);
+ }
+
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::Floppy)) {
setFloppyMountState(medium);
// We don't use the routine above as floppy disks are extremely slow (we don't want them accessed at all during media listing)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ medium->setMountable(true);
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
if (sdevice->mountPath().isNull()) {
medium->setMimeType("media/floppy_unmounted");
@@ -850,7 +882,7 @@ bool TDEBackend::setFloppyProperties(Medium* medium)
// Set label
TQString diskLabel = sdevice->diskLabel();
if (diskLabel.isNull()) {
- diskLabel = i18n("%1 Zip Disk").arg(sdevice->deviceFriendlySize());
+ diskLabel = i18n("%1 Zip Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
medium->setLabel(diskLabel);
}
@@ -885,7 +917,8 @@ void TDEBackend::setCameraProperties(Medium* medium)
device.sprintf("camera://@[usb:%s,%s]/", devNode0.ascii(), devNode1.ascii());
}
- medium->unmountableState(device);
+ medium->setMountable(false);
+ medium->setBaseURL(device);
medium->setMimeType("media/gphoto2camera");
medium->setIconName(TQString::null);
@@ -909,7 +942,11 @@ void TDEBackend::setFloppyMountState( Medium *medium )
if ((*it)->mountedFrom() == medium->deviceNode() ) {
fstype = (*it)->mountType().isNull() ? (*it)->mountType() : "auto";
mountpoint = (*it)->mountPoint();
- medium->mountableState( medium->deviceNode(), mountpoint, fstype, true );
+ medium->setMountable(true);
+ medium->setDeviceNode(medium->deviceNode());
+ medium->setMountPoint(mountpoint);
+ medium->setFsType(fstype);
+ medium->setMounted(true);
return;
}
}
@@ -997,7 +1034,7 @@ TQStringList TDEBackend::mountoptions(const TQString &name)
bool removable = false;
if (!drive_udi.isNull()) {
- removable = ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) || (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)));
+ removable = sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable);
}
TQString tmp;
@@ -1173,23 +1210,19 @@ bool TDEBackend::setMountoptions(const TQString &name, const TQStringList &optio
return true;
}
-void TDEBackend::slotPasswordReady() {
- m_decryptionPassword = m_unlockDialog->getPassword();
- m_decryptPasswordValid = true;
-}
-
-void TDEBackend::slotPasswordCancel() {
- m_decryptionPassword = TQString::null;
- m_decryptPasswordValid = true;
-}
-
TQStringVariantMap TDEBackend::mount(const Medium *medium)
{
kdDebug(1219) << "TDEBackend::mount for medium " << medium->name() << endl;
TQStringVariantMap result;
- if (medium->isMounted()) {
- result["result"] = true;
+ if (!medium->isMountable()) {
+ result["errStr"] = i18n("%1 is not a mountable media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (medium->isMounted()) {
+ result["errStr"] = i18n("%1 is already mounted to %2.").arg(medium->deviceNode()).arg(medium->mountPoint());
+ result["result"] = false;
return result;
}
@@ -1201,7 +1234,7 @@ TQStringVariantMap TDEBackend::mount(const Medium *medium)
data.medium = medium;
TDEIO::Job *job = TDEIO::mount(false, 0, medium->deviceNode(), mountPoint);
- connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), TQ_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be mounted when the function
// completes. Thus block until the job completes.
@@ -1222,7 +1255,7 @@ TQStringVariantMap TDEBackend::mount(const Medium *medium)
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
- result["errStr"] = i18n("Internal error. Couldn't find medium.");
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
result["result"] = false;
return result;
}
@@ -1242,99 +1275,13 @@ TQStringVariantMap TDEBackend::mount(const Medium *medium)
}
TQString qerror;
- if (!medium->isEncrypted()) {
- // normal volume
- TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, valids);
- TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
- if (mountedPath.isEmpty()) {
- qerror = i18n("Unable to mount this device.");
- TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- }
- }
- else {
- TQString iconName = medium->iconName();
- if (iconName.isEmpty())
- {
- TQString mime = medium->mimeType();
- iconName = KMimeType::mimeType(mime)->icon(mime, false);
- }
-
- bool continue_trying_to_decrypt = true;
- while (continue_trying_to_decrypt == true) {
- m_decryptPasswordValid = false;
-
- m_unlockDialog = new Dialog(sdevice->deviceNode(), iconName);
- m_unlockDialog->show();
-
- connect(m_unlockDialog, TQT_SIGNAL (user1Clicked()), this, TQT_SLOT (slotPasswordReady()));
- connect(m_unlockDialog, TQT_SIGNAL (cancelClicked()), this, TQT_SLOT (slotPasswordCancel()));
- connect(this, TQT_SIGNAL (signalDecryptionPasswordError(TQString)), m_unlockDialog, TQT_SLOT (slotDialogError(TQString)));
-
- while (m_decryptPasswordValid == false) {
- tqApp->processEvents();
- }
-
- m_unlockDialog->setEnabled(false);
- tqApp->processEvents();
-
- if (m_decryptionPassword.isNull()) {
- delete m_unlockDialog;
- result["errStr"] = i18n("Decryption aborted");
- result["result"] = false;
- return result;
- }
- else {
- // Just for some added fun, if udev emits a medium change event, which I then forward, with mounted==0, it stops the MediaProtocol::listDir method dead in its tracks,
- // and therefore the media:/ tdeioslave won't refresh after the encrypted device mount
- // Therefore, I need to ignore all change events on this device during the mount process and hope nothing bad happens as a result!
- if (!m_ignoreDeviceChangeEvents.contains(sdevice->uniqueID())) {
- m_ignoreDeviceChangeEvents.append(sdevice->uniqueID());
- }
-
- // mount encrypted volume with password
- TQStringVariantMap mountResult = sdevice->mountEncryptedDevice(m_decryptionPassword, diskLabel, valids);
- TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
- if (mountedPath.isEmpty()) {
- if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 0) {
- // Mounting was successful
- // Because the TDE hardware backend is event driven it might take a little while for the new enlock mapped device to show up
- // Wait up to 30 seconds for it to appear...
- for (int i=0;i<300;i++) {
- mountedPath = sdevice->mountPath();
- if (!mountedPath.isEmpty()) {
- break;
- }
- tqApp->processEvents(50);
- usleep(50000);
- }
- }
- }
- if (mountedPath.isEmpty()) {
- if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 25600) {
- // Probable LUKS failure
- // Retry
- m_unlockDialog->setEnabled(true);
- continue_trying_to_decrypt = true;
- }
- else {
- qerror = i18n("Cannot mount encrypted locked drives!");
- qerror = i18n("Unable to mount this device.");
- TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- continue_trying_to_decrypt = false;
- }
- }
- else {
- continue_trying_to_decrypt = false;
- }
-
- delete m_unlockDialog;
- }
+ TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, valids);
+ TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
+ if (mountedPath.isEmpty()) {
+ qerror = i18n("<b>Unable to mount this device.</b>");
+ TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty()) {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
}
}
@@ -1373,16 +1320,20 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
kdDebug(1219) << "TDEBackend::unmount for id " << id << endl;
TQStringVariantMap result;
-
- const Medium* medium = m_mediaList.findById(id);
+ const Medium *medium = m_mediaList.findById(id);
if (!medium) {
result["errStr"] = i18n("No such medium: %1").arg(id);
result["result"] = false;
return result;
}
-
- if (!medium->isMounted()) {
- result["result"] = true;
+ else if (!medium->isMountable()) {
+ result["errStr"] = i18n("%1 is not a mountable media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->isMounted()) {
+ result["errStr"] = i18n("%1 is already unmounted.").arg(medium->deviceNode());
+ result["result"] = false;
return result;
}
@@ -1394,7 +1345,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
data.medium = medium;
TDEIO::Job *job = TDEIO::unmount( medium->mountPoint(), false );
- connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), TQ_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be unmounted when the function
// completes. Thus block until the job completes.
@@ -1415,7 +1366,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
- result["errStr"] = i18n("Internal error. Couldn't find medium.");
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
result["result"] = false;
return result;
}
@@ -1428,7 +1379,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
TQStringVariantMap unmountResult = sdevice->unmountDevice();
if (unmountResult["result"].toBool() == false) {
// Unmount failed!
- qerror = i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
+ qerror = i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
"<b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(),
medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
@@ -1441,7 +1392,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
// Failed as BUSY
TQString processesUsingDev = listUsingProcesses(medium);
if (!processesUsingDev.isNull()) {
- if (KMessageBox::warningYesNo(0, i18n("<qt>The device <b>%1</b> (%2) named <b>'%3'</b> and currently "
+ if (KMessageBox::warningYesNo(0, i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and currently "
"mounted at <b>%4</b> can not be unmounted at this time.<p>%5<p><b>Would you like to forcibly "
"terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg("system:/media/" +
medium->name()).arg(medium->deviceNode()).arg(medium->prettyLabel()).arg(medium->prettyBaseURL().pathOrURL())
@@ -1450,7 +1401,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
unmountResult = sdevice->unmountDevice();
if (unmountResult["result"].toBool() == false) {
// Unmount failed!
- qerror = i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
+ qerror = i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
"<b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(),
medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
@@ -1476,10 +1427,225 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
m_mediaList.removeMedium(uid, true);
}
+ ResetProperties(sdevice, false, true);
+ result["result"] = true;
+ return result;
+}
+
+TQStringVariantMap TDEBackend::unlock(const TQString &id, const TQString &password)
+{
+ kdDebug(1219) << "TDEBackend::unlock for id " << id << endl;
+
+ TQStringVariantMap result;
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->isEncrypted()) {
+ result["errStr"] = i18n("%1 is not an encrypted media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->needUnlocking()) {
+ result["errStr"] = i18n("%1 is already unlocked.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice) {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ TQStringVariantMap unlockResult = sdevice->unlockDevice(password);
+ if (unlockResult["result"].toBool() == false) {
+ TQString qerror = i18n("<b>Unable to unlock the device.</b>");
+ TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty()) {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ ResetProperties(sdevice, false, true);
+ result["result"] = true;
+ return result;
+}
+
+TQStringVariantMap TDEBackend::lock(const TQString &id, bool releaseHolders)
+{
+ kdDebug(1219) << "TDEBackend::lock for id " << id << ", release holders "
+ << releaseHolders << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->isEncrypted()) {
+ result["errStr"] = i18n("%1 is not an encrypted media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (medium->needUnlocking()) {
+ result["errStr"] = i18n("%1 is already locked.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice) {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ // Release device holders if requested
+ if (releaseHolders)
+ {
+ releaseHolderDevices(medium->deviceNode(), false);
+ }
+
+ TQStringVariantMap lockResult = sdevice->lockDevice();
+ if (lockResult["result"].toBool() == false) {
+ TQString qerror = i18n("<b>Unable to lock the device.</b>");
+ TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty()) {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ ResetProperties(sdevice, false, true);
result["result"] = true;
return result;
}
+TQStringVariantMap TDEBackend::eject(const TQString &id)
+{
+ kdDebug(1219) << "TDEBackend::eject for id " << id << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium)
+ {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice)
+ {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ TQStringVariantMap ejectResult = sdevice->ejectDrive();
+ if (ejectResult["result"].toBool() == false)
+ {
+ TQString qerror = i18n("<b>Unable to eject the device.</b>");
+ TQString errStr = ejectResult.contains("errStr") ? ejectResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty())
+ {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ result["result"] = true;
+ return result;
+}
+
+TQStringVariantMap TDEBackend::safeRemove(const TQString &id)
+{
+ kdDebug(1219) << "TDEBackend::safeRemove for id " << id << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium)
+ {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+
+ releaseHolderDevices(medium->deviceNode(), true);
+ return eject(id);
+}
+
+void TDEBackend::releaseHolderDevices(const TQString &deviceNode, bool handleThis)
+{
+ kdDebug(1219) << "TDEBackend::releaseHolderDevices for node " << deviceNode
+ << ", handle this " << (handleThis ? "yes" : "no") << endl;
+
+ const Medium *medium = m_mediaList.findByNode(deviceNode);
+ if (!medium)
+ {
+ return;
+ }
+
+ // Scan the holding devices and unmount/lock them if possible
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (sdevice)
+ {
+ TQStringList holdingDeviceList = sdevice->holdingDevices();
+ for (TQStringList::Iterator holdingDevIt = holdingDeviceList.begin(); holdingDevIt != holdingDeviceList.end(); ++holdingDevIt)
+ {
+ TDEGenericDevice *hwHolderDevice = hwdevices->findBySystemPath(*holdingDevIt);
+ if (hwHolderDevice->type() == TDEGenericDeviceType::Disk)
+ {
+ TDEStorageDevice *holderSDevice = static_cast<TDEStorageDevice*>(hwHolderDevice);
+ const Medium *holderMedium = m_mediaList.findByNode(holderSDevice->deviceNode());
+ if (holderMedium && !holderMedium->id().isEmpty())
+ {
+ releaseHolderDevices(holderMedium->deviceNode(), true);
+ }
+ }
+ }
+ }
+
+ if (handleThis)
+ {
+ // Unmount if necessary
+ if (medium->isMountable() && medium->isMounted())
+ {
+ unmount(medium->id());
+ // Must process udev events before continuing, to make sure all
+ // affected devices are properly updated
+ tqApp->processEvents();
+ }
+ // Lock if necessary.
+ if (medium->isEncrypted() && !medium->isLocked())
+ {
+ lock(medium->id(), false);
+ // Must process udev events before continuing, to make sure all
+ // affected devices are properly updated
+ tqApp->processEvents();
+ }
+ }
+}
+
void TDEBackend::slotResult(TDEIO::Job *job)
{
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
@@ -1491,8 +1657,7 @@ void TDEBackend::slotResult(TDEIO::Job *job)
if (job->error() == TDEIO::ERR_COULD_NOT_UNMOUNT) {
TQString proclist(listUsingProcesses(medium));
- qerror = "<qt>";
- qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
+ qerror += "<p>" + i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and "
"currently mounted at <b>%4</b> could not be unmounted. ").arg(
"system:/media/" + medium->name(),
medium->deviceNode(),
@@ -1504,7 +1669,6 @@ void TDEBackend::slotResult(TDEIO::Job *job)
if (!proclist.isEmpty()) {
qerror += proclist;
}
- qerror += "</qt>";
} else if (job->error()) {
qerror = job->errorText();
}
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.h b/tdeioslave/media/mediamanager/tdehardwarebackend.h
index 5c6ce1260..0c3f84410 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.h
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.h
@@ -44,7 +44,7 @@ class Dialog;
class TDEBackend : public TQObject, public BackendBase
{
-Q_OBJECT
+TQ_OBJECT
public:
/**
@@ -68,11 +68,13 @@ public:
bool setMountoptions(const TQString &id, const TQStringList &options);
- TQStringVariantMap mount(const TQString &id);
TQStringVariantMap mount(const Medium *medium);
+ TQStringVariantMap mount(const TQString &id);
TQStringVariantMap unmount(const TQString &id);
-// TQStringVariantMap unlock(const TQString &id, const TQString &password);
-// TQStringVariantMap lock(const TQString &id);
+ TQStringVariantMap unlock(const TQString &id, const TQString &password);
+ TQStringVariantMap lock(const TQString &id, bool releaseHolders);
+ TQStringVariantMap eject(const TQString &id);
+ TQStringVariantMap safeRemove(const TQString &uid);
private:
/**
@@ -103,9 +105,6 @@ private slots:
void RemoveDeviceHandler(TDEGenericDevice* device);
void ModifyDeviceHandler(TDEGenericDevice* device);
- void slotPasswordReady();
- void slotPasswordCancel();
-
signals:
void signalDecryptionPasswordError(TQString);
@@ -120,28 +119,19 @@ private:
*/
void ResetProperties(TDEStorageDevice * sdevice, bool allowNotification=false, bool overrideIgnoreList=false);
- /**
- * Find the medium that is concerned with device udi
- */
-// const char* findMediumUdiFromUdi(const char* udi);
-
void setVolumeProperties(Medium* medium);
bool setFloppyProperties(Medium* medium);
- void setFloppyMountState( Medium* medium );
-// bool setFstabProperties(Medium* medium);
+ void setFloppyMountState(Medium* medium);
void setCameraProperties(Medium* medium);
+ void releaseHolderDevices(const TQString &deviceNode, bool handleThis);
TQString generateName(const TQString &devNode);
+
static TQString isInFstab(const Medium *medium);
static TQString listUsingProcesses(const Medium *medium);
static TQString killUsingProcesses(const Medium *medium);
TQString driveUDIFromDeviceUID(TQString uuid);
- // Decryption
- Dialog* m_unlockDialog;
- TQString m_decryptionPassword;
- bool m_decryptPasswordValid;
-
private slots:
void slotResult(TDEIO::Job *job);
diff --git a/tdeioslave/media/medianotifier/CMakeLists.txt b/tdeioslave/media/medianotifier/CMakeLists.txt
index ff2a8d802..215ee6de3 100644
--- a/tdeioslave/media/medianotifier/CMakeLists.txt
+++ b/tdeioslave/media/medianotifier/CMakeLists.txt
@@ -14,6 +14,7 @@ include_directories(
${CMAKE_BINARY_DIR}/tdeioslave/media/libmediacommon
${CMAKE_SOURCE_DIR}/tdeioslave/media/libmediacommon
${CMAKE_SOURCE_DIR}/tdmlib
+ ${CMAKE_BINARY_DIR}
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
)
diff --git a/tdeioslave/media/medianotifier/medianotifier.cpp b/tdeioslave/media/medianotifier/medianotifier.cpp
index 069e205de..2510019f2 100644
--- a/tdeioslave/media/medianotifier/medianotifier.cpp
+++ b/tdeioslave/media/medianotifier/medianotifier.cpp
@@ -19,14 +19,18 @@
#include "medianotifier.h"
-#if defined (__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined (__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)\
+ || defined(Q_OS_SOLARIS)
+#ifdef Q_OS_SOLARIS
+#include <sys/types.h>
+#endif /* Q_OS_SOLARIS */
#include <sys/statvfs.h>
#include <sys/param.h>
#include <sys/mount.h>
#else
#include <sys/vfs.h>
#endif
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(Q_OS_SOLARIS)
#define statfs statvfs
#endif
@@ -65,7 +69,7 @@ MediaNotifier::MediaNotifier(const TQCString &name) : KDEDModule(name)
m_notificationDialogList.setAutoDelete(FALSE);
m_freeTimer = new TQTimer( this );
- connect( m_freeTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( checkFreeDiskSpace() ) );
+ connect( m_freeTimer, TQ_SIGNAL( timeout() ), TQ_SLOT( checkFreeDiskSpace() ) );
m_freeTimer->start( 1000*6*2 /* 20 minutes */ );
m_freeDialog = 0;
}
@@ -119,8 +123,8 @@ void MediaNotifier::onMediumChange( const TQString &name, bool allowNotification
m_allowNotificationMap[job] = allowNotification;
- connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ),
- this, TQT_SLOT( slotStatResult( TDEIO::Job * ) ) );
+ connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ),
+ this, TQ_SLOT( slotStatResult( TDEIO::Job * ) ) );
}
void MediaNotifier::slotStatResult( TDEIO::Job *job )
@@ -343,7 +347,7 @@ void MediaNotifier::notify( KFileItem &medium )
if ( actions.size()>1 )
{
NotificationDialog* notifier = new NotificationDialog( medium, settings );
- connect(notifier, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(notificationDialogDestroyed(TQObject*)));
+ connect(notifier, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(notificationDialogDestroyed(TQObject*)));
m_notificationDialogList.append(notifier);
notifier->show();
}
@@ -403,8 +407,8 @@ void MediaNotifier::checkFreeDiskSpace()
i18n("Do not ask again"),
&checkboxResult, KMessageBox::Notify | KMessageBox::NoExec);
m_freeDialog->show();
- connect( m_freeDialog, TQT_SIGNAL( yesClicked() ), TQT_SLOT( slotFreeContinue() ) );
- connect( m_freeDialog, TQT_SIGNAL( noClicked() ), TQT_SLOT( slotFreeCancel() ) );
+ connect( m_freeDialog, TQ_SIGNAL( yesClicked() ), TQ_SLOT( slotFreeContinue() ) );
+ connect( m_freeDialog, TQ_SIGNAL( noClicked() ), TQ_SLOT( slotFreeCancel() ) );
}
}
}
@@ -421,7 +425,7 @@ void MediaNotifier::slotFreeCancel()
void MediaNotifier::slotFreeFinished( KMessageBox::ButtonCode res )
{
- TQCheckBox *checkbox = ::tqqt_cast<TQCheckBox*>( m_freeDialog->child( 0, TQCHECKBOX_OBJECT_NAME_STRING ) );
+ TQCheckBox *checkbox = ::tqt_cast<TQCheckBox*>( m_freeDialog->child( 0, "TQCheckBox" ) );
if ( checkbox && checkbox->isChecked() )
KMessageBox::saveDontShowAgainYesNo("dontagainfreespace", res);
m_freeDialog->delayedDestruct();
diff --git a/tdeioslave/media/medianotifier/medianotifier.h b/tdeioslave/media/medianotifier/medianotifier.h
index 84eee525c..c45db66c1 100644
--- a/tdeioslave/media/medianotifier/medianotifier.h
+++ b/tdeioslave/media/medianotifier/medianotifier.h
@@ -34,7 +34,7 @@ typedef TQPtrList<NotificationDialog> NotificationDialogList;
class MediaNotifier: public KDEDModule
{
- Q_OBJECT
+ TQ_OBJECT
K_DCOP
public:
diff --git a/tdeioslave/media/medianotifier/notificationdialog.cpp b/tdeioslave/media/medianotifier/notificationdialog.cpp
index 7e4004e8c..a8bb81ea5 100644
--- a/tdeioslave/media/medianotifier/notificationdialog.cpp
+++ b/tdeioslave/media/medianotifier/notificationdialog.cpp
@@ -17,6 +17,10 @@
Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "notificationdialog.h"
#include <tqlayout.h>
@@ -28,7 +32,7 @@
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqpushbutton.h>
-#ifdef __TDE_HAVE_TDEHWLIB
+#ifdef WITH_TDEHWLIB
#include <tdehardwaredevices.h>
#endif
@@ -40,7 +44,7 @@ NotificationDialog::NotificationDialog( KFileItem medium, NotifierSettings *sett
: KDialogBase( parent, name, false, i18n( "Medium Detected" ), Ok|Cancel|User1, Ok, true),
m_medium(medium), m_settings( settings )
{
- setCaption( TDEIO::decodeFileName(m_medium.name()) );
+ setCaption( m_medium.text() );
clearWState( WState_Polished );
TQWidget *page = new TQWidget( this );
@@ -50,13 +54,14 @@ NotificationDialog::NotificationDialog( KFileItem medium, NotifierSettings *sett
m_view = new NotificationDialogView( page );
topLayout->addWidget(m_view);
- m_view->iconLabel->setPixmap( m_medium.pixmap(64) );
- m_view->mimetypeLabel->setText( i18n( "<b>Medium type:</b>" ) + " "
- + m_medium.mimeTypePtr()->comment() );
+ m_view->iconLabel->setPixmap(m_medium.pixmap(64));
+ m_view->mimetypeLabel->setText(i18n("<b>Name:</b>") + "&#9;" + m_medium.text() + "<br/>" +
+ i18n("<b>Type:</b>") + "&#9;" + m_medium.mimeTypePtr()->comment() + "<br/>" +
+ i18n("<b>Url:</b>") + "&#9;" + m_medium.url().prettyURL());
updateActionsListBox();
- resize( TQSize(400,400).expandedTo( minimumSizeHint() ) );
+ resize( TQSize(500,500).expandedTo( minimumSizeHint() ) );
m_actionWatcher = new KDirWatch();
@@ -66,17 +71,17 @@ NotificationDialog::NotificationDialog( KFileItem medium, NotifierSettings *sett
setButtonText( User1, i18n("Configure...") );
- connect( m_actionWatcher, TQT_SIGNAL( dirty( const TQString & ) ),
- this, TQT_SLOT( slotActionsChanged( const TQString & ) ) );
- connect( this , TQT_SIGNAL( okClicked() ),
- this, TQT_SLOT( slotOk() ) );
- connect( this, TQT_SIGNAL( user1Clicked() ),
- this, TQT_SLOT( slotConfigure() ) );
- connect( m_view->actionsList, TQT_SIGNAL( doubleClicked ( TQListBoxItem*, const TQPoint & ) ),
- this, TQT_SLOT( slotOk() ) );
-
- connect( this, TQT_SIGNAL( finished() ),
- this, TQT_SLOT( delayedDestruct() ) );
+ connect( m_actionWatcher, TQ_SIGNAL( dirty( const TQString & ) ),
+ this, TQ_SLOT( slotActionsChanged( const TQString & ) ) );
+ connect( this , TQ_SIGNAL( okClicked() ),
+ this, TQ_SLOT( slotOk() ) );
+ connect( this, TQ_SIGNAL( user1Clicked() ),
+ this, TQ_SLOT( slotConfigure() ) );
+ connect( m_view->actionsList, TQ_SIGNAL( doubleClicked ( TQListBoxItem*, const TQPoint & ) ),
+ this, TQ_SLOT( slotOk() ) );
+
+ connect( this, TQ_SIGNAL( finished() ),
+ this, TQ_SLOT( delayedDestruct() ) );
m_actionWatcher->startScan();
TQPushButton * btn = actionButton( Ok );
diff --git a/tdeioslave/media/medianotifier/notificationdialog.h b/tdeioslave/media/medianotifier/notificationdialog.h
index 16bedb842..9f1f8057f 100644
--- a/tdeioslave/media/medianotifier/notificationdialog.h
+++ b/tdeioslave/media/medianotifier/notificationdialog.h
@@ -31,7 +31,7 @@
class NotificationDialog : public KDialogBase
{
- Q_OBJECT
+ TQ_OBJECT
public:
NotificationDialog( KFileItem medium, NotifierSettings *settings,
diff --git a/tdeioslave/media/mimetypes/cd-r_encrypted_locked.desktop b/tdeioslave/media/mimetypes/cd-r_encrypted_locked.desktop
index f4f288d10..50a23de70 100644
--- a/tdeioslave/media/mimetypes/cd-r_encrypted_locked.desktop
+++ b/tdeioslave/media/mimetypes/cd-r_encrypted_locked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Locked CD-R
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/cd-r_encrypted_unlocked.desktop b/tdeioslave/media/mimetypes/cd-r_encrypted_unlocked.desktop
index 4826eddfa..c410a4e43 100644
--- a/tdeioslave/media/mimetypes/cd-r_encrypted_unlocked.desktop
+++ b/tdeioslave/media/mimetypes/cd-r_encrypted_unlocked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Unlocked CD-R
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/cd-rw_encrypted_locked.desktop b/tdeioslave/media/mimetypes/cd-rw_encrypted_locked.desktop
index b5d3cabf0..5edac87e4 100644
--- a/tdeioslave/media/mimetypes/cd-rw_encrypted_locked.desktop
+++ b/tdeioslave/media/mimetypes/cd-rw_encrypted_locked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Locked CD-RW
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/cd-rw_encrypted_unlocked.desktop b/tdeioslave/media/mimetypes/cd-rw_encrypted_unlocked.desktop
index c64bb19f8..6dd0de842 100644
--- a/tdeioslave/media/mimetypes/cd-rw_encrypted_unlocked.desktop
+++ b/tdeioslave/media/mimetypes/cd-rw_encrypted_unlocked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Unlocked CD-RW
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/cdrom_encrypted_locked.desktop b/tdeioslave/media/mimetypes/cdrom_encrypted_locked.desktop
index e5b7e80c9..6dc794dff 100644
--- a/tdeioslave/media/mimetypes/cdrom_encrypted_locked.desktop
+++ b/tdeioslave/media/mimetypes/cdrom_encrypted_locked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Locked CD-ROM
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/cdrom_encrypted_unlocked.desktop b/tdeioslave/media/mimetypes/cdrom_encrypted_unlocked.desktop
index 4731ffe4e..011228a88 100644
--- a/tdeioslave/media/mimetypes/cdrom_encrypted_unlocked.desktop
+++ b/tdeioslave/media/mimetypes/cdrom_encrypted_unlocked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Unlocked CD-ROM
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/dvd_encrypted_locked.desktop b/tdeioslave/media/mimetypes/dvd_encrypted_locked.desktop
index 0450a29ed..d4e3b25bd 100644
--- a/tdeioslave/media/mimetypes/dvd_encrypted_locked.desktop
+++ b/tdeioslave/media/mimetypes/dvd_encrypted_locked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Locked DVD
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/dvd_encrypted_unlocked.desktop b/tdeioslave/media/mimetypes/dvd_encrypted_unlocked.desktop
index 16e0a86a8..a4a66904a 100644
--- a/tdeioslave/media/mimetypes/dvd_encrypted_unlocked.desktop
+++ b/tdeioslave/media/mimetypes/dvd_encrypted_unlocked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Unlocked DVD
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/hdd_encrypted_locked.desktop b/tdeioslave/media/mimetypes/hdd_encrypted_locked.desktop
index 7de6c35cb..d4cc6d261 100644
--- a/tdeioslave/media/mimetypes/hdd_encrypted_locked.desktop
+++ b/tdeioslave/media/mimetypes/hdd_encrypted_locked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Locked Hard Disk Volume
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/hdd_encrypted_unlocked.desktop b/tdeioslave/media/mimetypes/hdd_encrypted_unlocked.desktop
index 9e944ef58..7c91927aa 100644
--- a/tdeioslave/media/mimetypes/hdd_encrypted_unlocked.desktop
+++ b/tdeioslave/media/mimetypes/hdd_encrypted_unlocked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Unlocked Hard Disk Volume
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/removable_encrypted_locked.desktop b/tdeioslave/media/mimetypes/removable_encrypted_locked.desktop
index 66671c168..d97745e12 100644
--- a/tdeioslave/media/mimetypes/removable_encrypted_locked.desktop
+++ b/tdeioslave/media/mimetypes/removable_encrypted_locked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Locked Removable Medium
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mimetypes/removable_encrypted_unlocked.desktop b/tdeioslave/media/mimetypes/removable_encrypted_unlocked.desktop
index 94e81353b..fd98df9c0 100644
--- a/tdeioslave/media/mimetypes/removable_encrypted_unlocked.desktop
+++ b/tdeioslave/media/mimetypes/removable_encrypted_unlocked.desktop
@@ -9,4 +9,3 @@ Comment=Encrypted Unlocked Removable Medium
Patterns=
X-TDE-AutoEmbed=true
-X-TDE-IsAlso=inode/directory
diff --git a/tdeioslave/media/mounthelper/CMakeLists.txt b/tdeioslave/media/mounthelper/CMakeLists.txt
index 90afad33f..cf7ca553f 100644
--- a/tdeioslave/media/mounthelper/CMakeLists.txt
+++ b/tdeioslave/media/mounthelper/CMakeLists.txt
@@ -12,6 +12,7 @@
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/tdeioslave/media/libmediacommon
+ ${CMAKE_BINARY_DIR}
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
)
@@ -31,6 +32,6 @@ set( ${target}_SRCS
tde_add_executable( ${target} AUTOMOC
SOURCES ${${target}_SRCS}
- LINK mediacommon-static tdeio-shared
+ LINK mediacommon-static tdeio-shared ${TDEHW_LIBRARIES}
DESTINATION ${BIN_INSTALL_DIR}
)
diff --git a/tdeioslave/media/mounthelper/dialog.cpp b/tdeioslave/media/mounthelper/dialog.cpp
index f2cdb6b53..a257ca6d8 100644
--- a/tdeioslave/media/mounthelper/dialog.cpp
+++ b/tdeioslave/media/mounthelper/dialog.cpp
@@ -23,11 +23,10 @@
#include "dialog.h"
Dialog::Dialog(TQString url, TQString iconName) :
- KDialogBase(NULL, "Dialog", true, "Unlock Storage Device", (Cancel|User1), User1, false, KGuiItem(i18n("Unlock"), "unlocked" ))
+ KDialogBase(NULL, "Dialog", true, i18n("Unlock Storage Device"), (Cancel|User1), User1, false, KGuiItem(i18n("Unlock"), "unlocked" ))
{
unlockDialog = new UnlockDialog(this);
- unlockDialog->errorBox->hide();
unlockDialog->descLabel->setText(unlockDialog->descLabel->text().arg(url));
unlockDialog->descLabel->adjustSize();
unlockDialog->adjustSize();
@@ -37,7 +36,7 @@ Dialog::Dialog(TQString url, TQString iconName) :
TQPixmap pixmap = TDEGlobal::iconLoader()->loadIcon(iconName, TDEIcon::NoGroup, TDEIcon::SizeLarge);
unlockDialog->encryptedIcon->setPixmap( pixmap );
- connect(unlockDialog->passwordEdit, TQT_SIGNAL (textChanged(const TQString &)), this, TQT_SLOT (slotPasswordChanged(const TQString &)));
+ connect(unlockDialog->passwordEdit, TQ_SIGNAL (textChanged(const TQString &)), this, TQ_SLOT (slotPasswordChanged(const TQString &)));
setMainWidget(unlockDialog);
}
@@ -52,14 +51,6 @@ TQString Dialog::getPassword()
return unlockDialog->passwordEdit->text();
}
-void Dialog::slotDialogError(TQString errorMsg)
-{
- kdDebug() << __func__ << "(" << errorMsg << " )" << endl;
-
- unlockDialog->errorLabel->setText(TQString("<b>%1</b>").arg(errorMsg));
- unlockDialog->errorBox->show();
-}
-
void Dialog::slotPasswordChanged(const TQString &text)
{
enableButton( User1, !text.isEmpty() );
diff --git a/tdeioslave/media/mounthelper/dialog.h b/tdeioslave/media/mounthelper/dialog.h
index 8444ec7dd..d2b2925a9 100644
--- a/tdeioslave/media/mounthelper/dialog.h
+++ b/tdeioslave/media/mounthelper/dialog.h
@@ -36,12 +36,10 @@
#include "unlockdialog.h"
-class KryptoMedia;
-
class Dialog : public KDialogBase
{
-Q_OBJECT
+TQ_OBJECT
public:
Dialog(TQString url, TQString iconName);
@@ -50,7 +48,6 @@ public:
TQString getPassword();
public slots:
- void slotDialogError(TQString errorMsg);
void slotPasswordChanged(const TQString &text);
private:
diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
index 65b53a0f4..90f3caa3f 100644
--- a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
+++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
@@ -19,6 +19,10 @@
Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <tdecmdlineargs.h>
#include <tdelocale.h>
#include <tdeapplication.h>
@@ -33,223 +37,238 @@
#include <kprocess.h>
#include <tdestartupinfo.h>
#include <kmimetype.h>
-#ifdef __TDE_HAVE_TDEHWLIB
+#ifdef WITH_TDEHWLIB
#include <tdehardwaredevices.h>
#endif
#include "dialog.h"
#include "tdeio_media_mounthelper.h"
-const Medium MountHelper::findMedium(const KURL &url)
+const Medium MountHelper::findMedium(const TQString &device)
{
DCOPRef mediamanager("kded", "mediamanager");
-
- // Try filename first
- DCOPReply reply = mediamanager.call( "properties", url.fileName() );
- if ( !reply.isValid() ) {
- m_errorStr = i18n("The TDE mediamanager is not running.")+"\n";
+ DCOPReply reply = mediamanager.call("properties", device);
+ if (!reply.isValid())
+ {
+ m_errorStr = i18n("The TDE mediamanager is not running.\n");
return Medium(TQString::null, TQString::null, TQString::null);
}
- const Medium& medium = Medium::create(reply);
- if ( medium.id().isEmpty() ) {
- // Try full URL now
- reply = mediamanager.call( "properties", url.prettyURL() );
- if ( !reply.isValid() ) {
- m_errorStr = i18n("Internal Error");
- return Medium(TQString::null, TQString::null, TQString::null);
- }
- return Medium::create(reply);
- } else {
- return medium;
- }
+ const Medium &medium = Medium::create(reply);
+ return medium;
}
-MountHelper::MountHelper() : TDEApplication()
+void MountHelper::mount(const Medium &medium)
{
- TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ DCOPRef mediamanager("kded", "mediamanager");
+ DCOPReply reply = mediamanager.call("mount", medium.id());
+ TQStringVariantMap mountResult;
+ if (reply.isValid()) {
+ reply.get(mountResult);
+ }
+ if (!mountResult.contains("result") || !mountResult["result"].toBool()) {
+ m_errorStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
+ errorAndExit();
+ }
+}
- m_errorStr = TQString::null;
+void MountHelper::unmount(const Medium &medium)
+{
+ DCOPRef mediamanager("kded", "mediamanager");
+ DCOPReply reply = mediamanager.call("unmount", medium.id());
+ TQStringVariantMap unmountResult;
+ if (reply.isValid()) {
+ reply.get(unmountResult);
+ }
+ if (!unmountResult.contains("result") || !unmountResult["result"].toBool()) {
+ m_errorStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unknown unmount error.");
+ kdDebug() << "medium unmount " << m_errorStr << endl;
+ errorAndExit();
+ }
+}
- KURL url(args->url(0));
- const Medium medium = findMedium(url);
+void MountHelper::unlock(const Medium &medium)
+{
+ TQString device = medium.deviceNode();
+ if (device.isEmpty()) {
+ m_errorStr = i18n("Try to unlock an unknown medium.");
+ errorAndExit();
+ }
- if (medium.id().isEmpty())
+ TQString iconName = medium.iconName();
+ if (iconName.isEmpty())
{
- if (m_errorStr.isEmpty()) {
- m_errorStr+= i18n("%1 cannot be found.").arg(url.prettyURL());
- }
- TQTimer::singleShot(0, this, TQT_SLOT(error()) );
- return;
+ TQString mime = medium.mimeType();
+ iconName = KMimeType::mimeType(mime)->icon(mime, false);
}
+ m_mediumId = medium.id();
+ m_dialog = new Dialog(device, iconName);
+ connect(m_dialog, TQ_SIGNAL(user1Clicked()), this, TQ_SLOT(slotSendPassword()));
+ connect(m_dialog, TQ_SIGNAL(cancelClicked()), this, TQ_SLOT(slotCancel()));
+ m_dialog->show();
+}
- if (!medium.isMountable() && !args->isSet("e") && !args->isSet("s"))
+void MountHelper::lock(const Medium &medium)
+{
+ DCOPRef mediamanager("kded", "mediamanager");
+ DCOPReply reply = mediamanager.call("lock", medium.id(), true);
+ TQStringVariantMap lockResult;
+ if (reply.isValid()) {
+ reply.get(lockResult);
+ }
+ if (!lockResult.contains("result") || !lockResult["result"].toBool()) {
+ m_errorStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : i18n("Unknown lock error.");
+ kdDebug() << "medium lock " << m_errorStr << endl;
+ errorAndExit();
+ }
+}
+
+void MountHelper::eject(const Medium &medium)
+{
+#ifdef WITH_TDEHWLIB
+ DCOPRef mediamanager("kded", "mediamanager");
+ DCOPReply reply = mediamanager.call("eject", medium.id());
+ TQStringVariantMap ejectResult;
+ if (reply.isValid()) {
+ reply.get(ejectResult);
+ }
+ if (!ejectResult.contains("result") || !ejectResult["result"].toBool()) {
+ m_errorStr = ejectResult.contains("errStr") ? ejectResult["errStr"].toString() : i18n("Unknown eject error.");
+ kdDebug() << "medium eject " << m_errorStr << endl;
+ errorAndExit();
+ }
+ else
{
- m_errorStr = i18n("%1 is not a mountable media.").arg(url.prettyURL());
- TQTimer::singleShot(0, this, TQT_SLOT(error()) );
- return;
+ ::exit(0); // Success!
}
+#endif
- TQString device = medium.deviceNode();
- TQString mount_point = medium.mountPoint();
+ // Otherwise fall back to tdeeject
+ TDEProcess *proc = new TDEProcess(this);
+ *proc << "tdeeject";
+ *proc << medium.deviceNode();
+ connect(proc, TQ_SIGNAL(processExited(TDEProcess*)), this, TQ_SLOT(ejectFinished(TDEProcess*)));
+ proc->start();
+}
+
+void MountHelper::safeRemoval(const Medium &medium)
+{
+ DCOPRef mediamanager("kded", "mediamanager");
+ DCOPReply reply = mediamanager.call("safeRemove", medium.id());
+ TQStringVariantMap safeRemoveResult;
+ if (reply.isValid()) {
+ reply.get(safeRemoveResult);
+ }
+ if (!safeRemoveResult.contains("result") || !safeRemoveResult["result"].toBool()) {
+ m_errorStr = safeRemoveResult.contains("errStr") ? safeRemoveResult["errStr"].toString() : i18n("Unknown safe removal error.");
+ kdDebug() << "medium safeRemoval " << m_errorStr << endl;
+ errorAndExit();
+ }
+}
- m_isCdrom = medium.mimeType().find("dvd") != -1 || medium.mimeType().find("cd") != -1;
+void MountHelper::openRealFolder(const Medium &medium)
+{
+ Medium &m = const_cast<Medium&>(medium);
+ if (!m.isMounted())
+ {
+ // If the medium is not mounted, try mounting it first
+ mount(m);
+ m = findMedium(m.deviceNode());
+ }
- if (args->isSet("d"))
+ if (m.isMounted())
{
- if (!medium.isEncrypted())
- {
- m_errorStr = i18n("%1 is not an encrypted media.").arg(url.prettyURL());
- TQTimer::singleShot(0, this, TQT_SLOT(error()) );
- return;
- }
- if (!medium.needDecryption())
- {
- m_errorStr = i18n("%1 is already unlocked.").arg(url.prettyURL());
- TQTimer::singleShot(0, this, TQT_SLOT(error()));
- return;
- }
+ system((TQString("kfmclient exec 'file://") + m.mountPoint()).local8Bit() + "'");
+ }
+ else
+ {
+ m_errorStr = i18n("Try to open an unknown medium.");
+ errorAndExit();
+ }
+}
- TQString iconName = medium.iconName();
- if (iconName.isEmpty())
- {
- TQString mime = medium.mimeType();
- iconName = KMimeType::mimeType(mime)->icon(mime, false);
+MountHelper::MountHelper() : TDEApplication()
+{
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ m_errorStr = TQString::null;
+
+ const Medium medium = findMedium(args->arg(0));
+ if (medium.id().isEmpty())
+ {
+ if (m_errorStr.isEmpty()) {
+ m_errorStr+= i18n("%1 cannot be found.").arg(args->arg(0));
}
+ errorAndExit();
+ }
- m_mediumId = medium.id();
- dialog = new Dialog(url.prettyURL(), iconName);
- dialog->show();
+ TQString device = medium.deviceNode();
+ if (!medium.isMountable() && !medium.isEncrypted() && !args->isSet("e") && !args->isSet("s"))
+ {
+ m_errorStr = i18n("%1 is not a mountable or encrypted media.").arg(device);
+ errorAndExit();
+ }
- connect(dialog, TQT_SIGNAL (user1Clicked()), this, TQT_SLOT (slotSendPassword()));
- connect(dialog, TQT_SIGNAL (cancelClicked()), this, TQT_SLOT (slotCancel()));
- connect(this, TQT_SIGNAL (signalPasswordError(TQString)), dialog, TQT_SLOT (slotDialogError(TQString)));
+ if (args->isSet("m"))
+ {
+ mount(medium);
+ ::exit(0);
}
else if (args->isSet("u"))
{
- DCOPRef mediamanager("kded", "mediamanager");
- DCOPReply reply = mediamanager.call("unmount", medium.id());
- TQStringVariantMap unmountResult;
- if (reply.isValid()) {
- reply.get(unmountResult);
- }
- if (unmountResult.contains("result") && unmountResult["result"].toBool()) {
- ::exit(0);
- }
- else {
- m_errorStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unknown unmount error.");
- kdDebug() << "medium unmount " << m_errorStr << endl;
- error();
- }
- }
- else if (args->isSet("s") || args->isSet("e"))
+ unmount(medium);
+ ::exit(0);
+ }
+ else if (args->isSet("k"))
{
- 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
- * failure. However, there are cases when unmount would fail
- * (supermount, slackware, see bug#116209) but eject would succeed.
- * Thus if unmount fails, save unmount error message and invokeEject()
- * anyway. Only if both unmount and eject fail, notify the user by
- * displaying the saved error message (see ejectFinished()).
- */
- TQStringVariantMap unmountResult;
- if (medium.isMounted())
- {
- DCOPReply reply = mediamanager.call( "unmount", medium.id());
- if (reply.isValid()) {
- reply.get(unmountResult);
- if (unmountResult["result"].toBool()) {
- reply.get(m_errorStr);
- }
- }
- }
-
- // If this is an unlocked encrypted volume and there is no error yet, we try to lock it
- if (unmountResult.contains("result") && unmountResult["result"].toBool() &&
- medium.isEncrypted() && !medium.clearDeviceUdi().isNull())
- {
- DCOPReply reply = mediamanager.call( "undecrypt", medium.id());
- if (reply.isValid()) {
- TQStringVariantMap undecryptResult;
- reply.get(undecryptResult);
- if (undecryptResult["result"].toBool()) {
- reply.get(m_errorStr);
- }
- }
- }
-
- if (m_errorStr.isNull()) {
- invokeEject(device, true);
- }
- else {
- error();
- }
+ unlock(medium);
+ // No call to ::exit() here because this will open up the password dialog
+ // ::exit() is handled in the invoked code.
+ }
+ else if (args->isSet("l"))
+ {
+ lock(medium);
+ ::exit(0);
+ }
+ else if (args->isSet("e"))
+ {
+ eject(medium);
+ ::exit(0);
+ }
+ else if (args->isSet("s"))
+ {
+ safeRemoval(medium);
+ ::exit(0);
+ }
+ else if (args->isSet("f"))
+ {
+ openRealFolder(medium);
+ ::exit(0);
}
else
{
- DCOPRef mediamanager("kded", "mediamanager");
- DCOPReply reply = mediamanager.call("mount", medium.id());
- TQStringVariantMap mountResult;
- if (reply.isValid()) {
- reply.get(mountResult);
- }
- if (mountResult.contains("result") && mountResult["result"].toBool()) {
- ::exit(0);
- }
- else {
- m_errorStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
- error();
- }
+ TDECmdLineArgs::usage();
+ ::exit(0);
}
}
-void MountHelper::invokeEject(const TQString &device, bool quiet)
+MountHelper::~MountHelper()
{
-#ifdef __TDE_HAVE_TDEHWLIB
- // Try TDE HW library eject first...
- TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- TDEGenericDevice *hwdevice = hwdevices->findByDeviceNode(device);
- if (hwdevice->type() == TDEGenericDeviceType::Disk) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- if (sdevice->ejectDrive()) {
- // Success!
- ::exit(0);
- }
- }
-#endif
-
- // Then fall back to tdeeject if needed
- TDEProcess *proc = new TDEProcess(TQT_TQOBJECT(this));
- *proc << "tdeeject";
- if (quiet)
+ if (m_dialog)
{
- *proc << "-q";
+ delete m_dialog;
}
- *proc << device;
- connect( proc, TQT_SIGNAL(processExited(TDEProcess *)),
- this, TQT_SLOT( ejectFinished(TDEProcess *) ) );
- proc->start();
}
-void MountHelper::ejectFinished(TDEProcess* proc)
+void MountHelper::ejectFinished(TDEProcess *proc)
{
- /*
- * If eject failed, report the error stored in m_errorStr
- */
+ //If eject failed, report the error stored in m_errorStr
if (proc->normalExit() && proc->exitStatus() == 0) {
::exit(0);
- } else {
- if (m_errorStr.isEmpty()) {
- if (m_isCdrom)
- m_errorStr = i18n("The device was successfully unmounted, but the tray could not be opened");
- else
- m_errorStr = i18n("The device was successfully unmounted, but could not be ejected");
+ }
+ else {
+ if (!m_errorStr.isEmpty()) {
+ errorAndExit();
}
-//X Comment this because the error is useless as long as the unmount is successful.
-//X TQTimer::singleShot(0, this, TQT_SLOT(error()));
- ::exit(0);
+ ::exit(0);
}
}
@@ -262,25 +281,28 @@ void MountHelper::error()
}
}
KMessageBox::error(0, prettyErrorString);
+}
+
+void MountHelper::errorAndExit()
+{
+ error();
::exit(1);
}
void MountHelper::slotSendPassword()
{
DCOPRef mediamanager("kded", "mediamanager");
-
- DCOPReply reply = mediamanager.call( "decrypt", m_mediumId, dialog->getPassword() );
- TQStringVariantMap decryptResult;
+ DCOPReply reply = mediamanager.call("unlock", m_mediumId, m_dialog->getPassword());
+ TQStringVariantMap unlockResult;
if (reply.isValid()) {
- reply.get(decryptResult);
+ reply.get(unlockResult);
}
- if (decryptResult.contains("result") && decryptResult["result"].toBool()) {
+ if (unlockResult.contains("result") && unlockResult["result"].toBool()) {
::exit(0);
}
else {
- m_errorStr = decryptResult.contains("errStr") ? decryptResult["errStr"].toString() : i18n("Unknown decrypt error.");
- kdDebug() << "medium decrypt " << m_errorStr << endl;
- emit signalPasswordError(m_errorStr);
+ m_errorStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : i18n("Unknown unlock error.");
+ kdDebug() << "medium unlock " << m_errorStr << endl;
error();
}
}
@@ -292,12 +314,14 @@ void MountHelper::slotCancel()
static TDECmdLineOptions options[] =
{
- { "d", I18N_NOOP("Decrypt given URL"), 0 },
+ { "m", I18N_NOOP("Mount 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 tdeeject"), 0},
- { "s", I18N_NOOP("Unmount and Eject given URL (necessary for some USB devices)"), 0},
- {"!+URL", I18N_NOOP("media:/ URL to mount/unmount/eject/remove"), 0 },
+ { "k", I18N_NOOP("Unlock given URL"), 0 },
+ { "l", I18N_NOOP("Lock given URL"), 0 },
+ { "e", I18N_NOOP("Eject given URL"), 0},
+ { "s", I18N_NOOP("Safely remove (unmount and eject) given URL"), 0},
+ { "f", I18N_NOOP("Open real medium folder"), 0},
+ {"!+URL", I18N_NOOP("media:/URL to mount/unmount/unlock/lock/eject/remove"), 0 },
TDECmdLineLastOption
};
@@ -308,13 +332,15 @@ int main(int argc, char **argv)
"tdeio_media_mounthelper", "tdeio_media_mounthelper",
"0.1");
- TDECmdLineArgs::addCmdLineOptions( options );
+ TDECmdLineArgs::addCmdLineOptions(options);
TDEGlobal::locale()->setMainCatalogue("tdeio_media");
TDEApplication::addCmdLineOptions();
+ if (TDECmdLineArgs::parsedArgs()->count()==0)
+ {
+ TDECmdLineArgs::usage();
+ }
- if (TDECmdLineArgs::parsedArgs()->count()==0) TDECmdLineArgs::usage();
- TDEApplication *app = new MountHelper();
-
+ TDEApplication *app = new MountHelper();
TDEStartupInfo::appStarted();
app->dcopClient()->attach();
return app->exec();
diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h
index 97df6b7e8..3cdf58488 100644
--- a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h
+++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h
@@ -1,5 +1,5 @@
/* This file is part of the KDE project
- Copyright (c) 2004 Kévin Ottens <ervin ipsquad net>
+ Copyright (c) 2004 Kévin Ottens <ervin ipsquad net>
Parts of this file are
Copyright 2003 Waldo Bastian <bastian@kde.org>
@@ -29,29 +29,37 @@
#include "medium.h"
class Dialog;
+class TDEProcess;
class MountHelper : public TDEApplication
{
- Q_OBJECT
+ TQ_OBJECT
+
public:
MountHelper();
+ ~MountHelper();
private:
- const Medium findMedium(const KURL &url);
- void invokeEject(const TQString &device, bool quiet=false);
TQString m_errorStr;
- bool m_isCdrom;
TQString m_mediumId;
- Dialog *dialog;
+ Dialog *m_dialog;
+
+ const Medium findMedium(const TQString &device);
+ void error();
+
+ void mount(const Medium &medium);
+ void unmount(const Medium &medium);
+ void unlock(const Medium &medium);
+ void lock(const Medium &medium);
+ void eject(const Medium &medium);
+ void safeRemoval(const Medium &medium);
+ void openRealFolder(const Medium &medium);
private slots:
void slotSendPassword();
void slotCancel();
void ejectFinished(TDEProcess* proc);
- void error();
-
-signals:
- void signalPasswordError(TQString errorMsg);
+ void errorAndExit();
};
#endif
diff --git a/tdeioslave/media/mounthelper/unlockdialog.ui b/tdeioslave/media/mounthelper/unlockdialog.ui
index 99a46a9ac..7b78cdb42 100644
--- a/tdeioslave/media/mounthelper/unlockdialog.ui
+++ b/tdeioslave/media/mounthelper/unlockdialog.ui
@@ -107,7 +107,7 @@
</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>
+&lt;p&gt;Please enter the password to unlock the storage device.&lt;/p&gt;</string>
</property>
<property name="alignment">
<set>WordBreak|AlignTop</set>
@@ -155,46 +155,6 @@
</widget>
</hbox>
</widget>
- <widget class="TQGroupBox" 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="TQLabel" 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"/>
diff --git a/tdeioslave/media/propsdlgplugin/media_propsdlgplugin.desktop b/tdeioslave/media/propsdlgplugin/media_propsdlgplugin.desktop
index bd5ece69c..8d460d565 100644
--- a/tdeioslave/media/propsdlgplugin/media_propsdlgplugin.desktop
+++ b/tdeioslave/media/propsdlgplugin/media_propsdlgplugin.desktop
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Service
X-TDE-Library=media_propsdlgplugin
-X-TDE-ServiceTypes=KPropsDlg/Plugin,media/audiocd,media/blankcd,media/blankbluray,media/blankdvd,media/hdd_mounted,media/hdd_unmounted,media/hdd_encrypted_unlocked,media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_unlocked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_unlocked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_unlocked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_unlocked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_unlocked,media/removable_mounted,media/removable_unmounted,media/removable_encrypted_unlocked,media/nfs_mounted,media/nfs_unmounted,media/smb_mounted,media/smb_unmounted,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd,media/floppy_mounted,media/floppy_unmounted,media/floppy5_mounted,media/floppy5_unmounted,media/zip_mounted,media/zip_unmounted,media/gphoto2camera,media/camera_mounted,media/camera_unmounted
+X-TDE-ServiceTypes=KPropsDlg/Plugin,media/audiocd,media/blankcd,media/blankbluray,media/blankdvd,media/hdd_mounted,media/hdd_unmounted,media/bluray_mounted,media/bluray_unmounted,media/cdrom_mounted,media/cdrom_unmounted,media/cd-r_mounted,media/cd-r_unmounted,media/cd-rw_mounted,media/cd-rw_unmounted,media/dvd_mounted,media/dvd_unmounted,media/removable_mounted,media/removable_unmounted,media/nfs_mounted,media/nfs_unmounted,media/smb_mounted,media/smb_unmounted,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd,media/floppy_mounted,media/floppy_unmounted,media/floppy5_mounted,media/floppy5_unmounted,media/zip_mounted,media/zip_unmounted,media/gphoto2camera,media/camera_mounted,media/camera_unmounted
Name=Media Properties Page
diff --git a/tdeioslave/media/propsdlgplugin/propertiespage.cpp b/tdeioslave/media/propsdlgplugin/propertiespage.cpp
index 5b54c8c5a..57fff8573 100644
--- a/tdeioslave/media/propsdlgplugin/propertiespage.cpp
+++ b/tdeioslave/media/propsdlgplugin/propertiespage.cpp
@@ -64,43 +64,43 @@ PropertiesPage::PropertiesPage(TQWidget* parent, const TQString &_id)
option_ro->hide();
else
option_ro->setChecked(options["ro"] == "true");
- connect( option_ro, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_ro, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
if (!options.contains("quiet"))
option_quiet->hide();
else
option_quiet->setChecked(options["quiet"] == "true");
- connect( option_quiet, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_quiet, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
if (!options.contains("sync"))
option_sync->hide();
else
option_sync->setChecked(options["sync"] == "true");
- connect( option_sync, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_sync, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
if (!options.contains("atime"))
option_atime->hide();
else
option_atime->setChecked(options["atime"] == "true");
- connect( option_atime, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_atime, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
if (!options.contains("flush"))
option_flush->hide();
else
option_flush->setChecked(options["flush"] == "true");
- connect( option_flush, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_flush, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
if (!options.contains("utf8"))
option_utf8->hide();
else
option_utf8->setChecked(options["utf8"] == "true");
- connect( option_utf8, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_utf8, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
if (!options.contains("uid"))
option_uid->hide();
else
option_uid->setChecked(options["uid"] == "true");
- connect( option_uid, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_uid, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
if (!options.contains("shortname"))
{
@@ -115,7 +115,7 @@ PropertiesPage::PropertiesPage(TQWidget* parent, const TQString &_id)
option_shortname->setCurrentItem(index);
break;
}
- connect( option_shortname, TQT_SIGNAL( activated(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_shortname, TQ_SIGNAL( activated(int) ), TQ_SIGNAL( changed() ) );
}
if (!options.contains("journaling"))
@@ -131,14 +131,14 @@ PropertiesPage::PropertiesPage(TQWidget* parent, const TQString &_id)
option_journaling->setCurrentItem(index);
break;
}
- connect( option_journaling, TQT_SIGNAL( activated(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_journaling, TQ_SIGNAL( activated(int) ), TQ_SIGNAL( changed() ) );
}
label_filesystem->setText(i18n("Filesystem: %1").arg(options["filesystem"]));
option_mountpoint->setText(options["mountpoint"]);
- connect( option_mountpoint, TQT_SIGNAL( textChanged( const TQString &) ), TQT_SIGNAL( changed() ) );
+ connect( option_mountpoint, TQ_SIGNAL( textChanged( const TQString &) ), TQ_SIGNAL( changed() ) );
option_automount->setChecked(options["automount"] == "true");
- connect( option_automount, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_automount, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
bool has_groupbox_specific = true;
if (!options.contains("journaling") &&
@@ -152,11 +152,11 @@ PropertiesPage::PropertiesPage(TQWidget* parent, const TQString &_id)
// The order is important - we want groupboxes to hide automatically depending on use_defaults
// but don't want to emit changed() until user actually changes something.
- connect( option_defaults, TQT_SIGNAL( toggled(bool) ), groupbox_generic, SLOT( setHidden(bool) ) );
+ connect( option_defaults, TQ_SIGNAL( toggled(bool) ), groupbox_generic, TQ_SLOT( setHidden(bool) ) );
if (has_groupbox_specific)
- connect( option_defaults, TQT_SIGNAL( toggled(bool) ), groupbox_specific, SLOT( setHidden(bool) ) );
+ connect( option_defaults, TQ_SIGNAL( toggled(bool) ), groupbox_specific, TQ_SLOT( setHidden(bool) ) );
option_defaults->setChecked(options["use_defaults"] == "true");
- connect( option_defaults, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) );
+ connect( option_defaults, TQ_SIGNAL( stateChanged(int) ), TQ_SIGNAL( changed() ) );
} else {
diff --git a/tdeioslave/media/propsdlgplugin/propertiespage.h b/tdeioslave/media/propsdlgplugin/propertiespage.h
index 50a480719..33baef40f 100644
--- a/tdeioslave/media/propsdlgplugin/propertiespage.h
+++ b/tdeioslave/media/propsdlgplugin/propertiespage.h
@@ -28,7 +28,7 @@ class Medium;
class PropertiesPage : public PropertiesPageGUI
{
- Q_OBJECT
+ TQ_OBJECT
public:
PropertiesPage(TQWidget* parent, const TQString &_id);
diff --git a/tdeioslave/media/propsdlgplugin/propertiespagegui.ui b/tdeioslave/media/propsdlgplugin/propertiespagegui.ui
index 2a6ff899e..5d461b406 100644
--- a/tdeioslave/media/propsdlgplugin/propertiespagegui.ui
+++ b/tdeioslave/media/propsdlgplugin/propertiespagegui.ui
@@ -372,12 +372,12 @@ Display the short name as is; store a long name when the short name is not all u
<variables>
<variable>bool m_hasChanged;</variable>
</variables>
-<Q_SIGNALS>
+<signals>
<signal>changed()</signal>
-</Q_SIGNALS>
-<Q_SLOTS>
+</signals>
+<slots>
<slot access="protected">changedSlot()</slot>
-</Q_SLOTS>
+</slots>
<functions>
<function returnType="bool">hasChanged()</function>
</functions>
diff --git a/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.cpp b/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.cpp
index ea830d2e1..dce33d786 100644
--- a/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.cpp
+++ b/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.cpp
@@ -70,10 +70,10 @@ PropsDlgSharePlugin::PropsDlgSharePlugin( KPropertiesDialog *dlg,
d = new Private();
d->page = new PropertiesPage(vbox, Medium::create(reply).id());
- connect(d->page, TQT_SIGNAL(changed()),
- TQT_SLOT(slotChanged()));
+ connect(d->page, TQ_SIGNAL(changed()),
+ TQ_SLOT(slotChanged()));
- // TQTimer::singleShot(100, this, TQT_SLOT(slotChanged()));
+ // TQTimer::singleShot(100, this, TQ_SLOT(slotChanged()));
}
diff --git a/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.h b/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.h
index 87b7d1e13..e2ed740a7 100644
--- a/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.h
+++ b/tdeioslave/media/propsdlgplugin/propsdlgshareplugin.h
@@ -24,7 +24,7 @@
class PropsDlgSharePlugin : public KPropsDlgPlugin
{
-Q_OBJECT
+TQ_OBJECT
public:
PropsDlgSharePlugin( KPropertiesDialog *dlg, const char *, const TQStringList & );
virtual ~PropsDlgSharePlugin();
diff --git a/tdeioslave/media/services/CMakeLists.txt b/tdeioslave/media/services/CMakeLists.txt
index b550409ba..932188725 100644
--- a/tdeioslave/media/services/CMakeLists.txt
+++ b/tdeioslave/media/services/CMakeLists.txt
@@ -13,8 +13,10 @@
tde_create_translated_desktop(
SOURCE
- media_decrypt.desktop media_mount.desktop media_unmount.desktop
+ media_mount.desktop media_unmount.desktop
+ media_unlock.desktop media_lock.desktop
media_eject.desktop media_safelyremove.desktop
+ media_realfolder.desktop
DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus
PO_DIR tdeioslave-desktops
)
diff --git a/tdeioslave/media/services/Makefile.am b/tdeioslave/media/services/Makefile.am
index c744934f2..e08b06be8 100644
--- a/tdeioslave/media/services/Makefile.am
+++ b/tdeioslave/media/services/Makefile.am
@@ -1,3 +1,3 @@
servicesdir = $(kde_datadir)/konqueror/servicemenus
-services_DATA = media_decrypt.desktop media_mount.desktop media_unmount.desktop media_eject.desktop media_safelyremove.desktop
+services_DATA = media_mount.desktop media_unmount.desktop media_unlock.desktop media_lock.desktop media_eject.desktop media_safelyremove.desktop media_realfolder.desktop
diff --git a/tdeioslave/media/services/media_decrypt.desktop b/tdeioslave/media/services/media_decrypt.desktop
deleted file mode 100644
index ee48f2e63..000000000
--- a/tdeioslave/media/services/media_decrypt.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-X-TDE-ServiceTypes=media/removable_encrypted_locked,media/hdd_encrypted_locked,media/bluray_encrypted_locked,media/cdrom_encrypted_locked,media/cd-r_encrypted_locked,media/cd-rw_encrypted_locked,media/dvd_encrypted_locked
-Actions=MediaUnlock;
-X-TDE-Priority=TopLevel
-X-TDE-MediaNotifierHide=true
-
-[Desktop Action MediaUnlock]
-Name=Unlock
-
-Exec=tdeio_media_mounthelper -k %u
-Icon=decrypted
diff --git a/tdeioslave/media/services/media_eject.desktop b/tdeioslave/media/services/media_eject.desktop
index ad289fd33..0bb128656 100644
--- a/tdeioslave/media/services/media_eject.desktop
+++ b/tdeioslave/media/services/media_eject.desktop
@@ -1,10 +1,10 @@
[Desktop Entry]
-X-TDE-ServiceTypes=media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_unlocked,media/bluray_encrypted_locked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_unlocked,media/cdrom_encrypted_locked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_unlocked,media/cd-r_encrypted_locked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_unlocked,media/cd-rw_encrypted_locked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_unlocked,media/dvd_encrypted_locked,media/audiocd,media/blankbluray,media/blankcd,media/blankdvd,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd
+X-TDE-ServiceTypes=media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_locked,media/bluray_encrypted_unlocked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_locked,media/cdrom_encrypted_unlocked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_locked,media/cd-r_encrypted_unlocked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_locked,media/cd-rw_encrypted_unlocked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_locked,media/dvd_encrypted_unlocked,media/audiocd,media/blankbluray,media/blankcd,media/blankdvd,media/dvdvideo,media/svcd,media/vcd
Actions=MediaEject;
X-TDE-Priority=TopLevel
X-TDE-MediaNotifierHide=true
[Desktop Action MediaEject]
-Name=Eject
-
Exec=tdeio_media_mounthelper -e %u
+Icon=player_eject
+Name=Eject
diff --git a/tdeioslave/media/services/media_lock.desktop b/tdeioslave/media/services/media_lock.desktop
new file mode 100644
index 000000000..d57565312
--- /dev/null
+++ b/tdeioslave/media/services/media_lock.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+X-TDE-ServiceTypes=media/bluray_encrypted_unlocked,media/cdrom_encrypted_unlocked,media/cd-r_encrypted_unlocked,media/cd-rw_encrypted_unlocked,media/dvd_encrypted_unlocked,media/hdd_encrypted_unlocked,media/removable_encrypted_unlocked
+Actions=MediaLock;
+X-TDE-Priority=TopLevel
+X-TDE-MediaNotifierHide=true
+
+[Desktop Action MediaLock]
+Exec=tdeio_media_mounthelper -l %u
+Icon=encrypted
+Name=Lock
diff --git a/tdeioslave/media/services/media_mount.desktop b/tdeioslave/media/services/media_mount.desktop
index d0f164bb9..f018cfd18 100644
--- a/tdeioslave/media/services/media_mount.desktop
+++ b/tdeioslave/media/services/media_mount.desktop
@@ -1,10 +1,10 @@
[Desktop Entry]
-X-TDE-ServiceTypes=media/bluray_unmounted,media/bluray_encrypted_unlocked,media/cdrom_unmounted,media/cdrom_encrypted_unlocked,media/cd-r_unmounted,media/cd-r_encrypted_unlocked,media/cd-rw_unmounted,media/cd-rw_encrypted_unlocked,media/dvd_unmounted,media/dvd_encrypted_unlocked,media/floppy5_unmounted,media/floppy_unmounted,media/hdd_unmounted,media/hdd_encrypted_unlocked,media/nfs_unmounted,media/removable_unmounted,media/removable_encrypted_unlocked,media/smb_unmounted,media/zip_unmounted,media/camera_unmounted
+X-TDE-ServiceTypes=media/bluray_unmounted,media/camera_unmounted,media/cdrom_unmounted,media/cd-r_unmounted,media/cd-rw_unmounted,media/dvd_unmounted,media/floppy5_unmounted,media/floppy_unmounted,media/hdd_unmounted,media/nfs_unmounted,media/removable_unmounted,media/smb_unmounted,media/zip_unmounted,media/audiocd,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd
Actions=MediaMount;
X-TDE-Priority=TopLevel
-X-TDE-MediaNotifierHide=true
+X-TDE-MediaNotifierHide=false
[Desktop Action MediaMount]
-Name=Mount
-
Exec=tdeio_media_mounthelper -m %u
+Icon=drive-harddisk-mounted
+Name=Mount
diff --git a/tdeioslave/media/services/media_realfolder.desktop b/tdeioslave/media/services/media_realfolder.desktop
new file mode 100644
index 000000000..a89066c53
--- /dev/null
+++ b/tdeioslave/media/services/media_realfolder.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+X-TDE-ServiceTypes=media/bluray_mounted,media/bluray_unmounted,media/camera_mounted,media/camera_unmounted,media/cdrom_mounted,media/cdrom_unmounted,media/cd-r_mounted,media/cd-r_unmounted,media/cd-rw_mounted,media/cd-rw_unmounted,media/dvd_mounted,media/dvd_unmounted,media/floppy5_mounted,media/floppy5_unmounted,media/floppy_mounted,media/floppy_unmounted,media/hdd_mounted,media/hdd_unmounted,media/nfs_mounted,media/nfs_unmounted,media/removable_mounted,media/removable_unmounted,media/smb_mounted,media/smb_unmounted,media/zip_mounted,media/zip_unmounted,media/audiocd,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd
+Actions=MediaRealFolder
+X-TDE-Priority=TopLevel
+X-TDE-MediaNotifierHide=false
+
+[Desktop Action MediaRealFolder]
+Exec=tdeio_media_mounthelper -f %u
+Icon=folder_red
+Name=Open Medium System Folder
diff --git a/tdeioslave/media/services/media_safelyremove.desktop b/tdeioslave/media/services/media_safelyremove.desktop
index 5abfdcd85..cf7191c8b 100644
--- a/tdeioslave/media/services/media_safelyremove.desktop
+++ b/tdeioslave/media/services/media_safelyremove.desktop
@@ -1,10 +1,10 @@
[Desktop Entry]
-X-TDE-ServiceTypes=media/removable_mounted,media/removable_unmounted,media/removable_encrypted_unlocked,media/camera_mounted,media/camera_unmounted
+X-TDE-ServiceTypes=media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_locked,media/bluray_encrypted_unlocked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_locked,media/cdrom_encrypted_unlocked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_locked,media/cd-r_encrypted_unlocked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_locked,media/cd-rw_encrypted_unlocked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_locked,media/dvd_encrypted_unlocked,media/audiocd,media/blankbluray,media/blankcd,media/blankdvd,media/dvdvideo,media/svcd,media/vcd,media/camera_mounted,media/camera_unmounted,media/removable_mounted,media/removable_unmounted,media/removable_encrypted_locked,media/removable_encrypted_unlocked
Actions=MediaSafelyRemove;
X-TDE-Priority=TopLevel
X-TDE-MediaNotifierHide=true
[Desktop Action MediaSafelyRemove]
-Name=Safely Remove
-
Exec=tdeio_media_mounthelper -s %u
+Icon=player_safe_removal
+Name=Safely Remove
diff --git a/tdeioslave/media/services/media_unlock.desktop b/tdeioslave/media/services/media_unlock.desktop
new file mode 100644
index 000000000..8d15cd46e
--- /dev/null
+++ b/tdeioslave/media/services/media_unlock.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+X-TDE-ServiceTypes=media/bluray_encrypted_locked,media/cdrom_encrypted_locked,media/cd-r_encrypted_locked,media/cd-rw_encrypted_locked,media/dvd_encrypted_locked,media/hdd_encrypted_locked,media/removable_encrypted_locked
+Actions=MediaUnlock;
+X-TDE-Priority=TopLevel
+X-TDE-MediaNotifierHide=false
+
+[Desktop Action MediaUnlock]
+Exec=tdeio_media_mounthelper -k %u
+Icon=decrypted
+Name=Unlock
diff --git a/tdeioslave/media/services/media_unmount.desktop b/tdeioslave/media/services/media_unmount.desktop
index 32bd58406..38370dd25 100644
--- a/tdeioslave/media/services/media_unmount.desktop
+++ b/tdeioslave/media/services/media_unmount.desktop
@@ -1,10 +1,10 @@
[Desktop Entry]
-X-TDE-ServiceTypes=media/removable_mounted,media/bluray_mounted,media/cdrom_mounted,media/cd-r_mounted,media/cd-rw_mounted,media/dvd_mounted,media/floppy5_mounted,media/floppy_mounted,media/hdd_mounted,media/nfs_mounted,media/smb_mounted,media/zip_mounted,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd,media/camera_mounted
+X-TDE-ServiceTypes=media/bluray_mounted,media/camera_mounted,media/cdrom_mounted,media/cd-r_mounted,media/cd-rw_mounted,media/dvd_mounted,media/floppy5_mounted,media/floppy_mounted,media/hdd_mounted,media/nfs_mounted,media/removable_mounted,media/smb_mounted,media/zip_mounted,media/audiocd,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd
Actions=MediaUnmount;
X-TDE-Priority=TopLevel
X-TDE-MediaNotifierHide=true
[Desktop Action MediaUnmount]
-Name=Unmount
-
Exec=tdeio_media_mounthelper -u %u
+Icon=drive-harddisk-unmounted
+Name=Unmount
diff --git a/tdeioslave/media/tdecmodule/main.cpp b/tdeioslave/media/tdecmodule/main.cpp
index e2d367e7d..dabac39aa 100644
--- a/tdeioslave/media/tdecmodule/main.cpp
+++ b/tdeioslave/media/tdecmodule/main.cpp
@@ -49,13 +49,13 @@ MediaModule::MediaModule( TQWidget *parent, const char *name, const TQStringList
m_notifierModule = new NotifierModule( this, "notifier" );
tab->addTab( m_notifierModule, i18n( "&Notifications" ) );
- connect( m_notifierModule, TQT_SIGNAL( changed( bool ) ),
- this, TQT_SLOT( moduleChanged( bool ) ) );
+ connect( m_notifierModule, TQ_SIGNAL( changed( bool ) ),
+ this, TQ_SLOT( moduleChanged( bool ) ) );
m_managerModule = new ManagerModule( this, "manager" );
tab->addTab( m_managerModule, i18n( "&Advanced" ) );
- connect( m_managerModule, TQT_SIGNAL( changed( bool ) ),
- this, TQT_SLOT( moduleChanged( bool ) ) );
+ connect( m_managerModule, TQ_SIGNAL( changed( bool ) ),
+ this, TQ_SLOT( moduleChanged( bool ) ) );
diff --git a/tdeioslave/media/tdecmodule/main.h b/tdeioslave/media/tdecmodule/main.h
index 5052d58eb..29d9eb21f 100644
--- a/tdeioslave/media/tdecmodule/main.h
+++ b/tdeioslave/media/tdecmodule/main.h
@@ -24,7 +24,7 @@
class MediaModule : public TDECModule
{
- Q_OBJECT
+ TQ_OBJECT
public:
MediaModule( TQWidget *parent, const char *name, const TQStringList& );
diff --git a/tdeioslave/media/tdecmodule/managermodule.cpp b/tdeioslave/media/tdecmodule/managermodule.cpp
index 6478ee2a8..03a5ea500 100644
--- a/tdeioslave/media/tdecmodule/managermodule.cpp
+++ b/tdeioslave/media/tdecmodule/managermodule.cpp
@@ -44,13 +44,6 @@ ManagerModule::ManagerModule( TQWidget* parent, const char* name )
addConfig( MediaManagerSettings::self(), view );
-#ifndef COMPILE_HALBACKEND
- TQString hal_text = view->kcfg_HalBackendEnabled->text();
- hal_text += " ("+i18n("No support for HAL on this system")+")";
- view->kcfg_HalBackendEnabled->setText( hal_text );
-#endif
- view->kcfg_HalBackendEnabled->setEnabled( false );
-
#ifndef COMPILE_LINUXCDPOLLING
TQString poll_text = view->kcfg_CdPollingEnabled->text();
poll_text += " ("+i18n("No support for CD polling on this system")+")";
@@ -58,16 +51,16 @@ ManagerModule::ManagerModule( TQWidget* parent, const char* name )
#endif
view->kcfg_CdPollingEnabled->setEnabled( false );
- connect( view->option_automount, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_ro, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_quiet, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_flush, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_uid, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_utf8, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_sync, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_atime, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_shortname, SIGNAL( activated(int) ), this, SLOT( emitChanged() ) );
- connect( view->option_journaling, SIGNAL( activated(int) ), this, SLOT( emitChanged() ) );
+ connect( view->option_automount, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_ro, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_quiet, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_flush, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_uid, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_utf8, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_sync, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_atime, TQ_SIGNAL( stateChanged(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_shortname, TQ_SIGNAL( activated(int) ), this, TQ_SLOT( emitChanged() ) );
+ connect( view->option_journaling, TQ_SIGNAL( activated(int) ), this, TQ_SLOT( emitChanged() ) );
load();
}
@@ -98,7 +91,7 @@ void ManagerModule::load()
else
view->option_atime->setNoChange();
- QString value;
+ TQString value;
value = config.readEntry("shortname", "lower").lower();
for (int i = 0; i < view->option_shortname->count(); i++)
@@ -140,13 +133,12 @@ void ManagerModule::save()
rememberSettings();
- //Well... reloadBackends is buggy with HAL, it seems to be linked
- //to a bug in the unmaintained Qt3 DBUS binding ;-/
- //DCOPRef mediamanager( "kded", "mediamanager" );
- //DCOPReply reply = mediamanager.call( "reloadBackends" );
-
- // So we use this hack instead...
DCOPRef kded( "kded", "kded" );
+ // DCOPReply reply = mediamanager.call( "reloadBackends" );
+ // Well... reloadBackends had issues with HAL, it seems it was linked
+ // to a bug in the unmaintained Qt3 DBUS binding, but it is not quite clear.
+ // It may be ok now that HAL is no longer supported but needs to be tested.
+ // So we use this hack instead...
kded.call( "unloadModule", "mediamanager" );
kded.call( "loadModule", "mediamanager" );
diff --git a/tdeioslave/media/tdecmodule/managermodule.h b/tdeioslave/media/tdecmodule/managermodule.h
index a0a384675..ae79e8d78 100644
--- a/tdeioslave/media/tdecmodule/managermodule.h
+++ b/tdeioslave/media/tdecmodule/managermodule.h
@@ -27,7 +27,7 @@ class ManagerModuleView;
class ManagerModule : public TDECModule
{
- Q_OBJECT
+ TQ_OBJECT
public:
ManagerModule( TQWidget* parent = 0, const char* name = 0);
diff --git a/tdeioslave/media/tdecmodule/managermoduleview.ui b/tdeioslave/media/tdecmodule/managermoduleview.ui
index febef70f7..748cd825c 100644
--- a/tdeioslave/media/tdecmodule/managermoduleview.ui
+++ b/tdeioslave/media/tdecmodule/managermoduleview.ui
@@ -21,46 +21,46 @@
</property>
<widget class="TQCheckBox">
<property name="name">
- <cstring>kcfg_HalBackendEnabled</cstring>
+ <cstring>kcfg_CdPollingEnabled</cstring>
</property>
<property name="text">
- <string>Enable HAL backend</string>
+ <string>Enable CD polling</string>
</property>
<property name="whatsThis" stdset="0">
- <string>Select this if you want to enable the Hardware Abstraction Layer (http://hal.freedesktop.org/wiki/Software/hal) support.</string>
+ <string>Select this to enable the CD polling.</string>
</property>
</widget>
<widget class="TQCheckBox">
<property name="name">
- <cstring>kcfg_CdPollingEnabled</cstring>
+ <cstring>kcfg_AutostartEnabled</cstring>
</property>
<property name="text">
- <string>Enable CD polling</string>
+ <string>Enable medium application autostart after mount</string>
</property>
<property name="whatsThis" stdset="0">
- <string>Select this to enable the CD polling.</string>
+ <string>Select this if you want to enable application autostart after mounting a device.</string>
</property>
</widget>
<widget class="TQCheckBox">
<property name="name">
- <cstring>kcfg_AutostartEnabled</cstring>
+ <cstring>kcfg_NotificationPopupsEnabled</cstring>
</property>
<property name="text">
- <string>Enable medium application autostart after mount</string>
+ <string>Enable notification dialog popups</string>
</property>
<property name="whatsThis" stdset="0">
- <string>Select this if you want to enable application autostart after mounting a device.</string>
+ <string>Deselect this if you do not want action request dialog popups to be generated when devices are plugged in.</string>
</property>
</widget>
<widget class="TQCheckBox">
<property name="name">
- <cstring>kcfg_NotificationPopupsEnabled</cstring>
+ <cstring>kcfg_DeviceMonitorPopupsEnabled</cstring>
</property>
<property name="text">
- <string>Enable notification popups</string>
+ <string>Enable device monitor notification popups</string>
</property>
<property name="whatsThis" stdset="0">
- <string>Deselect this if you do not want action request popups to be generated when devices are plugged in.</string>
+ <string>Deselect this if you do not want device monitoring popups to be generated when devices are added, modified or removed.</string>
</property>
</widget>
<widget class="TQGroupBox">
@@ -337,19 +337,11 @@ Display the short name as is; store a long name when the short name is not all u
</spacer>
</vbox>
</widget>
-<connections>
- <connection>
- <sender>kcfg_HalBackendEnabled</sender>
- <signal>toggled(bool)</signal>
- <receiver>groupbox_mount</receiver>
- <slot>setEnabled(bool)</slot>
- </connection>
-</connections>
<tabstops>
- <tabstop>kcfg_HalBackendEnabled</tabstop>
<tabstop>kcfg_CdPollingEnabled</tabstop>
<tabstop>kcfg_AutostartEnabled</tabstop>
<tabstop>kcfg_NotificationPopupsEnabled</tabstop>
+ <tabstop>kcfg_DeviceMonitorPopupsEnabled</tabstop>
<tabstop>option_automount</tabstop>
<tabstop>option_ro</tabstop>
<tabstop>option_quiet</tabstop>
diff --git a/tdeioslave/media/tdecmodule/notifiermodule.cpp b/tdeioslave/media/tdecmodule/notifiermodule.cpp
index 4364d93ad..2d2d53481 100644
--- a/tdeioslave/media/tdecmodule/notifiermodule.cpp
+++ b/tdeioslave/media/tdecmodule/notifiermodule.cpp
@@ -57,18 +57,18 @@ NotifierModule::NotifierModule(TQWidget *parent, const char *name)
updateListBox();
- connect( m_view->mimetypesCombo, TQT_SIGNAL( activated(int) ),
- this, TQT_SLOT( slotMimeTypeChanged(int) ) );
- connect( m_view->actionsList, TQT_SIGNAL( selectionChanged(TQListBoxItem*) ),
- this, TQT_SLOT( slotActionSelected(TQListBoxItem*) ) );
- connect( m_view->addButton, TQT_SIGNAL( clicked() ),
- this, TQT_SLOT( slotAdd() ) );
- connect( m_view->editButton, TQT_SIGNAL( clicked() ),
- this, TQT_SLOT( slotEdit() ) );
- connect( m_view->deleteButton, TQT_SIGNAL( clicked() ),
- this, TQT_SLOT( slotDelete() ) );
- connect( m_view->toggleAutoButton, TQT_SIGNAL( clicked() ),
- this, TQT_SLOT( slotToggleAuto() ) );
+ connect( m_view->mimetypesCombo, TQ_SIGNAL( activated(int) ),
+ this, TQ_SLOT( slotMimeTypeChanged(int) ) );
+ connect( m_view->actionsList, TQ_SIGNAL( selectionChanged(TQListBoxItem*) ),
+ this, TQ_SLOT( slotActionSelected(TQListBoxItem*) ) );
+ connect( m_view->addButton, TQ_SIGNAL( clicked() ),
+ this, TQ_SLOT( slotAdd() ) );
+ connect( m_view->editButton, TQ_SIGNAL( clicked() ),
+ this, TQ_SLOT( slotEdit() ) );
+ connect( m_view->deleteButton, TQ_SIGNAL( clicked() ),
+ this, TQ_SLOT( slotDelete() ) );
+ connect( m_view->toggleAutoButton, TQ_SIGNAL( clicked() ),
+ this, TQ_SLOT( slotToggleAuto() ) );
}
NotifierModule::~NotifierModule()
diff --git a/tdeioslave/media/tdecmodule/notifiermodule.h b/tdeioslave/media/tdecmodule/notifiermodule.h
index d5d97a96d..2192c30a9 100644
--- a/tdeioslave/media/tdecmodule/notifiermodule.h
+++ b/tdeioslave/media/tdecmodule/notifiermodule.h
@@ -28,7 +28,7 @@
class NotifierModule : public TDECModule
{
- Q_OBJECT
+ TQ_OBJECT
public:
NotifierModule( TQWidget* parent = 0, const char* name = 0);
diff --git a/tdeioslave/media/tdecmodule/serviceconfigdialog.cpp b/tdeioslave/media/tdecmodule/serviceconfigdialog.cpp
index 4147e437c..bcf533b9d 100644
--- a/tdeioslave/media/tdecmodule/serviceconfigdialog.cpp
+++ b/tdeioslave/media/tdecmodule/serviceconfigdialog.cpp
@@ -78,10 +78,10 @@ ServiceConfigDialog::ServiceConfigDialog(NotifierServiceAction *action,
setMainWidget(m_view);
setCaption( m_action->label() );
- connect( m_view->iconButton, TQT_SIGNAL( iconChanged(TQString) ),
- this, TQT_SLOT( slotIconChanged() ) );
- connect( m_view->commandButton, TQT_SIGNAL( clicked() ),
- this, TQT_SLOT( slotCommand() ) );
+ connect( m_view->iconButton, TQ_SIGNAL( iconChanged(TQString) ),
+ this, TQ_SLOT( slotIconChanged() ) );
+ connect( m_view->commandButton, TQ_SIGNAL( clicked() ),
+ this, TQ_SLOT( slotCommand() ) );
}
bool operator==( KDEDesktopMimeType::Service s1, KDEDesktopMimeType::Service s2 )
diff --git a/tdeioslave/media/tdecmodule/serviceconfigdialog.h b/tdeioslave/media/tdecmodule/serviceconfigdialog.h
index 24e907205..2f35bfb54 100644
--- a/tdeioslave/media/tdecmodule/serviceconfigdialog.h
+++ b/tdeioslave/media/tdecmodule/serviceconfigdialog.h
@@ -27,7 +27,7 @@
class ServiceConfigDialog : public KDialogBase
{
- Q_OBJECT
+ TQ_OBJECT
public:
ServiceConfigDialog(NotifierServiceAction *action,
diff --git a/tdeioslave/media/tdefile-plugin/tdefile_media.desktop b/tdeioslave/media/tdefile-plugin/tdefile_media.desktop
index bfb7a6762..2b9b7c68e 100644
--- a/tdeioslave/media/tdefile-plugin/tdefile_media.desktop
+++ b/tdeioslave/media/tdefile-plugin/tdefile_media.desktop
@@ -1,6 +1,6 @@
[Desktop Entry]
Type=Service
X-TDE-Library=tdefile_media
-X-TDE-ServiceTypes=KFilePlugin,media/audiocd,media/blankcd,media/blankbluray,media/blankdvd,media/hdd_mounted,media/hdd_unmounted,media/hdd_encrypted_unlocked,media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_unlocked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_unlocked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_unlocked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_unlocked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_unlocked,media/removable_mounted,media/removable_unmounted,media/removable_encrypted_unlocked,media/nfs_mounted,media/nfs_unmounted,media/smb_mounted,media/smb_unmounted,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd,media/floppy_mounted,media/floppy_unmounted,media/floppy5_mounted,media/floppy5_unmounted,media/zip_mounted,media/zip_unmounted,media/gphoto2camera,media/camera_mounted,media/camera_unmounted
+X-TDE-ServiceTypes=KFilePlugin,media/audiocd,media/blankcd,media/blankbluray,media/blankdvd,media/hdd_mounted,media/hdd_unmounted,media/hdd_encrypted_unlocked,media/hdd_encrypted_locked,media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_unlocked,media/bluray_encrypted_locked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_unlocked,media/cdrom_encrypted_locked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_unlocked,media/cd-r_encrypted_locked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_unlocked,media/cd-rw_encrypted_locked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_unlocked,media/dvd_encrypted_locked,media/removable_mounted,media/removable_unmounted,media/removable_encrypted_unlocked,media/removable_encrypted_locked,media/nfs_mounted,media/nfs_unmounted,media/smb_mounted,media/smb_unmounted,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd,media/floppy_mounted,media/floppy_unmounted,media/floppy5_mounted,media/floppy5_unmounted,media/zip_mounted,media/zip_unmounted,media/gphoto2camera,media/camera_mounted,media/camera_unmounted
Name=Medium Information
diff --git a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp
index b7e4a437d..190bec197 100644
--- a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp
+++ b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp
@@ -55,24 +55,31 @@ KFileMediaPlugin::KFileMediaPlugin(TQObject *parent, const char *name,
addMimeType( "media/bluray_mounted" );
addMimeType( "media/bluray_unmounted" );
addMimeType( "media/bluray_encrypted_unlocked" );
+ addMimeType( "media/bluray_encrypted_locked" );
addMimeType( "media/cdrom_mounted" );
addMimeType( "media/cdrom_unmounted" );
addMimeType( "media/cdrom_encrypted_unlocked" );
+ addMimeType( "media/cdrom_encrypted_locked" );
addMimeType( "media/cd-r_mounted" );
addMimeType( "media/cd-r_unmounted" );
addMimeType( "media/cd-r_encrypted_unlocked" );
+ addMimeType( "media/cd-r_encrypted_locked" );
addMimeType( "media/cd-rw_mounted" );
addMimeType( "media/cd-rw_unmounted" );
addMimeType( "media/cd-rw_encrypted_unlocked" );
+ addMimeType( "media/cd-rw_encrypted_locked" );
addMimeType( "media/dvd_mounted" );
addMimeType( "media/dvd_unmounted" );
addMimeType( "media/dvd_encrypted_unlocked" );
+ addMimeType( "media/dvd_encrypted_locked" );
addMimeType( "media/hdd_mounted" );
addMimeType( "media/hdd_unmounted" );
addMimeType( "media/hdd_encrypted_unlocked" );
+ addMimeType( "media/hdd_encrypted_locked" );
addMimeType( "media/removable_mounted" );
addMimeType( "media/removable_unmounted" );
addMimeType( "media/removable_encrypted_unlocked" );
+ addMimeType( "media/removable_encrypted_locked" );
addMimeType( "media/nfs_mounted" );
addMimeType( "media/nfs_unmounted" );
addMimeType( "media/smb_mounted" );
@@ -151,12 +158,12 @@ bool KFileMediaPlugin::readInfo(KFileMetaInfo &info, uint /*what*/)
TQPixmap bar(150, 20);
TQPainter p(&bar);
- p.fillRect(0, 0, length, 20, Qt::red);
- p.fillRect(length, 0, 150-length, 20, Qt::green);
+ p.fillRect(0, 0, length, 20, TQt::red);
+ p.fillRect(length, 0, 150-length, 20, TQt::green);
TQColorGroup cg = TQApplication::palette().active();
- TQApplication::style().tqdrawPrimitive(TQStyle::PE_Panel, &p,
+ TQApplication::style().drawPrimitive(TQStyle::PE_Panel, &p,
TQRect(0, 0, 150, 20), cg,
TQStyle::Style_Sunken);
diff --git a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h
index dcc2591be..0f9dc0038 100644
--- a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h
+++ b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.h
@@ -28,7 +28,7 @@
class KFileMediaPlugin : public KFilePlugin
{
-Q_OBJECT
+TQ_OBJECT
public:
KFileMediaPlugin(TQObject *parent, const char *name,
const TQStringList &args);
diff --git a/tdeioslave/media/tdeio_media.cpp b/tdeioslave/media/tdeio_media.cpp
index 9124568c1..c68bc25d5 100644
--- a/tdeioslave/media/tdeio_media.cpp
+++ b/tdeioslave/media/tdeio_media.cpp
@@ -62,8 +62,8 @@ MediaProtocol::MediaProtocol(const TQCString &protocol,
const TQCString &pool, const TQCString &app)
: ForwardingSlaveBase(protocol, pool, app)
{
- connect( &m_impl, TQT_SIGNAL( warning( const TQString & ) ),
- this, TQT_SLOT( slotWarning( const TQString & ) ) );
+ connect( &m_impl, TQ_SIGNAL( warning( const TQString & ) ),
+ this, TQ_SLOT( slotWarning( const TQString & ) ) );
}
MediaProtocol::~MediaProtocol()
diff --git a/tdeioslave/media/tdeio_media.h b/tdeioslave/media/tdeio_media.h
index 7acc44df0..473a623b1 100644
--- a/tdeioslave/media/tdeio_media.h
+++ b/tdeioslave/media/tdeio_media.h
@@ -26,7 +26,7 @@
class MediaProtocol : public TDEIO::ForwardingSlaveBase
{
-Q_OBJECT
+TQ_OBJECT
public:
MediaProtocol(const TQCString &protocol, const TQCString &pool,
const TQCString &app);