emailservices/emailcommon/src/CFSMailBoxBase.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 30 759dc5235cdb
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  common base mailbox object
    14 * Description:  common base mailbox object
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 // <qmail>
    19 #include <nmcommonheaders.h>
    19 #include <nmcommonheaders.h>
       
    20 // </qmail>
       
    21 
    20 #include "emailtrace.h"
    22 #include "emailtrace.h"
    21 #include "CFSMailBoxBase.h"
    23 #include "CFSMailBoxBase.h"
    22 // <qmail>
    24 // <qmail>
    23 #include "CFSMailAddress.h"
    25 #include "CFSMailAddress.h"
    24 #include "mmrinfoprocessor.h"
    26 #include "mmrinfoprocessor.h"
    25 // </qmail>
    27 // </qmail>
    26 #include "nmmailbox.h"
    28 #include "nmmailbox.h"
    27 
    29 
       
    30 //<qmail> Cmail fix task applied using QString methods (AknTextUtils n/a in 10.1)
       
    31 const int KCharCount = 5;
       
    32 static const QChar KCharsToReplace[KCharCount] = { '\r','\n','\t',0x2028,0x2029 };
       
    33 //</qmail>
       
    34 
    28 // ================= MEMBER FUNCTIONS ==========================================
    35 // ================= MEMBER FUNCTIONS ==========================================
    29 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    30 // CFSMailBoxBase::NewLC
    37 // CFSMailBoxBase::NewLC
    31 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    32 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewLC( TFSMailMsgId aMailBoxId )
    39 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewLC(TFSMailMsgId aMailBoxId)
    33 {
    40 {
    34     FUNC_LOG;
    41     FUNC_LOG;
    35     CFSMailBoxBase* api = new (ELeave) CFSMailBoxBase();
    42   CFSMailBoxBase* api = new (ELeave) CFSMailBoxBase();
    36     CleanupStack:: PushL(api);
    43   CleanupStack:: PushL(api);
    37     api->ConstructL(aMailBoxId);  
    44   api->ConstructL(aMailBoxId);
    38     return api; 
    45   return api;
    39 }
    46 } 
    40 
    47 
    41 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    42 // CFSMailBoxBase::NewL
    49 // CFSMailBoxBase::NewL
    43 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    44 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewL( TFSMailMsgId aMailBoxId )
    51 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewL(TFSMailMsgId aMailBoxId)
    45 {
    52 {
    46     FUNC_LOG;
    53     FUNC_LOG;
    47     CFSMailBoxBase* api =  CFSMailBoxBase::NewLC(aMailBoxId);
    54   CFSMailBoxBase* api =  CFSMailBoxBase::NewLC(aMailBoxId);
    48     CleanupStack:: Pop(api);
    55   CleanupStack:: Pop(api);
    49     return api;
    56   return api;
    50 }
    57 }
    51 
    58 
    52 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    53 // CFSMailBoxBase::CFSMailBoxBase
    60 // CFSMailBoxBase::CFSMailBoxBase
    54 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    55 CFSMailBoxBase::CFSMailBoxBase()
    62 CFSMailBoxBase::CFSMailBoxBase() : CExtendableEmail()
    56 {
    63 {
    57     FUNC_LOG;
    64     FUNC_LOG;
       
    65 	
    58 }
    66 }
    59 
    67 
    60 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    61 // CFSMailBoxBase::~CFSMailBoxBase
    69 // CFSMailBoxBase::~CFSMailBoxBase
    62 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    63 EXPORT_C CFSMailBoxBase::~CFSMailBoxBase()
    71 EXPORT_C CFSMailBoxBase::~CFSMailBoxBase()
    64 {
    72 {
    65     FUNC_LOG;
    73     FUNC_LOG;
    66     if( iMailBoxName )
    74     if( iMailBoxName )
    67         {
    75         {
    68         delete iMailBoxName;
    76   		delete iMailBoxName;
    69         }
    77         }
    70     iMailBoxName = NULL;
    78 	iMailBoxName = NULL;
    71 
    79 
    72     if( iBrId )
    80     if( iBrId )
    73         {
    81         {
    74         delete iBrId;
    82   		delete iBrId;
    75         }
    83         }
    76     iBrId = NULL;
    84 	iBrId = NULL;
    77 
    85 
    78     if( iOwnMailAddress )
    86     if( iOwnMailAddress )
    79         {
    87         {
    80         delete iOwnMailAddress;
    88   		delete iOwnMailAddress;
    81         }
    89         }
    82     iOwnMailAddress = NULL;
    90 	iOwnMailAddress = NULL;	
    83 
    91 
    84     if( iMRInfoProcessor )
    92     if( iMRInfoProcessor )
    85         {
    93         {
    86         delete iMRInfoProcessor;
    94         delete iMRInfoProcessor;
    87         }
    95         }
    89 }
    97 }
    90 
    98 
    91 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
    92 // CFSMailBoxBase::ConstructL
   100 // CFSMailBoxBase::ConstructL
    93 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
    94 void CFSMailBoxBase::ConstructL( const TFSMailMsgId aMailBoxId )
   102 void CFSMailBoxBase::ConstructL(const TFSMailMsgId aMailBoxId)
    95 {
   103 {
    96     FUNC_LOG;
   104     FUNC_LOG;
    97 	// <qmail> Removed iMailboxId </qmail>
   105 // <qmail> Removed iMailboxId </qmail>
    98     // prepare null empty descriptor
   106     // prepare null empty descriptor
    99     iMailBoxName = HBufC::NewL(1);
   107     iMailBoxName = HBufC::NewL(1);
   100     iMailBoxName->Des().Copy(KNullDesC());
   108     iMailBoxName->Des().Copy(KNullDesC());
   101 
   109 
   102     iBrId = HBufC::NewL(1);
   110     iBrId = HBufC::NewL(1);
   103     iBrId->Des().Copy(KNullDesC());
   111     iBrId->Des().Copy(KNullDesC());
   104 
   112 
   105     // <qmail>
   113 // <qmail>
   106     // Creating QT side object of the mailbox class.
   114     // Creating QT side object of the mailbox class.
   107     iNmPrivateMailbox = new NmMailboxPrivate();
   115     iNmPrivateMailbox = new NmMailboxPrivate();
   108     // Initialize QT data: pluginId and id. These need conversions between QT
   116     // Initialize QT data: pluginId and id. These need conversions between QT
   109     // and Symbian data types. Name not set here as it is null.
   117     // and Symbian data types. Name not set here as it is null.
   110 
   118 
   114     // -> Assumption: iUid should never contain negative value.
   122     // -> Assumption: iUid should never contain negative value.
   115     iNmPrivateMailbox->mId.setId32( aMailBoxId.Id() );
   123     iNmPrivateMailbox->mId.setId32( aMailBoxId.Id() );
   116 
   124 
   117     // typedef unsigned int TUint -> typedef unsigned int quint32
   125     // typedef unsigned int TUint -> typedef unsigned int quint32
   118     iNmPrivateMailbox->mId.setPluginId32((unsigned int)aMailBoxId.PluginId().iUid);
   126     iNmPrivateMailbox->mId.setPluginId32((unsigned int)aMailBoxId.PluginId().iUid);
   119     // </qmail>
   127 // </qmail>
   120 }
   128 }
   121 
   129 
   122 // <qmail>
       
   123 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   124 // CFSMailBoxBase::GetId
   131 // CFSMailBoxBase::GetId
   125 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   126 EXPORT_C TFSMailMsgId CFSMailBoxBase::GetId() const
   133 EXPORT_C TFSMailMsgId CFSMailBoxBase::GetId() const
   127 {
   134 {
   128     FUNC_LOG;
   135     FUNC_LOG;
       
   136 // <qmail>
   129     return TFSMailMsgId(iNmPrivateMailbox->mId);
   137     return TFSMailMsgId(iNmPrivateMailbox->mId);
       
   138 // </qmail>
   130 }
   139 }
   131 
   140 
   132 // -----------------------------------------------------------------------------
   141 // -----------------------------------------------------------------------------
   133 // CFSMailBoxBase::GetName
   142 // CFSMailBoxBase::GetName
   134 // -----------------------------------------------------------------------------
   143 // -----------------------------------------------------------------------------
   135 EXPORT_C TDesC& CFSMailBoxBase::GetName()const
   144 EXPORT_C TDesC& CFSMailBoxBase::GetName()const
   136 {
   145 {
   137     FUNC_LOG;
   146     FUNC_LOG;
       
   147 // <qmail>
   138     iTextPtr.Set( 
   148     iTextPtr.Set( 
   139         reinterpret_cast<const TUint16*> (iNmPrivateMailbox->mName.utf16()),
   149         reinterpret_cast<const TUint16*> (iNmPrivateMailbox->mName.utf16()),
   140         iNmPrivateMailbox->mName.length());
   150         iNmPrivateMailbox->mName.length());
   141     return iTextPtr;
   151     return iTextPtr;
       
   152 // </qmail>
   142 }
   153 }
   143 
   154 
   144 // -----------------------------------------------------------------------------
   155 // -----------------------------------------------------------------------------
   145 // CFSMailBoxBase::SetName
   156 // CFSMailBoxBase::SetName
   146 // -----------------------------------------------------------------------------
   157 // -----------------------------------------------------------------------------
   147 EXPORT_C void CFSMailBoxBase::SetName( const TDesC& aMailBoxName )
   158 EXPORT_C void CFSMailBoxBase::SetName( const TDesC& aMailBoxName )
   148 {
   159 {
   149     FUNC_LOG;
   160     FUNC_LOG;
       
   161 // <qmail>
   150     QString qtName = QString::fromUtf16(aMailBoxName.Ptr(), aMailBoxName.Length());
   162     QString qtName = QString::fromUtf16(aMailBoxName.Ptr(), aMailBoxName.Length());
       
   163     // Fix from Cmail 9.2 rewritten with QString methods
       
   164     for (int i = 0; i < KCharCount; i++) {
       
   165         QChar chr = KCharsToReplace[i];
       
   166         qtName = qtName.replace(chr, ' ');
       
   167     }
   151     iNmPrivateMailbox->mName = qtName;
   168     iNmPrivateMailbox->mName = qtName;
   152 }
   169 // </qmail>
   153 // <qmail>
   170 }
   154 
   171 
   155 // -----------------------------------------------------------------------------
   172 // -----------------------------------------------------------------------------
   156 // CFSMailBoxBase::GetStatus
   173 // CFSMailBoxBase::GetStatus
   157 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   158 EXPORT_C TFSMailBoxStatus CFSMailBoxBase::GetStatus( ) const
   175 EXPORT_C TFSMailBoxStatus CFSMailBoxBase::GetStatus( ) const
   159 {
   176 {
   160     FUNC_LOG;
   177     FUNC_LOG;
   161     return EFSMailBoxOffline;
   178 	return EFSMailBoxOffline;
   162 }
   179 }
   163 
   180 
   164 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   165 // CFSMailBoxBase::SetStatus
   182 // CFSMailBoxBase::SetStatus
   166 // -----------------------------------------------------------------------------
   183 // -----------------------------------------------------------------------------
   167 EXPORT_C void CFSMailBoxBase::SetStatus( const TFSMailBoxStatus /*aStatus*/ )
   184 EXPORT_C void CFSMailBoxBase::SetStatus( const TFSMailBoxStatus /*aStatus*/ )
   168 {
   185 {
   169     FUNC_LOG;
   186     FUNC_LOG;
       
   187 	
   170 }
   188 }
   171 
   189 
   172 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   173 // CFSMailBoxBase::GetRCLInfo
   191 // CFSMailBoxBase::GetRCLInfo
   174 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   175 EXPORT_C void CFSMailBoxBase::GetRCLInfo( TUid& aProtocolUid, TUint& aAccountUid )
   193 EXPORT_C void CFSMailBoxBase::GetRCLInfo(TUid& aProtocolUid, TUint& aAccountUid)
   176 {
   194 {
   177     FUNC_LOG;
   195     FUNC_LOG;
   178     aProtocolUid = iProtocolUid;
   196 	aProtocolUid = iProtocolUid;
   179     aAccountUid = iAccountUid;
   197 	aAccountUid = iAccountUid;
   180 }
   198 }
   181 
   199 
   182 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   183 // CFSMailBoxBase::SetRCLInfo
   201 // CFSMailBoxBase::SetRCLInfo
   184 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   185 EXPORT_C void CFSMailBoxBase::SetRCLInfo( const TUid aProtocolUid, const TUint aAccountUid )
   203 EXPORT_C void CFSMailBoxBase::SetRCLInfo(const TUid aProtocolUid, const TUint aAccountUid)
   186 {
   204 {
   187     FUNC_LOG;
   205     FUNC_LOG;
   188     iProtocolUid = aProtocolUid;
   206 	iProtocolUid = aProtocolUid;
   189     iAccountUid = aAccountUid;
   207 	iAccountUid = aAccountUid;
   190 }
   208 }
   191 
   209 
   192 // -----------------------------------------------------------------------------
   210 // -----------------------------------------------------------------------------
   193 // CFSMailBoxBase::GetSettingsUid
   211 // CFSMailBoxBase::GetSettingsUid
   194 // -----------------------------------------------------------------------------
   212 // -----------------------------------------------------------------------------
   195 EXPORT_C const TUid CFSMailBoxBase::GetSettingsUid()
   213 EXPORT_C const TUid CFSMailBoxBase::GetSettingsUid()
   196   {
   214 	{
   197     FUNC_LOG;
   215     FUNC_LOG;
   198     return iSettingsUid;
   216 	return iSettingsUid;
   199 }
   217 	}
   200 
   218 
   201 // -----------------------------------------------------------------------------
   219 // -----------------------------------------------------------------------------
   202 // CFSMailBoxBase::SetSettingsUid
   220 // CFSMailBoxBase::SetSettingsUid
   203 // -----------------------------------------------------------------------------
   221 // -----------------------------------------------------------------------------
   204 EXPORT_C void CFSMailBoxBase::SetSettingsUid( const TUid aUid )
   222 EXPORT_C void CFSMailBoxBase::SetSettingsUid(const TUid aUid)
   205 {
   223 	{
   206     FUNC_LOG;
   224     FUNC_LOG;
   207     iSettingsUid = aUid;
   225 		iSettingsUid = aUid;
   208 }
   226 	}
   209 
   227 
   210 // -----------------------------------------------------------------------------
   228 // -----------------------------------------------------------------------------
   211 // CFSMailBoxBase::MRInfoProcessorL
   229 // CFSMailBoxBase::MRInfoProcessorL
   212 // -----------------------------------------------------------------------------
   230 // -----------------------------------------------------------------------------
   213 EXPORT_C MMRInfoProcessor& CFSMailBoxBase::MRInfoProcessorL()
   231 EXPORT_C MMRInfoProcessor& CFSMailBoxBase::MRInfoProcessorL()
   214 {
   232 	{
   215     FUNC_LOG;
   233     FUNC_LOG;
   216     return *iMRInfoProcessor;
   234 	return *iMRInfoProcessor;
   217 }
   235 	}
   218 
   236 
   219 // -----------------------------------------------------------------------------
   237 // -----------------------------------------------------------------------------
   220 // CFSMailBoxBase::IsMRInfoProcessorSet
   238 // CFSMailBoxBase::IsMRInfoProcessorSet
   221 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   222 EXPORT_C TBool CFSMailBoxBase::IsMRInfoProcessorSet()
   240 EXPORT_C TBool CFSMailBoxBase::IsMRInfoProcessorSet()
   223 {
   241 	{
   224     FUNC_LOG;
   242     FUNC_LOG;
   225     if(iMRInfoProcessor)
   243 	if(iMRInfoProcessor)
   226         {
   244 		{
   227         return ETrue;
   245 		return ETrue;
   228         }
   246 		}
   229     else
   247 	else
   230         {
   248 		{
   231         return EFalse;
   249 		return EFalse;
   232         }
   250 		}
   233 }
   251 	}
   234 
   252 
   235 // -----------------------------------------------------------------------------
   253 // -----------------------------------------------------------------------------
   236 // CFSMailBoxBase::SetMRInfoProcessorL
   254 // CFSMailBoxBase::SetMRInfoProcessorL
   237 // -----------------------------------------------------------------------------
   255 // -----------------------------------------------------------------------------
   238 EXPORT_C void CFSMailBoxBase::SetMRInfoProcessorL( MMRInfoProcessor* aMRInfoProcessor )
   256 EXPORT_C void CFSMailBoxBase::SetMRInfoProcessorL(MMRInfoProcessor* aMRInfoProcessor)
   239 {
   257 	{
   240     FUNC_LOG;
   258     FUNC_LOG;
   241 
   259 
   242     if(iMRInfoProcessor)
   260 	if(iMRInfoProcessor)
   243         {
   261 	{
   244         delete iMRInfoProcessor;
   262 		delete iMRInfoProcessor;
   245         }
   263 	}
   246     iMRInfoProcessor = aMRInfoProcessor;
   264 	iMRInfoProcessor = aMRInfoProcessor;
   247 }
   265 	}
   248 
   266 
   249 // -----------------------------------------------------------------------------
   267 // -----------------------------------------------------------------------------
   250 // CFSMailBoxBase::OwnMailAddress
   268 // CFSMailBoxBase::OwnMailAddress
   251 // -----------------------------------------------------------------------------
   269 // -----------------------------------------------------------------------------
   252 EXPORT_C CFSMailAddress& CFSMailBoxBase::OwnMailAddress( )
   270 EXPORT_C CFSMailAddress& CFSMailBoxBase::OwnMailAddress( )
   253 {
   271 {
   254     FUNC_LOG;
   272     FUNC_LOG;
   255     return *iOwnMailAddress;
   273 	return *iOwnMailAddress;
   256 }
   274 }
   257 
   275 
   258 // -----------------------------------------------------------------------------
   276 // -----------------------------------------------------------------------------
   259 // CFSMailBoxBase::SetOwnMailAddress
   277 // CFSMailBoxBase::SetOwnMailAddress
   260 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   261 EXPORT_C void CFSMailBoxBase::SetOwnMailAddressL( CFSMailAddress* aOwnMailAddress )
   279 EXPORT_C void CFSMailBoxBase::SetOwnMailAddressL( CFSMailAddress* aOwnMailAddress)
   262 {
   280 {
   263     FUNC_LOG;
   281     FUNC_LOG;
   264     if(iOwnMailAddress)
   282 	if(iOwnMailAddress)
   265         {
   283 		{
   266         delete iOwnMailAddress;
   284 		delete iOwnMailAddress;
   267         }
   285 		}
   268     iOwnMailAddress = aOwnMailAddress;
   286 	iOwnMailAddress = aOwnMailAddress;
   269 
   287 
   270     // set also branding id based on domain name
   288 	// set also branding id based on domain name
   271     TPtrC ptr = OwnMailAddress().GetEmailAddress();
   289     TPtrC ptr = OwnMailAddress().GetEmailAddress();
   272     TInt index = ptr.Locate('@') + 1;
   290     TInt index = ptr.Locate('@') + 1;
   273     if(index > 0 && ptr.Length() > 0)
   291     if(index > 0 && ptr.Length() > 0)
   274         {
   292     {
   275         if(iBrId)
   293         if(iBrId)
   276             {
   294         {
   277             delete iBrId;
   295             delete iBrId;
   278             iBrId = NULL;
   296             iBrId = NULL;
   279             }
   297         }
   280         ptr.Set( ptr.Right( ptr.Length() - index ) );
   298         ptr.Set( ptr.Right( ptr.Length() - index ) );        
   281         iBrId = HBufC::New(ptr.Length());
   299         iBrId = HBufC::New(ptr.Length());
   282         iBrId->Des().Copy(ptr);
   300         iBrId->Des().Copy(ptr);
   283         }
   301     }
       
   302 // <qmail>
   284     iNmPrivateMailbox->mAddress = aOwnMailAddress->GetNmAddress();
   303     iNmPrivateMailbox->mAddress = aOwnMailAddress->GetNmAddress();
       
   304 // </qmail>
   285 }
   305 }
   286 
   306 
   287 // -----------------------------------------------------------------------------
   307 // -----------------------------------------------------------------------------
   288 // CFSMailBoxBase::BrandingId
   308 // CFSMailBoxBase::BrandingId
   289 // -----------------------------------------------------------------------------
   309 // -----------------------------------------------------------------------------
   293     return *iBrId;
   313     return *iBrId;
   294 }
   314 }
   295 
   315 
   296 // <qmail> Removed SetMailBoxId </qmail>
   316 // <qmail> Removed SetMailBoxId </qmail>
   297 
   317 
       
   318 // <qmail>
   298 // -----------------------------------------------------------------------------
   319 // -----------------------------------------------------------------------------
   299 // CFSMailBoxBase::GetNmMailbox
   320 // CFSMailBoxBase::GetNmMailbox
   300 // -----------------------------------------------------------------------------
   321 // -----------------------------------------------------------------------------
   301 // <qmail>
       
   302 EXPORT_C NmMailbox* CFSMailBoxBase::GetNmMailbox()
   322 EXPORT_C NmMailbox* CFSMailBoxBase::GetNmMailbox()
   303 {
   323 {
   304     NmMailbox* nmmailbox = new NmMailbox(iNmPrivateMailbox);
   324     NmMailbox* nmmailbox = new NmMailbox(iNmPrivateMailbox);
   305     return nmmailbox;
   325     return nmmailbox;
   306 }
   326 }