email/pop3andsmtpmtm/smtpservermtm/src/csmtpsettings.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 "csmtpsettings.h"
       
    17 #include <cimsmtpmobilitysettings.h>
       
    18 #include <iapprefs.h>
       
    19 #include <msventry.h>
       
    20 
       
    21 /**
       
    22 Factory constructor
       
    23 */
       
    24 CSmtpSettings* CSmtpSettings::NewL(const CMsvServerEntry& aServerEntry)
       
    25 	{
       
    26 	CSmtpSettings* self = new (ELeave) CSmtpSettings(aServerEntry);
       
    27 	CleanupStack::PushL(self);
       
    28 	self->ConstructL(aServerEntry);
       
    29 	CleanupStack::Pop(self);
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 /**
       
    34 Constructor
       
    35 */
       
    36 CSmtpSettings::CSmtpSettings(const CMsvServerEntry& aServerEntry) :
       
    37  iSmtpAccountId(aServerEntry.Entry().MtmData2())
       
    38 	{
       
    39 	}
       
    40 
       
    41 /**
       
    42 Second phase constructor
       
    43 */
       
    44 void CSmtpSettings::ConstructL(const CMsvServerEntry& aServerEntry)
       
    45 	{
       
    46 	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
       
    47 
       
    48 	iDefaultSettings = new(ELeave) CImSmtpSettings;
       
    49 	iIapPrefs= CImIAPPreferences::NewLC();
       
    50 	CleanupStack::Pop();
       
    51 
       
    52 	TSmtpAccount id;
       
    53 	id.iSmtpAccountId = iSmtpAccountId;
       
    54 	id.iSmtpAccountName = aServerEntry.Entry().iDetails;
       
    55 	id.iSmtpService = aServerEntry.Entry().iServiceId;
       
    56 	id.iRelatedService = aServerEntry.Entry().iRelatedId;
       
    57 
       
    58 	emailAccounts->LoadSmtpSettingsL(id, *iDefaultSettings);
       
    59 	emailAccounts->LoadSmtpIapSettingsL(id, *iIapPrefs);
       
    60 
       
    61  	CleanupStack::PopAndDestroy(emailAccounts);
       
    62 	}
       
    63 
       
    64 /**
       
    65 Destructor
       
    66 */
       
    67 CSmtpSettings::~CSmtpSettings()
       
    68 	{
       
    69 	delete iDefaultSettings;
       
    70 	delete iIapSettings;
       
    71 	delete iIapPrefs;
       
    72 	}
       
    73 
       
    74 /**
       
    75 Sets the IAP currently in use.
       
    76 The class will be updated to use the settings specific to that IAP
       
    77 
       
    78 @param aIap IAP in use
       
    79 */
       
    80 void CSmtpSettings::SetIapL(TUint32 aIap)
       
    81 	{
       
    82 	delete iIapSettings;
       
    83 	iIapSettings = NULL;
       
    84 
       
    85 	if (aIap != KDefaultSettingsIap)
       
    86 		{
       
    87 		CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
       
    88 
       
    89 		CImSmtpMobilitySettings* newSettings = CImSmtpMobilitySettings::NewLC();
       
    90 
       
    91 		if (emailAccounts->LoadSmtpMobilitySettingsL(iSmtpAccountId, aIap, *newSettings))
       
    92 			{
       
    93 			CleanupStack::Pop(newSettings);
       
    94 			iIapSettings = newSettings;
       
    95 			}
       
    96 		else
       
    97 			{
       
    98 			CleanupStack::PopAndDestroy(newSettings);
       
    99 			}
       
   100 
       
   101 		CleanupStack::PopAndDestroy(emailAccounts);
       
   102 		}
       
   103 	}
       
   104 
       
   105 /**
       
   106 Get the IAP preferences
       
   107 
       
   108 @return IAP preferences
       
   109 */
       
   110 CImIAPPreferences& CSmtpSettings::IapPrefs()
       
   111 	{
       
   112 	return *iIapPrefs;
       
   113 	}
       
   114 
       
   115 /**
       
   116 Get server address
       
   117 
       
   118 @see CImSmtpSettings::ServerAddress()
       
   119 @see CImSmtpMobilitySettings::ServerAddress()
       
   120 
       
   121 @return Server address
       
   122 */
       
   123 const TPtrC CSmtpSettings::ServerAddress() const
       
   124 	{
       
   125 	if (iIapSettings)
       
   126 		{
       
   127 		return iIapSettings->ServerAddress();
       
   128 		}
       
   129 	else
       
   130 		{
       
   131 		return iDefaultSettings->ServerAddress();
       
   132 		}
       
   133 	}
       
   134 
       
   135 /**
       
   136 Get TCP port
       
   137 
       
   138 @see CImSmtpSettings::Port()
       
   139 @see CImSmtpMobilitySettings::Port()
       
   140 
       
   141 @return TCP port
       
   142 */
       
   143 TUint CSmtpSettings::Port() const
       
   144 	{
       
   145 	if (iIapSettings)
       
   146 		{
       
   147 		return iIapSettings->Port();
       
   148 		}
       
   149 	else
       
   150 		{
       
   151 		return iDefaultSettings->Port();
       
   152 		}	
       
   153 	}
       
   154 
       
   155 /**
       
   156 Get secure sockets flag
       
   157 
       
   158 @see CImSmtpSettings::SecureSockets()
       
   159 @see CImSmtpMobilitySettings::SecureSockets()
       
   160 
       
   161 @return ETrue if secure sockets flag is set, EFalse if not
       
   162 */
       
   163 TBool CSmtpSettings::SecureSockets() const
       
   164 	{
       
   165 	if (iIapSettings)
       
   166 		{
       
   167 		return iIapSettings->SecureSockets();
       
   168 		}
       
   169 	else
       
   170 		{
       
   171 		return iDefaultSettings->SecureSockets();
       
   172 		}
       
   173 	}
       
   174 
       
   175 /**
       
   176 Get SSL Wrapper flag
       
   177 
       
   178 @see CImSmtpSettings::SSLWrapper()
       
   179 @see CImSmtpMobilitySettings::SSLWrapper()
       
   180 
       
   181 @return ETrue if SSL wrapper flag is set, EFalse if not
       
   182 */
       
   183 TBool CSmtpSettings::SSLWrapper() const
       
   184 	{
       
   185 	if (iIapSettings)
       
   186 		{
       
   187 		return iIapSettings->SSLWrapper();
       
   188 		}
       
   189 	else
       
   190 		{
       
   191 		return iDefaultSettings->SSLWrapper();
       
   192 		}
       
   193 	}
       
   194 
       
   195 /**
       
   196 Get bearer mobility flag
       
   197 
       
   198 @see CImSmtpSettings::BearerMobility()
       
   199 
       
   200 @return ETrue if bearer mobility flag is set, EFalse if not
       
   201 */
       
   202 TBool CSmtpSettings::BearerMobility() const
       
   203 	{
       
   204 	return iDefaultSettings->BearerMobility();
       
   205 	}
       
   206 
       
   207 /**
       
   208 Get email alias
       
   209 
       
   210 @see CImSmtpSettings::EmailAlias()
       
   211 @see CImSmtpMobilitySettings::EmailAlias()
       
   212 
       
   213 @return Email alias
       
   214 */
       
   215 const TPtrC CSmtpSettings::EmailAlias() const
       
   216 	{
       
   217 	if (iIapSettings)
       
   218 		{
       
   219 		return iIapSettings->EmailAlias();
       
   220 		}
       
   221 	else
       
   222 		{
       
   223 		return iDefaultSettings->EmailAlias();
       
   224 		}
       
   225 	}
       
   226 
       
   227 /**
       
   228 Get email address
       
   229 
       
   230 @see CImSmtpSettings::EmailAddress()
       
   231 @see CImSmtpMobilitySettings::EmailAddress()
       
   232 
       
   233 @return Email address
       
   234 */
       
   235 const TPtrC CSmtpSettings::EmailAddress() const
       
   236 	{
       
   237 	if (iIapSettings)
       
   238 		{
       
   239 		return iIapSettings->EmailAddress();
       
   240 		}
       
   241 	else
       
   242 		{
       
   243 		return iDefaultSettings->EmailAddress();
       
   244 		}
       
   245 	}
       
   246 
       
   247 /**
       
   248 Get reply to address
       
   249 
       
   250 @see CImSmtpSettings::ReplyToAddress()
       
   251 
       
   252 @return Reply to address
       
   253 */
       
   254 const TPtrC CSmtpSettings::ReplyToAddress() const
       
   255 	{
       
   256 	return iDefaultSettings->ReplyToAddress();
       
   257 	}
       
   258 
       
   259 /**
       
   260 Get receipt address
       
   261 
       
   262 @see CImSmtpSettings::ReceiptAddress()
       
   263 
       
   264 @return Receipt address
       
   265 */
       
   266 const TPtrC CSmtpSettings::ReceiptAddress() const
       
   267 	{
       
   268 	return iDefaultSettings->ReceiptAddress();
       
   269 	}
       
   270 
       
   271 /**
       
   272 Get body encoding
       
   273 
       
   274 @see CImSmtpSettings::BodyEncoding()
       
   275 
       
   276 @return Body encoding
       
   277 */
       
   278 TMsgOutboxBodyEncoding CSmtpSettings::BodyEncoding() const
       
   279 	{
       
   280 	return iDefaultSettings->BodyEncoding();
       
   281 	}
       
   282 
       
   283 /**
       
   284 Get default message charset
       
   285 
       
   286 @see CImSmtpSettings::DefaultMsgCharSet()
       
   287 @see CImSmtpMobilitySettings::DefaultMsgCharSet()
       
   288 
       
   289 @return Default message charset
       
   290 */
       
   291 const TUid CSmtpSettings::DefaultMsgCharSet() const
       
   292 	{
       
   293 	if (iIapSettings)
       
   294 		{
       
   295 		return iIapSettings->DefaultMsgCharSet();
       
   296 		}
       
   297 	else
       
   298 		{
       
   299 		return iDefaultSettings->DefaultMsgCharSet();
       
   300 		}
       
   301 	}
       
   302 
       
   303 /**
       
   304 Get send copy to self option
       
   305 
       
   306 @see CImSmtpSettings::SendCopyToSelf()
       
   307 
       
   308 @return Send copy to self option
       
   309 */
       
   310 TImSMTPSendCopyToSelf CSmtpSettings::SendCopyToSelf() const
       
   311 	{
       
   312 	return iDefaultSettings->SendCopyToSelf();
       
   313 	}
       
   314 
       
   315 /**
       
   316 Get login name
       
   317 
       
   318 @see CImSmtpSettings::LoginName()
       
   319 @see CImSmtpMobilitySettings::LoginName()
       
   320 
       
   321 @return Login name
       
   322 */
       
   323 const TPtrC8 CSmtpSettings::LoginName() const
       
   324 	{
       
   325 	if (iIapSettings)
       
   326 		{
       
   327 		return iIapSettings->LoginName();
       
   328 		}
       
   329 	else
       
   330 		{
       
   331 		return iDefaultSettings->LoginName();
       
   332 		}
       
   333 	}
       
   334 
       
   335 /**
       
   336 Get password
       
   337 
       
   338 @see CImSmtpSettings::Password()
       
   339 @see CImSmtpMobilitySettings::Password()
       
   340 
       
   341 @return Password
       
   342 */
       
   343 const TPtrC8 CSmtpSettings::Password() const
       
   344 	{
       
   345 	if (iIapSettings)
       
   346 		{
       
   347 		return iIapSettings->Password();
       
   348 		}
       
   349 	else
       
   350 		{
       
   351 		return iDefaultSettings->Password();
       
   352 		}
       
   353 	}
       
   354 
       
   355 /**
       
   356 Get SMTP authentication flag
       
   357 
       
   358 @see CImSmtpSettings::()
       
   359 @see CImSmtpMobilitySettings::SMTPAuth()
       
   360 
       
   361 @return ETrue if SMTP authentication flag is set, EFalse if not
       
   362 */
       
   363 TBool CSmtpSettings::SMTPAuth() const
       
   364 	{
       
   365 	if (iIapSettings)
       
   366 		{
       
   367 		return iIapSettings->SMTPAuth();
       
   368 		}
       
   369 	else
       
   370 		{
       
   371 		return iDefaultSettings->SMTPAuth();
       
   372 		}
       
   373 	}
       
   374 
       
   375 /**
       
   376 Get TLS/SSL domain name
       
   377 
       
   378 @see CImSmtpSettings::TlsSslDomain()
       
   379 @see CImSmtpMobilitySettings::TlsSslDomain()
       
   380 
       
   381 @return TLS/SSL domain name
       
   382 */
       
   383 TPtrC8 CSmtpSettings::TlsSslDomain() const
       
   384 	{
       
   385 	if (iIapSettings)
       
   386 		{
       
   387 		return iIapSettings->TlsSslDomain();
       
   388 		}
       
   389 	else
       
   390 		{
       
   391 		return iDefaultSettings->TlsSslDomain();
       
   392 		}
       
   393 	}
       
   394 
       
   395 const CImSmtpSettings& CSmtpSettings::SmtpSettings() const
       
   396 	{
       
   397 	return *iDefaultSettings;
       
   398 	}