email/imum/Mtms/Src/SmtpMtmUiData.cpp
changeset 0 72b543305e3a
child 2 0bf1d54f37d9
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *       SMTP MTM Ui data layer base API
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <coemain.h>    // ccoeenv
       
    21 #include <eikon.rsg>
       
    22 
       
    23 // Messaging includes
       
    24 #include <mtclbase.h>
       
    25 #include <mtmuidef.hrh>
       
    26 #include <smtcmtm.h>// ksmtcmaxtextmessagesize, kuidmsgtypesmtp
       
    27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    28 #include <mtmdef.hrh> 
       
    29 #else
       
    30 #include <mtmdef.hrh>
       
    31 #include <mtmuidsdef.hrh>
       
    32 #endif
       
    33 #include <MtmExtendedCapabilities.hrh>
       
    34 
       
    35 // Specific includes
       
    36 #include "SmtpMtmUiData.h"
       
    37 #include "ImumPanic.h"
       
    38 #include <muiu.mbg>
       
    39 #include <imum.rsg>
       
    40 #include "EmailEditorViewerUids.h"
       
    41 
       
    42 #include <AknsUtils.h>
       
    43 #include <AknsConstants.h>//skinned icon ids
       
    44 #include <data_caging_path_literals.hrh>
       
    45 #include <featmgr.h>
       
    46 
       
    47 // CONSTANTS
       
    48 const TInt KImumSmtpBitmapIndex = 0; // only one bitmap for create email
       
    49 const TInt KSmtpMtmUdNumberOfZoomStates =       2; // second one is mask!
       
    50 _LIT(KSmtpMtmUdResourceFile, "IMUM");
       
    51 // Correct path is added to literal when it is used.
       
    52 _LIT(KSmtpMtmUdBitmapFile, "z:MUIU.MBM");
       
    53 
       
    54 
       
    55 // ==================== LOCAL FUNCTIONS ====================
       
    56 
       
    57 // ================= MEMBER FUNCTIONS =======================
       
    58 
       
    59 // ----------------------------------------------------------------------------
       
    60 //NewSMTIMtmUiDataLayerL
       
    61 // ----------------------------------------------------------------------------
       
    62 EXPORT_C CBaseMtmUiData* NewSMTIMtmUiDataLayerL(CRegisteredMtmDll& aRegisteredDll)
       
    63     {
       
    64     return CSmtpMtmUiData::NewL(aRegisteredDll);
       
    65     }
       
    66 
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 //NewL
       
    70 // ----------------------------------------------------------------------------
       
    71 CSmtpMtmUiData* CSmtpMtmUiData::NewL(CRegisteredMtmDll& aRegisteredDll)
       
    72     {
       
    73     CSmtpMtmUiData* self=new(ELeave) CSmtpMtmUiData(aRegisteredDll);
       
    74     CleanupStack::PushL(self);
       
    75     self->ConstructL();
       
    76     CleanupStack::Pop();
       
    77     return self;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // ~CSmtpMtmUiData
       
    82 // ----------------------------------------------------------------------------
       
    83 CSmtpMtmUiData::~CSmtpMtmUiData()
       
    84     {
       
    85     }
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // OperationSupportedL
       
    89 // ----------------------------------------------------------------------------
       
    90 TInt CSmtpMtmUiData::OperationSupportedL(TInt aOperationId, const TMsvEntry& aContext) const
       
    91     {
       
    92     TInt rid=R_EIK_TBUF_NOT_AVAILABLE;
       
    93     if (CheckEntry(aContext))
       
    94         {
       
    95         if (aContext.iType.iUid==KUidMsvMessageEntryValue)
       
    96             {
       
    97             switch (aOperationId)
       
    98                 {
       
    99             case KMtmUiFunctionSendAs:
       
   100             case KMtmUiFunctionMessageInfo:
       
   101                 rid=0; // Operation is supported
       
   102                 break;
       
   103             default:
       
   104                 break;
       
   105                 }
       
   106             }
       
   107         }
       
   108     return rid;
       
   109     }
       
   110 
       
   111 // ----------------------------------------------------------------------------
       
   112 // QueryCapability
       
   113 // ----------------------------------------------------------------------------
       
   114 TInt CSmtpMtmUiData::QueryCapability(TUid aCapability, TInt& aResponse) const
       
   115     {
       
   116     switch (aCapability.iUid)
       
   117         {
       
   118         // --- Supported valued capabilities ---
       
   119         case KUidMtmQueryMaxBodySizeValue:
       
   120             aResponse=KMaxTInt;
       
   121             break;
       
   122         case KUidMtmQueryMaxTotalMsgSizeValue:
       
   123             aResponse=KMaxTInt;
       
   124             break;
       
   125         case KUidMsvMtmQueryEditorUidValue:
       
   126             aResponse=KUidMsgInternetMailEditorAppValue;
       
   127             break;
       
   128         case KUidMsvMtmQueryViewerUidValue:
       
   129             aResponse=KUidMsgInternetMailViewerAppValue;
       
   130             break;
       
   131         case KUidMtmQuerySupportedBodyValue:
       
   132             aResponse = KMtm7BitBody | KMtm8BitBody | KMtm16BitBody;
       
   133             break;
       
   134     
       
   135         //
       
   136         // --- Support depends on variation ---
       
   137         case KUidMsvMtmQuerySupportEditor:
       
   138             aResponse = iFFEmailVariation ? EFalse : ETrue;
       
   139             // FALLTHROUGH
       
   140         case KUidMtmQueryCanCreateNewMsgValue:
       
   141             return iFFEmailVariation ? KErrNotSupported : KErrNone;
       
   142     
       
   143         //
       
   144         // --- Supported non-valued capabilities ---
       
   145         case KUidMtmQuerySupportAttachmentsValue:
       
   146         case KUidMtmQueryCanSendMsgValue:
       
   147         case KUidMsvMtmQueryMessageInfo:
       
   148                 break;
       
   149         default:
       
   150             return KErrNotSupported;
       
   151         };
       
   152     return KErrNone;
       
   153     }
       
   154 
       
   155 
       
   156 #ifdef _DEBUG
       
   157 const CBaseMtmUiData::CBitmapArray& CSmtpMtmUiData::ContextIcon(const TMsvEntry& aContext,TInt /*aStateFlags*/) const
       
   158 #else
       
   159 const CBaseMtmUiData::CBitmapArray& CSmtpMtmUiData::ContextIcon(const TMsvEntry& /*aContext*/,TInt /*aStateFlags*/) const
       
   160 #endif
       
   161     {
       
   162     __ASSERT_DEBUG(CheckEntry(aContext), User::Panic(KImumMtmUiPanic, ESmtpMtmUdNoIconAvailable));
       
   163     __ASSERT_DEBUG(aContext.iType!=KUidMsvAttachmentEntry, User::Panic(KImumMtmUiPanic, ESmtpMtmUdNoIconForAttachment));
       
   164 
       
   165     return *iIconArrays->At( KImumSmtpBitmapIndex ); // smtp has only one icon
       
   166     }
       
   167 
       
   168 // ----------------------------------------------------------------------------
       
   169 // CSmtpMtmUiData
       
   170 // ----------------------------------------------------------------------------
       
   171 CSmtpMtmUiData::CSmtpMtmUiData(CRegisteredMtmDll& aRegisteredDll)
       
   172     :       CBaseMtmUiData(aRegisteredDll)
       
   173     {
       
   174     __ASSERT_DEBUG(aRegisteredDll.MtmTypeUid()==KUidMsgTypeSMTP, User::Panic(KImumMtmUiPanic, ESmtpMtmUdWrongMtmType));
       
   175     }
       
   176 
       
   177 // ----------------------------------------------------------------------------
       
   178 // PopulateArraysL
       
   179 // ----------------------------------------------------------------------------
       
   180 void CSmtpMtmUiData::PopulateArraysL()
       
   181     {
       
   182     FeatureManager::InitializeLibL();
       
   183     iFFEmailVariation = 
       
   184         FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework );
       
   185     FeatureManager::UnInitializeLib();
       
   186 
       
   187     // --- Populate function array ---
       
   188     ReadFunctionsFromResourceFileL( iFFEmailVariation ?
       
   189         R_SMTPUD_FUNCTION_ARRAY_FFEMAIL : R_SMTPUD_FUNCTION_ARRAY );
       
   190 
       
   191     //
       
   192     // --- Populate bitmap array ---
       
   193     CreateSkinnedBitmapsL( KSmtpMtmUdNumberOfZoomStates );
       
   194     }
       
   195 
       
   196 // ----------------------------------------------------------------------------
       
   197 // GetResourceFileName
       
   198 // ----------------------------------------------------------------------------
       
   199 void CSmtpMtmUiData::GetResourceFileName(TFileName& aFileName) const
       
   200     {
       
   201     aFileName=KSmtpMtmUdResourceFile;
       
   202     }
       
   203 
       
   204 // ----------------------------------------------------------------------------
       
   205 // CanCreateEntryL
       
   206 // ----------------------------------------------------------------------------
       
   207 TBool CSmtpMtmUiData::CanCreateEntryL(const TMsvEntry& aParent, TMsvEntry& aNewEntry, TInt& aReasonResourceId) const
       
   208     {
       
   209     if (CheckEntry(aNewEntry))
       
   210         {
       
   211         aReasonResourceId=0;
       
   212         //
       
   213         // --- Can create services if they are off root ---
       
   214         if (aNewEntry.iType.iUid == KUidMsvServiceEntryValue)
       
   215             return (aParent.Id() == KMsvRootIndexEntryIdValue);
       
   216         //
       
   217         // --- Can create messages in local folders ---
       
   218         if (aNewEntry.iType.iUid == KUidMsvMessageEntryValue)
       
   219             return (aParent.iMtm.iUid == KMsvLocalServiceIndexEntryIdValue);
       
   220         }
       
   221     //
       
   222     // --- Can't create other types ---
       
   223     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   224     return EFalse;
       
   225     }
       
   226 
       
   227 // ----------------------------------------------------------------------------
       
   228 // CanOpenEntryL
       
   229 // ----------------------------------------------------------------------------
       
   230 TBool CSmtpMtmUiData::CanOpenEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   231     {
       
   232     // not used, just return EFalse
       
   233     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   234     return EFalse;
       
   235     }
       
   236 
       
   237 // ----------------------------------------------------------------------------
       
   238 // CanCloseEntryL
       
   239 // ----------------------------------------------------------------------------
       
   240 TBool CSmtpMtmUiData::CanCloseEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   241     {
       
   242     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   243     return EFalse;
       
   244     }
       
   245 
       
   246 // ----------------------------------------------------------------------------
       
   247 // CanViewEntryL
       
   248 // ----------------------------------------------------------------------------
       
   249 TBool CSmtpMtmUiData::CanViewEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   250     {
       
   251     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   252     return EFalse;
       
   253     }
       
   254 
       
   255 // ----------------------------------------------------------------------------
       
   256 // CanEditEntryL
       
   257 // ----------------------------------------------------------------------------
       
   258 TBool CSmtpMtmUiData::CanEditEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   259     {
       
   260     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   261     return EFalse;
       
   262     }
       
   263 
       
   264 // ----------------------------------------------------------------------------
       
   265 // CanDeleteServiceL
       
   266 // ----------------------------------------------------------------------------
       
   267 TBool CSmtpMtmUiData::CanDeleteServiceL(const TMsvEntry& /*aService*/, TInt& aReasonResourceId) const
       
   268     {
       
   269     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   270     return EFalse;
       
   271     }
       
   272 
       
   273 // ----------------------------------------------------------------------------
       
   274 // CanDeleteFromEntryL
       
   275 // ----------------------------------------------------------------------------
       
   276 TBool CSmtpMtmUiData::CanDeleteFromEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   277     {
       
   278     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   279     return EFalse;
       
   280     }
       
   281 
       
   282 // ----------------------------------------------------------------------------
       
   283 // CanCopyMoveToEntryL
       
   284 // ----------------------------------------------------------------------------
       
   285 TBool CSmtpMtmUiData::CanCopyMoveToEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   286     {
       
   287     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   288     return EFalse;
       
   289     }
       
   290 
       
   291 // ----------------------------------------------------------------------------
       
   292 // CanCopyMoveFromEntryL
       
   293 // ----------------------------------------------------------------------------
       
   294 TBool CSmtpMtmUiData::CanCopyMoveFromEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   295     {
       
   296     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   297     return EFalse;
       
   298     }
       
   299 
       
   300 // ----------------------------------------------------------------------------
       
   301 // CanReplyToEntryL
       
   302 // ----------------------------------------------------------------------------
       
   303 TBool CSmtpMtmUiData::CanReplyToEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   304     {
       
   305     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   306     return EFalse;
       
   307     }
       
   308 
       
   309 // ----------------------------------------------------------------------------
       
   310 // CanForwardEntryL
       
   311 // ----------------------------------------------------------------------------
       
   312 TBool CSmtpMtmUiData::CanForwardEntryL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   313     {
       
   314     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   315     return EFalse;
       
   316     }
       
   317 
       
   318 // ----------------------------------------------------------------------------
       
   319 // CanCancelL
       
   320 // ----------------------------------------------------------------------------
       
   321 TBool CSmtpMtmUiData::CanCancelL(const TMsvEntry& /*aContext*/, TInt& aReasonResourceId) const
       
   322     {
       
   323     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   324     return EFalse;
       
   325     }
       
   326 
       
   327 // ----------------------------------------------------------------------------
       
   328 // StatusTextL
       
   329 // ----------------------------------------------------------------------------
       
   330 HBufC* CSmtpMtmUiData::StatusTextL(const TMsvEntry& aContext) const
       
   331     {
       
   332     TInt res = 0;
       
   333     switch(aContext.SendingState())
       
   334         {
       
   335         case KMsvSendStateFailed:
       
   336             res = R_SMTP_OUTBOX_STATUS_FAILED;
       
   337             break;
       
   338         // Functionally identical states. (Don't send on next connection)
       
   339         case KMsvSendStateUponRequest:
       
   340         case KMsvSendStateSuspended:
       
   341             res = R_SMTP_OUTBOX_STATUS_SUSPENDED;
       
   342             break;
       
   343 
       
   344         // Functionally identical states. (Send on next connection)
       
   345         case KMsvSendStateWaiting:
       
   346         case KMsvSendStateResend:
       
   347         case KMsvSendStateScheduled:
       
   348             res = R_SMTP_OUTBOX_STATUS_QUEUED;
       
   349             break;
       
   350 
       
   351         // Sending in progress.
       
   352         case KMsvSendStateSending:
       
   353             res = R_SMTP_OUTBOX_STATUS_SENDING;
       
   354             break;
       
   355 
       
   356         case KMsvSendStateSent:
       
   357             // how these should be handled?
       
   358             break;
       
   359 
       
   360         // Unknown (!)
       
   361         case KMsvSendStateUnknown:
       
   362         default:
       
   363 #ifdef _DEBUG
       
   364             User::Panic(KImumMtmUiPanic, ESmtpMtmUdUnknownMsgStatus);
       
   365 #endif
       
   366             break;
       
   367             }
       
   368         if(!res)
       
   369             return HBufC::NewL(0);
       
   370         else
       
   371             return iCoeEnv->AllocReadResourceL(res);
       
   372     }
       
   373 
       
   374 // ----------------------------------------------------------------------------
       
   375 // CheckEntry
       
   376 // ----------------------------------------------------------------------------
       
   377 TBool CSmtpMtmUiData::CheckEntry(const TMsvEntry& aContext) const
       
   378     {
       
   379     return ( (aContext.iMtm==KUidMsgTypeSMTP) && (aContext.iType.iUid!=KUidMsvFolderEntryValue) );
       
   380     }
       
   381 
       
   382 // ----------------------------------------------------------------------------
       
   383 // CSmtpMtmUiData::CreateSkinnedBitmapsL
       
   384 //
       
   385 // ----------------------------------------------------------------------------
       
   386 void CSmtpMtmUiData::CreateSkinnedBitmapsL( TInt aNumZoomStates )
       
   387     {
       
   388     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
       
   389     TAknsItemID id;
       
   390     CFbsBitmap* bitmap;
       
   391     CFbsBitmap* bitmapMask;
       
   392 
       
   393     CBitmapArray* array = NULL;
       
   394 
       
   395     id.Set( KAknsIIDQgnPropMceMailFetRead );
       
   396 
       
   397     array = new(ELeave) CArrayPtrFlat<CFbsBitmap>( aNumZoomStates );
       
   398     CleanupStack::PushL( array );
       
   399 
       
   400     TParse tp;
       
   401     tp.Set( KSmtpMtmUdBitmapFile, &KDC_APP_BITMAP_DIR, NULL );
       
   402 
       
   403     AknsUtils::CreateIconL( skins, id, bitmap,
       
   404         bitmapMask, tp.FullName(), EMbmMuiuQgn_prop_mce_mail_fet_read,
       
   405         EMbmMuiuQgn_prop_mce_mail_fet_read_mask );
       
   406 
       
   407 
       
   408     array->AppendL( bitmap );
       
   409     array->AppendL( bitmapMask );
       
   410     iIconArrays->AppendL( array );
       
   411 
       
   412     CleanupStack::Pop();//array
       
   413     }
       
   414 
       
   415 // End of File
       
   416