static TnyMsg * tny_camel_partial_msg_receive_strategy_perform_get_msg_default (TnyMsgReceiveStrategy *self, TnyFolder *folder, TnyHeader *header, GError **err) { TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); TnyMsg *message = NULL; CamelMimeMessage *camel_message = NULL; gchar *id; CamelException ex = CAMEL_EXCEPTION_INITIALISER; CamelFolderReceiveType mtype = CAMEL_FOLDER_RECEIVE_PARTIAL; g_assert (TNY_IS_HEADER (header)); if (!priv->strict_retrieval) mtype = CAMEL_FOLDER_RECEIVE_ANY_OR_PARTIAL; id = tny_header_dup_uid (TNY_HEADER (header)); message = NULL; camel_message = camel_folder_get_message (priv->folder, (const char *) id, mtype, -1, &ex); g_free (id); if (camel_exception_is_set (&ex)) { _tny_camel_exception_to_tny_error (&ex, err); camel_exception_clear (&ex); } else { if (camel_message && CAMEL_IS_OBJECT (camel_message)) { TnyHeader *nheader = NULL; nheader = _tny_camel_msg_header_new (CAMEL_MIME_MESSAGE (camel_message), folder, tny_header_get_date_received (header)); _tny_camel_msg_header_set_decorated (TNY_CAMEL_MSG_HEADER (nheader), header, FALSE); message = tny_camel_msg_new (); _tny_camel_msg_set_received (TNY_CAMEL_MSG (message), tny_header_get_date_received (header)); _tny_camel_msg_set_folder (TNY_CAMEL_MSG (message), folder); TNY_CAMEL_MSG_HEADER (nheader)->old_uid = tny_header_dup_uid (header); _tny_camel_msg_set_header (TNY_CAMEL_MSG (message), nheader); _tny_camel_mime_part_set_part (TNY_CAMEL_MIME_PART (message), CAMEL_MIME_PART (camel_message)); tny_header_set_flag (nheader, TNY_HEADER_FLAG_CACHED); tny_header_set_flag (nheader, TNY_HEADER_FLAG_PARTIAL); g_object_unref (nheader); tny_header_set_flag (header, TNY_HEADER_FLAG_CACHED); tny_header_set_flag (header, TNY_HEADER_FLAG_PARTIAL); } } if (camel_message && CAMEL_IS_OBJECT (camel_message)) camel_object_unref (CAMEL_OBJECT (camel_message)); return message; }
static void offline_folder_downsync (CamelOfflineFolder *offline, const char *expression, CamelException *ex) { CamelFolder *folder = (CamelFolder *) offline; CamelMimeMessage *message; GPtrArray *uids; int i; camel_operation_start (NULL, _("Syncing messages in folder '%s' to disk"), folder->full_name); if (expression) uids = camel_folder_search_by_expression (folder, expression, ex); else uids = camel_folder_get_uids (folder); if (!uids) { camel_operation_end (NULL); return; } for (i = 0; i < uids->len; i++) { int pc = i * 100 / uids->len; message = camel_folder_get_message (folder, uids->pdata[i], ex); camel_operation_progress (NULL, pc); if (message == NULL) break; camel_object_unref (message); } if (expression) camel_folder_search_free (folder, uids); else camel_folder_free_uids (folder, uids); camel_operation_end (NULL); }
static void offline_downsync_sync (CamelSession *session, CamelSessionThreadMsg *mm) { struct _offline_downsync_msg *m = (struct _offline_downsync_msg *) mm; CamelMimeMessage *message; int i; camel_operation_start (NULL, _("Downloading new messages for offline mode")); if (m->changes) { for (i = 0; i < m->changes->uid_added->len; i++) { int pc = i * 100 / m->changes->uid_added->len; camel_operation_progress (NULL, pc); if ((message = camel_folder_get_message (m->folder, m->changes->uid_added->pdata[i], &mm->ex))) camel_object_unref (message); } } else { camel_offline_folder_downsync ((CamelOfflineFolder *) m->folder, "(match-all)", &mm->ex); } camel_operation_end (NULL); }
void com_irontec_evosugar(void *ep, EMPopupTargetSelect *t) { CamelException ex = {0}; gchar *folder_name = camel_folder_get_name(t->folder); gboolean folder_is_sent = FALSE; BREAKPOINT; gui.gtkBuilder = gtk_builder_new(); gtk_builder_set_translation_domain(gui.gtkBuilder, GETTEXT_PACKAGE); gtk_builder_add_from_file(gui.gtkBuilder, g_build_filename(PLUGIN_INSTALL_DIR, UI_FILE, NULL), NULL); gui.entry_search = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "entrySearch")); gui.button_search = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "buttonSearch")); gui.radio_button_from = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "radiobuttonFrom")); gui.radio_button_to = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "radiobuttonTo")); gui.button_submit = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "buttonAddToSugarCRM")); gui.entry_subject_edit = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "entryEditSubject")); BREAKPOINT; g_signal_connect(gui.button_search, "clicked", G_CALLBACK(on_button_search_clicked), GTK_ENTRY(gui.entry_search)); g_signal_connect(gui.button_submit, "clicked", G_CALLBACK(on_button_AddToSugarCRM_clicked), NULL); scrm_session.id = scrm_login(gconf_get_username(), gconf_get_password(), gconf_get_server()); if ((g_strcmp0(folder_name, "Sent") == 0) || (g_strcmp0(folder_name, _("Sent")) == 0) ) { folder_is_sent = TRUE; } if (scrm_session.id == NULL || g_strcmp0(scrm_session.id, "-1") == 0) { gui_show_message(_("SugarCRM"), _("Unable to connect: check your connection and settings please.")); } else { BREAKPOINT; msg = camel_folder_get_message(t->folder, t->uids->pdata[0], &ex); util_get_msg_body(msg, &msg_body); if (msg == NULL) { camel_exception_clear(&ex); return; } BREAKPOINT; subject = camel_mime_message_get_subject(msg); gtk_entry_set_text(gui.entry_subject_edit, subject); gui.body_text_view = gtk_builder_get_object(gui.gtkBuilder, "bodyTextView"); model.body_text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gui.body_text_view)); gtk_text_buffer_set_text(model.body_text_buffer, msg_body, -1); from = camel_mime_message_get_from(msg); to = camel_mime_message_get_recipients(msg, CAMEL_RECIPIENT_TYPE_TO); BREAKPOINT; msg_date = camel_mime_message_get_date(msg, NULL); camel_internet_address_get(from, 0, &from_name, &from_addr); camel_internet_address_get(to, 0, &to_name, &to_addr); g_signal_connect(gui.radio_button_from, "pressed", G_CALLBACK(on_radio_group_search_changed), from_addr); gchar *to_search = to_addr; g_signal_connect(gui.radio_button_to, "pressed", G_CALLBACK(on_radio_group_search_changed), to_search); if (folder_is_sent) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui.radio_button_to),TRUE); } BREAKPOINT; GtkWidget *content_box = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "vboxContents")); GtkWidget *frame_attach = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "frameAttach")); if (folder_is_sent) { gtk_entry_set_text(gui.entry_search, to_addr); } else { gtk_entry_set_text(gui.entry_search, from_addr); } GtkScrolledWindow *scrolledwindow = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); gtk_scrolled_window_set_policy(scrolledwindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); GtkScrolledWindow *scrolledwindow2 = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); gtk_scrolled_window_set_policy(scrolledwindow2, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); BREAKPOINT; gtk_container_add(GTK_CONTAINER(content_box), scrolledwindow); gtk_container_add(GTK_CONTAINER(frame_attach), scrolledwindow2); BREAKPOINT; gui.treeview_search = gtk_tree_view_new(); gui.treeview_attach = gtk_tree_view_new(); add_columns_search(GTK_TREE_VIEW(gui.treeview_search)); add_columns_attachment(GTK_TREE_VIEW(gui.treeview_attach)); model.model_attach = util_get_msg_attachments(msg); //gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), model_search); BREAKPOINT; //g_object_unref (G_OBJECT (model_search)); gtk_builder_connect_signals(gui.gtkBuilder, NULL); gtk_tree_view_set_model(GTK_TREE_VIEW(gui.treeview_attach), model.model_attach); gtk_container_add(scrolledwindow, gui.treeview_search); gtk_container_add(scrolledwindow2, gui.treeview_attach); gui.mainwin = GTK_WIDGET(gtk_builder_get_object (gui.gtkBuilder, "addToSugarCRMwindow")); /* * Show the application window */ gtk_widget_show_all(gui.mainwin); //trigger on_button_search_clicked(NULL, gui.entry_search); if (DEBUG_ON) { //g_mem_profile (); } } // end-else comprobar conexion }
void camel_disco_diary_replay (CamelDiscoDiary *diary, CamelException *ex) { guint32 action; off_t size; double pc; d(printf("disco diary replay\n")); fseek (diary->file, 0, SEEK_END); size = ftell (diary->file); g_return_if_fail (size != 0); rewind (diary->file); camel_operation_start (NULL, _("Resynchronizing with server")); while (!camel_exception_is_set (ex)) { pc = ftell (diary->file) / size; camel_operation_progress (NULL, pc * 100); if (camel_file_util_decode_uint32 (diary->file, &action) == -1) break; if (action == CAMEL_DISCO_DIARY_END) break; switch (action) { case CAMEL_DISCO_DIARY_FOLDER_EXPUNGE: { CamelFolder *folder; GPtrArray *uids; folder = diary_decode_folder (diary); uids = diary_decode_uids (diary); if (!uids) goto lose; if (folder) camel_disco_folder_expunge_uids (folder, uids, ex); free_uids (uids); break; } case CAMEL_DISCO_DIARY_FOLDER_APPEND: { CamelFolder *folder; char *uid, *ret_uid; CamelMimeMessage *message; CamelMessageInfo *info; folder = diary_decode_folder (diary); if (camel_file_util_decode_string (diary->file, &uid) == -1) goto lose; if (!folder) { g_free (uid); continue; } message = camel_folder_get_message (folder, uid, NULL); if (!message) { /* The message was appended and then deleted. */ g_free (uid); continue; } info = camel_folder_get_message_info (folder, uid); camel_folder_append_message (folder, message, info, &ret_uid, ex); camel_folder_free_message_info (folder, info); if (ret_uid) { camel_disco_diary_uidmap_add (diary, uid, ret_uid); g_free (ret_uid); } g_free (uid); break; } case CAMEL_DISCO_DIARY_FOLDER_TRANSFER: { CamelFolder *source, *destination; GPtrArray *uids, *ret_uids; guint32 delete_originals; int i; source = diary_decode_folder (diary); destination = diary_decode_folder (diary); uids = diary_decode_uids (diary); if (!uids) goto lose; if (camel_file_util_decode_uint32 (diary->file, &delete_originals) == -1) goto lose; if (!source || !destination) { free_uids (uids); continue; } camel_folder_transfer_messages_to (source, uids, destination, &ret_uids, delete_originals, ex); if (ret_uids) { for (i = 0; i < uids->len; i++) { if (!ret_uids->pdata[i]) continue; camel_disco_diary_uidmap_add (diary, uids->pdata[i], ret_uids->pdata[i]); g_free (ret_uids->pdata[i]); } g_ptr_array_free (ret_uids, TRUE); } free_uids (uids); break; } } } lose: camel_operation_end (NULL); /* Close folders */ g_hash_table_foreach (diary->folders, close_folder, diary); g_hash_table_destroy (diary->folders); diary->folders = NULL; /* Truncate the log */ ftruncate (fileno (diary->file), 0); }