Skip to content

Commit

Permalink
Merge pull request #776 from FreeRDP/autoreconnect
Browse files Browse the repository at this point in the history
Autoreconnect
  • Loading branch information
giox069 committed Feb 28, 2016
2 parents 68195eb + 4b8bbdf commit 83c8286
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 57 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ check_include_files(sys/param.h HAVE_SYS_PARAM_H)
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
check_include_files(netinet/tcp.h HAVE_NETINET_TCP_H)
check_include_files(termios.h HAVE_TERMIOS_H)
check_include_files(netdb.h HAVE_NETDB_H)
check_include_files(fcntl.h HAVE_FCNTL_H)
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#cmakedefine HAVE_SYS_SOCKET_H
#cmakedefine HAVE_ARPA_INET_H
#cmakedefine HAVE_NETINET_IN_H
#cmakedefine HAVE_NETINET_TCP_H
#cmakedefine HAVE_TERMIOS_H
#cmakedefine HAVE_NETDB_H
#cmakedefine HAVE_FCNTL_H
Expand Down
84 changes: 66 additions & 18 deletions remmina-plugins/rdp/rdp_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void remmina_rdp_event_on_focus_in(GtkWidget* widget, GdkEventKey* event,
GdkDeviceManager *manager;
GdkDevice *keyboard = NULL;

if ( !rfi )
if (!rfi || !rfi->connected || rfi->is_reconnecting)
return;

input = rfi->instance->input;
Expand Down Expand Up @@ -86,7 +86,9 @@ static void remmina_rdp_event_event_push(RemminaProtocolWidget* gp, const Remmin
rfContext* rfi = GET_PLUGIN_DATA(gp);
RemminaPluginRdpEvent* event;

if ( !rfi )
/* Here we push mouse/keyboard events in the event_queue */

if (!rfi || !rfi->connected || rfi->is_reconnecting)
return;

if (rfi->event_queue)
Expand Down Expand Up @@ -149,7 +151,7 @@ static void remmina_rdp_event_scale_area(RemminaProtocolWidget* gp, gint* x, gin
gint sx, sy, sw, sh;
rfContext* rfi = GET_PLUGIN_DATA(gp);

if (!rfi->surface)
if (!rfi || !rfi->connected || rfi->is_reconnecting || !rfi->surface)
return;

width = remmina_plugin_service->protocol_plugin_get_width(gp);
Expand Down Expand Up @@ -276,21 +278,50 @@ static gboolean remmina_rdp_event_on_draw(GtkWidget* widget, cairo_t* context, R
TRACE_CALL("remmina_rdp_event_on_draw");
gboolean scale;
rfContext* rfi = GET_PLUGIN_DATA(gp);
guint width, height;
gchar *msg;
cairo_text_extents_t extents;

if (!rfi) return FALSE;

if (!rfi->surface)
if (!rfi || !rfi->connected)
return FALSE;

scale = remmina_plugin_service->protocol_plugin_get_scale(gp);

if (scale)
cairo_scale(context, rfi->scale_x, rfi->scale_y);
if (rfi->is_reconnecting)
{
/* freerdp is reconnecting, just show a message to the user */

width = gtk_widget_get_allocated_width(widget);
height = gtk_widget_get_allocated_height (widget);

/* Draw text */
msg = g_strdup_printf(_("Reconnection in progress. Attempt %d of %d..."),
rfi->reconnect_nattempt, rfi->reconnect_maxattempts);

cairo_select_font_face(context, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(context, 24);
cairo_set_source_rgb(context, 0.9, 0.9, 0.9);
cairo_text_extents(context, msg, &extents);
cairo_move_to(context, (width - (extents.width + extents.x_bearing)) / 2, (height - (extents.height + extents.y_bearing)) / 2);
cairo_show_text(context, msg);

}
else
{
/* Standard drawing: we copy the surface from RDP */

if (!rfi->surface)
return FALSE;

scale = remmina_plugin_service->protocol_plugin_get_scale(gp);

if (scale)
cairo_scale(context, rfi->scale_x, rfi->scale_y);

cairo_set_source_surface(context, rfi->surface, 0, 0);
cairo_set_source_surface(context, rfi->surface, 0, 0);

cairo_set_operator (context, CAIRO_OPERATOR_SOURCE); // Ignore alpha channel from FreeRDP
cairo_paint(context);
cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); // Ignore alpha channel from FreeRDP
cairo_paint(context);
}

return TRUE;
}
Expand All @@ -300,7 +331,8 @@ static gboolean remmina_rdp_event_on_configure(GtkWidget* widget, GdkEventConfig
TRACE_CALL("remmina_rdp_event_on_configure");
rfContext* rfi = GET_PLUGIN_DATA(gp);

if (!rfi) return FALSE;
if (!rfi || !rfi->connected || rfi->is_reconnecting)
return FALSE;

/* We do a delayed reallocating to improve performance */

Expand All @@ -322,7 +354,8 @@ static void remmina_rdp_event_translate_pos(RemminaProtocolWidget* gp, int ix, i
* RDP coordinates and put result on (*ox,*uy)
* */

if (!rfi) return;
if (!rfi || !rfi->connected || rfi->is_reconnecting)
return;

if ((rfi->scale) && (rfi->scale_width >= 1) && (rfi->scale_height >= 1))
{
Expand All @@ -346,7 +379,8 @@ static void remmina_rdp_event_reverse_translate_pos_reverse(RemminaProtocolWidge
* local window coordinates and put result on (*ox,*uy)
* */

if (!rfi) return;
if (!rfi || !rfi->connected || rfi->is_reconnecting)
return;

if ((rfi->scale) && (rfi->scale_width >= 1) && (rfi->scale_height >= 1))
{
Expand Down Expand Up @@ -468,7 +502,8 @@ static gboolean remmina_rdp_event_on_key(GtkWidget* widget, GdkEventKey* event,
RemminaPluginRdpEvent rdp_event;
DWORD scancode;

if ( !rfi ) return TRUE;
if (!rfi || !rfi->connected || rfi->is_reconnecting)
return FALSE;

#ifdef ENABLE_GTK_INSPECTOR_KEY
/* GTK inspector key is propagated up. Disabled by default.
Expand Down Expand Up @@ -542,7 +577,9 @@ gboolean remmina_rdp_event_on_clipboard(GtkClipboard *gtkClipboard, GdkEvent *ev
rfContext* rfi = GET_PLUGIN_DATA(gp);
rfClipboard* clipboard;

if ( !rfi ) return TRUE;
if (!rfi || !rfi->connected || rfi->is_reconnecting)
return FALSE;

clipboard = &(rfi->clipboard);

if ( clipboard->sync ) {
Expand All @@ -564,7 +601,7 @@ void remmina_rdp_event_init(RemminaProtocolWidget* gp)
rfContext* rfi = GET_PLUGIN_DATA(gp);
GtkClipboard* clipboard;

if ( !rfi ) return;
if (!rfi) return;

rfi->drawing_area = gtk_drawing_area_new();
gtk_widget_show(rfi->drawing_area);
Expand Down Expand Up @@ -763,6 +800,13 @@ static void remmina_rdp_event_connected(RemminaProtocolWidget* gp, RemminaPlugin
remmina_rdp_event_update_scale(gp);
}

static void remmina_rdp_event_reconnect_progress(RemminaProtocolWidget* gp, RemminaPluginRdpUiObject* ui)
{
TRACE_CALL("remmina_rdp_event_reconnect_progress");
rfContext* rfi = GET_PLUGIN_DATA(gp);
gdk_window_invalidate_rect(gtk_widget_get_window(rfi->drawing_area), NULL, TRUE);
}

static BOOL remmina_rdp_event_create_cursor(RemminaProtocolWidget* gp, RemminaPluginRdpUiObject* ui)
{
TRACE_CALL("remmina_rdp_event_create_cursor");
Expand Down Expand Up @@ -897,6 +941,10 @@ gboolean remmina_rdp_event_queue_ui(RemminaProtocolWidget* gp)
remmina_rdp_event_connected(gp, ui);
break;

case REMMINA_RDP_UI_RECONNECT_PROGRESS:
remmina_rdp_event_reconnect_progress(gp, ui);
break;

case REMMINA_RDP_UI_CURSOR:
remmina_rdp_event_cursor(gp, ui);
break;
Expand Down
Loading

0 comments on commit 83c8286

Please sign in to comment.