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