rb-skypemac 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +7 -0
- data/lib/rb-skypemac/call.rb +23 -14
- data/lib/rb-skypemac/group.rb +4 -0
- data/lib/rb-skypemac/skype.rb +33 -9
- data/lib/rb-skypemac/user.rb +10 -6
- data/lib/rb-skypemac/version.rb +2 -2
- data/test/test_call.rb +19 -0
- data/test/test_skype.rb +5 -0
- data/test/test_user.rb +1 -1
- data/website/index.txt +19 -1
- metadata +3 -2
data/README.txt
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
README for rb-skypemac
|
2
2
|
======================
|
3
3
|
|
4
|
+
- 0.3.0
|
5
|
+
Adds support for:
|
6
|
+
* Conference calling
|
7
|
+
* Checking for incoming calls
|
8
|
+
* Answering incoming calls
|
9
|
+
|
10
|
+
- 0.2.0
|
4
11
|
Include support for calling, managing calls, and managing users. Most invocations are made via the Skype class which
|
5
12
|
abstracts much of the Skype API, delegating calls to the constituent objects in the official Skype API.
|
data/lib/rb-skypemac/call.rb
CHANGED
@@ -4,26 +4,31 @@ include Appscript
|
|
4
4
|
|
5
5
|
|
6
6
|
module SkypeMac
|
7
|
-
|
8
|
-
#
|
7
|
+
# Represents a Skype call. Developer is responsible for calling Call#hangup at the end of each call, whether it was placed
|
8
|
+
# by the caller or is an answered call.
|
9
9
|
class Call
|
10
10
|
@@TOGGLE_FLAGS = [:START, :STOP]
|
11
|
-
|
11
|
+
|
12
12
|
attr :call_id
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
def Call.active_call_ids
|
15
|
+
r = Skype.send_ :command => "SEARCH ACTIVECALLS"
|
16
|
+
r.gsub(/CALLS /, "").split(", ")
|
17
|
+
end
|
18
|
+
|
19
|
+
def Call.active_calls
|
20
|
+
calls = Call.active_call_ids.collect { |id| Call.new id unless id == "COMMAND_PENDING"}
|
21
|
+
calls
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates a Call object from a call_id.
|
25
|
+
def initialize(call_id)
|
26
|
+
raise ArgumentError("Cannot pass nil call_id") if call_id.nil?
|
27
|
+
@call_id = call_id
|
23
28
|
end
|
24
29
|
|
25
|
-
# Attempts to hang up a call
|
26
|
-
# <
|
30
|
+
# Attempts to hang up a call. <b>Note</b>: If Skype hangs while placing the call, this method could hang indefinitely.
|
31
|
+
# <u>Use Skype#Call instead of this method unless you like memory leaks</u>
|
27
32
|
def hangup
|
28
33
|
Skype.send_ :command => "set call #{@call_id} status finished"
|
29
34
|
end
|
@@ -50,5 +55,9 @@ module SkypeMac
|
|
50
55
|
raise Error.new("Illegal flag: #{toggle_flag}") if not @@TOGGLE_FLAGS.index toggle_flag
|
51
56
|
Skype.send_ :command => "alter call #{id} #{toggle_flag.downcase.to_s}_video_receive"
|
52
57
|
end
|
58
|
+
|
59
|
+
def <=>(call)
|
60
|
+
@call_id <=> call.call_id
|
61
|
+
end
|
53
62
|
end
|
54
63
|
end
|
data/lib/rb-skypemac/group.rb
CHANGED
data/lib/rb-skypemac/skype.rb
CHANGED
@@ -7,12 +7,8 @@ module SkypeMac
|
|
7
7
|
# Singleton for interfacing with Skype
|
8
8
|
class Skype
|
9
9
|
@@groups = nil
|
10
|
+
@@calls = []
|
10
11
|
|
11
|
-
# Initiates a Skype call
|
12
|
-
def Skype.call(name_or_num)
|
13
|
-
Call.new name_or_num
|
14
|
-
end
|
15
|
-
|
16
12
|
# The Appscript interface to Skype. Requires a Hash containing:
|
17
13
|
# (1) <i>:command</i> - the Skype API command to pass,
|
18
14
|
# (2) <i>:script_name</i> - unknown all though an empty String makes Skype happy.
|
@@ -21,12 +17,40 @@ module SkypeMac
|
|
21
17
|
params[:script_name] = "" if not params.has_key? :script_name
|
22
18
|
app('Skype').send_ params
|
23
19
|
end
|
20
|
+
|
21
|
+
# Initiates a Skype call
|
22
|
+
def Skype.call(*person)
|
23
|
+
user_handles = person.collect { |u| user_str << ((u.is_a? User) ? u.handle : u) }
|
24
|
+
status = Skype.send_ :command => "call #{user_handles.join(', ')}"
|
25
|
+
if status =~ /CALL (\d+) STATUS/: @@calls << call = Call.new($1)
|
26
|
+
else raise RuntimeError.new("Call failed. Skype returned '#{status}'")
|
27
|
+
end
|
28
|
+
call
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns an Array of call IDs if there is an incoming Skype call otherwise nil
|
32
|
+
def Skype.incoming_calls
|
33
|
+
calls = Call.active_calls - @@calls
|
34
|
+
calls
|
35
|
+
end
|
36
|
+
|
37
|
+
# Answers a call given a skype call ID. Returns an Array of Call objects.
|
38
|
+
def Skype.answer(call)
|
39
|
+
cmd = "ALTER CALL #{call.call_id} ANSWER"
|
40
|
+
r = Skype.send_ :command => cmd
|
41
|
+
raise RuntimeError("Failed to answer call. Skype returned '#{r}'") unless r == cmd
|
42
|
+
@@calls << call
|
43
|
+
end
|
44
|
+
|
45
|
+
# Use this method to disconnect from a Call whether it was answered or iniiated locally.
|
46
|
+
def Skype.hangup(call)
|
47
|
+
call.hangup
|
48
|
+
@@calls.delete call
|
49
|
+
end
|
24
50
|
|
25
|
-
# Returns an Array of
|
51
|
+
# Returns an Array of Group
|
26
52
|
def Skype.groups
|
27
|
-
if not @@groups
|
28
|
-
@@groups = Group.groups
|
29
|
-
end
|
53
|
+
@@groups = Group.groups if not @@groups
|
30
54
|
@@groups
|
31
55
|
end
|
32
56
|
|
data/lib/rb-skypemac/user.rb
CHANGED
@@ -11,7 +11,7 @@ module SkypeMac
|
|
11
11
|
r = Skype.send_ :command => "get user \#{@handle} #{attr_sym.to_s}"
|
12
12
|
v = r.sub(/^.*#{attr_sym.to_s.upcase} /, "")
|
13
13
|
v = true if v == "TRUE"
|
14
|
-
v =
|
14
|
+
v = false if v == "FALSE"
|
15
15
|
v
|
16
16
|
end}
|
17
17
|
if accessor
|
@@ -21,7 +21,7 @@ module SkypeMac
|
|
21
21
|
r = Skype.send_ :command => "set user \#{@handle} #{attr_sym.to_s} \#{value}"
|
22
22
|
v = r.sub(/^.*#{attr_sym.to_s.upcase} /, "")
|
23
23
|
v = true if v == "TRUE"
|
24
|
-
v =
|
24
|
+
v = false if v == "FALSE"
|
25
25
|
v
|
26
26
|
end}
|
27
27
|
end
|
@@ -42,17 +42,21 @@ module SkypeMac
|
|
42
42
|
attr_reader :handle
|
43
43
|
skype_attr_reader :fullname, :birthday, :sex, :language, :country, :province
|
44
44
|
skype_attr_reader :city, :phone_home, :phone_office, :phone_mobile, :homepage
|
45
|
-
skype_attr_reader :about, :is_video_capable, :
|
46
|
-
skype_attr_reader :
|
47
|
-
skype_attr_reader :can_leave_vm, :
|
45
|
+
skype_attr_reader :about, :is_video_capable, :is_authorized
|
46
|
+
skype_attr_reader :onlinestatus, :skypeout, :lastonlinetimestamp
|
47
|
+
skype_attr_reader :can_leave_vm, :receivedauthrequest, :mood_text
|
48
48
|
skype_attr_reader :rich_mood_text, :is_cf_active, :nrof_authed_buddies
|
49
49
|
|
50
50
|
#TODO: attr_reader :aliases, :timezone
|
51
51
|
|
52
|
-
|
52
|
+
skype_attr_accessor :buddystatus, :isblocked, :isauthorized, :speeddial, :displayname
|
53
53
|
|
54
54
|
def initialize(handle)
|
55
55
|
@handle = handle
|
56
56
|
end
|
57
|
+
|
58
|
+
def <=>(user)
|
59
|
+
@handle <=> user.handle
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
data/lib/rb-skypemac/version.rb
CHANGED
data/test/test_call.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
include SkypeMac
|
3
|
+
|
4
|
+
class TestCall< Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_new
|
7
|
+
assert Call.new 42
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_active_call_ids
|
11
|
+
assert call_ids = Call.active_call_ids
|
12
|
+
assert call_ids.empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_active_calls
|
16
|
+
assert calls = Call.active_calls
|
17
|
+
assert calls.empty?
|
18
|
+
end
|
19
|
+
end
|
data/test/test_skype.rb
CHANGED
data/test/test_user.rb
CHANGED
data/website/index.txt
CHANGED
@@ -25,13 +25,29 @@ call.hangup
|
|
25
25
|
|
26
26
|
sleight42 = Skype.online_friends.find { |u| u.handle == "sleight42" }
|
27
27
|
call = Skype.call sleight42
|
28
|
-
|
28
|
+
Skype.hangup call # no one wants to talk to him anyway
|
29
29
|
|
30
30
|
# Set your user status to away
|
31
31
|
Iam.away
|
32
32
|
|
33
33
|
# Set your user status to back
|
34
34
|
Iam.online
|
35
|
+
|
36
|
+
# Attempt to detect and answer a call -- still experimental!
|
37
|
+
# Sporadically crashes Skype 2.6.0.17
|
38
|
+
loop do
|
39
|
+
begin
|
40
|
+
if not (calls = Skype.incoming_calls).empty?
|
41
|
+
call = Skype.answer calls.first
|
42
|
+
sleep 10
|
43
|
+
call.hangup
|
44
|
+
end
|
45
|
+
rescue RuntimeError => e
|
46
|
+
puts e.message
|
47
|
+
end
|
48
|
+
puts "sleeping..."
|
49
|
+
sleep 1
|
50
|
+
end
|
35
51
|
</pre>
|
36
52
|
|
37
53
|
h2. Licence
|
@@ -41,3 +57,5 @@ This code is free to use under the terms of the <a href="http://creativecommons.
|
|
41
57
|
h2. Contact
|
42
58
|
|
43
59
|
Comments are welcome. Send an email to "Evan Light":mailto:sleight42@gmail.com.
|
60
|
+
|
61
|
+
Copyright 2007, Evan Light
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rb-skypemac
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.3.0
|
7
|
+
date: 2007-05-02 00:00:00 -04:00
|
8
8
|
summary: Ruby interface to Skype on Mac OS X
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- website/stylesheets/screen.css
|
51
51
|
- website/template.rhtml
|
52
52
|
test_files:
|
53
|
+
- test/test_call.rb
|
53
54
|
- test/test_group.rb
|
54
55
|
- test/test_helper.rb
|
55
56
|
- test/test_rb-skypemac.rb
|