1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-06 03:50:08 +02:00
This commit is contained in:
B. Petersen 2016-07-15 23:50:09 +02:00
parent 98b975086b
commit a6191f957b
2 changed files with 19 additions and 6 deletions

View file

@ -38,14 +38,16 @@ MrLoginParam::MrLoginParam(MrMailbox* mailbox)
// init pointers (this cannot be done by Clear() as this function checks against NULL pointers)
m_email = NULL;
m_mail_server = NULL;
m_mail_port = 0;
m_mail_user = NULL;
m_mail_pw = NULL;
m_mail_port = 0;
m_send_server = NULL;
m_send_port = 0;
m_send_user = NULL;
m_send_pw = NULL;
m_send_port = 0;
}
@ -58,26 +60,32 @@ MrLoginParam::~MrLoginParam()
void MrLoginParam::Clear()
{
#define FREE_(a) if((a)) { free((a)); (a) = NULL; }
FREE_(m_email)
FREE_(m_mail_server)
m_mail_port = 0;
FREE_(m_mail_user)
FREE_(m_mail_pw)
m_mail_port = 0;
FREE_(m_send_server)
m_send_port = 0;
FREE_(m_send_user)
FREE_(m_send_pw)
m_send_port = 0;
}
void MrLoginParam::ReadFromSql()
{
Clear();
m_email = m_mailbox->GetConfig ("email", NULL);
m_mail_server = m_mailbox->GetConfig ("mail_server", NULL);
m_mail_port = m_mailbox->GetConfigInt("mail_port", 0);
m_mail_user = m_mailbox->GetConfig ("mail_user", NULL);
m_mail_pw = m_mailbox->GetConfig ("mail_pw", NULL);
m_send_server = m_mailbox->GetConfig ("send_server", NULL);
m_send_port = m_mailbox->GetConfigInt("send_port", 0);
m_send_user = m_mailbox->GetConfig ("send_user", NULL);

View file

@ -39,18 +39,23 @@ public:
MrLoginParam (MrMailbox* mailbox);
~MrLoginParam ();
// clears all data and frees its memory. All pointers are NULL after this function is called.
void Clear ();
// read all data from database, unset values are still NULL after calling ReadFromSql()
void ReadFromSql ();
// tries to set missing parameters from at least m_email and m_mail_pw
void Complete ();
// IMAP/POP3
// IMAP/POP3 - all pointers may be NULL if unset
char* m_email;
char* m_mail_server;
char* m_mail_user;
char* m_mail_pw;
uint16_t m_mail_port;
// SMTP
// SMTP - all pointers may be NULL if unset
char* m_send_server;
char* m_send_user;
char* m_send_pw;