OSX Calendar Database (iCal)

barring the use of MBS (or similar plugins), does anyone have any code to interface to the OSX calendar database?
I have AppleScript that does “some” things with Reminders, but can’t seem to manipulate appointments,

Here’s a project that wraps the now-deprecated CalendarStore API: https://github.com/sirg3/ALCalendarKit. Unfortunately its replacement framework, EventKit, is unavailable to 32-bit applications.

I think I just ran across that :slight_smile:

So this code works with 32bit, EventKit works for only 64bit?
If I were to create something based on your github code, do you figure it would be short-lived?

[quote=181014:@Dave S]I think I just ran across that :slight_smile:

So this code works with 32bit, EventKit works for only 64bit?
If I were to create something based on your github code, do you figure it would be short-lived?[/quote]

Both CalendarStore and EventKit are Apple frameworks. CalendarStore was introduced in 10.5 or so and deprecated around 10.8 in favor of EventKit. I don’t know how much maintenance the CalendarStore framework is receiving, if any.

The ALCalendarKit Xojo code is open source, but I don’t provide support for it and won’t be fixing any bugs in it. It’s open source just because it might be helpful to people. As for its longevity, it’s really just tied to how long the CalendarStore framework keeps working.

Ok… .need some additional insight here…

Why is it (or is it not) a good approach to manipulating the OSX Calendar by accessing the SQLite Cache database directly?

I have written simple queries that can read the data (and it matches the OSX Calendar App), and can update existing records and the OSX Calendar App reflects whatever I change. I haven’t yet attempted creating a new event yet…

AppleScript is slow and cumbersome
CalendarStore is deprecated
EventKit is not well documented (more so for iOS than for OSX)

Plus, those all require authorization from the user, the database doesn’t (not sure what would happen if I tried to send to MAS)

[quote=182268:@Dave S]Ok… .need some additional insight here…

Why is it (or is it not) a good approach to manipulating the OSX Calendar by accessing the SQLite Cache database directly?

I have written simple queries that can read the data (and it matches the OSX Calendar App), and can update existing records and the OSX Calendar App reflects whatever I change. I haven’t yet attempted creating a new event yet…

AppleScript is slow and cumbersome
CalendarStore is deprecated
EventKit is not well documented (more so for iOS than for OSX)

Plus, those all require authorization from the user, the database doesn’t (not sure what would happen if I tried to send to MAS)[/quote]

You would be rejected if you access the database directly.

The reason to use the published API is so that changes to the database format don’t break your program.

Not worried about MAS … and as I mentioned…documentation on the “accepted API” is quite scarce…

https://developer.apple.com/library/mac/documentation/EventKit/Reference/EventKitFrameworkRef/

It’s an undocumented, unsupported, fragile, and in general horrible way of accessing the information. It could change at any time, even between point releases of the OS.

This is a good thing. People don’t want applications accessing their personal information without at least being notified.

Use one of the available APIs. I’d recommend just grabbing ALCalendarKit and running with it – deprecated isn’t the same as removed.

While that is true… I just proved that that “personal information” CAN be accessed without the users knowledge (not all Desktop apps are deployed via the App Store)

The addressbook database should be accessible only by the frameworks. Everything else should be considered a security hole.

PS: I do have an EventKit plugin sitting here and waiting for 2 years now for 64-bit support…

Ok… I’m getting my head around the ALCalendarKit code, and am trying to fill in some of the “missing” bits

One for example is to get the COLOR of the calendar

here is how it returns the calendar title, but I can’t figure out how to handle NSColor/Color

  Declare Function CalCalendar_title Lib kObjCLib selector "title" (handle As Integer) As Integer
  Return ALPrivateCocoaUtils.NSStringToString(CalCalendar_title(handle))

and how to set the title

  Declare Sub CalCalendar_setTitle Lib kObjCLib selector "setTitle:" (handle As Integer, value As CFStringRef)
  CalCalendar_setTitle(handle, value)

ANSWER :

  Declare Function CalCalendar_color Lib kObjCLib selector "color" (handle As Integer) As Integer
  return ALPrivateCocoaUtils.NSColorToColor(CalCalendar_color(handle))