[Kde-hardware-devel] KDE/kdelibs/solid/solid/backends/fstab
Jacopo De Simoi
wilderkde at gmail.com
Tue Jan 4 11:18:07 CET 2011
SVN commit 1211505 by jacopods:
forwardport r1211499: do the "dbus dance" for the fstab backend
We should investigate whether it is sane or not to implement the "dbus dance"
for all backends separately or find a better way.
Ideas and suggestions are welcome.
CCMAIL: kde-hardware-devel at kde.org
M +41 -6 fstabstorageaccess.cpp
M +7 -0 fstabstorageaccess.h
--- trunk/KDE/kdelibs/solid/solid/backends/fstab/fstabstorageaccess.cpp #1211504:1211505
@@ -25,6 +25,8 @@
#include <solid/backends/fstab/fstabservice.h>
#include <QtCore/QStringList>
+#include <QTimer>
+
#define MTAB "/etc/mtab"
using namespace Solid::Backends::Fstab;
@@ -36,12 +38,25 @@
m_currentMountPoints = FstabHandling::currentMountPoints();
connect(FstabWatcher::instance(), SIGNAL(mtabChanged()), this, SLOT(onMtabChanged()));
+ QTimer::singleShot(0, this, SLOT(connectDBusSignals()));
}
FstabStorageAccess::~FstabStorageAccess()
{
}
+
+void FstabStorageAccess::connectDBusSignals()
+{
+ m_fstabDevice->registerAction("setup", this,
+ SLOT(slotSetupRequested()),
+ SLOT(slotSetupDone(int, const QString&)));
+
+ m_fstabDevice->registerAction("teardown", this,
+ SLOT(slotTeardownRequested()),
+ SLOT(slotTeardownDone(int, const QString&)));
+}
+
const Solid::Backends::Fstab::FstabDevice *FstabStorageAccess::fstabDevice() const
{
return m_fstabDevice;
@@ -76,45 +91,65 @@
if (filePath().isEmpty()) {
return false;
}
- emit setupRequested(m_fstabDevice->udi());
+ m_fstabDevice->broadcastActionRequested("setup");
m_process = FstabHandling::callSystemCommand("mount", filePath(),
this, SLOT(slotSetupFinished(int, QProcess::ExitStatus)));
return m_process!=0;
}
+void FstabStorageAccess::slotSetupRequested()
+{
+ emit setupRequested(m_fstabDevice->udi());
+}
+
bool FstabStorageAccess::teardown()
{
if (filePath().isEmpty()) {
return false;
}
- emit teardownRequested(m_fstabDevice->udi());
+ m_fstabDevice->broadcastActionRequested("teardown");
m_process = FstabHandling::callSystemCommand("umount", filePath(),
this, SLOT(slotTeardownFinished(int, QProcess::ExitStatus)));
return m_process!=0;
}
+void FstabStorageAccess::slotTeardownRequested()
+{
+ emit teardownRequested(m_fstabDevice->udi());
+}
+
void FstabStorageAccess::slotSetupFinished(int exitCode, QProcess::ExitStatus /*exitStatus*/)
{
if (exitCode==0) {
- emit setupDone(Solid::NoError, QVariant(), m_fstabDevice->udi());
+ m_fstabDevice->broadcastActionDone("setup", Solid::NoError, QString());
} else {
- emit setupDone(Solid::UnauthorizedOperation, m_process->readAllStandardError(), m_fstabDevice->udi());
+ m_fstabDevice->broadcastActionDone("setup", Solid::UnauthorizedOperation, m_process->readAllStandardError());
}
delete m_process;
}
+void FstabStorageAccess::slotSetupDone(int error, const QString &errorString)
+{
+ emit setupDone(static_cast<Solid::ErrorType>(error), errorString, m_fstabDevice->udi());
+}
+
void FstabStorageAccess::slotTeardownFinished(int exitCode, QProcess::ExitStatus /*exitStatus*/)
{
if (exitCode==0) {
- emit teardownDone(Solid::NoError, QVariant(), m_fstabDevice->udi());
+ m_fstabDevice->broadcastActionDone("teardown", Solid::NoError, QString());
} else {
- emit teardownDone(Solid::UnauthorizedOperation, m_process->readAllStandardError(), m_fstabDevice->udi());
+ m_fstabDevice->broadcastActionDone("teardown", Solid::UnauthorizedOperation, m_process->readAllStandardError());
}
delete m_process;
}
+void FstabStorageAccess::slotTeardownDone(int error, const QString &errorString)
+{
+ emit teardownDone(static_cast<Solid::ErrorType>(error), errorString, m_fstabDevice->udi());
+}
+
void FstabStorageAccess::onMtabChanged()
{
QStringList currentMountPoints = FstabHandling::currentMountPoints();
--- trunk/KDE/kdelibs/solid/solid/backends/fstab/fstabstorageaccess.h #1211504:1211505
@@ -71,6 +71,13 @@
void slotSetupFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotTeardownFinished(int exitCode, QProcess::ExitStatus exitStatus);
void onMtabChanged();
+ void connectDBusSignals();
+
+ void slotSetupRequested();
+ void slotSetupDone(int error, const QString &errorString);
+ void slotTeardownRequested();
+ void slotTeardownDone(int error, const QString &errorString);
+
private:
Solid::Backends::Fstab::FstabDevice *m_fstabDevice;
QProcess *m_process;
More information about the Kde-hardware-devel
mailing list