- <APSiriSession> for public API

- Pre and Post installation scripts
- Location Daemon
This commit is contained in:
ZaidElkurdi 2015-03-17 23:42:48 -07:00
parent 369df2f065
commit 15725a9931
53 changed files with 93 additions and 218 deletions

View File

@ -1,35 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:APPluginManager.h">
</FileRef>
<FileRef
location = "group:APPluginManager.mm">
</FileRef>
<FileRef
location = "container:AssistantHeaders.h">
</FileRef>
<FileRef
location = "group:APPlugin.h">
</FileRef>
<FileRef
location = "group:APPlugin.m">
</FileRef>
<FileRef
location = "group:AssistantPlusHeaders.h">
</FileRef>
<FileRef
location = "group:APPluginSnippetViewController.xm"
assignedFileDataType = "public.objective-c-source">
</FileRef>
<FileRef
location = "container:APSession.h">
</FileRef>
<FileRef
location = "container:APSession.xm"
assignedFileDataType = "public.objective-c-source">
</FileRef>
<FileRef
location = "container:AssistantHooks.xm"
assignedFileDataType = "public.objective-c-source">

View File

@ -33,17 +33,18 @@ static APPluginManager *pluginManager;
BOOL shouldHandleRequest(NSString *text, APSession *currSession) {
pluginManager = [%c(APSpringboardUtils) getSharedManager];
return [pluginManager handleCommand:text withSession:currSession];
NSSet *tokens = [NSSet setWithArray:[text componentsSeparatedByString: @" "]];
return [pluginManager handleCommand:text withTokens:tokens withSession:currSession];
}
%hook BasicAceContext
- (Class)classWithClassName:(NSString*)name group:(NSString*)group {
%log;
id r = %orig;
id r;
if ([name isEqualToString:@"SnippetObject"] && [group isEqualToString:@"zaid.assistantplus.plugin"]) {
r = NSClassFromString(@"SAUISnippet");
} else {
r = %orig;
}
NSLog(@"CWC: %@", r);
return r;
}
@ -112,30 +113,6 @@ BOOL shouldHandleRequest(NSString *text, APSession *currSession) {
}
}
- (void)_requestWillBeginWithRequestClass:(id)arg1 isSpeechRequest:(BOOL)arg2 isBackgroundRequest:(BOOL)arg3 {
NSLog(@"yoyoyyo");
%log;
%orig;
}
- (void)_requestWillBeginWithRequestClass:(id)arg1 isSpeechRequest:(BOOL)arg2 {
NSLog(@"heyheyhey");
%log;
%orig;
}
- (void)requestWillBeginWithRequestClass:(id)arg1 isSpeechRequest:(BOOL)arg2 isBackgroundRequest:(BOOL)arg3 {
NSLog(@"brobrobro");
%log;
%orig;
}
- (void)requestWillBeginWithRequestClass:(id)arg1 isSpeechRequest:(BOOL)arg2 {
NSLog(@"zaidzaidzaid");
%log;
%orig;
}
- (void)startAcousticIDRequestWithOptions:(id)arg1 { %log; %orig; }
- (void)startSpeechPronunciationRequestWithOptions:(id)arg1 pronunciationContext:(id)arg2 { %log; %orig; }
@ -174,21 +151,20 @@ BOOL shouldHandleRequest(NSString *text, APSession *currSession) {
}
}
NSLog(@"Query: %@", phraseBuilder);
NSLog(@"AP Starting Speech Query: %@", phraseBuilder);
AFConnection *connection;
object_getInstanceVariable(self, "_connection", (void **)&connection);
currConnection = connection;
APSession *currSession = [APSession sessionWithRefId:nil andConnection:currConnection];
pluginManager = [%c(APSpringboardUtils) getSharedManager];
if ([pluginManager handleCommand:phraseBuilder withSession:currSession]) {
if (shouldHandleRequest(phraseBuilder, currSession)) {
defaultHandling = NO;
NSLog(@"Handling with plugin!");
} else {
defaultHandling = NO;
defaultHandling = YES;
NSLog(@"Going to default!");
%orig;
}
}
@ -199,5 +175,4 @@ BOOL shouldHandleRequest(NSString *text, APSession *currSession) {
%orig;
}
}
%end
%end

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>RunAtLoad</key>
<true/>
<key>Label</key>
<string>com.zaid.aplocationdaemon</string>
<key>MachServices</key>
<dict>
<key>com.zaid.aplocationdaemon</key>
<true/>
</dict>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/APLocationDaemon</string>
</array>
<key>UserName</key>
<string>mobile</string>
</dict>
</plist>

View File

