localconnectivityservice/obexreceiveservices/mtmuibluetooth/src/btmtmuidata.cpp
branchRCL_3
changeset 39 4096754ee773
parent 38 3dcb815346df
child 40 52a167391590
equal deleted inserted replaced
38:3dcb815346df 39:4096754ee773
     1 /*
       
     2 * Copyright (c) 2002 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 *      Class CBtMtmUiData
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "btmtmuidata.h"
       
    22 #include "btmtmuidebug.h"
       
    23 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    24 #include <mtmdef.hrh>       //kuidmtmquerymaxbodysizevalue etc
       
    25 #else
       
    26 #include <mtmdef.hrh>       //kuidmtmquerymaxbodysizevalue etc
       
    27 #include <mtmuidsdef.hrh>       //kuidmtmquerymaxbodysizevalue etc
       
    28 #endif
       
    29 #include <msvuids.h>
       
    30 #include <Obexutils.rsg> 
       
    31 #include <obexutilsmessagehandler.h>
       
    32 
       
    33 
       
    34 const TInt KBtMtmUiNfcContext       = 2;
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 
       
    38 // Two-phased constructor.
       
    39 CBtMtmUiData* CBtMtmUiData::NewL( CRegisteredMtmDll& aRegisteredDll )
       
    40 	{
       
    41     FLOG( _L( " CBtMtmUiData: CBtMtmUiData\t" ) );
       
    42 	CBtMtmUiData* self = new(ELeave) CBtMtmUiData( aRegisteredDll );
       
    43 	CleanupStack::PushL( self );
       
    44 	self->ConstructL();
       
    45 	CleanupStack::Pop( self );
       
    46 	return self;
       
    47 	}
       
    48 
       
    49 // Symbian OS default constructor can leave.
       
    50 void CBtMtmUiData::ConstructL()
       
    51 	{
       
    52     FLOG( _L( " CBtMtmUiData: ConstructL\t" ) );
       
    53     CBaseMtmUiData::ConstructL();
       
    54     TObexUtilsMessageHandler::CreateDefaultMtmServiceL(KUidMsgTypeBt);
       
    55     FLOG( _L( " CBtMtmUiData: ConstructL done\t" ) );
       
    56 	}
       
    57 
       
    58 // C++ default constructor can NOT contain any code, that
       
    59 // might leave.
       
    60 //
       
    61 CBtMtmUiData::CBtMtmUiData(CRegisteredMtmDll& aRegisteredDll)
       
    62 	:       CBaseMtmUiData(aRegisteredDll)
       
    63 	{
       
    64     FLOG( _L( " CBtMtmUiData: CBtMtmUiData\t" ) );
       
    65 	}
       
    66 
       
    67 // Destructor
       
    68 CBtMtmUiData::~CBtMtmUiData()
       
    69 	{ 
       
    70     FLOG( _L( " CBtMtmUiData: ~CBtMtmUiData\t" ) );
       
    71 	}
       
    72 
       
    73 // ---------------------------------------------------------
       
    74 // OperationSupportedL(...)
       
    75 // 
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 TInt CBtMtmUiData::OperationSupportedL( TInt /*aOperationId*/, 
       
    79                                        const TMsvEntry& /*aContext*/) const
       
    80 	{
       
    81     FLOG( _L( " CBtMtmUiData: OperationSupportedL\t" ) );    
       
    82 	return TObexUtilsUiLayer::OperationNotSupported(); 
       
    83 	}
       
    84 
       
    85 // ---------------------------------------------------------
       
    86 // QueryCapability(...)
       
    87 // MTM query capability
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 TInt CBtMtmUiData::QueryCapability( TUid aCapability, 
       
    91                                    TInt& aResponse ) const
       
    92 	{
       
    93     FLOG( _L( " CBtMtmUiData: QueryCapability\t" ) );
       
    94 	switch( aCapability.iUid )
       
    95 		{
       
    96 	    // --- Supported valued capabilities ---
       
    97 	    case KUidMtmQueryMaxBodySizeValue:
       
    98             {
       
    99 		    aResponse = KMaxTInt;
       
   100 		    break;
       
   101             }
       
   102 	    case KUidMtmQueryMaxTotalMsgSizeValue:
       
   103             {
       
   104 		    aResponse = KMaxTInt;
       
   105 		    break;
       
   106             }
       
   107 	    case KUidMsvMtmQueryEditorUidValue:
       
   108             {
       
   109 			aResponse = 0;
       
   110 		    break;
       
   111             }
       
   112 	    case KUidMtmQuerySupportAttachmentsValue:
       
   113 	    case KUidMtmQueryCanSendMsgValue:
       
   114             {
       
   115 		    break;
       
   116             }
       
   117 	    case KUidMtmQuerySupportedBodyValue:    
       
   118 	    default:
       
   119             {
       
   120 		    return KErrNotSupported;
       
   121             }
       
   122 		}
       
   123 	return KErrNone;
       
   124 	}
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CBitmapArray& CBtMtmUiData::ContextIcon(...)
       
   128 // Handles received msg icon.
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 const CBaseMtmUiData::CBitmapArray& CBtMtmUiData::ContextIcon( const TMsvEntry& aContext, 
       
   132                                                               TInt /*aStateFlags*/) const
       
   133 	{
       
   134 	// Check if NFC context
       
   135 	TInt icon = 0;
       
   136 	if ( aContext.MtmData1() == KBtMtmUiNfcContext )
       
   137 	    {
       
   138       icon = TObexUtilsUiLayer::ContextIcon( aContext, ENfc );
       
   139 	    }
       
   140 	else
       
   141 	    {
       
   142 	    icon = TObexUtilsUiLayer::ContextIcon( aContext, EBluetooth );
       
   143 	    }
       
   144 
       
   145 	return *iIconArrays->At( icon/2 ); 
       
   146 	}
       
   147 
       
   148 // ---------------------------------------------------------
       
   149 // PopulateArraysL()
       
   150 // Populates bitmap array 
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 void CBtMtmUiData::PopulateArraysL()
       
   154 	{
       
   155     FLOG( _L( " CBtMtmUiData: PopulateArraysL\t" ) );
       
   156 	TObexUtilsUiLayer::CreateIconsL( KUidMsgTypeBt, iIconArrays );
       
   157 	}
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // GetResourceFileName(TFileName& aFileName) const
       
   161 // Gives resource filename.
       
   162 // ---------------------------------------------------------
       
   163 //
       
   164 void CBtMtmUiData::GetResourceFileName( TFileName& aFileName ) const
       
   165 	{ 
       
   166     FLOG( _L( " CBtMtmUiData: GetResourceFileName\t" ) );
       
   167     aFileName = KObexUtilsFileDrive;
       
   168     aFileName += KDC_RESOURCE_FILES_DIR;
       
   169     aFileName += KObexUtilsResourceFileName;
       
   170 	}
       
   171 
       
   172 // ---------------------------------------------------------
       
   173 // CanCreateEntryL(...)
       
   174 // Checks if it is possible to create entry.
       
   175 // ---------------------------------------------------------
       
   176 //
       
   177 TBool CBtMtmUiData::CanCreateEntryL( const TMsvEntry& aParent, 
       
   178                                     TMsvEntry& aNewEntry, 
       
   179                                     TInt& aReasonResourceId ) const
       
   180 	{
       
   181     FLOG( _L( " CBtMtmUiData: CanCreateEntryL\t" ) );
       
   182 	aReasonResourceId = 0;
       
   183 	if( CheckEntry( aNewEntry ) )
       
   184 		{
       
   185         // --- Can create messages in local folders ---
       
   186 		return ( aParent.iMtm.iUid == KMsvLocalServiceIndexEntryIdValue );
       
   187 		}
       
   188 	// --- Can't create other types ---
       
   189 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   190 	return EFalse;
       
   191 	}
       
   192 
       
   193 // ---------------------------------------------------------
       
   194 // CanOpenEntryL(...)
       
   195 // Checks if it is possible to open entry.
       
   196 // ---------------------------------------------------------
       
   197 //
       
   198 TBool CBtMtmUiData::CanOpenEntryL( const TMsvEntry& aContext, 
       
   199                                   TInt& aReasonResourceId ) const
       
   200 	{
       
   201     FLOG( _L( " CBtMtmUiData: CanOpenEntryL\t" ) );
       
   202 	if( CheckEntry( aContext ) )
       
   203 		{
       
   204 		if( aContext.iType.iUid == KUidMsvMessageEntryValue )
       
   205 			{
       
   206 			aReasonResourceId = 0;
       
   207 			return ETrue;
       
   208 			}
       
   209 		}
       
   210 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   211 	return EFalse;
       
   212 	}
       
   213 
       
   214 // ---------------------------------------------------------
       
   215 // CanCloseEntryL(...)
       
   216 // Checks if it is possible to close entry.
       
   217 // ---------------------------------------------------------
       
   218 //
       
   219 TBool CBtMtmUiData::CanCloseEntryL( const TMsvEntry& aContext, 
       
   220                                    TInt& aReasonResourceId ) const
       
   221 	{
       
   222     FLOG( _L( " CBtMtmUiData: CanCloseEntryL\t" ) );
       
   223 	if( CheckEntry( aContext ) )
       
   224 		{
       
   225 		if( aContext.iType.iUid == KUidMsvServiceEntryValue )
       
   226 			{
       
   227 			aReasonResourceId = 0;
       
   228 			return ETrue;
       
   229 			}
       
   230 		}
       
   231 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   232 	return EFalse;
       
   233 	}
       
   234 
       
   235 // ---------------------------------------------------------
       
   236 // CanViewEntryL(...)
       
   237 // Checks if it is possible to view entry.
       
   238 // ---------------------------------------------------------
       
   239 //
       
   240 TBool CBtMtmUiData::CanViewEntryL( const TMsvEntry& aContext, 
       
   241                                   TInt& aReasonResourceId ) const
       
   242 	{
       
   243     FLOG( _L( " CBtMtmUiData: CanViewEntryL\t" ) );
       
   244 	if( CheckEntry( aContext ) )
       
   245 		{
       
   246 		if( aContext.iType.iUid == KUidMsvMessageEntryValue )
       
   247 			{
       
   248 			aReasonResourceId = 0;
       
   249 			return ETrue;
       
   250 			}
       
   251 		}   
       
   252 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   253 	return EFalse;
       
   254 	}
       
   255 
       
   256 // ---------------------------------------------------------
       
   257 // CanEditEntryL(...)
       
   258 // Checks if it is possible to edit entry.
       
   259 // ---------------------------------------------------------
       
   260 //
       
   261 TBool CBtMtmUiData::CanEditEntryL( const TMsvEntry& aContext, 
       
   262                                   TInt& aReasonResourceId ) const
       
   263 	{
       
   264     FLOG( _L( " CBtMtmUiData: CanEditEntryL\t" ) );
       
   265 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   266 	if( CheckEntry( aContext ) )
       
   267 		{
       
   268 		if ( ( aContext.iType.iUid == KUidMsvMessageEntryValue ) || 
       
   269              ( aContext.iType.iUid == KUidMsvFolderEntryValue ) )
       
   270 			{
       
   271 			aReasonResourceId=0;
       
   272 			return ETrue;
       
   273 			}
       
   274 		}
       
   275 	return EFalse;
       
   276 	}
       
   277 
       
   278 // ---------------------------------------------------------
       
   279 // CanDeleteServiceL(...)
       
   280 // Checks if it is possible to delete service.
       
   281 // ---------------------------------------------------------
       
   282 //
       
   283 TBool CBtMtmUiData::CanDeleteServiceL( const TMsvEntry& /*aService*/, 
       
   284                                       TInt& aReasonResourceId ) const
       
   285 	{
       
   286     FLOG( _L( " CBtMtmUiData: CanDeleteServiceL\t" ) );   
       
   287 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   288     return EFalse; 
       
   289 	}
       
   290 
       
   291 // ---------------------------------------------------------
       
   292 // CanDeleteFromEntryL(...)
       
   293 // Checks if it is possible to delete from entry.
       
   294 // ---------------------------------------------------------
       
   295 //
       
   296 TBool CBtMtmUiData::CanDeleteFromEntryL( const TMsvEntry& /*aContext*/, 
       
   297                                         TInt& aReasonResourceId ) const
       
   298 	{
       
   299 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported();
       
   300 	return EFalse;
       
   301 	}
       
   302 
       
   303 // ---------------------------------------------------------
       
   304 // CanCopyMoveToEntryL(...)
       
   305 // Checks if it is possible to move to entry.
       
   306 // ---------------------------------------------------------
       
   307 //
       
   308 TBool CBtMtmUiData::CanCopyMoveToEntryL( const TMsvEntry& /*aContext*/, 
       
   309                                         TInt& aReasonResourceId ) const
       
   310 	{
       
   311 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   312 	return EFalse;
       
   313 	}
       
   314 
       
   315 // ---------------------------------------------------------
       
   316 // CanCopyMoveFromEntryL(...)
       
   317 // Checks if it is possible to move from entry.
       
   318 // ---------------------------------------------------------
       
   319 //
       
   320 TBool CBtMtmUiData::CanCopyMoveFromEntryL( const TMsvEntry& /*aContext*/,
       
   321                                           TInt& aReasonResourceId ) const
       
   322 	{
       
   323 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported(); 
       
   324 	return EFalse;
       
   325 	}
       
   326 
       
   327 // ---------------------------------------------------------
       
   328 // CanReplyToEntryL(...)
       
   329 // Checks if it is possible to reply to entry.
       
   330 // ---------------------------------------------------------
       
   331 //
       
   332 TBool CBtMtmUiData::CanReplyToEntryL( const TMsvEntry& /*aContext*/, 
       
   333                                      TInt& aReasonResourceId ) const
       
   334 	{
       
   335 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported();
       
   336 	return EFalse;	// Not Ok to do
       
   337 	}
       
   338 
       
   339 // ---------------------------------------------------------
       
   340 // CanForwardEntryL(...)
       
   341 // Checks if it is possible to forward entry.
       
   342 // ---------------------------------------------------------
       
   343 //
       
   344 TBool CBtMtmUiData::CanForwardEntryL( const TMsvEntry& /*aContext*/, 
       
   345                                      TInt& aReasonResourceId ) const
       
   346 	{
       
   347 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported();
       
   348 	return EFalse;	// Not Ok to do
       
   349 	}
       
   350 
       
   351 // ---------------------------------------------------------
       
   352 // CheckEntry(...)
       
   353 // Checks is the entry valid.
       
   354 // ---------------------------------------------------------
       
   355 //
       
   356 TBool CBtMtmUiData::CheckEntry( const TMsvEntry& /*aContext*/ ) const
       
   357 	{
       
   358     FLOG( _L( " CBtMtmUiData: CheckEntry\t" ) );
       
   359     return EFalse;
       
   360 	}
       
   361 
       
   362 // ---------------------------------------------------------
       
   363 // CanCancelL(...)
       
   364 // Checks if it is possible to cancel entry.
       
   365 // ---------------------------------------------------------
       
   366 //
       
   367 TBool CBtMtmUiData::CanCancelL( const TMsvEntry& /*aContext*/,
       
   368                                TInt& aReasonResourceId ) const
       
   369     {
       
   370     // No way of sending a message from the outbox, so no need to cancel.
       
   371 	aReasonResourceId = TObexUtilsUiLayer::OperationNotSupported();
       
   372 	return EFalse;
       
   373     }
       
   374 
       
   375 // ---------------------------------------------------------
       
   376 // StatusTextL(...)
       
   377 // Returns status text when sending message(outbox).
       
   378 // ---------------------------------------------------------
       
   379 //
       
   380 HBufC* CBtMtmUiData::StatusTextL( const TMsvEntry& /*aContext*/ ) const
       
   381     {  
       
   382     FLOG( _L( " CBtMtmUiData: StatusTextL\t" ) );
       
   383     TBuf<80> buffer;
       
   384     TInt resourceId = R_BT_SEND_PROGRESS_SENDING;
       
   385     TObexUtilsUiLayer::ReadResourceL( buffer, resourceId );
       
   386     return buffer.AllocL();
       
   387     }
       
   388 
       
   389 //  End of File