diff options
28 files changed, 254 insertions, 219 deletions
diff --git a/plugins/exec/exec_plugin.c b/plugins/exec/exec_plugin.c index 8a0df8b9f..f40aa7772 100644 --- a/plugins/exec/exec_plugin.c +++ b/plugins/exec/exec_plugin.c @@ -111,7 +111,7 @@ static void remmina_plugin_exec_init(RemminaProtocolWidget *gp) TRACE_CALL(__func__); RemminaPluginExecData *gpdata; - remmina_plugin_service->log_printf("[%s] Plugin init\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin init", PLUGIN_NAME); gpdata = g_new0(RemminaPluginExecData, 1); g_object_set_data_full(G_OBJECT(gp), "plugin-data", gpdata, g_free); @@ -148,7 +148,7 @@ static gboolean remmina_plugin_exec_run(RemminaProtocolWidget *gp) GtkDialog *dialog; GIOChannel *out_ch, *err_ch; - remmina_plugin_service->log_printf("[%s] Plugin run\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin run", PLUGIN_NAME); RemminaPluginExecData *gpdata = GET_PLUGIN_DATA(gp); remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); @@ -169,7 +169,7 @@ static gboolean remmina_plugin_exec_run(RemminaProtocolWidget *gp) } if (remmina_plugin_service->file_get_int(remminafile, "runasync", FALSE)) { - remmina_plugin_service->log_printf("[%s] Run Async\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Run Async", PLUGIN_NAME); g_spawn_async_with_pipes( NULL, argv, NULL, @@ -214,7 +214,7 @@ static gboolean remmina_plugin_exec_run(RemminaProtocolWidget *gp) break; } gtk_widget_destroy(GTK_WIDGET(dialog)); - remmina_plugin_service->log_printf("[%s] Run Sync\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Run Sync", PLUGIN_NAME); g_spawn_sync (NULL, // CWD or NULL argv, NULL, // ENVP or NULL @@ -227,7 +227,7 @@ static gboolean remmina_plugin_exec_run(RemminaProtocolWidget *gp) NULL, // Exit status &error); if (!error) { - remmina_plugin_service->log_printf("[%s] Command executed\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Command executed", PLUGIN_NAME); gtk_text_buffer_set_text (gpdata->log_buffer, stdout_buffer, -1); }else { g_warning("Command %s exited with error: %s\n", cmd, error->message); @@ -245,7 +245,7 @@ static gboolean remmina_plugin_exec_run(RemminaProtocolWidget *gp) static gboolean remmina_plugin_exec_close(RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin close\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin close", PLUGIN_NAME); remmina_plugin_service->protocol_plugin_signal_connection_closed(gp); return FALSE; } diff --git a/plugins/nx/nx_plugin.c b/plugins/nx/nx_plugin.c index 0c553d1ed..b959307ee 100644 --- a/plugins/nx/nx_plugin.c +++ b/plugins/nx/nx_plugin.c @@ -331,7 +331,7 @@ static gboolean remmina_plugin_nx_start_session(RemminaProtocolWidget *gp) remmina_nx_session_set_encryption(nx, 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); + remmina_nx_session_set_log_callback(nx, remmina_plugin_nx_service->debug); s2 = remmina_plugin_nx_service->protocol_plugin_start_direct_tunnel(gp, 22, FALSE); if (s2 == NULL) { diff --git a/plugins/nx/nx_session.c b/plugins/nx/nx_session.c index e698e92fa..8fe287392 100644 --- a/plugins/nx/nx_session.c +++ b/plugins/nx/nx_session.c @@ -443,7 +443,7 @@ static gint remmina_nx_session_parse_response(RemminaNXSession *nx) while ((line = remmina_nx_session_get_line(nx)) != NULL) { if (nx->log_callback) - nx->log_callback("[NX] %s\n", line); + nx->log_callback(line); status = remmina_nx_session_parse_line(nx, line, &p); if (status == 500) { @@ -480,7 +480,7 @@ static gint remmina_nx_session_parse_response(RemminaNXSession *nx) status = nx->status; } else { if (nx->log_callback) - nx->log_callback("[NX] %s\n", pos); + nx->log_callback(pos); nx->response_pos += 8; } nx->status = -1; diff --git a/plugins/nx/nx_session_manager.c b/plugins/nx/nx_session_manager.c index bfddfedaa..d3a808e96 100644 --- a/plugins/nx/nx_session_manager.c +++ b/plugins/nx/nx_session_manager.c @@ -113,7 +113,7 @@ void remmina_nx_session_manager_on_row_activated(GtkTreeView *tree, GtkTreePath { TRACE_CALL(__func__); RemminaPluginNxData *gpdata = GET_PLUGIN_DATA(gp); - remmina_plugin_nx_service->log_printf("[NX] Default response_id %d\n", + remmina_plugin_nx_service->debug("Default response_id %d", gpdata->default_response); if (gpdata->default_response >= 0) { diff --git a/plugins/rdp/rdp_channels.c b/plugins/rdp/rdp_channels.c index cc01b6daa..e0847c259 100644 --- a/plugins/rdp/rdp_channels.c +++ b/plugins/rdp/rdp_channels.c @@ -79,7 +79,7 @@ void remmina_rdp_OnChannelConnectedEventHandler(rdpContext* context, ChannelConn if (rfi->scale == REMMINA_PROTOCOL_WIDGET_SCALE_MODE_DYNRES) { remmina_rdp_event_send_delayed_monitor_layout(rfi->protocol_widget); } - }remmina_plugin_service->log_printf("Channel %s has been opened\n", e->name); + }remmina_plugin_service->debug("Channel %s has been opened", e->name); } void remmina_rdp_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelConnectedEventArgs* e) @@ -91,6 +91,6 @@ void remmina_rdp_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelC if (rfi->settings->SoftwareGdi) gdi_graphics_pipeline_uninit(context->gdi, (RdpgfxClientContext*) e->pInterface); } - remmina_plugin_service->log_printf("Channel %s has been closed\n", e->name); + remmina_plugin_service->debug("Channel %s has been closed", e->name); } diff --git a/plugins/rdp/rdp_cliprdr.c b/plugins/rdp/rdp_cliprdr.c index 83ae84cee..cf2592ad8 100644 --- a/plugins/rdp/rdp_cliprdr.c +++ b/plugins/rdp/rdp_cliprdr.c @@ -239,7 +239,7 @@ static UINT remmina_rdp_cliprdr_server_format_list(CliprdrClientContext *context gp = clipboard->rfi->protocol_widget; GtkTargetList *list = gtk_target_list_new(NULL, 0); - g_debug("[RDP] format list from the server:"); + remmina_plugin_service->debug("format list from the server:"); for (i = 0; i < formatList->numFormats; i++) { format = &formatList->formats[i]; serverFormatName = format->formatName; @@ -280,7 +280,7 @@ static UINT remmina_rdp_cliprdr_server_format_list(CliprdrClientContext *context } else if (format->formatId == CF_METAFILEPICT) { serverFormatName = "CF_METAFILEPICT"; } - g_debug("[RDP] the server has clipboard format %d: %s", format->formatId, serverFormatName); + remmina_plugin_service->debug("the server has clipboard format %d: %s", format->formatId, serverFormatName); } /* Keep only one DIB format, if present */ @@ -452,12 +452,12 @@ static UINT remmina_rdp_cliprdr_server_format_data_response(CliprdrClientContext pthread_mutex_lock(&clipboard->transfer_clip_mutex); pthread_cond_signal(&clipboard->transfer_clip_cond); if (clipboard->srv_clip_data_wait == SCDW_BUSY_WAIT) { - g_debug("[RDP] clibpoard transfer from server completed."); + remmina_plugin_service->debug("clibpoard transfer from server completed."); clipboard->srv_data = output; } else { // Clipboard data arrived from server when we are not busywaiting on main loop // Unfortunately, we must discard it - g_debug("[RDP] clibpoard transfer from server completed. Data discarded due to abort or timeout."); + remmina_plugin_service->debug("clibpoard transfer from server completed. Data discarded due to abort or timeout."); clipboard->srv_clip_data_wait = SCDW_NONE; } pthread_mutex_unlock(&clipboard->transfer_clip_mutex); @@ -481,7 +481,7 @@ void remmina_rdp_cliprdr_request_data(GtkClipboard *gtkClipboard, GtkSelectionDa int rc; time_t tlimit; - g_debug("[RDP] A local application has requested remote clipboard data for local format id %d", info); + remmina_plugin_service->debug("A local application has requested remote clipboard data for local format id %d", info); clipboard = &(rfi->clipboard); if (clipboard->srv_clip_data_wait != SCDW_NONE) { @@ -500,7 +500,7 @@ void remmina_rdp_cliprdr_request_data(GtkClipboard *gtkClipboard, GtkSelectionDa pFormatDataRequest->requestedFormatId = clipboard->format; clipboard->srv_clip_data_wait = SCDW_BUSY_WAIT; - g_debug("[RDP] Requesting clipboard data with fotmat %d from the server", clipboard->format); + remmina_plugin_service->debug("Requesting clipboard data with fotmat %d from the server", clipboard->format); rdp_event.type = REMMINA_RDP_EVENT_TYPE_CLIPBOARD_SEND_CLIENT_FORMAT_DATA_REQUEST; rdp_event.clipboard_formatdatarequest.pFormatDataRequest = pFormatDataRequest; @@ -582,7 +582,7 @@ CLIPRDR_FORMAT_LIST *remmina_rdp_cliprdr_get_client_format_list(RemminaProtocolW gtkClipboard = gtk_widget_get_clipboard(rfi->drawing_area, GDK_SELECTION_CLIPBOARD); if (gtkClipboard) result = gtk_clipboard_wait_for_targets(gtkClipboard, &targets, &loccount); - g_debug("[RDP] Sending to server the following local clipboard content formats"); + remmina_plugin_service->debug("Sending to server the following local clipboard content formats"); if (result && loccount > 0) { formats = (CLIPRDR_FORMAT *)malloc(loccount * sizeof(CLIPRDR_FORMAT)); srvcount = 0; @@ -590,7 +590,7 @@ CLIPRDR_FORMAT_LIST *remmina_rdp_cliprdr_get_client_format_list(RemminaProtocolW formatId = remmina_rdp_cliprdr_get_format_from_gdkatom(targets[i]); if (formatId != 0) { name = gdk_atom_name(targets[i]); - g_debug("[RDP] local clipboard format %s will be sent to remote as %d", name, formatId); + remmina_plugin_service->debug(" local clipboard format %s will be sent to remote as %d", name, formatId); g_free(name); formats[srvcount].formatId = formatId; formats[srvcount].formatName = NULL; @@ -751,7 +751,7 @@ void remmina_rdp_cliprdr_set_clipboard_data(RemminaProtocolWidget *gp, RemminaPl if (gtkClipboard) { targets = gtk_target_table_new_from_list(ui->clipboard.targetlist, &n_targets); if (targets) { - g_debug("[RDP] setting clipboard with owner to owner %p", gp); + remmina_plugin_service->debug("setting clipboard with owner to owner %p", gp); gtk_clipboard_set_with_owner(gtkClipboard, targets, n_targets, (GtkClipboardGetFunc)remmina_rdp_cliprdr_request_data, (GtkClipboardClearFunc)remmina_rdp_cliprdr_empty_clipboard, G_OBJECT(gp)); @@ -814,7 +814,7 @@ void remmina_rdp_clipboard_free(rfContext *rfi) void remmina_rdp_clipboard_abort_transfer(rfContext *rfi) { if (rfi && rfi->clipboard.srv_clip_data_wait == SCDW_BUSY_WAIT) { - g_debug("[RDP] requesting clipboard transfer to abort"); + remmina_plugin_service->debug("requesting clipboard transfer to abort"); /* Allow clipboard transfer from server to terminate */ rfi->clipboard.srv_clip_data_wait = SCDW_ABORTING; usleep(100000); diff --git a/plugins/rdp/rdp_event.c b/plugins/rdp/rdp_event.c index 52f580c7b..782e28530 100644 --- a/plugins/rdp/rdp_event.c +++ b/plugins/rdp/rdp_event.c @@ -717,7 +717,7 @@ gboolean remmina_rdp_event_on_clipboard(GtkClipboard *gtkClipboard, GdkEvent *ev * after receivina a RDP server format list in remmina_rdp_cliprdr_server_format_list() * In the latter case, we must ignore owner change */ - g_debug("[RDP] owner-change event received"); + remmina_plugin_service->debug("owner-change event received"); rfContext *rfi = GET_PLUGIN_DATA(gp); if (rfi) @@ -726,7 +726,7 @@ gboolean remmina_rdp_event_on_clipboard(GtkClipboard *gtkClipboard, GdkEvent *ev if (gtk_clipboard_get_owner(gtkClipboard) != (GObject*)gp) { /* To do: avoid this when the new owner is another remmina protocol widget of * the same remmina application */ - g_debug("[RDP] new owner is different than me: new=%p me=%p. Sending local clipboard format list to server.", + remmina_plugin_service->debug(" new owner is different than me: new=%p me=%p. Sending local clipboard format list to server.", gtk_clipboard_get_owner(gtkClipboard), (GObject*)gp); pFormatList = remmina_rdp_cliprdr_get_client_format_list(gp); @@ -734,7 +734,7 @@ gboolean remmina_rdp_event_on_clipboard(GtkClipboard *gtkClipboard, GdkEvent *ev rdp_event.clipboard_formatlist.pFormatList = pFormatList; remmina_rdp_event_event_push(gp, &rdp_event); } else { - g_debug("[RDP] ... but I'm the owner!"); + remmina_plugin_service->debug(" ... but I'm the owner!"); } return TRUE; } @@ -984,7 +984,7 @@ static void remmina_rdp_event_connected(RemminaProtocolWidget* gp, RemminaPlugin gtk_widget_queue_draw_area(rfi->drawing_area, 0, 0, gdi->width, gdi->height); remmina_rdp_event_update_scale(gp); - + remmina_plugin_service->protocol_plugin_signal_connection_opened(gp); } diff --git a/plugins/rdp/rdp_plugin.c b/plugins/rdp/rdp_plugin.c index 095aa5f5a..84e510e92 100644 --- a/plugins/rdp/rdp_plugin.c +++ b/plugins/rdp/rdp_plugin.c @@ -190,14 +190,14 @@ static gboolean remmina_rdp_tunnel_init(RemminaProtocolWidget *gp) gint port; rfContext *rfi = GET_PLUGIN_DATA(gp); - g_debug("[RDP] %s\n", __func__); + remmina_plugin_service->debug("Tunnel init"); hostport = remmina_plugin_service->protocol_plugin_start_direct_tunnel(gp, 3389, FALSE); if (hostport == NULL) return FALSE; remmina_plugin_service->get_server_port(hostport, 3389, &host, &port); - g_debug("[RDP] protocol_plugin_start_direct_tunnel() returned %s\n", hostport); + remmina_plugin_service->debug("protocol_plugin_start_direct_tunnel() returned %s", hostport); cert_host = host; cert_port = port; @@ -217,7 +217,7 @@ static gboolean remmina_rdp_tunnel_init(RemminaProtocolWidget *gp) } } - g_debug("[RDP] tunnel has been optionally initialized. Now connecting to %s:%d\n", host, port); + remmina_plugin_service->debug("Tunnel has been optionally initialized. Now connecting to %s:%d", host, port); if (cert_host != host) g_free(cert_host); g_free(host); @@ -254,7 +254,7 @@ BOOL rf_auto_reconnect(rfContext *rfi) } /* A network disconnect was detected and we should try to reconnect */ - remmina_plugin_service->log_printf("[RDP][%s] network disconnection detected, initiating reconnection attempt\n", + remmina_plugin_service->debug("[%s] network disconnection detected, initiating reconnection attempt", rfi->settings->ServerHostname); ui = g_new0(RemminaPluginRdpUiObject, 1); @@ -272,13 +272,13 @@ BOOL rf_auto_reconnect(rfContext *rfi) while (TRUE) { /* Quit retrying if max retries has been exceeded */ if (rfi->reconnect_nattempt++ >= rfi->reconnect_maxattempts) { - remmina_plugin_service->log_printf("[RDP][%s] maximum number of reconnection attempts exceeded.\n", + remmina_plugin_service->debug("[%s] maximum number of reconnection attempts exceeded.", rfi->settings->ServerHostname); break; } /* Attempt the next reconnect */ - remmina_plugin_service->log_printf("[RDP][%s] reconnection, attempt #%d of %d\n", + remmina_plugin_service->debug("[%s] reconnection, attempt #%d of %d", rfi->settings->ServerHostname, rfi->reconnect_nattempt, rfi->reconnect_maxattempts); ui = g_new0(RemminaPluginRdpUiObject, 1); @@ -289,13 +289,12 @@ BOOL rf_auto_reconnect(rfContext *rfi) /* Reconnect the SSH tunnel, if needed */ if (!remmina_rdp_tunnel_init(rfi->protocol_widget)) { - remmina_plugin_service->log_printf("[RDP][%s] unable to recreate tunnel with remmina_rdp_tunnel_init.\n", + remmina_plugin_service->debug("[%s] unable to recreate tunnel with remmina_rdp_tunnel_init.", rfi->settings->ServerHostname); } else { if (freerdp_reconnect(rfi->instance)) { /* Reconnection is successful */ - remmina_plugin_service->log_printf("[RDP][%s] reconnected.\n", - rfi->settings->ServerHostname); + remmina_plugin_service->debug("[%s] reconnected.", rfi->settings->ServerHostname); rfi->is_reconnecting = FALSE; return TRUE; } @@ -787,7 +786,7 @@ static void remmina_rdp_main_loop(RemminaProtocolWidget *gp) } } freerdp_disconnect(rfi->instance); - g_debug("RDP client disconnected\n"); + remmina_plugin_service->debug("RDP client disconnected"); } int remmina_rdp_load_static_channel_addin(rdpChannels *channels, rdpSettings *settings, char *name, void *data) @@ -926,24 +925,24 @@ int remmina_rdp_set_printers(void *user_data, unsigned flags, cups_dest_t *dest) printer = (RDPDR_PRINTER *)calloc(1, sizeof(RDPDR_PRINTER)); printer->Type = RDPDR_DTYP_PRINT; - g_debug("Printer Type: %d", printer->Type); + remmina_plugin_service->debug("Printer Type: %d", printer->Type); rfi->settings->RedirectPrinters = TRUE; remmina_rdp_load_static_channel_addin(channels, rfi->settings, "rdpdr", rfi->settings); - g_debug("Destination: %s", dest->name); + remmina_plugin_service->debug("Destination: %s", dest->name); if (!(printer->Name = _strdup(dest->name))) { free(printer); return 1; } - g_debug("Printer Name: %s", printer->Name); + remmina_plugin_service->debug("Printer Name: %s", printer->Name); if (s) { gchar *d = remmina_rdp_find_prdriver(strdup(s), printer->Name); if (d) { printer->DriverName = strdup(d); - g_debug("Printer DriverName set to: %s", printer->DriverName); + remmina_plugin_service->debug("Printer DriverName set to: %s", printer->DriverName); g_free(d); } else { /** @@ -961,7 +960,7 @@ int remmina_rdp_set_printers(void *user_data, unsigned flags, cups_dest_t *dest) printer->DriverName = _strdup(model); } - g_debug("Printer Driver: %s", printer->DriverName); + remmina_plugin_service->debug("Printer Driver: %s", printer->DriverName); if (!freerdp_device_collection_add(rfi->settings, (RDPDR_DEVICE *)printer)) { free(printer->DriverName); free(printer->Name); @@ -1011,7 +1010,7 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget *gp) #if defined(PROXY_TYPE_IGNORE) if (!remmina_plugin_service->file_get_int(remminafile, "useproxyenv", FALSE) ? TRUE : FALSE) { - remmina_plugin_service->log_print("[RDP] Not using system proxy settings\n"); + remmina_plugin_service->debug("Not using system proxy settings"); rfi->settings->ProxyType = PROXY_TYPE_IGNORE; } #endif @@ -1099,11 +1098,11 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget *gp) gchar *proxy_password = g_strdup(remmina_plugin_service->file_get_string(remminafile, "proxy_password")); gchar *proxy_hostname = g_strdup(remmina_plugin_service->file_get_string(remminafile, "proxy_hostname")); gint proxy_port = remmina_plugin_service->file_get_int(remminafile, "proxy_port", 80); - g_debug("proxy_type: %s", proxy_type); - g_debug("proxy_username: %s", proxy_username); - g_debug("proxy_password: %s", proxy_password); - g_debug("proxy_hostname: %s", proxy_hostname); - g_debug("proxy_port: %d", proxy_port); + remmina_plugin_service->debug("proxy_type: %s", proxy_type); + remmina_plugin_service->debug("proxy_username: %s", proxy_username); + remmina_plugin_service->debug("proxy_password: %s", proxy_password); + remmina_plugin_service->debug("proxy_hostname: %s", proxy_hostname); + remmina_plugin_service->debug("proxy_port: %d", proxy_port); if (proxy_type && proxy_hostname) { if (g_strcmp0(proxy_type, "no_proxy") == 0) rfi->settings->ProxyType = PROXY_TYPE_IGNORE; @@ -1113,7 +1112,7 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget *gp) rfi->settings->ProxyType = PROXY_TYPE_SOCKS; else g_warning("Invalid proxy protocol, at the moment only no_proxy, HTTP and SOCKS5 are supported"); - g_debug("ProxyType set to: %d", rfi->settings->ProxyType); + remmina_plugin_service->debug("ProxyType set to: %d", rfi->settings->ProxyType); rfi->settings->ProxyHostname = proxy_hostname; if (proxy_username) rfi->settings->ProxyUsername = proxy_username; @@ -1387,12 +1386,12 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget *gp) if (remmina_plugin_service->file_get_int(remminafile, "shareprinter", FALSE)) { #ifdef HAVE_CUPS - g_debug("Sharing printers"); + remmina_plugin_service->debug("Sharing printers"); if (cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, 0, 0, remmina_rdp_set_printers, rfi)) - g_debug("All printers have been shared"); + remmina_plugin_service->debug("All printers have been shared"); else - g_debug("Cannot share printers, are there any available?"); + remmina_plugin_service->debug("Cannot share printers, are there any available?"); #endif /* HAVE_CUPS */ } @@ -1824,7 +1823,7 @@ static gboolean remmina_rdp_close_connection(RemminaProtocolWidget *gp) if (rfi && rfi->clipboard.srv_clip_data_wait == SCDW_BUSY_WAIT) { - g_debug("[RDP] requesting clipboard transfer to abort"); + remmina_plugin_service->debug("[RDP] requesting clipboard transfer to abort"); /* Allow clipboard transfer from server to terminate */ rfi->clipboard.srv_clip_data_wait = SCDW_ABORTING; usleep(100000); @@ -1915,10 +1914,10 @@ static gboolean remmina_rdp_get_screenshot(RemminaProtocolWidget *gp, RemminaPlu szmem = gdi->width * gdi->height * bytesPerPixel; - remmina_plugin_service->log_printf("[RDP] allocating %zu bytes for a full screenshot\n", szmem); + remmina_plugin_service->debug("allocating %zu bytes for a full screenshot", szmem); rpsd->buffer = malloc(szmem); if (!rpsd->buffer) { - remmina_plugin_service->log_printf("[RDP] could not set aside %zu bytes for a full screenshot\n", szmem); + remmina_plugin_service->debug("could not set aside %zu bytes for a full screenshot", szmem); return FALSE; } rpsd->width = gdi->width; diff --git a/plugins/secret/src/glibsecret_plugin.c b/plugins/secret/src/glibsecret_plugin.c index edfd2a539..ffde68c60 100644 --- a/plugins/secret/src/glibsecret_plugin.c +++ b/plugins/secret/src/glibsecret_plugin.c @@ -84,7 +84,7 @@ static void remmina_plugin_glibsecret_unlock_secret_service() 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); + remmina_plugin_service->debug("Requesting unlock of the default '%s' collection", lbl); objects = g_list_append(NULL, defaultcollection); secret_service_unlock_sync(secretservice, objects, NULL, &ul, &error); g_list_free(objects); @@ -108,9 +108,9 @@ void remmina_plugin_glibsecret_store_password(RemminaFile *remminafile, const gc NULL, &r, "filename", path, "key", key, NULL); g_free(s); if (r == NULL) { - remmina_plugin_service->log_printf("[glibsecret] password \"%s\" saved for file %s\n", key, path); + remmina_plugin_service->debug("Password \"%s\" saved for file %s\n", key, path); }else { - remmina_plugin_service->log_printf("[glibsecret] password \"%s\" cannot be saved for file %s\n", key, path); + remmina_plugin_service->debug("Password \"%s\" cannot be saved for file %s\n", key, path); g_error_free(r); } } @@ -127,12 +127,11 @@ 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) { - // remmina_plugin_service->log_printf("[glibsecret] found password for file %s\n", path); p = g_strdup(password); secret_password_free(password); return p; }else { - remmina_plugin_service->log_printf("[glibsecret] password cannot be found for file %s\n", path); + remmina_plugin_service->debug("Password cannot be found for file %s\n", path); return NULL; } } @@ -145,11 +144,10 @@ 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) { - remmina_plugin_service->log_printf("[glibsecret] password \"%s\" deleted for file %s\n", key, path); - }else { - remmina_plugin_service->log_printf("[glibsecret] password \"%s\" cannot be deleted for file %s\n", key, path); - } + if (r == NULL) + remmina_plugin_service->debug("password \"%s\" deleted for file %s", key, path); + else + remmina_plugin_service->debug("password \"%s\" cannot be deleted for file %s", key, path); } gboolean remmina_plugin_glibsecret_init() diff --git a/plugins/st/st_plugin.c b/plugins/st/st_plugin.c index 32d5c4d52..2144c8efa 100644 --- a/plugins/st/st_plugin.c +++ b/plugins/st/st_plugin.c @@ -67,7 +67,7 @@ static void remmina_plugin_st_on_plug_added(GtkSocket *socket, RemminaProtocolWi TRACE_CALL(__func__); RemminaPluginData *gpdata; gpdata = (RemminaPluginData*) g_object_get_data(G_OBJECT(gp), "plugin-data"); - remmina_plugin_service->log_printf("[%s] Plugin plug added on socket %d\n", PLUGIN_NAME, gpdata->socket_id); + remmina_plugin_service->debug("[%s] Plugin plug added on socket %d", PLUGIN_NAME, gpdata->socket_id); remmina_plugin_service->protocol_plugin_signal_connection_opened(gp); return; } @@ -75,14 +75,14 @@ static void remmina_plugin_st_on_plug_added(GtkSocket *socket, RemminaProtocolWi static void remmina_plugin_st_on_plug_removed(GtkSocket *socket, RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin plug removed\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin plug removed", PLUGIN_NAME); remmina_plugin_service->protocol_plugin_signal_connection_closed(gp); } static void remmina_plugin_st_init(RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin init\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin init", PLUGIN_NAME); RemminaPluginData *gpdata; gpdata = g_new0(RemminaPluginData, 1); @@ -99,7 +99,7 @@ static void remmina_plugin_st_init(RemminaProtocolWidget *gp) static gboolean remmina_plugin_st_open_connection(RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin open connection\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin open connection", PLUGIN_NAME); #define ADD_ARGUMENT(name, value) \ { \ argv[argc] = g_strdup(name); \ @@ -176,7 +176,7 @@ static gboolean remmina_plugin_st_open_connection(RemminaProtocolWidget *gp) ADD_ARGUMENT(NULL, NULL); // Retrieve the whole command line command_line = g_strjoinv(g_strdup(" "), (gchar **)&argv_debug[0]); - remmina_plugin_service->log_printf("[%s] starting %s\n", PLUGIN_NAME, command_line); + remmina_plugin_service->debug("[%s] starting %s", PLUGIN_NAME, command_line); // Execute the external process st g_spawn_command_line_async(command_line, &error); g_free(command_line); @@ -195,7 +195,7 @@ static gboolean remmina_plugin_st_open_connection(RemminaProtocolWidget *gp) } // Show attached window socket ID if (!remmina_plugin_service->file_get_int(remminafile, "detached", FALSE)) { - remmina_plugin_service->log_printf("[%s] attached window to socket %d\n", + remmina_plugin_service->debug("[%s] attached window to socket %d", PLUGIN_NAME, gpdata->socket_id); return TRUE; } @@ -208,7 +208,7 @@ static gboolean remmina_plugin_st_open_connection(RemminaProtocolWidget *gp) static gboolean remmina_plugin_st_close_connection(RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin close connection\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin close connection", PLUGIN_NAME); remmina_plugin_service->protocol_plugin_signal_connection_closed(gp); return FALSE; } diff --git a/plugins/tool_hello_world/plugin.c b/plugins/tool_hello_world/plugin.c index 44a75a48f..fe41a0bc0 100644 --- a/plugins/tool_hello_world/plugin.c +++ b/plugins/tool_hello_world/plugin.c @@ -46,13 +46,13 @@ static RemminaPluginService *remmina_plugin_service = NULL; static void remmina_plugin_tool_init(RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin init\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin init", PLUGIN_NAME); } static gboolean remmina_plugin_tool_open_connection(RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin open connection\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin open connection", PLUGIN_NAME); GtkDialog *dialog; dialog = GTK_DIALOG(gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL | GTK_DIALOG_USE_HEADER_BAR, @@ -65,7 +65,7 @@ static gboolean remmina_plugin_tool_open_connection(RemminaProtocolWidget *gp) static gboolean remmina_plugin_tool_close_connection(RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - remmina_plugin_service->log_printf("[%s] Plugin close connection\n", PLUGIN_NAME); + remmina_plugin_service->debug("[%s] Plugin close connection", PLUGIN_NAME); remmina_plugin_service->protocol_plugin_emit_signal(gp, "disconnect"); return FALSE; } diff --git a/plugins/vnc/vnc_plugin.c b/plugins/vnc/vnc_plugin.c index ab48c4b61..3fc45fb06 100644 --- a/plugins/vnc/vnc_plugin.c +++ b/plugins/vnc/vnc_plugin.c @@ -939,17 +939,14 @@ static void remmina_plugin_vnc_rfb_output(const char *format, ...) NULL); g_snprintf(vnc_error, MAX_ERROR_LENGTH, ff, p); g_free(ff); - } else { + } else g_snprintf(vnc_error, MAX_ERROR_LENGTH, _(f), p); - } - } else { + } else g_vsnprintf(vnc_error, MAX_ERROR_LENGTH, _(f), args); - } g_free(f); va_end(args); - remmina_plugin_service->log_printf("[VNC] %s\n", vnc_error); - g_debug("[VNC] %s", vnc_error); + remmina_plugin_service->debug("VNC returned: %s", vnc_error); } static void remmina_plugin_vnc_chat_on_send(RemminaProtocolWidget *gp, const gchar *text) diff --git a/plugins/www/www_plugin.c b/plugins/www/www_plugin.c index 92edd883b..32ec68fc5 100644 --- a/plugins/www/www_plugin.c +++ b/plugins/www/www_plugin.c @@ -86,13 +86,13 @@ void remmina_plugin_www_download_started(WebKitWebContext *context, void remmina_plugin_www_response_received(WebKitDownload *download, GParamSpec *ps, RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - g_debug("Download response received"); + remmina_plugin_service->debug("Download response received"); } void remmina_plugin_www_notify_download(WebKitDownload *download, gchar *destination, RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - g_debug("Download is finished"); + remmina_plugin_service->debug("Download is finished"); const gchar *dest = webkit_download_get_destination(download); www_utils_send_notification("www-plugin-download-completed-id", _("File downloaded"), dest); //download(gp, webkit_download_get_response(download)); @@ -128,7 +128,7 @@ static gboolean remmina_plugin_www_decide_policy_cb( void remmina_plugin_www_decide_nav(WebKitPolicyDecision *decision, RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - g_debug("Policy decision navigation"); + remmina_plugin_service->debug("Policy decision navigation"); const gchar *url = NULL; WebKitNavigationAction *a = webkit_navigation_policy_decision_get_navigation_action( @@ -136,25 +136,25 @@ void remmina_plugin_www_decide_nav(WebKitPolicyDecision *decision, RemminaProtoc switch (webkit_navigation_action_get_navigation_type(a)) { case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: - g_debug("WEBKIT_NAVIGATION_TYPE_LINK_CLICKED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_LINK_CLICKED"); url = webkit_uri_request_get_uri( webkit_navigation_action_get_request(a)); - g_debug("url is %s ", url); + remmina_plugin_service->debug("url is %s ", url); break; case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: - g_debug("WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED"); break; case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: - g_debug("WEBKIT_NAVIGATION_TYPE_BACK_FORWARD"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_BACK_FORWARD"); break; case WEBKIT_NAVIGATION_TYPE_RELOAD: - g_debug("WEBKIT_NAVIGATION_TYPE_RELOAD"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_RELOAD"); break; case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: - g_debug("WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED"); break; case WEBKIT_NAVIGATION_TYPE_OTHER: - g_debug("WEBKIT_NAVIGATION_TYPE_OTHER"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_OTHER"); break; default: /* Do not navigate to links with a "_blank" target (popup) */ @@ -174,7 +174,7 @@ void remmina_plugin_www_decide_nav(WebKitPolicyDecision *decision, RemminaProtoc void remmina_plugin_www_on_create(WebKitWebView *webview, WebKitNavigationAction *a, RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - g_debug("New web-view"); + remmina_plugin_service->debug("New web-view"); const gchar *url = NULL; @@ -183,52 +183,52 @@ void remmina_plugin_www_on_create(WebKitWebView *webview, WebKitNavigationAction switch (webkit_navigation_action_get_navigation_type(a)) { case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: - g_debug("WEBKIT_NAVIGATION_TYPE_LINK_CLICKED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_LINK_CLICKED"); url = webkit_uri_request_get_uri( webkit_navigation_action_get_request(a)); - g_debug("Downloading url %s ", url); + remmina_plugin_service->debug("Downloading url %s ", url); WebKitDownload *d = webkit_web_view_download_uri(gpdata->webview, url); break; case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: - g_debug("WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED"); break; case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: - g_debug("WEBKIT_NAVIGATION_TYPE_BACK_FORWARD"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_BACK_FORWARD"); break; case WEBKIT_NAVIGATION_TYPE_RELOAD: - g_debug("WEBKIT_NAVIGATION_TYPE_RELOAD"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_RELOAD"); break; case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: - g_debug("WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED"); /* Filter domains here */ /* If the value of “mouse-button” is not 0, then the navigation was triggered by a mouse event. * test for link clicked but no button ? */ url = webkit_uri_request_get_uri( webkit_navigation_action_get_request(a)); - g_debug("Trying to open url: %s", url); + remmina_plugin_service->debug("Trying to open url: %s", url); webkit_web_view_load_uri(gpdata->webview, url); break; case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - g_debug("WEBKIT_NAVIGATION_TYPE_OTHER"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_OTHER"); /* Filter domains here */ /* If the value of “mouse-button” is not 0, then the navigation was triggered by a mouse event. * test for link clicked but no button ? */ url = webkit_uri_request_get_uri( webkit_navigation_action_get_request(a)); - g_debug("Trying to open url: %s", url); + remmina_plugin_service->debug("Trying to open url: %s", url); webkit_web_view_load_uri(gpdata->webview, url); break; default: break; } - g_debug("WEBKIT_NAVIGATION_TYPE is %d", webkit_navigation_action_get_navigation_type(a)); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE is %d", webkit_navigation_action_get_navigation_type(a)); } void remmina_plugin_www_decide_newwin(WebKitPolicyDecision *decision, RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - g_debug("Policy decision new window"); + remmina_plugin_service->debug("Policy decision new window"); const gchar *url = NULL; @@ -241,54 +241,54 @@ void remmina_plugin_www_decide_newwin(WebKitPolicyDecision *decision, RemminaPro switch (webkit_navigation_action_get_navigation_type(a)) { case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: - g_debug("WEBKIT_NAVIGATION_TYPE_LINK_CLICKED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_LINK_CLICKED"); url = webkit_uri_request_get_uri( webkit_navigation_action_get_request(a)); - g_debug("Downloading url %s ", url); + remmina_plugin_service->debug("Downloading url %s ", url); WebKitDownload *d = webkit_web_view_download_uri(gpdata->webview, url); break; case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: - g_debug("WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED"); break; case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: - g_debug("WEBKIT_NAVIGATION_TYPE_BACK_FORWARD"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_BACK_FORWARD"); break; case WEBKIT_NAVIGATION_TYPE_RELOAD: - g_debug("WEBKIT_NAVIGATION_TYPE_RELOAD"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_RELOAD"); break; case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: - g_debug("WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED"); /* Filter domains here */ /* If the value of “mouse-button” is not 0, then the navigation was triggered by a mouse event. * test for link clicked but no button ? */ url = webkit_uri_request_get_uri( webkit_navigation_action_get_request(a)); - g_debug("Trying to open url: %s", url); + remmina_plugin_service->debug("Trying to open url: %s", url); webkit_web_view_load_uri(gpdata->webview, url); break; case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - g_debug("WEBKIT_NAVIGATION_TYPE_OTHER"); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE_OTHER"); /* Filter domains here */ /* If the value of “mouse-button” is not 0, then the navigation was triggered by a mouse event. * test for link clicked but no button ? */ url = webkit_uri_request_get_uri( webkit_navigation_action_get_request(a)); - g_debug("Trying to open url: %s", url); + remmina_plugin_service->debug("Trying to open url: %s", url); webkit_web_view_load_uri(gpdata->webview, url); break; default: break; } - g_debug("WEBKIT_NAVIGATION_TYPE is %d", webkit_navigation_action_get_navigation_type(a)); + remmina_plugin_service->debug("WEBKIT_NAVIGATION_TYPE is %d", webkit_navigation_action_get_navigation_type(a)); webkit_policy_decision_ignore(decision); } gboolean remmina_plugin_www_decide_resource(WebKitPolicyDecision *decision, RemminaProtocolWidget *gp) { TRACE_CALL(__func__); - g_debug("Policy decision resource"); + remmina_plugin_service->debug("Policy decision resource"); WebKitResponsePolicyDecision *response_decision = WEBKIT_RESPONSE_POLICY_DECISION(decision); WebKitURIResponse *response = @@ -305,7 +305,7 @@ gboolean remmina_plugin_www_decide_resource(WebKitPolicyDecision *decision, Remm mime_type = webkit_uri_response_get_mime_type(response); - g_debug("The media type is %s", mime_type); + remmina_plugin_service->debug("The media type is %s", mime_type); /* If WebKit can't handle the media type, start the download * process */ @@ -329,7 +329,7 @@ gboolean remmina_plugin_www_decide_resource(WebKitPolicyDecision *decision, Remm else if (!strncmp(mime_type, "application/octet-stream", 6)) type = WWW_WEB_VIEW_DOCUMENT_OCTET_STREAM; - g_debug("Document type is %i", type); + remmina_plugin_service->debug("Document type is %i", type); /* FIXME: Maybe it makes more sense to have an API to query the media * type when the load of a page starts than doing this here. @@ -395,7 +395,7 @@ static gboolean remmina_plugin_www_load_failed_tls_cb(WebKitWebView *webview, { TRACE_CALL(__func__); /* Avoid failing if certificate is not good. TODO: Add widgets to let the user decide */ - g_debug("Ignoring certificate and return TRUE"); + remmina_plugin_service->debug("Ignoring certificate and return TRUE"); return TRUE; } @@ -424,7 +424,7 @@ static void remmina_plugin_www_init(RemminaProtocolWidget *gp) PLUGIN_NAME, NULL); cache_dir = g_build_path("/", datapath, "cache", NULL); - g_debug("WWW data path is %s", datapath); + remmina_plugin_service->debug("WWW data path is %s", datapath); if (datapath) { gchar *indexeddb_dir = g_build_filename(datapath, "indexeddb", NULL); @@ -616,7 +616,7 @@ static void remmina_plugin_www_form_auth(WebKitWebView *webview, remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); - g_debug("load-changed emitted"); + remmina_plugin_service->debug("load-changed emitted"); const gchar *const *dirs = g_get_system_data_dirs(); @@ -643,10 +643,10 @@ static void remmina_plugin_www_form_auth(WebKitWebView *webview, switch (load_event) { case WEBKIT_LOAD_STARTED: - g_debug("Load started"); + remmina_plugin_service->debug("Load started"); break; case WEBKIT_LOAD_REDIRECTED: - g_debug("Load redirected"); + remmina_plugin_service->debug("Load redirected"); break; case WEBKIT_LOAD_COMMITTED: /* The load is being performed. Current URI is @@ -654,18 +654,18 @@ static void remmina_plugin_www_form_auth(WebKitWebView *webview, * load is requested or a navigation within the * same page is performed * uri = webkit_web_view_get_uri (webview); */ - g_debug("Load committed"); + remmina_plugin_service->debug("Load committed"); break; case WEBKIT_LOAD_FINISHED: /* Load finished, we can now set user/password * in the HTML form */ - g_debug("Load finished"); + remmina_plugin_service->debug("Load finished"); if (gpdata && gpdata->formauthenticated == TRUE) break; if (remmina_plugin_service->file_get_string(remminafile, "username") || remmina_plugin_service->file_get_string(remminafile, "password")) { - g_debug("Authentication is enabled"); + remmina_plugin_service->debug("Authentication is enabled"); if (www_js_file) { error = NULL; if (g_file_get_contents(www_js_file, &s_js, NULL, &error)) { @@ -681,7 +681,7 @@ static void remmina_plugin_www_form_auth(WebKitWebView *webview, if (!s_js || s_js[0] == '\0') { break; } else { - g_debug("Trying to send this JavaScript: %s", s_js); + remmina_plugin_service->debug("Trying to send this JavaScript: %s", s_js); webkit_web_view_run_javascript( webview, s_js, @@ -692,10 +692,10 @@ static void remmina_plugin_www_form_auth(WebKitWebView *webview, } } else { if (error) { - g_debug("Unable to read file: %s\n", error->message); + remmina_plugin_service->debug("Unable to read file: %s\n", error->message); g_error_free(error); } else { - g_debug("Unable to read file. No error returned from glib.\n"); + remmina_plugin_service->debug("Unable to read file. No error returned from glib.\n"); } } } @@ -749,7 +749,7 @@ static gboolean remmina_plugin_www_open_connection(RemminaProtocolWidget *gp) if (remmina_plugin_service->file_get_string(remminafile, "username") || remmina_plugin_service->file_get_string(remminafile, "password")) { - g_debug("Authentication is enabled"); + remmina_plugin_service->debug("Authentication is enabled"); remmina_plugin_www_on_auth(gpdata->webview, NULL, gp); } @@ -811,7 +811,7 @@ static void remmina_plugin_www_save_snapshot(GObject *object, GAsyncResult *resu screenshot = gdk_pixbuf_get_from_surface(surface, 0, 0, width, height); if (screenshot == NULL) - g_debug("WWW: gdk_pixbuf_get_from_surface failed"); + remmina_plugin_service->debug("WWW: gdk_pixbuf_get_from_surface failed"); pngstr = g_string_new(g_strdup_printf("%s/%s.png", remmina_plugin_service->pref_get_value("screenshot_path"), @@ -833,7 +833,7 @@ static void remmina_plugin_www_save_snapshot(GObject *object, GAsyncResult *resu g_strdup_printf("%f", g_date_time_get_seconds(date))); g_date_time_unref(date); pngname = g_string_free(pngstr, FALSE); - g_debug("Saving screenshot as %s", pngname); + remmina_plugin_service->debug("Saving screenshot as %s", pngname); cairo_surface_write_to_png(surface, pngname); if (g_file_test(pngname, G_FILE_TEST_EXISTS)) diff --git a/src/include/remmina/plugin.h b/src/include/remmina/plugin.h index 32c7f1f4c..ca2014f90 100644 --- a/src/include/remmina/plugin.h +++ b/src/include/remmina/plugin.h @@ -211,6 +211,7 @@ typedef struct _RemminaPluginService { gboolean (*pref_get_ssh_parseconfig)(void); guint (*pref_keymap_get_keyval)(const gchar *keymap, guint keyval); + void (*debug)(const gchar *fmt, ...); void (*log_print)(const gchar *text); void (*log_printf)(const gchar *fmt, ...); diff --git a/src/include/remmina/remmina_trace_calls.h b/src/include/remmina/remmina_trace_calls.h index 16274b7f7..e5450df2d 100644 --- a/src/include/remmina/remmina_trace_calls.h +++ b/src/include/remmina/remmina_trace_calls.h @@ -35,19 +35,26 @@ #pragma once -#ifdef WITH_TRACE_CALLS - #include <gtk/gtk.h> +extern char *fun; /* function name externalized to be used everywhere */ +#define UNUSED(expr) do { (void)(expr); } while (0) + +#ifdef WITH_TRACE_CALLS #define TRACE_CALL(text) \ { \ + fun = g_strdup (text); \ + UNUSED(fun); \ GDateTime *datetime = g_date_time_new_now_local(); \ gchar *sfmtdate = g_date_time_format(datetime, "%x %X"); \ g_print("%s Trace calls: %s\n", sfmtdate, text); \ g_free(sfmtdate); \ g_date_time_unref(datetime); \ } - #else -#define TRACE_CALL(text) +#define TRACE_CALL(text) \ + { \ + fun = g_strdup (text); \ + UNUSED(fun); \ + } #endif /* _WITH_TRACE_CALLS_ */ @@ -1961,7 +1961,7 @@ static void rcw_toolbar_screenshot(GtkWidget *widget, RemminaConnectionWindow *c if (remmina_protocol_widget_plugin_screenshot(gp, &rpsd)) { // Good, we have a screenshot from the plugin ! - remmina_log_printf("Screenshot from plugin: w=%d h=%d bpp=%d bytespp=%d\n", + remmina_debug("Screenshot from plugin: w=%d h=%d bpp=%d bytespp=%d\n", rpsd.width, rpsd.height, rpsd.bitsPerPixel, rpsd.bytesPerPixel); width = rpsd.width; @@ -2853,11 +2853,11 @@ static gboolean rcw_map_event_fullscreen(GtkWidget *widget, GdkEvent *event, gpo gtk_window_fullscreen_on_monitor(GTK_WINDOW(widget), gtk_window_get_screen(GTK_WINDOW(widget)), target_monitor); } else { - remmina_log_print("Fullscreen managed by WM or by the user, as per settings"); + remmina_debug("Fullscreen managed by WM or by the user, as per settings"); gtk_window_fullscreen(GTK_WINDOW(widget)); } #else - remmina_log_print("Cannot fullscreen on a specific monitor, feature available from GTK 3.18"); + remmina_debug("Cannot fullscreen on a specific monitor, feature available from GTK 3.18"); gtk_window_fullscreen(GTK_WINDOW(widget)); #endif diff --git a/src/remmina_exec.c b/src/remmina_exec.c index 6bcebbf7a..5a6793e7e 100644 --- a/src/remmina_exec.c +++ b/src/remmina_exec.c @@ -41,6 +41,7 @@ #include <stdlib.h> #include "remmina.h" #include "remmina_main.h" +#include "remmina_log.h" #include "remmina_pref.h" #include "remmina_widget_pool.h" #include "remmina_unlock.h" @@ -205,7 +206,7 @@ static void remmina_exec_autostart_cb(RemminaFile *remminafile, gpointer user_da TRACE_CALL(__func__); if (remmina_file_get_int(remminafile, "enable-autostart", FALSE)) { - g_debug ("Profile %s is set to autostart", remminafile->filename); + remmina_debug ("Profile %s is set to autostart", remminafile->filename); rcw_open_from_filename(remminafile->filename); } diff --git a/src/remmina_file.c b/src/remmina_file.c index 8ea09b04d..20eb7be49 100644 --- a/src/remmina_file.c +++ b/src/remmina_file.c @@ -345,7 +345,7 @@ remmina_file_load(const gchar *filename) if (g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS)) { if (!g_key_file_load_from_file(gkeyfile, filename, G_KEY_FILE_NONE, NULL)) { g_key_file_free(gkeyfile); - g_debug("Unable to load remmina profile file %s: g_key_file_load_from_file() returned NULL.\n", filename); + remmina_debug ("Unable to load remmina profile file %s: g_key_file_load_from_file() returned NULL.\n", filename); return NULL; } } @@ -411,7 +411,7 @@ remmina_file_load(const gchar *filename) } } else { - g_debug("Unable to load remmina profile file %s: cannot find key name= in section remmina.\n", filename); + remmina_debug ("Unable to load remmina profile file %s: cannot find key name= in section remmina.\n", filename); remminafile = NULL; } @@ -578,7 +578,7 @@ void remmina_file_save(RemminaFile *remminafile) if ((gkeyfile = remmina_file_get_keyfile(remminafile)) == NULL) return; - g_debug("Saving profile"); + remmina_debug ("Saving profile"); /* get disablepasswordstoring */ nopasswdsave = remmina_file_get_int(remminafile, "disablepasswordstoring", 0); /* Identify the protocol plugin and get pointers to its RemminaProtocolSetting structs */ @@ -598,7 +598,7 @@ void remmina_file_save(RemminaFile *remminafile) if (remmina_plugin_manager_is_encrypted_setting(protocol_plugin, key)) { if (remminafile->filename && g_strcmp0(remminafile->filename, remmina_pref_file)) { if (secret_service_available && nopasswdsave == 0) { - g_debug ("We have a secret and disablepasswordstoring=0"); + remmina_debug ("We have a secret and disablepasswordstoring=0"); if (value && value[0]) { if (g_strcmp0(value, ".") != 0) secret_plugin->store_password(remminafile, key, value); @@ -608,7 +608,7 @@ void remmina_file_save(RemminaFile *remminafile) secret_plugin->delete_password(remminafile, key); } } else { - g_debug ("We have a password and disablepasswordstoring=0"); + remmina_debug ("We have a password and disablepasswordstoring=0"); if (value && value[0] && nopasswdsave == 0) { s = remmina_crypt_encrypt(value); g_key_file_set_string(gkeyfile, KEYFILE_GROUP_REMMINA, key, s); @@ -620,7 +620,7 @@ void remmina_file_save(RemminaFile *remminafile) if (secret_service_available && nopasswdsave == 1) { if (value && value[0]) { if (g_strcmp0(value, ".") != 0) { - g_debug ("Deleting the secret in the keyring as disablepasswordstoring=1"); + remmina_debug ("Deleting the secret in the keyring as disablepasswordstoring=1"); secret_plugin->delete_password(remminafile, key); g_key_file_set_string(gkeyfile, KEYFILE_GROUP_REMMINA, key, "."); } @@ -644,7 +644,7 @@ void remmina_file_save(RemminaFile *remminafile) content = g_key_file_to_data(gkeyfile, &length, NULL); if (g_file_set_contents(remminafile->filename, content, length, &err)) { - g_debug("Profile saved"); + remmina_debug ("Profile saved"); } else { g_warning("Remmina connection profile cannot be saved, with error %d (%s)", err->code, err->message); } @@ -845,17 +845,17 @@ remmina_file_touch(RemminaFile *remminafile) if ((r = stat(remminafile->filename, &st)) < 0) { if (errno != ENOENT) - remmina_log_printf("stat %s:", remminafile->filename); + remmina_debug("stat %s:", remminafile->filename); } else if (!r) { times[0] = st.st_atim; times[1] = st.st_mtim; if (utimensat(AT_FDCWD, remminafile->filename, times, 0) < 0) - remmina_log_printf("utimensat %s:", remminafile->filename); + remmina_debug("utimensat %s:", remminafile->filename); return; } if ((fd = open(remminafile->filename, O_CREAT | O_EXCL, 0644)) < 0) - remmina_log_printf("open %s:", remminafile->filename); + remmina_debug("open %s:", remminafile->filename); close(fd); remmina_file_touch(remminafile); diff --git a/src/remmina_log.c b/src/remmina_log.c index bc05ebeba..78fb473a6 100644 --- a/src/remmina_log.c +++ b/src/remmina_log.c @@ -76,7 +76,6 @@ static GtkWidget *log_window = NULL; static gboolean remmina_log_on_keypress(GtkWidget *widget, GdkEvent *event, gpointer user_data) { TRACE_CALL(__func__); - // RemminaLogWindow *logwin = (RemminaLogWindow*)user_data; GdkEventKey *e = (GdkEventKey *)event; if (!log_window) @@ -188,6 +187,31 @@ void remmina_log_print(const gchar *text) IDLE_ADD(remmina_log_print_real, g_strdup(text)); } +/** + * Print a string in the Remmina Debug Windows and in the terminal. + * The string will be visible in the terminal if G_MESSAGES_DEBUG=all + */ +void remmina_debug(const gchar *fmt, ...) +{ + /* IMPORTANT: DO NOT USE TRACES IN THIS FUNCION */ + /* DO NOT USE TRACE_CALL(__func__); */ + + va_list args; + gchar *text; + va_start(args, fmt); + text = g_strdup_vprintf(fmt, args); + va_end(args); + g_autofree gchar *buf = g_strconcat("(", fun, ") - ", text, NULL); + + g_debug ("%s", g_strdup(buf)); + + buf = g_strconcat (buf, "\n", NULL); + + if (!log_window) + return; + IDLE_ADD(remmina_log_print_real, g_strdup(buf)); +} + void remmina_log_printf(const gchar *fmt, ...) { TRACE_CALL(__func__); diff --git a/src/remmina_log.h b/src/remmina_log.h index 0c7d9627b..d8508d50d 100644 --- a/src/remmina_log.h +++ b/src/remmina_log.h @@ -40,6 +40,7 @@ G_BEGIN_DECLS void remmina_log_start(void); gboolean remmina_log_running(void); void remmina_log_print(const gchar *text); +void remmina_debug(const gchar *fmt, ...); void remmina_log_printf(const gchar *fmt, ...); G_END_DECLS diff --git a/src/remmina_main.c b/src/remmina_main.c index b1f51abd6..f0e71acdb 100644 --- a/src/remmina_main.c +++ b/src/remmina_main.c @@ -66,6 +66,8 @@ static RemminaMain *remminamain; #define RM_GET_OBJECT(object_name) gtk_builder_get_object(remminamain->builder, object_name) +char *fun = "main"; /* just setting the initial value of the calling function name, that is set in the remmina_trace */ + enum { PROTOCOL_COLUMN, NAME_COLUMN, @@ -1220,6 +1222,7 @@ static void remmina_main_init(void) int i, qcp_idx, qcp_actidx; char *name; + remmina_debug ("Initializing the Remmina main window"); remminamain->priv->expanded_group = remmina_string_array_new_from_string(remmina_pref.expanded_group); if (!kioskmode && kioskmode == FALSE) { gtk_window_set_title(remminamain->window, _("Remmina Remote Desktop Client")); diff --git a/src/remmina_mpchange.c b/src/remmina_mpchange.c index e68aa8067..338b0e6bb 100644 --- a/src/remmina_mpchange.c +++ b/src/remmina_mpchange.c @@ -342,7 +342,7 @@ static gboolean remmina_file_multipasswd_changer_mt(gpointer d) bu = remmina_public_gtk_builder_new_from_file("remmina_mpc.glade"); if (!bu) { - remmina_log_printf("Unable to load the multiple password changer glade file interface\n"); + remmina_debug("Unable to load the multiple password changer glade file interface\n"); return FALSE; } diff --git a/src/remmina_plugin_manager.c b/src/remmina_plugin_manager.c index 74f813c50..539629af6 100644 --- a/src/remmina_plugin_manager.c +++ b/src/remmina_plugin_manager.c @@ -236,6 +236,7 @@ RemminaPluginService remmina_plugin_manager_service = remmina_pref_get_ssh_parseconfig, remmina_pref_keymap_get_keyval, + remmina_debug, remmina_log_print, remmina_log_printf, diff --git a/src/remmina_protocol_widget.c b/src/remmina_protocol_widget.c index 89adf6ab8..61cdd867a 100644 --- a/src/remmina_protocol_widget.c +++ b/src/remmina_protocol_widget.c @@ -555,7 +555,7 @@ void remmina_protocol_widget_send_keystrokes(RemminaProtocolWidget *gp, GtkMenuI gboolean remmina_protocol_widget_plugin_screenshot(RemminaProtocolWidget *gp, RemminaPluginScreenshotData *rpsd) { if (!gp->priv->plugin->get_plugin_screenshot) { - remmina_log_printf("plugin screenshot function is not implemented\n"); + remmina_debug("plugin screenshot function is not implemented, using core Remmina functionality"); return FALSE; } @@ -748,14 +748,14 @@ static RemminaSSHTunnel* remmina_protocol_widget_init_tunnel(RemminaProtocolWidg g_free(msg); if (!remmina_ssh_init_session(REMMINA_SSH(tunnel))) { - g_debug ("[SSH] %s Cannot init SSH session with tunnel struct", __func__); + remmina_debug ("%s Cannot init SSH session with tunnel struct", __func__); remmina_protocol_widget_set_error(gp, REMMINA_SSH(tunnel)->error); remmina_ssh_tunnel_free(tunnel); return NULL; } ret = remmina_ssh_auth_gui(REMMINA_SSH(tunnel), gp, gp->priv->remmina_file); - g_debug ("[SSH] tunnel auth returned %d", ret); + remmina_debug ("Tunnel auth returned %d", ret); if (ret != REMMINA_SSH_AUTH_SUCCESS) { if (ret != REMMINA_SSH_AUTH_USERCANCEL) remmina_protocol_widget_set_error(gp, REMMINA_SSH(tunnel)->error); @@ -855,7 +855,7 @@ gchar *remmina_protocol_widget_start_direct_tunnel(RemminaProtocolWidget *gp, gi if (!tunnel) { g_free(srv_host); g_free(ssh_tunnel_host); - g_debug ("[SSH] %s remmina_protocol_widget_init_tunnel failed with error is %s\n", + remmina_debug ("%s remmina_protocol_widget_init_tunnel failed with error is %s", __func__, remmina_protocol_widget_get_error_message(gp)); return NULL; } diff --git a/src/remmina_ssh.c b/src/remmina_ssh.c index a80008fc3..073e61c45 100644 --- a/src/remmina_ssh.c +++ b/src/remmina_ssh.c @@ -193,21 +193,21 @@ remmina_ssh_auth_password(RemminaSSH *ssh) TRACE_CALL(__func__); gint ret; - g_debug("[SSH] %s\n", __func__); + remmina_debug("Password authentication"); ret = SSH_AUTH_ERROR; if (ssh->authenticated) { - g_debug("[SSH] already authenticated, returning from %s", __func__); + remmina_debug("Already authenticated"); return REMMINA_SSH_AUTH_SUCCESS; } if (ssh->password == NULL) { remmina_ssh_set_error(ssh, "Password is null"); - g_debug("[SSH] password is null, returning from %s", __func__); + remmina_debug("Password is null, returning"); return REMMINA_SSH_AUTH_AUTHFAILED_RETRY_AFTER_PROMPT; } ret = ssh_userauth_password(ssh->session, NULL, ssh->password); - g_debug("[SSH] %s ssh_userauth_password returned %d\n", __func__, ret); + remmina_debug("Authentication returned %d", ret); if (ret != SSH_AUTH_SUCCESS) { // TRANSLATORS: The placeholder %s is an error message remmina_ssh_set_error(ssh, _("Could not authenticate with SSH password. %s")); @@ -267,7 +267,7 @@ remmina_ssh_auth_pubkey(RemminaSSH *ssh) if (ret != SSH_AUTH_SUCCESS) { // TRANSLATORS: The placeholder %s is an error message remmina_ssh_set_error(ssh, _("Could not authenticate with public SSH key. %s")); - g_debug("[SSH] %s() failed. Error is %s", __func__, ssh->error); + remmina_debug("Cannot authenticate with public SSH key. Error is %s", ssh->error); return REMMINA_SSH_AUTH_AUTHFAILED_RETRY_AFTER_PROMPT; } @@ -287,7 +287,7 @@ remmina_ssh_auth_auto_pubkey(RemminaSSH *ssh, RemminaProtocolWidget *gp, Remmina if (ret != SSH_AUTH_SUCCESS) { // TRANSLATORS: The placeholder %s is an error message remmina_ssh_set_error(ssh, _("Could not authenticate automatically with public SSH key. %s")); - g_debug("[SSH] %s() failed. Error is %s", __func__, ssh->error); + g_debug("Cannot authenticate automatically with public SSH key. Error is %s", ssh->error); return REMMINA_SSH_AUTH_AUTHFAILED_RETRY_AFTER_PROMPT; } @@ -378,7 +378,7 @@ remmina_ssh_auth(RemminaSSH *ssh, const gchar *password, RemminaProtocolWidget * */ ssh_userauth_none(ssh->session, NULL); method = ssh_userauth_list(ssh->session, NULL); - g_debug("[SSH] methods supported by server: %s%s%s%s", + remmina_debug("Methods supported by server: %s%s%s%s", (method & SSH_AUTH_METHOD_PASSWORD) ? "SSH_AUTH_METHOD_PASSWORD ": "", (method & SSH_AUTH_METHOD_PUBLICKEY) ? "SSH_AUTH_METHOD_PUBLICKEY ": "", (method & SSH_AUTH_METHOD_HOSTBASED) ? "SSH_AUTH_METHOD_HOSTBASED ": "", @@ -386,7 +386,7 @@ remmina_ssh_auth(RemminaSSH *ssh, const gchar *password, RemminaProtocolWidget * ); switch (ssh->auth) { case SSH_AUTH_PASSWORD: - g_debug("[SSH] ssh->auth: SSH_AUTH_PASSWORD (%d)", ssh->auth); + remmina_debug("SSH_AUTH_PASSWORD (%d)", ssh->auth); if (ssh->authenticated) return REMMINA_SSH_AUTH_SUCCESS; if (method & SSH_AUTH_METHOD_PASSWORD) { @@ -410,7 +410,7 @@ remmina_ssh_auth(RemminaSSH *ssh, const gchar *password, RemminaProtocolWidget * return REMMINA_SSH_AUTH_SUCCESS; case SSH_AUTH_PUBLICKEY: - g_debug("[SSH] ssh->auth: SSH_AUTH_PUBLICKEY (%d)", ssh->auth); + remmina_debug("SSH_AUTH_PUBLICKEY (%d)", ssh->auth); if (method & SSH_AUTH_METHOD_PUBLICKEY) return remmina_ssh_auth_pubkey(ssh); // The real error here should be: "The SSH server %s:%d does not support public key authentication" @@ -418,11 +418,11 @@ remmina_ssh_auth(RemminaSSH *ssh, const gchar *password, RemminaProtocolWidget * break; case SSH_AUTH_AGENT: - g_debug("[SSH] ssh->auth: SSH_AUTH_AGENT (%d)", ssh->auth); + remmina_debug("SSH_AUTH_AGENT (%d)", ssh->auth); return remmina_ssh_auth_agent(ssh); case SSH_AUTH_AUTO_PUBLICKEY: - g_debug("[SSH] ssh->auth: SSH_AUTH_AUTO_PUBLICKEY (%d)", ssh->auth); + remmina_debug("SSH_AUTH_AUTO_PUBLICKEY (%d)", ssh->auth); /* ssh_agent or none */ if (method & SSH_AUTH_METHOD_PUBLICKEY) return remmina_ssh_auth_auto_pubkey(ssh, gp, remminafile); @@ -439,17 +439,17 @@ remmina_ssh_auth(RemminaSSH *ssh, const gchar *password, RemminaProtocolWidget * #endif case SSH_AUTH_GSSAPI: - g_debug("[SSH] ssh->auth: SSH_AUTH_GSSAPI (%d)", ssh->auth); + remmina_debug("SSH_AUTH_GSSAPI (%d)", ssh->auth); if (method & SSH_AUTH_METHOD_GSSAPI_MIC) return remmina_ssh_auth_gssapi(ssh); break; default: - g_debug("[SSH] ssh->auth: UNKNOWN (%d)", ssh->auth); + remmina_debug("UNKNOWN (%d)", ssh->auth); return REMMINA_SSH_AUTH_FATAL_ERROR; } - g_debug("[SSH] user auth method not supported at server side"); + remmina_debug("User auth method not supported at server side"); // We come here after a "break". ssh->error should be already set return REMMINA_SSH_AUTH_FATAL_ERROR; @@ -600,7 +600,7 @@ remmina_ssh_auth_gui(RemminaSSH *ssh, RemminaProtocolWidget *gp, RemminaFile *re /* Try existing password/passphrase first */ ret = remmina_ssh_auth(ssh, current_pwd, gp, remminafile); - g_debug("[SSH] %s remmina_ssh_auth returned %d at 1st attempt\n", __func__, ret); + remmina_debug("Returned %d at 1st attempt", ret); /* It seems that functions like ssh_userauth_password() can only be called 3 times * on a ssh connection. And the 3rd failed attempt will block the calling thread forever. @@ -609,7 +609,7 @@ remmina_ssh_auth_gui(RemminaSSH *ssh, RemminaProtocolWidget *gp, RemminaFile *re attempt < 2 && ret == REMMINA_SSH_AUTH_AUTHFAILED_RETRY_AFTER_PROMPT; attempt++) { if (ssh->error) - g_debug("[SSH] retrying auth because %s", ssh->error); + remmina_debug("Retrying auth because %s", ssh->error); if (remmina_ssh_auth_type == REMMINA_SSH_AUTH_PKPASSPHRASE) { ret = remmina_protocol_widget_panel_auth(gp, @@ -660,9 +660,9 @@ remmina_ssh_auth_gui(RemminaSSH *ssh, RemminaProtocolWidget *gp, RemminaFile *re g_free(current_pwd); return REMMINA_SSH_AUTH_FATAL_ERROR; } - g_debug("[SSH] %s retrying auth\n", __func__); + remmina_debug("Retrying authentication"); ret = remmina_ssh_auth(ssh, current_pwd, gp, remminafile); - g_debug("[SSH] %s remmina_ssh_auth returned %d at %d attempt\n", __func__, ret, attempt + 2); + remmina_debug("Authentication attempt n° %d returned %d", attempt + 2, ret); } g_free(current_pwd); @@ -670,7 +670,7 @@ remmina_ssh_auth_gui(RemminaSSH *ssh, RemminaProtocolWidget *gp, RemminaFile *re /* After attempting the max number of times, REMMINA_SSH_AUTH_AUTHFAILED_RETRY_AFTER_PROMPT * becomes REMMINA_SSH_AUTH_FATAL_ERROR */ if (ret == REMMINA_SSH_AUTH_AUTHFAILED_RETRY_AFTER_PROMPT) { - g_debug("[SSH] SSH Authentication failed"); + remmina_debug("SSH Authentication failed"); ret = REMMINA_SSH_AUTH_FATAL_ERROR; } @@ -681,7 +681,7 @@ void remmina_ssh_log_callback(ssh_session session, int priority, const char *message, void *userdata) { TRACE_CALL(__func__); - remmina_log_printf("[SSH] %s\n", message); + remmina_debug(message); } gboolean @@ -698,20 +698,23 @@ remmina_ssh_init_session(RemminaSSH *ssh) ssh->callback = g_new0(struct ssh_callbacks_struct, 1); /* Init & startup the SSH session */ - g_debug("[SSH] %s server=%s port=%d is_tunnel=%s tunnel_entrance_host=%s tunnel_entrance_port=%d\n", __func__, - ssh->server, ssh->port, ssh->is_tunnel ? "Yes" : "No", ssh->tunnel_entrance_host, ssh->tunnel_entrance_port); + remmina_debug("server=%s port=%d is_tunnel=%s tunnel_entrance_host=%s tunnel_entrance_port=%d", + ssh->server, + ssh->port, + ssh->is_tunnel ? "Yes" : "No", + ssh->tunnel_entrance_host, ssh->tunnel_entrance_port); ssh->session = ssh_new(); /* Tunnel sanity checks */ if (ssh->is_tunnel && ssh->tunnel_entrance_host != NULL) { ssh->error = g_strdup_printf("Internal error in %s: is_tunnel and tunnel_entrance != NULL", __func__); - g_debug("[SSH] %s", ssh->error); + remmina_debug(ssh->error); return FALSE; } if (!ssh->is_tunnel && ssh->tunnel_entrance_host == NULL) { ssh->error = g_strdup_printf("Internal error in %s: is_tunnel == false and tunnel_entrance == NULL", __func__); - g_debug("[SSH] %s", ssh->error); + remmina_debug(ssh->error); return FALSE; } @@ -722,7 +725,7 @@ remmina_ssh_init_session(RemminaSSH *ssh) } else { ssh_options_set(ssh->session, SSH_OPTIONS_HOST, ssh->tunnel_entrance_host); ssh_options_set(ssh->session, SSH_OPTIONS_PORT, &ssh->tunnel_entrance_port); - g_debug("[SSH] setting SSH_OPTIONS_HOST to %s and SSH_OPTIONS_PORT to %d", ssh->tunnel_entrance_host, ssh->tunnel_entrance_port); + remmina_debug("Setting SSH_OPTIONS_HOST to %s and SSH_OPTIONS_PORT to %d", ssh->tunnel_entrance_host, ssh->tunnel_entrance_port); } if (*ssh->user != 0) @@ -730,9 +733,9 @@ remmina_ssh_init_session(RemminaSSH *ssh) if (ssh->privkeyfile && *ssh->privkeyfile != 0) { rc = ssh_options_set(ssh->session, SSH_OPTIONS_IDENTITY, ssh->privkeyfile); if (rc == 0) - remmina_log_printf("[SSH] SSH_OPTIONS_IDENTITY is now %s\n", ssh->privkeyfile); + remmina_debug("SSH_OPTIONS_IDENTITY is now %s", ssh->privkeyfile); else - remmina_log_printf("[SSH] SSH_OPTIONS_IDENTITY is not set, by default the files \"identity\", \"id_dsa\" and \"id_rsa\" are used.\n"); + remmina_debug("SSH_OPTIONS_IDENTITY is not set, by default the files \"identity\", \"id_dsa\" and \"id_rsa\" are used."); } #ifdef SNAP_BUILD @@ -740,34 +743,34 @@ remmina_ssh_init_session(RemminaSSH *ssh) #endif rc = ssh_options_set(ssh->session, SSH_OPTIONS_KEY_EXCHANGE, ssh->kex_algorithms); if (rc == 0) - remmina_log_printf("[SSH] SSH_OPTIONS_KEY_EXCHANGE is now %s\n", ssh->kex_algorithms); + remmina_debug("SSH_OPTIONS_KEY_EXCHANGE is now %s", ssh->kex_algorithms); else - remmina_log_printf("[SSH] SSH_OPTIONS_KEY_EXCHANGE does not have a valid value. %s\n", ssh->kex_algorithms); + remmina_debug("SSH_OPTIONS_KEY_EXCHANGE does not have a valid value. %s", ssh->kex_algorithms); rc = ssh_options_set(ssh->session, SSH_OPTIONS_CIPHERS_C_S, ssh->ciphers); if (rc == 0) - remmina_log_printf("[SSH] SSH_OPTIONS_CIPHERS_C_S has been set to %s\n", ssh->ciphers); + remmina_debug("SSH_OPTIONS_CIPHERS_C_S has been set to %s", ssh->ciphers); else - remmina_log_printf("[SSH] SSH_OPTIONS_CIPHERS_C_S does not have a valid value. %s\n", ssh->ciphers); + remmina_debug("SSH_OPTIONS_CIPHERS_C_S does not have a valid value. %s", ssh->ciphers); rc = ssh_options_set(ssh->session, SSH_OPTIONS_HOSTKEYS, ssh->hostkeytypes); if (rc == 0) - remmina_log_printf("[SSH] SSH_OPTIONS_HOSTKEYS is now %s\n", ssh->hostkeytypes); + remmina_debug("SSH_OPTIONS_HOSTKEYS is now %s", ssh->hostkeytypes); else - remmina_log_printf("[SSH] SSH_OPTIONS_HOSTKEYS does not have a valid value. %s\n", ssh->hostkeytypes); + remmina_debug("SSH_OPTIONS_HOSTKEYS does not have a valid value. %s", ssh->hostkeytypes); rc = ssh_options_set(ssh->session, SSH_OPTIONS_PROXYCOMMAND, ssh->proxycommand); if (rc == 0) - remmina_log_printf("[SSH] SSH_OPTIONS_PROXYCOMMAND is now %s\n", ssh->proxycommand); + remmina_debug("SSH_OPTIONS_PROXYCOMMAND is now %s", ssh->proxycommand); else - remmina_log_printf("[SSH] SSH_OPTIONS_PROXYCOMMAND does not have a valid value. %s\n", ssh->proxycommand); + remmina_debug("SSH_OPTIONS_PROXYCOMMAND does not have a valid value. %s", ssh->proxycommand); rc = ssh_options_set(ssh->session, SSH_OPTIONS_STRICTHOSTKEYCHECK, &ssh->stricthostkeycheck); if (rc == 0) - remmina_log_printf("[SSH] SSH_OPTIONS_STRICTHOSTKEYCHECK is now %d\n", ssh->stricthostkeycheck); + remmina_debug("SSH_OPTIONS_STRICTHOSTKEYCHECK is now %d", ssh->stricthostkeycheck); else - remmina_log_printf("[SSH] SSH_OPTIONS_STRICTHOSTKEYCHECK does not have a valid value. %d\n", ssh->stricthostkeycheck); + remmina_debug("SSH_OPTIONS_STRICTHOSTKEYCHECK does not have a valid value. %d", ssh->stricthostkeycheck); rc = ssh_options_set(ssh->session, SSH_OPTIONS_COMPRESSION, ssh->compression); if (rc == 0) - remmina_log_printf("[SSH] SSH_OPTIONS_COMPRESSION is now %s\n", ssh->compression); + remmina_debug("SSH_OPTIONS_COMPRESSION is now %s", ssh->compression); else - remmina_log_printf("[SSH] SSH_OPTIONS_COMPRESSION does not have a valid value. %s\n", ssh->compression); + remmina_debug("SSH_OPTIONS_COMPRESSION does not have a valid value. %s", ssh->compression); ssh_callbacks_init(ssh->callback); if (remmina_log_running()) { @@ -797,40 +800,40 @@ remmina_ssh_init_session(RemminaSSH *ssh) if (sshsock >= 0) { optval = 1; if (setsockopt(sshsock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) - remmina_log_printf("[SSH] TCP KeepAlive not set\n"); + remmina_debug("TCP KeepAlive not set"); else - remmina_log_printf("[SSH] TCP KeepAlive enabled\n"); + remmina_debug("TCP KeepAlive enabled"); #ifdef TCP_KEEPIDLE optval = remmina_pref.ssh_tcp_keepidle; if (setsockopt(sshsock, IPPROTO_TCP, TCP_KEEPIDLE, &optval, sizeof(optval)) < 0) - remmina_log_printf("[SSH] TCP_KEEPIDLE not set\n"); + remmina_debug("TCP_KEEPIDLE not set"); else - remmina_log_printf("[SSH] TCP_KEEPIDLE set to %i\n", optval); + remmina_debug("TCP_KEEPIDLE set to %i", optval); #endif #ifdef TCP_KEEPCNT optval = remmina_pref.ssh_tcp_keepcnt; if (setsockopt(sshsock, IPPROTO_TCP, TCP_KEEPCNT, &optval, sizeof(optval)) < 0) - remmina_log_printf("[SSH] TCP_KEEPCNT not set\n"); + remmina_debug("TCP_KEEPCNT not set"); else - remmina_log_printf("[SSH] TCP_KEEPCNT set to %i\n", optval); + remmina_debug("TCP_KEEPCNT set to %i", optval); #endif #ifdef TCP_KEEPINTVL optval = remmina_pref.ssh_tcp_keepintvl; if (setsockopt(sshsock, IPPROTO_TCP, TCP_KEEPINTVL, &optval, sizeof(optval)) < 0) - remmina_log_printf("[SSH] TCP_KEEPINTVL not set\n"); + remmina_debug("TCP_KEEPINTVL not set"); else - remmina_log_printf("[SSH] TCP_KEEPINTVL set to %i\n", optval); + remmina_debug("TCP_KEEPINTVL set to %i", optval); #endif #ifdef TCP_USER_TIMEOUT optval = remmina_pref.ssh_tcp_usrtimeout; if (setsockopt(sshsock, IPPROTO_TCP, TCP_USER_TIMEOUT, &optval, sizeof(optval)) < 0) - remmina_log_printf("[SSH] TCP_USER_TIMEOUT not set\n"); + remmina_debug("TCP_USER_TIMEOUT not set"); else - remmina_log_printf("[SSH] TCP_USER_TIMEOUT set to %i\n", optval); + remmina_debug("TCP_USER_TIMEOUT set to %i", optval); #endif } @@ -891,7 +894,7 @@ remmina_ssh_init_from_file(RemminaSSH *ssh, RemminaFile *remminafile, gboolean i remmina_public_get_server_port(server, 0, &ssh->server, NULL); } - g_debug("[SSH] %s initialized SSH struct from file with ssh->server = %s and SSH->port = %d", __func__, ssh->server, ssh->port); + remmina_debug("Initialized SSH struct from file with ssh->server = %s and SSH->port = %d", ssh->server, ssh->port); ssh->user = g_strdup(username ? username : g_get_user_name()); ssh->password = NULL; @@ -1377,7 +1380,7 @@ remmina_ssh_tunnel_main_thread_proc(gpointer data) diff = g_date_time_difference(t1, t2) * 10000000 + g_date_time_difference(t1, t2) / 100000; if (diff > 1) { - g_debug("[SSH] Polling tunnel channels"); + remmina_debug("Polling tunnel channels"); if (tunnel->tunnel_type == REMMINA_SSH_TUNNEL_X11) channel = ssh_channel_accept_x11(tunnel->x11_channel, 0); else @@ -1459,7 +1462,7 @@ remmina_ssh_tunnel_main_thread_proc(gpointer data) } } if (disconnected) { - remmina_log_printf("[SSH] tunnel disconnected because %s\n", REMMINA_SSH(tunnel)->error); + remmina_debug("tunnel disconnected because %s", REMMINA_SSH(tunnel)->error); remmina_ssh_tunnel_remove_channel(tunnel, i); continue; } @@ -1512,7 +1515,7 @@ remmina_ssh_tunnel_main_thread_proc(gpointer data) } if (disconnected) { - remmina_log_printf("Connection to SSH tunnel dropped. %s\n", REMMINA_SSH(tunnel)->error); + remmina_debug("Connection to SSH tunnel dropped. %s", REMMINA_SSH(tunnel)->error); remmina_ssh_tunnel_remove_channel(tunnel, i); continue; } @@ -1526,7 +1529,7 @@ remmina_ssh_tunnel_main_thread_proc(gpointer data) if (sock > 0) { channel = remmina_ssh_tunnel_create_forward_channel(tunnel); if (!channel) { - remmina_log_printf("Could not open new SSH connection. %s\n", REMMINA_SSH(tunnel)->error); + remmina_debug("Could not open new SSH connection. %s", REMMINA_SSH(tunnel)->error); close(sock); /* Leave thread loop */ tunnel->running = FALSE; @@ -1707,7 +1710,7 @@ remmina_ssh_tunnel_free(RemminaSSHTunnel *tunnel) TRACE_CALL(__func__); pthread_t thread; - g_debug("[SSH] %s tunnel->thread = %lX\n", __func__, tunnel->thread); + remmina_debug("tunnel->thread = %lX\n", tunnel->thread); thread = tunnel->thread; if (thread != 0) { diff --git a/src/remmina_ssh_plugin.c b/src/remmina_ssh_plugin.c index fb97afbbf..bf5d42f60 100644 --- a/src/remmina_ssh_plugin.c +++ b/src/remmina_ssh_plugin.c @@ -46,6 +46,7 @@ #include <vte/vte.h> #include <locale.h> #include <langinfo.h> +#include "remmina_log.h" #include "remmina_public.h" #include "remmina_plugin_manager.h" #include "remmina_ssh.h" @@ -263,7 +264,7 @@ remmina_plugin_ssh_main_thread(gpointer data) while (1) { if (!remmina_ssh_init_session(ssh)) { - g_debug("[SSH] init session error: %s\n", ssh->error); + remmina_debug("init session error: %s", ssh->error); remmina_plugin_service->protocol_plugin_set_error(gp, "%s", ssh->error); break; } diff --git a/src/remmina_stats.c b/src/remmina_stats.c index 4e18707c6..f583f7559 100644 --- a/src/remmina_stats.c +++ b/src/remmina_stats.c @@ -466,9 +466,9 @@ JsonNode *remmina_stats_get_wm_name() /** We try to get the Gnome SHELL version */ wmver = remmina_sysinfo_get_gnome_shell_version(); if (!wmver || wmver[0] == '\0') { - remmina_log_print("Gnome Shell not found\n"); + remmina_debug("Gnome Shell not found"); }else { - remmina_log_printf("Gnome Shell version: %s\n", wmver); + remmina_debug("Gnome Shell version: %s\n", wmver); json_builder_add_string_value(b, "Gnome Shell"); json_builder_set_member_name(b, "gnome_shell_ver"); json_builder_add_string_value(b, wmver); @@ -479,10 +479,10 @@ JsonNode *remmina_stats_get_wm_name() wmname = remmina_sysinfo_get_wm_name(); if (!wmname || wmname[0] == '\0') { /** When everything else fails with set the WM name to NULL **/ - remmina_log_print("Cannot determine the Window Manger name\n"); + remmina_debug("Cannot determine the Window Manger name"); json_builder_add_string_value(b, "n/a"); }else { - remmina_log_printf("Window Manger names %s\n", wmname); + remmina_debug("Window Manger names %s", wmname); json_builder_add_string_value(b, wmname); } g_free(wmname); diff --git a/src/remmina_stats_sender.c b/src/remmina_stats_sender.c index e5cd509b0..3a6f38241 100644 --- a/src/remmina_stats_sender.c +++ b/src/remmina_stats_sender.c @@ -88,15 +88,15 @@ static void soup_callback(SoupSession *session, SoupMessage *msg, gpointer user_ g_free(s); if (msg->status_code != 200) { - remmina_log_printf("HTTP status error sending stats: %d\n",msg->status_code); + remmina_debug("HTTP status error sending stats: %d\n", msg->status_code); return; } passed = FALSE; sb = soup_message_body_flatten(msg->response_body); - remmina_log_printf("STATS script response: %.40s\n", sb->data); + remmina_debug("STATS script response: %.40s\n", sb->data); if (strncmp(sb->data, "200 ", 4) != 0) { - remmina_log_printf("STATS http upload error from server side script: %s\n", sb->data); + remmina_debug("STATS http upload error from server side script: %s\n", sb->data); } else { passed = TRUE; } @@ -195,8 +195,7 @@ static gboolean remmina_stats_collector_done(gpointer data) json_generator_set_root(g, n); json_node_unref(n); unenc_s = json_generator_to_data(g, NULL); // unenc_s=serialized stats - remmina_log_printf("STATS upload: JSON data%s\n", unenc_s); - g_debug("STATS upload: JSON data%s\n", unenc_s); + remmina_debug("STATS upload: JSON data%s\n", unenc_s); g_object_unref(g); /* Now encrypt "s" with remminastats public key */ @@ -253,7 +252,7 @@ static gboolean remmina_stats_collector_done(gpointer data) SOUP_MEMORY_COPY, enc_s, strlen(enc_s)); soup_session_queue_message(ss, msg, soup_callback, enc_s); - remmina_log_printf("STATS upload: Starting upload to url %s\n", PERIODIC_UPLOAD_URL); + remmina_debug("STATS upload: Starting upload to url %s\n", PERIODIC_UPLOAD_URL); } json_node_unref(n); |