maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   Quick add new task to Calendar? (https://talk.maemo.org/showthread.php?t=67942)

dov 2011-01-06 07:42

Quick add new task to Calendar?
 
Is there any way of accessing the calendar from the command line? E.g. I would like to write add a calendar quick add widget that does the follows:

1. Pops up a small entry widget in which I would type something like:

Lunch with Ron next Wednesday at 12:00

2. A freetext format parses would convert this into an ical file.
3. The widget should somehow import the ical file into the calendar db.

The question is how to do step number 3?

nicolai 2011-01-06 10:44

Re: Quick add new task to Calendar?
 
Quote:

Originally Posted by dov (Post 912955)
Is there any way of accessing the calendar from the command line? E.g. I would like to write add a calendar quick add widget that does the follows:

1. Pops up a small entry widget in which I would type something like:

Lunch with Ron next Wednesday at 12:00

2. A freetext format parses would convert this into an ical file.
3. The widget should somehow import the ical file into the calendar db.

The question is how to do step number 3?

The only way I know is using the calendar-backend API.
http://maemo.org/api_refs/5.0/5.0-fi...4d8d5b8d043570
But if you do so, you can just skip step 2 and 3 and use
the API for adding a new task.

Feel free to ask me if you have any questions. I used the calendar
API in my calendar-home-widget and my scout application.

Nicolai

jackburton 2011-01-06 12:16

Re: Quick add new task to Calendar?
 
This is a little off-topic, Nicolai, but how hard would it be to create a command line app that exports a calendar to ical? I know there is an option in the UI for this, but I would like to automatically push some of my calendars to my personal "cloud" using scheduled tasks. I don't know C++ nor QT (I'm a java guy) but I'd like to learn. Would this API be something easy enough to use to do what I have described. Any high level steps to get started? There is a ton of documentation floating out there on how to develop on Maemo and getting started seems difficult.

nicolai 2011-01-06 12:57

Re: Quick add new task to Calendar?
 
@jackburton

Yes, this should be easy.
Setting up the scratchbox development
envrionment is much more difficult than writing this app.

I don't know the qtmobility api for the calendar. But installing
QtCreator and making a simple commandline application should be
easy. The calendar-backend uses C++ as well, so it is easier to use
this from Qt code than for a gtk+ application for example.


nicolai

jackburton 2011-01-06 13:22

Re: Quick add new task to Calendar?
 
@Nicolai

Thanks for the input. So I should be able to do this with QtCreator then? I'll check that out first.

Also, kudos for the Calendar Home Widget.

dov 2011-01-06 13:52

Re: Quick add new task to Calendar?
 
@nicolai

The link you pointed me at imports ICS data. Do you have a link to this format, or did you suggest that I use non-file methods of the API? Is it the same fromat as the VCARD file format mentioned in: http://en.wikipedia.org/wiki/ICalendar ?

Regarding your programs scout and calendar-home-widget, are the sources available for reference?

Quote:

Originally Posted by nicolai (Post 913072)
The only way I know is using the calendar-backend API.
http://maemo.org/api_refs/5.0/5.0-fi...4d8d5b8d043570
But if you do so, you can just skip step 2 and 3 and use
the API for adding a new task.

Feel free to ask me if you have any questions. I used the calendar
API in my calendar-home-widget and my scout application.

Nicolai

Thanks a lot!

nicolai 2011-01-06 14:08

Re: Quick add new task to Calendar?
 
Quote:

Originally Posted by dov (Post 913224)
@nicolai

The link you pointed me at imports ICS data. Do you have a link to this format, or did you suggest that I use non-file methods of the API? Is it the same fromat as the VCARD file format mentioned in: http://en.wikipedia.org/wiki/ICalendar ?

I would suggest to use non-file methods and use the api to
create and insert new entries.
Quote:

Originally Posted by dov (Post 913224)
Regarding your programs scout and calendar-home-widget, are the sources available for reference?
Thanks a lot!

Yes -> maemo.org/packages

regards
Nicolai

Khertan 2011-01-06 14:20

Re: Quick add new task to Calendar?
 
http://wiki.forum.nokia.com/index.ph...lendar_example

Khertan 2011-01-06 14:37

Re: Quick add new task to Calendar?
 
And the bruteforce methode :)


Quote:

sqlite3 ~/.calendardb
Insert into Components (CalendarId, ComponentType, Flags, DateStart, DateEnd, Summary, Status, AllDay, Until, CreatedTime, ModifiedTime, Tzid, TzOffset) VALUES (1, 2, -1, 1294095600, -1, 'Test Insert Todo Non valide', 0, -1,0,1294087227,1294144124,'Europe/Paris',3600);
^D
But be careful with text encoding :)

dov 2011-01-06 15:03

Re: Quick add new task to Calendar?
 
@ Khertan

Now we're talking. :)

Does the calendar application poll its database or is it necessary to bump it somehow to make it reread the file when it changes after inserting changes through sqlite3?

Btw, I assume that you meant ~/.calendar/calendardb .

nicolai 2011-01-06 15:12

Re: Quick add new task to Calendar?
 
Quote:

