Discussion Board

Results 1 to 9 of 9
  1. #1
    Hi,
    I need to raed contacts from phone and show in a list box. I have code to read contacts. list box is ready. need to convert read contactdetails ContactItem* to CDesCArrayFlat
    I have the following code which is called from AppUi::handleCommandl()
    CContactDatabase* contactsDb = CContactDatabase::OpenL();
    CleanupStack::PushL(contactsDb);
    // Get the ID of the own card and open the contact:
    TContactItemId ownCardId = contactsDb->OwnCardId();
    if (ownCardId == KNullContactId )
    User::Leave(KNullContactId );
    //Own card may not be set
    CContactItem* ownCard = contactsDb->ReadContactL(ownCardId);
    CleanupStack::PushL(ownCard);
    TInt count = ownCard->CardFields().Count();
    contactsDb->CloseContactL(ownCard->Id());
    CleanupStack::PopAndDestroy(2); // ownCard, contactsDb



    CDesCArray* array = new (ELeave) CDesCArrayFlat(3);
    iSearchList->MakeVisible(EFalse);
    //iDetailedView = ETrue;
    iSearchList->Model()->SetItemTextArray(array);
    iSearchList->MakeVisible(ETrue);
    iSearchList->SetCurrentItemIndexAndDraw(0);
    SizeChanged();
    iSearchList->ActivateL();


    following code in AppView->constructL()
    CreateWindowL();

    iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);

    iSearchList = new (ELeave) CAknSingleStyleListBox();
    iSearchList->ConstructL(this);
    iSearchList->SetContainerWindowL(*this);
    iSearchList->CreateScrollBarFrameL(ETrue);
    iSearchList->ScrollBarFrame()->SetScrollBarVisibilityL(
    CEikScrollBarFrame::EOn,
    CEikScrollBarFrame::EAuto);

    iItemList = new (ELeave) CDesCArrayFlat(3);
    iSearchList->Model()->SetItemTextArray(iItemList);
    iSearchList->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);

    iDetailList = new (ELeave) CAknFormDoubleStyleListBox;
    iDetailList->ConstructL(this);
    iDetailList->SetContainerWindowL(*this);
    iDetailList->CreateScrollBarFrameL(ETrue);
    iDetailList->ScrollBarFrame()->SetScrollBarVisibilityL(
    CEikScrollBarFrame::EOn,
    CEikScrollBarFrame::EAuto);
    iDetailList->Model()->SetOwnershipType(ELbmOwnsItemArray);
    iDetailList->MakeVisible(EFalse);
    iSearchList->MakeVisible(ETrue); // show "no results" at startup
    iSearchList->SetListBoxObserver(this);
    SetRect(aRect);
    ActivateL();
    MakeVisible(ETrue);


    following code in appview::draw()
    CWindowGc& gc = SystemGc();

    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbWhite );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );

    gc.UseFont(iFont);
    TInt lineHeight = iFont->HeightInPixels()+1;

    const TInt col = 5;
    gc.DrawText(KAboutString1, TPoint(col, lineHeight));
    gc.DrawText(KAboutString2, TPoint(col, lineHeight*2));
    gc.DrawText(KAboutString3, TPoint(col, lineHeight*3));
    gc.DrawText(KAboutString4, TPoint(col, lineHeight*4));
    gc.DrawText(KAboutString5, TPoint(col, lineHeight*5));

  2. #2
    Nokia Developer Champion vineet.jain's Avatar
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,840
    You may iterate through each contact & extract the required fields from it , store that in an array & then display them in listbox.

    http://www.developer.nokia.com/Commu...fault_database

    Above link may be a good reference to do so.The part of code in link, where field data is getting stored in the buffer 'wmobile', you may pass the CdesCArray instead & fill up the array with field elements

  3. #3
    Hi,
    The link suggests use of 3 fields workmobile number, home mobile number. There must be other fields also.What are those fields? How to extract them?Any pointer?

  4. #4
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    you could check the API docs for other fields, here's one link to online docs: http://library.developer.nokia.com/i...ngs.guide.html

  5. #5
    I got the link I was looking for->
    » Symbian OS v9.3 » Symbian OS guide » Application Engines » Using Contacts Model (CNTMODEL) » UIDs that Identify vCard Properties
    Symbian OS v9.3 » Symbian OS reference » C++ component reference » Application Engines CNTMODEL » CNTDEF.H Global variables

  6. #6
    using HandleDatabaseEventL(TContactDbObserverEvent aEvent), is there any way to know what changes invoked the function?

  7. #7
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    You can certainly get some details from that argument eEvent, but that is all.

  8. #8
    using HandleDatabaseEventL(TContactDbObserverEvent aEvent),.(I get phone number that is added or edited, but not that is deleted). Do I need to take a backup of database to get deleted numbers details. If I have to take a backup of the database, can someone throw light on how to do that. or is there any other way?
    from appui I am creating object of ContactsEngine. ContactEngine is derived from MContactDbObserver.

    In constructl() of ContactEngine->
    gConsole=((CPhoneAppUi *)(CEikonEnv::Static()->AppUi()))->gConsole2;
    iContactDatabase = CContactDatabase::OpenL();
    // Here iContactDatabaseObserver is a CContactDatabaseObserver pointer
    //
    CContactChangeNotifier* DatabaseNotifier = CContactChangeNotifier::NewL(*iContactDatabase , this);

    in HandleDatabaseEventL( TContactDbObserverEvent aEvent )
    _LIT(KConsoleMessageDisplay,"MessageDisplay");
    _LIT(KConsoleEdit,"Edit");
    _LIT(KConsoleAdd,"Add");
    _LIT(KConsoleDelete,"Delete");
    TContactItemId aChangeId=aEvent.iContactId;
    CContactItem* ownCard = iContactDatabase->ReadContactL(aChangeId);
    CleanupStack::PushL(ownCard);
    TBuf<100> mobile(0);
    CContactItemFieldSet &field_set = ownCard->CardFields();
    for (TInt i = 0 ; i < field_set.Count() ; i++)
    {
    CContactItemField& field = field_set[i];
    if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapCELL))
    {
    // This is general mobile processing. It will get all general mobiles in the contact list
    mobile.Fill('\0',1);
    mobile.Copy(field.TextStorage()->Text());
    mobile.ZeroTerminate();
    gConsole = Console::NewL(KConsoleMessageDisplay,TSize(20,20));
    CleanupStack::PushL(gConsole);
    gConsole->Printf(mobile);
    gConsole->Getch();
    CleanupStack::PopAndDestroy(gConsole);
    //TBuf<100> abc(KTab);
    //abc.Append(mobile);
    //iItemList->AppendL(abc);
    //process general mobile according to application logic
    continue;
    }
    }
    CleanupStack::PopAndDestroy();
    TUint aConnInt=aEvent.iConnectionId;
    switch(aEvent.iType)
    {

    //if any contact deleted in phonebook
    case EContactDbObserverEventContactDeleted:
    {
    gConsole = Console::NewL(KConsoleMessageDisplay,TSize(20,20));
    CleanupStack::PushL(gConsole);
    gConsole->Printf(KConsoleDelete);
    gConsole->Getch();
    CleanupStack::PopAndDestroy(gConsole);
    }
    break;
    //event if any contact changed
    case EContactDbObserverEventContactChanged:
    {
    gConsole = Console::NewL(KConsoleMessageDisplay,TSize(20,20));
    CleanupStack::PushL(gConsole);
    gConsole->Printf(KConsoleEdit);
    gConsole->Getch();
    CleanupStack::PopAndDestroy(gConsole);
    }
    break;
    //event if any new contact added to phonebook
    case EContactDbObserverEventContactAdded:
    {
    gConsole = Console::NewL(KConsoleMessageDisplay,TSize(20,20));
    CleanupStack::PushL(gConsole);
    gConsole->Printf(KConsoleAdd);
    gConsole->Getch();
    CleanupStack::PopAndDestroy(gConsole);
    }
    break;
    //check TContactDbObserverEventType for more events.
    }
    Last edited by abhinavnishantintg; 2012-10-04 at 07:39.

  9. #9
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    (It has been a while, sorry)

    Yes, you need a shadow copy of the database because the event you get is a notification, it comes when the contact is deleted (and thus is inaccessible) already, the same applies if you want to track changes. An other noteworthy thing is that in case of mass deletion you get the event for a few dozens-hundreds items at most, so if you really want to know about all deleted items, you may want to use some timer for recognising a possible sequence deletion events, and compare the remaining database with your shadow copy at the end only.

Similar Threads

  1. On nokia 6080 i am able to read contact name but not able read contact number
    By rosapanaidu.p in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2012-06-13, 11:15
  2. Replies: 3
    Last Post: 2010-04-01, 07:52
  3. Want to vie details of a contact
    By knights123 in forum Mobile Java General
    Replies: 2
    Last Post: 2009-05-13, 13:36
  4. How to get the highlighted contact details
    By dinesh547 in forum Symbian Networking & Messaging (Closed)
    Replies: 11
    Last Post: 2009-04-27, 18:46
  5. Getting Contact Details
    By primal in forum Symbian C++
    Replies: 4
    Last Post: 2008-06-04, 04:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved