From b1cec3747cf43a5919fdd104166d0a3213256554 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Thu, 14 Oct 2004 21:03:42 +0000 Subject: [PATCH] Fixed SSL compilation, a compiler warning, and eliminated a crashing bug that would happen on connection timeouts or failures. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9362 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../inbound_protocols/imap/imap_client.cpp | 18 ++++++++++++------ .../inbound_protocols/imap/imap_config.cpp | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) 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