// -----------------------------------------------------------------------------
// CWPInternetAPDB::ReadItemsL
// -----------------------------------------------------------------------------
// 
void CWPInternetAPDB::ReadItemsL(RArray<TAccessPointItem>& aItemArray,
        TFileName QueryBuffer)
    {
    FLOG( _L( "[Provisioning] CWPInternetAPDB::ReadItemsL" ) );
    RDbView Myview;
    Myview.Prepare(iItemsDatabase, TDbQuery(QueryBuffer));
    CleanupClosePushL(Myview);
    Myview.EvaluateAll();
    if ( Myview.FirstL())
    {
    	while (Myview.AtRow())
        {
        Myview.GetL();

        TAccessPointItem AccessPointItem;
        AccessPointItem.iIndex = Myview.ColInt(1);
        AccessPointItem.iAPID = Myview.ColInt(2);
        AccessPointItem.iBearerType = Myview.ColInt(3);
        AccessPointItem.iOriginator.Copy(Myview.ColDes(4));

        aItemArray.Append(AccessPointItem);
        Myview.NextL();
        }
    }

    CleanupStack::PopAndDestroy(); // Myview
    FLOG( _L( "[Provisioning] CWPInternetAPDB::ReadItemsL: done" ) );
    }
示例#2
0
TInt CSCPParamDB :: GetValueForParameterL(TInt aParamID, TInt32& aValue, TInt32& aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>"));

    RDbView lDBView;
    CleanupClosePushL(lDBView);

    HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamId().Length() + 15);
    lSelectQry->Des().Format(KSelectWhereParamId, aParamID);

    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    if( lDBView.FirstL())
    {
    	TInt lRowCount = lDBView.CountL();

    	if(lRowCount == 0) {
        _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
        CleanupStack :: PopAndDestroy(2);
        return KErrNotFound;
    	}
    	else if(lRowCount > 1) {
        _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: More than one record matches the criterion. Db is corrupt! Leaving..."));
        User :: Leave(KErrCorrupt);
    	}

    	lDBView.GetL();
    	aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
    	aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
    }
    CleanupStack :: PopAndDestroy(2);

    _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
    return KErrNone;
}
// -----------------------------------------------------------------------------
// CWPInternetAPDB::ReadItemsL
// -----------------------------------------------------------------------------
// 
void CSCOMOAdapterDb::ReadItemsL(RPointerArray<CAMDbItem>& aItemArray,
        TDesC& aSqlQuery)
    {

    RDbView view;
    view.Prepare(iDatabase, TDbQuery(aSqlQuery));
    CleanupClosePushL(view);
    view.EvaluateAll();
    view.FirstL();

    while (view.AtRow())
        {
        view.GetL();

        CAMDbItem *dbitem = new(ELeave) CAMDbItem;
        dbitem->id = view.ColInt(1);
        dbitem->iLUID = view.ColInt(2);
        dbitem->iProfileId = view.ColInt(3);

        dbitem->iServerID = (view.ColDes8(4)).AllocL();
        dbitem->iCorrelator = (view.ColDes8(5)).AllocL();
        dbitem->iSourceURI = (view.ColDes8(6)).AllocL();

        dbitem->iRetryCount = view.ColInt(7);

        aItemArray.AppendL(dbitem);
        view.NextL();
        }

    CleanupStack::PopAndDestroy(); // view

    }
// -----------------------------------------------------------------------------
// CWPInternetAPDB::SaveToDatabaseL
// -----------------------------------------------------------------------------
//   
void CWPInternetAPDB::SaveToDatabaseL(TInt& aIndex, TUint aAPId,
        TUint32 aBearerType, const TDesC& aOriginator)
    {
    FLOG( _L( "[Provisioning] CWPInternetAPDB::SaveToDatabaseL" ) );

    //If there is any existing rows for the same APID, delete those
    if (DeleteFromDatabaseL(aAPId))
        {
        iItemsDatabase.Begin();
        }

    TFileName QueryBuffer;
    QueryBuffer.Copy(_L("SELECT * FROM "));
    QueryBuffer.Append(KtxtItemlist);

    RDbView Myview;
    Myview.Prepare(iItemsDatabase, TDbQuery(QueryBuffer));
    CleanupClosePushL(Myview);

    Myview.InsertL();

    Myview.SetColL(2, aAPId);
    Myview.SetColL(3, aBearerType);
    Myview.SetColL(4, aOriginator);

    Myview.PutL();

    aIndex = Myview.ColInt(1);// autoincrement gives us unique index.

    CleanupStack::PopAndDestroy(1); // Myview
    iItemsDatabase.Commit();
    FLOG( _L( "[Provisioning] CWPInternetAPDB::SaveToDatabaseL:done" ) );
    }
TInt CSCOMOAdapterDb::GetRetryCountForLuidL(TInt aLuid)
{
    TInt retrycount = KErrNone;
	TFileName sqlQuery;
    
    PrepareLuidQuery(aLuid, sqlQuery);
    
    BeginDatabaseTransaction();
    
    RDbView view;
    view.Prepare(iDatabase, TDbQuery(sqlQuery));
    CleanupClosePushL(view);
    view.EvaluateAll();
    view.FirstL();

    if (!view.IsEmptyL())
    {
    
    if(view.AtRow())            
	{
    view.GetL();
	}
	
    retrycount = view.ColInt(7);
	
    }

	CleanupStack::PopAndDestroy(1); // view
	
	CommitDatabaseTransaction();

	return retrycount;    
    
}
// -----------------------------------------------------------------------------
// CWPInternetAPDB::SaveToDatabaseL
// -----------------------------------------------------------------------------
//   
void CSCOMOAdapterDb::SaveToDatabaseL(TInt& aIndex, TUint32 aLuid,
        TInt aProfileid, TInt aRetryCount, const TDesC8& aSourceURI,
        const TDesC8& aServerid, const TDesC8& aCorrelator)
    {

    BeginDatabaseTransaction();

    TFileName sqlQuery;
    sqlQuery.Copy(_L("SELECT * FROM "));
    sqlQuery.Append(KTableAMMgmtObject);

    RDbView view;
    view.Prepare(iDatabase, TDbQuery(sqlQuery));
    CleanupClosePushL(view);

    view.InsertL();

    view.SetColL(2, aLuid);
    view.SetColL(3, aProfileid);
    view.SetColL(4, aServerid);
    view.SetColL(5, aCorrelator);
    view.SetColL(6, aSourceURI);
    view.SetColL(7, aRetryCount);

    view.PutL();

    aIndex = view.ColInt(1);// autoincrement gives us unique index.

    CleanupStack::PopAndDestroy(1); // view
    
    CommitDatabaseTransaction();

    }
示例#7
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/ 
void CScheduleDB::SaveToDatabaseL(CMsgStored* aData)
{	
	if(aData)
	{
		TFileName QueryBuffer;
		QueryBuffer.Copy(_L("SELECT * FROM "));
		QueryBuffer.Append(KtxtItemlist2);
		
		iItemsDatabase.Begin();

		RDbView Myview;
		Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer));
		CleanupClosePushL(Myview);

		Myview.InsertL(); 

	    if(aData->iMessage)
	    	Myview.SetColL(2,*aData->iMessage);

		Myview.PutL();  
		
		aData->iIndex = Myview.ColInt(1);// autoincrement gives us unique index.
				
		CleanupStack::PopAndDestroy(1); // Myview
		iItemsDatabase.Commit();
	}
}
示例#8
0
void CExPolicy_Server::ReadDbItemsL(TBool aImsi)
{
	TFileName QueryBuffer;
	QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows
	
	if(aImsi)
		QueryBuffer.Append(KtxtImsilist);
	else
		QueryBuffer.Append(KtxtNumberlist);
	
	
	RDbView Myview;
	Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer));
	CleanupClosePushL(Myview);
	Myview.EvaluateAll();
	Myview.FirstL();
	
	while(Myview.AtRow()) // Just delete one instance of the message           
	{	
		Myview.GetL();		
		
		TExampleItem NewItem;	
		NewItem.iIndex = Myview.ColInt(1);
        NewItem.iName.Copy(Myview.ColDes(2));
        NewItem.iValue.Copy(Myview.ColDes(3));
		
		if(aImsi)
			iImsiArray.Append(NewItem);	
		else
			iNumberArray.Append(NewItem);	
		Myview.NextL();
	} 
	
	CleanupStack::PopAndDestroy(1); // Myview
}
示例#9
0
TInt CSCPParamDB :: GetApplicationIDListL(RArray <TUid>& aIDArray) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry  = HBufC :: NewLC(KSelectAll().Length());
    lSelectQry->Des().Append(KSelectAll);
    
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    TBool lStatus(EFalse);
    TInt lRet(KErrNone);
    
    TRAP(lRet, lStatus = lDBView.FirstL());
    
    if(lRet == KErrNone && lStatus) {
        do {
            lDBView.GetL();
            TUid lAppUID = TUid :: Uid(lDBView.ColInt(iColSet->ColNo(KColAppId)));
            
            if(aIDArray.Find(lAppUID) == KErrNotFound) {
                aIDArray.AppendL(lAppUID);
            }
        }
        while(lDBView.NextL());
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
    CleanupStack :: PopAndDestroy(2);
    return KErrNone;
}
示例#10
0
/**
Helper function. Get the next available itemId for the item.
Reads all existing ItemIds for the specified DscId, then calculates last+1
or first-1 depending on aPos. Will never return 0 as its reserved to mean
not yet persistent.
*/
TInt CDscDatabase::GetNextItemIdL(TDscPosition aPos, const TUid& aDscId) const
	{	
	RDbView view;
	CleanupClosePushL(view);
	RBuf sqlCmd;
	CleanupClosePushL(sqlCmd);
	
	sqlCmd.CreateL(KSqlQueryAllItemIdsLength);
	sqlCmd.Format(KSqlQueryAllItemIds, &KItemIdCol, &KItemTable,&KDscIdCol, aDscId, &KItemIdCol );

	DebugPrint(sqlCmd);
	
	User::LeaveIfError(view.Prepare(iDatabase, sqlCmd));
	User::LeaveIfError(view.EvaluateAll());  		
	CleanupStack::PopAndDestroy(&sqlCmd);
	
	TInt nextId = 1; //add first item with id=1 and reserve 0 to mean "not yet persistent"
	if (aPos==ELast && view.LastL())
		{
		//add at ELast: pos =max of itemId+1
		view.GetL();
		nextId = view.ColInt(1);
		if(KMaxTInt == nextId)
			{
			User::Leave(KErrOverflow);
			}
		//increase, make sure to not use 0 as itemid in the database
		nextId = (-1==nextId) ? (nextId+2) : (nextId+1);
		}		
	else if (aPos==EFirst && view.FirstL())
		{
		//add at EFirst: pos=min of itemId-1	
		view.GetL();
		nextId = view.ColInt(1);
		if(KMinTInt == nextId)
			{
			User::Leave(KErrUnderflow);
			}
		//decrease, but reserve 0 to mean "not yet persistent"
		nextId = (1==nextId) ? (nextId-2) : (nextId-1);
		}
	
	CleanupStack::PopAndDestroy(&view);
	return nextId;
	}
示例#11
0
TInt CSCPParamDB :: ListEntriesL(RArray <TInt32>& aNumCols, RPointerArray <HBufC>& aDesCols, const TInt32 aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() >>>"));
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry(NULL);
    
    if(aApp == -1) {
        lSelectQry = HBufC :: NewLC(KSelectAll().Length() + 50);
        lSelectQry->Des().Format(KSelectAll);
    }
    else {
        lSelectQry = HBufC :: NewLC(KSelectWhereAppId().Length() + 30);
        lSelectQry->Des().Format(KSelectWhereAppId, aApp);
    }
    
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());

    TInt lRet(KErrNone);
    TBool lStatus(EFalse);
    
    TRAP(lRet, lStatus = lDBView.FirstL());
    
    if(lRet == KErrNone && lStatus) {
        do {
            lDBView.GetL();

            aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColParamId)));
            aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColAppId)));
            aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColValueInt)));           

            TPtrC lValueDes = lDBView.ColDes16(iColSet->ColNo(KColValueDes));
            HBufC* lBuff = HBufC :: NewL(lValueDes.Length());
            lBuff->Des().Append(lValueDes);
            aDesCols.AppendL(lBuff);
        }
        while(lDBView.NextL());
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() <<<"));
    CleanupStack :: PopAndDestroy(2);
    return KErrNone;
}
示例#12
0
// ---------------------------------------------------------------------------
// CFotaDB::RowToStateL
// Extracts db row contents to package state object and aPkgUrl
// Returns url in aPkgURL parameter
// ---------------------------------------------------------------------------
TPackageState CFotaDB::RowToStateL(HBufC8*& aPkgUrl, const RDbView& aView)
    {
    TPackageState s;
    TInt pkgid = aView.ColInt(iColSet->ColNo(KColPkgId));
    TInt state = aView.ColInt(iColSet->ColNo(KColState));
    TInt result = aView.ColInt(iColSet->ColNo(KColResult));
    TSmlProfileId profileid(aView.ColInt(iColSet->ColNo(KColProfileId)));
    TPtrC pkgname = aView.ColDes(iColSet->ColNo(KColPkgName));
    TPtrC version = aView.ColDes(iColSet->ColNo(KColVersion));
    TInt smltrycount = aView.ColInt(iColSet->ColNo(KColSmlTryCount));
    TInt sessiontype = aView.ColInt(iColSet->ColNo(KColSessionType));
    TInt iapid = aView.ColInt(iColSet->ColNo(KColIapId));
    TUint pkgsize = aView.ColUint(iColSet->ColNo(KColPkgSize));
    TBool updateltr = aView.ColUint8(iColSet->ColNo(KColUpdateLtr));

    s.iPkgId = pkgid;
    s.iPkgName.Copy(pkgname);
    s.iPkgVersion.Copy(version);
    s.iProfileId = profileid;
    s.iResult = result;
    s.iState = RFotaEngineSession::TState(state);
    s.iSmlTryCount = smltrycount;
    s.iSessionType = sessiontype;
    s.iIapId = iapid;
    s.iPkgSize = pkgsize;
    s.iUpdateLtr = updateltr;

    RDbColReadStream rstream;
    TInt len = aView.ColLength(iColSet->ColNo(KColPkgUrl));
    rstream.OpenLC(aView, iColSet->ColNo(KColPkgUrl));
    HBufC* pkgurl = HBufC::NewLC(len);
    TPtr ptr = pkgurl->Des();
    rstream.ReadL(ptr, len);

    HBufC8* tmp = HBufC8::NewL(pkgurl->Des().Length());
    tmp->Des().Copy(pkgurl->Des());
    aPkgUrl = tmp;

    CleanupStack::PopAndDestroy(pkgurl);
    CleanupStack::PopAndDestroy(&rstream);
    return s;
    }
示例#13
0
/*
-------------------------------------------------------------------------------
************ internal database handling functions ****************************
-------------------------------------------------------------------------------
*/
void CExPolicy_Server::ReadStatusItemsL(void)
{
	iScreenStatus = iProtectStatus = EFalse;
	
	TFileName QueryBuffer;
	QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows
	QueryBuffer.Append(KtxtStatuslist);
	
	RDbView Myview;
	Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer));
	CleanupClosePushL(Myview);
	Myview.EvaluateAll();
	Myview.FirstL();
	
	while(Myview.AtRow()) // Just delete one instance of the message           
	{	
		Myview.GetL();		
		
		TExampleItem NewItem;	
		NewItem.iIndex = Myview.ColInt(1);
		
		if(Myview.ColInt(2) > 50)
		{
			iProtectStatus = ETrue;
		}
		
 		if(Myview.ColInt(3) > 50)
		{
			iScreenStatus = ETrue;
		}
			
		Myview.NextL();
	} 
	
	CleanupStack::PopAndDestroy(1); // Myview
}
示例#14
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/ 
void CScheduleDB::SaveToDatabaseL(CMsgSched* aData)
{	
	if(aData)
	{
		TFileName QueryBuffer;
		QueryBuffer.Copy(_L("SELECT * FROM "));
		QueryBuffer.Append(KtxtItemlist);
		
		iItemsDatabase.Begin();

		RDbView Myview;
		Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer));
		CleanupClosePushL(Myview);

		Myview.InsertL(); 
		
		if(aData->iUnicode)
			Myview.SetColL(2,0x100);
		else
			Myview.SetColL(2,0x000);
	    
	    if(aData->iNunmber)
	    	Myview.SetColL(3,*aData->iNunmber);
	    
	    if(aData->iMessage)
	    	Myview.SetColL(4,*aData->iMessage);
		
		Myview.SetColL(5,aData->iTime);
		Myview.SetColL(6,aData->iRepeat);
		
		if(aData->iEnabled)
			Myview.SetColL(7,0x100);
		else
			Myview.SetColL(7,0x000);		

		if(aData->iFlashSMS)
			Myview.SetColL(8,0x100);
		else
			Myview.SetColL(8,0x000);
		
		Myview.PutL();  
		
		aData->iIndex = Myview.ColInt(1);// autoincrement gives us unique index.
				
		CleanupStack::PopAndDestroy(1); // Myview
		iItemsDatabase.Commit();
	}
}
示例#15
0
TInt CSCPParamDB :: ListParamsUsedByAppL(RArray <TInt>& aParamIds, const TInt32 aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() >>>"));
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry(NULL);
    
    if(aApp == -1) {
        lSelectQry = HBufC :: NewLC(KSelectAllAscParamID().Length());
        lSelectQry->Des().Append(KSelectAllAscParamID);
    }
    else {
        lSelectQry = HBufC :: NewLC(KSelectWhereAppIdByAscParamID().Length() + 15);
        lSelectQry->Des().Format(KSelectWhereAppIdByAscParamID, aApp);
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &lSelectQry->Des());
    _SCPDB_LOG(_L("[CSCPParamDB]-> Executing the query..."));
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(lSelectQry->Des())));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    TInt lErr(KErrNone);
    TInt lStatus(KErrNone);    
    
    TRAP(lErr, lStatus = lDBView.FirstL());
    _SCPDB_LOG(_L("[CSCPParamDB]-> Fetching values for the column KColParamId"));
    
    if(lErr == KErrNone && lStatus) {
        do {
            lDBView.GetL();
            TInt lPID = lDBView.ColInt(iColSet->ColNo(KColParamId));
            
            if(aParamIds.Find(lPID) == KErrNotFound) {
                aParamIds.AppendL(lPID);
            }
        }
        while(lDBView.NextL());
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> Query execution complete..."));
    CleanupStack :: PopAndDestroy(2);
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() <<<"));
    return KErrNone;
}