mirror of https://github.com/FreeRDP/FreeRDP
- MRDPView: rdpConnectError moved outside of the Framework, to the native App (in AppDelegate) This is now handled on the client side.
- freerdp_connect: all code paths now trigger a ConnectionResult event.
This commit is contained in:
parent
2d90d5bb81
commit
20d3518c6b
|
@ -90,8 +90,6 @@
|
|||
- (int) rdpStart :(rdpContext*) rdp_context;
|
||||
- (void) setCursor: (NSCursor*) cursor;
|
||||
|
||||
- (void) rdpConnectError;
|
||||
- (void) rdpRemoteAppError;
|
||||
- (void) onPasteboardTimerFired :(NSTimer *) timer;
|
||||
- (void) releaseResources;
|
||||
- (void) setViewSize : (int) w : (int) h;
|
||||
|
|
|
@ -165,7 +165,6 @@ DWORD mac_client_thread(void* param)
|
|||
if (!status)
|
||||
{
|
||||
[view setIs_connected:0];
|
||||
[view rdpConnectError];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -723,50 +722,6 @@ DWORD mac_client_thread(void* param)
|
|||
instance methods
|
||||
************************************************************************/
|
||||
|
||||
|
||||
/** *********************************************************************
|
||||
* called when we fail to connect to a RDP server
|
||||
***********************************************************************/
|
||||
|
||||
- (void) rdpConnectError
|
||||
{
|
||||
NSString* message = @"Error connecting to server";
|
||||
if (connectErrorCode == AUTHENTICATIONERROR)
|
||||
{
|
||||
message = [NSString stringWithFormat:@"%@:\n%@", message, @"Authentication failure, check credentials."];
|
||||
}
|
||||
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText:message];
|
||||
[alert beginSheetModalForWindow:[self window]
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
}
|
||||
|
||||
/** *********************************************************************
|
||||
* called when we fail to launch remote app on RDP server
|
||||
***********************************************************************/
|
||||
|
||||
- (void) rdpRemoteAppError
|
||||
{
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText:@"Error starting remote app on specified server"];
|
||||
[alert beginSheetModalForWindow:[self window]
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
}
|
||||
|
||||
/** *********************************************************************
|
||||
* just a terminate selector for above call
|
||||
***********************************************************************/
|
||||
|
||||
- (void) alertDidEnd:(NSAlert *)a returnCode:(NSInteger)rc contextInfo:(void *)ci
|
||||
{
|
||||
[NSApp terminate:nil];
|
||||
}
|
||||
|
||||
- (void) onPasteboardTimerFired :(NSTimer*) timer
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
MRDPView* mrdpView;
|
||||
}
|
||||
|
||||
- (void) rdpConnectError;
|
||||
|
||||
@property (assign) IBOutlet NSWindow *window;
|
||||
@property (assign) rdpContext *context;
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#import "MacFreeRDP/mf_client.h"
|
||||
|
||||
static AppDelegate* _singleDelegate = nil;
|
||||
void AppDelegate_EmbedWindowEventHandler(rdpContext* context, EmbedWindowEventArgs* e);
|
||||
|
||||
void AppDelegate_EmbedWindowEventHandler(void* context, EmbedWindowEventArgs* e);
|
||||
void AppDelegate_ConnectionResultEventHandler(void* context, ConnectionResultEventArgs* e);
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
@ -45,7 +45,9 @@ void AppDelegate_EmbedWindowEventHandler(rdpContext* context, EmbedWindowEventAr
|
|||
}
|
||||
else
|
||||
{
|
||||
PubSub_Subscribe(context->pubSub, "EmbedWindow", (pEventHandler) AppDelegate_EmbedWindowEventHandler);
|
||||
PubSub_SubscribeConnectionResult(context->pubSub, AppDelegate_ConnectionResultEventHandler);
|
||||
PubSub_SubscribeEmbedWindow(context->pubSub, AppDelegate_EmbedWindowEventHandler);
|
||||
|
||||
freerdp_client_start(context);
|
||||
}
|
||||
}
|
||||
|
@ -110,10 +112,45 @@ void AppDelegate_EmbedWindowEventHandler(rdpContext* context, EmbedWindowEventAr
|
|||
}
|
||||
|
||||
|
||||
/** *********************************************************************
|
||||
* called when we fail to connect to a RDP server
|
||||
***********************************************************************/
|
||||
|
||||
- (void) rdpConnectError
|
||||
{
|
||||
// TODO: This should be called on the main thread
|
||||
|
||||
NSString* message = @"Error connecting to server";
|
||||
if (connectErrorCode == AUTHENTICATIONERROR)
|
||||
{
|
||||
message = [NSString stringWithFormat:@"%@:\n%@", message, @"Authentication failure, check credentials."];
|
||||
}
|
||||
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText:message];
|
||||
[alert beginSheetModalForWindow:[self window]
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
}
|
||||
|
||||
|
||||
/** *********************************************************************
|
||||
* just a terminate selector for above call
|
||||
***********************************************************************/
|
||||
|
||||
- (void) alertDidEnd:(NSAlert *)a returnCode:(NSInteger)rc contextInfo:(void *)ci
|
||||
{
|
||||
[NSApp terminate:nil];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
void AppDelegate_EmbedWindowEventHandler(rdpContext* context, EmbedWindowEventArgs* e)
|
||||
void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
|
||||
{
|
||||
rdpContext* context = (rdpContext*) ctx;
|
||||
|
||||
if (_singleDelegate)
|
||||
{
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
|
@ -124,4 +161,19 @@ void AppDelegate_EmbedWindowEventHandler(rdpContext* context, EmbedWindowEventAr
|
|||
[[_singleDelegate->window contentView] addSubview:mfc->view];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** *********************************************************************
|
||||
* On connection error, display message and quit application
|
||||
***********************************************************************/
|
||||
|
||||
void AppDelegate_ConnectionResultEventHandler(void* ctx, ConnectionResultEventArgs* e)
|
||||
{
|
||||
if (_singleDelegate)
|
||||
{
|
||||
if (e->result != 0)
|
||||
{
|
||||
[_singleDelegate rdpConnectError];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,7 +83,8 @@ BOOL freerdp_connect(freerdp* instance)
|
|||
connectErrorCode = PREECONNECTERROR;
|
||||
}
|
||||
fprintf(stderr, "%s:%d: freerdp_pre_connect failed\n", __FILE__, __LINE__);
|
||||
return FALSE;
|
||||
|
||||
goto freerdp_connect_finally;
|
||||
}
|
||||
|
||||
status = rdp_client_connect(rdp);
|
||||
|
@ -92,8 +93,8 @@ BOOL freerdp_connect(freerdp* instance)
|
|||
if (instance->settings->AuthenticationOnly)
|
||||
{
|
||||
fprintf(stderr, "%s:%d: Authentication only, exit status %d\n", __FILE__, __LINE__, !status);
|
||||
return status;
|
||||
}
|
||||
goto freerdp_connect_finally;
|
||||
}
|
||||
|
||||
if (status)
|
||||
{
|
||||
|
@ -118,7 +119,7 @@ BOOL freerdp_connect(freerdp* instance)
|
|||
connectErrorCode = POSTCONNECTERROR;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
goto freerdp_connect_finally;
|
||||
}
|
||||
|
||||
if (instance->settings->PlayRemoteFx)
|
||||
|
@ -132,7 +133,10 @@ BOOL freerdp_connect(freerdp* instance)
|
|||
update->pcap_rfx = pcap_open(settings->PlayRemoteFxFile, FALSE);
|
||||
|
||||
if (!update->pcap_rfx)
|
||||
return FALSE;
|
||||
{
|
||||
status = FALSE;
|
||||
goto freerdp_connect_finally;
|
||||
}
|
||||
else
|
||||
update->play_rfx = TRUE;
|
||||
|
||||
|
@ -154,7 +158,8 @@ BOOL freerdp_connect(freerdp* instance)
|
|||
Stream_Release(s);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
status = TRUE;
|
||||
goto freerdp_connect_finally;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,6 +175,9 @@ BOOL freerdp_connect(freerdp* instance)
|
|||
|
||||
SetEvent(rdp->transport->connectedEvent);
|
||||
|
||||
freerdp_connect_finally:
|
||||
|
||||
fprintf(stderr, "ConnectionResult: %s\n", status ? "TRUE" : "FALSE");
|
||||
EventArgsInit(&e, "freerdp");
|
||||
e.result = status ? 0 : -1;
|
||||
PubSub_OnConnectionResult(instance->context->pubSub, instance->context, &e);
|
||||
|
|
Loading…
Reference in New Issue