siriproxy 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ # load plugins
6
+ require 'yaml'
7
+ require 'ostruct'
8
+
9
+ if !File.exists?(File.expand_path('~/.siriproxy/config.yml'))
10
+ $stderr.puts "config.yml not found. Copy config.example.yml to config.yml, then modify it."
11
+ exit 1
12
+ end
13
+
14
+ gem 'cora', '0.0.4'
15
+
16
+ config = OpenStruct.new(YAML.load_file(File.expand_path('~/.siriproxy/config.yml')))
17
+ if config.plugins
18
+ config.plugins.each do |plugin|
19
+ if plugin.is_a? String
20
+ gem "siriproxy-#{plugin.downcase}"
21
+ else
22
+ gem "siriproxy-#{plugin['gem'] || plugin['name'].downcase}", :path => plugin['path'], :git => plugin['git'], :branch => plugin['branch'], :require => plugin['require']
23
+ end
24
+ end
25
+ end
data/README.md ADDED
@@ -0,0 +1,262 @@
1
+ Siri Proxy
2
+ ==========
3
+
4
+ About
5
+ -----
6
+ Siri Proxy is a proxy server for Apple's Siri "assistant." The idea is to allow for the creation of custom handlers for different actions. This can allow developers to easily add functionality to Siri.
7
+
8
+ The main example I provide is a plugin to control [my thermostat](http://www.radiothermostat.com/latestnews.html#advanced) with Siri. It responds to commands such as, "What's the status of the thermostat?", or "Set the thermostat to 68 degrees", or even "What's the inside temperature?"
9
+
10
+ Notice About Plugins
11
+ --------------------
12
+
13
+ We recently changed the way plugins work very significantly. That being the case, your old plugins won't work.
14
+
15
+ New plugins should be independent Gems. Take a look at the included [example plugin](https://github.com/plamoni/SiriProxy/tree/master/plugins/siriproxy-example) for some inspiration. We will try to keep that file up to date with the latest features.
16
+
17
+ The State of This Project
18
+ -------------------------
19
+
20
+ Please remember that this project is super-pre-alpha right now. If you're not a developer with a good bit of experience with networks, you're probably not even going to get the proxy running. But if you do (we are willing to help to an extent, check the IRC chat and my Twitter feed [@plamoni](http://www.twitter.com/plamoni)), then test out building a plugin. It's very easy to do and takes almost no time at all for most experienced developers. Check the demo videos and other plugins below for inspiration!
21
+
22
+
23
+ Find us on IRC
24
+ --------------
25
+
26
+ We now have an IRC channel. Check out the #SiriProxy channel on irc.freenode.net.
27
+
28
+ Demo Video
29
+ -----------
30
+
31
+ See the system in action here: [http://www.youtube.com/watch?v=AN6wy0keQqo](http://www.youtube.com/watch?v=AN6wy0keQqo)
32
+
33
+ More Demo Videos and Other Plugins
34
+ ----------------------------------
35
+
36
+ For a list of current plugins and some more demo videos, check the [Plugins page](https://github.com/plamoni/SiriProxy/wiki/Plugins) on the wiki.
37
+
38
+ Set-up Instructions
39
+ -------------------
40
+
41
+ **Video of a complete installation on Ubuntu 11.10**
42
+
43
+ [http://www.youtube.com/watch?v=GQXyJR6mOk0](http://www.youtube.com/watch?v=GQXyJR6mOk0)
44
+
45
+ This is a video of a complete start-to-finish installation on a fresh install of Ubuntu 11.10.
46
+
47
+ The commands used in the video can be found at [https://gist.github.com/1428474](https://gist.github.com/1428474).
48
+
49
+ **Set up DNS**
50
+
51
+ Before you can use SiriProxy, you must set up a DNS server on your network to forward requests for guzzoni.apple.com to the computer running the proxy (siriproxy uses Google's public DNS servers to resolve guzzoni.apple.com, so it may use your forwarding DNS server). I recommend dnsmasq for this purpose. It's easy to get running and can easily handle this sort of behavior. ([http://www.youtube.com/watch?v=a9gO4L0U59s](http://www.youtube.com/watch?v=a9gO4L0U59s))
52
+
53
+ **Set up RVM and Ruby 1.9.3**
54
+
55
+ If you don't already have Ruby 1.9.3 installed through RVM, please do so in order to make sure you can follow the steps later. Experts can ignore this. If you're unsure, follow these directions carefully:
56
+
57
+ 1. Download and install RVM (if you don't have it already):
58
+ * Download/install RVM:
59
+ `bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)`
60
+ * Activate RVM:
61
+ `[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"`
62
+ * (optional, but useful) Add RVM to your .bash_profile:
63
+ `echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile`
64
+ 2. Install Ruby 1.9.3 (if you don't have it already):
65
+ `rvm install 1.9.3`
66
+ 3. Set RVM to use/default to 1.9.3:
67
+ `rvm use 1.9.3 --default`
68
+
69
+ **Set up SiriProxy**
70
+
71
+ Clone this repo locally, then navigate into the SiriProxy directory (the root of the repo). Then follow these instructions carefully. Note that nothing needs to be (or should be) done as root until you launch the server:
72
+
73
+ 1. Install Rake and Bundler:
74
+ `rvmsudo gem install rake bundler`
75
+ 2. Install SiriProxy gem (do this from your SiriProxy directory):
76
+ `rake install`
77
+ 3. Make .siriproxy directory:
78
+ `mkdir ~/.siriproxy`
79
+ 4. Move default config file to .siriproxy (if you need to make configuration changes, do that now by editing the config.yml):
80
+ `cp ./config.example.yml ~/.siriproxy/config.yml`
81
+ 5. Generate certificates:
82
+ `siriproxy gencerts`
83
+ 6. Install `~/.siriproxy/ca.pem` on your phone. This can easily be done by emailing the file to yourself and clicking on it in the iPhone email app. Follow the prompts.
84
+ 7. Bundle SiriProxy (this should be done every time you change the config.yml):
85
+ `siriproxy bundle`
86
+ 8. Start SiriProxy (must start as root because it uses a port < 1024):
87
+ `rvmsudo siriproxy server`
88
+ 9. Test that the server is running by saying "Test Siri Proxy" to your phone.
89
+
90
+ Note: on some machines, rvmsudo changes "`~`" to "`/root/`". This means that you may need to symlink your "`.siriproxy`" directory to "`/root/`" in order to get the application to work:
91
+
92
+ sudo ln -s ~/.siriproxy /root/.siriproxy
93
+
94
+ **Updating SiriProxy**
95
+
96
+ Once you're up and running, if you modify the code, or you want to grab the latest code from GitHub, you can do that easily using the "siriproxy update" command. Here's a couple of examples:
97
+
98
+ siriproxy update
99
+
100
+ Installs the latest code from the [master] branch on GitHub.
101
+
102
+ siriproxy update /path/to/SiriProxy
103
+
104
+ Installs the code from /path/to/SiriProxy
105
+
106
+ siriproxy update -b dev
107
+
108
+ Installs the latest code from the development branch (called "dev") on GitHub.
109
+
110
+
111
+ FAQ
112
+ ---
113
+
114
+ **Will this let me run Siri on my iPhone 4, iPod Touch, iPhone 3G, Microwave, etc?**
115
+
116
+ No. Please stop asking.
117
+
118
+ **What is your opinion on h1siri, public SiriProxy servers, and other Siri "ports"?**
119
+
120
+ Glad you asked! Watch this: [http://youtu.be/Y_Q6PfxBSbA](http://youtu.be/Y_Q6PfxBSbA)
121
+
122
+ **How do I generate the certificate?**
123
+
124
+ Certificates can now be easily generated using `siriproxy gencerts` once you install the SiriProxy gem. See the instructions above.
125
+
126
+ **How do I set up a DNS server to forward Guzzoni.apple.com traffic to my computer?**
127
+
128
+ Check out my video on this:
129
+
130
+ [http://www.youtube.com/watch?v=a9gO4L0U59s](http://www.youtube.com/watch?v=a9gO4L0U59s)
131
+
132
+ **Will this work outside my home network?**
133
+
134
+ No, it won't. But, as suggested by STBullard on YouTube, you COULD VPN into your home network from outside your house in order to make this work. That would not require a jailbreak. Of course, it also means ALL your traffic gets funneled through your home network. The nice thing about adding an entry to your /etc/hosts file (on a jailbroken phone) is that it funnels only Siri traffic through your home network, and not all your traffic.
135
+
136
+ **Can you provide me with an iPhone 4S UDID?**
137
+
138
+ No. Don't even ask.
139
+
140
+ **I'm getting a bunch of "[Info - Guzzoni] Object: SessionValidationFailed" messages. What's wrong?!**
141
+
142
+ You're probably not using an iPhone 4S. You need to be using an iPhone 4S (or have a UDID you can sub in) in order to make use of SiriProxy. Sorry, this is not designed to be a way around that limitation. (Thanks to [@brownie545](http://www.twitter.com/brownie545) for providing information on what happens when you use a non-iPhone 4S)
143
+
144
+ **How do I remove the certificate from my iPhone when I'm done?**
145
+
146
+ Just go into your phone's Settings app, then go to "General->Profiles." Your CA will probably be the only thing listed under "Configuration Profiles." It will be listed as "SiriProxyCA" Just click it and click "Remove" and it will be removed. (Thanks to [@tidegu](http://www.twitter.com/tidegu) for asking!)
147
+
148
+ **Does this require a jailbreak?**
149
+
150
+ No. The only action you need to take on the phone is to install the root CA's public key.
151
+
152
+ **Using Siri causes a whole bunch of the following messages, followed by SiriProxy crashing!**
153
+
154
+ Create server for iPhone connection
155
+ start conn #<SiriProxy::Connection::Iphone:0x966a400 @signature=880, @processed_headers=false, @output_buffer="", @input_buffer="", @unzipped_input="", @unzipped_output="", @unzip_stream=#<Zlib::Inflate:0x9669640>, @zip_stream=#<Zlib::Deflate:0x96695dc>, @consumed_ace=false, @name="iPhone", @ssled=false>
156
+ [Info - Plugin Manager] Plugins loaded: [#<SiriProxy::Plugin::Example:0x968a818 @manager=#<SiriProxy::PluginManager:0x9685750 @plugins=[...]>>]
157
+
158
+ This is actually really common (but can be tricky to fix). The problem is that your SiriProxy server is using your tainted DNS server. So what happens is this:
159
+
160
+ 1. Your iPhone connects to your server, thinking it's `guzzoni.apple.com`
161
+ 2. Your server connects to *itself*, thinking that *it's* `guzzoni.apple.com`
162
+ 3. Your server thinks another iPhone has connected, and repeats step 2.
163
+
164
+ This goes on forever, or at least a second or two before the server up and dies. The trick is that you need to make sure your server isn't connecting to itself when it requests a connection to `guzzoni.apple.com`. This is actually the default behavior, but many people accidentally mess things up by either (1) setting up their server to use itself as a DNS server (while using dnsmasq to taint the entry for `guzzoni.apple.com`), or (2) putting their server on a network where the DNS server issued by DHCP is tainted to point to the wrong `guzzoni.apple.com`.
165
+
166
+ So the fix for this varies based on your setup, but one possible fix for scenario 1 (above) on many *NIX machines is to edit `/etc/resolve.conf` and change the `nameserver` entry to `8.8.8.8` (one of Google's public DNS servers). Do this and then restart networking (or just restart the computer) and things should start working.
167
+
168
+ Your network setup may be different. This is THE most complex part of setting up SiriProxy (getting DNS set up correctly). So once you have this working, you are probably home free. Keep with it, good luck, and have fun!
169
+
170
+
171
+ Running SiriProxy as an unprivileged user
172
+ -----------------------------------------
173
+
174
+ Given that SiriProxy is a bit of a hack and very unstable, it's probably a good idea to not run it as root. This is especially true if you're allowing access to your server from outside your network. Doing this isn't actually that hard, as SiriProxy doesn't need access to anything privileged.
175
+
176
+ The only trick is that Siri expects the server to be running on port 443, and only privileged users can open ports below 1024 on *NIX operating systems. So I work around this by running SiriProxy on port 2000 and redirecting traffic to that port using iptables.
177
+
178
+ **Step 1: Set up an account**
179
+
180
+ I just set up an account called "siriproxy". I made sure it wasn't a "sudoer" (on my computer, that means keep it out of the "sudo" group). I also think it's a good idea to refrain from giving it login privileges. But do as I say on that one, not as I do.
181
+
182
+ **Step 2: Set up iptables/ufw**
183
+
184
+ I run UFW on my machine, which is pretty much a wrapper on iptables. I tossed in the following at the top of my `/etc/ufw/before.rules`:
185
+
186
+ *nat
187
+ :PREROUTING ACCEPT [0:0]
188
+ -A PREROUTING --dst 10.0.0.3 -p tcp --dport 443 -j REDIRECT --to-port 2000
189
+ COMMIT
190
+
191
+ The IP referenced (10.0.0.3) is the IP of the computer running SiriProxy. Since this computer is being used as a wireless AP, it's important to only redirect traffic targeted directly at the server, otherwise all traffic to 443/tcp on my wifi network would be incorrectly redirected.
192
+
193
+ I also made sure to open up 2000/tcp to allow traffic:
194
+
195
+ sudo ufw allow 2000/tcp
196
+
197
+ **Step 3: Set up upstart script**
198
+
199
+ The full explanation of this is shown below. It's a handy thing to do by itself. It allows me to have SiriProxy start on boot and also allows me to easily control it using commands like `start siriproxy` and `stop siriproxy`.
200
+
201
+ Running SiriProxy via Upstart
202
+ -----------------------------
203
+
204
+ Here's the upstart script I created for my home SiriProxy server. It respawns on a crash because SiriProxy is delicate and likes to crash. My server is running BackTrack 5 (a derivative of Ubuntu 10.04, I believe) and I use it as my wireless access point, making it an obvious location for SiriProxy:
205
+
206
+ description "SiriProxy server"
207
+
208
+ #Not sure if this is right, but it seems to work.
209
+ start on (started networking
210
+ and filesystem)
211
+
212
+ stop on runlevel [!023456]
213
+
214
+ respawn
215
+
216
+ exec start-stop-daemon --start --chuid siriproxy --exec /home/siriproxy/src/SiriProxy/siriproxy2000.sh
217
+
218
+ Here are the contents of `siriproxy2000.sh` (as referenced above):
219
+
220
+ #!/bin/bash
221
+
222
+ #make sure that rvm is set up
223
+ [[ -s "/home/siriproxy/.rvm/scripts/rvm" ]] && . "/home/siriproxy/.rvm/scripts/rvm"
224
+
225
+ #feel free to insert logging if needed.
226
+ siriproxy server --port 2000 > /dev/null 2>&1
227
+
228
+ Note that I run my server on port 2000 as the siriproxy user. See the comments above about running as an unprivileged user.
229
+
230
+
231
+ Acknowledgements
232
+ ----------------
233
+ I really can't give enough credit to [Applidium](http://applidium.com/en/news/cracking_siri/) and the [tools they created](https://github.com/applidium/Cracking-Siri). While I've been toying with Siri for a while, their proof of concept for intercepting and interpreting the Siri protocol was invaluable. Although all the code included in the project (so far) is my own, much of the base logic behind my code is based on the sample code they provided. They do great work.
234
+
235
+ I also want to give a shout-out to [Arch Reactor](http://www.archreactor.org) - my local Hackerspace. Hackerspaces are a fantastic place to go learn about stuff like this. I was able to get some help from folks there, and more importantly, I got encouragement to do stuff like this. Check [Hackerspaces.org](http://www.hackerspaces.org) for a hackerspace in your area and make sure to check it out!
236
+
237
+ Regarding Licensing
238
+ -------------------
239
+
240
+ It's a pain. MIT seems nice. Go hunt through the commit history if you're interested in knowing about SiriProxy's long and frustrating licensing history.
241
+
242
+ License (MIT)
243
+ -------------
244
+
245
+ SiriProxy - A tampering proxy server for the Siri (Ace) Protocol.
246
+ Copyright (c) 2013 Pete Lamonica
247
+
248
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
249
+
250
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
251
+
252
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
253
+
254
+ Disclaimer
255
+ ----------
256
+ I'm not affiliated with Apple in any way. They don't endorse this application. They own all the rights to Siri (and all associated trademarks).
257
+
258
+ This software is provided as-is with no warranty whatsoever. Apple could do things to block this kind of behavior if they want. Also, if you cause problems (by sending lots of trash to the Guzzoni servers or anything), I fully support Apple's right to ban your UDID (making your phone unable to use Siri). They can, and I wouldn't blame them if they do.
259
+
260
+ I'm a huge fan of Apple and the work that they do. Siri is a very cool feature and I'm pretty excited to explore it and add functionality. Please refrain from using this software for anything malicious.
261
+
262
+ Also, this is my first project done in Ruby. Please don't be too critical of my code.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require "bundler/gem_tasks"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/*.rb']
8
+ t.verbose = true
9
+ end
data/bin/siriproxy ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ require 'siriproxy/command_line'
5
+
6
+ SiriProxy::CommandLine.new
@@ -0,0 +1,30 @@
1
+ listen: 0.0.0.0
2
+ port: 443
3
+ log_level: 1
4
+ plugins:
5
+ # NOTE: run bundle after changing plugin configurations to update required gems
6
+
7
+ - name: 'Example'
8
+ path: './plugins/siriproxy-example'
9
+
10
+ # - name: 'Thermostat'
11
+ # git: 'git://github.com/plamoni/SiriProxy-Thermostat.git'
12
+ # host: '192.168.2.71'
13
+
14
+ # - name: 'Twitter'
15
+ # path: './plugins/siriproxy-twitter' # path works just like specifing in gemfile
16
+ # consumer_key: "YOUR_KEY"
17
+ # consumer_secret: "YOUR_SECRET"
18
+ # oauth_token: "YOUR_TOKEN"
19
+ # oauth_token_secret: "YOUR_TOKEN_SECRET"
20
+
21
+ # Note: Eliza should not be run with other plugins
22
+ # - name: 'Eliza'
23
+ # path: './plugins/siriproxy-eliza' # path works just like specifing in gemfile
24
+
25
+ # Below are not actual plugins, just further example of config options
26
+
27
+ # - SimplePlugin # simple syntax for plugins that are in rubygems and have no config
28
+
29
+ # - name: 'AnotherPlugin'
30
+ # git: 'git://github.com/netpro2k/SiriProxy-AnotherPlugin.git' # git works just like specifying in Gemfile
@@ -0,0 +1,331 @@
1
+ require 'rubygems'
2
+ require 'uuidtools'
3
+
4
+ def generate_siri_utterance(ref_id, text, speakableText=text, listenAfterSpeaking=false)
5
+ object = SiriAddViews.new
6
+ object.make_root(ref_id)
7
+ object.views << SiriAssistantUtteranceView.new(text, speakableText, "Misc#ident", listenAfterSpeaking)
8
+ return object.to_hash
9
+ end
10
+
11
+ def generate_request_completed(ref_id, callbacks=nil)
12
+ object = SiriRequestCompleted.new()
13
+ object.callbacks = callbacks if callbacks != nil
14
+ object.make_root(ref_id)
15
+ return object.to_hash
16
+ end
17
+
18
+ class SiriObject
19
+ attr_accessor :klass, :group, :properties
20
+
21
+ def initialize(klass, group)
22
+ @klass = klass
23
+ @group = group
24
+ @properties = {}
25
+ end
26
+
27
+ #watch out for circular references!
28
+ def to_hash
29
+ hash = {
30
+ "class" => self.klass,
31
+ "group" => self.group,
32
+ "properties" => {}
33
+ }
34
+
35
+ (hash["refId"] = ref_id) rescue nil
36
+ (hash["aceId"] = ace_id) rescue nil
37
+
38
+ properties.each_key { |key|
39
+ if properties[key].class == Array
40
+ hash["properties"][key] = []
41
+ self.properties[key].each { |val| hash["properties"][key] << (val.to_hash rescue val) }
42
+ else
43
+ hash["properties"][key] = (properties[key].to_hash rescue properties[key])
44
+ end
45
+ }
46
+
47
+ hash
48
+ end
49
+
50
+ def make_root(ref_id=nil, ace_id=nil)
51
+ self.extend(SiriRootObject)
52
+
53
+ self.ref_id = (ref_id || random_ref_id)
54
+ self.ace_id = (ace_id || random_ace_id)
55
+ end
56
+ end
57
+
58
+ def add_property_to_class(klass, prop)
59
+ klass.send(:define_method, (prop.to_s + "=").to_sym) { |value|
60
+ self.properties[prop.to_s] = value
61
+ }
62
+
63
+ klass.send(:define_method, prop.to_s.to_sym) {
64
+ self.properties[prop.to_s]
65
+ }
66
+ end
67
+
68
+ module SiriRootObject
69
+ attr_accessor :ref_id, :ace_id
70
+
71
+ def random_ref_id
72
+ UUIDTools::UUID.random_create.to_s.upcase
73
+ end
74
+
75
+ def random_ace_id
76
+ UUIDTools::UUID.random_create.to_s
77
+ end
78
+ end
79
+
80
+ class SiriAddViews < SiriObject
81
+ def initialize(scrollToTop=false, temporary=false, dialogPhase="Completion", views=[])
82
+ super("AddViews", "com.apple.ace.assistant")
83
+ self.scrollToTop = scrollToTop
84
+ self.views = views
85
+ self.temporary = temporary
86
+ self.dialogPhase = dialogPhase
87
+ end
88
+ end
89
+ add_property_to_class(SiriAddViews, :scrollToTop)
90
+ add_property_to_class(SiriAddViews, :views)
91
+ add_property_to_class(SiriAddViews, :temporary)
92
+ add_property_to_class(SiriAddViews, :dialogPhase)
93
+
94
+ #####
95
+ # VIEWS
96
+ #####
97
+
98
+ class SiriAssistantUtteranceView < SiriObject
99
+ def initialize(text="", speakableText=text, dialogIdentifier="Misc#ident", listenAfterSpeaking=false)
100
+ super("AssistantUtteranceView", "com.apple.ace.assistant")
101
+ self.text = text
102
+ self.speakableText = speakableText
103
+ self.dialogIdentifier = dialogIdentifier
104
+ self.listenAfterSpeaking = listenAfterSpeaking
105
+ end
106
+ end
107
+ add_property_to_class(SiriAssistantUtteranceView, :text)
108
+ add_property_to_class(SiriAssistantUtteranceView, :speakableText)
109
+ add_property_to_class(SiriAssistantUtteranceView, :dialogIdentifier)
110
+ add_property_to_class(SiriAssistantUtteranceView, :listenAfterSpeaking)
111
+
112
+ class SiriMapItemSnippet < SiriObject
113
+ def initialize(userCurrentLocation=true, items=[])
114
+ super("MapItemSnippet", "com.apple.ace.localsearch")
115
+ self.userCurrentLocation = userCurrentLocation
116
+ self.items = items
117
+ end
118
+ end
119
+ add_property_to_class(SiriMapItemSnippet, :userCurrentLocation)
120
+ add_property_to_class(SiriMapItemSnippet, :items)
121
+
122
+ class SiriButton < SiriObject
123
+ def initialize(text="Button Text", commands=[])
124
+ super("Button", "com.apple.ace.assistant")
125
+ self.text = text
126
+ self.commands = commands
127
+ end
128
+ end
129
+ add_property_to_class(SiriButton, :text)
130
+ add_property_to_class(SiriButton, :commands)
131
+
132
+ class SiriAnswerSnippet < SiriObject
133
+ def initialize(answers=[], confirmationOptions=nil)
134
+ super("Snippet", "com.apple.ace.answer")
135
+ self.answers = answers
136
+
137
+ if confirmationOptions
138
+ # need to figure out good way to do API for this
139
+ self.confirmationOptions = confirmationOptions
140
+ end
141
+
142
+ end
143
+ end
144
+ add_property_to_class(SiriAnswerSnippet, :answers)
145
+ add_property_to_class(SiriAnswerSnippet, :confirmationOptions)
146
+
147
+ #####
148
+ # Items
149
+ #####
150
+
151
+ class SiriMapItem < SiriObject
152
+ def initialize(label="Apple Headquarters", location=SiriLocation.new, detailType="BUSINESS_ITEM")
153
+ super("MapItem", "com.apple.ace.localsearch")
154
+ self.label = label
155
+ self.detailType = detailType
156
+ self.location = location
157
+ end
158
+ end
159
+ add_property_to_class(SiriMapItem, :label)
160
+ add_property_to_class(SiriMapItem, :detailType)
161
+ add_property_to_class(SiriMapItem, :location)
162
+
163
+ #####
164
+ # Commands
165
+ #####
166
+
167
+ class SiriSendCommands < SiriObject
168
+ def initialize(commands=[])
169
+ super("SendCommands", "com.apple.ace.system")
170
+ self.commands=commands
171
+ end
172
+ end
173
+ add_property_to_class(SiriSendCommands, :commands)
174
+
175
+ class SiriConfirmationOptions < SiriObject
176
+ def initialize(submitCommands=[], cancelCommands=[], denyCommands=[], confirmCommands=[], denyText="Cancel", cancelLabel="Cancel", submitLabel="Send", confirmText="Send", cancelTrigger="Deny")
177
+ super("ConfirmationOptions", "com.apple.ace.assistant")
178
+
179
+ self.submitCommands = submitCommands
180
+ self.cancelCommands = cancelCommands
181
+ self.denyCommands = denyCommands
182
+ self.confirmCommands = confirmCommands
183
+
184
+ self.denyText = denyText
185
+ self.cancelLabel = cancelLabel
186
+ self.submitLabel = submitLabel
187
+ self.confirmText = confirmText
188
+ self.cancelTrigger = cancelTrigger
189
+ end
190
+ end
191
+ add_property_to_class(SiriConfirmationOptions, :submitCommands)
192
+ add_property_to_class(SiriConfirmationOptions, :cancelCommands)
193
+ add_property_to_class(SiriConfirmationOptions, :denyCommands)
194
+ add_property_to_class(SiriConfirmationOptions, :confirmCommands)
195
+ add_property_to_class(SiriConfirmationOptions, :denyText)
196
+ add_property_to_class(SiriConfirmationOptions, :cancelLabel)
197
+ add_property_to_class(SiriConfirmationOptions, :submitLabel)
198
+ add_property_to_class(SiriConfirmationOptions, :confirmText)
199
+ add_property_to_class(SiriConfirmationOptions, :cancelTrigger)
200
+
201
+ class SiriConfirmSnippetCommand < SiriObject
202
+ def initialize(request_id = "")
203
+ super("ConfirmSnippet", "com.apple.ace.assistant")
204
+ self.request_id = request_id
205
+ end
206
+ end
207
+ add_property_to_class(SiriConfirmSnippetCommand, :request_id)
208
+
209
+ class SiriCancelSnippetCommand < SiriObject
210
+ def initialize(request_id = "")
211
+ super("ConfirmSnippet", "com.apple.ace.assistant")
212
+ self.request_id = request_id
213
+ end
214
+ end
215
+ add_property_to_class(SiriCancelSnippetCommand, :request_id)
216
+
217
+ #####
218
+ # Objects
219
+ #####
220
+
221
+ class SiriLocation < SiriObject
222
+ def initialize(label="Apple", street="1 Infinite Loop", city="Cupertino", stateCode="CA", countryCode="US", postalCode="95014", latitude=37.3317031860352, longitude=-122.030089795589)
223
+ super("Location", "com.apple.ace.system")
224
+ self.label = label
225
+ self.street = street
226
+ self.city = city
227
+ self.stateCode = stateCode
228
+ self.countryCode = countryCode
229
+ self.postalCode = postalCode
230
+ self.latitude = latitude
231
+ self.longitude = longitude
232
+ end
233
+ end
234
+ add_property_to_class(SiriLocation, :label)
235
+ add_property_to_class(SiriLocation, :street)
236
+ add_property_to_class(SiriLocation, :city)
237
+ add_property_to_class(SiriLocation, :stateCode)
238
+ add_property_to_class(SiriLocation, :countryCode)
239
+ add_property_to_class(SiriLocation, :postalCode)
240
+ add_property_to_class(SiriLocation, :latitude)
241
+ add_property_to_class(SiriLocation, :longitude)
242
+
243
+ class SiriAnswer < SiriObject
244
+ def initialize(title="", lines=[])
245
+ super("Object", "com.apple.ace.answer")
246
+ self.title = title
247
+ self.lines = lines
248
+ end
249
+ end
250
+ add_property_to_class(SiriAnswer, :title)
251
+ add_property_to_class(SiriAnswer, :lines)
252
+
253
+ class SiriAnswerLine < SiriObject
254
+ def initialize(text="", image="")
255
+ super("ObjectLine", "com.apple.ace.answer")
256
+ self.text = text
257
+ self.image = image
258
+ end
259
+ end
260
+ add_property_to_class(SiriAnswerLine, :text)
261
+ add_property_to_class(SiriAnswerLine, :image)
262
+
263
+ #####
264
+ # Guzzoni Commands (commands that typically come from the server side)
265
+ #####
266
+
267
+ class SiriGetRequestOrigin < SiriObject
268
+ def initialize(desiredAccuracy="HundredMeters", searchTimeout=8.0, maxAge=1800)
269
+ super("GetRequestOrigin", "com.apple.ace.system")
270
+ self.desiredAccuracy = desiredAccuracy
271
+ self.searchTimeout = searchTimeout
272
+ self.maxAge = maxAge
273
+ end
274
+ end
275
+ add_property_to_class(SiriGetRequestOrigin, :desiredAccuracy)
276
+ add_property_to_class(SiriGetRequestOrigin, :searchTimeout)
277
+ add_property_to_class(SiriGetRequestOrigin, :maxAge)
278
+
279
+ class SiriRequestCompleted < SiriObject
280
+ def initialize(callbacks=[])
281
+ super("RequestCompleted", "com.apple.ace.system")
282
+ self.callbacks = callbacks
283
+ end
284
+ end
285
+ add_property_to_class(SiriRequestCompleted, :callbacks)
286
+
287
+ #####
288
+ # iPhone Responses (misc meta data back to the server)
289
+ #####
290
+
291
+ class SiriStartRequest < SiriObject
292
+ def initialize(utterance="Testing", handsFree=false, proxyOnly=false)
293
+ super("StartRequest", "com.apple.ace.system")
294
+ self.utterance = utterance
295
+ self.handsFree = handsFree
296
+ if proxyOnly # dont send local when false since its non standard
297
+ self.proxyOnly = proxyOnly
298
+ end
299
+ end
300
+ end
301
+ add_property_to_class(SiriStartRequest, :utterance)
302
+ add_property_to_class(SiriStartRequest, :handsFree)
303
+ add_property_to_class(SiriStartRequest, :proxyOnly)
304
+
305
+
306
+ class SiriSetRequestOrigin < SiriObject
307
+ def initialize(longitude=-122.030089795589, latitude=37.3317031860352, desiredAccuracy="HundredMeters", altitude=0.0, speed=1.0, direction=1.0, age=0, horizontalAccuracy=50.0, verticalAccuracy=10.0)
308
+ super("SetRequestOrigin", "com.apple.ace.system")
309
+ self.horizontalAccuracy = horizontalAccuracy
310
+ self.latitude = latitude
311
+ self.desiredAccuracy = desiredAccuracy
312
+ self.altitude = altitude
313
+ self.speed = speed
314
+ self.longitude = longitude
315
+ self.verticalAccuracy = verticalAccuracy
316
+ self.direction = direction
317
+ self.age = age
318
+ end
319
+ end
320
+ add_property_to_class(SiriSetRequestOrigin, :horizontalAccuracy)
321
+ add_property_to_class(SiriSetRequestOrigin, :latitude)
322
+ add_property_to_class(SiriSetRequestOrigin, :desiredAccuracy)
323
+ add_property_to_class(SiriSetRequestOrigin, :altitude)
324
+ add_property_to_class(SiriSetRequestOrigin, :speed)
325
+ add_property_to_class(SiriSetRequestOrigin, :longitude)
326
+ add_property_to_class(SiriSetRequestOrigin, :verticalAccuracy)
327
+ add_property_to_class(SiriSetRequestOrigin, :direction)
328
+ add_property_to_class(SiriSetRequestOrigin, :age)
329
+
330
+
331
+