* modest-tny-account-store:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sun, 11 Mar 2007 10:17:55 +0000 (10:17 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sun, 11 Mar 2007 10:17:55 +0000 (10:17 +0000)
- implement the new find_account_func in the TnyAccountStore interface
  this is to find the account for a mail, based on its URL

pmo-trunk-r898

src/modest-tny-account-store.c

index 03b1e50..880eb30 100644 (file)
@@ -560,6 +560,41 @@ modest_tny_account_store_get_device (TnyAccountStore *self)
 }
 
 
 }
 
 
+static TnyAccount*
+modest_tny_account_store_find_account_by_url (TnyAccountStore *self, const gchar* url_string)
+{
+       TnyAccount *account = NULL;
+       ModestTnyAccountStorePrivate *priv;     
+       GSList *cursor;
+       
+       g_return_val_if_fail (self, NULL);
+       g_return_val_if_fail (url_string, NULL);
+       
+       priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
+       for (cursor = priv->store_accounts; cursor ; cursor = cursor->next) {
+               if (tny_account_matches_url_string (TNY_ACCOUNT(cursor->data), url_string)) {
+                       account = TNY_ACCOUNT(cursor->data);
+                       break;
+               }
+       }
+
+       if (!account) {
+               for (cursor = priv->transport_accounts; !account && cursor ; cursor = cursor->next) {
+                       if (tny_account_matches_url_string (TNY_ACCOUNT(cursor->data), url_string)) {
+                               account = TNY_ACCOUNT(cursor->data);
+                               break;
+                       }
+               }
+       }
+
+       if (account)
+               g_object_ref (G_OBJECT(account));
+
+       return account;
+}
+
+
 
 static gboolean
 modest_tny_account_store_alert (TnyAccountStore *self, TnyAlertType type,
 
 static gboolean
 modest_tny_account_store_alert (TnyAccountStore *self, TnyAlertType type,
@@ -636,6 +671,8 @@ modest_tny_account_store_init (gpointer g, gpointer iface_data)
                modest_tny_account_store_get_device;
        klass->alert_func =
                modest_tny_account_store_alert;
                modest_tny_account_store_get_device;
        klass->alert_func =
                modest_tny_account_store_alert;
+       klass->find_account_func =
+               modest_tny_account_store_find_account_by_url;
 }
 
 void
 }
 
 void