Code style fixes
authorRobert Corrigan <corrigan@rohrer.com>
Thu, 20 Oct 2016 15:22:08 +0000 (11:22 -0400)
committerRobert Corrigan <corrigan@rohrer.com>
Thu, 20 Oct 2016 15:22:08 +0000 (11:22 -0400)
client/Mac/MRDPView.m
client/Mac/PasswordDialog.h
client/Mac/PasswordDialog.m
client/Mac/cli/AppDelegate.m

index 48cfb28..a8c5805 100644 (file)
@@ -194,7 +194,7 @@ DWORD mac_client_thread(void* param)
                if (settings->AsyncInput)
                {
                        if (!(inputThread = CreateThread(NULL, 0,
-                       (LPTHREAD_START_ROUTINE) mac_client_input_thread, context, 0, NULL)))
+                                                        (LPTHREAD_START_ROUTINE) mac_client_input_thread, context, 0, NULL)))
                        {
                                WLog_ERR(TAG,  "failed to create async input thread");
                                goto disconnect;
@@ -203,7 +203,7 @@ DWORD mac_client_thread(void* param)
                else
                {
                        if (!(inputEvent = freerdp_get_message_queue_event_handle(instance,
-                       FREERDP_INPUT_MESSAGE_QUEUE)))
+                                          FREERDP_INPUT_MESSAGE_QUEUE)))
                        {
                                WLog_ERR(TAG, "failed to get input event handle");
                                goto disconnect;
@@ -221,7 +221,7 @@ DWORD mac_client_thread(void* param)
                        if (!settings->AsyncTransport)
                        {
                                if (!(nCountTmp = freerdp_get_event_handles(context, &events[nCount],
-                               16 - nCount)))
+                                                 16 - nCount)))
                                {
                                        WLog_ERR(TAG, "freerdp_get_event_handles failed");
                                        break;
@@ -967,11 +967,11 @@ BOOL mac_authenticate(freerdp* instance, char** username, char** password,
 {
        mfContext* mfc = (mfContext*) instance->context;
        MRDPView* view = (MRDPView*) mfc->view;
-
        PasswordDialog* dialog = [PasswordDialog new];
        dialog.serverHostname = [NSString stringWithFormat:@"%@:%u",
-                                       [NSString stringWithCString:instance->settings->ServerHostname encoding:NSUTF8StringEncoding],
-                                       instance->settings->ServerPort];
+                                [NSString stringWithCString:instance->settings->ServerHostname encoding:
+                                 NSUTF8StringEncoding],
+                                instance->settings->ServerPort];
 
        if (*username)
                dialog.username = [NSString stringWithCString:*username encoding:
@@ -983,26 +983,24 @@ BOOL mac_authenticate(freerdp* instance, char** username, char** password,
 
        if (*domain)
                dialog.domain = [NSString stringWithCString:*domain encoding:
-                                  NSUTF8StringEncoding];
-
-       [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view window] waitUntilDone:TRUE];
+                                NSUTF8StringEncoding];
 
+       [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view
+               window] waitUntilDone:TRUE];
        BOOL ok = dialog.modalCode;
 
-       if (ok) 
+       if (ok)
        {
                const char* submittedUsername = [dialog.username cStringUsingEncoding:
                                                 NSUTF8StringEncoding];
                *username = malloc((strlen(submittedUsername) + 1) * sizeof(char));
                strcpy(*username, submittedUsername);
-
                const char* submittedPassword = [dialog.password cStringUsingEncoding:
                                                 NSUTF8StringEncoding];
                *password = malloc((strlen(submittedPassword) + 1) * sizeof(char));
                strcpy(*password, submittedPassword);
-
                const char* submittedDomain = [dialog.domain cStringUsingEncoding:
-                                                NSUTF8StringEncoding];
+                                              NSUTF8StringEncoding];
                *domain = malloc((strlen(submittedDomain) + 1) * sizeof(char));
                strcpy(*domain, submittedDomain);
        }
