Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Quick way to remove all contacts from a QContactManager?
I am looking for a single function call that removes all contacts from a QContactManager. I see in the documentation that I can make a QContactManager remove a QList<QContactLocalId> or I can do something similar asynchronously with a QContactRemoveRequest.
What I want is a single function call that does not require any arguments. Something like:
You might very reasonably ask me why I need such a function when there are already two perfectly good ways to remove contacts.
I need this for the "PanicButton":http://talk.maemo.org/showpost.php?p=982082&postcount=1 application I announced on talk.maemo.org a little while ago. Among the target audience are democracy activists. Those brave people sometimes face arrest and to protect their friends, families, and other contacts, it might be important for PanicButton to delete the entire address book.
It's obvious that I can fetch all of the contacts whenever PanicButton is launched and keep a QContactRemoveRequest prepared for when the panic button is pressed. I'm worried that the Maemo or Symbian device on which it runs might not have enough memory to hold all contacts at the same time. I can avoid the problem if there is a single, zero-argument function to call.
chriadam last edited by
Currently, there is no such function in the API. If you make a Suggestion task on JIRA and it gets enough votes, it may get roadmapped for a future version of Mobility. You can, however, do it in two lines of code:
Regarding the amount of memory used if you were to keep them in memory, while it's true that holding all contacts in memory may be prohibitively expensive, holding all contact ids in memory should not be. Alternatively, you could store ids in serialised form on disk; when the panic button is pressed, read the serialised ids in from file and call removeContacts() on that list of ids. I would assume, however, that such file I/O would scarcely be faster than the database call to retrieve the full list of contact ids.
Thanks, Chris. I followed your example but changed it to delete the contacts asynchronously. It doesn't take long to obtain all of the contact IDs. However, deleting the contacts takes a long time. For example, on my Nokia N900 phone, it takes 26 minutes to delete 889 contacts.
chriadam last edited by
That sounds like a problem in the N900 contacts backend - it must do something extremely inefficient in the contact deletion codepath for it to take that long. Please file a bug on JIRA so it can be investigated, and include the version of Mobility / Qt / Fremantle / etc you're using.
I filed both a "suggestion":http://bugreports.qt.nokia.com/browse/QTMOBILITY-1506 and a "bug report":http://bugreports.qt.nokia.com/browse/QTMOBILITY-1507 .
michael.goddard last edited by
For best results I'd probably try direct file access to erase things, or don't store sensitive things in an unprotected database. Of course that makes using the device as a phone a fair bit worse :/