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
helex
Posts: 287
Registered: ‎02-14-2012
My Device: Nokia N950 / BB Playbook
My Carrier: -

Calendar Invokation - only default calendar selectable

Hi!

 

I'm invoking the Calendar application using this from within my C++ code:

https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/calendar.h...

 

Everything works fine. But only the default system calendar is available, I'm unable to select a different one. The button is there, but the other calendars are grayed out.

 

After creating the event I can move it to a different calendar without problem. So I see no reason why it shouldn't work out of the box. I see also no invokation parameter to change this behavior.

 

A Android app I tried (http://oeffi.schildbach.de/download.html) is able to invoke the calendar and I'm able to select the target calendar without issue. But here the Calendar application opens in a separate window, at my Application it is a Card Invokation.

 

Any ideas?

Please use plain text.
BlackBerry Development Advisor
shaque
Posts: 234
Registered: ‎07-14-2008
My Device: Not Specified

Re: Calendar Invokation - only default calendar selectable

Which invoke parameters are yo using? Best if you paste your invoke code here.

Shadid
Please use plain text.
Developer
bennyantony
Posts: 27
Registered: ‎03-27-2011
My Device: Z10,Q10,Z30
My Carrier: Verizon and ATT

Re: Calendar Invokation - only default calendar selectable

The following code will select thed default calendar(not the home calendar/local calendar). most important thing setting accountId and folderId through whatever methods before invoking calendar

 

///////////

   data.insert("accountId", defaultCalendar.first);
    data.insert("folderId", defaultCalendar.second);

//////

 

 

//Code starts

// Create the calendar service object
    CalendarService calendarService;

    // Retrieve the IDs for the default calendar
    QPair<AccountId, FolderId> defaultCalendar = calendarService.defaultCalendarFolder();

    QVariantList participants = QVariantList();
    participants.append(emailaddress);
    QVariantMap data;
    data.insert(QString("participants"),QVariant(participants));
    data.insert("accountId", defaultCalendar.first);
    data.insert("folderId", defaultCalendar.second);
     qDebug() << "Account id " << defaultCalendar.first;
    qDebug() << "Folder id " << defaultCalendar.second;
   
     InvokeRequest request;
     request.setTarget(tr("sys.pim.calendar.viewer.eventcreate"));
     request.setAction(tr("bb.action.CREATE"));
     request.setMimeType(tr("text/calendar"));
    QByteArray encData = bb::smileytongue:sObject::encode(data,NULL);
    request.setData(encData);
     bb::system::InvokeManager* m_invokeManager = new InvokeManager(this);
     m_invokeManager->invoke(request);

 

//Code ends

 

 

Now if there are mutliple calendars, then you have to iterate through the calendar and take the right accountId and folderId and invoke calendar, it will work

 

Use the following code to iterate through the calendars

 

// Create the calendar service object
CalendarService calendarService;
 
// Retrieve the list of all calendars
QList<CalendarFolder> allFolders = calendarService.folders();
 
// Determine whether a calendar named "Birthdays" exists in the list of
// all calendars
bool found = false;
for (int i = 0; i < allFolders.size(); i++) {
   qDebug()<<"accountId"<<allFolders.at(i).accountId();
qDebug()<<"folderId"<<allFolders.at(i).id();
qDebug()<<"Name"<<allFolders.at(i).name();
 
 
//set the above 2 values while creating calendar entry or invoking calendar entry
}
 
 

 

Please use plain text.
Developer
helex
Posts: 287
Registered: ‎02-14-2012
My Device: Nokia N950 / BB Playbook
My Carrier: -

Re: Calendar Invokation - only default calendar selectable

Thanks for your reply bennyantony.

 

My current code was like this one:

 

    InvokeManager invokeManager;

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

    QVariantMap map;

    QTextDocument ver;
    ver.setHtml("Testsubject");
    map.insert("subject", tr("Test: ") + ver.toPlainText());

    QString BodyText;
    BodyText = "Testtext"
    map.insert("body", BodyText);

    QByteArray requestData = bb::PpsObject::encode(map, NULL);

    request.setData(requestData);

    invokeManager.invoke(request);

 

Worked fine at firmware 10.2.0 and below. I haven't set the accountId or folderId because the user should chose himself which calendar should get used.

 

But beginning with firmware 10.2.1 the Option for the target calendar is grayed out.

 

The big benefit was that I haven't needed the permission to access the calendar. I just started the invocation and the calendar dialog has done the rest. According to the CalendarService documentation I would need the permission using your method.

 

I wonder how I could give the user the option in the invoked dialog back without the need to get before all available calendars and handle it myself via a setting.

 

Please use plain text.
Developer
helex
Posts: 287
Registered: ‎02-14-2012
My Device: Nokia N950 / BB Playbook
My Carrier: -

Re: Calendar Invokation - only default calendar selectable

Okay, even after adding the <permission>access_pimdomain_calendars</permission> permission and adding all calendars to the invocation the selection dialog is still grayed out:

 

CalendarService calendarService;
 
QList<CalendarFolder> allFolders = calendarService.folders();
 
for (int i = 0; i < allFolders.size(); i++) {
            map.insert("accountId", allFolders.at(i).accountId());
            map.insert("folderId", allFolders.at(i).id());
}

 

Using this code only the last calendar gets added to the dialog. Without the additional permission only the default calender is in the CalendarFolder list.

 

Preferable I would use again the invocation dialog without the additional access_pimdomain_calendars permission. I'm using the invocation framework especially because it works natively and without additional permission which would make reading and changing possible without the knowledge of the user.

 

Android apps are still able to select the target calendar in the invocation dialog. Why not the native ones? What am I making here wrong?

Please use plain text.