Commit 01453a37 authored by Antenore Gatta's avatar Antenore Gatta

Code beautyfied

parent bf34393e
......@@ -44,10 +44,11 @@ static RemminaPluginService *remmina_plugin_service = NULL;
static SecretSchema remmina_file_secret_schema =
{ "org.remmina.Password", SECRET_SCHEMA_NONE,
{
{ "filename", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ "key", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 } } };
{
{ "filename", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ "key", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 }
} };
#ifdef LIBSECRET_VERSION_0_18
......@@ -65,10 +66,8 @@ static void remmina_plugin_glibsecret_unlock_secret_service()
GList *objects, *ul;
gchar* lbl;
if (secretservice && defaultcollection)
{
if (secret_collection_get_locked(defaultcollection))
{
if (secretservice && defaultcollection) {
if (secret_collection_get_locked(defaultcollection)) {
lbl = secret_collection_get_label(defaultcollection);
remmina_plugin_service->log_printf("[glibsecret] requesting unlock of the default '%s' collection\n", lbl);
objects = g_list_append(NULL, defaultcollection);
......@@ -93,16 +92,13 @@ void remmina_plugin_glibsecret_store_password(RemminaFile *remminafile, const gc
path = remmina_plugin_service->file_get_path(remminafile);
s = g_strdup_printf("Remmina: %s - %s", remmina_plugin_service->file_get_string(remminafile, "name"), key);
secret_password_store_sync(&remmina_file_secret_schema, SECRET_COLLECTION_DEFAULT, s, password,
NULL, &r, "filename", path, "key", key, NULL);
NULL, &r, "filename", path, "key", key, NULL);
g_free(s);
if (r == NULL)
{
if (r == NULL) {
remmina_plugin_service->log_printf("[glibsecret] password saved for file %s\n", path);
}
else
{
}else {
remmina_plugin_service->log_printf("[glibsecret] password cannot be saved for file %s\n", path);
g_error_free (r);
g_error_free(r);
}
}
......@@ -119,15 +115,12 @@ remmina_plugin_glibsecret_get_password(RemminaFile *remminafile, const gchar *ke
path = remmina_plugin_service->file_get_path(remminafile);
password = secret_password_lookup_sync(&remmina_file_secret_schema, NULL, &r, "filename", path, "key", key, NULL);
if (r == NULL)
{
if (r == NULL) {
remmina_plugin_service->log_printf("[glibsecret] found password for file %s\n", path);
p = g_strdup(password);
secret_password_free(password);
return p;
}
else
{
}else {
remmina_plugin_service->log_printf("[glibsecret] password cannot be found for file %s\n", path);
return NULL;
}
......@@ -143,20 +136,17 @@ void remmina_plugin_glibsecret_delete_password(RemminaFile *remminafile, const g
path = remmina_plugin_service->file_get_path(remminafile);
secret_password_clear_sync(&remmina_file_secret_schema, NULL, &r, "filename", path, "key", key, NULL);
if (r == NULL)
{
if (r == NULL) {
remmina_plugin_service->log_printf("[glibsecret] password deleted for file %s\n", path);
}
else
{
}else {
remmina_plugin_service->log_printf("[glibsecret] password cannot be deleted for file %s\n", path);
}
}
static RemminaSecretPlugin remmina_plugin_glibsecret =
{ REMMINA_PLUGIN_TYPE_SECRET, "glibsecret", "GNOME libsecret", NULL, VERSION,
{ REMMINA_PLUGIN_TYPE_SECRET, "glibsecret", "GNOME libsecret", NULL, VERSION,
TRUE, remmina_plugin_glibsecret_store_password, remmina_plugin_glibsecret_get_password, remmina_plugin_glibsecret_delete_password };
TRUE, remmina_plugin_glibsecret_store_password, remmina_plugin_glibsecret_get_password, remmina_plugin_glibsecret_delete_password };
G_MODULE_EXPORT gboolean
remmina_plugin_entry(RemminaPluginService *service)
......@@ -165,8 +155,7 @@ remmina_plugin_entry(RemminaPluginService *service)
remmina_plugin_service = service;
if (!service->register_plugin((RemminaPlugin *) &remmina_plugin_glibsecret))
{
if (!service->register_plugin((RemminaPlugin*)&remmina_plugin_glibsecret)) {
return FALSE;
}
......
......@@ -71,8 +71,8 @@ typedef void (*PThreadCleanupFunc)(void*);
#define IDLE_ADD gdk_threads_add_idle
#define TIMEOUT_ADD gdk_threads_add_timeout
#define CANCEL_ASYNC pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);pthread_testcancel();
#define CANCEL_DEFER pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,NULL);
#define CANCEL_ASYNC pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); pthread_testcancel();
#define CANCEL_DEFER pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
#define THREADS_ENTER _Pragma("GCC error \"THREADS_ENTER has been deprecated in Remmina 1.2\"")
#define THREADS_LEAVE _Pragma("GCC error \"THREADS_LEAVE has been deprecated in Remmina 1.2\"")
......@@ -81,21 +81,21 @@ typedef void (*PThreadCleanupFunc)(void*);
#define X_UNIX_SOCKET "/tmp/.X11-unix/X%d"
#define INCLUDE_GET_AVAILABLE_XDISPLAY static gint \
remmina_get_available_xdisplay (void) \
{ \
gint i; \
gint display = 0; \
gchar fn[200]; \
for (i = 1; i < MAX_X_DISPLAY_NUMBER; i++) \
remmina_get_available_xdisplay(void) \
{ \
g_snprintf (fn, sizeof (fn), X_UNIX_SOCKET, i); \
if (!g_file_test (fn, G_FILE_TEST_EXISTS)) \
gint i; \
gint display = 0; \
gchar fn[200]; \
for (i = 1; i < MAX_X_DISPLAY_NUMBER; i++) \
{ \
display = i; \
break; \
g_snprintf(fn, sizeof(fn), X_UNIX_SOCKET, i); \
if (!g_file_test(fn, G_FILE_TEST_EXISTS)) \
{ \
display = i; \
break; \
} \
} \
} \
return display; \
}
return display; \
}
......@@ -82,10 +82,10 @@ static gboolean onMainThread_cb(struct onMainThread_cb_data *d)
{
TRACE_CALL("__func__");
if ( !d->cancelled ) {
switch( d->func ) {
case FUNC_GTK_SOCKET_ADD_ID:
gtk_socket_add_id( d->sk, d->w );
break;
switch ( d->func ) {
case FUNC_GTK_SOCKET_ADD_ID:
gtk_socket_add_id( d->sk, d->w );
break;
}
pthread_mutex_unlock( &d->mu );
} else {
......@@ -111,7 +111,7 @@ static void onMainThread_schedule_callback_and_wait( struct onMainThread_cb_data
pthread_cleanup_push( onMainThread_cleanup_handler, d );
pthread_mutex_init( &d->mu, NULL );
pthread_mutex_lock( &d->mu );
gdk_threads_add_idle( (GSourceFunc)onMainThread_cb, (gpointer) d );
gdk_threads_add_idle( (GSourceFunc)onMainThread_cb, (gpointer)d );
pthread_mutex_lock( &d->mu );
......@@ -147,16 +147,13 @@ static gboolean remmina_plugin_nx_try_window_id(Window window_id)
gboolean found = FALSE;
pthread_mutex_lock(&remmina_nx_init_mutex);
for (i = 0; i < remmina_nx_window_id_array->len; i++)
{
if (g_array_index(remmina_nx_window_id_array, Window, i) == window_id)
{
for (i = 0; i < remmina_nx_window_id_array->len; i++) {
if (g_array_index(remmina_nx_window_id_array, Window, i) == window_id) {
found = TRUE;
break;
}
}
if (!found)
{
if (!found) {
g_array_append_val(remmina_nx_window_id_array, window_id);
}
pthread_mutex_unlock(&remmina_nx_init_mutex);
......@@ -171,16 +168,13 @@ static void remmina_plugin_nx_remove_window_id(Window window_id)
gboolean found = FALSE;
pthread_mutex_lock(&remmina_nx_init_mutex);
for (i = 0; i < remmina_nx_window_id_array->len; i++)
{
if (g_array_index(remmina_nx_window_id_array, Window, i) == window_id)
{
for (i = 0; i < remmina_nx_window_id_array->len; i++) {
if (g_array_index(remmina_nx_window_id_array, Window, i) == window_id) {
found = TRUE;
break;
}
}
if (found)
{
if (found) {
g_array_remove_index_fast(remmina_nx_window_id_array, i);
}
pthread_mutex_unlock(&remmina_nx_init_mutex);
......@@ -201,7 +195,7 @@ static void remmina_plugin_nx_on_plug_removed(GtkSocket *socket, RemminaProtocol
gboolean remmina_plugin_nx_ssh_auth_callback(gchar **passphrase, gpointer userdata)
{
TRACE_CALL("__func__");
RemminaProtocolWidget *gp = (RemminaProtocolWidget*) userdata;
RemminaProtocolWidget *gp = (RemminaProtocolWidget*)userdata;
gint ret;
/* SSH passwords must not be saved */
......@@ -217,7 +211,7 @@ gboolean remmina_plugin_nx_ssh_auth_callback(gchar **passphrase, gpointer userda
static void remmina_plugin_nx_on_proxy_exit(GPid pid, gint status, gpointer data)
{
TRACE_CALL("__func__");
RemminaProtocolWidget *gp = (RemminaProtocolWidget*) data;
RemminaProtocolWidget *gp = (RemminaProtocolWidget*)data;
remmina_plugin_nx_service->protocol_plugin_close_connection(gp);
}
......@@ -259,7 +253,7 @@ static gboolean remmina_plugin_nx_monitor_create_notify(RemminaProtocolWidget *g
CANCEL_DEFER
gpdata = GET_PLUGIN_DATA(gp);
gpdata = GET_PLUGIN_DATA(gp);
atom = XInternAtom(gpdata->display, "WM_COMMAND", True);
if (atom == None)
return FALSE;
......@@ -267,11 +261,9 @@ static gboolean remmina_plugin_nx_monitor_create_notify(RemminaProtocolWidget *g
ts.tv_sec = 0;
ts.tv_nsec = 200000000;
while (1)
{
while (1) {
pthread_testcancel();
while (!XPending(gpdata->display))
{
while (!XPending(gpdata->display)) {
nanosleep(&ts, NULL);
continue;
}
......@@ -280,10 +272,9 @@ static gboolean remmina_plugin_nx_monitor_create_notify(RemminaProtocolWidget *g
continue;
w = xev.xcreatewindow.window;
if (XGetWindowProperty(gpdata->display, w, atom, 0, 255, False, AnyPropertyType, &type, &format, &nitems, &rest,
&data) != Success)
&data) != Success)
continue;
if (data && strstr((char *) data, cmd) && remmina_plugin_nx_try_window_id(w))
{
if (data && strstr((char*)data, cmd) && remmina_plugin_nx_try_window_id(w)) {
gpdata->window_id = w;
XFree(data);
break;
......@@ -309,10 +300,9 @@ static gint remmina_plugin_nx_wait_signal(RemminaPluginNxData *gpdata)
FD_ZERO(&set);
FD_SET(gpdata->event_pipe[0], &set);
select(gpdata->event_pipe[0] + 1, &set, NULL, NULL, NULL);
if (read(gpdata->event_pipe[0], &dummy, 1))
{
if (read(gpdata->event_pipe[0], &dummy, 1)) {
}
return (gint) dummy;
return (gint)dummy;
}
static gboolean remmina_plugin_nx_start_session(RemminaProtocolWidget *gp)
......@@ -337,21 +327,19 @@ static gboolean remmina_plugin_nx_start_session(RemminaProtocolWidget *gp)
/* Connect */
remmina_nx_session_set_encryption(nx,
remmina_plugin_nx_service->file_get_int(remminafile, "disableencryption", FALSE) ? 0 : 1);
remmina_plugin_nx_service->file_get_int(remminafile, "disableencryption", FALSE) ? 0 : 1);
remmina_nx_session_set_localport(nx, remmina_plugin_nx_service->pref_get_sshtunnel_port());
remmina_nx_session_set_log_callback(nx, remmina_plugin_nx_service->log_printf);
s2 = remmina_plugin_nx_service->protocol_plugin_start_direct_tunnel(gp, 22, FALSE);
if (s2 == NULL)
{
if (s2 == NULL) {
return FALSE;
}
remmina_plugin_nx_service->get_server_port(s2, 22, &s1, &port);
g_free(s2);
if (!remmina_nx_session_open(nx, s1, port, remmina_plugin_nx_service->file_get_string(remminafile, "nx_privatekey"),
remmina_plugin_nx_ssh_auth_callback, gp))
{
remmina_plugin_nx_ssh_auth_callback, gp)) {
g_free(s1);
return FALSE;
}
......@@ -362,12 +350,9 @@ static gboolean remmina_plugin_nx_start_session(RemminaProtocolWidget *gp)
s1 = g_strdup(remmina_plugin_nx_service->file_get_string(remminafile, "username"));
s2 = g_strdup(remmina_plugin_nx_service->file_get_string(remminafile, "password"));
if (s1 && s2)
{
if (s1 && s2) {
ret = remmina_nx_session_login(nx, s1, s2);
}
else
{
}else {
g_free(s1);
g_free(s2);
......@@ -391,76 +376,57 @@ static gboolean remmina_plugin_nx_start_session(RemminaProtocolWidget *gp)
/* Prepare the session type and application */
cs = remmina_plugin_nx_service->file_get_string(remminafile, "exec");
if (!cs || g_strcmp0(cs, "GNOME") == 0)
{
if (!cs || g_strcmp0(cs, "GNOME") == 0) {
type = "unix-gnome";
app = NULL;
}else
if (g_strcmp0(cs, "KDE") == 0) {
type = "unix-kde";
app = NULL;
}else
if (g_strcmp0(cs, "Xfce") == 0) {
/* NX does not know Xfce. So we simply launch the Xfce startup program. */
type = "unix-application";
app = "startxfce4";
}else
if (g_strcmp0(cs, "Shadow") == 0) {
type = "shadow";
app = NULL;
}else {
type = "unix-application";
app = cs;
}
else
if (g_strcmp0(cs, "KDE") == 0)
{
type = "unix-kde";
app = NULL;
}
else
if (g_strcmp0(cs, "Xfce") == 0)
{
/* NX does not know Xfce. So we simply launch the Xfce startup program. */
type = "unix-application";
app = "startxfce4";
}
else
if (g_strcmp0(cs, "Shadow") == 0)
{
type = "shadow";
app = NULL;
}
else
{
type = "unix-application";
app = cs;
}
/* List sessions */
gpdata->attach_session = (g_strcmp0(type, "shadow") == 0);
while (1)
{
while (1) {
remmina_nx_session_add_parameter(nx, "type", type);
if (!gpdata->attach_session)
{
if (!gpdata->attach_session) {
remmina_nx_session_add_parameter(nx, "user",
remmina_plugin_nx_service->file_get_string(remminafile, "username"));
remmina_plugin_nx_service->file_get_string(remminafile, "username"));
remmina_nx_session_add_parameter(nx, "status", "suspended,running");
}
if (!remmina_nx_session_list(nx))
{
if (!remmina_nx_session_list(nx)) {
return FALSE;
}
is_empty_list = !remmina_nx_session_iter_first(nx, &gpdata->iter);
if (is_empty_list && !gpdata->manager_started && !gpdata->attach_session)
{
if (is_empty_list && !gpdata->manager_started && !gpdata->attach_session) {
event_type = REMMINA_NX_EVENT_START;
}
else
{
}else {
remmina_nx_session_manager_start(gp);
event_type = remmina_plugin_nx_wait_signal(gpdata);
if (event_type == REMMINA_NX_EVENT_CANCEL)
{
if (event_type == REMMINA_NX_EVENT_CANCEL) {
return FALSE;
}
if (event_type == REMMINA_NX_EVENT_TERMINATE)
{
if (!is_empty_list)
{
if (event_type == REMMINA_NX_EVENT_TERMINATE) {
if (!is_empty_list) {
s1 = remmina_nx_session_iter_get(nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_ID);
remmina_nx_session_add_parameter(nx, "sessionid", s1);
g_free(s1);
if (!remmina_nx_session_terminate(nx))
{
if (!remmina_nx_session_terminate(nx)) {
remmina_nx_session_manager_start(gp);
remmina_plugin_nx_wait_signal(gpdata);
}
......@@ -477,58 +443,57 @@ static gboolean remmina_plugin_nx_start_session(RemminaProtocolWidget *gp)
i = remmina_plugin_nx_service->file_get_int(remminafile, "quality", 0);
remmina_nx_session_add_parameter(nx, "link", i > 2 ? "lan" : i == 2 ? "adsl" : i == 1 ? "isdn" : "modem");
remmina_nx_session_add_parameter(nx, "geometry", "%ix%i",
remmina_plugin_nx_service->get_profile_remote_width(gp),
remmina_plugin_nx_service->get_profile_remote_height(gp));
remmina_plugin_nx_service->get_profile_remote_width(gp),
remmina_plugin_nx_service->get_profile_remote_height(gp));
remmina_nx_session_add_parameter(nx, "keyboard", remmina_kbtype);
remmina_nx_session_add_parameter(nx, "client", "linux");
remmina_nx_session_add_parameter(nx, "media", "0");
remmina_nx_session_add_parameter(nx, "clipboard",
remmina_plugin_nx_service->file_get_int(remminafile, "disableclipboard", FALSE) ? "none" : "both");
remmina_plugin_nx_service->file_get_int(remminafile, "disableclipboard", FALSE) ? "none" : "both");
switch (event_type)
{
switch (event_type) {
case REMMINA_NX_EVENT_START:
if (app)
remmina_nx_session_add_parameter(nx, "application", app);
case REMMINA_NX_EVENT_START:
if (app)
remmina_nx_session_add_parameter(nx, "application", app);
remmina_nx_session_add_parameter(nx, "session",
remmina_plugin_nx_service->file_get_string(remminafile, "name"));
remmina_nx_session_add_parameter(nx, "screeninfo", "%ix%ix24+render",
remmina_plugin_nx_service->file_get_int(remminafile, "resolution_width", 0),
remmina_plugin_nx_service->file_get_int(remminafile, "resolution_height", 0));
remmina_nx_session_add_parameter(nx, "session",
remmina_plugin_nx_service->file_get_string(remminafile, "name"));
remmina_nx_session_add_parameter(nx, "screeninfo", "%ix%ix24+render",
remmina_plugin_nx_service->file_get_int(remminafile, "resolution_width", 0),
remmina_plugin_nx_service->file_get_int(remminafile, "resolution_height", 0));
if (!remmina_nx_session_start(nx))
return FALSE;
break;
case REMMINA_NX_EVENT_ATTACH:
s1 = remmina_nx_session_iter_get(nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_ID);
remmina_nx_session_add_parameter(nx, "id", s1);
g_free(s1);
if (!remmina_nx_session_start(nx))
return FALSE;
break;
s1 = remmina_nx_session_iter_get(nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_DISPLAY);
remmina_nx_session_add_parameter(nx, "display", s1);
g_free(s1);
case REMMINA_NX_EVENT_ATTACH:
s1 = remmina_nx_session_iter_get(nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_ID);
remmina_nx_session_add_parameter(nx, "id", s1);
g_free(s1);
if (!remmina_nx_session_attach(nx))
return FALSE;
break;
s1 = remmina_nx_session_iter_get(nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_DISPLAY);
remmina_nx_session_add_parameter(nx, "display", s1);
g_free(s1);
case REMMINA_NX_EVENT_RESTORE:
s1 = remmina_nx_session_iter_get(nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_ID);
remmina_nx_session_add_parameter(nx, "id", s1);
g_free(s1);
if (!remmina_nx_session_attach(nx))
return FALSE;
break;
remmina_nx_session_add_parameter(nx, "session",
remmina_plugin_nx_service->file_get_string(remminafile, "name"));
case REMMINA_NX_EVENT_RESTORE:
s1 = remmina_nx_session_iter_get(nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_ID);
remmina_nx_session_add_parameter(nx, "id", s1);
g_free(s1);
if (!remmina_nx_session_restore(nx))
return FALSE;
break;
remmina_nx_session_add_parameter(nx, "session",
remmina_plugin_nx_service->file_get_string(remminafile, "name"));
default:
if (!remmina_nx_session_restore(nx))
return FALSE;
break;
default:
return FALSE;
}
if (!remmina_nx_session_tunnel_open(nx))
......@@ -561,11 +526,9 @@ static gboolean remmina_plugin_nx_main(RemminaProtocolWidget *gp)
gpdata->nx = remmina_nx_session_new();
ret = remmina_plugin_nx_start_session(gp);
if (!ret)
{
if (!ret) {
err = remmina_nx_session_get_error(gpdata->nx);
if (err)
{
if (err) {
remmina_plugin_nx_service->protocol_plugin_set_error(gp, "%s", err);
}
}
......@@ -580,9 +543,8 @@ static gpointer remmina_plugin_nx_main_thread(gpointer data)
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
CANCEL_ASYNC
if (!remmina_plugin_nx_main((RemminaProtocolWidget*) data))
{
IDLE_ADD((GSourceFunc) remmina_plugin_nx_service->protocol_plugin_close_connection, data);
if (!remmina_plugin_nx_main((RemminaProtocolWidget*)data)) {
IDLE_ADD((GSourceFunc)remmina_plugin_nx_service->protocol_plugin_close_connection, data);
}
return NULL;
}
......@@ -603,14 +565,11 @@ static void remmina_plugin_nx_init(RemminaProtocolWidget *gp)
g_signal_connect(G_OBJECT(gpdata->socket), "plug-removed", G_CALLBACK(remmina_plugin_nx_on_plug_removed), gp);
gtk_container_add(GTK_CONTAINER(gp), gpdata->socket);
if (pipe(gpdata->event_pipe))
{
if (pipe(gpdata->event_pipe)) {
g_print("Error creating pipes.\n");
gpdata->event_pipe[0] = -1;
gpdata->event_pipe[1] = -1;
}
else
{
}else {
flags = fcntl(gpdata->event_pipe[0], F_GETFL, 0);
fcntl(gpdata->event_pipe[0], F_SETFL, flags | O_NONBLOCK);
}
......@@ -624,9 +583,8 @@ static gboolean remmina_plugin_nx_open_connection(RemminaProtocolWidget *gp)
const gchar *resolution;
gint width, height;
if (!remmina_plugin_nx_service->gtksocket_available())
{
remmina_plugin_nx_service->protocol_plugin_set_error (gp,
if (!remmina_plugin_nx_service->gtksocket_available()) {
remmina_plugin_nx_service->protocol_plugin_set_error(gp,
_("Protocol %s is unavailable because GtkSocket only works under Xorg"),
remmina_plugin_nx.name);
return FALSE;
......@@ -635,13 +593,10 @@ static gboolean remmina_plugin_nx_open_connection(RemminaProtocolWidget *gp)
remminafile = remmina_plugin_nx_service->protocol_plugin_get_file(gp);
resolution = remmina_plugin_nx_service->file_get_string(remminafile, "resolution");
if (!resolution || !strchr(resolution, 'x'))
{
if (!resolution || !strchr(resolution, 'x')) {
remmina_plugin_nx_service->protocol_plugin_set_expand(gp, TRUE);
gtk_widget_set_size_request(GTK_WIDGET(gp), 640, 480);
}
else
{
}else {
width = remmina_plugin_nx_service->file_get_int(remminafile, "resolution_width", 640);
height = remmina_plugin_nx_service->file_get_int(remminafile, "resolution_height", 480);
remmina_plugin_nx_service->protocol_plugin_set_width(gp, width);
......@@ -650,15 +605,12 @@ static gboolean remmina_plugin_nx_open_connection(RemminaProtocolWidget *gp)
}
gpdata->socket_id = gtk_socket_get_id(GTK_SOCKET(gpdata->socket));
if (pthread_create(&gpdata->thread, NULL, remmina_plugin_nx_main_thread, gp))
{
if (pthread_create(&gpdata->thread, NULL, remmina_plugin_nx_main_thread, gp)) {
remmina_plugin_nx_service->protocol_plugin_set_error(gp,
"Failed to initialize pthread. Falling back to non-thread mode...");
"Failed to initialize pthread. Falling back to non-thread mode...");
gpdata->thread = 0;
return FALSE;
}
else
{
}else {
return TRUE;
}
}
......@@ -668,31 +620,26 @@ static gboolean remmina_plugin_nx_close_connection(RemminaProtocolWidget *gp)
TRACE_CALL("__func__");
RemminaPluginNxData *gpdata = GET_PLUGIN_DATA(gp);
if (gpdata->thread)
{
if (gpdata->thread) {
pthread_cancel(gpdata->thread);
if (gpdata->thread)
pthread_join(gpdata->thread, NULL);
}
if (gpdata->session_manager_start_handler)
{
if (gpdata->session_manager_start_handler) {
g_source_remove(gpdata->session_manager_start_handler);
gpdata->session_manager_start_handler = 0;
}
if (gpdata->window_id)
{
if (gpdata->window_id) {
remmina_plugin_nx_remove_window_id(gpdata->window_id);
}
if (gpdata->nx)
{
if (gpdata->nx) {
remmina_nx_session_free(gpdata->nx);
gpdata->nx = NULL;
}
if (gpdata->display)
{
if (gpdata->display) {
XSetErrorHandler(gpdata->orig_handler);
XCloseDisplay(gpdata->display);
gpdata->display = NULL;
......@@ -725,13 +672,12 @@ static gboolean remmina_plugin_nx_query_feature(RemminaProtocolWidget *gp, const
static void remmina_plugin_nx_call_feature(RemminaProtocolWidget *gp, const RemminaProtocolFeature *feature)
{
TRACE_CALL("__func__");
switch (feature->id)
{
case REMMINA_PLUGIN_NX_FEATURE_TOOL_SENDCTRLALTDEL:
remmina_plugin_nx_send_ctrlaltdel(gp);
break;
default:
break;
switch (feature->id) {
case REMMINA_PLUGIN_NX_FEATURE_TOOL_SENDCTRLALTDEL:
remmina_plugin_nx_send_ctrlaltdel(gp);
break;
default:
break;
}
}
......@@ -756,14 +702,14 @@ static gpointer quality_list[] =
*/
static const RemminaProtocolSetting remmina_plugin_nx_basic_settings[] =
{
{ REMMINA_PROTOCOL_SETTING_TYPE_SERVER, "server", NULL, FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_FILE, "nx_privatekey", N_("Identity file"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "username", N_("User name"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD, "password", N_("User password"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_RESOLUTION, "resolution", NULL, FALSE, GINT_TO_POINTER(1), NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_SELECT, "quality", N_("Quality"), FALSE, quality_list, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_COMBO, "exec", N_("Startup program"), FALSE, "GNOME,KDE,Xfce,Shadow", NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL }
{ REMMINA_PROTOCOL_SETTING_TYPE_SERVER, "server", NULL, FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_FILE, "nx_privatekey", N_("Identity file"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "username", N_("User name"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD, "password", N_("User password"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_RESOLUTION, "resolution", NULL, FALSE, GINT_TO_POINTER(1), NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_SELECT, "quality", N_("Quality"), FALSE, quality_list, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_COMBO, "exec", N_("Startup program"), FALSE, "GNOME,KDE,Xfce,Shadow", NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL }
};