Kaydet (Commit) 1ffc4df4 authored tarafından siqi's avatar siqi

threading fixes & preview screen

Change-Id: Ifc80aee5c2fa5f73a0115c840f11f1140dde810a
üst ae7496a4
......@@ -16,18 +16,5 @@
landmarkName = "@implementation libreoffice_sdremoteViewController"
landmarkType = "3">
</FileBreakpoint>
<FileBreakpoint
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "iosremote/Communication/SlideShow.m"
timestampString = "393177884.882194"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "57"
endingLineNumber = "57"
landmarkName = "-init"
landmarkType = "5">
</FileBreakpoint>
</FileBreakpoints>
</Bucket>
......@@ -88,13 +88,17 @@
//Setup mInputStream
self.inputStream = (__bridge NSInputStream *)readStream;
[self.inputStream setDelegate:self];
[self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
dispatch_async(dispatch_get_main_queue(), ^{
[self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
});
[self.inputStream open];
//Setup outputstream
self.outputStream = (__bridge NSOutputStream *)writeStream;
[self.outputStream setDelegate:self];
[self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
dispatch_async(dispatch_get_main_queue(), ^{
[self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
});
[self.outputStream open];
NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.name, @"\n", self.pin, @"\n\n", nil];
......@@ -118,8 +122,7 @@ int count = 0;
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
switch(eventCode) {
case NSStreamEventOpenCompleted:{
NSLog(@"Connection established");
if (count == 1) {
[self stopConnectionTimeoutTimer];
[[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.connected" object:nil];
} else {
count++;
......
......@@ -35,6 +35,7 @@
if ([command count] == 0) {
return;
}
NSLog(@"Command:%@", command);
NSString *instruction = [command objectAtIndex:0];
if([instruction isEqualToString:@"slideshow_started"]){
......
......@@ -9,13 +9,13 @@
#import <Foundation/Foundation.h>
@class slideShowViewController;
@class slideShowPreview_vc;
@interface SlideShow : NSObject
@property uint size;
@property uint currentSlide;
@property (nonatomic, strong) slideShowViewController* delegate;
@property (nonatomic, strong) slideShowPreview_vc* delegate;
- (void) putImage: (NSString *)img AtIndex: (uint) index;
- (void) putNotes: (NSString *)notes AtIndex: (uint) index;
......
......@@ -9,8 +9,8 @@
#import "SlideShow.h"
#import "Base64.h"
#import "slideShowPreview_vc.h"
#import <dispatch/dispatch.h>
#import "slideShowViewController.h"
@interface SlideShow()
......@@ -39,28 +39,28 @@ dispatch_queue_t backgroundQueue;
_currentSlide = 0;
backgroundQueue = dispatch_queue_create("org.libreoffice.iosremote.bgqueue", NULL);
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
// NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.slideShowImageReadyObserver =[[NSNotificationCenter defaultCenter]
addObserverForName:@"storage_update_image_ready"
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedImage) {
[self.delegate.image setImage:[self getImageAtIndex:self.lastRequestedImage]];
self.lastRequestedImage = -1;
}
}];
// self.slideShowImageReadyObserver =[[NSNotificationCenter defaultCenter]
// addObserverForName:@"storage_update_image_ready"
// object:nil
// queue:mainQueue
// usingBlock:^(NSNotification *note) {
// if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedImage) {
// [self.delegate.image setImage:[self getImageAtIndex:self.lastRequestedImage]];
// self.lastRequestedImage = -1;
// }
// }];
self.slideShowNoteReadyObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"storage_update_note_ready"
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedNote) {
[self.delegate.lecturer_notes loadHTMLString:[self getNotesAtIndex:self.lastRequestedNote] baseURL:nil];
self.lastRequestedNote = -1;
}
}];
// self.slideShowNoteReadyObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"storage_update_note_ready"
// object:nil
// queue:mainQueue
// usingBlock:^(NSNotification *note) {
// if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedNote) {
// [self.delegate.lecturer_notes loadHTMLString:[self getNotesAtIndex:self.lastRequestedNote] baseURL:nil];
// self.lastRequestedNote = -1;
// }
// }];
return self;
}
......
//
// pinValidation_vcViewController.m
// iosremote
//
// Created by Liu Siqi on 7/4/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "pinValidation_vc.h"
#import "slideShowPreview_vc.h"
#import "SlideShow.h"
#import "CommandInterpreter.h"
#import "CommunicationManager.h"
@interface pinValidation_vc ()
@property (nonatomic, strong) CommunicationManager *comManager;
@property (nonatomic, strong) id slideShowPreviewStartObserver;
@end
@implementation pinValidation_vc
@synthesize comManager = _comManager;
@synthesize slideShowPreviewStartObserver = _slideShowPreviewStartObserver;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.comManager = [CommunicationManager sharedComManager];
[self.pinLabel setText:[NSString stringWithFormat:@"%@", [self.comManager getPairingPin]]];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.slideShowPreviewStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
[self performSegueWithIdentifier:@"pinValidated" sender:self ];
}];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"pinValidated"]) {
slideShowPreview_vc *destViewController = segue.destinationViewController;
destViewController.slideshow = [self.comManager.interpreter slideShow];
[destViewController.slideshow setDelegate:destViewController];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidUnload {
[self setPinLabel:nil];
[self setStatusLabel:nil];
[super viewDidUnload];
}
@end
......@@ -47,6 +47,14 @@
self.comManager = [CommunicationManager sharedComManager];
self.serverTable.dataSource = self;
self.serverTable.delegate = self;
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.slideShowPreviewStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
[self performSegueWithIdentifier:@"SlideShowPreview" sender:self ];
}];
}
-(void)viewWillAppear:(BOOL)animated
......@@ -63,6 +71,11 @@
#pragma mark - Table view delegate
- (void)disableSpinner
{
[self.tableView cellForRowAtIndexPath:self.lastSpinningCellIndex].accessoryView = nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
......
//
// slideShowPreviewTable_vc.h
// iosremote
//
// Created by Liu Siqi on 7/4/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface slideShowPreviewTable_vc : UITableViewController
@end
//
// slideShowPreviewTable_vc.m
// iosremote
//
// Created by Liu Siqi on 7/4/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "slideShowPreviewTable_vc.h"
@interface slideShowPreviewTable_vc ()
@property (nonatomic, strong) UIButton * startButton;
@end
@implementation slideShowPreviewTable_vc
@synthesize startButton = _startButton;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
-(IBAction)startPresentationAction:(id)sender {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Reset"
message:@"You just pressed the Reset button"
delegate:self
cancelButtonTitle:@"Acknowledged"
otherButtonTitles:nil];
[alert show];
}
- (UIButton *)startButton{
if (self.startButton == nil)
{
self.startButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.startButton.frame = CGRectMake(20.0, 40 , 95.0, 37.0);
[self.startButton setTitle:@"Start Presentation" forState:UIControlStateNormal];
self.startButton.backgroundColor = [UIColor clearColor];
[self.startButton addTarget:self action:@selector(startPresentationAction:) forControlEvents:UIControlEventTouchDown];
self.startButton.tag = 1;
}
return self.startButton;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 100.0)];
[customView addSubview:self.startButton];
return customView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 100.0;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
}
- (void)viewDidUnload {
[super viewDidUnload];
}
@end
//
// slideShowPreview_vc.h
// iosremote
//
// Created by Liu Siqi on 7/4/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <UIKit/UIKit.h>
@class SlideShow;
@interface slideShowPreview_vc : UITableViewController
@property (nonatomic, strong) SlideShow* slideshow;
@property (nonatomic, strong) id slideShowImageReadyObserver;
@property (nonatomic, strong) id slideShowNoteReadyObserver;
@end
//
// slideShowPreview_vc.m
// iosremote
//
// Created by Liu Siqi on 7/4/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "slideShowPreview_vc.h"
#import "SlideShow.h"
#import "CommunicationManager.h"
@interface slideShowPreview_vc ()
@property (nonatomic, strong) CommunicationManager* comManager;
@end
@implementation slideShowPreview_vc
@synthesize slideshow = _slideshow;
@synthesize slideShowImageReadyObserver = _slideShowImageReadyObserver;
@synthesize slideShowNoteReadyObserver = _slideShowNoteReadyObserver;
@synthesize comManager = _comManager;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
// NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
// self.slideShowImageReadyObserver =[center addObserverForName:MSG_SLIDE_CHANGED
// object:nil
// queue:mainQueue
// usingBlock:^(NSNotification *note) {
// NSLog(@"Getting slide: %u image to display: %@", self.slideshow.currentSlide, [self.slideshow getImageAtIndex:self.slideshow.currentSlide]);
//
// [self.image setImage:[self.slideshow getImageAtIndex:self.slideshow.currentSlide]];
// [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:self.slideshow.currentSlide]baseURL:nil];
// }];
//
// self.slideShowNoteReadyObserver = [center addObserverForName:STATUS_CONNECTED_NOSLIDESHOW
// object:nil
// queue:mainQueue
// usingBlock:^(NSNotification *note) {
// [self.navigationController popViewControllerAnimated:YES];
// }];
// [self.image setImage:[self.slideshow getImageAtIndex:0]];
self.comManager = [CommunicationManager sharedComManager];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment