aboutsummaryrefslogtreecommitdiffstats
path: root/src/messaging
diff options
context:
space:
mode:
Diffstat (limited to 'src/messaging')
-rw-r--r--src/messaging/imap/IMAPConnection.cpp72
-rw-r--r--src/messaging/imap/IMAPStore.cpp49
-rw-r--r--src/messaging/maildir/maildirStore.cpp35
-rw-r--r--src/messaging/pop3/POP3Store.cpp75
-rw-r--r--src/messaging/sendmail/sendmailTransport.cpp34
-rw-r--r--src/messaging/serviceInfos.cpp150
-rw-r--r--src/messaging/smtp/SMTPTransport.cpp67
7 files changed, 386 insertions, 96 deletions
diff --git a/src/messaging/imap/IMAPConnection.cpp b/src/messaging/imap/IMAPConnection.cpp
index 0f5934c8..37a132de 100644
--- a/src/messaging/imap/IMAPConnection.cpp
+++ b/src/messaging/imap/IMAPConnection.cpp
@@ -28,6 +28,15 @@
#include <sstream>
+// Helpers for service properties
+#define GET_PROPERTY(type, prop) \
+ (m_store->getInfos().getPropertyValue <type>(getSession(), \
+ dynamic_cast <const IMAPStore::_infos&>(m_store->getInfos()).getProperties().prop))
+#define HAS_PROPERTY(prop) \
+ (m_store->getInfos().hasProperty(getSession(), \
+ dynamic_cast <const IMAPStore::_infos&>(m_store->getInfos()).getProperties().prop))
+
+
namespace vmime {
namespace messaging {
namespace imap {
@@ -60,28 +69,26 @@ void IMAPConnection::connect()
m_state = STATE_NONE;
m_hierarchySeparator = '\0';
- const string address = m_store->getSession()->getProperties()[m_store->getInfos().getPropertyPrefix() + "server.address"];
- const port_t port = m_store->getSession()->getProperties().getProperty(m_store->getInfos().getPropertyPrefix() + "server.port", m_store->getInfos().getDefaultPort());
+ const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
+ const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
// Create the time-out handler
- if (m_store->getSession()->getProperties().hasProperty
- (m_store->getInfos().getPropertyPrefix() + "timeout.factory"))
+ if (HAS_PROPERTY(PROPERTY_TIMEOUT_FACTORY))
{
timeoutHandlerFactory* tof = platformDependant::getHandler()->
- getTimeoutHandlerFactory(m_store->getSession()->getProperties()
- [m_store->getInfos().getPropertyPrefix() + "timeout.factory"]);
+ getTimeoutHandlerFactory(GET_PROPERTY(string, PROPERTY_TIMEOUT_FACTORY));
m_timeoutHandler = tof->create();
}
// Create and connect the socket
- socketFactory* sf = platformDependant::getHandler()->getSocketFactory
- (m_store->getSession()->getProperties().getProperty
- (m_store->getInfos().getPropertyPrefix() + "server.socket-factory", string("default")));
+ socketFactory* sf = platformDependant::getHandler()->
+ getSocketFactory(GET_PROPERTY(string, PROPERTY_SERVER_SOCKETFACTORY));
m_socket = sf->create();
m_socket->connect(address, port);
+
delete (m_tag);
m_tag = new IMAPTag();
@@ -260,6 +267,53 @@ IMAPParser::response* IMAPConnection::readResponse(IMAPParser::literalHandler* l
}
+const IMAPConnection::ProtocolStates IMAPConnection::state() const
+{
+ return (m_state);
+}
+
+
+void IMAPConnection::setState(const ProtocolStates state)
+{
+ m_state = state;
+}
+
+const char IMAPConnection::hierarchySeparator() const
+{
+ return (m_hierarchySeparator);
+}
+
+
+const IMAPTag* IMAPConnection::getTag() const
+{
+ return (m_tag);
+}
+
+
+const IMAPParser* IMAPConnection::getParser() const
+{
+ return (m_parser);
+}
+
+
+const IMAPStore* IMAPConnection::getStore() const
+{
+ return (m_store);
+}
+
+
+IMAPStore* IMAPConnection::getStore()
+{
+ return (m_store);
+}
+
+
+session* IMAPConnection::getSession()
+{
+ return (m_store->getSession());
+}
+
+
} // imap
} // messaging
} // vmime
diff --git a/src/messaging/imap/IMAPStore.cpp b/src/messaging/imap/IMAPStore.cpp
index 81eab9a7..07b22351 100644
--- a/src/messaging/imap/IMAPStore.cpp
+++ b/src/messaging/imap/IMAPStore.cpp
@@ -230,15 +230,14 @@ const int IMAPStore::getCapabilities() const
CAPABILITY_RENAME_FOLDER |
CAPABILITY_ADD_MESSAGE |
CAPABILITY_COPY_MESSAGE |
- CAPABILITY_DELETE_MESSAGE |
+ CAPABILITY_DELETE_MESSAGE |
CAPABILITY_PARTIAL_FETCH |
CAPABILITY_MESSAGE_FLAGS |
- CAPABILITY_EXTRACT_PART);
+ CAPABILITY_EXTRACT_PART);
}
-
// Service infos
IMAPStore::_infos IMAPStore::sm_infos;
@@ -256,39 +255,57 @@ const serviceInfos& IMAPStore::getInfos() const
}
-const port_t IMAPStore::_infos::getDefaultPort() const
+const string IMAPStore::_infos::getPropertyPrefix() const
{
- return (143);
+ return "store.imap.";
}
-const string IMAPStore::_infos::getPropertyPrefix() const
+const IMAPStore::_infos::props& IMAPStore::_infos::getProperties() const
{
- return "store.imap.";
+ static props p =
+ {
+ // IMAP-specific options
+ // (none)
+
+ // Common properties
+ property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED),
+ property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED),
+
+ property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
+ property(serviceInfos::property::SERVER_PORT, "143"),
+ property(serviceInfos::property::SERVER_SOCKETFACTORY),
+
+ property(serviceInfos::property::TIMEOUT_FACTORY)
+ };
+
+ return p;
}
-const std::vector <string> IMAPStore::_infos::getAvailableProperties() const
+const std::vector <serviceInfos::property> IMAPStore::_infos::getAvailableProperties() const
{
- std::vector <string> list;
+ std::vector <property> list;
+ const props& p = getProperties();
// IMAP-specific options
- //list.push_back("auth.mechanism");
+ // (none)
// Common properties
- list.push_back("auth.username");
- list.push_back("auth.password");
+ list.push_back(p.PROPERTY_AUTH_USERNAME);
+ list.push_back(p.PROPERTY_AUTH_PASSWORD);
- list.push_back("server.address");
- list.push_back("server.port");
- list.push_back("server.socket-factory");
+ list.push_back(p.PROPERTY_SERVER_ADDRESS);
+ list.push_back(p.PROPERTY_SERVER_PORT);
+ list.push_back(p.PROPERTY_SERVER_SOCKETFACTORY);
- list.push_back("timeout.factory");
+ list.push_back(p.PROPERTY_TIMEOUT_FACTORY);
return (list);
}
+
} // imap
} // messaging
} // vmime
diff --git a/src/messaging/maildir/maildirStore.cpp b/src/messaging/maildir/maildirStore.cpp
index 7188a281..87204299 100644
--- a/src/messaging/maildir/maildirStore.cpp
+++ b/src/messaging/maildir/maildirStore.cpp
@@ -27,6 +27,13 @@
#include "vmime/platformDependant.hpp"
+// Helpers for service properties
+#define GET_PROPERTY(type, prop) \
+ (sm_infos.getPropertyValue <type>(getSession(), sm_infos.getProperties().prop))
+#define HAS_PROPERTY(prop) \
+ (sm_infos.hasProperty(getSession(), sm_infos.getProperties().prop))
+
+
namespace vmime {
namespace messaging {
namespace maildir {
@@ -108,8 +115,7 @@ void maildirStore::connect()
// Get root directory
utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory();
- m_fsPath = fsf->stringToPath
- (getSession()->getProperties()[getInfos().getPropertyPrefix() + "server.rootpath"]);
+ m_fsPath = fsf->stringToPath(GET_PROPERTY(string, PROPERTY_SERVER_ROOTPATH));
utility::auto_ptr <utility::file> rootDir = fsf->create(m_fsPath);
@@ -181,10 +187,10 @@ const int maildirStore::getCapabilities() const
CAPABILITY_RENAME_FOLDER |
CAPABILITY_ADD_MESSAGE |
CAPABILITY_COPY_MESSAGE |
- CAPABILITY_DELETE_MESSAGE |
+ CAPABILITY_DELETE_MESSAGE |
CAPABILITY_PARTIAL_FETCH |
CAPABILITY_MESSAGE_FLAGS |
- CAPABILITY_EXTRACT_PART);
+ CAPABILITY_EXTRACT_PART);
}
@@ -207,23 +213,30 @@ const serviceInfos& maildirStore::getInfos() const
}
-const port_t maildirStore::_infos::getDefaultPort() const
+const string maildirStore::_infos::getPropertyPrefix() const
{
- return (0);
+ return "store.maildir.";
}
-const string maildirStore::_infos::getPropertyPrefix() const
+const maildirStore::_infos::props& maildirStore::_infos::getProperties() const
{
- return "store.maildir.";
+ static props p =
+ {
+ property(serviceInfos::property::SERVER_ROOTPATH, serviceInfos::property::FLAG_REQUIRED)
+ };
+
+ return p;
}
-const std::vector <string> maildirStore::_infos::getAvailableProperties() const
+const std::vector <serviceInfos::property> maildirStore::_infos::getAvailableProperties() const
{
- std::vector <string> list;
+ std::vector <property> list;
+ const props& p = getProperties();
- list.push_back("server.rootpath");
+ // Maildir-specific properties
+ list.push_back(p.PROPERTY_SERVER_ROOTPATH);
return (list);
}
diff --git a/src/messaging/pop3/POP3Store.cpp b/src/messaging/pop3/POP3Store.cpp
index 69e09bc6..032a8f6f 100644
--- a/src/messaging/pop3/POP3Store.cpp
+++ b/src/messaging/pop3/POP3Store.cpp
@@ -28,6 +28,13 @@
#include <algorithm>
+// Helpers for service properties
+#define GET_PROPERTY(type, prop) \
+ (sm_infos.getPropertyValue <type>(getSession(), sm_infos.getProperties().prop))
+#define HAS_PROPERTY(prop) \
+ (sm_infos.hasProperty(getSession(), sm_infos.getProperties().prop))
+
+
namespace vmime {
namespace messaging {
namespace pop3 {
@@ -93,23 +100,21 @@ void POP3Store::connect()
if (isConnected())
throw exceptions::already_connected();
- const string address = getSession()->getProperties()[sm_infos.getPropertyPrefix() + "server.address"];
- const port_t port = getSession()->getProperties().getProperty(sm_infos.getPropertyPrefix() + "server.port", sm_infos.getDefaultPort());
+ const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
+ const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
// Create the time-out handler
- if (getSession()->getProperties().hasProperty
- (sm_infos.getPropertyPrefix() + "timeout.factory"))
+ if (HAS_PROPERTY(PROPERTY_TIMEOUT_FACTORY))
{
timeoutHandlerFactory* tof = platformDependant::getHandler()->
- getTimeoutHandlerFactory(getSession()->getProperties()
- [sm_infos.getPropertyPrefix() + "timeout.factory"]);
+ getTimeoutHandlerFactory(GET_PROPERTY(string, PROPERTY_TIMEOUT_FACTORY));
m_timeoutHandler = tof->create();
}
// Create and connect the socket
- socketFactory* sf = platformDependant::getHandler()->getSocketFactory
- (getSession()->getProperties().getProperty(sm_infos.getPropertyPrefix() + "server.socket-factory", string("default")));
+ socketFactory* sf = platformDependant::getHandler()->
+ getSocketFactory(GET_PROPERTY(string, PROPERTY_SERVER_SOCKETFACTORY));
m_socket = sf->create();
m_socket->connect(address, port);
@@ -134,7 +139,7 @@ void POP3Store::connect()
// --- S: +OK vincent is a valid mailbox
messageId mid(response);
- if (getSession()->getProperties().getProperty(sm_infos.getPropertyPrefix() + "options.apop", false))
+ if (GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP))
{
if (mid.getLeft().length() && mid.getRight().length())
{
@@ -149,8 +154,7 @@ void POP3Store::connect()
}
else
{
- if (getSession()->getProperties().getProperty(sm_infos.getPropertyPrefix() +
- "options.apop.fallback", false) == false)
+ if (!GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP_FALLBACK))
{
internalDisconnect();
throw exceptions::authentication_error(response);
@@ -160,8 +164,7 @@ void POP3Store::connect()
else
{
// APOP not supported
- if (getSession()->getProperties().getProperty(sm_infos.getPropertyPrefix() +
- "options.apop.fallback", false) == false)
+ if (!GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP_FALLBACK))
{
// Can't fallback on basic authentification
internalDisconnect();
@@ -591,35 +594,53 @@ const serviceInfos& POP3Store::getInfos() const
}
-const port_t POP3Store::_infos::getDefaultPort() const
+const string POP3Store::_infos::getPropertyPrefix() const
{
- return (110);
+ return "store.pop3.";
}
-const string POP3Store::_infos::getPropertyPrefix() const
+const POP3Store::_infos::props& POP3Store::_infos::getProperties() const
{
- return "store.pop3.";
+ static props p =
+ {
+ // POP3-specific options
+ property("options.apop", serviceInfos::property::TYPE_BOOL, "false"),
+ property("options.apop.fallback", serviceInfos::property::TYPE_BOOL, "false"),
+
+ // Common properties
+ property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED),
+ property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED),
+
+ property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
+ property(serviceInfos::property::SERVER_PORT, "110"),
+ property(serviceInfos::property::SERVER_SOCKETFACTORY),
+
+ property(serviceInfos::property::TIMEOUT_FACTORY)
+ };
+
+ return p;
}
-const std::vector <string> POP3Store::_infos::getAvailableProperties() const
+const std::vector <serviceInfos::property> POP3Store::_infos::getAvailableProperties() const
{
- std::vector <string> list;
+ std::vector <property> list;
+ const props& p = getProperties();
// POP3-specific options
- list.push_back("options.apop");
- list.push_back("options.apop.fallback");
+ list.push_back(p.PROPERTY_OPTIONS_APOP);
+ list.push_back(p.PROPERTY_OPTIONS_APOP_FALLBACK);
// Common properties
- list.push_back("auth.username");
- list.push_back("auth.password");
+ list.push_back(p.PROPERTY_AUTH_USERNAME);
+ list.push_back(p.PROPERTY_AUTH_PASSWORD);
- list.push_back("server.address");
- list.push_back("server.port");
- list.push_back("server.socket-factory");
+ list.push_back(p.PROPERTY_SERVER_ADDRESS);
+ list.push_back(p.PROPERTY_SERVER_PORT);
+ list.push_back(p.PROPERTY_SERVER_SOCKETFACTORY);
- list.push_back("timeout.factory");
+ list.push_back(p.PROPERTY_TIMEOUT_FACTORY);
return (list);
}
diff --git a/src/messaging/sendmail/sendmailTransport.cpp b/src/messaging/sendmail/sendmailTransport.cpp
index 1d4d2361..969cb7ae 100644
--- a/src/messaging/sendmail/sendmailTransport.cpp
+++ b/src/messaging/sendmail/sendmailTransport.cpp
@@ -28,6 +28,15 @@
#include "vmime/utility/childProcess.hpp"
#include "vmime/utility/smartPtr.hpp"
+#include "vmime/config.hpp"
+
+
+// Helpers for service properties
+#define GET_PROPERTY(type, prop) \
+ (sm_infos.getPropertyValue <type>(getSession(), sm_infos.getProperties().prop))
+#define HAS_PROPERTY(prop) \
+ (sm_infos.hasProperty(getSession(), sm_infos.getProperties().prop))
+
#if VMIME_BUILTIN_PLATFORM_POSIX
@@ -62,8 +71,7 @@ void sendmailTransport::connect()
throw exceptions::already_connected();
// Use the specified path for 'sendmail' or a default one if no path is specified
- m_sendmailPath = getSession()->getProperties().getProperty
- (sm_infos.getPropertyPrefix() + "binpath", string(VMIME_SENDMAIL_PATH));
+ m_sendmailPath = GET_PROPERTY(string, PROPERTY_BINPATH);
m_connected = true;
}
@@ -177,24 +185,30 @@ const serviceInfos& sendmailTransport::getInfos() const
}
-const port_t sendmailTransport::_infos::getDefaultPort() const
+const string sendmailTransport::_infos::getPropertyPrefix() const
{
- return (0);
+ return "transport.sendmail.";
}
-const string sendmailTransport::_infos::getPropertyPrefix() const
+const sendmailTransport::_infos::props& sendmailTransport::_infos::getProperties() const
{
- return "transport.sendmail.";
+ static props p =
+ {
+ // Path to sendmail (override default)
+ property("binpath", serviceInfos::property::TYPE_STRING, string(VMIME_SENDMAIL_PATH))
+ };
+
+ return p;
}
-const std::vector <string> sendmailTransport::_infos::getAvailableProperties() const
+const std::vector <serviceInfos::property> sendmailTransport::_infos::getAvailableProperties() const
{
- std::vector <string> list;
+ std::vector <property> list;
+ const props& p = getProperties();
- // Path to sendmail (override default)
- list.push_back("binpath");
+ list.push_back(p.PROPERTY_BINPATH);
return (list);
}
diff --git a/src/messaging/serviceInfos.cpp b/src/messaging/serviceInfos.cpp
new file mode 100644
index 00000000..685ccf3e
--- /dev/null
+++ b/src/messaging/serviceInfos.cpp
@@ -0,0 +1,150 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+
+#include "vmime/messaging/serviceInfos.hpp"
+
+
+namespace vmime {
+namespace messaging {
+
+
+// Common properties
+const serviceInfos::property serviceInfos::property::SERVER_ADDRESS
+ ("server.address", serviceInfos::property::TYPE_STRING);
+
+const serviceInfos::property serviceInfos::property::SERVER_PORT
+ ("server.port", serviceInfos::property::TYPE_INTEGER);
+
+const serviceInfos::property serviceInfos::property::SERVER_ROOTPATH
+ ("server.rootpath", serviceInfos::property::TYPE_STRING);
+
+const serviceInfos::property serviceInfos::property::SERVER_SOCKETFACTORY
+ ("server.socket-factory", serviceInfos::property::TYPE_STRING, "default");
+
+const serviceInfos::property serviceInfos::property::AUTH_USERNAME
+ ("auth.username", serviceInfos::property::TYPE_STRING);
+
+const serviceInfos::property serviceInfos::property::AUTH_PASSWORD
+ ("auth.password", serviceInfos::property::TYPE_STRING);
+
+const serviceInfos::property serviceInfos::property::TIMEOUT_FACTORY
+ ("timeout.factory", serviceInfos::property::TYPE_STRING);
+
+
+
+// serviceInfos
+
+serviceInfos::serviceInfos()
+{
+}
+
+
+serviceInfos::serviceInfos(const serviceInfos&)
+{
+}
+
+
+serviceInfos& serviceInfos::operator=(const serviceInfos&)
+{
+ return (*this);
+}
+
+
+serviceInfos::~serviceInfos()
+{
+}
+
+
+const bool serviceInfos::hasProperty(session* s, const property& p) const
+{
+ return s->getProperties().hasProperty(getPropertyPrefix() + p.getName());
+}
+
+
+
+// serviceInfos::property
+
+serviceInfos::property::property
+ (const string& name, const Types type,
+ const string& defaultValue, const int flags)
+ : m_name(name), m_defaultValue(defaultValue),
+ m_type(type), m_flags(flags)
+{
+}
+
+
+serviceInfos::property::property
+ (const property& p, const int addFlags, const int removeFlags)
+{
+ m_name = p.m_name;
+ m_type = p.m_type;
+ m_defaultValue = p.m_defaultValue;
+ m_flags = (p.m_flags | addFlags) & ~removeFlags;
+}
+
+
+serviceInfos::property::property
+ (const property& p, const string& newDefaultValue,
+ const int addFlags, const int removeFlags)
+{
+ m_name = p.m_name;
+ m_type = p.m_type;
+ m_defaultValue = newDefaultValue;
+ m_flags = (p.m_flags | addFlags) & ~removeFlags;
+}
+
+
+serviceInfos::property& serviceInfos::property::operator=(const property& p)
+{
+ m_name = p.m_name;
+ m_type = p.m_type;
+ m_defaultValue = p.m_defaultValue;
+ m_flags = p.m_flags;
+
+ return (*this);
+}
+
+
+const string& serviceInfos::property::getName() const
+{
+ return (m_name);
+}
+
+
+const string& serviceInfos::property::getDefaultValue() const
+{
+ return (m_defaultValue);
+}
+
+
+const serviceInfos::property::Types serviceInfos::property::getType() const
+{
+ return (m_type);
+}
+
+
+const int serviceInfos::property::getFlags() const
+{
+ return (m_flags);
+}
+
+
+} // messaging
+} // vmime
+
diff --git a/src/messaging/smtp/SMTPTransport.cpp b/src/messaging/smtp/SMTPTransport.cpp
index 4f7df174..a32b0c95 100644
--- a/src/messaging/smtp/SMTPTransport.cpp
+++ b/src/messaging/smtp/SMTPTransport.cpp
@@ -29,6 +29,13 @@
#include "vmime/utility/filteredStream.hpp"
+// Helpers for service properties
+#define GET_PROPERTY(type, prop) \
+ (sm_infos.getPropertyValue <type>(getSession(), sm_infos.getProperties().prop))
+#define HAS_PROPERTY(prop) \
+ (sm_infos.hasProperty(getSession(), sm_infos.getProperties().prop))
+
+
namespace vmime {
namespace messaging {
namespace smtp {
@@ -61,23 +68,21 @@ void SMTPTransport::connect()
if (isConnected())
throw exceptions::already_connected();
- const string address = getSession()->getProperties()[sm_infos.getPropertyPrefix() + "server.address"];
- const port_t port = getSession()->getProperties().getProperty(sm_infos.getPropertyPrefix() + "server.port", sm_infos.getDefaultPort());
+ const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
+ const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
// Create the time-out handler
- if (getSession()->getProperties().hasProperty
- (sm_infos.getPropertyPrefix() + "timeout.factory"))
+ if (HAS_PROPERTY(PROPERTY_TIMEOUT_FACTORY))
{
timeoutHandlerFactory* tof = platformDependant::getHandler()->
- getTimeoutHandlerFactory(getSession()->getProperties()
- [sm_infos.getPropertyPrefix() + "timeout.factory"]);
+ getTimeoutHandlerFactory(GET_PROPERTY(string, PROPERTY_TIMEOUT_FACTORY));
m_timeoutHandler = tof->create();
}
// Create and connect the socket
- socketFactory* sf = platformDependant::getHandler()->getSocketFactory
- (getSession()->getProperties().getProperty(sm_infos.getPropertyPrefix() + "server.socket-factory", string("default")));
+ socketFactory* sf = platformDependant::getHandler()->
+ getSocketFactory(GET_PROPERTY(string, PROPERTY_SERVER_SOCKETFACTORY));
m_socket = sf->create();
m_socket->connect(address, port);
@@ -129,8 +134,7 @@ void SMTPTransport::connect()
}
// Authentication
- if (getSession()->getProperties().getProperty
- (sm_infos.getPropertyPrefix() + "options.need-authentication", false) == true)
+ if (GET_PROPERTY(bool, PROPERTY_OPTIONS_NEEDAUTH))
{
if (!m_extendedSMTP)
{
@@ -447,34 +451,51 @@ const serviceInfos& SMTPTransport::getInfos() const
}
-const port_t SMTPTransport::_infos::getDefaultPort() const
+const string SMTPTransport::_infos::getPropertyPrefix() const
{
- return (25);
+ return "transport.smtp.";
}
-const string SMTPTransport::_infos::getPropertyPrefix() const
+const SMTPTransport::_infos::props& SMTPTransport::_infos::getProperties() const
{
- return "transport.smtp.";
+ static props p =
+ {
+ // SMTP-specific options
+ property("options.need-authentication", serviceInfos::property::TYPE_BOOL, "false"),
+
+ // Common properties
+ property(serviceInfos::property::AUTH_USERNAME),
+ property(serviceInfos::property::AUTH_PASSWORD),
+
+ property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
+ property(serviceInfos::property::SERVER_PORT, "25"),
+ property(serviceInfos::property::SERVER_SOCKETFACTORY),
+
+ property(serviceInfos::property::TIMEOUT_FACTORY)
+ };
+
+ return p;
}
-const std::vector <string> SMTPTransport::_infos::getAvailableProperties() const
+const std::vector <serviceInfos::property> SMTPTransport::_infos::getAvailableProperties() const
{
- std::vector <string> list;
+ std::vector <property> list;
+ const props& p = getProperties();
// SMTP-specific options
- list.push_back("options.need-authentication");
+ list.push_back(p.PROPERTY_OPTIONS_NEEDAUTH);
// Common properties
- list.push_back("auth.username");
- list.push_back("auth.password");
+ list.push_back(p.PROPERTY_AUTH_USERNAME);
+ list.push_back(p.PROPERTY_AUTH_PASSWORD);
- list.push_back("server.address");
- list.push_back("server.port");
- list.push_back("server.socket-factory");
+ list.push_back(p.PROPERTY_SERVER_ADDRESS);
+ list.push_back(p.PROPERTY_SERVER_PORT);
+ list.push_back(p.PROPERTY_SERVER_SOCKETFACTORY);
- list.push_back("timeout.factory");
+ list.push_back(p.PROPERTY_TIMEOUT_FACTORY);
return (list);
}