diff options
author | siqi <me@siqi.fr> | 2013-06-11 22:44:00 +0200 |
---|---|---|
committer | siqi <me@siqi.fr> | 2013-06-12 09:01:33 +0200 |
commit | 22e4465d8cbc7b8cbc29948705994284c84475a1 (patch) | |
tree | 862e54b9adb17d49024214aa5bb44eff594e1358 /ios | |
parent | 5705833197bceff4fc1be5bd179d8eff3225b386 (diff) |
loading existing server lsit
Diffstat (limited to 'ios')
6 files changed, 47 insertions, 2 deletions
diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h index 3612a5039d49..93046a188a77 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.h +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h @@ -8,6 +8,9 @@ #import <Foundation/Foundation.h> +#import "Client.h" +#import "Server.h" +#import "CommandInterpreter.h" #define MSG_SLIDESHOW_STARTED @"SLIDESHOW_STARTED" #define MSG_SLIDE_CHANGED @"SLIDE_CHANGED" diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m index 2be29fcfb4e5..a62988611365 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.m +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m @@ -16,6 +16,8 @@ @interface CommunicationManager() @property (nonatomic, strong) Client* client; +@property (nonatomic, strong) CommandInterpreter* interpreter; +@property (atomic, strong) NSMutableArray* servers; @end @@ -24,6 +26,8 @@ @synthesize client = _client; @synthesize state = _state; +@synthesize interpreter = _interpreter; +@synthesize servers = _servers; + (CommunicationManager *)sharedComManager { @@ -45,6 +49,26 @@ return self; } +- (id) initWithExistingServers +{ + self = [self init]; + + NSUserDefaults * userDefaluts = [NSUserDefaults standardUserDefaults]; + + if(!userDefaluts) + NSLog(@"userDefaults nil"); + + NSData *dataRepresentingExistingServers = [userDefaluts objectForKey:@"ExistingServers"]; + if (dataRepresentingExistingServers != nil) + { + NSArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingExistingServers]; + if (oldSavedArray != nil) + self.servers = [[NSMutableArray alloc] initWithArray:oldSavedArray]; + else + self.servers = [[NSMutableArray alloc] init]; + } +} + + (id)allocWithZone:(NSZone *)zone { return [self sharedComManager]; diff --git a/ios/iosremote/iosremote/Communication/Server.h b/ios/iosremote/iosremote/Communication/Server.h index ceeff1ff0ef4..0fb6c9df0c74 100644 --- a/ios/iosremote/iosremote/Communication/Server.h +++ b/ios/iosremote/iosremote/Communication/Server.h @@ -10,7 +10,7 @@ typedef enum protocol {NETWORK} Protocol_t; -@interface Server : NSObject +@interface Server : NSObject <NSCoding> @property (nonatomic) Protocol_t protocol; @property (nonatomic, strong) NSString* serverName; diff --git a/ios/iosremote/iosremote/Communication/Server.m b/ios/iosremote/iosremote/Communication/Server.m index 08061ffca485..71547c77108e 100644 --- a/ios/iosremote/iosremote/Communication/Server.m +++ b/ios/iosremote/iosremote/Communication/Server.m @@ -16,11 +16,28 @@ @implementation Server + @synthesize protocol = _protocol; @synthesize serverName = _serverName; @synthesize serverAddress = _serverAddress; +- (void)encodeWithCoder:(NSCoder *)coder; +{ + [coder encodeObject:self.serverName forKey:@"name"]; + [coder encodeObject:self.serverAddress forKey:@"address"]; + [coder encodeInteger:self.protocol forKey:@"protocol"]; +} + +- (id)initWithCoder:(NSCoder *)coder; +{ + self = [self initWithProtocol:[coder decodeIntegerForKey:@"protocol"] + atAddress:[coder decodeObjectForKey:@"address"] + ofName:[coder decodeObjectForKey:@"name"]]; + return self; +} + + - (id)initWithProtocol:(Protocol_t)protocal atAddress:(NSString*) address ofName:(NSString*) name diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m index 7cecc7067b77..dfecb9f8f71f 100644 --- a/ios/iosremote/iosremote/Communication/SlideShow.m +++ b/ios/iosremote/iosremote/Communication/SlideShow.m @@ -35,7 +35,6 @@ NSData* data = [NSData dataWithBase64String:img]; UIImage* image = [UIImage imageWithData:data]; [self.imagesArray insertObject:image atIndex:index]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"IMAGE_READY" object:nil]; } diff --git a/ios/iosremote/iosremote/slideShowViewController.m b/ios/iosremote/iosremote/slideShowViewController.m index f39bead78137..d79cb28a5d98 100644 --- a/ios/iosremote/iosremote/slideShowViewController.m +++ b/ios/iosremote/iosremote/slideShowViewController.m @@ -34,6 +34,8 @@ NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; + [self.image setImage:[self.slideshow getImageAtIndex:0]]; + [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil]; self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil queue:mainQueue usingBlock:^(NSNotification *note) { NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]); |