email/pop3andsmtpmtm/clientmtms/src/cimsmtpmobilitysettings.cpp
changeset 31 ebfee66fde93
parent 0 72b543305e3a
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "cimsmtpmobilitysettings.h"
       
    17 #include <smtpset.h>
       
    18 
       
    19 /**
       
    20 Factory constructor
       
    21 */
       
    22 EXPORT_C CImSmtpMobilitySettings* CImSmtpMobilitySettings::NewL()
       
    23 	{
       
    24 	CImSmtpMobilitySettings* self = NewLC();
       
    25 	CleanupStack::Pop();
       
    26 	return self;
       
    27 	}
       
    28 
       
    29 /**
       
    30 Factory constructor
       
    31 */
       
    32 EXPORT_C CImSmtpMobilitySettings* CImSmtpMobilitySettings::NewLC()
       
    33 	{
       
    34 	CImSmtpMobilitySettings* self = new(ELeave) CImSmtpMobilitySettings();
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL();
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 /**
       
    41 Constructor
       
    42 */
       
    43 CImSmtpMobilitySettings::CImSmtpMobilitySettings()
       
    44 	{
       
    45 	}
       
    46 
       
    47 /**
       
    48 Second phase constructor
       
    49 */
       
    50 void CImSmtpMobilitySettings::ConstructL()
       
    51 	{
       
    52 	iSmtpSettings = new(ELeave) CImSmtpSettings();
       
    53 	}
       
    54 
       
    55 /**
       
    56 Destructor
       
    57 */
       
    58 CImSmtpMobilitySettings::~CImSmtpMobilitySettings()
       
    59 	{
       
    60 	delete iSmtpSettings;
       
    61 	}
       
    62 
       
    63 /**
       
    64 Creates copy of class instance
       
    65 */
       
    66 EXPORT_C CImSmtpMobilitySettings* CImSmtpMobilitySettings::CopyL()
       
    67 	{
       
    68 	CImSmtpMobilitySettings* dest = CopyLC();
       
    69 	CleanupStack::Pop();
       
    70 	return dest;
       
    71 	}
       
    72 
       
    73 /**
       
    74 Creates copy of class instance
       
    75 */
       
    76 EXPORT_C CImSmtpMobilitySettings* CImSmtpMobilitySettings::CopyLC()
       
    77 	{
       
    78 	CImSmtpMobilitySettings* dest = NewLC();
       
    79 
       
    80 	dest->SetServerAddressL(ServerAddress());
       
    81 	dest->SetPort(Port());
       
    82 	dest->SetSecureSockets(SecureSockets());
       
    83 	dest->SetSSLWrapper(SSLWrapper());
       
    84 	dest->SetEmailAliasL(EmailAlias());
       
    85 	dest->SetEmailAddressL(EmailAddress());
       
    86 	dest->SetDefaultMsgCharSet(DefaultMsgCharSet());
       
    87 	dest->SetLoginNameL(LoginName());
       
    88 	dest->SetPasswordL(Password());
       
    89 	dest->SetSMTPAuth(SMTPAuth());
       
    90 	dest->SetTlsSslDomainL(TlsSslDomain());
       
    91 
       
    92 	return dest;
       
    93 	}
       
    94 
       
    95 /**
       
    96 Reset settings to default values
       
    97 */
       
    98 EXPORT_C void CImSmtpMobilitySettings::Reset()
       
    99 	{
       
   100 	iSmtpSettings->Reset();
       
   101 	}
       
   102 
       
   103 /**
       
   104 Sets the configured IP address or host name of the outbound SMTP email server
       
   105 
       
   106 @param aServerAddress Outbound email server address to set
       
   107 */
       
   108 EXPORT_C void CImSmtpMobilitySettings::SetServerAddressL(const TDesC& aServerAddress)
       
   109 	{
       
   110 	iSmtpSettings->SetServerAddressL(aServerAddress);
       
   111 	}
       
   112 
       
   113 /**
       
   114 Gets the configured IP address or host name of the outbound SMTP email server
       
   115 
       
   116 @return Outbound SMTP email server address
       
   117 */
       
   118 EXPORT_C const TPtrC CImSmtpMobilitySettings::ServerAddress() const
       
   119 	{
       
   120 	return iSmtpSettings->ServerAddress();
       
   121 	}
       
   122 
       
   123 /**
       
   124 Sets the port number of the TCP connection to the outbound SMTP email server
       
   125 
       
   126 Defaults to port 25
       
   127 
       
   128 @param aPortNumber Port number
       
   129 */
       
   130 EXPORT_C void CImSmtpMobilitySettings::SetPort(const TUint aPortNumber)
       
   131 	{
       
   132 	iSmtpSettings->SetPort(aPortNumber);
       
   133 	}
       
   134 
       
   135 /**
       
   136 Gets the port number to use for the TCP connection to the outbound SMTP email
       
   137 server
       
   138 
       
   139 @return Port number
       
   140 */
       
   141 EXPORT_C TUint CImSmtpMobilitySettings::Port() const
       
   142 	{
       
   143 	return iSmtpSettings->Port();
       
   144 	}
       
   145 
       
   146 /**
       
   147 Sets whether a secure TLS connection will be negotiated over a non-secure
       
   148 socket when a connection to the outbound SMTP email server is being
       
   149 established.
       
   150 
       
   151 Refer to RFC 3207 - "SMTP Service Extension for Secure SMTP over Transport
       
   152 Layer Security" for information on how a secure socket is established when
       
   153 sending an email. 
       
   154 
       
   155 Not all SMTP servers support this protocol
       
   156 
       
   157 @param aFlag ETrue if a secure socket session will be negotiated after
       
   158        establishing a non-secure TCP connection with the SMTP server.
       
   159 */
       
   160 EXPORT_C void CImSmtpMobilitySettings::SetSecureSockets(TBool aFlag)
       
   161 	{
       
   162 	iSmtpSettings->SetSecureSockets(aFlag);
       
   163 	}
       
   164 
       
   165 /**
       
   166 Gets whether a secure TLS connection will be negotiated over a non-secure
       
   167 TCP socket connection when a connection to the outbound SMTP email server
       
   168 is being established.
       
   169 
       
   170 Refer to RFC 3207 - "SMTP Service Extension for Secure SMTP over Transport
       
   171 Layer Security" for information on how a secure socket is established when
       
   172 sending an email. 
       
   173 
       
   174 @return ETrue if a secure socket session will be negotiated after
       
   175         establishing a non-secure TCP connection with the SMTP server.
       
   176 */
       
   177 EXPORT_C TBool CImSmtpMobilitySettings::SecureSockets() const
       
   178 	{
       
   179 	return iSmtpSettings->SecureSockets();
       
   180 	}
       
   181 
       
   182 /**
       
   183 Sets whether a secure TLS connection will be established directly over a
       
   184 TLS/SSL socket when connecting to the outbound SMTP email server
       
   185 
       
   186 The port number upon which the connection is attempted is configured by
       
   187 calling SetPort(). 
       
   188 */
       
   189 EXPORT_C void CImSmtpMobilitySettings::SetSSLWrapper(TBool aFlag)
       
   190 	{
       
   191 	iSmtpSettings->SetSSLWrapper(aFlag);
       
   192 	}
       
   193 
       
   194 /**
       
   195 Gets whether a secure TLS connection will be established directly over a
       
   196 TLS/SSL socket when connecting to the outbound SMTP email server
       
   197 */
       
   198 EXPORT_C TBool CImSmtpMobilitySettings::SSLWrapper() const
       
   199 	{
       
   200 	return iSmtpSettings->SSLWrapper();
       
   201 	}
       
   202 
       
   203 /**
       
   204 Sets the email alias (display name) that will be sent with outbound email.
       
   205 
       
   206 @param aEmailAlias Email alias
       
   207 */
       
   208 EXPORT_C void CImSmtpMobilitySettings::SetEmailAliasL(const TDesC& aEmailAlias)
       
   209 	{
       
   210 	iSmtpSettings->SetEmailAliasL(aEmailAlias);
       
   211 	}
       
   212 
       
   213 /**
       
   214 Gets the email alias (display name) that will be sent with outbound email.
       
   215 
       
   216 @return Email alias
       
   217 */
       
   218 EXPORT_C const TPtrC CImSmtpMobilitySettings::EmailAlias() const
       
   219 	{
       
   220 	return iSmtpSettings->EmailAlias();
       
   221 	}
       
   222 
       
   223 /**
       
   224 Sets the SMTP email address of the user
       
   225 
       
   226 @param aEmailAddress SMTP email address of the user.
       
   227 */
       
   228 EXPORT_C void CImSmtpMobilitySettings::SetEmailAddressL(const TDesC& aEmailAddress)
       
   229 	{
       
   230 	iSmtpSettings->SetEmailAddressL(aEmailAddress);
       
   231 	}
       
   232 
       
   233 /**
       
   234 Gets the SMTP email address of the user
       
   235 
       
   236 @return SMTP email address of the user.
       
   237 */
       
   238 EXPORT_C const TPtrC CImSmtpMobilitySettings::EmailAddress() const
       
   239 	{
       
   240 	return iSmtpSettings->EmailAddress();
       
   241 	}
       
   242 
       
   243 /**
       
   244 Sets which character set is used to send text in MIME email messages.
       
   245 
       
   246 The default character set is ISO-8859-1 (Latin 1). The UIDs used to identify 
       
   247 all character sets are defined in the Character Conversion API. 
       
   248 
       
   249 @param aDefaultMsgCharSet Character set identifier
       
   250 */
       
   251 EXPORT_C void CImSmtpMobilitySettings::SetDefaultMsgCharSet(TUid aDefaultMsgCharSet)
       
   252 	{
       
   253 	iSmtpSettings->SetDefaultMsgCharSet(aDefaultMsgCharSet);
       
   254 	}
       
   255 
       
   256 /**
       
   257 Gets which character set is used to send text in MIME email messages.
       
   258 
       
   259 @return Character set identifier
       
   260 */
       
   261 EXPORT_C const TUid CImSmtpMobilitySettings::DefaultMsgCharSet() const
       
   262 	{
       
   263 	return iSmtpSettings->DefaultMsgCharSet();
       
   264 	}
       
   265 
       
   266 /**
       
   267 Sets the login user name to use for SMTP authentication
       
   268 
       
   269 @param aLoginName Login user name
       
   270 */
       
   271 EXPORT_C void CImSmtpMobilitySettings::SetLoginNameL(const TDesC8& aLoginName)
       
   272 	{
       
   273 	iSmtpSettings->SetLoginNameL(aLoginName);
       
   274 	}
       
   275 
       
   276 /**
       
   277 Gets the login user name used for SMTP authentication
       
   278 
       
   279 @return Login user name
       
   280 */
       
   281 EXPORT_C const TPtrC8 CImSmtpMobilitySettings::LoginName() const
       
   282 	{
       
   283 	return iSmtpSettings->LoginName();
       
   284 	}
       
   285 
       
   286 /**
       
   287 Sets the password to use for SMTP authentication
       
   288 
       
   289 @param aPassword Password
       
   290 */
       
   291 EXPORT_C void CImSmtpMobilitySettings::SetPasswordL(const TDesC8& aPassword)
       
   292 	{
       
   293 	iSmtpSettings->SetPasswordL(aPassword);
       
   294 	}
       
   295 
       
   296 /**
       
   297 Gets the password used for SMTP authentication
       
   298 
       
   299 @return Password
       
   300 */
       
   301 EXPORT_C const TPtrC8 CImSmtpMobilitySettings::Password() const
       
   302 	{
       
   303 	return iSmtpSettings->Password();
       
   304 	}
       
   305 
       
   306 /**
       
   307 Sets whether SMTP authentication is used when sending emails.
       
   308 
       
   309 See RFC 2554 "SMTP Service Extension for Authentication" for more details.
       
   310 
       
   311 @param aFlag ETrue to enable SMTP authentication, EFalse to disable it.
       
   312 */
       
   313 EXPORT_C void CImSmtpMobilitySettings::SetSMTPAuth(TBool aFlag)
       
   314 	{
       
   315 	iSmtpSettings->SetSMTPAuth(aFlag);
       
   316 	}
       
   317 
       
   318 /**
       
   319 Gets whether SMTP authentication is used when sending emails.
       
   320 
       
   321 @return ETrue if SMTP authentication is enabled, EFalse if disabled
       
   322 */
       
   323 EXPORT_C TBool CImSmtpMobilitySettings::SMTPAuth() const
       
   324 	{
       
   325 	return iSmtpSettings->SMTPAuth();
       
   326 	}
       
   327 
       
   328 /**
       
   329 Sets the domain name to use during TLS/SSL certificate validation.
       
   330 
       
   331 @param aDomainName Domain name
       
   332 */
       
   333 EXPORT_C void CImSmtpMobilitySettings::SetTlsSslDomainL(const TDesC8& aDomainName)
       
   334 	{
       
   335 	iSmtpSettings->SetTlsSslDomainL(aDomainName);
       
   336 	}
       
   337 
       
   338 /**
       
   339 Gets the domain name to use during TLS/SSL certificate validation.
       
   340 
       
   341 @return Domain name
       
   342 */
       
   343 EXPORT_C TPtrC8 CImSmtpMobilitySettings::TlsSslDomain() const
       
   344 	{
       
   345 	return iSmtpSettings->TlsSslDomain();
       
   346 	}
       
   347 
       
   348 /**
       
   349 Sets the SMTP settings to a new value
       
   350 
       
   351 @param aSettings New SMTP settings
       
   352 */
       
   353 void CImSmtpMobilitySettings::SetSmtpSettings(CImSmtpSettings* aSettings)
       
   354 	{
       
   355 	delete iSmtpSettings;
       
   356 	iSmtpSettings = aSettings;
       
   357 	}
       
   358 
       
   359 /**
       
   360 Gets the SMTP settings
       
   361 
       
   362 @return SMTP settings
       
   363 */
       
   364 CImSmtpSettings& CImSmtpMobilitySettings::SmtpSettings() const
       
   365 	{
       
   366 	return *iSmtpSettings;
       
   367 	}