
2002-11-27 Not Zed <NotZed@Ximian.com> * message-tag-followup.c (construct): gnome_pixmap -> gtkimage. (construct): gtk_clist -> gtk_tree_view, setup columns. They dont size well :-/ (message_tag_followup_append_message): Append using model, remove clist stuff. (construct): Show date edit (glade bugs?) * folder-browser.c (folder_browser_class_init): gtk_marshal -> g_cclosure_marshal (setup_popup_icons): gnome_pixmap -> gtk_image. (on_right_click): gtk_pixmap -> gtk_image. * mail-accounts.c (account_delete_clicked): removed #if 0'd out code. * mail-send-recv.c (receive_done): remove FIXME and extra unref. * mail-session.c (request_password): Removed #if 0'd out stuff. * mail-vfolder.c (new_rule_clicked): proper cast for g_object_get_data. * mail-local.c (reconfigure_response): cast for g_object_get_data. * mail-account-editor.c (construct): GNOME_DIALOG -> GTK_DIALOG. * *.[ch]: re-ran fix.sh for e_notice change * mail-callbacks.c (save_msg_ok): g_object_get_data + gtk_object_remove_no_notify -> g_object_steal_data. (find_socket): gtk_container_children -> gtk_container_get_children (edit_msg): gnome_*_dialog -> gtk_message_dialog. (resent_msg): " (search_msg): " (confirm_goto_next_folder): gtkmessagedialogised (even if not used). (confirm_expunge): gtkmessagedialogised (filter_edit): " (do_mail_print): e_notice -> gtk_message_dialog. (are_you_sure): removed e_gnome_ok_cancel_dialog crap, replaced with a gtk dialog. (are_you_sure): gtkmessagedialogised. (edit_msg_internal): Dont free uids array, are_you_sure() free's it. (resend_msg): Same. (check_send_configuration): Use e_notice for stuff. Sigh, here we go again ...! (e_question): A utility function to ask a question, potentially with 'dont ask again' as well. (configure_mail): use e_question to save code. Here we go again, again ... (ask_confirm_for_unwanted_html_mail): " (ask_confirm_for_only_bcc): " (ask_confirm_for_only_bcc): " (composer_get_message): Use e_notice. (composer_save_draft_cb): Use e_question (edit_msg): use e_notice, & change to an ERROR. (resend_msg): same. (save_msg_ok): Properly initialise ret to OK, and use e_question, and use access() to determine existance/write access rather than stat, display an error if we can't write to a file that exists, and print the filename in all dialogues. (confirm_goto_next_folder): Use e_question. (confirm_expunge): use e_question. (filter_edit): Use e_notice. (do_mail_print): use e_notice. svn path=/trunk/; revision=18974
290 lines
6.2 KiB
C
290 lines
6.2 KiB
C
/*
|
|
* folder-info.c: Implementation of GNOME_Evolution_FolderInfo
|
|
*
|
|
* Copyright (C) 2001 Ximian, Inc.
|
|
*
|
|
* Authors: Iain Holmes <iain@ximian.com>
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#include "folder-info.h"
|
|
|
|
#include "Mailer.h"
|
|
|
|
#include <glib.h>
|
|
|
|
#include <bonobo/bonobo-xobject.h>
|
|
#include <bonobo/bonobo-generic-factory.h>
|
|
#include <bonobo/bonobo-property-bag.h>
|
|
#include <bonobo/bonobo-context.h>
|
|
#include <bonobo/bonobo-exception.h>
|
|
|
|
#include "mail.h"
|
|
#include "mail-mt.h"
|
|
#include "mail-tools.h"
|
|
|
|
#include <camel/camel-folder.h>
|
|
#include <camel/camel-exception.h>
|
|
|
|
#define FOLDER_INFO_IID "OAFIID:GNOME_Evolution_FolderInfo_Factory"
|
|
|
|
#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
|
|
static BonoboObjectClass *parent_class = NULL;
|
|
|
|
static GSList *folder_infos;
|
|
|
|
typedef struct _EvolutionFolderInfo EvolutionFolderInfo;
|
|
typedef struct _EvolutionFolderInfoClass EvolutionFolderInfoClass;
|
|
|
|
struct _EvolutionFolderInfo {
|
|
BonoboXObject parent;
|
|
|
|
BonoboPropertyBag *pb;
|
|
};
|
|
|
|
struct _EvolutionFolderInfoClass {
|
|
BonoboXObjectClass parent_class;
|
|
|
|
POA_GNOME_Evolution_FolderInfo__epv epv;
|
|
};
|
|
|
|
/* MT stuff */
|
|
struct _folder_info_msg {
|
|
struct _mail_msg msg;
|
|
|
|
Bonobo_Listener listener;
|
|
char *foldername;
|
|
|
|
int read;
|
|
int unread;
|
|
};
|
|
|
|
gboolean ready;
|
|
|
|
static char *
|
|
do_describe_info (struct _mail_msg *mm, gint complete)
|
|
{
|
|
return g_strdup (_("Getting Folder Information"));
|
|
}
|
|
|
|
static void
|
|
do_get_info (struct _mail_msg *mm)
|
|
{
|
|
struct _folder_info_msg *m = (struct _folder_info_msg *) mm;
|
|
CamelFolder *folder;
|
|
|
|
folder = mail_tool_uri_to_folder (m->foldername, 0, NULL);
|
|
if (folder) {
|
|
m->read = camel_folder_get_message_count (folder);
|
|
m->unread = camel_folder_get_unread_message_count (folder);
|
|
}
|
|
}
|
|
|
|
static void
|
|
do_got_info (struct _mail_msg *mm)
|
|
{
|
|
struct _folder_info_msg *m = (struct _folder_info_msg *) mm;
|
|
CORBA_Environment ev;
|
|
CORBA_any a;
|
|
GNOME_Evolution_FolderInfo_MessageCount count;
|
|
|
|
/* g_print ("You've got mail: %d, %d\n", m->read, m->unread); */
|
|
|
|
count.path = m->foldername;
|
|
count.count = m->read;
|
|
count.unread = m->unread;
|
|
|
|
a._type = (CORBA_TypeCode) TC_GNOME_Evolution_FolderInfo_MessageCount;
|
|
a._value = &count;
|
|
|
|
CORBA_exception_init (&ev);
|
|
Bonobo_Listener_event (m->listener, "youve-got-mail", &a, &ev);
|
|
if (BONOBO_EX (&ev)) {
|
|
g_warning ("Got exception on listener: %s", CORBA_exception_id (&ev));
|
|
}
|
|
CORBA_exception_free (&ev);
|
|
}
|
|
|
|
static void
|
|
do_free_info (struct _mail_msg *mm)
|
|
{
|
|
struct _folder_info_msg *m = (struct _folder_info_msg *) mm;
|
|
|
|
bonobo_object_release_unref (m->listener, NULL);
|
|
g_free (m->foldername);
|
|
}
|
|
|
|
struct _mail_msg_op get_info_op = {
|
|
do_describe_info,
|
|
do_get_info,
|
|
do_got_info,
|
|
do_free_info,
|
|
};
|
|
|
|
typedef struct {
|
|
int read;
|
|
int unread;
|
|
} MailFolderInfo;
|
|
|
|
/* Returns a MailFolderInfo struct or NULL on error */
|
|
static void
|
|
mail_get_info (const char *foldername,
|
|
Bonobo_Listener listener)
|
|
{
|
|
CORBA_Environment ev;
|
|
struct _folder_info_msg *m;
|
|
|
|
m = mail_msg_new (&get_info_op, NULL, sizeof (*m));
|
|
|
|
/* g_print ("Folder: %s", foldername); */
|
|
m->foldername = g_strdup (foldername);
|
|
|
|
CORBA_exception_init (&ev);
|
|
m->listener = bonobo_object_dup_ref (listener, &ev);
|
|
CORBA_exception_free (&ev);
|
|
|
|
e_thread_put (mail_thread_new, (EMsg *) m);
|
|
}
|
|
|
|
static void
|
|
impl_GNOME_Evolution_FolderInfo_getInfo (PortableServer_Servant servant,
|
|
const CORBA_char *foldername,
|
|
const Bonobo_Listener listener,
|
|
CORBA_Environment *ev)
|
|
{
|
|
mail_get_info (foldername, listener);
|
|
}
|
|
|
|
#if 0
|
|
static void
|
|
destroy (GtkObject *object)
|
|
{
|
|
EvolutionFolderInfo *info = (EvolutionFolderInfo *) object;
|
|
|
|
bonobo_object_unref (BONOBO_OBJECT (info->pb));
|
|
}
|
|
#endif
|
|
|
|
static void
|
|
evolution_folder_info_class_init (EvolutionFolderInfoClass *klass)
|
|
{
|
|
POA_GNOME_Evolution_FolderInfo__epv *epv = &klass->epv;
|
|
|
|
parent_class = g_type_class_ref(PARENT_TYPE);
|
|
epv->getInfo = impl_GNOME_Evolution_FolderInfo_getInfo;
|
|
}
|
|
|
|
static void
|
|
evolution_folder_info_init (EvolutionFolderInfo *info)
|
|
{
|
|
}
|
|
|
|
BONOBO_X_TYPE_FUNC_FULL (EvolutionFolderInfo,
|
|
GNOME_Evolution_FolderInfo,
|
|
PARENT_TYPE,
|
|
evolution_folder_info);
|
|
|
|
enum {
|
|
PROP_FOLDER_INFO_READY
|
|
};
|
|
|
|
static void
|
|
set_prop (BonoboPropertyBag *bag,
|
|
const BonoboArg *arg,
|
|
guint arg_id,
|
|
CORBA_Environment *ev,
|
|
gpointer user_data)
|
|
{
|
|
switch (arg_id) {
|
|
case PROP_FOLDER_INFO_READY:
|
|
ready = BONOBO_ARG_GET_BOOLEAN (arg);
|
|
break;
|
|
default:
|
|
bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
|
|
break;
|
|
}
|
|
}
|
|
|
|
static void
|
|
get_prop (BonoboPropertyBag *bag,
|
|
BonoboArg *arg,
|
|
guint arg_id,
|
|
CORBA_Environment *ev,
|
|
gpointer user_data)
|
|
{
|
|
switch (arg_id) {
|
|
case PROP_FOLDER_INFO_READY:
|
|
BONOBO_ARG_SET_BOOLEAN (arg, ready);
|
|
break;
|
|
default:
|
|
bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
|
|
break;
|
|
}
|
|
}
|
|
|
|
static BonoboObject *
|
|
evolution_folder_info_factory_fn (BonoboGenericFactory *factory,
|
|
const char *id,
|
|
void *closure)
|
|
{
|
|
EvolutionFolderInfo *info;
|
|
BonoboPropertyBag *pb;
|
|
|
|
info = g_object_new (evolution_folder_info_get_type (), NULL);
|
|
pb = bonobo_property_bag_new (get_prop, set_prop, info);
|
|
info->pb = pb;
|
|
/* Add properties */
|
|
bonobo_property_bag_add (pb, "folder-info-ready",
|
|
PROP_FOLDER_INFO_READY,
|
|
BONOBO_ARG_BOOLEAN, NULL, FALSE,
|
|
BONOBO_PROPERTY_READABLE |
|
|
BONOBO_PROPERTY_WRITEABLE);
|
|
|
|
bonobo_object_add_interface (BONOBO_OBJECT (info), BONOBO_OBJECT (pb));
|
|
|
|
/* Add to the folder info list so we can get at them all afterwards */
|
|
folder_infos = g_slist_append (folder_infos, info);
|
|
|
|
return BONOBO_OBJECT (info);
|
|
}
|
|
|
|
gboolean
|
|
evolution_folder_info_factory_init (void)
|
|
{
|
|
BonoboGenericFactory *factory;
|
|
|
|
folder_infos = NULL;
|
|
ready = FALSE;
|
|
|
|
factory = bonobo_generic_factory_new (FOLDER_INFO_IID,
|
|
evolution_folder_info_factory_fn,
|
|
NULL);
|
|
|
|
if (factory == NULL) {
|
|
g_warning ("Error starting FolderInfo");
|
|
return FALSE;
|
|
}
|
|
|
|
bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
evolution_folder_info_notify_ready (void)
|
|
{
|
|
GSList *p;
|
|
|
|
ready = TRUE;
|
|
|
|
for (p = folder_infos; p; p = p->next) {
|
|
EvolutionFolderInfo *info = p->data;
|
|
Bonobo_PropertyBag bag;
|
|
|
|
bag = (Bonobo_PropertyBag)bonobo_object_corba_objref(BONOBO_OBJECT(info->pb));
|
|
bonobo_pbclient_set_boolean("folder-info-ready", ready, NULL);
|
|
}
|
|
}
|