Skip to main content

PIM and 'Non-standard Properties'; RIM; JDE 4.3.0

1 reply [Last post]
carstenuk
Offline
Joined: 2009-04-23

Hi community!

I'm trying to introduce some non-standard properties into the VCALENDAR of my Blackberry. Even though I think I comply with RFC 2445, sect 4.8.8.1., my app won't work. I guess the 'commit()' menthod kills everything I put in. Is there any other way to bypass the 'commit()' call?

Code:
-----------------------------------------------------------------------------------------------------------
import java.io.*;
import java.util.*;

import javax.microedition.pim.*;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

.
.
.

// Get PIM Instance
PIM pim = PIM.getInstance();

// Get EventList in RW mode
EventList el = (EventList)pim.openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);

// Get EventList items
Enumeration e = el.items();

// simplified retrieval of first event.
// No further checks, I know that there is one in there :-)
Event c = (Event)e.nextElement();

// Get event serialized
ByteArrayOutputStream output = new ByteArrayOutputStream();
String[] dataFormats = pim.supportedSerialFormats(PIM.EVENT_LIST);
pim.toSerialFormat(c, output, "UTF8", dataFormats[0]);

// convert serialized event to String
String serialEvent = output.toString();

// show content on screen
add(new SeparatorField());
RichTextField rtf = new RichTextField();
rtf.setText(serialEvent);
add(new SeparatorField());

//
// In order to see whether the changes I make are actually applid
// to the Event in the PIM I modify the 'DESCRIPTION:' field. It
// contains the text 'This is a Note'
//

// temp and target String
String _tmp;
String _new;

// modification of text in 'DESCRIPTION:'. I put a '-' in front of it
int _pos = serialEvent.indexOf("This is a ");
_tmp = serialEvent.substring(0, _pos) + "-" + serialEvent.substring(_pos, serialEvent.length());

// search end of VCALENDAR declaration ...
_pos = _tmp.indexOf("END:VCALENDAR");

// ... and insert X- property according to RFC 2445 sect. 4.8.8.1
_new = _tmp.substring(0, _pos) + "X-XXX-XXX;X-XXX-XXXTYPE=XXX:MyType" + "\r\n" + _tmp.substring(_pos, _tmp.length());

// Modification is done. Check on screen
RichTextField rtf_4 = new RichTextField();
rtf_4.setText(_new);
add (rtf_4);
add(new SeparatorField());

//
// Modification looks good. Now put it back to the PIM
//

// kill original event
el.removeEvent(c);

// prepare stream
ByteArrayInputStream bais = new ByteArrayInputStream(_new.getBytes());

// create PIM Item from _new String (the modified one)
PIMItem[] pi = pim.fromSerialFormat(bais, "UTF8");

// create new Event from PIM Item
Event newEv = el.importEvent((Event)pi[0]);

// and now commit Event to PIM
newEv.commit();

// close EventList
el.close();
-----------------------------------------------------------------------------------------------------------

As stated in the comments of the code the modified serialized event looks ok. The change to the event in the DESCRIPTION: field has been taken over and is visible in the normal event in the calendar application on the phone. So the change of the data and the commit() stuff works. But the X- property is filtered out and not applied. This I can see when I run my application a second time and check the serialized VCALENDAR entry on the screen.

I'm not quite sure about the correct location of the X- property. I tried it immediately before the 'END:VEVENT', as well as before 'END:VCALENDAR'. Neither of them works.

Any body who knows how to add X- properties successfully?

Blackberry JDE 4.3.0

Thanks for your time!

Regards,

Carsten

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
carstenuk
Offline
Joined: 2009-04-23

Hi,

well, I'll answer this one myself then.

X- properties as defined in RFC 2445 are not supported by the Blackberry API I was told in a reply from RIM.

Disappointing :-(

Regards!