return OSSO_OK;
}
-
static TnyMsg *
find_message_by_url (const char *uri, TnyAccount **ac_out)
{
return NULL;
}
+ if (uri && g_str_has_prefix (uri, "merge://")) {
+ /* we assume we're talking about outbox folder, as this
+ * is the only merge folder we work with in modest */
+ return modest_tny_account_store_find_msg_in_outboxes (astore, uri, ac_out);
+ }
+
printf ("DEBUG: %s: uri=%s\n", __FUNCTION__, uri);
/* TODO: When tinymail is built with the extra DBC assertion checks,
* this will crash for local folders (such as drafts),
* Note that we don't copy the strings,
* because this struct will only be used for the lifetime of this function.
*/
- search.folder = folder;
+ if (folder && g_str_has_prefix (folder, "MAND:")) {
+ search.folder = folder + strlen ("MAND:");
+ } else if (folder && g_str_has_prefix (folder, "USER:")) {
+ search.folder = folder + strlen ("USER:");
+ } else {
+ search.folder = folder;
+ }
/* Remember the text to search for: */
#ifdef MODEST_HAVE_OGS
return;
if (TNY_IS_MERGE_FOLDER (folder)) {
+ const gchar * folder_name;
/* Ignore these because their IDs ares
* a) not always unique or sensible.
* b) not human-readable, and currently need a human-readable
* We could hack our D-Bus API to understand "outbox" as the merged outboxes,
* but that seems unwise. murrayc.
*/
- return;
+ folder_name = tny_folder_get_name (folder);
+ if (folder_name && !strcmp (folder_name, "Outbox")) {
+ *list = g_list_append(*list, g_strdup ("MAND:outbox"));
+ }
+ return;
}
/* Add this folder to the list: */
* TODO: osso-global search should probably be changed to
* take an ID and a Name.
*/
- const gchar * id = tny_folder_get_id (folder);
- if (id && strlen(id))
- *list = g_list_append(*list, g_strdup (id));
+ const gchar * id = tny_folder_get_id (folder);
+ if (id && strlen(id)) {
+ const gchar *prefix = NULL;
+ TnyFolderType folder_type;
+
+ /* dbus global search api expects a prefix identifying the type of
+ * folder here. Mandatory folders should have MAND: prefix, and
+ * other user created folders should have USER: prefix
+ */
+ folder_type = modest_tny_folder_guess_folder_type (folder);
+ switch (folder_type) {
+ case TNY_FOLDER_TYPE_INBOX:
+ case TNY_FOLDER_TYPE_OUTBOX:
+ case TNY_FOLDER_TYPE_DRAFTS:
+ case TNY_FOLDER_TYPE_SENT:
+ case TNY_FOLDER_TYPE_ARCHIVE:
+ prefix = "MAND:";
+ break;
+ default:
+ prefix = "USER:";
+ }
+
+
+ *list = g_list_append(*list, g_strdup_printf ("%s%s", prefix, id));
+ }
/*
else {
g_warning ("DEBUG: %s: folder has no name or ID.\n", __FUNCTION__);
#include "modest-account-mgr.h"
#include "modest-tny-account-store.h"
#include "modest-tny-account.h"
+#include "modest-tny-folder.h"
#include "modest-search.h"
#include "modest-runtime.h"
#include "modest-platform.h"
/* Check that we should be searching this folder. */
/* Note that we don't try to search sub-folders.
* Maybe we should, but that should be specified. */
- if (search->folder && strlen (search->folder) && (strcmp (tny_folder_get_id (folder), search->folder) != 0))
- return NULL;
+ if (search->folder && strlen (search->folder)) {
+ if (!strcmp (search->folder, "outbox")) {
+ if (modest_tny_folder_guess_folder_type (folder) != TNY_FOLDER_TYPE_OUTBOX) {
+ return NULL;
+ }
+ } else if (strcmp (tny_folder_get_id (folder), search->folder) != 0) {
+ return NULL;
+ }
+ }
GList *retval = NULL;
TnyIterator *iter = NULL;
iter = g_slist_next (iter);
}
}
+
+TnyMsg *
+modest_tny_account_store_find_msg_in_outboxes (ModestTnyAccountStore *self,
+ const gchar *uri,
+ TnyAccount **ac_out)
+{
+ TnyIterator *acc_iter;
+ ModestTnyAccountStorePrivate *priv;
+ TnyMsg *msg = NULL;
+ TnyAccount *msg_account = NULL;
+
+ g_return_val_if_fail (MODEST_IS_TNY_ACCOUNT_STORE (self), NULL);
+ priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
+
+ acc_iter = tny_list_create_iterator (priv->store_accounts_outboxes);
+ while (!msg && !tny_iterator_is_done (acc_iter)) {
+ TnyList *folders = tny_simple_list_new ();
+ TnyAccount *account = TNY_ACCOUNT (tny_iterator_get_current (acc_iter));
+ TnyIterator *folders_iter = NULL;
+
+ tny_folder_store_get_folders (TNY_FOLDER_STORE (account), folders, NULL, NULL);
+ folders_iter = tny_list_create_iterator (folders);
+
+ while (msg == NULL && !tny_iterator_is_done (folders_iter)) {
+ TnyFolder *folder = TNY_FOLDER (tny_iterator_get_current (folders_iter));
+ msg = tny_folder_find_msg (folder, uri, NULL);
+
+ if (msg)
+ msg_account = g_object_ref (account);
+
+ g_object_unref (folder);
+ tny_iterator_next (folders_iter);
+ }
+
+ g_object_unref (folders);
+ g_object_unref (account);
+ tny_iterator_next (acc_iter);
+ }
+
+ g_object_unref (acc_iter);
+
+ if (ac_out != NULL)
+ *ac_out = msg_account;
+
+ return msg;
+}
**/
void modest_tny_account_store_forget_already_asked (ModestTnyAccountStore *self, TnyAccount *account);
+/**
+ * modest_tny_account_store_find_msg_in_outboxes:
+ * @self: a #ModestTnyAccountStore
+ * @uri: the uri of the message
+ * @ac_out: output attribute, %NULL, or the #TnyAccount of the message
+ *
+ * finds a message in the set of outboxes, using the uri.
+ *
+ * Returns: %NULL or a #TnyMsg
+ **/
+TnyMsg *modest_tny_account_store_find_msg_in_outboxes (ModestTnyAccountStore *self,
+ const gchar *uri,
+ TnyAccount **ac_out);
+
G_END_DECLS