ref: refs/heads/master
commit b37ea623fa549a000ebd24e6a53ffb544237f711
Author: Klaus Kämpf
Date: Thu Jul 9 17:01:58 2009 +0200
refactor slp scan out of SessionsController
---
webclient/app/controllers/sessions_controller.rb | 33 ----------------------
webclient/lib/slp_scan.rb | 33 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/webclient/app/controllers/sessions_controller.rb b/webclient/app/controllers/sessions_controller.rb
index 9083daf..52c53d8 100644
--- a/webclient/app/controllers/sessions_controller.rb
+++ b/webclient/app/controllers/sessions_controller.rb
@@ -13,39 +13,6 @@ class SessionsController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
- # helper scan for hosts via slp
- # may be move out?
- def scan
- @hosts = []
- # make output parseable + terminate
- services = `avahi-browse _yastws._tcp -t -p --no-db-lookup`
-
- # +;eth0;IPv4;YaST\032Webservice\032http\058\047\047aries\.suse\.de\0588080;_yastws._tcp;local
-
- services.each do |s|
- sp = s.split ";"
- next unless sp[0] == "+"
- name = sp[3]
- sp = name.split "\\"
- name = ""
- sp.each do |s|
- if s.length > 2
- val = s[0,3].to_i
- if val > 0
- s = val.chr + (s[3..-1] || "")
- end
- name << s
- end
- end
- url = name.split(" ").pop || name
-
- if Webservice.find(:first, :conditions => "name = '#{url}'") == nil
- host = Webservice.new({"name"=>url, "desc"=>"via network scan"})
- @webservices << host
- end
- end
- end
-
def index
# only used to display the flash message
end
diff --git a/webclient/lib/slp_scan.rb b/webclient/lib/slp_scan.rb
new file mode 100644
index 0000000..505c2be
--- /dev/null
+++ b/webclient/lib/slp_scan.rb
@@ -0,0 +1,33 @@
+# helper scan for hosts via slp
+module Slp
+ def scan
+ @hosts = []
+ # make output parseable + terminate
+ services = `avahi-browse _yastws._tcp -t -p --no-db-lookup`
+
+ # +;eth0;IPv4;YaST\032Webservice\032http\058\047\047aries\.suse\.de\0588080;_yastws._tcp;local
+
+ services.each do |s|
+ sp = s.split ";"
+ next unless sp[0] == "+"
+ name = sp[3]
+ sp = name.split "\\"
+ name = ""
+ sp.each do |s|
+ if s.length > 2
+ val = s[0,3].to_i
+ if val > 0
+ s = val.chr + (s[3..-1] || "")
+ end
+ name << s
+ end
+ end
+ url = name.split(" ").pop || name
+
+ if Webservice.find(:first, :conditions => "name = '#{url}'").nil?
+ host = Webservice.new({"name"=>url, "desc"=>"via network scan"})
+ @webservices << host
+ end
+ end
+ end
+end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org