gint i = 0;
while (TRUE) {
- name = g_strdup_printf ("%s:%s@%s:%d",
- modest_protocol_info_get_protocol_name(proto),
- username ? username : "<none>",
- servername ? servername : "<none>",
- i++);
+ name = g_strdup_printf ("%s:%d",
+ modest_protocol_info_get_protocol_name(proto), i++);
if (modest_account_mgr_account_exists (acc_mgr, name, TRUE, NULL))
g_free (name);
else
modest_account_mgr_add_account (priv->account_mgr,
account_name,
store_name,
- NULL, NULL);
+ transport_name,
+ NULL);
modest_account_mgr_set_string (priv->account_mgr,
account_name,
MODEST_ACCOUNT_FULLNAME,
modest_edit_msg_window_get_msg_data (ModestEditMsgWindow *edit_window)
{
MsgData *data;
- ModestAccountData *account_data;
GtkTextBuffer *buf;
GtkTextIter b, e;
+ const gchar *account_name;
+ gchar *from_string = NULL;
ModestEditMsgWindowPrivate *priv;
g_return_val_if_fail (MODEST_IS_EDIT_MSG_WINDOW (edit_window), NULL);
priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE (edit_window);
- account_data = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field));
+ account_name = (gchar*)modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field));
+ if (account_name)
+ from_string = modest_account_mgr_get_from_string (
+ modest_runtime_get_account_mgr(), account_name);
+ if (!from_string) {
+ g_printerr ("modest: cannot get from string\n");
+ return NULL;
+ }
+
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body));
gtk_text_buffer_get_bounds (buf, &b, &e);
/* don't free these (except from) */
data = g_slice_new0 (MsgData);
- data->from = g_strdup_printf ("%s <%s>", account_data->fullname, account_data->email) ;
+ data->from = from_string, /* will be freed when data is freed */
data->to = (gchar*) gtk_entry_get_text (GTK_ENTRY(priv->to_field));
data->cc = (gchar*) gtk_entry_get_text (GTK_ENTRY(priv->cc_field));
data->bcc = (gchar*) gtk_entry_get_text (GTK_ENTRY(priv->bcc_field));
TnyAccount*
modest_account_mgr_get_tny_account (ModestAccountMgr *self, const gchar* account_name,
- TnyAccountType type)
+ TnyAccountType type)
{
TnyAccount *account = NULL;
TnyList *accounts;
TnyIterator *iter;
gchar *server_account;
const gchar *conf_key;
+ TnyGetAccountsRequestType request_type; /* really confusing.... */
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (account_name, NULL);
switch (type) {
case TNY_ACCOUNT_TYPE_STORE:
- conf_key = MODEST_ACCOUNT_STORE_ACCOUNT; break;
+ conf_key = MODEST_ACCOUNT_STORE_ACCOUNT;
+ request_type = TNY_ACCOUNT_STORE_STORE_ACCOUNTS;
+ break;
case TNY_ACCOUNT_TYPE_TRANSPORT:
- conf_key = MODEST_ACCOUNT_TRANSPORT_ACCOUNT; break;
+ conf_key = MODEST_ACCOUNT_TRANSPORT_ACCOUNT;
+ request_type = TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS;
+ break;
default:
g_return_val_if_reached (NULL);
}
accounts = tny_simple_list_new ();
tny_account_store_get_accounts (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()),
- accounts, type);
+ accounts, request_type);
iter = tny_list_create_iterator (accounts);
while (tny_iterator_is_done (iter)) {
account = TNY_ACCOUNT(tny_iterator_get_current(iter));
GHashTable *date_str_cache;
GHashTable *display_str_cache;
GHashTable *pixbuf_cache;
+ GHashTable *send_queue_cache;
};
#define MODEST_CACHE_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_CACHE_MGR, \
static
-void pixbuf_unref (GObject *pixbuf)
+void my_object_unref (GObject *obj)
{
- if (pixbuf)
- g_object_unref (pixbuf);
+ if (obj)
+ g_object_unref (obj);
}
static void
g_hash_table_new_full (g_str_hash, /* gchar* */
g_str_equal,
g_free, /* gchar*/
- (GDestroyNotify)pixbuf_unref);
+ (GDestroyNotify)my_object_unref);
+ priv->send_queue_cache =
+ g_hash_table_new_full (g_direct_hash, /* ptr */
+ g_direct_equal,
+ (GDestroyNotify)my_object_unref, /* ref'd GObject */
+ (GDestroyNotify)my_object_unref); /* ref'd GObject */
+
}
priv->date_str_cache = NULL;
priv->display_str_cache = NULL;
priv->pixbuf_cache = NULL;
+ priv->send_queue_cache = NULL;
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
return priv->display_str_cache;
case MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF:
return priv->pixbuf_cache;
+ case MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE:
+ return priv->send_queue_cache;
default:
g_return_val_if_reached(NULL); /* should not happen */
}
MODEST_CACHE_MGR_CACHE_TYPE_DATE_STRING, /* time_t => string */
MODEST_CACHE_MGR_CACHE_TYPE_DISPLAY_STRING, /* gchar* => gchar* */
MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF, /* gchar* => GdkPixbuf */
+ MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE, /* TnyAccount* => TnySendQueue* */
MODEST_CACHE_MGR_CACHE_TYPE_NUM
} ModestCacheMgrCacheType;
*
* get the cache (GHashTable) of the requested type
*
- * Returns: the requested cache (GHashTable) or NULL in case caching
- * has been disabled (MODEST_DEBUG_DISABLE_CACHE); clients are supposed
- * to handle that case
+ * Returns: the requested cache (GHashTable)
*
* the returned hashtable should NOT be destroyed or unref'd.
*/
/**
* modest_conf_get_type:
*
- * get the GType for ModestConf
+ * get the #GType for #ModestConf
*
- * Returns: the GType
+ * Returns: the #GType
*/
GType modest_conf_get_type (void) G_GNUC_CONST;
/**
* modest_conf_new:
*
- * create a new modest ModestConf object.
+ * create a new modest #ModestConf object.
*
- * Returns: a new ModestConf instance, or NULL in case
+ * Returns: a new #ModestConf instance, or NULL in case
* of any error
*/
ModestConf* modest_conf_new (void);
#include <camel/camel-stream-mem.h>
#include <glib/gi18n.h>
#include <modest-tny-account.h>
+#include <modest-tny-send-queue.h>
+#include <modest-runtime.h>
#include "modest-text-utils.h"
#include "modest-tny-msg.h"
#include "modest-tny-platform-factory.h"
TnyTransportAccount *transport_account,
TnyMsg* msg)
{
+ TnySendQueue *send_queue;
+
g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT (transport_account));
- tny_transport_account_send (transport_account, msg, NULL); /* FIXME */
+ send_queue = TNY_SEND_QUEUE (modest_runtime_get_send_queue (transport_account));
+
+ tny_send_queue_add (send_queue, msg);
}
void
add_attachments (new_msg, (GList*) attachments_list);
/* Send mail */
- tny_transport_account_send (transport_account, new_msg, NULL); /* FIXME */
+ modest_mail_operation_send_mail (self, transport_account, new_msg);
/* Clean */
g_object_unref (header);
}
+ModestTnySendQueue*
+modest_runtime_get_send_queue (TnyTransportAccount *account)
+{
+ ModestCacheMgr *cache_mgr;
+ GHashTable *send_queue_cache;
+ gpointer orig_key, send_queue;
+
+ g_return_val_if_fail (_singletons, NULL);
+ g_return_val_if_fail (!TNY_IS_TRANSPORT_ACCOUNT(account), NULL);
+
+ cache_mgr = modest_singletons_get_cache_mgr (_singletons);
+ send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
+ MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF);
+ if (!g_hash_table_lookup_extended (send_queue_cache, account, &orig_key, &send_queue)) {
+ send_queue = (gpointer)modest_tny_send_queue_new (TNY_CAMEL_TRANSPORT_ACCOUNT(account));
+ g_hash_table_insert (send_queue_cache, account, send_queue);
+ }
+
+ return MODEST_TNY_SEND_QUEUE(send_queue);
+}
+
+
+
/* http://primates.ximian.com/~federico/news-2006-04.html#memory-debugging-infrastructure*/
ModestRuntimeDebugFlags
#include <modest-mail-operation-queue.h>
#include <modest-tny-account-store.h>
#include <modest-widget-factory.h>
+#include <modest-tny-send-queue.h>
G_BEGIN_DECLS
/**
* modest_runtime_get_mail_operation_queue:
*
- * get the ModestMailOperationQueue singleton instance
+ * get the #ModestMailOperationQueue singleton instance
*
- * Returns: the ModestMailOperationQueue singleton
+ * Returns: the #ModestMailOperationQueue singleton
**/
ModestMailOperationQueue* modest_runtime_get_mail_operation_queue (void);
/**
- * modest_runtime_get_widget_factory
+ * modest_runtime_get_widget_factory:
*
- * get the ModestWidgetFactory singleton instance
+ * get the #ModestWidgetFactory singleton instance
*
- * Returns: the ModestCacheMgr singleton
+ * Returns: the #ModestCacheMgr singleton
**/
ModestWidgetFactory* modest_runtime_get_widget_factory (void);
+
+/**
+ * modest_runtime_get_send_queue:
+ * @account: a valid TnyTransportAccount
+ *
+ * get the send queue for the given account
+ *
+ * Returns: the #ModestTnySendQueue singleton instance for this account
+ * (ie., one singleton per account)
+ **/
+ModestTnySendQueue* modest_runtime_get_send_queue (TnyTransportAccount *account);
+
+
+
G_END_DECLS
#endif /*__MODEST_RUNTIME_H__*/
}
return priv->widget_factory;
}
+
/**
* modest_singletons_get_conf:
+ * @self: a valid ModestSingletons instance
*
* get the ModestConf singleton instance
* don't use this function directly, use the modest-runtime
/**
* modest_singletons_get_account_mgr:
+ * @self: a valid ModestSingletons instance
*
* get the ModestAccountMgr singleton instance
* don't use this function directly, use the modest-runtime
/**
* modest_singletons_get_account_store:
+ * @self: a valid #ModestSingletons instance
*
- * get the ModestTnyAccountStore singleton instance
+ * get the #ModestTnyAccountStore singleton instance
* don't use this function directly, use the modest-runtime
* functions instead.
*
- * Returns: the ModestTnyAccountStore singleton
+ * Returns: the #ModestTnyAccountStore singleton
**/
ModestTnyAccountStore* modest_singletons_get_account_store (ModestSingletons *self);
/**
- * modest_singletons_get_cache_mgr:
+ * modest_singletons_get_widget_factory:
+ * @self: a valid #ModestSingletons instance
*
- * get the ModestCacheMgr singleton instance
+ * get the #ModestWidgetFactory singleton instance
* don't use this function directly, use the modest-runtime
* functions instead.
*
- * Returns: the ModestCacheMgr singleton
+ * Returns: the #ModestWidgetFactory singleton
**/
-ModestCacheMgr* modest_singletons_get_cache_mgr (ModestSingletons *self);
-
+ModestWidgetFactory* modest_singletons_get_widget_factory (ModestSingletons *self);
/**
- * modest_singletons_get_mail_operation_queue:
+ * modest_singletons_get_cache_mgr:
+ * @self: a valid #ModestSingletons instance
*
- * get the ModestMailOperationQueue singleton instance
+ * get the #ModestCacheMgr singleton instance
* don't use this function directly, use the modest-runtime
* functions instead.
*
- * Returns: the ModestMailOperationQueue singleton
+ * Returns: the #ModestCacheMgr singleton
**/
-ModestMailOperationQueue* modest_singletons_get_mail_operation_queue (ModestSingletons *self);
-
-
+ModestCacheMgr* modest_singletons_get_cache_mgr (ModestSingletons *self);
/**
- * modest_singletons_get_widget_factory:
+ * modest_singletons_get_mail_operation_queue:
+ * @self: a valid ModestSingletons instance
*
- * get the ModestWidgetFactory singleton instance
+ * get the ModestMailOperationQueue singleton instance
* don't use this function directly, use the modest-runtime
* functions instead.
*
- * Returns: the ModestWidgetFactory singleton
+ * Returns: the ModestMailOperationQueue singleton
**/
-ModestWidgetFactory* modest_singletons_get_widget_factory (ModestSingletons *self);
-
+ModestMailOperationQueue* modest_singletons_get_mail_operation_queue (ModestSingletons *self);
G_END_DECLS
TRUE, NULL);
}
-
-
-/* instantiate the correct tny account subclass */
-static TnyAccount*
-tny_account_for_proto (ModestProtocol proto)
-{
- ModestProtocolType type;
- TnyAccount *tny_account = NULL;
-
- type = modest_protocol_info_get_protocol_type (proto);
-
- if (type == MODEST_PROTOCOL_TYPE_TRANSPORT)
- tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ());
- else if (proto == MODEST_PROTOCOL_STORE_POP)
- tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ());
- else if (proto == MODEST_PROTOCOL_STORE_IMAP)
- tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ());
- else if (proto == MODEST_PROTOCOL_STORE_MAILDIR || proto == MODEST_PROTOCOL_STORE_MBOX)
- tny_account = TNY_ACCOUNT(tny_camel_store_account_new());
- else
- g_return_val_if_reached (NULL);
-
- return tny_account;
-}
-
-
/* create a tnyaccount for the server account connected to the account with name 'key'
*/
static TnyAccount*
get_tny_account_from_server_account (ModestTnyAccountStore *self,
- ModestServerAccountData *account_data,
- ModestProtocolType modest_type)
+ ModestServerAccountData *account_data, TnyAccountType type)
{
TnyAccount *tny_account;
ModestTnyAccountStorePrivate *priv;
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- /* proto */
+ /* sanity checks */
if (account_data->proto == MODEST_PROTOCOL_UNKNOWN) {
g_printerr ("modest: '%s' does not provide a protocol\n",
account_data->account_name);
return NULL;
}
- tny_account = tny_account_for_proto (account_data->proto);
+ if ((account_data->proto == MODEST_PROTOCOL_TYPE_TRANSPORT && type != TNY_ACCOUNT_TYPE_TRANSPORT) ||
+ (account_data->proto == MODEST_PROTOCOL_TYPE_STORE && type != TNY_ACCOUNT_TYPE_STORE)) {
+ g_printerr ("modest: protocol types do not match <%d,%d>\n", account_data->proto, type);
+ return NULL;
+ }
+
+ switch (account_data->proto) {
+ case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
+ case MODEST_PROTOCOL_TRANSPORT_SMTP:
+ tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
+ case MODEST_PROTOCOL_STORE_POP:
+ tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
+ case MODEST_PROTOCOL_STORE_IMAP:
+ tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
+ case MODEST_PROTOCOL_STORE_MAILDIR:
+ case MODEST_PROTOCOL_STORE_MBOX:
+ tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
+ default:
+ g_return_val_if_reached (NULL);
+ }
+
if (!tny_account) {
g_printerr ("modest: could not create tny account for '%s'\n",
account_data->account_name);
return NULL;
}
tny_account_set_id (tny_account, account_data->account_name);
- tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), priv->tny_session_camel);
+
+ /*
+ * FIXME --> bug in tinymail
+ */
+ if (type == TNY_ACCOUNT_TYPE_TRANSPORT) {
+ g_printerr ("modest: BUG: cannot create transports accounts... stay tuned\n");
+ g_object_unref (G_OBJECT(tny_account));
+ return NULL;
+ }
+
+ tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), priv->tny_session_camel);
tny_account_set_forget_pass_func (tny_account, forget_password);
tny_account_set_pass_func (tny_account, get_password);
modest_protocol_info_get_protocol_name(account_data->proto));
g_object_set_data (G_OBJECT(tny_account), "account_store", (gpointer)self);
-
if (account_data->uri)
tny_account_set_url_string (TNY_ACCOUNT(tny_account), account_data->uri);
else {
return MODEST_TNY_ACCOUNT_STORE(obj);
}
-static void
-modest_tny_account_store_add_store_account (TnyAccountStore *self,
- TnyStoreAccount *account)
-{
- /* we should not need this...*/
- g_printerr ("modest: add_store_account_func not implemented\n");
-}
-
-
-static void
-modest_tny_account_store_add_transport_account (TnyAccountStore *self,
- TnyTransportAccount *account)
-{
- /* we should not need this...*/
- g_printerr ("modest: add_transport_account_func not implemented\n");
-}
-
-
static TnyAccount*
get_tny_account_from_account (ModestTnyAccountStore *self, ModestAccountData *account_data,
- TnyGetAccountsRequestType type)
+ TnyAccountType type)
{
TnyAccount *tny_account = NULL;
ModestServerAccountData *server_account = NULL;
- if (type == TNY_ACCOUNT_STORE_STORE_ACCOUNTS && account_data->store_account)
+ if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
server_account = account_data->store_account;
- else if (type == TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS && account_data->transport_account)
+ else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
server_account = account_data->transport_account;
if (!server_account) {
g_printerr ("modest: no %s account defined for '%s'\n",
- type == TNY_ACCOUNT_STORE_STORE_ACCOUNTS ? "store" : "transport",
+ type == TNY_ACCOUNT_TYPE_STORE ? "store" : "transport",
account_data->display_name);
return NULL;
}
tny_account = get_tny_account_from_server_account (self, server_account, type);
if (!tny_account) {
- g_printerr ("modest: failed to create tny account for %s\n",
- account_data->account_name);
+ g_printerr ("modest: failed to create tny account for %s (%s)\n",
+ account_data->account_name, server_account->account_name);
return NULL;
}
-
+
+ /* this name is what shows up in the folder view -- so for some POP/IMAP/... server
+ * account, we set its name to the acount of which it is part */
if (account_data->display_name)
tny_account_set_name (tny_account, account_data->display_name);
static void
modest_tny_account_store_get_accounts (TnyAccountStore *account_store, TnyList *list,
- TnyGetAccountsRequestType type)
+ TnyGetAccountsRequestType request_type)
{
+ TnyAccountType type;
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
GSList *accounts, *cursor;
g_return_if_fail (account_store);
g_return_if_fail (TNY_IS_LIST(list));
-
+ g_return_if_fail (request_type == TNY_ACCOUNT_STORE_STORE_ACCOUNTS ||
+ request_type == TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS ||
+ request_type == TNY_ACCOUNT_STORE_BOTH);
+
self = MODEST_TNY_ACCOUNT_STORE(account_store);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- if (type == TNY_ACCOUNT_STORE_BOTH) {
+ if (request_type == TNY_ACCOUNT_STORE_BOTH) {
modest_tny_account_store_get_accounts (account_store, list,
TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
modest_tny_account_store_get_accounts (account_store, list,
return;
}
+ /*
+ * confusingly, tinymail uses both TnyAccountRequestType and TnyAccountType
+ */
+ switch (request_type) {
+ case TNY_ACCOUNT_STORE_STORE_ACCOUNTS : type = TNY_ACCOUNT_TYPE_STORE; break;
+ case TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS: type = TNY_ACCOUNT_TYPE_TRANSPORT; break;
+ default: g_return_if_reached (); /* 'BOTH' is not possible here */
+ }
+
accounts = modest_account_mgr_account_names (priv->account_mgr, NULL);
for (cursor = accounts; cursor; cursor = cursor->next) {
TnyAccount *tny_account = NULL;
(gchar*)cursor->data);
if (account_data && account_data->is_enabled) {
tny_account = get_tny_account_from_account (self, account_data, type);
- if (tny_account)
+ if (tny_account) {
tny_list_prepend (list, G_OBJECT(tny_account));
+ g_object_unref (G_OBJECT(tny_account));
+ }
}
g_free (cursor->data);
modest_account_mgr_free_account_data (priv->account_mgr, account_data);
g_slist_free (accounts);
/* also, add the local folder pseudo-account */
- if (type != TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS) {
+ if (request_type != TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS) {
if (!priv->local_folders)
priv->local_folders = get_local_folders_account (self);
if (!priv->local_folders)
g_printerr ("modest: no local folders account\n");
- else
+ else
tny_list_prepend (list, G_OBJECT(priv->local_folders));
}
}
}
+
+static void
+modest_tny_account_store_add_store_account (TnyAccountStore *self,
+ TnyStoreAccount *account)
+{
+ /* we should not need this...*/
+ g_printerr ("modest: add_store_account_func not implemented\n");
+}
+
+
+static void
+modest_tny_account_store_add_transport_account (TnyAccountStore *self,
+ TnyTransportAccount *account)
+{
+ /* we should not need this...*/
+ g_printerr ("modest: add_transport_account_func not implemented\n");
+}
+
+
+
static void
modest_tny_account_store_init (gpointer g, gpointer iface_data)
{
gpointer user_data);
};
-/* member functions */
-
/**
* modest_tny_account_store_get_type:
*
return special_folder;
}
+
+
/* 'private'/'protected' functions */
static void modest_tny_send_queue_class_init (ModestTnySendQueueClass *klass);
-static void modest_tny_send_queue_init (gpointer g, gpointer iface_data);
static void modest_tny_send_queue_finalize (GObject *obj);
static void modest_tny_send_queue_instance_init (GTypeInstance *instance, gpointer g_class);
typedef struct _ModestTnySendQueuePrivate ModestTnySendQueuePrivate;
struct _ModestTnySendQueuePrivate {
- TnyTransportAccount *account;
- GThread *flush_outbox_thread;
- GMutex *flush_lock;
-
+ TnyCamelTransportAccount *account;
};
#define MODEST_TNY_SEND_QUEUE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_TNY_SEND_QUEUE, \
ModestTnySendQueuePrivate))
/* globals */
-static GObjectClass *parent_class = NULL;
+static TnyCamelSendQueueClass *parent_class = NULL;
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
/*
* this thread actually tries to send all the mails in the outbox
*/
-static void
-flush_outbox_thread (TnySendQueue *self)
-{
- TnyFolder *outbox, *sentbox;
- TnyMsg *msg;
- TnyHeader *header;
-
- TnyList *headers;
- TnyIterator *iter;
-
- ModestTnySendQueuePrivate *priv;
-
- priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
-
- outbox = tny_send_queue_get_outbox (self);
- sentbox = tny_send_queue_get_sentbox (self);
-
- headers = tny_simple_list_new ();
-
- g_mutex_lock (priv->flush_lock);
- tny_folder_get_headers (outbox, headers, TRUE, NULL); /* FIXME: err */
- iter = tny_list_create_iterator (headers);
-
- while (!tny_iterator_is_done (iter)) {
- header = TNY_HEADER(tny_iterator_get_current(iter));
- msg = tny_folder_get_msg (outbox, header, NULL);
- tny_transport_account_send (priv->account,
- msg, NULL); /* FIXME: err */
- tny_folder_add_msg (sentbox, msg, NULL); /* FIXME: err */
- tny_folder_remove_msg (outbox, header, NULL); /* FIXME: err */
-
- g_object_unref (G_OBJECT(header));
- g_object_unref (G_OBJECT(msg));
-
- tny_iterator_next (iter);
- }
-
-
- g_object_unref (G_OBJECT(headers));
- g_object_unref (G_OBJECT(iter));
-
- priv->flush_outbox_thread = NULL;
- g_mutex_unlock (priv->flush_lock);
-
- g_thread_exit (NULL);
-}
static void
modest_tny_send_queue_cancel (TnySendQueue *self, gboolean remove)
{
- MODEST_TNY_SEND_QUEUE_GET_CLASS(self)->cancel_func (self, remove);
+ TNY_CAMEL_SEND_QUEUE_GET_CLASS(parent_class)->cancel_func (self, remove);
}
static void
modest_tny_send_queue_add (TnySendQueue *self, TnyMsg *msg)
{
- MODEST_TNY_SEND_QUEUE_GET_CLASS(self)->add_func (self, msg);
-}
-
-
-static TnyFolder*
-modest_tny_send_queue_get_sentbox (TnySendQueue *self)
-{
- return MODEST_TNY_SEND_QUEUE_GET_CLASS(self)->get_sentbox_func (self);
-}
-
-
-static TnyFolder*
-modest_tny_send_queue_get_outbox (TnySendQueue *self)
-{
- return MODEST_TNY_SEND_QUEUE_GET_CLASS(self)->get_outbox_func (self);
-}
-
-
-
-
-static void
-modest_tny_send_queue_cancel_default (TnySendQueue *self, gboolean remove)
-{
- /* FIXME */
-}
-
-
-static void
-modest_tny_send_queue_add_default (TnySendQueue *self, TnyMsg *msg)
-{
ModestTnySendQueuePrivate *priv;
- TnyFolder *outbox;
g_return_if_fail (self);
g_return_if_fail (TNY_IS_CAMEL_MSG(msg));
priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
-
- outbox = tny_send_queue_get_outbox (self);
- tny_folder_add_msg (outbox, msg, NULL);
- priv->flush_outbox_thread = g_thread_create (
- (GThreadFunc)flush_outbox_thread,
- self, FALSE, NULL);
+ /* FIXME: do something smart here... */
+
+ TNY_CAMEL_SEND_QUEUE_GET_CLASS(parent_class)->add_func (self, msg);
}
static TnyFolder*
-modest_tny_send_queue_get_sentbox_default (TnySendQueue *self)
+modest_tny_send_queue_get_sentbox (TnySendQueue *self)
{
ModestTnySendQueuePrivate *priv;
static TnyFolder*
-modest_tny_send_queue_get_outbox_default (TnySendQueue *self)
+modest_tny_send_queue_get_outbox (TnySendQueue *self)
{
ModestTnySendQueuePrivate *priv;
{
static GType my_type = 0;
- if (G_UNLIKELY (!camel_type_init_done)) {
- if (!g_thread_supported ())
- g_thread_init (NULL);
- camel_type_init ();
- camel_type_init_done = TRUE;
- }
-
- if (!my_type) {
+ if (my_type == 0) {
static const GTypeInfo my_info = {
sizeof(ModestTnySendQueueClass),
NULL, /* base init */
NULL, /* class finalize */
NULL, /* class data */
sizeof(ModestTnySendQueue),
- 1, /* n_preallocs */
+ 0, /* n_preallocs */
(GInstanceInitFunc) modest_tny_send_queue_instance_init,
NULL
};
-
- static const GInterfaceInfo tny_send_queue_info = {
- (GInterfaceInitFunc) modest_tny_send_queue_init,
- /* interface_init */
- NULL, /* interface_finalize */
- NULL /* interface_data */
- };
-
my_type = g_type_register_static (G_TYPE_OBJECT,
"ModestTnySendQueue",
- &my_info, 0);
- g_type_add_interface_static (my_type, TNY_TYPE_SEND_QUEUE,
- &tny_send_queue_info);
+ &my_info, 0);
}
-
return my_type;
}
static void
-modest_tny_send_queue_init (gpointer g, gpointer iface_data)
-{
- TnySendQueueIface *klass = (TnySendQueueIface*)g;
-
- klass->add_func = modest_tny_send_queue_add;
- klass->get_outbox_func = modest_tny_send_queue_get_outbox;
- klass->get_sentbox_func = modest_tny_send_queue_get_sentbox;
- klass->cancel_func = modest_tny_send_queue_cancel;
-}
-
-
-
-static void
modest_tny_send_queue_class_init (ModestTnySendQueueClass *klass)
{
GObjectClass *gobject_class;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = modest_tny_send_queue_finalize;
- klass->add_func = modest_tny_send_queue_add_default;
- klass->get_outbox_func = modest_tny_send_queue_get_outbox_default;
- klass->get_sentbox_func = modest_tny_send_queue_get_sentbox_default;
- klass->cancel_func = modest_tny_send_queue_cancel_default;
+ parent_class->add_func = modest_tny_send_queue_add;
+ parent_class->get_outbox_func = modest_tny_send_queue_get_outbox;
+ parent_class->get_sentbox_func = modest_tny_send_queue_get_sentbox;
+ parent_class->cancel_func = modest_tny_send_queue_cancel;
g_type_class_add_private (gobject_class, sizeof(ModestTnySendQueuePrivate));
}
self = (ModestTnySendQueue*)instance;
priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
- priv->flush_lock = g_mutex_new ();
- priv->flush_outbox_thread = NULL;
priv->account = NULL;
}
priv->account = NULL;
}
- if (priv->flush_lock) {
- g_mutex_free (priv->flush_lock);
- priv->flush_lock = NULL;
- }
-
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
ModestTnySendQueue*
-modest_tny_send_queue_new (TnyTransportAccount *account)
+modest_tny_send_queue_new (TnyCamelTransportAccount *account)
{
ModestTnySendQueue *self;
ModestTnySendQueuePrivate *priv;
- g_return_val_if_fail (account, NULL);
+ g_return_val_if_fail (TNY_IS_CAMEL_TRANSPORT_ACCOUNT(account), NULL);
self = MODEST_TNY_SEND_QUEUE(g_object_new(MODEST_TYPE_TNY_SEND_QUEUE, NULL));
priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
#include <glib.h>
#include <glib-object.h>
#include <tny-send-queue.h>
+#include <tny-camel-send-queue.h>
#include <tny-msg.h>
#include <tny-camel-transport-account.h>
typedef struct _ModestTnySendQueueClass ModestTnySendQueueClass;
struct _ModestTnySendQueue {
- GObject parent;
+ TnyCamelSendQueue parent;
};
struct _ModestTnySendQueueClass {
- GObjectClass parent_class;
-
- void (*add_func) (TnySendQueue *self, TnyMsg *msg);
- TnyFolder* (*get_sentbox_func) (TnySendQueue *self);
- TnyFolder* (*get_outbox_func) (TnySendQueue *self);
- void (*cancel_func) (TnySendQueue *self, gboolean remove);
+ TnyCamelSendQueueClass parent_class;
};
-/* member functions */
+/**
+ * modest_tny_send_queue_get_type:
+ *
+ * get the #GType for #ModestTnySendQueue
+ *
+ * Returns: the #GType
+ */
GType modest_tny_send_queue_get_type (void) G_GNUC_CONST;
-/* typical parameter-less _new function */
-/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
-ModestTnySendQueue* modest_tny_send_queue_new (TnyTransportAccount *account);
+
+/**
+ * modest_tny_send_queue_new:
+ * @account: a valid camel transport account
+ *
+ * create a new modest #ModestTnySendQueue object.
+ *
+ * Returns: a new #ModestTnySendQueue instance, or NULL in case
+ * of any error
+ */
+ModestTnySendQueue* modest_tny_send_queue_new (TnyCamelTransportAccount *account);
G_END_DECLS
if (type == TNY_FOLDER_TYPE_ROOT) {
/* the account name is also the name of the root folder
* in case of local folders */
- if (strcmp (name1, MODEST_LOCAL_FOLDERS_ACCOUNT_NAME) == 0)
+ if (name1 && strcmp (name1, MODEST_LOCAL_FOLDERS_ACCOUNT_NAME) == 0)
cmp = +1;
- else if (strcmp (name2, MODEST_LOCAL_FOLDERS_ACCOUNT_NAME) == 0)
+ else if (name2 && strcmp (name2, MODEST_LOCAL_FOLDERS_ACCOUNT_NAME) == 0)
cmp = -1;
else
cmp = modest_text_utils_utf8_strcmp (name1, name2, TRUE);
* modest_folder_view_update_model:
* @self: a #ModestFolderView
*
- * returns a new reference to the #TnyFolder that is already selected
+ * refresh the current model
*
* Returns: the selected folder or NULL if none is selected
**/
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#include <modest-header-view.h>
#include <modest-header-view-priv.h>
#include <modest-icon-names.h>
if (!icon_cache || !g_hash_table_lookup_extended (icon_cache, name, &orig_key,&pixbuf)) {
pixbuf = (gpointer)gdk_pixbuf_new_from_file (name, &err);
if (!pixbuf) {
- g_printerr ("modest: error in icon factory while loading '%s': %s\n",
+ g_printerr ("modest: error while loading '%s': %s\n",
name, err->message);
g_error_free (err);
}
static gint cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2,
gpointer user_data);
-#define MODEST_HEADER_VIEW_PTR "modest-header-view"
-
-enum {
- HEADER_SELECTED_SIGNAL,
- ITEM_NOT_FOUND_SIGNAL,
- STATUS_UPDATE_SIGNAL,
- LAST_SIGNAL
-};
-
typedef struct _ModestHeaderViewPrivate ModestHeaderViewPrivate;
struct _ModestHeaderViewPrivate {
MODEST_TYPE_HEADER_VIEW, \
ModestHeaderViewPrivate))
+
+
+#define MODEST_HEADER_VIEW_PTR "modest-header-view"
+
+enum {
+ HEADER_SELECTED_SIGNAL,
+ ITEM_NOT_FOUND_SIGNAL,
+ STATUS_UPDATE_SIGNAL,
+ LAST_SIGNAL
+};
+
/* globals */
static GObjectClass *parent_class = NULL;