mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 14:42:18 +00:00
Approprate naming for service protocol
Minor code cleanup
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -727,7 +727,7 @@
|
||||
4CF62B85179385D700B660B6 /* KPKAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKAttribute.m; sourceTree = "<group>"; };
|
||||
4CF6C70F176F4533007A811D /* MPStringLengthValueTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPStringLengthValueTransformer.h; sourceTree = "<group>"; };
|
||||
4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPStringLengthValueTransformer.m; sourceTree = "<group>"; };
|
||||
4CF6C715176F5183007A811D /* MPServerRequestHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPServerRequestHandler.h; sourceTree = "<group>"; };
|
||||
4CF6C715176F5183007A811D /* MPServerRequestHandling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPServerRequestHandling.h; sourceTree = "<group>"; };
|
||||
4CF6C716176F5234007A811D /* MPAssociateRequestHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAssociateRequestHandler.h; sourceTree = "<group>"; };
|
||||
4CF6C717176F5234007A811D /* MPAssociateRequestHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAssociateRequestHandler.m; sourceTree = "<group>"; };
|
||||
4CF78055176E5CFD0032EE71 /* MPConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPConnection.h; sourceTree = "<group>"; };
|
||||
@@ -1323,7 +1323,7 @@
|
||||
4CA0B30E15BCB70200654E32 /* Protocolls */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4CF6C715176F5183007A811D /* MPServerRequestHandler.h */,
|
||||
4CF6C715176F5183007A811D /* MPServerRequestHandling.h */,
|
||||
4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */,
|
||||
);
|
||||
name = Protocolls;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MPServerRequestHandler.h"
|
||||
#import "MPServerRequestHandling.h"
|
||||
|
||||
@interface MPAssociateRequestHandler : NSObject <MPServerRequestHandler>
|
||||
@interface MPAssociateRequestHandler : NSObject <MPServerRequestHandling>
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import "MPConnection.h"
|
||||
#import "HTTPMessage.h"
|
||||
#import "MPRequestHandlerService.h"
|
||||
#import "MPServerRequestHandler.h"
|
||||
#import "MPServerRequestHandling.h"
|
||||
|
||||
|
||||
NSString *const MPRequestTypeKey = @"RequestType";
|
||||
@@ -67,7 +67,7 @@ NSString *const MPRequestTypeKey = @"RequestType";
|
||||
if(!requestType) {
|
||||
NSLog(@"Malformed Request. Missing request type");
|
||||
}
|
||||
id<MPServerRequestHandler> handler = [MPRequestHandlerService requestHandler:requestType];
|
||||
id<MPServerRequestHandling> handler = [MPRequestHandlerService requestHandler:requestType];
|
||||
[handler respondTo:aRequest];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
|
||||
@class KPKEntry;
|
||||
|
||||
/**
|
||||
* Service to querey for entries
|
||||
*/
|
||||
@interface MPDocumentQueryService : NSObject
|
||||
|
||||
+ (MPDocumentQueryService *)defaultService;
|
||||
+ (MPDocumentQueryService *)sharedService;
|
||||
|
||||
- (KPKEntry *)configurationEntry;
|
||||
- (KPKEntry *)createConfigurationEntry;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
@implementation MPDocumentQueryService
|
||||
|
||||
+ (MPDocumentQueryService *)defaultService {
|
||||
+ (MPDocumentQueryService *)sharedService {
|
||||
static id instance;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
@@ -32,20 +32,18 @@
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
static const Byte uuidBytes[] = {
|
||||
static const uuid_t uuidBytes = {
|
||||
0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0,
|
||||
0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31
|
||||
};
|
||||
NSData *data = [NSData dataWithBytes:uuidBytes length:16];
|
||||
rootUuid = [[NSUUID alloc] initWithData:data];
|
||||
rootUuid = [[NSUUID alloc] initWithUUIDBytes:uuidBytes];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (KPKEntry *)configurationEntry {
|
||||
/*
|
||||
We are looking in all document,
|
||||
We are looking in all documents,
|
||||
but only store the key in one.
|
||||
*/
|
||||
NSArray *documents = [[NSDocumentController sharedDocumentController] documents];
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol MPServerRequestHandler;
|
||||
@protocol MPServerRequestHandling;
|
||||
|
||||
//FOUNDATION_EXPORT NSString *const MPRequestTypeAssociate;
|
||||
//FOUNDATION_EXPORT NSString *const MPRequestTypeTestAssociate;
|
||||
FOUNDATION_EXPORT NSString *const MPRequestTypeGetLogins;
|
||||
FOUNDATION_EXPORT NSString *const MPRequestTypeGetLoginsCount;
|
||||
FOUNDATION_EXPORT NSString *const MPRequestTypeGetAllLogins;
|
||||
FOUNDATION_EXPORT NSString *const MPRequestTypeSetLogin;
|
||||
FOUNDATION_EXPORT NSString *const MPRequestTypeGeneratePassword;
|
||||
|
||||
/**
|
||||
* Servive class to be called for getting specific request handler for indifidual reuqest
|
||||
* The service is identified by a string
|
||||
*/
|
||||
@interface MPRequestHandlerService : NSObject
|
||||
|
||||
+ (id<MPServerRequestHandler>)requestHandler:(NSString *)identifier;
|
||||
+ (id<MPServerRequestHandling>)requestHandler:(NSString *)identifier;
|
||||
|
||||
+ (BOOL)validKeyProposal;
|
||||
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
//
|
||||
|
||||
#import "MPRequestHandlerService.h"
|
||||
#import "MPServerRequestHandler.h"
|
||||
#import "MPServerRequestHandling.h"
|
||||
#import "MPAssociateRequestHandler.h"
|
||||
#import "MPTestAssociateRequestHandler.h"
|
||||
|
||||
//NSString *const MPRequestTypeAssociate = @"associate";
|
||||
//NSString *const MPRequestTypeTestAssociate = @"test-associate";
|
||||
NSString *const MPRequestTypeGetLogins = @"get-logins";
|
||||
NSString *const MPRequestTypeGetLoginsCount = @"get-logins-count";
|
||||
NSString *const MPRequestTypeGetAllLogins = @"get-all-logins";
|
||||
@@ -21,11 +19,11 @@ NSString *const MPRequestTypeGeneratePassword = @"generate-password";
|
||||
|
||||
@implementation MPRequestHandlerService
|
||||
|
||||
+ (id<MPServerRequestHandler>)requestHandler:(NSString *)identifier {
|
||||
return [self requestHander][identifier];
|
||||
+ (id<MPServerRequestHandling>)requestHandler:(NSString *)identifier {
|
||||
return [self requestHandler][identifier];
|
||||
}
|
||||
|
||||
+ (NSDictionary *)requestHander {
|
||||
+ (NSDictionary *)requestHandler {
|
||||
static NSDictionary *requestHandler;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#import "HTTPServer.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPConnection.h"
|
||||
#import "MPServerRequestHandler.h"
|
||||
#import "MPServerRequestHandling.h"
|
||||
|
||||
@interface MPServerDaemon () {
|
||||
@private
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol MPServerRequestHandler <NSObject>
|
||||
@protocol MPServerRequestHandling <NSObject>
|
||||
|
||||
@required
|
||||
- (NSString *)identifier;
|
||||
@@ -7,8 +7,8 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MPServerRequestHandler.h"
|
||||
#import "MPServerRequestHandling.h"
|
||||
|
||||
@interface MPTestAssociateRequestHandler : NSObject <MPServerRequestHandler>
|
||||
@interface MPTestAssociateRequestHandler : NSObject <MPServerRequestHandling>
|
||||
|
||||
@end
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
}
|
||||
|
||||
- (void)respondTo:(NSDictionary *)data {
|
||||
MPDocumentQueryService *service = [MPDocumentQueryService defaultService];
|
||||
MPDocumentQueryService *service = [MPDocumentQueryService sharedService];
|
||||
if(![service configurationEntry]) {
|
||||
return; //Nothing to do
|
||||
}
|
||||
//TestRequestedData
|
||||
/*
|
||||
Test request data
|
||||
store entry db as main db?
|
||||
*/
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user