Creating a CContactItem and specifying its Id

Login to reply to this topic.
Thu, 2008-02-21 15:02
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1964

Hi there,

I have a situation where I need to create a CContactItem and need to assign it a specific Id (basically, I am working on a backup/restore application and I am here trying to restore a specific contact in the contact database and need it to keep the same id).

I haven't find any specific ways of doing this and even could not find out of the CContactItem ::iId is initialized by Symbian OS. Any clues someone ?

Thanks.
Eric


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant


Fri, 2008-02-22 14:04
Joined: 2004-05-24
Forum posts: 982
Re: Creating a CContactItem and specifying its Id

Hi Eric,

There is no way client can specify the ID of a newly created contact item, whilst this is created by contact model.
Can I ask why do you need exactly the same id? Can't you use GUIDs? Or can't you just store in other place a mapping between your "fixed ids" and ids on contact db (similar to syncml)?


pirosl

Fri, 2008-02-22 14:58
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1964
Re: Creating a CContactItem and specifying its Id

Can I ask why do you need exactly the same id? Can't you use GUIDs? Or can't you just store in other place a mapping between your "fixed ids" and ids on contact db (similar to syncml)?

I just wanted to avoid what you described! Being able to use the Contact Id as my Id would simplify/speedup a lot my processing.


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Fri, 2008-02-22 15:03
Joined: 2004-05-24
Forum posts: 982
Re: Creating a CContactItem and specifying its Id

I do agree with you.....
One question...do you really have to delete the contact item? Can't you update it?


pirosl

Fri, 2008-02-22 15:06
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1964
Re: Creating a CContactItem and specifying its Id

I can, but only if the contact is present in the database. in the case the user or another application has accidentaly deleted the contact, I also need to restore it properly and this is where I have all this extra processing to do.


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Fri, 2008-02-22 15:14
Joined: 2004-05-24
Forum posts: 982
Re: Creating a CContactItem and specifying its Id

Ok.....but I'm back to my initial question....why can't you make all this logic arround GUID and not arround ID (contact ID).
GUID is supposed to be unique...and really doesn't matter if the contact was deleted, newly created or updated


pirosl

Fri, 2008-02-22 15:29
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1964
Re: Creating a CContactItem and specifying its Id

Sorry, but I am not sure I can answer this (just to avoid disclosing the details of my customer's application until they launch it on market)


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Fri, 2008-02-22 15:55
Joined: 2004-05-24
Forum posts: 982
Re: Creating a CContactItem and specifying its Id

ok Smiling seems fair.

From technical point of view, using GUID should be enough and should be used for same reasons as using id.
I was just trying to understand what other use cases people have in mind.

And actually there is smth it might work (but please keep in mind it's just an idea...I've never tested).....
You can increment access count for contact items you want to delete....this means that they will not physycal be deleted from contact db. Which means there are chances to update that contact item when you try to create it second time.......Of course, may be you'll still have the problem with the case when other apps will delete contact items (!?)


pirosl

Sun, 2008-02-24 19:15
Joined: 2007-09-15
Forum posts: 61
Re: Creating a CContactItem and specifying its Id

Hi Eric

What I can make out from your requirement is that you are trying to restore a contact and don't want the contact Item to be duplicate in the contact list. If this is what your requirement is, then unfortunately, as Pirosl said, the client cannot specify the ID while creating the new contact, moreover if any contact has been deleted then that contact's ID cannot be re-assigned by the Contact Database untill the device is formatted. So if the contact you want to restore is deleted (anyhow), your logic of using the same contact ID will not work.
As per my observation the contact database generated the contact IDs in a sequence and the ID once issed is never reissued.

Mon, 2008-02-25 10:26
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1964
Re: Creating a CContactItem and specifying its Id

Thanks guy.
I think I will go with my own mapping and GUID. I was just looking for simplicity and I am not sure that other alternatives would do it.


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Tue, 2008-02-26 08:09
Joined: 2007-06-20
Forum posts: 26
Re: Creating a CContactItem and specifying its Id
  • Login to reply to this topic.