@ -0,0 +1,12 @@
{
Filter = {
Classes = (
VTPhraseSpotter,
);
Bundles = (
"com.apple.AssistantServices",
"com.apple.springboard",
"com.apple.SiriViewService",
);
};
}

View File

@ -0,0 +1,8 @@
{
Filter = {
Bundles = (
"com.apple.springboard",
"com.apple.SiriViewService",
);
};
}

View File

@ -0,0 +1,10 @@
Package: com.zaid.assistant+
Name: Assistant+
Depends: mobilesubstrate
Architecture: iphoneos-arm
Description: Framework for Siri Extensions
Maintainer: Zaid Elkurdi
Author: Zaid Elkurdi
Section: Tweaks
Version: 0.0.1-272
Installed-Size: 528

6
assistant+/_/debian/postinst Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
chown root:wheel /Library/LaunchDaemons/com.zaid.aplocationdaemon.plist
launchctl unload /Library/LaunchDaemons/com.zaid.aplocationdaemon.plist
launchctl load /Library/LaunchDaemons/com.zaid.aplocationdaemon.plist
echo "Starting APLocationManger..."
exit 0

5
assistant+/_/debian/preinst Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
echo "Installing APLocationManager!"
chown root:wheel /Library/LaunchDaemons/com.zaid.aplocationdaemon.plist
launchctl unload /Library/LaunchDaemons/com.zaid.aplocationdaemon.plist
exit 0

3
assistant+/_/debian/prerm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
launchctl unload /Library/LaunchDaemons/com.zaid.aplocationdaemon.plist
exit 0

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -27,7 +27,7 @@
-(NSString*)displayName;
- (id)initWithFilePath:(NSURL*)filePath andName:(NSString*)name;
- (NSSet*)getRegisteredSnippets;
- (BOOL)handleSpeech:(NSString*)text forSession:(id<APSiriSession>)session;
- (BOOL)handleSpeech:(NSString*)text withTokens:(NSSet*)tokens withSession:(id<APSiriSession>)session;
/// Register a command class
-(BOOL)registerCommand:(Class)cls;

View File

