Permalink
Browse files

add Logger and Gateway

  • Loading branch information...
1 parent 13d9cb3 commit fd6853c6222b51c28649e7f2d7cacc6cea6f0308 @Malaar committed Mar 11, 2012
View
@@ -1 +1,16 @@
-.DS_Store
+/build/
+Builds
+.DS_Store
+build.output
+*.xcodeproj/project.xcworkspace/xcuserdata/*
+*.xcodeproj/xcuserdata/*
+pkg/
+*.xcodeproj/**
+!*.xcodeproj/*.pbxproj
+
+*.xcworkspace/**
+!*.xcworkspace/*.xcworkspacedata
+
+Pods
+Podfile.lock
+.idea
View
@@ -0,0 +1,26 @@
+//
+// MUGateway.h
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "MUGatewayTask.h"
+#import "MUHTTPClient.h"
+#import "MUGatewayResponse.h"
+
+typedef void(^MUGatewayCallback)(MUGatewayResponse* aResponse);
+
+@interface MUGateway : NSObject
+{
+ MUHTTPClient* httpClient;
+
+ MUGatewayTask* startingTask;
+}
+
+- (void) configureHTTPClientWithBaseURL:(NSURL*)aBaseURL;
+- (void) httpRequestOperationDidEnqueue:(AFHTTPRequestOperation *)operation;
+
+@end
View
@@ -0,0 +1,42 @@
+//
+// MUGateway.m
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MUGateway.h"
+
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+@implementation MUGateway
+
+//==============================================================================
+- (void) dealloc
+{
+ [httpClient release];
+
+ [super dealloc];
+}
+
+//==============================================================================
+- (void) configureHTTPClientWithBaseURL:(NSURL*)aBaseURL
+{
+ [httpClient release];
+ httpClient = [[MUHTTPClient alloc] initWithBaseURL:aBaseURL];
+}
+
+//==============================================================================
+- (void) httpRequestOperationDidEnqueue:(AFHTTPRequestOperation *)anOperation
+{
+ MUGatewayTask* task = [MUGatewayTask taskWithGateway:self operation:anOperation];
+ startingTask = task;
+}
+
+//==============================================================================
+//==============================================================================
+
+@end
@@ -0,0 +1,18 @@
+//
+// MUGatewayResponse.h
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface MUGatewayResponse : NSObject
+
+@property (nonatomic, assign) NSInteger responseCode;
+@property (nonatomic, retain) NSString* textMessage;
+@property (nonatomic, readonly) NSMutableDictionary* dataDictionary;
+@property (nonatomic, readonly) NSMutableArray* boArray;
+
+@end
@@ -0,0 +1,37 @@
+//
+// MUGatewayResponse.m
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MUGatewayResponse.h"
+
+@implementation MUGatewayResponse
+
+@synthesize responseCode, textMessage, dataDictionary, boArray;
+
+//==============================================================================
+- (id)init
+{
+ self = [super init];
+ if(self)
+ {
+ dataDictionary = [NSMutableDictionary new];
+ boArray = [NSMutableArray new];
+ }
+ return self;
+}
+
+//==============================================================================
+- (void) dealloc
+{
+ [textMessage release];
+ [dataDictionary release];
+ [boArray release];
+
+ [super dealloc];
+}
+
+@end
@@ -0,0 +1,24 @@
+//
+// MUGatewayTask.h
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "AFHTTPRequestOperation.h"
+
+@class MUGateway;
+
+@interface MUGatewayTask : NSObject
+
+@property (nonatomic, readonly) MUGateway* gateway;
+@property (nonatomic, readonly) AFHTTPRequestOperation* operation;
+
++ (id) taskWithGateway:(MUGateway*)aGateway operation:(AFHTTPRequestOperation*)anOperation;
+- (id) initWithGateway:(MUGateway*)aGateway operation:(AFHTTPRequestOperation*)anOperation;
+
+- (void) cancel;
+
+@end
@@ -0,0 +1,48 @@
+//
+// MUGatewayTask.m
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MUGatewayTask.h"
+#import "MUGateway.h"
+
+
+@implementation MUGatewayTask
+
+@synthesize gateway;
+@synthesize operation;
+
+//==============================================================================
++ (id) taskWithGateway:(MUGateway*)aGateway operation:(AFHTTPRequestOperation*)anOperation
+{
+ return [[[MUGatewayTask alloc] initWithGateway:aGateway operation:anOperation] autorelease];
+}
+
+//==============================================================================
+- (id) init
+{
+ [self release];
+ return nil;
+}
+
+//==============================================================================
+- (id) initWithGateway:(MUGateway*)aGateway operation:(AFHTTPRequestOperation*)anOperation
+{
+ if( (self = [super init]) )
+ {
+ gateway = aGateway;
+ operation = anOperation;
+ }
+ return self;
+}
+
+//==============================================================================
+- (void) cancel
+{
+ [operation cancel];
+}
+
+@end
@@ -0,0 +1,18 @@
+//
+// MUHTTPClient.h
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "AFNetworking.h"
+
+
+@class MUGateway;
+
+@interface MUHTTPClient : AFHTTPClient
+
+@property (nonatomic, assign) MUGateway* gatewayDelegate;
+
+@end
@@ -0,0 +1,24 @@
+//
+// MUHTTPClient.m
+// MUGatewayTest
+//
+// Created by Malaar on 11.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MUHTTPClient.h"
+#import "MUGateway.h"
+
+
+@implementation MUHTTPClient
+
+@synthesize gatewayDelegate;
+
+//==============================================================================
+- (void) enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation
+{
+ [gatewayDelegate httpRequestOperationDidEnqueue:operation];
+ [super enqueueHTTPRequestOperation:operation];
+}
+
+@end
@@ -0,0 +1,23 @@
+//
+// MULogConsumer.h
+// MULogger
+//
+// Created by Malaar on 04.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "MULogFormatter.h"
+
+@interface MULogConsumer : NSObject
+{
+ NSObject<MULogFormatter>* formatter;
+}
+
+@property (nonatomic, readonly) NSObject<MULogFormatter>* formatter;
+
++ (id) consumerWithFormatter:(NSObject<MULogFormatter>*)aLogFormatter;
+- (id) initWithFormatter:(NSObject<MULogFormatter>*)aLogFormatter;
+- (void) consumeMessages:(NSArray*)aMessages;
+
+@end
@@ -0,0 +1,52 @@
+//
+// MULogConsumer.m
+// MULogger
+//
+// Created by Malaar on 04.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MULogConsumer.h"
+
+@implementation MULogConsumer
+
+@synthesize formatter;
+
+//==============================================================================
++ (id) consumerWithFormatter:(NSObject<MULogFormatter>*)aLogFormatter
+{
+ return [[[[self class] alloc] initWithFormatter:aLogFormatter] autorelease];
+}
+
+//==============================================================================
+- (id) init
+{
+ [self release];
+ return nil;
+}
+
+//==============================================================================
+- (id) initWithFormatter:(NSObject<MULogFormatter>*)aLogFormatter
+{
+ if( (self = [super init]) )
+ {
+ formatter = [aLogFormatter retain];
+ }
+ return self;
+}
+
+//==============================================================================
+- (void) dealloc
+{
+ [formatter release];
+
+ [super dealloc];
+}
+
+//==============================================================================
+- (void) consumeMessages:(NSArray*)aMessages
+{
+ NSAssert(NO, @"Owerride this method in subclasses!");
+}
+
+@end
@@ -0,0 +1,25 @@
+//
+// MULogConsumerFile.h
+// MULogger
+//
+// Created by Malaar on 04.03.12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "MULogConsumer.h"
+
+
+//typedef enum MULogUpdateFilePolicy
+//{
+// updateFilePolicyByDate,
+// updateFilePolicyBySize
+//
+//} MULogUpdateFilePolicy;
+
+@interface MULogConsumerFile : MULogConsumer
+{
+}
+
+@property (nonatomic, retain) NSString* filePath;
+
+@end
Oops, something went wrong.

0 comments on commit fd6853c

Please sign in to comment.