void DoMemoryLeakTests(TUid aUid,TBool aCheckMNotifierManager)
	{
	TInt r;
	TRequestStatus stat;

	test.Start(_L("Connect to notifier server"));
	RNotifier n;
	r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("Get Notifier Server Heap Info"));
	static TBuf8<128> heapInfo1;
	heapInfo1.Zero();
	n.StartNotifierAndGetResponse(stat,aUid,KHeapData,heapInfo1);
	User::WaitForRequest(stat);
	n.CancelNotifier(aUid);
	TInt heapCellCount=stat.Int();
	test(heapCellCount>0);

	test.Next(_L("Repeated StartNotifierAndGetResponse"));
	for(TInt i=0; i<1000; i++)
		{
		TBuf8<128> response;
		response.SetMax();
		response.FillZ();
		response.Zero();
		n.StartNotifierAndGetResponse(stat,aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KStartData,response);
		User::WaitForRequest(stat);
		n.CancelNotifier(aUid);
		test(stat==KErrNone);
		test(response==KResponseData);
		}

	test.Next(_L("Check Notifier Server Heap Info"));
	static TBuf8<128> heapInfo2;
	heapInfo2.Zero();
	n.StartNotifierAndGetResponse(stat,aUid,KHeapData,heapInfo2);
	User::WaitForRequest(stat);
	n.CancelNotifier(aUid);
	test(stat==heapCellCount);
	
	TInt size1, size2;
	TLex8 lex(heapInfo1);
	r = lex.Val(size1);
	test(r==KErrNone);
	lex.Assign(heapInfo2);
	r = lex.Val(size2);
	test(r==KErrNone);
	//allocated size after should not be greater than before BUT may be less with new allocator
	test(size2 <= size1); 

	test.Next(_L("Close connection to notifier server"));
	n.Close();

	test.End();
	}
// -----------------------------------------------------------------------------
// CTestDomExtNotifiers::TestCANSASHandleMessageL
// -----------------------------------------------------------------------------
//
TInt CTestDomExtNotifiers::TestCANSASHandleMessageL( CStifItemParser& /*aItem*/ )
    {
    // Print to UI
    _LIT( KTestDomExtNotifiers, "TestDomExtNotifiers" );
    _LIT( KTestCANSASHandleMessageL, "TestCANSASHandleMessageL" );
    TestModuleIf().Printf( 0, KTestDomExtNotifiers, KTestCANSASHandleMessageL );
    // Print to log file
    iLog->Log( KTestCANSASHandleMessageL );
    
    TBuf8<KGeneralBufferLength> buffer;
    TBuf8<KGeneralBufferLength> responseBuffer;
    
    RNotifier notify;
    User::LeaveIfError( notify.Connect() );
    
    //Call StartL() function.
    notify.StartNotifier( KAknGlobalNoteUid,
        buffer, responseBuffer);
    
    notify.UpdateNotifier( KAknGlobalNoteUid,
        buffer, responseBuffer );
    
    notify.CancelNotifier( KAknGlobalNoteUid );
    notify.Close();
    
    return KErrNone;
    }
Esempio n. 3
0
void CTcBtManager::TurnOnBtL()
	{
#ifdef __SERIES60_
   	LOG( _L("CTcBtManager::TurnOnBtL() start") );

	// Connect to notitifier service
	RNotifier notifier;
	User::LeaveIfError( notifier.Connect() );
	CleanupClosePushL( notifier );

	// Request notification about power, don't care about the results 
	// This results in a UI popup being displayed to the user shortly
	TRequestStatus status;
	TPckgBuf< TBool > pckg;
	TPckgBuf< TBool > resultPckg;
	notifier.StartNotifierAndGetResponse( status,
										  KPowerModeSettingNotifierUid,
										  pckg,
										  resultPckg );
	User::WaitForRequest( status );
	// Disable error checking. this would make auto-reconnect impossible
	// The power notifier reports an error if the time between the last
	// connection attempt and this connection is too small (even if it
	// doesn't hurt..)
	//User::LeaveIfError( status.Int() );

	notifier.CancelNotifier( KPowerModeSettingNotifierUid );

	CleanupStack::PopAndDestroy(); // notifier
   	LOG( _L("CTcBtManager::TurnOnBtL() end") );
#endif
	}
bool ShowDialogL( const QString& server, const QByteArray& certificate, int reason, bool cancel )
    {
    RNotifier notifier;
    User::LeaveIfError( notifier.Connect() );
    CleanupClosePushL( notifier );

    HBufC8* buffer = GetInputBufferL( server, certificate, reason );
    CleanupStack::PushL( buffer );

    TRequestStatus status;
    TPckgBuf<TServerAuthenticationFailureDialogResult> resultPckg;
    notifier.StartNotifierAndGetResponse( status, KUidSecurityDialogNotifier,
        *buffer, resultPckg );
    if( cancel )
        {
        const TInt KTenSecDelay = 10000000;
        User::After( KTenSecDelay );
        notifier.CancelNotifier( KUidSecurityDialogNotifier );
        }
    User::WaitForRequest( status );
    User::LeaveIfError( status.Int() );

    CleanupStack::PopAndDestroy( buffer );
    CleanupStack::PopAndDestroy( &notifier );
    return( resultPckg() == EContinue );
    }
