Commit 24c910f0 authored by Felipe Borges's avatar Felipe Borges 👣

frdp-display: Delegate the authentication to clients

The frdp_display_authenticate() method is virtual, so clients
need to implement it in order to be able to provide credentials
whenever it is necessary.

Gtk-frdp clients can always provide credentials before opening
the host (connecting), this way they don't need to implement
frdp_display_authenticate()
parent c8309001
......@@ -357,7 +357,7 @@ frdp_display_open_host (FrdpDisplay *display,
port,
NULL, // TODO: Cancellable
frdp_display_open_host_cb,
display);
g_object_ref (display));
g_debug ("Connecting to %s…", host);
}
......@@ -438,3 +438,14 @@ GtkWidget *frdp_display_new (void)
{
return GTK_WIDGET (g_object_new (FRDP_TYPE_DISPLAY, NULL));
}
gboolean
frdp_display_authenticate (FrdpDisplay *self,
gchar **username,
gchar **password,
gchar **domain)
{
FrdpDisplayClass *klass = FRDP_DISPLAY_DISPLAY_GET_CLASS (self);
return klass->authenticate (self, username, password, domain);
}
......@@ -32,6 +32,8 @@ typedef struct _FrdpDisplayPrivate FrdpDisplayPrivate;
struct _FrdpDisplayClass
{
GtkDrawingAreaClass parent_parent;
gboolean (*authenticate) (FrdpDisplay *self, gchar **username, gchar **password, gchar **domain);
};
GtkWidget *frdp_display_new (void);
......@@ -47,4 +49,9 @@ void frdp_display_close (FrdpDisplay *display);
void frdp_display_set_scaling (FrdpDisplay *display,
gboolean scaling);
gboolean frdp_display_authenticate (FrdpDisplay *self,
gchar **username,
gchar **password,
gchar **domain);
G_END_DECLS
......@@ -174,9 +174,13 @@ frdp_authenticate (freerdp *freerdp_session,
gchar **password,
gchar **domain)
{
/* TODO: ask for credentials */
FrdpSession *self = ((frdpContext *) freerdp_session->context)->self;
gboolean result;
return TRUE;
return frdp_display_authenticate (FRDP_DISPLAY (self->priv->display),
username,
password,
domain);
}
static gboolean
......@@ -463,6 +467,7 @@ frdp_session_finalize (GObject *object)
if (self->priv->freerdp_session) {
freerdp_disconnect (self->priv->freerdp_session);
freerdp_context_free (self->priv->freerdp_session);
g_clear_pointer (&self->priv->freerdp_session, freerdp_free);
}
......@@ -613,7 +618,6 @@ frdp_session_close (FrdpSession *self)
if (self->priv->freerdp_session != NULL) {
gdi_free (self->priv->freerdp_session);
freerdp_context_free (self->priv->freerdp_session);
self->priv->is_connected = FALSE;
......
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