@ -81,10 +81,10 @@
return snippets;
}
- (BOOL)handleSpeech:(NSString*)text forSession:(id<APSiriSession>)currSession {
- (BOOL)handleSpeech:(NSString*)text withTokens:(NSSet*)tokens withSession:(id<APSiriSession>)currSession {
for (NSObject<APPluginCommand>* cmd in commands) {
if ([cmd respondsToSelector:@selector(handleSpeech:session:)]) {
if ([cmd handleSpeech:text session:currSession]) {
if ([cmd respondsToSelector:@selector(handleSpeech:withTokens:withSession:)]) {
if ([cmd handleSpeech:text withTokens:tokens withSession:currSession]) {
return YES;
}
} else {

View File

@ -14,6 +14,6 @@
}
+ (id)sharedManager;
- (BOOL)loadPlugins;
- (BOOL)handleCommand:(NSString*)command withSession:(APSession*)currSession;
- (BOOL)handleCommand:(NSString*)command withTokens:(NSSet*)tokens withSession:(APSession*)currSession;
- (id<APPluginSnippet>)viewControllerForClass:(NSString*)snippetClass;
@end

View File

@ -57,12 +57,12 @@
return TRUE;
}
- (BOOL)handleCommand:(NSString*)command withSession:(APSession*)currSession {
- (BOOL)handleCommand:(NSString*)command withTokens:(NSSet*)tokens withSession:(APSession*)currSession {
NSLog(@"Looking for command to handle: %@", command);
NSLog(@"There are currently %lu plugins registered: %@", (unsigned long)plugins.count, plugins);
for (APPlugin *currPlugin in plugins) {
NSLog(@"Currently on: %@:%@", currPlugin, [currPlugin displayName]);
if ([currPlugin handleSpeech:command forSession:currSession]) {
if ([currPlugin handleSpeech:command withTokens:tokens withSession:currSession]) {
NSLog(@"%@ is handling command: %@", [currPlugin displayName], command);
return YES;
}

View File

@ -48,7 +48,7 @@
@protocol APPluginCommand <NSObject>
@optional
-(BOOL)handleSpeech:(NSString*)text session:(id<APSiriSession>)session;
-(BOOL)handleSpeech:(NSString*)text withTokens:(NSSet*)tokens withSession:(id<APSiriSession>)session;
-(id)initWithSystem:(id<APPluginManager>)manager;
-(void)assistantDismissed;

0
assistant+/obj/.stamp Normal file
View File

BIN
assistant+/obj/Assistant+.dylib Executable file

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
@interface APHelloSnippetCommands : NSObject<APPluginCommand>
-(BOOL)handleSpeech:(NSString*)text session:(id<APSiriSession>)session;
-(BOOL)handleSpeech:(NSString*)text withTokens:(NSSet*)tokens withSession:(id<APSiriSession>)session;
@end
// vim:ft=objc

View File

@ -17,7 +17,8 @@
[super dealloc];
}
-(BOOL)handleSpeech:(NSString*)text session:(id<APSiriSession>)session {
-(BOOL)handleSpeech:(NSString*)text withTokens:(NSSet*)tokens withSession:(id<APSiriSession>)session {
NSLog(@"Tokens: %@", tokens);
if ([[text lowercaseString] rangeOfString:@"hello"].location != NSNotFound) {
[session sendCustomSnippet:@"APHelloSnippetView" withProperties:nil];
NSLog(@"Commands: %@", [session getCurrentLocation]);

View File

@ -53,7 +53,7 @@
@protocol APPluginCommand <NSObject>
@optional
-(BOOL)handleSpeech:(NSString*)text session:(id<APSiriSession>)session;
-(BOOL)handleSpeech:(NSString*)text withTokens:(NSSet*)tokens withSession:(id<APSiriSession>)session;
-(id)initWithSystem:(id<APPluginManager>)manager;
-(void)assistantDismissed;

View File

@ -1,10 +0,0 @@
Package: com.zaid.hellosnippet
Name: HelloSnippet
Depends: firmware (>= 8.0), com.zaid.assistant+
Architecture: iphoneos-arm
Description: Displays a custom snippet in response to "Hello"
Maintainer: Zaid Elkurdi
Author: Zaid Elkurdi
Section: Addons (AssistantPlus)
Version: 0.0.1-29
Installed-Size: 140

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>HelloSnippet</string>
<key>CFBundleIdentifier</key>
<string>com.zaid.hellosnippet</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleDisplayName</key>
<string>HelloSnippet</string>
<key>MinimumOSVersion</key>
<string>5.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>AppBundleID</key>
<string>com.zaid.hellosnippet</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>APHelloSnippet</string>
</dict>
</plist>

View File

@ -1 +0,0 @@
"HelloSnippet" = "HelloSnippet";

View File

@ -1,17 +0,0 @@
obj/APHelloSnippet.mm.9b5b59cf.md obj/APHelloSnippet.mm.9b5b59cf.o: \
APHelloSnippet.mm \
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch \
APHelloSnippet.h AssistantPlusHeaders.h AssistantHeaders.h \
APHelloSnippetCommands.h APHelloSnippetView.h
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch:
APHelloSnippet.h:
AssistantPlusHeaders.h:
AssistantHeaders.h:
APHelloSnippetCommands.h:
APHelloSnippetView.h:

View File

@ -1,12 +0,0 @@
obj/APHelloSnippetCommands.mm.9b5b59cf.md obj/APHelloSnippetCommands.mm.9b5b59cf.o: \
APHelloSnippetCommands.mm \
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch \
APHelloSnippetCommands.h AssistantPlusHeaders.h AssistantHeaders.h
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch:
APHelloSnippetCommands.h:
AssistantPlusHeaders.h:
AssistantHeaders.h:

View File

@ -1,10 +0,0 @@
obj/APHelloSnippetSnippet.mm.9b5b59cf.md obj/APHelloSnippetSnippet.mm.9b5b59cf.o: \
APHelloSnippetSnippet.mm \
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch \
APHelloSnippetSnippet.h AssistantPlusHeaders.h
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch:
APHelloSnippetSnippet.h:
AssistantPlusHeaders.h:

View File

@ -1,12 +0,0 @@
obj/APHelloSnippetView.mm.9b5b59cf.md obj/APHelloSnippetView.mm.9b5b59cf.o: \
APHelloSnippetView.mm \
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch \
APHelloSnippetView.h AssistantPlusHeaders.h AssistantHeaders.h
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch:
APHelloSnippetView.h:
AssistantPlusHeaders.h:
AssistantHeaders.h:

View File

@ -1,10 +0,0 @@
obj/APHelloSnippetViewController.mm.9b5b59cf.md obj/APHelloSnippetViewController.mm.9b5b59cf.o: \
APHelloSnippetViewController.mm \
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch \
APHelloSnippetViewController.h AssistantPlusHeaders.h
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch:
APHelloSnippetViewController.h:
AssistantPlusHeaders.h:

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>HelloSnippet</string>
<key>CFBundleIdentifier</key>
<string>com.zaid.hellosnippet</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleDisplayName</key>
<string>HelloSnippet</string>
<key>MinimumOSVersion</key>
<string>5.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>AppBundleID</key>
<string>com.zaid.hellosnippet</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>APHelloSnippet</string>
</dict>
</plist>

View File

@ -1 +0,0 @@
"HelloSnippet" = "HelloSnippet";