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

Code beautyfied

parent bf34393e
...@@ -44,10 +44,11 @@ static RemminaPluginService *remmina_plugin_service = NULL; ...@@ -44,10 +44,11 @@ static RemminaPluginService *remmina_plugin_service = NULL;
static SecretSchema remmina_file_secret_schema = static SecretSchema remmina_file_secret_schema =
{ "org.remmina.Password", SECRET_SCHEMA_NONE, { "org.remmina.Password", SECRET_SCHEMA_NONE,
{ {
{ "filename", SECRET_SCHEMA_ATTRIBUTE_STRING }, { "filename", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ "key", SECRET_SCHEMA_ATTRIBUTE_STRING }, { "key", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 } } }; { NULL, 0 }
} };
#ifdef LIBSECRET_VERSION_0_18 #ifdef LIBSECRET_VERSION_0_18
...@@ -65,10 +66,8 @@ static void remmina_plugin_glibsecret_unlock_secret_service() ...@@ -65,10 +66,8 @@ static void remmina_plugin_glibsecret_unlock_secret_service()
GList *objects, *ul; GList *objects, *ul;
gchar* lbl; gchar* lbl;
if (secretservice && defaultcollection) if (secretservice && defaultcollection) {
{ if (secret_collection_get_locked(defaultcollection)) {
if (secret_collection_get_locked(defaultcollection))
{
lbl = secret_collection_get_label(defaultcollection); lbl = secret_collection_get_label(defaultcollection);
remmina_plugin_service->log_printf("[glibsecret] requesting unlock of the default '%s' collection\n", lbl); remmina_plugin_service->log_printf("[glibsecret] requesting unlock of the default '%s' collection\n", lbl);
objects = g_list_append(NULL, defaultcollection); objects = g_list_append(NULL, defaultcollection);
...@@ -93,16 +92,13 @@ void remmina_plugin_glibsecret_store_password(RemminaFile *remminafile, const gc ...@@ -93,16 +92,13 @@ void remmina_plugin_glibsecret_store_password(RemminaFile *remminafile, const gc
path = remmina_plugin_service->file_get_path(remminafile); path = remmina_plugin_service->file_get_path(remminafile);
s = g_strdup_printf("Remmina: %s - %s", remmina_plugin_service->file_get_string(remminafile, "name"), key); 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, 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); g_free(s);
if (r == NULL) if (r == NULL) {
{
remmina_plugin_service->log_printf("[glibsecret] password saved for file %s\n", path); 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); 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 ...@@ -119,15 +115,12 @@ remmina_plugin_glibsecret_get_password(RemminaFile *remminafile, const gchar *ke
path = remmina_plugin_service->file_get_path(remminafile); path = remmina_plugin_service->file_get_path(remminafile);
password = secret_password_lookup_sync(&remmina_file_secret_schema, NULL, &r, "filename", path, "key", key, NULL); 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); remmina_plugin_service->log_printf("[glibsecret] found password for file %s\n", path);
p = g_strdup(password); p = g_strdup(password);
secret_password_free(password); secret_password_free(password);
return p; return p;
} }else {
else
{
remmina_plugin_service->log_printf("[glibsecret] password cannot be found for file %s\n", path); remmina_plugin_service->log_printf("[glibsecret] password cannot be found for file %s\n", path);
return NULL; return NULL;
} }
...@@ -143,20 +136,17 @@ void remmina_plugin_glibsecret_delete_password(RemminaFile *remminafile, const g ...@@ -143,20 +136,17 @@ void remmina_plugin_glibsecret_delete_password(RemminaFile *remminafile, const g
path = remmina_plugin_service->file_get_path(remminafile); path = remmina_plugin_service->file_get_path(remminafile);
secret_password_clear_sync(&remmina_file_secret_schema, NULL, &r, "filename", path, "key", key, NULL); 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); 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); remmina_plugin_service->log_printf("[glibsecret] password cannot be deleted for file %s\n", path);
} }
} }
static RemminaSecretPlugin remmina_plugin_glibsecret = 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 G_MODULE_EXPORT gboolean
remmina_plugin_entry(RemminaPluginService *service) remmina_plugin_entry(RemminaPluginService *service)
...@@ -165,8 +155,7 @@ remmina_plugin_entry(RemminaPluginService *service) ...@@ -165,8 +155,7 @@ remmina_plugin_entry(RemminaPluginService *service)
remmina_plugin_service = service; remmina_plugin_service = service;
if (!service->register_plugin((RemminaPlugin *) &remmina_plugin_glibsecret)) if (!service->register_plugin((RemminaPlugin*)&remmina_plugin_glibsecret)) {
{
return FALSE; return FALSE;
} }
......
...@@ -71,8 +71,8 @@ typedef void (*PThreadCleanupFunc)(void*); ...@@ -71,8 +71,8 @@ typedef void (*PThreadCleanupFunc)(void*);
#define IDLE_ADD gdk_threads_add_idle #define IDLE_ADD gdk_threads_add_idle
#define TIMEOUT_ADD gdk_threads_add_timeout #define TIMEOUT_ADD gdk_threads_add_timeout
#define CANCEL_ASYNC pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);pthread_testcancel(); #define CANCEL_ASYNC pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); pthread_testcancel();
#define CANCEL_DEFER pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,NULL); #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_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\"") #define THREADS_LEAVE _Pragma("GCC error \"THREADS_LEAVE has been deprecated in Remmina 1.2\"")
...@@ -81,21 +81,21 @@ typedef void (*PThreadCleanupFunc)(void*); ...@@ -81,21 +81,21 @@ typedef void (*PThreadCleanupFunc)(void*);
#define X_UNIX_SOCKET "/tmp/.X11-unix/X%d" #define X_UNIX_SOCKET "/tmp/.X11-unix/X%d"
#define INCLUDE_GET_AVAILABLE_XDISPLAY static gint \ #define INCLUDE_GET_AVAILABLE_XDISPLAY static gint \
remmina_get_available_xdisplay (void) \ remmina_get_available_xdisplay(void) \
{ \
gint i; \
gint display = 0; \
gchar fn[200]; \
for (i = 1; i < MAX_X_DISPLAY_NUMBER; i++) \
{ \ { \
g_snprintf (fn, sizeof (fn), X_UNIX_SOCKET, i); \ gint i; \
if (!g_file_test (fn, G_FILE_TEST_EXISTS)) \ gint display = 0; \
gchar fn[200]; \
for (i = 1; i < MAX_X_DISPLAY_NUMBER; i++) \
{ \ { \
display = i; \ g_snprintf(fn, sizeof(fn), X_UNIX_SOCKET, i); \
break; \ if (!g_file_test(fn, G_FILE_TEST_EXISTS)) \
{ \
display = i; \
break; \
} \
} \ } \
} \ return display; \
return display; \ }
}
This diff is collapsed.
...@@ -36,14 +36,13 @@ ...@@ -36,14 +36,13 @@
#pragma once #pragma once
#define GET_PLUGIN_DATA(gp) (RemminaPluginNxData*) g_object_get_data(G_OBJECT(gp), "plugin-data"); #define GET_PLUGIN_DATA(gp) (RemminaPluginNxData*)g_object_get_data(G_OBJECT(gp), "plugin-data");
G_BEGIN_DECLS G_BEGIN_DECLS
#include "nx_session.h" #include "nx_session.h"
typedef enum typedef enum {
{
REMMINA_NX_EVENT_CANCEL, REMMINA_NX_EVENT_CANCEL,
REMMINA_NX_EVENT_START, REMMINA_NX_EVENT_START,
REMMINA_NX_EVENT_RESTORE, REMMINA_NX_EVENT_RESTORE,
...@@ -51,8 +50,7 @@ typedef enum ...@@ -51,8 +50,7 @@ typedef enum
REMMINA_NX_EVENT_TERMINATE REMMINA_NX_EVENT_TERMINATE
} RemminaNXEventType; } RemminaNXEventType;
typedef struct _RemminaPluginNxData typedef struct _RemminaPluginNxData {
{
GtkWidget *socket; GtkWidget *socket;
gint socket_id; gint socket_id;
......
...@@ -76,17 +76,17 @@ static gboolean remmina_get_keytype(const gchar *private_key_file, gint *keytype ...@@ -76,17 +76,17 @@ static gboolean remmina_get_keytype(const gchar *private_key_file, gint *keytype
/*****/ /*****/
static const gchar nx_default_private_key[] = "-----BEGIN DSA PRIVATE KEY-----\n" static const gchar nx_default_private_key[] = "-----BEGIN DSA PRIVATE KEY-----\n"
"MIIBuwIBAAKBgQCXv9AzQXjxvXWC1qu3CdEqskX9YomTfyG865gb4D02ZwWuRU/9\n" "MIIBuwIBAAKBgQCXv9AzQXjxvXWC1qu3CdEqskX9YomTfyG865gb4D02ZwWuRU/9\n"
"C3I9/bEWLdaWgJYXIcFJsMCIkmWjjeSZyTmeoypI1iLifTHUxn3b7WNWi8AzKcVF\n" "C3I9/bEWLdaWgJYXIcFJsMCIkmWjjeSZyTmeoypI1iLifTHUxn3b7WNWi8AzKcVF\n"
"aBsBGiljsop9NiD1mEpA0G+nHHrhvTXz7pUvYrsrXcdMyM6rxqn77nbbnwIVALCi\n" "aBsBGiljsop9NiD1mEpA0G+nHHrhvTXz7pUvYrsrXcdMyM6rxqn77nbbnwIVALCi\n"
"xFdHZADw5KAVZI7r6QatEkqLAoGBAI4L1TQGFkq5xQ/nIIciW8setAAIyrcWdK/z\n" "xFdHZADw5KAVZI7r6QatEkqLAoGBAI4L1TQGFkq5xQ/nIIciW8setAAIyrcWdK/z\n"
"5/ZPeELdq70KDJxoLf81NL/8uIc4PoNyTRJjtT3R4f8Az1TsZWeh2+ReCEJxDWgG\n" "5/ZPeELdq70KDJxoLf81NL/8uIc4PoNyTRJjtT3R4f8Az1TsZWeh2+ReCEJxDWgG\n"
"fbk2YhRqoQTtXPFsI4qvzBWct42WonWqyyb1bPBHk+JmXFscJu5yFQ+JUVNsENpY\n" "fbk2YhRqoQTtXPFsI4qvzBWct42WonWqyyb1bPBHk+JmXFscJu5yFQ+JUVNsENpY\n"
"+Gkz3HqTAoGANlgcCuA4wrC+3Cic9CFkqiwO/Rn1vk8dvGuEQqFJ6f6LVfPfRTfa\n" "+Gkz3HqTAoGANlgcCuA4wrC+3Cic9CFkqiwO/Rn1vk8dvGuEQqFJ6f6LVfPfRTfa\n"
"QU7TGVLk2CzY4dasrwxJ1f6FsT8DHTNGnxELPKRuLstGrFY/PR7KeafeFZDf+fJ3\n" "QU7TGVLk2CzY4dasrwxJ1f6FsT8DHTNGnxELPKRuLstGrFY/PR7KeafeFZDf+fJ3\n"
"mbX5nxrld3wi5titTnX+8s4IKv29HJguPvOK/SI7cjzA+SqNfD7qEo8CFDIm1xRf\n" "mbX5nxrld3wi5titTnX+8s4IKv29HJguPvOK/SI7cjzA+SqNfD7qEo8CFDIm1xRf\n"
"8xAPsSKs6yZ6j1FNklfu\n" "8xAPsSKs6yZ6j1FNklfu\n"
"-----END DSA PRIVATE KEY-----\n"; "-----END DSA PRIVATE KEY-----\n";
static const gchar nx_hello_server_msg[] = "hello nxserver - version "; static const gchar nx_hello_server_msg[] = "hello nxserver - version ";
...@@ -208,9 +208,9 @@ static void remmina_nx_session_set_application_error(RemminaNXSession *nx, const ...@@ -208,9 +208,9 @@ static void remmina_nx_session_set_application_error(RemminaNXSession *nx, const
va_list args; va_list args;
if (nx->error) g_free(nx->error); if (nx->error) g_free(nx->error);
va_start (args, fmt); va_start(args, fmt);
nx->error = g_strdup_vprintf (fmt, args); nx->error = g_strdup_vprintf(fmt, args);
va_end (args); va_end(args);
} }
gboolean remmina_nx_session_has_error(RemminaNXSession *nx) gboolean remmina_nx_session_has_error(RemminaNXSession *nx)
...@@ -283,7 +283,7 @@ static gboolean remmina_nx_session_get_response(RemminaNXSession *nx) ...@@ -283,7 +283,7 @@ static gboolean remmina_nx_session_get_response(RemminaNXSession *nx)
return FALSE; return FALSE;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS
buffer = buffer_new(); buffer = buffer_new();
len = channel_read_buffer(nx->channel, buffer, len, is_stderr); len = channel_read_buffer(nx->channel, buffer, len, is_stderr);
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
if (len <= 0) { if (len <= 0) {
...@@ -292,7 +292,7 @@ static gboolean remmina_nx_session_get_response(RemminaNXSession *nx) ...@@ -292,7 +292,7 @@ static gboolean remmina_nx_session_get_response(RemminaNXSession *nx)
} }
if (len > 0) { if (len > 0) {
G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_string_append_len(nx->response, (const gchar*) buffer_get(buffer), len); g_string_append_len(nx->response, (const gchar*)buffer_get(buffer), len);
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
} }
...@@ -310,7 +310,7 @@ static void remmina_nx_session_parse_session_list_line(RemminaNXSession *nx, con ...@@ -310,7 +310,7 @@ static void remmina_nx_session_parse_session_list_line(RemminaNXSession *nx, con
gint i; gint i;
GtkTreeIter iter; GtkTreeIter iter;
p1 = (char*) line; p1 = (char*)line;
while (*p1 == ' ') while (*p1 == ' ')
p1++; p1++;
if (*p1 == '\0') if (*p1 == '\0')
...@@ -318,7 +318,7 @@ static void remmina_nx_session_parse_session_list_line(RemminaNXSession *nx, con ...@@ -318,7 +318,7 @@ static void remmina_nx_session_parse_session_list_line(RemminaNXSession *nx, con
gtk_list_store_append(nx->session_list, &iter); gtk_list_store_append(nx->session_list, &iter);
p1 = (char*) line; p1 = (char*)line;
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
p2 = strchr(p1, ' '); p2 = strchr(p1, ' ');
if (!p2) if (!p2)
...@@ -523,18 +523,18 @@ static void remmina_nx_session_send_command(RemminaNXSession *nx, const gchar *c ...@@ -523,18 +523,18 @@ static void remmina_nx_session_send_command(RemminaNXSession *nx, const gchar *c
va_list args; va_list args;
gchar *cmd; gchar *cmd;
va_start (args, cmdfmt); va_start(args, cmdfmt);
cmd = g_strdup_vprintf (cmdfmt, args); cmd = g_strdup_vprintf(cmdfmt, args);
ssh_channel_write (nx->channel, cmd, strlen (cmd)); ssh_channel_write(nx->channel, cmd, strlen(cmd));
g_free(cmd); g_free(cmd);
ssh_set_fd_towrite (nx->session); ssh_set_fd_towrite(nx->session);
ssh_channel_write (nx->channel, "\n", 1); ssh_channel_write(nx->channel, "\n", 1);
va_end(args); va_end(args);
} }
gboolean remmina_nx_session_open(RemminaNXSession *nx, const gchar *server, guint port, const gchar *private_key_file, gboolean remmina_nx_session_open(RemminaNXSession *nx, const gchar *server, guint port, const gchar *private_key_file,
RemminaNXPassphraseCallback passphrase_func, gpointer userdata) RemminaNXPassphraseCallback passphrase_func, gpointer userdata)
{ {
TRACE_CALL("__func__"); TRACE_CALL("__func__");
gint ret; gint ret;
...@@ -644,9 +644,9 @@ void remmina_nx_session_add_parameter(RemminaNXSession *nx, const gchar *name, c ...@@ -644,9 +644,9 @@ void remmina_nx_session_add_parameter(RemminaNXSession *nx, const gchar *name, c
va_list args; va_list args;
gchar *value; gchar *value;
va_start (args, valuefmt); va_start(args, valuefmt);
value = g_strdup_vprintf (valuefmt, args); value = g_strdup_vprintf(valuefmt, args);
g_hash_table_insert(nx->session_parameters, g_strdup (name), value); g_hash_table_insert(nx->session_parameters, g_strdup(name), value);
va_end(args); va_end(args);
} }
...@@ -659,7 +659,7 @@ static gboolean remmina_nx_session_send_session_command(RemminaNXSession *nx, co ...@@ -659,7 +659,7 @@ static gboolean remmina_nx_session_send_session_command(RemminaNXSession *nx, co
cmd = g_string_new(cmd_type); cmd = g_string_new(cmd_type);
g_hash_table_iter_init(&iter, nx->session_parameters); g_hash_table_iter_init(&iter, nx->session_parameters);
while (g_hash_table_iter_next(&iter, (gpointer*) &key, (gpointer*) &value)) { while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&value)) {
g_string_append_printf(cmd, " --%s=\"%s\"", key, value); g_string_append_printf(cmd, " --%s=\"%s\"", key, value);
} }
...@@ -678,7 +678,7 @@ gboolean remmina_nx_session_list(RemminaNXSession *nx) ...@@ -678,7 +678,7 @@ gboolean remmina_nx_session_list(RemminaNXSession *nx)
if (nx->session_list == NULL) { if (nx->session_list == NULL) {
nx->session_list = gtk_list_store_new(REMMINA_NX_SESSION_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, nx->session_list = gtk_list_store_new(REMMINA_NX_SESSION_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING); G_TYPE_STRING, G_TYPE_STRING);
} else { } else {
gtk_list_store_clear(nx->session_list); gtk_list_store_clear(nx->session_list);
} }
...@@ -780,7 +780,7 @@ gboolean remmina_nx_session_terminate(RemminaNXSession *nx) ...@@ -780,7 +780,7 @@ gboolean remmina_nx_session_terminate(RemminaNXSession *nx)
static gpointer remmina_nx_session_tunnel_main_thread(gpointer data) static gpointer remmina_nx_session_tunnel_main_thread(gpointer data)
{ {
TRACE_CALL("__func__"); TRACE_CALL("__func__");
RemminaNXSession *nx = (RemminaNXSession*) data; RemminaNXSession *nx = (RemminaNXSession*)data;
gchar *ptr; gchar *ptr;
ssize_t len = 0, lenw = 0; ssize_t len = 0, lenw = 0;
fd_set set; fd_set set;
...@@ -834,7 +834,7 @@ static gpointer remmina_nx_session_tunnel_main_thread(gpointer data) ...@@ -834,7 +834,7 @@ static gpointer remmina_nx_session_tunnel_main_thread(gpointer data)
for (ptr = buffer, lenw = 0; len > 0; len -= lenw, ptr += lenw) { for (ptr = buffer, lenw = 0; len > 0; len -= lenw, ptr += lenw) {
ssh_set_fd_towrite(nx->session); ssh_set_fd_towrite(nx->session);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS
lenw = channel_write(channels[0], (char*) ptr, len); lenw = channel_write(channels[0], (char*)ptr, len);
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
if (lenw <= 0) { if (lenw <= 0) {
nx->running = FALSE; nx->running = FALSE;
...@@ -861,10 +861,10 @@ static gpointer remmina_nx_session_tunnel_main_thread(gpointer data) ...@@ -861,10 +861,10 @@ static gpointer remmina_nx_session_tunnel_main_thread(gpointer data)
/* Clean up the stderr buffer in case FreeNX send something there */ /* Clean up the stderr buffer in case FreeNX send something there */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS
len = channel_read_nonblocking(channels_out[0], buffer, sizeof(buffer), 1); len = channel_read_nonblocking(channels_out[0], buffer, sizeof(buffer), 1);
if (len == SSH_ERROR || len == SSH_EOF) { if (len == SSH_ERROR || len == SSH_EOF) {
nx->running = FALSE; nx->running = FALSE;
break; break;
} }
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
} }
} }
...@@ -923,7 +923,7 @@ gboolean remmina_nx_session_tunnel_open(RemminaNXSession *nx) ...@@ -923,7 +923,7 @@ gboolean remmina_nx_session_tunnel_open(RemminaNXSession *nx)
sin.sin_port = htons(port); sin.sin_port = htons(port);
sin.sin_addr.s_addr = inet_addr("127.0.0.1"); sin.sin_addr.s_addr = inet_addr("127.0.0.1");
if (bind(sock, (struct sockaddr *) &sin, sizeof(sin))) { if (bind(sock, (struct sockaddr *)&sin, sizeof(sin))) {
remmina_nx_session_set_application_error(nx, "Failed to bind on local port."); remmina_nx_session_set_application_error(nx, "Failed to bind on local port.");
close(sock); close(sock);
return FALSE; return FALSE;
...@@ -952,12 +952,12 @@ remmina_nx_session_get_proxy_option(RemminaNXSession *nx) ...@@ -952,12 +952,12 @@ remmina_nx_session_get_proxy_option(RemminaNXSession *nx)
TRACE_CALL("__func__"); TRACE_CALL("__func__");
if (nx->encryption) { if (nx->encryption) {
return g_strdup_printf("nx,session=%s,cookie=%s,id=%s,shmem=1,shpix=1,connect=127.0.0.1:%i", return g_strdup_printf("nx,session=%s,cookie=%s,id=%s,shmem=1,shpix=1,connect=127.0.0.1:%i",
(gchar*) g_hash_table_lookup(nx->session_parameters, "session"), nx->proxy_cookie, (gchar*)g_hash_table_lookup(nx->session_parameters, "session"), nx->proxy_cookie,
nx->session_id, (nx->localport ? nx->localport : nx->session_display)); nx->session_id, (nx->localport ? nx->localport : nx->session_display));
} else { } else {
return g_strdup_printf("nx,session=%s,cookie=%s,id=%s,shmem=1,shpix=1,connect=%s:%i", return g_strdup_printf("nx,session=%s,cookie=%s,id=%s,shmem=1,shpix=1,connect=%s:%i",
(gchar*) g_hash_table_lookup(nx->session_parameters, "session"), nx->proxy_cookie, (gchar*)g_hash_table_lookup(nx->session_parameters, "session"), nx->proxy_cookie,
nx->session_id, nx->server, nx->session_display); nx->session_id, nx->server, nx->session_display);
} }
} }
...@@ -995,7 +995,7 @@ gboolean remmina_nx_session_invoke_proxy(RemminaNXSession *nx, gint display, GCh ...@@ -995,7 +995,7 @@ gboolean remmina_nx_session_invoke_proxy(RemminaNXSession *nx, gint display, GCh
argv[argc++] = NULL; argv[argc++] = NULL;
ret = g_spawn_async(NULL, argv, envp, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &nx->proxy_pid, ret = g_spawn_async(NULL, argv, envp, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &nx->proxy_pid,
&error); &error);
g_strfreev(envp); g_strfreev(envp);
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
g_free(argv[i]); g_free(argv[i]);
......
...@@ -37,8 +37,7 @@ ...@@ -37,8 +37,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
enum enum {
{
REMMINA_NX_SESSION_COLUMN_DISPLAY, REMMINA_NX_SESSION_COLUMN_DISPLAY,
REMMINA_NX_SESSION_COLUMN_TYPE, REMMINA_NX_SESSION_COLUMN_TYPE,
REMMINA_NX_SESSION_COLUMN_ID, REMMINA_NX_SESSION_COLUMN_ID,
...@@ -69,7 +68,7 @@ void remmina_nx_session_set_localport(RemminaNXSession *nx, gint localport); ...@@ -69,7 +68,7 @@ void remmina_nx_session_set_localport(RemminaNXSession *nx, gint localport);
void remmina_nx_session_set_log_callback(RemminaNXSession *nx, RemminaNXLogCallback log_callback); void remmina_nx_session_set_log_callback(RemminaNXSession *nx, RemminaNXLogCallback log_callback);
gboolean remmina_nx_session_open(RemminaNXSession *nx, const gchar *server, guint port, const gchar *private_key_file, gboolean remmina_nx_session_open(RemminaNXSession *nx, const gchar *server, guint port, const gchar *private_key_file,
RemminaNXPassphraseCallback passphrase_func, gpointer userdata); RemminaNXPassphraseCallback passphrase_func, gpointer userdata);
gboolean remmina_nx_session_login(RemminaNXSession *nx, const gchar *username, const gchar *password); gboolean remmina_nx_session_login(RemminaNXSession *nx, const gchar *username, const gchar *password);
......
...@@ -44,28 +44,24 @@ static void remmina_nx_session_manager_set_sensitive(RemminaProtocolWidget *gp, ...@@ -44,28 +44,24 @@ static void remmina_nx_session_manager_set_sensitive(RemminaProtocolWidget *gp,
TRACE_CALL("__func__"); TRACE_CALL("__func__");
RemminaPluginNxData *gpdata = GET_PLUGIN_DATA(gp); RemminaPluginNxData *gpdata = GET_PLUGIN_DATA(gp);
if (gpdata->attach_session) if (gpdata->attach_session) {
{
gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_TERMINATE, sensitive); gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_TERMINATE, sensitive);
gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_ATTACH, sensitive); gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_ATTACH, sensitive);
} }else {
else
{
gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_TERMINATE, sensitive); gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_TERMINATE, sensitive);
gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_RESTORE, sensitive); gtk_dialog_set_response_sensitive(GTK_DIALOG(gpdata->manager_dialog), REMMINA_NX_EVENT_RESTORE, sensitive);
} }
} }
static gboolean remmina_nx_session_manager_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, static gboolean remmina_nx_session_manager_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path,
gboolean path_currently_selected, gpointer user_data) gboolean path_currently_selected, gpointer user_data)
{ {
TRACE_CALL("__func__"); TRACE_CALL("__func__");
RemminaProtocolWidget *gp = (RemminaProtocolWidget*) user_data; RemminaProtocolWidget *gp = (RemminaProtocolWidget*)user_data;
RemminaPluginNxData *gpdata = GET_PLUGIN_DATA(gp); RemminaPluginNxData *gpdata = GET_PLUGIN_DATA(gp);
gpdata->manager_selected = FALSE; gpdata->manager_selected = FALSE;
if (path_currently_selected) if (path_currently_selected) {
{
remmina_nx_session_manager_set_sensitive(gp, FALSE); remmina_nx_session_manager_set_sensitive(gp, FALSE);
return TRUE; return TRUE;
} }
...@@ -80,10 +76,9 @@ static gboolean remmina_nx_session_manager_selection_func(GtkTreeSelection *sele ...@@ -80,10 +76,9 @@ static gboolean remmina_nx_session_manager_selection_func(GtkTreeSelection *sele
static void remmina_nx_session_manager_send_signal(RemminaPluginNxData *gpdata, gint event_type) static void remmina_nx_session_manager_send_signal(RemminaPluginNxData *gpdata, gint event_type)
{ {
TRACE_CALL("__func__"); TRACE_CALL("__func__");
guchar dummy = (guchar) event_type; guchar dummy = (guchar)event_type;
/* Signal the NX thread to resume execution */ /* Signal the NX thread to resume execution */
if (write(gpdata->event_pipe[1], &dummy, 1)) if (write(gpdata->event_pipe[1], &dummy, 1)) {
{
} }
} }
...@@ -94,25 +89,19 @@ static void remmina_nx_session_manager_on_response(GtkWidget *dialog, gint respo ...@@ -94,25 +89,19 @@ static void remmina_nx_session_manager_on_response(GtkWidget *dialog, gint respo
gint event_type; gint event_type;
remmina_nx_session_manager_set_sensitive(gp, FALSE); remmina_nx_session_manager_set_sensitive(gp, FALSE);
if (response_id <= 0) if (response_id <= 0) {
{
event_type = REMMINA_NX_EVENT_CANCEL; event_type = REMMINA_NX_EVENT_CANCEL;
} }else {
else
{
event_type = response_id; event_type = response_id;
} }
if (response_id == REMMINA_NX_EVENT_TERMINATE && gpdata->manager_selected) if (response_id == REMMINA_NX_EVENT_TERMINATE && gpdata->manager_selected) {
{
remmina_nx_session_iter_set(gpdata->nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_STATUS, _("Terminating")); remmina_nx_session_iter_set(gpdata->nx, &gpdata->iter, REMMINA_NX_SESSION_COLUMN_STATUS, _("Terminating"));
} }
if (response_id != REMMINA_NX_EVENT_TERMINATE) if (response_id != REMMINA_NX_EVENT_TERMINATE) {
{
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
gpdata->manager_dialog = NULL; gpdata->manager_dialog = NULL;
} }
if (response_id != REMMINA_NX_EVENT_TERMINATE && response_id != REMMINA_NX_EVENT_CANCEL) if (response_id != REMMINA_NX_EVENT_TERMINATE && response_id != REMMINA_NX_EVENT_CANCEL) {
{
remmina_plugin_nx_service->protocol_plugin_init_show(gp); remmina_plugin_nx_service->protocol_plugin_init_show(gp);
} }
remmina_nx_session_manager_send_signal(gpdata, event_type); remmina_nx_session_manager_send_signal(gpdata, event_type);
...@@ -127,9 +116,8 @@ void remmina_nx_session_manager_on_row_activated(GtkTreeView *tree, GtkTreePath ...@@ -127,9 +116,8 @@ void remmina_nx_session_manager_on_row_activated(GtkTreeView *tree, GtkTreePath
remmina_plugin_nx_service->log_printf("[NX] Default response_id %d\n", remmina_plugin_nx_service->log_printf("[NX] Default response_id %d\n",
gpdata->default_response); gpdata->default_response);
if (gpdata->default_response >= 0) if (gpdata->default_response >= 0) {
{ gtk_dialog_response(GTK_DIALOG(gpdata->manager_dialog), gpdata->default_response);
gtk_dialog_response(GTK_DIALOG(gpdata->manager_dialog), gpdata->default_response);
} }
} }
...@@ -148,22 +136,18 @@ static gboolean remmina_nx_session_manager_main(RemminaProtocolWidget *gp) ...@@ -148,22 +136,18 @@ static gboolean remmina_nx_session_manager_main(RemminaProtocolWidget *gp)
remminafile = remmina_plugin_nx_service->protocol_plugin_get_file(gp); remminafile = remmina_plugin_nx_service->protocol_plugin_get_file(gp);
gpdata->default_response = -1; gpdata->default_response = -1;
if (!gpdata->manager_started) if (!gpdata->manager_started) {
{
remmina_plugin_nx_service->protocol_plugin_init_hide(gp); remmina_plugin_nx_service->protocol_plugin_init_hide(gp);
dialog = gtk_dialog_new(); dialog = gtk_dialog_new();
s = g_strdup_printf(_("NX Sessions on %s"), remmina_plugin_nx_service->file_get_string(remminafile, "server")); s = g_strdup_printf(_("NX Sessions on %s"), remmina_plugin_nx_service->file_get_string(remminafile, "server"));
gtk_window_set_title(GTK_WINDOW(dialog), s); gtk_window_set_title(GTK_WINDOW(dialog), s);
g_free(s); g_free(s);
if (gpdata->attach_session)