wow - almost work, but some tricks...

This commit is contained in:
Samoilenko Yuri 2014-01-30 20:39:11 +04:00
parent a54dd853ff
commit 881450146f
3 changed files with 25 additions and 31 deletions

View file

@ -40,11 +40,10 @@ QObject* createSftpInterface(QVariant deviceId)
return new SftpDbusInterface(deviceId.toString()); return new SftpDbusInterface(deviceId.toString());
} }
QDeclarativeEngine* engine_;
QObject* createDBusResponse() QObject* createDBusResponse()
{ {
return new DBusResponse(engine_); return new DBusResponse();
} }
void KdeConnectDeclarativePlugin::registerTypes(const char* uri) void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
@ -60,7 +59,6 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
void KdeConnectDeclarativePlugin::initializeEngine(QDeclarativeEngine* engine, const char* uri) void KdeConnectDeclarativePlugin::initializeEngine(QDeclarativeEngine* engine, const char* uri)
{ {
engine_ = engine;
QDeclarativeExtensionPlugin::initializeEngine(engine, uri); QDeclarativeExtensionPlugin::initializeEngine(engine, uri);
engine->rootContext()->setContextProperty("SftpDbusInterfaceFactory" engine->rootContext()->setContextProperty("SftpDbusInterfaceFactory"

View file

@ -78,6 +78,7 @@ void DBusResponse::onCallFinished(QDBusPendingCallWatcher* watcher)
} }
} }
} }
deleteLater();
} }
const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const

View file

@ -30,20 +30,23 @@ PlasmaComponents.ListItem
property variant sftp: SftpDbusInterfaceFactory.create(deviceId) property variant sftp: SftpDbusInterfaceFactory.create(deviceId)
DBusResponse Component.onCompleted: {
{ var response = DBusResponseFactory.create()
id: resp response.success.connect( function(result) {
onSuccess: { if (result) {
console.log(1) state = "MOUNTED"
if (result)
{
browse.state = "MOUNTED"
} }
} else {
onError: function(message) { state = "UNMOUNTED"
console.debug("error:" + message) }
} })
pendingCall: sftp.isMounted()
response.error.connect( function(message) {
console.error("Error:" + message)
state = "UNMOUNTED"
})
response.pendingCall = sftp.isMounted()
} }
Column { Column {
@ -62,13 +65,11 @@ PlasmaComponents.ListItem
text: "Browse" text: "Browse"
state: "UNMOUNTED" state: "UNMOUNTED"
function mounted() {
console.debug("SUCCESS")
}
onClicked: { onClicked: {
if (state == "UNMOUNTED") { if (state == "UNMOUNTED") {
state = "MOUNTING" state = "MOUNTING"
resp.success.connect(function(result){ var response = DBusResponseFactory.create()
response.success.connect( function(result){
if (result) { if (result) {
state = "MOUNTED" state = "MOUNTED"
} }
@ -77,18 +78,12 @@ PlasmaComponents.ListItem
} }
}) })
resp.error.connect(function(){ response.error.connect( function(message) {
console.debug("ERROR") console.error("Error:" + message)
state = "UNMOUNTED"
}) })
resp.pendingCall = sftp.startBrowsing()
// if (ResponseWaiter.waitForReply(sftp.startBrowsing())) response.pendingCall = sftp.startBrowsing()
// {
// state = "MOUNTED"
// }
// else
// {
// state = "UNMOUNTED"
// }
} }
else { else {
sftp.umount() sftp.umount()