// Presents a Device Selection UI and returns the error code.
//
// Arguments:
//  - aResponse - the object to hold the details of the selected device.
//
// Returns an error code.
TInt SelectDeviceUI(TBTDeviceResponseParamsPckg& aResponse)
{
    TInt err;
    RNotifier notifier;
    
    err = notifier.Connect();
    if (err) return err;
    
    TBTDeviceSelectionParamsPckg selectionFilter;
    TRequestStatus status;
    notifier.StartNotifierAndGetResponse(
        status,
        KDeviceSelectionNotifierUid,
        selectionFilter,
        aResponse
    );
    
    User::WaitForRequest(status);
    
    err = status.Int();

    notifier.CancelNotifier(KDeviceSelectionNotifierUid);
    notifier.Close();
    return err;    
}
void CBTDiscoverer::DoCancel()
{
	CALLSTACKITEM_N(_CL("CBTDiscoverer"), _CL("DoCancel"));

	switch(current_state) {
case SELECTING:
	iNotifier.CancelNotifier(KDeviceSelectionNotifierUid);
	break;
default:
	break;
	}
	current_state=IDLE;
}
Esempio n. 7
0
// ----------------------------------------------------------------------------
//Uses the Notifier API to ask the user to turn on Bluetooth if it's not on already.
// ----------------------------------------------------------------------------
void CBluetoothEngine::TurnBtOnL() {
	//the constant is from btnotifierapi.h which is not in all SDKs
	//so it's hard coded here
	const TUid KPowerModeSettingNotifierUid = { 0x100059E2 };
	//const TUid KBTPowerStateNotifierUid = {0x101F808E}; //S80 and 7710

	RNotifier notifier;
	User::LeaveIfError(notifier.Connect());
	TPckgBuf<TBool> dummy(ETrue);
	TPckgBuf<TBool> reply(EFalse);
	TRequestStatus stat;
	notifier.StartNotifierAndGetResponse(stat, KPowerModeSettingNotifierUid,
			dummy, reply);
	User::WaitForRequest(stat);
	notifier.CancelNotifier(KPowerModeSettingNotifierUid);
	notifier.Close();
}
Esempio n. 8
0
TInt CIkev1Dialog::LauchSyncDialog(const TDesC8& aInput, TDes8& aOutput)
{
    RNotifier notifier;
    TInt err = notifier.Connect();
    if(err != KErrNone)
        {
        return err;
        }
    
    TRequestStatus status;
    notifier.StartNotifierAndGetResponse(status, KUidVpnDialogNotifier, aInput, aOutput);
    User::WaitForRequest( status );
    
    notifier.CancelNotifier(KUidVpnDialogNotifier);
    notifier.Close();
    
    return status.Int();
}
void DoTests(TUid aUid,TBool aCheckMNotifierManager)
	{	
	TInt r;
	
	test.Start(_L("Connect to notifier server"));
	RNotifier n;
	r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("StartNotifier (without response)"));
	r = n.StartNotifier(aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KStartData);
	RDebug::Printf("r=%d", r);
	test(r==KErrNone);

	test.Next(_L("CancelNotifier"));
	r = n.CancelNotifier(aUid);
	test(r==KErrNone);

	test.Next(_L("StartNotifier"));
	TBuf8<128> response;
	response.SetMax();
	response.FillZ();
	response.Zero();
	r = n.StartNotifier(aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KStartData,response);
	test(r==KErrNone);
	test(response==KResponseData);

	test.Next(_L("UpdateNotifier"));
	response.SetMax();
	response.FillZ();
	response.Zero();   // EKA1 text notifier dies if current length < length of response
	r = n.UpdateNotifier(aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KUpdateData,response);
	test(r==KErrNone);
	test(response==KResponseData);

	test.Next(_L("UpdateNotifierAndGetResponse"));
	response.SetMax();
	response.FillZ();
	response.Zero();   // EKA1 text notifier dies if current length < length of response
	TRequestStatus updateStat;
	n.UpdateNotifierAndGetResponse(updateStat,aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KUpdateData,response);
	User::WaitForRequest(updateStat);
	test(updateStat==KErrNone);
	test(response==KResponseData);
	
	test.Next(_L("CancelNotifier"));
	r = n.CancelNotifier(aUid);
	test(r==KErrNone);

	test.Next(_L("StartNotifierAndGetResponse (to check previous notifier was cancelled)"));
	response.SetMax();
	response.FillZ();
	response.Zero();
	TRequestStatus stat;
	n.StartNotifierAndGetResponse(stat,aUid,aCheckMNotifierManager?*&KMNotifierManagerWithCancelCheck:*&KStartWithCancelCheckData,response);
	User::WaitForRequest(stat);
	test(stat==KTestNotifierWasPreviouselyCanceled);
	test(response==KResponseData);

	test.Next(_L("CancelNotifier"));
	r = n.CancelNotifier(aUid);
	test(r==KErrNone);

	test.Next(_L("Close connection to notifier server"));
	n.Close();

	test.Next(_L("Memory leak tests"));
	DoMemoryLeakTests(aUid,aCheckMNotifierManager);

	test.Next(_L("Session cleanup test"));
	DoCleanumpTests(aUid,aCheckMNotifierManager);

	test.End();
	}