skypemac 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +19 -0
- data/README.md +69 -0
- data/Rakefile +1 -0
- data/lib/skypemac.rb +12 -0
- data/lib/skypemac/base.rb +127 -0
- data/lib/skypemac/objects/call.rb +118 -0
- data/lib/skypemac/objects/chat.rb +98 -0
- data/lib/skypemac/objects/chat_member.rb +21 -0
- data/lib/skypemac/objects/chat_message.rb +47 -0
- data/lib/skypemac/objects/group.rb +60 -0
- data/lib/skypemac/objects/profile.rb +41 -0
- data/lib/skypemac/objects/user.rb +95 -0
- data/lib/skypemac/skype.rb +23 -0
- data/lib/skypemac/version.rb +3 -0
- data/skypemac.gemspec +25 -0
- data/spec/spec_helper.rb +1 -0
- metadata +103 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Zoltan Dezso
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Introduction
|
2
|
+
|
3
|
+
SkypeMac is a ruby wrapper for the Skype public API using AppleScript.
|
4
|
+
|
5
|
+
It allows basic commands to be sent to a running Skype instance, such
|
6
|
+
as changing the online status of the current user, listing friends or
|
7
|
+
chat messages, initiating calls and chats etc.
|
8
|
+
|
9
|
+
NOTE: At this point, Skype does not support asynchronous commands over the
|
10
|
+
AppleScript API.
|
11
|
+
|
12
|
+
# Installation
|
13
|
+
|
14
|
+
gem install skypemac
|
15
|
+
|
16
|
+
# Usage
|
17
|
+
|
18
|
+
require 'skypemac'
|
19
|
+
|
20
|
+
### Current user
|
21
|
+
|
22
|
+
user = SkypeMac::User.current_user
|
23
|
+
# => echotest123
|
24
|
+
|
25
|
+
### Online Status
|
26
|
+
|
27
|
+
SkypeMac::User.status
|
28
|
+
# => "ONLINE"
|
29
|
+
SkypeMac::User.status = "OFFLINE"
|
30
|
+
# => "OFFLINE"
|
31
|
+
|
32
|
+
### Calling
|
33
|
+
|
34
|
+
# Call a user
|
35
|
+
call = SkypeMac::Call.call('echo123')
|
36
|
+
# => #<SkypeMac::Call:0x007fc3b30f30d8 @id="2214381">
|
37
|
+
call.status
|
38
|
+
# => "INPROGRESS"
|
39
|
+
call.partner_dispname
|
40
|
+
# "Skype Test Call"
|
41
|
+
|
42
|
+
### Chats
|
43
|
+
|
44
|
+
# List recent chats
|
45
|
+
chats = SkypeMac::Chat.recent_chats
|
46
|
+
# => [ #<SkypeMac::Chat:0x007fc3b3195f68 @id="#test/$zaki001;123456abcdef">, #<SkypeMac::Chat:0x007fc3b3195f40 @id="#test/$zaki;1234556abcdef"> ]
|
47
|
+
messages = chats.first.recent_chat_messages
|
48
|
+
# => [ #<SkypeMac::ChatMessage:0x007fc3b3854ea8 @id="1234">, #<SkypeMac::ChatMessage:0x007fc3b3854e80 @id="1234"> ]
|
49
|
+
messages.map &:body
|
50
|
+
# => [ "Hi", "This is a test" ]
|
51
|
+
|
52
|
+
# Send a message to an existing chat
|
53
|
+
chats.first.send_message("Hey there")
|
54
|
+
# => "CHATMESSAGE 2114633 STATUS SENDING"
|
55
|
+
# it is not possible to get an asynchronous delivery notification,
|
56
|
+
# if you need to make sure it got sent, you will need to poll:
|
57
|
+
|
58
|
+
message = SkypeMac::ChatMessage.new(2114633)
|
59
|
+
message.status
|
60
|
+
# => "SENT"
|
61
|
+
|
62
|
+
# Get information about a chat
|
63
|
+
chat.topic
|
64
|
+
# => "Test chat"
|
65
|
+
|
66
|
+
|
67
|
+
# License
|
68
|
+
|
69
|
+
SkypeMac is available under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/skypemac.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "skypemac/version"
|
2
|
+
|
3
|
+
require 'skypemac/base'
|
4
|
+
require 'skypemac/skype'
|
5
|
+
require 'skypemac/objects/call'
|
6
|
+
require 'skypemac/objects/chat'
|
7
|
+
require 'skypemac/objects/chat_member'
|
8
|
+
require 'skypemac/objects/chat_message'
|
9
|
+
require 'skypemac/objects/group'
|
10
|
+
require 'skypemac/objects/profile'
|
11
|
+
require 'skypemac/objects/user'
|
12
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'appscript'
|
2
|
+
|
3
|
+
module SkypeMac
|
4
|
+
class SkypeException < ArgumentError
|
5
|
+
def initialize(command, error)
|
6
|
+
@command = command
|
7
|
+
@error = error
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
"COMMAND '#{@command}' failed:\n#{@error}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Base
|
16
|
+
@_class = 'BASE'
|
17
|
+
@id = nil
|
18
|
+
class << self
|
19
|
+
# Sends an API command to Skype using the Applescript client
|
20
|
+
def send(options)
|
21
|
+
options[:script_name] ||= 'skypemac-ruby'
|
22
|
+
result = Appscript.app('Skype').send_ options
|
23
|
+
if result =~ /^ERROR /
|
24
|
+
raise SkypeException.new(options[:command], result)
|
25
|
+
end
|
26
|
+
result
|
27
|
+
end
|
28
|
+
|
29
|
+
def protocol_required(protocol)
|
30
|
+
end
|
31
|
+
|
32
|
+
def send_command(command, command_id=nil, &block)
|
33
|
+
id=''
|
34
|
+
if command_id =~ /[a-zA-Z0-9]+/
|
35
|
+
id = "##{command_id} "
|
36
|
+
end
|
37
|
+
result = SkypeMac::Base.send(:command=>"#{id}#{command}")
|
38
|
+
if block
|
39
|
+
yield result
|
40
|
+
else
|
41
|
+
result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def property(property_name, options={})
|
46
|
+
api_name = options[:api_name] || property_name.to_s.gsub(/[?!]$/, '')
|
47
|
+
api_name = api_name.to_s.upcase
|
48
|
+
property_type = options[:type] || :string
|
49
|
+
immutable = options[:immutable] || false
|
50
|
+
collection_class = options[:collection] || Class
|
51
|
+
|
52
|
+
class_eval <<-RUBY
|
53
|
+
def #{property_name.to_s}
|
54
|
+
#{immutable ? "@#{property_name.to_s}||" : '_property'}= Base::send_command "GET #{@_class} \#{@id} #{api_name}" do |result|
|
55
|
+
case result
|
56
|
+
when /^#{@_class} (.+) #{api_name} (.*)$/
|
57
|
+
$2
|
58
|
+
end
|
59
|
+
end
|
60
|
+
Base::property_convert(_property, :#{property_type}, #{collection_class}) unless _property.nil?
|
61
|
+
end
|
62
|
+
RUBY
|
63
|
+
end
|
64
|
+
|
65
|
+
def property_writer(property_name, options={})
|
66
|
+
api_name = options[:api_name] || property_name.to_s.gsub(/[?!]$/, '')
|
67
|
+
api_name = api_name.to_s.upcase
|
68
|
+
|
69
|
+
class_eval <<-RUBY
|
70
|
+
def #{property_name.to_s}=(value)
|
71
|
+
Base::send_command "SET #{@_class} \#{@id} #{api_name} \#{value}" do |result|
|
72
|
+
case result
|
73
|
+
when /^#{@_class} (.+) #{api_name} (.*)$/
|
74
|
+
$2
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
RUBY
|
79
|
+
end
|
80
|
+
|
81
|
+
def alter(property_name, options={})
|
82
|
+
api_name = options[:api_name] || (property_name.to_s =~ /!$/ ? '' : 'SET')+property_name.to_s.gsub(/[?!]$/, '')
|
83
|
+
api_name = api_name.to_s.upcase
|
84
|
+
signature = property_name.to_s =~ /!$/ ? "#{property_name}(*value)" : "#{property_name.to_s}=(*value)"
|
85
|
+
|
86
|
+
class_eval <<-RUBY
|
87
|
+
def #{signature}
|
88
|
+
Base::send_command "ALTER #{@_class} \#{@id} #{api_name} \#{Array(value).join(', ')}" do |result|
|
89
|
+
case result
|
90
|
+
when /^#{@_class} (.+) (#{api_name} )?(.*)$/
|
91
|
+
$3
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
RUBY
|
96
|
+
end
|
97
|
+
|
98
|
+
def property_convert(property, type, collection_class)
|
99
|
+
return if property.nil?
|
100
|
+
case type
|
101
|
+
when :string
|
102
|
+
property.to_s
|
103
|
+
when :integer
|
104
|
+
property.to_i
|
105
|
+
when :timestamp
|
106
|
+
Time.at(property.to_i)
|
107
|
+
when :boolean
|
108
|
+
!!(property =~ /true/i)
|
109
|
+
when :collection
|
110
|
+
property.to_s.split(/, /).map {|x| collection_class.new(x) }
|
111
|
+
else
|
112
|
+
property
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def protocol(protocol_version=8)
|
118
|
+
Base::send_command "PROTOCOL #{protocol_version}" do |result|
|
119
|
+
if result =~ /^PROTOCOL (\d)$/
|
120
|
+
@protocol = $1.to_i
|
121
|
+
warn "Requested #{protocol_version} but received #{@protocol}" if @protocol != protocol_version
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module SkypeMac
|
2
|
+
class Call < SkypeMac::Base
|
3
|
+
@_class = 'CALL'
|
4
|
+
class << self
|
5
|
+
# -> CALL target[, target]*
|
6
|
+
# <- CALL id status
|
7
|
+
def call(*targets)
|
8
|
+
protocol_required 1
|
9
|
+
Base::send_command "CALL #{Array(targets).join(',')}" do |result|
|
10
|
+
case result
|
11
|
+
when /^CALL (\d+) (.*)$/
|
12
|
+
return Call.new($1)
|
13
|
+
else
|
14
|
+
raise SkypeException.new("CALL", result)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def _search(command)
|
19
|
+
Base::send_command "SEARCH #{command}" do |result|
|
20
|
+
case result
|
21
|
+
when /^CALLS (.*)$/
|
22
|
+
calls = $1
|
23
|
+
return calls.split(', ').map {|x| Call.new x}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def search(target)
|
29
|
+
_search "CALLS #{target}"
|
30
|
+
end
|
31
|
+
def active_calls
|
32
|
+
_search "ACTIVECALLS"
|
33
|
+
end
|
34
|
+
def missed_calls
|
35
|
+
_search "MISSEDCALLS"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(id)
|
41
|
+
@id = id
|
42
|
+
end
|
43
|
+
|
44
|
+
#{{{ - Properties
|
45
|
+
property :partner_handle
|
46
|
+
property :partner_dispname
|
47
|
+
property :target_identity
|
48
|
+
property :conf_id
|
49
|
+
property :status
|
50
|
+
property :video_status
|
51
|
+
property :video_send_status
|
52
|
+
property :video_receive_status
|
53
|
+
property :pstn_number
|
54
|
+
property :duration, :type=>:integer
|
55
|
+
property :pstn_status
|
56
|
+
property :conf_participants_count, :type=>:integer
|
57
|
+
property :wm_duration, :type=>:integer
|
58
|
+
property :wm_allowed_duration, :type=>:integer
|
59
|
+
property :rate, :type=>:integer
|
60
|
+
property :rate_currency
|
61
|
+
property :rate_precision
|
62
|
+
property :transfer_active?, :api_name=>:transfer_active, :type=>:boolean
|
63
|
+
property :transfer_status
|
64
|
+
property :timestamp, :type=>:timestamp
|
65
|
+
property :failure_reason, :api_name=>:failurereason
|
66
|
+
property :type, :immutable=>true
|
67
|
+
|
68
|
+
def conf_participant(index)
|
69
|
+
Base::send_command "GET CALL #{@id} CONF_PARTICIPANT #{index}" do |response|
|
70
|
+
case response
|
71
|
+
when /^CALL #{@id} CONF_PARTICIPANT #{index} (.+)$/
|
72
|
+
return $1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
#{{{ - Type helpers
|
78
|
+
def pstn?
|
79
|
+
type =~ /PSTN/
|
80
|
+
end
|
81
|
+
|
82
|
+
def p2p?
|
83
|
+
!pstn
|
84
|
+
end
|
85
|
+
|
86
|
+
def incoming?
|
87
|
+
type =~ /INCOMING/
|
88
|
+
end
|
89
|
+
|
90
|
+
def outgoing?
|
91
|
+
!incoming
|
92
|
+
end
|
93
|
+
#}}}
|
94
|
+
|
95
|
+
#{{{ - Status helpers
|
96
|
+
%w(unplaced routing earlymedia failed ringing inprogress onhold finished
|
97
|
+
missed refused busy cancelled transferring transferred
|
98
|
+
wm_buffering_greeting wm_playing_greeting wm_recording wm_uploading wm_sent wm_cancelled wm_failed
|
99
|
+
waiting_redial_command redial_pending).each do |status|
|
100
|
+
class_eval <<-RUBY
|
101
|
+
def #{status}?; status == '#{status.upcase}'; end
|
102
|
+
RUBY
|
103
|
+
end
|
104
|
+
#}}}
|
105
|
+
|
106
|
+
#}}}
|
107
|
+
|
108
|
+
# -> SET CALL id STATUS status
|
109
|
+
# <- CALL id STATUS status
|
110
|
+
# status = INPROGRESS | FINISHED | ONHOLD
|
111
|
+
def set_call_status(status)
|
112
|
+
end
|
113
|
+
|
114
|
+
# -> SET CALL join_id JOIN_CONFERENCE master_id
|
115
|
+
def join_conference(join_id, master_id)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'skypemac/objects/user'
|
2
|
+
require 'skypemac/objects/chat_message'
|
3
|
+
require 'skypemac/objects/chat_member'
|
4
|
+
|
5
|
+
|
6
|
+
module SkypeMac
|
7
|
+
class Chat < SkypeMac::Base
|
8
|
+
@_class = 'CHAT'
|
9
|
+
class << self
|
10
|
+
def _search(command)
|
11
|
+
Base::send_command "SEARCH #{command}" do |result|
|
12
|
+
case result
|
13
|
+
when /^CHATS (.*)$/
|
14
|
+
chats = $1
|
15
|
+
return chats.split(', ').map {|x| Chat.new x}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def recent_chats
|
20
|
+
_search "RECENTCHATS"
|
21
|
+
end
|
22
|
+
def active_chats
|
23
|
+
_search "ACTIVECHATS"
|
24
|
+
end
|
25
|
+
def missed_chats
|
26
|
+
_search "MISSEDCHATS"
|
27
|
+
end
|
28
|
+
def bookmarked_chats
|
29
|
+
_search "BOOKMARKEDCHATS"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(id)
|
34
|
+
@id = id
|
35
|
+
end
|
36
|
+
|
37
|
+
def send_message(message)
|
38
|
+
Base::send_command "CHATMESSAGE #{@id} #{message}"
|
39
|
+
end
|
40
|
+
|
41
|
+
#{{{ - Properties
|
42
|
+
property :name
|
43
|
+
property :topic
|
44
|
+
property :status
|
45
|
+
property :topic_xml, :api_name=>:topicxml
|
46
|
+
property :bookmarked?, :api_name=>:bookmarked, :type=>:boolean
|
47
|
+
property :friendly_name, :api_name=>:friendlyname
|
48
|
+
property :timestamp, :type=>:timestamp
|
49
|
+
property :adder, :type=>:collection, :collection=>SkypeMac::User
|
50
|
+
property :posters, :type=>:collection, :collection=>SkypeMac::User
|
51
|
+
property :members, :type=>:collection, :collection=>SkypeMac::User
|
52
|
+
property :active_members, :api_name=>:activemembers, :type=>:collection, :collection=>SkypeMac::User
|
53
|
+
property :chat_messages, :api_name=>:chatmessages, :type=>:collection, :collection=>SkypeMac::ChatMessage
|
54
|
+
property :recent_chat_messages, :api_name=>:recentchatmessages, :type=>:collection, :collection=>SkypeMac::ChatMessage
|
55
|
+
|
56
|
+
# protocol 7 additions
|
57
|
+
property :password_hint, :api_name=>:passwordhint
|
58
|
+
property :guidelines
|
59
|
+
property :options
|
60
|
+
property :description
|
61
|
+
property :my_status, :api_name=>:mystatus
|
62
|
+
property :my_role, :api_name=>:myrole
|
63
|
+
property :blob
|
64
|
+
property :activity_timestamp, :type=>:timestamp
|
65
|
+
|
66
|
+
# ALTER commands
|
67
|
+
alter :topic
|
68
|
+
alter :topic_xml, :api_name=>:settopicxml
|
69
|
+
alter :leave!
|
70
|
+
alter :bookmark!
|
71
|
+
alter :unbookmark!
|
72
|
+
alter :join!
|
73
|
+
alter :clear_recent_messages!, :api_name=>:clearrecentmessages
|
74
|
+
alter :alert_string, :api_name=>:alertstring
|
75
|
+
alter :accept_add!, :api_name=>:acceptadd
|
76
|
+
alter :disband!
|
77
|
+
|
78
|
+
alter :password
|
79
|
+
alter :enter_password, :api_name=>:enterpassword
|
80
|
+
alter :options
|
81
|
+
alter :kick
|
82
|
+
alter :kickban
|
83
|
+
|
84
|
+
def member_objects
|
85
|
+
#TODO
|
86
|
+
end
|
87
|
+
|
88
|
+
def dialog_partner
|
89
|
+
#TODO
|
90
|
+
end
|
91
|
+
|
92
|
+
def applicants
|
93
|
+
#TODO
|
94
|
+
end
|
95
|
+
|
96
|
+
#}}}
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SkypeMac
|
2
|
+
class ChatMember < SkypeMac::Base
|
3
|
+
@_class = 'CHATMEMBER'
|
4
|
+
class << self
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(id)
|
8
|
+
@id = id
|
9
|
+
end
|
10
|
+
|
11
|
+
#{{{ - Properties
|
12
|
+
property :chat_name, :api_name=>:chatname
|
13
|
+
property :identity
|
14
|
+
property :role
|
15
|
+
property :active?, :api_name=>:is_active, :type=>:boolean
|
16
|
+
|
17
|
+
alter :role, :api_name=>:setroleto
|
18
|
+
alter :can_set_role, :api_name=>:cansetroleto
|
19
|
+
#}}}
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module SkypeMac
|
2
|
+
class ChatMessage < SkypeMac::Base
|
3
|
+
@_class = 'CHATMESSAGE'
|
4
|
+
class << self
|
5
|
+
def _search(command)
|
6
|
+
Base::send_command "SEARCH #{command}" do |result|
|
7
|
+
case result
|
8
|
+
when /^CHATMESSAGES (.*)$/
|
9
|
+
chatmessages = $1
|
10
|
+
return chatmessages.split(', ').map {|x| ChatMessage.new x}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def search(user)
|
16
|
+
_search "CHATMESSAGES #{user.to_s}"
|
17
|
+
end
|
18
|
+
def missed_chat_messages
|
19
|
+
_search "MISSEDCHATMESSAGES"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(id)
|
24
|
+
@id = id
|
25
|
+
end
|
26
|
+
|
27
|
+
#{{{ - Properties
|
28
|
+
property :seen?, :type=>:boolean
|
29
|
+
property :body
|
30
|
+
property :from_dispname
|
31
|
+
property :status
|
32
|
+
property :chat_name
|
33
|
+
property :options
|
34
|
+
property :role
|
35
|
+
property :timestamp, :type=>:timestamp
|
36
|
+
property :from_handle, :immutable=>true
|
37
|
+
property :type, :immutable=>true
|
38
|
+
property :leave_reason, :api_name=>:leavereason
|
39
|
+
property :editable?, :type=>:boolean
|
40
|
+
property :edited_timestamp, :type=>:timestamp
|
41
|
+
|
42
|
+
property_writer :seen
|
43
|
+
property_writer :body
|
44
|
+
#}}}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'skypemac/objects/user'
|
2
|
+
|
3
|
+
module SkypeMac
|
4
|
+
class Group < SkypeMac::Base
|
5
|
+
@_class = 'GROUP'
|
6
|
+
class << self
|
7
|
+
def _search(command)
|
8
|
+
Base::send_command "SEARCH #{command}" do |result|
|
9
|
+
case result
|
10
|
+
when /^GROUPS (.*)$/
|
11
|
+
users = $1
|
12
|
+
return users.split(', ').map {|x| Group.new x}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(name)
|
18
|
+
Base::send_command "CREATE GROUP #{name}" do |result|
|
19
|
+
case result
|
20
|
+
when /^CREATE GROUP (.*)$/
|
21
|
+
Group.new $1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# [{ALL|CUSTOM|HARDWIRED}]
|
27
|
+
def search(type='')
|
28
|
+
_search "GROUPS #{type.to_s.upcase}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(id)
|
33
|
+
@id = id
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete
|
37
|
+
Base::send_command "DELETE GROUP #{@id}"
|
38
|
+
end
|
39
|
+
|
40
|
+
#{{{ - Properties
|
41
|
+
property :type
|
42
|
+
property :custom_group_id, :immutable=>true
|
43
|
+
property :display_name,:api_name=>:displayname
|
44
|
+
property :user_count, :api_name=>:nrofusers
|
45
|
+
property :online_user_count, :api_name=>:nrofusers_online
|
46
|
+
property :users, :type=>:collection, :collection=>SkypeMac::User
|
47
|
+
|
48
|
+
property :expanded, :type=>:boolean
|
49
|
+
property_writer :display_name, :api_name=>:displayname
|
50
|
+
|
51
|
+
alter :add_user, :api_name=>:adduser
|
52
|
+
alter :remove_user, :api_name=>:removeuser
|
53
|
+
|
54
|
+
alter :share!
|
55
|
+
alter :accept!
|
56
|
+
alter :decline!
|
57
|
+
#}}}
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module SkypeMac
|
2
|
+
class Profile < SkypeMac::Base
|
3
|
+
@_class = 'PROFILE'
|
4
|
+
class << self
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(id)
|
8
|
+
@id = id
|
9
|
+
end
|
10
|
+
|
11
|
+
#{{{ - Properties
|
12
|
+
property :pstn_balance
|
13
|
+
property :pstn_balance_currency
|
14
|
+
property :full_name, :api_name=>:fullname
|
15
|
+
property :birthday
|
16
|
+
property :gender, :api_name=>:sex
|
17
|
+
property :languages
|
18
|
+
property :country
|
19
|
+
property :ip_country, :api_name=>:ipcountry
|
20
|
+
property :province
|
21
|
+
property :city
|
22
|
+
property :phone_home
|
23
|
+
property :phone_office
|
24
|
+
property :phone_mobile
|
25
|
+
property :homepage
|
26
|
+
property :about
|
27
|
+
property :mood_text
|
28
|
+
property :rich_mood_text
|
29
|
+
property :time_zone, :api_name=>:timezone
|
30
|
+
property :call_apply_forwading, :api_name=>:call_apply_cf
|
31
|
+
property :call_noanswer_timeout
|
32
|
+
property :call_forward_rules
|
33
|
+
property :call_send_to_voicemail, :api_name=>:call_send_to_vm
|
34
|
+
property :sms_validated_numbers
|
35
|
+
|
36
|
+
property_writer :mood_text
|
37
|
+
property_writer :rich_mood_text
|
38
|
+
#}}}
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module SkypeMac
|
2
|
+
class User < SkypeMac::Base
|
3
|
+
@_class = 'USER'
|
4
|
+
class << self
|
5
|
+
def current_user
|
6
|
+
Base::send_command "GET CURRENTUSERHANDLE" do |result|
|
7
|
+
if result =~ /^CURRENTUSERHANDLE (.*)$/
|
8
|
+
User.new $1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
def status
|
13
|
+
Base::send_command "GET USERSTATUS" do |result|
|
14
|
+
if result =~ /^USERSTATUS (.*)$/
|
15
|
+
$1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def status=(value)
|
20
|
+
Base::send_command "SET USERSTATUS #{value}" do |result|
|
21
|
+
if result =~ /^USERSTATUS (.*)$/
|
22
|
+
$1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def _search(command)
|
27
|
+
Base::send_command "SEARCH #{command}" do |result|
|
28
|
+
case result
|
29
|
+
when /^USERS (.*)$/
|
30
|
+
users = $1
|
31
|
+
return users.split(', ').map {|x| User.new x}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
def search(keyword)
|
36
|
+
_search "USERS #{keyword}"
|
37
|
+
end
|
38
|
+
def friends
|
39
|
+
_search "FRIENDS"
|
40
|
+
end
|
41
|
+
def users_waiting_authorization
|
42
|
+
_search "USERSWAITINGMYAUTHORIZATION"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(id)
|
47
|
+
@id = id
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
@id
|
52
|
+
end
|
53
|
+
|
54
|
+
#{{{ - Properties
|
55
|
+
property :language
|
56
|
+
property :country
|
57
|
+
property :provice
|
58
|
+
property :city
|
59
|
+
property :phone_home
|
60
|
+
property :phone_office
|
61
|
+
property :phone_mobile
|
62
|
+
property :homepage
|
63
|
+
property :about
|
64
|
+
property :skypeme
|
65
|
+
property :speed_dial, :api_name=>:speeddial
|
66
|
+
property :mood_text
|
67
|
+
property :rich_mood_text
|
68
|
+
property :display_name, :api_name=>:displayname
|
69
|
+
property :handle, :immutable=>true
|
70
|
+
property :full_name, :api_name=>:fullname
|
71
|
+
property :birthday
|
72
|
+
property :gender, :api_name=>:sex
|
73
|
+
property :has_call_equipment?, :api_name=>:hascallequipment, :type=>:boolean
|
74
|
+
property :video_capable?, :api_name=>:is_video_capable, :type=>:boolean
|
75
|
+
property :voicemail_capable?, :api_name=>:is_voicemail_capable, :type=>:boolean
|
76
|
+
property :buddy_status, :api_name=>:buddystatus
|
77
|
+
property :authorized?, :api_name=>:isauthorized, :type=>:boolean
|
78
|
+
property :blocked?, :api_name=>:isblocked, :type=>:boolean
|
79
|
+
property :online_status, :api_name=>:onlinestatus
|
80
|
+
property :last_online_timestamp, :api_name=>:lastonlinetimestamp, :type=>:timestamp
|
81
|
+
property :can_leave_voicemail?, :api_name=>:can_leave_vm, :type=>:boolean
|
82
|
+
property :received_auth_request, :api_name=>:receivedauthrequest
|
83
|
+
property :call_forwarding_active?, :api_name=>:is_cf_active, :type=>:boolean
|
84
|
+
property :authorized_buddy_count, :api_name=>:nrof_authed_buddies, :type=>:integer
|
85
|
+
|
86
|
+
property_writer :buddy_status, :api_name=>:buddystatus
|
87
|
+
property_writer :is_blocked, :api_name=>:isblocked
|
88
|
+
property_writer :is_authorized, :api_name=>:isauthorized
|
89
|
+
property_writer :speeddial
|
90
|
+
property_writer :display_name, :api_name=>:displayname
|
91
|
+
#}}}
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SkypeMac
|
2
|
+
class Skype < SkypeMac::Base
|
3
|
+
class << self
|
4
|
+
def skype_version
|
5
|
+
Base::send_command "GET SKYPEVERSION" do |result|
|
6
|
+
if result =~ /^SKYPEVERSION (.*)$/
|
7
|
+
$1
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
def connection_status
|
13
|
+
Base::send_command "GET CONNSTATUS" do |result|
|
14
|
+
if result =~ /^CONNSTATUS (.*)$/
|
15
|
+
$1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def initialize(version=8)
|
20
|
+
protocol(version)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/skypemac.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "skypemac/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "skypemac"
|
7
|
+
s.version = SkypeMac::VERSION
|
8
|
+
s.authors = ["Zoltan Dezso"]
|
9
|
+
s.email = ["dezso.zoltan@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Skype Public API client for Mac}
|
12
|
+
s.description = %q{Skype Public API client for Mac}
|
13
|
+
|
14
|
+
s.rubyforge_project = "skypemac"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "rake"
|
24
|
+
s.add_runtime_dependency "rb-appscript"
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'skypemac'
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skypemac
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Zoltan Dezso
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-08 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70210452179520 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70210452179520
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70210452178700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70210452178700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rb-appscript
|
38
|
+
requirement: &70210452177840 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70210452177840
|
47
|
+
description: Skype Public API client for Mac
|
48
|
+
email:
|
49
|
+
- dezso.zoltan@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/skypemac.rb
|
60
|
+
- lib/skypemac/base.rb
|
61
|
+
- lib/skypemac/objects/call.rb
|
62
|
+
- lib/skypemac/objects/chat.rb
|
63
|
+
- lib/skypemac/objects/chat_member.rb
|
64
|
+
- lib/skypemac/objects/chat_message.rb
|
65
|
+
- lib/skypemac/objects/group.rb
|
66
|
+
- lib/skypemac/objects/profile.rb
|
67
|
+
- lib/skypemac/objects/user.rb
|
68
|
+
- lib/skypemac/skype.rb
|
69
|
+
- lib/skypemac/version.rb
|
70
|
+
- skypemac.gemspec
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
homepage: ''
|
73
|
+
licenses: []
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
hash: 1776554521654031330
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
hash: 1776554521654031330
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project: skypemac
|
98
|
+
rubygems_version: 1.8.10
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Skype Public API client for Mac
|
102
|
+
test_files:
|
103
|
+
- spec/spec_helper.rb
|