Пример #1
0
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();
	}
Пример #2
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 );
    }
Пример #4
0
void TestRemovedMethods()
//
// Test deprecated but exported methods
//
	{
	test.Start(_L("Test removed methods of RNotifier class"));
	
	// connect to server
	RNotifier n;
	TInt r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("StartNotifierAndGetResponse (5-params with dllUid)"));
	TBuf8<128> response;
	response.SetMax();
	response.FillZ();
	response.Zero();
	TRequestStatus stat;
	n.StartNotifierAndGetResponse(stat,KUidTestTextNotifier1,KUidTestTextNotifier2,*&KStartData,response);
	User::WaitForRequest(stat);
	test(stat==KErrNotSupported);

	test.Next(_L("StartNotifier (4-params with dllUid)"));
	test(n.StartNotifier(KUidTestTextNotifier2,KUidTestTextNotifier1,*&KStartData,response)==KErrNotSupported);
	
	test.Next(_L("Test removed method LoadNotifiers()"));
	test(n.LoadNotifiers(KUidTestTextNotifier1)==KErrNotSupported);
	
	test.Next(_L("Test removed method UnloadNotifiers()"));
	test(n.UnloadNotifiers(KUidTestTextNotifier1)==KErrNotSupported);

	test.Next(_L("Close connection to notifier server"));
	n.Close();
	test.End();
	}
Пример #5
0
// 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;    
}
Пример #6
0
void DoCleanumpTests(TUid aUid,TBool aCheckMNotifierManager)
	{
	TInt r;

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

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

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

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

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

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

	test.End();
	}
TBool CSenBaseIdentityManager::AllowSavePasswordL()
    {
    TBool retVal = EFalse;

    RNotifier notifier;
    User::LeaveIfError(notifier.Connect());
    CleanupClosePushL(notifier);

    TPckgBuf<TAskSaveDlgRequest>* request = new(ELeave)TPckgBuf<TAskSaveDlgRequest>();
    CleanupStack::PushL(request);

    TPckgBuf<TAskSaveDlgResponse>* response = new(ELeave)TPckgBuf<TAskSaveDlgResponse>();
    CleanupStack::PushL(response);

    TRequestStatus reqStatus;
    notifier.StartNotifierAndGetResponse(reqStatus, KSenNotifierPluginUID, *request, *response);

    User::WaitForRequest(reqStatus);
    notifier.Close();

    if(reqStatus.Int() == KErrNone)
        {
        if((*response)().OkButtonPressed())
            {
            TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("User pressed OK Button to allow password saving")));
            retVal = ETrue;
            }
#ifdef _SENDEBUG
        else
            {
            TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("User pressed Cancel Button to deny password saving")));
            }
#endif
        }
#ifdef _SENDEBUG
    else if(reqStatus.Int() == KErrNotFound)
        {
        TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("Notifier plug-in for 'Save WS data?' -dialog was not found")));
        }
    else
        {
        TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8("'Save WS data?' -dialog returned an error: %d"), 
                                                        reqStatus.Int()));
        }
#endif

    CleanupStack::PopAndDestroy(2); // request, response;
    //CleanupStack::PopAndDestroy(); // close the notifier
    CleanupStack::Pop(); // notifier
    return retVal;
    }
Пример #8
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();
}
Пример #9
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 CBTDiscoverer::SelectDevice()
{
	CALLSTACKITEM_N(_CL("CBTDiscoverer"), _CL("SelectDevice"));

#ifdef __WINS__

	TBuf8<10> addr=_L8("12345");
	if (iDevCount==0) {
		unsigned char a[]={ 0x00, 0x02, 0xee, 0x51, 0xc4, 0x37};
		TPtrC8 ap(&a[0], 6);
		addr=ap;
	} else {
		addr.AppendNum(iDevCount);
	}

	TBuf<20> name=_L("test name ");

	name.AppendNum(iDevCount);
	AddToArrays(addr, name);
	++iDevCount;
	return;
#endif

	TInt ret;
	if ( (ret=iNotifier.Connect())!= KErrNone ) return;

	not_is_open=true;

	selectionFilter.SetUUID(targetServiceClass);
	result.Zero();
	pckg.Zero();
	iNotifier.StartNotifierAndGetResponse(iStatus, KDeviceSelectionNotifierUid, pckg, result);

	SetActive();	
	current_state=SELECTING;
}
TInt CSenBaseIdentityManager::AuthenticationForL(
                            CSenIdentityProvider& aProvider, 
                            TPckgBuf<TSenAuthentication>& aResponse)
    {
    TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CSenBaseIdentityManager::AuthenticationForL");

    TPtrC8 user = aProvider.AuthzID();
    if (user == KNullDesC8)
        {
        user.Set(aProvider.AdvisoryAuthnID());
        }


    if (!iShowPasswordDialog)
        {
        TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"Not allowed to show password dialog");
        HBufC8* pDecodedPassword = SenXmlUtils::DecodeHttpCharactersLC(aProvider.Password());
        TPtrC8 decodedPassword = pDecodedPassword->Des();

        aResponse().iUsername.Append((const TUint8*)user.Ptr(), user.Size());
        aResponse().iPassword.Append((const TUint8*)decodedPassword.Ptr(), 
                                        decodedPassword.Size());
        CleanupStack::PopAndDestroy(); // delete pDecodedPassword
        return KErrNone;
        }


    RNotifier notifier;
    User::LeaveIfError(notifier.Connect());
    CleanupClosePushL(notifier);

    TPckgBuf<TAuthenticationDlgRequest>* request = 
                            new(ELeave)TPckgBuf<TAuthenticationDlgRequest>();
    CleanupStack::PushL(request);

    // convert username to unicode
    HBufC* pUserAsUnicode = SenXmlUtils::ToUnicodeLC(user); // push
    TPtrC username = pUserAsUnicode->Des();

    // decode password
    HBufC8* pDecodedPassword = SenXmlUtils::DecodeHttpCharactersLC(aProvider.Password());
    TPtrC8 decodedPassword = pDecodedPassword->Des();
    // convert decoded password to unicode
    HBufC* pPasswordAsUnicode = 
                SenXmlUtils::ToUnicodeLC(decodedPassword); // push
    TPtrC password = pPasswordAsUnicode->Des();

    // set data to request
    (*request)().SetData(username, password);

    CleanupStack::PopAndDestroy(3); // delete pPasswordAsUnicode, pDecodedPassword, pUserAsUnicode


    TPckgBuf<TAuthenticationDlgResponse>* response = 
                        new(ELeave)TPckgBuf<TAuthenticationDlgResponse>();
    CleanupStack::PushL(response);

    TRequestStatus reqStatus;
    notifier.StartNotifierAndGetResponse(reqStatus, 
                            KSenNotifierPluginUID, *request, *response);

    TBool illegalUsername = EFalse;

    HBufC8* pUsernameUtf8 = NULL;
    HBufC8* pPasswordUtf8 = NULL;
    User::WaitForRequest(reqStatus);

    notifier.Close();

    if(reqStatus.Int() == KErrNone)
        {
        if((*response)().OkButtonPressed())
            {
            TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("User pressed OK Button in Password dialog")));
            pUsernameUtf8 = SenXmlUtils::ToUtf8LC((*response)().Username());
            pPasswordUtf8 = SenXmlUtils::ToUtf8LC((*response)().Password());
            TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8("Username: %S"), pUsernameUtf8));
            TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8("Password: %S"), pPasswordUtf8 ));
            HBufC8* pEncodedUsername = NULL;
            illegalUsername = 
                SenXmlUtils::EncodeHttpCharactersL(*pUsernameUtf8,
                                                    pEncodedUsername);
            if (illegalUsername) 
                {
                TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("Username included illegal characters.")));
                delete pEncodedUsername;
                pEncodedUsername = NULL;
                }
#ifdef _SENDEBUG
            else
                {
                TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"Username did NOT include illegal characters.");
                }
#endif
       		
       		//Check if iilegal chars are there then return
            if (!illegalUsername)
                {
                
                if(user != *pUsernameUtf8)
                {
                	
	                // User modified the username in the dialog prompt(!)
	                // We have to save it right away, because there is
	                // no in-memory/session based member variables in
	                // components calling identity manager (sec mechs and
	                // in ID-WSF AS client!
	                TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"Username changed. Saving new username.");

	                // Use Advisory only if AuthzID is not available
	                if (aProvider.AuthzID() == KNullDesC8 
	                    && aProvider.AdvisoryAuthnID() != KNullDesC8)
	                    {
	                    aProvider.SetUserInfoL(aProvider.AuthzID(),
	                                            *pUsernameUtf8, 
	                                            aProvider.Password());
	                    }
	                else 
	                    {
	                    // There was at least AuthzID available, and possibly
	                    // also advisory value. Any way, if 

	                    
	                    // We have to NULL advisory value (set it to KNullDesC8), 
	                    // because if both were available, then user was
	                    // prompted to allow modification of AuthzID AND 
	                    // if advisory was changed in service (is no longer
	                    // valid), there would NOT be any way for end-user
	                    // to change (remove) it(!)

	                    CSenElement& element = aProvider.AsElement();
	                    delete element.RemoveElement(KSenIdpAdvisoryAuthnIdLocalname);

	                    aProvider.SetUserInfoL(*pUsernameUtf8, 
	                                            KNullDesC8,
	                                            aProvider.Password());
	                    }
	                // serialize changed username into sensessions.xml database immediately
	                WriteDatabase();
                }
                
	            if (AllowSavePasswordL())
	                {
	                HBufC8* pEncodedPassword = SenXmlUtils::EncodeHttpCharactersLC(*pPasswordUtf8);
#ifdef _SENDEBUG
                if(pEncodedPassword)
                    {
                    TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8("Encoded password: %S"), pEncodedPassword));
                    }
#endif
					if(pEncodedPassword)
						{
							aProvider.SetUserInfoL(aProvider.AuthzID(),
	                                        aProvider.AdvisoryAuthnID(),
	                                        *pEncodedPassword);
						}
	                WriteDatabase();
	                CleanupStack::PopAndDestroy(1); // pEncodedPassword
	                }
                
                }

            aResponse().iUsername.Zero();
            aResponse().iPassword.Zero();
            if (!illegalUsername) 
            {
	            aResponse().iUsername.Copy(pUsernameUtf8->Des());
	            aResponse().iPassword.Copy(pPasswordUtf8->Des());
            }

            CleanupStack::PopAndDestroy(2); // pPasswordUtf8, pUsernameUtf8
            }
        else
            {
            TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("User pressed Cancel Button in Password dialog")));
            }
        }
    else if(reqStatus.Int() == KErrNotFound)
        {
        TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("Password dialog plugin notifier impl. was not found")));
        }
    else
        {
        TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMinLogLevel, _L8(" Notifier plugin for 'Password' dialog returned an error: %d"), 
                                                        reqStatus.Int()));
        }

    CleanupStack::PopAndDestroy(2); // request, response;
    CleanupStack::Pop(); // notifier

    if (illegalUsername) return KErrArgument;
    return reqStatus.Int();
    }
Пример #12
0
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();
	}