index e7fb9b6..833336e 100644 (file)
 @interface PasswordDialog : NSWindowController
 {
 @public
-    NSTextField* usernameText;
-    NSTextField* passwordText;
-    NSTextField* messageLabel;
-    NSString* serverHostname;
-    NSString* username;
-    NSString* password;
-    NSString* domain;
-    BOOL modalCode;
+       NSTextField* usernameText;
+       NSTextField* passwordText;
+       NSTextField* messageLabel;
+       NSString* serverHostname;
+       NSString* username;
+       NSString* password;
+       NSString* domain;
+       BOOL modalCode;
 }
-@property (retain) IBOutlet NSTextField* usernameText;
-@property (retain) IBOutlet NSTextField* passwordText;
-@property (retain) IBOutlet NSTextField* messageLabel;
+@property(retain) IBOutlet NSTextField* usernameText;
+@property(retain) IBOutlet NSTextField* passwordText;
+@property(retain) IBOutlet NSTextField* messageLabel;
 
 - (IBAction)onOK:(NSObject*)sender;
 - (IBAction)onCancel:(NSObject*)sender;
 
-@property (retain) NSString* serverHostname;
-@property (retain) NSString* username;
-@property (retain) NSString* password;
-@property (retain) NSString* domain;
-@property (readonly) BOOL modalCode;
+@property(retain) NSString* serverHostname;
+@property(retain) NSString* username;
+@property(retain) NSString* password;
+@property(retain) NSString* domain;
+@property(readonly) BOOL modalCode;
 
 - (BOOL) runModal:(NSWindow*)mainWindow;
 
index 37f4f18..01de275 100644 (file)
@@ -20,9 +20,9 @@
 #import "PasswordDialog.h"
 #import <freerdp/client/cmdline.h>
 
-@interface PasswordDialog ()
+@interface PasswordDialog()
 
-@property BOOL modalCode;
+       @property BOOL modalCode;
 
 @end
 
        [super windowDidLoad];
        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
        [self.window setTitle:self.serverHostname];
-       [messageLabel setStringValue:[NSString stringWithFormat:@"Authenticate to %@", self.serverHostname]];
-
+       [messageLabel setStringValue:[NSString stringWithFormat:@"Authenticate to %@",
+                                     self.serverHostname]];
        NSMutableString* domainUser = [[NSMutableString alloc] initWithString:@""];
 
-       if (self.domain != nil && [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] > 0)
+       if (self.domain != nil
+           && [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet
+                   whitespaceCharacterSet]] length] > 0)
        {
                [domainUser appendFormat:@"%@\\", self.domain];
        }
                [domainUser appendString:self.username];
                [self.window makeFirstResponder:passwordText];
        }
+
        [usernameText setStringValue:domainUser];
 }
 
-- (IBAction)onOK:(NSObject *)sender
+- (IBAction)onOK:(NSObject*)sender
 {
-       char *submittedUser = NULL;
-       char *submittedDomain = NULL;
+       charsubmittedUser = NULL;
+       charsubmittedDomain = NULL;
 
-       if (freerdp_parse_username([self.usernameText.stringValue cStringUsingEncoding:NSUTF8StringEncoding], &submittedUser, &submittedDomain)) {
-               self.username = [NSString stringWithCString: submittedUser encoding:NSUTF8StringEncoding];
-               self.domain = [NSString stringWithCString: submittedDomain encoding:NSUTF8StringEncoding];
-       } else {
+       if (freerdp_parse_username([self.usernameText.stringValue cStringUsingEncoding:
+                                   NSUTF8StringEncoding], &submittedUser, &submittedDomain))
+       {
+               self.username = [NSString stringWithCString: submittedUser encoding:
+                                NSUTF8StringEncoding];
+               self.domain = [NSString stringWithCString: submittedDomain encoding:
+                              NSUTF8StringEncoding];
+       }
+       else
+       {
                self.username = self.usernameText.stringValue;
        }
 
        [NSApp stopModalWithCode:TRUE];
 }
 
-- (IBAction)onCancel:(NSObject *)sender
+- (IBAction)onCancel:(NSObject*)sender
 {
        [NSApp stopModalWithCode:FALSE];
 }
 
 - (BOOL)runModal:(NSWindow*)mainWindow
 {
-       if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)]) {
-
+       if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)])
+       {
                [mainWindow beginSheet:self.window completionHandler:nil];
-
                self.modalCode = [NSApp runModalForWindow: self.window];
                [mainWindow endSheet: self.window];
-
-       } else {
+       }
+       else
+       {
                [NSApp beginSheet: self.window
-                       modalForWindow: mainWindow
-                       modalDelegate: nil
-                       didEndSelector: nil
-                       contextInfo: nil];
-
+                modalForWindow: mainWindow
+                modalDelegate: nil
+                didEndSelector: nil
+                contextInfo: nil];
                self.modalCode = [NSApp runModalForWindow: self.window];
                [NSApp endSheet: self.window];
        }
 
        [self.window orderOut:nil];
