2007-06-13 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Wed, 13 Jun 2007 12:50:33 +0000 (12:50 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Wed, 13 Jun 2007 12:50:33 +0000 (12:50 +0000)
* libmodest-dbus-client/libmodest-dbus-client.c:
        (libmodest_dbus_client_send_mail), (libmodest_dbus_client_mail_to),
        (libmodest_dbus_client_compose_mail),
        (libmodest_dbus_client_open_message),
        (libmodest_dbus_client_send_and_receive),
        (libmodest_dbus_client_open_default_inbox):  Improved debug messages.

        * src/dbus_api/modest-dbus-callbacks.c: (find_message_by_url),
        (on_idle_open_message), (modest_dbus_req_handler),
        (search_result_to_message), (modest_dbus_req_filter):
        * src/modest-search.c: (add_hit), (modest_search_folder),
        (modest_search_all_accounts): Improved debug messages.

        * tests/dbus_api/test_open_message.c: (main): Improved comments.

        * src/modest-tny-account-store.c:
        (modest_tny_account_store_get_tny_account_by): Initialize a variable to
        fix the build.

pmo-trunk-r2202

ChangeLog2
libmodest-dbus-client/libmodest-dbus-client.c
src/dbus_api/modest-dbus-callbacks.c
src/modest-search.c
src/modest-tny-account-store.c
tests/dbus_api/test_open_message.c

index a9b5088..3d85fe2 100644 (file)
@@ -1,3 +1,27 @@
+2007-06-13  Murray Cumming  <murrayc@murrayc.com>
+
+       * libmodest-dbus-client/libmodest-dbus-client.c:
+       (libmodest_dbus_client_send_mail), (libmodest_dbus_client_mail_to),
+       (libmodest_dbus_client_compose_mail),
+       (libmodest_dbus_client_open_message),
+       (libmodest_dbus_client_send_and_receive),
+       (libmodest_dbus_client_open_default_inbox):  Improved debug messages.
+       
+       * src/dbus_api/modest-dbus-callbacks.c: (find_message_by_url),
+       (on_idle_open_message), (modest_dbus_req_handler),
+       (search_result_to_message), (modest_dbus_req_filter):
+       * src/modest-search.c: (add_hit), (modest_search_folder),
+       (modest_search_all_accounts): Improved debug messages.
+       
+       * tests/dbus_api/test_open_message.c: (main): Improved comments.
+       
+       * src/modest-tny-account-store.c:
+       (modest_tny_account_store_get_tny_account_by): Initialize a variable to 
+       fix the build.
+
+2007-06-13  Murray Cumming  <murrayc@murrayc.com>
+
+
 2007-06-12  Murray Cumming  <murrayc@murrayc.com>
 
        * src/modest-tny-account-store.c: (get_server_accounts):
index 8c89c45..6e25703 100644 (file)
@@ -69,10 +69,10 @@ libmodest_dbus_client_send_mail (osso_context_t *osso_context, const gchar *to,
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
-               printf("debug: osso_rpc_run() failed.\n");
+               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
                return FALSE;
        } else {
-               printf("debug: osso_rpc_run() succeeded.\n");
+               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
        }
        
        osso_rpc_free_val(&retval);
@@ -91,10 +91,10 @@ libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
-               printf("debug: osso_rpc_run() failed.\n");
+               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
                return FALSE;
        } else {
-               printf("debug: osso_rpc_run() succeeded.\n");
+               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
        }
        
        osso_rpc_free_val(&retval);
@@ -135,10 +135,10 @@ libmodest_dbus_client_compose_mail (osso_context_t *osso_context, const gchar *t
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
-               printf("debug: osso_rpc_run() failed.\n");
+               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
                return FALSE;
        } else {
-               printf("debug: osso_rpc_run() succeeded.\n");
+               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
        }
        
        osso_rpc_free_val(&retval);
