rhoconnect 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. data/CHANGELOG +208 -0
  2. data/CREDITS +38 -0
  3. data/Gemfile +18 -0
  4. data/Gemfile.lock +97 -0
  5. data/LICENSE +75 -0
  6. data/README.md +10 -0
  7. data/Rakefile +82 -0
  8. data/bench/bench +7 -0
  9. data/bench/bench_runner.rb +112 -0
  10. data/bench/benchapp/Gemfile +21 -0
  11. data/bench/benchapp/Gemfile.lock +76 -0
  12. data/bench/benchapp/Rakefile +22 -0
  13. data/bench/benchapp/application.rb +39 -0
  14. data/bench/benchapp/config.ru +36 -0
  15. data/bench/benchapp/settings/license.key +1 -0
  16. data/bench/benchapp/settings/settings.yml +20 -0
  17. data/bench/benchapp/sources/mock_adapter.rb +55 -0
  18. data/bench/benchapp/sources/queue_mock_adapter.rb +2 -0
  19. data/bench/benchapp/spec/sources/mock_adapter_spec.rb +25 -0
  20. data/bench/benchapp/spec/sources/queue_mock_adapter_spec.rb +25 -0
  21. data/bench/benchapp/spec/spec_helper.rb +42 -0
  22. data/bench/blobapp/Gemfile +31 -0
  23. data/bench/blobapp/Gemfile.lock +103 -0
  24. data/bench/blobapp/Rakefile +25 -0
  25. data/bench/blobapp/application.rb +44 -0
  26. data/bench/blobapp/config.ru +36 -0
  27. data/bench/blobapp/settings/license.key +1 -0
  28. data/bench/blobapp/settings/settings.yml +16 -0
  29. data/bench/blobapp/sources/blob_adapter.rb +71 -0
  30. data/bench/blobapp/spec/sources/blob_adapter_spec.rb +25 -0
  31. data/bench/blobapp/spec/spec_helper.rb +42 -0
  32. data/bench/lib/bench/cli.rb +16 -0
  33. data/bench/lib/bench/logging.rb +13 -0
  34. data/bench/lib/bench/mock_client.rb +41 -0
  35. data/bench/lib/bench/result.rb +50 -0
  36. data/bench/lib/bench/runner.rb +107 -0
  37. data/bench/lib/bench/session.rb +67 -0
  38. data/bench/lib/bench/statistics.rb +56 -0
  39. data/bench/lib/bench/test_data.rb +98 -0
  40. data/bench/lib/bench/timer.rb +10 -0
  41. data/bench/lib/bench/utils.rb +49 -0
  42. data/bench/lib/bench.rb +129 -0
  43. data/bench/lib/testdata/100-data.txt +148 -0
  44. data/bench/lib/testdata/5-data.txt +9 -0
  45. data/bench/lib/testdata/images/icon.ico +0 -0
  46. data/bench/lib/testdata/images/icon.png +0 -0
  47. data/bench/lib/testdata/images/loading-Landscape.png +0 -0
  48. data/bench/lib/testdata/images/loading-LandscapeLeft.png +0 -0
  49. data/bench/lib/testdata/images/loading-LandscapeRight.png +0 -0
  50. data/bench/lib/testdata/images/loading-Portrait.png +0 -0
  51. data/bench/lib/testdata/images/loading-PortraitUpsideDown.png +0 -0
  52. data/bench/lib/testdata/images/loading.png +0 -0
  53. data/bench/lib/testdata/images/loading@2x.png +0 -0
  54. data/bench/run_bench.sh +42 -0
  55. data/bench/run_blob_script.sh +3 -0
  56. data/bench/run_cud_script.sh +3 -0
  57. data/bench/run_query_md_script.sh +3 -0
  58. data/bench/run_query_only_script.sh +3 -0
  59. data/bench/run_query_script.sh +3 -0
  60. data/bench/scripts/blob_cud_script.rb +98 -0
  61. data/bench/scripts/cud_script.rb +92 -0
  62. data/bench/scripts/helpers.rb +101 -0
  63. data/bench/scripts/query_md_script.rb +45 -0
  64. data/bench/scripts/query_only_script.rb +51 -0
  65. data/bench/scripts/query_script.rb +45 -0
  66. data/bench/spec/bench_spec_helper.rb +33 -0
  67. data/bench/spec/logging_spec.rb +15 -0
  68. data/bench/spec/mock_adapter_spec.rb +61 -0
  69. data/bench/spec/mock_client_spec.rb +65 -0
  70. data/bench/spec/result_spec.rb +61 -0
  71. data/bench/spec/utils_spec.rb +36 -0
  72. data/bin/rhoconnect +34 -0
  73. data/bin/rhoconnect-setup +84 -0
  74. data/doc/async-jobs.txt +69 -0
  75. data/doc/authentication.txt +76 -0
  76. data/doc/benchmarks.txt +168 -0
  77. data/doc/blob-sync.txt +130 -0
  78. data/doc/bulk-sync.txt +102 -0
  79. data/doc/client.txt +432 -0
  80. data/doc/command-line.txt +210 -0
  81. data/doc/contributing.txt +60 -0
  82. data/doc/deploying.txt +82 -0
  83. data/doc/install.txt +28 -0
  84. data/doc/introduction.txt +20 -0
  85. data/doc/licensing.txt +18 -0
  86. data/doc/metadata.txt +458 -0
  87. data/doc/migration.txt +182 -0
  88. data/doc/public/css/print.css +29 -0
  89. data/doc/public/css/screen.css +257 -0
  90. data/doc/public/css/style.css +20 -0
  91. data/doc/push.txt +135 -0
  92. data/doc/release.txt +41 -0
  93. data/doc/rest-api.txt +367 -0
  94. data/doc/source-adapters.txt +325 -0
  95. data/doc/stats-middleware.txt +69 -0
  96. data/doc/testing.txt +222 -0
  97. data/doc/tutorial.txt +315 -0
  98. data/doc/web-console.txt +35 -0
  99. data/examples/simple/Rakefile +14 -0
  100. data/examples/simple/application.rb +27 -0
  101. data/examples/simple/config.ru +49 -0
  102. data/examples/simple/settings/license.key +1 -0
  103. data/examples/simple/settings/settings.yml +23 -0
  104. data/examples/simple/sources/sample_adapter.rb +5 -0
  105. data/examples/simple/sources/simple_adapter.rb +5 -0
  106. data/generators/rhoconnect.rb +119 -0
  107. data/generators/templates/application/Gemfile +21 -0
  108. data/generators/templates/application/Rakefile +22 -0
  109. data/generators/templates/application/application.rb +39 -0
  110. data/generators/templates/application/config.ru +36 -0
  111. data/generators/templates/application/settings/license.key +1 -0
  112. data/generators/templates/application/settings/settings.yml +14 -0
  113. data/generators/templates/application/spec/spec_helper.rb +42 -0
  114. data/generators/templates/source/source_adapter.rb +47 -0
  115. data/generators/templates/source/source_spec.rb +25 -0
  116. data/install.sh +408 -0
  117. data/installer/unix-like/rho_connect_install_checkers.rb +140 -0
  118. data/installer/unix-like/rho_connect_install_constants.rb +51 -0
  119. data/installer/unix-like/rho_connect_install_debian.rb +63 -0
  120. data/installer/unix-like/rho_connect_install_dnd.rb +58 -0
  121. data/installer/unix-like/rho_connect_install_get_params.rb +30 -0
  122. data/installer/unix-like/rho_connect_install_installers.rb +142 -0
  123. data/installer/unix-like/rho_connect_install_utilities.rb +85 -0
  124. data/installer/unix-like/rho_connect_install_yum.rb +63 -0
  125. data/installer/unix-like/rhoinstaller.rb +89 -0
  126. data/installer/utils/create_texts.rb +366 -0
  127. data/installer/utils/install_test.rb +140 -0
  128. data/installer/windows/EnvVarUpdate.nsh +328 -0
  129. data/installer/windows/ServiceLib.nsh +369 -0
  130. data/installer/windows/configUi.ini +44 -0
  131. data/installer/windows/icon.ico +0 -0
  132. data/installer/windows/rhosync.nsi +418 -0
  133. data/installer/windows/uninstall.bat +7 -0
  134. data/lib/rhoconnect/api/admin/get_api_token.rb +14 -0
  135. data/lib/rhoconnect/api/admin/get_license_info.rb +8 -0
  136. data/lib/rhoconnect/api/admin/login.rb +6 -0
  137. data/lib/rhoconnect/api/admin/reset.rb +10 -0
  138. data/lib/rhoconnect/api/admin/stats.rb +21 -0
  139. data/lib/rhoconnect/api/application/bulk_data.rb +7 -0
  140. data/lib/rhoconnect/api/application/clientcreate.rb +8 -0
  141. data/lib/rhoconnect/api/application/clientlogin.rb +6 -0
  142. data/lib/rhoconnect/api/application/clientregister.rb +6 -0
  143. data/lib/rhoconnect/api/application/clientreset.rb +6 -0
  144. data/lib/rhoconnect/api/application/query.rb +7 -0
  145. data/lib/rhoconnect/api/application/queue_updates.rb +6 -0
  146. data/lib/rhoconnect/api/application/search.rb +6 -0
  147. data/lib/rhoconnect/api/client/create_client.rb +3 -0
  148. data/lib/rhoconnect/api/client/delete_client.rb +5 -0
  149. data/lib/rhoconnect/api/client/get_client_params.rb +3 -0
  150. data/lib/rhoconnect/api/client/list_client_docs.rb +12 -0
  151. data/lib/rhoconnect/api/client/list_clients.rb +3 -0
  152. data/lib/rhoconnect/api/client/ping.rb +7 -0
  153. data/lib/rhoconnect/api/source/get_adapter.rb +3 -0
  154. data/lib/rhoconnect/api/source/get_db_doc.rb +7 -0
  155. data/lib/rhoconnect/api/source/get_source_params.rb +3 -0
  156. data/lib/rhoconnect/api/source/list_source_docs.rb +10 -0
  157. data/lib/rhoconnect/api/source/list_sources.rb +15 -0
  158. data/lib/rhoconnect/api/source/push_deletes.rb +8 -0
  159. data/lib/rhoconnect/api/source/push_objects.rb +8 -0
  160. data/lib/rhoconnect/api/source/save_adapter.rb +3 -0
  161. data/lib/rhoconnect/api/source/set_db_doc.rb +8 -0
  162. data/lib/rhoconnect/api/source/set_refresh_time.rb +8 -0
  163. data/lib/rhoconnect/api/source/upload_file.rb +4 -0
  164. data/lib/rhoconnect/api/user/create_user.rb +7 -0
  165. data/lib/rhoconnect/api/user/delete_user.rb +9 -0
  166. data/lib/rhoconnect/api/user/list_users.rb +3 -0
  167. data/lib/rhoconnect/api/user/update_user.rb +4 -0
  168. data/lib/rhoconnect/api_token.rb +19 -0
  169. data/lib/rhoconnect/app.rb +76 -0
  170. data/lib/rhoconnect/bulk_data/bulk_data.rb +88 -0
  171. data/lib/rhoconnect/bulk_data/syncdb.index.schema +4 -0
  172. data/lib/rhoconnect/bulk_data/syncdb.schema +41 -0
  173. data/lib/rhoconnect/bulk_data.rb +2 -0
  174. data/lib/rhoconnect/client.rb +96 -0
  175. data/lib/rhoconnect/client_sync.rb +412 -0
  176. data/lib/rhoconnect/console/app/helpers/auth_helper.rb +22 -0
  177. data/lib/rhoconnect/console/app/helpers/extensions.rb +19 -0
  178. data/lib/rhoconnect/console/app/helpers/helpers.rb +57 -0
  179. data/lib/rhoconnect/console/app/public/ThickBox.css +649 -0
  180. data/lib/rhoconnect/console/app/public/home.css +438 -0
  181. data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
  182. data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
  183. data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
  184. data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
  185. data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
  186. data/lib/rhoconnect/console/app/public/images/rhomobile_rhohub_logo.png +0 -0
  187. data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
  188. data/lib/rhoconnect/console/app/public/jqplot/excanvas.min.js +35 -0
  189. data/lib/rhoconnect/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
  190. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
  191. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
  192. data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
  193. data/lib/rhoconnect/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
  194. data/lib/rhoconnect/console/app/public/jqplot/jqplot.cursor.js +952 -0
  195. data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
  196. data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
  197. data/lib/rhoconnect/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
  198. data/lib/rhoconnect/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
  199. data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
  200. data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
  201. data/lib/rhoconnect/console/app/public/main.css +7 -0
  202. data/lib/rhoconnect/console/app/public/reset.css +76 -0
  203. data/lib/rhoconnect/console/app/public/style.css +2201 -0
  204. data/lib/rhoconnect/console/app/public/text.txt +0 -0
  205. data/lib/rhoconnect/console/app/routes/adapter.rb +28 -0
  206. data/lib/rhoconnect/console/app/routes/auth.rb +29 -0
  207. data/lib/rhoconnect/console/app/routes/client.rb +31 -0
  208. data/lib/rhoconnect/console/app/routes/docs.rb +145 -0
  209. data/lib/rhoconnect/console/app/routes/heroku.rb +19 -0
  210. data/lib/rhoconnect/console/app/routes/home.rb +63 -0
  211. data/lib/rhoconnect/console/app/routes/timing.rb +242 -0
  212. data/lib/rhoconnect/console/app/routes/user.rb +117 -0
  213. data/lib/rhoconnect/console/app/views/adapter.erb +16 -0
  214. data/lib/rhoconnect/console/app/views/client.erb +30 -0
  215. data/lib/rhoconnect/console/app/views/content.erb +14 -0
  216. data/lib/rhoconnect/console/app/views/doc.erb +8 -0
  217. data/lib/rhoconnect/console/app/views/docdata.erb +28 -0
  218. data/lib/rhoconnect/console/app/views/docs.erb +30 -0
  219. data/lib/rhoconnect/console/app/views/edituser.erb +13 -0
  220. data/lib/rhoconnect/console/app/views/headermenu.erb +40 -0
  221. data/lib/rhoconnect/console/app/views/home.erb +24 -0
  222. data/lib/rhoconnect/console/app/views/index.erb +58 -0
  223. data/lib/rhoconnect/console/app/views/jqplot.erb +52 -0
  224. data/lib/rhoconnect/console/app/views/layout.erb +165 -0
  225. data/lib/rhoconnect/console/app/views/login.erb +26 -0
  226. data/lib/rhoconnect/console/app/views/newuser.erb +17 -0
  227. data/lib/rhoconnect/console/app/views/ping.erb +28 -0
  228. data/lib/rhoconnect/console/app/views/result.erb +11 -0
  229. data/lib/rhoconnect/console/app/views/rightboxlinks.erb +15 -0
  230. data/lib/rhoconnect/console/app/views/select_doc.erb +17 -0
  231. data/lib/rhoconnect/console/app/views/upload_doc.erb +23 -0
  232. data/lib/rhoconnect/console/app/views/user.erb +29 -0
  233. data/lib/rhoconnect/console/app/views/users.erb +12 -0
  234. data/lib/rhoconnect/console/rhoconnect_api.rb +245 -0
  235. data/lib/rhoconnect/console/server.rb +32 -0
  236. data/lib/rhoconnect/console.rb +3 -0
  237. data/lib/rhoconnect/cors.rb +229 -0
  238. data/lib/rhoconnect/credential.rb +9 -0
  239. data/lib/rhoconnect/db_adapter.rb +46 -0
  240. data/lib/rhoconnect/document.rb +49 -0
  241. data/lib/rhoconnect/dynamic_adapter.rb +91 -0
  242. data/lib/rhoconnect/generator.rb +1 -0
  243. data/lib/rhoconnect/jobs/bulk_data_job.rb +203 -0
  244. data/lib/rhoconnect/jobs/ping_job.rb +46 -0
  245. data/lib/rhoconnect/jobs/source_job.rb +16 -0
  246. data/lib/rhoconnect/license.rb +86 -0
  247. data/lib/rhoconnect/lock_ops.rb +11 -0
  248. data/lib/rhoconnect/model.rb +414 -0
  249. data/lib/rhoconnect/ping/android.rb +56 -0
  250. data/lib/rhoconnect/ping/apple.rb +52 -0
  251. data/lib/rhoconnect/ping/blackberry.rb +56 -0
  252. data/lib/rhoconnect/ping.rb +3 -0
  253. data/lib/rhoconnect/read_state.rb +31 -0
  254. data/lib/rhoconnect/rho_indifferent_access.rb +88 -0
  255. data/lib/rhoconnect/server/views/index.erb +13 -0
  256. data/lib/rhoconnect/server.rb +286 -0
  257. data/lib/rhoconnect/source.rb +289 -0
  258. data/lib/rhoconnect/source_adapter.rb +123 -0
  259. data/lib/rhoconnect/source_sync.rb +302 -0
  260. data/lib/rhoconnect/stats/middleware.rb +20 -0
  261. data/lib/rhoconnect/stats/record.rb +108 -0
  262. data/lib/rhoconnect/store.rb +232 -0
  263. data/lib/rhoconnect/tasks.rb +350 -0
  264. data/lib/rhoconnect/test_methods.rb +220 -0
  265. data/lib/rhoconnect/user.rb +95 -0
  266. data/lib/rhoconnect/version.rb +3 -0
  267. data/lib/rhoconnect/x_domain_session_wrapper.rb +53 -0
  268. data/lib/rhoconnect.rb +285 -0
  269. data/rhoconnect.gemspec +67 -0
  270. data/spec/api/admin/api_token_spec.rb +14 -0
  271. data/spec/api/admin/get_api_token_spec.rb +36 -0
  272. data/spec/api/admin/get_license_info_spec.rb +38 -0
  273. data/spec/api/admin/reset_spec.rb +22 -0
  274. data/spec/api/admin/stats_spec.rb +66 -0
  275. data/spec/api/api_helper.rb +21 -0
  276. data/spec/api/application/rhoconnect_api_spec.rb +548 -0
  277. data/spec/api/client/create_client_spec.rb +13 -0
  278. data/spec/api/client/delete_client_spec.rb +13 -0
  279. data/spec/api/client/get_client_params_spec.rb +18 -0
  280. data/spec/api/client/list_client_docs_spec.rb +32 -0
  281. data/spec/api/client/list_clients_spec.rb +22 -0
  282. data/spec/api/client/ping_spec.rb +23 -0
  283. data/spec/api/rhosync_api_spec.rb.orig +606 -0
  284. data/spec/api/source/adapter_spec.rb +29 -0
  285. data/spec/api/source/get_db_doc_spec.rb +21 -0
  286. data/spec/api/source/get_source_params_spec.rb +32 -0
  287. data/spec/api/source/list_source_docs_spec.rb +25 -0
  288. data/spec/api/source/list_sources_spec.rb +26 -0
  289. data/spec/api/source/push_deletes_spec.rb +18 -0
  290. data/spec/api/source/push_objects_spec.rb +27 -0
  291. data/spec/api/source/set_db_doc_spec.rb +19 -0
  292. data/spec/api/source/set_refresh_time_spec.rb +43 -0
  293. data/spec/api/source/upload_file_spec.rb +26 -0
  294. data/spec/api/user/create_user_spec.rb +16 -0
  295. data/spec/api/user/delete_user_spec.rb +36 -0
  296. data/spec/api/user/list_users_spec.rb +30 -0
  297. data/spec/api/user/update_user_spec.rb +31 -0
  298. data/spec/api_token_spec.rb +14 -0
  299. data/spec/app_spec.rb +18 -0
  300. data/spec/apps/emptyapp/application.rb +27 -0
  301. data/spec/apps/emptyapp/settings/license.key +1 -0
  302. data/spec/apps/emptyapp/settings/settings.yml +14 -0
  303. data/spec/apps/rhotestapp/Rakefile +1 -0
  304. data/spec/apps/rhotestapp/application.rb +19 -0
  305. data/spec/apps/rhotestapp/config.ru +1 -0
  306. data/spec/apps/rhotestapp/settings/apple_fake_cert.pem +1 -0
  307. data/spec/apps/rhotestapp/settings/license.key +1 -0
  308. data/spec/apps/rhotestapp/settings/settings.yml +36 -0
  309. data/spec/apps/rhotestapp/sources/base_adapter.rb +9 -0
  310. data/spec/apps/rhotestapp/sources/fixed_schema_adapter.rb +28 -0
  311. data/spec/apps/rhotestapp/sources/sample_adapter.rb +71 -0
  312. data/spec/apps/rhotestapp/sources/simple_adapter.rb +41 -0
  313. data/spec/apps/rhotestapp/sources/sub_adapter.rb +7 -0
  314. data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem/mygem.rb +8 -0
  315. data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem.rb +1 -0
  316. data/spec/bulk_data/bulk_data_spec.rb +97 -0
  317. data/spec/client_spec.rb +124 -0
  318. data/spec/client_sync_spec.rb +774 -0
  319. data/spec/doc/base.html +72 -0
  320. data/spec/doc/doc_spec.rb +376 -0
  321. data/spec/doc/footer.html +4 -0
  322. data/spec/doc/header.html +30 -0
  323. data/spec/document_spec.rb +31 -0
  324. data/spec/dynamic_adapter_spec.rb +43 -0
  325. data/spec/factories/factories.rb +17 -0
  326. data/spec/generator/generator_spec.rb +58 -0
  327. data/spec/generator/generator_spec_helper.rb +9 -0
  328. data/spec/jobs/bulk_data_job_spec.rb +125 -0
  329. data/spec/jobs/ping_job_spec.rb +102 -0
  330. data/spec/jobs/source_job_spec.rb +29 -0
  331. data/spec/license_spec.rb +66 -0
  332. data/spec/model_spec.rb +273 -0
  333. data/spec/perf/bulk_data_perf_spec.rb +32 -0
  334. data/spec/perf/perf_spec_helper.rb +50 -0
  335. data/spec/perf/store_perf_spec.rb +27 -0
  336. data/spec/ping/android_spec.rb +91 -0
  337. data/spec/ping/apple_spec.rb +70 -0
  338. data/spec/ping/blackberry_spec.rb +62 -0
  339. data/spec/read_state_spec.rb +35 -0
  340. data/spec/rhosync_spec.rb +75 -0
  341. data/spec/server/cors_spec.rb +287 -0
  342. data/spec/server/server_spec.rb +470 -0
  343. data/spec/server/x_domain_session_wrapper_spec.rb +150 -0
  344. data/spec/source_adapter_spec.rb +125 -0
  345. data/spec/source_spec.rb +114 -0
  346. data/spec/source_sync_spec.rb +328 -0
  347. data/spec/spec.opts +4 -0
  348. data/spec/spec_helper.rb +231 -0
  349. data/spec/stats/middleware_spec.rb +53 -0
  350. data/spec/stats/record_spec.rb +92 -0
  351. data/spec/store_spec.rb +251 -0
  352. data/spec/support/shared_examples.rb +168 -0
  353. data/spec/sync_states_spec.rb +72 -0
  354. data/spec/test_methods_spec.rb +134 -0
  355. data/spec/testdata/1000-data.txt +1414 -0
  356. data/spec/testdata/compressed/compress-data.txt +1 -0
  357. data/spec/testdata/upload1.txt +1 -0
  358. data/spec/testdata/upload2.txt +1 -0
  359. data/spec/user_spec.rb +139 -0
  360. data/tasks/redis.rake +206 -0
  361. metadata +706 -0
