We have moved to a new Sailfish OS Forum. Please start new discussions there.
22

How to interact with calendar database

asked 2014-06-04 01:12:01 +0300

jollajo gravatar image

updated 2014-07-25 14:02:10 +0300

jiit gravatar image

I'm working on a script/program that tries to imports calendar events into the calendar database. Since it is a sqlite-db it seems to be straight forward to add/modify/remove entries in the database as user root.

However if I add an alarm it is not fired by the phone. The alarm is shown in the official Jolla calendar app however closing the calendar app or even restarting the phone does not give me alarms for those events?

Is there some documentation how to register those alarms in the notification system? How does the calendar app cause the alarms to be registered?

Two side questions: 1. Why does the calender app ignore alarms that do not match the suggested times? I.e. a alarm 10 minutes before the event seems to be ignored, if the interval is 0, 5, or 15 minutes it is recognized.
2. There is a file db_changed in the same directory as the calendar db (/home/nemo/.local/share/priviledged/calendar/mkcal/). I see that it is an empty file that is touched when the calendar app makes some changes. What is it good for? Should I touch this file as well from my script?

I wish there were a proper documentation of the system services (e.g. dbus interfaces) and also how to interact with the data managed by the 'official' Jolla apps.

edit retag flag offensive close delete

Comments

8

The lack of documentation is really frustrating. And Jolla is not doing much to improve.

rooster13 ( 2014-06-04 07:30:33 +0300 )edit

I am really interested in this topic, too! But unfortunately i have not found much information and documentation by now. Can you give me a hint where i can find dome information about the database and how to edit it?

Alex-jj ( 2014-09-11 16:45:15 +0300 )edit
3

The recently released buteo-sync-plugins-social source code contains great examples on how to use the calendar database (look into googlecalendarsyncadaptor.cpp)

eber42 ( 2014-09-16 20:38:59 +0300 )edit

@eber42 thanks for the hint. The problem I couldn't solve was to register an alarm/notification on the phone. I can set the alarm in the database however the phone does not show the alarm.

In the source file you referred to I couldn't find a hint on how to inform the phone of new alarms.

jollajo ( 2014-09-17 02:17:08 +0300 )edit
1

Could it be the same reason, which causes the birthday calendar alarms to keep silence i.e. not giving alarm. Check the birthday alarm posts in TJC for more info, if that would help ad well.

Kari ( 2014-09-17 08:29:39 +0300 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2015-01-07 14:08:33 +0300

Pekka Vuorela gravatar image

Calendar uses https://github.com/nemomobile/nemo-qml-plugin-calendar to provide QML interface for calendar. Underneath there are https://github.com/mer-packages/mkcal and https://github.com/mer-packages/kcalcore/ for actual calendar db handling. Stability is not promised for any, but last two are expected to change very little, if any.

Wouldn't recommend touching sqlite directly. If that's what was being done here, timed didn't get information on new alarms, as is done mkcal, thus alarms didn't trigger.

Side questions: 1. Calendar currently lacks support for showing custom alarm times in the UI. Could be enhanced. 2. db_changed is mkcal internal file for signaling changes. As said, should use those interfaces instead of directly modifying the db file.

Sorry for late reply.

edit flag offensive delete publish link more
3

answered 2016-05-27 20:59:37 +0300

Sharing some findings in the hope it will be useful for somebody...
Registering events via CLI
As of 2016-05-23: SailfishOS 2.0.1.11
Two things:
1) Manipulating Calendar,
2) Creating an alarm.
Testing alarm creation:
As normal user:
timedclient-qt5 -e'APPLICATION=libextendedkcal;PLUGIN=libCalendarReminder;TITLE=alarm test 01;endDate=2016-05-23 23:58:00;startDate=2016-05-23 23:37:00;time=2016-05-23 23:35:00;type=event;reminder;triggerIfMissed;' This should give an alarm on "2016-05-23 23:35:00" (time) anouncing an event starting on "2016-05-23 23:37:00" (startDate) and ending on "2016-05-23 23:58:00" (endDate) and title "alarm test 01".
"Calendar" data base is in /home/nemo/.local/share/system/privileged/Calendar/mkcal/db. There you need root/"devel-su".
Manipulating Calendar
I did things in "sqlite".
sqlite3 /home/nemo/.local/share/system/privileged/Calendar/mkcal/db
Register event: (calendar app should not be running)
INSERT INTO Components(Notebook,Type,Summary,DateStart,DateStartLocal,StartTimeZone,DateEndDue,DateEndDueLocal,EndDueTimeZone,Description,Priority,DateCreated,DateStamp,DateLastModified,Sequence,URL,UID,DateDeleted) VALUES('061b84cd-ce36-423a-912b-dea95a028824','Event','test entry alarm N14r','1464034500','1464034500','Europe/Lisbon','1464036000','1464036000','Europe/Lisbon','no use, just test alarm 14r','0','1464033874','1464033874','1464033874','0','urn:x-ical:280d1620-17a0-4ced-ae4d-406d8c57c133','280d1620-17a0-4ced-ae4d-406d8c57c133','0');
INSERT INTO "Alarm" VALUES((select max(ComponentId) from Components),'0','0','0','-300','startTriggerRelation','0','0','','','','','','','1');
Creating an alarm.
(As normal user, at the shell prompt)
timedclient-qt5 -e'APPLICATION=libextendedkcal;PLUGIN=libCalendarReminder;TITLE=test entry alarm N14r;type=event;time=2016-05-23 21:10:00;notebook=061b84cd-ce36-423a-912b-dea95a028824;uid=280d1620-17a0-4ced-ae4d-406d8c57c133;alarmtime=2016-05-23 21:10:00;startDate=2016-05-23 21:15:00;endDate=2016-05-23 21:40:00;reminder;triggerIfMissed;'
"notebook" is the identification of the calendar, "uid" the identification of the event. Have a look at /home/nemo/.timed/events.data. Try timedclient-qt5 -l before and after the alarm fires.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
16 followers

Stats

Asked: 2014-06-04 01:12:01 +0300

Seen: 1,631 times

Last updated: May 27 '16