×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    Very Urgent:: How to be notified when contacts changed or added on the simulator?

    Hi All,
    I need to write a symbian application which will be notified when contacts added or existing contacts changed I tried this:
    QContactManager* contactManager = new QContactManager();
    connect(contactManager,SIGNAL(contactsAdded(QList<QContactLocalId>)),this,SLOT(ContactChanged(QList<QContactLocalId>)));
    connect(contactManager,SIGNAL(contactsChanged(QList<QContactLocalId>)),this,SLOT(ContactChanged(QList<QContactLocalId>)));

    ContactChanged(QList<QContactLocalId> ContactsIDs)
    {

    QMessageBox::warning(0,"Contact changed","Contact XChanged",QMessageBox::Ok);
    }
    I run it on the qt nokia simulator and tried to import contacts and edit the existing contacts names, but the function ContactChanged is never called.

    Could any one tell me how to be notified with these changes and how to test the code on the simulator

    Best Regards

  2. #2
    Nokia Developer Expert
    Join Date
    May 2010
    Posts
    65

    Re: Very Urgent:: How to be notified when contacts changed or added on the simulator?

    Hi,

    Firstly, can I suggest getting some code working on the desktop with the memory engine first? It will give debugging output as to whether the signals/slots exist as written, which may be a problem.

    Where are you performing the connect() calls? In the ctor of the class? The function signature of your slot seems wrong (no return type, no class name). If that's just a copy/paste error in your forum post, then there are a few other possibilities:

    1) the QContactManager* contactManager = new QContactManager(); call is not creating the simulator manager, but some other manager (memory manager perhaps). Please ensure that you're definitely constructing the manager you think you are.

    2) there is no guarantee that the contactsAdded() or contactsChanged() signals will be emitted for every change. In particular, managers can "coalesce" change signals into batches, for performance reasons; alternatively, they can emit the dataChanged() signal instead. Ensure that you also connect to the dataChanged() signal.

    3) If the problem only occurs in the simulator, and not on the desktop with the memory engine, nor on device, then it's most likely a bug in the simulator engine signal emission code. Please create a bug report on our bug tracking system if this proves to be the case.

    Cheers,
    Chris.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    Re: Very Urgent:: How to be notified when contacts changed or added on the simulator?

    Thanks Chris for your reply,
    Here is exactly my code:

    ContactsSynchronizer::ContactsSynchronizer(QObject *parent) :
    QObject(parent)
    {

    QContactManager* contactManager = new QContactManager();

    QList<QContact> contactIds = contactManager->contacts();
    if(contactIds.count()>0)
    QMessageBox::warning(0,"right manager","right manager",QMessageBox::Ok);

    connect(contactManager, SIGNAL(dataChanged()), this, SIGNAL(Changed()));
    connect(contactManager, SIGNAL(contactsAdded(QList<QContactLocalId>)), this, SIGNAL(contactsAdded(QList<QContactLocalId>)));
    connect(contactManager, SIGNAL(contactsChanged(QList<QContactLocalId>)), this, SIGNAL(contactsChanged(QList<QContactLocalId>)));
    connect(contactManager, SIGNAL(contactsRemoved(QList<QContactLocalId>)), this, SIGNAL(contactsRemoved(QList<QContactLocalId>)));
    connect(contactManager, SIGNAL(relationshipsAdded(QList<QContactLocalId>)), this, SIGNAL(relationshipsAdded(QList<QContactLocalId>)));
    connect(contactManager, SIGNAL(relationshipsRemoved(QList<QContactLocalId>)), this, SIGNAL(relationshipsRemoved(QList<QContactLocalId>)));

    connect(contactManager,SIGNAL(contactsAdded(QList<QContactLocalId>)),this,SLOT(ContactChanged(QList<QContactLocalId>)));
    connect(contactManager,SIGNAL(contactsChanged(QList<QContactLocalId>)),this,SLOT(ContactChanged(QList<QContactLocalId>)));

    }

    void ContactsSynchronizer::ContactChanged(QList<QContactLocalId> ContactsIDs)
    {

    QMessageBox::warning(0,"Done","Dne",QMessageBox::Ok);
    }

    void ContactsSynchronizer::Changed()
    {
    QMessageBox::warning(0,"Done","Done",QMessageBox::Ok);
    }


    The manager retrieves the contacts in the simulator correctly . but it doesn't respond to the cntacts changed , contacts added and data changed signals.
    If yoy have any code snippest for the dsktop , I will be very grateful.
    Thanks again for your reply,
    Best Regards,
    Mohamed.

  4. #4
    Nokia Developer Expert
    Join Date
    May 2010
    Posts
    65

    Re: Very Urgent:: How to be notified when contacts changed or added on the simulator?

    Hi Mohamed,

    The code you posted looks ok. This suggests that there is a problem with signal emission from the simulator engine, although I'd like to confirm that the problem does _not_ occur when using the memory engine on desktop, before we make that assumption.

    For the desktop, the same code should work (Qt Everywhere ;-) although you need to use a different toolchain to build the application, obviously (msvc toolchain from Microsoft Visual Studio 2008 Express Edition is what I use personally, on Windows; if you have a Linux development environment it's even easier, obviously). Take a look at the samplephonebook example in mobility for some sample code. If you can confirm that the signals are emitted correctly on desktop from memory engine, but not in simulator with simulator engine, then I'd suggest making a bug report at bugreports.qt.nokia.com. If it doesn't work as expected for you on desktop with the memory engine, then I'd suggest that the problem is in your code, somewhere (as signal emission with memory backend does work correctly).

    Cheers,
    Chris.

Similar Threads

  1. Contacts on QT Simulator
    By wenz in forum [Archived] Qt Mobility Project
    Replies: 11
    Last Post: 2010-09-30, 05:32
  2. Replies: 0
    Last Post: 2010-01-28, 06:47
  3. problem with reading contacts added from call log
    By schoudri in forum Mobile Java General
    Replies: 1
    Last Post: 2008-07-21, 17:45

Posting Permissions

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