rsence 2.0.0.10.pre → 2.0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. data/.yardopts +10 -0
  2. data/INSTALL.rdoc +52 -86
  3. data/{LICENSE → LICENSE.txt} +0 -0
  4. data/README.rdoc +52 -49
  5. data/VERSION +1 -1
  6. data/bin/rsence +4 -6
  7. data/conf/default_conf.yaml +314 -305
  8. data/conf/default_strings.yaml +70 -71
  9. data/docs/ExampleGuiPlugin.rdoc +193 -0
  10. data/{js/comm/comm/autosync/js.inc → docs/JavascriptBundles.rdoc} +0 -0
  11. data/docs/PluginBundleInfo.rdoc +173 -0
  12. data/docs/PluginBundles.rdoc +96 -0
  13. data/docs/Values.rdoc +163 -0
  14. data/js/comm/{comm/autosync → autosync}/autosync.js +1 -2
  15. data/js/comm/{comm → autosync}/js.inc +0 -0
  16. data/js/comm/{comm/comm.js → comm.js} +1 -0
  17. data/js/comm/{comm/queue/js.inc → js.inc} +0 -0
  18. data/js/comm/jsloader/jsloader.js +2 -4
  19. data/js/comm/{comm/session → queue}/js.inc +0 -0
  20. data/js/comm/{comm/queue → queue}/queue.js +1 -0
  21. data/js/comm/{comm/sessionwatcher → session}/js.inc +0 -0
  22. data/js/comm/{comm/session → session}/session.js +4 -3
  23. data/js/comm/{comm/transporter → sessionwatcher}/js.inc +0 -0
  24. data/js/comm/{comm/sessionwatcher → sessionwatcher}/sessionwatcher.js +1 -0
  25. data/js/comm/{comm/urlresponder → transporter}/js.inc +0 -0
  26. data/js/comm/{comm/transporter → transporter}/transporter.js +1 -0
  27. data/js/comm/{comm/values → urlresponder}/js.inc +0 -0
  28. data/js/comm/{comm/urlresponder → urlresponder}/urlresponder.js +1 -0
  29. data/js/comm/{reloadapp → values}/js.inc +0 -0
  30. data/js/comm/{comm/values → values}/values.js +1 -0
  31. data/js/controls/button/button.js +10 -1
  32. data/js/controls/checkbox/checkbox.js +2 -0
  33. data/js/controls/dialogs/alert_sheet/alert_sheet.js +1 -0
  34. data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +1 -0
  35. data/js/controls/dialogs/sheet/sheet.js +1 -0
  36. data/js/controls/imageview/imageview.js +1 -0
  37. data/js/controls/passwordcontrol/passwordcontrol.js +1 -0
  38. data/js/controls/progress/progressbar/progressbar.js +1 -0
  39. data/js/controls/progress/progressindicator/progressindicator.js +1 -0
  40. data/js/controls/radiobutton/radiobutton.js +3 -1
  41. data/js/controls/sliders/slider/slider.js +1 -0
  42. data/js/controls/sliders/vslider/vslider.js +1 -0
  43. data/js/controls/stepper/stepper.js +1 -0
  44. data/js/controls/stringview/stringview.js +2 -2
  45. data/js/controls/tab/tab.js +7 -5
  46. data/js/controls/textarea/textarea.js +1 -0
  47. data/js/controls/textcontrol/textcontrol.js +3 -1
  48. data/js/controls/uploader/uploader.js +1 -0
  49. data/js/controls/validatorview/validatorview.js +62 -59
  50. data/js/controls/window/window.js +1 -0
  51. data/js/core/class/class.js +2 -1
  52. data/js/core/elem/elem.js +27 -27
  53. data/js/core/event/event.js +3 -874
  54. data/js/{comm/sha → core/rsence_ns}/js.inc +0 -0
  55. data/js/core/rsence_ns/rsence_ns.js +15 -0
  56. data/js/{controls/datetime → datetime}/calendar/calendar.js +1 -0
  57. data/js/{comm/values/value → datetime/calendar}/js.inc +0 -0
  58. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.css +0 -0
  59. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.html +0 -0
  60. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
  61. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows.png +0 -0
  62. data/js/{controls/datetime → datetime}/datetimevalue/datetimevalue.js +1 -0
  63. data/js/{comm/values/valuematrix → datetime/datetimevalue}/js.inc +0 -0
  64. data/js/{controls/datetime/calendar → datetime/timesheet}/js.inc +0 -0
  65. data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.css +0 -0
  66. data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.html +0 -0
  67. data/js/{controls/datetime → datetime}/timesheet/timesheet.js +1 -0
  68. data/js/{controls/datetime/datetimevalue → datetime/timesheet_item}/js.inc +0 -0
  69. data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.css +0 -0
  70. data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.html +0 -0
  71. data/js/{controls/datetime → datetime}/timesheet_item/timesheet_item.js +1 -0
  72. data/js/{controls/datetime/timesheet → datetime/timesheet_item_edit}/js.inc +0 -0
  73. data/js/{controls/datetime → datetime}/timesheet_item_edit/timesheet_item_edit.js +1 -1
  74. data/js/foundation/application/application.js +1 -2
  75. data/js/foundation/control/control.js +1 -4
  76. data/js/foundation/control/controldefaults/controldefaults.js +1 -4
  77. data/js/foundation/control/dummyvalue/dummyvalue.js +1 -0
  78. data/js/foundation/control/dyncontrol/dyncontrol.js +1 -2
  79. data/js/foundation/control/eventresponder/eventresponder.js +11 -3
  80. data/js/{controls/datetime/timesheet_item → foundation/control/valuematrix}/js.inc +0 -0
  81. data/js/{comm/values → foundation/control}/valuematrix/valuematrix.js +2 -5
  82. data/js/foundation/control/valueresponder/valueresponder.js +3 -1
  83. data/js/foundation/eventmanager/eventmanager.js +884 -0
  84. data/js/{controls/datetime/timesheet_item_edit → foundation/eventmanager}/js.inc +0 -0
  85. data/js/foundation/geom/point/point.js +2 -2
  86. data/js/foundation/geom/rect/rect.js +1 -0
  87. data/js/foundation/json_renderer/json_renderer.js +2 -0
  88. data/js/foundation/system/system.js +2 -1
  89. data/js/foundation/thememanager/thememanager.js +29 -23
  90. data/js/{controls/lists/checkboxlist → foundation/value}/js.inc +0 -0
  91. data/js/{comm/values → foundation}/value/value.js +1 -0
  92. data/js/foundation/view/markupview/markupview.js +2 -1
  93. data/js/foundation/view/morphanimation/morphanimation.js +1 -0
  94. data/js/foundation/view/view.js +6 -12
  95. data/js/foundation/view/viewdefaults/viewdefaults.js +1 -0
  96. data/js/{controls/lists → lists}/checkboxlist/checkboxlist.js +1 -0
  97. data/js/{controls/lists/listitems → lists/checkboxlist}/js.inc +0 -0
  98. data/js/{controls/lists/radiobuttonlist → lists/listitems}/js.inc +0 -0
  99. data/js/{controls/lists → lists}/listitems/listitems.js +22 -3
  100. data/js/lists/radiobuttonlist/js.inc +0 -0
  101. data/js/{controls/lists → lists}/radiobuttonlist/radiobuttonlist.js +2 -12
  102. data/js/util/reloadapp/js.inc +0 -0
  103. data/js/{comm → util}/reloadapp/reloadapp.js +10 -8
  104. data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
  105. data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning.png +0 -0
  106. data/js/util/sha/js.inc +0 -0
  107. data/js/{comm → util}/sha/sha.js +27 -33
  108. data/js/views/centerview/centerview.js +33 -3
  109. data/js/views/inlineview/inlineview.js +1 -0
  110. data/js/views/scrollview/scrollview.js +1 -0
  111. data/lib/conf/argv.rb +34 -22
  112. data/lib/conf/default.rb +165 -173
  113. data/lib/daemon/daemon.rb +9 -9
  114. data/lib/daemon/sigcomm.rb +4 -4
  115. data/lib/http/broker.rb +30 -27
  116. data/lib/http/rackup.rb +2 -3
  117. data/lib/http/request.rb +1 -2
  118. data/lib/http/response.rb +10 -10
  119. data/lib/plugins/dependencies.rb +2 -1
  120. data/lib/plugins/gui_plugin.rb +77 -50
  121. data/lib/plugins/guiparser.rb +26 -22
  122. data/lib/plugins/plugin.rb +207 -427
  123. data/lib/plugins/plugin_base.rb +162 -0
  124. data/lib/plugins/plugin_plugins.rb +21 -15
  125. data/lib/plugins/plugin_sqlite_db.rb +45 -20
  126. data/lib/plugins/pluginmanager.rb +10 -5
  127. data/lib/plugins/plugins.rb +65 -31
  128. data/lib/plugins/servlet.rb +74 -26
  129. data/lib/rsence.rb +32 -0
  130. data/lib/session/msg.rb +131 -96
  131. data/lib/session/sessionmanager.rb +5 -4
  132. data/lib/session/sessionstorage.rb +4 -3
  133. data/lib/transporter/transporter.rb +30 -21
  134. data/lib/util/gzstring.rb +4 -2
  135. data/lib/util/ruby19_fixes.rb +18 -0
  136. data/lib/values/hvalue.rb +139 -88
  137. data/lib/values/valuemanager.rb +60 -46
  138. data/plugins/client_pkg/client_pkg.rb +6 -5
  139. data/plugins/client_pkg/lib/client_pkg_build.rb +5 -5
  140. data/plugins/client_pkg/lib/client_pkg_serve.rb +8 -0
  141. data/plugins/index_html/index_html.rb +3 -1
  142. data/plugins/index_html/tmpl/index.html +2 -3
  143. data/plugins/main/js/main.js +84 -0
  144. data/plugins/main/main.rb +54 -27
  145. data/plugins/ticket/lib/common.rb +4 -2
  146. data/plugins/ticket/lib/favicon.rb +3 -2
  147. data/plugins/ticket/lib/file.rb +2 -2
  148. data/plugins/ticket/lib/img.rb +2 -2
  149. data/plugins/ticket/lib/objblob.rb +2 -2
  150. data/plugins/ticket/lib/rsrc.rb +2 -2
  151. data/plugins/ticket/lib/upload.rb +9 -8
  152. data/plugins/ticket/ticket.rb +141 -8
  153. data/setup/welcome/welcome.rb +1 -0
  154. metadata +76 -72
  155. data/lib/plugins/plugin_util.rb +0 -107
  156. data/plugins/index_html/tmpl/startup_index.html +0 -29
  157. data/plugins/main/js/riassence_ns.js +0 -87
  158. data/setup/legacy/info.yaml +0 -18
  159. data/setup/legacy/legacy.rb +0 -17
  160. data/setup/welcome/gui/welcome.yaml +0 -68
  161. data/setup/welcome/text/welcome.html +0 -8
