social_stream-presence 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,11 +10,20 @@ function storeChatData(){
10
10
  return
11
11
  }
12
12
 
13
+ storeChatStatus();
13
14
  storeUserChatStatus();
14
- storeChatConnectionParametres();
15
15
  storeConversations();
16
16
  }
17
17
 
18
+ function storeChatStatus(){
19
+ //Status of the mainChatBoxWindow
20
+ if(mainChatBox!=null){
21
+ sessionStorage.setItem("chat_mainChatBox_status", $(mainChatBox).is(":visible"));
22
+ } else {
23
+ sessionStorage.setItem("chat_mainChatBox_status", null);
24
+ }
25
+ }
26
+
18
27
  function storeConversations() {
19
28
 
20
29
  var chatboxes = getAllChatBoxes();
@@ -23,8 +32,6 @@ function storeConversations() {
23
32
  var visibleMaxSlugs = [];
24
33
  var visibleMinSlugs = [];
25
34
 
26
- //window[getChatVariableFromSlug("eric-white")].is(":visible")
27
-
28
35
  //Stored all conversations
29
36
  for (var i=0;i<chatboxes.length;i++){
30
37
  var slug = chatboxes[i].id
@@ -62,35 +69,13 @@ function storeConversations() {
62
69
  }
63
70
  }
64
71
 
65
-
66
- function storeChatConnectionParametres() {
67
- if ((sessionStorage.getItem("cookie") == null)||(sessionStorage.getItem("chat_user_name") == null)){
68
- if ((typeof cookie != 'undefined')&&(cookie!=null)){
69
- sessionStorage.setItem("cookie", cookie);
70
- }
71
- if ((typeof user_name != 'undefined') && (user_name != null)) {
72
- sessionStorage.setItem("chat_user_name", user_name);
73
- }
74
- if ((typeof user_slug != 'undefined') && (user_slug != null)) {
75
- sessionStorage.setItem("chat_user_slug", user_slug);
76
- }
77
- if ((typeof user_jid != 'undefined') && (user_jid != null)) {
78
- sessionStorage.setItem("chat_user_jid", user_jid);
79
- }
80
- }
81
- }
82
-
83
72
  function storeUserChatStatus(){
84
73
  sessionStorage.setItem("chat_user_status", userStatus);
85
74
  }
86
75
 
87
76
  function removeAllDataStored(){
88
- sessionStorage.removeItem("cookie");
89
- sessionStorage.removeItem("chat_user_name");
90
- sessionStorage.removeItem("chat_user_slug");
91
- sessionStorage.removeItem("chat_user_jid");
92
-
93
77
  sessionStorage.removeItem("chat_user_status");
78
+ sessionStorage.removeItem("chat_mainChatBox_status");
94
79
 
95
80
  sessionStorage.removeItem("slugs_with_stored_log");
96
81
  sessionStorage.removeItem("slugs_with_visible_max_chatbox");
@@ -117,9 +102,23 @@ function restoreChatData(){
117
102
  if (! window.sessionStorage){
118
103
  return
119
104
  }
105
+
120
106
  restoreConversations();
121
107
  }
122
108
 
109
+
110
+ function getRestoreMainChatBoxStatus(){
111
+ if (!window.sessionStorage) {
112
+ return false;
113
+ } else {
114
+ if(sessionStorage.getItem("chat_mainChatBox_status") == "true"){
115
+ return true;
116
+ } else {
117
+ return false;
118
+ }
119
+ }
120
+ }
121
+
123
122
  function restoreConversations() {
124
123
 
125
124
  //Get Stored slugs
@@ -405,7 +405,7 @@ function createMainChatBox(){
405
405
  $(mainChatBox).css('overflow-y','hidden')
406
406
 
407
407
  //Minimize
408
- mainChatBox.parent().toggle(false);
408
+ mainChatBox.parent().toggle(getRestoreMainChatBoxStatus());
409
409
 
410
410
  //Header title
411
411
  updateConnectedUsersOfMainChatBox();
@@ -98,9 +98,9 @@ class XmppController < ApplicationController
98
98
  return
99
99
  end
100
100
 
101
- #Actual connected users
102
- user_slugs = params[:name].split(",")
103
- SocialStream::Presence::XmppServerOrder::synchronizePresenceForSlugs(user_slugs)
101
+ #Actual connected jids
102
+ user_jids = params[:name].split(",")
103
+ SocialStream::Presence::XmppServerOrder::synchronizePresenceForJids(user_jids)
104
104
  render :text => "Ok"
105
105
  end
106
106
 
@@ -13,15 +13,16 @@ scripts_path=/my_scripts_path
13
13
  #Source path: uncomment to compile ejabberd social stream module
14
14
  #source_path=/.../ejabberd_source/src
15
15
 
16
+ #Web Domains for REST API
17
+ web_domains=[webDomain1,webDomain2,...,webDomainN]
16
18
 
17
- #Web Domain for REST API
18
- web_domain=ssdomain.example.com
19
+ #Specify Web Domains URL
20
+ web_domain_name=ssdomain.example.com
19
21
 
20
22
  #Rails Web Server Cookie name
21
23
  #Check this line in your app/config/initializers/session_store.rb: Global::Application.config.session_store :cookie_store, :key => '_rails_server_cookie'
22
24
  cookie_name=_rails_server_cookie
23
25
 
24
-
25
26
  #Ejabberd Server Password
26
27
  ejabberd_password=password
27
28
  #True to enable REST API Security
Binary file
@@ -31,12 +31,10 @@ def getOption(option)
31
31
  return "Undefined"
32
32
  end
33
33
 
34
- $accessByPasswordUrl = "http://" + getOption("web_domain=") + "/users/sign_in"
35
- $accessByCookieUrl = "http://" + getOption("web_domain=") + "/api/me"
36
34
  $cookie_name = getOption("cookie_name=")
37
35
 
38
36
 
39
- def auth(username, password)
37
+ def auth(username,domain,password)
40
38
 
41
39
  #[TEST ONLY] Allow everybody
42
40
  #return true
@@ -46,9 +44,10 @@ def auth(username, password)
46
44
  # return true
47
45
  #end
48
46
 
47
+ accessByPasswordUrl = "http://" + getWebDomainUrlFromDomain(domain) + "/users/sign_in"
49
48
 
50
49
  begin
51
- response = RestClient.post $accessByPasswordUrl, :user => { :email => username , :password => password }
50
+ response = RestClient.post accessByPasswordUrl, :user => { :email => username , :password => password }
52
51
 
53
52
  if response.code == 201
54
53
  return true
@@ -69,9 +68,10 @@ def auth(username, password)
69
68
  end
70
69
 
71
70
 
72
- def authByCookie(username, cookie)
71
+ def authByCookie(username, domain, cookie)
73
72
  begin
74
- response = RestClient.get $accessByCookieUrl, :cookies => {:"#{$cookie_name}" => cookie}
73
+ accessByCookieUrl = "http://" + getWebDomainUrlFromDomain(domain) + "/api/me"
74
+ response = RestClient.get accessByCookieUrl, :cookies => {:"#{$cookie_name}" => cookie}
75
75
  doc = REXML::Document.new(response.body)
76
76
 
77
77
  slug = ""
@@ -108,6 +108,16 @@ def validateParameters(username,domain,password)
108
108
  end
109
109
 
110
110
 
111
+ def getWebDomainUrlFromDomain(domain)
112
+ web_domain = getOption(domain + "=");
113
+ if (web_domain != "Undefined")
114
+ return web_domain
115
+ else
116
+ return domain
117
+ end
118
+ end
119
+
120
+
111
121
  loop do
112
122
  begin
113
123
  $stdin.eof? # wait for input
@@ -136,17 +146,17 @@ loop do
136
146
  password = data[2]
137
147
  if password.split(">>")[0]=="AuthenticationByCookie"
138
148
  cookie = password.split(">>")[1]
139
- $logger.info "#{Process.pid}: With username #{data[0]} and cookie #{cookie}"
140
- authByCookie(data[0], cookie)
149
+ $logger.info "#{Process.pid}: With userJid #{data[0]}@#{data[1]} and cookie #{cookie}"
150
+ authByCookie(data[0], data[1], cookie)
141
151
  else
142
- $logger.info "#{Process.pid}: With username #{data[0]} and password ******"
143
- #$logger.info "#{Process.pid}: With username #{data[0]} and password #{data[2]}"
144
- auth(data[0], data[2])
152
+ $logger.info "#{Process.pid}: With userJid #{data[0]}@#{data[1]} and password ******"
153
+ #$logger.info "#{Process.pid}: With userJid #{data[0]}@#{data[1]} and password #{data[2]}"
154
+ auth(data[0], data[1], data[2])
145
155
  end
146
156
 
147
157
  when "isuser"
148
158
 
149
- $logger.info "#{Process.pid}: Isuser #{data[0]}@#{data[1]}"
159
+ $logger.info "#{Process.pid}: Isuser with userJid: #{data[0]}@#{data[1]}"
150
160
 
151
161
  #Authorization condition for ISUSER (Add buddys)
152
162
  true
@@ -17,20 +17,19 @@ end
17
17
  puts ""
18
18
  puts "############### Ejabberd Configuration ###############"
19
19
  puts "Config file for Social Stream Presence: /etc/ejabberd/ssconfig.cfg"
20
- puts "Xmpp Server domain: #{getOption("server_domain=")}"
21
20
  puts "Scripts Path: #{getOption("scripts_path=")}"
22
21
  puts "mod_sspresence Path: #{getOption("source_path=")}"
23
- puts "Web Domain for REST API: #{getOption("web_domain=")}"
22
+ puts "Web Server domains: #{getOption("web_domains=")}"
24
23
  puts "##############################"
25
24
  puts "REST API"
26
- puts "Authentication by password: http://#{getOption("web_domain=")}/users/sign_in"
27
- puts "Authentication by cookie: http://#{getOption("web_domain=")}/api/me"
28
- puts "onRegisterConnection: http://#{getOption("web_domain=")}/xmpp/setConnection"
29
- puts "onRemoveConnection: http://#{getOption("web_domain=")}/xmpp/unsetConnection"
30
- puts "onPresence: http://#{getOption("web_domain=")}/xmpp/setPresence"
31
- puts "onUnsetPresence: http://#{getOption("web_domain=")}/xmpp/unsetPresence"
32
- puts "ResetConnection: http://#{getOption("web_domain=")}/xmpp/resetConnection"
33
- puts "SynchronizePresence: http://#{getOption("web_domain=")}/xmpp/synchronizePresence"
25
+ puts "Authentication by password: http://domainURL/users/sign_in"
26
+ puts "Authentication by cookie: http://domainURL/api/me"
27
+ puts "onRegisterConnection: http://domainURL/xmpp/setConnection"
28
+ puts "onRemoveConnection: http://domainURL/xmpp/unsetConnection"
29
+ puts "onPresence: http://domainURL/xmpp/setPresence"
30
+ puts "onUnsetPresence: http://domainURL/xmpp/unsetPresence"
31
+ puts "ResetConnection: http://domainURL/xmpp/resetConnection"
32
+ puts "SynchronizePresence: http://domainURL/xmpp/synchronizePresence"
34
33
  puts "##############################"
35
34
  puts "Social Stream Presence logs in var/log/ejabberd/"
36
35
  puts "######################################################"