social_stream-presence 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,12 @@ $(document).ready(function () {
10
10
 
11
11
 
12
12
  function storePassword() {
13
+
14
+ //Dont store password if cookie authentication is enable
15
+ if (authByCookie()) {
16
+ return
17
+ }
18
+
13
19
  if (window.sessionStorage) {
14
20
  if (($("#user_password").length==1)&&($("#user_password").val()!="")){
15
21
  sessionStorage.setItem("ss_user_pass", $('#user_password').val());
@@ -3,7 +3,7 @@
3
3
  ////////////////////
4
4
 
5
5
  function log(msg) {
6
- //console.log(msg)
6
+ console.log(msg)
7
7
  }
8
8
 
9
9
 
@@ -17,6 +17,45 @@ statusMessage['away'] = "Away";
17
17
  statusMessage['xa'] = "Away";
18
18
  statusMessage['dnd'] = "Busy";
19
19
 
20
+
21
+ ////////////////////
22
+ //Connect functions
23
+ ////////////////////
24
+
25
+ function connectToServerWithCookie(){
26
+ try {
27
+ connection = new Strophe.Connection(BOSH_SERVICE);
28
+ connection.connect(user_jid, cookie, onConnect);
29
+ } catch (err) {
30
+ //"Handle errors"
31
+ return false;
32
+ }
33
+ }
34
+
35
+ //Password: Get from chatPassword param if exists, instead try to get from sessionStorage.
36
+ function connectToServerWithPassword(chatPassword){
37
+
38
+ //Get Password
39
+ if ((chatPassword!=null)&&(chatPassword!="")){
40
+ var password = chatPassword;
41
+ } else if ((window.sessionStorage)&&(sessionStorage.getItem("ss_user_pass") != null)) {
42
+ var password = sessionStorage.getItem("ss_user_pass");
43
+ } else {
44
+ return false;
45
+ }
46
+
47
+ try {
48
+ //Connect actual user to the chat
49
+ connection = new Strophe.Connection(BOSH_SERVICE);
50
+ connection.connect(user_jid, password, onConnect);
51
+ } catch (err) {
52
+ //"Handle errors"
53
+ return false;
54
+ }
55
+
56
+ return true;
57
+ }
58
+
20
59
  ////////////////////
21
60
  //Strophe functions
22
61
  ////////////////////
@@ -176,6 +215,19 @@ function sendChatMessage(from,to,text){
176
215
  return true;
177
216
  }
178
217
 
218
+ function authByCookie(){
219
+ var authMethod = '<%= SocialStream::Presence.auth_method %>';
220
+ return authMethod=="cookie";
221
+ }
222
+
223
+ function authByPassword(){
224
+ var authMethod = '<%= SocialStream::Presence.auth_method %>';
225
+ return authMethod=="password";
226
+ }
227
+
228
+ function ifCookie(){
229
+ return (!(typeof cookie == 'undefined'))
230
+ }
179
231
 
180
232
  ////////////////////
181
233
  //Audio functions
@@ -1,4 +1,4 @@
1
- <% if current_subject.subject_type=="User" %>
1
+ <% if current_user and current_subject.subject_type=="User" %>
2
2
 
3
3
  <% content_for :headers do %>
4
4
  <%= stylesheet_link_tag "chat.css", :media => "screen, projection" %>
@@ -12,52 +12,32 @@
12
12
 
13
13
 
14
14
  <script type="text/javascript">
15
-
16
- //Global variables
15
+
16
+ //Global variables
17
17
  var BOSH_SERVICE = '<%= SocialStream::Presence.bosh_service || root_url + "http-bind/" %>';
18
+ var cookie = "AuthenticationByCookie>>" + "<%=cookies["_global_session"]%>";
18
19
  var domain = '<%=SocialStream::Presence.domain%>';
19
- var user_name = '<%=current_user.name%>';
20
+ var user_name = '<%=current_user.name%>';
20
21
  var user_slug = '<%=current_user.slug%>';
21
- var user_jid = '<%=current_user.slug%>'+"@"+domain;
22
+ var user_jid = '<%=current_user.slug%>'+"@"+domain;
22
23
  var sound_path = "/assets/audio/chat/onMessage";
23
- var cookie = "<%=cookies["_global_session"]%>";
24
24
 
25
- function connectToServerWithCookie(){
26
- connection = new Strophe.Connection(BOSH_SERVICE);
27
- connection.connect(user_jid, cookie, onConnect);
28
- }
29
25
 
30
- function connectToServer(chatPassword){
31
- <%unless current_user.nil? %>
32
-
33
- //Get Password
34
- if ((chatPassword!=null)&&(chatPassword!="")){
35
- var password = chatPassword;
36
- } else if ((window.sessionStorage)&&(sessionStorage.getItem("ss_user_pass") != null)) {
37
- var password = sessionStorage.getItem("ss_user_pass");
38
- } else {
39
- return false;
26
+ $(document).ready(function () {
27
+
28
+ if (authByCookie()){
29
+ if (connectToServerWithCookie()==false){
30
+ refreshChatWindow();
31
+ }
32
+ } else {
33
+ if (connectToServerWithPassword(null)==false){
34
+ refreshChatWindow();
35
+ }
40
36
  }
41
37
 
42
- try {
43
- //Connect actual user to the chat
44
- connection = new Strophe.Connection(BOSH_SERVICE);
45
- connection.connect(user_jid, password, onConnect);
46
- } catch (err) {
47
- //"Handle errors"
48
- return false;
49
- }
50
-
51
- return true;
52
- <%end%>
53
- }
54
-
55
- $(document).ready(function () {
56
- if (connectToServer(null)==false){
57
- refreshChatWindow();
58
- }
59
- initialTimer = setTimeout("updateChatWindow()", 15000);
60
- initAudio();
38
+ initialTimer = setTimeout("updateChatWindow()", 15000);
39
+ initAudio();
40
+
61
41
  });
62
42
 
63
43
  </script>
@@ -1,18 +1,32 @@
1
1
  <script type="text/javascript">
2
- $(document).ready(function () {
3
- if ((window.sessionStorage) && (sessionStorage.getItem("ss_user_pass") != null)) {
4
- $("#passwordFormChat").hide();
5
- } else {
6
- $("#passwordFormChat").show();
7
- }
2
+ $(document).ready(function () {
8
3
 
9
- $('.connectChatButton').bind('click', function () {
10
- connectToServer($('#user_password').val());
11
- });
12
-
13
- $('.storePass').bind('click', function () {
14
- storePassword();
15
- });
4
+ if (authByCookie()){
5
+ //Authentication by cookie
6
+
7
+ $("#passwordFormChat").hide();
8
+ $('.connectChatButton').bind('click', function () {
9
+ connectToServerWithCookie();
10
+ });
11
+
12
+ } else {
13
+ //Authentication by password
14
+
15
+ if ((window.sessionStorage) && (sessionStorage.getItem("ss_user_pass") != null)) {
16
+ $("#passwordFormChat").hide();
17
+ } else {
18
+ $("#passwordFormChat").show();
19
+ }
20
+
21
+ $('.connectChatButton').bind('click', function () {
22
+ connectToServerWithPassword($('#user_password').val());
23
+ });
24
+
25
+ $('.storePass').bind('click', function () {
26
+ storePassword();
27
+ });
28
+
29
+ }
16
30
 
17
31
  });
18
32
  </script>
@@ -15,6 +15,7 @@ scripts_path=/my_scripts_path
15
15
 
16
16
  #API REST
17
17
  auth_api=http://localhost/users/sign_in
18
+ auth_by_cookie_api=http://localhost/api/me
18
19
  set_connection_api=http://localhost/xmpp/setConnection
19
20
  unset_connection_api=http://localhost/xmpp/unsetConnection
20
21
  reset_connection_api=http://localhost/xmpp/resetConnection
@@ -33,3 +34,4 @@ ejabberd_password=password
33
34
 
34
35
  #Emanagement configuration
35
36
  users_require_sudo=user1,user2,...
37
+ verbose=false
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'logger'
4
4
  require 'rest_client'
5
+ require 'rexml/document'
6
+ include REXML
5
7
 
6
8
  $stdout.sync = true
7
9
  $stdin.sync = true
@@ -30,6 +32,7 @@ def getOption(option)
30
32
  end
31
33
 
32
34
  $accessUrl = getOption("auth_api=")
35
+ $accessByCookieUrl = getOption("auth_by_cookie_api=")
33
36
  $sslogin = getOption("ss_login=")
34
37
  $sspass = getOption("ss_password=")
35
38
 
@@ -75,6 +78,45 @@ def auth(username, password)
75
78
  end
76
79
 
77
80
 
81
+ def authByCookie(username, cookie)
82
+ begin
83
+ response = RestClient.get $accessByCookieUrl, :cookies => {:_global_session => cookie}
84
+ doc = REXML::Document.new(response.body)
85
+
86
+ slug = ""
87
+ doc.elements.each('user/slug') do |ele|
88
+ slug = ele.text
89
+ end
90
+
91
+ if username != "" and username == slug
92
+ return true
93
+ else
94
+ return false
95
+ end
96
+
97
+ rescue => e
98
+
99
+ unless e.class.name == "RestClient::Unauthorized" and e.message == "401 Unauthorized"
100
+ $logger.error "#{Process.pid}: Exception in authByCookie(username, cookie)"
101
+ $logger.error "#{Process.pid}: #{e.class.name}: #{e.message}"
102
+ end
103
+
104
+ return false
105
+ end
106
+ end
107
+
108
+
109
+ def validateParameters(username,domain,password)
110
+ if !username or !password or !domain
111
+ return false
112
+ end
113
+ if (username.gsub(/\s+/, "")=="") or (password.gsub(/\s+/, "")=="") or (domain.gsub(/\s+/, "")=="")
114
+ return false
115
+ end
116
+ return true
117
+ end
118
+
119
+
78
120
  loop do
79
121
  begin
80
122
  $stdin.eof? # wait for input
@@ -91,12 +133,24 @@ loop do
91
133
 
92
134
  when "auth"
93
135
  $logger.info "#{Process.pid}: Authenticating #{data[0]}@#{data[1]}"
94
- #$logger.info "#{Process.pid}: With password #{data[2]}"
95
- #password = data[2]
96
-
97
- #Authorization condition for LOGIN
98
- auth(data[0], data[2])
99
136
 
137
+ #Parameters basic validation: validateParameters(username,domain,password)
138
+ if !validateParameters(data[0],data[1],data[2])
139
+ $logger.info "#{Process.pid}: Invalid parameters"
140
+ return false
141
+ end
142
+
143
+ #Select authorization condition for LOGIN
144
+ #Authentication methods: user/password or user/cookie
145
+ password = data[2]
146
+ if password.split(">>")[0]=="AuthenticationByCookie"
147
+ cookie = password.split(">>")[1]
148
+ $logger.info "#{Process.pid}: With username #{data[0]} and cookie #{cookie}"
149
+ authByCookie(data[0], cookie)
150
+ else
151
+ $logger.info "#{Process.pid}: With username #{data[0]} and password ******"
152
+ auth(data[0], data[2])
153
+ end
100
154
 
101
155
  when "isuser"
102
156
 
@@ -26,12 +26,11 @@ def getOption(option)
26
26
  return "Undefined"
27
27
  end
28
28
 
29
- def ejabberdLog(text)
30
- $logger.info "Ejabberd Management Script: " + text
31
- end
29
+
32
30
 
33
31
  #Configuration variables
34
32
  $domain = getOption("server_domain=")
33
+ $verbose = (getOption("verbose=")=="true")
35
34
 
36
35
 
37
36
  PARAMS_FOR_COMMANDS = {
@@ -87,6 +86,13 @@ SYNTAX_FOR_COMMANDS = {
87
86
 
88
87
 
89
88
  #Debug methods
89
+ def ejabberdLog(text)
90
+ $logger.info "Ejabberd Management Script: " + text
91
+ if $verbose
92
+ #puts "Writing to ejabberdLog: " + "Ejabberd Management Script: " + text
93
+ end
94
+ end
95
+
90
96
  def log(msg)
91
97
  logWithTitle(msg,nil)
92
98
  end
@@ -126,8 +132,7 @@ def addBuddyToRoster(userSid,buddySid,buddyNick,buddyGroup,subscription_type)
126
132
  buddy = buddySid.split("@")[0]
127
133
  userDomain = userSid.split("@")[1]
128
134
  buddyDomain = buddySid.split("@")[1]
129
- command = buildCommand("ejabberdctl add-rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain + " " + buddyNick + " " + buddyGroup + " " + subscription_type)
130
- %x[#{command}];
135
+ executeCommand("ejabberdctl add-rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain + " " + buddyNick + " " + buddyGroup + " " + subscription_type)
131
136
  return "Done"
132
137
  end
133
138
 
@@ -137,8 +142,7 @@ def removeBuddyFromRoster(userSid,buddySid)
137
142
  userDomain = userSid.split("@")[1]
138
143
  buddyDomain = buddySid.split("@")[1]
139
144
  if checkUserInRoster(buddy,getRoster(user))
140
- command = buildCommand("ejabberdctl delete_rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain)
141
- %x[#{command}];
145
+ executeCommand("ejabberdctl delete_rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain)
142
146
  return "Done"
143
147
  else
144
148
  return "User " + buddy + " not found in " + user + " roster."
@@ -150,10 +154,9 @@ end
150
154
 
151
155
  def getRoster(username)
152
156
  if checkUser(username)
153
- command = buildCommand("ejabberdctl get_roster " + username + " " + $domain)
154
- %x[#{command}];
157
+ executeCommand("ejabberdctl get_roster " + username + " " + $domain)
155
158
  else
156
- return "User " + username + " not found"
159
+ return "Roster not found for user " + username
157
160
  end
158
161
  end
159
162
 
@@ -177,21 +180,18 @@ def removeRoster(username)
177
180
  end
178
181
  return "Done"
179
182
  else
180
- return "User " + username + " not found"
183
+ return "Roster not found for user " + username
181
184
  end
182
185
  end
183
186
 
184
187
  def removeAllRosters()
185
- command = buildCommand("ejabberdctl process_rosteritems delete any any any any")
186
- %x[#{command}];
188
+ executeCommand("ejabberdctl process_rosteritems delete any any any any")
187
189
  return "Done";
188
190
  end
189
191
 
190
192
  def getAllUsersWithRoster()
191
- command = buildCommand("ejabberdctl process_rosteritems list any any any any")
192
- output = %x[#{command}];
193
+ output = executeCommand("ejabberdctl process_rosteritems list any any any any")
193
194
 
194
- i = 0
195
195
  users = []
196
196
 
197
197
  lines = output.split("\n");
@@ -201,14 +201,13 @@ def getAllUsersWithRoster()
201
201
  if items.to_i.to_s == items
202
202
  if items.to_i > 0
203
203
  lines.each do |line|
204
- if i%2==1
204
+ if line.split(":")[0]=="Matches"
205
205
  user = line.split(" ")[1].split("@")[0]
206
206
  #puts i.to_s() + " :" + line
207
207
  unless users.include?(user)
208
208
  users << user
209
209
  end
210
210
  end
211
- i=i+1
212
211
  end
213
212
  end
214
213
  end
@@ -289,9 +288,7 @@ end
289
288
  def sendStanzaUserMessage(username,msg)
290
289
  resource = getUserResource(username);
291
290
  stanza = "\\<\\'message\\'\\>\\<\\'body\\'\\>\\'" + msg + "\\'\\<\\'/body\\'\\>\\<\\'/message\\'\\>"
292
- command = buildCommand("ejabberdctl send_stanza_c2s " + username + " " + $domain + " " + resource + " " + stanza)
293
- puts "Executing: " + command
294
- %x[#{command}];
291
+ executeCommand("ejabberdctl send_stanza_c2s " + username + " " + $domain + " " + resource + " " + stanza)
295
292
  return "Done"
296
293
  end
297
294
 
@@ -314,9 +311,7 @@ def sendPresenceWithShow(from_name,to_name,show)
314
311
  from_sid = from_name + "@" + $domain;
315
312
  to_sid = to_name + "@" + $domain;
316
313
  pres_stanza = "\\<\\'presence from=\\'\\\"\\'" + from_sid + "\\'\\\"\\' to=\\'\\\"\\'" + to_sid + "\\'\\\"\\>\\<\\'show\\'\\>\\'" + show + "\\'\\<\\'/show\\'\\>\\<\\'/presence\\'\\>"
317
- command = buildCommand("ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza)
318
- puts "Executing: " + command
319
- %x[#{command}];
314
+ executeCommand("ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza)
320
315
  return "Done"
321
316
  end
322
317
 
@@ -325,24 +320,19 @@ def sendPresenceStanzaWithType(from_name,to_name,presence_type)
325
320
  from_sid = from_name + "@" + $domain;
326
321
  to_sid = to_name + "@" + $domain;
327
322
  pres_stanza = "\\<\\'presence type=\\'\\\"\\'" + presence_type + "\\'\\\"\\' from=\\'\\\"\\'" + from_sid + "\\'\\\"\\' to=\\'\\\"\\'" + to_sid + "\\'\\\"\\>\\<\\'/presence\\'\\>"
328
- command = buildCommand("ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza)
329
- puts "Executing: " + command
330
- %x[#{command}];
323
+ executeCommand("ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza)
331
324
  return "Done"
332
325
  end
333
326
 
334
327
  def sendMessageToUser(from_name,to_name,msg)
335
328
  from_sid = from_name + "@" + $domain;
336
329
  to_sid = to_name + "@" + $domain;
337
- command = buildCommand("ejabberdctl send_message_chat " + from_sid + " " + to_sid + " " + buildQuotedString(msg))
338
- puts "Executing: " + command
339
- %x[#{command}];
330
+ executeCommand("ejabberdctl send_message_chat " + from_sid + " " + to_sid + " " + buildQuotedString(msg))
340
331
  return "Done"
341
332
  end
342
333
 
343
334
  def getUserResource(username)
344
- command = buildCommand("ejabberdctl connected-users")
345
- output = %x[#{command}];
335
+ output = executeCommand("ejabberdctl connected-users")
346
336
  lines = output.split("\n");
347
337
  lines.each do |line|
348
338
  if line.split("@")[0] == username
@@ -359,8 +349,7 @@ end
359
349
  #More utilities
360
350
 
361
351
  def isEjabberdNodeStarted
362
- command = buildCommand("ejabberdctl status")
363
- output = %x[#{command}]
352
+ output = executeCommand("ejabberdctl status")
364
353
  if firstLine = output.split("\n")[0]
365
354
  return ((firstLine.split(":")[1]).strip()=="started")
366
355
  end
@@ -437,9 +426,23 @@ end
437
426
 
438
427
  #Help & Support methods
439
428
 
429
+ def executeCommand(command)
430
+ #Building...
431
+ command = buildCommand(command)
432
+
433
+ if $verbose
434
+ puts "Executing: " + command
435
+ ejabberdLog("Executing (#{command})")
436
+ end
437
+
438
+ #Executing...
439
+ output = %x[#{command}]
440
+ return output
441
+ end
442
+
440
443
  def buildCommand(command)
441
444
  if execute_as_sudo
442
- command = "sudo " + command
445
+ command = "sudo -u ejabberd " + command
443
446
  end
444
447
  return command
445
448
  end
@@ -471,7 +474,7 @@ begin
471
474
  if ARGV[0] and PARAMS_FOR_COMMANDS.keys.include?(ARGV[0])
472
475
  if (ARGV.length == (PARAMS_FOR_COMMANDS[ARGV[0]]+1))
473
476
 
474
- ejabberdLog("Executing (#{ARGV[0]})")
477
+ ejabberdLog("Executing (#{ARGV})")
475
478
 
476
479
  length = ARGV.length;
477
480
  case length
@@ -3,6 +3,8 @@ SocialStream::Presence.setup do |config|
3
3
  config.domain = "localhost"
4
4
  #Configures Bosh Service Path
5
5
  #config.bosh_service = "http://xmpp-proxy/http-bind"
6
+ #Configures Authentication Method: "cookie" or "password"
7
+ config.auth_method = "cookie"
6
8
  #Configures XMPP Server Password
7
9
  config.xmpp_server_password = "password"
8
10
  #Remote or local mode
@@ -44,7 +44,7 @@ module SocialStream
44
44
  end
45
45
 
46
46
 
47
- def remove_buddy
47
+ def remove_buddy
48
48
 
49
49
  unless SocialStream::Presence.enable
50
50
  return
@@ -64,7 +64,7 @@ module SocialStream
64
64
  #Check if is a positive and replied tie
65
65
  if self.bidirectional?
66
66
  #Execute unsetRosterForBidirectionalTie(user_sid,oldfriend_sid,oldfriendNick,oldfriendGroup)
67
- SocialStream::Presence::XmppServerOrder::unsetRosterForBidirectionalTie(user_sid,buddy_sid,buddy_name,"SocialStream")
67
+ SocialStream::Presence::XmppServerOrder::unsetRosterForBidirectionalTie(buddy_sid,user_sid,user_name,"SocialStream")
68
68
  elsif self.positive?
69
69
  #Case: Possitive tie unidirectional
70
70
  #Execute removeBuddyFromRoster(user_sid,buddy_sid)
@@ -1,5 +1,5 @@
1
1
  module Socialstream
2
2
  module Presence
3
- VERSION = "0.0.14"
3
+ VERSION = "0.0.15"
4
4
  end
5
5
  end
@@ -10,6 +10,7 @@ module SocialStream
10
10
 
11
11
  class << self
12
12
 
13
+
13
14
  def setRosterForBidirectionalTie(userASid,userBSid,userANick,userBNick,groupForA,groupForB)
14
15
  if SocialStream::Presence.remote_xmpp_server
15
16
  puts "Not implemented setRosterForBidirectionalTie(userASid,userBSid,userANick,userBNick,groupForA,groupForB) for remote_xmpp_server"
@@ -20,6 +21,7 @@ module SocialStream
20
21
  end
21
22
  end
22
23
 
24
+
23
25
  def unsetRosterForBidirectionalTie(userSid,oldfriendSid,oldfriendNick,oldfriendGroup)
24
26
  if SocialStream::Presence.remote_xmpp_server
25
27
  puts "Not implemented unsetRosterForBidirectionalTie(user_sid,oldfriend_sid,oldfriendNick,oldfriendGroup) for remote_xmpp_server"
@@ -30,6 +32,7 @@ module SocialStream
30
32
  end
31
33
  end
32
34
 
35
+
33
36
  def addBuddyToRoster(userSid,buddySid,buddyNick,buddyGroup,subscription_type)
34
37
  if SocialStream::Presence.remote_xmpp_server
35
38
  puts "Not implemented addBuddyToRoster(userSID,buddySID,buddyNick,buddyGroup,subscription_type) for remote_xmpp_server"
@@ -40,6 +43,7 @@ module SocialStream
40
43
  end
41
44
  end
42
45
 
46
+
43
47
  def removeBuddyFromRoster(userSid,buddySid)
44
48
  if SocialStream::Presence.remote_xmpp_server
45
49
  puts "Not implemented removeBuddyFromRoster(userSid,buddySid) for remote_xmpp_server"
@@ -50,6 +54,39 @@ module SocialStream
50
54
  end
51
55
  end
52
56
 
57
+
58
+ #Before delete contact (destroy ties) callback
59
+ def removeBuddy(contact)
60
+
61
+ unless SocialStream::Presence.enable
62
+ return
63
+ end
64
+
65
+ unless contact.receiver.subject_type == "User" and contact.sender.subject_type == "User"
66
+ return
67
+ end
68
+
69
+ #XMPP DOMAIN
70
+ domain = SocialStream::Presence.domain
71
+ user_sid = contact.sender.slug + "@" + domain
72
+ user_name = contact.sender.name
73
+ buddy_sid = contact.receiver.slug + "@" + domain
74
+ buddy_name = contact.receiver.name
75
+
76
+ #Check for bidirecctional
77
+
78
+ if contact.sender.contact_actors(:type=>:user).include?(contact.receiver)
79
+ #Bidirectional contacts
80
+ #Execute unsetRosterForBidirectionalTie(user_sid,oldfriend_sid,oldfriendNick,oldfriendGroup)
81
+ SocialStream::Presence::XmppServerOrder::unsetRosterForBidirectionalTie(buddy_sid,user_sid,user_name,"SocialStream")
82
+ elsif contact.sender.contact_actors(:type=>:user, :direction=>:sent).include?(contact.receiver)
83
+ #Unidirectional contacts
84
+ SocialStream::Presence::XmppServerOrder::removeBuddyFromRoster(user_sid,buddy_sid)
85
+ end
86
+
87
+ end
88
+
89
+
53
90
  def synchronize_presence
54
91
  if SocialStream::Presence.remote_xmpp_server
55
92
 
@@ -105,6 +142,7 @@ module SocialStream
105
142
  end
106
143
  end
107
144
 
145
+
108
146
  def synchronize_rosters
109
147
  puts "Removing all rosters"
110
148
  remove_all_rosters
@@ -129,6 +167,7 @@ module SocialStream
129
167
  end
130
168
 
131
169
 
170
+
132
171
  #Help methods
133
172
 
134
173
  def getSocialStreamUserSid
@@ -139,6 +178,7 @@ module SocialStream
139
178
  return ss_name + "@" + domain
140
179
  end
141
180
 
181
+
142
182
  def openXmppClientForSocialStreamUser
143
183
  begin
144
184
  password= SocialStream::Presence.password
@@ -158,12 +198,14 @@ module SocialStream
158
198
  end
159
199
  end
160
200
 
201
+
161
202
  def sendXmppChatMessage(client,dest_sid,body)
162
203
  msg = Jabber::Message::new(dest_sid, body)
163
204
  msg.type=:chat
164
205
  client.send(msg)
165
206
  end
166
207
 
208
+
167
209
  def synchronize_presence_for_slugs(user_slugs)
168
210
  #Check connected users
169
211
  users = User.find_all_by_connected(true)
@@ -184,6 +226,7 @@ module SocialStream
184
226
  end
185
227
  end
186
228
 
229
+
187
230
  def reset_presence
188
231
  users = User.find_all_by_connected(true)
189
232
 
@@ -193,6 +236,7 @@ module SocialStream
193
236
  end
194
237
  end
195
238
 
239
+
196
240
  def executeEmanagementLocalCommand(order,params)
197
241
  command = SocialStream::Presence.scripts_path + "/emanagement " + order
198
242
  params.each do |param|
@@ -203,8 +247,8 @@ module SocialStream
203
247
  return output
204
248
  end
205
249
 
250
+
206
251
  end
207
-
208
252
  end
209
253
  end
210
254
  end
@@ -9,19 +9,21 @@ module SocialStream
9
9
  autoload :BuddyManager, 'social_stream/presence/models/buddy_manager'
10
10
  end
11
11
 
12
+ mattr_accessor :domain
12
13
  mattr_accessor :bosh_service
14
+ mattr_accessor :auth_method
13
15
  mattr_accessor :xmpp_server_password
14
16
  mattr_accessor :remote_xmpp_server
15
17
  mattr_accessor :enable
16
18
 
17
- mattr_accessor :domain
18
19
  mattr_accessor :social_stream_presence_username
19
20
  mattr_accessor :password
20
21
 
21
22
  mattr_accessor :scripts_path
22
23
 
23
- @@enable = true
24
+ @@auth_method = "cookie"
24
25
  @@remote_xmpp_server = false
26
+ @@enable = true
25
27
 
26
28
  class << self
27
29
  def setup
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-presence
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 14
9
- version: 0.0.14
4
+ prerelease:
5
+ version: 0.0.15
10
6
  platform: ruby
11
7
  authors:
12
8
  - Aldo Gordillo
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-10-31 00:00:00 +01:00
13
+ date: 2011-11-02 00:00:00 +01:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ~>
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 9
31
- - 18
32
24
  version: 0.9.18
33
25
  type: :runtime
34
26
  version_requirements: *id001
@@ -40,8 +32,6 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
35
  version: "0"
46
36
  type: :runtime
47
37
  version_requirements: *id002
@@ -53,8 +43,6 @@ dependencies:
53
43
  requirements:
54
44
  - - ">="
55
45
  - !ruby/object:Gem::Version
56
- segments:
57
- - 0
58
46
  version: "0"
59
47
  type: :development
60
48
  version_requirements: *id003
@@ -84,7 +72,7 @@ files:
84
72
  - app/assets/javascripts/social_stream-presence.js
85
73
  - app/assets/javascripts/store.js
86
74
  - app/assets/javascripts/strophe.js
87
- - app/assets/javascripts/xmpp_client.js
75
+ - app/assets/javascripts/xmpp_client.js.erb
88
76
  - app/assets/stylesheets/chat.css
89
77
  - app/assets/stylesheets/jquery.ui.chatbox.css
90
78
  - app/assets/stylesheets/social_stream-presence.css
@@ -196,21 +184,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
184
  requirements:
197
185
  - - ">="
198
186
  - !ruby/object:Gem::Version
199
- segments:
200
- - 0
201
187
  version: "0"
202
188
  required_rubygems_version: !ruby/object:Gem::Requirement
203
189
  none: false
204
190
  requirements:
205
191
  - - ">="
206
192
  - !ruby/object:Gem::Version
207
- segments:
208
- - 0
209
193
  version: "0"
210
194
  requirements: []
211
195
 
212
196
  rubyforge_project: social_stream-presence
213
- rubygems_version: 1.3.7
197
+ rubygems_version: 1.6.1
214
198
  signing_key:
215
199
  specification_version: 3
216
200
  summary: Presence capabilities for Social Stream, the core for building social network websites