social_stream-presence 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/status/offline.png +0 -0
- data/app/assets/javascripts/chat_interface_manager.js.erb +21 -12
- data/app/assets/javascripts/xmpp_client_management.js.erb +72 -30
- data/app/views/chat/_contacts.html.erb +7 -6
- data/config/locales/en.yml +3 -0
- data/config/locales/es.yml +3 -0
- data/lib/social_stream/presence/version.rb +1 -1
- data/social_stream-presence.gemspec +1 -1
- metadata +7 -6
Binary file
|
@@ -80,7 +80,11 @@ function setUserFunctions(){
|
|
80
80
|
$(".dropdown dd ul li a.option").click(function(event) {
|
81
81
|
event.preventDefault();
|
82
82
|
userStatus = $(this).find("span.value").html();
|
83
|
-
|
83
|
+
if(userStatus == "offline"){
|
84
|
+
disconnectStrophe();
|
85
|
+
} else {
|
86
|
+
sendStatus(userStatus);
|
87
|
+
}
|
84
88
|
$(".dropdown dd ul").hide();
|
85
89
|
});
|
86
90
|
|
@@ -102,17 +106,21 @@ function setStatusWidgetTitle(status){
|
|
102
106
|
return;
|
103
107
|
}
|
104
108
|
|
105
|
-
|
106
|
-
|
107
|
-
if ($("#" + statusIcons[status]).length == 0){
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
var text = $("#" + statusIcons[status]).html();
|
111
|
-
$(".dropdown dt a span").html(text);
|
112
|
-
|
113
|
-
} else if(status=="default"){
|
109
|
+
if(status=="default"){
|
114
110
|
var defaultTitle = '<%=I18n.t('chat.status.choose')%>'
|
115
111
|
$(".dropdown dt a span").html(defaultTitle);
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
|
115
|
+
if(status=="offline"){
|
116
|
+
var text = $("#" + status).html();
|
117
|
+
$(".dropdown dt a span").html(text);
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
|
121
|
+
if ((status in statusIcons)&&($("#" + statusIcons[status]).length > 0)) {
|
122
|
+
var text = $("#" + statusIcons[status]).html();
|
123
|
+
$(".dropdown dt a span").html(text);
|
116
124
|
}
|
117
125
|
|
118
126
|
}
|
@@ -180,10 +188,11 @@ function refreshChatWindow(){
|
|
180
188
|
function updateChatWindow(){
|
181
189
|
timerCounter=0;
|
182
190
|
log("updateChatWindow()");
|
183
|
-
|
191
|
+
var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
|
192
|
+
$.post("/chatWindow", { userConnected: stropheConnectedAndOnlineStatus }, function(data){
|
184
193
|
$(".tooltip").hide() //Prevent tooltips
|
185
194
|
$("#chat_partial").html(data);
|
186
|
-
if (
|
195
|
+
if (isStropheConnected()) {
|
187
196
|
setStatusWidgetTitle(userStatus);
|
188
197
|
$(".user_presence a[title]").tooltip();
|
189
198
|
setUserFunctions();
|
@@ -14,7 +14,21 @@ statusMessage['dnd'] = "Busy";
|
|
14
14
|
//Connect functions
|
15
15
|
////////////////////
|
16
16
|
|
17
|
+
function isStropheConnected(){
|
18
|
+
if((connection!=null)&&(connection.connected)){
|
19
|
+
return true;
|
20
|
+
} else {
|
21
|
+
return false;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
|
17
26
|
function connectToServerWithCookie(){
|
27
|
+
|
28
|
+
if (isStropheConnected()){
|
29
|
+
log("connectToServerWithCookie() returns: Strophe already connected");
|
30
|
+
}
|
31
|
+
log("connectToServerWithCookie() calls");
|
18
32
|
try {
|
19
33
|
connection = new Strophe.Connection(BOSH_SERVICE);
|
20
34
|
connection.connect(user_jid, cookie, onConnect);
|
@@ -24,9 +38,14 @@ function connectToServerWithCookie(){
|
|
24
38
|
}
|
25
39
|
}
|
26
40
|
|
41
|
+
|
27
42
|
//Password: Get from chatPassword param if exists, instead try to get from sessionStorage.
|
28
43
|
function connectToServerWithPassword(chatPassword){
|
29
44
|
|
45
|
+
if (isStropheConnected()){
|
46
|
+
log("connectToServerWithPassword() returns: Strophe already connected");
|
47
|
+
}
|
48
|
+
|
30
49
|
//Get Password
|
31
50
|
if ((chatPassword!=null)&&(chatPassword!="")){
|
32
51
|
var password = chatPassword;
|
@@ -79,10 +98,11 @@ var awayTime = 300000;
|
|
79
98
|
var awayCounter = 0;
|
80
99
|
var timerCounter = 0;
|
81
100
|
var connection = null;
|
82
|
-
var userConnected = false;
|
83
101
|
var reconnectAttempts = 3;
|
84
102
|
var awayTimer;
|
85
103
|
var timer;
|
104
|
+
var reconnectTimer;
|
105
|
+
var disconnectionFlag = true;
|
86
106
|
var requestContacts=false;
|
87
107
|
var cyclesToRefresh = (refreshMinTime/timerPeriod);
|
88
108
|
|
@@ -102,7 +122,7 @@ function onConnect(status) {
|
|
102
122
|
log('Strophe onConnect callback call with status ' + status);
|
103
123
|
|
104
124
|
if (status == Strophe.Status.ATTACHED){
|
105
|
-
|
125
|
+
log('Strophe connection attached');
|
106
126
|
return;
|
107
127
|
}
|
108
128
|
|
@@ -112,50 +132,61 @@ function onConnect(status) {
|
|
112
132
|
}
|
113
133
|
|
114
134
|
if (status == Strophe.Status.CONNECTING) {
|
115
|
-
|
116
|
-
|
135
|
+
log('Strophe is connecting.');
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
|
139
|
+
if (status == Strophe.Status.DISCONNECTING) {
|
140
|
+
log('Strophe is disconnecting.');
|
141
|
+
return;
|
117
142
|
}
|
118
143
|
|
119
144
|
clearTimeout(initialTimer);
|
120
145
|
|
121
146
|
if (status == Strophe.Status.CONNFAIL) {
|
122
|
-
|
123
|
-
|
124
|
-
|
147
|
+
log('Strophe failed to connect.');
|
148
|
+
reconnectTimer = setTimeout ("onReconnect()", 5000);
|
149
|
+
disconnectionFlag = true;
|
125
150
|
} else if (status == Strophe.Status.AUTHFAIL) {
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
151
|
+
log('Strophe authentication fail.');
|
152
|
+
if ((window.sessionStorage)&&(sessionStorage.getItem("ss_user_pass") != null)){
|
153
|
+
sessionStorage.setItem("ss_user_pass",null);
|
154
|
+
}
|
155
|
+
disconnectionFlag = true;
|
131
156
|
} else if (status == Strophe.Status.ERROR) {
|
132
|
-
|
133
|
-
|
157
|
+
log('Strophe error.');
|
158
|
+
disconnectionFlag = true;
|
134
159
|
} else if (status == Strophe.Status.DISCONNECTED) {
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
160
|
+
log('Strophe is disconnected.');
|
161
|
+
disconnectionFlag = true;
|
162
|
+
clearTimeout(awayTimer);
|
163
|
+
reconnectTimer = setTimeout ("onReconnect()", 5000);
|
139
164
|
} else if (status == Strophe.Status.CONNECTED) {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
165
|
+
log('Strophe is connected.');
|
166
|
+
log('Presenze stanza send for:' + connection.jid);
|
167
|
+
clearTimeout(reconnectTimer);
|
168
|
+
connection.addHandler(onMessage, null, 'message', null, null, null);
|
169
|
+
connection.addHandler(onPresence, null, 'presence', null, null, null);
|
170
|
+
//addHandler:(callback, namespace to match, stanza name, stanza type, stanza id , stanza from, options)
|
171
|
+
disconnectionFlag = false;
|
172
|
+
userStatus = "chat";
|
173
|
+
sendStatus(userStatus);
|
174
|
+
awayTimer = setInterval("awayTimerFunction()", awayTimerPeriod);
|
175
|
+
timer = setInterval("timerFunction()", timerPeriod);
|
149
176
|
}
|
150
177
|
|
151
178
|
updateChatWindow();
|
152
179
|
}
|
153
180
|
|
154
181
|
function onReconnect(){
|
155
|
-
|
182
|
+
log("onReconnect!")
|
183
|
+
if ((!isStropheConnected())&&(userStatus!="offline")) {
|
184
|
+
|
156
185
|
if (reconnectAttempts>0) {
|
157
186
|
reconnectAttempts--;
|
158
187
|
|
188
|
+
$("#chat_header_title").html('<%=I18n.t('chat.reconnecting')%>')
|
189
|
+
|
159
190
|
if (authByCookie()){
|
160
191
|
//Authentication by cookie
|
161
192
|
connectToServerWithCookie();
|
@@ -163,13 +194,24 @@ function onReconnect(){
|
|
163
194
|
//Authentication by password
|
164
195
|
connectToServerWithPassword(null);
|
165
196
|
}
|
166
|
-
setTimeout ("onReconnect()", 9000);
|
197
|
+
reconnectTimer = setTimeout ("onReconnect()", 9000);
|
167
198
|
} else {
|
199
|
+
$("#chat_header_title").html('<%=I18n.t('chat.unableconnect')%>')
|
168
200
|
//Notify issue to Rails App Server?
|
169
201
|
}
|
202
|
+
|
170
203
|
}
|
171
204
|
}
|
172
205
|
|
206
|
+
function disconnectStrophe(){
|
207
|
+
userStatus = "offline";
|
208
|
+
setStatusWidgetTitle("offline");
|
209
|
+
|
210
|
+
if(isStropheConnected()){
|
211
|
+
connection.send($pres({type: "unavailable"}).tree());
|
212
|
+
connection.disconnect();
|
213
|
+
}
|
214
|
+
}
|
173
215
|
|
174
216
|
////////
|
175
217
|
//Manage Message stanzas
|
@@ -198,7 +240,7 @@ function onMessage(msg) {
|
|
198
240
|
//Manage Presence stanzas
|
199
241
|
///////
|
200
242
|
function onPresence(presence) {
|
201
|
-
|
243
|
+
|
202
244
|
//Check presence stanza type
|
203
245
|
ptype = $(presence).attr('type');
|
204
246
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
<div>
|
2
2
|
|
3
3
|
<div class="block">
|
4
4
|
<div class="header">
|
@@ -15,6 +15,7 @@
|
|
15
15
|
<li><a id="available" href="#" class="option"><img class="flag" src="assets/status/available.png" alt=""/> <%=t('chat.status.available')%> <span class="value">chat</span></a></li>
|
16
16
|
<li><a id="away" href="#" class="option"><img class="flag" src="assets/status/away.png" alt=""/> <%=t('chat.status.away')%> <span class="value">away</span></a></li>
|
17
17
|
<li><a id="dnd" href="#" class="option"><img class="flag" src="assets/status/dnd.png" alt=""/> <%=t('chat.status.dnd')%> <span class="value">dnd</span></a></li>
|
18
|
+
<li><a id="offline" href="#" class="option"><img class="flag" src="assets/status/offline.png" alt=""/> <%=t('chat.status.offline')%> <span class="value">offline</span></a></li>
|
18
19
|
</ul>
|
19
20
|
</dd>
|
20
21
|
</div>
|
@@ -38,9 +39,9 @@
|
|
38
39
|
<% end %>
|
39
40
|
</div>
|
40
41
|
|
41
|
-
|
42
|
+
</div>
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
<div id="chat_divs">
|
45
|
+
<div id="chat_div">
|
46
|
+
</div>
|
47
|
+
</div>
|
data/config/locales/en.yml
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
en:
|
2
2
|
chat:
|
3
3
|
connecting: "Chat Connecting"
|
4
|
+
reconnecting: "Chat Reconnecting"
|
4
5
|
disconnected: "Chat Disconnected"
|
6
|
+
unableconnect: "Chat Disconnected"
|
5
7
|
title: "Chat"
|
6
8
|
password: "Password"
|
7
9
|
status:
|
@@ -9,6 +11,7 @@ en:
|
|
9
11
|
available: "Available"
|
10
12
|
away: "Away"
|
11
13
|
dnd: "Busy"
|
14
|
+
offline: "Offline"
|
12
15
|
settings:
|
13
16
|
title: "Enable and configure Social Stream Chat"
|
14
17
|
checkbox: "Enable or disable Social Stream Chat"
|
data/config/locales/es.yml
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
es:
|
2
2
|
chat:
|
3
3
|
connecting: "Chat Conectando"
|
4
|
+
reconnecting: "Chat Reconectando"
|
4
5
|
disconnected: "Chat Desconectado"
|
6
|
+
unableconnect: "Chat Desconectado"
|
5
7
|
title: "Chat"
|
6
8
|
password: "Contraseña"
|
7
9
|
status:
|
@@ -9,6 +11,7 @@ es:
|
|
9
11
|
available: "Disponible"
|
10
12
|
away: "Ausente"
|
11
13
|
dnd: "No molestar"
|
14
|
+
offline: "Desconectado"
|
12
15
|
settings:
|
13
16
|
title: "Activación y configuración del chat de Social Stream"
|
14
17
|
checkbox: "Activar o desactivar chat"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Aldo Gordillo
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-11-
|
17
|
+
date: 2011-11-28 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,9 +27,9 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 0
|
30
|
-
-
|
31
|
-
-
|
32
|
-
version: 0.
|
30
|
+
- 10
|
31
|
+
- 0
|
32
|
+
version: 0.10.0
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- app/assets/images/status/available.png
|
101
101
|
- app/assets/images/status/away.png
|
102
102
|
- app/assets/images/status/dnd.png
|
103
|
+
- app/assets/images/status/offline.png
|
103
104
|
- app/assets/javascripts/chat_audio.js
|
104
105
|
- app/assets/javascripts/chat_interface_manager.js.erb
|
105
106
|
- app/assets/javascripts/chat_parser.js
|