2 * Copyright 2004-2012, Haiku, Inc. All rights reserved.
3 * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
4 * Copyright 2011, Clemens Zeidler. All rights reserved.
6 * Distributed under the terms of the MIT License.
10 //! C-mail API - compatibility function (stubs) for the old mail kit
16 #include <Directory.h>
19 #include <FindDirectory.h>
24 #include <MailDaemon.h>
25 #include <MailMessage.h>
26 #include <MailSettings.h>
30 check_for_mail(int32
* _incomingCount
)
32 status_t status
= BMailDaemon().CheckMail();
36 if (_incomingCount
!= NULL
)
37 *_incomingCount
= BMailDaemon().CountNewMessages(true);
44 send_queued_mail(void)
46 return BMailDaemon().SendQueuedMail();
51 count_pop_accounts(void)
53 BMailAccounts accounts
;
54 return accounts
.CountAccounts();
59 get_mail_notification(mail_notification
*notification
)
61 notification
->alert
= true;
62 notification
->beep
= false;
68 set_mail_notification(mail_notification
*, bool)
75 get_pop_account(mail_pop_account
* account
, int32 index
)
77 BMailAccounts accounts
;
78 BMailAccountSettings
* accountSettings
= accounts
.AccountAt(index
);
79 if (accountSettings
== NULL
)
82 const BMessage
& settings
= accountSettings
->InboundSettings();
83 strcpy(account
->pop_name
, settings
.FindString("username"));
84 strcpy(account
->pop_host
, settings
.FindString("server"));
85 strcpy(account
->real_name
, accountSettings
->RealName());
86 strcpy(account
->reply_to
, accountSettings
->ReturnAddress());
88 const char* encryptedPassword
= get_passwd(&settings
, "cpasswd");
89 const char* password
= encryptedPassword
;
91 password
= settings
.FindString("password");
92 strcpy(account
->pop_password
, password
);
94 delete[] encryptedPassword
;
100 set_pop_account(mail_pop_account
*, int32
, bool)
107 get_smtp_host(char* buffer
)
109 BMailAccounts accounts
;
110 BMailAccountSettings
* account
= accounts
.AccountAt(
111 BMailSettings().DefaultOutboundAccount());
115 const BMessage
& settings
= account
->OutboundSettings();
117 if (!settings
.HasString("server"))
118 return B_NAME_NOT_FOUND
;
120 strcpy(buffer
, settings
.FindString("server"));
126 set_smtp_host(char * /* host */, bool /* save */)
133 forward_mail(entry_ref
*ref
, const char *recipients
, bool now
)
135 BFile
file(ref
, O_RDONLY
);
136 status_t status
= file
.InitCheck();
140 BEmailMessage
mail(&file
);
141 mail
.SetTo(recipients
);
143 return mail
.Send(now
);