social_stream 0.14.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/base/app/assets/images/btn/btn_play.png +0 -0
  2. data/base/app/assets/stylesheets/messages.css.scss +4 -2
  3. data/base/app/models/activity_object.rb +5 -0
  4. data/base/app/views/activity_objects/_activity_object.html.erb +1 -1
  5. data/base/app/views/groups/_show.html.erb +5 -3
  6. data/base/app/views/notifications/activities/_like.html.erb +1 -1
  7. data/base/app/views/notifications/activities/_like.text.erb +1 -1
  8. data/base/app/views/posts/_post_global_search.html.erb +2 -2
  9. data/base/app/views/users/_show.html.erb +6 -3
  10. data/base/config/locales/en.yml +3 -1
  11. data/base/config/locales/es.yml +1 -0
  12. data/base/lib/generators/social_stream/base/templates/relations.yml +0 -13
  13. data/base/lib/social_stream/base/version.rb +1 -1
  14. data/base/social_stream-base.gemspec +0 -2
  15. data/base/spec/dummy/config/relations.yml +0 -13
  16. data/documents/app/views/common_documents/_show.html.erb +1 -1
  17. data/documents/lib/social_stream/documents/version.rb +1 -1
  18. data/documents/social_stream-documents.gemspec +1 -1
  19. data/events/README.rdoc +1 -4
  20. data/events/app/assets/javascripts/social_stream-events.js +0 -4
  21. data/events/app/assets/stylesheets/social_stream-events.css +0 -273
  22. data/events/config/locales/en.yml +0 -115
  23. data/events/config/locales/es.yml +0 -115
  24. data/events/config/routes.rb +0 -28
  25. data/events/db/migrate/20111209120019_reset_events.rb +18 -0
  26. data/events/lib/social_stream/events/engine.rb +0 -5
  27. data/events/lib/social_stream/events/version.rb +1 -1
  28. data/events/lib/social_stream-events.rb +0 -18
  29. data/events/social_stream-events.gemspec +1 -1
  30. data/lib/social_stream/version.rb +1 -1
  31. data/linkser/app/assets/javascripts/linkser.js.erb +59 -0
  32. data/linkser/app/assets/javascripts/social_stream-linkser.js +2 -1
  33. data/linkser/app/assets/stylesheets/linkser.css.scss +19 -0
  34. data/linkser/app/controllers/linkser_controller.rb +1 -8
  35. data/linkser/app/models/link.rb +17 -9
  36. data/linkser/app/views/links/_link.html.erb +15 -2
  37. data/linkser/app/views/links/_link_preview.html.erb +3 -0
  38. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  39. data/linkser/social_stream-linkser.gemspec +1 -1
  40. data/presence/ejabberd/ejabberd_files.zip +0 -0
  41. data/presence/ejabberd/ejabberd_scripts/set_script_header.sh +112 -0
  42. data/presence/ejabberd/installer.sh +267 -0
  43. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  44. data/presence/ejabberd/mod_sspresence/mod_sspresence.erl +29 -101
  45. data/presence/lib/generators/social_stream/presence/install_generator.rb +1 -1
  46. data/presence/lib/generators/social_stream/presence/templates/initializer.rb +6 -4
  47. data/presence/lib/social_stream/presence/xmpp_server_order.rb +119 -4
  48. data/presence/lib/social_stream-presence.rb +2 -1
  49. data/presence/lib/tasks/presence/installer.rake +100 -0
  50. data/presence/social_stream-presence.gemspec +2 -0
  51. data/social_stream.gemspec +4 -4
  52. data/spec/dummy/config/relations.yml +0 -13
  53. metadata +22 -104
  54. data/events/GPL Affero license +0 -663
  55. data/events/app/assets/images/btn/btn_certificate.png +0 -0
  56. data/events/app/assets/images/btn/btn_certificates.png +0 -0
  57. data/events/app/assets/images/btn/btn_edit.png +0 -0
  58. data/events/app/assets/images/btn/btn_embebed.png +0 -0
  59. data/events/app/assets/images/btn/btn_event.png +0 -0
  60. data/events/app/assets/images/btn/btn_outline.png +0 -0
  61. data/events/app/assets/images/btn/event.png +0 -0
  62. data/events/app/assets/images/btn/flyer.png +0 -0
  63. data/events/app/assets/images/btn/keynote.png +0 -0
  64. data/events/app/assets/images/btn/live.png +0 -0
  65. data/events/app/assets/images/btn/time.png +0 -0
  66. data/events/app/assets/images/btn/trash.png +0 -0
  67. data/events/app/assets/images/frontpage/thumbs/tvideo_1_happy.jpg +0 -0
  68. data/events/app/assets/images/frontpage/thumbs/tvideo_2_kostas.jpg +0 -0
  69. data/events/app/assets/images/frontpage/thumbs/tvideo_3_colin.jpg +0 -0
  70. data/events/app/assets/images/frontpage/thumbs/tvideo_4_romilla.jpg +0 -0
  71. data/events/app/assets/images/frontpage/video_1_happy.jpg +0 -0
  72. data/events/app/assets/images/frontpage/video_2_kostas.jpg +0 -0
  73. data/events/app/assets/images/frontpage/video_3_colin.jpg +0 -0
  74. data/events/app/assets/images/frontpage/video_4_romilla.jpg +0 -0
  75. data/events/app/assets/images/icons/IconsByGlyphish.txt +0 -1
  76. data/events/app/assets/images/icons/down.png +0 -0
  77. data/events/app/assets/images/icons/search.png +0 -0
  78. data/events/app/assets/images/icons/up.png +0 -0
  79. data/events/app/assets/images/logos/actor/event.png +0 -0
  80. data/events/app/assets/images/logos/contact/event.png +0 -0
  81. data/events/app/assets/images/logos/original/event.png +0 -0
  82. data/events/app/assets/images/logos/profile/event.png +0 -0
  83. data/events/app/assets/images/logos/representation/event.png +0 -0
  84. data/events/app/assets/images/tab_bottom.png +0 -0
  85. data/events/app/assets/javascripts/schedule.js +0 -123
  86. data/events/app/controllers/agendas_controller.rb +0 -54
  87. data/events/app/controllers/events_controller.rb +0 -81
  88. data/events/app/controllers/sessions_controller.rb +0 -146
  89. data/events/app/helpers/event_helper.rb +0 -12
  90. data/events/app/models/agenda.rb +0 -55
  91. data/events/app/models/event.rb +0 -141
  92. data/events/app/models/session.rb +0 -23
  93. data/events/app/views/agendas/_agenda.html.erb +0 -1
  94. data/events/app/views/agendas/_edit.html.erb +0 -136
  95. data/events/app/views/agendas/_schedule.html.erb +0 -19
  96. data/events/app/views/agendas/_show.html.erb +0 -81
  97. data/events/app/views/agendas/_show_day.html.erb +0 -6
  98. data/events/app/views/agendas/edit.html.erb +0 -24
  99. data/events/app/views/agendas/event.html.erb +0 -1
  100. data/events/app/views/agendas/index.html.erb +0 -0
  101. data/events/app/views/agendas/show.html.erb +0 -25
  102. data/events/app/views/documents/_mediawall.html.erb +0 -111
  103. data/events/app/views/events/_event.html.erb +0 -10
  104. data/events/app/views/events/_event_focus_search.html.erb +0 -2
  105. data/events/app/views/events/_event_global_search.html.erb +0 -2
  106. data/events/app/views/events/_event_with_details.html.erb +0 -2
  107. data/events/app/views/events/_form.html.erb +0 -12
  108. data/events/app/views/events/_manage.html.erb +0 -35
  109. data/events/app/views/events/_new_activity.html.erb +0 -2
  110. data/events/app/views/events/_new_activity_fields.html.erb +0 -10
  111. data/events/app/views/events/_sessions_edit.html.erb +0 -46
  112. data/events/app/views/events/_sidebar_cloud.html.erb +0 -27
  113. data/events/app/views/events/_sidebar_index.html.erb +0 -1
  114. data/events/app/views/events/_sidebar_show.html.erb +0 -5
  115. data/events/app/views/events/agendas.html +0 -1
  116. data/events/app/views/events/edit.html.erb +0 -12
  117. data/events/app/views/events/index.html.erb +0 -30
  118. data/events/app/views/events/manage.html.erb +0 -69
  119. data/events/app/views/events/manage.js.erb +0 -1
  120. data/events/app/views/events/new.html.erb +0 -1
  121. data/events/app/views/events/show.html.erb +0 -38
  122. data/events/app/views/frontpage/_caracteristics.html.erb +0 -73
  123. data/events/app/views/frontpage/index.html.erb +0 -72
  124. data/events/app/views/profiles/_outline.html.erb +0 -81
  125. data/events/app/views/sessions/_form.html.erb +0 -41
  126. data/events/app/views/sessions/_new.html.erb +0 -63
  127. data/events/app/views/sessions/_session.html.erb +0 -1
  128. data/events/app/views/sessions/_show.html.erb +0 -27
  129. data/events/app/views/sessions/create.html.erb +0 -3
  130. data/events/app/views/sessions/create.js.erb +0 -1
  131. data/events/app/views/sessions/destroy.js.erb +0 -2
  132. data/events/app/views/sessions/edit.html.erb +0 -27
  133. data/events/app/views/sessions/index.html.erb +0 -1
  134. data/events/app/views/sessions/index.js.erb +0 -1
  135. data/events/app/views/sessions/new.html.erb +0 -27
  136. data/events/app/views/toolbar/_organizer.html.erb +0 -25
  137. data/events/app/views/toolbar/_sponsor.html.erb +0 -18
  138. data/events/app/views/toolbar/_suscribed.html.erb +0 -17
  139. data/linkser/app/views/links/_link_with_details.html.erb +0 -4
  140. data/linkser/app/views/posts/_new_activity_fields.erb +0 -53
