- /* Get the server name: */
- server_account =
- TNY_TRANSPORT_ACCOUNT (tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self)));
- if (server_account)
- server_name = tny_account_get_hostname (TNY_ACCOUNT (server_account));
- else
- g_return_if_reached ();
+ /* Get the server name. Note that we could be using a
+ connection specific transport account */
+ transport = (TnyTransportAccount *)
+ tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self));
+ if (transport) {
+ ModestTnyAccountStore *acc_store;
+ const gchar *acc_name;
+ TnyTransportAccount *conn_specific;
+
+ acc_store = modest_runtime_get_account_store();
+ acc_name = modest_tny_account_get_parent_modest_account_name_for_server_account (TNY_ACCOUNT (transport));
+ conn_specific = (TnyTransportAccount *)
+ modest_tny_account_store_get_transport_account_for_open_connection (acc_store, acc_name);
+ if (conn_specific) {
+ server_name = tny_account_get_hostname (TNY_ACCOUNT (conn_specific));
+ g_object_unref (conn_specific);
+ } else {
+ server_name = tny_account_get_hostname (TNY_ACCOUNT (transport));
+ }
+ g_object_unref (transport);
+ }
+
+ /* Get protocol */
+ protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ tny_account_get_proto (TNY_ACCOUNT (transport)));
+ if (!protocol) {
+ g_warning ("%s: Account with no proto", __FUNCTION__);
+ return;
+ }