-
        return self.modalCode;
 }
 
        [username release];
        [password release];
        [domain release];
-
        [super dealloc];
 }
 
index 4920c35..ec40573 100644 (file)
 #import <freerdp/client/cmdline.h>
 
 static AppDelegate* _singleDelegate = nil;
-void AppDelegate_ConnectionResultEventHandler(void* context, ConnectionResultEventArgs* e);
+void AppDelegate_ConnectionResultEventHandler(void* context,
+        ConnectionResultEventArgs* e);
 void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e);
-void AppDelegate_EmbedWindowEventHandler(void* context, EmbedWindowEventArgs* e);
-void AppDelegate_ResizeWindowEventHandler(void* context, ResizeWindowEventArgs* e);
+void AppDelegate_EmbedWindowEventHandler(void* context,
+        EmbedWindowEventArgs* e);
+void AppDelegate_ResizeWindowEventHandler(void* context,
+        ResizeWindowEventArgs* e);
 void mac_set_view_size(rdpContext* context, MRDPView* view);
 
 @implementation AppDelegate
@@ -35,22 +38,17 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
 {
        int status;
        mfContext* mfc;
-
        _singleDelegate = self;
        [self CreateContext];
-
        status = [self ParseCommandLineArguments];
-
        mfc = (mfContext*) context;
        mfc->view = (void*) mrdpView;
 
        if (status < 0)
        {
-               NSString *winTitle;
+               NSStringwinTitle;
                winTitle = [[NSString alloc] initWithCString:"ERROR"];
-
                [window setTitle:winTitle];
-
        }
        else
        {
@@ -63,23 +61,27 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
                        context->instance->settings->DesktopHeight = screenFrame.size.height;
                }
 
-               PubSub_SubscribeConnectionResult(context->pubSub, AppDelegate_ConnectionResultEventHandler);
+               PubSub_SubscribeConnectionResult(context->pubSub,
+                                                AppDelegate_ConnectionResultEventHandler);
                PubSub_SubscribeErrorInfo(context->pubSub, AppDelegate_ErrorInfoEventHandler);
-               PubSub_SubscribeEmbedWindow(context->pubSub, AppDelegate_EmbedWindowEventHandler);
-               PubSub_SubscribeResizeWindow(context->pubSub, AppDelegate_ResizeWindowEventHandler);
-               
+               PubSub_SubscribeEmbedWindow(context->pubSub,
+                                           AppDelegate_EmbedWindowEventHandler);
+               PubSub_SubscribeResizeWindow(context->pubSub,
+                                            AppDelegate_ResizeWindowEventHandler);
                freerdp_client_start(context);
+               NSString* winTitle;
 
-               NSString *winTitle;
-               if ( mfc->context.settings->WindowTitle && mfc->context.settings->WindowTitle[0])
+               if (mfc->context.settings->WindowTitle && mfc->context.settings->WindowTitle[0])
                {
-                       winTitle = [[NSString alloc] initWithCString:mfc->context.settings->WindowTitle];
+                       winTitle = [[NSString alloc] initWithCString:
+                                   mfc->context.settings->WindowTitle];
                }
                else
                {
-                       winTitle = [[NSString alloc] initWithFormat:@"%@:%u", 
-                                       [NSString stringWithCString:mfc->context.settings->ServerHostname encoding:NSUTF8StringEncoding],
-                                       mfc->context.settings->ServerPort];
+                       winTitle = [[NSString alloc] initWithFormat:@"%@:%u",
+                                   [NSString stringWithCString:mfc->context.settings->ServerHostname encoding:
+                                    NSUTF8StringEncoding],
+                                   mfc->context.settings->ServerPort];
                }
 
                [window setTitle:winTitle];
@@ -90,14 +92,12 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
 {
        NSLog(@"Stopping...\n");
        freerdp_client_stop(context);
-
        [mrdpView releaseResources];
        _singleDelegate = nil;
-
        NSLog(@"Stopped.\n");
 }
 
-- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender
 {
        return YES;
 }
@@ -108,49 +108,41 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
        int length;
        int status;
        char* cptr;
-
        NSArray* args = [[NSProcessInfo processInfo] arguments];
-
        context->argc = (int) [args count];
        context->argv = malloc(sizeof(char*) * context->argc);
-       
        i = 0;
-       
-       for (NSString* str in args)
+
+       for (NSString * str in args)
        {
                /* filter out some arguments added by XCode */
-               
                if ([str isEqualToString:@"YES"])
                        continue;
-               
+
                if ([str isEqualToString:@"-NSDocumentRevisionsDebugMode"])
                        continue;
-               
-               length = (int) ([str length] + 1);
+
+               length = (int)([str length] + 1);
                cptr = (char*) malloc(length);
                strcpy(cptr, [str UTF8String]);
                context->argv[i++] = cptr;
        }
-       
-       context->argc = i;
-       
-       status = freerdp_client_settings_parse_command_line(context->settings, context->argc, context->argv, FALSE);
-       
-       status = freerdp_client_settings_command_line_status_print(context->settings, status, context->argc, context->argv);
 
+       context->argc = i;
+       status = freerdp_client_settings_parse_command_line(context->settings,
+                context->argc, context->argv, FALSE);
+       status = freerdp_client_settings_command_line_status_print(context->settings,
+                status, context->argc, context->argv);
        return status;
 }
 
 - (void) CreateContext
 {
        RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
-
        ZeroMemory(&clientEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
        clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
        clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
-
        RdpClientEntry(&clientEntryPoints);
-
        context = freerdp_client_context_new(&clientEntryPoints);
 }
 
@@ -158,15 +150,12 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
 {
        mfContext* mfc;
        MRDPView* view;
-       
        mfc = (mfContext*) context;
        view = (MRDPView*) mfc->view;
-       
        [view exitFullScreenModeWithOptions:nil];
        [view releaseResources];
        [view release];
-        mfc->view = nil;
-       
+       mfc->view = nil;
        freerdp_client_context_free(context);
        context = nil;
 }
@@ -180,20 +169,16 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
 {
        mfContext* mfc;
        MRDPView* view;
-
        mfc = (mfContext*) context;
        view = (MRDPView*) mfc->view;
-
        [view exitFullScreenModeWithOptions:nil];
-
        NSString* message = withMessage ? withMessage : @"Error connecting to server";
-
-       NSAlert *alert = [[NSAlert alloc] init];
+       NSAlert* alert = [[NSAlert alloc] init];
        [alert setMessageText:message];
        [alert beginSheetModalForWindow:[self window]
-                                         modalDelegate:self
-                                        didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
-                                               contextInfo:nil];
+        modalDelegate:self
+        didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
+        contextInfo:nil];
 }
 
 
