diff --git a/src/kits/mail/Jamfile b/src/kits/mail/Jamfile index 8232ad6865..19f1351526 100644 --- a/src/kits/mail/Jamfile +++ b/src/kits/mail/Jamfile @@ -12,6 +12,7 @@ SubDirC++Flags -D_BUILDING_mail=1 ; UsePrivateHeaders textencoding ; SharedLibrary libmail.so : + c_mail_api.cpp crypt.cpp des.c FileConfigView.cpp diff --git a/src/kits/mail/c_mail_api.cpp b/src/kits/mail/c_mail_api.cpp new file mode 100644 index 0000000000..8dc5143b8f --- /dev/null +++ b/src/kits/mail/c_mail_api.cpp @@ -0,0 +1,145 @@ +/* C-mail API - compatibility function (stubs) for the old mail kit +** +** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. +** Copyright 2011 Clemens Zeidler. All rights reserved. +*/ + + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +_EXPORT status_t +check_for_mail(int32 * incoming_count) +{ + status_t err = BMailDaemon::CheckMail(true); + if (err < B_OK) + return err; + + if (incoming_count != NULL) + *incoming_count = BMailDaemon::CountNewMessages(true); + + return B_OK; +} + + +_EXPORT status_t +send_queued_mail(void) +{ + return BMailDaemon::SendQueuedMail(); +} + + +_EXPORT int32 +count_pop_accounts(void) +{ + BPath path; + status_t status = find_directory(B_USER_SETTINGS_DIRECTORY,&path); + if (status < B_OK) + return 0; + + path.Append("Mail/chains/inbound"); + BDirectory dir(path.Path()); + return dir.CountEntries(); +} + + +_EXPORT status_t +get_mail_notification(mail_notification *notification) +{ + notification->alert = true; + notification->beep = false; + return B_OK; +} + + +_EXPORT status_t +set_mail_notification(mail_notification *, bool) +{ + return B_NO_REPLY; +} + + +_EXPORT status_t +get_pop_account(mail_pop_account* account, int32 index) +{ + BMailAccounts accounts; + BMailAccountSettings* accountSettings = accounts.AccountAt(index); + if (accountSettings == NULL) + return B_BAD_INDEX; + + const BMessage& settings = accountSettings->InboundSettings().Settings(); + strcpy(account->pop_name, settings.FindString("username")); + strcpy(account->pop_host, settings.FindString("server")); + strcpy(account->real_name, accountSettings->RealName()); + strcpy(account->reply_to, accountSettings->ReturnAddress()); + + const char *password, *passwd; + password = settings.FindString("password"); + passwd = get_passwd(&settings, "cpasswd"); + if (passwd) + password = passwd; + strcpy(account->pop_password, password); + + return B_OK; +} + + +_EXPORT status_t +set_pop_account(mail_pop_account *, int32, bool) +{ + return B_NO_REPLY; +} + + +_EXPORT status_t +get_smtp_host(char* buffer) +{ + BMailAccounts accounts; + BMailAccountSettings* account = accounts.AccountAt( + BMailSettings().DefaultOutboundAccount()); + if (account == NULL) + return B_ERROR; + + const BMessage& settings = account->OutboundSettings().Settings(); + + if (settings.HasString("server")) + strcpy(buffer,settings.FindString("server")); + else + return B_NAME_NOT_FOUND; + + return B_OK; +} + + +_EXPORT status_t +set_smtp_host(char * /* host */, bool /* save */) +{ + return B_NO_REPLY; +} + + +_EXPORT status_t +forward_mail(entry_ref *ref, const char *recipients, bool now) +{ + BFile file(ref, O_RDONLY); + status_t status = file.InitCheck(); + if (status < B_OK) + return status; + + BEmailMessage mail(&file); + mail.SetTo(recipients); + + return mail.Send(now); +}