Class: ConnectionProperties
- Inherits:
-
Gtk::Dialog
- Object
- Gtk::Dialog
- ConnectionProperties
- Defined in:
- lib/ConnectionProperties.rb
Overview
this file is part of manqod-server-console manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Instance Method Summary collapse
-
#initialize(parent_window, cn, manqod_server) ⇒ ConnectionProperties
constructor
A new instance of ConnectionProperties.
- #run ⇒ Object
- #save_conn ⇒ Object
Constructor Details
#initialize(parent_window, cn, manqod_server) ⇒ ConnectionProperties
Returns a new instance of ConnectionProperties.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ConnectionProperties.rb', line 6 def initialize(parent_window,cn,manqod_server) @manqod_server=manqod_server @cn=cn conn=@manqod_server.conn(@cn) super("Connection Properties",parent_window,Gtk::Dialog::MODAL,[Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT]) dh=Gtk::Table.new(2,1) dh.attach2("Conenction: ",Gtk::Label.new(@cn)) @name=dh.attach2("Visible connection name: ",Gtk::Entry.new.set_text(conn["name"])) @uri=dh.attach2("URI:",Gtk::Entry.new.set_text(conn["uri"])) @cache_host=dh.attach2("Memcache host:",Gtk::Entry.new.set_text(conn["cache_host"])) @sql_host=dh.attach2("SQL host:",Gtk::Entry.new.set_text(conn["sql_host"])) @sql_user=dh.attach2("SQL user:",Gtk::Entry.new.set_text(conn["sql_user"])) @sql_password=dh.attach2("SQL password:",Gtk::Entry.new.set_text(conn["sql_password"])) @sql_db=dh.attach2("SQL database:",Gtk::Entry.new.set_text(conn["sql_db"])) dh.attach2("SQL database functions:",Gtk::HButtonBox.new. pack_start(check_db=Gtk::Button.new("check")). pack_start(pstruct_db=Gtk::Button.new("populate\nstructure"))). pack_start(pmanqod_db=Gtk::Button.new("pupulate\nmanqod")) @admin_uri=dh.attach2("Admin URI:",Gtk::Entry.new.set_text(conn["admin_uri"])) @client_uri=dh.attach2("Client URI:",Gtk::Entry.new.set_text(conn["client_uri"])) @auto_load=dh.attach2("Auto load on startup:",Gtk::CheckButton.new.set_active(conn["auto_load"])) @auto_load_order=dh.attach2("Auto load order:",Gtk::Entry.new.set_text(conn["auto_load_order"])) @client_default=dh.attach2("Default for clients:",Gtk::CheckButton.new.set_active(conn["client_default"])) vbox.pack_start(dh) #check and create database and permission check_db.signal_connect("clicked",@cn){|me,cn| begin save_conn @manqod_server.check_sql_db(cn) Gtk::warn("Mysql connection is OK") rescue =>err begin Gtk::warn("checking #{cn.inspect} failed",err,ERROR) dialog=Gtk::Dialog.new("Crate database and permissions",self,Gtk::Dialog::MODAL,[Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT]) holder=Gtk::Table.new(2,1) su=holder.attach2("Super User Username",Gtk::Entry.new.set_text("root")) sup=holder.attach2("Super User Password",Gtk::Entry.new.set_visibility(false)) dialog.vbox.pack_start(holder) dialog.show_all if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT @manqod_server.create_sql_db_and_perms(cn,su.text,sup.text) Gtk::warn("Mysql database and permissions created.\nCheck again.") end rescue =>err2 Gtk::warn("SU on #{@cn.inspect} failed",err2,ERROR) ensure dialog.destroy end end } #populate manqod db pmanqod_db.signal_connect("clicked",@cn){|me,cn| begin save_conn @manqod_server.populate_manqod_db(cn) Gtk::warn("Population of #{cn} was succesful") rescue =>err Gtk::warn("Population of #{cn.inspect} failed",err,ERROR) end } #populate manqod db structure pstruct_db.signal_connect("clicked",@cn){|me,cn| begin save_conn @manqod_server.populate_manqod_db(cn,true) Gtk::warn("Structure population of #{cn} was succesful") rescue =>err Gtk::warn("Structure population of #{cn.inspect} failed",err,ERROR) end } end |
Instance Method Details
#run ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ConnectionProperties.rb', line 84 def run show_all ret=super() if ret==Gtk::Dialog::RESPONSE_ACCEPT save_conn end ret=@name.text destroy ret end |
#save_conn ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ConnectionProperties.rb', line 94 def save_conn begin @manqod_server.set_conn_variables(@cn,{"name" => @name.text, "uri" => @uri.text, "cache_host" => @cache_host.text, "sql_host" => @sql_host.text, "sql_user" => @sql_user.text, "sql_password" => @sql_password.text, "sql_db" => @sql_db.text, "admin_uri" => @admin_uri.text, "client_uri" => @client_uri.text, "auto_load" => @auto_load.active?, "auto_load_order" => @auto_load_order.text, "client_default" => @client_default.active?} ) rescue => err retry if Gtk::warn("restoring #{@cn.inspect} failed",err,ERROR,true) end end |