Hi,
about two weeks ago I released the freeware TimeMachineScheduler, a little AppleScript Studio application
to change the backup interval of Time Machine in Leopard.
I’m just working on an improved new version, which should display the (mounted) status of the specified backup volume.
Of course it’s easy to poll the contents of /Volumes to detect if the volume is available.
But this way is quite silly, because it wastes too many resources.
The second method I’m considering is to install an own launchd daemon, which does the “watchdog” job.
Then I discovered that the system has a framework, which does exactly what I need providing a callback function if a volume appears or disappears.
Here is my question:
How can I use DiskArbitration framework to change a string in a text field and assign a certain image to an image view
depending on the status of the volume?
I found this Obj-C notification snippet in the net, but I don’t know how to integrate it in my AppleScript Studio project
[code]#include <stdio.h>
#include <DiskArbitration/DiskArbitration.h>
void hello_disk(DADiskRef disk, void *context)
{
printf(“disk %s appeared\n”, DADiskGetBSDName(disk));
}
void goodbye_disk(DADiskRef disk, void *context)
{
printf(“disk %s disappeared\n”, DADiskGetBSDName(disk));
}
main()
{
DASessionRef session;
session = DASessionCreate(kCFAllocatorDefault);
DARegisterDiskAppearedCallback(session, NULL, hello_disk, NULL);
DARegisterDiskDisappearedCallback(session, NULL, goodbye_disk, NULL);
DASessionScheduleWithRunLoop(session,
CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
CFRunLoopRun();
CFRelease(session);
exit(0);
}[/code]
Can anybody help?