@@ -7,6 +7,7 @@
7
7
  ##
8
8
 
9
9
 
10
+
10
11
  module RSence
11
12
 
12
13
  require 'rubygems'
@@ -240,7 +241,7 @@ module RSence
240
241
  def stop_client_with_message( msg,
241
242
  title = 'Unknown Issue',
242
243
  descr = 'No issue description given.',
243
- uri = ::RSence.config[:index_html][:respond_address] )
244
+ uri = RSence.config[:index_html][:respond_address] )
244
245
  msg.error_msg( [
245
246
  "jsLoader.load('default_theme');",
246
247
  "jsLoader.load('controls');",
@@ -261,7 +262,7 @@ module RSence
261
262
  # checks, if a cookie named 'ses_key' is found
262
263
  if cookie_raw.has_key?('ses_key')
263
264
 
264
- # gets just the data itself (discards comment, domain, exipiry etc)
265
+ # gets just the data itself (discards comment, domain, expiration etc)
265
266
  cookie_key = cookie_raw['ses_key'].split(';')[0]
266
267
 
267
268
  end
@@ -383,11 +384,11 @@ module RSence
383
384
  ses_cookie_max_age = @config[:timeout_secs]
384
385
 
385
386
  ## Only match the handshaking address of rsence,
386
- ## prevents unneccessary cookie-juggling in xhr's
387
+ ## prevents unnecessary cookie-juggling in xhr's
387
388
  if @config[:trust_cookies]
388
389
  ses_cookie_path = '/'
389
390
  else
390
- ses_cookie_path = ::RSence.config[:broker_urls][:hello]
391
+ ses_cookie_path = RSence.config[:broker_urls][:hello]
391
392
  end
392
393
 
393
394
  ## Formats the cookie to string
@@ -7,6 +7,7 @@
7
7
  ##
8
8
 
9
9
 
10
+
10
11
  module RSence
11
12
 
12
13
  require 'rubygems'
@@ -19,7 +20,7 @@ module RSence
19
20
  # the superclass for SessionManager that does all the boring
20
21
  # housekeeping duties.
21
22
  #
22
- # Splitted of as a separate file to reduce the complexity
23
+ # Spliced of as a separate file to reduce the complexity
23
24
  # of SessionManager.
24
25
  class SessionStorage
25
26
  attr_accessor :db
@@ -44,9 +45,9 @@ module RSence
44
45
  }
45
46
 
46
47
  ## Disposable keys (new ses_key each request)
47
- @config = ::RSence.config[:session_conf]
48
+ @config = RSence.config[:session_conf]
48
49
 
49
- @db_uri = ::RSence.config[:database][:ses_db]
50
+ @db_uri = RSence.config[:database][:ses_db]
50
51
 
51
52
  if db_test
52
53
  @db_avail = true
@@ -1,4 +1,3 @@
1
- #--
2
1
  ## RSence
3
2
  # Copyright 2008 Riassence Inc.
4
3
  # http://riassence.com/
@@ -6,28 +5,38 @@
6
5
  # You should have received a copy of the GNU General Public License along
7
6
  # with this software package. If not, contact licensing@riassence.com
8
7
  ##
9
- #++
10
8
 
11
9
 
12
- module RSence
10
+ # ValueManager synchronizes value objects
11
+ require 'values/valuemanager'
13
12
 
14
- # Transporter handles incoming requests targeted at RSence
15
- # and distributes calls and data accordingly.
16
- class Transporter
17
-
18
- # ValueManager syncronizes value objects
19
- require 'values/valuemanager'
20
-
21
- # SessionManager creates, validates, stores and expires sessions
22
- require 'session/sessionmanager'
13
+ # SessionManager creates, validates, stores and expires sessions
14
+ require 'session/sessionmanager'
23
15
 
24
- # PluginManager handles all the plugins
25
- require 'plugins/pluginmanager'
26
-
27
- attr_accessor :valuemanager, :sessions, :plugins
16
+ # PluginManager handles all the plugins
17
+ require 'plugins/pluginmanager'
18
+
19
+
20
+ module RSence
28
21
 
22
+ # Transporter handles incoming requests targeted at RSence and distributes calls and data accordingly. It's called via {Broker}.
23
+ # @see Broker
24
+ class Transporter
25
+
26
+ # The single instance of the {ValueManager}
27
+ # @return [ValueManager]
28
+ attr_accessor :valuemanager
29
+
30
+ # The single instance of the {SessionManager}
31
+ # @return [SessionManager]
32
+ attr_accessor :sessions
33
+
34
+ # The main instance of the {PluginManager}
35
+ # @return [PluginManager]
36
+ attr_accessor :plugins
37
+
29
38
  def initialize
30
- @config = ::RSence.config[:transporter_conf]
39
+ @config = RSence.config[:transporter_conf]
31
40
  @accept_req = false
32
41
  @valuemanager = ValueManager.new
33
42
  @sessions = SessionManager.new( self )
@@ -35,7 +44,7 @@ module RSence
35
44
  :core => [:transporter, :session_storage, :session_manager, :value_manager]
36
45
  }
