emailservices/emailframework/src/CFSMailBrand.cpp
branchRCL_3
changeset 24 d189ee25cf9d
parent 20 efd4f1afd43e
child 25 3533d4323edc
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
    13 *
    13 *
    14 * Description: This file implements class CFSMailBrand.
    14 * Description: This file implements class CFSMailBrand.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 #include "emailtrace.h"
    18 #include "emailtrace.h"
       
    19 
       
    20 //<qmail>
       
    21 #include <nmcommonheaders.h>
       
    22 //</qmail>
       
    23 
    20 #include <barsread.h>
    24 #include <barsread.h>
    21 #include <AknIconUtils.h>
    25 //<qmail> Commented out in Qmail
       
    26 //#include <AknIconUtils.h>
       
    27 //</qmail>
    22 #include <gulicon.h>
    28 #include <gulicon.h>
    23 #include <centralrepository.h>
    29 #include <centralrepository.h>
    24 //<cmail>
    30 //<cmail>
    25 #include "freestyleemailcenrepkeys.h"
    31 //<qmail> Commented out in Qmail
       
    32 //#include "freestyleemailcenrepkeys.h"
       
    33 //</qmail>
    26 //</cmail>
    34 //</cmail>
    27 
    35 
    28 #include "cfsmailbrand.h"
    36 #include "CFSMailBrand.h"
    29 
    37 
    30 const TInt KElementArrayGranularity = 5;
    38 const TInt KElementArrayGranularity = 5;
    31 const TInt KMaxStringLenFromCenrep = 256;
    39 //<qmail> Commented out in Qmail
       
    40 //const TInt KMaxStringLenFromCenrep = 256;
       
    41 //</qmail>
    32 const TInt KMaxDesLen = 256;
    42 const TInt KMaxDesLen = 256;
    33 _LIT(KSpace, " ");
    43 _LIT(KSpace, " ");
    34 // -----------------------------------------------------------------------------
    44 // -----------------------------------------------------------------------------
    35 // CFSMailBrand::NewL
    45 // CFSMailBrand::NewL
    36 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    37 CFSMailBrand* CFSMailBrand::NewL( TResourceReader& aReader, TBool aIsWhiteLabel )
    47 CFSMailBrand* CFSMailBrand::NewL( TResourceReader& aReader, TBool aIsWhiteLabel )
    38 	{
    48 	{
    39     FUNC_LOG;
    49     NM_FUNCTION;
       
    50     
    40 	CFSMailBrand* brManager =  CFSMailBrand::NewLC(aReader, aIsWhiteLabel);
    51 	CFSMailBrand* brManager =  CFSMailBrand::NewLC(aReader, aIsWhiteLabel);
    41   	CleanupStack:: Pop(brManager);
    52   	CleanupStack:: Pop(brManager);
    42   	return brManager;
    53   	return brManager;
    43 	}
    54 	}
    44 
    55 
    45 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    46 // CFSMailBrand::NewLC
    57 // CFSMailBrand::NewLC
    47 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    48 CFSMailBrand* CFSMailBrand::NewLC( TResourceReader& aReader, TBool aIsWhiteLabel )
    59 CFSMailBrand* CFSMailBrand::NewLC( TResourceReader& aReader, TBool aIsWhiteLabel )
    49 	{
    60 	{
    50     FUNC_LOG;
    61     NM_FUNCTION;
       
    62     
    51     CFSMailBrand* self = new ( ELeave ) CFSMailBrand();
    63     CFSMailBrand* self = new ( ELeave ) CFSMailBrand();
    52     CleanupStack::PushL( self );
    64     CleanupStack::PushL( self );
    53     if ( aIsWhiteLabel )
    65     if ( aIsWhiteLabel )
    54     	{
    66     	{
    55     	self->ConstructFromCenrepL( );
    67     	self->ConstructFromCenrepL( );
    65 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    66 // CFSMailBrand::ConstructFromCenrepL
    78 // CFSMailBrand::ConstructFromCenrepL
    67 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    68 void CFSMailBrand::ConstructFromCenrepL( )
    80 void CFSMailBrand::ConstructFromCenrepL( )
    69     {
    81     {
    70     FUNC_LOG;
    82     NM_FUNCTION;
    71     
    83     
       
    84 	/*
    72     TBuf<KMaxStringLenFromCenrep> tBuf; // Temporary buffer
    85     TBuf<KMaxStringLenFromCenrep> tBuf; // Temporary buffer
    73     HBufC*    mailboxName;
    86     HBufC*    mailboxName;
    74 
    87 
    75     iGraphicElements = new ( ELeave )
    88     iGraphicElements = new ( ELeave )
    76         CArrayFixSeg< TBrandedGraphic >( KElementArrayGranularity );
    89         CArrayFixSeg< TBrandedGraphic >( KElementArrayGranularity );
   124             iTextElements->AppendL( newMailboxNameElement );
   137             iTextElements->AppendL( newMailboxNameElement );
   125             }
   138             }
   126         CleanupStack::PopAndDestroy( mailboxName );
   139         CleanupStack::PopAndDestroy( mailboxName );
   127         CleanupStack::PopAndDestroy( repository );
   140         CleanupStack::PopAndDestroy( repository );
   128         }
   141         }
       
   142 		*/
   129    }
   143    }
   130 
   144 
   131 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   132 // CFSMailBrand::ConstructFromResourceL
   146 // CFSMailBrand::ConstructFromResourceL
   133 // -----------------------------------------------------------------------------
   147 // -----------------------------------------------------------------------------
   134 void CFSMailBrand::ConstructFromResourceL( TResourceReader& aReader )
   148 void CFSMailBrand::ConstructFromResourceL( TResourceReader& aReader )
   135     {
   149     {
   136     FUNC_LOG;
   150     NM_FUNCTION;
   137 
   151 
   138     // read icon filepath
   152     // read icon filepath
   139     iIconFilePath = aReader.ReadHBufCL();
   153     iIconFilePath = aReader.ReadHBufCL();
   140 
   154 
   141     // read match strings
   155     // read match strings
   193 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   194 // CFSMailBrand::~CFSMailBrand()
   208 // CFSMailBrand::~CFSMailBrand()
   195 // -----------------------------------------------------------------------------
   209 // -----------------------------------------------------------------------------
   196 CFSMailBrand::~CFSMailBrand()
   210 CFSMailBrand::~CFSMailBrand()
   197 	{
   211 	{
   198     FUNC_LOG;
   212     NM_FUNCTION;
       
   213     
   199 	iBrandMatchStrings.ResetAndDestroy();
   214 	iBrandMatchStrings.ResetAndDestroy();
   200 	delete iIconFilePath;
   215 	delete iIconFilePath;
   201 	delete iGraphicElements;
   216 	delete iGraphicElements;
   202 	delete iTextElements;
   217 	delete iTextElements;
   203 	delete iColorElements;
   218 	delete iColorElements;
   208 // -----------------------------------------------------------------------------
   223 // -----------------------------------------------------------------------------
   209 // CFSMailBrand::CFSMailBrand()
   224 // CFSMailBrand::CFSMailBrand()
   210 // -----------------------------------------------------------------------------
   225 // -----------------------------------------------------------------------------
   211 CFSMailBrand::CFSMailBrand()
   226 CFSMailBrand::CFSMailBrand()
   212 	{
   227 	{
   213     FUNC_LOG;
   228     NM_FUNCTION;
       
   229     
   214 		// prepare null empty descriptor
   230 		// prepare null empty descriptor
   215 	iEmpty = HBufC::New(1);
   231 	iEmpty = HBufC::New(1);
   216 	iEmpty->Des().Copy(KNullDesC());
   232 	iEmpty->Des().Copy(KNullDesC());
   217 
   233 
   218 	}
   234 	}
   220 // -----------------------------------------------------------------------------
   236 // -----------------------------------------------------------------------------
   221 // CFSMailBrand::IsMatching
   237 // CFSMailBrand::IsMatching
   222 // -----------------------------------------------------------------------------
   238 // -----------------------------------------------------------------------------
   223 TBool CFSMailBrand::IsMatching( const TDesC& aBrandId )
   239 TBool CFSMailBrand::IsMatching( const TDesC& aBrandId )
   224     {
   240     {
   225     FUNC_LOG;
   241     NM_FUNCTION;
   226     const TChar KStar = '*';
   242     const TChar KStar = '*';
   227     TBool ret = EFalse;
   243     TBool ret = EFalse;
   228     TInt intRet = 0; 
   244     TInt intRet = 0; 
   229     TInt count = iBrandMatchStrings.Count();
   245     TInt count = iBrandMatchStrings.Count();
   230     for( TInt i=0;i<count;i++ )
   246     for( TInt i=0;i<count;i++ )
   254 // -----------------------------------------------------------------------------
   270 // -----------------------------------------------------------------------------
   255 // CFSMailBrand::GetText
   271 // CFSMailBrand::GetText
   256 // -----------------------------------------------------------------------------
   272 // -----------------------------------------------------------------------------
   257 TDesC& CFSMailBrand::GetText( TFSBrandElement aElementId )
   273 TDesC& CFSMailBrand::GetText( TFSBrandElement aElementId )
   258     {
   274     {
   259     FUNC_LOG;
   275     NM_FUNCTION;
       
   276     
   260     TInt textCount( iTextElements->Count() );
   277     TInt textCount( iTextElements->Count() );
   261 
   278 
   262     for ( TInt i( 0 ); i < textCount; i++ )
   279     for ( TInt i( 0 ); i < textCount; i++ )
   263         {
   280         {
   264         if ( iTextElements->At( i ).iElementId == aElementId )
   281         if ( iTextElements->At( i ).iElementId == aElementId )
   273 // -----------------------------------------------------------------------------
   290 // -----------------------------------------------------------------------------
   274 // CFSMailBrand::GetColor
   291 // CFSMailBrand::GetColor
   275 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   276 TInt CFSMailBrand::GetColor( TFSBrandElement aElementId, TRgb& aColor )
   293 TInt CFSMailBrand::GetColor( TFSBrandElement aElementId, TRgb& aColor )
   277     {
   294     {
   278     FUNC_LOG;
   295     NM_FUNCTION;
       
   296     
   279     TInt colorCount( iColorElements->Count() );
   297     TInt colorCount( iColorElements->Count() );
   280 
   298 
   281     for ( TInt i( 0 ); i < colorCount; i++ )
   299     for ( TInt i( 0 ); i < colorCount; i++ )
   282         {
   300         {
   283         if ( iColorElements->At( i ).iElementId == aElementId )
   301         if ( iColorElements->At( i ).iElementId == aElementId )
   293 // -----------------------------------------------------------------------------
   311 // -----------------------------------------------------------------------------
   294 // CFSMailBrand::GetGraphicL
   312 // CFSMailBrand::GetGraphicL
   295 // -----------------------------------------------------------------------------
   313 // -----------------------------------------------------------------------------
   296 CGulIcon* CFSMailBrand::GetGraphicL( TFSBrandElement aElementId )
   314 CGulIcon* CFSMailBrand::GetGraphicL( TFSBrandElement aElementId )
   297     {
   315     {
   298     FUNC_LOG;
   316     NM_FUNCTION;
       
   317     
   299     TInt graphicsCount( iGraphicElements->Count() );
   318     TInt graphicsCount( iGraphicElements->Count() );
   300 
   319 
   301     for ( TInt i( 0 ); i < graphicsCount; i++ )
   320     for ( TInt i( 0 ); i < graphicsCount; i++ )
   302         {
   321         {
   303         TBrandedGraphic element = iGraphicElements->At( i );
   322         TBrandedGraphic element = iGraphicElements->At( i );
   317             TFileName dllFileName;
   336             TFileName dllFileName;
   318             Dll::FileName( dllFileName );
   337             Dll::FileName( dllFileName );
   319 		 	TParse parse;
   338 		 	TParse parse;
   320 		    User::LeaveIfError( parse.Set( *iIconFilePath, &dllFileName, NULL) );
   339 		    User::LeaveIfError( parse.Set( *iIconFilePath, &dllFileName, NULL) );
   321 		    TFileName iconFileName( parse.FullName() );
   340 		    TFileName iconFileName( parse.FullName() );
   322                 
   341              
   323                 
   342 //<qmail>
   324             AknIconUtils::CreateIconLC( icon,
   343             // Get icon and mask with above info
       
   344             /*AknIconUtils::CreateIconLC( icon,
   325                                         mask,
   345                                         mask,
   326                                         iconFileName,
   346                                         iconFileName,
   327                                         element.iIconId,
   347                                         element.iIconId,
   328                                         element.iMaskId );
   348                                         element.iMaskId );*/
       
   349 //</qmail>
   329             CGulIcon* gulIcon = CGulIcon::NewL( icon, mask );
   350             CGulIcon* gulIcon = CGulIcon::NewL( icon, mask );
   330 
   351 
   331             CleanupStack::Pop( 2 ); // icon, mask
   352             CleanupStack::Pop( 2 ); // icon, mask
   332             
   353             
   333             return gulIcon;
   354             return gulIcon;
   341 // CFSMailBrand::GetGraphicIdsL
   362 // CFSMailBrand::GetGraphicIdsL
   342 // -----------------------------------------------------------------------------
   363 // -----------------------------------------------------------------------------
   343 TInt CFSMailBrand::GetGraphicIdsL( TFSBrandElement aElementId,
   364 TInt CFSMailBrand::GetGraphicIdsL( TFSBrandElement aElementId,
   344                                    TDes& aIconIds)
   365                                    TDes& aIconIds)
   345     {
   366     {
   346     FUNC_LOG;
   367     NM_FUNCTION;
   347     
   368     
   348     aIconIds.Zero();
   369     aIconIds.Zero();
   349     TInt graphicsCount( iGraphicElements->Count() );
   370     TInt graphicsCount( iGraphicElements->Count() );
   350 
   371 
   351     for ( TInt i( 0 ); i < graphicsCount; i++ )
   372     for ( TInt i( 0 ); i < graphicsCount; i++ )