* If USE_SSL is set when compiling the MDR add-ons, SSL will be used.
* By default, it will use a directory generated/cross-ssl where you need to unzip the optional openssl package into before. If you're on Haiku, you can use the SSL_DIR environment variable to point it to /boot/home/config instead. * Fixed build with USE_SSL defined. * Renamed USESSL to USE_SSL. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26971 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6a5919034d
commit
ad12e71861
@ -11,9 +11,14 @@ UsePrivateHeaders mail ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
|
||||
|
||||
if $(USESSL) {
|
||||
SubDirC++Flags -DUSESSL ;
|
||||
SubDirHdrs [ FDirName / boot home config include ] ;
|
||||
if $(USE_SSL) {
|
||||
SubDirC++Flags -DUSE_SSL ;
|
||||
if ! $(SSL_DIR) {
|
||||
sslDir = [ FDirName $(HAIKU_OUTPUT_DIR) cross-ssl config ] ;
|
||||
} else {
|
||||
sslDir = $(SSL_DIR) ;
|
||||
}
|
||||
SubDirSysHdrs [ FDirName $(sslDir) include ] ;
|
||||
}
|
||||
|
||||
Addon IMAP :
|
||||
@ -23,10 +28,10 @@ Addon IMAP :
|
||||
|
||||
LinkAgainst IMAP : be libmail.so $(TARGET_NETWORK_LIBS) ;
|
||||
|
||||
if $(USESSL) {
|
||||
LinkAgainst IMAP : ssl crypto ;
|
||||
if $(USE_SSL) {
|
||||
LinkAgainst IMAP : $(sslDir)/lib/libssl.so $(sslDir)/lib/libcrypto.so ;
|
||||
}
|
||||
|
||||
Package haiku-maildaemon-cvs :
|
||||
IMAP :
|
||||
IMAP :
|
||||
boot home config add-ons mail_daemon inbound_protocols ;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,11 @@
|
||||
/* IMAPConfig - config view for the IMAP protocol add-on
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007-2008, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//! config view for the IMAP protocol add-on
|
||||
|
||||
#include <TextControl.h>
|
||||
|
||||
@ -11,48 +14,53 @@
|
||||
|
||||
#include <MDRLanguage.h>
|
||||
|
||||
|
||||
class IMAPConfig : public BMailProtocolConfigView {
|
||||
public:
|
||||
IMAPConfig(BMessage *archive);
|
||||
virtual ~IMAPConfig();
|
||||
virtual status_t Archive(BMessage *into, bool deep = true) const;
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
public:
|
||||
IMAPConfig(BMessage *archive);
|
||||
virtual ~IMAPConfig();
|
||||
virtual status_t Archive(BMessage *into, bool deep = true) const;
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
};
|
||||
|
||||
|
||||
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 USESSL
|
||||
| B_MAIL_PROTOCOL_HAS_FLAVORS)
|
||||
: 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 USE_SSL
|
||||
| B_MAIL_PROTOCOL_HAS_FLAVORS
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef USE_SSL
|
||||
AddFlavor("No Encryption");
|
||||
AddFlavor("SSL");
|
||||
#else
|
||||
) {
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
SetTo(archive);
|
||||
|
||||
|
||||
((BControl *)(FindView("leave_mail_remote")))->SetValue(B_CONTROL_ON);
|
||||
((BControl *)(FindView("leave_mail_remote")))->Hide();
|
||||
|
||||
|
||||
BRect frame = FindView("delete_remote_when_local")->Frame();
|
||||
|
||||
|
||||
((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true);
|
||||
((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0,-25);
|
||||
|
||||
|
||||
|
||||
|
||||
frame.right -= 10;// FindView("pass")->Frame().right;
|
||||
/*frame.top += 10;
|
||||
frame.bottom += 10;*/
|
||||
|
||||
|
||||
BTextControl *folder = new BTextControl(frame,"root","Top Mailbox Folder: ","",NULL);
|
||||
folder->SetDivider(be_plain_font->StringWidth("Top Mailbox Folder: "));
|
||||
|
||||
|
||||
if (archive->HasString("root"))
|
||||
folder->SetText(archive->FindString("root"));
|
||||
|
||||
|
||||
AddChild(folder);
|
||||
|
||||
|
||||
ResizeToPreferred();
|
||||
}
|
||||
|
||||
@ -60,12 +68,12 @@ IMAPConfig::~IMAPConfig() {}
|
||||
|
||||
status_t IMAPConfig::Archive(BMessage *into, bool deep) const {
|
||||
BMailProtocolConfigView::Archive(into,deep);
|
||||
|
||||
|
||||
if (into->ReplaceString("root",((BTextControl *)(FindView("root")))->Text()) != B_OK)
|
||||
into->AddString("root",((BTextControl *)(FindView("root")))->Text());
|
||||
|
||||
|
||||
into->PrintToStream();
|
||||
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,16 @@ UsePrivateHeaders mail ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
|
||||
|
||||
if $(USESSL) {
|
||||
SubDirC++Flags -DUSESSL ;
|
||||
SubDirHdrs [ FDirName / boot home config include ] ;
|
||||
local sslDir ;
|
||||
|
||||
if $(USE_SSL) {
|
||||
SubDirC++Flags -DUSE_SSL ;
|
||||
if ! $(SSL_DIR) {
|
||||
sslDir = [ FDirName $(HAIKU_OUTPUT_DIR) cross-ssl config ] ;
|
||||
} else {
|
||||
sslDir = $(SSL_DIR) ;
|
||||
}
|
||||
SubDirSysHdrs [ FDirName $(sslDir) include ] ;
|
||||
}
|
||||
|
||||
Addon POP3 :
|
||||
@ -24,8 +31,8 @@ Addon POP3 :
|
||||
|
||||
LinkAgainst POP3 : be libmail.so $(TARGET_NETWORK_LIBS) ;
|
||||
|
||||
if $(USESSL) {
|
||||
LinkAgainst POP3 : ssl crypto ;
|
||||
if $(USE_SSL) {
|
||||
LinkAgainst POP3 : $(sslDir)/lib/libssl.so $(sslDir)/lib/libcrypto.so ;
|
||||
}
|
||||
|
||||
Package haiku-maildaemon-cvs :
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2007-2008, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
* Copyright 2007, Haiku Inc. All Rights Reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@ -19,16 +19,16 @@
|
||||
|
||||
#ifndef HAIKU_TARGET_PLATFORM_BEOS
|
||||
// These headers don't exist in BeOS R5.
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/select.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if USESSL
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/md5.h>
|
||||
#if USE_SSL
|
||||
# include <openssl/ssl.h>
|
||||
# include <openssl/rand.h>
|
||||
# include <openssl/md5.h>
|
||||
#else
|
||||
#include "md5.h"
|
||||
# include "md5.h"
|
||||
#endif
|
||||
|
||||
#include <DataIO.h>
|
||||
@ -51,7 +51,7 @@ POP3Protocol::POP3Protocol(BMessage *settings, BMailChainRunner *status)
|
||||
fNumMessages(-1),
|
||||
fMailDropSize(0)
|
||||
{
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
fUseSSL = (settings->FindInt32("flavor") == 1);
|
||||
#endif
|
||||
Init();
|
||||
@ -60,12 +60,12 @@ POP3Protocol::POP3Protocol(BMessage *settings, BMailChainRunner *status)
|
||||
|
||||
POP3Protocol::~POP3Protocol()
|
||||
{
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (!fUseSSL || fSSL)
|
||||
#endif
|
||||
SendCommand("QUIT" CRLF);
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL) {
|
||||
if (fSSL)
|
||||
SSL_shutdown(fSSL);
|
||||
@ -76,7 +76,7 @@ POP3Protocol::~POP3Protocol()
|
||||
|
||||
#ifndef HAIKU_TARGET_PLATFORM_BEOS
|
||||
close(fSocket);
|
||||
#else
|
||||
#else
|
||||
closesocket(fSocket);
|
||||
#endif
|
||||
}
|
||||
@ -89,7 +89,7 @@ POP3Protocol::Open(const char *server, int port, int)
|
||||
"POP3サーバに接続しています..."));
|
||||
|
||||
if (port <= 0) {
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
port = fUseSSL ? 995 : 110;
|
||||
#else
|
||||
port = 110;
|
||||
@ -149,7 +149,7 @@ POP3Protocol::Open(const char *server, int port, int)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL) {
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
@ -400,7 +400,7 @@ POP3Protocol::RetrieveInternal(const char *command, int32 message,
|
||||
|
||||
if (SendCommand(command) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = POP3_RETRIEVAL_TIMEOUT / 1000000;
|
||||
tv.tv_usec = POP3_RETRIEVAL_TIMEOUT % 1000000;
|
||||
@ -412,7 +412,7 @@ POP3Protocol::RetrieveInternal(const char *command, int32 message,
|
||||
while (cont) {
|
||||
int result = 0;
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL && SSL_pending(fSSL))
|
||||
result = 1;
|
||||
else
|
||||
@ -426,7 +426,7 @@ POP3Protocol::RetrieveInternal(const char *command, int32 message,
|
||||
}
|
||||
if (amountToReceive > bufSize - 1 - amountInBuffer)
|
||||
amountToReceive = bufSize - 1 - amountInBuffer;
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL) {
|
||||
amountReceived = SSL_read(fSSL, buf + amountInBuffer,
|
||||
amountToReceive);
|
||||
@ -594,7 +594,7 @@ POP3Protocol::ReceiveLine(BString &line)
|
||||
FD_SET(fSocket, &readSet);
|
||||
|
||||
int result;
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL && SSL_pending(fSSL))
|
||||
result = 1;
|
||||
else
|
||||
@ -606,7 +606,7 @@ POP3Protocol::ReceiveLine(BString &line)
|
||||
// Hope there's an end of line out there else this gets stuck.
|
||||
int32 bytesReceived;
|
||||
uint8 c = 0;
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL)
|
||||
bytesReceived = SSL_read(fSSL, (char*)&c, 1);
|
||||
else
|
||||
@ -647,7 +647,7 @@ POP3Protocol::SendCommand(const char *cmd)
|
||||
// Flush any accumulated garbage data before we send our command, so we
|
||||
// don't misinterrpret responses from previous commands (that got left over
|
||||
// due to bugs) as being from this command.
|
||||
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1000;
|
||||
@ -657,7 +657,7 @@ POP3Protocol::SendCommand(const char *cmd)
|
||||
FD_ZERO(&readSet);
|
||||
FD_SET(fSocket, &readSet);
|
||||
int result;
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL && SSL_pending(fSSL))
|
||||
result = 1;
|
||||
else
|
||||
@ -667,7 +667,7 @@ POP3Protocol::SendCommand(const char *cmd)
|
||||
if (result > 0) {
|
||||
int amountReceived;
|
||||
char tempString [1025];
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL)
|
||||
amountReceived = SSL_read(fSSL, tempString, sizeof(tempString) - 1);
|
||||
else
|
||||
@ -683,7 +683,7 @@ POP3Protocol::SendCommand(const char *cmd)
|
||||
// break;
|
||||
}
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (fUseSSL) {
|
||||
SSL_write(fSSL, cmd,::strlen(cmd));
|
||||
} else
|
||||
@ -723,10 +723,10 @@ POP3Protocol::SendCommand(const char *cmd)
|
||||
|
||||
void
|
||||
POP3Protocol::MD5Digest(unsigned char *in, char *asciiDigest)
|
||||
{
|
||||
{
|
||||
unsigned char digest[16];
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
MD5(in, ::strlen((char*)in), digest);
|
||||
#else
|
||||
MD5_CTX context;
|
||||
@ -761,14 +761,14 @@ instantiate_config_panel(BMessage *settings, BMessage *)
|
||||
B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_AUTH_METHODS
|
||||
| B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME
|
||||
| B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER
|
||||
#if USESSL
|
||||
#if USE_SSL
|
||||
| B_MAIL_PROTOCOL_HAS_FLAVORS
|
||||
#endif
|
||||
);
|
||||
view->AddAuthMethod("Plain Text");
|
||||
view->AddAuthMethod("APOP");
|
||||
|
||||
#if USESSL
|
||||
#if USE_SSL
|
||||
view->AddFlavor("No Encryption");
|
||||
view->AddFlavor("SSL");
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2007-2008, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
* Copyright 2007, Haiku Inc. All Rights Reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@ -10,6 +10,10 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#ifdef USE_SSL
|
||||
# include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
#include <List.h>
|
||||
#include <String.h>
|
||||
|
||||
@ -20,7 +24,7 @@ class POP3Protocol : public SimpleMailProtocol {
|
||||
public:
|
||||
POP3Protocol(BMessage *settings, BMailChainRunner *status);
|
||||
~POP3Protocol();
|
||||
|
||||
|
||||
status_t Open(const char *server, int port, int protocol);
|
||||
status_t Login(const char *uid, const char *password, int method);
|
||||
status_t UniqueIDs();
|
||||
@ -47,7 +51,7 @@ private:
|
||||
size_t fMailDropSize;
|
||||
BList fSizes;
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
SSL_CTX* fSSLContext;
|
||||
SSL* fSSL;
|
||||
BIO* fSSLBio;
|
||||
|
@ -11,9 +11,14 @@ UsePrivateHeaders mail ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
|
||||
|
||||
if $(USESSL) {
|
||||
SubDirC++Flags -DUSESSL ;
|
||||
SubDirHdrs [ FDirName / boot home config include ] ;
|
||||
if $(USE_SSL) {
|
||||
SubDirC++Flags -DUSE_SSL ;
|
||||
if ! $(SSL_DIR) {
|
||||
sslDir = [ FDirName $(HAIKU_OUTPUT_DIR) cross-ssl config ] ;
|
||||
} else {
|
||||
sslDir = $(SSL_DIR) ;
|
||||
}
|
||||
SubDirSysHdrs [ FDirName $(sslDir) include ] ;
|
||||
}
|
||||
|
||||
Addon SMTP :
|
||||
@ -22,8 +27,8 @@ Addon SMTP :
|
||||
|
||||
LinkAgainst SMTP : be libmail.so $(TARGET_NETWORK_LIBS) ;
|
||||
|
||||
if $(USESSL) {
|
||||
LinkAgainst SMTP : ssl crypto ;
|
||||
if $(USE_SSL) {
|
||||
LinkAgainst SMTP : $(sslDir)/lib/libssl.so $(sslDir)/lib/libcrypto.so ;
|
||||
}
|
||||
|
||||
Package haiku-maildaemon-cvs :
|
||||
|
@ -1,7 +1,11 @@
|
||||
/* SMTPProtocol - implementation of the SMTP protocol
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007-2008, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//! implementation of the SMTP protocol
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <Message.h>
|
||||
@ -19,8 +23,8 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#ifndef HAIKU_TARGET_PLATFORM_BEOS // These headers don't exist in BeOS R5.
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/select.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <status.h>
|
||||
@ -34,8 +38,10 @@
|
||||
#include <map>
|
||||
|
||||
#include "smtp.h"
|
||||
#ifndef USESSL
|
||||
#include "md5.h"
|
||||
#ifdef USE_SSL
|
||||
# include <openssl/md5.h>
|
||||
#else
|
||||
# include "md5.h"
|
||||
#endif
|
||||
|
||||
#include <MDRLanguage.h>
|
||||
@ -167,7 +173,7 @@ void MD5Digest (char* hexdigest, unsigned char *text, int text_len) {
|
||||
int i;
|
||||
unsigned char digest[17];
|
||||
unsigned char c;
|
||||
|
||||
|
||||
MD5Sum((char*)digest, text, text_len);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
@ -207,7 +213,7 @@ SplitChallengeIntoMap(BString str, map<BString,BString>& m)
|
||||
if (*s == 0)
|
||||
return false;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
*s++ = '\0';
|
||||
} else {
|
||||
val = s;
|
||||
@ -350,19 +356,19 @@ SMTPProtocol::Open(const char *address, int port, bool esmtp)
|
||||
{
|
||||
runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE ("Connecting to server...","接続中..."));
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
use_ssl = (fSettings->FindInt32("flavor") == 1);
|
||||
ssl = NULL;
|
||||
ctx = NULL;
|
||||
#endif
|
||||
|
||||
if (port <= 0)
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
port = use_ssl ? 465 : 25;
|
||||
#else
|
||||
port = 25;
|
||||
#endif
|
||||
|
||||
|
||||
uint32 hostIP = inet_addr(address); // first see if we can parse it as a numeric address
|
||||
if ((hostIP == 0)||(hostIP == (uint32)-1)) {
|
||||
struct hostent * he = gethostbyname(address);
|
||||
@ -371,7 +377,7 @@ SMTPProtocol::Open(const char *address, int port, bool esmtp)
|
||||
|
||||
if (hostIP == 0)
|
||||
return EHOSTUNREACH;
|
||||
|
||||
|
||||
#ifndef HAIKU_TARGET_PLATFORM_BEOS
|
||||
_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
#else
|
||||
@ -397,7 +403,7 @@ SMTPProtocol::Open(const char *address, int port, bool esmtp)
|
||||
return errno;
|
||||
}
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (use_ssl) {
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
@ -405,12 +411,12 @@ SMTPProtocol::Open(const char *address, int port, bool esmtp)
|
||||
/*--- Because we're an add-on loaded at an unpredictable time, all
|
||||
the memory addresses and things contained in ourself are
|
||||
esssentially random. */
|
||||
|
||||
|
||||
ctx = SSL_CTX_new(SSLv23_method());
|
||||
ssl = SSL_new(ctx);
|
||||
sbio=BIO_new_socket(_fd,BIO_NOCLOSE);
|
||||
SSL_set_bio(ssl,sbio,sbio);
|
||||
|
||||
|
||||
if (SSL_connect(ssl) <= 0) {
|
||||
BString error;
|
||||
error << "Could not connect to SMTP server " << fSettings->FindString("server");
|
||||
@ -429,18 +435,18 @@ SMTPProtocol::Open(const char *address, int port, bool esmtp)
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
BString line;
|
||||
ReceiveResponse(line);
|
||||
|
||||
|
||||
char localhost[255];
|
||||
gethostname(localhost,255);
|
||||
|
||||
|
||||
if (localhost[0] == 0)
|
||||
strcpy(localhost,"namethisbebox");
|
||||
|
||||
|
||||
char *cmd = new char[::strlen(localhost)+8];
|
||||
if (!esmtp)
|
||||
::sprintf(cmd,"HELO %s"CRLF, localhost);
|
||||
@ -749,7 +755,7 @@ SMTPProtocol::Close()
|
||||
// Error
|
||||
}
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (use_ssl) {
|
||||
if (ssl)
|
||||
SSL_shutdown(ssl);
|
||||
@ -844,7 +850,7 @@ SMTPProtocol::Send(const char *to, const char *from, BPositionIO *message)
|
||||
if (data[i] == '\r' && data[i+1] == '\n' && data[i+2] == '.') {
|
||||
foundCRLFPeriod = true;
|
||||
// Send data up to the CRLF, and include the period too.
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (use_ssl) {
|
||||
if (SSL_write(ssl,data,i + 3) < 0) {
|
||||
amountUnread = 0; // Stop when an error happens.
|
||||
@ -870,7 +876,7 @@ SMTPProtocol::Send(const char *to, const char *from, BPositionIO *message)
|
||||
if (!foundCRLFPeriod) {
|
||||
if (amountUnread <= 0) { // No more data, all we have is in the buffer.
|
||||
if (bufferLen > 0) {
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (use_ssl)
|
||||
SSL_write(ssl,data,bufferLen);
|
||||
else
|
||||
@ -887,7 +893,7 @@ SMTPProtocol::Send(const char *to, const char *from, BPositionIO *message)
|
||||
// Send most of the buffer, except a few characters to overlap with
|
||||
// the next read, in case the CRLFPeriod is split between reads.
|
||||
if (bufferLen > 3) {
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (use_ssl) {
|
||||
if (SSL_write(ssl,data,bufferLen - 3) < 0)
|
||||
break;
|
||||
@ -927,20 +933,20 @@ SMTPProtocol::ReceiveResponse(BString &out)
|
||||
bool gotCode = false;
|
||||
int32 errCode;
|
||||
BString searchStr = "";
|
||||
|
||||
|
||||
struct timeval tv;
|
||||
struct fd_set fds;
|
||||
|
||||
tv.tv_sec = long(timeout / 1e6);
|
||||
tv.tv_usec = long(timeout-(tv.tv_sec * 1e6));
|
||||
|
||||
|
||||
/* Initialize (clear) the socket mask. */
|
||||
FD_ZERO(&fds);
|
||||
|
||||
|
||||
/* Set the socket in the mask. */
|
||||
FD_SET(_fd, &fds);
|
||||
int result = -1;
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if ((use_ssl) && (SSL_pending(ssl)))
|
||||
result = 1;
|
||||
else
|
||||
@ -948,10 +954,10 @@ SMTPProtocol::ReceiveResponse(BString &out)
|
||||
result = select(32, &fds, NULL, NULL, &tv);
|
||||
if (result < 0)
|
||||
return errno;
|
||||
|
||||
|
||||
if (result > 0) {
|
||||
while (1) {
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (use_ssl)
|
||||
r = SSL_read(ssl,buf,SMTP_RESPONSE_SIZE - 1);
|
||||
else
|
||||
@ -959,7 +965,7 @@ SMTPProtocol::ReceiveResponse(BString &out)
|
||||
r = recv(_fd,buf, SMTP_RESPONSE_SIZE - 1,0);
|
||||
if (r <= 0)
|
||||
break;
|
||||
|
||||
|
||||
if (!gotCode)
|
||||
{
|
||||
if (buf[3] == ' ' || buf[3] == '-')
|
||||
@ -967,12 +973,12 @@ SMTPProtocol::ReceiveResponse(BString &out)
|
||||
errCode = atol(buf);
|
||||
gotCode = true;
|
||||
searchStr << errCode << ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
len += r;
|
||||
out.Append(buf, r);
|
||||
|
||||
|
||||
if (strstr(buf, CRLF) && (out.FindFirst(searchStr) != B_ERROR))
|
||||
break;
|
||||
}
|
||||
@ -991,7 +997,7 @@ SMTPProtocol::SendCommand(const char *cmd)
|
||||
{
|
||||
D(bug("C:%s\n", cmd));
|
||||
|
||||
#ifdef USESSL
|
||||
#ifdef USE_SSL
|
||||
if (use_ssl && ssl) {
|
||||
if (SSL_write(ssl,cmd,::strlen(cmd)) < 0)
|
||||
return B_ERROR;
|
||||
@ -1039,8 +1045,8 @@ instantiate_mailfilter(BMessage *settings, BMailChainRunner *status)
|
||||
BView *
|
||||
instantiate_config_panel(BMessage *settings, BMessage *)
|
||||
{
|
||||
#ifdef USESSL
|
||||
BMailProtocolConfigView *view = new BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS |
|
||||
#ifdef USE_SSL
|
||||
BMailProtocolConfigView *view = new BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS |
|
||||
B_MAIL_PROTOCOL_HAS_USERNAME |
|
||||
B_MAIL_PROTOCOL_HAS_PASSWORD |
|
||||
B_MAIL_PROTOCOL_HAS_HOSTNAME |
|
||||
@ -1048,7 +1054,7 @@ instantiate_config_panel(BMessage *settings, BMessage *)
|
||||
view->AddFlavor("Unencrypted");
|
||||
view->AddFlavor("SSL");
|
||||
#else
|
||||
BMailProtocolConfigView *view = new BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS |
|
||||
BMailProtocolConfigView *view = new BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS |
|
||||
B_MAIL_PROTOCOL_HAS_USERNAME |
|
||||
B_MAIL_PROTOCOL_HAS_PASSWORD |
|
||||
B_MAIL_PROTOCOL_HAS_HOSTNAME);
|
||||
@ -1060,7 +1066,7 @@ instantiate_config_panel(BMessage *settings, BMessage *)
|
||||
|
||||
BTextControl *control = (BTextControl *)(view->FindView("host"));
|
||||
control->SetLabel(MDR_DIALECT_CHOICE ("SMTP Server: ","SMTPサーバ: "));
|
||||
|
||||
|
||||
// Reset the dividers after changing one
|
||||
float widestLabel=0;
|
||||
for (int32 i = view->CountChildren(); i-- > 0;) {
|
||||
|
@ -1,20 +1,23 @@
|
||||
/*
|
||||
* Copyright 2007-2008, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef ZOIDBERG_SMTP_H
|
||||
#define ZOIDBERG_SMTP_H
|
||||
/* SMTPProtocol - implementation of the SMTP protocol
|
||||
**
|
||||
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include <MailAddon.h>
|
||||
|
||||
#ifdef USESSL
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/rand.h>
|
||||
#ifdef USE_SSL
|
||||
# include <openssl/ssl.h>
|
||||
# include <openssl/rand.h>
|
||||
#endif
|
||||
|
||||
|
||||
class SMTPProtocol : public BMailFilter {
|
||||
public:
|
||||
SMTPProtocol(BMessage *message, BMailChainRunner *runner);
|
||||
@ -41,14 +44,14 @@ class SMTPProtocol : public BMailFilter {
|
||||
BMessage *fSettings;
|
||||
BMailChainRunner *runner;
|
||||
int32 fAuthType;
|
||||
|
||||
#ifdef USESSL
|
||||
SSL_CTX *ctx;
|
||||
SSL *ssl;
|
||||
BIO *sbio;
|
||||
|
||||
bool use_ssl;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SSL
|
||||
SSL_CTX *ctx;
|
||||
SSL *ssl;
|
||||
BIO *sbio;
|
||||
|
||||
bool use_ssl;
|
||||
#endif
|
||||
|
||||
status_t fStatus;
|
||||
BString fServerName; // required for DIGEST-MD5
|
||||
|
Loading…
Reference in New Issue
Block a user