MoreFinderEvents.h

/*
    File:       MoreFinderEvents.h
 
    Contains:   Functions to help you build and sending Apple events to the Finder.
 
    Written by: Andy Bachorski  
 
    Copyright:  Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                7/22/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
#ifndef MOREFINDEREVENTS
#define MOREFINDEREVENTS
 
//  System includes
#include <Aliases.h>
#include <AppleScript.h>
#include <Components.h>
#include <Folders.h>
#include <Icons.h>
#include <OSA.h>
 
 
 
enum {
    kFinderFileType         = 'FNDR',
    kFinderCreatorType      = 'MACS'
};
 
 
 
#ifdef __cplusplus
extern "C" {
#endif
 
pascal OSErr MFESetSelectionToNone( const AEIdleUPP idleProcUPP );
/*
    Sets the Finder's selection to nothing by sending it an empty list.
*/
 
// *****************************************************************************
 
pascal OSErr MFEChangeFolderViewNewSuite( const FSSpecPtr fssPtr,
                                          const long viewStyle,
                                          const AEIdleUPP idleProcUPP );
/*
    Given an FSSpec to a folder and a view constant value from the view by list
    defined in AERegistry.h, send an Apple event to the system 7.5.x Finder asking
    it to set the view of the folder's window to the specified style.
 
    Requires that the folder's window be open, otherwise an error is returned
    in the reply event.
    
    If your application will receive update event (i.e., it has windows), you must
    supply a more complete idle function than the simple idle function included
    with this library. It should pass any updated, activate, null, or osEvt events
    received to your application's do event routine.
*/
 
// *****************************************************************************
pascal OSErr MFEChangeFolderViewOldSuite( const FSSpecPtr fssPtr,
                                          const long viewStyle,
                                          const AEIdleUPP idleProcUPP );
/*
    Given an FSSpec to a folder and a view constant value from the view by list
    defined in AERegistry.h, send an Apple event to the system 7.1.1/7.1.2 Finder
    asking it to set the view of the folder's window to the specified style.
    
    If your application will receive update event (i.e., it has windows), you must
    supply a more complete idle function than the simple idle function included
    with this library. It should pass any updated, activate, null, or osEvt events
    received to your application's do event routine.
*/
 
// *****************************************************************************
 
pascal OSErr MFEChangeFolderView( const FSSpecPtr fssPtr,
                                  const long viewStyle,
                                  const AEIdleUPP idleProcUPP );
/*
    Given an FSSpec to a folder and a view constant value from the view by list
    defined in AERegistry.h, send an Apple event to the Finder asking it to set
    the view of the folder's window to the specified style.
 
    Requires that the folder's window be open, otherwise an error is returned
    in the reply event.
    
    If your application will receive update event (i.e., it has windows), you must
    supply a more complete idle function than the simple idle function included
    with this library. It should pass any updated, activate, null, or osEvt events
    received to your application's do event routine.
*/
 
// *****************************************************************************
 
pascal OSErr MFEAddCustomIconToItem( const FSSpecPtr fssPtr,
                                     const Handle theIconSuite,
                                     const IconSelectorValue iconSelector,
                                     const AEIdleUPP idleProcUPP );
 
/*  
    MFEAddCustomIconToItem adds a custom icon, via the Finder, to the item 
    specified by the fssPtr. 
    If an UPP to an idle function is provided in the idleProcUPP parameter,
    AESend is called with a send mode of kAEWaitReply. If idleProcUPP is set
    to nil, kAENoReply will be used for the send mode.
 
    fssPtr          input:  The item to add the custom icon to.
    theIconSuite    input:  The handle to the icon suite to install.
    iconSelector    input:  An IconSelectorValue specifying which icon types
                            to add.
    idleProcUPP     input:  A UniversalProcPtr for an idle function, or nil.
    
    Result Codes
    _____________
    noErr                       0       No error    
    paramErr                    -50     The value of target or alias parameter, or of both,
                                        is NIL or odd, or the alias record is corrupt
    eLenErr                     -92     Buffer too big to send  
    memFullErr                  -108    Not enough room in heap zone    
    procNotFound                -600    No eligible process with specified descriptor
    connectionInvalid           -609    Nonexistent signature or session ID 
    noUserInteractionAllowed    -610    Background application sends event
                                        requiring authentication    
    noPortErr                   -903    Client hasnÕt set 'SIZE' resource to indicate
                                        awareness of high-level events  
    destPortErr                 -906    Server hasnÕt set 'SIZE' resource to indicate
                                        awareness of high-level events, or else is not present  
    sessClosedErr               -917    The kAEDontReconnect flag in the sendMode parameter
                                        was set and the server quit, then restarted 
    errAECoercionFail           -1700   Data could not be coerced to the 
                                        requested Apple event data type 
    errAEWrongDataType          -1703   Wrong Apple event data type 
    errAENotAEDesc              -1704   Not a valid descriptor record   
    errAEBadListItem            -1705   Operation involving a list item failed  
    errAEEventNotHandled        -1708   Event wasnÕt handled by an Apple event handler  
    errAEUnknownSendMode        -1710   Invalid sending mode was passed 
    errAEWaitCanceled           -1711   User canceled out of wait loop for reply or receipt 
    errAETimeout                -1712   Apple event timed out   
    errAEUnknownAddressType     -1716   Unknown Apple event address type    
    Any error code returned by the event handler of the target application.
    ____________
*/
 
// *****************************************************************************
 
pascal OSErr MFEGetItemIcon( const FSSpecPtr fssPtr,
                             const AEIdleUPP idleProcUPP,
                                   Handle    *theIconSuite );
 