Originally Posted by dov (Post 913284)
Does the calendar application poll its database or is it necessary to bump it somehow to make it reread the file when it changes after inserting changes through sqlite3?

The calendar application rereads the database everytime on startup,
but it is also listening for dbus-signals send by the calendar-backand.
Maybe you can send this signals manually.

nicolai

garrick 2011-01-09 20:04

Re: Quick add new task to Calendar?
 
Hi all.

I can confirm that writing entries directly into ~user/.calendar/calendardb works fine.

I have just bought an n900 and wanted to import the datebook from my old Palm Pilot into my new toy. I wrote a Perl script to parse dumps from the Palm and generate SQL statements to run against the database and now have a nicely populated calendar. I didn't need to restart or signal anything.

Thanks to Khertan for the suggestion. :)

Cheers.

Garrick.

kingdomnebaneba 2011-01-12 19:41

Re: Quick add new task to Calendar?
 
Quote:

Originally Posted by dov (Post 912955)
Is there any way of accessing the calendar from the command line? E.g. I would like to write add a calendar quick add widget that does the follows:

1. Pops up a small entry widget in which I would type something like:

Lunch with Ron next Wednesday at 12:00

2. A freetext format parses would convert this into an ical file.
3. The widget should somehow import the ical file into the calendar db.

The question is how to do step number 3?

Hi dov,

I've been looking for the same functionality for a long time, esp. setting an appointment+alarm from the command line. I don't know why it has to be so difficult!

Based on Khertan's response and this thread I was able to make a simple utility to add appointments from command line. Never tried to directly modify the sqlitedb.

The source and binary is on github. Binary works for me but otherwise the single file should be buildable if you have the dependencies. See main.cpp for arguments. e.g.

Code:

setcalendar --start "2011-01-11 10:20:00" --end "2011-01-11 10:20:00" --name "make phonecall" --desc "whatever description" --loc "some location" --alarm "5min"
It's a crappy program and will probably crash if you don't give all the arguments like above or if you use --name "make phonecall!" (because of exclamation mark), but good enough for me to call from org-mode :)

Forgot to add, by default it looks for a calendar named "Org-calendar". Didn't try to see what happens if you don't have it. You can change it though.

jackburton 2011-02-04 17:15

Re: Quick add new task to Calendar?
 
Quote:

Originally Posted by nicolai (Post 913159)
@jackburton

Yes, this should be easy.
Setting up the scratchbox development
envrionment is much more difficult than writing this app.

I don't know the qtmobility api for the calendar. But installing
QtCreator and making a simple commandline application should be
easy. The calendar-backend uses C++ as well, so it is easier to use
this from Qt code than for a gtk+ application for example.


nicolai

Hi Nicolai.

I have finally gotten around to trying out some C++ and Maemo Dev. My first task is to try to work with the calendar api has you have mentioned.

I downloaded the Nokia Qt SDK, which comes with Qt Creator and other things.

I loaded up the sample calendar application referenced in this thread by Khertan that is hosted at the Nokia dev forum.
http://wiki.forum.nokia.com/index.ph...lendar_example

I load the project into the Qt Creator, but it cannot resolve the headers for the calendar api.

This includes the CCalendar.h, CMulticalendar.h, CEvent.h, etc. files where the api is defined.

Does the Nokia Qt SDK come with the full dev API or am I going to have to use the Maemo SDK itself for this?

Thanks!

nicolai 2011-02-04 18:04

Re: Quick add new task to Calendar?
 
Hm, it does work for me.
I just downloaded the example from
http://wiki.forum.nokia.com/index.ph...lendar_example
and opened the .pro file with qt creator.
No compilation errors the project build fine.
If you made your own project, be sure you have this
line in your .pro file:
PKGCONFIG += calendar-backend

Nicolai

jackburton 2011-02-04 19:03

Re: Quick add new task to Calendar?
 
Thanks! Not sure why it wasn't working. A reboot seems to have fixed it.

jackburton 2011-03-08 00:36

Re: Quick add new task to Calendar?
 
Quote:

Originally Posted by nicolai (Post 936082)
If you made your own project, be sure you have this
line in your .pro file:
PKGCONFIG += calendar-backend

Nicolai

Hi Nicolai,

I finally got my app to work and build in scratchbox. The .deb also installs and works fine on my N900 itself.

I uploaded it to Extras-Devel, but the autobuilder fails saying
Code:

cd builddir && qmake-qt4 PREFIX=/usr ../maecaltool.pro
Package calendar-backend was not found in the pkg-config search path.
Perhaps you should add the directory containing `calendar-backend.pc'
to the PKG_CONFIG_PATH environment variable
No package 'calendar-backend' found

https://garage.maemo.org/builder/fre...log.FAILED.txt

Any thoughts?

Thanks so much.

jackburton 2011-03-08 01:43

Re: Quick add new task to Calendar?
 
Nevermind. I got it!

I added calendar-backend-dev to the debian control file under Build-Depends.

It now reads
Code:

Build-Depends: debhelper (>= 5), libqt4-dev, calendar-backend-dev
Finally. I have finished my first C++ app ever. Simple, but fun.


All times are GMT. The time now is 11:23.

vBulletin® Version 3.8.8