@@ -0,0 +1,267 @@
1
+ #!/bin/bash
2
+
3
+ #Social Stream Presence Ejabberd files installer
4
+ #@author Aldo
5
+
6
+ #Call example:
7
+ #./installer.sh ejabberd_module_path="/ejabberd_module_path/" scripts_path="/scripts_path/" [key1=value1,key2=value2]
8
+
9
+ #Constants
10
+ config_files_path="/etc/ejabberd/"
11
+ logs_path="/var/log/ejabberd/"
12
+ installer_file_path=$(readlink -f $0)
13
+ installer_folder_path=`dirname "$installer_file_path"`
14
+
15
+
16
+
17
+ #Functions
18
+
19
+ help () {
20
+ echo "Syntax error: ./installer [onlyconf=true] ejabberd_module_path=mpath scripts_path=spath [key1=value1,key2=value2,...]"
21
+ }
22
+
23
+
24
+ msg () {
25
+ echo "#################################"
26
+ echo $1
27
+ }
28
+
29
+
30
+ applyOption () {
31
+ if [ ! $1 ] || [ ! $2 ]
32
+ then
33
+ return 1
34
+ fi
35
+ #key $1
36
+ #value $2
37
+ #string ssconfig $3
38
+ echo "Enable option " $1"="$2
39
+
40
+ SEPARATOR=$(echo -en "\n\b")
41
+ match=$1"="
42
+
43
+ if [[ $ssconfig == *$match* ]]
44
+ then {
45
+ #Modify existing options
46
+ repl=$1"="$2"="
47
+
48
+ if [ $2 == "remove" ]
49
+ then
50
+ repl="removedVar=true="
51
+ fi
52
+
53
+ ssconfig=${ssconfig/$match/$repl}
54
+ } else {
55
+ #Add new options
56
+ if [ ! $2 == "remove" ]
57
+ then
58
+ ssconfig="${ssconfig}${SEPARATOR}${1}=${2}="
59
+ fi
60
+ }
61
+ fi
62
+
63
+ return 0
64
+ }
65
+
66
+
67
+ restoreFile () {
68
+ IFS=$(echo -en "\n\b")
69
+ cat /dev/null > $conffile
70
+ for word in $ssconfigrestore; do
71
+ echo $word >> $conffile
72
+ done
73
+ return 0
74
+ }
75
+
76
+
77
+ updateSSConfig () {
78
+
79
+ if [ $1 ] && [ ${#1} -gt 2 ]
80
+ then {
81
+
82
+ if [ ${1:0:1} != "[" ] || [ ${1:${#1}-1:${#1}} != "]" ]
83
+ then
84
+ echo "Malformed options"
85
+ help
86
+ exit 1
87
+ fi
88
+
89
+ msg "Processing options"
90
+ options=${1:1:${#1}-2}
91
+ options=(${options//","/ })
92
+
93
+
94
+ #Read config file
95
+ ssconfig=""
96
+ conffile=$config_files_path/ssconfig.cfg
97
+
98
+ SAVEIFS=$IFS
99
+ IFS=$(echo -en "\n\b")
100
+
101
+ while read line
102
+ do
103
+ ssconfig="${ssconfig}${line}${IFS}"
104
+ done < $conffile
105
+
106
+ IFS=$SAVEIFS
107
+
108
+ ssconfigrestore=$ssconfig;
109
+
110
+ #Modify ssconfig to apply options
111
+ for option in ${options[@]}; do
112
+ option=(${option//"="/ })
113
+ key=${option[0]}
114
+ value=${option[1]}
115
+ applyOption $key $value
116
+ done
117
+
118
+
119
+ #Write (ssconfig) to file
120
+ cat /dev/null > $conffile
121
+ IFS=$(echo -en "\n\b")
122
+ for word in $ssconfig; do
123
+
124
+ if [[ $word =~ [#] ]] || [ -z $word ]
125
+ then {
126
+ echo $word >> $conffile
127
+ } else {
128
+ IFS=$SAVEIFS
129
+ arr=(${word//"="/ })
130
+ if [ ${#arr[@]} -lt 2 ]
131
+ then
132
+ echo "ssconfig.cfg error in line:" $word
133
+ restoreFile
134
+ exit 1
135
+ fi
136
+ word="${arr[0]}=${arr[1]}"
137
+ if [ ! $word == "removedVar=true" ]
138
+ then
139
+ echo $word >> $conffile
140
+ fi
141
+ }
142
+ fi
143
+ done
144
+ }
145
+ fi
146
+
147
+ }
148
+
149
+
150
+ #Main Program
151
+
152
+
153
+ #Look for only configuration mode
154
+ arr=(${1//"="/ })
155
+ if [ ${#arr} -ge 2 ] && [ ${arr[0]} == "onlyconf" ] && [ ${arr[1]} == "true" ]
156
+ then {
157
+ msg "Updating ssconfig"
158
+ updateSSConfig $2
159
+ exit 0
160
+ }
161
+ fi
162
+
163
+
164
+
165
+ #Installer mode
166
+ msg "Start installer"
167
+
168
+ if [ $# -lt 2 ]
169
+ then
170
+ help
171
+ exit 1
172
+ fi
173
+
174
+
175
+ msg "Reading parameters..."
176
+
177
+ arr=(${1//"="/ })
178
+
179
+ if [ ${arr[0]} == "ejabberd_module_path" ]
180
+ then {
181
+ ejabberd_module_path=${arr[1]}
182
+ } else {
183
+ help
184
+ exit 1
185
+ }
186
+ fi
187
+
188
+ arr=(${2//"="/ })
189
+
190
+ if [ ${arr[0]} == "scripts_path" ]
191
+ then {
192
+ scripts_path=${arr[1]}
193
+ } else {
194
+ help
195
+ exit 1
196
+ }
197
+ fi
198
+
199
+
200
+ echo "Installer path:" $installer_file_path
201
+ echo "Ejabberd module path:" $ejabberd_module_path
202
+ echo "scripts_path:" $scripts_path
203
+ echo "config_files_path:" $config_files_path
204
+ echo "logs_path:" $logs_path
205
+
206
+
207
+ paths=($ejabberd_module_path $scripts_path $config_files_path $logs_path )
208
+
209
+ msg "Creating directories"
210
+
211
+ for path in ${paths[@]}; do
212
+ mkdir -p $path
213
+ done
214
+
215
+
216
+ msg "Copying Ejabberd modules"
217
+ cp $installer_folder_path/mod_admin_extra/mod_admin_extra.beam $ejabberd_module_path
218
+ cp $installer_folder_path/mod_sspresence/mod_sspresence.beam $ejabberd_module_path
219
+
220
+ msg "Copying scripts"
221
+ cp -r $installer_folder_path/ejabberd_scripts/* $scripts_path
222
+
223
+
224
+ msg "Checking and copying configuration files"
225
+
226
+ if [ -e $config_files_path/ssconfig.cfg ]
227
+ then {
228
+ echo "Find ssconfig.cfg: updating ssconfig_example.cfg"
229
+ cp $installer_folder_path/conf/ssconfig_example.cfg $config_files_path/ssconfig_example.cfg
230
+ } else {
231
+ echo "ssconfig not exists"
232
+ cp $installer_folder_path/conf/ssconfig_example.cfg $config_files_path/ssconfig.cfg
233
+ }
234
+ fi
235
+
236
+ cp $installer_folder_path/conf/ejabberd_example.cfg $config_files_path/ejabberd_example.cfg
237
+ echo "Updating ejabberd_example.cfg"
238
+
239
+ msg "Check and copying log files"
240
+ if [ ! -e $logs_path/scripts.log ]
241
+ then {
242
+ echo "Creating scripts.log"
243
+ touch $logs_path/scripts.log
244
+ }
245
+ fi
246
+
247
+ if [ ! -e $logs_path/auth.log ]
248
+ then {
249
+ echo "Creating auth.log"
250
+ touch $logs_path/auth.log
251
+ }
252
+ fi
253
+
254
+
255
+ #Processing options
256
+ updateSSConfig $3
257
+
258
+
259
+ msg "Complete"
260
+ exit 0
261
+
262
+
263
+
264
+
265
+
266
+
267
+
@@ -1,10 +1,31 @@
1
+ %%%-------------------------------------------------------------------
2
+ %%% File : mod_sspresence.erl
3
+ %%% Author : Aldo
4
+ %%% Contact: < social-stream@dit.upm.es >
5
+ %%% Purpose : Process events and hooks for Social Stream Presence: http://social-stream.dit.upm.es/
6
+ %%% Created : 1 Oct 2011
7
+ %%%
8
+ %%%
9
+ %%% http://social-stream.dit.upm.es/
10
+ %%% Copyright © 2011 Social Stream
11
+ %%%
12
+ %%%-------------------------------------------------------------------
13
+
1
14
  -module(mod_sspresence).
15
+ -author('aldo').
2
16
 
3
17
  -behavior(gen_mod).
4
18
 
5
19
  -include("ejabberd.hrl").
6
20
 
7
- -export([start/2, stop/1, on_register_connection/3, on_remove_connection/3, on_presence/4, on_unset_presence/4, isConnected/1, on_packet_send/3]).
21
+ -export([start/2, stop/1,
22
+ on_register_connection/3,
23
+ on_remove_connection/3,
24
+ on_presence/4,
25
+ on_unset_presence/4,
26
+ on_packet_send/3,
27
+ isConnected/1
28
+ ]).
8
29
 
9
30
  start(Host, _Opts) ->
10
31
  ?INFO_MSG("mod_sspresence starting", []),
@@ -52,34 +73,25 @@ on_presence(User, _Server, _Resource, Packet) ->
52
73
 
53
74
  case Type of
54
75
  "presence" -> Status = getStatusFromSubel(Subel),
55
- Login_path = string:concat(getOptionValue("scripts_path="), "/set_presence_script "),
76
+ Presence_path = string:concat(getOptionValue("scripts_path="), "/set_presence_script "),
56
77
  ?INFO_MSG("mod_sspresence: set_presence_script call with user (~p) and status (~p)", [User,Status]),
57
- os:cmd(string:join([Login_path, User , Status], " "));
78
+ os:cmd(string:join([Presence_path, User , Status], " "));
58
79
  _ -> ok
59
80
  end,
60
81
  ok.
61
82
 
62
83
  on_unset_presence(User, _Server, _Resource, _Status) ->
63
84
  ?INFO_MSG("mod_sspresence: on_unset_presence (~p)", [User]),
64
- Login_path = string:concat(getOptionValue("scripts_path="), "/unset_presence_script "),
85
+ _UPresence_path = string:concat(getOptionValue("scripts_path="), "/unset_presence_script "),
65
86
  %% Wait for on_remove_connection
66
87
  %% ?INFO_MSG("mod_sspresence: unset_presence_script call with user (~p)", [User]),
67
- %% os:cmd(string:join([Login_path, User , Status], " "));
88
+ %%os:cmd(string:join([UPresence_path, User , Status], " "));
68
89
  ok.
69
90
 
70
- on_packet_send(From, _To, {xmlelement, Type, _Attr, Subel} = _Packet) ->
91
+ on_packet_send(_From, _To, {xmlelement, Type, _Attr, _Subel} = _Packet) ->
71
92
  case Type of
72
- "message" ->
73
- {_SenderJID,Sender,_SenderDomain,_A,_B,_C,_D} = From,
74
-
75
- SSlogin = getOptionValue("ss_login="),
76
-
77
- case Sender of
78
- SSlogin ->
79
- Message = getMessageFromSubel(Subel),
80
- execute(Message);
81
- _ -> ok
82
- end;
93
+ "message" ->
94
+ ok;
83
95
  _ -> ok
84
96
  end.
85
97
 
@@ -105,82 +117,11 @@ getStatusFromSubel(Subel) ->
105
117
  end.
106
118
 
107
119
 
108
- getMessageFromSubel(Subel) ->
109
- [{_I,_J,_K,[{_L,MessageData}]}] = Subel,
110
- parseXmlCdata(MessageData).
111
-
112
-
113
120
  parseXmlCdata(Msg) ->
114
121
  MessageString = binary_to_list(list_to_binary(io_lib:format("~p", [Msg]))),
115
122
  lists:sublist(MessageString, 4, string:len(MessageString)-6).
116
123
 
117
124
 
118
- execute(Message) ->
119
- %?INFO_MSG("Message vale: ~p", [Message]),
120
- %?INFO_MSG("Order vale: ~p", [Order]),
121
- [Order|Params] = string:tokens(Message, "&"),
122
- case Order of
123
- "AddItemToRoster" ->
124
- case length(Params) of
125
- 4 -> [UserSID,BuddySID,BuddyName,Subscription_type] = Params,
126
- ?INFO_MSG("Execute: ~p with params ~p", [Order,Params]),
127
- [ContactName|_R] = string:tokens(BuddyName, " "),
128
- [UserSlug,UserDomain] = string:tokens(UserSID, "@"),
129
- [BuddySlug,BuddyDomain] = string:tokens(BuddySID, "@"),
130
- addItemToRoster(UserSlug,UserDomain,BuddySlug,BuddyDomain,ContactName,"SocialStream",Subscription_type),
131
- ok;
132
- _ -> ?INFO_MSG("Incorrect parameters in order ~p", [Order]),
133
- ok
134
- end,
135
- ok;
136
-
137
- "SetRosterForBidirectionalTie" ->
138
- case length(Params) of
139
- 4 -> [UserASID,UserBSID,UserAName,UserBName] = Params,
140
- ?INFO_MSG("Executing: ~p with params ~p", [Order,Params]),
141
- [UserASlug,UserADomain] = string:tokens(UserASID, "@"),
142
- [UserBSlug,UserBDomain] = string:tokens(UserBSID, "@"),
143
- addItemToRoster(UserASlug,UserADomain,UserBSlug,UserBDomain,UserBName,"SocialStream","both"),
144
- addItemToRoster(UserBSlug,UserBDomain,UserASlug,UserADomain,UserAName,"SocialStream","both"),
145
- ok;
146
- _ -> ?INFO_MSG("Incorrect parameters in order ~p", [Order]),
147
- ok
148
- end,
149
- ok;
150
-
151
- "Synchronize" ->
152
- synchronizePresence(),
153
- ok;
154
-
155
- "SynchronizeRosters" ->
156
- synchronizeRosters(),
157
- ok;
158
-
159
- _ -> ?INFO_MSG("Command not found", []),
160
- ok
161
- end.
162
-
163
-
164
-
165
- %%Call ejabberdctl command add_rosteritem
166
- %Command Name: add_rosteritem
167
- %Needs mod_admin_extra (http://www.ejabberd.im/ejabberd-modules)
168
- %ejabberdctl add_rosteritem localuser localserver buddy buddyserver nick group subs
169
- %subs= none, from, to or both,
170
-
171
- %Example
172
- %ejabberdctl add_rosteritem frank-williamson trapo demo trapo NickName SocialStream from
173
- %frank-williamson@trapo adds demo@trapo to its roster with subscription from, in the group SocialStream with the name Nickname
174
- %%
175
- addItemToRoster(UserSlug,UserDomain,BuddySlug,BuddyDomain,ContactName,Group,Subscription_type) ->
176
- %%Command = lists:concat(["ejabberdctl add_rosteritem ", UserSlug , " ", UserDomain, " ", BuddySlug, " ", BuddyDomain , " \\'", ContactName , "\\' ", Group , " ", Subscription_type]),
177
- %%Command = lists:concat(["ejabberdctl add_rosteritem ", UserSlug , " ", UserDomain, " ", BuddySlug, " ", BuddyDomain , " \'", ContactName , "\' ", Group , " ", Subscription_type]),
178
-
179
- [UserName|_R] = string:tokens(ContactName, " "),
180
- Command = lists:concat(["ejabberdctl add_rosteritem ", UserSlug , " ", UserDomain, " ", BuddySlug, " ", BuddyDomain , " ", UserName , " ", Group , " ", Subscription_type]),
181
- os:cmd(Command),
182
- ?INFO_MSG("Execute command: ~p", [Command]),
183
- ok.
184
125
 
185
126
  %%GETTERS CONFIG VALUES
186
127
  %%CONFIG FILE: /etc/ejabberd/ssconfig.cfg
@@ -241,19 +182,6 @@ case Output of
241
182
  end.
242
183
 
243
184
 
244
- %%Send all connected users to Social Stream Rails Application
245
- synchronizePresence() ->
246
- Synchronize_path = string:concat(getOptionValue("scripts_path="), "/synchronize_presence_script "),
247
- os:cmd(Synchronize_path),
248
- ok.
249
-
250
-
251
- %%Reset all rosters and wait to received data from Social Stream Rails Application
252
- synchronizeRosters() ->
253
- SynchronizeRosters_path = string:concat(getOptionValue("scripts_path="), "/emanagement removeAllRosters"),
254
- os:cmd(SynchronizeRosters_path),
255
- ok.
256
-
257
185
 
258
186
  %Reset all connections
259
187
  reset_connections() ->
@@ -4,7 +4,7 @@ class SocialStream::Presence::InstallGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path('../templates', __FILE__)
5
5
 
6
6
  def create_initializer_file
7
- copy_file 'initializer.rb', 'config/initializers/social_stream-presence.rb'
7
+ template 'initializer.rb', 'config/initializers/social_stream_presence.rb'
8
8
  end
9
9
 
10
10
  def create_migration_file
@@ -6,13 +6,15 @@ SocialStream::Presence.setup do |config|
6
6
  #Configures Authentication Method: "cookie" or "password"
7
7
  config.auth_method = "cookie"
8
8
  #Configures XMPP Server Password
9
- config.xmpp_server_password = "password"
9
+ config.xmpp_server_password = <%= SecureRandom.hex(64).inspect %>
10
10
  #Remote or local mode
11
11
  config.remote_xmpp_server = false
12
12
  #Scripts path to execute ejabberd scripts: local or remote
13
13
  config.scripts_path = "/scripts_path"
14
- #False to disable Social Stream Presence
15
- #config.enable = false
14
+ #Ejabberd module path in the xmpp server
15
+ config.ejabberd_module_path = "/lib/ejabberd/ebin"
16
+ #Uncomment to enable Social Stream Presence
17
+ #config.enable = true
16
18
 
17
19
  #Parameters for remote mode
18
20
  #SSH Login
@@ -25,6 +27,6 @@ SocialStream::Presence.setup do |config|
25
27
  #Username of the the Social Stream Admin sid
26
28
  config.social_stream_presence_username = "social_stream-presence"
27
29
  #Configures Social Stream Rails App Password
28
- config.password = "password"
30
+ config.password = <%= SecureRandom.hex(64).inspect %>
29
31
 
30
32
  end
@@ -4,6 +4,7 @@ require 'xmpp4r/roster'
4
4
  require 'xmpp4r/client'
5
5
  require 'xmpp4r/message'
6
6
  require 'net/ssh'
7
+ require 'net/sftp'
7
8
 
8
9
  module SocialStream
9
10
  module Presence
@@ -108,6 +109,117 @@ module SocialStream
108
109
  end
109
110
 
110
111
 
112
+ #Installation methods
113
+
114
+ def copyFolder(oPath,dPath)
115
+ if SocialStream::Presence.remote_xmpp_server
116
+ #Remote mode
117
+ copyRemoteFolder(oPath,dPath)
118
+ else
119
+ #Local mode
120
+ SocialStream::Presence::XmppServerOrder::executeCommand("cp -r " + oPath + "/* " + dPath)
121
+ end
122
+ end
123
+
124
+
125
+ def copyRemoteFolder(localPath,remotePath)
126
+ begin
127
+ if SocialStream::Presence.ssh_password
128
+
129
+ Net::SFTP.start(SocialStream::Presence.ssh_domain, SocialStream::Presence.ssh_user, :password => SocialStream::Presence.ssh_password, :auth_methods => ["password"] ) do |sftp|
130
+ recursiveCopyFolder(localPath,remotePath,sftp)
131
+ end
132
+
133
+ else
134
+ #SSH with authentication key instead of password
135
+ Net::SFTP.start(SocialStream::Presence.ssh_domain, SocialStream::Presence.ssh_user) do |sftp|
136
+ recursiveCopyFolder(localPath,remotePath,sftp)
137
+ end
138
+ end
139
+ output="Ok"
140
+ rescue Exception => e
141
+ case e
142
+ when Net::SSH::AuthenticationFailed
143
+ output = "AuthenticationFailed on remote access"
144
+ else
145
+ output = "Unknown exception in copyRemoteFolder method: #{e.to_s}"
146
+ end
147
+ end
148
+
149
+ return output
150
+ end
151
+
152
+
153
+ def recursiveCopyFolder(localPath,remotePath,sftp)
154
+ # Create directory if not exits
155
+ sftp.mkdir(remotePath)
156
+ # Upload files to the remote host
157
+ Dir.foreach(localPath) do |f|
158
+ file_path = localPath + "/#{f}"
159
+ if File.file?(file_path)
160
+ sftp.upload(file_path, remotePath + "/#{f}")
161
+ elsif File.directory?(file_path) and f!="." and f!=".."
162
+ recursiveCopyFolder(file_path,remotePath + "/#{f}",sftp)
163
+ end
164
+ end
165
+ end
166
+
167
+ def autoconf(options)
168
+ autoconf=[]
169
+
170
+ #Add autoconfiguration options
171
+ #autoconf.push("key=value")
172
+
173
+ autoconf.push("scripts_path=" + SocialStream::Presence.scripts_path)
174
+ autoconf.push("ejabberd_password=" + SocialStream::Presence.xmpp_server_password)
175
+ autoconf.push("server_domain=" + SocialStream::Presence.domain)
176
+ autoconf.push("cookie_name=" + Rails.application.config.session_options[:key])
177
+
178
+ #Param options
179
+ if options
180
+ options.each do |option|
181
+ autoconf = addManualOption(autoconf,option)
182
+ end
183
+ end
184
+
185
+ #return "[key1=value1,key2=value2,key3=value3]"
186
+ return "[" + autoconf.join(',') + "]"
187
+ end
188
+
189
+
190
+ def addManualOption(array,option)
191
+
192
+ optionSplit = option.split("=")
193
+ unless optionSplit.length == 2
194
+ return array
195
+ end
196
+
197
+ key = optionSplit[0];
198
+ array.each do |element|
199
+ if element.split("=")[0]==key
200
+ #Replace element
201
+ array[array.index(element)]=option
202
+ return array
203
+ end
204
+ end
205
+ #Add option
206
+ array.push(option)
207
+ return array
208
+ end
209
+
210
+
211
+ def getExecutorUser
212
+ if SocialStream::Presence.remote_xmpp_server
213
+ if SocialStream::Presence.ssh_user
214
+ return SocialStream::Presence.ssh_user
215
+ else
216
+ return nil
217
+ end
218
+ else
219
+ return %x["whoami"].gsub(/\n/,"");
220
+ end
221
+ end
222
+
111
223
 
112
224
  #Execution commands manage
113
225
 
@@ -133,11 +245,11 @@ module SocialStream
133
245
  if commands.length > 1
134
246
  puts "Executing the following commands:"
135
247
  commands.each do |command|
136
- puts command
248
+ puts parsingCommand(command)
137
249
  end
138
250
  puts "Command list finish"
139
251
  elsif commands.length == 1
140
- puts "Executing " + commands[0]
252
+ puts "Executing " + parsingCommand(commands[0])
141
253
  else
142
254
  puts "No command to execute"
143
255
  return
@@ -189,7 +301,7 @@ module SocialStream
189
301
 
190
302
  return output
191
303
  end
192
-
304
+
193
305
 
194
306
 
195
307
  #Help methods
@@ -200,7 +312,10 @@ module SocialStream
200
312
  return (nodeUp and nodeUp.strip()=="true")
201
313
  end
202
314
 
203
-
315
+ def parsingCommand(command)
316
+ #Hide passwords on sudo commands: command pattern = "echo password | sudo -S order"
317
+ return command.gsub(/echo ([aA-zZ]+) [|] sudo -S [.]*/,"echo ****** | sudo -S \\2")
318
+ end
204
319
 
205
320
  #Xmpp client manage methods
206
321
 
@@ -22,6 +22,7 @@ module SocialStream
22
22
  mattr_accessor :xmpp_server_password
23
23
  mattr_accessor :remote_xmpp_server
24
24
  mattr_accessor :scripts_path
25
+ mattr_accessor :ejabberd_module_path
25
26
  mattr_accessor :enable
26
27
 
27
28
  mattr_accessor :ssh_domain
@@ -33,7 +34,7 @@ module SocialStream
33
34
 
34
35
  @@auth_method = "cookie"
35
36
  @@remote_xmpp_server = false
36
- @@enable = true
37
+ @@enable = false
37
38
 
38
39
  class << self
39
40
  def setup