diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp index 733279fc0d..a252dc8cd5 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp @@ -118,12 +118,14 @@ class NoopWorker : public BHandler { time_t last_run; }; -IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BMailRemoteStorageProtocol(settings,run), commandCount(0), net(-1), selected_mb(""), noop(NULL), force_reselect(false) { +IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BMailRemoteStorageProtocol(settings,run), noop(NULL), commandCount(0), net(-1), selected_mb(""), force_reselect(false) { err = B_OK; mb_root = settings->FindString("root"); #ifdef USESSL use_ssl = (settings->FindInt32("flavor") == 1); + ssl = NULL; + ctx = NULL; #endif int port = settings->FindInt32("port"); @@ -270,9 +272,11 @@ IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BMailRemot } IMAP4Client::~IMAP4Client() { - if (selected_mb != "") - SendCommand("CLOSE"); - SendCommand("LOGOUT"); + if (net > 0) { + if (selected_mb != "") + SendCommand("CLOSE"); + SendCommand("LOGOUT"); + } for (int32 i = 0; i < box_info.CountItems(); i++) delete (struct mailbox_info *)(box_info.ItemAt(i)); @@ -281,8 +285,10 @@ IMAP4Client::~IMAP4Client() { #ifdef USESSL if (use_ssl) { - SSL_shutdown(ssl); - SSL_CTX_free(ctx); + if (ssl) + SSL_shutdown(ssl); + if (ctx) + SSL_CTX_free(ctx); } #endif diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp index a7def77b02..b0d7863810 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp @@ -21,11 +21,11 @@ class IMAPConfig : public BMailProtocolConfigView { IMAPConfig::IMAPConfig(BMessage *archive) : BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME | B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER - #ifdef IMAPSSL + #ifdef USESSL | B_MAIL_PROTOCOL_HAS_FLAVORS) { AddFlavor("Unencrypted"); - AddFlavor("IMAP-SSL"); + AddFlavor("SSL"); #else ) { #endif