Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
tonygluk
Posts: 30
Registered: ‎11-06-2012
My Device: BB 10 Dev Alpha
Accepted Solution

Calendar composer ignores the startTime parameter

Hello everybody!

I'm trying to create a calendar event using the system Calendar composer via Invocation Framework. The problem is that Calendar composer dialog ignores the startTime parameter. Here is the code:

bb::system::InvokeRequest cardRequest;
QVariantMap requestData;

requestData["startTime"] = dateTimePicker_->value().toString("yyyy-MM-dd hh:mm:ss");

cardRequest.setTarget("sys.pim.calendar.viewer.eventcreate");
cardRequest.setAction("bb.action.CREATE");
cardRequest.setMimeType("text/calendar");

bool ok = true;
QByteArray encodedRequestData = bb::PpsObject::encode(requestData, &ok);
if (!ok)
{
	Q_ASSERT(false);
	return;
}

bb::system::InvokeTargetReply *reply = invokeManager_->invoke(cardRequest);
QObject::connect(reply, SIGNAL(finished()),
		 this, SLOT(invokeCalendar_finished()));

I've tried to use both "startTime" and "start", neither works. 

 

Any help is very appreciated!

Developer
oniongarlic
Posts: 72
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB

Re: Calendar composer ignores the startTime parameter

Hitting this too. Any ideas?
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: Calendar composer ignores the startTime parameter

this might be too obvious, but you are never setting the encodedRequestData variable to the data parameter of the invokerequest
Like all of my posts
Developer
oniongarlic
Posts: 72
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB

Re: Calendar composer ignores the startTime parameter

Well, my code does
    map.insert("subject", title);
    map.insert("startTime", start.toString("yyyy-MM-dd hh:mm:ss"));
    map.insert("duration", duration);

    request.setMimeType("text/calendar");
    request.setAction("bb.action.CREATE");
    request.setTarget("sys.pim.calendar.viewer.eventcreate");
    QByteArray requestData = bb::PpsObject::encode(map, &ok);
    if (!ok) {
    	qDebug("EventPPSEncode failed?");
    }

    request.setData(requestData);
    bb::system::InvokeTargetReply *reply = m_invokeManager.invoke(request);
The subject comes trough fine, but not the datetime or duration.
Developer
tonygluk
Posts: 30
Registered: ‎11-06-2012
My Device: BB 10 Dev Alpha

Re: Calendar composer ignores the startTime parameter

[ Edited ]
    cardRequest.setData(encodedRequestData);

 is present in my code, it seems like I've somehow erased this line from post. I'll edit the initial post so that it doesn't confuse anybody.

 

EDIT: Unfortunately I can't edit my original post.

Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: Calendar composer ignores the startTime parameter

From the documentation, it expects startTime to be passed a QDateTime into the qvariantmap, maybe give that a try?
Like all of my posts
Developer
tonygluk
Posts: 30
Registered: ‎11-06-2012
My Device: BB 10 Dev Alpha

Re: Calendar composer ignores the startTime parameter

I thought that it expects a QDateTime too. In fact, documentation tells us to convert QDateTime to QString. Actually I've already encountered an encoding error using QDateTime.

Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: Calendar composer ignores the startTime parameter

Just doing QDateTime.toString() with no args just worked for me.

Have any idea what unit the duration is supposed to be in? It says int but doesnt say whether thats in seconds/minutes/hours/milliseconds
Like all of my posts
Developer
tonygluk
Posts: 30
Registered: ‎11-06-2012
My Device: BB 10 Dev Alpha

Re: Calendar composer ignores the startTime parameter

Thanks kylefowler! I'll try and then tell you whether this works.

Developer
oniongarlic
Posts: 72
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB

Re: Calendar composer ignores the startTime parameter

This worked for me too. Thanks for the hint.