btobexprofiles/obexreceiveservices/mtmuibluetooth/src/btmtmui.cpp
branchRCL_3
changeset 55 613943a21004
equal deleted inserted replaced
54:0ba996a9b75d 55:613943a21004
       
     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 *       CBtMtmUi class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "btmtmui.h"
       
    22 #include "btmtmuidebug.h"
       
    23 
       
    24 //#include <obexmtmuilayer.h>
       
    25 #ifdef NO101APPDEPFIXES
       
    26 #include <MuiuMsvProgressReporterOperation.h>
       
    27 #endif  //NO101APPDEPFIXES
       
    28 
       
    29 #ifdef NO101APPDEPFIXES_NEW 
       
    30 #include <app/btcmtm.h>
       
    31 #endif //NO101APPDEPFIXES_NEW
       
    32 
       
    33 #include <mtmuidef.hrh>
       
    34 #include <mtclreg.h>
       
    35 #include <msvuids.h>
       
    36 #include <msvids.h>
       
    37 #include <obexconstants.h>
       
    38 
       
    39 
       
    40 // CONSTANTS
       
    41 #ifdef NO101APPDEPFIXES
       
    42 const TInt KBtMtmUiToFromFieldBuffer     = 80;
       
    43 const TInt KBtMtmUiConnectionTimeout     = 20000000;
       
    44 const TInt KBtMtmUiConnectionPutTimeout  = 0;
       
    45 const TInt KBtMtmUiObexPort              = 1;
       
    46 const TInt KBtMtmUiAddressMaxLength      = 3;
       
    47 #endif  //NO101APPDEPFIXES
       
    48 
       
    49 // ENUMS
       
    50 enum TBtMtmAsyncCmds
       
    51     {
       
    52     EBtMtmCmdSend
       
    53     };
       
    54 
       
    55 // ================= MEMBER FUNCTIONS =======================
       
    56 
       
    57 // C++ default constructor can NOT contain any code, that
       
    58 // might leave.
       
    59 //
       
    60 CBtMtmUi::CBtMtmUi( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll )
       
    61 	:	CBaseMtmUi( aBaseMtm, aRegisteredMtmDll )
       
    62 	{
       
    63     FLOG( _L( "[CBtMtmUi] CBtMtmUi: CBtMtmUi\t" ) );
       
    64 	}
       
    65 
       
    66 // Two-phased constructor.
       
    67 CBtMtmUi* CBtMtmUi::NewL( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll )
       
    68 	{
       
    69     FLOG( _L( "[CBtMtmUi] CBtMtmUi: NewL\t" ) );
       
    70 	CBtMtmUi* self = new( ELeave ) CBtMtmUi( aBaseMtm, aRegisteredMtmDll );
       
    71 	CleanupStack::PushL( self );
       
    72 	self->ConstructL();
       
    73 	CleanupStack::Pop( self );
       
    74 	return self;
       
    75 	}
       
    76 
       
    77 // Destructor
       
    78 CBtMtmUi::~CBtMtmUi()
       
    79 	{
       
    80     FLOG( _L( "[CBtMtmUi] CBtMtmUi: ~CBtMtmUi\t" ) );
       
    81 	delete iClientRegistry;
       
    82 	delete iDialog;
       
    83 	}
       
    84 
       
    85 // Symbian OS default constructor can leave.
       
    86 void CBtMtmUi::ConstructL()
       
    87 	{
       
    88     FLOG( _L( "[CBtMtmUi] CBtMtmUi: ConstructL\t" ) );
       
    89     CBaseMtmUi::ConstructL();
       
    90     iDialog = CObexUtilsDialog::NewL(this);
       
    91 	}
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // GetResourceFileName(...)
       
    95 // return progress status.
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CBtMtmUi::GetResourceFileName( TFileName& aFileName ) const
       
    99 	{ 
       
   100 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetResourceFileName\t" ) );
       
   101 	(void)aFileName;
       
   102 	//todo: This function should be removed it is using avkon resource file.
       
   103 	}
       
   104 
       
   105 // ---------------------------------------------------------
       
   106 // QueryCapability(TUid aCapability, TInt& aResponse)
       
   107 // return capability of mtm.
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 TInt CBtMtmUi::QueryCapability(TUid aCapability, TInt& aResponse)
       
   111 	{ 
       
   112     // Querying of menu availablility is done in syni.
       
   113 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: QueryCapability\t" ) );
       
   114 	if( aCapability.iUid == KUidMsvMtmUiQueryCanPrintMsgValue )
       
   115 		{
       
   116 		aResponse = ETrue;
       
   117 		return KErrNone;
       
   118 		}
       
   119 	return CBaseMtmUi::QueryCapability( aCapability, aResponse );
       
   120 	}
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // InvokeSyncFunctionL(...)
       
   124 // Invoke sync -function from BaseMTM.
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 void CBtMtmUi::InvokeSyncFunctionL( TInt aFunctionId, 
       
   128                                    const CMsvEntrySelection& aSelection, 
       
   129                                    TDes8& aParameter )
       
   130 	{
       
   131 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: InvokeSyncFunctionL\t" ) );
       
   132 	CBaseMtmUi::InvokeSyncFunctionL( aFunctionId, aSelection, aParameter );
       
   133 	}
       
   134 
       
   135 
       
   136 // ---------------------------------------------------------
       
   137 // CreateL(...)
       
   138 // Entry creation forbidden.
       
   139 // ---------------------------------------------------------
       
   140 //
       
   141 CMsvOperation* CBtMtmUi::CreateL( const TMsvEntry& /*aEntry*/,
       
   142                                  CMsvEntry& /*aParent*/, 
       
   143                                  TRequestStatus& /*aStatus*/ )
       
   144 	{
       
   145     FLOG( _L( "[CBtMtmUi] CBtMtmUi: CreateL\t" ) );
       
   146     // Entries created through utility functions.
       
   147 	User::Leave( KErrNotSupported );
       
   148     // Return value is needed for removing compilation errors
       
   149     return NULL;
       
   150 	}
       
   151 
       
   152 // ---------------------------------------------------------
       
   153 // OpenL(TRequestStatus& aStatus)
       
   154 // handles opening entry.
       
   155 // ---------------------------------------------------------
       
   156 //
       
   157 CMsvOperation* CBtMtmUi::OpenL( TRequestStatus& aStatus )
       
   158 	{
       
   159 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: OpenL\t" ) );
       
   160 	const TMsvEntry& context = iBaseMtm.Entry().Entry();
       
   161 	const TUid type( context.iType );
       
   162 	if( ( type == KUidMsvMessageEntry ) &&  
       
   163          ( ( context.Parent() == KMsvSentEntryIdValue )
       
   164          ||( context.Parent() == KMsvGlobalInBoxIndexEntryIdValue ) ) )
       
   165         {
       
   166 		// Message is in the sent folder, so can't be edited
       
   167 		return ViewL( aStatus );
       
   168         }
       
   169 	return EditL( aStatus );
       
   170 	}
       
   171 
       
   172 // ---------------------------------------------------------
       
   173 // OpenL(...)
       
   174 // handles opening entry using selection.
       
   175 // ---------------------------------------------------------
       
   176 //
       
   177 CMsvOperation* CBtMtmUi::OpenL( TRequestStatus& aStatus, 
       
   178                                const CMsvEntrySelection& aSelection )
       
   179 	{
       
   180 	iBaseMtm.Entry().SetEntryL( aSelection.At(0) );
       
   181 	return OpenL( aStatus );
       
   182 	}
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // CloseL(TRequestStatus& aStatus)
       
   186 // Closes entry.
       
   187 // ---------------------------------------------------------
       
   188 //
       
   189 CMsvOperation* CBtMtmUi::CloseL( TRequestStatus& aStatus )
       
   190 	{
       
   191 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: CloseL\t" ) );
       
   192 	CMsvCompletedOperation* op = CMsvCompletedOperation::NewL( Session(), 
       
   193         Type(), 
       
   194         KNullDesC8, 
       
   195         KMsvLocalServiceIndexEntryId, 
       
   196         aStatus);
       
   197 	return op;
       
   198 	}
       
   199 
       
   200 // ---------------------------------------------------------
       
   201 // CloseL(TRequestStatus& aStatus)
       
   202 // Closes entry using selection.
       
   203 // ---------------------------------------------------------
       
   204 //
       
   205 CMsvOperation* CBtMtmUi::CloseL(
       
   206     TRequestStatus& aStatus, 
       
   207     const CMsvEntrySelection& aSelection)
       
   208 	{
       
   209 	iBaseMtm.Entry().SetEntryL( aSelection.At(0) );
       
   210 	return CloseL( aStatus );
       
   211 	}
       
   212 
       
   213 // ---------------------------------------------------------
       
   214 // EditL(...)
       
   215 // Handles message sending using selection.
       
   216 // ---------------------------------------------------------
       
   217 //
       
   218 CMsvOperation* CBtMtmUi::EditL( TRequestStatus& aStatus, const CMsvEntrySelection& aSelection )
       
   219 	{
       
   220     FLOG( _L( "[BtMtmUi] CBtMtmUi: EditL 1 \t" ) );
       
   221 	iBaseMtm.Entry().SetEntryL( aSelection.At(0) );
       
   222 	return EditL( aStatus );
       
   223 	}
       
   224 
       
   225 // ---------------------------------------------------------
       
   226 // EditL(TRequestStatus& aStatus)
       
   227 // Handles message sending over Bluetooth.
       
   228 // ---------------------------------------------------------
       
   229 //
       
   230 CMsvOperation* CBtMtmUi::EditL( TRequestStatus& aStatus )
       
   231 	{
       
   232 	FLOG( _L( "[BtMtmUi] CBtMtmUi: EditL 2 \t" ) );
       
   233 	switch( iBaseMtm.Entry().Entry().iType.iUid )
       
   234 		{
       
   235 	    case KUidMsvMessageEntryValue:
       
   236 		    {
       
   237 		    if( iBaseMtm.Entry().Entry().Parent() != KMsvDraftEntryId &&
       
   238 		       iBaseMtm.Entry().Entry().Parent() != KMsvGlobalOutBoxIndexEntryId )
       
   239 			    {
       
   240 			    //   Edit/"use" entries in the Inbox
       
   241 			    return LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session() );   
       
   242 			    }
       
   243 #ifdef NO101APPDEPFIXES
       
   244 		    else
       
   245 			    {
       
   246 			    TInt resourceId;
       
   247                 HBufC* password = HBufC::NewL(1);
       
   248                 CleanupStack::PushL( password );  // 1st push
       
   249                 BaseMtm().LoadMessageL();
       
   250 
       
   251                 TBTDevAddr address;
       
   252 
       
   253                 CBtClientMtm::SBtcCmdSendParams sendparams;
       
   254 			    sendparams.iTimeouts.iConnectTimeout    = KBtMtmUiConnectionTimeout;
       
   255 			    sendparams.iTimeouts.iPutTimeout        = KBtMtmUiConnectionPutTimeout;
       
   256 			    sendparams.iRemoteObexPort              = KBtMtmUiObexPort;
       
   257 			    sendparams.iConnectPassword             = password;
       
   258 
       
   259                 iDiscovery = CBTEngDiscovery::NewL(this);
       
   260 				CBTDevice* iDevice = CBTDevice::NewL( );
       
   261 				
       
   262 
       
   263                 if ( iDiscovery->SearchRemoteDevice( iDevice ) == KErrNone )
       
   264                     {
       
   265                     TInt retVal=0;
       
   266 				    iWaiter.Start();
       
   267 				    
       
   268 				    if ( iState ==KErrNone)
       
   269 				        {
       
   270 					    address = iDevice->BDAddr();
       
   271 				        FLOG( _L( "[BtMtmUi] CBtMtmUi:SearchRemoteChannelL \t" ) );
       
   272                         retVal = iDiscovery->RemoteProtocolChannelQuery(address, TUUID(KBTSdpObjectPush));
       
   273                         if(retVal == KErrNone)
       
   274                             {
       
   275                             iWaiter.Start();
       
   276                             }
       
   277                         }
       
   278                     if ( retVal != KErrNone ||iState  != KErrNone )
       
   279                         {
       
   280                         //resourceId = R_BT_DEV_NOT_AVAIL;                        
       
   281 						//TObexUtilsUiLayer::ShowInformationNoteL( resourceId );
       
   282                         //todo: Need to use Localized string.
       
   283                         _LIT(KText, "Cannot establish Bluetooth connection");
       
   284                         iDialog->ShowInformationNoteL(KText);
       
   285                         CleanupStack::PopAndDestroy(3); // BtDevice, BtConnection, password
       
   286                         return CMsvCompletedOperation::NewL(
       
   287                              Session(), 
       
   288                              Type(), 
       
   289                              KNullDesC8, 
       
   290                              KMsvLocalServiceIndexEntryId, 
       
   291                             aStatus );
       
   292                         }                     
       
   293                     sendparams.iRemoteObexPort = iClientChannel;
       
   294 
       
   295 			        TPtrC8 ptr8 = address.Des();
       
   296                     TBuf16<KBtMtmUiAddressMaxLength> convertedaddress16;//48 bits
       
   297                     // Bt address conversion
       
   298 			        TInt i;
       
   299                     for( i=0; i<3; i++ )
       
   300                         {
       
   301 			            TUint16 word = ptr8[( i*2 )+1];
       
   302 			            word = ( TUint16 )( word << 8 );
       
   303 			            word = ( TUint16 )( word + ptr8[i*2] );
       
   304 			            convertedaddress16.Append( &word, 1 );
       
   305 			            }
       
   306 
       
   307 			        BaseMtm().AddAddresseeL( convertedaddress16 );
       
   308                     }
       
   309                 else
       
   310                     {
       
   311                     CleanupStack::PopAndDestroy(3); // BtDevice, BTConnection, password
       
   312 				    FLOG( _L( "[BTMTMUI] CBtMtmUi:CMsvCompletedOperation NewL\t" ) );
       
   313                     return CMsvCompletedOperation::NewL(
       
   314                         Session(), 
       
   315                         Type(), 
       
   316                         KNullDesC8, 
       
   317                         KMsvLocalServiceIndexEntryId, 
       
   318                         aStatus );
       
   319                     }
       
   320 
       
   321 			    CMsvEntrySelection* sel = new( ELeave ) CMsvEntrySelection();
       
   322 			    CleanupStack::PushL( sel );					// 4th push
       
   323 			    sel->AppendL( BaseMtm().Entry().EntryId() );
       
   324 			    
       
   325 			    CMsvOperationWait* waiter = CMsvOperationWait::NewLC();	// 5th push
       
   326                 
       
   327                 TBuf<KBtMtmUiToFromFieldBuffer> toFrom;
       
   328                 resourceId = R_BT_SEND_OUTBOX_SENDING;                
       
   329 				TObexUtilsUiLayer::ReadResourceL( toFrom, resourceId );
       
   330                                 
       
   331                 BaseMtm().SaveMessageL();
       
   332 			    
       
   333                 TMsvEntry newTEntry( iBaseMtm.Entry().Entry() );
       
   334 			    newTEntry.iDetails.Set( toFrom );
       
   335                 newTEntry.SetVisible( ETrue );
       
   336                 newTEntry.SetInPreparation( ETrue );
       
   337 
       
   338                 iBaseMtm.Entry().ChangeL( newTEntry );
       
   339 
       
   340 			    CMsvEntry* entry = 
       
   341                     BaseMtm().Session().GetEntryL( KMsvDraftEntryId );
       
   342 
       
   343                 CleanupStack::PushL( entry );  // 6th push
       
   344 
       
   345 			    CMsvOperation* moveOp = entry->MoveL(
       
   346                     *sel,
       
   347                     KMsvGlobalOutBoxIndexEntryId, 
       
   348                     waiter->iStatus );
       
   349 
       
   350                 CleanupStack::PopAndDestroy( entry );
       
   351 
       
   352 			    waiter->Start();
       
   353 			    CActiveScheduler::Start();
       
   354 			    delete moveOp;
       
   355 
       
   356                 CMsvProgressReporterOperation* reporter 
       
   357                     = CMsvProgressReporterOperation::NewL( Session(), aStatus );
       
   358 			    CleanupStack::PushL( reporter );  // 6th push
       
   359 
       
   360    			    TPckgBuf<CBtClientMtm::SBtcCmdSendParams> paramBuf( sendparams );
       
   361 			    
       
   362   			    CMsvOperation* op = BaseMtm().InvokeAsyncFunctionL(
       
   363                     EBtMtmCmdSend, 
       
   364                     *sel,
       
   365                     paramBuf, 
       
   366                     reporter->RequestStatus() );
       
   367 
       
   368                 // ownership of op transfered to reporter
       
   369 		        reporter->SetOperationL( op ); 
       
   370 
       
   371                 aStatus = KRequestPending;
       
   372 
       
   373                 CleanupStack::Pop( reporter );
       
   374                 CleanupStack::PopAndDestroy(3);  // waiter, sel,  password
       
   375                 return reporter;
       
   376 			    }
       
   377 #endif  //NO101APPDEPFIXES
       
   378 		    }
       
   379 	    case KUidMsvServiceEntryValue:
       
   380 	    case KUidMsvAttachmentEntryValue:
       
   381 	    case KUidMsvFolderEntryValue:
       
   382             {
       
   383 		    User::Leave( KErrNotSupported );
       
   384             }
       
   385         default:
       
   386             {
       
   387             break;
       
   388             }
       
   389 		}
       
   390 
       
   391 	CMsvCompletedOperation* op = CMsvCompletedOperation::NewL(
       
   392         Session(), 
       
   393         Type(), 
       
   394         KNullDesC8, 
       
   395         KMsvLocalServiceIndexEntryId, 
       
   396         aStatus );
       
   397     aStatus = KRequestPending;
       
   398 	return op;
       
   399 	}
       
   400 
       
   401 // ---------------------------------------------------------
       
   402 // ViewL(TRequestStatus& aStatus)
       
   403 // Handles viewing of received object.
       
   404 // ---------------------------------------------------------
       
   405 //
       
   406 CMsvOperation* CBtMtmUi::ViewL( TRequestStatus& aStatus )
       
   407 	{
       
   408 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: ViewL\t" ) );
       
   409 	return LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session() );
       
   410 	}
       
   411 
       
   412 // ---------------------------------------------------------
       
   413 // ViewL(...)
       
   414 // Handles viewing of received object using selection.
       
   415 // ---------------------------------------------------------
       
   416 //
       
   417 CMsvOperation* CBtMtmUi::ViewL( TRequestStatus& aStatus, 
       
   418                                const CMsvEntrySelection& aSelection )
       
   419 	{
       
   420     FLOG( _L( "[CBtMtmUi] CBtMtmUi: ViewL 1\t" ) );
       
   421 	iBaseMtm.Entry().SetEntryL( aSelection.At(0) );
       
   422 	return ViewL( aStatus );
       
   423 	}
       
   424 
       
   425 // ---------------------------------------------------------
       
   426 // CopyFromL(...)
       
   427 // Not supported.
       
   428 // ---------------------------------------------------------
       
   429 //
       
   430 CMsvOperation* CBtMtmUi::CopyFromL( const CMsvEntrySelection& /*aSelection*/, 
       
   431                                    TMsvId /*aTargetId*/, 
       
   432                                    TRequestStatus& /*aStatus*/ )
       
   433 	{
       
   434     User::Leave( KErrNotSupported );
       
   435     // Return value is needed for removing compilation errors
       
   436     return NULL;
       
   437 	}
       
   438 
       
   439 // ---------------------------------------------------------
       
   440 // MoveFromL(...)
       
   441 // Not supported.
       
   442 // ---------------------------------------------------------
       
   443 //
       
   444 CMsvOperation* CBtMtmUi::MoveFromL( const CMsvEntrySelection& /*aSelection*/, 
       
   445                                    TMsvId /*aTargetId*/, 
       
   446                                    TRequestStatus& /*aStatus*/ )
       
   447 	{
       
   448     User::Leave( KErrNotSupported );
       
   449     // Return value is needed for removing compilation errors
       
   450     return NULL;
       
   451 	}
       
   452 
       
   453 // ---------------------------------------------------------
       
   454 // MoveToL(...)
       
   455 // Not supported.
       
   456 // ---------------------------------------------------------
       
   457 //
       
   458 CMsvOperation* CBtMtmUi::MoveToL( const CMsvEntrySelection& /*aSelection*/, 
       
   459                                  TRequestStatus& /*aStatus*/)
       
   460 	{
       
   461     User::Leave( KErrNotSupported );
       
   462     // Return value is needed for removing compilation errors
       
   463     return NULL;
       
   464 	}
       
   465 
       
   466 // ---------------------------------------------------------
       
   467 // CopyToL(...)
       
   468 // Not supported.
       
   469 // ---------------------------------------------------------
       
   470 //
       
   471 CMsvOperation* CBtMtmUi::CopyToL( const CMsvEntrySelection& /*aSelection*/, 
       
   472                                  TRequestStatus& /*aStatus*/)
       
   473 	{
       
   474     User::Leave( KErrNotSupported );
       
   475     // Return value is needed for removing compilation errors
       
   476     return NULL;
       
   477 	}
       
   478 
       
   479 // ---------------------------------------------------------
       
   480 // DisplayProgressSummary(const TDesC8& aProgress) const
       
   481 // calls leaving DisplayProgressSummaryL -function and
       
   482 // traps the error.
       
   483 // ---------------------------------------------------------
       
   484 //
       
   485 TInt CBtMtmUi::DisplayProgressSummary( const TDesC8& aProgress ) const
       
   486     {
       
   487     TInt retVal = KErrNone;
       
   488     TRAP( retVal, retVal = DisplayProgressSummaryL( aProgress ) );
       
   489     return retVal;
       
   490     }
       
   491 
       
   492 // ---------------------------------------------------------
       
   493 // DisplayProgressSummary(const TDesC8& aProgress) const
       
   494 // calls leaving DisplayProgressSummaryL -function and
       
   495 // traps the error.
       
   496 // ---------------------------------------------------------
       
   497 //
       
   498 TInt CBtMtmUi::DisplayProgressSummaryL( const TDesC8& aProgress ) const
       
   499     {
       
   500     #ifndef NO101APPDEPFIXES_NEW
       
   501     (void) aProgress;
       
   502     #endif //NO101APPDEPFIXES_NEW
       
   503 
       
   504     #ifdef NO101APPDEPFIXES_NEW
       
   505     FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL\t" ) );
       
   506     TInt resourceId;
       
   507     if( ( !aProgress.Length() ) || ( aProgress.Size() == sizeof( TMsvLocalOperationProgress ) ) )
       
   508         {
       
   509         // Probably a CMsvCompletedOperation
       
   510         return KErrCancel;
       
   511         }
       
   512 	TPckgBuf<TObexMtmProgress> paramPack;
       
   513 	paramPack.Copy( aProgress );
       
   514 	TObexMtmProgress& progress = paramPack();
       
   515 
       
   516 	const TObexMtmProgress::TSendState progressType	= progress.iSendState;
       
   517 	const TInt error = progress.iError;
       
   518     if ( error == KErrInUse )
       
   519 		{
       
   520         //resourceId = R_BT_DEV_NOT_AVAIL;
       
   521 		//TObexUtilsUiLayer::ShowInformationNoteL( resourceId );
       
   522         //todo: Need to use Localized string.
       
   523         _LIT(KText, "Cannot establish Bluetooth connection");
       
   524         iDialog->ShowInformationNoteL(KText);
       
   525 
       
   526 	    return KErrNone;
       
   527 		}
       
   528     
       
   529 	switch( progressType )
       
   530 		{
       
   531 	    case TObexMtmProgress::EDisconnected:
       
   532             {
       
   533             FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: EDisconnected\t" ) );
       
   534             // Allowed to send again.
       
   535             //resourceId = R_BT_DATA_SENT;
       
   536 			//TObexUtilsUiLayer::ShowInformationNoteL( resourceId );
       
   537             //todo: Need to use Localized string.
       
   538             _LIT(KText, "Message sent!");
       
   539             iDialog->ShowInformationNoteL(KText);
       
   540 
       
   541 		    break;
       
   542             }
       
   543         case TObexMtmProgress::ESendError:
       
   544             {
       
   545             FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: ESendError\t" ) );
       
   546             if( error == KErrIrObexClientNoDevicesFound )
       
   547                 {
       
   548                 //resourceId = R_BT_DEV_NOT_AVAIL;
       
   549 				//TObexUtilsUiLayer::ShowInformationNoteL( resourceId );
       
   550                 //todo: Need to use Localized string.
       
   551                 _LIT(KText, "Cannot establish Bluetooth connection");
       
   552                 iDialog->ShowInformationNoteL(KText);
       
   553 
       
   554                 }
       
   555             else
       
   556                 {
       
   557                 //resourceId = R_BT_FAILED_TO_SEND;
       
   558 				//TObexUtilsUiLayer::ShowErrorNoteL( resourceId );
       
   559                 //todo: Need to use Localized string.
       
   560                 _LIT(KText, "Failed to send message");
       
   561                 iDialog->ShowErrorNoteL(KText);
       
   562 
       
   563                 }
       
   564             break;
       
   565             }
       
   566         case TObexMtmProgress::ESendComplete:
       
   567             {
       
   568             FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: ESendComplete\t" ) );
       
   569             break;
       
   570             }
       
   571         case TObexMtmProgress::EInitialise:
       
   572 	    case TObexMtmProgress::EConnect:
       
   573 	    case TObexMtmProgress::EConnectAttemptComplete:
       
   574 	    case TObexMtmProgress::ESendObject:
       
   575 	    case TObexMtmProgress::ESendNextObject:
       
   576             {
       
   577             FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: ESendObject\t" ) );
       
   578             return KErrCancel;
       
   579             }
       
   580         case TObexMtmProgress::EUserCancelled:
       
   581             {
       
   582             FLOG( _L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: EUserCancelled\t" ) );
       
   583             return KErrCancel;
       
   584             }
       
   585 	    default:
       
   586             {
       
   587             FTRACE( FPrint(_L( "[CBtMtmUi] CBtMtmUi:DisplayProgressSummaryL: Default\t %d" ), progressType ) );
       
   588             return KErrCancel;
       
   589             }
       
   590         }
       
   591   #endif //NO101APPDEPFIXES_NEW
       
   592 	return KErrNone;
       
   593 	}
       
   594 
       
   595 
       
   596 // ---------------------------------------------------------
       
   597 // GetProgress(...)
       
   598 // return progress status.
       
   599 // ---------------------------------------------------------
       
   600 //
       
   601 TInt CBtMtmUi::GetProgress( const TDesC8& aProgress,
       
   602                            TBuf<EProgressStringMaxLen>& aReturnString, 
       
   603                            TInt& aTotalEntryCount, 
       
   604                            TInt& aEntriesDone, 
       
   605                            TInt& aCurrentEntrySize, 
       
   606                            TInt& aCurrentBytesTrans ) const
       
   607 	{
       
   608 	#ifndef NO101APPDEPFIXES_NEW
       
   609 	(void) aProgress;
       
   610 	(void) aReturnString;
       
   611 	(void) aTotalEntryCount;
       
   612 	(void) aEntriesDone;
       
   613 	(void) aCurrentEntrySize;
       
   614 	(void) aCurrentBytesTrans;	
       
   615 	#endif //NO101APPDEPFIXES_NEW
       
   616 	
       
   617    #ifdef  NO101APPDEPFIXES_NEW
       
   618     TInt resourceId;    
       
   619 
       
   620 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetProgress\t" ) );	
       
   621 	TPckgBuf<TObexMtmProgress> paramPack;
       
   622 	paramPack.Copy( aProgress );
       
   623 	TObexMtmProgress& progress = paramPack();
       
   624     const TObexMtmProgress::TSendState progressType	= progress.iSendState;
       
   625 	aTotalEntryCount	= progress.iTotalEntryCount;
       
   626 	aEntriesDone		= progress.iEntriesDone;
       
   627 	aCurrentEntrySize	= progress.iCurrentEntrySize; 
       
   628 	aCurrentBytesTrans	= progress.iCurrentBytesTrans;
       
   629 
       
   630     if( aTotalEntryCount > 1 ) // This is for progress bar multisending
       
   631         {
       
   632         aCurrentEntrySize = 0;
       
   633         }
       
   634 
       
   635 	switch( progressType )
       
   636 		{
       
   637 	    case TObexMtmProgress::ENullOp:
       
   638 	    case TObexMtmProgress::ESendError:
       
   639             {
       
   640 		    aReturnString = KNullDesC;
       
   641 		    break;
       
   642             }
       
   643 	    case TObexMtmProgress::EInitialise:
       
   644 	    case TObexMtmProgress::EConnect:
       
   645 	    case TObexMtmProgress::EConnectAttemptComplete:
       
   646             {
       
   647             resourceId = R_BT_CONNECTING;
       
   648 			TRAPD( retVal, TObexUtilsUiLayer::ReadResourceL( aReturnString, resourceId ) );
       
   649 						retVal=retVal; //avoid warning
       
   650             // Leave causes progress note to be empty. Not fatal
       
   651 		    break;
       
   652             }
       
   653 	    case TObexMtmProgress::ESendObject:
       
   654 	    case TObexMtmProgress::ESendNextObject:
       
   655 	    case TObexMtmProgress::ESendComplete:
       
   656             {
       
   657             resourceId = R_BT_SENDING_DATA;
       
   658 			TRAPD( retVal, TObexUtilsUiLayer::ReadResourceL( aReturnString, resourceId ) );
       
   659             // Leave causes progress note to be empty. Not fatal
       
   660             retVal=retVal; //avoid warning
       
   661 		    break;
       
   662             }
       
   663 	    case TObexMtmProgress::EDisconnected:
       
   664             {
       
   665 		    break;
       
   666             }
       
   667 	    default:
       
   668             {
       
   669 		    return KErrCancel;
       
   670             }
       
   671 		}
       
   672 	FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetProgress Done\t" ) );
       
   673 	#endif //NO101APPDEPFIXES_NEW
       
   674 	return KErrNone;
       
   675 	}
       
   676 
       
   677 // ---------------------------------------------------------
       
   678 // LaunchEditorApplicationL(...)
       
   679 // Launch viewer for selected object. The first is object's 
       
   680 // recognition(document handler).
       
   681 // ---------------------------------------------------------
       
   682 //
       
   683 CMsvOperation* CBtMtmUi::LaunchEditorApplicationL( TRequestStatus& aStatus, 
       
   684                                                   CMsvSession& aSession)
       
   685 	{
       
   686 	FLOG( _L( "[CommonMtmUi] CBtMtmUi: LaunchEditorApplicationL\t" ) );
       
   687 	(void)aStatus;
       
   688 	(void)aSession;
       
   689 	//CMsvEntry* message;
       
   690 	//message = &iBaseMtm.Entry();
       
   691 	//todo: need to replace this 
       
   692 	//return TObexUtilsUiLayer::LaunchEditorApplicationOperationL( aSession, message, aStatus );
       
   693 	return NULL;
       
   694 	}
       
   695 
       
   696 // ---------------------------------------------------------
       
   697 // GetClientMtmLC(TUid aMtmType)
       
   698 // Handles MTM registration.
       
   699 // ---------------------------------------------------------
       
   700 //
       
   701 CBaseMtm* CBtMtmUi::GetClientMtmLC( TUid aMtmType )
       
   702 	{
       
   703     FLOG( _L( "[CBtMtmUi] CBtMtmUi: GetClientMtmLC\t" ) );
       
   704 	if( !iClientRegistry )
       
   705         {
       
   706 		iClientRegistry = CClientMtmRegistry::NewL( Session() );
       
   707         }
       
   708 	CBaseMtm* mtm = iClientRegistry->NewMtmL( aMtmType );
       
   709 	CleanupStack::PushL( mtm );
       
   710 	return mtm;
       
   711 	}
       
   712 
       
   713 // ---------------------------------------------------------
       
   714 // DeleteFromL(TUid aMtmType)
       
   715 // passes entry selection to Base for deletion.
       
   716 // ---------------------------------------------------------
       
   717 //
       
   718 CMsvOperation* CBtMtmUi::DeleteFromL( const CMsvEntrySelection& aSelection, 
       
   719                                      TRequestStatus& aStatus )
       
   720 	{
       
   721 	return CBaseMtmUi::DeleteFromL( aSelection, aStatus );
       
   722 	}
       
   723 
       
   724 // ---------------------------------------------------------
       
   725 // DeleteServiceL(...)
       
   726 // has no service, just complete it.
       
   727 // ---------------------------------------------------------
       
   728 //
       
   729 CMsvOperation* CBtMtmUi::DeleteServiceL( const TMsvEntry& /*aService*/, 
       
   730                                         TRequestStatus& aStatus)
       
   731 	{
       
   732 	return CMsvCompletedOperation::NewL(
       
   733         Session(), 
       
   734         Type(), 
       
   735         KNullDesC8, 
       
   736         KMsvLocalServiceIndexEntryId, 
       
   737         aStatus);
       
   738 	}
       
   739 
       
   740 // ---------------------------------------------------------
       
   741 // ReplyL(...)
       
   742 // Reply is forbidden.
       
   743 // ---------------------------------------------------------
       
   744 //
       
   745 CMsvOperation* CBtMtmUi::ReplyL( TMsvId /*aDestination*/, 
       
   746                                 TMsvPartList /*aPartlist*/, 
       
   747                                 TRequestStatus& /*aCompletionStatus*/ )
       
   748 	{
       
   749 	User::Leave( KErrNotSupported );
       
   750     // Return value is needed for removing compilation errors
       
   751     return NULL;
       
   752 	}
       
   753 
       
   754 // ---------------------------------------------------------
       
   755 // ForwardL(...)
       
   756 // Forward is forbidden.
       
   757 // ---------------------------------------------------------
       
   758 //
       
   759 CMsvOperation* CBtMtmUi::ForwardL( TMsvId /*aDestination*/, 
       
   760                                   TMsvPartList /*aPartList*/, 
       
   761                                   TRequestStatus& /*aCompletionStatus*/ )
       
   762 	{
       
   763 	User::Leave( KErrNotSupported );
       
   764     // Return value is needed for removing compilation errors
       
   765     return NULL;
       
   766 	}
       
   767 
       
   768 // ---------------------------------------------------------
       
   769 // CancelL(...)
       
   770 // No MS way of sending a message from the outbox, so no need to cancel.
       
   771 // Just complete it.
       
   772 // ---------------------------------------------------------
       
   773 //
       
   774 CMsvOperation* CBtMtmUi::CancelL( TRequestStatus& aStatus, 
       
   775                                  const CMsvEntrySelection& /*aSelection*/)
       
   776     { 
       
   777 	return CMsvCompletedOperation::NewL(
       
   778         Session(), 
       
   779         Type(), 
       
   780         KNullDesC8, 
       
   781         KMsvLocalServiceIndexEntryId, 
       
   782         aStatus, 
       
   783         KErrNone);
       
   784     }
       
   785     
       
   786 // -----------------------------------------------------------------------------
       
   787 //  CBtMtmUi::ServiceSearchComplete
       
   788 // -----------------------------------------------------------------------------
       
   789 //	
       
   790 void CBtMtmUi::ServiceSearchComplete( const RSdpRecHandleArray& /*aResult*/, 
       
   791                                          TUint /*aTotalRecordsCount*/, TInt /*aErr */)
       
   792     {
       
   793     }
       
   794 
       
   795 // -----------------------------------------------------------------------------
       
   796 // CBtMtmUi::AttributeSearchComplete(
       
   797 // -----------------------------------------------------------------------------
       
   798 //	
       
   799 void CBtMtmUi::AttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, 
       
   800                                            const RSdpResultArray& aAttr, 
       
   801                                            TInt aErr )
       
   802     {
       
   803    iState=aErr;     
       
   804     if (aErr==KErrNone)
       
   805         {            
       
   806         RSdpResultArray results=aAttr;    
       
   807         iDiscovery->ParseRfcommChannel(results,iClientChannel);                        
       
   808         }   
       
   809     iWaiter.AsyncStop();
       
   810     }
       
   811 // -----------------------------------------------------------------------------
       
   812 // CBtMtmUi::ServiceAttributeSearchComplete
       
   813 // -----------------------------------------------------------------------------
       
   814 //	
       
   815 void CBtMtmUi::ServiceAttributeSearchComplete( TSdpServRecordHandle /*aHandle*/, 
       
   816                                                           const RSdpResultArray& /*aAttr*/, 
       
   817                                                           TInt /*aErr*/ )
       
   818     {
       
   819     }
       
   820 // -----------------------------------------------------------------------------
       
   821 // CBtMtmUi::DeviceSearchComplete
       
   822 // -----------------------------------------------------------------------------
       
   823 //	
       
   824 void CBtMtmUi::DeviceSearchComplete( CBTDevice* /*aDevice*/, TInt aErr )
       
   825     {
       
   826     iState=aErr;        
       
   827     iWaiter.AsyncStop();
       
   828     }            
       
   829 
       
   830 void CBtMtmUi::DialogDismissed(TInt /*aButtonId*/)
       
   831     {
       
   832     
       
   833     }
       
   834 
       
   835 // End of File