+static gboolean account_is_multimailbox (const gchar *account_name, ModestProtocol **mmb_protocol)
+{
+ gchar *transport_account;
+ gboolean result = FALSE;
+
+ if (mmb_protocol)
+ *mmb_protocol = NULL;
+
+ transport_account = modest_account_mgr_get_server_account_name (modest_runtime_get_account_mgr (),
+ account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+ if (transport_account) {
+ gchar *proto;
+ ModestProtocolRegistry *registry;
+
+ registry = modest_runtime_get_protocol_registry ();
+
+ proto = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), transport_account,
+ MODEST_ACCOUNT_PROTO, TRUE);
+ if (proto != NULL) {
+ ModestProtocol *protocol =
+ modest_protocol_registry_get_protocol_by_name (registry,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
+ proto);
+ if (protocol &&
+ modest_protocol_registry_protocol_type_has_tag
+ (registry,
+ modest_protocol_get_type_id (protocol),
+ MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS)) {
+ if (mmb_protocol)
+ *mmb_protocol = protocol;
+ result = TRUE;
+ }
+
+ }
+ }
+
+ return result;
+}
+
+static gchar *
+multimailbox_get_default_mailbox (const gchar *account_name)
+{
+ gchar *transport_account;
+ gchar *result = NULL;
+
+ transport_account = modest_account_mgr_get_server_account_name (modest_runtime_get_account_mgr (),
+ account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+ if (transport_account) {
+ gchar *proto;
+ ModestProtocolRegistry *registry;
+
+ registry = modest_runtime_get_protocol_registry ();
+
+ proto = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), transport_account,
+ MODEST_ACCOUNT_PROTO, TRUE);
+ if (proto != NULL) {
+ ModestProtocol *protocol =
+ modest_protocol_registry_get_protocol_by_name (registry,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
+ proto);
+ if (MODEST_ACCOUNT_PROTOCOL (protocol)) {
+ ModestPairList *pair_list;
+
+ pair_list = modest_account_protocol_get_from_list (MODEST_ACCOUNT_PROTOCOL (protocol),
+ account_name);
+ if (pair_list) {
+ ModestPair *pair = (ModestPair *) pair_list->data;
+ result = g_strdup ((const gchar *) pair->first);
+ modest_pair_list_free (pair_list);
+ }
+ }
+
+ }
+ }
+
+ return result;
+}