@@ -147,7 +147,7 @@ libmodest_dbus_client_compose_mail (osso_context_t *osso_context, const gchar *t
 }
 
 /**
- * libmodest_dbus_client_dopen_message:
+ * libmodest_dbus_client_open_message:
  * @osso_context: a valid #osso_context_t object.
  * @msg_uri: A valid url to a mail
  *
@@ -169,10 +169,10 @@ libmodest_dbus_client_open_message (osso_context_t *osso_context, const gchar *m
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
-               printf("debug: osso_rpc_run() failed.\n");
+               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
                return FALSE;
        } else {
-               printf("debug: osso_rpc_run() succeeded.\n");
+               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
        }
        
        osso_rpc_free_val(&retval);
@@ -190,10 +190,10 @@ libmodest_dbus_client_send_and_receive (osso_context_t *osso_context)
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
-               printf("debug: osso_rpc_run() failed.\n");
+               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
                return FALSE;
        } else {
-               printf("debug: osso_rpc_run() succeeded.\n");
+               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
        }
        
        osso_rpc_free_val(&retval);
@@ -211,10 +211,10 @@ libmodest_dbus_client_open_default_inbox (osso_context_t *osso_context)
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
-               printf("debug: osso_rpc_run() failed.\n");
+               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
                return FALSE;
        } else {
-               printf("debug: osso_rpc_run() succeeded.\n");
+               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
        }
        
        osso_rpc_free_val(&retval);
index ee4419a..2f1a3ac 100644 (file)
@@ -521,7 +521,6 @@ static gint on_compose_mail(GArray * arguments, gpointer data, osso_rpc_t * retv
 static TnyMsg *
 find_message_by_url (const char *uri, TnyAccount **ac_out)
 {
-
        ModestTnyAccountStore *astore;
        TnyAccount            *account;
        TnyFolder             *folder;
@@ -536,23 +535,22 @@ find_message_by_url (const char *uri, TnyAccount **ac_out)
        if (astore == NULL) {
                return NULL;
        }
-       
-       g_debug ("Got AccountStore, lets go");
 
        account = tny_account_store_find_account (TNY_ACCOUNT_STORE (astore),
                                                  uri);
        
        if (account == NULL) {
+               g_debug ("%s: tny_account_store_find_account() failed.\n", __FUNCTION__);
                return NULL;
        }
 
-       g_debug ("Found account");
+       g_debug ("%s: Found account.\n", __FUNCTION__);
 
        if ( ! TNY_IS_STORE_ACCOUNT (account)) {
                goto out;
        }
 
-       g_debug ("Account is store account");
+       g_debug ("%s: Account is store account.\n", __FUNCTION__);
 
        *ac_out = account;
 
@@ -561,12 +559,17 @@ find_message_by_url (const char *uri, TnyAccount **ac_out)
                                                NULL);
 
        if (folder == NULL) {
+               g_debug ("%s: tny_store_account_find_folder() failed.\n", __FUNCTION__);
                goto out;
        }
-       g_debug ("Found folder");
+       g_debug ("%s: Found folder.\n",  __FUNCTION__);
        
 
        msg = tny_folder_find_msg (folder, uri, NULL);
+       
+       if (!msg) {
+               g_debug ("%s: tny_folder_find_msg() failed.\n", __FUNCTION__);
+       }
 
 out:
        if (account && !msg) {
@@ -594,14 +597,15 @@ on_idle_open_message (gpointer user_data)
        
        uri = (char *) user_data;
 
-       g_debug ("Trying to find msg by url: %s", uri); 
+       g_debug ("%s: Trying to find msg by url: %s", __FUNCTION__, uri);       
        msg = find_message_by_url (uri, &account);
        g_free (uri);
 
        if (msg == NULL) {
+               g_debug ("  %s: message not found.", __FUNCTION__);
                return FALSE;
        }
-       g_debug ("Found message");
+       g_debug ("  %s: Found message.", __FUNCTION__);
 
        header = tny_msg_get_header (msg);
        account_name = tny_account_get_name (account);
@@ -801,8 +805,8 @@ gint modest_dbus_req_handler(const gchar * interface, const gchar * method,
                       osso_rpc_t * retval)
 {
        
-       g_debug ("modest_dbus_req_handler()\n");
-       g_debug ("debug: method received: %s\n", method);
+       g_debug ("debug: %s\n", __FUNCTION__);
+       g_debug ("debug: %s: method received: %s\n", __FUNCTION__, method);
        
        if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_SEND_MAIL) == 0) {
                return on_send_mail (arguments, data, retval);
@@ -841,7 +845,7 @@ gint modest_dbus_req_handler(const gchar * interface, const gchar * method,
        DBUS_STRUCT_END_CHAR_AS_STRING
 
 static DBusMessage *
-search_result_to_messsage (DBusMessage *reply,
+search_result_to_message (DBusMessage *reply,
                           GList       *hits)
 {
        DBusMessageIter iter;
@@ -877,7 +881,7 @@ search_result_to_messsage (DBusMessage *reply,
                is_unread      = hit->is_unread;
                ts             = hit->timestamp;
 
-               g_debug ("Adding hit: %s", msg_url);    
+               g_debug ("DEBUG: %s: Adding hit: %s", __FUNCTION__, msg_url);   
                
                dbus_message_iter_open_container (&array_iter,
                                                  DBUS_TYPE_STRUCT,
@@ -1030,7 +1034,7 @@ modest_dbus_req_filter (DBusConnection *con,
 
                reply = dbus_message_new_method_return (message);
 
-               search_result_to_messsage (reply, hits);
+               search_result_to_message (reply, hits);
 
                if (reply == NULL) {
                        g_warning ("Could not create reply");
index c8d82c0..60a15bf 100644 (file)
@@ -79,8 +79,21 @@ add_hit (GList *list, TnyHeader *header, TnyFolder *folder)
        hit = g_slice_new0 (ModestSearchHit);
 
        furl = tny_folder_get_url_string (folder);
+       if (!furl) {
+               g_warning ("%s: tny_folder_get_url_string(): returned NULL for folder. Folder name=%s\n", __FUNCTION__, tny_folder_get_name (folder));
+       }
+       
+       /* Make sure that we use the short UID instead of the long UID,
+        * and/or find out what UID form is used when finding, in camel_data_cache_get().
+        * so we can find what we get. Philip is working on this.
+        */
        uid = tny_header_get_uid (header);
