ImagePrint/ImagePrintEngine/DeviceProtocols/btprotocol/src/cbtonquery.cpp
branchGCC_SURGE
changeset 25 59ea2209bb67
parent 23 08cc4cc059d4
parent 15 a92d00fca574
equal deleted inserted replaced
23:08cc4cc059d4 25:59ea2209bb67
     1 /*
       
     2 * Copyright (c) 2004-2007 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:  Contains the CBtOnQuery class definition. This Implementation is used to avoid
       
    15 *  				 User::WaitForRequest() function and ViewServer 11 panic when BT naming query is activated. 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <btnotifierapi.h>
       
    22 
       
    23 #include "cbtonquery.h"
       
    24 #include "mbtonnotify.h"
       
    25 #include "clog.h"
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ==============================
       
    28 
       
    29 // ----------------------------------------------------------------------------
       
    30 // CObjectExchangeClient::NewL()
       
    31 // Symbian two-phased constructor.
       
    32 // ----------------------------------------------------------------------------
       
    33 //
       
    34 CBtOnQuery* CBtOnQuery::NewL( MBTOnNotify& aNotify )  
       
    35 	{
       
    36 	CBtOnQuery* self = CBtOnQuery::NewLC( aNotify );
       
    37     CleanupStack::Pop( self );
       
    38     return self;
       
    39 	}
       
    40 
       
    41 // ----------------------------------------------------------------------------
       
    42 // CBtOnQuery::NewLC()
       
    43 // Symbian two-phased constructor.
       
    44 // ----------------------------------------------------------------------------
       
    45 //
       
    46 CBtOnQuery* CBtOnQuery::NewLC( MBTOnNotify& aNotify )
       
    47     {
       
    48     CBtOnQuery* self;
       
    49     self = new ( ELeave ) CBtOnQuery( aNotify );
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     return self;
       
    53    	}
       
    54 
       
    55 // ----------------------------------------------------------------------------
       
    56 // CBtOnQuery::CBtOnQuery()
       
    57 // Constructor.
       
    58 // ----------------------------------------------------------------------------
       
    59 //
       
    60 CBtOnQuery::CBtOnQuery( MBTOnNotify& aNotify ) : CActive( CActive::EPriorityLow ),
       
    61                                                  iNotify( aNotify )
       
    62     {
       
    63 	CActiveScheduler::Add( this );
       
    64     }
       
    65 
       
    66 // ----------------------------------------------------------------------------
       
    67 // CBtOnQuery::~CBtOnQuery()
       
    68 // Destructor.
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 CBtOnQuery::~CBtOnQuery()
       
    72     {
       
    73 	Cancel();
       
    74     }
       
    75 
       
    76 // ----------------------------------------------------------------------------
       
    77 // CBtOnQuery::ConstructL()
       
    78 // Perform second phase construction of this object.
       
    79 // ----------------------------------------------------------------------------
       
    80 //
       
    81 void CBtOnQuery::ConstructL()
       
    82     {
       
    83     iResultPckg = EFalse;
       
    84     }
       
    85 
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // CBtOnQuery::IsBluetoothOn()
       
    89 // Starts Notifier to ask user to BT activation. 
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 void CBtOnQuery::IsBluetoothOn()
       
    93     {
       
    94     LOG("CBtOnQuery::IsBluetoothOn, start");
       
    95 	TPckgBuf<TBool> pckg( ETrue ); // Input parameter
       
    96 
       
    97 	if( iNotif.Connect() == KErrNone )
       
    98 		{		
       
    99 	    LOG("CBtOnQuery::IsBluetoothOn() iNotif.Connect() == KErrNone");
       
   100 		iNotif.StartNotifierAndGetResponse( iStatus, KPowerModeSettingNotifierUid, pckg, iResultPckg );
       
   101 	    LOG1("CBtOnQuery::IsBluetoothOn %d", iResultPckg());
       
   102 		}
       
   103 
       
   104 	SetActive();
       
   105     LOG("CBtOnQuery::IsBluetoothOn, end");
       
   106     }
       
   107 
       
   108 // ----------------------------------------------------------------------------
       
   109 // CBtOnQuery::IsBluetoothOn()
       
   110 // Respond to an event. 
       
   111 // ----------------------------------------------------------------------------
       
   112 //
       
   113 void CBtOnQuery::RunL()
       
   114     {
       
   115     LOG1("CBtOnQuery::RunL() %d", iStatus.Int());
       
   116     if( iStatus.Int() == KErrNone || iStatus.Int() == KErrCancel || iStatus.Int() == KErrGeneral )
       
   117         {
       
   118       	iNotif.CancelNotifier( KPowerModeSettingNotifierUid );
       
   119 		iNotif.Close();
       
   120 		LOG1("CBtOnQuery::RunL() %d", iResultPckg());
       
   121         iNotify.BTOnCompleteL( iResultPckg() );  // iResultPckg contains user answer 
       
   122         }   
       
   123 	LOG("CBtOnQuery::RunL()  End");		// Activate BT -> iResultPckg = ETrue 
       
   124     }                                           // No BT Activation -> iResultPckg  EFalse) 
       
   125 
       
   126 // ----------------------------------------------------------------------------
       
   127 // CBtOnQuery::RunError()
       
   128 // Handles errors which is throwed by RunL() function. 
       
   129 // ----------------------------------------------------------------------------
       
   130 //
       
   131 void CBtOnQuery::RunError()
       
   132     {
       
   133 	// No implementation required										
       
   134     }
       
   135 
       
   136 // ----------------------------------------------------------------------------
       
   137 // CBtOnQuery::RunError()
       
   138 // Cancel any outstanding requests.
       
   139 // ----------------------------------------------------------------------------
       
   140 //
       
   141 void CBtOnQuery::DoCancel()
       
   142     {
       
   143     // No implementation required
       
   144     }
       
   145 
       
   146 // End of file