-Snippet creation

This commit is contained in:
ZaidElkurdi 2015-03-15 13:51:49 -07:00
parent 68e5181dd6
commit f7680f364a
55 changed files with 544 additions and 239 deletions

View File

@ -3,6 +3,7 @@
Bundles = (
"com.apple.AssistantServices",
"com.apple.springboard",
"com.apple.SiriViewService",
);
};
}

View File

@ -28,8 +28,41 @@
@end
static BOOL defaultHandling = YES;
//static AFConnection *currConnection;
static AFConnection *currConnection;
static APPluginManager *pluginManager;
%hook BasicAceContext
- (void)registerGroupAcronym:(id)arg1 forGroupWithIdentifier:(id)arg2 {
NSMutableDictionary *groupMaps;
object_getInstanceVariable(self, "_groupMap", (void **)&groupMaps);
NSLog(@"Group Map: %@", groupMaps);
%log;
%orig;
}
+ (id)sharedBasicAceContext {
%log;
id r = %orig;
NSLog(@"CWC: %@", r);
return r;
}
- (id)aceObjectWithDictionary:(id)arg1 {
%log;
id r = %orig;
NSLog(@"CWC: %@", r);
return r;
}
- (Class)classWithClassName:(NSString*)name group:(NSString*)group {
%log;
id r = %orig;
if ([name isEqualToString:@"SnippetObject"] && [group isEqualToString:@"zaid.assistantplus.plugin"]) {
r = NSClassFromString(@"SAUISnippet");
}
NSLog(@"CWC: %@", r);
return r;
}
%end
//%hook AFUISiriSession
//- (AFConnection * )_connection { %log; AFConnection * r = %orig; NSLog(@" = %@", r); return r; }
//- (NSString * )debugDescription { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
@ -131,113 +164,143 @@ static BOOL defaultHandling = YES;
//%end
//%hook SAAceView
//+ (id)aceViewWithDictionary:(id)arg1 context:(id)arg2 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//+ (id)aceView { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setViewId:(NSString *)viewId { %log; %orig; }
//- (NSString *)viewId { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setSpeakableText:(NSString *)speakableText { %log; %orig; }
//- (NSString *)speakableText { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setListenAfterSpeaking:(NSNumber *)listenAfterSpeaking { %log; %orig; }
//- (NSNumber *)listenAfterSpeaking { %log; NSNumber * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setDeferredRendering:(BOOL )deferredRendering { %log; %orig; }
//- (BOOL )deferredRendering { %log; BOOL r = %orig; NSLog(@" = %d", r); return r; }
//- (void)setContext:(id)context { %log; %orig; }
//- (id)context { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)encodedClassName { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)groupIdentifier { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (NSString *)debugDescription { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//- (NSString *)description { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//%end
%hook SAAceView
+ (id)aceViewWithDictionary:(id)arg1 context:(id)arg2 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
+ (id)aceView { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (void)setViewId:(NSString *)viewId { %log; %orig; }
- (NSString *)viewId { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setSpeakableText:(NSString *)speakableText { %log; %orig; }
- (NSString *)speakableText { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setListenAfterSpeaking:(NSNumber *)listenAfterSpeaking { %log; %orig; }
- (NSNumber *)listenAfterSpeaking { %log; NSNumber * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setDeferredRendering:(BOOL )deferredRendering { %log; %orig; }
- (BOOL )deferredRendering { %log; BOOL r = %orig; NSLog(@" = %d", r); return r; }
- (void)setContext:(id)context { %log; %orig; }
- (id)context { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (id)encodedClassName { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (id)groupIdentifier { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (NSString *)debugDescription { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
- (NSString *)description { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
%end
//
//%hook SiriUIPluginManager
%hook SiriUIPluginManager
//
//- (id)disambiguationItemForListItem:(id)arg1 disambiguationKey:(id)arg2 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)speakableProviderForObject:(id)arg1 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)transcriptItemForObject:(AceObject*)arg1 {
// NSLog(@"ARG1 is: %@", arg1);
// %log;
// // return %orig;
- (id)transcriptItemForObject:(AceObject*)arg1 {
NSLog(@"new manager: %@ and self:%@", [%c(APPluginManager) sharedManager], self);
NSDictionary *properties = [arg1 properties];
if (properties) {
NSString *className = properties[@"snippetClass"];
if (className) {
NSLog(@"Looking for %@", className);
if (true) {
id<APPluginSnippet> helloClass = [[NSClassFromString(className) alloc] init];
NSLog(@"Hello: %@", helloClass);
UIView *customVC = [helloClass customView];
NSLog(@"Custom: %@ %@", customVC, customVC.backgroundColor);
SiriUISnippetViewController *vc = [[%c(SiriUISnippetViewController) alloc] init];
NSLog(@"SiriSnippet: %@", vc);
NSLog(@"BREAK -- 1 --");
NSLog(@"Intermediary: %@", [%c(APPluginSnippetViewController) class]);
object_setClass(vc, [%c(APPluginSnippetViewController) class]);
NSLog(@"View was: %@", (APPluginSnippetViewController*)vc.view);
[(APPluginSnippetViewController*)vc setCustomView:customVC];
NSLog(@"View is now: %@", (APPluginSnippetViewController*)vc.view);
NSLog(@"BREAK -- 2 --");
SiriUITranscriptItem *item = [%c(SiriUITranscriptItem) transcriptItemWithAceObject:arg1];
NSLog(@"BREAK -- 3 --");
item.viewController = vc;
NSLog(@"SiriUITranscriptItem: %@", item);
return item;
} else {
NSLog(@"Found no VC!");
}
} else {
NSLog(@"No class!");
}
} else {
NSLog(@"No properties!");
}
id r = %orig;
return r;
}
//
// SiriUISnippetViewController *vc = [[%c(SiriUISnippetViewController) alloc] init];
// object_setClass(vc, [%c(HelloSnippetViewController) class]);
// SiriUITranscriptItem *item = [%c(SiriUITranscriptItem) transcriptItemWithAceObject:arg1];
// item.viewController = vc;
//
// NSLog(@"Returning: %@", item);
// return item;
// // id r = %orig;
// // NSLog(@" = %@", r);
// // return r;
//}
// id r = %orig;
// NSLog(@" = %@", r);
// return r;
//%end
%end
//%hook SiriUITranscriptItem
//+ (id)transcriptItemWithAceObject:(id)arg1 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)aceObject { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)description { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)initWithAceObject:(id)arg1 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (id)itemIdentifier { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setAceObject:(id)arg1 { %log; %orig; }
//- (void)setItemIdentifier:(id)arg1 { %log; %orig; }
//- (void)setViewController:(id)arg1 { %log; %orig; }
//- (id)viewController {
// id r = %orig;
//// NSLog(@" Going to return = %@", r);
// return r; }
//%end
%hook SiriUITranscriptItem
+ (id)transcriptItemWithAceObject:(id)arg1 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (id)aceObject { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (id)description { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (id)initWithAceObject:(id)arg1 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (id)itemIdentifier { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (void)setAceObject:(id)arg1 { %log; %orig; }
- (void)setItemIdentifier:(id)arg1 { %log; %orig; }
- (void)setViewController:(id)arg1 { %log; %orig; }
- (id)viewController {
id r = %orig;
// NSLog(@" Going to return = %@", r);
return r; }
%end
//%hook SiriUISnippetViewController
//- (void)setAceObject:(AceObject * )aceObject { %log; %orig; }
//- (AceObject * )aceObject { %log; AceObject * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setAttributedSubtitle:(NSAttributedString * )attributedSubtitle { %log; %orig; }
//- (NSAttributedString * )attributedSubtitle { %log; NSAttributedString * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setCancelled:(bool )cancelled { %log; %orig; }
//- (void)setConfirmed:(bool )confirmed { %log; %orig; }
//- (bool )isConfirmed { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
//- (NSString * )debugDescription { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//- (NSString * )description { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//- (unsigned long long )hash { %log; unsigned long long r = %orig; NSLog(@" = %llu", r); return r; }
//- (void)setHeaderPunchOut:(SAUIAppPunchOut * )headerPunchOut { %log; %orig; }
//- (SAUIAppPunchOut * )headerPunchOut { %log; SAUIAppPunchOut * r = %orig; NSLog(@" = %@", r); return r; }
//- (SAUIConfirmationOptions * )_previousConfirmationOptions { %log; SAUIConfirmationOptions * r = %orig; NSLog(@" = %@", r); return r; }
//- (bool )_isProvisional { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
//- (void)setRequestContext:(NSArray * )requestContext { %log; %orig; }
//- (NSArray * )requestContext { %log; NSArray * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setSnippet:(SAUISnippet * )snippet { %log; %orig; }
//- (SAUISnippet * )snippet { %log; SAUISnippet * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setSnippetPunchOut:(SAUIAppPunchOut * )snippetPunchOut { %log; %orig; }
//- (SAUIAppPunchOut * )snippetPunchOut { %log; SAUIAppPunchOut * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setSubtitle:(NSString * )subtitle { %log; %orig; }
//- (NSString * )subtitle { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//- (void)setTitle:(NSString * )title { %log; %orig; }
//- (NSString * )title { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
//- (bool )isVirgin { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
//- (id)_headerView { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (long long)_insertionAnimation { %log; long long r = %orig; NSLog(@" = %lld", r); return r; }
//- (long long)_pinAnimationType { %log; long long r = %orig; NSLog(@" = %lld", r); return r; }
//- (id)_privateDelegate { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (long long)_replacementAnimation { %log; long long r = %orig; NSLog(@" = %lld", r); return r; }
//- (void)_setProvisional:(bool)arg1 { %log; %orig; }
//- (void)_setVirgin:(bool)arg1 { %log; %orig; }
//- (void)_snippetPunchOutButtonTapped { %log; %orig; }
//- (void)_snippetViewControllerWillBeRemoved { %log; %orig; }
//- (void)cancelButtonTapped:(id)arg1 { %log; %orig; }
//- (void)confirmButtonTapped:(id)arg1 { %log; %orig; }
//- (id)delegate { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (double)desiredHeight { %log; double r = %orig; NSLog(@" = %f", r); return r; }
//- (double)desiredHeightForFooterView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
//- (double)desiredHeightForHeaderView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
//- (double)desiredHeightForTransparentFooterView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
//- (double)desiredHeightForTransparentHeaderView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
//- (void)headerTapped:(id)arg1 { %log; %orig; }
//- (id)initWithNibName:(id)arg1 bundle:(id)arg2 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//- (bool)removedAfterDialogProgresses { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
//%end
%hook SiriUISnippetViewController
- (void)setAceObject:(AceObject * )aceObject { %log; %orig; }
- (AceObject * )aceObject { %log; AceObject * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setAttributedSubtitle:(NSAttributedString * )attributedSubtitle { %log; %orig; }
- (NSAttributedString * )attributedSubtitle { %log; NSAttributedString * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setCancelled:(bool )cancelled { %log; %orig; }
- (void)setConfirmed:(bool )confirmed { %log; %orig; }
- (bool )isConfirmed { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
- (NSString * )debugDescription { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
- (NSString * )description { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
- (unsigned long long )hash { %log; unsigned long long r = %orig; NSLog(@" = %llu", r); return r; }
- (void)setHeaderPunchOut:(SAUIAppPunchOut * )headerPunchOut { %log; %orig; }
- (SAUIAppPunchOut * )headerPunchOut { %log; SAUIAppPunchOut * r = %orig; NSLog(@" = %@", r); return r; }
- (SAUIConfirmationOptions * )_previousConfirmationOptions { %log; SAUIConfirmationOptions * r = %orig; NSLog(@" = %@", r); return r; }
- (bool )_isProvisional { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
- (void)setRequestContext:(NSArray * )requestContext { %log; %orig; }
- (NSArray * )requestContext { %log; NSArray * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setSnippet:(SAUISnippet * )snippet { %log; %orig; }
- (SAUISnippet * )snippet { %log; SAUISnippet * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setSnippetPunchOut:(SAUIAppPunchOut * )snippetPunchOut { %log; %orig; }
- (SAUIAppPunchOut * )snippetPunchOut { %log; SAUIAppPunchOut * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setSubtitle:(NSString * )subtitle { %log; %orig; }
- (NSString * )subtitle { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
- (void)setTitle:(NSString * )title { %log; %orig; }
- (NSString * )title { %log; NSString * r = %orig; NSLog(@" = %@", r); return r; }
- (bool )isVirgin { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
- (id)_headerView { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (long long)_insertionAnimation { %log; long long r = %orig; NSLog(@" = %lld", r); return r; }
- (long long)_pinAnimationType { %log; long long r = %orig; NSLog(@" = %lld", r); return r; }
- (id)_privateDelegate { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (long long)_replacementAnimation { %log; long long r = %orig; NSLog(@" = %lld", r); return r; }
- (void)_setProvisional:(bool)arg1 { %log; %orig; }
- (void)_setVirgin:(bool)arg1 { %log; %orig; }
- (void)_snippetPunchOutButtonTapped { %log; %orig; }
- (void)_snippetViewControllerWillBeRemoved { %log; %orig; }
- (void)cancelButtonTapped:(id)arg1 { %log; %orig; }
- (void)confirmButtonTapped:(id)arg1 { %log; %orig; }
- (id)delegate { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (double)desiredHeight { %log; double r = %orig; NSLog(@" = %f", r); return r; }
- (double)desiredHeightForFooterView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
- (double)desiredHeightForHeaderView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
- (double)desiredHeightForTransparentFooterView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
- (double)desiredHeightForTransparentHeaderView { %log; double r = %orig; NSLog(@" = %f", r); return r; }
- (void)headerTapped:(id)arg1 { %log; %orig; }
- (id)initWithNibName:(id)arg1 bundle:(id)arg2 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
- (bool)removedAfterDialogProgresses { %log; bool r = %orig; NSLog(@" = %d", r); return r; }
%end
//
//%hook SVSSnippetPluginBundle
//- (void)setBundle:(NSBundle * )bundle { %log; %orig; }
@ -247,21 +310,21 @@ static BOOL defaultHandling = YES;
//+ (id)snippetPluginWithBundle:(id)arg1 { %log; id r = %orig; NSLog(@" = %@", r); return r; }
//%end
//
//%hook SAUISnippet
//+ (id)snippetWithDictionary:(id)arg1 context:(id)arg2 {
// %log;
// id r = %orig;
// NSLog(@" = %@", r);
// return r;
//}
//
//+ (id)snippet {
// %log;
// id r = %orig;
// NSLog(@" = %@", r);
// return r;
//}
//%end
%hook SAUISnippet
+ (id)snippetWithDictionary:(id)arg1 context:(id)arg2 {
%log;
id r = %orig;
NSLog(@" = %@", r);
return r;
}
+ (id)snippet {
%log;
id r = %orig;
NSLog(@" = %@", r);
return r;
}
%end
%hook AFConnection
- (void)_doCommand:(SAUIAddViews*)arg1 reply:(id)arg2 {
@ -271,7 +334,9 @@ static BOOL defaultHandling = YES;
NSLog(@"Service: %@", service);
NSLog(@"Doing: %@", arg1);
NSLog(@"Views: %@", arg1.views);
if ([arg1 respondsToSelector:@selector(views)]) {
NSLog(@"Views: %@", arg1.views);
}
%log;
%orig;
}
@ -321,7 +386,7 @@ static BOOL defaultHandling = YES;
NSLog(@"text is %@", text);
NSLog(@"Here!!!");
APSession *currSession = [APSession sessionWithRefId:nil andConnection:self];
APPluginManager *pluginManager = [%c(APSBPluginManager) getSharedManager];
pluginManager = [%c(APSBPluginManager) getSharedManager];
NSLog(@"Retrieved: %@", pluginManager);
if ([pluginManager handleCommand:text withSession:currSession]) {
NSLog(@"Handling!");
@ -350,7 +415,6 @@ static BOOL defaultHandling = YES;
%hook AFConnectionClientServiceDelegate
- (void)speechRecognized:(SASSpeechRecognized*)arg1 {
NSLog(@"Back: %@", [NSThread callStackSymbols]);
NSMutableString *phraseBuilder = [NSMutableString string];
for (AFSpeechPhrase *currPhrase in arg1.recognition.phrases) {
if (currPhrase.interpretations.count > 0) {
@ -364,23 +428,23 @@ static BOOL defaultHandling = YES;
NSLog(@"Query: %@", phraseBuilder);
// AFConnection *connection;
// object_getInstanceVariable(self, "_connection", (void **)&connection);
// currConnection = connection;
//
// APSession *currSession = [APSession sessionWithRefId:nil andConnection:currConnection];
//
// if ([pluginManager handleCommand:phraseBuilder withSession:currSession]) {
// defaultHandling = NO;
// NSLog(@"Handling with plugin!");
// } else {
// defaultHandling = NO;
// NSLog(@"Going to default!");
// }
AFConnection *connection;
object_getInstanceVariable(self, "_connection", (void **)&connection);
currConnection = connection;
APSession *currSession = [APSession sessionWithRefId:nil andConnection:currConnection];
pluginManager = [%c(APSBPluginManager) getSharedManager];
if ([pluginManager handleCommand:phraseBuilder withSession:currSession]) {
defaultHandling = NO;
NSLog(@"Handling with plugin!");
} else {
defaultHandling = NO;
NSLog(@"Going to default!");
}
}
- (void)requestDidFinish{ %log; %orig; }
- (void)requestDidReceiveCommand:(id)arg1 reply:(CDUnknownBlockType*)arg2 {
%log;
if (defaultHandling) {

View File

@ -6,5 +6,5 @@ Description: Framework for Siri Extensions
Maintainer: Zaid Elkurdi
Author: Zaid Elkurdi
Section: Tweaks
Version: 0.0.1-51
Installed-Size: 276
Version: 0.0.1-153
Installed-Size: 344

View File

@ -3,6 +3,7 @@
Bundles = (
"com.apple.AssistantServices",
"com.apple.springboard",
"com.apple.SiriViewService",
);
};
}

View File

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

View File

@ -26,7 +26,7 @@
}
-(NSString*)displayName;
- (id)initWithFilePath:(NSURL*)filePath andName:(NSString*)name;
- (NSSet*)getRegisteredSnippets;
- (BOOL)handleSpeech:(NSString*)text forSession:(APSession*)session;
/// Register a command class

View File

@ -76,6 +76,11 @@
return displayName;
}
- (NSSet*)getRegisteredSnippets {
NSLog(@"Registered Snippets: %@", snippets);
return snippets;
}
- (BOOL)handleSpeech:(NSString*)text forSession:(APSession*)currSession {
for (NSObject<APPluginCommand>* cmd in commands) {
if ([cmd respondsToSelector:@selector(handleSpeech:session:)]) {
@ -159,9 +164,11 @@
return NO;
}
NSLog(@"Registered snippet %@, snippets is now %@", className, snippets);
[snippets addObject:className];
id helloClass = [[NSClassFromString(className) alloc] init];
NSLog(@"Snippet Initalized: %@", helloClass);
[snippets addObject:className];
NSLog(@"Registered snippet %@, snippets is now %@", className, snippets);
return YES;
}
@ -173,4 +180,5 @@
return text;
}
@end

View File

@ -7,6 +7,7 @@
//
#import "APSession.h"
#import "AssistantPlusHeaders.h"
@interface APPluginManager : NSObject {
NSMutableArray *plugins;
@ -14,4 +15,5 @@
+ (id)sharedManager;
- (BOOL)loadPlugins;
- (BOOL)handleCommand:(NSString*)command withSession:(APSession*)currSession;
- (id<APPluginSnippet>)viewControllerForClass:(NSString*)snippetClass;
@end

View File

@ -58,7 +58,6 @@
}
- (BOOL)handleCommand:(NSString*)command withSession:(APSession*)currSession {
[currSession sendSnippetWithText:@"Shit!"];
NSLog(@"Looking for command to handle: %@", command);
NSLog(@"There are currently %lu plugins registered: %@", (unsigned long)plugins.count, plugins);
for (APPlugin *currPlugin in plugins) {
@ -71,6 +70,32 @@
return NO;
}
- (id<APPluginSnippet>)viewControllerForClass:(NSString*)snippetClass {
NSLog(@"Begin search for: %@ with %d plugins", snippetClass, (int)plugins.count);
for (APPlugin *currPlugin in plugins) {
NSLog(@"Current (%@) contains: %@", [currPlugin displayName], [currPlugin getRegisteredSnippets]);
if ([[currPlugin getRegisteredSnippets] containsObject:snippetClass]) {
NSObject<APPluginSnippet>* snip = [NSClassFromString(snippetClass) alloc];
id initRes = nil;
if ([snip respondsToSelector:@selector(initWithProperties:)])
initRes = [snip initWithProperties:@{@"labelText" : @"fuck you"}];
if (!initRes)
initRes = [snip init];
if (!initRes) {
NSLog(@"ERROR: Snippet class %@ failed to initialize!", snippetClass);
return nil;
}
return snip;
}
}
NSLog(@"APPluginManager: Found no VC for %@", snippetClass);
return nil;
}
-(NSString*)localizedString:(NSString*)text {
return text;
}

View File

@ -1,29 +1,68 @@
#import "AssistantHeaders.h"
#import "AssistantPlusHeaders.h"
%subclass APPluginSnippetViewController : SiriUISnippetViewController <SiriUISnippetPlugin>
@interface APPluginSnippetObject : SAUISnippet
- (id)encodedClassName;
- (id)groupIdentifier;
@end
- (void)viewDidLoad {
// [(SiriUISnippetViewController*)super viewDidLoad];
// NSLog(@"Super is: %@", [(SiriUISnippetViewController*)super class]);
NSLog(@"Hello snippet view did load!");
@implementation APPluginSnippetObject
-(id)init {
NSLog(@">> APPluginSnippetObject init");
if ( (self = [super init]) ){
}
return self;
}
-(void)initWithProperties:(NSDictionary*)props {
NSString *newText = props[@"labelText"];
UILabel *helloLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)] autorelease];
helloLabel.text = newText;
UIViewController *vc = (UIViewController*)self;
[vc.view addSubview:helloLabel];
- (id)encodedClassName
{
return @"SnippetObject";
}
- (id)groupIdentifier
{
return @"zaid.assistantplus.plugin";
}
@end
static UIView *_view;
%subclass APPluginSnippetViewController : SiriUISnippetViewController <SiriUISnippetPlugin, SiriUIViewController>
//- (void)viewDidLoad {
// // [(SiriUISnippetViewController*)super viewDidLoad];
// // NSLog(@"Super is: %@", [(SiriUISnippetViewController*)super class]);
// NSLog(@"Hello snippet view did load!");
// UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
// label.text = @"HELLO SNIPPET!";
//
// UIViewController *vc = (UIViewController*)self;
// [vc.view addSubview:label];
//}
- (id)view {
NSLog(@"Returning custom view: %@ %@", _view, _view.backgroundColor);
//NSLog(@">> K3AExtensionSnippetController view");
return _view;
}
%new
-(void)setCustomView:(UIView*)newVC {
NSLog(@"Setting custom view to: %@", newVC);
_view = [newVC retain];
}
%new
-(id)viewControllerForSnippet:(id)arg1 error:(id)arg2 {
NSLog(@"VC FOR Snippet: %@" ,arg1);
return self;
}
%new
-(id)viewControllerForAceObject:(id)arg1 {
NSLog(@"VC FOR ACE: %@" ,arg1);
return self;
}
@ -32,9 +71,31 @@
NSLog(@"View is presenting!");
}
-(double)desiredHeightForWidth:(double)arg1 {
return 200;
//-(double)desiredHeightForWidth:(double)arg1 {
// return 200;
//}
-(double)desiredHeight {
return _view.frame.size.height;
}
%new
-(id)speakableNamespaceProviderForAceObject:(id)arg1 {
return nil;
}
-(id)navigationTitle {
return @"yoyoyo";
}
%new
-(void)transcriptViewControllerTappedOutsideEditingView {
NSLog(@"tapped outside editing view!");
}
- (void)didMoveToParentViewController:(UIViewController *)parent {
NSLog(@"Hello moved to %@", parent);
}
//-(id)speakableNamespaceProviderForAceObject:(id)arg1;
%end

View File

@ -13,7 +13,11 @@
+(APSession*)sessionWithRefId:(NSString*)refId andConnection:(AFConnection*)connection;
- (void)sendSnippetWithText:(NSString*)text;
- (void)sendAddViews:(NSArray*)views;
-(SOObject*)createSnippet:(NSString*)snippetClass properties:(NSDictionary*)props;
- (void)sendSnippetForViewController:(NSString*)snippetClass withProperties:(NSDictionary*)props;
- (void)sendRequestCompleted;
-(SOObject*)createAssistantUtteranceView:(NSString*)text;
//-(SOObject*)createObjectDict:(NSString*)className group:(NSString*)group properties:(NSDictionary*)props;
//-(SOObject*)createAssistantUtteranceView:(NSString*)text;

View File

@ -45,11 +45,20 @@ static AFConnection *currConnection = nil;
sendAddViews(views);
}
- (void)sendSnippetForViewController:(NSString*)snippetClass withProperties:(NSDictionary*)props {
NSLog(@"Sending snippet: %@", snippetClass);
[self sendAddViewsSnippet:snippetClass properties:props dialogPhase:@"Completion" scrollToTop:NO temporary:NO];
}
- (void)sendRequestCompleted {
NSMutableDictionary* dict = SOCreateAceRequestCompleted(referenceId);
SessionSendToClient(dict);
}
- (void)sendAddViews:(NSArray*)views {
return sendAddViews(views);
}
#pragma mark - Communication
id SessionSendToClient(NSDictionary* dict) {
@ -59,7 +68,7 @@ id SessionSendToClient(NSDictionary* dict) {
static Class AceObject = objc_getClass("AceObject");
static Class BasicAceContext = objc_getClass("BasicAceContext");
if (!AceObject) NSLog(@"AE ERROR: No AceObject class");
if (!AceObject) NSLog(@"No AceObject class");
if (!BasicAceContext) NSLog(@"AE ERROR: No BasicAceContext class");
if (!dict) {
@ -101,6 +110,13 @@ id SessionSendToClient(NSDictionary* dict) {
return obj;
}
-(void)sendAddViewsSnippet:(NSString*)snippetClass properties:(NSDictionary*)props dialogPhase:(NSString*)dialogPhase scrollToTop:(BOOL)scrollToTop temporary:(BOOL)temporary {
if (!props) props = [NSDictionary dictionary];
NSArray* views = [NSArray arrayWithObject:[self createSnippet:snippetClass properties:props]];
// NSLog(@"About to send: %@", views);
sendAddViews(views);
}
void sendAddViews(NSArray* views, NSString *dialogPhase, BOOL scrollToTop, BOOL temporary) {
NSMutableDictionary* dict = SOCreateAceAddViews(referenceId, views, dialogPhase, scrollToTop, temporary);
@ -125,14 +141,21 @@ void sendAddViews(NSArray* views) {
#pragma mark - Object Creation
-(SOObject*)createSnippet:(NSString*)snippetClass properties:(NSDictionary*)props {
NSMutableDictionary* lowLevelProps = [NSMutableDictionary dictionaryWithObjectsAndKeys:
props,@"snippetProps", snippetClass,@"snippetClass", nil];
NSLog(@"Creating snippet: %@ with properties: %@", snippetClass, lowLevelProps);
return SOCreateObjectDict(@"zaid.assistantplus.plugin", @"SnippetObject", lowLevelProps);
}
-(SOObject*)createObjectDict:(NSString*)className group:(NSString*)group properties:(NSDictionary*)props {
return SOCreateObjectDict(group, className, [[props mutableCopy] autorelease]);
}
#pragma mark - Object Dictionary Creation
NSMutableDictionary* SOCreateObjectDict(NSString* group, NSString* className, NSMutableDictionary* properties)
{
NSMutableDictionary* SOCreateObjectDict(NSString* group, NSString* className, NSMutableDictionary* properties) {
NSMutableDictionary *objDict = [[NSMutableDictionary alloc] init];
[objDict setObject:className forKey:@"$class"];
[objDict setObject:group forKey:@"$group"];
@ -145,11 +168,11 @@ NSMutableDictionary* SOCreateObjectDict(NSString* group, NSString* className, NS
[objDict setObject:properties[currKey] forKey:currKey];
}
}
NSLog(@"Returning: %@", objDict);
return objDict;
}
NSMutableDictionary* SOCreateAceObjectDict(NSString* refId, NSString* group, NSString* className, NSMutableDictionary* properties)
{
NSMutableDictionary* SOCreateAceObjectDict(NSString* refId, NSString* group, NSString* className, NSMutableDictionary* properties) {
NSString* aceId = RandomUUID();
NSMutableDictionary *dict = SOCreateObjectDict(group, className, properties);

View File

@ -8,13 +8,23 @@
#ifndef _AssistantHeaders_h
#define _AssistantHeaders_h
static char kAPPluginAssociatedObjectKey;
@interface BasicAceContext : NSObject
+ (id)sharedBasicAceContext;
- (void)registerGroupAcronym:(id)arg1 forGroupWithIdentifier:(id)arg2;
- (id)aceObjectWithDictionary:(id)arg1;
- (Class)classWithClassName:(id)arg1 group:(id)arg2;
@end
@interface AceObject : NSObject
@property(copy, nonatomic) NSString *refId;
@property(copy, nonatomic) NSString *aceId;
- (id)properties;
- (id)dictionary;
+ (id)aceObjectWithDictionary:(id)arg1 context:(id)arg2;
@end
@interface SiriUISnippetViewController : UIViewController
@property(retain) AceObject * aceObject;
-(void)siriWillActivateFromSource:(long long)arg1;
@ -137,6 +147,10 @@ typedef SOObject SOAceObject;
- (id)groupIdentifier;
@end
@interface SAUISnippet : SAAceView
+ (id)snippetWithDictionary:(id)arg1 context:(id)arg2;
@end
@interface SASRecognition : AceObject
@property(nonatomic) int sentenceConfidence;
@property(copy, nonatomic) NSArray *phrases;

View File

@ -27,6 +27,7 @@
@protocol APPluginSnippet <SiriUIViewController>
@optional
-(id)customView;
/// Initializes a snippet by properties
-(id)initWithProperties:(NSDictionary*)props;
/// Initializes a snippet by properties and system
@ -36,7 +37,7 @@
@end
@interface APPluginSnippetViewController : UIViewController <APPluginSnippet>
-(void)setCustomView:(UIView*)newVC;
@end

View File

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

View File

@ -1,7 +1,9 @@
include theos/makefiles/common.mk
TWEAK_NAME = AssistantPlusPluginManager
AssistantPlusPluginManager_FILES = Tweak.xm APSession.xm APPluginManager.mm APPlugin.m
AssistantPlusPluginManager_FILES = Tweak.xm APSession.xm APPluginManager.mm APPlugin.m APPluginSnippetViewController.xm
AssistantPlusPluginManager_PRIVATE_FRAMEWORKS = AssistantServices SAObjects
AssistantPlusPluginManager_FRAMEWORKS = Foundation UIKit
AssistantPlusPluginManager_LIBRARIES=substrate objcipc
include $(THEOS_MAKE_PATH)/tweak.mk

View File

@ -14,13 +14,15 @@
location = "container:APPluginManager.mm">
</FileRef>
<FileRef
location = "container:APPluginSnippetViewController.xm">
location = "container:APPluginSnippetViewController.xm"
assignedFileDataType = "public.objective-c-source">
</FileRef>
<FileRef
location = "container:APSession.h">
</FileRef>
<FileRef
location = "container:APSession.xm">
location = "container:APSession.xm"
assignedFileDataType = "public.objective-c-source">
</FileRef>
<FileRef
location = "container:AssistantHeaders.h">
@ -35,4 +37,8 @@
location = "container:Tweak.xm"
assignedFileDataType = "public.objective-c-source">
</FileRef>
<FileRef
location = "group:../AssistantHooks.xm"
assignedFileDataType = "public.objective-c-source">
</FileRef>
</Workspace>

View File

@ -6,13 +6,12 @@ static APPluginManager *pluginManager;
static inline __attribute__((constructor)) void init() {
NSLog(@"Creating AssistantPlusSBPluginManager!");
pluginManager = [APPluginManager sharedManager];
NSLog(@"Registed for messages!");
[OBJCIPC registerIncomingMessageFromAppHandlerForMessageName:@"AssistantPlus.Query" handler:^NSDictionary *(NSDictionary *message) {
NSLog(@"Message: %@", message);
return @{@"Hello" : @"Sucker!"};
}];
NSLog(@"Initialized SPM: %@", [%c(SiriUIPluginManager) sharedInstance]);
pluginManager = [APPluginManager sharedManager];
objc_setAssociatedObject([%c(SiriUIPluginManager) sharedInstance], &kAPPluginAssociatedObjectKey, @"hey!", OBJC_ASSOCIATION_RETAIN);
[[%c(BasicAceContext) sharedBasicAceContext] registerGroupAcronym:@"APPlugin" forGroupWithIdentifier:@"zaid.assistantplus.plugin"];
}
%subclass APSBPluginManager : NSObject

View File

@ -0,0 +1,13 @@
obj/APPlugin.m.eb32989f.md obj/APPlugin.m.eb32989f.o: APPlugin.m \
/Users/Zaid/Programming/Assistant2/assistant+/theos/Prefix.pch \
APPlugin.h AssistantPlusHeaders.h APSession.h AssistantHeaders.h
/Users/Zaid/Programming/Assistant2/assistant+/theos/Prefix.pch:
APPlugin.h:
AssistantPlusHeaders.h:
APSession.h:
AssistantHeaders.h:

View File

@ -1,8 +1,8 @@
obj/APPluginManager.mm.d5906e1e.md obj/APPluginManager.mm.d5906e1e.o: \
APPluginManager.mm \
/Users/Zaid/Programming/Assistant2/assistant+/theos/Prefix.pch \
APPluginManager.h APSession.h AssistantHeaders.h APPlugin.h \
AssistantPlusHeaders.h
APPluginManager.h APSession.h AssistantHeaders.h \
AssistantPlusHeaders.h APPlugin.h
/Users/Zaid/Programming/Assistant2/assistant+/theos/Prefix.pch:
@ -12,6 +12,6 @@ APSession.h:
AssistantHeaders.h:
APPlugin.h:
AssistantPlusHeaders.h:
APPlugin.h:

View File

@ -0,0 +1,17 @@
obj/APPluginManager.mm.eb32989f.md obj/APPluginManager.mm.eb32989f.o: \
APPluginManager.mm \
/Users/Zaid/Programming/Assistant2/assistant+/theos/Prefix.pch \
APPluginManager.h APSession.h AssistantHeaders.h \
AssistantPlusHeaders.h APPlugin.h
/Users/Zaid/Programming/Assistant2/assistant+/theos/Prefix.pch:
APPluginManager.h:
APSession.h:
AssistantHeaders.h:
AssistantPlusHeaders.h:
APPlugin.h:

Binary file not shown.

View File

@ -1,6 +1,6 @@
#import "APHelloSnippet.h"
#import "APHelloSnippetCommands.h"
#import "APHelloSnippetViewController.h"
#import "APHelloSnippetView.h"
@implementation APHelloSnippet
@ -9,7 +9,7 @@
if ((self = [super init])) {
// register all extension classes provided
[manager registerCommand:[APHelloSnippetCommands class]];
[manager registerSnippet:[APHelloSnippetViewController class]];
[manager registerSnippet:[APHelloSnippetView class]];
}
return self;
}

View File

@ -19,11 +19,11 @@
-(BOOL)handleSpeech:(NSString*)text session:(APSession*)session {
if ([[text lowercaseString] rangeOfString:@"hello"].location != NSNotFound) {
[session sendSnippetWithText:@"Fuck!"];
[session sendSnippetForViewController:@"APHelloSnippetView" withProperties:nil];
} else if ([[text lowercaseString] rangeOfString:@"test"].location != NSNotFound) {
[session sendSnippetWithText:@"Shit!"];
} else {
[session sendSnippetWithText:@"Bitch!"];
return NO;
}
return YES;

View File

@ -8,7 +8,7 @@
#import "AssistantPlusHeaders.h"
@interface APHelloSnippetViewController : UIViewController <APPluginSnippet>
@interface APHelloSnippetView : NSObject<APPluginSnippet>
@property (nonatomic,retain) AceObject *aceObject;
-(id)initWithProperties:(NSDictionary*)props;
@end

View File

@ -0,0 +1,90 @@
//
// HelloSnippetSnippet.m
//
//
// Created by Zaid Elkurdi on 3/14/15.
//
//
#import "APHelloSnippetView.h"
@implementation APHelloSnippetView {
UILabel *helloLabel;
}
@synthesize aceObject;
-(id)customView {
UIView *shit = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 1000)];
shit.backgroundColor = [UIColor redColor];
NSLog(@"Returing hello view: %@ %@", shit, shit.backgroundColor);
return shit;
}
-(id)initWithAceObject:(id)aceObj {
NSLog(@"Init with: %@", aceObj);
[self setAceObject:aceObj];
return self;
}
-(id)initWithProperties:(NSDictionary*)props {
NSLog(@"Init with: %@" ,props);
if (self = [super init]) {
NSString *newText = @"bitch nigga";
helloLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)] autorelease];
helloLabel.text = newText;
}
return self;
}
-(double)desiredHeightForWidth:(double)arg1 {
return 200.0;
}
-(void)siriWillActivateFromSource:(long long)arg1 {
NSLog(@"Is activating from: %lld", arg1);
}
-(void)siriDidDeactivate {
NSLog(@"Did deactivate!");
}
-(void)wasAddedToTranscript {
NSLog(@"Was added!");
}
-(AceObject *)aceObject {
return aceObject;
}
-(void)setAceObject:(AceObject*)aceObj {
aceObject = aceObj;
}
-(id)viewControllerForSnippet:(id)arg1 error:(id)arg2 {
return self;
}
-(id)speakableNamespaceProviderForAceObject:(id)arg1 {
return nil;
}
-(id)viewControllerForSnippet:(id)arg1 {
NSLog(@"hello snippet: %@", arg1);
return self;
}
-(id)viewControllerForAceObject:(id)arg1 {
NSLog(@"hello ace: %@", arg1);
return self;
}
-(id)navigationTitle {
return @"yoyoyo";
}
-(void)transcriptViewControllerTappedOutsideEditingView {
}
@end

View File

@ -1,55 +0,0 @@
//
// HelloSnippetSnippet.m
//
//
// Created by Zaid Elkurdi on 3/14/15.
//
//
#import "APHelloSnippetViewController.h"
@implementation APHelloSnippetViewController {
UILabel *helloLabel;
}
@synthesize aceObject;
- (void)viewDidLoad {
[super viewDidLoad];
}
-(id)initWithProperties:(NSDictionary*)props {
if (self = [super init]) {
NSString *newText = props[@"labelText"];
helloLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)] autorelease];
helloLabel.text = newText;
}
return self;
}
-(double)desiredHeightForWidth:(double)arg1 {
return 200.0;
}
-(void)siriWillActivateFromSource:(long long)arg1 {
NSLog(@"Is activating from: %lld", arg1);
}
-(void)siriDidDeactivate {
NSLog(@"Did deactivate!");
}
-(void)wasAddedToTranscript {
NSLog(@"Was added!");
}
-(AceObject *)aceObject {
return aceObject;
}
-(void)setAceObject:(AceObject*)aceObj {
aceObject = aceObj;
}
@end

View File

@ -9,6 +9,9 @@
#ifndef _AssistantPlusHeaders_h
#define _AssistantPlusHeaders_h
@interface SOObject : NSObject
@end
@interface AceObject : NSObject
@property(copy, nonatomic) NSString *refId;
@property(copy, nonatomic) NSString *aceId;
@ -17,6 +20,11 @@
@interface APSession : NSObject
- (void)sendSnippetWithText:(NSString*)text;
- (void)sendAddViews:(NSArray*)views;
-(SOObject*)createSnippet:(NSString*)snippetClass properties:(NSDictionary*)props;
- (void)sendSnippetForViewController:(NSString*)snippetClass withProperties:(NSDictionary*)props;
- (void)sendRequestCompleted;
-(SOObject*)createAssistantUtteranceView:(NSString*)text;
@end
@protocol APPluginManager <NSObject>
@ -49,6 +57,7 @@
@protocol APPluginSnippet <SiriUIViewController>
@optional
-(id)view;
/// Initializes a snippet by properties
-(id)initWithProperties:(NSDictionary*)props;
/// Initializes a snippet by properties and system
@ -57,10 +66,6 @@
@end
@interface APPluginSnippetViewController : UIViewController <APPluginSnippet>
@end
/** Protocol specifying methods of an extension class handling commands.
Classes conforming to this protocol are initialized just after loading bundle and will remain in memory.

View File

@ -6,7 +6,7 @@ export SDKVERSION=8.1
BUNDLE_NAME = HelloSnippet
HelloSnippet_BUNDLE_EXTENSION = assistantPlugin
HelloSnippet_FILES = APHelloSnippet.mm APHelloSnippetCommands.mm APHelloSnippetViewController.mm
HelloSnippet_FILES = APHelloSnippet.mm APHelloSnippetCommands.mm APHelloSnippetView.mm
HelloSnippet_INSTALL_PATH = /Library/AssistantPlusPlugins/
HelloSnippet_FRAMEWORKS = UIKit CoreGraphics

View File

@ -6,5 +6,5 @@ Description: Displays a custom snippet in response to "Hello"
Maintainer: Zaid Elkurdi
Author: Zaid Elkurdi
Section: Addons (AssistantPlus)
Version: 0.0.1-9
Version: 0.0.1-26
Installed-Size: 140

View File

@ -2,7 +2,7 @@ obj/APHelloSnippet.mm.9b5b59cf.md obj/APHelloSnippet.mm.9b5b59cf.o: \
APHelloSnippet.mm \
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch \
APHelloSnippet.h AssistantPlusHeaders.h APHelloSnippetCommands.h \
APHelloSnippetViewController.h
APHelloSnippetView.h
/Users/Zaid/Programming/Assistant2/hellosnippet/theos/Prefix.pch:
@ -12,4 +12,4 @@ AssistantPlusHeaders.h:
APHelloSnippetCommands.h:
APHelloSnippetViewController.h:
APHelloSnippetView.h:

View File

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

Binary file not shown.