static void exec_autoforward_onoff_cb(void) { if (g_enable != TRUE){ syl_plugin_alertpanel_message(_("Autoforward"), _("autoforward plugin is enabled."), ALERT_NOTICE); g_enable=TRUE; gtk_widget_hide(g_plugin_off); gtk_widget_show(g_plugin_on); gtk_tooltips_set_tip (g_tooltip, g_onoff_switch, _("Autoforward is enabled. Click the icon to disable plugin."), NULL); }else{ syl_plugin_alertpanel_message(_("Autoforward"), _("autoforward plugin is disabled."), ALERT_NOTICE); g_enable=FALSE; gtk_widget_hide(g_plugin_on); gtk_widget_show(g_plugin_off); gtk_tooltips_set_tip (g_tooltip, g_onoff_switch, _("Autoforward is disabled. Click the icon to enable plugin."), NULL); } }
static void send_with_encryption(gpointer compose) { GSList *alist, *cur; GHashTable *hash; SylPluginAttachInfo *ainfo; gboolean duplicated = FALSE; GtkWidget *dialog; gchar *password; const gchar *tmp_path; const gchar *arc_path; gchar *zip_path; gchar *filename; GString *cmdline; gint ret; gchar *orig_to; gchar *orig_cc; gchar *orig_bcc; gchar *orig_replyto; gchar *orig_subject; gchar *subject; gchar *body; gchar send_date[80]; /* Check attachments */ alist = syl_plugin_get_attach_list(compose); if (!alist) { syl_plugin_alertpanel_message(_("No attachment"), _("There is no attachment. Please attach files before sending."), 3); return; } hash = g_hash_table_new(str_case_hash, str_case_equal); for (cur = alist; cur != NULL; cur = cur->next) { const gchar *base; ainfo = (SylPluginAttachInfo *)cur->data; debug_print("attach: file: %s (%s) name: %s\n", ainfo->file, ainfo->content_type, ainfo->name); base = g_basename(ainfo->file); if (g_hash_table_lookup(hash, base)) { duplicated = TRUE; break; } else { g_hash_table_insert(hash, (gpointer)base, (gpointer)base); } } g_hash_table_destroy(hash); if (duplicated) { syl_plugin_alertpanel_message(_("Duplicate filename"), _("There are duplicate filenames. Multiple files with same name cannot be attached."), 3); return; } /* Get recipients */ orig_to = syl_plugin_compose_entry_get_text(compose, 0); orig_cc = syl_plugin_compose_entry_get_text(compose, 1); orig_bcc = syl_plugin_compose_entry_get_text(compose, 2); orig_replyto = syl_plugin_compose_entry_get_text(compose, 3); orig_subject = syl_plugin_compose_entry_get_text(compose, 4); if (orig_to) g_strstrip(orig_to); if (orig_cc) g_strstrip(orig_cc); if (orig_bcc) g_strstrip(orig_bcc); if ((!orig_to || *orig_to == '\0') && (!orig_cc || *orig_cc == '\0') && (!orig_bcc || *orig_bcc == '\0')) { syl_plugin_alertpanel_message(_("No recipients"), _("Recipient is not specified."), 3); g_free(orig_subject); g_free(orig_replyto); g_free(orig_bcc); g_free(orig_cc); g_free(orig_to); return; } /* Show processing dialog */ dialog = autoenc_processing_dialog_create(); /* Generate password */ password = generate_password(); /* Generate encrypted zip */ filename = generate_filename(); tmp_path = get_autoenc_tmp_dir(); if (!is_dir_exist(tmp_path)) { make_dir(tmp_path); } arc_path = get_7z_path(); zip_path = g_strconcat(tmp_path, G_DIR_SEPARATOR_S, filename, NULL); cmdline = g_string_new(""); if (arc_path) { g_string_append_printf(cmdline, "\"%s\\7z\" a -y ", arc_path); } else { g_string_append(cmdline, "7z a -y "); } g_string_append(cmdline, "-p"); g_string_append(cmdline, password); g_string_append(cmdline, " "); g_string_append_printf(cmdline, "\"%s\"", zip_path); for (cur = alist; cur != NULL; cur = cur->next) { ainfo = (SylPluginAttachInfo *)cur->data; g_string_append(cmdline, " "); g_string_append_printf(cmdline, "\"%s\"", ainfo->file); } debug_print("cmdline: %s\n", cmdline->str); ret = execute_command_line_async_wait(cmdline->str); /* Close processing dialog */ gtk_widget_destroy(dialog); // check if zip was really created if (ret != 0 || !is_file_exist(zip_path) || get_file_size(zip_path) <= 0) { gchar message[256]; if (ret < 0) { g_snprintf(message, sizeof(message), _("Error occurred while creating encrypted zip file.\n\n7z command could not be executed. Please check if 7-Zip is correctly installed.")); } else if (ret > 0) { g_snprintf(message, sizeof(message), _("Error occurred while creating encrypted zip file.\n\n7z command returned error (%d)"), ret); } else { g_snprintf(message, sizeof(message), _("Encrypted zip file could not be created.")); } syl_plugin_alertpanel_message(_("Encrypted zip file creation error"), message, 3); g_string_free(cmdline, TRUE); g_free(zip_path); g_free(filename); g_free(password); g_free(orig_subject); g_free(orig_replyto); g_free(orig_bcc); g_free(orig_cc); g_free(orig_to); g_slist_free(alist); return; } g_string_free(cmdline, TRUE); g_slist_free(alist); /* Replace attachments */ syl_plugin_compose_attach_remove_all(compose); syl_plugin_compose_attach_append(compose, zip_path, filename, "application/zip"); /* Send */ get_rfc822_date(send_date, sizeof(send_date)); ret = syl_plugin_compose_send(compose, TRUE); if (ret != 0) { g_free(zip_path); g_free(filename); g_free(password); g_free(orig_subject); g_free(orig_replyto); g_free(orig_bcc); g_free(orig_cc); g_free(orig_to); return; } /* Create password mail */ subject = create_password_mail_subject(orig_subject, send_date, filename, password); body = create_password_mail_body(orig_subject, send_date, filename, password); debug_print("%s\n", body); compose = syl_plugin_compose_new(NULL, NULL, body, NULL); syl_plugin_compose_entry_set(compose, orig_to, 0); syl_plugin_compose_entry_set(compose, orig_cc, 1); if (orig_bcc && *orig_bcc != '\0') syl_plugin_compose_entry_set(compose, orig_bcc, 2); if (orig_replyto && *orig_replyto != '\0') syl_plugin_compose_entry_set(compose, orig_replyto, 3); syl_plugin_compose_entry_set(compose, subject, 4); /* Cleanup */ g_free(body); g_free(subject); g_free(zip_path); g_free(filename); g_free(password); g_free(orig_subject); g_free(orig_replyto); g_free(orig_bcc); g_free(orig_cc); g_free(orig_to); }