|
|
Line 1: |
Line 1: |
− | '''VoiceServices plug-ins''' are plugins to the iOS voice dial feature. They provide possible results within plists and receive recognized results. | + | The NSAutoreleasePool class is a thin wrapper around the '''NSPushAutoreleasePool''' and '''NSPopAutoreleasePool''' functions. |
| | | |
− | There is currently no plugin loader available. Developers have to "hard-code" their plugins by writing them in [[/System/Library/VoiceServices/PlugIns]].
| + | <source lang="objc"> |
− | | + | #ifdef __cplusplus |
− | Currently, there is little known about the internals of VoiceServices plugins and their state of usability, especially on recent iOS versions.
| + | extern "C" { |
− | | + | #endif |
− | == iOS 6 ==
| + | void *NSPushAutoreleasePool(NSUInteger capacity); |
− | In iOS 6 VoiceServices plugins can easily be loaded by creating an appropriate folder in [[/System/Library/VoiceServices/PlugIns]]. Plugins are slightly extended bundles and always have the suffix <tt>.vsplugin</tt>.
| + | void NSPopAutoreleasePool(void* token); |
− | | + | #ifdef __cplusplus |
− | === Info.plist ===
| + | } |
− | The bundle contains an Info.plist and its typical elements, like <tt>CFBundleIdentifier</tt>.
| + | #endif |
− | | + | </source> |
− | Additional keys are:
| |
− | | |
− | <code>VSRecognitionVersion</code> which contains a string. Most probably an internal version identifier. The Base plugin currently has 4.0 as value.
| |
− | | |
− | <code>VSRecognitionModels</code> which contains an array of dictionaries.
| |
− | | |
− | ==== VSRecognitionModels ====
| |
− | Every dictionary can contain the following keys:
| |
− | | |
− | {| class="wikitable"
| |
− | |-
| |
− | ! Key
| |
− | ! Value type
| |
− | ! Function
| |
− | |-
| |
− | | VSRecognitionModelIdentifier
| |
− | | String
| |
− | | Obligatory. Complete function unknown, seems to be some kind of internal identifier to sort all the different recognition handlers.
| |
− | |-
| |
− | | VSRecognitionModelFileName
| |
− | | String
| |
− | | Obligatory. The file name of all the possible recognition results. A localized suffix will be added by the plugin loader, for example if your name is "org.h6nry.test.plist" and you are french, it will search for a file named "org.h6nry.test-fr.plist".
| |
− | |-
| |
− | | VSRecognitionResultHandler
| |
− | | String
| |
− | | Obligatory. The name of the class which is implemented in the bundle executable and which should handle the results for all the recognition results provided in VSRecognitionModelFileName.
| |
− | |}
| |
| | | |
− | === VSRecognitionModelFileName plist files ===
| + | Example: |
− | These files are stored directly in the base directory of the bundle and are localized with "-lang-code" suffixes.
| |
− | They have the following base structure:
| |
− | <source lang=xml>
| |
− | (xml and doctype plist references)
| |
− | <dict>
| |
− | <key>VSRecognitionClasses</key>
| |
− | <array>
| |
− | <dict>
| |
− | <key>VSRecognitionClassIdentifier</key> <string>myClassIdentifier</string> <!-- Used for the VSRecognitionSequences array -->
| |
− | <key>VSRecognitionClassElements</key> <!-- Array of words which are going to be recognized -->
| |
− | <array>
| |
− | <string>string 1</string>
| |
− | <string>string 2</string>
| |
− | <string>Hello</string>
| |
− | <array>
| |
− | </dict>
| |
− | </array>
| |
| | | |
− | <key>VSRecognitionSequences</key> <!-- Specifies in which sequence all the just defined keywords are spoken -->
| + | <source lang="objc"> |
− | <array>
| + | static void MyMethod() |
− | <dict>
| + | { |
− | <key>VSRecognitionSequenceElements</key>
| + | void *pool = NSPushAutoreleasePool(0); |
− | <array>
| + | [[[NSObject alloc] init] autorelease]; |
− | <string>myClassIdentifier</string>
| + | NSPopAutoreleasePool(pool); |
− | <string>anotherClassIdentifier</string>
| + | } |
− | </array>
| |
− | </dict>
| |
− | <dict>
| |
− | <key>VSRecognitionSequenceElements</key>
| |
− | <array>
| |
− | <string>someOtherClassIdentifier</string>
| |
− | <string>anotherClassIdentifier</string>
| |
− | </array>
| |
− | </dict>
| |
− | </array> | |
− | </dict>
| |
| </source> | | </source> |
− | This is just the very basic structure, there are other keys, objects and identifiers. Most of them can be obtained from the existing voice plugins, they are quite self-explanatory.
| |
| | | |
− | === The executable ===
| + | The "capacity" argument of NSPushAutoreleasePool only serves as a hint. It is unused in the current implementation. |
− | The executable should implement all of the classes specified in the <tt>VSRecognitionResultHandler</tt> keys. These classes should conform to the VSRecognitionResultHandler protocol, which can be found in class-dumps of SpringBoard. It is being linked to the VoiceServices private framework.
| |
| | | |
− | == External links == | + | {{occlass|library=Foundation.framework}} |
− |
| |
− | * http://arstechnica.com/apple/2010/02/iphone-voiceservices-looking-under-the-hood/
| |