sshfs-mapper qasim-gui: Connect on click.

git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1707 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
glenux 2011-07-21 15:50:57 +00:00
parent 1c0cfa88e5
commit a82eb9c82a
2 changed files with 30 additions and 4 deletions

View file

@ -79,6 +79,7 @@ module Qasim
itemx.setCheckable true; itemx.setCheckable true;
itemx.connect(SIGNAL(:triggered)) do itemx.connect(SIGNAL(:triggered)) do
puts "%s => %s" % [name, itemx.checked ] puts "%s => %s" % [name, itemx.checked ]
map.connect
end end
menu.addAction itemx; menu.addAction itemx;
end end

View file

@ -12,14 +12,13 @@ module Qasim
:user, :user,
:map :map
class MapParseError < RuntimeError class MapParseError < RuntimeError ; end
end class ConnectError < RuntimeError ; end
CYPHER_ARCFOUR = :arcfour CYPHER_ARCFOUR = :arcfour
CYPHER_AES256CBC = "aes-256-cbc".to_sym CYPHER_AES256CBC = "aes-256-cbc".to_sym
CYPHERS = [ CYPHER_ARCFOUR, CYPHER_AES256CBC ] CYPHERS = [ CYPHER_ARCFOUR, CYPHER_AES256CBC ]
def initialize map_path def initialize map_path
@path = map_path @path = map_path
@host = nil @host = nil
@ -99,10 +98,36 @@ module Qasim
def connect def connect
puts "[#{File.basename @path}] Connecting..." puts "[#{File.basename @path}] Connecting..."
puts " #{@user}@#{@host}:#{@port}" puts " #{@user}@#{@host}:#{@port}"
puts " maps = %s" % @maps.map{ |k,v| "%s => %s" % [ k, v ] }.join(', ') #puts " maps = %s" % @maps.map{ |k,v| "%s => %s" % [ k, v ] }.join(', ')
# do something # do something
# test server connection # test server connection
# mount # mount
#
# FIXME: test connexion with Net::SSH + timeout or ask password
@maps.each do |name, remotepath|
pp map
cmd = [ "sshfs" ,
"-o allow_root" ,
"-o idmap=user" ,
"-o uid=%s" % Process.uid,
"-o gid=%s" % Process.gid,
"-o reconnect",
"-o workaround=all",
"-o cache_timeout=240",
"-o ServerAliveInterval 15",
"-o no_readahead",
"-o Ciphers=arcfour",
"-o Port=%s" % @port,
"%s@%s:%s:%s" % [@user,@host,@port,remotepath],
"$localdir" ].join(' ')
rdebug "command: %s" % cmd
=begin
system cmd
if $?.exitstatus != 0 then
raise ConnectError, self
end
=end
end
end end
def disconnect def disconnect