Conversion of MailFileSystem object to MString.
This commit is contained in:
parent
8e7834a320
commit
09c6163a74
@ -4,39 +4,37 @@
|
|||||||
|
|
||||||
namespace mail {
|
namespace mail {
|
||||||
|
|
||||||
MailFileSystem::MailFileSystem(std::string mailPath) : mailPath(mailPath) {}
|
MailFileSystem::MailFileSystem(coreutils::ZString &mailPath) : mailPath(mailPath) {}
|
||||||
|
|
||||||
bool MailFileSystem::ifMailBoxExists(std::string mailbox) {
|
bool MailFileSystem::ifMailBoxExists(coreutils::ZString &mailbox) {
|
||||||
std::cout << "{" << mailbox << "}" << std::endl;
|
std::cout << "{" << mailbox << "}" << std::endl;
|
||||||
|
|
||||||
if(stat(getMailBoxPath(mailbox).c_str(), &statbuf) != -1)
|
if(stat(getMailBoxPath(mailbox).c_str(), &statbuf) != -1)
|
||||||
if(S_ISDIR(statbuf.st_mode))
|
if(S_ISDIR(statbuf.st_mode))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MailFileSystem::ifAliasExists(std::string alias) {
|
bool MailFileSystem::ifAliasExists(coreutils::ZString &alias) {
|
||||||
if(stat(getMailBoxPath(alias).c_str(), &statbuf) != -1)
|
if(stat(getMailBoxPath(alias).c_str(), &statbuf) != -1)
|
||||||
if(S_ISREG(statbuf.st_mode))
|
if(S_ISREG(statbuf.st_mode))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MailFileSystem::getMailBoxPath(std::string mailbox) {
|
coreutils::MString MailFileSystem::getMailBoxPath(coreutils::ZString &mailbox) {
|
||||||
coreutils::ZString email(mailbox);
|
mailbox.split("@", 1);
|
||||||
email.split("@", 1);
|
std::cout << mailbox[0] << "-" << mailbox[1] << std::endl;
|
||||||
std::cout << email[0] << "-" << email[1] << std::endl;
|
coreutils::MString path(mailPath + "/" + mailbox[1] + "/" + mailbox[0]);
|
||||||
std::string path = mailPath + "/" + email[1].str() + "/" + email[0].str();
|
|
||||||
std::cout << "{" << path << "}" << std::endl;
|
std::cout << "{" << path << "}" << std::endl;
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> MailFileSystem::getAliasMailboxes(std::string alias) {
|
std::vector<coreutils::MString> MailFileSystem::getAliasMailboxes(coreutils::ZString &alias) {
|
||||||
std::vector<std::string> returnValue;
|
std::vector<coreutils::MString> returnValue;
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MailFileSystem::getMailPath() {
|
coreutils::ZString& MailFileSystem::getMailPath() {
|
||||||
return mailPath;
|
return mailPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef __MailFileSystem_h__
|
#ifndef __MailFileSystem_h__
|
||||||
# define __MailFileSystem_h__
|
# define __MailFileSystem_h__
|
||||||
|
|
||||||
# include "ZString.h"
|
# include "MString.h"
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
@ -11,15 +11,15 @@ namespace mail {
|
|||||||
class MailFileSystem {
|
class MailFileSystem {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MailFileSystem(std::string mailPath);
|
MailFileSystem(coreutils::ZString &mailPath);
|
||||||
bool ifMailBoxExists(std::string mailbox);
|
bool ifMailBoxExists(coreutils::ZString &mailbox);
|
||||||
bool ifAliasExists(std::string alias);
|
bool ifAliasExists(coreutils::ZString &alias);
|
||||||
std::string getMailBoxPath(std::string mailbox);
|
coreutils::MString getMailBoxPath(coreutils::ZString &mailbox);
|
||||||
std::vector<std::string> getAliasMailboxes(std::string alias);
|
std::vector<coreutils::MString> getAliasMailboxes(coreutils::ZString &alias);
|
||||||
std::string getMailPath();
|
coreutils::ZString& getMailPath();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mailPath;
|
coreutils::ZString &mailPath;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "__SMTP_AUTH.h"
|
#include "__SMTP_AUTH.h"
|
||||||
#include "Base64.h"
|
#include "Base64.h"
|
||||||
|
#include "SMTPServer.h"
|
||||||
|
|
||||||
namespace mail {
|
namespace mail {
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ namespace mail {
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case USER_QUERY:
|
case USER_QUERY:
|
||||||
session.userName = request[0].str();
|
session.userName = request[0];
|
||||||
// setTimer(0.0f);
|
// setTimer(0.0f);
|
||||||
session.out << "334 UGFzc3dvcmQ6" << CRLF;
|
session.out << "334 UGFzc3dvcmQ6" << CRLF;
|
||||||
// setTimer(10.0f);
|
// setTimer(10.0f);
|
||||||
@ -28,10 +29,10 @@ namespace mail {
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case USER_SECRET_QUERY:
|
case USER_SECRET_QUERY:
|
||||||
session.password = request[0].str();
|
session.password = request[0];
|
||||||
// setTimer(0.0f);
|
// setTimer(0.0f);
|
||||||
coreutils::Base64 base64;
|
coreutils::Base64 base64;
|
||||||
if(authLogin(session.userName, session.password)) {
|
if(authLogin(session.userName, session.password, server)) {
|
||||||
session.out << "235 2.7.0 Authentication successful" << CRLF;
|
session.out << "235 2.7.0 Authentication successful" << CRLF;
|
||||||
session.relay = true;
|
session.relay = true;
|
||||||
session.authState = USER_KNOWN;
|
session.authState = USER_KNOWN;
|
||||||
@ -45,12 +46,11 @@ namespace mail {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool __SMTP_AUTH::authLogin(coreutils::ZString userName, coreutils::ZString password) {
|
bool __SMTP_AUTH::authLogin(coreutils::ZString &userName, coreutils::ZString &password, SMTPServer &server) {
|
||||||
// std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password";
|
std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password";
|
||||||
// coreutils::File secret(secretPath);
|
coreutils::File secret(secretPath);
|
||||||
// secret.read();
|
secret.read();
|
||||||
// return secret.asString() == password;
|
return password == secret.asString();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace mail {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int processCommand(coreutils::ZString &request, SMTPSession &session, SMTPServer &server) override;
|
int processCommand(coreutils::ZString &request, SMTPSession &session, SMTPServer &server) override;
|
||||||
bool authLogin(coreutils::ZString userName, coreutils::ZString password);
|
bool authLogin(coreutils::ZString &userName, coreutils::ZString &password, SMTPServer &server);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
namespace mail {
|
namespace mail {
|
||||||
|
|
||||||
// class SMTPServer;
|
|
||||||
|
|
||||||
class __SMTP_MAIL : public SMTPCommand {
|
class __SMTP_MAIL : public SMTPCommand {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user