+       if (!furl) {
+               g_warning ("%s: tny_header_get_uid(): returned NULL for message with subject=%s\n", __FUNCTION__, tny_header_get_subject (header));
+       }
+       
        msg_url = g_strdup_printf ("%s/%s", furl, uid);
+       
        subject = tny_header_get_subject (header);
        sender = tny_header_get_from (header);
 
@@ -89,12 +102,12 @@ add_hit (GList *list, TnyHeader *header, TnyFolder *folder)
        hit->msgid = msg_url;
        hit->subject = g_strdup_or_null (subject);
        hit->sender = g_strdup_or_null (sender);
-       hit->folder = furl;
+       hit->folder = furl; /* We just provide our new instance instead of copying it and freeing it. */
        hit->msize = tny_header_get_message_size (header);
        hit->has_attachment = flags & TNY_HEADER_FLAG_ATTACHMENTS;
        hit->is_unread = ! (flags & TNY_HEADER_FLAG_SEEN);
        hit->timestamp = tny_header_get_date_received (header);
-
+       
        return g_list_prepend (list, hit);
 }
 
@@ -378,7 +391,7 @@ modest_search_folder (TnyFolder *folder, ModestSearch *search)
                        msg = tny_folder_get_msg (folder, cur, &err);
 
                        if (err != NULL || msg == NULL) {
-                               g_warning ("Could not get message\n");
+                               g_warning ("%s: Could not get message.\n", __FUNCTION__);
                                g_error_free (err);
 
                                if (msg) {
@@ -489,8 +502,8 @@ modest_search_all_accounts (ModestSearch *search)
 
                account = TNY_ACCOUNT (tny_iterator_get_current (iter));
 
-               g_debug ("Searching account %s",
-                        tny_account_get_name (account));
+               g_debug ("DEBUG: %s: Searching account %s",
+                        __FUNCTION__, tny_account_get_name (account));
                res = modest_search_account (account, search);
                
                if (res != NULL) {
index 2b82794..5b85b37 100644 (file)
@@ -1099,7 +1099,7 @@ modest_tny_account_store_get_tny_account_by (ModestTnyAccountStore *self,
        TnyAccount *account = NULL;
        ModestTnyAccountStorePrivate *priv;     
        GSList *cursor;
-       const gchar *val;
+       const gchar *val = NULL;
 
        g_return_val_if_fail (self, NULL);
        g_return_val_if_fail (str, NULL);
@@ -1119,6 +1119,7 @@ modest_tny_account_store_get_tny_account_by (ModestTnyAccountStore *self,
                        val = tny_account_get_url_string (TNY_ACCOUNT(cursor->data));
                        break;
                }
+               
                if (type == MODEST_TNY_ACCOUNT_STORE_QUERY_URL && 
                    tny_account_matches_url_string (TNY_ACCOUNT(cursor->data), val)) {
                        account = TNY_ACCOUNT (cursor->data);
@@ -1144,6 +1145,7 @@ modest_tny_account_store_get_tny_account_by (ModestTnyAccountStore *self,
                        val = tny_account_get_url_string (TNY_ACCOUNT(cursor->data));
                        break;
                }
+               
                if (type == MODEST_TNY_ACCOUNT_STORE_QUERY_URL && 
                    tny_account_matches_url_string (TNY_ACCOUNT(cursor->data), val)) {
                        account = TNY_ACCOUNT (cursor->data);
index e518ddf..195b8ab 100644 (file)
@@ -18,10 +18,16 @@ main (int argc, char *argv[])
            return -1;
        }
        
+       /* For instance, 
+        * "pop://murray.cumming%40gmail.com@pop.gmail.com:995/;use_ssl=wrapped/inbox/GmailId112e166949157685"
+        */
        if (argc == 2) {
                url = argv[1];
        } else {
-               url = "local://???FIXME???";
+               /* TODO: Add some test DBus method to get a valid URL for a message, 
+                * just so we can test this method. */
+               g_printerr ("No email URL argument supplied on the command line.\n");
+               return -1;
        }
 
        g_print ("Trying to open msg: %s\n", url);