Fixed sftp plugin crashing when mounting
Removed sftp notificatons and some configuration options Homogenized coding style
This commit is contained in:
parent
400cff1c9c
commit
e9a9d742d6
7 changed files with 70 additions and 248 deletions
|
@ -389,86 +389,3 @@ Comment[tr]=Bilinmeyen bir durum oluştu
|
|||
Comment[uk]=Сталося щось невідоме програмі
|
||||
Comment[x-test]=xxSomething unknown happenedxx
|
||||
Action=Popup
|
||||
|
||||
[Event/mounted]
|
||||
Name=Mounted
|
||||
Name[bg]=Монтирана
|
||||
Name[ca]=Muntada
|
||||
Name[cs]=Připojen
|
||||
Name[da]=Monteret
|
||||
Name[de]=Eingebunden
|
||||
Name[fr]=Monté
|
||||
Name[hu]=Csatolva
|
||||
Name[ko]=마운트됨
|
||||
Name[nl]=Aangekoppeld
|
||||
Name[pl]=Zamontowany
|
||||
Name[pt]=Montado
|
||||
Name[pt_BR]=Montado
|
||||
Name[ro]=Montat
|
||||
Name[sk]=Pripojené
|
||||
Name[sv]=Monterat
|
||||
Name[tr]=Bağlı
|
||||
Name[uk]=Змонтовано
|
||||
Name[x-test]=xxMountedxx
|
||||
Comment=Filesystem mounted
|
||||
Comment[bg]=Файловата система е монтирана
|
||||
Comment[ca]=Sistema de fitxers muntat
|
||||
Comment[cs]=Souborový systém byl připojen
|
||||
Comment[da]=Filsystem monteret
|
||||
Comment[de]=Dateisystem eingebunden
|
||||
Comment[fr]=Système de fichiers monté
|
||||
Comment[hu]=Fájlrendszer csatolva
|
||||
Comment[ko]=파일 시스템 마운트됨
|
||||
Comment[nl]=Bestandssysteem aangekoppeld
|
||||
Comment[pl]=Zamontowano system plików
|
||||
Comment[pt]=Sistema de ficheiros montado
|
||||
Comment[pt_BR]=Sistema de arquivos montado
|
||||
Comment[ro]=Sistem de fișiere montat
|
||||
Comment[sk]=Súborový systém pripojený
|
||||
Comment[sv]=Filsystem monterat
|
||||
Comment[tr]=Dosya sistemi bağlandı
|
||||
Comment[uk]=Файлову систему змонтовано
|
||||
Comment[x-test]=xxFilesystem mountedxx
|
||||
Action=None
|
||||
|
||||
[Event/unmounted]
|
||||
Name=Unmounted
|
||||
Name[bg]=Демонтирана
|
||||
Name[ca]=Desmuntat
|
||||
Name[cs]=Odpojen
|
||||
Name[da]=Afmonteret
|
||||
Name[de]=Einbindung gelöst
|
||||
Name[fr]=Libéré
|
||||
Name[hu]=Leválasztva
|
||||
Name[ko]=마운트 해제됨
|
||||
Name[nl]=Afgekoppeld
|
||||
Name[pl]=Odmontowano
|
||||
Name[pt]=Desmontado
|
||||
Name[pt_BR]=Desmontado
|
||||
Name[ro]=Nemontat
|
||||
Name[sk]=Nepripojený
|
||||
Name[sv]=Avmonterat
|
||||
Name[tr]=Ayrıldı
|
||||
Name[uk]=Демонтовано
|
||||
Name[x-test]=xxUnmountedxx
|
||||
Comment=Filesystem unmounted
|
||||
Comment[bg]=Файловата система е демонтирана
|
||||
Comment[ca]=Sistema de fitxers desmuntat
|
||||
Comment[cs]=Souborový systém byl odpojen
|
||||
Comment[da]=Filsystem afmonteret
|
||||
Comment[de]=Einbindung des Dateisystems gelöst
|
||||
Comment[fr]=Système de fichiers libéré
|
||||
Comment[hu]=Fájlrendszer leválasztva
|
||||
Comment[ko]=파일 시스템 마운트 해제됨
|
||||
Comment[nl]=Bestandssysteem afgekoppeld
|
||||
Comment[pl]=Odmontowano system plików
|
||||
Comment[pt]=Sistema de ficheiros desmontado
|
||||
Comment[pt_BR]=Sistema de arquivos desmontado
|
||||
Comment[ro]=Sistem de fișiere nemontat
|
||||
Comment[sk]=Súborový systém odpojený
|
||||
Comment[sv]=Filsystem avmonterat
|
||||
Comment[tr]=Dosya sistemi ayrıldı
|
||||
Comment[uk]=Файлову систему демонтовано
|
||||
Comment[x-test]=xxFilesystem unmountedxx
|
||||
Action=None
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ SftpConfig::SftpConfig(QWidget *parent, const QVariantList& )
|
|||
|
||||
connect(m_ui->refresh, SIGNAL(clicked(bool)), this, SLOT(checkSshfs()));
|
||||
|
||||
connect(m_ui->mountpoint, SIGNAL(textChanged(QString)), this, SLOT(changed()));
|
||||
connect(m_ui->idle, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->timeout, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
}
|
||||
|
@ -65,8 +64,6 @@ void SftpConfig::defaults()
|
|||
KCModule::defaults();
|
||||
|
||||
checkSshfs();
|
||||
m_ui->mountpoint->setUrl(m_cfg->group("main").readEntry("mountpoint"
|
||||
, KStandardDirs::locateLocal("appdata", "", true, SftpPlugin::componentData())));
|
||||
m_ui->idle->setChecked(m_cfg->group("main").readEntry("idle", true));
|
||||
m_ui->timeout->setValue(m_cfg->group("main").readEntry("idletimeout", 10));
|
||||
|
||||
|
@ -79,8 +76,6 @@ void SftpConfig::load()
|
|||
KCModule::load();
|
||||
|
||||
checkSshfs();
|
||||
m_ui->mountpoint->setUrl(m_cfg->group("main").readEntry("mountpoint"
|
||||
, KStandardDirs::locateLocal("appdata", "", true, SftpPlugin::componentData())));
|
||||
m_ui->idle->setChecked(m_cfg->group("main").readEntry("idle", true));
|
||||
m_ui->timeout->setValue(m_cfg->group("main").readEntry("idletimeout", 10));
|
||||
|
||||
|
@ -93,7 +88,6 @@ void SftpConfig::save()
|
|||
checkSshfs();
|
||||
m_cfg->group("main").writeEntry("idle", m_ui->idle->isChecked());
|
||||
m_cfg->group("main").writeEntry("idletimeout", m_ui->timeout->value());
|
||||
m_cfg->group("main").writeEntry("mountpoint", m_ui->mountpoint->url().url());
|
||||
|
||||
KCModule::save();
|
||||
Q_EMIT changed(false);
|
||||
|
|
|
@ -9,51 +9,15 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>303</width>
|
||||
<height>155</height>
|
||||
<width>505</width>
|
||||
<height>127</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share plugin settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="2">
|
||||
<widget class="KUrlRequester" name="mountpoint">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="mode">
|
||||
<set>KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly</set>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>291</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="idle">
|
||||
<property name="text">
|
||||
<string>Disconnect when idle</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="error">
|
||||
<property name="title">
|
||||
<string>Error</string>
|
||||
|
@ -101,23 +65,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mountpoint:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
|
@ -132,6 +80,29 @@
|
|||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="idle">
|
||||
<property name="text">
|
||||
<string>Disconnect when idle</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>53</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
|
@ -170,31 +141,24 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>53</width>
|
||||
<height>20</height>
|
||||
<width>291</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KUrlRequester</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>kurlrequester.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
|
@ -87,15 +87,14 @@ void SftpPlugin::removeFromDolphin()
|
|||
|
||||
void SftpPlugin::connected()
|
||||
{
|
||||
kDebug(kdeconnect_kded()) << "Exposing DBUS interface: "
|
||||
<< QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents);
|
||||
bool state = QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents);
|
||||
kDebug(kdeconnect_kded()) << "Exposing DBUS interface: " << state;
|
||||
}
|
||||
|
||||
void SftpPlugin::mount()
|
||||
{
|
||||
kDebug(kdeconnect_kded()) << "Device:" << device()->name();
|
||||
if (m_d->mounter)
|
||||
{
|
||||
kDebug(kdeconnect_kded()) << "Mount device:" << device()->name();
|
||||
if (m_d->mounter) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -113,8 +112,11 @@ void SftpPlugin::mount()
|
|||
|
||||
void SftpPlugin::unmount()
|
||||
{
|
||||
//FIXME
|
||||
if (m_d->mounter) m_d->mounter->deleteLater();
|
||||
if (m_d->mounter)
|
||||
{
|
||||
m_d->mounter->deleteLater();
|
||||
m_d->mounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool SftpPlugin::mountAndWait()
|
||||
|
@ -130,8 +132,7 @@ bool SftpPlugin::isMounted() const
|
|||
|
||||
bool SftpPlugin::startBrowsing()
|
||||
{
|
||||
if (mountAndWait())
|
||||
{
|
||||
if (mountAndWait()) {
|
||||
//return new KRun(KUrl::fromLocalFile(mountPoint()), 0);
|
||||
return new KRun(KUrl::fromPathOrUrl("kdeconnect://"+device()->id()), 0);
|
||||
}
|
||||
|
@ -153,8 +154,7 @@ bool SftpPlugin::receivePackage(const NetworkPackage& np)
|
|||
|
||||
QString SftpPlugin::mountPoint()
|
||||
{
|
||||
const QString defaultMountDir = KStandardDirs::locateLocal("appdata", "", true, componentData());
|
||||
const QString mountDir = KConfig("kdeconnect/plugins/sftp").group("main").readEntry("mountpoint", defaultMountDir);
|
||||
const QString mountDir = KStandardDirs::locateLocal("appdata", "", true, KComponentData("kdeconnect", "kdeconnect"));
|
||||
return QDir(mountDir).absoluteFilePath(device()->id());
|
||||
}
|
||||
|
||||
|
@ -162,36 +162,18 @@ void SftpPlugin::onMounted()
|
|||
{
|
||||
kDebug(kdeconnect_kded()) << device()->name() << QString("Remote filesystem mounted at %1").arg(mountPoint());
|
||||
|
||||
KNotification* notification = new KNotification("mounted", KNotification::CloseOnTimeout, this);
|
||||
notification->setPixmap(KIconLoader::global()->loadIcon("drive-removable-media", KIconLoader::Desktop));
|
||||
notification->setComponentData(KComponentData("kdeconnect", "kdeconnect-kded"));
|
||||
notification->setTitle(i18n("Device %1", device()->name()));
|
||||
notification->setText(i18n("Filesystem mounted at %1", mountPoint()));
|
||||
notification->sendEvent();
|
||||
|
||||
Q_EMIT mounted();
|
||||
}
|
||||
|
||||
void SftpPlugin::onUnmounted(bool idleTimeout)
|
||||
{
|
||||
if (idleTimeout)
|
||||
{
|
||||
if (idleTimeout) {
|
||||
kDebug(kdeconnect_kded()) << device()->name() << "Remote filesystem unmounted by idle timeout";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
kDebug(kdeconnect_kded()) << device()->name() << "Remote filesystem unmounted";
|
||||
}
|
||||
|
||||
KNotification* notification = new KNotification("unmounted", KNotification::CloseOnTimeout, this);
|
||||
notification->setPixmap(KIconLoader::global()->loadIcon("dialog-ok", KIconLoader::Desktop));
|
||||
notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
|
||||
notification->setTitle(i18n("Device %1", device()->name()));
|
||||
notification->setText(i18n("Filesystem unmounted"));
|
||||
notification->sendEvent();
|
||||
|
||||
m_d->mounter->deleteLater();
|
||||
m_d->mounter = 0;
|
||||
unmount();
|
||||
|
||||
Q_EMIT unmounted();
|
||||
}
|
||||
|
@ -202,8 +184,8 @@ void SftpPlugin::onFailed(const QString& message)
|
|||
, message
|
||||
, KIconLoader::global()->loadIcon("dialog-error", KIconLoader::Desktop)
|
||||
);
|
||||
m_d->mounter->deleteLater();
|
||||
m_d->mounter = 0;
|
||||
|
||||
unmount();
|
||||
|
||||
Q_EMIT unmounted();
|
||||
}
|
||||
|
|
|
@ -38,11 +38,6 @@ public:
|
|||
explicit SftpPlugin(QObject *parent, const QVariantList &args);
|
||||
virtual ~SftpPlugin();
|
||||
|
||||
inline static KComponentData componentData()
|
||||
{
|
||||
return KComponentData("kdeconnect", "kdeconnect");
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
void packageReceived(const NetworkPackage& np);
|
||||
|
|
|
@ -48,7 +48,7 @@ QtObject {
|
|||
onSuccess: root.charge = result
|
||||
}
|
||||
|
||||
/* Note: magically called by qml */
|
||||
// Note: magically called by qml
|
||||
onAvailableChanged: {
|
||||
if (available) {
|
||||
battery = DeviceBatteryDbusInterfaceFactory.create(deviceId)
|
||||
|
@ -58,8 +58,7 @@ QtObject {
|
|||
|
||||
startupCheck1.setPendingCall(battery.isCharging())
|
||||
startupCheck2.setPendingCall(battery.charge())
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
battery = null
|
||||
}
|
||||
}
|
||||
|
@ -69,8 +68,7 @@ QtObject {
|
|||
|
||||
if (result && result != "error") {
|
||||
available = true
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
available = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,58 +31,30 @@ QtObject {
|
|||
property variant device: DeviceDbusInterfaceFactory.create(deviceId)
|
||||
property bool available: false
|
||||
|
||||
property bool isMounted: false
|
||||
property variant sftp: null
|
||||
property variant nested: DBusAsyncResponse {
|
||||
id: startupCheck
|
||||
onSuccess: (result) ? root.mounted() : root.unmounted()
|
||||
onError: root.error(message)
|
||||
}
|
||||
|
||||
signal mounted
|
||||
signal unmounted
|
||||
signal error(string message)
|
||||
|
||||
onMounted: isMounted = true
|
||||
onUnmounted: isMounted = false
|
||||
|
||||
function browse() {
|
||||
startupCheck.setPendingCall(sftp.startBrowsing())
|
||||
}
|
||||
|
||||
function unmount() {
|
||||
sftp.unmount()
|
||||
if (sftp)
|
||||
sftp.startBrowsing();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
device.pluginsChanged.connect(pluginsChanged)
|
||||
device.pluginsChanged()
|
||||
pluginsChanged()
|
||||
}
|
||||
|
||||
/* Note: magically called by qml */
|
||||
// Note: magically called by qml
|
||||
onAvailableChanged: {
|
||||
if (available) {
|
||||
sftp = SftpDbusInterfaceFactory.create(deviceId)
|
||||
|
||||
sftp.mounted.connect(mounted)
|
||||
sftp.unmounted.connect(unmounted)
|
||||
|
||||
startupCheck.setPendingCall(sftp.isMounted())
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sftp = null
|
||||
}
|
||||
}
|
||||
|
||||
function pluginsChanged() {
|
||||
var result = DBusResponseWaiter.waitForReply(device.hasPlugin("kdeconnect_sftp"))
|
||||
|
||||
if (result && result != "error") {
|
||||
available = true
|
||||
}
|
||||
else {
|
||||
available = false
|
||||
}
|
||||
available = (result && result != "error");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue