innowhite 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/innowhite.gemspec +1 -1
- data/lib/innowhite.rb +70 -73
- metadata +2 -2
data/innowhite.gemspec
CHANGED
data/lib/innowhite.rb
CHANGED
@@ -1,87 +1,84 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
-
|
2
|
+
class Innowhite
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
attr_accessor :mod_name, :org_name, :sub, :server_address, :private_key
|
7
|
-
|
8
|
-
def initialize(mod_name, org_name = nil, parent_org = "innowhite")
|
9
|
-
load_settings
|
10
|
-
@mod_name = mod_name.gsub(/ /,'')
|
11
|
-
@org_name = org_name unless org_name.blank?
|
12
|
-
@parent_org = parent_org
|
13
|
-
end
|
4
|
+
attr_accessor :mod_name, :org_name, :sub, :server_address, :private_key
|
14
5
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
def initialize(mod_name, org_name = nil, parent_org = "innowhite")
|
7
|
+
load_settings
|
8
|
+
@mod_name = mod_name.gsub(/ /,'')
|
9
|
+
@org_name = org_name unless org_name.blank?
|
10
|
+
@parent_org = parent_org
|
11
|
+
end
|
21
12
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
def load_settings
|
14
|
+
settings = YAML.load_file('config/innowhite.yml')
|
15
|
+
@server_address = settings["innowhite"]["server_address"]
|
16
|
+
@private_key = settings["innowhite"]["private_key"]
|
17
|
+
@org_name = settings["innowhite"]["organization"]
|
18
|
+
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
room_id = doc.xpath('//roomId').text.gsub("\n","").to_i
|
34
|
-
elsif status.include?('AUTH_FAILED')
|
35
|
-
room_id = "AUTH_FAILED"
|
36
|
-
elsif status.include?('EXPIRED')
|
37
|
-
room_id = 'EXPIRED'
|
38
|
-
elsif status.include?('OUT_OF_SERVICE')
|
39
|
-
room_id = 'OUT_OF_SERVICE'
|
40
|
-
else
|
41
|
-
room_id = "Error With the Server #{@server_address}CreateRoom?parentOrg=innowhite&orgName=#{@sub_name}&user=#{@mod_name}&checksum=#{generate_checksum("innowhite",@sub_name, @mod_name)}"
|
42
|
-
end
|
43
|
-
return room_id
|
44
|
-
end
|
45
|
-
|
46
|
-
def join_meeting(room_id, user)
|
47
|
-
address = join_room_helper(@server_address,@org_name, room_id, user, false)
|
48
|
-
return address
|
49
|
-
end
|
20
|
+
def create_room
|
21
|
+
room_id = set_room_id
|
22
|
+
address = join_room_helper(@server_address,@org_name, room_id, @mod_name,true)
|
23
|
+
return {:address => address, :room_id => room_id}
|
24
|
+
end
|
50
25
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
26
|
+
def set_room_id
|
27
|
+
room_id = ""
|
28
|
+
doc = Nokogiri::XML(open("#{@server_address}CreateRoom?parentOrg=innowhite&orgName=#{@sub_name}&user=#{@mod_name}&checksum=#{generate_checksum("innowhite",@sub_name, @mod_name)}"))
|
29
|
+
status = doc.xpath('//returnStatus').text.gsub("\n","") rescue ""
|
30
|
+
if status.include?('SUCCESS')
|
31
|
+
room_id = doc.xpath('//roomId').text.gsub("\n","").to_i
|
32
|
+
elsif status.include?('AUTH_FAILED')
|
33
|
+
room_id = "AUTH_FAILED"
|
34
|
+
elsif status.include?('EXPIRED')
|
35
|
+
room_id = 'EXPIRED'
|
36
|
+
elsif status.include?('OUT_OF_SERVICE')
|
37
|
+
room_id = 'OUT_OF_SERVICE'
|
38
|
+
else
|
39
|
+
room_id = "Error With the Server #{@server_address}CreateRoom?parentOrg=innowhite&orgName=#{@sub_name}&user=#{@mod_name}&checksum=#{generate_checksum("innowhite",@sub_name, @mod_name)}"
|
63
40
|
end
|
41
|
+
return room_id
|
42
|
+
end
|
64
43
|
|
65
|
-
|
44
|
+
def join_meeting(room_id, user)
|
45
|
+
address = join_room_helper(@server_address,@org_name, room_id, user, false)
|
46
|
+
return address
|
47
|
+
end
|
66
48
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
49
|
+
def get_sessions(status)
|
50
|
+
ids = []
|
51
|
+
descs = []
|
52
|
+
res = []
|
53
|
+
x = Nokogiri::XML(open("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}"))
|
54
|
+
x.xpath('//web-session/session-id').each{|m| ids << m.text}
|
55
|
+
x.xpath('//web-session/session-desc').each{|m| descs << m.text}
|
73
56
|
|
74
|
-
|
75
|
-
|
57
|
+
ids.each_with_index do |id, index|
|
58
|
+
res << {:id => id, :description => descs[index]}
|
76
59
|
end
|
60
|
+
return res
|
61
|
+
end
|
77
62
|
|
78
|
-
|
79
|
-
Digest::SHA1.hexdigest(generate_information_url(parent_org, org_name,user_name))
|
80
|
-
end
|
63
|
+
private
|
81
64
|
|
82
|
-
|
83
|
-
|
84
|
-
|
65
|
+
def join_room_helper(server_addr, org_name, room_id,user, is_teacher)
|
66
|
+
action = "#{server_addr}JoinRoom?"
|
67
|
+
address = "parentOrg=innowhite&orgName=#{org_name}&roomId=#{room_id}&user=#{user}&roomLeader=#{is_teacher}"
|
68
|
+
checksum = address+@private_key
|
69
|
+
return "#{action}#{address}&checksum=#{generating_checksum(checksum)}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def generating_checksum(params)
|
73
|
+
Digest::SHA1.hexdigest(params)
|
74
|
+
end
|
75
|
+
|
76
|
+
def generate_checksum(parent_org, org_name,user_name)
|
77
|
+
Digest::SHA1.hexdigest(generate_information_url(parent_org, org_name,user_name))
|
78
|
+
end
|
79
|
+
|
80
|
+
def generate_information_url(parent_org, org_name,user_name)
|
81
|
+
"parentOrg=#{parent_org}&orgName=#{org_name}&user=#{user_name}#{@private_key}"
|
82
|
+
end
|
85
83
|
|
86
|
-
|
87
|
-
end
|
84
|
+
end
|