messagingappbase/bium/src/bioi.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 1998 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:  bioi implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "bioi.h"               // Class declaration
       
    21 #include "bium.pan"             // Panic codes
       
    22 
       
    23 #include <bium.rsg>             // Resources
       
    24 #include <mtmuidef.hrh>
       
    25 #include <mtmdef.hrh>
       
    26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    27 #include <mtmuidsdef.hrh>
       
    28 #endif
       
    29 #include <MtmExtendedCapabilities.hrh>  // for KMtmUiNewMessageAction...
       
    30 #include <msvuids.h>
       
    31 #include <muiu.mbg>             // Resource Bitmap Ids
       
    32 #include <bioscmds.h>           // TBiosCmds & TBioProgress
       
    33 #include <biouids.h>            // KUidBIOMessageTypeMtm...
       
    34 #include <MsgBioUids.h> // KMsgBioUidPictureMsg
       
    35 #include <AknsUtils.h>
       
    36 #include <data_caging_path_literals.hrh>
       
    37 
       
    38 // Defines/constants
       
    39 _LIT(KBIOMtmUdResourceFile,"bium");
       
    40 _LIT(KMuiuIconsFile,"muiu.mbm");
       
    41 
       
    42 const TInt KBiumNumberOfZoomStates = 2; 
       
    43 const TInt KBiumFirstBitmapIndex = EMbmMuiuQgn_prop_mce_smart_read;
       
    44 const TInt KBiumLastBitmapIndex = EMbmMuiuQgn_prop_mce_smart_unread_mask;
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CBioMtmUiData::NewL
       
    48 // Panic function
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 GLDEF_C void Panic(TBioUdPanic aPanic)
       
    52     {
       
    53     _LIT(KPanicName,"BioUiData");
       
    54     User::Panic(KPanicName, aPanic);
       
    55     }
       
    56     
       
    57 // -----------------------------------------------------------------------------
       
    58 // CBioMtmUiData::NewL
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CBioMtmUiData* CBioMtmUiData::NewL(CRegisteredMtmDll& aRegisteredDll)
       
    62     {
       
    63     CBioMtmUiData* self=new(ELeave) CBioMtmUiData(aRegisteredDll);
       
    64     CleanupStack::PushL(self);
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop(self);
       
    67     return self;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CBioMtmUiData::CBioMtmUiData
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CBioMtmUiData::CBioMtmUiData(CRegisteredMtmDll& aRegisteredDll)
       
    75     :   CBaseMtmUiData(aRegisteredDll)
       
    76     {
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CBioMtmUiData::ConstructL
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 void CBioMtmUiData::ConstructL()
       
    84     {
       
    85     //
       
    86     // Construct base
       
    87     CBaseMtmUiData::ConstructL();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CBioMtmUiData::~CBioMtmUiData
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CBioMtmUiData::~CBioMtmUiData()
       
    95     {
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CBioMtmUiData::OperationSupportedL
       
   100 // --- Function querys ---
       
   101 //@todo What about the strings?
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TInt CBioMtmUiData::OperationSupportedL(
       
   105     TInt aOperationId, const TMsvEntry& aContext) const
       
   106     {
       
   107     //
       
   108     // Not supported if context is not of BIO message type or folder or service.
       
   109     if(!CheckEntry(aContext))
       
   110         return KErrNotSupported; //R_BIOUD_NOT_SUPPORTED;
       
   111 
       
   112     //
       
   113     // Handle query, return 0 if operation *is* supported
       
   114     switch(aOperationId)
       
   115         {
       
   116         case KMtmUiFunctionMessageInfo:
       
   117             if (aContext.iType==KUidMsvMessageEntry)
       
   118                 return NULL;
       
   119             break;
       
   120         case KMtmUiFunctionPrint:               // Drop thru
       
   121         case KMtmUiFunctionPrintPreview:
       
   122             return KErrNotSupported; //R_BIOUD_PRINT_NOT_SUPPORTED;
       
   123 
       
   124         case KMtmUiNewMessageAction:            // Drop thru
       
   125         case KBiosMtmParse:                     // Drop thru
       
   126         case KBiosMtmParseThenProcess:          // Drop thru
       
   127         case KBiosMtmProcess:                   // Drop thru
       
   128             return 0;
       
   129         // Called once when MTM is being registered
       
   130         case KMtmUiMessagingInitialisation:
       
   131             break;
       
   132 
       
   133 #if defined(DEBUG)
       
   134         default:
       
   135             Panic(EBioMtmUdUnknownOperationId);
       
   136 #endif
       
   137         };
       
   138 
       
   139     return KErrNotSupported; //R_BIOUD_NOT_SUPPORTED;
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CBioMtmUiData::QueryCapability
       
   144 // --- Capability checks ---
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 TInt CBioMtmUiData::QueryCapability(TUid aCapability, TInt& aResponse) const
       
   148     {
       
   149 	TInt error(KErrNone);
       
   150 
       
   151     switch (aCapability.iUid)
       
   152         {
       
   153         case KMtmUiFunctionMessageInfo:
       
   154 			{
       
   155             break;
       
   156 			}
       
   157         // --- Supported valued capabilities ---
       
   158         case KUidMtmQueryMaxBodySizeValue:
       
   159         case KUidMtmQueryMaxTotalMsgSizeValue:
       
   160 			{
       
   161             aResponse = KMaxTInt;                 // ie. No max value
       
   162             break;
       
   163 			}
       
   164         case KUidMtmQuerySupportedBodyValue:
       
   165 			{
       
   166             aResponse = ETrue;
       
   167             break;
       
   168 			}
       
   169         // --- Supported non-valued capabilities ---
       
   170         case KUidMsvMtmCanActOnNewMessagesUidValue:
       
   171 			{
       
   172             break;
       
   173 			}
       
   174         // --- Non-Supported capabilities ---
       
   175         default:
       
   176 			{
       
   177             error = KErrNotSupported;
       
   178 			}
       
   179         };
       
   180 
       
   181     return error;
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CBioMtmUiData::ContextIcon
       
   186 // --- Context icons ---
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 const CBaseMtmUiData::CBitmapArray& CBioMtmUiData::ContextIcon(
       
   190     const TMsvEntry& aContext,TInt /*aStateFlags*/) const
       
   191     {
       
   192     __ASSERT_DEBUG(CheckEntry(aContext), Panic(EBioMtmUdNoIconAvailable));
       
   193     const TInt KUnreadArrayIndex = 1;
       
   194     const TInt KReadArrayIndex = 0;
       
   195     const TInt arrayIndex = aContext.Unread() ? 
       
   196         KUnreadArrayIndex : 
       
   197         KReadArrayIndex;
       
   198         
       
   199     return *iIconArrays->At(arrayIndex);
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CBioMtmUiData::PopulateArraysL
       
   204 // CBioMtmUiData - (private methods)
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 void CBioMtmUiData::PopulateArraysL()
       
   208     {
       
   209     ReadFunctionsFromResourceFileL(R_BIOUD_FUNCTION_ARRAY);
       
   210 
       
   211     // Populate bitmap array
       
   212 	CreateSkinnedBitmapsL( KBiumNumberOfZoomStates );
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CBioMtmUiData::GetResourceFileName
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 void CBioMtmUiData::GetResourceFileName(TFileName& aFileName) const
       
   220     {
       
   221     aFileName=KBIOMtmUdResourceFile;
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CBioMtmUiData::CanCreateEntryL
       
   226 // --- Function query ---
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 TBool CBioMtmUiData::CanCreateEntryL(
       
   230     const TMsvEntry& /*aParent*/, 
       
   231     TMsvEntry& /*aNewEntry*/, 
       
   232     TInt& /*aReasonResourceId*/) const
       
   233     {
       
   234     // BIO Messages are received only, never created or sent.
       
   235     return EFalse;
       
   236     }
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // CBioMtmUiData::CanOpenEntryL
       
   240 // --- Function query ---
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 TBool CBioMtmUiData::CanOpenEntryL(
       
   244     const TMsvEntry& aContext, TInt& /*aReasonResourceId*/) const
       
   245     {
       
   246     //
       
   247     // If context is a BIO Message Entry then we can open it.
       
   248     if(CheckEntry(aContext))
       
   249         {
       
   250         return ETrue;
       
   251         }
       
   252     return EFalse;
       
   253     }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // CBioMtmUiData::CanCloseEntryL
       
   257 // --- Function query ---
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 TBool CBioMtmUiData::CanCloseEntryL(
       
   261     const TMsvEntry& /*aContext*/, TInt& /*aReasonResourceId*/) const
       
   262     {
       
   263     //
       
   264     // This only used for services, and BIO has no service entry.
       
   265     return EFalse;
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CBioMtmUiData::CanViewEntryL
       
   270 // --- Function query ---
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 TBool CBioMtmUiData::CanViewEntryL(
       
   274     const TMsvEntry& aContext, TInt& /*aReasonResourceId*/) const
       
   275     {
       
   276     //
       
   277     // If context is a BIO Message Entry then we can view it.
       
   278     if(CheckEntry(aContext))
       
   279         {
       
   280         return ETrue;
       
   281         }
       
   282     return EFalse;
       
   283     }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // CBioMtmUiData::CanEditEntryL
       
   287 // --- Function query ---
       
   288 // -----------------------------------------------------------------------------
       
   289 //
       
   290 TBool CBioMtmUiData::CanEditEntryL(
       
   291     const TMsvEntry& /*aContext*/, TInt& /*aReasonResourceId*/) const
       
   292     {
       
   293     //
       
   294     // BIO Messages are received only, never created or sent.
       
   295     return EFalse;
       
   296     }
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CBioMtmUiData::CanDeleteFromEntryL
       
   300 // --- Function query ---
       
   301 // -----------------------------------------------------------------------------
       
   302 //
       
   303 TBool CBioMtmUiData::CanDeleteFromEntryL(
       
   304     const TMsvEntry& /*aContext*/, TInt& /*aReasonResourceId*/) const
       
   305     {
       
   306     //
       
   307     // As BIO messaging does not support folder or service entries,
       
   308     // you can never delete the child of an entry.
       
   309     return EFalse;
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CBioMtmUiData::CanDeleteServiceL
       
   314 // --- Function query ---
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 TBool CBioMtmUiData::CanDeleteServiceL(
       
   318     const TMsvEntry& /*aService*/, TInt& /*aReasonResourceId*/) const
       
   319     {
       
   320     //
       
   321     // BIO messaging does not have folders or services.
       
   322     return EFalse;
       
   323     }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CBioMtmUiData::CanCopyMoveFromEntryL
       
   327 // --- Function query---
       
   328 // -----------------------------------------------------------------------------
       
   329 //
       
   330 TBool CBioMtmUiData::CanCopyMoveFromEntryL(
       
   331     const TMsvEntry& /*aContext*/, TInt& /*aReasonResourceId*/) const
       
   332     {
       
   333     //
       
   334     // As BIO messaging does not support folders or service entries,
       
   335     // you can never copy or move the child of an entry.
       
   336     return EFalse;
       
   337     }
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CBioMtmUiData::CanCopyMoveToEntryL
       
   341 // --- Function query---
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 TBool CBioMtmUiData::CanCopyMoveToEntryL(
       
   345     const TMsvEntry& /*aContext*/, TInt& /*aReasonResourceId*/) const
       
   346     {
       
   347     //
       
   348     // As BIO messaging does not support folders or service entries,
       
   349     // you can never copy or move the child of an entry.
       
   350     return EFalse;
       
   351     }
       
   352 
       
   353 // -----------------------------------------------------------------------------
       
   354 // CBioMtmUiData::CanReplyToEntryL
       
   355 // --- Function query ---
       
   356 // -----------------------------------------------------------------------------
       
   357 //
       
   358 TBool CBioMtmUiData::CanReplyToEntryL(
       
   359     const TMsvEntry& aContext, TInt& /*aReasonResourceId*/) const
       
   360     {
       
   361     //
       
   362 	// Reply is possible only for Picture messages
       
   363 	return (aContext.iBioType == KMsgBioUidPictureMsg.iUid);
       
   364     }
       
   365 
       
   366 // -----------------------------------------------------------------------------
       
   367 // CBioMtmUiData::CreateSkinnedBitmapsL
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 // --- Function query ---
       
   371 TBool CBioMtmUiData::CanForwardEntryL(
       
   372     const TMsvEntry& /*aContext*/, TInt& /*aReasonResourceId*/) const
       
   373     {
       
   374     //
       
   375     // BIO Messages are received only, never created or sent.
       
   376     return EFalse;
       
   377     }
       
   378 
       
   379 // -----------------------------------------------------------------------------
       
   380 // CBioMtmUiData::CanCancelL
       
   381 // --- Function query ---
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 TBool CBioMtmUiData::CanCancelL(
       
   385     const TMsvEntry& /*aContext*/, TInt& /*aReasonResourceId*/) const
       
   386     {
       
   387     // BIO messages can never be sent, consequently can never be cancelled.
       
   388     return EFalse;
       
   389     }
       
   390 
       
   391 // -----------------------------------------------------------------------------
       
   392 // CBioMtmUiData::StatusTextL
       
   393 // --- Function query ---
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 HBufC* CBioMtmUiData::StatusTextL(const TMsvEntry& /*aContext*/) const
       
   397     {
       
   398     // BIO messages never have a status in the outbox.
       
   399     return HBufC::NewL(1);
       
   400     }
       
   401 
       
   402 // -----------------------------------------------------------------------------
       
   403 // CBioMtmUiData::CheckEntry
       
   404 // --- Specific functions to BIOI ---
       
   405 // -----------------------------------------------------------------------------
       
   406 //
       
   407 TBool CBioMtmUiData::CheckEntry(const TMsvEntry& aContext) const
       
   408     {
       
   409     // Only MESSAGES of BIO MsgType are supported, 
       
   410     // not Bio Msg FOLDERS or SERVICES.
       
   411     return ((aContext.iMtm==KUidBIOMessageTypeMtm) &&
       
   412             (aContext.iType.iUid==KUidMsvMessageEntryValue));
       
   413     }
       
   414 
       
   415 // -----------------------------------------------------------------------------
       
   416 // CBioMtmUiData::CreateSkinnedBitmapsL
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 void CBioMtmUiData::CreateSkinnedBitmapsL( TInt aNumZoomStates )
       
   420     {
       
   421     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
       
   422     TAknsItemID id;
       
   423     CFbsBitmap* bitmap;
       
   424     CFbsBitmap* bitmapMask;
       
   425     TBool found = ETrue;
       
   426     
       
   427     CBitmapArray* array = NULL;
       
   428     
       
   429     for( TInt i = KBiumFirstBitmapIndex; i < KBiumLastBitmapIndex+1; i++ )
       
   430         {
       
   431         found = ETrue;
       
   432         switch( i )
       
   433             {
       
   434 			case EMbmMuiuQgn_prop_mce_smart_read:
       
   435 				id.Set( KAknsIIDQgnPropMceSmartRead );
       
   436                 break;
       
   437 			case EMbmMuiuQgn_prop_mce_smart_unread:
       
   438 				id.Set( KAknsIIDQgnPropMceSmartUnread );
       
   439                 break;
       
   440             default:
       
   441                 found = EFalse;
       
   442                 break;
       
   443             }
       
   444 
       
   445         if( found )
       
   446             {
       
   447             array = new(ELeave) CArrayPtrFlat< CFbsBitmap >( aNumZoomStates );
       
   448             CleanupStack::PushL( array );
       
   449 
       
   450             TParse tp;
       
   451             tp.Set( KMuiuIconsFile, &KDC_APP_BITMAP_DIR, NULL );
       
   452             
       
   453             AknsUtils::CreateIconL( skins, id, bitmap,
       
   454                 bitmapMask, tp.FullName(), i, i + 1 );
       
   455 
       
   456             array->AppendL( bitmap );
       
   457             array->AppendL( bitmapMask );
       
   458             iIconArrays->AppendL( array );
       
   459 
       
   460             CleanupStack::Pop(); //array
       
   461             }       
       
   462         }
       
   463 	}
       
   464 
       
   465 // end of file