@@ -0,0 +1,328 @@
1
+ /**
2
+ * EnvVarUpdate.nsh
3
+ * : Environmental Variables: append, prepend, and remove entries
4
+ *
5
+ * WARNING: If you use StrFunc.nsh header then include it before this file
6
+ * with all required definitions. This is to avoid conflicts
7
+ *
8
+ * Usage:
9
+ * ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString"
10
+ *
11
+ * Credits:
12
+ * Version 1.0
13
+ * * Cal Turney (turnec2)
14
+ * * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this
15
+ * function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar,
16
+ * WriteEnvStr, and un.DeleteEnvStr
17
+ * * Diego Pedroso (deguix) for StrTok
18
+ * * Kevin English (kenglish_hi) for StrContains
19
+ * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry
20
+ * (dandaman32) for StrReplace
21
+ *
22
+ * Version 1.1 (compatibility with StrFunc.nsh)
23
+ * * techtonik
24
+ *
25
+ * http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries
26
+ *
27
+ */
28
+
29
+
30
+ !ifndef ENVVARUPDATE_FUNCTION
31
+ !define ENVVARUPDATE_FUNCTION
32
+ !verbose push
33
+ !verbose 3
34
+ !include "LogicLib.nsh"
35
+ !include "WinMessages.NSH"
36
+ !include "StrFunc.nsh"
37
+
38
+ ; ---- Fix for conflict if StrFunc.nsh is already includes in main file -----------------------
39
+ !macro _IncludeStrFunction StrFuncName
40
+ !ifndef ${StrFuncName}_INCLUDED
41
+ ${${StrFuncName}}
42
+ !endif
43
+ !ifndef Un${StrFuncName}_INCLUDED
44
+ ${Un${StrFuncName}}
45
+ !endif
46
+ !define un.${StrFuncName} "${Un${StrFuncName}}"
47
+ !macroend
48
+
49
+ !insertmacro _IncludeStrFunction StrTok
50
+ !insertmacro _IncludeStrFunction StrStr
51
+ !insertmacro _IncludeStrFunction StrRep
52
+
53
+ ; ---------------------------------- Macro Definitions ----------------------------------------
54
+ !macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString
55
+ Push "${EnvVarName}"
56
+ Push "${Action}"
57
+ Push "${RegLoc}"
58
+ Push "${PathString}"
59
+ Call EnvVarUpdate
60
+ Pop "${ResultVar}"
61
+ !macroend
62
+ !define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"'
63
+
64
+ !macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString
65
+ Push "${EnvVarName}"
66
+ Push "${Action}"
67
+ Push "${RegLoc}"
68
+ Push "${PathString}"
69
+ Call un.EnvVarUpdate
70
+ Pop "${ResultVar}"
71
+ !macroend
72
+ !define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"'
73
+ ; ---------------------------------- Macro Definitions end-------------------------------------
74
+
75
+ ;----------------------------------- EnvVarUpdate start----------------------------------------
76
+ !define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
77
+ !define hkcu_current_user 'HKCU "Environment"'
78
+
79
+ !macro EnvVarUpdate UN
80
+
81
+ Function ${UN}EnvVarUpdate
82
+
83
+ Push $0
84
+ Exch 4
85
+ Exch $1
86
+ Exch 3
87
+ Exch $2
88
+ Exch 2
89
+ Exch $3
90
+ Exch
91
+ Exch $4
92
+ Push $5
93
+ Push $6
94
+ Push $7
95
+ Push $8
96
+ Push $9
97
+ Push $R0
98
+
99
+ /* After this point:
100
+ -------------------------
101
+ $0 = ResultVar (returned)
102
+ $1 = EnvVarName (input)
103
+ $2 = Action (input)
104
+ $3 = RegLoc (input)
105
+ $4 = PathString (input)
106
+ $5 = Orig EnvVar (read from registry)
107
+ $6 = Len of $0 (temp)
108
+ $7 = tempstr1 (temp)
109
+ $8 = Entry counter (temp)
110
+ $9 = tempstr2 (temp)
111
+ $R0 = tempChar (temp) */
112
+
113
+ ; Step 1: Read contents of EnvVarName from RegLoc
114
+ ;
115
+ ; Check for empty EnvVarName
116
+ ${If} $1 == ""
117
+ SetErrors
118
+ DetailPrint "ERROR: EnvVarName is blank"
119
+ Goto EnvVarUpdate_Restore_Vars
120
+ ${EndIf}
121
+
122
+ ; Check for valid Action
123
+ ${If} $2 != "A"
124
+ ${AndIf} $2 != "P"
125
+ ${AndIf} $2 != "R"
126
+ SetErrors
127
+ DetailPrint "ERROR: Invalid Action - must be A, P, or R"
128
+ Goto EnvVarUpdate_Restore_Vars
129
+ ${EndIf}
130
+
131
+ ${If} $3 == HKLM
132
+ ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5
133
+ ${ElseIf} $3 == HKCU
134
+ ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5
135
+ ${Else}
136
+ SetErrors
137
+ DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"'
138
+ Goto EnvVarUpdate_Restore_Vars
139
+ ${EndIf}
140
+
141
+ ; Check for empty PathString
142
+ ${If} $4 == ""
143
+ SetErrors
144
+ DetailPrint "ERROR: PathString is blank"
145
+ Goto EnvVarUpdate_Restore_Vars
146
+ ${EndIf}
147
+
148
+ ; Make sure we've got some work to do
149
+ ${If} $5 == ""
150
+ ${AndIf} $2 == "R"
151
+ SetErrors
152
+ DetailPrint "$1 is empty - Nothing to remove"
153
+ Goto EnvVarUpdate_Restore_Vars
154
+ ${EndIf}
155
+
156
+ ; Step 2: Scrub EnvVar
157
+ ;
158
+ StrCpy $0 $5 ; Copy the contents to $0
159
+ ; Remove spaces around semicolons (NOTE: spaces before the 1st entry or
160
+ ; after the last one are not removed here but instead in Step 3)
161
+ ${If} $0 != "" ; If EnvVar is not empty ...
162
+ ${Do}
163
+ ${${UN}StrStr} $7 $0 " ;"
164
+ ${If} $7 == ""
165
+ ${ExitDo}
166
+ ${EndIf}
167
+ ${${UN}StrRep} $0 $0 " ;" ";" ; Remove '<space>;'
168
+ ${Loop}
169
+ ${Do}
170
+ ${${UN}StrStr} $7 $0 "; "
171
+ ${If} $7 == ""
172
+ ${ExitDo}
173
+ ${EndIf}
174
+ ${${UN}StrRep} $0 $0 "; " ";" ; Remove ';<space>'
175
+ ${Loop}
176
+ ${Do}
177
+ ${${UN}StrStr} $7 $0 ";;"
178
+ ${If} $7 == ""
179
+ ${ExitDo}
180
+ ${EndIf}
181
+ ${${UN}StrRep} $0 $0 ";;" ";"
182
+ ${Loop}
183
+
184
+ ; Remove a leading or trailing semicolon from EnvVar
185
+ StrCpy $7 $0 1 0
186
+ ${If} $7 == ";"
187
+ StrCpy $0 $0 "" 1 ; Change ';<EnvVar>' to '<EnvVar>'
188
+ ${EndIf}
189
+ StrLen $6 $0
190
+ IntOp $6 $6 - 1
191
+ StrCpy $7 $0 1 $6
192
+ ${If} $7 == ";"
193
+ StrCpy $0 $0 $6 ; Change ';<EnvVar>' to '<EnvVar>'
194
+ ${EndIf}
195
+ ; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug
196
+ ${EndIf}
197
+
198
+ /* Step 3. Remove all instances of the target path/string (even if "A" or "P")
199
+ $6 = bool flag (1 = found and removed PathString)
200
+ $7 = a string (e.g. path) delimited by semicolon(s)
201
+ $8 = entry counter starting at 0
202
+ $9 = copy of $0
203
+ $R0 = tempChar */
204
+
205
+ ${If} $5 != "" ; If EnvVar is not empty ...
206
+ StrCpy $9 $0
207
+ StrCpy $0 ""
208
+ StrCpy $8 0
209
+ StrCpy $6 0
210
+
211
+ ${Do}
212
+ ${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter
213
+
214
+ ${If} $7 == "" ; If we've run out of entries,
215
+ ${ExitDo} ; were done
216
+ ${EndIf} ;
217
+
218
+ ; Remove leading and trailing spaces from this entry (critical step for Action=Remove)
219
+ ${Do}
220
+ StrCpy $R0 $7 1
221
+ ${If} $R0 != " "
222
+ ${ExitDo}
223
+ ${EndIf}
224
+ StrCpy $7 $7 "" 1 ; Remove leading space
225
+ ${Loop}
226
+ ${Do}
227
+ StrCpy $R0 $7 1 -1
228
+ ${If} $R0 != " "
229
+ ${ExitDo}
230
+ ${EndIf}
231
+ StrCpy $7 $7 -1 ; Remove trailing space
232
+ ${Loop}
233
+ ${If} $7 == $4 ; If string matches, remove it by not appending it
234
+ StrCpy $6 1 ; Set 'found' flag
235
+ ${ElseIf} $7 != $4 ; If string does NOT match
236
+ ${AndIf} $0 == "" ; and the 1st string being added to $0,
237
+ StrCpy $0 $7 ; copy it to $0 without a prepended semicolon
238
+ ${ElseIf} $7 != $4 ; If string does NOT match
239
+ ${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0,
240
+ StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon
241
+ ${EndIf} ;
242
+
243
+ IntOp $8 $8 + 1 ; Bump counter
244
+ ${Loop} ; Check for duplicates until we run out of paths
245
+ ${EndIf}
246
+
247
+ ; Step 4: Perform the requested Action
248
+ ;
249
+ ${If} $2 != "R" ; If Append or Prepend
250
+ ${If} $6 == 1 ; And if we found the target
251
+ DetailPrint "Target is already present in $1. It will be removed and"
252
+ ${EndIf}
253
+ ${If} $0 == "" ; If EnvVar is (now) empty
254
+ StrCpy $0 $4 ; just copy PathString to EnvVar
255
+ ${If} $6 == 0 ; If found flag is either 0
256
+ ${OrIf} $6 == "" ; or blank (if EnvVarName is empty)
257
+ DetailPrint "$1 was empty and has been updated with the target"
258
+ ${EndIf}
259
+ ${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty),
260
+ StrCpy $0 $0;$4 ; append PathString
261
+ ${If} $6 == 1
262
+ DetailPrint "appended to $1"
263
+ ${Else}
264
+ DetailPrint "Target was appended to $1"
265
+ ${EndIf}
266
+ ${Else} ; If Prepend (and EnvVar is not empty),
267
+ StrCpy $0 $4;$0 ; prepend PathString
268
+ ${If} $6 == 1
269
+ DetailPrint "prepended to $1"
270
+ ${Else}
271
+ DetailPrint "Target was prepended to $1"
272
+ ${EndIf}
273
+ ${EndIf}
274
+ ${Else} ; If Action = Remove
275
+ ${If} $6 == 1 ; and we found the target
276
+ DetailPrint "Target was found and removed from $1"
277
+ ${Else}
278
+ DetailPrint "Target was NOT found in $1 (nothing to remove)"
279
+ ${EndIf}
280
+ ${If} $0 == ""
281
+ DetailPrint "$1 is now empty"
282
+ ${EndIf}
283
+ ${EndIf}
284
+
285
+ ; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change
286
+ ;
287
+ ClearErrors
288
+ ${If} $3 == HKLM
289
+ WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section
290
+ ${ElseIf} $3 == HKCU
291
+ WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section
292
+ ${EndIf}
293
+
294
+ IfErrors 0 +4
295
+ MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3"
296
+ DetailPrint "Could not write updated $1 to $3"
297
+ Goto EnvVarUpdate_Restore_Vars
298
+
299
+ ; "Export" our change
300
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
301
+
302
+ EnvVarUpdate_Restore_Vars:
303
+ ;
304
+ ; Restore the user's variables and return ResultVar
305
+ Pop $R0
306
+ Pop $9
307
+ Pop $8
308
+ Pop $7
309
+ Pop $6
310
+ Pop $5
311
+ Pop $4
312
+ Pop $3
313
+ Pop $2
314
+ Pop $1
315
+ Push $0 ; Push my $0 (ResultVar)
316
+ Exch
317
+ Pop $0 ; Restore his $0
318
+
319
+ FunctionEnd
320
+
321
+ !macroend ; EnvVarUpdate UN
322
+ !insertmacro EnvVarUpdate ""
323
+ !insertmacro EnvVarUpdate "un."
324
+ ;----------------------------------- EnvVarUpdate end----------------------------------------
325
+
326
+ !verbose pop
327
+ !endif
328
+
@@ -0,0 +1,369 @@
1
+ ; NSIS SERVICE LIBRARY - servicelib.nsh
2
+ ; Version 1.5 - Jun 25th, 2008
3
+ ; Questions/Comments - dselkirk@hotmail.com
4
+ ;
5
+ ; Description:
6
+ ; Provides an interface to window services
7
+ ;
8
+ ; Inputs:
9
+ ; action - systemlib action ie. create, delete, start, stop, pause,
10
+ ; continue, installed, running, status
11
+ ; name - name of service to manipulate
12
+ ; param - action parameters; usage: var1=value1;var2=value2;...etc.
13
+ ; (don't forget to add a ';' after the last value!)
14
+ ;
15
+ ; Actions:
16
+ ; create - creates a new windows service
17
+ ; Parameters:
18
+ ; path - path to service executable
19
+ ; autostart - automatically start with system ie. 1|0
20
+ ; interact - interact with the desktop ie. 1|0
21
+ ; depend - service dependencies
22
+ ; user - user that runs the service
23
+ ; password - password of the above user
24
+ ; display - display name in service's console
25
+ ; description - Description of service
26
+ ;
27
+ ; delete - deletes a windows service
28
+ ; start - start a stopped windows service
29
+ ; stop - stops a running windows service
30
+ ; pause - pauses a running windows service
31
+ ; continue - continues a paused windows service
32
+ ; installed - is the provided service installed
33
+ ; Parameters:
34
+ ; action - if true then invokes the specified action
35
+ ; running - is the provided service running
36
+ ; Parameters:
37
+ ; action - if true then invokes the specified action
38
+ ; status - check the status of the provided service
39
+ ;
40
+ ; If run from uninstall define "UN" as "un." before running.
41
+ ;
42
+ ; Usage:
43
+ ; Method 1:
44
+ ; Push "action"
45
+ ; Push "name"
46
+ ; Push "param"
47
+ ; Call Service
48
+ ; Pop $0 ;response
49
+ ;
50
+ ; Method 2:
51
+ ; !insertmacro SERVICE "action" "name" "param"
52
+ ;
53
+ ; History:
54
+ ; 1.0 - 09/15/2003 - Initial release
55
+ ; 1.1 - 09/16/2003 - Changed &l to i, thx brainsucker
56
+ ; 1.2 - 02/29/2004 - Fixed documentation.
57
+ ; 1.3 - 01/05/2006 - Fixed interactive flag and pop order (Kichik)
58
+ ; 1.4 - 12/07/2006 - Added display and depend, fixed datatypes (Vitoco)
59
+ ; 1.5 - 06/25/2008 - Added description of service.(DeSafe.com/liuqixing#gmail.com)
60
+
61
+ !ifndef SERVICELIB
62
+ !define SERVICELIB
63
+
64
+ !define SC_MANAGER_ALL_ACCESS 0x3F
65
+ !define SERVICE_ALL_ACCESS 0xF01FF
66
+
67
+ !define SERVICE_CONTROL_STOP 1
68
+ !define SERVICE_CONTROL_PAUSE 2
69
+ !define SERVICE_CONTROL_CONTINUE 3
70
+
71
+ !define SERVICE_STOPPED 0x1
72
+ !define SERVICE_START_PENDING 0x2
73
+ !define SERVICE_STOP_PENDING 0x3
74
+ !define SERVICE_RUNNING 0x4
75
+ !define SERVICE_CONTINUE_PENDING 0x5
76
+ !define SERVICE_PAUSE_PENDING 0x6
77
+ !define SERVICE_PAUSED 0x7
78
+
79
+ !ifndef UN
80
+ !define UN ""
81
+ !endif
82
+
83
+ !macro SERVICE ACTION NAME PARAM
84
+ Push '${ACTION}'
85
+ Push '${NAME}'
86
+ Push '${PARAM}'
87
+ Call ${UN}Service
88
+ !macroend
89
+
90
+ !macro FUNC_GETPARAM
91
+ Push $0
92
+ Push $1
93
+ Push $2
94
+ Push $3
95
+ Push $4
96
+ Push $5
97
+ Push $6
98
+ Push $7
99
+ Exch 8
100
+ Pop $1 ;name
101
+ Exch 8
102
+ Pop $2 ;source
103
+ StrCpy $0 ""
104
+ StrLen $7 $2
105
+ StrCpy $3 0
106
+ lbl_loop:
107
+ IntCmp $3 $7 0 0 lbl_done
108
+ StrLen $4 "$1="
109
+ StrCpy $5 $2 $4 $3
110
+ StrCmp $5 "$1=" 0 lbl_next
111
+ IntOp $5 $3 + $4
112
+ StrCpy $3 $5
113
+ lbl_loop2:
114
+ IntCmp $3 $7 0 0 lbl_done
115
+ StrCpy $6 $2 1 $3
116
+ StrCmp $6 ";" 0 lbl_next2
117
+ IntOp $6 $3 - $5
118
+ StrCpy $0 $2 $6 $5
119
+ Goto lbl_done
120
+ lbl_next2:
121
+ IntOp $3 $3 + 1
122
+ Goto lbl_loop2
123
+ lbl_next:
124
+ IntOp $3 $3 + 1
125
+ Goto lbl_loop
126
+ lbl_done:
127
+ Pop $5
128
+ Pop $4
129
+ Pop $3
130
+ Pop $2
131
+ Pop $1
132
+ Exch 2
133
+ Pop $6
134
+ Pop $7
135
+ Exch $0
136
+ !macroend
137
+
138
+ !macro CALL_GETPARAM VAR NAME DEFAULT LABEL
139
+ Push $1
140
+ Push ${NAME}
141
+ Call ${UN}GETPARAM
142
+ Pop $6
143
+ StrCpy ${VAR} "${DEFAULT}"
144
+ StrCmp $6 "" "${LABEL}" 0
145
+ StrCpy ${VAR} $6
146
+ !macroend
147
+
148
+ !macro FUNC_SERVICE UN
149
+ Push $0
150
+ Push $1
151
+ Push $2
152
+ Push $3
153
+ Push $4
154
+ Push $5
155
+ Push $6
156
+ Push $7
157
+ Exch 8
158
+ Pop $1 ;param
159
+ Exch 8
160
+ Pop $2 ;name
161
+ Exch 8
162
+ Pop $3 ;action
163
+ ;$0 return
164
+ ;$4 OpenSCManager
165
+ ;$5 OpenService
166
+
167
+ StrCpy $0 "false"
168
+ System::Call 'advapi32::OpenSCManagerA(n, n, i ${SC_MANAGER_ALL_ACCESS}) i.r4'
169
+ IntCmp $4 0 lbl_done
170
+ StrCmp $3 "create" lbl_create
171
+ System::Call 'advapi32::OpenServiceA(i r4, t r2, i ${SERVICE_ALL_ACCESS}) i.r5'
172
+ IntCmp $5 0 lbl_done
173
+
174
+ lbl_select:
175
+ StrCmp $3 "delete" lbl_delete
176
+ StrCmp $3 "start" lbl_start
177
+ StrCmp $3 "stop" lbl_stop
178
+ StrCmp $3 "pause" lbl_pause
179
+ StrCmp $3 "continue" lbl_continue
180
+ StrCmp $3 "installed" lbl_installed
181
+ StrCmp $3 "running" lbl_running
182
+ StrCmp $3 "status" lbl_status
183
+ Goto lbl_done
184
+
185
+ ; create service
186
+ lbl_create:
187
+ Push $R1 ;depend
188
+ Push $R2 ;user
189
+ Push $R3 ;password
190
+ Push $R4 ;interact
191
+ Push $R5 ;autostart
192
+ Push $R6 ;path
193
+ Push $R7 ;display
194
+ Push $R8 ;description
195
+
196
+ !insertmacro CALL_GETPARAM $R1 "depend" "n" "lbl_depend"
197
+ StrCpy $R1 't "$R1"'
198
+ lbl_depend:
199
+ StrCmp $R1 "n" 0 lbl_machine ;old name of depend param
200
+ !insertmacro CALL_GETPARAM $R1 "machine" "n" "lbl_machine"
201
+ StrCpy $R1 't "$R1"'
202
+ lbl_machine:
203
+
204
+ !insertmacro CALL_GETPARAM $R2 "user" "n" "lbl_user"
205
+ StrCpy $R2 't "$R2"'
206
+ lbl_user:
207
+
208
+ !insertmacro CALL_GETPARAM $R3 "password" "n" "lbl_password"
209
+ StrCpy $R3 't "$R3"'
210
+ lbl_password:
211
+
212
+ !insertmacro CALL_GETPARAM $R4 "interact" "0x10" "lbl_interact"
213
+ StrCpy $6 0x10
214
+ IntCmp $R4 0 +2
215
+ IntOp $6 $6 | 0x100
216
+ StrCpy $R4 $6
217
+ lbl_interact:
218
+
219
+ !insertmacro CALL_GETPARAM $R5 "autostart" "0x3" "lbl_autostart"
220
+ StrCpy $6 0x3
221
+ IntCmp $R5 0 +2
222
+ StrCpy $6 0x2
223
+ StrCpy $R5 $6
224
+ lbl_autostart:
225
+
226
+ !insertmacro CALL_GETPARAM $R6 "path" "n" "lbl_path"
227
+ lbl_path:
228
+
229
+ !insertmacro CALL_GETPARAM $R7 "display" "$2" "lbl_display"
230
+ lbl_display:
231
+
232
+ !insertmacro CALL_GETPARAM $R8 "description" "$2" "lbl_description"
233
+ lbl_description:
234
+
235
+ System::Call 'advapi32::CreateServiceA(i r4, t r2, t R7, i ${SERVICE_ALL_ACCESS}, \
236
+ i R4, i R5, i 0, t R6, n, n, $R1, $R2, $R3) i.r6'
237
+
238
+ ; write description of service
239
+ WriteRegStr HKLM "SYSTEM\ControlSet001\Services\$2" "Description" $R8
240
+
241
+ Pop $R8
242
+ Pop $R7
243
+ Pop $R6
244
+ Pop $R5
245
+ Pop $R4
246
+ Pop $R3
247
+ Pop $R2
248
+ Pop $R1
249
+ StrCmp $6 0 lbl_done lbl_good
250
+
251
+ ; delete service
252
+ lbl_delete:
253
+ System::Call 'advapi32::DeleteService(i r5) i.r6'
254
+ StrCmp $6 0 lbl_done lbl_good
255
+
256
+ ; start service
257
+ lbl_start:
258
+ System::Call 'advapi32::StartServiceA(i r5, i 0, i 0) i.r6'
259
+ StrCmp $6 0 lbl_done lbl_good
260
+
261
+ ; stop service
262
+ lbl_stop:
263
+ Push $R1
264
+ System::Call '*(i,i,i,i,i,i,i) i.R1'
265
+ System::Call 'advapi32::ControlService(i r5, i ${SERVICE_CONTROL_STOP}, i $R1) i'
266
+ System::Free $R1
267
+ Pop $R1
268
+ StrCmp $6 0 lbl_done lbl_good
269
+
270
+ ; pause service
271
+ lbl_pause:
272
+ Push $R1
273
+ System::Call '*(i,i,i,i,i,i,i) i.R1'
274
+ System::Call 'advapi32::ControlService(i r5, i ${SERVICE_CONTROL_PAUSE}, i $R1) i'
275
+ System::Free $R1
276
+ Pop $R1
277
+ StrCmp $6 0 lbl_done lbl_good
278
+
279
+ ; continue service
280
+ lbl_continue:
281
+ Push $R1
282
+ System::Call '*(i,i,i,i,i,i,i) i.R1'
283
+ System::Call 'advapi32::ControlService(i r5, i ${SERVICE_CONTROL_CONTINUE}, i $R1) i'
284
+ System::Free $R1
285
+ Pop $R1
286
+ StrCmp $6 0 lbl_done lbl_good
287
+
288
+ ; is installed
289
+ lbl_installed:
290
+ !insertmacro CALL_GETPARAM $7 "action" "" "lbl_good"
291
+ StrCpy $3 $7
292
+ Goto lbl_select
293
+
294
+ ; is service running
295
+ lbl_running:
296
+ Push $R1
297
+ System::Call '*(i,i,i,i,i,i,i) i.R1'
298
+ System::Call 'advapi32::QueryServiceStatus(i r5, i $R1) i'
299
+ System::Call '*$R1(i, i.r6)'
300
+ System::Free $R1
301
+ Pop $R1
302
+ IntFmt $6 "0x%X" $6
303
+ StrCmp $6 ${SERVICE_RUNNING} 0 lbl_done
304
+ !insertmacro CALL_GETPARAM $7 "action" "" "lbl_good"
305
+ StrCpy $3 $7
306
+ Goto lbl_select
307
+
308
+ lbl_status:
309
+ Push $R1
310
+ System::Call '*(i,i,i,i,i,i,i) i.R1'
311
+ System::Call 'advapi32::QueryServiceStatus(i r5, i $R1) i'
312
+ System::Call '*$R1(i, i .r6)'
313
+ System::Free $R1
314
+ Pop $R1
315
+ IntFmt $6 "0x%X" $6
316
+ StrCpy $0 "running"
317
+ IntCmp $6 ${SERVICE_RUNNING} lbl_done
318
+ StrCpy $0 "stopped"
319
+ IntCmp $6 ${SERVICE_STOPPED} lbl_done
320
+ StrCpy $0 "start_pending"
321
+ IntCmp $6 ${SERVICE_START_PENDING} lbl_done
322
+ StrCpy $0 "stop_pending"
323
+ IntCmp $6 ${SERVICE_STOP_PENDING} lbl_done
324
+ StrCpy $0 "running"
325
+ IntCmp $6 ${SERVICE_RUNNING} lbl_done
326
+ StrCpy $0 "continue_pending"
327
+ IntCmp $6 ${SERVICE_CONTINUE_PENDING} lbl_done
328
+ StrCpy $0 "pause_pending"
329
+ IntCmp $6 ${SERVICE_PAUSE_PENDING} lbl_done
330
+ StrCpy $0 "paused"
331
+ IntCmp $6 ${SERVICE_PAUSED} lbl_done
332
+ StrCpy $0 "unknown"
333
+ Goto lbl_done
334
+
335
+ lbl_good:
336
+ StrCpy $0 "true"
337
+ lbl_done:
338
+ IntCmp $5 0 +2
339
+ System::Call 'advapi32::CloseServiceHandle(i r5) n'
340
+ IntCmp $4 0 +2
341
+ System::Call 'advapi32::CloseServiceHandle(i r4) n'
342
+ Pop $4
343
+ Pop $3
344
+ Pop $2
345
+ Pop $1
346
+ Exch 3
347
+ Pop $5
348
+ Pop $7
349
+ Pop $6
350
+ Exch $0
351
+ !macroend
352
+
353
+ Function Service
354
+ !insertmacro FUNC_SERVICE ""
355
+ FunctionEnd
356
+
357
+ Function un.Service
358
+ !insertmacro FUNC_SERVICE "un."
359
+ FunctionEnd
360
+
361
+ Function GetParam
362
+ !insertmacro FUNC_GETPARAM
363
+ FunctionEnd
364
+
365
+ Function un.GetParam
366
+ !insertmacro FUNC_GETPARAM
367
+ FunctionEnd
368
+
369
+ !endif