How to commit unsigned char* data to CContactDataBase?

Login to reply to this topic.
Thu, 2007-11-08 13:06
Joined: 2007-10-16
Forum posts: 65

TPtrC16 name = _L("");
name.Set(contactItem->CardFields()

.TextStorage()->Text());
TInt FieldTextLength = name.Length();
TBuf<2000>DataBuf16;
DataBuf16.Copy(name);
TInt iFieldDatalen = DataBuf16.Length();
unsigned char *encryptdata = NULL;
encryptdata = new unsigned char[100];
for(TInt i=0;i {
encryptdata[i]=DataBuf16[i];
}
encryptdata[iFieldDatalen]=0;
//Encrypt the Data
Encrypt(encryptdata,dwDataLength,DKey);

//Now How to commit this Encrypted data to CContactDataBase?

Pls help me.Its not understanding for me.


Thu, 2007-11-08 14:14
Joined: 2004-05-24
Forum posts: 982
Re: How to commit unsigned char* data to CContactDataBase?

What exactly you don't understand?

encryptdata is a pointer to char so you can't commit that in contact database since contact database stores contact items.

You can change the contact item and commit the contact item....
To change the contact item you do this:
- read contact item
- if you want to add a new item field; you create a new item field, set the field with your encrypted data (you can do this since you work with descriptors....which are able to handle binary data)
- add new item field
- commit contact item

- if you want to change an existing field item; read that field item, set the field with encrypted data (again you can do this since you work with descriptors....which are able to handle binary data)
- commit contact item


pirosl

Tue, 2007-11-13 05:54
Joined: 2007-10-16
Forum posts: 65
Re: How to commit unsigned char* data to CContactDataBase?

Hai pirosl,
Thanks for ur reply.
Iam doing the following steps.Are they correct?

1.Getting the text of each field and encrypting that field text.
2.Storing the encrypted text in TBuf .
3.Setting TBuf Text to ContactItem

pls help me.

Tue, 2007-11-13 12:37
Joined: 2004-05-24
Forum posts: 982
Re: How to commit unsigned char* data to CContactDataBase?

Seems rigth to me.....
One single comment....be sure your encrypted text is encoded in 16 bytes not in 8....(or compile everything on 8 bytes)


pirosl

  • Login to reply to this topic.