Index: kdebase/kioslave/media/kcmodule/managermoduleview.ui =================================================================== --- kdebase/kioslave/media/kcmodule/managermoduleview.ui (revision 604326) +++ kdebase/kioslave/media/kcmodule/managermoduleview.ui (working copy) @@ -12,6 +12,9 @@ 480 + + ManagerModuleView + unnamed @@ -49,6 +52,245 @@ Select this if you want to enable application autostart after mounting a device. + + + groupbox_mount + + + Mount options + + + + unnamed + + + + textLabel3 + + + Here you can specify default mount options for your storage media. Please note that some options are not supported for certain filesystems and/or medium. You will be able to redefine all these options on per-volume basis later, using Properties dialog of the corresponding volume.<br> +Some of the options are tristate. Leave them "undefined" to let KDE choose the best value depending on your media. + + + WordBreak|AlignVCenter + + + + + layout30 + + + + unnamed + + + + option_ro + + + Read only + + + By default, mount all file systems read-only. + + + + + option_uid + + + Mount as user + + + Mount this file system as user. + + + + + option_flush + + + Flushed IO + + + true + + + Always flush all data to the hot plug devices immediately and don't cache it. + + + + + option_sync + + + Synchronous + + + true + + + All I/O to the file system should be done synchronously. + + + + + option_quiet + + + Quiet + + + Attempts to chown or chmod files do not return errors, although they fail. Use with caution! + + + + + option_utf8 + + + UTF-8 charset + + + UTF8 is the filesystem safe 8-bit encoding of Unicode that is used by the console. It can be be enabled for the filesystem with this option. + + + + + layout29 + + + + unnamed + + + + text_shortname + + + Short names: + + + option_shortname + + + <h2>Defines the behaviour for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be preferred display.</h2> + +<h3><b>Lower</b></h3> +Force the short name to lower case upon display; store a long name when the short name is not all upper case. + +<h3><b>Windows 95</b></h3> +Force the short name to upper case upon display; store a long name when the short name is not all upper case. + +<h3><b>Windows NT</b></h3> +Display the shortname as is; store a long name when the short name is not all lower case or all upper case. + +<h3><b>Mixed</b></h3> +Display the short name as is; store a long name when the short name is not all upper case. + + + + + + All Data + + + + + Ordered + + + + + Writeback + + + + option_journaling + + + 1 + + + + + text_journaling + + + Journaling: + + + option_journaling + + + <h2>Specifies the journalling mode for file data. Metadata is always journaled. </h2> + +<h3><b>All Data</b></h3> + All data is committed into the journal prior to being written into the main file system. This is the slowest variant with the highest data security. + +<h3><b>Ordered</b></h3> + All data is forced directly out to the main file system prior to its metadata being committed to the journal. + +<h3><b>Write Back</b></h3> + Data ordering is not preserved - data may be written into the main file system after its metadata has been committed to the journal. This is rumoured to be the highest-throughput option. It guarantees internal file system integrity, however it can allow old data to appear in files after a crash and journal recovery. + + + + + + Lower + + + + + Windows 95 + + + + + Windows NT + + + + + Mixed + + + + option_shortname + + + + + + + option_automount + + + Mount automatically + + + By default, mount all file systems automatically. + + + + + option_atime + + + Access time updates + + + true + + + Update inode access time for each access. + + + + + + spacer1 @@ -62,11 +304,40 @@ 21 - 360 + 130 + + + kcfg_HalBackendEnabled + toggled(bool) + groupbox_mount + setEnabled(bool) + + + + kcfg_HalBackendEnabled + kcfg_CdPollingEnabled + kcfg_AutostartEnabled + option_automount + option_ro + option_quiet + option_sync + option_atime + option_flush + option_utf8 + option_uid + option_journaling + option_shortname + + + managermoduleview.ui.h + + + init() + Index: kdebase/kioslave/media/kcmodule/managermodule.cpp =================================================================== --- kdebase/kioslave/media/kcmodule/managermodule.cpp (revision 604326) +++ kdebase/kioslave/media/kcmodule/managermodule.cpp (working copy) @@ -1,5 +1,6 @@ /* This file is part of the KDE Project Copyright (c) 2005 Kévin Ottens + Copyright (c) 2006 Valentine Sinitsyn This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -20,9 +21,13 @@ #include "managermodule.h" +#include #include #include +#include #include +#include +#include #include #include "managermoduleview.h" @@ -31,7 +36,7 @@ ManagerModule::ManagerModule( TQWidget* parent, const char* name ) : KCModule( parent, name ) { - ManagerModuleView *view = new ManagerModuleView( this ); + view = new ManagerModuleView( this ); addConfig( MediaManagerSettings::self(), view ); @@ -49,12 +54,87 @@ #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() ) ); + load(); +} + + +void ManagerModule::load() +{ + KCModule::load(); + + KConfig config("mediamanagerrc"); + config.setGroup("DefaultOptions"); + + view->option_automount->setChecked( config.readBoolEntry("automount", false) ); + view->option_ro->setChecked( config.readBoolEntry("ro", false) ); + view->option_quiet->setChecked( config.readBoolEntry("quiet", false) ); + if (config.hasKey("flush")) + view->option_flush->setChecked( config.readBoolEntry("flush") ); + else + view->option_flush->setNoChange(); + view->option_uid->setChecked( config.readBoolEntry("uid", true) ); + view->option_utf8->setChecked( config.readBoolEntry("utf8", true) ); + if (config.hasKey("sync")) + view->option_sync->setChecked( config.readBoolEntry("sync") ); + else + view->option_sync->setNoChange(); + if (config.hasKey("atime")) + view->option_atime->setChecked( config.readBoolEntry("atime") ); + else + view->option_atime->setNoChange(); + + QString value; + + value = config.readEntry("shortname", "lower").lower(); + for (int i = 0; i < view->option_shortname->count(); i++) + if (view->option_shortname->text(i).lower() == value) view->option_shortname->setCurrentItem(i); + + value = config.readEntry("journaling", "ordered").lower(); + for (int i = 0; i < view->option_journaling->count(); i++) + if (view->option_journaling->text(i).lower() == value) view->option_journaling->setCurrentItem(i); + + rememberSettings(); } void ManagerModule::save() { KCModule::save(); + + KConfig config("mediamanagerrc"); + config.setGroup("DefaultOptions"); + + config.writeEntry("automount", view->option_automount->isChecked()); + config.writeEntry("ro", view->option_ro->isChecked()); + config.writeEntry("quiet", view->option_quiet->isChecked()); + if (view->option_flush->state() == QButton::NoChange) + config.deleteEntry("flush"); + else + config.writeEntry("flush", view->option_flush->isChecked()); + config.writeEntry("uid", view->option_uid->isChecked()); + config.writeEntry("utf8", view->option_utf8->isChecked()); + if (view->option_sync->state() == QButton::NoChange) + config.deleteEntry("sync"); + else + config.writeEntry("sync", view->option_sync->isChecked()); + if (view->option_atime->state() == QButton::NoChange) + config.deleteEntry("atime"); + else + config.writeEntry("atime", view->option_atime->isChecked()); + config.writeEntry("journaling", view->option_journaling->currentText().lower()); + config.writeEntry("shortname", view->option_shortname->currentText().lower()); + + rememberSettings(); //Well... reloadBackends is buggy with HAL, it seems to be linked //to a bug in the unmaintained Qt3 DBUS binding ;-/ @@ -70,5 +150,64 @@ notifier.FilesAdded( "media:/" ); } +void ManagerModule::defaults() +{ + KCModule::defaults(); + + view->option_automount->setChecked(false); + view->option_ro->setChecked(false); + view->option_quiet->setChecked(false); + view->option_flush->setNoChange(); + view->option_uid->setChecked(true); + view->option_utf8->setChecked(true); + view->option_sync->setNoChange(); + view->option_atime->setNoChange(); + view->option_journaling->setCurrentItem(1); + view->option_shortname->setCurrentItem(0); +} +void ManagerModule::rememberSettings() +{ + QObjectList *options = view->queryList(0, "^option_"); + QObject *current = 0; + QObjectListIterator it(*options); + + settings.clear(); + while ( (current = it.current()) != 0 ) { + if (current->isA("QCheckBox")) + settings[current] = ((QCheckBox *)current)->state(); + else if (current->isA("QComboBox")) + settings[current] = ((QComboBox *)current)->currentItem(); + ++it; + } + delete options; + +} + +void ManagerModule::emitChanged() +{ + QObjectList *options = view->queryList(0, "^option_"); + QObject *current = 0; + QObjectListIterator it(*options); + int value = -1; + bool somethingChanged = false; + + while ( (current = it.current()) != 0 ) { + if (current->isA("QCheckBox")) + value = ((QCheckBox *)current)->state(); + else if (current->isA("QComboBox")) + value = ((QComboBox *)current)->currentItem(); + + if (settings[current] != value) { + somethingChanged = true; + break; + } + + ++it; + } + delete options; + + emit changed(somethingChanged); +} + #include "managermodule.moc" Index: kdebase/kioslave/media/kcmodule/main.cpp =================================================================== --- kdebase/kioslave/media/kcmodule/main.cpp (revision 604326) +++ kdebase/kioslave/media/kcmodule/main.cpp (working copy) @@ -67,6 +67,7 @@ I18N_NOOP("(c) 2005 Jean-Remy Falleri")); about->addAuthor("Jean-Remy Falleri", I18N_NOOP("Maintainer"), "jr.falleri@laposte.net"); about->addAuthor("Kevin Ottens", 0, "ervin ipsquad net"); + about->addAuthor("Valentine Sinitsyn", 0, "e_val@inbox.ru"); about->addCredit("Achim Bohnet", I18N_NOOP("Help for the application design")); setAboutData( about ); Index: kdebase/kioslave/media/kcmodule/managermodule.h =================================================================== --- kdebase/kioslave/media/kcmodule/managermodule.h (revision 604326) +++ kdebase/kioslave/media/kcmodule/managermodule.h (working copy) @@ -1,5 +1,6 @@ /* This file is part of the KDE Project Copyright (c) 2005 Kévin Ottens + Copyright (c) 2006 Valentine Sinitsyn This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -19,8 +20,11 @@ #ifndef _MANAGERMODULE_H_ #define _MANAGERMODULE_H_ +#include #include +class ManagerModuleView; + class ManagerModule : public KCModule { Q_OBJECT @@ -28,7 +32,18 @@ public: ManagerModule( TQWidget* parent = 0, const char* name = 0); + void load(); void save(); + void defaults(); + +private: + void rememberSettings(); + + ManagerModuleView *view; + TQMap settings; + +private slots: + void emitChanged(); }; #endif Index: kdebase/kioslave/media/kcmodule/managermoduleview.ui.h =================================================================== --- kdebase/kioslave/media/kcmodule/managermoduleview.ui.h (revision 0) +++ kdebase/kioslave/media/kcmodule/managermoduleview.ui.h (revision 0) @@ -0,0 +1,18 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you want to add, delete, or rename functions or slots, use +** Qt Designer to update this file, preserving your code. +** +** You should not define a constructor or destructor in this file. +** Instead, write your code in functions called init() and destroy(). +** These will automatically be called by the form's constructor and +** destructor. +*****************************************************************************/ + +void ManagerModuleView::init() +{ + option_flush->setNoChange(); + option_sync->setNoChange(); + option_atime->setNoChange(); +} Index: kdebase/kioslave/media/propsdlgplugin/propertiespage.cpp =================================================================== --- kdebase/kioslave/media/propsdlgplugin/propertiespage.cpp (revision 604326) +++ kdebase/kioslave/media/propsdlgplugin/propertiespage.cpp (working copy) @@ -140,12 +140,23 @@ option_automount->setChecked(options["automount"] == "true"); connect( option_automount, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); + bool has_groupbox_specific = true; if (!options.contains("journaling") && !options.contains("shortname") && !options.contains("uid") && !options.contains("utf8") && - !options.contains("flush")) + !options.contains("flush")) { groupbox_specific->hide(); + has_groupbox_specific = false; + } + + // 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) ) ); + if (has_groupbox_specific) + connect( option_defaults, TQT_SIGNAL( toggled(bool) ), groupbox_specific, SLOT( setHidden(bool) ) ); + option_defaults->setChecked(options["use_defaults"] == "true"); + connect( option_defaults, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); } else { @@ -198,6 +210,7 @@ } result << TQString("mountpoint=%1").arg(mp); result << TQString("automount=%1").arg(option_automount->isChecked() ? "true" : "false"); + result << TQString("use_defaults=%1").arg(option_defaults->isChecked() ? "true" : "false"); kdDebug() << result << endl; Index: kdebase/kioslave/media/propsdlgplugin/propertiespagegui.ui =================================================================== --- kdebase/kioslave/media/propsdlgplugin/propertiespagegui.ui (revision 604326) +++ kdebase/kioslave/media/propsdlgplugin/propertiespagegui.ui (working copy) @@ -8,207 +8,207 @@ 0 0 - 527 - 476 + 219 + 446 - + + PropertiesPageGUI + + unnamed - - 0 - - + - layout17 + option_defaults + + Use default mount options + + + + + groupbox_generic + + + Generic Mount Options + unnamed - + - groupbox_generic + layout15 - - Generic Mount Options - unnamed + + + option_ro + + + Read only + + + Mount the file system read-only. + + + + + option_quiet + + + Quiet + + + Attempts to chown or chmod files do not return errors, although they fail. Use with caution! + + + + + option_sync + + + Synchronous + + + All I/O to the file system should be done synchronously. + + + + + option_atime + + + Access time updates + + + Update inode access time for each access. + + - layout15 + layout14 - + unnamed - + - option_ro + textLabel3 - Read only + Mountpoint: - - Mount the file system read-only. + + option_mountpoint - - - - option_quiet - - - Quiet - - Attempts to chown or chmod files do not return errors, although they fail. Use with caution! + Under what directory this file system shall be mounted. Please note that there is no guarantee that the system will respect your wish. For one the directory has to be below /media - and it does not yet have to exist. - + - option_sync + option_mountpoint - Synchronous + - - All I/O to the file system should be done synchronously. - - - - option_atime - - - Access time updates - - - Update inode access time for each access. - - - - - layout14 - - - - unnamed - - - - textLabel3 - - - Mountpoint: - - - option_mountpoint - - - Under what directory this file system shall be mounted. Please note that there is no guarantee that the system will respect your wish. For one the directory has to be below /media - and it does not yet have to exist. - - - - - option_mountpoint - - - - - - - - - - option_automount - - - Mount automatically - - - Mount this file system automatically. - - - + + + + option_automount + + + Mount automatically + + + Mount this file system automatically. + + - + + + + + groupbox_specific + + + Filesystem Specific Mount Options + + + + unnamed + + - groupbox_specific + layout11 - - Filesystem Specific Mount Options - unnamed + + + option_flush + + + Flushed IO + + + Always flush all data to the hot plug devices immediately and don't cache it. + + + + + option_utf8 + + + UTF-8 charset + + + UTF8 is the filesystem safe 8-bit encoding of Unicode that is used by the console. It can be be enabled for the filesystem with this option. + + + + + option_uid + + + Mount as user + + + Mount this file system as user. + + - layout11 + layout7 - + unnamed - + - option_flush + text_journaling - Flushed IO + Journaling: - - Always flush all data to the hot plug devices immediately and don't cache it. + + option_journaling - - - - option_utf8 - - - UTF-8 charset - - UTF8 is the filesystem safe 8-bit encoding of Unicode that is used by the console. It can be be enabled for the filesystem with this option. - - - - - option_uid - - - Mount as user - - - Mount this file system as user. - - - - - layout7 - - - - unnamed - - - - text_journaling - - - Journaling: - - - option_journaling - - - <h2>Specifies the journalling mode for file data. Metadata is always journaled. </h2> + <h2>Specifies the journalling mode for file data. Metadata is always journaled. </h2> <h3><b>All Data</b></h3> All data is committed into the journal prior to being written into the main file system. This is the slowest variant with the highest data security. @@ -218,29 +218,29 @@ <h3><b>Write Back</b></h3> Data ordering is not preserved - data may be written into the main file system after its metadata has been committed to the journal. This is rumoured to be the highest-throughput option. It guarantees internal file system integrity, however it can allow old data to appear in files after a crash and journal recovery. - - - - - - All Data - - - - - Ordered - - - - - Write Back - - - - option_journaling - - - <h2>Specifies the journalling mode for file data. Metadata is always journaled. </h2> + + + + + + All Data + + + + + Ordered + + + + + Write Back + + + + option_journaling + + + <h2>Specifies the journalling mode for file data. Metadata is always journaled. </h2> <h3><b>All Data</b></h3> All data is committed into the journal prior to being written into the main file system. This is the slowest variant with the highest data security. @@ -250,30 +250,30 @@ <h3><b>Write Back</b></h3> Data ordering is not preserved - data may be written into the main file system after its metadata has been committed to the journal. This is rumoured to be the highest-throughput option. It guarantees internal file system integrity, however it can allow old data to appear in files after a crash and journal recovery. - - - + - + + + + + layout14 + + + + unnamed + + - layout14 + text_shortname - - - unnamed - - - - text_shortname - - - Short names: - - - option_shortname - - - <h2>Defines the behaviour for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be preferred display.</h2> + + Short names: + + + option_shortname + + + <h2>Defines the behaviour for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be preferred display.</h2> <h3><b>Lower</b></h3> Force the short name to lower case upon display; store a long name when the short name is not all upper case. @@ -286,34 +286,34 @@ <h3><b>Mixed</b></h3> Display the short name as is; store a long name when the short name is not all upper case. - - - - - - Lower - - - - - Windows 95 - - - - - Windows NT - - - - - Mixed - - - - option_shortname - - - <h2>Defines the behaviour for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be preferred display.</h2> + + + + + + Lower + + + + + Windows 95 + + + + + Windows NT + + + + + Mixed + + + + option_shortname + + + <h2>Defines the behaviour for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be preferred display.</h2> <h3><b>Lower</b></h3> Force the short name to lower case upon display; store a long name when the short name is not all upper case. @@ -326,42 +326,40 @@ <h3><b>Mixed</b></h3> Display the short name as is; store a long name when the short name is not all upper case. - - - + - + - - - label_filesystem - - - Filesystem: iso9660 - - - - - spacer1 - - - Vertical - - - Expanding - - - - 20 - 20 - - - - + + + label_filesystem + + + Filesystem: iso9660 + + + + + spacer1 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + Index: kdebase/kioslave/media/mediamanager/halbackend.cpp =================================================================== --- kdebase/kioslave/media/mediamanager/halbackend.cpp (revision 604326) +++ kdebase/kioslave/media/mediamanager/halbackend.cpp (working copy) @@ -1,5 +1,6 @@ /* This file is part of the KDE Project Copyright (c) 2004-2005 Jérôme Lodewyck + Copyright (c) 2006 Valentine Sinitsyn This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -56,9 +57,7 @@ { char* _ppt_string; TQString _ppt_QString; - DBusError error; - dbus_error_init(&error); - _ppt_string = libhal_device_get_property_string(ctx, udi, key, &error); + _ppt_string = libhal_device_get_property_string(ctx, udi, key, NULL); if ( _ppt_string ) _ppt_QString = _ppt_string; libhal_free_string(_ppt_string); @@ -929,7 +928,16 @@ } KConfig config("mediamanagerrc"); - config.setGroup(name); + + 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 valids; @@ -944,6 +952,8 @@ 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()) @@ -956,9 +966,18 @@ 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); - config.setGroup(drive_udi); - bool value = config.readBoolEntry("automount", false); - config.setGroup(name); + 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) @@ -1083,7 +1099,7 @@ TQMap valids = MediaManagerUtils::splitOptions(options); - const char *names[] = { "ro", "quiet", "atime", "uid", "utf8", "flush", "sync", 0 }; + 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");