• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mount/Unmount events in Foundation tool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mount/Unmount events in Foundation tool


  • Subject: Re: Mount/Unmount events in Foundation tool
  • From: "R. Matthew Emerson" <email@hidden>
  • Date: Thu, 25 Jan 2007 21:03:31 -0500


On Jan 25, 2007, at 6:31 PM, James Bucanek wrote:

I have a Foundation tool (daemon) that I would very much like to get volume mount and unmount events. I can't get NSWorkspaceDidMountNotification because I can't use NSWorkspace.

Is there some other event I can subscribe to, or is there a way of subscribing to Carbon events for the same action from within a Cocoa app? I already checked NSDistributedNotificationCenter, and it doesn't fire any useful events on volume mount/unmount.

It would appear to be necessary to grovel through the DiskArbitration framework headers.


It looks pretty straightforward, though. I was able to throw together a trivial program in about 15 or 20 minutes from first looking at DiskArbitration.h. Maybe it will help get you going.


#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);
}

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Mount/Unmount events in Foundation tool
      • From: James Bucanek <email@hidden>
References: 
 >Mount/Unmount events in Foundation tool (From: James Bucanek <email@hidden>)

  • Prev by Date: CoreData and Undo menu item title?
  • Next by Date: No sure way to tell whether an array is mutable?
  • Previous by thread: Mount/Unmount events in Foundation tool
  • Next by thread: Re: Mount/Unmount events in Foundation tool
  • Index(es):
    • Date
    • Thread