rsence-pre 2.1.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. data/.yardopts +10 -0
  2. data/INSTALL.rdoc +330 -0
  3. data/LICENSE.txt +622 -0
  4. data/README.rdoc +98 -0
  5. data/VERSION +1 -0
  6. data/bin/rsence +25 -0
  7. data/bin/rsence-pre +25 -0
  8. data/conf/default_conf.yaml +346 -0
  9. data/conf/default_strings.yaml +76 -0
  10. data/conf/rsence_command_strings.yaml +444 -0
  11. data/docs/ExampleGuiPlugin.rdoc +193 -0
  12. data/docs/JavascriptBundles.rdoc +0 -0
  13. data/docs/PluginBundleInfo.rdoc +173 -0
  14. data/docs/PluginBundles.rdoc +96 -0
  15. data/docs/Values.rdoc +163 -0
  16. data/js/comm/autosync/autosync.js +17 -0
  17. data/js/comm/autosync/js.inc +0 -0
  18. data/js/comm/comm.js +203 -0
  19. data/js/comm/js.inc +0 -0
  20. data/js/comm/jsloader/js.inc +0 -0
  21. data/js/comm/jsloader/jsloader.js +112 -0
  22. data/js/comm/queue/js.inc +0 -0
  23. data/js/comm/queue/queue.js +184 -0
  24. data/js/comm/session/js.inc +0 -0
  25. data/js/comm/session/session.js +52 -0
  26. data/js/comm/sessionwatcher/js.inc +0 -0
  27. data/js/comm/sessionwatcher/sessionwatcher.js +44 -0
  28. data/js/comm/transporter/js.inc +0 -0
  29. data/js/comm/transporter/transporter.js +261 -0
  30. data/js/comm/urlresponder/js.inc +0 -0
  31. data/js/comm/urlresponder/urlresponder.js +149 -0
  32. data/js/comm/values/js.inc +0 -0
  33. data/js/comm/values/values.js +433 -0
  34. data/js/controls/button/button.js +72 -0
  35. data/js/controls/button/js.inc +0 -0
  36. data/js/controls/button/themes/bright/button.css +89 -0
  37. data/js/controls/button/themes/bright/button.html +7 -0
  38. data/js/controls/button/themes/bright/button_parts1-ie6.gif +0 -0
  39. data/js/controls/button/themes/bright/button_parts1.png +0 -0
  40. data/js/controls/button/themes/default/button.css +89 -0
  41. data/js/controls/button/themes/default/button.html +7 -0
  42. data/js/controls/button/themes/default/button_parts1-ie6.gif +0 -0
  43. data/js/controls/button/themes/default/button_parts1.png +0 -0
  44. data/js/controls/checkbox/checkbox.js +49 -0
  45. data/js/controls/checkbox/js.inc +0 -0
  46. data/js/controls/checkbox/themes/default/checkbox.css +69 -0
  47. data/js/controls/checkbox/themes/default/checkbox.html +5 -0
  48. data/js/controls/checkbox/themes/default/checkbox_parts1-ie6.gif +0 -0
  49. data/js/controls/checkbox/themes/default/checkbox_parts1.png +0 -0
  50. data/js/controls/dialogs/alert_sheet/alert_sheet.js +63 -0
  51. data/js/controls/dialogs/alert_sheet/js.inc +0 -0
  52. data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +37 -0
  53. data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
  54. data/js/controls/dialogs/sheet/js.inc +0 -0
  55. data/js/controls/dialogs/sheet/sheet.js +84 -0
  56. data/js/controls/dialogs/sheet/themes/default/sheet.css +64 -0
  57. data/js/controls/dialogs/sheet/themes/default/sheet.html +14 -0
  58. data/js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif +0 -0
  59. data/js/controls/dialogs/sheet/themes/default/sheet_bg.png +0 -0
  60. data/js/controls/dialogs/sheet/themes/default/sheet_dim-ie6.gif +0 -0
  61. data/js/controls/dialogs/sheet/themes/default/sheet_dim.png +0 -0
  62. data/js/controls/dialogs/sheet/themes/default/sheet_parts1-ie6.gif +0 -0
  63. data/js/controls/dialogs/sheet/themes/default/sheet_parts1.png +0 -0
  64. data/js/controls/dialogs/sheet/themes/default/sheet_parts2-ie6.gif +0 -0
  65. data/js/controls/dialogs/sheet/themes/default/sheet_parts2.png +0 -0
  66. data/js/controls/dialogs/sheet/themes/default/sheet_warning-ie6.gif +0 -0
  67. data/js/controls/dialogs/sheet/themes/default/sheet_warning.png +0 -0
  68. data/js/controls/imageview/imageview.js +109 -0
  69. data/js/controls/imageview/js.inc +0 -0
  70. data/js/controls/imageview/themes/default/blank.gif +0 -0
  71. data/js/controls/passwordcontrol/js.inc +0 -0
  72. data/js/controls/passwordcontrol/passwordcontrol.js +23 -0
  73. data/js/controls/passwordcontrol/themes/default/passwordcontrol.css +0 -0
  74. data/js/controls/passwordcontrol/themes/default/passwordcontrol.html +18 -0
  75. data/js/controls/progress/progressbar/js.inc +0 -0
  76. data/js/controls/progress/progressbar/progressbar.js +40 -0
  77. data/js/controls/progress/progressbar/themes/default/progressbar.css +16 -0
  78. data/js/controls/progress/progressbar/themes/default/progressbar.html +2 -0
  79. data/js/controls/progress/progressindicator/js.inc +0 -0
  80. data/js/controls/progress/progressindicator/progressindicator.js +44 -0
  81. data/js/controls/radiobutton/js.inc +0 -0
  82. data/js/controls/radiobutton/radiobutton.js +43 -0
  83. data/js/controls/radiobutton/themes/default/radiobutton.css +69 -0
  84. data/js/controls/radiobutton/themes/default/radiobutton.html +5 -0
  85. data/js/controls/radiobutton/themes/default/radiobutton_parts1-ie6.gif +0 -0
  86. data/js/controls/radiobutton/themes/default/radiobutton_parts1.png +0 -0
  87. data/js/controls/sliders/slider/js.inc +0 -0
  88. data/js/controls/sliders/slider/slider.js +357 -0
  89. data/js/controls/sliders/slider/themes/default/hslider_tracks-ie6.gif +0 -0
  90. data/js/controls/sliders/slider/themes/default/hslider_tracks.png +0 -0
  91. data/js/controls/sliders/slider/themes/default/slider.css +108 -0
  92. data/js/controls/sliders/slider/themes/default/slider.html +5 -0
  93. data/js/controls/sliders/slider/themes/default/slider_thumbs-ie6.gif +0 -0
  94. data/js/controls/sliders/slider/themes/default/slider_thumbs.png +0 -0
  95. data/js/controls/sliders/vslider/js.inc +0 -0
  96. data/js/controls/sliders/vslider/themes/default/vslider.css +52 -0
  97. data/js/controls/sliders/vslider/themes/default/vslider.html +5 -0
  98. data/js/controls/sliders/vslider/themes/default/vslider_tracks-ie6.gif +0 -0
  99. data/js/controls/sliders/vslider/themes/default/vslider_tracks.png +0 -0
  100. data/js/controls/sliders/vslider/vslider.js +41 -0
  101. data/js/controls/stepper/js.inc +0 -0
  102. data/js/controls/stepper/stepper.js +213 -0
  103. data/js/controls/stepper/themes/default/stepper-ie6.gif +0 -0
  104. data/js/controls/stepper/themes/default/stepper.css +14 -0
  105. data/js/controls/stepper/themes/default/stepper.html +2 -0
  106. data/js/controls/stepper/themes/default/stepper.png +0 -0
  107. data/js/controls/stringview/js.inc +0 -0
  108. data/js/controls/stringview/stringview.js +49 -0
  109. data/js/controls/stringview/themes/default/stringview.css +8 -0
  110. data/js/controls/stringview/themes/default/stringview.html +1 -0
  111. data/js/controls/tab/js.inc +0 -0
  112. data/js/controls/tab/tab.js +280 -0
  113. data/js/controls/tab/themes/bright/tab.css +76 -0
  114. data/js/controls/tab/themes/bright/tab.html +6 -0
  115. data/js/controls/tab/themes/bright/tab_bg_color-ie6.gif +0 -0
  116. data/js/controls/tab/themes/bright/tab_bg_color.png +0 -0
  117. data/js/controls/tab/themes/bright/tab_border_pattern-ie6.gif +0 -0
  118. data/js/controls/tab/themes/bright/tab_border_pattern.png +0 -0
  119. data/js/controls/tab/themes/bright/tab_parts1-ie6.gif +0 -0
  120. data/js/controls/tab/themes/bright/tab_parts1.png +0 -0
  121. data/js/controls/tab/themes/default/tab.css +77 -0
  122. data/js/controls/tab/themes/default/tab.html +6 -0
  123. data/js/controls/tab/themes/default/tab_bg_color-ie6.gif +0 -0
  124. data/js/controls/tab/themes/default/tab_bg_color.png +0 -0
  125. data/js/controls/tab/themes/default/tab_border_pattern-ie6.gif +0 -0
  126. data/js/controls/tab/themes/default/tab_border_pattern.png +0 -0
  127. data/js/controls/tab/themes/default/tab_parts1-ie6.gif +0 -0
  128. data/js/controls/tab/themes/default/tab_parts1.png +0 -0
  129. data/js/controls/textarea/js.inc +0 -0
  130. data/js/controls/textarea/textarea.js +24 -0
  131. data/js/controls/textarea/themes/default/textarea.css +21 -0
  132. data/js/controls/textarea/themes/default/textarea.html +18 -0
  133. data/js/controls/textcontrol/js.inc +0 -0
  134. data/js/controls/textcontrol/textcontrol.js +374 -0
  135. data/js/controls/textcontrol/themes/default/textcontrol.css +107 -0
  136. data/js/controls/textcontrol/themes/default/textcontrol.html +18 -0
  137. data/js/controls/textcontrol/themes/default/textcontrol_parts1-ie6.gif +0 -0
  138. data/js/controls/textcontrol/themes/default/textcontrol_parts1.png +0 -0
  139. data/js/controls/textcontrol/themes/default/textcontrol_parts2-ie6.gif +0 -0
  140. data/js/controls/textcontrol/themes/default/textcontrol_parts2.png +0 -0
  141. data/js/controls/textcontrol/themes/default/textcontrol_parts3-ie6.gif +0 -0
  142. data/js/controls/textcontrol/themes/default/textcontrol_parts3.png +0 -0
  143. data/js/controls/uploader/js.inc +0 -0
  144. data/js/controls/uploader/themes/default/upload_progress.gif +0 -0
  145. data/js/controls/uploader/themes/default/uploader.css +108 -0
  146. data/js/controls/uploader/themes/default/uploader.html +27 -0
  147. data/js/controls/uploader/uploader.js +154 -0
  148. data/js/controls/validatorview/js.inc +0 -0
  149. data/js/controls/validatorview/themes/default/validator-ie6.gif +0 -0
  150. data/js/controls/validatorview/themes/default/validator.png +0 -0
  151. data/js/controls/validatorview/themes/default/validatorview.css +0 -0
  152. data/js/controls/validatorview/themes/default/validatorview.html +0 -0
  153. data/js/controls/validatorview/validatorview.js +62 -0
  154. data/js/controls/window/js.inc +0 -0
  155. data/js/controls/window/themes/default/window.css +219 -0
  156. data/js/controls/window/themes/default/window.html +17 -0
  157. data/js/controls/window/themes/default/window_bg_active-ie6.gif +0 -0
  158. data/js/controls/window/themes/default/window_bg_active.png +0 -0
  159. data/js/controls/window/themes/default/window_bg_inactive-ie6.gif +0 -0
  160. data/js/controls/window/themes/default/window_bg_inactive.png +0 -0
  161. data/js/controls/window/themes/default/window_buttons-ie6.gif +0 -0
  162. data/js/controls/window/themes/default/window_buttons.png +0 -0
  163. data/js/controls/window/themes/default/window_parts1-ie6.gif +0 -0
  164. data/js/controls/window/themes/default/window_parts1.png +0 -0
  165. data/js/controls/window/themes/default/window_parts2-ie6.gif +0 -0
  166. data/js/controls/window/themes/default/window_parts2.png +0 -0
  167. data/js/controls/window/window.js +286 -0
  168. data/js/core/class/class.js +318 -0
  169. data/js/core/class/js.inc +0 -0
  170. data/js/core/elem/elem.js +1383 -0
  171. data/js/core/elem/js.inc +0 -0
  172. data/js/core/event/event.js +153 -0
  173. data/js/core/event/js.inc +0 -0
  174. data/js/core/iefix/ie_css_element.htc +5 -0
  175. data/js/core/iefix/ie_css_style.htc +5 -0
  176. data/js/core/iefix/iefix.js +359 -0
  177. data/js/core/iefix/js.inc +0 -0
  178. data/js/core/rsence_ns/js.inc +0 -0
  179. data/js/core/rsence_ns/rsence_ns.js +21 -0
  180. data/js/datetime/calendar/calendar.js +198 -0
  181. data/js/datetime/calendar/js.inc +0 -0
  182. data/js/datetime/calendar/themes/default/calendar.css +108 -0
  183. data/js/datetime/calendar/themes/default/calendar.html +9 -0
  184. data/js/datetime/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
  185. data/js/datetime/calendar/themes/default/calendar_arrows.png +0 -0
  186. data/js/datetime/datetimevalue/datetimevalue.js +247 -0
  187. data/js/datetime/datetimevalue/js.inc +0 -0
  188. data/js/datetime/timesheet/js.inc +0 -0
  189. data/js/datetime/timesheet/themes/default/timesheet.css +30 -0
  190. data/js/datetime/timesheet/themes/default/timesheet.html +2 -0
  191. data/js/datetime/timesheet/timesheet.js +183 -0
  192. data/js/datetime/timesheet_item/js.inc +0 -0
  193. data/js/datetime/timesheet_item/themes/default/timesheet_item.css +42 -0
  194. data/js/datetime/timesheet_item/themes/default/timesheet_item.html +8 -0
  195. data/js/datetime/timesheet_item/timesheet_item.js +248 -0
  196. data/js/datetime/timesheet_item_edit/js.inc +0 -0
  197. data/js/datetime/timesheet_item_edit/timesheet_item_edit.js +274 -0
  198. data/js/foundation/application/application.js +208 -0
  199. data/js/foundation/application/js.inc +0 -0
  200. data/js/foundation/control/control.js +339 -0
  201. data/js/foundation/control/controldefaults/controldefaults.js +56 -0
  202. data/js/foundation/control/controldefaults/js.inc +0 -0
  203. data/js/foundation/control/dummyvalue/dummyvalue.js +51 -0
  204. data/js/foundation/control/dummyvalue/js.inc +0 -0
  205. data/js/foundation/control/dyncontrol/dyncontrol.js +500 -0
  206. data/js/foundation/control/dyncontrol/js.inc +0 -0
  207. data/js/foundation/control/dyncontrol/themes/default/dyncontrol.css +0 -0
  208. data/js/foundation/control/dyncontrol/themes/default/dyncontrol.html +0 -0
  209. data/js/foundation/control/eventresponder/eventresponder.js +750 -0
  210. data/js/foundation/control/eventresponder/js.inc +0 -0
  211. data/js/foundation/control/js.inc +0 -0
  212. data/js/foundation/control/valuematrix/js.inc +0 -0
  213. data/js/foundation/control/valuematrix/valuematrix.js +135 -0
  214. data/js/foundation/control/valueresponder/js.inc +0 -0
  215. data/js/foundation/control/valueresponder/valueresponder.js +79 -0
  216. data/js/foundation/eventmanager/eventmanager.js +991 -0
  217. data/js/foundation/eventmanager/js.inc +0 -0
  218. data/js/foundation/geom/point/js.inc +0 -0
  219. data/js/foundation/geom/point/point.js +202 -0
  220. data/js/foundation/geom/rect/js.inc +0 -0
  221. data/js/foundation/geom/rect/rect.js +651 -0
  222. data/js/foundation/json_renderer/js.inc +0 -0
  223. data/js/foundation/json_renderer/json_renderer.js +246 -0
  224. data/js/foundation/system/js.inc +0 -0
  225. data/js/foundation/system/system.js +381 -0
  226. data/js/foundation/thememanager/js.inc +0 -0
  227. data/js/foundation/thememanager/thememanager.js +393 -0
  228. data/js/foundation/value/js.inc +0 -0
  229. data/js/foundation/value/value.js +183 -0
  230. data/js/foundation/view/js.inc +0 -0
  231. data/js/foundation/view/markupview/js.inc +0 -0
  232. data/js/foundation/view/markupview/markupview.js +114 -0
  233. data/js/foundation/view/morphanimation/js.inc +0 -0
  234. data/js/foundation/view/morphanimation/morphanimation.js +237 -0
  235. data/js/foundation/view/view.js +1812 -0
  236. data/js/foundation/view/viewdefaults/js.inc +0 -0
  237. data/js/foundation/view/viewdefaults/viewdefaults.js +26 -0
  238. data/js/lists/checkboxlist/checkboxlist.js +171 -0
  239. data/js/lists/checkboxlist/js.inc +0 -0
  240. data/js/lists/listitems/js.inc +0 -0
  241. data/js/lists/listitems/listitems.js +88 -0
  242. data/js/lists/propertylist/js.inc +0 -0
  243. data/js/lists/propertylist/propertylist.js +326 -0
  244. data/js/lists/radiobuttonlist/js.inc +0 -0
  245. data/js/lists/radiobuttonlist/radiobuttonlist.js +116 -0
  246. data/js/util/reloadapp/js.inc +0 -0
  247. data/js/util/reloadapp/reloadapp.js +152 -0
  248. data/js/util/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
  249. data/js/util/reloadapp/themes/default/reloadapp_warning.png +0 -0
  250. data/js/util/sha/js.inc +0 -0
  251. data/js/util/sha/sha.js +426 -0
  252. data/js/views/centerview/centerview.js +75 -0
  253. data/js/views/centerview/js.inc +0 -0
  254. data/js/views/inlineview/inlineview.js +15 -0
  255. data/js/views/inlineview/js.inc +0 -0
  256. data/js/views/scrollview/js.inc +0 -0
  257. data/js/views/scrollview/scrollview.js +40 -0
  258. data/lib/conf/argv.rb +850 -0
  259. data/lib/conf/default.rb +219 -0
  260. data/lib/daemon/daemon.rb +387 -0
  261. data/lib/daemon/sigcomm.rb +64 -0
  262. data/lib/http/broker.rb +150 -0
  263. data/lib/http/rackup.rb +91 -0
  264. data/lib/http/request.rb +66 -0
  265. data/lib/http/response.rb +65 -0
  266. data/lib/plugins/dependencies.rb +285 -0
  267. data/lib/plugins/gui_plugin.rb +160 -0
  268. data/lib/plugins/guiparser.rb +123 -0
  269. data/lib/plugins/plugin.rb +438 -0
  270. data/lib/plugins/plugin_base.rb +162 -0
  271. data/lib/plugins/plugin_plugins.rb +81 -0
  272. data/lib/plugins/plugin_sqlite_db.rb +98 -0
  273. data/lib/plugins/pluginmanager.rb +635 -0
  274. data/lib/plugins/plugins.rb +169 -0
  275. data/lib/plugins/servlet.rb +108 -0
  276. data/lib/rsence.rb +32 -0
  277. data/lib/session/msg.rb +327 -0
  278. data/lib/session/sessionmanager.rb +522 -0
  279. data/lib/session/sessionstorage.rb +340 -0
  280. data/lib/transporter/transporter.rb +263 -0
  281. data/lib/util/gzstring.rb +9 -0
  282. data/lib/util/ruby19_fixes.rb +18 -0
  283. data/lib/values/hvalue.rb +378 -0
  284. data/lib/values/valuemanager.rb +172 -0
  285. data/plugins/client_pkg/client_pkg.rb +157 -0
  286. data/plugins/client_pkg/info.yaml +25 -0
  287. data/plugins/client_pkg/lib/client_pkg_build.rb +561 -0
  288. data/plugins/client_pkg/lib/client_pkg_cache.rb +50 -0
  289. data/plugins/client_pkg/lib/client_pkg_serve.rb +218 -0
  290. data/plugins/index_html/img/loading.gif +0 -0
  291. data/plugins/index_html/img/riassence.gif +0 -0
  292. data/plugins/index_html/index_html.rb +120 -0
  293. data/plugins/index_html/info.yaml +18 -0
  294. data/plugins/index_html/tmpl/index.html +15 -0
  295. data/plugins/main/info.yaml +18 -0
  296. data/plugins/main/js/main.js +84 -0
  297. data/plugins/main/main.rb +255 -0
  298. data/plugins/main/values.yaml +8 -0
  299. data/plugins/ticket/info.yaml +21 -0
  300. data/plugins/ticket/lib/common.rb +392 -0
  301. data/plugins/ticket/lib/favicon.rb +39 -0
  302. data/plugins/ticket/lib/file.rb +58 -0
  303. data/plugins/ticket/lib/img.rb +50 -0
  304. data/plugins/ticket/lib/objblob.rb +66 -0
  305. data/plugins/ticket/lib/rsrc.rb +34 -0
  306. data/plugins/ticket/lib/upload.rb +236 -0
  307. data/plugins/ticket/ticket.rb +333 -0
  308. data/setup/welcome/gui/welcome.yaml +92 -0
  309. data/setup/welcome/info.yaml +13 -0
  310. data/setup/welcome/text/welcome.html +9 -0
  311. data/setup/welcome/values.yaml +9 -0
  312. data/setup/welcome/welcome.rb +54 -0
  313. metadata +407 -0
