rsence 2.0.9.23 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL.rdoc +61 -49
- data/README.rdoc +20 -4
- data/VERSION +1 -1
- data/conf/default_conf.yaml +8 -0
- data/conf/rsence_command_strings.yaml +31 -20
- data/docs/ExampleGuiPlugin.rdoc +2 -2
- data/js/comm/comm.js +27 -5
- data/js/comm/transporter/transporter.js +1 -1
- data/js/comm/values/values.js +12 -5
- data/js/controls/button/button.js +12 -2
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +13 -1
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +13 -2
- data/js/controls/dialogs/sheet/sheet.js +35 -28
- data/js/controls/imageview/imageview.js +13 -13
- data/js/controls/progress/progressindicator/progressindicator.js +5 -5
- data/js/controls/sliders/slider/slider.js +4 -31
- data/js/controls/stepper/stepper.js +12 -19
- data/js/controls/textcontrol/textcontrol.js +0 -50
- data/js/controls/textcontrol/themes/default/textcontrol.html +1 -1
- data/js/controls/window/window.js +1 -1
- data/js/core/elem/elem.js +146 -160
- data/js/core/rsence_ns/rsence_ns.js +7 -0
- data/js/foundation/control/eventresponder/eventresponder.js +8 -7
- data/js/foundation/eventmanager/eventmanager.js +81 -48
- data/js/foundation/geom/rect/rect.js +1 -1
- data/js/foundation/json_renderer/json_renderer.js +4 -1
- data/js/foundation/system/system.js +37 -34
- data/js/foundation/view/morphanimation/morphanimation.js +53 -43
- data/js/foundation/view/view.js +119 -118
- data/js/lists/listitems/listitems.js +10 -10
- data/js/lists/propertylist/js.inc +0 -0
- data/js/lists/propertylist/propertylist.js +574 -0
- data/js/lists/propertylist/propertylisteditor/js.inc +0 -0
- data/js/lists/propertylist/propertylisteditor/propertylisteditor.js +233 -0
- data/js/lists/radiobuttonlist/radiobuttonlist.js +15 -8
- data/js/menus/minimenu/js.inc +0 -0
- data/js/menus/minimenu/minimenu.js +139 -0
- data/js/menus/minimenu/minimenuitem/js.inc +0 -0
- data/js/menus/minimenu/minimenuitem/minimenuitem.js +33 -0
- data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem.css +45 -0
- data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem.html +4 -0
- data/js/menus/minimenu/minimenuitem/themes/default/minimenuitem_checkmark.png +0 -0
- data/js/menus/minimenu/themes/default/minimenu.css +63 -0
- data/js/menus/minimenu/themes/default/minimenu.html +7 -0
- data/js/menus/minimenu/themes/default/minimenu.png +0 -0
- data/js/util/reloadapp/reloadapp.js +1 -1
- data/lib/conf/argv.rb +40 -11
- data/lib/daemon/daemon.rb +63 -22
- data/lib/plugins/gui_plugin.rb +28 -31
- data/lib/plugins/guiparser.rb +37 -7
- data/lib/plugins/plugin.rb +260 -28
- data/lib/plugins/plugin_base.rb +14 -0
- data/lib/plugins/plugin_plugins.rb +11 -1
- data/lib/plugins/pluginmanager.rb +127 -44
- data/lib/plugins/plugins.rb +10 -1
- data/lib/session/msg.rb +25 -1
- data/lib/session/sessionmanager.rb +11 -2
- data/lib/session/sessionstorage.rb +14 -14
- data/lib/transporter/transporter.rb +29 -13
- data/lib/values/hvalue.rb +30 -0
- data/plugins/client_pkg/info.yaml +2 -2
- data/plugins/{index_html → main}/img/loading.gif +0 -0
- data/plugins/{index_html → main}/img/riassence.gif +0 -0
- data/plugins/main/info.yaml +5 -4
- data/plugins/main/main.rb +180 -24
- data/plugins/{index_html → main}/tmpl/index.html +4 -2
- data/plugins/ticket/info.yaml +2 -2
- data/plugins/ticket/lib/upload.rb +57 -5
- data/plugins/ticket/ticket.rb +10 -4
- data/setup/welcome/info.yaml +2 -2
- data/setup/welcome/text/welcome.html +1 -1
- metadata +22 -11
- data/plugins/index_html/index_html.rb +0 -120
- data/plugins/index_html/info.yaml +0 -18
@@ -23,9 +23,21 @@ module RSence
|
|
23
23
|
|
24
24
|
attr_reader :transporter, :sessions
|
25
25
|
|
26
|
+
@@incr = 0
|
27
|
+
def incr
|
28
|
+
return @@incr
|
29
|
+
end
|
30
|
+
|
26
31
|
# Returns the registry data for plugin bundle +plugin_name+
|
27
|
-
def registry( plugin_name )
|
28
|
-
return @registry
|
32
|
+
def registry( plugin_name=false )
|
33
|
+
return @registry unless plugin_name
|
34
|
+
if @registry.has_key?( plugin_name )
|
35
|
+
return @registry[ plugin_name ]
|
36
|
+
elsif @parent_manager
|
37
|
+
return @parent_manager.registry( plugin_name )
|
38
|
+
else
|
39
|
+
throw "Plugin not in registry: #{plugin_name.inspect}"
|
40
|
+
end
|
29
41
|
end
|
30
42
|
alias [] registry
|
31
43
|
|
@@ -37,6 +49,8 @@ module RSence
|
|
37
49
|
elsif block == nil
|
38
50
|
call( sym, *args )
|
39
51
|
end
|
52
|
+
elsif @parent_manager
|
53
|
+
return @parent_manager.method_missing( sym, *args, &block )
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
@@ -63,11 +77,27 @@ module RSence
|
|
63
77
|
inst.init if inst.respond_to? :init and not inst.inited
|
64
78
|
@registry[ bundle_name ] = inst
|
65
79
|
if inst.respond_to?( :match ) and ( inst.respond_to?( :get ) or inst.respond_to?( :post ) )
|
66
|
-
|
80
|
+
add_servlet( bundle_name )
|
67
81
|
end
|
68
82
|
end
|
69
83
|
end
|
70
84
|
|
85
|
+
def add_servlet( bundle_name )
|
86
|
+
if @parent_manager
|
87
|
+
sub_name = "#{@name_prefix.to_s}:#{bundle_name.to_s}"
|
88
|
+
@parent_manager.add_servlet( sub_name )
|
89
|
+
end
|
90
|
+
@servlets.push( bundle_name )
|
91
|
+
end
|
92
|
+
|
93
|
+
def del_servlet( bundle_name )
|
94
|
+
if @parent_manager
|
95
|
+
sub_name = "#{@name_prefix.to_s}:#{bundle_name.to_s}"
|
96
|
+
@parent_manager.del_servlet( sub_name )
|
97
|
+
end
|
98
|
+
@servlets.delete( bundle_name )
|
99
|
+
end
|
100
|
+
|
71
101
|
def callable?( plugin_name, method_name )
|
72
102
|
return false if @deps.category?( plugin_name )
|
73
103
|
return false unless @registry.has_key?( plugin_name )
|
@@ -79,6 +109,20 @@ module RSence
|
|
79
109
|
# Calls the method +method_name+ with args +args+ of the plugin +plugin_name+.
|
80
110
|
# Returns false, if no such plugin or method exists.
|
81
111
|
def call( plugin_name, method_name, *args )
|
112
|
+
puts "#{plugin_name}.#{method_name}" if RSence.args[:trace_delegate]
|
113
|
+
plugin_name_s = plugin_name.to_s
|
114
|
+
if plugin_name_s.include?(':')
|
115
|
+
colon_index = plugin_name_s.index(':')
|
116
|
+
sub_manager_name = plugin_name_s[0..(colon_index-1)].to_sym
|
117
|
+
plugin_name = plugin_name_s[(colon_index+1)..-1].to_sym
|
118
|
+
if @registry.has_key?( sub_manager_name )
|
119
|
+
sub_manager = @registry[sub_manager_name]
|
120
|
+
if sub_manager.respond_to?( :plugin_plugins )
|
121
|
+
return sub_manager.plugin_plugins.call( plugin_name, method_name, *args )
|
122
|
+
end
|
123
|
+
end
|
124
|
+
return false
|
125
|
+
end
|
82
126
|
plugin_name = plugin_name.to_sym
|
83
127
|
if callable?( plugin_name, method_name )
|
84
128
|
begin
|
@@ -94,7 +138,7 @@ module RSence
|
|
94
138
|
elsif @deps.category?( plugin_name )
|
95
139
|
warn "Warning! Tried to call category: #{plugin_name.inpsect}"
|
96
140
|
elsif not @registry.has_key?( plugin_name )
|
97
|
-
warn "Warning! No such plugin: #{plugin_name.inspect}"
|
141
|
+
warn "Warning (#{@pluginmanager_id})! No such plugin: #{plugin_name.inspect} (tried to call #{method_name.inspect[0..100]} using args: #{args.inspect[0..100]}"
|
98
142
|
elsif not @registry[ plugin_name ].respond_to?( method_name )
|
99
143
|
warn "Warning! Plugin: #{plugin_name.inspect} does not respond to #{method_name.inspect}"
|
100
144
|
end
|
@@ -103,6 +147,7 @@ module RSence
|
|
103
147
|
alias run_plugin call
|
104
148
|
|
105
149
|
# Prettier error handling.
|
150
|
+
@@prev_errors = []
|
106
151
|
def plugin_error( e, err_location, err_location_descr, eval_repl=false )
|
107
152
|
err_msg = [
|
108
153
|
"*"*40,
|
@@ -113,6 +158,12 @@ module RSence
|
|
113
158
|
"\t"+e.backtrace.join("\n\t"),
|
114
159
|
"*"*40
|
115
160
|
].join("\n")+"\n"
|
161
|
+
error_say = "Error! #{err_location_descr.capitalize}. #{e.class.to_s}, #{e.message}?"
|
162
|
+
unless @@prev_errors.include?( error_say )
|
163
|
+
@@prev_errors.push( error_say )
|
164
|
+
say error_say
|
165
|
+
end
|
166
|
+
@@prev_errors.shift if @@prev_errors.length > 10
|
116
167
|
if eval_repl
|
117
168
|
puts
|
118
169
|
puts "plugin: #{eval_repl}"
|
@@ -126,21 +177,10 @@ module RSence
|
|
126
177
|
def match_servlet_uri( uri, req_type=:get )
|
127
178
|
match_score = {}
|
128
179
|
@servlets.each do | servlet_name |
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
score = servlet.score
|
134
|
-
match_score[ score ] = [] unless match_score.has_key? score
|
135
|
-
match_score[ score ].push( servlet_name )
|
136
|
-
end
|
137
|
-
rescue => e
|
138
|
-
plugin_error(
|
139
|
-
e,
|
140
|
-
"RSence::PluginManager.match_servlet_uri",
|
141
|
-
"servlet: #{servlet_name.inspect}, req_type: #{req_type.inspect}, uri: #{uri.inspect}",
|
142
|
-
servlet_name
|
143
|
-
)
|
180
|
+
if call( servlet_name, :match, uri, req_type )
|
181
|
+
score = call( servlet_name, :score )
|
182
|
+
match_score[ score ] = [] unless match_score.has_key? score
|
183
|
+
match_score[ score ].push( servlet_name )
|
144
184
|
end
|
145
185
|
end
|
146
186
|
match_scores = match_score.keys.sort
|
@@ -172,7 +212,7 @@ module RSence
|
|
172
212
|
return false unless matches_order
|
173
213
|
matches_order.each do |servlet_name|
|
174
214
|
begin
|
175
|
-
|
215
|
+
call( servlet_name, req_type, req, resp, session )
|
176
216
|
return true
|
177
217
|
rescue => e
|
178
218
|
plugin_error(
|
@@ -206,7 +246,11 @@ module RSence
|
|
206
246
|
# Delegates the +flush+ and +close+ methods to any
|
207
247
|
# loaded plugins, in that order.
|
208
248
|
def shutdown
|
209
|
-
@
|
249
|
+
if @parent_manager
|
250
|
+
@closed = true
|
251
|
+
else
|
252
|
+
@transporter.online = false
|
253
|
+
end
|
210
254
|
@deps.list.reverse.each do |bundle_name|
|
211
255
|
unload_bundle( bundle_name )
|
212
256
|
end
|
@@ -221,9 +265,10 @@ module RSence
|
|
221
265
|
end
|
222
266
|
if is_dir
|
223
267
|
Dir.entries( bundle_path ).each do |entry_name|
|
224
|
-
next if entry_name[0].chr == '.'
|
268
|
+
next if entry_name[0].chr == '.' # skip hidden, '.' and '..'
|
225
269
|
full_path = File.join( bundle_path, entry_name )
|
226
270
|
unless File.directory?( full_path )
|
271
|
+
next if entry_name == 'plugins' # skip sub-plugins
|
227
272
|
has_dot = entry_name.include?('.')
|
228
273
|
next unless has_dot
|
229
274
|
is_src_file = ['yaml','rb'].include?( entry_name.split('.')[-1] )
|
@@ -255,7 +300,7 @@ module RSence
|
|
255
300
|
|
256
301
|
# System version requirement.
|
257
302
|
# NOTE: Has no effect yet!
|
258
|
-
:sys_version => '>=
|
303
|
+
:sys_version => '>= 2.0.0',
|
259
304
|
|
260
305
|
# Dependency, by default the system category (built-in plugins).
|
261
306
|
# A nil ( "~" in yaml ) value means no dependencies.
|
@@ -270,7 +315,10 @@ module RSence
|
|
270
315
|
|
271
316
|
# Optional, reverse dependency. Loads before the prepended plugin(category).
|
272
317
|
# NOTE: Doesn't support packages yet!
|
273
|
-
:prepends => nil
|
318
|
+
:prepends => nil,
|
319
|
+
|
320
|
+
# Name of plugin manager, so the bundle internals know what its path is.
|
321
|
+
:manager => @name_prefix
|
274
322
|
|
275
323
|
}
|
276
324
|
|
@@ -281,7 +329,7 @@ module RSence
|
|
281
329
|
info_yaml.each do |info_key,info_value|
|
282
330
|
info[ info_key.to_sym ] = info_value
|
283
331
|
end
|
284
|
-
|
332
|
+
elsif RSence.args[:debug]
|
285
333
|
warn "Expected info.yaml, using defaults:"
|
286
334
|
warn " #{info_path}"
|
287
335
|
end
|
@@ -425,6 +473,7 @@ module RSence
|
|
425
473
|
if bundle_status
|
426
474
|
(bundle_path, src_file) = bundle_status
|
427
475
|
unless disabled?( bundle_path )
|
476
|
+
# bundle_name = "#{@name_prefix.to_s}.#{bundle_name}" if @name_prefix
|
428
477
|
bundles_found.push( [bundle_path, bundle_name.to_sym, src_file] )
|
429
478
|
end
|
430
479
|
end
|
@@ -441,8 +490,10 @@ module RSence
|
|
441
490
|
end
|
442
491
|
puts "Unloading bundle: #{bundle_name.inspect}" if RSence.args[:debug]
|
443
492
|
@deps.del_item( bundle_name )
|
444
|
-
|
445
|
-
|
493
|
+
if @transporter
|
494
|
+
online_status = @transporter.online?
|
495
|
+
@transporter.online = false
|
496
|
+
end
|
446
497
|
call( bundle_name, :flush )
|
447
498
|
call( bundle_name, :close )
|
448
499
|
@registry.delete( bundle_name )
|
@@ -452,12 +503,12 @@ module RSence
|
|
452
503
|
end
|
453
504
|
end
|
454
505
|
if @servlets.include?( bundle_name )
|
455
|
-
|
506
|
+
del_servlet( bundle_name )
|
456
507
|
end
|
457
508
|
if @info.include?( bundle_name )
|
458
509
|
@info.delete( bundle_name )
|
459
510
|
end
|
460
|
-
@transporter.online = online_status
|
511
|
+
@transporter.online = online_status if @transporter
|
461
512
|
return unload_order
|
462
513
|
end
|
463
514
|
end
|
@@ -477,7 +528,7 @@ module RSence
|
|
477
528
|
if RSence.args[:say]
|
478
529
|
Thread.new do
|
479
530
|
Thread.pass
|
480
|
-
system(%{say "#{message.gsub('"','')}"})
|
531
|
+
system(%{say "#{message.gsub('"',"'").gsub('`',"'")}"})
|
481
532
|
end
|
482
533
|
end
|
483
534
|
end
|
@@ -564,6 +615,8 @@ module RSence
|
|
564
615
|
puts "done!" if RSence.args[:verbose]
|
565
616
|
end
|
566
617
|
if not (to_load.empty? and to_unload.empty? and to_reload.empty?)
|
618
|
+
@@incr += 1
|
619
|
+
puts "@@incr: #{@@incr}" if RSence.args[:debug]
|
567
620
|
puts "Plugin bundles:"
|
568
621
|
puts " loaded: #{to_load.join(', ')}" unless to_load.empty?
|
569
622
|
puts " unloaded: #{to_unload.join(', ')}" unless to_unload.empty?
|
@@ -582,25 +635,52 @@ module RSence
|
|
582
635
|
update_bundles!
|
583
636
|
end
|
584
637
|
|
638
|
+
attr_reader :transporter
|
639
|
+
attr_reader :sessions
|
640
|
+
attr_reader :autoreload
|
641
|
+
attr_reader :name_prefix
|
642
|
+
attr_reader :plugin_paths
|
643
|
+
attr_reader :parent_manager
|
644
|
+
|
645
|
+
@@pluginmanager_id = 0
|
585
646
|
# Initialize with a list of directories as plugin_paths.
|
586
647
|
# It's an array containing all plugin directories to scan.
|
587
|
-
def initialize(
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
648
|
+
def initialize( options )
|
649
|
+
|
650
|
+
options = {
|
651
|
+
:plugin_paths => nil,
|
652
|
+
:transporter => nil,
|
653
|
+
:autoreload => false,
|
654
|
+
:name_prefix => false,
|
655
|
+
:resolved_deps => [],
|
656
|
+
:resolved_categories => {},
|
657
|
+
:parent_manager => nil
|
658
|
+
}.merge( options )
|
659
|
+
|
660
|
+
@pluginmanager_id = @@pluginmanager_id
|
661
|
+
@@pluginmanager_id += 1
|
662
|
+
|
663
|
+
@closed = false
|
664
|
+
@plugin_paths = options[:plugin_paths]
|
665
|
+
|
666
|
+
if options[:transporter]
|
667
|
+
@transporter = options[:transporter]
|
668
|
+
@sessions = options[:transporter].sessions
|
669
|
+
end
|
670
|
+
|
671
|
+
@autoreload = options[:autoreload]
|
672
|
+
@name_prefix = options[:name_prefix]
|
673
|
+
@parent_manager = options[:parent_manager]
|
674
|
+
|
675
|
+
@deps = Dependencies.new( options[:resolved_deps], options[:resolved_categories] )
|
676
|
+
|
677
|
+
puts "Loading #{@name_prefix.to_s+' ' if @name_prefix}plugins..." if RSence.args[:verbose]
|
598
678
|
init_bundles!
|
599
|
-
puts %{Plugins #{"of #{name_prefix} " if name_prefix}loaded.} if RSence.args[:verbose]
|
600
|
-
if autoreload
|
679
|
+
puts %{Plugins #{"of #{@name_prefix} " if @name_prefix}loaded.} if RSence.args[:verbose]
|
680
|
+
if @autoreload
|
601
681
|
@thr = Thread.new do
|
602
682
|
Thread.pass
|
603
|
-
|
683
|
+
until @closed
|
604
684
|
begin
|
605
685
|
update_bundles!
|
606
686
|
rescue => e
|
@@ -608,9 +688,12 @@ module RSence
|
|
608
688
|
end
|
609
689
|
sleep 3
|
610
690
|
end
|
691
|
+
puts "No longer reloading plugins of #{@name_prefix}." if RSence.args[:verbose]
|
611
692
|
end
|
612
693
|
end
|
694
|
+
|
613
695
|
end
|
696
|
+
|
614
697
|
end
|
615
698
|
end
|
616
699
|
|
data/lib/plugins/plugins.rb
CHANGED
@@ -123,7 +123,7 @@ module RSence
|
|
123
123
|
path = File.expand_path( path, _bundle_path )
|
124
124
|
return path
|
125
125
|
end
|
126
|
-
def self.inspect; "#<module BundleWrapper of #{
|
126
|
+
def self.inspect; "#<module BundleWrapper of #{self._bundle_path}}>"; end
|
127
127
|
def self.const_missing( name )
|
128
128
|
if name == :Servlet
|
129
129
|
return Plugins.Servlet.call( self )
|
@@ -142,6 +142,15 @@ module RSence
|
|
142
142
|
plugin_src = "_bundle_path = #{params[:bundle_path].inspect};" + plugin_src
|
143
143
|
end
|
144
144
|
m.module_eval( plugin_src )
|
145
|
+
rescue SyntaxError => e
|
146
|
+
src_path = params[:src_path]
|
147
|
+
src_path = "<undefined src_path>" if src_path == nil
|
148
|
+
params[:plugin_manager].plugin_error(
|
149
|
+
e,
|
150
|
+
'BundleLoaderSyntaxError',
|
151
|
+
"The syntax of #{params[:bundle_name]} is invalid.",
|
152
|
+
src_path
|
153
|
+
)
|
145
154
|
rescue => e
|
146
155
|
src_path = params[:src_path]
|
147
156
|
src_path = "<undefined src_path>" if src_path == nil
|
data/lib/session/msg.rb
CHANGED
@@ -174,13 +174,37 @@ module RSence
|
|
174
174
|
def user_id
|
175
175
|
@session[:user_id]
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
|
+
# Getter for the user info hash
|
179
|
+
# @return [Hash] The current user info hash. Returns {} by default.
|
180
|
+
def user_info
|
181
|
+
@session[:user_info] = {} unless @session.has_key?(:user_info)
|
182
|
+
@session[:user_info]
|
183
|
+
end
|
184
|
+
|
185
|
+
# @private used for automatic reload of page, when the plugins have been changed.
|
186
|
+
def refresh_page?( plugin_incr )
|
187
|
+
if plugin_incr != @session[:plugin_incr]
|
188
|
+
puts "@session[:plugin_incr] = #{@session[:plugin_incr].inspect} vs plugin_incr = #{plugin_incr.inspect}" if RSence.args[:debug]
|
189
|
+
@session[:plugin_incr] = plugin_incr
|
190
|
+
return true
|
191
|
+
end
|
192
|
+
return false
|
193
|
+
end
|
194
|
+
|
178
195
|
# Setter for the user id
|
179
196
|
# @param [Number, String] user_id The user id to set. Use in login situations to store the user id.
|
180
197
|
# @return [nil]
|
181
198
|
def user_id=(user_id)
|
182
199
|
@session[:user_id] = user_id
|
183
200
|
end
|
201
|
+
|
202
|
+
# Setter for the user info
|
203
|
+
# @param [Hash] user_info The user info hash to set. Use in login situations to store the user information.
|
204
|
+
# @return [nil]
|
205
|
+
def user_info=(user_info)
|
206
|
+
@session[:user_info] = user_info
|
207
|
+
end
|
184
208
|
|
185
209
|
# Returns the session id
|
186
210
|
# @return [Number]
|
@@ -74,7 +74,9 @@ module RSence
|
|
74
74
|
|
75
75
|
# the time, when the session will time out
|
76
76
|
:timeout => timeout,
|
77
|
-
|
77
|
+
|
78
|
+
:plugin_incr => @plugins.incr,
|
79
|
+
|
78
80
|
# session id, used internally
|
79
81
|
:ses_id => ses_id,
|
80
82
|
|
@@ -86,6 +88,9 @@ module RSence
|
|
86
88
|
|
87
89
|
# user id, map to your own user management code
|
88
90
|
:user_id => 0,
|
91
|
+
|
92
|
+
# user info, map to your own user management code
|
93
|
+
:user_info => {},
|
89
94
|
|
90
95
|
# valuemanager data
|
91
96
|
:values => {
|
@@ -168,7 +173,7 @@ module RSence
|
|
168
173
|
end
|
169
174
|
|
170
175
|
def clone_ses( msg, old_data, old_id, old_key, ses_seed )
|
171
|
-
ses_data = Marshal.
|
176
|
+
ses_data = Marshal.load( Marshal.dump( old_data ) )
|
172
177
|
old_data[:timeout] = Time.now.to_i + @config[:cloned_session_expires_in]
|
173
178
|
timeout = Time.now.to_i + @config[:timeout_secs]
|
174
179
|
cookie_key = @randgen.gen_many(@config[:cookie_key_multiplier]).join('')
|
@@ -177,6 +182,7 @@ module RSence
|
|
177
182
|
ses_data[:timeout] = timeout
|
178
183
|
ses_data[:ses_key] = ses_key
|
179
184
|
ses_data[:cookie_key] = cookie_key
|
185
|
+
ses_data[:plugin_incr] = @plugins.incr
|
180
186
|
ses_id = new_ses_id( cookie_key, ses_key, timeout )
|
181
187
|
ses_data[:ses_id] = ses_id
|
182
188
|
@sessions[ ses_id ] = ses_data
|
@@ -307,6 +313,9 @@ module RSence
|
|
307
313
|
|
308
314
|
# binds the new cookie key to the old session data
|
309
315
|
@sessions[ses_id][:cookie_key] = cookie_key
|
316
|
+
|
317
|
+
|
318
|
+
msg.session[:plugin_incr] = @plugins.incr
|
310
319
|
|
311
320
|
# Sets the restored_session flag of msg to true
|
312
321
|
# It signals plugins to re-set data
|
@@ -181,13 +181,6 @@ module RSence
|
|
181
181
|
## Used for future upgrades:
|
182
182
|
# version = table_version
|
183
183
|
|
184
|
-
if @config[:reset_sessions]
|
185
|
-
puts "Resetting all sessions..."
|
186
|
-
reset_sessions()
|
187
|
-
else
|
188
|
-
restore_sessions()
|
189
|
-
end
|
190
|
-
|
191
184
|
return true
|
192
185
|
end
|
193
186
|
|
@@ -214,16 +207,22 @@ module RSence
|
|
214
207
|
@db[:rsence_session].all do |ses_row|
|
215
208
|
ses_id = ses_row[:id]
|
216
209
|
ses_data_dump = ses_row[:ses_data]
|
217
|
-
|
210
|
+
|
218
211
|
if ses_data_dump == nil
|
219
212
|
@db[:rsence_session].filter(:id => ses_id).delete
|
220
213
|
@db[:rsence_uploads].filter(:ses_id => ses_id).delete
|
221
214
|
else
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
215
|
+
begin
|
216
|
+
ses_data = Marshal.load( ses_data_dump )
|
217
|
+
ses_key = ses_data[:ses_key]
|
218
|
+
@sessions[ses_id] = ses_data
|
219
|
+
@session_keys[ ses_key ] = ses_id
|
220
|
+
@session_cookie_keys[ ses_data[:cookie_key] ] = ses_id
|
221
|
+
rescue => e
|
222
|
+
warn "Unable to restore session id: #{ses_id}, error: #{e.inspect}"
|
223
|
+
@db[:rsence_session].filter(:id => ses_id).delete
|
224
|
+
@db[:rsence_uploads].filter(:ses_id => ses_id).delete
|
225
|
+
end
|
227
226
|
end
|
228
227
|
end
|
229
228
|
db_close
|
@@ -297,7 +296,7 @@ module RSence
|
|
297
296
|
@sessions.delete( ses_id )
|
298
297
|
|
299
298
|
# Removes all ticket-based storage bound to the session
|
300
|
-
@plugins[:
|
299
|
+
@plugins[:ticket].expire_ses_id( ses_id ) if @plugins
|
301
300
|
|
302
301
|
# target -> source cleanup
|
303
302
|
if @clone_sources.has_key?( ses_id )
|
@@ -317,6 +316,7 @@ module RSence
|
|
317
316
|
if @db_avail
|
318
317
|
db_open
|
319
318
|
# Deletes the session's row from the database
|
319
|
+
@db[:rsence_uploads].filter(:ses_id => ses_id).delete
|
320
320
|
@db[:rsence_session].filter(:id => ses_id).delete
|
321
321
|
db_close
|
322
322
|
end
|