/*  
    MFEAddCustomIconToItem adds a custom icon, via the Finder, to the item 
    specified by the fssPtr. 
    If an UPP to an idle function is provided in the idleProcUPP parameter,
    AESend is called with a send mode of kAEWaitReply. If idleProcUPP is set
    to nil, kAENoReply will be used for the send mode.
 
    fssPtr          input:  The item to add the custom icon to.
    theIconSuite    input:  The handle to the icon suite to install.
    iconSelector    input:  An IconSelectorValue specifying which icon types
                            to add.
    idleProcUPP     input:  A UniversalProcPtr for an idle function, or nil.
    
    Result Codes
    _____________
    noErr                       0       No error    
    paramErr                    -50     The value of target or alias parameter, or of both,
                                        is NIL or odd, or the alias record is corrupt
    eLenErr                     -92     Buffer too big to send  
    memFullErr                  -108    Not enough room in heap zone    
    procNotFound                -600    No eligible process with specified descriptor
    connectionInvalid           -609    Nonexistent signature or session ID 
    noUserInteractionAllowed    -610    Background application sends event
                                        requiring authentication    
    noPortErr                   -903    Client hasnÕt set 'SIZE' resource to indicate
                                        awareness of high-level events  
    destPortErr                 -906    Server hasnÕt set 'SIZE' resource to indicate
                                        awareness of high-level events, or else is not present  
    sessClosedErr               -917    The kAEDontReconnect flag in the sendMode parameter
                                        was set and the server quit, then restarted 
    errAECoercionFail           -1700   Data could not be coerced to the 
                                        requested Apple event data type 
    errAEWrongDataType          -1703   Wrong Apple event data type 
    errAENotAEDesc              -1704   Not a valid descriptor record   
    errAEBadListItem            -1705   Operation involving a list item failed  
    errAEEventNotHandled        -1708   Event wasnÕt handled by an Apple event handler  
    errAEUnknownSendMode        -1710   Invalid sending mode was passed 
    errAEWaitCanceled           -1711   User canceled out of wait loop for reply or receipt 
    errAETimeout                -1712   Apple event timed out   
    errAEUnknownAddressType     -1716   Unknown Apple event address type    
    Any error code returned by the event handler of the target application.
    ____________
*/
 
// *****************************************************************************
pascal OSErr MFEGetEveryItemOnDesktop( const AEIdleUPP idleProcUPP,
                                             AEDescList *objectList );
/*  The MFEGetEveryItemOnDesktop function asks the Finder for a list of object
    descriptors for every item on the desktop (includes files, folders, and
    volumes).
    If an UPP to an idle function is provided in the idleProcUPP parameter,
    AESend is called with a send mode of kAEWaitReply. If idleProcUPP is set
    to nil, kAENoReply will be used for the send mode.
 
    idleProcUPP     input:  A UniversalProcPtr for an idle function, or nil.
    objectList      input:  A null AEDesc.
    iconSelector    output: A list containing object descriptors,
                            or a null AEDesc if an error is encountered.
    
    Result Codes
    _____________
    noErr                       0       No error
    paramErr                    -50     The value of target or alias parameter, or of both,
                                        is NIL or odd, or the alias record is corrupt
    eLenErr                     -92     Buffer too big to send
    memFullErr                  -108    Not enough room in heap zone
    procNotFound                -600    No eligible process with specified descriptor
    connectionInvalid           -609    Nonexistent signature or session ID
    noUserInteractionAllowed    -610    Background application sends event
                                        requiring authentication
    noPortErr                   -903    Client hasnÕt set 'SIZE' resource to indicate
                                        awareness of high-level events
    destPortErr                 -906    Server hasnÕt set 'SIZE' resource to indicate
                                        awareness of high-level events, or else is not present
    sessClosedErr               -917    The kAEDontReconnect flag in the sendMode parameter
                                        was set and the server quit, then restarted
    errAECoercionFail           -1700   Data could not be coerced to the
                                        requested Apple event data type 
    errAEWrongDataType          -1703   Wrong Apple event data type 
    errAENotAEDesc              -1704   Not a valid descriptor record
    errAEBadListItem            -1705   Operation involving a list item failed
    errAEEventNotHandled        -1708   Event wasnÕt handled by an Apple event handler
    errAEUnknownSendMode        -1710   Invalid sending mode was passed
    errAEWaitCanceled           -1711   User canceled out of wait loop for reply or receipt
    errAETimeout                -1712   Apple event timed out
    errAEUnknownAddressType     -1716   Unknown Apple event address type
    Any error code returned by the event handler of the target application.
    ____________
*/
 
// *****************************************************************************
 
pascal  OSErr   MFEUpdateItemFSS( const FSSpecPtr fssPtr );
/*
    Given an FSSpec to an item (file, folder, what ever), send an Apple event to
    the Finder asking it to update it's display of the item. For files, shows
    things like icon changes. For folders, shows things like new files that have
    been added.
*/
 
// *****************************************************************************
 
pascal  OSErr   MFEUpdateItemAlias( const AliasHandle aliasHandle );
/*
    Given an alias to an item (file, folder, what ever), send an Apple event to
    the Finder asking it to update it's display of the item. For files, shows
    things like icon changes. For folders, shows things like new files that have
    been added.
*/
 
// *****************************************************************************
 
pascal  OSErr MFEOpenFile( const AEIdleUPP idleProcUPP,
                                 FSSpec *fssPtr );
/*
    Given an FSSpec to a file, send an open document event to the
    Finder, passing the FSSpec as the direct parameter.
*/
 
#ifdef __cplusplus
}
#endif
 
#ifndef COMPILING_MORE_FINDER_EVENTS
#undef pascal
#endif
 
 
#endif//MOREFINDEREVENTS