localconnectivityservice/obexsendservices/obexservicebtsend/src/BTSSProvider.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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <AiwCommon.hrh>
       
    22 #include <btserviceapi.h>
       
    23 #include <AiwVariantType.hrh>
       
    24 #include <AiwVariant.h>
       
    25 #include <AiwMenu.h>
       
    26 #include <f32file.h>
       
    27 #include <btfeaturescfg.h>	// For Enterprise security settings
       
    28 #include <btnotif.h>	// For Enterprise security notifier
       
    29 #include <data_caging_path_literals.hrh> 
       
    30 #include <BtSSMenu.rsg>
       
    31 
       
    32 #include "BTSSProvider.h"
       
    33 #include "BTSendingServiceDebug.h"
       
    34 #include "BTSSSendListHandler.h"
       
    35 
       
    36 _LIT( KBTSendingServiceFileDrive, "z:");
       
    37 _LIT( KBTSSResFileName,"BtSSMenu.rsc");
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CBTSSProvider::CBTSSProvider
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CBTSSProvider::CBTSSProvider(): iConverter(NULL)
       
    48 	{
       
    49 	}
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CBTSSProvider::ConstructL
       
    53 // Symbian 2nd phase constructor can leave.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 void CBTSSProvider::ConstructL()
       
    57     {
       
    58     FLOG(_L("[BTSS]\t CBTSSProvider::ConstructL()"));
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CBTSSProvider::NewL
       
    63 // Two-phased constructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CBTSSProvider* CBTSSProvider::NewL()
       
    67     {
       
    68     CBTSSProvider* self = new( ELeave ) CBTSSProvider;
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop();
       
    72     return self;
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // Destructor
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 CBTSSProvider::~CBTSSProvider()
       
    80 	{
       
    81     FLOG(_L("[BTSS]\t CBTSSProvider::destructor"));
       
    82 	
       
    83     if( iBTSendingService )
       
    84         {
       
    85         delete iBTSendingService;
       
    86         }
       
    87     
       
    88     delete iConverter;
       
    89     iConverter = NULL;
       
    90 	}
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CBTSSProvider::InitialiseL
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CBTSSProvider::InitialiseL(MAiwNotifyCallback& /*aFrameworkCallback*/,
       
    97 								      const RCriteriaArray& /*aInterest*/)
       
    98 	{
       
    99 	// Not needed.
       
   100 	}
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CBTSSProvider::HandleServiceCmdL
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CBTSSProvider::HandleServiceCmdL(const TInt& aCmdId,
       
   107 								    	    const CAiwGenericParamList& aInParamList,
       
   108 											CAiwGenericParamList& /*aOutParamList*/,
       
   109 											TUint /*aCmdOptions*/,
       
   110 											const MAiwNotifyCallback* aCallback )
       
   111 	{	
       
   112     FLOG(_L("[BTSS]\t CBTSSProvider::HandleServiceCmdL()"));
       
   113 	
       
   114     if (  &aInParamList == NULL  || aInParamList.Count() <= 0 ) 
       
   115         {
       
   116         FLOG(_L("[BTSS]\t CBTSSProvider::HandleServiceCmdL() aOutParamList check failed: Leave"));
       
   117         User::Leave( KErrArgument );
       
   118         }
       
   119     
       
   120     if ( aCallback )
       
   121         {
       
   122         FLOG(_L("[BTSS]\t CBTSSProvider::HandleServiceCmdL() aCallback exists: Leave"));
       
   123         User::Leave( KErrNotSupported );
       
   124         }
       
   125 
       
   126     switch ( aCmdId )
       
   127         {
       
   128         case KAiwCmdSend:
       
   129             {
       
   130 			// Check features setting - if not completely enabled with enterprise settings then we are not allowed to send anything.
       
   131 			// Fail here at the first fence, otherwise there are a number of other areas that need to be considered.
       
   132 			if(BluetoothFeatures::EnterpriseEnablementL() != BluetoothFeatures::EEnabled)
       
   133 				{
       
   134 				RNotifier notifier;
       
   135 				User::LeaveIfError(notifier.Connect());
       
   136 				CleanupClosePushL(notifier);
       
   137 				User::LeaveIfError(notifier.StartNotifier(KBTEnterpriseItSecurityInfoNotifierUid, KNullDesC8));
       
   138 				CleanupStack::PopAndDestroy(&notifier);
       
   139 				// Don't leave as we have already commuicated (through the security notifier) why we failed.
       
   140 				break;
       
   141 				}
       
   142 			
       
   143             if ( !iBTSendingService )
       
   144                 {
       
   145                 // Create the controller when needed
       
   146                 //
       
   147                 iBTSendingService = CBTServiceAPI::NewL();
       
   148                 }            
       
   149             CBTServiceParameterList* parameterList = CBTServiceParameterList::NewLC();       
       
   150             
       
   151             iConverter = CBTSSSendListHandler::NewL();
       
   152             User::LeaveIfError(iConverter->ConvertList( &aInParamList, parameterList));
       
   153 			
       
   154                 delete iConverter;
       
   155                 iConverter = NULL;
       
   156 
       
   157             // Start sending files. This function returns when all of the files are sent
       
   158             // or some error has occured.
       
   159             //          
       
   160             
       
   161 			CleanupStack::Pop(parameterList);
       
   162             iBTSendingService->StartSynchronousServiceL( EBTSendingService, parameterList ); 
       
   163            
       
   164 			 break;
       
   165             }
       
   166 		default:
       
   167             {
       
   168             FLOG(_L("[BTSS]\t CBTSSProvider::HandleServiceCmdL() wrong command id: Leave"));
       
   169             User::Leave( KErrNotSupported );
       
   170             break;
       
   171             }
       
   172         }
       
   173 
       
   174     FLOG(_L("[BTSS]\t CBTSSProvider::HandleServiceCmdL() completed"));
       
   175     }
       
   176 
       
   177 	
       
   178  void CBTSSProvider::HandleMenuCmdL(TInt aMenuCmdId, 
       
   179                                     const CAiwGenericParamList& aInParamList,
       
   180                                     CAiwGenericParamList& aOutParamList,
       
   181                                     TUint aCmdOptions,
       
   182                                     const MAiwNotifyCallback* aCallback )
       
   183     {
       
   184     HandleServiceCmdL(aMenuCmdId,aInParamList, aOutParamList, aCmdOptions, aCallback);
       
   185     }
       
   186     
       
   187  void   CBTSSProvider::InitializeMenuPaneL(  CAiwMenuPane& aMenuPane,
       
   188                                             TInt aIndex,
       
   189                                             TInt /* aCascadeId */,
       
   190                                             const CAiwGenericParamList& /*aInParamList*/ )
       
   191     {
       
   192     TFileName resourceFile;
       
   193     TInt resId;
       
   194     
       
   195     resourceFile += KBTSendingServiceFileDrive;
       
   196     resourceFile += KDC_RESOURCE_FILES_DIR;
       
   197     resourceFile += KBTSSResFileName;    
       
   198     resId=R_SEND_VIA_BT_MENU;
       
   199     
       
   200     aMenuPane.AddMenuItemsL(
       
   201             resourceFile, 
       
   202             resId,
       
   203             KAiwCmdSend,
       
   204             aIndex);
       
   205     
       
   206     }
       
   207 
       
   208 // End of file