@@ -0,0 +1,378 @@
1
+ ## RSence
2
+ # Copyright 2006 Riassence Inc.
3
+ # http://riassence.com/
4
+ #
5
+ # You should have received a copy of the GNU General Public License along
6
+ # with this software package. If not, contact licensing@riassence.com
7
+ ##
8
+
9
+
10
+
11
+ module RSence
12
+
13
+
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.
16
+ class HValue
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
+
51
+ # get the value storage from the session data
52
+ session_values = msg.session[:values][:by_id]
53
+
54
+ ## Store the object here
55
+ session_values[ @value_id ] = self
56
+
57
+ ## Sends the client-side description
58
+ restore( msg )
59
+
60
+ ## Set the valid flag, so we know that the value is initially in sync
61
+ @is_valid = true
62
+ end
63
+
64
+ # @private (Re-)Send the client-size representation
65
+ def restore( msg )
66
+
67
+ ## Tags itself as a new value from the client's point of view
68
+ @is_new_to_client = true
69
+
70
+ add_to_sync( msg )
71
+
72
+ end
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
+
83
+ ## Get an unique integer id for the value
84
+ if RSence.args[:debug] and meta[:name] and not msg.valuemanager.id_exists?( msg, meta[:name] )
85
+ @value_id = meta[:name]
86
+ else
87
+ @value_id = msg.valuemanager.randgen.gen
88
+ end
89
+
90
+ @meta = meta
91
+
92
+ ## set the data of the hvalue
93
+ set( msg, data, true )
94
+
95
+ ## the @sync flag is raised, when the client data is older than the server data
96
+ @sync = false
97
+
98
+ ## the @is_valid flag is lowered, when the client data is newer than the server data
99
+ @is_valid = true
100
+
101
+ ## Bind the value to the value manager and report it to the client
102
+ add( msg )
103
+
104
+ ## storage for validator bindings
105
+ @members = {}
106
+
107
+ end
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+ )
113
+ #
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]
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
120
+ @members[plugin_name] = [] unless @members.has_key?( plugin_name )
121
+ @members[plugin_name].push( method_name ) unless @members[plugin_name].include?( method_name )
122
+ return true
123
+ end
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.
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
132
+ return release_all if not plugin_name and not method_name
133
+ return false unless @members.has_key?( plugin_name )
134
+ if not method_name
135
+ @members.delete( plugin_name )
136
+ else
137
+ @members[plugin_name].slice!(@members[plugin_name].index( method_name )) if @members[plugin_name].include?(method_name)
138
+ end
139
+ return true
140
+ end
141
+
142
+ # Releases all responders.
143
+ # @return [true]
144
+ def release_all
145
+ @members = {}
146
+ return true
147
+ end
148
+
149
+ # @deprecated Use {#release} as the opposite to bind.
150
+ alias unbind release
151
+
152
+ # @private Tell all bound instances that the value is changed.
153
+ def tell( msg )
154
+ invalid_count = 0
155
+ @members.each_key do |plugin_name|
156
+ @members[plugin_name].each do |method_name|
157
+ invalid_count += 1 unless msg.plugins.run_plugin( plugin_name, method_name, msg, self )
158
+ end
159
+ end
160
+ if invalid_count == 0
161
+ @is_valid = true
162
+ msg.session[:values][:check].delete( @value_id )
163
+ end
164
+ end
165
+
166
+ # @private Handle updates from the client.
167
+ def from_client( msg, data )
168
+
169
+ # only process changes, if different from the one already stored.
170
+ if @data != data
171
+
172
+ ## set takes care of the setting..
173
+ @data = data
174
+
175
+ ## change the valid state, because the value was set by the client!
176
+ @is_valid = false
177
+
178
+ ## add the id to the values to be checked
179
+ check_ids = msg.session[:values][:check]
180
+ unless check_ids.include?( @value_id )
181
+ check_ids.push( @value_id )
182
+ end
183
+ end
184
+
185
+ end
186
+
187
+ # @private Adds the value to the sync array.
188
+ def add_to_sync( msg )
189
+ ## add the id to the values to be synchronized (to client)
190
+ sync_ids = msg.session[:values][:sync]
191
+ unless sync_ids.include?( @value_id )
192
+ sync_ids.push( @value_id )
193
+ end
194
+ end
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
+
202
+ @data = data
203
+
204
+ # won't tell the client about the change, usually not needed
205
+ unless dont_tell_client
206
+ ## update the flags
207
+ @sync = false
208
+ @is_valid = true
209
+
210
+ add_to_sync( msg )
211
+ end
212
+ end
213
+
214
+ # @private Tell the client that the value changed.
215
+ def to_client( msg )
216
+ if @is_new_to_client
217
+ ## Initialize a new client value
218
+ init_str = "COMM.Values.create(#{@value_id.to_json},#{@data.to_json});"
219
+ msg.reply_value( init_str )
220
+ @is_new_to_client = false
221
+ else
222
+ ## Sets the client value
223
+ msg.reply_value "HVM.s(#{@value_id.to_json},#{@data.to_json});"
224
+ end
225
+ end
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
+
231
+ release_all
232
+
233
+ # get the value storage from the session data
234
+ session_values = msg.session[:values][:by_id]
235
+
236
+ ## Store the object here
237
+ session_values.delete( @value_id )
238
+
239
+ if msg and not @is_new_to_client
240
+ msg.reply_value("HVM.del(#{@value_id.to_json});")
241
+ end
242
+ end
243
+ alias die die!
244
+
245
+ end
246
+
247
+
248
+ =begin
249
+ class UploadValue < HValue
250
+
251
+ @state_responders = {
252
+ :ready => [], # id == 0
253
+ :started => [], # id == 1
254
+ :process => [], # id == 2 ; also uses bind
255
+ 3 => [], # id == 3
256
+ 4 => [], # id == 4
257
+ :error => [] # id < 0
258
+ }
259
+
260
+ @upload_state = 0
261
+ @upload_key = ''
262
+ @uploads = []
263
+
264
+ # the data should contain both state and key in the value
265
+ def from_client( msg, data )
266
+
267
+ ## change the valid state, because the value was set by the client!
268
+ @is_valid = data.include?(':::')
269
+
270
+ # the state and key are separated by the ':::' delimiter string
271
+ if @is_valid
272
+
273
+ # split state and key using the delimiter
274
+ (upload_state, upload_key) = data.split(':::')
275
+
276
+ # the state is a number
277
+ upload_state = upload_state.to_i
278
+
279
+ @upload_state = upload_state
280
+ @upload_key = upload_key
281
+
282
+ # negative states are errors
283
+ if upload_state < 0
284
+ # "upload error: #{upload_state}"
285
+ # (parse the error)
286
+ unless @state_responders[:error].empty?
287
+ @state_responders[:error].each do |plugin_name,method_name|
288
+ msg.run( plugin_name,method_name,msg,self,upload_state )
289
+ end
290
+ end
291
+
292
+ # the default state, 0 means the UI is ready to send an
293
+ # upload and ticketserve is ready to receive it
294
+ elsif upload_state == 0
295
+ # "upload state: ready to upload."
296
+ # (do nothing)
297
+
298
+ unless @state_responders[:ready].empty?
299
+ @state_responders[:ready].each do |plugin_name,method_name|
300
+ msg.run( plugin_name,method_name,msg,self,upload_state )
301
+ end
302
+ end
303
+
304
+ # this state means the upload's transfer is started and progressing
305
+ elsif upload_state == 1
306
+ # "upload state: upload started."
307
+ # (show progress bar)
308
+
309
+ unless @state_responders[:started].empty?
310
+ @state_responders[:started].each do |plugin_name,method_name|
311
+ msg.run( plugin_name,method_name,msg,self,upload_state )
312
+ end
313
+ end
314
+
315
+ # this state means the upload's transfer is complete,
316
+ # but the uploaded data hasn't been handled yet.
317
+ elsif upload_state == 2
318
+ # "upload state: waiting to process."
319
+
320
+ uploads = msg.plugins[:ticketservices].get_uploads(upload_key,true)
321
+ if uploads.size == 1
322
+ uploaded_data = uploads[0]
323
+
324
+ # only process changes, if different from the one already stored.
325
+ if uploaded_data != @data
326
+
327
+ @data = uploaded_data
328
+
329
+ ## add the id to the values to be checked
330
+ check_ids = msg.session[:values][:check]
331
+ unless check_ids.include?( @value_id )
332
+ check_ids.push( @value_id )
333
+ end
334
+
335
+ end
336
+ msg.plugins[:ticketservices].del_uploads(upload_key,msg.ses_id)
337
+ else
338
+ # "upload, amount of uploads: #{uploads.size}"
339
+ end
340
+
341
+ #
342
+ hvalue.set(msg,"3:::#{upload_key}")
343
+
344
+ msg.console( "upload state: set to ack" )
345
+
346
+ elsif upload_state == 3
347
+ # "upload state: waiting for user ack."
348
+ # (do nothing)
349
+
350
+ msg.console( "upload state: waiting user ack" )
351
+
352
+
353
+ elsif upload_state == 4
354
+ # "upload state: user wants to upload again."
355
+ # (set a new upload key, )
356
+
357
+ msg.console( "upload state: ack, getting new key" )
358
+
359
+
360
+ setup_upload( msg, hvalue )
361
+
362
+
363
+ else
364
+ # "upload unknown state: #{upload_state.inspect}"
365
+ end
366
+ end
367
+ return true
368
+ end
369
+ def setup_upload(msg,hvalue,size_bytes=500*1024,accept_mime=/image\/(.*?)/,allow_multi=false)
370
+ upload_key = msg.plugins[:ticketservices].upload_key(msg,hvalue.val_id,size_bytes,accept_mime,allow_multi)
371
+ hvalue.set( msg, upload_key )
372
+ end
373
+ end
374
+ =end
375
+
376
+ end
377
+
378
+
@@ -0,0 +1,172 @@
1
+ ## RSence
2
+ # Copyright 2006 Riassence Inc.
3
+ # http://riassence.com/
4
+ #
5
+ # You should have received a copy of the GNU General Public License along
6
+ # with this software package. If not, contact licensing@riassence.com
7
+ ##
8
+
9
+
10
+
11
+ # Require needed value types (hvalue supports bool/float/int/string)
12
+ require 'values/hvalue'
13
+
14
+ # RandomGenerator produces unique, random values
15
+ require 'randgen'
16
+
17
+ module RSence
18
+
19
+ # @private ValueManager provides automatic, transparent synchronization of values
20
+ # between client and server by keeping track of session value ids that
21
+ # need to be synchronized to the client and to pass on the incoming data
22
+ # for validation.
23
+ class ValueManager
24
+
25
+ # @private Accessor for the {RandGen} instance used.
26
+ # @return [RandGen]
27
+ attr_accessor :randgen
28
+
29
+ def initialize
30
+ # Initializes the member value handler objects.
31
+ @config = RSence.config[:session_conf]
32
+
33
+ ## 'Unique' Random String generator for HValue keys (passed on to the client)
34
+ @randgen = RandGen.new( @config[:key_length] )
35
+
36
+ end
37
+
38
+ # @private Re-constructs all stored values and sends them to the client.
39
+ # Used for restoring and cloning session values.
40
+ def resend_session_values( msg )
41
+
42
+ # with disposable keys enabled,
43
+ # sessions restored from cookie_key replace
44
+ # all val_id:s with new ones
45
+ if @config[:disposable_keys]
46
+
47
+ # get the session values
48
+ ses_values = msg.session[:values]
49
+
50
+ # loop through the value id:s
51
+ old_ids = ses_values[:by_id].keys
52
+ old_ids.each do |old_id|
53
+
54
+ # get the hvalue
55
+ val_obj = ses_values[:by_id][old_id]
56
+
57
+ # make a new id
58
+ unless RSence.args[:debug] and val_obj.meta[:name]
59
+ new_id = @randgen.gen
60
+ new_id = @randgen.gen while id_exists?( msg, new_id )
61
+
62
+ # replace the old id in the hvalue itself
63
+ val_obj.val_id = new_id
64
+
65
+ # re-associate the value with the new id
66
+ ses_values[:by_id][new_id] = val_obj
67
+ ses_values[:by_id].delete(old_id)
68
+
69
+ # replace the id in the unvalidated values (:check) array
70
+ if ses_values[:check].include?(old_id)
71
+ old_idx = ses_values[:check].index(old_id)
72
+ ses_values[:check][old_idx] = new_id
73
+ end
74
+
75
+ # replace the id in the unsynchronized values (:sync) array
76
+ if ses_values[:sync].include?(old_id)
77
+ old_idx = ses_values[:sync].index(old_id)
78
+ ses_values[:sync][old_idx] = new_id
79
+ end
80
+
81
+ end
82
+
83
+ # tell the hvalue to send its client-side initialization
84
+ val_obj.restore( msg )
85
+
86
+ end
87
+
88
+ ## keeping the id:s between page reloads is faster, but less tamper-proof
89
+ else
90
+ msg.session[:values][:by_id].each_key do |val_id|
91
+ msg.session[:values][:by_id][val_id].restore( msg )
92
+ end
93
+ end
94
+
95
+ end
96
+
97
+ # @private Verifies new_id is unique.
98
+ def id_exists?( msg, new_id )
99
+ return msg.session[:values][:by_id].has_key?(new_id)
100
+ end
101
+
102
+ # @private Parses the json from the client and passes it on to associated values
103
+ def xhr( msg, syncdata_str )
104
+
105
+ # parses the json data sent by the client
106
+ syncdata = JSON.parse( syncdata_str )
107
+
108
+ session_values = msg.session[:values][:by_id]
109
+ syncdata.each do |value_key, value_data|
110
+ if session_values.has_key?( value_key )
111
+ value_obj = session_values[ value_key ]
112
+ value_obj.from_client( msg, value_data )
113
+ else
114
+ raise "HValue; unassigned value id! (#{val_id.inspect})"
115
+ end
116
+ end
117
+ end
118
+
119
+ # @private Sets a value by id
120
+ def set( msg, val_id, val_data )
121
+
122
+ # get the session data of this session
123
+ session_values = msg.session[:values][:by_id]
124
+
125
+ # tell the value of that id that it has new data
126
+ val_obj = session_values[ val_id ]
127
+ val_obj.set( msg, val_data )
128
+ end
129
+
130
+ # @private Validates the new data of all client-side-modified session-bound values
131
+ def validate( msg )
132
+
133
+ # get the session data of this session
134
+ session_values = msg.session[:values]
135
+
136
+ # loop through un-validated values and validate them
137
+ check_ids = session_values[:check]
138
+ check_ids.clone.each do |check_id|
139
+ session_values[:by_id][check_id].tell( msg )
140
+ end
141
+
142
+ end
143
+
144
+ # @private Sends the new data of all server-side-modified session-bound values to the client
145
+ def sync_client( msg )
146
+
147
+ # get the session data of this session
148
+ session_values = msg.session[:values]
149
+
150
+ # go through the currently un-synced values
151
+ session_values[:sync].size.times do |count_num|
152
+
153
+ # the sync-array will return the value id
154
+ val_id = session_values[:sync].shift
155
+
156
+ unless session_values[:by_id].has_key? val_id
157
+ warn "ValueManager#sync_client -- Invalid value id: #{val_id.inspect}"
158
+ next
159
+ end
160
+
161
+ # tell the value of that id to report its state to the client
162
+ session_values[:by_id][val_id].to_client( msg )
163
+
164
+ end
165
+
166
+ end
167
+
168
+ end
169
+
170
+
171
+ end
172
+
@@ -0,0 +1,157 @@
1
+ ## RSence
2
+ # Copyright 2007 Riassence Inc.
3
+ # http://riassence.com/
4
+ #
5
+ # You should have received a copy of the GNU General Public License along
6
+ # with this software package. If not, contact licensing@riassence.com
7
+ ##
8
+
9
+
10
+ # the library path of this plugin
11
+ lib_path = File.join( bundle_path, 'lib' )
12
+
13
+ # The ClientPkgCache class:
14
+ require File.join( lib_path, 'client_pkg_cache' )
15
+
16
+ # The ClientPkgServe module:
17
+ require File.join( lib_path, 'client_pkg_serve' )
18
+
19
+ # The ClientPkgBuild class:
20
+ require File.join( lib_path, 'client_pkg_build' )
21
+
22
+
23
+ # @private The ClientPkgPlugin builds and serves the client packages. It's not intended to be a part of the public API at this time.
24
+ class ClientPkgPlugin < Servlet
25
+
26
+ include ClientPkgServe
27
+
28
+ class BuildLogger
29
+ def initialize( log_path )
30
+ @last_time = Time.now
31
+ @log_path = log_path
32
+ @log_file = nil
33
+ end
34
+ def log( str )
35
+ if RSence.args[:verbose]
36
+ puts str
37
+ return
38
+ else
39
+ if @last_time < Time.now - 30
40
+ @last_time = Time.now
41
+ @log_file.write( %{--- #{@last_time.strftime("%Y-%m-%d %H:%M:%S")} ---\n} )
42
+ end
43
+ @log_file.write( "#{str}\n" )
44
+ @log_file.flush
45
+ end
46
+ end
47
+ def open
48
+ return if @log_file
49
+ @log_file = File.open( @log_path, 'a' )
50
+ end
51
+ def close
52
+ @log_file.close
53
+ @log_file = nil
54
+ end
55
+ end
56
+
57
+ def rebuild_client
58
+ until not @build_busy
59
+ puts "build busy, sleeping.."
60
+ sleep 0.5
61
+ end
62
+ @build_busy = true
63
+ @last_change = Time.now.to_i
64
+ @client_build.setup_dirs
65
+ @client_build.run
66
+ @client_cache.set_cache( @client_build.js, @client_build.gz, @client_build.themes )
67
+ @build_busy = false
68
+ end
69
+
70
+ def open
71
+ if not @thr and RSence.args[:autoupdate]
72
+ @thr = Thread.new do
73
+ Thread.pass
74
+ while true
75
+ begin
76
+ if @client_build.bundle_changes( @last_change )
77
+ rebuild_client
78
+ puts "Autobuilt."
79
+ if RSence.args[:say]
80
+ Thread.new do
81
+ Thread.pass
82
+ system('say "Autobuilt."')
83
+ end
84
+ end
85
+ end
86
+ rescue => e
87
+ warn e.inspect
88
+ end
89
+ sleep 3
90
+ end
91
+ end
92
+ end
93
+
94
+ end
95
+
96
+ def add_src_dir( src_dir ); @client_build.add_src_dir( src_dir ); end
97
+ def add_src_dirs( src_dirs ); @client_build.add_src_dirs( src_dirs ); end
98
+ def del_src_dir( src_dir ); @client_build.del_src_dir( src_dir ); end
99
+ def del_src_dirs( src_dirs ); @client_build.del_src_dirs( src_dirs ); end
100
+
101
+ def add_theme( theme_name ); @client_build.add_theme( theme_name ); end
102
+ def add_themes( theme_names ); @client_build.add_themes( theme_names ); end
103
+ def del_theme( theme_name ); @client_build.del_theme( theme_name ); end
104
+ def del_themes( theme_names ); @client_build.del_themes( theme_names ); end
105
+
106
+ def add_package( pkg_name, pkg_items ); @client_build.add_package( pkg_name, pkg_items ); end
107
+ def add_packages( packages ); @client_build.add_packages( packages ); end
108
+ def del_package( pkg_name ); @client_build.del_package( pkg_name ); end
109
+ def del_packages( packages ); @client_build.del_packages( packages ); end
110
+
111
+ def add_reserved_name( reserved_name ); @client_build.add_reserved_name( reserved_name ); end
112
+ def add_reserved_names( reserved_names ); @client_build.add_reserved_names( reserved_names ); end
113
+ def del_reserved_name( reserved_name ); @client_build.del_reserved_name( reserved_name ); end
114
+ def del_reserved_names( reserved_names ); @client_build.del_reserved_names( reserved_names ); end
115
+
116
+ def add_gfx_format( gfx_format_name ); @client_build.add_gfx_format( gfx_format_name ); end
117
+ def add_gfx_formats( gfx_format_names ); @client_build.add_gfx_formats( gfx_format_names ); end
118
+ def del_gfx_format( gfx_format_name ); @client_build.del_gfx_format( gfx_format_name ); end
119
+ def del_gfx_formats( gfx_format_names ); @client_build.del_gfx_formats( gfx_format_names ); end
120
+
121
+ def client_build; @client_build; end
122
+
123
+ def client_cache; @client_cache; end
124
+
125
+ def close
126
+ if @thr
127
+ @thr.kill
128
+ @thr = false
129
+ end
130
+ @client_build.flush
131
+ @client_build = nil
132
+ @client_cache = nil
133
+ @build_logger.close
134
+ end
135
+
136
+ def squeeze( js )
137
+ return @client_build.squeeze( js )
138
+ end
139
+
140
+ def init
141
+
142
+ @thr = false
143
+
144
+ @build_logger = BuildLogger.new( File.join(RSence.args[:env_path],'log','build_log') )
145
+ @build_logger.open
146
+
147
+ @client_build = ClientPkgBuild.new( RSence.config[:client_pkg], @build_logger )
148
+ @client_cache = ClientPkgCache.new
149
+
150
+ @build_busy = false
151
+ rebuild_client
152
+
153
+ end
154
+
155
+ end
156
+
157
+