37
46
  @plugins = PluginManager.new(
38
- ::RSence.config[:plugin_paths],
47
+ RSence.config[:plugin_paths],
39
48
  self,
40
49
  RSence.args[:autoupdate],
41
50
  false,
@@ -70,7 +79,7 @@ module RSence
70
79
  end
71
80
 
72
81
  def servlet( request_type, request, response )
73
- broker_urls = ::RSence.config[:broker_urls]
82
+ broker_urls = RSence.config[:broker_urls]
74
83
  uri = request.fullpath
75
84
 
76
85
  if request_type == :post
@@ -116,7 +125,7 @@ module RSence
116
125
  ## handles incoming XMLHttpRequests from the browser
117
126
  def xhr(request, response, options = { :cookies => false, :servlet => false } )
118
127
 
119
- session_conf = ::RSence.config[:session_conf]
128
+ session_conf = RSence.config[:session_conf]
120
129
 
121
130
  options[:cookies] = false unless options.has_key?(:cookies)
122
131
 
@@ -143,7 +152,7 @@ module RSence
143
152
  # If cookies are true, it means the url base needs to
144
153
  # be changed from /hello to /x to prevent further cookie juggling.
145
154
  if options[:cookies] and not options[:servlet]
146
- msg.reply("COMM.Transporter.url=#{::RSence.config[:broker_urls][:x].to_json};")
155
+ msg.reply("COMM.Transporter.url=#{RSence.config[:broker_urls][:x].to_json};")
147
156
  end
148
157
 
149
158
  # Appends a 'new session.' message for new sessions in RSence.args[:verbose]:
@@ -1,7 +1,9 @@
1
+
1
2
  require 'zlib'
2
3
 
3
- # Implements the +write+ method for strings, used with zlib to
4
- # use GZStrings as the target for compression.
4
+
5
+ # @private Implements the +write+ method for strings, used with zlib to
6
+ # use GZStrings as the target for compression.
5
7
  class GZString < String
6
8
  alias write <<
7
9
  end
@@ -0,0 +1,18 @@
1
+
2
+ # NOTE: Ruby 1.9 isn't fully supported yet.
3
+ # There are some encoding handlers and some of the dependencies are not fully working yet.
4
+ # One should wait for Ruby 2.0 for production use anyway.
5
+
6
+ # Ruby 1.9 encoding defaults.
7
+ # This is clearly not enough but a good start for fixing the encoding madness.
8
+ Encoding.default_external = Encoding::BINARY
9
+ Encoding.default_internal = Encoding::BINARY
10
+
11
+ # Ruby 1.9 doesn't have String#each anymore.
12
+ # This is a backwards-compatible work-around.
13
+ class String
14
+ def each
15
+ self.split($/).each { |e| yield e }
16
+ end
17
+ end
18
+
@@ -7,87 +7,128 @@
7
7
  ##
8
8
 
9
9
 
10
+
10
11
  module RSence
11
12
 
12
13
 
13
- ## HValue is the server-side representation of the client's HValue object.
14
- ## It's the 'messenger' to syncronize server-client data and is smart enough
15
- ## to validate and process itself as well as tell the client-side
16
- ## representation of itself.
14
+ # HValue is the model for client-server synchronized values.
15
+ # A value contains its payload {#data} and enough meta-data to define its behavior.
17
16
  class HValue
18
-
19
- attr_reader :valid, :sync, :val_id, :data, :members
20
- attr_writer :valid, :val_id
21
-
22
- # Method for binding the value to the session data.
23
- def add( msg )
24
17
 
18
+ # The validity of the data. Defaults to false, when the data comes from the client.
19
+ # @return [Boolean] True, when set by the server. False when initially set by the client. Also false, unless all responders return true.
20
+ attr_reader :is_valid
21
+
22
+ # @private Is true when changed by the server. Causes the ValueManager to send its client-side representation.
23
+ attr_reader :sync
24
+
25
+ # @private The unique ID of the value.
26
+ attr_reader :value_id
27
+ alias val_id value_id
28
+
29
+ # The payload data. Use {#set} to change.
30
+ attr_reader :data
31
+
32
+ # @private List of responders
33
+ attr_reader :members
34
+
35
+ # @private
36
+ attr_writer :is_valid
37
+
38
+ # @private
39
+ def value_id=(new_id)
40
+ @value_id = new_id
41
+ end
42
+ # @private
43
+ alias val_id= value_id=
44
+
45
+ alias valid is_valid
46
+ alias valid? is_valid
47
+
48
+ # @private Method for binding the value to the session data.
49
+ def add( msg )
50
+
25
51
  # get the value storage from the session data
26
52
  session_values = msg.session[:values][:by_id]
27
-
53
+
28
54
  ## Store the object here
29
- session_values[ @val_id ] = self
30
-
55
+ session_values[ @value_id ] = self
56
+
31
57
  ## Sends the client-side description
32
58
  restore( msg )
33
-
59
+
34
60
  ## Set the valid flag, so we know that the value is initially in sync
35
- @valid = true
61
+ @is_valid = true
36
62
  end
37
-
38
- ## (Re-)Send the client-size representation
39
- def restore( msg )
40
63
 
64
+ # @private (Re-)Send the client-size representation
65
+ def restore( msg )
66
+
41
67
  ## Tags itself as a new value from the client's point of view
42
68
  @is_new_to_client = true
43
-
69
+
44
70
  add_to_sync( msg )
45
-
71
+
46
72
  end
47
-
48
- # +HValue+ constructor. Binds HValue automatically to the +Message+ instance
49
- # given as parameter. Data given as second parameter.
50
- def initialize( msg, data, meta = { :name => nil } )
51
73
 
74
+ # Value meta-data. The third constructor parameter
75
+ attr_accessor :meta
76
+
77
+ # Creates a new client-server automatically synchronized data wrapper object.
78
+ # @param [Message] msg Just pass on the +msg+ from the scope you call from.
79
+ # @param [#to_json] data Any data that can be converted to JSON.
80
+ # @param [Hash] meta Has no effect yet.
81
+ def initialize( msg, data, meta = { :name => nil } )
82
+
52
83
  ## Get an unique integer id for the value
53
84
  if RSence.args[:debug] and meta[:name] and not msg.valuemanager.id_exists?( msg, meta[:name] )
54
- @val_id = meta[:name]
85
+ @value_id = meta[:name]
55
86
  else
56
- @val_id = msg.valuemanager.randgen.gen
87
+ @value_id = msg.valuemanager.randgen.gen
57
88
  end
58
-
89
+
90
+ @meta = meta
91
+
59
92
  ## set the data of the hvalue
60
93
  set( msg, data, true )
61
-
94
+
62
95
  ## the @sync flag is raised, when the client data is older than the server data
63
96
  @sync = false
64
-
65
- ## the @is_valid flas is lowered, when the client data is newer than the server data
97
+
98
+ ## the @is_valid flag is lowered, when the client data is newer than the server data
66
99
  @is_valid = true
67
-
100
+
68
101
  ## Bind the value to the value manager and report it to the client
69
102
  add( msg )
70
-
103
+
71
104
  ## storage for validator bindings
72
105
  @members = {}
73
-
106
+
74
107
  end
75
-
76
- # Binds the value to the plugin method (both as
77
- # strings; plugin as the name registered in PluginManager)
108
+
109
+ # Binds the value to a responder. The responder is an instance of {Plugins::Plugin__ Plugin} or {Plugins::GUIPlugin__ GUIPlugin}.
110
+ # Responders are called once, when the client requests the data to be changed.
111
+ # Responders must return +true+, if they accept the change. Otherwise the data is treated as invalid.
112
+ # Responders must respond to exactly two parameters: ( (Message) +msg+, (HValue) +value+ )
78
113
  #
79
- # It uses strings instead of '...method(...)' because
80
- # it won't work with marshal. Strings are easier and work
81
- # as well.
114
+ # @param [Symbol] plugin_name The name of the registered plugin to call with the +method_name+
115
+ # @param [Symbol] method_name The name of the method of the registered plugin +plugin_name+ to call.
116
+ # @return [true]
82
117
  def bind( plugin_name, method_name )
118
+ plugin_name = plugin_name.to_sym unless plugin_name.class == Symbol
119
+ method_name = method_name.to_sym unless method_name.class == Symbol
83
120
  @members[plugin_name] = [] unless @members.has_key?( plugin_name )
84
121
  @members[plugin_name].push( method_name ) unless @members[plugin_name].include?( method_name )
85
122
  return true
86
123
  end
87
-
88
- # Releases the binding of the value, both params as
89
- # in bind, but optional (false = 'wildcard')
124
+
125
+ # Releases the responder of the value, both params as in bind, but optional +method_name+ can be omitted, matching all methods bound to the +plugin_name+.
126
+ # @param [Symbol] plugin_name The name of the plugin acting as a responder to the value.
127
+ # @param [Symbol] method_name The name of the method of the plugin acting as a responder to the value.
128
+ # @return [Boolean] Returns true, if successful, false if not bound or other error.
90
129
  def release( plugin_name=false, method_name=false )
130
+ plugin_name = plugin_name.to_sym if plugin_name.class == String
131
+ method_name = method_name.to_sym if method_name.class == String
91
132
  return release_all if not plugin_name and not method_name
92
133
  return false unless @members.has_key?( plugin_name )
93
134
  if not method_name
@@ -97,17 +138,18 @@ module RSence
97
138
  end
98
139
  return true
99
140
  end
100
-
101
- ## Releases all members.
141
+
142
+ # Releases all responders.
143
+ # @return [true]
102
144
  def release_all
103
145
  @members = {}
104
146
  return true
105
147
  end
106
-
107
- # The unbind method can be used as an alias to release (as in the client).
148
+
149
+ # @deprecated Use {#release} as the opposite to bind.
108
150
  alias unbind release
109
-
110
- # Tell all bound instances that the value is changed.
151
+
152
+ # @private Tell all bound instances that the value is changed.
111
153
  def tell( msg )
112
154
  invalid_count = 0
113
155
  @members.each_key do |plugin_name|
@@ -117,85 +159,93 @@ module RSence
117
159
  end
118
160
  if invalid_count == 0
119
161
  @is_valid = true
120
- msg.session[:values][:check].delete( @val_id )
162
+ msg.session[:values][:check].delete( @value_id )
121
163
  end
122
164
  end
123
-
124
- # Handle client updates.
125
- def from_client( msg, data )
126
165
 
166
+ # @private Handle updates from the client.
167
+ def from_client( msg, data )
168
+
127
169
  # only process changes, if different from the one already stored.
128
170
  if @data != data
129
-
171
+
130
172
  ## set takes care of the setting..
131
173
  @data = data
132
-
174
+
133
175
  ## change the valid state, because the value was set by the client!
134
176
  @is_valid = false
135
-
177
+
136
178
  ## add the id to the values to be checked
137
179
  check_ids = msg.session[:values][:check]
138
- unless check_ids.include?( @val_id )
139
- check_ids.push( @val_id )
180
+ unless check_ids.include?( @value_id )
181
+ check_ids.push( @value_id )
140
182
  end
141
183
  end
142
-
184
+
143
185
  end
144
-
186
+
187
+ # @private Adds the value to the sync array.
145
188
  def add_to_sync( msg )
146
- ## add the id to the values to be syncronized (to client)
189
+ ## add the id to the values to be synchronized (to client)
147
190
  sync_ids = msg.session[:values][:sync]
148
- unless sync_ids.include?( @val_id )
149
- sync_ids.push( @val_id )
191
+ unless sync_ids.include?( @value_id )
192
+ sync_ids.push( @value_id )
150
193
  end
151
194
  end
152
-
153
- # Sets the data.
154
- def set( msg, data, dont_tell_client=false )
155
195
 
196
+ # Sets the data of the value, the change will be synced with the client.
197
+ # @param [Message] msg The {Message} instance.
198
+ # @param [#to_json] data Any data that can be mapped to JSON and handled by the client.
199
+ # @param [Boolean] dont_tell_client Doesn't notify the client about the change, if true.
200
+ def set( msg, data, dont_tell_client=false )
201
+
156
202
  @data = data
157
-
203
+
158
204
  # won't tell the client about the change, usually not needed
159
205
  unless dont_tell_client
160
206
  ## update the flags
161
207
  @sync = false
162
208
  @is_valid = true
163
-
209
+
164
210
  add_to_sync( msg )
165
211
  end
166
212
  end
167
-
168
- # Tell the client that the value changed.
213
+
214
+ # @private Tell the client that the value changed.
169
215
  def to_client( msg )
170
216
  if @is_new_to_client
171
217
  ## Initialize a new client value
172
- init_str = "COMM.Values.create(#{@val_id.to_json},#{@data.to_json});"
218
+ init_str = "COMM.Values.create(#{@value_id.to_json},#{@data.to_json});"
173
219
  msg.reply_value( init_str )
174
220
  @is_new_to_client = false
175
221
  else
176
222
  ## Sets the client value
177
- msg.reply_value "HVM.s(#{@val_id.to_json},#{@data.to_json});"
223
+ msg.reply_value "HVM.s(#{@value_id.to_json},#{@data.to_json});"
178
224
  end
179
225
  end
180
-
181
- # Clean up self.
182
- def die( msg=false )
183
226
 
227
+ # Destructor method. If msg is supplied, deletes the client representation too.
228
+ # @param [false, Message] A {Message} instance. When supplied, deletes the client representation.
229
+ def die!( msg=false )
230
+
184
231
  release_all
185
-
232
+
186
233
  # get the value storage from the session data
187
234
  session_values = msg.session[:values][:by_id]
188
-
235
+
189
236
  ## Store the object here
190
- session_values.delete( @val_id )
191
-
237
+ session_values.delete( @value_id )
238
+
192
239
  if msg and not @is_new_to_client
193
- msg.reply_value("HVM.del(#{@val_id.to_json});")
240
+ msg.reply_value("HVM.del(#{@value_id.to_json});")
194
241
  end
195
242
  end
196
-
243
+ alias die die!
244
+
197
245
  end
198
246
 
247
+
248
+ =begin
199
249
  class UploadValue < HValue
200
250
 
201
251
  @state_responders = {
@@ -217,10 +267,10 @@ module RSence
217
267
  ## change the valid state, because the value was set by the client!
218
268
  @is_valid = data.include?(':::')
219
269
 
220
- # the state and key are separated by the ':::' delimitter string
270
+ # the state and key are separated by the ':::' delimiter string
221
271
  if @is_valid
222
272
 
223
- # split state and key using the delimitter
273
+ # split state and key using the delimiter
224
274
  (upload_state, upload_key) = data.split(':::')
225
275
 
226
276
  # the state is a number
@@ -233,19 +283,19 @@ module RSence
233
283
  if upload_state < 0
234
284
  # "upload error: #{upload_state}"
235
285
  # (parse the error)
236
- unless @state_respders[:error].empty?
286
+ unless @state_responders[:error].empty?
237
287
  @state_responders[:error].each do |plugin_name,method_name|
238
288
  msg.run( plugin_name,method_name,msg,self,upload_state )
239
289
  end
240
290
  end
241
291
 
242
- # the default state, 0 means the ui is ready to send an
292
+ # the default state, 0 means the UI is ready to send an
243
293
  # upload and ticketserve is ready to receive it
244
294
  elsif upload_state == 0
245
295
  # "upload state: ready to upload."
246
296
  # (do nothing)
247
297
 
248
- unless @state_respders[:ready].empty?
298
+ unless @state_responders[:ready].empty?
249
299
  @state_responders[:ready].each do |plugin_name,method_name|
250
300
  msg.run( plugin_name,method_name,msg,self,upload_state )
251
301
  end
@@ -256,7 +306,7 @@ module RSence
256
306
  # "upload state: upload started."
257
307
  # (show progress bar)
258
308
 
259
- unless @state_respders[:started].empty?
309
+ unless @state_responders[:started].empty?
260
310
  @state_responders[:started].each do |plugin_name,method_name|
261
311
  msg.run( plugin_name,method_name,msg,self,upload_state )
262
312
  end
@@ -278,8 +328,8 @@ module RSence
278
328
 
279
329
  ## add the id to the values to be checked
280
330
  check_ids = msg.session[:values][:check]
281
- unless check_ids.include?( @val_id )
282
- check_ids.push( @val_id )
331
+ unless check_ids.include?( @value_id )
332
+ check_ids.push( @value_id )
283
333
  end
284
334
 
285
335
  end
@@ -321,6 +371,7 @@ module RSence
321
371
  hvalue.set( msg, upload_key )
322
372
  end
323
373
  end
374
+ =end
324
375
 
325
376
  end
326
377