SkypeR 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +25 -79
  2. data/bin/iskype.rb +37 -28
  3. data/bin/iskype.rb~ +133 -0
  4. metadata +14 -5
data/README CHANGED
@@ -7,6 +7,7 @@ SkypeR is the library which enables SkypeAPI connection via RBus.
7
7
  * Skype for Linux
8
8
  * RBus
9
9
  For more infomation, please refer to http://rbus.rubyforge.org/
10
+ * yaparc
10
11
 
11
12
  = Install & Preparation
12
13
 
@@ -32,10 +33,9 @@ Invoke skype with dbus messaging enabled.
32
33
 
33
34
  # skype --enable-dbus --use-session-dbus &
34
35
 
35
-
36
36
  = Usage
37
37
 
38
- == iSky
38
+ == iskype
39
39
 
40
40
  Be sure to invoke skype with with dbus messaging enabled.
41
41
  And then, run iskype.rb with application name.
@@ -43,86 +43,32 @@ And then, run iskype.rb with application name.
43
43
  $ ruby iskype.rb -n application_name
44
44
  Skype> GET USER my_skype_account FULLNAME
45
45
  Skype> GET USER somebodys_account BUDDYSTATUS
46
+ Skype> SEARCH FRIENDS
46
47
  Skype> GET USERSTATUS
47
- #<RBus::Variant:0xb7ac9920 @object_signature="s", @object="USERSTATUS ONLINE">
48
- => #<Thread:0xb7ade26c>
48
+ OK
49
+ PROTOCOL 5
50
+ USERSTATUS ONLINE
51
+ Skype> GET USER somebodys_account ONLINESTATUS
52
+ OK
53
+ PROTOCOL 5
54
+ USER somebodys_account ONLINESTATUS OFFLINE
55
+
56
+ Skype> GET USER somebodys_account LASTONLINETIMESTAMP
57
+
49
58
  Skype> exit
50
59
  See you again.
51
60
 
61
+ With -p option, iskype parses input command before execution. The parser is still rudimentary.
62
+
63
+ $ ruby iskype.rb -p
64
+ Skype> blah, blah
65
+ => Parse Error
66
+ Skype> SEARCH FRIENDS
67
+ OK
68
+ PROTOCOL 5
69
+ => USERS echo123, foo, bar
70
+
52
71
 
53
- = Skype API reference
54
-
55
-
56
- == Comannds
57
-
58
- === CALL
59
- Command: CALL <target>[, <target>]*
60
- Response: CALL <call_id> <status>
61
-
62
- <target> := USERNAME
63
- | PSTN
64
- | SPEED DIAL CODE
65
- <status> := STATUS ROUTING
66
- | SUBJECT
67
- | STATUS RINGING
68
- | STATUS INPROGRESS
69
- | DURATION <integer>
70
- | STATUS FINISHED
71
- === GET CALL
72
- Command: GET CALL <id> property
73
- Response: CALL <id> property <value>
74
- === SET CALL INPROGRESS
75
- === SET CALL FINISHED
76
- === SET CALL ONHOLD
77
- === SET CALL JOIN CONFERENCE
78
- === SET CALL DTMF
79
- === SET CALL SEEN
80
-
81
- == Voicemail
82
-
83
- === VOICEMAIL
84
- === OPEN VOICEMAIL
85
- === ALTER VOICEMAIL
86
- == Chat
87
- === CHAT CREATE
88
- === CHATMESSAGE
89
- === ALTER CHAT SETTOPIC
90
- === ALTER CHAT ADDMEMBERS
91
- === ALTER CHAT LEAVE
92
- === GET CHAT CHATMESSAGES
93
- === GET CHAT RECENTCHATMESSAGES
94
- === SET CHATMESSAGE SEEN
95
-
96
- == Search
97
-
98
- === SEARCH
99
- <search> := SEARCH <search-args>
100
- <search-args> := USERS
101
- | FRIENDS
102
- | CALLS <target>
103
- | ACTIVECALLS
104
- | MISSEDCALLS
105
- | VOICEMAILS
106
- | CHATS
107
- | MISSEDCHATS
108
- | ACTIVECHATS
109
- | RECENTCHATS
110
- | BOOKMARKEDCHATS
111
- | CHATMESSAGES [<target>]
112
- | MISSEDCHATMESSAGES
113
- | MESSAGES [<target>]
114
- | MISSEDMESSAGES
115
- | USERWAITINGMYAUTHORIZATION
116
-
117
- == History
118
-
119
- === CLEAR HISTORY
120
-
121
- === CLEAR VOICEMAILHISTORY
122
-
123
- === CLEAR CALLHISTORY
124
-
125
- == User interface
126
-
127
- == AP2AP
72
+ Have fun!!
128
73
 
