New frontiers with Google Data APIs and Objective-C

Thursday, March 20, 2008 at 11:54 AM

I work on Mac client software because I enjoy the compile-link-run cycle that is central to crafting great experiences for users. But we live in a client-server world, and Google has world-class servers and web applications. That's why Google Data APIs are so cool if you develop Mac software: you don't need to build your own server farms and write your own web interfaces. Just let your software talk directly to Google's servers.

With the recent release of the Google Contacts Data API and the YouTube API for browsing and uploading, developers now have two more ways to reach users. Today's release of version 1.4 of the GData Objective-C Client Library adds support for these new APIs. Any Mac program that creates video can easily let users upload the video to a YouTube account. Mac software can also now enable users to access or edit their Google account contacts.

It's easy and natural for Cocoa programmers to use the library. This code snippet shows how get the names of all contacts in a user's Gmail account address book:

#import "GData/GDataContacts.h"

- (void)fetchContacts {
GDataServiceGoogleContact *service =
[[GDataServiceGoogleContact alloc] init];
[service setUserCredentialsWithUsername:@""
NSURL *feedURL =
[NSURL URLWithString:kGDataGoogleContactDefaultBaseFeed];

[service fetchContactFeedWithURL:feedURL

- (void)ticket:(GDataServiceTicket *)ticket
finishedWithContactFeed:(GDataFeedContact *)feed {

NSArray *names =
[feed valueForKeyPath:@"entries.title.stringValue"];

- (void)ticket:(GDataServiceTicket *)ticket
failedWithError:(NSError *)error {
NSLog(@"%@", error);

Uploading video takes just a bit more effort, because YouTube's API requires metadata describing the video along with the video data itself. The Objective-C GData Library includes sample code showing how to do these and other common tasks with the APIs.

And one more thing...

The source code for the GData Objective-C Client Library is now compatible with the iPhone SDK as well. Perhaps you want your iPhone software to send photos to a Picasa Web Albums account, or keep a journal of phone calls automatically in Blogger. Maybe your iPhone application accesses a database of information from a Google Spreadsheet or from Google Base. With the Google Data APIs Objective-C Client Library, creating software for these tasks is straightforward.

If you are writing iPhone software, just drag the "GData Sources" group folder from the GData project file into your iPhone project, and use the GData APIs as you would when writing a Mac application. The Objective-C Client Library is an open-source project, so you can find links to the sources and documentation on the project page.

Macworld: Another Look Inside

Thursday, March 13, 2008 at 9:22 AM

By Mark Sabec, Associate Product Marketing Manager

This year at Macworld we asked visitors to our booth to talk about what they do online and the Google products they use. The people who participated were anything but camera-shy, and they were all such good sports that we are happy to give them a little YouTube fame. Enjoy the video, and please stop by to see us at Macworld next year!

A File System Change Logger for Leopard

Tuesday, March 11, 2008 at 12:07 PM

When you use Mac OS X, you frequently access files and folders. But you might not realize how often you are creating and modifying files and folders. Developers, power users, and even curious regular users have long been interested in observing and understanding file system changes. This desire might be for security reasons, analyzing software, troubleshooting, or just out of plain old curiosity. In any case, being able to see how files are changing on your machine in real time is a powerful capability.

About three years ago, Apple released Mac OS X Tiger. One major feature of Tiger was the Spotlight search technology, and one of Spotlight's lowest-level building blocks is a kernel-level file system event notification mechanism called fsevents. Spotlight relies upon this mechanism to know about file system changes in real time. Soon after Tiger's release, I released fslogger, a program that subscribes to the fsevents mechanism and displays file system change notifications as they arrive from the kernel. fslogger went on to be quite a popular tool in some circles.

In Mac OS X Leopard, the fsevents mechanism is used for more than just Spotlight. Apple even added the FSEvents API as a way for your applications to ask for notification when contents of a directory hierarchy are modified. (Being directory-level, FSEvents API notifications aren't as granular as directly using fsevents, like fslogger does, but then direct use of fsevents isn't without caveats either.) All said, it can indeed be greatly useful during experimentation to be able to retrieve complete, unfiltered fsevents data from the kernel.

Here's an excerpt from fslogger's output.

$ sudo ./fslogger
=> received 90 bytes
# Event
pid = 13 (syslogd)
# Details
# type len data
FSE_ARG_STRING 24 string = /private/var/log/asl.db
FSE_ARG_DEV 4 dev = 0xe000002 (major 14, minor 2)
FSE_ARG_INO 4 ino = 4277280
FSE_ARG_MODE 4 mode = -rw------- (0x008180, vnode type VREG)
FSE_ARG_UID 4 uid = 0 (root)
FSE_ARG_GID 4 gid = 0 (wheel)
FSE_ARG_INT64 8 tstamp = 25511051709692
FSE_ARG_DONE (0xb33f)

I had to make some changes to fslogger to make it compatible with Leopard. Here's the new version that works with Leopard. Source code is also available.

Google Gadgets: Nine New Languages

Wednesday, March 05, 2008 at 10:53 AM

In November we announced Google Gadgets for the Mac. Today we're thrilled to follow up with its release in nine more languages. For the linguistically curious, we're now shipping in English (US and UK), French, Italian, German, Spanish, Dutch, Japanese, and Simplified and Traditional Chinese.

Google Gadgets for the Mac lets you choose from the many hundreds of gadgets that developers have created. As before, your Google Gadgets will run seamlessly in Dashboard.

Google Gadgets are available as a feature of Google Desktop. To get started with gadgets, head over to our Mac site and be sure to try out some of our other great Mac software! And if you want to create your own gadgets that run on Mac OS X and Windows, visit the Google Desktop Gadget API homepage to get started. We've added some new information to help you make sure that your new gadget runs fine on both platforms.

We're always working to improve our software, so if you've got any suggestions, drop them off in the Google Mac forum.