Discussion Board

Results 1 to 5 of 5
  1. #1

    Arrow Finding a Contact using a string of words


    I want to search the Contact Database using a string containing more than one word.

    The SDK documentation describes the function FindInTextDefLC for this purpose. The doc for this function exactly describes the kind of search that I want to do.



    Allows the user to search the database for a string containing text which is stored in one or more fields — overloaded function. The string is specified as an array of words.

    For example, a user might want to search for the string "John Smith". To the user the string is a single item, but the text which makes up the string is stored in two separate fields in the database.

    The caller of this function needs to provide an array of words to find (aFindWords), and a function to break down the text in the contact item into a list of words (aWordParserCallback).


    I am not clear about the function that is to be provided(function to break down the text in the contact item into a list of words (aWordParserCallback)); so I need some reference to make this function.

    There is no example / code snippet anywhere as to how to use FindInTextDefLC.
    If anybody has used this function or has a link to a related example , please let me know.
    I have searched a lot on this forum and elsewhere but not found anything useful.
    Last edited by jp4symbian; 2007-01-18 at 08:29.

  2. #2
    Regular Contributor
    Join Date
    Mar 2005

    Re: Finding a Contact using a string of words

    Have u tried using CPbkMultipleEntryFetchDlg/CPbkSingleEntryFetchDlg. There is find textbox along with listbox containing filtered contacts

    U can also give try to
    CPbkContactEngine::FindAsyncL ()
    CPbkContactEngine::FindLC ()

  3. #3

    Exclamation Re: Finding a Contact using a string of words

    Hi SymbianSandy,

    My process of finding contacts is occurring in the background.
    I dont have to provide any GUI to my user for this.
    While CPbkMultipleEntryFetchDlg/CPbkSingleEntryFetchDlg would be dialogs requiring user interaction, right?

    And I have tried CPbkContactEngine::FindLC () . But this does not satisfy my search criteria since I have to search not one word but multiple words (string containing text which is stored in one or more fields) as I have described in my previous post.

  4. #4
    Registered User
    Join Date
    Nov 2006

    Re: Finding a Contact using a string of words

    Hi jp4symbian,

    here is a code snippet using FindInTextDefLC which works for me:

    Defintion of WordParserCallback() function:
    This is a function is not a member of any class.
    FindInTextDefLC() calls this function to tokenize
    the contents of an individual contact field.
    When the given name field contains "foo bar"
    this function has to break it down to the tokens "foo" 
    and "bar" and put each token into
    static TInt WordParser(TAny *aParam)
    	SFindInTextDefWordParser *aSFindInTextDefWordParser = static_cast<SFindInTextDefWordParser *>(aParam);
    	TLex Input(*aSFindInTextDefWordParser->iSearchString);
    	TBuf<64> Token;
    	TInt TokenCount = 0;
    	do	{
    		Token = Input.NextToken();
    		if(Token.Length())	{
    	return TokenCount;   // why not?
    The call of the function FindInTextDefLC():

    // declare the callback function
    TCallBack WordParserCB(WordParser);		
    CContactTextDef *ContactTextDef = CContactTextDef::NewLC();
    // determine which contact fields are to search
    TContactTextDefItem GivenName(KUidContactFieldGivenName);
    TContactTextDefItem FamilyName(KUidContactFieldFamilyName);
    CDesCArrayFlat *FindWordArray = new(ELeave) CDesCArrayFlat(10);
    // Break the search string down into tokens
    TLex Input(iSearchString);
    TBuf<64> Token;
    do	{
    	Token = Input.NextToken();
    CContactIdArray *ContactIdArrayOfMatches = iDatabase->FindInTextDefLC(*FindWordArray, ContactTextDef, WordParserCB);
    Hope this helps...



  5. #5

    Smile Re: Finding a Contact using a string of words

    Hi pgivy,

    Thank you so much for the code snippet.
    I shall surely try it out.

    Well I had solved my problem using CPbkContactItem::GetContactTitleL
    for each contact; by iterating through the entire Contacts database and comparing with the contact title to search.
    And this also worked quite well.


Similar Threads

  1. PIM API: updating contact causes a reboot on 6270!
    By suzier in forum Mobile Java General
    Replies: 8
    Last Post: 2007-04-03, 07:29
  2. Replies: 3
    Last Post: 2006-10-09, 12:24
  3. contact number and contact names doesn't match.
    By ninidotnet in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-10-09, 09:25
  4. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52
  5. D211 new linux driver 1.04 not working !!
    By franz_meyer in forum Multimodecards
    Replies: 1
    Last Post: 2002-12-12, 09:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts