Professional Web Applications Themes

getting notified of volume eject - Mac Programming

Hi, I'm writing a program and I want to be notified if a volume is ejected/inserted. Sounds easy? Here are the details: - The program is written in C++ - I'm using the Qt framework from trolltech for crossplatform development. My code has almost no OS-specific parts. - This part would be OS-specific - I have _zero_ knowledge of the Carbon API (which I think I'll need here) - Qt has a hook for native Mac events: ----- bool QApplication::macEventFilter ( EventHandlerCallRef, EventRef ) [virtual] This virtual function is only implemented under Macintosh. If you create an application that inherits ...

  1. #1

    Default getting notified of volume eject

    Hi,

    I'm writing a program and I want to be notified if a volume is
    ejected/inserted.

    Sounds easy?

    Here are the details:

    - The program is written in C++
    - I'm using the Qt framework from trolltech for crossplatform
    development. My code has almost no OS-specific parts.
    - This part would be OS-specific
    - I have _zero_ knowledge of the Carbon API (which I think I'll need
    here)
    - Qt has a hook for native Mac events:

    -----
    bool QApplication::macEventFilter ( EventHandlerCallRef, EventRef )
    [virtual]
    This virtual function is only implemented under Macintosh. If you
    create an application that inherits QApplication and reimplement this
    function, you get direct access to all Carbon Events that are received
    from the MacOS.
    -----

    I think I need only a few lines of code here and a few #includes just
    to receive a notification if a volume is ejected or inserted but I'm
    lost where to start. Can anyone help me or lead me in the right
    direction?

    I havent' found anything via google/usenet or from trolltech.

    TIA,
    Herwig
    Herwig Guest

  2. #2

    Default Re: getting notified of volume eject

    In article <291120031921261456%de>,
    Herwig Henseler <de> wrote:
     

    There may be a problem here: by default, an application does not receive
    _any_ Carbon Event from Mac OS. Each control registers the events it is
    interested in.

    => You may have to register for two events in class kEventClassVolume:
    kEventVolumeMounted and kEventVolumeUnmounted
     

    Read the relevant sections of CarbonEventsCore.h (search for the
    declaration of InstallEventHandler) and CarbonEvents.h (search for
    kEventClassVolume). Both files are in

    /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framewor
    k/Headers/

    If InstallEventHandler returns eventHandlerAlreadyInstalledErr you don't
    need to call it. In that case, I would guess that QT calls
    macEventFilter for such events, allowing you to check for the relevant
    event using GetEventClass and GetEventKind (also explained in
    CarbonEventsCore.h)

    Reinder
    Reinder Guest

  3. #3

    Default Re: getting notified of volume eject

    Hi,

    In article <wxs.nl>, Reinder
    Verlinde <invalid> wrote: 

    Thanks for your answer. It was an important part that led me to a
    working solution (together wit a post in a german newsgroup and reading
    some sourcecode from Qt).

    Again, thanks for your help.

    Herwig
    Herwig Guest

Similar Threads

  1. Get notified on clicks
    By Eric in forum Mac Programming
    Replies: 9
    Last Post: November 2nd, 07:35 PM
  2. Replies: 0
    Last Post: September 8th, 04:05 PM
  3. Notified
    By Arizona 1991 in forum AIX
    Replies: 1
    Last Post: September 1st, 10:00 AM
  4. How to determine if a volume is a remote volume
    By Jhnny Fvrt (it means genetic antagonism) in forum Mac Programming
    Replies: 0
    Last Post: July 25th, 06:37 AM
  5. when volume changes a beep sounds at the new volume
    By Doug in forum Windows XP/2000/ME
    Replies: 0
    Last Post: July 12th, 08:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139