74
+ Akimichi Tatsukawa
data/bin/iskype.rb CHANGED
@@ -3,9 +3,11 @@ $:.unshift File.join(File.dirname(__FILE__))
3
3
 
4
4
  require 'readline'
5
5
  require 'optparse'
6
+ require 'logger'
6
7
  require "lib/skyper.rb"
7
8
 
8
9
  module SkypeR
10
+ LOGGER = nil
9
11
  class Arguments < Hash
10
12
  def initialize(args)
11
13
  super()
@@ -16,6 +18,14 @@ module SkypeR
16
18
  self[:name] = string || '$'
17
19
  end
18
20
 
21
+ opts.on('-l', '--log [STRING]', 'log file path') do |string|
22
+ self[:log] = string || '$'
23
+ end
24
+
25
+ opts.on('-p', '--parse', 'parsing enabled') do
26
+ self[:parse] = true
27
+ end
28
+
19
29
  opts.on_tail('-h', '--help', 'display this help') do
20
30
  puts opts
21
31
  exit
@@ -26,18 +36,22 @@ module SkypeR
26
36
  end
27
37
 
28
38
  class REPL
29
- def initialize(name)
39
+ def initialize(name, log = nil, parse = false)
30
40
  @debug = false
31
41
  @application = Service::Application.new(name)
