720 CleanupStack::Pop(idArray); |
720 CleanupStack::Pop(idArray); |
721 |
721 |
722 return idArray; |
722 return idArray; |
723 } |
723 } |
724 |
724 |
725 CContactIdArray* CPplContactItemManager::SearchIdListL(const TDesC& aSearchQuery) const |
725 /** |
|
726 Fast access method for retrieving a list of contact details as raw data. |
|
727 This method can be used for example to fetch the names of all contacts |
|
728 in a very efficient manner. It is assumed that the first column in |
|
729 aSearchQuery is 'id' and that the other columns are text. |
|
730 |
|
731 The returned buffer can be read with RBufReadStream - the first column |
|
732 of each row is a 32-bit integer (the id), the rest of the columns are |
|
733 16-bit descriptors. An id of 0 signifies the end of the list. |
|
734 */ |
|
735 CBufSeg* CPplContactItemManager::DetailsListL(const TDesC& aSearchQuery) const |
726 { |
736 { |
727 CContactIdArray* idArray = CContactIdArray::NewLC(); |
737 CBufSeg* array = CBufSeg::NewL(4096); |
728 |
738 CleanupStack::PushL(array); |
|
739 |
729 //Prepare and execute the sql query |
740 //Prepare and execute the sql query |
730 RSqlStatement selectStatement; |
741 RSqlStatement selectStatement; |
731 CleanupClosePushL(selectStatement); |
742 CleanupClosePushL(selectStatement); |
732 User::LeaveIfError(selectStatement.Prepare(iDatabase, aSearchQuery)); |
743 User::LeaveIfError(selectStatement.Prepare(iDatabase, aSearchQuery)); |
733 const TInt KIdx = iSelectStatement->ParameterIndex(KContactId); |
744 |
734 |
|
735 // Iterate through the results and append the contactIds to idArray |
745 // Iterate through the results and append the contactIds to idArray |
736 TInt err; |
746 TInt err; |
737 while((err = selectStatement.Next()) == KSqlAtRow) |
747 RBufWriteStream stream; |
|
748 stream.Open(*array); |
|
749 TInt columnCount = selectStatement.ColumnCount(); |
|
750 while ((err = selectStatement.Next()) == KSqlAtRow) |
738 { |
751 { |
739 idArray->AddL(selectStatement.ColumnInt(KIdx)); |
752 stream.WriteInt32L(selectStatement.ColumnInt(0)); |
|
753 for (TInt i = 1; i < columnCount; ++i) |
|
754 stream << selectStatement.ColumnTextL(i); |
740 } |
755 } |
|
756 stream.WriteInt32L(0); |
|
757 stream.Close(); |
741 |
758 |
742 if(err != KSqlAtEnd) |
759 if(err != KSqlAtEnd) |
743 { |
760 { |
744 User::Leave(err); |
761 User::Leave(err); |
745 } |
762 } |
746 |
763 |
747 //Cleanup |
764 //Cleanup |
748 CleanupStack::PopAndDestroy(&selectStatement); |
765 CleanupStack::PopAndDestroy(&selectStatement); |
749 CleanupStack::Pop(idArray); |
766 CleanupStack::Pop(array); |
750 |
767 |
751 return idArray; |
768 return array; |
752 } |
769 } |
|
770 |
753 |
771 |
754 /** |
772 /** |
755 Utility method used to rthe prefered card template id |
773 Utility method used to rthe prefered card template id |
756 */ |
774 */ |
757 TInt CPplContactItemManager::CardTemplatePrefIdL() const |
775 TInt CPplContactItemManager::CardTemplatePrefIdL() const |