diff options
Diffstat (limited to 'QSThingsPlugin/Actions')
| -rw-r--r-- | QSThingsPlugin/Actions/CompleteTaskAction.h | 12 | ||||
| -rw-r--r-- | QSThingsPlugin/Actions/CompleteTaskAction.m | 41 | ||||
| -rw-r--r-- | QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.h | 11 | ||||
| -rw-r--r-- | QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.m | 21 |
4 files changed, 85 insertions, 0 deletions
diff --git a/QSThingsPlugin/Actions/CompleteTaskAction.h b/QSThingsPlugin/Actions/CompleteTaskAction.h new file mode 100644 index 0000000..19609b9 --- /dev/null +++ b/QSThingsPlugin/Actions/CompleteTaskAction.h @@ -0,0 +1,12 @@ +#import "Constants.h" +#import "KeychainHelper.h" +#import <Foundation/Foundation.h> +#import <QSCore/QSCore.h> + +NS_ASSUME_NONNULL_BEGIN + +@interface CompleteTaskAction : QSActionProvider + +@end + +NS_ASSUME_NONNULL_END diff --git a/QSThingsPlugin/Actions/CompleteTaskAction.m b/QSThingsPlugin/Actions/CompleteTaskAction.m new file mode 100644 index 0000000..9673840 --- /dev/null +++ b/QSThingsPlugin/Actions/CompleteTaskAction.m @@ -0,0 +1,41 @@ +#import "CompleteTaskAction.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation CompleteTaskAction + +- (QSObject *)completeTask:(QSObject *)directObject +{ + NSSet *validTypes = [NSSet setWithObjects:kProjectType, kTaskType, nil]; + NSString *authenticationKey = [KeychainHelper authenticationKey]; + + if (!authenticationKey) { + NSLog(@"There is no authentication key."); + } + + if (authenticationKey && [validTypes containsObject:directObject.primaryType]) { + NSDictionary *contents = [directObject objectForType:directObject.primaryType]; + NSString *path = @"update"; + if (directObject.primaryType == kProjectType) { + path = @"update-project"; + } + if (contents) { + NSString *uuid = [contents objectForKey:@"uuid"]; + if (uuid) { + NSString *urlString = [NSString stringWithFormat:@"things:///%@?id=%@&auth-token=%@&completed=true", path, uuid, authenticationKey]; + NSURL *url = [NSURL URLWithString:urlString]; + + [[NSWorkspace sharedWorkspace] openURL:url]; + } else { + NSLog(@"Things object did not have a uuid."); + } + } else { + NSLog(@"Could not get the contents of the Things object."); + } + } + return directObject; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.h b/QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.h new file mode 100644 index 0000000..376d6d4 --- /dev/null +++ b/QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.h @@ -0,0 +1,11 @@ +#import "KeychainHelper.h" +#import <Foundation/Foundation.h> +#import <QSCore/QSCore.h> + +NS_ASSUME_NONNULL_BEGIN + +@interface SetThingsAuthenticationKeyAction : QSActionProvider + +@end + +NS_ASSUME_NONNULL_END diff --git a/QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.m b/QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.m new file mode 100644 index 0000000..b9e7031 --- /dev/null +++ b/QSThingsPlugin/Actions/SetThingsAuthenticationKeyAction.m @@ -0,0 +1,21 @@ +#import "SetThingsAuthenticationKeyAction.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation SetThingsAuthenticationKeyAction + +- (QSObject *)setAuthenticationKey:(QSObject *)directObject +{ + + NSString *contents = [directObject displayName]; + if (contents) { + [KeychainHelper setAuthenticationKey:contents]; + } else { + [KeychainHelper deleteAuthenticationKey]; + } + return directObject; +} + +@end + +NS_ASSUME_NONNULL_END |