static void mimeview_show_mime_part(MimeView *mimeview, MimeInfo *partinfo) { TextView *textview = mimeview->textview; GtkTextBuffer *buffer; GtkTextIter iter; GtkTextChildAnchor *anchor; GtkWidget *vbbox; GtkWidget *button; gchar buf[BUFFSIZE]; if (!partinfo) return; textview_set_font(textview, NULL); textview_clear(textview); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview->text)); gtk_text_buffer_get_start_iter(buffer, &iter); gtk_text_buffer_insert(buffer, &iter, _("Select an action for the attached file:\n"), -1); if (partinfo->filename || partinfo->name) g_snprintf(buf, sizeof(buf), "[%s %s (%s)]\n\n", partinfo->filename ? partinfo->filename : partinfo->name, partinfo->content_type, to_human_readable(partinfo->content_size)); else g_snprintf(buf, sizeof(buf), "[%s (%s)]\n\n", partinfo->content_type, to_human_readable(partinfo->content_size)); gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, buf, -1, "mimepart", NULL); vbbox = gtk_vbutton_box_new(); gtk_box_set_spacing(GTK_BOX(vbbox), 5); button = gtk_button_new_from_stock(GTK_STOCK_OPEN); gtk_container_add(GTK_CONTAINER(vbbox), button); g_signal_connect(button, "clicked", G_CALLBACK(open_button_clicked), mimeview); button = gtk_button_new_with_mnemonic(_("Open _with...")); gtk_container_add(GTK_CONTAINER(vbbox), button); g_signal_connect(button, "clicked", G_CALLBACK(open_with_button_clicked), mimeview); button = gtk_button_new_with_mnemonic(_("_Display as text")); gtk_container_add(GTK_CONTAINER(vbbox), button); g_signal_connect(button, "clicked", G_CALLBACK(display_as_text_button_clicked), mimeview); button = gtk_button_new_with_mnemonic(_("_Save as...")); gtk_container_add(GTK_CONTAINER(vbbox), button); g_signal_connect(button, "clicked", G_CALLBACK(save_as_button_clicked), mimeview); gtk_widget_show_all(vbbox); anchor = gtk_text_buffer_create_child_anchor(buffer, &iter); gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(textview->text), vbbox, anchor); }
static GtkCTreeNode *mimeview_append_part(MimeView *mimeview, MimeInfo *partinfo, GtkCTreeNode *parent) { GtkCTree *ctree = GTK_CTREE(mimeview->ctree); GtkCTreeNode *node; static gchar content_type[64]; gchar *str[N_MIMEVIEW_COLS]; if (partinfo->type != MIMETYPE_UNKNOWN && partinfo->subtype) { g_snprintf(content_type, 64, "%s/%s", procmime_get_media_type_str(partinfo->type), partinfo->subtype); } else { g_snprintf(content_type, 64, "UNKNOWN"); } str[COL_MIMETYPE] = content_type; str[COL_SIZE] = to_human_readable(partinfo->length); if (prefs_common.attach_desc) str[COL_NAME] = (gchar *) get_part_description(partinfo); else str[COL_NAME] = (gchar *) get_part_name(partinfo); node = gtk_ctree_insert_node(ctree, parent, NULL, str, 0, NULL, NULL, NULL, NULL, FALSE, TRUE); gtk_ctree_node_set_row_data(ctree, node, partinfo); return node; }
static gchar *prefs_themes_get_theme_stats(const gchar *dirname) { gchar *stats; DirInfo *dinfo; dinfo = g_new0(DirInfo, 1); prefs_themes_foreach_file(dirname, prefs_themes_file_stats, dinfo); stats = g_strdup_printf(_("%d files (%d icons), size: %s"), dinfo->files, dinfo->pixms, to_human_readable((goffset)dinfo->bytes)); g_free(dinfo); return stats; }
static gchar *avatar_stats_label_markup(AvatarCacheStats *stats) { if (stats == NULL) return g_strdup( _("<span color=\"red\">Error reading cache stats</span>")); if (stats->errors > 0) return g_markup_printf_escaped( _("<span color=\"red\">Using %s in %d files, %d " "directories, %d others and %d errors</span>"), to_human_readable((goffset) stats->bytes), stats->files, stats->dirs, stats->others, stats->errors); return g_strdup_printf( _("Using %s in %d files, %d directories and %d others"), to_human_readable((goffset) stats->bytes), stats->files, stats->dirs, stats->others); }
static gboolean grouplist_recv_func(SockInfo *sock, gint count, gint read_bytes, gpointer data) { gchar buf[BUFFSIZE]; g_snprintf(buf, sizeof(buf), _("%d newsgroups received (%s read)"), count, to_human_readable((goffset)read_bytes)); gtk_label_set_text(GTK_LABEL(status_label), buf); GTK_EVENTS_FLUSH(); if (ack == FALSE) return FALSE; else return TRUE; }
static void inc_progress_dialog_set_progress(IncProgressDialog *inc_dialog, IncSession *inc_session) { gchar buf[MESSAGEBUFSIZE]; Pop3Session *pop3_session = POP3_SESSION(inc_session->session); gchar *total_size_str; gint cur_total; gint total; if (!pop3_session->new_msg_exist) return; cur_total = inc_session->cur_total_bytes; total = pop3_session->total_bytes; if (pop3_session->state == POP3_RETR || pop3_session->state == POP3_RETR_RECV || pop3_session->state == POP3_DELETE) { Xstrdup_a(total_size_str, to_human_readable((goffset)total), return); g_snprintf(buf, sizeof(buf), _("Retrieving message (%d / %d) (%s / %s)"), pop3_session->cur_msg, pop3_session->count, to_human_readable((goffset)cur_total), total_size_str); progress_dialog_set_label(inc_dialog->dialog, buf); }
static gboolean mimeview_append_part(MimeView *mimeview, MimeInfo *partinfo, GtkTreeIter *iter, GtkTreeIter *parent) { gchar *mime_type; gchar *size; gchar *name; mime_type = partinfo->content_type ? partinfo->content_type : ""; size = to_human_readable(partinfo->content_size); name = get_part_name(partinfo); if (name && *name != '\0') mimeview->has_attach_file = TRUE; gtk_tree_store_append(mimeview->store, iter, parent); gtk_tree_store_set(mimeview->store, iter, COL_MIMETYPE, mime_type, COL_SIZE, size, COL_NAME, name, COL_MIME_INFO, partinfo, -1); return TRUE; }
static gint smtp_session_recv_msg(Session *session, const gchar *msg) { SMTPSession *smtp_session = SMTP_SESSION(session); gboolean cont = FALSE; if (strlen(msg) < 4) { log_warning(_("bad SMTP response\n")); return -1; } switch (smtp_session->state) { case SMTP_EHLO: case SMTP_STARTTLS: case SMTP_AUTH: case SMTP_AUTH_PLAIN: case SMTP_AUTH_LOGIN_USER: case SMTP_AUTH_LOGIN_PASS: case SMTP_AUTH_CRAM_MD5: log_print("ESMTP< %s\n", msg); break; default: log_print("SMTP< %s\n", msg); break; } if (msg[0] == '5' && msg[1] == '0' && (msg[2] == '4' || msg[2] == '3' || msg[2] == '1')) { log_warning(_("error occurred on SMTP session\n")); smtp_session->state = SMTP_ERROR; smtp_session->error_val = SM_ERROR; g_free(smtp_session->error_msg); smtp_session->error_msg = g_strdup(msg); return -1; } if (!strncmp(msg, "535", 3)) { log_warning(_("error occurred on authentication\n")); smtp_session->state = SMTP_ERROR; smtp_session->error_val = SM_AUTHFAIL; g_free(smtp_session->error_msg); smtp_session->error_msg = g_strdup(msg); return -1; } if (msg[0] != '1' && msg[0] != '2' && msg[0] != '3') { log_warning(_("error occurred on SMTP session\n")); smtp_session->state = SMTP_ERROR; smtp_session->error_val = SM_ERROR; g_free(smtp_session->error_msg); smtp_session->error_msg = g_strdup(msg); return -1; } if (msg[3] == '-') cont = TRUE; else if (msg[3] != ' ' && msg[3] != '\0') { log_warning(_("bad SMTP response\n")); smtp_session->state = SMTP_ERROR; smtp_session->error_val = SM_UNRECOVERABLE; return -1; } /* ignore all multiline responses except for EHLO */ if (cont && smtp_session->state != SMTP_EHLO) return session_recv_msg(session); switch (smtp_session->state) { case SMTP_READY: if (strstr(msg, "ESMTP")) smtp_session->is_esmtp = TRUE; case SMTP_CONNECTED: #if USE_OPENSSL if (smtp_session->user || session->ssl_type != SSL_NONE || smtp_session->is_esmtp) #else if (smtp_session->user || smtp_session->is_esmtp) #endif smtp_ehlo(smtp_session); else smtp_helo(smtp_session); break; case SMTP_HELO: smtp_from(smtp_session); break; case SMTP_EHLO: smtp_ehlo_recv(smtp_session, msg); if (cont == TRUE) break; if (smtp_session->max_message_size > 0 && smtp_session->max_message_size < smtp_session->send_data_len) { log_warning(_("Message is too big " "(Maximum size is %s)\n"), to_human_readable( (off_t)(smtp_session->max_message_size))); smtp_session->state = SMTP_ERROR; smtp_session->error_val = SM_ERROR; return -1; } #if USE_OPENSSL if (session->ssl_type == SSL_STARTTLS && smtp_session->tls_init_done == FALSE) { smtp_starttls(smtp_session); break; } #endif if (smtp_session->user) { if (smtp_auth(smtp_session) != SM_OK) smtp_from(smtp_session); } else smtp_from(smtp_session); break; case SMTP_STARTTLS: #if USE_OPENSSL if (session_start_tls(session) < 0) { log_warning(_("can't start TLS session\n")); smtp_session->state = SMTP_ERROR; smtp_session->error_val = SM_ERROR; return -1; } smtp_session->tls_init_done = TRUE; smtp_ehlo(smtp_session); #endif break; case SMTP_AUTH: smtp_auth_recv(smtp_session, msg); break; case SMTP_AUTH_LOGIN_USER: smtp_auth_login_user_recv(smtp_session, msg); break; case SMTP_AUTH_PLAIN: case SMTP_AUTH_LOGIN_PASS: case SMTP_AUTH_CRAM_MD5: smtp_from(smtp_session); break; case SMTP_FROM: if (smtp_session->cur_to) smtp_rcpt(smtp_session); break; case SMTP_RCPT: if (smtp_session->cur_to) smtp_rcpt(smtp_session); else smtp_data(smtp_session); break; case SMTP_DATA: smtp_send_data(smtp_session); break; case SMTP_EOM: smtp_quit(smtp_session); break; case SMTP_QUIT: session_disconnect(session); break; case SMTP_ERROR: default: log_warning(_("error occurred on SMTP session\n")); smtp_session->error_val = SM_ERROR; return -1; } if (cont) return session_recv_msg(session); return 0; }
static gint inc_start(IncProgressDialog *inc_dialog) { IncSession *session; GList *qlist; Pop3Session *pop3_session; IncState inc_state; gint error_num = 0; gint new_msgs = 0; gchar *msg; gchar *fin_msg; FolderItem *processing, *inbox; GSList *msglist, *msglist_element; gboolean cancelled = FALSE; qlist = inc_dialog->queue_list; while (qlist != NULL) { GList *next = qlist->next; session = qlist->data; pop3_session = POP3_SESSION(session->session); pop3_session->user = g_strdup(pop3_session->ac_prefs->userid); if (pop3_session->ac_prefs->passwd) pop3_session->pass = g_strdup(pop3_session->ac_prefs->passwd); else { gchar *pass; if (inc_dialog->show_dialog) manage_window_focus_in (inc_dialog->dialog->window, NULL, NULL); pass = input_dialog_query_password_keep (pop3_session->ac_prefs->recv_server, pop3_session->user, &(pop3_session->ac_prefs->session_passwd)); if (inc_dialog->show_dialog) manage_window_focus_out (inc_dialog->dialog->window, NULL, NULL); if (pass) { pop3_session->pass = pass; } } qlist = next; } #define SET_PIXMAP_AND_TEXT(pix, str) \ { \ progress_dialog_list_set(inc_dialog->dialog, \ inc_dialog->cur_row, \ pix, \ NULL, \ str); \ } for (; inc_dialog->queue_list != NULL && !cancelled; inc_dialog->cur_row++) { session = inc_dialog->queue_list->data; pop3_session = POP3_SESSION(session->session); GSList *filtered, *unfiltered; if (pop3_session->pass == NULL) { SET_PIXMAP_AND_TEXT(okpix, _("Cancelled")); inc_session_destroy(session); inc_dialog->queue_list = g_list_remove(inc_dialog->queue_list, session); continue; } inc_progress_dialog_clear(inc_dialog); progress_dialog_scroll_to_row(inc_dialog->dialog, inc_dialog->cur_row); SET_PIXMAP_AND_TEXT(currentpix, _("Retrieving")); /* begin POP3 session */ inc_state = inc_pop3_session_do(session); switch (inc_state) { case INC_SUCCESS: if (pop3_session->cur_total_num > 0) msg = g_strdup_printf( ngettext("Done (%d message (%s) received)", "Done (%d messages (%s) received)", pop3_session->cur_total_num), pop3_session->cur_total_num, to_human_readable((goffset)pop3_session->cur_total_recv_bytes)); else msg = g_strdup_printf(_("Done (no new messages)")); SET_PIXMAP_AND_TEXT(okpix, msg); g_free(msg); break; case INC_CONNECT_ERROR: SET_PIXMAP_AND_TEXT(errorpix, _("Connection failed")); break; case INC_AUTH_FAILED: SET_PIXMAP_AND_TEXT(errorpix, _("Auth failed")); if (pop3_session->ac_prefs->session_passwd) { g_free(pop3_session->ac_prefs->session_passwd); pop3_session->ac_prefs->session_passwd = NULL; } break; case INC_LOCKED: SET_PIXMAP_AND_TEXT(errorpix, _("Locked")); break; case INC_ERROR: case INC_NO_SPACE: case INC_IO_ERROR: case INC_SOCKET_ERROR: case INC_EOF: SET_PIXMAP_AND_TEXT(errorpix, _("Error")); break; case INC_TIMEOUT: SET_PIXMAP_AND_TEXT(errorpix, _("Timeout")); break; case INC_CANCEL: SET_PIXMAP_AND_TEXT(okpix, _("Cancelled")); if (!inc_dialog->show_dialog) cancelled = TRUE; break; default: break; } if (pop3_session->error_val == PS_AUTHFAIL) { if(!prefs_common.no_recv_err_panel) { if((prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS) || ((prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL) && focus_window)) manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL); } } /* CLAWS: perform filtering actions on dropped message */ /* CLAWS: get default inbox (perhaps per account) */ if (pop3_session->ac_prefs->inbox) { /* CLAWS: get destination folder / mailbox */ inbox = folder_find_item_from_identifier(pop3_session->ac_prefs->inbox); if (!inbox) inbox = folder_get_default_inbox(); } else inbox = folder_get_default_inbox(); /* get list of messages in processing */ processing = folder_get_default_processing(); folder_item_scan(processing); msglist = folder_item_get_msg_list(processing); /* process messages */ folder_item_update_freeze(); procmsg_msglist_filter(msglist, pop3_session->ac_prefs, &filtered, &unfiltered, pop3_session->ac_prefs->filter_on_recv); filtering_move_and_copy_msgs(msglist); if (unfiltered != NULL) folder_item_move_msgs(inbox, unfiltered); for(msglist_element = msglist; msglist_element != NULL; msglist_element = msglist_element->next) { MsgInfo *msginfo = (MsgInfo *)msglist_element->data; procmsg_msginfo_free(msginfo); } folder_item_update_thaw(); g_slist_free(msglist); g_slist_free(filtered); g_slist_free(unfiltered); statusbar_pop_all(); new_msgs += pop3_session->cur_total_num; pop3_write_uidl_list(pop3_session); if (inc_state != INC_SUCCESS && inc_state != INC_CANCEL) { error_num++; if (inc_dialog->show_dialog) manage_window_focus_in (inc_dialog->dialog->window, NULL, NULL); inc_put_error(inc_state, pop3_session); if (inc_dialog->show_dialog) manage_window_focus_out (inc_dialog->dialog->window, NULL, NULL); if (inc_state == INC_NO_SPACE || inc_state == INC_IO_ERROR) break; } folder_item_free_cache(processing, TRUE); inc_session_destroy(session); inc_dialog->queue_list = g_list_remove(inc_dialog->queue_list, session); } #undef SET_PIXMAP_AND_TEXT if (new_msgs > 0) fin_msg = g_strdup_printf(ngettext("Finished (%d new message)", "Finished (%d new messages)", new_msgs), new_msgs); else fin_msg = g_strdup_printf(_("Finished (no new messages)")); progress_dialog_set_label(inc_dialog->dialog, fin_msg); while (inc_dialog->queue_list != NULL) { session = inc_dialog->queue_list->data; inc_session_destroy(session); inc_dialog->queue_list = g_list_remove(inc_dialog->queue_list, session); } if (prefs_common.close_recv_dialog || !inc_dialog->show_dialog) inc_progress_dialog_destroy(inc_dialog); else { gtk_window_set_title(GTK_WINDOW(inc_dialog->dialog->window), fin_msg); gtk_button_set_label(GTK_BUTTON(inc_dialog->dialog->cancel_btn), GTK_STOCK_CLOSE); } g_free(fin_msg); return new_msgs; }
static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo) { GtkWidget *pixmap; GtkWidget *vbox; GtkWidget *button; gchar *tip; gchar *tiptmp; const gchar *desc = NULL; gchar *sigshort = NULL; gchar *content_type; StockPixmap stockp; MimeInfo *partinfo; MimeInfo *siginfo = NULL; MimeInfo *encrypted = NULL; vbox = mimeview->icon_vbox; mimeview->icon_count++; button = gtk_toggle_button_new(); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_object_set_data(GTK_OBJECT(button), "icon_number", GINT_TO_POINTER(mimeview->icon_count)); gtk_object_set_data(GTK_OBJECT(button), "partinfo", mimeinfo); switch (mimeinfo->type) { case MIMETYPE_TEXT: if (mimeinfo->subtype && !g_strcasecmp(mimeinfo->subtype, "html")) stockp = STOCK_PIXMAP_MIME_TEXT_HTML; else if (mimeinfo->subtype && !g_strcasecmp(mimeinfo->subtype, "enriched")) stockp = STOCK_PIXMAP_MIME_TEXT_ENRICHED; else stockp = STOCK_PIXMAP_MIME_TEXT_PLAIN; break; case MIMETYPE_MESSAGE: stockp = STOCK_PIXMAP_MIME_MESSAGE; break; case MIMETYPE_APPLICATION: stockp = STOCK_PIXMAP_MIME_APPLICATION; break; case MIMETYPE_IMAGE: stockp = STOCK_PIXMAP_MIME_IMAGE; break; case MIMETYPE_AUDIO: stockp = STOCK_PIXMAP_MIME_AUDIO; break; default: stockp = STOCK_PIXMAP_MIME_UNKNOWN; break; } partinfo = mimeinfo; while (partinfo != NULL) { if (privacy_mimeinfo_is_signed(partinfo)) { siginfo = partinfo; break; } if (privacy_mimeinfo_is_encrypted(partinfo)) { encrypted = partinfo; break; } partinfo = procmime_mimeinfo_parent(partinfo); } if (siginfo != NULL) { switch (privacy_mimeinfo_get_sig_status(siginfo)) { case SIGNATURE_UNCHECKED: case SIGNATURE_CHECK_FAILED: pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp, STOCK_PIXMAP_PRIVACY_EMBLEM_SIGNED, OVERLAY_BOTTOM_RIGHT, 6, 3); break; case SIGNATURE_OK: pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp, STOCK_PIXMAP_PRIVACY_EMBLEM_PASSED, OVERLAY_BOTTOM_RIGHT, 6, 3); break; case SIGNATURE_WARN: pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp, STOCK_PIXMAP_PRIVACY_EMBLEM_WARN, OVERLAY_BOTTOM_RIGHT, 6, 3); break; case SIGNATURE_INVALID: pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp, STOCK_PIXMAP_PRIVACY_EMBLEM_FAILED, OVERLAY_BOTTOM_RIGHT, 6, 3); break; } sigshort = privacy_mimeinfo_sig_info_short(siginfo); } else if (encrypted != NULL) { pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp, STOCK_PIXMAP_PRIVACY_EMBLEM_ENCRYPTED, OVERLAY_BOTTOM_RIGHT, 6, 3); } else { pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp, 0, OVERLAY_NONE, 6, 3); } gtk_container_add(GTK_CONTAINER(button), pixmap); if (!desc) { if (prefs_common.attach_desc) desc = get_part_description(mimeinfo); else desc = get_part_name(mimeinfo); } content_type = procmime_get_content_type_str(mimeinfo->type, mimeinfo->subtype); tip = g_strjoin("\n", content_type, to_human_readable(mimeinfo->length), NULL); g_free(content_type); if (desc && *desc) { tiptmp = g_strjoin("\n", desc, tip, NULL); g_free(tip); tip = tiptmp; } if (sigshort && *sigshort) { tiptmp = g_strjoin("\n", tip, sigshort, NULL); g_free(tip); tip = tiptmp; } g_free(sigshort); gtk_tooltips_set_tip(mimeview->tooltips, button, tip, NULL); g_free(tip); gtk_widget_show_all(button); gtk_signal_connect(GTK_OBJECT(button), "button_release_event", GTK_SIGNAL_FUNC(icon_clicked_cb), mimeview); gtk_signal_connect(GTK_OBJECT(button), "key_press_event", GTK_SIGNAL_FUNC(icon_key_pressed), mimeview); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); }