@@ -201,7 +186,7 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
  * just a terminate selector for above call
  ***********************************************************************/
 
-- (void) alertDidEnd:(NSAlert *)a returnCode:(NSInteger)rc contextInfo:(void *)ci
+- (void) alertDidEnd:(NSAlert*)a returnCode:(NSInteger)rc contextInfo:(void*)ci
 {
        [NSApp terminate:nil];
 }
@@ -213,22 +198,26 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
  * On connection error, display message and quit application
  ***********************************************************************/
 
-void AppDelegate_ConnectionResultEventHandler(void* ctx, ConnectionResultEventArgs* e)
+void AppDelegate_ConnectionResultEventHandler(void* ctx,
+        ConnectionResultEventArgs* e)
 {
        NSLog(@"ConnectionResult event result:%d\n", e->result);
+
        if (_singleDelegate)
        {
                if (e->result != 0)
                {
                        NSString* message = nil;
+
                        if (connectErrorCode == AUTHENTICATIONERROR)
                        {
-                               message = [NSString stringWithFormat:@"%@", @"Authentication failure, check credentials."];
+                               message = [NSString stringWithFormat:@"%@",
+                                          @"Authentication failure, check credentials."];
                        }
-                       
-                       
+
                        // Making sure this should be invoked on the main UI thread.
-                       [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:) withObject:message waitUntilDone:FALSE];
+                       [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:)
+                        withObject:message waitUntilDone:FALSE];
                }
        }
 }
@@ -236,18 +225,21 @@ void AppDelegate_ConnectionResultEventHandler(void* ctx, ConnectionResultEventAr
 void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e)
 {
        NSLog(@"ErrorInfo event code:%d\n", e->code);
+
        if (_singleDelegate)
        {
                // Retrieve error message associated with error code
                NSString* message = nil;
+
                if (e->code != ERRINFO_NONE)
                {
                        const char* errorMessage = freerdp_get_error_info_string(e->code);
                        message = [[NSString alloc] initWithUTF8String:errorMessage];
                }
-               
+
                // Making sure this should be invoked on the main UI thread.
-               [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:) withObject:message waitUntilDone:TRUE];
+               [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:)
+                withObject:message waitUntilDone:TRUE];
                [message release];
        }
 }
@@ -255,17 +247,17 @@ void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e)
 void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
 {
        rdpContext* context = (rdpContext*) ctx;
-       
+
        if (_singleDelegate)
        {
                mfContext* mfc = (mfContext*) context;
                _singleDelegate->mrdpView = mfc->view;
-               
+
                if (_singleDelegate->window)
                {
                        [[_singleDelegate->window contentView] addSubview:mfc->view];
                }
-               
+
                mac_set_view_size(context, mfc->view);
        }
 }
@@ -273,9 +265,8 @@ void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
 void AppDelegate_ResizeWindowEventHandler(void* ctx, ResizeWindowEventArgs* e)
 {
        rdpContext* context = (rdpContext*) ctx;
-       
        fprintf(stderr, "ResizeWindowEventHandler: %d %d\n", e->width, e->height);
-       
+
        if (_singleDelegate)
        {
                mfContext* mfc = (mfContext*) context;
@@ -292,17 +283,14 @@ void mac_set_view_size(rdpContext* context, MRDPView* view)
        innerRect.size.width = context->settings->DesktopWidth;
        innerRect.size.height = context->settings->DesktopHeight;
        [view setFrame:innerRect];
-       
        // calculate window of same size, but keep position
        NSRect outerRect = [[view window] frame];
        outerRect.size = [[view window] frameRectForContentRect:innerRect].size;
-       
        // we are not in RemoteApp mode, disable larger than resolution
        [[view window] setContentMaxSize:innerRect.size];
-       
        // set window to given area
        [[view window] setFrame:outerRect display:YES];
-       
+
        if (context->settings->Fullscreen)
                [[view window] toggleFullScreen:nil];
 }