Added support for disconnect.
This commit is contained in:
parent
9cb84c06bb
commit
e6be2a649b
2 changed files with 50 additions and 34 deletions
|
@ -92,16 +92,17 @@ module Qasim
|
|||
#
|
||||
def action_trigger_map_item map, item
|
||||
puts "%s => %s" % [map.path, item.checked ]
|
||||
if map.connected? then
|
||||
puts "disconnect !"
|
||||
else
|
||||
puts "connect !"
|
||||
begin
|
||||
success = true
|
||||
|
||||
@connect_error[map.path] = Set.new
|
||||
@connect_running[map.path] = 0
|
||||
map.connect do |linkname,cmd,cmd_args|
|
||||
if map.connected? then
|
||||
puts "disconnect !"
|
||||
method = :disconnect
|
||||
else
|
||||
puts "connect !"
|
||||
method = :connect
|
||||
end
|
||||
begin
|
||||
map.send(method) do |linkname,cmd,cmd_args|
|
||||
process = Qt::Process.new
|
||||
process.connect(SIGNAL('finished(int, QProcess::ExitStatus)')) do |exitcode,exitstatus|
|
||||
puts "exitcode = %s, exitstatus = %s" % [exitcode, exitstatus]
|
||||
|
@ -112,16 +113,16 @@ module Qasim
|
|||
end
|
||||
if @connect_running[map.path] == 0 then
|
||||
# display someting
|
||||
if @connect_error[map.path] == 0 then
|
||||
if @connect_error[map.path].empty? then
|
||||
|
||||
dbus_notify "%s (%s)" % [APP_NAME, map.name],
|
||||
"<b>Map connected successfully<b>",
|
||||
("<b>Map %sed successfully<b>" % method.to_s),
|
||||
'dialog-information'
|
||||
else
|
||||
erroneous = @connect_error[map.path].to_a.join(', ')
|
||||
dbus_notify "%s (%s)" % [APP_NAME, map.name],
|
||||
("<b>Unable to connect map</b><br>" +
|
||||
"Broken link(s): %s" % erroneous),
|
||||
("<b>Unable to %s map</b><br>" % method.to_s) +
|
||||
("Broken link(s): %s" % erroneous),
|
||||
'dialog-error'
|
||||
end
|
||||
end
|
||||
|
@ -134,8 +135,6 @@ module Qasim
|
|||
puts e.inspect
|
||||
end
|
||||
#FIXME: on error, setChecked false
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
|
19
qasim/map.rb
19
qasim/map.rb
|
@ -174,7 +174,24 @@ module Qasim
|
|||
|
||||
def disconnect &block
|
||||
puts "Disconnecting map #{@path}"
|
||||
# umount
|
||||
@links.each do |name, remotepath|
|
||||
pp map
|
||||
localpath = File.join ENV['HOME'], "mnt", name
|
||||
cmd = "fusermount"
|
||||
cmd_args = [
|
||||
"-u", #umount
|
||||
"-z" ,#lazy
|
||||
localpath ]
|
||||
rdebug "command: %s" % [ cmd, cmd_args ].flatten.join(' ')
|
||||
if block_given? then
|
||||
yield name, cmd, cmd_args
|
||||
else
|
||||
system cmd, cmd_args
|
||||
if $?.exitstatus != 0 then
|
||||
raise ConnectError, self
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue