/** GetListForItemL has a dual nature. If aIsGroup is ETrue, a list of contact items belonging to specified group is returned. Otherwise a list of group ids to which contact id belongs is returned. @param aItemId contact item id @param aIsGroup ETrue if the method will fill a group. */ CContactIdArray* CPplGroupsTable::GetListForItemL(TContactItemId aItemId, TBool aIsGroup) { /* // Check if group membership information was not requested or if the item // is not derived from CContactItemPlusGroup. if (!(aType == KUidContactGroup || aType == KUidContactCard || aType == KUidContactOwnCard || aType == KUidContactICCEntry) ) { return NULL; } */ // build the RSqlStatement RSqlStatement stmnt; CleanupClosePushL(stmnt); TInt idIndex; // build the CCntSqlStatement statement const TInt KWhereParamIndex(KFirstIndex); // only one parameter in the query if (aIsGroup) { // group -> select members stmnt.PrepareL(iDatabase, iSelectMembersStmnt->SqlStringL() ); User::LeaveIfError(stmnt.BindInt(KWhereParamIndex, aItemId ) ); idIndex = stmnt.ColumnIndex(KGroupContactGroupMemberId() ); } else { // member -> select groups stmnt.PrepareL(iDatabase, iSelectGroupsStmnt->SqlStringL() ); User::LeaveIfError(stmnt.BindInt(KWhereParamIndex, aItemId ) ); idIndex = stmnt.ColumnIndex(KGroupContactGroupId() ); } User::LeaveIfError(idIndex); // fetch the list of any matching ids CContactIdArray* items = CContactIdArray::NewLC(); TInt err(KErrNone); while ((err = stmnt.Next() ) == KSqlAtRow) { items->AddL(stmnt.ColumnInt(idIndex) ); } // leave if we didn't complete going through the results properly if(err != KSqlAtEnd) { User::Leave(err); } CleanupStack::Pop(items); CleanupStack::PopAndDestroy(&stmnt); return items; }
// ----------------------------------------------------------------------------- // CUpnpSecurityDbConnection::GetAllFilenamesL // Get all filenames. // ----------------------------------------------------------------------------- // void CUpnpSecurityDbConnection::GetAllFilenamesL( RPointerArray<HBufC>& aFilenameArray ) { TInt err; RSqlStatement statement; User::LeaveIfError( statement.Prepare( iDatabase, KUpnpSecSqlSelectAllFiles ) ); CleanupClosePushL( statement ); TInt columnIndex = statement.ColumnIndex( KUpnpSecSqlFilename ); while ( (err = statement.Next()) == KSqlAtRow ) { TPtrC data = statement.ColumnTextL( columnIndex ); HBufC* filename = data.AllocLC(); aFilenameArray.AppendL( filename ); CleanupStack::Pop( filename ); } if ( err != KSqlAtEnd ) { User::LeaveIfError( err ); } CleanupStack::PopAndDestroy( &statement ); }
/** Utility method used to read binary blob fields from contacts database. Provides a mechanism to fill a contact item with informations stored in binary blobs within contact database. A reference to the contact item to be fill has to be provided. A template has to be provided if the contact item is based on a template. Template can be NULL. Also a view definition can be provided to filter which fields are read from blob fields. @param aItem Contact item to be filled with information from binary blob field. @param aView View definition specifying what item fields should be read from binary blob field @param aTemplate Contact item representing a template based on which aItem should be read. Can be NULL @param aDatabase RSqlDatabase reference. @leave KErrNotFound if the specified contact item does not exist any more in contact database */ void TCntPersistenceUtility::ReadBinaryBlobL(CContactItem& aItem, const CContactItemViewDef& aView, const CContactItem* aTemplate, RSqlDatabase& aDatabase) { HBufC* selectString = HBufC::NewLC(KSelectTwoFields().Length() + KContactBinaryFieldHeader().Length() + KContactBinaryFields().Length() + KSqlContactTableName().Length() + KContactId().Length()); TPtr ptrSelectString = selectString->Des(); ptrSelectString.Format(KSelectTwoFields, &KContactBinaryFieldHeader, &KContactBinaryFields, &KSqlContactTableName, &KContactId, aItem.Id()); RSqlStatement selectStmt; CleanupClosePushL(selectStmt); User::LeaveIfError(selectStmt.Prepare(aDatabase, ptrSelectString)); TInt err = selectStmt.Next(); if(err != KSqlAtRow) { if(err == KSqlAtEnd) { User::Leave(KErrNotFound); } else { User::Leave(err); } } TPtrC8 binaryHeader; selectStmt.ColumnBinary(User::LeaveIfError(selectStmt.ColumnIndex(KContactBinaryFieldHeader)), binaryHeader); RDesReadStream binaryHeaderStream(binaryHeader); CleanupClosePushL(binaryHeaderStream); CEmbeddedStore* binaryHeaderStore = CEmbeddedStore::FromLC(binaryHeaderStream); TPtrC8 binaryFields; selectStmt.ColumnBinary(User::LeaveIfError(selectStmt.ColumnIndex(KContactBinaryFields)), binaryFields); RDesReadStream binaryFieldsStream(binaryFields); CleanupClosePushL(binaryFieldsStream); CEmbeddedStore* binaryBlobStore = CEmbeddedStore::FromLC(binaryFieldsStream); ReadBinaryBlobL(*binaryHeaderStore, *binaryBlobStore, aItem, aView, aTemplate); CleanupStack::PopAndDestroy(6, selectString); //binaryHeaderStore, binaryHeaderStrean, binaryBlobStore, binaryBlobStream, selectStmt, selectString }
// ----------------------------------------------------------------------------- // CUpnpSecurityDbConnection::GetAllIpAddressesL // Get all ips. // ----------------------------------------------------------------------------- // void CUpnpSecurityDbConnection::GetAllIpAddressesL( RArray<TInetAddr>& aAddressArray ) { TInt err; RSqlStatement statement; User::LeaveIfError( statement.Prepare( iDatabase, KUpnpSecSqlSelectAllIpAddresses ) ); CleanupClosePushL( statement ); TInt columnIndex = statement.ColumnIndex( KUpnpSecSqlIp ); while ( (err = statement.Next()) == KSqlAtRow ) { TUint32 data = statement.ColumnInt( columnIndex ); aAddressArray.AppendL( TInetAddr( data, 0 ) ); } if ( err != KSqlAtEnd ) { User::LeaveIfError( err ); } CleanupStack::PopAndDestroy( &statement ); }