static void ok_button_clicked(GtkButton *button, gpointer user_data) { struct _ctx *ctx = (struct _ctx *)user_data; const gchar *old = NULL; const gchar *new1 = gtk_entry_get_text(GTK_ENTRY(ctx->entry_new1)); const gchar *new2 = gtk_entry_get_text(GTK_ENTRY(ctx->entry_new2)); debug_print("OK button activated\n"); /* Now we check the new passphrase - same in both entries. */ if (strcmp(new1, new2)) { debug_print("passphrases do not match\n"); alertpanel_warning(_("New passphrases do not match, try again.")); gtk_entry_set_text(GTK_ENTRY(ctx->entry_new1), ""); gtk_entry_set_text(GTK_ENTRY(ctx->entry_new2), ""); gtk_widget_grab_focus(ctx->entry_new1); return; } /* If there is an existing master passphrase, check for its correctness * in entry_old. */ if (master_passphrase_is_set() && ((old = gtk_entry_get_text(GTK_ENTRY(ctx->entry_old))) == NULL || strlen(old) == 0 || !master_passphrase_is_correct(old))) { debug_print("old passphrase incorrect\n"); alertpanel_warning(_("Incorrect old master passphrase entered, try again.")); gtk_entry_set_text(GTK_ENTRY(ctx->entry_old), ""); gtk_widget_grab_focus(ctx->entry_old); return; } master_passphrase_change(old, new1); ctx->done = TRUE; gtk_widget_destroy(ctx->dialog); ctx->dialog = NULL; }
static void cache_clean_button_clicked_cb(GtkButton *button, gpointer data) { GtkLabel *label = (GtkLabel *) data; gint val = 0; AvatarCleanupResult *acr; guint misses; val = alertpanel_full(_("Clear icon cache"), _("Are you sure you want to remove all cached avatar icons?"), GTK_STOCK_NO, GTK_STOCK_YES, NULL, FALSE, NULL, ALERT_WARNING, G_ALERTDEFAULT); if (val != G_ALERTALTERNATE) return; debug_print("cleaning missing cache"); misses = g_hash_table_size(libravatarmisses); g_hash_table_remove_all(libravatarmisses); debug_print("cleaning disk cache"); acr = libravatar_cache_clean(); if (acr == NULL) { alertpanel_error(_("Not enough memory for operation")); return; } if (acr->e_stat == 0 && acr->e_unlink == 0) { alertpanel_notice(_("Icon cache successfully cleared:\n" "• %u missing entries removed.\n" "• %u files removed."), misses, acr->removed); gtk_label_set_markup(label, _("<span color=\"#006400\">Icon cache succesfully cleared!</span>")); } else { alertpanel_warning(_("Errors clearing icon cache:\n" "• %u missing entries removed.\n" "• %u files removed.\n" "• %u files failed to be read.\n" "• %u files couldn't be removed."), misses, acr->removed, acr->e_stat, acr->e_unlink); gtk_label_set_markup(label, _("<span color=\"red\">Error clearing icon cache.</span>")); } gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); g_free(acr); }
gint plugin_init(gchar **error) { gchar *rcpath; if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72), VERSION_NUMERIC, PLUGIN_NAME, error)) return -1; hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL); if (hook_id == -1) { *error = g_strdup(_("Failed to register mail filtering hook")); return -1; } prefs_set_default(param); rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL); prefs_read_config(param, "ClamAV", rcpath, NULL); g_free(rcpath); clamav_gtk_init(); if (config.clamav_enable) { debug_print("Creating socket\n"); config.alert_ack = TRUE; Clamd_Stat status = clamd_prepare(); switch (status) { case NO_SOCKET: g_warning("[init] No socket information"); alertpanel_error(_("Init\nNo socket information.\nAntivirus disabled.")); break; case NO_CONNECTION: g_warning("[init] Clamd does not respond to ping"); alertpanel_warning(_("Init\nClamd does not respond to ping.\nIs clamd running?")); break; default: break; } } debug_print("Clamd plugin loaded\n"); return 0; }
static gboolean scan_func(GNode *node, gpointer data) { struct clamd_result *result = (struct clamd_result *) data; MimeInfo *mimeinfo = (MimeInfo *) node->data; gchar *outfile; response buf; int max; GStatBuf info; gchar* msg; outfile = procmime_get_tmp_file_name(mimeinfo); if (procmime_get_part(outfile, mimeinfo) < 0) g_warning("Can't get the part of multipart message."); else { max = config.clamav_max_size * 1048576; /* maximum file size */ if (g_stat(outfile, &info) == -1) g_warning("Can't determine file size"); else { if (info.st_size <= max) { debug_print("Scanning %s\n", outfile); result->status = clamd_verify_email(outfile, &buf); debug_print("status: %d\n", result->status); switch (result->status) { case NO_SOCKET: g_warning("[scanning] No socket information"); if (config.alert_ack) { alertpanel_error(_("Scanning\nNo socket information.\nAntivirus disabled.")); config.alert_ack = FALSE; } break; case NO_CONNECTION: g_warning("[scanning] Clamd does not respond to ping"); if (config.alert_ack) { alertpanel_warning(_("Scanning\nClamd does not respond to ping.\nIs clamd running?")); config.alert_ack = FALSE; } break; case VIRUS: msg = g_strconcat(_("Detected %s virus."), clamd_get_virus_name(buf.msg), NULL); g_warning("%s\n", msg); debug_print("no_recv: %d\n", prefs_common_get_prefs()->no_recv_err_panel); if (prefs_common_get_prefs()->no_recv_err_panel) { statusbar_print_all("%s", msg); } else { alertpanel_warning("%s\n", msg); } g_free(msg); config.alert_ack = TRUE; break; case SCAN_ERROR: debug_print("Error: %s\n", buf.msg); if (config.alert_ack) { alertpanel_error(_("Scanning error:\n%s"), buf.msg); config.alert_ack = FALSE; } break; case OK: debug_print("No virus detected.\n"); config.alert_ack = TRUE; break; } } else { msg = g_strdup_printf(_("File: %s. Size (%d) greater than limit (%d)\n"), outfile, (int) info.st_size, max); statusbar_print_all("%s", msg); debug_print("%s", msg); g_free(msg); } } g_unlink(outfile); } return (result->status == OK) ? FALSE : TRUE; }