42
+ @headers = []
43
+ @logger = Logger.new(log ? log : $stderr)
32
44
  @commands = {
33
45
  'd' => ['toggle debug mode.',
34
46
  proc { @debug = !@debug; puts "debug is #{@debug?'on':'off'}" }],
35
- 'h' => ['"h foo.h": bring in a C header.',
36
- proc { |args| @headers << args }],
47
+ 'logger' => ['"logger on": bring logger active.',
48
+ proc {|args|
49
+ @headers << args
50
+ }],
37
51
  'l' => ['"l m": bring in a C library.',
38
52
  proc { |args| @libraries << args }],
39
- 't' => ['test if the repl is ok by running a printf through it.',
40
- proc { xsb_command('printf("repl is ok\n");') }],
53
+ 'test' => ['test if the repl is ok by running a printf through it.',
54
+ proc { xsb_command('printf("repl is ok\n");') }],
41
55
  's' => ['cause a segfault to let crepl attempt to recover.',
42
56
  proc do
43
57
  puts 'attempting segfault'
@@ -47,30 +61,24 @@ module SkypeR
47
61
  }
48
62
  end
49
63
 
50
- # Generate code from snippet, writing it to out.
51
- def generate_code(name, out)
52
- out.puts "#include <stdio.h>"
53
- @headers.each do |header|
54
- out.puts "#include \"#{header}\""
55
- end
56
- @externs.each do |extern|
57
- out.puts "extern #{extern}"
58
- end
59
-
60
- out.puts "}"
61
- end
62
64
 
63
65
  def skype_command(code)
64
66
  command = Service::Command.new(code)
65
- @application.invoke_with_timeout(command, 60)
67
+ if @application.validate(command)
68
+ @application.invoke(command, 40)
69
+ else
70
+ "Parse Error"
71
+ end
66
72
  end
67
73
 
68
74
  def skype_exit
69
75
  raise
70
76
  end
71
77
 
78
+
72
79
  def show_help
73
80
  puts <<-EOT
81
+ Not in use, yet.
74
82
  Type C statements and declarations as you would in a normal program.
75
83
  Type a variable name by itself to see its value.
76
84
 
@@ -91,15 +99,17 @@ Commands start with a . and are as follows:
91
99
  if line.empty?
92
100
  next
93
101
  else
102
+ @logger.debug("INPUT> #{line}")
94
103
  case line
95
104
  when /^exit$/
96
105
  puts "See you again."
106
+ @logger.debug("OUTPUT> See you again.")
97
107
  return
98
108
  else
99
109
  result = skype_command(line)
100
110
  puts "=> #{result}"
111
+ @logger.debug("OUTPUT> #{result}")
101
112
  end
102
-
103
113
  end
104
114
  Readline::HISTORY.push(line)
105
115
  end
@@ -110,19 +120,18 @@ end # of SkypeR
110
120
 
111
121
  begin
112
122
  arguments = SkypeR::Arguments.new(ARGV)
113
- p "arguments[:name] = #{arguments[:name]}"
114
123
  if name = arguments[:name]
115
- repl = SkypeR::REPL.new(name)
124
+ repl = SkypeR::REPL.new(name, arguments[:log], arguments[:parse])
116
125
  else
117
- repl = SkypeR::REPL.new('test')
126
+ repl = SkypeR::REPL.new('test', 'log/iskype.log', arguments[:parse])
118
127
  end
119
128
  repl.input_loop
120
- rescue Exception => e
121
- puts e.message
122
- puts "Backtrace:"
123
- e.backtrace.each {|line|
124
- puts line
125
- }
129
+ # rescue Exception => e
130
+ # puts e.message
131
+ # puts "Backtrace:"
132
+ # e.backtrace.each {|line|
133
+ # puts line
134
+ # }
126
135
  end
127
136
 
128
137
 
data/bin/iskype.rb~ CHANGED
@@ -1,2 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__))
3
+
4
+ require 'readline'
5
+ require 'optparse'
6
+ require 'logger'
7
+ require "lib/skyper.rb"
8
+
9
+ module SkypeR
10
+ LOGGER = nil
11
+ class Arguments < Hash
12
+ def initialize(args)
13
+ super()
14
+ # default values
15
+ opts = ::OptionParser.new do |opts|
16
+ opts.banner = "Usage: #$0 [options]"
17
+ opts.on('-n', '--name [STRING]', 'application name to access Skype') do |string|
18
+ self[:name] = string || '$'
19
+ end
20
+
21
+ opts.on('-l', '--log [STRING]', 'log file path') do |string|
22
+ self[:log] = string || '$'
23
+ end
24
+
25
+ opts.on_tail('-h', '--help', 'display this help') do
26
+ puts opts
27
+ exit
28
+ end
29
+ end
30
+ opts.parse(args)
31
+ end
32
+ end
33
+
34
+ class REPL
35
+ def initialize(name, log = nil)
36
+ @debug = false
37
+ @application = Service::Application.new(name)
38
+ @headers = []
39
+ @logger = Logger.new(log ? log : $stderr)
40
+ @commands = {
41
+ 'd' => ['toggle debug mode.',
42
+ proc { @debug = !@debug; puts "debug is #{@debug?'on':'off'}" }],
43
+ 'logger' => ['"logger on": bring logger active.',
44
+ proc {|args|
45
+ @headers << args
46
+ }],
47
+ 'l' => ['"l m": bring in a C library.',
48
+ proc { |args| @libraries << args }],
49
+ 'test' => ['test if the repl is ok by running a printf through it.',
50
+ proc { xsb_command('printf("repl is ok\n");') }],
51
+ 's' => ['cause a segfault to let crepl attempt to recover.',
52
+ proc do
53
+ puts 'attempting segfault'
54
+ xsb_command '*((char*)0) = 0;'
55
+ end],
56
+ 'help' => ['show help on commands.', proc { show_help }]
57
+ }
58
+ end
59
+
60
+
61
+ def skype_command(code)
62
+ command = Service::Command.new(code)
63
+ @application.invoke(command, 40)
64
+ # @application.invoke_with_timeout(command, 40)
65
+ end
66
+
67
+ def skype_exit
68
+ raise
69
+ end
70
+
71
+
72
+ def show_help
73
+ puts <<-EOT
74
+ Not in use, yet.
75
+ Type C statements and declarations as you would in a normal program.
76
+ Type a variable name by itself to see its value.
77
+
78
+ Commands start with a . and are as follows:
79
+ EOT
80
+ cmds = @commands.keys.sort
81
+ len = cmds.map{|c|c.length}.max
82
+ @commands.keys.sort.each do |cmd|
83
+ printf(" %-#{len}s %s\n", cmd, @commands[cmd][0])
84
+ end
85
+ end
86
+
87
+ def input_loop
88
+ loop do
89
+ line = Readline.readline('Skype> ')
90
+ break unless line
91
+ line.chomp!
92
+ if line.empty?
93
+ next
94
+ else
95
+ @logger.debug("INPUT> #{line}")
96
+ case line
97
+ when /^exit$/
98
+ puts "See you again."
99
+ @logger.debug("OUTPUT> See you again.")
100
+ return
101
+ else
102
+ result = skype_command(line)
103
+ puts "=> #{result}"
104
+ @logger.debug("OUTPUT> #{result}")
105
+ end
106
+ end
107
+ Readline::HISTORY.push(line)
108
+ end
109
+ @interpreter.close
110
+ end # of Command
111
+ end # of Service
112
+ end # of SkypeR
113
+
114
+ begin
115
+ arguments = SkypeR::Arguments.new(ARGV)
116
+ # p "arguments[:name] = #{arguments[:name]}"
117
+ if name = arguments[:name]
118
+ repl = SkypeR::REPL.new(name, arguments[:log])
119
+ else
120
+ repl = SkypeR::REPL.new('test', 'log/iskype.log')
121
+ end
122
+ repl.input_loop
123
+ rescue Exception => e
124
+ puts e.message
125
+ puts "Backtrace:"
126
+ e.backtrace.each {|line|
127
+ puts line
128
+ }
129
+ end
130
+
131
+
132
+
133
+
1
134
 
