
/*
 * xfpgmf.idl:
 *      SOM interface description file for the following
 *      XFolder classes (in this order):
 *          XFldProgramFile
 *      and the respective metaclasses.
 *
 *      Check the other files starting with xf* for the
 *      other XFolder classes.
 *
 *      XFldProgram is only responsible for changing the
 *      default icons of executable files.
 *
 *      Installation of this class is optional.
 *
 *      Copyright (C) 1997-99 Ulrich M”ller.
 *      This file is part of the XFolder source package.
 *      XFolder is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published
 *      by the Free Software Foundation, in version 2 as it comes in the
 *      "COPYING" file of the XFolder main distribution.
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 */

#include <wppgmf.idl>         // this is SOM for WPProgramFile

/*
   CLASS: XFldProgramFile

   CLASS HIERARCHY:

       SOMObject
         ÀÄÄ WPObject = XFldObject
               ÀÄÄ WPFileSystem
                     ÀÄÄ WPDataFile = XFldDataFile
                           ÀÄÄ WPProgramFile
                                 ÀÄÄ XFldProgramFile
*/

interface M_XFldProgramFile;            // Forward Reference to XFldProgramFile metaclass

interface XFldProgramFile : WPProgramFile
{

    /*
     * New instance methods for XFldProgramFile:
     *
     */

    ULONG xfQueryProgType();
        /*@@ xfQueryProgType:
           this returns the PROG_* flag signalling the executable
           type of the program file.
           Note that in addition to the PROG_* flags defined in
           PROGDETAILS, this may also return the following:
               PROG_XF_DLL     for dynamic link libraries
               PROG_XF_DRIVER  for virtual or physical device drivers;
                               most files ending in .SYS will be
                               recognized as DLL's though. */

#ifdef __SOMIDL__
  implementation {

    /*
     * Class Modifiers:
     *
     */

    externalprefix = xfpgmf_;
    externalstem = xfpgmf;
    majorversion = 1;
    minorversion = 1;
    filestem = xfpgmf;           //# specifies the filestem for sc-generated files
    metaclass = M_XFldProgramFile;
    dllname = "xfldr.dll";
    callstyle = oidl;           //# forget CORBA stuff (*ev and such)

     passthru C_h =
"// additional PROG_* flags for _ulAppType in XFldProgramFile instance data;"
"// these are only used by XFldProgramFile to determine the correct icons"
"#define PROG_XF_DLL        998 // dynamic link library"
"#define PROG_XF_DRIVER     999 // virtual or physical dev' drivers"
"";

    /*
     * Internal instance variables for XFldProgramFile:
     *
     */

    HPOINTER    hptrThis;        // set by wpSetIcon
    BOOL        fProgIconSet;    // TRUE if the current icon was set
                                 // using wpSetProgIcon
    ULONG       ulDosAppType;    // return value from DosQueryAppType
    ULONG       ulAppType;       // XFPGMF_* flag

    /*
     * WPProgramFile methods overridden by XFldProgramFile:
     *
     */

    wpInitData: override;
        /*@@ wpInitData:
           initialize instance data for a program file */

    wpObjectReady: override;
        /*@@ wpObjectReady:
           this is called upon an object when its creation
           or awakening is complete. This is the last method
           which gets called during instantiation of a
           WPS object.
           For XFldProgramFile, we need this notification to
           reset the icon data in our instance data, because
           otherwise we get wrong icons when copying program
           files. */

    wpQueryStyle: override;
        /*@@ wpQueryStyle:
           this instance method returns the object style flags. */

    wpSetIcon: override;
        /*@@ wpSetIcon:
           this instance method sets the visual icon for
           this program file. This is not stored in the
           persistent data (which is only done in
           wpSetIconData), but only changes the visual
           appearance of the object. */

    wpSetProgIcon: override;
        /*@@ wpSetProgIcon:
           this instance method sets the visual icon for
           this program file to the appropriate custom
           or default icon. We override this to change
           the default icons for program files using
           /ICONS/ICONS.DLL, if the global settings allow
           this.
           The following methods are called by the WPS when
           an icon is to be determined for a WPProgramFile:
           -- if the file has its own icon, e.g. from the
              .ICON EAs: only wpSetIcon, this method does
              _not_ get called then.
           -- otherwise (no .ICON):
              1)  wpQueryIcon, which calls
              2)  wpSetProgIcon, which per default calls
              3)  wpSetIcon
           We must return an individual icon in this method,
           so we load the icons from /ICONS/ICONS.DLL every
           time we arrive here.
           If we return a "global" icon handle which could
           have been loaded in wpclsInitData, unfortunately
           the WPS will destroy that "global" icon, ruining
           the icons of all other program files also. */

    wpQueryDefaultView: override;
        /*@@ wpQueryDefaultView:
           this returns the default view of an object, that
           is, which view is opened if the program file is
           double-clicked upon. This is also used to mark
           the default view in the "Open" context submenu.
           For WPProgramFile, the WPS always returns
           OPEN_RUNNING (0x04), which doesn't make sense
           for DLL's and drivers, which cannot be executed.
           We therefore return the value for "first associated
           program", which is 0x1000.
           Oh yes, as usual, this value is undocumented. ;-) */

    wpFilterPopupMenu: override;
        /*@@ wpFilterPopupMenu:
           remove the "Program" context menu entry for
           DLL's and drivers */

#ifdef __PRIVATE__

#endif

  }; // implementation
#endif /* __SOMIDL__ */
};

//#
//#
//# Now define Metaclass.
//# ---------------------
//#

interface M_XFldProgramFile : M_WPProgramFile
{

    /*
     * New class methods for M_XFldProgramFile:
     *
     */

#ifdef __SOMIDL__
  implementation {

    /*
     * Class Modifiers:
     *
     */

    externalprefix = xfpgmfM_;
    externalstem = xfpgmfM;
    functionprefix = xfpgmfM_;
    majorversion = 1;
    minorversion = 1;
    filestem = xfpgmf;           //# specifies the filestem for sc-generated files
    dllname = "xfldr.dll";
    callstyle = oidl;

    /*
     * Internal class variables for M_XFldProgramFile:
     *
     */

    /*
     * M_WPProgramFile methods overridden by M_XFldProgramFile:
     *
     */

    wpclsInitData: override;
        /*@@ wpclsInitData:
           we override this to initialize the path for the
           custom XFolder icons from the /ICONS directory. */

    wpclsQueryInstanceFilter: override;
        /*@@ wpclsQueryInstanceFilter:
           this class method determines which file-system objects
           will be instances of WPProgramFile/XFldProgramFile
           by specifying a file title filter. To avoid the annoying
           behavior of OS/2 Warp 4 that some DLL's are instances
           of WPProgramFile and some are not, we make all DLL's
           instances of WPProgramFile by specifying "*.DLL" too.
           This does not work using wpclsQueryInstance type,
           because the WPS seems to be using some default file
           type of "Executable", which is determined in some hidden
           place. */

  };
#endif /* __SOMIDL__ */
};


