There are 4 ways, you can integrate with Daylite using the desktop app as the medium.
- AppleScript: You can wrap fscript inside an applescript.
- Direct Script: You can write fscript without requiring to wrap it in applescript
- Distributed Objects: You can use NSConnection and NSDistant object to talk to Daylite from your Cocoa App - although the status of Distributed Objects and Sandboxing is opaque at this point.
- Plugins: You can create an Cocoa plugin to add things like menus and tabs in the app itself.
You can interact with the Daylite Server directly using 2 methods.
- CalDAV: Daylite Server implement a CalDAV server and you can interact with it the same way iCal & Calendar do.
- CardDAV: Daylite Server also implements a CardDAV server and you can interact with it the same way Contacts and AddressBook do.
In order to take advantage of the API environments on the client side, you should be familiar with:
- Cocoa, especially foundation classes such as NSObject, NSString, NSNumber, NSDate, NSNull, NSArray, NSDictionary, NSData and their mutable counterparts.
- Design Patterns, especially MVC, KVC and Memory Management
Daylite Application Architecture
Daylite (the desktop app) is a full Cocoa application written in Objective-C. It uses many common patterns in Cocoa and especially MVC. For integration purposes, the most common used part of that pattern is the M (Model).
While it's backed by a SQL database, you never talk to the database directly. Instead, you talk to the ObjectContext and the objects it returns or creates for you.
The key aspects you need to remember are:
- All persistent data is created or fetched via the objectContext (an instance of DLPObjectContext).
- Any persistent object is a subclass of MCPObject.
- You interact with persistent objects using valueForKey: or setValue:forKey: in Objective-C or you do a set
: or in FScript (you can also use valueForKey: and setValue:forKey: in FScript). Updated objects are automatically saved.
- You fetch objects using BDQualifiers or locums
Daylite has a complex data structure comprising of a couple hundred database tables. We've exposed the most commonly used entities. Find the list here.
There is a set of objects that require special handing because they are used as options on objects (i.e. category or keywords). We keep these in the options cache and you access them using the optionsCache on the objectContext. You can find the list here.
The API exposes some classes and extensions (objective-c categories) that can be used in both the FScript and Objective-C environments. You can find them here.
The key scripting language for Daylite on the client side is FScript. FScript is a smalltalk like language implemented using the objective-c runtime giving you access to tons of Cocoa goodness. The flexibility it gives you is a bit of a double-edged sword in the sense that you can do great things but you can also really mess things up, so you have to be careful. You can execute FScript in the following places in Daylite:
- Direct Script - just called fscripts
- Distributed Objects
- PDF Reports
- Interactive Reports
We've assembled some commonly used code snippets. For some people, the best way to learn is through examples. The concepts discussed on this page can also be applied in the Objective-C environment albeit with syntax changes.