social_stream-presence 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +7 -0
- data/app/assets/audio/chat/onMessageAudio.mp3 +0 -0
- data/app/assets/audio/chat/onMessageAudio.wav +0 -0
- data/app/assets/images/black_arrow3.png +0 -0
- data/app/assets/images/status/available.png +0 -0
- data/app/assets/images/status/away.png +0 -0
- data/app/assets/images/status/dnd.png +0 -0
- data/app/assets/javascripts/jquery-ui-1.8.14.custom.min.js +789 -0
- data/app/assets/javascripts/jquery.tools.min.js +17 -0
- data/app/assets/javascripts/jquery.tools.tooltip.js +11 -0
- data/app/assets/javascripts/jquery.ui.chatbox.js +260 -0
- data/app/assets/javascripts/social_stream-presence.js +2 -0
- data/app/assets/javascripts/store.js +20 -0
- data/app/assets/javascripts/strophe.js +3612 -0
- data/app/assets/javascripts/xmpp_client.js +494 -0
- data/app/assets/stylesheets/chat.css +239 -0
- data/app/assets/stylesheets/jquery.ui.chatbox.css +54 -0
- data/app/assets/stylesheets/social_stream-presence.css +3 -0
- data/app/controllers/xmpp_controller.rb +223 -0
- data/app/helpers/xmpp_helper.rb +20 -0
- data/app/views/xmpp/_chat.html.erb +63 -0
- data/app/views/xmpp/_chat_connecting.html.erb +8 -0
- data/app/views/xmpp/_chat_contacts.html.erb +46 -0
- data/app/views/xmpp/_chat_off.html.erb +35 -0
- data/app/views/xmpp/active_users.html.erb +33 -0
- data/app/views/xmpp/chat.html.erb +13 -0
- data/app/views/xmpp/index.html +19 -0
- data/app/views/xmpp/test.html.erb +11 -0
- data/config/routes.rb +15 -0
- data/db/migrate/20110711111408_add_connected_column_to_user.rb +9 -0
- data/db/migrate/20110928135031_add_status_column_to_user.rb +9 -0
- data/ejabberd/conf/ejabberd.cfg +625 -0
- data/ejabberd/conf/ejabberdctl.cfg +154 -0
- data/ejabberd/conf/inetrc +3 -0
- data/ejabberd/conf/server.pem +37 -0
- data/ejabberd/conf/ssconfig.cfg +32 -0
- data/ejabberd/ejabberd_scripts/authentication_script +117 -0
- data/ejabberd/ejabberd_scripts/authentication_script_org +114 -0
- data/ejabberd/ejabberd_scripts/compile_module +34 -0
- data/ejabberd/ejabberd_scripts/emanagement +245 -0
- data/ejabberd/ejabberd_scripts/generate_random_password +18 -0
- data/ejabberd/ejabberd_scripts/kill_authentication_script.sh +13 -0
- data/ejabberd/ejabberd_scripts/reset_connection_script +55 -0
- data/ejabberd/ejabberd_scripts/reset_logs.sh +23 -0
- data/ejabberd/ejabberd_scripts/set_connection_script +48 -0
- data/ejabberd/ejabberd_scripts/set_presence_script +48 -0
- data/ejabberd/ejabberd_scripts/show_config.sh +30 -0
- data/ejabberd/ejabberd_scripts/start_ejabberd.sh +68 -0
- data/ejabberd/ejabberd_scripts/stop_ejabberd.sh +12 -0
- data/ejabberd/ejabberd_scripts/synchronize_presence_script +57 -0
- data/ejabberd/ejabberd_scripts/unset_connection_script +48 -0
- data/ejabberd/mod_admin_extra/mod_admin_extra.beam +0 -0
- data/ejabberd/mod_admin_extra/mod_admin_extra.erl +1560 -0
- data/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
- data/ejabberd/mod_sspresence/mod_sspresence.erl +257 -0
- data/lib/social_stream-presence.rb +19 -2
- data/lib/social_stream/migrations/presence.rb +9 -0
- data/lib/social_stream/presence/engine.rb +62 -0
- data/lib/social_stream/presence/models/buddy_manager.rb +76 -0
- data/lib/social_stream/presence/version.rb +5 -0
- data/lib/tasks/presence/synchronize.rake +63 -0
- data/social_stream-presence.gemspec +4 -4
- metadata +69 -11
- data/.project +0 -17
@@ -0,0 +1,239 @@
|
|
1
|
+
/* Chatbox style sheet */
|
2
|
+
|
3
|
+
.ui-chatbox {
|
4
|
+
position: fixed;
|
5
|
+
bottom:0;
|
6
|
+
padding: 2px 2px 2px 2px;
|
7
|
+
padding: 2px 2px 2px 2px;
|
8
|
+
background: #CCCCCC;
|
9
|
+
}
|
10
|
+
|
11
|
+
.ui-chatbox-titlebar {
|
12
|
+
padding: 3px 3px 3px 3px;
|
13
|
+
height: 20px;
|
14
|
+
}
|
15
|
+
|
16
|
+
.ui-chatbox-content {
|
17
|
+
padding: 0px 0px 0px 0px;
|
18
|
+
margin: 0px 0px 0px 0px;
|
19
|
+
border: 0px;
|
20
|
+
}
|
21
|
+
|
22
|
+
.ui-chatbox-log {
|
23
|
+
padding: 3px 3px 3px 3px;
|
24
|
+
height: 150px;
|
25
|
+
overflow-y: auto;
|
26
|
+
background: #FFFFFF;
|
27
|
+
}
|
28
|
+
|
29
|
+
.ui-chatbox-input {
|
30
|
+
padding: 3px 3px 3px 3px;
|
31
|
+
border-top: 1px solid grey;
|
32
|
+
overflow: hidden;
|
33
|
+
/* background: #FFFFFF; */
|
34
|
+
}
|
35
|
+
|
36
|
+
.ui-chatbox-input-box {
|
37
|
+
margin: 5px 5px 5px 5px;
|
38
|
+
border: 2px solid lightgrey;
|
39
|
+
height: 35px;
|
40
|
+
}
|
41
|
+
|
42
|
+
.ui-chatbox-icon {
|
43
|
+
float: right;
|
44
|
+
}
|
45
|
+
|
46
|
+
.ui-chatbox-input-focus {
|
47
|
+
border-color: #6699FF;
|
48
|
+
}
|
49
|
+
|
50
|
+
.ui-chatbox-msg {
|
51
|
+
float: left;
|
52
|
+
clear: both;
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
/* Presence Partial */
|
57
|
+
|
58
|
+
div.user_presence {
|
59
|
+
float: left;
|
60
|
+
position: relative;
|
61
|
+
width: 30px;
|
62
|
+
height: 30px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.user_presence p {
|
66
|
+
text-align: center;
|
67
|
+
}
|
68
|
+
|
69
|
+
#chat_partial {
|
70
|
+
width: 150px;
|
71
|
+
margin-top: 10px;
|
72
|
+
margin-left: 5px;
|
73
|
+
margin-right: 5px;
|
74
|
+
}
|
75
|
+
|
76
|
+
.presence_status {
|
77
|
+
position: absolute;
|
78
|
+
bottom:0px;
|
79
|
+
right:0px;
|
80
|
+
border:none;
|
81
|
+
}
|
82
|
+
|
83
|
+
.users_connected{
|
84
|
+
display: block;
|
85
|
+
width: 150px;
|
86
|
+
}
|
87
|
+
|
88
|
+
.chat_off{
|
89
|
+
width: 150px;
|
90
|
+
}
|
91
|
+
|
92
|
+
#passwordFormChat{
|
93
|
+
width: 150px;
|
94
|
+
background-color: #1F4A75;
|
95
|
+
padding-top:3px;
|
96
|
+
padding-bottom:1px;
|
97
|
+
}
|
98
|
+
|
99
|
+
label.chatPasswordTitle{
|
100
|
+
color: white;
|
101
|
+
margin-left: 5px;
|
102
|
+
}
|
103
|
+
|
104
|
+
input.chat_password{
|
105
|
+
width: 135px;
|
106
|
+
margin-left: 5px;
|
107
|
+
margin-right: 5px;
|
108
|
+
margin-bottom: 5px;
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
input.connectChatButton{
|
113
|
+
text-align: center;
|
114
|
+
width: 150px;
|
115
|
+
background-color: #1F4A75;
|
116
|
+
border: 0 none;
|
117
|
+
cursor: pointer;
|
118
|
+
color: white;
|
119
|
+
font-family: Helvetica;
|
120
|
+
font-size: 11px;
|
121
|
+
padding: 2px 0 2px 0px;
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
/* Tooltip */
|
128
|
+
|
129
|
+
.tooltip {
|
130
|
+
display:none;
|
131
|
+
font-size:12px;
|
132
|
+
height:21px;
|
133
|
+
width:160px;
|
134
|
+
padding: 18px 25px 15px 25px;
|
135
|
+
margin: -15px 0px 0px 0px;
|
136
|
+
color:#fff;
|
137
|
+
background:transparent url(black_arrow3.png);
|
138
|
+
text-align: center;
|
139
|
+
/* border: 5px solid red; */
|
140
|
+
}
|
141
|
+
|
142
|
+
|
143
|
+
/* Status style sheet */
|
144
|
+
|
145
|
+
|
146
|
+
#status{
|
147
|
+
z-index: 1;
|
148
|
+
}
|
149
|
+
|
150
|
+
.desc {
|
151
|
+
color:#6b6b6b;
|
152
|
+
}
|
153
|
+
|
154
|
+
.desc a {
|
155
|
+
color:#0092dd;
|
156
|
+
}
|
157
|
+
|
158
|
+
.dropdown dd, .dropdown dt, .dropdown ul {
|
159
|
+
margin:0px;
|
160
|
+
padding:0px;
|
161
|
+
}
|
162
|
+
|
163
|
+
.dropdown dd {
|
164
|
+
position:relative;
|
165
|
+
}
|
166
|
+
|
167
|
+
.dropdown a, .dropdown a:visited {
|
168
|
+
color:#1F4A75;
|
169
|
+
text-decoration:none;
|
170
|
+
outline:none;
|
171
|
+
}
|
172
|
+
|
173
|
+
.dropdown a:hover {
|
174
|
+
color:#1F4A75;
|
175
|
+
}
|
176
|
+
.dropdown dt a:hover {
|
177
|
+
color:#1F4A75;
|
178
|
+
border: 1px solid #1F4A75;
|
179
|
+
}
|
180
|
+
|
181
|
+
.dropdown dt a {
|
182
|
+
background:#DFECF1 url(btn/arrowBlue.png) no-repeat scroll right center;
|
183
|
+
display:block;
|
184
|
+
padding-right:20px;
|
185
|
+
border:1px solid #DFECF1;
|
186
|
+
width:128px;
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
.dropdown dt a span {
|
192
|
+
cursor:pointer;
|
193
|
+
display:block;
|
194
|
+
padding:5px;
|
195
|
+
}
|
196
|
+
|
197
|
+
.dropdown dd ul {
|
198
|
+
background:#DFECF1 none repeat scroll 0 0;
|
199
|
+
border:1px solid #DFECF1; color:#DFECF1;
|
200
|
+
display:none;
|
201
|
+
left:0px;
|
202
|
+
padding:5px 0px;
|
203
|
+
position:absolute;
|
204
|
+
top:2px;
|
205
|
+
width:auto;
|
206
|
+
min-width:170px;
|
207
|
+
list-style:none;
|
208
|
+
z-index: 1;
|
209
|
+
}
|
210
|
+
|
211
|
+
.dropdown span.value {
|
212
|
+
display:none;
|
213
|
+
}
|
214
|
+
|
215
|
+
.dropdown dd ul li a {
|
216
|
+
padding:5px;
|
217
|
+
display:block;
|
218
|
+
}
|
219
|
+
|
220
|
+
.dropdown dd ul li a:hover {
|
221
|
+
background-color:#D4E5EF;
|
222
|
+
}
|
223
|
+
|
224
|
+
.dropdown img.flag {
|
225
|
+
border:none;
|
226
|
+
vertical-align:middle;
|
227
|
+
margin-left:10px;
|
228
|
+
}
|
229
|
+
|
230
|
+
.flagvisibility {
|
231
|
+
display:none;
|
232
|
+
}
|
233
|
+
|
234
|
+
.input_select{
|
235
|
+
width: 100%;
|
236
|
+
background-color: #D0C9AF;
|
237
|
+
margin-top:5px;
|
238
|
+
margin-bottom:5px;
|
239
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/* style sheets */
|
2
|
+
.ui-chatbox {
|
3
|
+
position: fixed;
|
4
|
+
bottom:0;
|
5
|
+
padding: 2px 2px 2px 2px;
|
6
|
+
padding: 2px 2px 2px 2px;
|
7
|
+
background: #CCCCCC;
|
8
|
+
/* background: #CCCCCC; */
|
9
|
+
}
|
10
|
+
|
11
|
+
.ui-chatbox-titlebar {
|
12
|
+
padding: 3px 3px 3px 3px;
|
13
|
+
height: 20px;
|
14
|
+
}
|
15
|
+
|
16
|
+
.ui-chatbox-content {
|
17
|
+
padding: 0px 0px 0px 0px;
|
18
|
+
margin: 0px 0px 0px 0px;
|
19
|
+
border: 0px;
|
20
|
+
}
|
21
|
+
|
22
|
+
.ui-chatbox-log {
|
23
|
+
padding: 3px 3px 3px 3px;
|
24
|
+
height: 150px;
|
25
|
+
overflow-y: auto;
|
26
|
+
background: #FFFFFF;
|
27
|
+
}
|
28
|
+
|
29
|
+
.ui-chatbox-input {
|
30
|
+
padding: 3px 3px 3px 3px;
|
31
|
+
border-top: 1px solid grey;
|
32
|
+
overflow: hidden;
|
33
|
+
/* background: #FFFFFF; */
|
34
|
+
}
|
35
|
+
|
36
|
+
.ui-chatbox-input-box {
|
37
|
+
margin: 5px 5px 5px 5px;
|
38
|
+
border: 2px solid lightgrey;/* #6699FF */
|
39
|
+
/* padding:5px 5px 5px 5px; */
|
40
|
+
height: 35px;
|
41
|
+
}
|
42
|
+
|
43
|
+
.ui-chatbox-icon {
|
44
|
+
float: right;
|
45
|
+
}
|
46
|
+
|
47
|
+
.ui-chatbox-input-focus {
|
48
|
+
border-color: #6699FF;
|
49
|
+
}
|
50
|
+
|
51
|
+
.ui-chatbox-msg {
|
52
|
+
float: left;
|
53
|
+
clear: both;
|
54
|
+
}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require 'xmpp4r'
|
2
|
+
require 'xmpp4r/muc'
|
3
|
+
require 'xmpp4r/roster'
|
4
|
+
require 'xmpp4r/client'
|
5
|
+
require 'xmpp4r/message'
|
6
|
+
|
7
|
+
class XmppController < ApplicationController
|
8
|
+
|
9
|
+
#Mapping XMPP Standar Status to Social Stream Chat Status
|
10
|
+
STATUS = {
|
11
|
+
'' => 'available',
|
12
|
+
'chat' => 'available',
|
13
|
+
'away' => 'away',
|
14
|
+
'xa' => 'away',
|
15
|
+
'dnd' => 'dnd',
|
16
|
+
#Special status to disable chat
|
17
|
+
'disable' => 'disable'
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
#API METHODS
|
22
|
+
|
23
|
+
def resetConnection
|
24
|
+
unless authorization
|
25
|
+
render :text => "Authorization error"
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
users = User.find_all_by_connected(true)
|
30
|
+
|
31
|
+
users.each do |user|
|
32
|
+
user.connected = false
|
33
|
+
user.save!
|
34
|
+
end
|
35
|
+
|
36
|
+
render :text => "Ok"
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def unsetConecction
|
41
|
+
unless authorization
|
42
|
+
render :text => "Authorization error"
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
user = User.find_by_slug(params[:name])
|
47
|
+
|
48
|
+
if user && user.connected
|
49
|
+
user.connected = false
|
50
|
+
user.save!
|
51
|
+
render :text => "Ok"
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
render :text => "Error"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def setConnection
|
60
|
+
unless authorization
|
61
|
+
render :text => "Authorization error"
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
65
|
+
user = User.find_by_slug(params[:name])
|
66
|
+
|
67
|
+
if user && !user.connected
|
68
|
+
user.connected = true
|
69
|
+
user.status = "available"
|
70
|
+
user.save!
|
71
|
+
render :text => "Ok"
|
72
|
+
return
|
73
|
+
end
|
74
|
+
|
75
|
+
render :text => "Error"
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def synchronizePresence
|
80
|
+
unless authorization
|
81
|
+
render :text => "Authorization error"
|
82
|
+
return
|
83
|
+
end
|
84
|
+
|
85
|
+
#Actual connected users
|
86
|
+
user_slugs = params[:name]
|
87
|
+
|
88
|
+
#Check connected users
|
89
|
+
users = User.find_all_by_connected(true)
|
90
|
+
|
91
|
+
users.each do |user|
|
92
|
+
if user_slugs.include?(user.slug) == false
|
93
|
+
user.connected = false
|
94
|
+
user.save!
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
user_slugs.each do |user_slug|
|
99
|
+
u = User.find_by_slug(user_slug)
|
100
|
+
if (u != nil && u.connected == false)
|
101
|
+
u.connected = true
|
102
|
+
u.save!
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
render :text => "ok"
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
def setPresence
|
111
|
+
unless authorization
|
112
|
+
render :text => "Authorization error"
|
113
|
+
return
|
114
|
+
end
|
115
|
+
|
116
|
+
user = User.find_by_slug(params[:name])
|
117
|
+
status = params[:status]
|
118
|
+
|
119
|
+
if setStatus(user,status)
|
120
|
+
render :text => 'Status changed'
|
121
|
+
else
|
122
|
+
render :text => 'Status not changed'
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
def unsetPresence
|
129
|
+
unless authorization
|
130
|
+
render :text => "Authorization error"
|
131
|
+
return
|
132
|
+
end
|
133
|
+
render :text => "Ok"
|
134
|
+
end
|
135
|
+
|
136
|
+
def authorization
|
137
|
+
return params[:password] == SocialStream::Presence.xmpp_server_password
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
def chatWindow
|
142
|
+
if (current_user) and (current_user.status != 'disable') and (params[:userConnected]=="true")
|
143
|
+
render :partial => 'xmpp/chat_contacts'
|
144
|
+
else
|
145
|
+
#User not connected or chat desactivated
|
146
|
+
render :partial => 'xmpp/chat_off'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
#TEST METHODS
|
155
|
+
def active_users
|
156
|
+
@users = User.find_all_by_connected(true)
|
157
|
+
@all_users = User.all
|
158
|
+
end
|
159
|
+
|
160
|
+
def test
|
161
|
+
puts "TEST"
|
162
|
+
|
163
|
+
# Thread.start{
|
164
|
+
|
165
|
+
# #XMPP DOMAIN
|
166
|
+
# domain = SocialStream::Presence.domain
|
167
|
+
# #PASSWORD
|
168
|
+
# password= SocialStream::Presence.password
|
169
|
+
# #SS Username
|
170
|
+
# ss_name = SocialStream::Presence.social_stream_presence_username
|
171
|
+
# ss_sid = ss_name + "@" + domain
|
172
|
+
#
|
173
|
+
# client = Jabber::Client.new(Jabber::JID.new(ss_sid))
|
174
|
+
# client.connect
|
175
|
+
# client.auth(password)
|
176
|
+
#
|
177
|
+
# #Remove all rosters
|
178
|
+
# msg = Jabber::Message::new(ss_sid, "SynchronizeRosters")
|
179
|
+
# msg.type=:chat
|
180
|
+
# client.send(msg)
|
181
|
+
#
|
182
|
+
#
|
183
|
+
# #Write rosters
|
184
|
+
# users = User.all
|
185
|
+
# checkedUsers = []
|
186
|
+
#
|
187
|
+
# users.each do |user|
|
188
|
+
# checkedUsers << user.slug
|
189
|
+
# contacts = user.contact_actors(:type=>:user)
|
190
|
+
# contacts.each do |contact|
|
191
|
+
# unless checkedUsers.include?(contact.slug)
|
192
|
+
# user_sid = user.slug + "@" + domain
|
193
|
+
# buddy_sid = contact.slug + "@" + domain
|
194
|
+
# msg = Jabber::Message::new(ss_sid, "SetRosterForBidirectionalTie&" + user_sid + "&" + buddy_sid + "&" + user.name + "&" + contact.name)
|
195
|
+
# msg.type=:chat
|
196
|
+
# client.send(msg)
|
197
|
+
# end
|
198
|
+
# end
|
199
|
+
# end
|
200
|
+
#
|
201
|
+
# client.close()
|
202
|
+
# }
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
private
|
209
|
+
|
210
|
+
def setStatus(user,status)
|
211
|
+
if user and status and user.status != status and validStatus(status)
|
212
|
+
user.status = STATUS[status]
|
213
|
+
user.save!
|
214
|
+
return true
|
215
|
+
end
|
216
|
+
return false
|
217
|
+
end
|
218
|
+
|
219
|
+
def validStatus(status)
|
220
|
+
return STATUS.keys.include?(status)
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|