rsence 2.0.0.11 → 2.0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.11
1
+ 2.0.1.12
data/js/core/elem/elem.js CHANGED
@@ -1369,6 +1369,9 @@ ELEM = {
1369
1369
  };
1370
1370
  ELEM._constructor();
1371
1371
 
1372
+ var//RSence.Foundation
1373
+ ElementManager = ELEM;
1374
+
1372
1375
  var//RSence.Core
1373
1376
  LOAD = ELEM._domLoader;
1374
1377
 
@@ -48,7 +48,7 @@ Event = {
48
48
  **/
49
49
  isLeftClick: function(e) {
50
50
  // IE: left 1, middle 4, right 2
51
- if (BROWSER_TYPE.ie || BROWSER_TYPE.safari) {
51
+ if (BROWSER_TYPE.ie) {
52
52
  return (e.button === 1);
53
53
  }
54
54
  else {
@@ -37,12 +37,12 @@ EVENT = {
37
37
  *
38
38
  * = Indexes
39
39
  * +EVENT.status[ EVENT.button1 ]+:: The state of the left mouse button.
40
- * 0 when not pressed
41
- * 1 when pressed.
40
+ * false when not pressed
41
+ * true when pressed.
42
42
  *
43
43
  * +EVENT.status[ EVENT.button2 ]+:: The state of the right mouse button.
44
- * 0 when not pressed
45
- * 1 when pressed.
44
+ * false when not pressed
45
+ * true when pressed.
46
46
  *
47
47
  * +EVENT.status[ EVENT.crsrX ]+:: The x-coordinate of the mouse cursor.
48
48
  *
@@ -62,8 +62,14 @@ EVENT = {
62
62
  * +EVENT.status[ EVENT.shiftKeyDown ]+:: The boolean status of the Shift
63
63
  * modifier key being held down.
64
64
  *
65
+ * +EVENT.status[ EVENT.metaKeyDown ]+:: The boolean status of the Meta
66
+ * modifier key being held down.
67
+ *
68
+ * +EVENT.status[ EVENT.cmdKeyDown ]+:: The boolean status of any of the system-specific
69
+ * Command, Menu or Start modifier keys being held down.
70
+ *
65
71
  **/
66
- status: [false, false, 0, 0, [], false, false, false],
72
+ status: [false, false, 0, 0, [], false, false, false, false, false],
67
73
 
68
74
  /** The index in the status array for the left mouse button.
69
75
  **/
@@ -88,18 +94,26 @@ EVENT = {
88
94
  **/
89
95
  keysDown: 4,
90
96
 
91
- /** The index in the status orray for the state of the Alt modifier key.
97
+ /** The index in the status array for the state of the Alt modifier key.
92
98
  **/
93
99
  altKeyDown: 5,
94
100
 
95
- /** The index in the status orray for the state of the Ctrl modifier key.
101
+ /** The index in the status array for the state of the Ctrl modifier key.
96
102
  **/
97
103
  ctrlKeyDown: 6,
98
104
 
99
- /** The index in the status orray for the state of the Shift modifier key.
105
+ /** The index in the status array for the state of the Shift modifier key.
100
106
  **/
101
107
  shiftKeyDown: 7,
102
108
 
109
+ /** The index in the status array for the state of the Meta modifier key.
110
+ **/
111
+ metaKeyDown: 8,
112
+
113
+ /** The index in the status array for the state of the Command modifier key.
114
+ **/
115
+ cmdKeyDown: 9,
116
+
103
117
  /** A flag to disable, if your applications don't need drop events.
104
118
  * Setting this to false when not needed improves overall performance,
105
119
  * because the drop events need constant calculation of the mouse cursor
@@ -231,11 +245,23 @@ EVENT = {
231
245
  _this.textEnterCtrls.push(_ctrl.viewId);
232
246
  }
233
247
  }
248
+ else {
249
+ var _textEnterIndex = _this.textEnterCtrls.indexOf(_ctrl.viewId);
250
+ if (_textEnterIndex !== -1) {
251
+ _this.textEnterCtrls.splice(_textEnterIndex,1);
252
+ }
253
+ }
234
254
  if (_focusOptions.resize) {
235
255
  if (_this.resizeListeners.indexOf(_ctrl.viewId) === -1) {
236
256
  _this.resizeListeners.push(_ctrl.viewId);
237
257
  }
238
258
  }
259
+ else {
260
+ var _resizeIndex = _this.resizeListeners.indexOf(_ctrl.viewId);
261
+ if (_resizeIndex !== -1) {
262
+ _this.resizeListeners.splice(_resizeIndex,1);
263
+ }
264
+ }
239
265
  Event.observe(_elem, 'mouseover', _this._mouseOver);
240
266
  },
241
267
 
@@ -524,12 +550,12 @@ EVENT = {
524
550
  * +_ctrl+:: An object that uses the HControl API, becomes new drag target.
525
551
  *
526
552
  **/
527
- startDragging: function(_ctrl) {
553
+ startDragging: function(_ctrl, _isLeftButton) {
528
554
  var _this = EVENT;
529
555
  _this.dragItems = [_ctrl.elemId];
530
556
  _this.focus(_ctrl);
531
557
  _this.changeActiveControl(_ctrl);
532
- _ctrl.startDrag(_this.status[_this.crsrX], _this.status[_this.crsrY]);
558
+ _ctrl.startDrag( _this.status[_this.crsrX], _this.status[_this.crsrY], _isLeftButton );
533
559
  },
534
560
 
535
561
  /** Mid-level mouse button press manager.
@@ -588,7 +614,7 @@ EVENT = {
588
614
  // Call the mouseDown and startDrag events after the active control change has been handled.
589
615
  for (i = 0; i !== _startDragElementIds.length; i++) {
590
616
  _this.dragItems.push(_startDragElementIds[i]);
591
- _this.focusOptions[_startDragElementIds[i]].ctrl.startDrag(x, y);
617
+ _this.focusOptions[_startDragElementIds[i]].ctrl.startDrag(x, y, _isLeftButton);
592
618
  _didStartDrag = true;
593
619
  }
594
620
 
@@ -672,6 +698,12 @@ EVENT = {
672
698
  }
673
699
  }
674
700
  //if(_this.hovered.length!==0){Event.stop(e);}
701
+ if(_isLeftButton){
702
+ _this.status[_this.button1] = false;
703
+ }
704
+ else {
705
+ _this.status[_this.button2] = false;
706
+ }
675
707
  return true;
676
708
  },
677
709
 
@@ -722,13 +754,11 @@ EVENT = {
722
754
  _ctrl,
723
755
  i = 0;
724
756
  _this._modifiers(e);
725
- _this.status[_this.button1] = false;
726
- _this.status[_this.button2] = false;
727
757
  // Send endDrag for the currently dragged items even when they don't have focus, and clear the drag item array.
728
758
  for (; i !== _this.dragItems.length; i++) {
729
759
  _elemId = _this.dragItems[i];
730
760
  _ctrl = _this.focusOptions[_elemId].ctrl;
731
- _ctrl.endDrag(x, y);
761
+ _ctrl.endDrag(x, y,_isLeftButton);
732
762
  _didEndDrag = true;
733
763
  // If the mouse slipped off the dragged item before the mouse button was released, blur the item manually
734
764
  if (_this.enableDroppableChecks) {
@@ -758,6 +788,12 @@ EVENT = {
758
788
  }
759
789
  }
760
790
  }
791
+ if(_isLeftButton){
792
+ _this.status[_this.button1] = false;
793
+ }
794
+ else {
795
+ _this.status[_this.button2] = false;
796
+ }
761
797
  return true;
762
798
  },
763
799
 
@@ -771,6 +807,9 @@ EVENT = {
771
807
  var _this = EVENT,
772
808
  _theKeyCode = e.keyCode;
773
809
  _this._modifiers(e);
810
+ if(!_this.status[_this.cmdKeyDown] && _this._detectCmdKey(e.keyCode)){
811
+ _this.status[_this.cmdKeyDown] = true;
812
+ }
774
813
  if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
775
814
  Event.stop(e);
776
815
  // Workaround for msie rapid fire keydown
@@ -812,6 +851,9 @@ EVENT = {
812
851
  _ctrl.textEnter();
813
852
  }
814
853
  }
854
+ if(_this.status[_this.cmdKeyDown] && _this._detectCmdKey(e.keyCode)){
855
+ _this.status[_this.cmdKeyDown] = false;
856
+ }
815
857
  // Remove the key from the realtime array, inserted in keyDown
816
858
  _keyCodeIndex = _this.status[_this.keysDown].indexOf(_theKeyCode);
817
859
  if (_keyCodeIndex !== -1) {
@@ -857,23 +899,45 @@ EVENT = {
857
899
  }
858
900
  }
859
901
  },
860
-
902
+
861
903
  /* Alternative right button detection, wrapper for the mouseDown method */
862
904
  contextMenu: function(e) {
863
905
  EVENT.mouseDown(e, false);
864
906
  Event.stop(e);
907
+ if(Event.isLeftClick(e)){
908
+ EVENT.status[EVENT.button2] = false;
909
+ }
865
910
  },
866
-
911
+
912
+ _cmdKeys: [
913
+ 224, // Mozilla Left or Right Command Key
914
+ 219, // Opera Left Windows Key
915
+ 220, // Opera Right Windows Key
916
+ 0, // Opera Menu Key or Linux Gecko: any Windows Key
917
+ 17, // Opera
918
+ 91, // Others (Left Start Key or Left Command Key)
919
+ 92, // Others (Right Start Key)
920
+ 93 // Others (Menu Key or Right Command Key)
921
+ ],
922
+ _detectCmdKey: function( _keyCode ) {
923
+ return (EVENT._cmdKeys.indexOf(_keyCode) !== -1);
924
+ },
925
+
867
926
  /* Handle the event modifiers. */
868
927
  _modifiers: function(e) {
869
928
  var _this = EVENT;
870
929
  _this.status[_this.altKeyDown] = e.altKey;
871
930
  _this.status[_this.ctrlKeyDown] = e.ctrlKey;
872
931
  _this.status[_this.shiftKeyDown] = e.shiftKey;
932
+ _this.status[_this.metaKeyDown] = e.metaKey;
873
933
  }
874
934
 
875
935
  };
876
936
 
937
+ var//RSence.Foundation
938
+ EventManager = EVENT;
939
+
940
+
877
941
  /** Starts the only instance
878
942
  */
879
943
  LOAD(
data/lib/http/broker.rb CHANGED
@@ -89,6 +89,7 @@ class Broker
89
89
  sleep 0.2
90
90
  end
91
91
  puts "..#{host}:#{port} responds!" if ::RSence.args[:debug]
92
+ puts "RSence is online on the address http://#{host}:#{port}#{::RSence.config[:base_url]}"
92
93
  @@transporter.online = true
93
94
  end
94
95
 
@@ -96,8 +97,8 @@ class Broker
96
97
 
97
98
  # Loads the selected web-server (default is 'mongrel')
98
99
  rack_require = conf[:rack_require]
99
- puts conf.inspect
100
- puts "rack require: #{rack_require.inspect}" if RSence.args[:debug]
100
+ puts conf.inspect if RSence.args[:debug]
101
+
101
102
  require rack_require
102
103
 
103
104
  # Selects the handler for Rack
@@ -114,14 +115,6 @@ class Broker
114
115
 
115
116
  end
116
117
 
117
- =begin
118
- # Extends the receiver with SingletonMethods
119
- def self.included( receiver )
120
- receiver.extend( SingletonMethods )
121
- end
122
- =end
123
-
124
-
125
118
  # Generic 404 error handler. Just sets up response status, headers, body as a small "Page Not Found" html page
126
119
  def not_found
127
120
  puts "/404: #{@request.fullpath.inspect}" if RSence.args[:verbose]
data/lib/session/msg.rb CHANGED
@@ -155,7 +155,7 @@ module RSence
155
155
  # Invalidates the active session.
156
156
  # @return [nil]
157
157
  def expire_session
158
- @sessions.expire_session( @ses_id )
158
+ @sessions.expire_session( @session[:ses_id] ) if @session
159
159
  end
160
160
 
161
161
  # @private Define the session key.
@@ -405,21 +405,60 @@ module RSence
405
405
  ### Sets the set-cookie header
406
406
  msg.response['Set-Cookie'] = ses_cookie_arr.join('; ')
407
407
  end
408
-
408
+
409
+ def expire_ses_by_req( req, res )
410
+
411
+ cookie_raw = req.cookies
412
+
413
+ # checks, if a cookie named 'ses_key' is found
414
+ if cookie_raw.has_key?('ses_key')
415
+
416
+ # gets just the data itself (discards comment, domain, expiration etc)
417
+ cookie_key = cookie_raw['ses_key'].split(';')[0]
418
+
419
+ end
420
+
421
+ # if a cookie key is found (non-false), checks if it's valid
422
+ if cookie_key
423
+
424
+ # checks for validity by looking the key up in @session_cookie_keys
425
+ cookie_key_exist = @session_cookie_keys.has_key?( cookie_key )
426
+
427
+ # sets the cookie key to false, if it doesn't exist
428
+ cookie_key = false unless cookie_key_exist
429
+
430
+ end
431
+
432
+ # at this point, the cookie key seems valid:
433
+ if cookie_key and cookie_key_exist
434
+
435
+ # get the session identifier
436
+ ses_id = @session_cookie_keys[ cookie_key ]
437
+
438
+ # Expire the session
439
+ expire_session( ses_id )
440
+
441
+ return true
442
+
443
+ end
444
+
445
+ return false
446
+ end
447
+
409
448
  ### Creates a message and checks the session
410
449
  def init_msg( request, response, options = { :cookies => false, :servlet => false } )
411
-
450
+
412
451
  cookies = options[:cookies]
413
-
452
+
414
453
  if options.has_key?(:query)
415
454
  query = options[:query]
416
455
  else
417
456
  query = request.query
418
457
  end
419
-
458
+
420
459
  ## Perform old-session cleanup on all xhr:s
421
460
  expire_sessions
422
-
461
+
423
462
  ## The 'ses_id' request query key is required.
424
463
  ## The client defaults to '0', which means the
425
464
  ## client needs to be initialized.
@@ -427,7 +466,7 @@ module RSence
427
466
  if not query.has_key?( 'ses_key' )
428
467
  return Message.new( @transporter, request, response, options )
429
468
  else
430
-
469
+
431
470
  ## get the ses_key from the request query:
432
471
  ses_key = query[ 'ses_key' ]
433
472
  # puts "ses key: #{ses_key}"
@@ -437,13 +476,13 @@ module RSence
437
476
  ## request/response/user/session -related
438
477
  ## data is needed.
439
478
  msg = Message.new( @transporter, request, response, options )
440
-
479
+
441
480
  ## The client tells that its ses_key is '0',
442
481
  ## until the server tells it otherwise.
443
482
  (req_num, ses_seed) = ses_key.split(':.o.:')
444
-
445
- if req_num == '0'
446
483
 
484
+ if req_num == '0'
485
+
447
486
  # If Broker encounters a '/hello' request, it
448
487
  # sets cookies to true.
449
488
  #
@@ -457,24 +496,24 @@ module RSence
457
496
  init_ses( msg, ses_seed )
458
497
  ses_status = true
459
498
  end
460
-
499
+
461
500
  # for non-'0' ses_keys:
462
501
  else
463
-
502
+
464
503
  ## Validate the session key
465
504
  ses_status = check_ses( msg, ses_seed )[0]
466
-
505
+
467
506
  ## Renew the cookie even when the request is a "x" (not "hello")
468
507
  if @config[:session_cookies] and ses_status
469
508
  renew_cookie( msg, msg.session[:cookie_key] )
470
509
  end
471
510
 
472
511
  end # /ses_key
473
-
512
+
474
513
  ## msg.ses_valid is false by default, meaning
475
514
  ## it's not valid or hasn't been initialized.
476
515
  msg.ses_valid = ses_status
477
-
516
+
478
517
  return msg
479
518
  end # /ses_key
480
519
  end # /init_msg
@@ -82,7 +82,9 @@ module RSence
82
82
  broker_urls = RSence.config[:broker_urls]
83
83
  uri = request.fullpath
84
84
 
85
- if request_type == :post
85
+ if @plugins.match_servlet( request_type, request, response, {} )
86
+ return true
87
+ elsif request_type == :post
86
88
  ## /x handles xhr without cookies
87
89
  if uri == broker_urls[:x] and @sessions.accept_requests
88
90
  xhr( request, response, { :cookies => true, :servlet => false } )
@@ -91,14 +93,9 @@ module RSence
91
93
  elsif uri == broker_urls[:hello] and @sessions.accept_requests
92
94
  xhr( request, response, { :cookies => true, :servlet => false } )
93
95
  return true
94
- else
95
- session = {}
96
- return @plugins.match_servlet( request_type, request, response, session )
97
96
  end
98
- else
99
- session = {}
100
- return @plugins.match_servlet( request_type, request, response, session )
101
97
  end
98
+ return false
102
99
  end
103
100
 
104
101
  # wrapper for the session manager stop client functionality
data/plugins/main/main.rb CHANGED
@@ -23,12 +23,12 @@ class MainPlugin < Plugin
23
23
  super
24
24
  @conf = ::RSence.config[:index_html]
25
25
  @bconf = ::RSence.config[:broker_urls]
26
+ @goodbye_uri = File.join(@bconf[:hello],'goodbye')
26
27
  end
27
28
 
28
29
  # @private Internal structures, matches the "hello/goodbye" session termination request
29
30
  def match( uri, request_type )
30
- if request_type == :post and
31
- uri == File.join(@bconf[:hello],'goodbye')
31
+ if request_type == :post and uri == @goodbye_uri
32
32
  return true
33
33
  end
34
34
  return false
@@ -39,9 +39,7 @@ class MainPlugin < Plugin
39
39
 
40
40
  # @private Internal structures, handler for the "hello/goodbye" session termination request
41
41
  def post( req, res, ses )
42
- msg = @plugins.sessions.init_msg( req, res, { :cookies => true } )
43
- msg.expire_session()
44
- msg.response_done
42
+ @plugins.sessions.expire_ses_by_req( req, res )
45
43
  end
46
44
 
47
45
  # @private url_responder gets called whenever the
@@ -69,11 +67,11 @@ class MainPlugin < Plugin
69
67
  # server-side session and reloads the page
70
68
  if virtual_uri == '/sign_out'
71
69
  resp_addr = @conf[:respond_address]
70
+ msg.expire_session()
72
71
  msg.reply( [
73
72
  'COMM.Transporter.stop=true;',
74
73
  "location.href=#{resp_addr.to_json};"
75
74
  ].join('') )
76
- msg.expire_session()
77
75
  end
78
76
 
79
77
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsence
3
3
  version: !ruby/object:Gem::Version
4
- hash: 121
4
+ hash: 115
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0
10
- - 11
11
- version: 2.0.0.11
9
+ - 1
10
+ - 12
11
+ version: 2.0.1.12
12
12
  platform: ruby
13
13
  authors:
14
14
  - Riassence Inc.
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-06 00:00:00 +03:00
19
+ date: 2010-07-07 00:00:00 +03:00
20
20
  default_executable: rsence
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency