FreeRDP/client/Mac/cli/AppDelegate.m

107 lines
1.7 KiB
Mathematica
Raw Normal View History

//
// AppDelegate.m
// MacClient2
//
// Created by Benoît et Kathy on 2013-05-08.
//
//
#import "AppDelegate.h"
#import "MacFreeRDP/mfreerdp.h"
#import "MacFreeRDP/mf_client.h"
@implementation AppDelegate
- (void)dealloc
{
2013-06-23 04:27:23 +04:00
[super dealloc];
}
@synthesize window = window;
@synthesize mrdpView = mrdpView;
@synthesize context = context;
- (void) applicationDidFinishLaunching:(NSNotification*)aNotification
{
2013-06-23 04:27:23 +04:00
int status;
2013-06-23 06:55:51 +04:00
mfContext* mfc;
2013-06-23 04:27:23 +04:00
[self CreateContext];
status = [self ParseCommandLineArguments];
2013-06-23 06:55:51 +04:00
mfc = (mfContext*) context;
mfc->view = (void*) mrdpView;
2013-06-23 04:27:23 +04:00
if (status < 0)
{
}
else
{
2013-06-23 06:55:51 +04:00
freerdp_client_start(context);
2013-06-23 04:27:23 +04:00
}
}
- (void) applicationWillTerminate:(NSNotification*)notification
{
2013-06-23 04:27:23 +04:00
[mrdpView releaseResources];
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
2013-06-23 04:27:23 +04:00
return YES;
}
- (int) ParseCommandLineArguments
{
2013-06-23 04:27:23 +04:00
int i;
int len;
2013-06-23 06:55:51 +04:00
int status;
2013-06-23 04:27:23 +04:00
char* cptr;
int argc;
char** argv = nil;
2013-06-23 08:18:55 +04:00
NSArray* args = [[NSProcessInfo processInfo] arguments];
2013-06-23 04:27:23 +04:00
argc = (int) [args count];
2013-06-23 08:18:55 +04:00
argv = malloc(sizeof(char*) * argc);
i = 0;
2013-06-23 08:18:55 +04:00
for (NSString* str in args)
2013-06-23 04:27:23 +04:00
{
len = (int) ([str length] + 1);
2013-06-23 08:18:55 +04:00
cptr = (char*) malloc(len);
2013-06-23 04:27:23 +04:00
strcpy(cptr, [str UTF8String]);
argv[i++] = cptr;
}
2013-06-23 08:18:55 +04:00
status = freerdp_client_parse_command_line(context, argc, argv);
2013-06-23 04:27:23 +04:00
return status;
}
- (void) CreateContext
{
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
2013-06-23 04:27:23 +04:00
ZeroMemory(&clientEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
2013-06-23 04:27:23 +04:00
RdpClientEntry(&clientEntryPoints);
2013-06-23 04:27:23 +04:00
context = freerdp_client_context_new(&clientEntryPoints);
}
- (void) ReleaseContext
{
2013-06-23 08:18:55 +04:00
freerdp_client_context_free(context);
2013-06-23 04:27:23 +04:00
context = nil;
}
@end