+
+static TnyAccount*
+get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *self,
+ const gchar *account_name)
+{
+ /* Get the current connection: */
+ TnyDevice *device = modest_runtime_get_device ();
+
+ if (!tny_device_is_online (device))
+ return NULL;
+
+#ifdef MODEST_PLATFORM_MAEMO
+ g_assert (TNY_IS_MAEMO_CONIC_DEVICE (device));
+ TnyMaemoConicDevice *maemo_device = TNY_MAEMO_CONIC_DEVICE (device);
+ const gchar* iap_id = tny_maemo_conic_device_get_current_iap_id (maemo_device);
+ /* printf ("DEBUG: %s: iap_id=%s\n", __FUNCTION__, iap_id); */
+ if (!iap_id)
+ return NULL;
+
+ ConIcIap* connection = tny_maemo_conic_device_get_iap (maemo_device, iap_id);
+ if (!connection)
+ return NULL;
+
+ const gchar *connection_name = con_ic_iap_get_name (connection);
+ /* printf ("DEBUG: %s: connection_name=%s\n", __FUNCTION__, connection_name); */
+ if (!connection_name)
+ return NULL;
+
+ /* Get the connection-specific transport acccount, if any: */
+ ModestAccountMgr *account_manager = modest_runtime_get_account_mgr ();
+ gchar* server_account_name = modest_account_mgr_get_connection_specific_smtp (account_manager,
+ account_name, connection_name);
+
+ /* printf ("DEBUG: %s: server_account_name=%s\n", __FUNCTION__, server_account_name); */
+ if (!server_account_name) {
+ return NULL; /* No connection-specific SMTP server was specified for this connection. */
+ }
+
+ TnyAccount* account = modest_tny_account_store_get_tny_account_by_id (self, server_account_name);
+
+ /* printf ("DEBUG: %s: account=%p\n", __FUNCTION__, account); */
+ g_free (server_account_name);
+
+ /* Unref the get()ed object, as required by the tny_maemo_conic_device_get_iap() documentation. */
+ g_object_unref (connection);
+
+ return account;
+#else
+ return NULL; /* TODO: Implement this for GNOME, instead of just Maemo? */
+#endif /* MODEST_PLATFORM_MAEMO */
+}
+
+
+TnyAccount*
+modest_tny_account_store_get_transport_account_for_open_connection (ModestTnyAccountStore *self,
+ const gchar *account_name)
+{
+ /* Get the connection-specific transport acccount, if any: */
+ TnyAccount *account = get_smtp_specific_transport_account_for_open_connection (self, account_name);
+
+ /* If there is no connection-specific transport account (the common case),
+ * just get the regular transport account: */
+ if (!account) {
+ /* printf("DEBUG: %s: using regular transport account for account %s.\n", __FUNCTION__, account_name); */
+ account = modest_tny_account_store_get_tny_account_by_account (self, account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+ }
+
+ return account;
+}
+
+gboolean modest_tny_folder_store_is_virtual_local_folders (TnyFolderStore *self)
+{
+ /* We should make this more sophisticated if we ever use ModestTnySimpleFolderStore
+ * for anything else. */
+ return MODEST_IS_TNY_SIMPLE_FOLDER_STORE (self);
+}