2
135
 
metadata CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.9.3
3
3
  specification_version: 1
4
4
  name: SkypeR
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2007-08-12 00:00:00 +09:00
6
+ version: 0.0.3
7
+ date: 2008-01-08 00:00:00 +09:00
8
8
  summary: a SkypeAPI library for Ruby
9
9
  require_paths:
10
10
  - lib
11
11
  email: akimichi_tatsukawa@nifty.com
12
- homepage: http://akimichi.homeunix.net/~emile/aki/hiki.cgi?SkypeR
12
+ homepage: http://rubyforge.org/projects/skyper/
13
13
  rubyforge_project:
14
14
  description:
15
15
  autorequire: skyper
@@ -29,10 +29,10 @@ post_install_message:
29
29
  authors:
30
30
  - Akimichi Tatsukawa
31
31
  files:
32
+ - bin/iskype.rb
32
33
  - bin/iskype.rb~
33
- - bin/rbus_send
34
34
  - bin/rbus_skype.rb
35
- - bin/iskype.rb
35
+ - bin/rbus_send
36
36
  - README
37
37
  test_files: []
38
38
 
@@ -56,3 +56,12 @@ dependencies:
56
56
  - !ruby/object:Gem::Version
57
57
  version: 0.2.0
58
58
  version:
59
+ - !ruby/object:Gem::Dependency
60
+ name: yaparc
61
+ version_requirement:
62
+ version_requirements: !ruby/object:Gem::Version::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.0.7
67
+ version: