×

Discussion Board

Results 1 to 15 of 16

Hybrid View

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    6

    Question How to print all contact names in N900 addressbook - Please Help

    I have been trying to access the contacts in the N900 using Qt mobility and osso-addressbook for a long time now with no luck. All I want to do is to print out the names of all the contacts in the addressbook as a list on the console but am not able to do so. I do not mind whether I use Qt Mobility or the standard libebook or libosso-abook methods. Please help.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    6

    Re: How to print all contact names in N900 addressbook - Please Help

    I know this is a Qt forum but I was at a loss as to where else to ask. Also since the code is being implemented as part of a Qt program (I cant get Qt Mobility to work) I thought I would ask my question here.

    Could someone please tell me why the following code wont work on a N900? It simply quits without ever entering the for loop to print out the contacts.

    #include <libosso-abook/osso-abook.h>
    #include <libebook/e-book.h>
    #include <QDebug>

    int main(int argc, char** argv)
    {
    GList *contacts2, *c;
    GtkWidget *view;
    osso_context_t *osso_cxt; //libosso initialization
    OssoABookContactModel *default_model;

    osso_cxt = osso_initialize (argv[0], "1.0", FALSE, NULL); //libossoinit
    osso_abook_init (&argc, &argv, osso_cxt); //pass ossocontext
    default_model = osso_abook_contact_model_get_default ();

    view = osso_abook_contact_view_new_basic (HILDON_UI_MODE_NORMAL, default_model);
    contacts2 = osso_abook_contact_view_get_selection (OSSO_ABOOK_CONTACT_VIEW (view));


    //now print out the contacts in contacts2 using a for loop

    int count;
    count = 1;
    qDebug() << "ok so far..";
    for (c = contacts2; c; c = c->next) {
    qDebug() << "entered loop..";
    EContact *contact = E_CONTACT (c->data);
    EVCard *vcard = E_VCARD (contact);
    char *v;
    v = e_vcard_to_string (vcard, EVC_FORMAT_VCARD_30);
    g_print ("Card %d\n", count);
    g_print ("%s", v);
    g_print ("-------\n");
    g_free (v);
    count++;
    }

    return 0;
    }


    Any help would be highly appreciated. Been trying to work this out for over a week now.

    Thanks!
    Last edited by sarsh1910; 2010-05-17 at 01:25. Reason: Corrrection in code + additional information

  3. #3
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to print all contact names in N900 addressbook - Please Help

    The reason it doesn't work is because you are trying to print selected contacts from view widget. However, you do not show your widget anywhere and thus do not give yourself a chance to select anything. If your goal is to print all contacts, you don't need view and its selection.

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    6

    Re: How to print all contact names in N900 addressbook - Please Help

    thanks for the reply Danill.

    yes i'm simply trying to print out all contact names.

    could you please tell me how i could do this without using view and its selection like you mentioned?

    thanks in advance.
    Sarshad

  5. #5
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: How to print all contact names in N900 addressbook - Please Help

    Hi,
    You should:
    1) get the list of the master contacts:
    GList *contacts = osso_abook_aggregator_list_master_contacts(m_abookAgregator);

    2) Then you can get the display labels from any contact:
    acontact = (OssoABookContact*)contacts->data;
    const char* displayName = osso_abook_contact_get_display_name(acontact);

    Note:
    The contact display name is created in Maemo5 in according to some "internal" rules...
    Internal since user should not be able to change those...

    However the contact display name is created using First and Last name. If those are missing
    then email is used. If contacts doesn't have any email address then the account name (eg: Skype, GTalk and so on)
    associated to the contact is used.

    If you don't want to get the Display name but just a contact attribute like First/Last name, email...
    then instead of casting contacts->data to (OssoABookContact*) you have to cast it to EContact:
    econtact = E_CONTACT(contacts->data)
    so that you can use the EBook API to retrieve values and parameters from the contact attributes.

  6. #6
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to print all contact names in N900 addressbook - Please Help

    You can use this example to achieve the same with Qt Mobility (note that QContactManager::contacts is deprecated method)
    http://wiki.forum.nokia.com/index.ph...t_Mobility_API
    However, I faced the problem that Qt Mobility from extras-devel:
    http://repository.maemo.org/extras-d...q/qt-mobility/
    Conflicts with the latest Qt from Fremantle repository.

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to print all contact names in N900 addressbook - Please Help

    Quote Originally Posted by divanov View Post
    You can use this example to achieve the same with Qt Mobility (note that QContactManager::contacts is deprecated method)
    http://wiki.forum.nokia.com/index.ph...t_Mobility_API
    However, I faced the problem that Qt Mobility from extras-devel:
    http://repository.maemo.org/extras-d...q/qt-mobility/
    Conflicts with the latest Qt from Fremantle repository.
    The latter was fixed. However 1.0.0-beta1-maemo6 doesn't contain contacts backend.
    Last edited by divanov; 2010-05-17 at 15:22.

  8. #8
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to print all contact names in N900 addressbook - Please Help

    Don't forget to consider using QContacts API from Qt Mobility, but note that at the moment Qt Mobility cannot be used by paid applications for Ovi Store.

Similar Threads

  1. Guitar Tuner in Python
    By cassioli in forum Symbian
    Replies: 44
    Last Post: 2009-11-30, 20:03
  2. Random RingTone within Contact List for 3rd
    By cckfranky in forum Symbian
    Replies: 5
    Last Post: 2007-12-29, 18:33
  3. How to send an image with attachment in email
    By krtrivdi in forum Symbian
    Replies: 1
    Last Post: 2007-01-09, 12:07
  4. Sending an image over email
    By jeclarim in forum Symbian
    Replies: 3
    Last Post: 2006-12-15, 20:25
  5. contact number and contact names doesn't match.
    By ninidotnet in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-10-09, 09:25

Posting Permissions

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