Added more handler stubs

This commit is contained in:
michael starke
2013-06-17 21:49:00 +02:00
parent ed78068a6d
commit 510113156d
9 changed files with 128 additions and 24 deletions

View File

@@ -146,6 +146,8 @@
4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4CB9339716D3A0DD00A13B5D /* Credits.rtf */; };
4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */; };
4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */; };
4CC299FF176F99E50050C939 /* MPRequestHandlerService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC299FE176F99E50050C939 /* MPRequestHandlerService.m */; };
4CC29A02176F9D140050C939 /* MPTestAssociateRequestHanlder.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC29A01176F9D140050C939 /* MPTestAssociateRequestHanlder.m */; };
4CC3AABD175F4983003EF01B /* HNHRoundedTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */; };
4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */; };
4CD78ABC16D155FF00768A1D /* 07_NotepadTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78AB716D155FF00768A1D /* 07_NotepadTemplate.pdf */; };
@@ -450,6 +452,10 @@
4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsHelper.m; sourceTree = "<group>"; };
4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbTree+MPAdditions.h"; sourceTree = "<group>"; };
4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbTree+MPAdditions.m"; sourceTree = "<group>"; };
4CC299FD176F99E50050C939 /* MPRequestHandlerService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRequestHandlerService.h; sourceTree = "<group>"; };
4CC299FE176F99E50050C939 /* MPRequestHandlerService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPRequestHandlerService.m; sourceTree = "<group>"; };
4CC29A00176F9D140050C939 /* MPTestAssociateRequestHanlder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTestAssociateRequestHanlder.h; sourceTree = "<group>"; };
4CC29A01176F9D140050C939 /* MPTestAssociateRequestHanlder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTestAssociateRequestHanlder.m; sourceTree = "<group>"; };
4CC3AAB8175F4983003EF01B /* HNHRoundedTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundedTextFieldCell.h; sourceTree = "<group>"; };
4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHRoundedTextFieldCell.m; sourceTree = "<group>"; };
4CC6258F15BA1C99002F5B11 /* MPOutlineViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineViewDelegate.h; sourceTree = "<group>"; };
@@ -662,6 +668,10 @@
4CF7805C176E71170032EE71 /* MPServerDaemon.m */,
4CF6C716176F5234007A811D /* MPAssociateRequestHandler.h */,
4CF6C717176F5234007A811D /* MPAssociateRequestHandler.m */,
4CC29A00176F9D140050C939 /* MPTestAssociateRequestHanlder.h */,
4CC29A01176F9D140050C939 /* MPTestAssociateRequestHanlder.m */,
4CC299FD176F99E50050C939 /* MPRequestHandlerService.h */,
4CC299FE176F99E50050C939 /* MPRequestHandlerService.m */,
);
name = Server;
sourceTree = "<group>";
@@ -1371,6 +1381,8 @@
4CF78064176E75AD0032EE71 /* MPServerSettingsController.m in Sources */,
4CF6C711176F4533007A811D /* MPStringLengthValueTransformer.m in Sources */,
4CF6C718176F5234007A811D /* MPAssociateRequestHandler.m in Sources */,
4CC299FF176F99E50050C939 /* MPRequestHandlerService.m in Sources */,
4CC29A02176F9D140050C939 /* MPTestAssociateRequestHanlder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -10,7 +10,7 @@
@implementation MPAssociateRequestHandler
+ (NSString *)identifyer {
- (NSString *)identifier {
return @"associate";
}

View File

@@ -8,24 +8,14 @@
#import "MPConnection.h"
#import "HTTPMessage.h"
#import "MPRequestHandlerService.h"
#import "MPServerRequestHandler.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";
NSString *const MPRequestTypeSetLogin = @"set-login";
NSString *const MPRequestTypeGeneratePassword = @"generate-password";
NSString *const MPRequestTypeKey = @"RequestType";
@implementation MPConnection
+ (NSArray *)requestHander {
}
- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path
{
// Override me to support methods such as POST.
@@ -52,7 +42,7 @@ NSString *const MPRequestTypeKey = @"RequestType";
NSError *error = nil;
id obj = [NSJSONSerialization JSONObjectWithData:[request body] options:0 error:&error];
if(error) {
NSLog(@"Error while parsing request:%@", [error localizedDescription]);
NSLog(@"Error while parsing JSON request data:%@", [error localizedDescription]);
}
if([obj isKindOfClass:[NSDictionary class]]) {
NSDictionary *requestDict = obj;
@@ -74,13 +64,7 @@ NSString *const MPRequestTypeKey = @"RequestType";
if(!requestType) {
NSLog(@"Malformed Request. Missing request type");
}
NSLog(@"%@", requestType);
if([requestType isEqualToString:MPRequestTypeAssociate]) {
return;
}
if([requestType isEqualToString:MPRequestTypeGeneratePassword]) {
return;
}
id<MPServerRequestHandler> handler = [MPRequestHandlerService requestHandler:requestType];
[handler respondTo:aRequest];
}
@end

View File

@@ -0,0 +1,25 @@
//
// MPRequestHandlerService.h
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol MPServerRequestHandler;
//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;
@interface MPRequestHandlerService : NSObject
+ (id<MPServerRequestHandler>)requestHandler:(NSString *)identifier;
@end

View File

@@ -0,0 +1,48 @@
//
// MPRequestHandlerService.m
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPRequestHandlerService.h"
#import "MPServerRequestHandler.h"
#import "MPAssociateRequestHandler.h"
#import "MPTestAssociateRequestHanlder.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";
NSString *const MPRequestTypeSetLogin = @"set-login";
NSString *const MPRequestTypeGeneratePassword = @"generate-password";
@implementation MPRequestHandlerService
+ (id<MPServerRequestHandler>)requestHandler:(NSString *)identifier {
return [self requestHander][identifier];
}
+ (NSDictionary *)requestHander {
static NSDictionary *requestHandler;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
requestHandler = [[self _setupHandlerDictionary] retain];
});
return requestHandler;
}
+ (NSDictionary *)_setupHandlerDictionary {
MPAssociateRequestHandler *associateHandler = [[MPAssociateRequestHandler alloc] init];
MPTestAssociateRequestHanlder *testAssociateHandler = [[MPTestAssociateRequestHanlder alloc] init];
NSDictionary *handlerDict = @{
[associateHandler identifier] : associateHandler,
[testAssociateHandler identifier] : testAssociateHandler
};
[associateHandler release];
return handlerDict;
}
@end

View File

@@ -11,7 +11,7 @@
@protocol MPServerRequestHandler <NSObject>
@required
+ (NSString *)identifyer;
- (NSString *)identifier;
- (void)respondTo:(NSDictionary *)data;
@end

View File

@@ -0,0 +1,14 @@
//
// MPTestAssociateRequestHanlder.h
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MPServerRequestHandler.h"
@interface MPTestAssociateRequestHanlder : NSObject <MPServerRequestHandler>
@end

View File

@@ -0,0 +1,21 @@
//
// MPTestAssociateRequestHanlder.m
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPTestAssociateRequestHanlder.h"
@implementation MPTestAssociateRequestHanlder
- (NSString *)identifier {
return @"test-associate";
}
- (void)respondTo:(NSDictionary *)data {
}
@end

View File

@@ -48,7 +48,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>561</string>
<string>573</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>