home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / FileMover / HF-OM1.DMS / in.adf / OpusSDK.lha / SDK / docs / hooks.doc < prev    next >
Encoding:
Text File  |  1997-05-09  |  20.5 KB  |  519 lines

  1. The DOpus Hooks are a series of hook functions which offer you direct
  2. access to some of the internals of Directory Opus. Using these functions
  3. offers significant speed advantages and is considerably more convenient
  4. than using ARexx.
  5.  
  6. To get a pointer to the hooks, you need to initialise a DOpusCallbackInfo
  7. structure and send it to the Opus main process. Set the dc_Count field to
  8. the number of hooks you want (the best thing is to set it to DOPUS_HOOK_COUNT).
  9.  
  10.     DOpusCallbackInfo info;
  11.     short num;
  12.  
  13.     info.dc_Count=DOPUS_HOOK_COUNT;
  14.     num=IPC_Command(opus_main_ipc,HOOKCMD_GET_CALLBACKS,0,&info,0,REPLY_NO_PORT);
  15.  
  16. The return value from this message will be the number of hooks copied into your
  17. structure. If this is 0, you will know this is an older version of Opus that does
  18. not support hooks (this is a cheap way to do a version check).
  19.  
  20. More hook functions will be added in the future, and this structure will grow
  21. appropriately. You should never attempt to use a hook without checking to see
  22. if its pointer is valid.
  23.  
  24. Once you have an initialised structure you can call the hook functions
  25. directly (ie no message passing).
  26.  
  27.  
  28.  
  29.     APTR dc_CreateFileEntry(   ULONG lister,
  30.                                struct FileInfoBlock *fib,
  31.                                BPTR lock);
  32.  
  33.     This function creates a file entry, ready to be added to a lister. Pass it
  34.     the lister handle and a filled out FileInfoBlock structure. The 'lock'
  35.     argument is optional; if not set to NULL it should be a lock on the
  36.     directory containing the FileInfoBlock (and is used for resolving links).
  37.     The information in the FileInfoBlock structure is copied and can be
  38.     disposed of when this function returns. The FileInfoBlock structure does
  39.     not need to be longword-aligned.
  40.  
  41.  
  42.     void dc_FileSet(   ULONG lister,
  43.                        APTR entry,
  44.                        struct TagItem *tags);
  45.  
  46.     This command allows you to add or modify entry information. It is mainly
  47.     used BEFORE an entry has been added to a list but can be used after. Pass
  48.     an array of tags with the item ID in ti_Tag and the new value in ti_Data.
  49.     Valid tags for this function are:
  50.  
  51.         HFFS_NAME       - The name of the entry (char *)
  52.         HFFS_SIZE       - The size of the entry (ULONG)
  53.         HFFS_PROTECTION - Protection flags      (ULONG)
  54.         HFFS_DATE       - Entry date            (struct Datestamp *)
  55.         HFFS_COMMENT    - Comment               (char *)
  56.         HFFS_SELECTED   - Selected state        (BOOL)
  57.         HFFS_LINK       - Indicates a 'link'    (BOOL)
  58.         HFFS_COLOUR     - Entry colour          (1 = device colour,
  59.                                                  2 = assign colour)
  60.         HFFS_USERDATA   - User-defined data     (ULONG)
  61.         HFFS_FILETYPE   - Filetype description  (char *)
  62.         HFFS_DISPLAY    - Custom display string (char *)
  63.         HFFS_VERSION    - Version Information   (VersionInfo *)
  64.         HFFS_MENU       - Custom menus          (struct List *)
  65.  
  66.     A note about custom menus: To add custom menus to the pop-up menu for an
  67.     entry, use the HFFS_MENU tag. ti_Data should point to a struct List *, the
  68.     ln_Name field of the nodes should contain the names of the menu items.
  69.     Note that the names of menu items are NOT copied (to conserve memory) and
  70.     so must remain valid while the entry is in use.
  71.  
  72.  
  73.     void dc_SortFileList(   ULONG lister,
  74.                             struct List *list,
  75.                             long file_count,
  76.                             long dir_count);
  77.  
  78.     This function allows you to add and quicksort a list of entries at once.
  79.     It is much faster than multiple dc_AddFileEntry() commands. To use it, you
  80.     should add the return values from your calls to dc_CreateFileEntry() to an
  81.     initialised exec List structure. Then, pass the list structure along with a
  82.     count of the number of files and number of directories in the list to this
  83.     function. Eg,
  84.  
  85.         struct List file_list;
  86.         long file_count=0,dir_count=0;
  87.         DOpusCallbackInfo info;
  88.  
  89.         NewList(&file_list);
  90.  
  91.         while (entries_to_add)
  92.         {
  93.             entry=info.dc_CreateFileEntry(lister,fib,0);
  94.             AddTail(&file_list,(struct Node *)entry);
  95.  
  96.             if (fib->fib_DirEntryType<0) ++file_count;
  97.             else ++dir_count;
  98.         }
  99.  
  100.         info.dc_SortFileList(lister,&list,file_count,dir_count);
  101.  
  102.  
  103.  
  104.     APTR dc_AddFileEntry(    ULONG lister,
  105.                              APTR entry,
  106.                              BOOL sort);
  107.  
  108.     This function adds a file entry to a lister. Pass it the lister handle
  109.     and the return value of the dc_CreateFileEntry() command. If sort==TRUE,
  110.     the entry will be added using the lister's current sort method, otherwise
  111.     it will just be added to the end of the list. If you have a whole directory
  112.     to add, dc_SortFileList() is quicker. However, using dc_AddFileEntry() with
  113.     sort==FALSE and then calling dc_ResortLister() isn't that much slower.
  114.  
  115.  
  116.     void dc_ResortLister(    ULONG lister,
  117.                              ListFormat *format);
  118.  
  119.     This hook allows you to resort the lister, optionally with a new sort
  120.     format. If you pass NULL for the format parameter, the list will be
  121.     resorted using the current settings. Use this hook if you have added
  122.     multiple files with the dc_AddFileEntry() hook and now wish to sort them
  123.     (a quicksort will be used).
  124.  
  125.  
  126.     void dc_RefreshLister(    ULONG lister,
  127.                              ULONG flags);
  128.  
  129.     Allows you to refresh a lister; you should call it after adding entries
  130.     with the above commands. The HOOKREFRESH_DATE flag indicates that the
  131.     lister should update its datestamp (to prevent it being automatically
  132.     re-read). The HOOKREFRESH_FULL flag causes a total refresh of the lister,
  133.     including the title.
  134.  
  135.  
  136.     void dc_LockFileList(    ULONG lister,
  137.                              BOOL exclusive)
  138.  
  139.     You should use this to protect the file list from changes by other tasks.
  140.     Set 'exclusive' to TRUE if you are going to be adding or removing entries
  141.     from the list; set to FALSE if you are just looking at list entries.
  142.  
  143.  
  144.     void dc_UnlockFileList(   ULONG lister)
  145.  
  146.     If you have locked the list with dc_LockFileList() you MUST call this
  147.     function when you have finished.
  148.  
  149.  
  150.     APTR dc_FindFileEntry(   ULONG lister,
  151.                              char *name)
  152.  
  153.     Searches the file list for a named entry, and returns a handle to it if
  154.     found. This handle can then be used with dc_FileSet() and dc_FileQuery(),
  155.     or dc_RemoveFileEntry().
  156.  
  157.  
  158.     void dc_RemoveFileEntry(   ULONG lister,
  159.                                APTR entry)
  160.  
  161.     Removed an entry from a list and frees the memory associated with it. The
  162.     lister display is not updated automatically.
  163.  
  164.  
  165.     BOOL dc_FileQuery(   ULONG lister,
  166.                          APTR entry,
  167.                          struct TagItem *tags)
  168.  
  169.     Lets you query a file entry. This function uses the same tags as the
  170.     dc_FileSet() function does. The ti_Data field of each TagItem should point
  171.     to the appropriate memory area to store the result. That is,
  172.  
  173.         HFFS_NAME
  174.         HFFS_COMMENT
  175.         HFFS_FILETYPE
  176.         HFFS_DIPSLAY
  177.  
  178.             For the string items, ti_Data MUST point to a buffer big enough to
  179.             receive the string (256 characters is safe in most cases).
  180.  
  181.         HFFS_SIZE
  182.         HFFS_PROTECTION
  183.         HFFS_SELECTED
  184.         HFFS_LINK
  185.         HFFS_USERDATA
  186.  
  187.             For these items, ti_Data must point to a ULONG, in which the value
  188.             will be stored.
  189.  
  190.         HFFS_DATE
  191.  
  192.             ti_Data must point to a (struct DateStamp), which will be used to
  193.             store the date.
  194.  
  195.         HFFS_VERSION
  196.  
  197.             This tag is slightly different. ti_Data must point to a
  198.             VersionInfo * (ie a 4-byte pointer, NOT an instance of a
  199.             VersionInfo structure itself). DOpus will allocate a VersionInfo
  200.             structure and store a pointer to it in the address you provide in
  201.             ti_Data. When you have finished with the version information, you
  202.             must call FreeVec() on the memory.
  203.  
  204.  
  205.     void dc_ShowHelp(    char *file_name,
  206.                          char *node_name)
  207.  
  208.     Calls the internal Opus help system to display help (via AmigaGuide) on the
  209.     given topic. If file_name is specified, it must be the name of an AmigaGuide
  210.     help file in the dopus5:Help/ directory. If NULL is given for the file name,
  211.     the default Opus help file will be used. node_name is the name within the
  212.     guide of the node to display.
  213.  
  214.  
  215.     *** The following hooks are a new interface to the old module callback
  216.         system, and take and return similar parameters. The 'handle' parameter
  217.         in any functions that take it is passed to the Module_Entry() function
  218.         in your module ***
  219.  
  220.     APTR dc_ConvertEntry(    APTR entry)
  221.  
  222.     Takes an entry as returned by the dc_GetEntry() function and converts it to
  223.     an entry you can use with the dc_FileSet()/dc_FileQuery()/etc.. functions.
  224.     You MUST use this as the two entry types are not compatible with each other.
  225.     Use the return value from this as the entry pointer to pass (the old entry
  226.     pointer is still valid too).
  227.  
  228.  
  229.     ULONG dc_GetLister(   APTR path)
  230.  
  231.     Takes a path as returned by the dc_GetSource(), etc functions, and converts
  232.     it to a lister handle that you can use with the dc_AddFileEntry() and similar
  233.     functions.
  234.  
  235.  
  236.     APTR dc_GetSource(    APTR handle,
  237.                           char *path)
  238.  
  239.     Copies the current source path into the supplied buffer (must be at least
  240.     512 bytes in size). The return value is a pointer to the path handle; you
  241.     can use this with other hook functions.
  242.     This hook is the same as the old EXTCMD_GET_SOURCE callback function.
  243.  
  244.  
  245.     APTR dc_EndSource(    APTR handle,
  246.                           long ununsed)
  247.  
  248.     Call this hook if you are aborting early and do not wish to process
  249.     further source paths. Set the 'unused' parameter to 0.
  250.     This hook is the same as the old EXTCMD_END_SOURCE callback function.
  251.  
  252.  
  253.     APTR dc_NextSource(    APTR handle,
  254.                            char *path)
  255.  
  256.     Call this hook when you have finished with the first source path and want
  257.     to move onto the next one. The return value is the new path handle, or
  258.     NULL if there are no more source paths.
  259.     This hook is the same as the old EXTCMD_NEXT_SOURCE callback function.
  260.  
  261.  
  262.     void dc_UnlockSource(    APTR handle)
  263.  
  264.     When your module command is called, any source listers are locked
  265.     automatically. Call this command when you want to unlock them (they
  266.     are unlocked automatically when your module returns).
  267.     This hook is the same as the old EXTCMD_UNLOCK_SOURCE callback function.
  268.  
  269.  
  270.     void dc_GetDest(    APTR handle,
  271.                         char *path)
  272.  
  273.     Copies the current destination path into the supplied buffer (must be at least
  274.     512 bytes in size). The return value is a pointer to the path handle; you
  275.     can use this with other hook functions. Call this command repeatedly to move
  276.     through the destination paths. When all the destination paths have been used,
  277.     this command will return NULL. If you call this command again, it will start
  278.     again with the first destination path.
  279.     This hook is the same as the old EXTCMD_GET_DEST callback function.
  280.     
  281.  
  282.     void dc_EndDest(    APTR handle,
  283.                         long continue)
  284.  
  285.     You must call this command when you have finished with one destination path,
  286.     prior to calling dc_GetDest().
  287.     This hook is the same as the old EXTCMD_END_DEST callback function.
  288.  
  289.  
  290.     APTR dc_GetEntry(    APTR handle)
  291.  
  292.     This returns a pointer to the next entry in the current source path. Use
  293.     the dc_ExamineEntry() hook function to get information about the entry.
  294.     This hook is the same as the old EXTCMD_GET_ENTRY callback function.
  295.  
  296.  
  297.     ULONG dc_ExamineEntry(    APTR entry,
  298.                               long type)
  299.  
  300.     Returns information about an entry handle retrieved with dc_GetEntry().
  301.     'type' can be either EE_NAME, which returns a pointer to the name,
  302.     or EE_TYPE, which returns the type of the entry.
  303.  
  304.  
  305.     void dc_EndEntry(    APTR handle,
  306.                          APTR entry,
  307.                          BOOL deselect)
  308.  
  309.     Call this hook when you have finished working with one entry and want
  310.     to move on to the next. 'entry' is the pointer that was returned by
  311.     dc_GetEntry(). Set 'deselect' to TRUE to have the entry deselected
  312.     in the lister.
  313.     This hook is the same as the old EXTCMD_NEXT_ENTRY callback function.
  314.  
  315.  
  316.     void dc_ReloadEntry(    APTR handle,
  317.                             APTR entry)
  318.  
  319.     This function marks the specified entry to be reloaded. When the
  320.     function finishes, the entry will be reloaded to update any changes
  321.     that your module might have made to it.
  322.     This hook is the same as the old EXTCMD_RELOAD_ENTRY callback function.
  323.  
  324.  
  325.     void dc_RemoveEntry(    APTR entry)
  326.  
  327.     This function marks the specified entry to be removed. When the
  328.     function finishes, the entry will be removed from the lister it is
  329.     in.
  330.     This hook is the same as the old EXTCMD_REMOVE_ENTRY callback function.
  331.  
  332.                             
  333.     long dc_EntryCount(    APTR handle)
  334.  
  335.     Returns the number of selected entries for the function.
  336.     This hook is the same as the old EXTCMD_ENTRY_COUNT callback function.
  337.  
  338.  
  339.     long dc_AddFile(    APTR handle,
  340.                         char *path,
  341.                         struct FileInfoBlock *fib,
  342.                         APTR lister)
  343.  
  344.     Allows you to add a file or directory to a lister. The 'path' field
  345.     points to the full path of the file to add. 'fib' is an initialised
  346.     FileInfoBlock which is used to create the file entry. The 'lister'
  347.     pointer is obtained via a call to the dc_GetLister() function.
  348.     The display is not updated until you call dc_DoChanges(), or your
  349.     function returns.
  350.     This hook is the same as the old EXTCMD_ADD_FILE callback function.
  351.  
  352.  
  353.     void dc_DelFile(    APTR handle,
  354.                         char *path,
  355.                         char *name,
  356.                         APTR lister)
  357.  
  358.     This removes the specified file from any listers it is currently
  359.     shown in. The file itself is not deleted, only the display of it in
  360.     the lister. The display is not updated until you call dc_DoChanges(),
  361.     or your function returns.
  362.     This hook is the same as the old EXTCMD_DEL_FILE callback function.
  363.  
  364.  
  365.     void dc_LoadFile(    APTR handle,
  366.                          char *path,
  367.                          char *name,
  368.                          long flags,
  369.                          BOOL reload)
  370.  
  371.     This function is similar to dc_AddFile() except that it takes a
  372.     filename and path and supplies the FileInfoBlock structure itself.
  373.     'path' is the full path of the file and 'name' is the file name. If
  374.     'flags' is set to LFF_ICON, the icon of the supplied file will be
  375.     loaded instead of the file itself. If 'reload' is set to TRUE, an
  376.     existing file will be reloaded (ie the old entry in the lister
  377.     will be removed).
  378.     This hook is the same as the old EXTCMD_LOAD_FILE callback function.
  379.  
  380.  
  381.     void dc_DoChanges(    APTR handle)
  382.  
  383.     This command causes any changes made to listers by the dc_AddFile(),
  384.     dc_DelFile() and dc_LoadFile() commands to be displayed. If your
  385.     function returns without calling this command, the changes are
  386.     displayed automatically.
  387.     This hook is the same as the old EXTCMD_DO_CHANGES callback function.
  388.  
  389.  
  390.     BOOL dc_CheckAbort(    APTR handle)
  391.  
  392.     This hook returns TRUE if your function has been aborted by the user.
  393.     This could have occurred because the user pressed escape or clicked the
  394.     close button on a lister, clicked the Abort button in the progress
  395.     window or quit the program.
  396.     This hook is the same as the old EXTCMD_CHECK_ABORT callback function.
  397.  
  398.  
  399.     struct Window *dc_GetWindow(    APTR path)
  400.  
  401.     This function returns a pointer to the Window for the lister specified
  402.     by the supplied path handle (as returned by dc_GetSource(), etc). This
  403.     is useful if you want to open a requester over a lister window.
  404.     This hook is the same as the old EXTCMD_GET_WINDOW callback function.
  405.  
  406.  
  407.     struct MsgPort *dc_GetPort(    char *name)
  408.  
  409.     This function copies the name of the Opus ARexx port into the supplied
  410.     buffer (max 40 bytes), and returns a pointer to the message port.
  411.     This hook is the same as the old EXTCMD_GET_PORT callback function.
  412.  
  413.  
  414.     struct Screen *dc_GetScreen(    char *name)
  415.  
  416.     This function copies the name of the Opus public screen into the
  417.     supplied buffer (max 40 bytes), and returns a pointer to the screen.
  418.     This hook is the same as the old EXTCMD_GET_SCREEN callback function.
  419.  
  420.  
  421.     long dc_ReplaceReq(    struct Window *window,
  422.                            struct Screen *screen,
  423.                            IPCData *ipc,
  424.                            struct FileInfoBlock *file1,
  425.                            struct FileInfoBlock *file2,
  426.                            long flags)
  427.  
  428.     This function shows a 'file exists - replace?' requester, comparing
  429.     the two supplied files. Set either the value of 'window' or 'screen'
  430.     to specify where the requester is to open. 'ipc' is your IPC pointer.
  431.     'file1' and 'file2' are the two files. 'flags' should be set to 0
  432.     for now.
  433.  
  434.     The result of this function is REPLACE_ABORT for abort, REPLACE_LEAVE
  435.     for skip or REPLACE_REPLACE for replace. If the REPLACEF_ALL flag is
  436.     set in the result, it indicates an 'All' gagdet (ie Skip All, Replace
  437.     All).
  438.  
  439.     This hook is the same as the old EXTCMD_REPLACE_REQ callback function.
  440.  
  441.  
  442.     DOpusScreenData *dc_GetScreenData(void)
  443.  
  444.     Returns a structure with useful information about the Opus screen. This
  445.     structure is READ_ONLY! You must call dc_FreeScreenData() to free the
  446.     structure when you have finished with it.
  447.     This hook is the same as the old EXTCMD_GET_SCREENDATA callback function.
  448.  
  449.  
  450.     void dc_FreeScreenData(    DOpusScreenData *data)
  451.  
  452.     Frees the result of a dc_GetScreenData() function call.
  453.     This hook is the same as the old EXTCMD_FREE_SCREENDATA callback function.
  454.  
  455.  
  456.     void dc_OpenProgress(    APTR path,
  457.                              char *operation,
  458.                              long total)
  459.  
  460.     This opens the lister progress indicator for the specified path handle.
  461.     'operation' is the operation string displayed in the title bar, and
  462.     'total' is the total number of files to process.
  463.     This hook is the same as the old EXTCMD_OPEN_PROGRESS callback function.
  464.  
  465.  
  466.     void dc_UpdateProgress(    APTR path,
  467.                                char *name,
  468.                                long count)
  469.  
  470.     This updates an open progress indicator. 'path' is the path handle that
  471.     you previously opened a progress indicator for. 'name' is the new
  472.     filename to display, and 'count' is the new count of files processed.
  473.     This hook is the same as the old EXTCMD_UPDATE_PROGRESS callback function.
  474.  
  475.  
  476.     void dc_CloseProgress(    APTR path)
  477.  
  478.     Closes the progress indicator for the specified path.
  479.     This hook is the same as the old EXTCMD_CLOSE_PROGRESS callback function.
  480.  
  481.  
  482.     long dc_SendCommand(    APTR handle,
  483.                             char *command,
  484.                             char **result,
  485.                             ULONG flags)
  486.  
  487.     This command sends an ARexx instruction directly to the Opus ARexx port.
  488.     If you want a result string returned, pass a pointer to a char * in
  489.     'result', and set 'flags' to COMMANDF_RESULT. If a string is returned,
  490.     your supplied pointer will have the address of the string stored in it.
  491.     You MUST call FreeVec() on this pointer when you have finished with the
  492.     result. This function returns the RC result of the call.
  493.     This hook is the same as the old EXTCMD_SEND_COMMAND callback function.
  494.  
  495.  
  496.     void dc_CheckDesktop(   char *path)
  497.  
  498.     This command is used when your program has just copied one or more files
  499.     to a directory. You pass it the destination path that you copied the
  500.     files to, and DOpus compares this path with the location of the Desktop
  501.     folder. If they are the same, DOpus will then scan the Desktop folder and
  502.     update the icons on-screen if necessary.
  503.     This slightly clumsy method has been used because of problems in the
  504.     system notification routines.
  505.  
  506.  
  507.     short dc_GetDesktop(    char *buffer);
  508.  
  509.     This command lets you get the path of the DOpus Desktop Folder. The
  510.     buffer you supply MUST be at least 256 bytes. The current Desktop Folder
  511.     path will be copied to this buffer. The return value of this hook
  512.     indicates the user's desktop settings:
  513.  
  514.                     0    desktop popup disabled
  515.                     1    no default action
  516.                     2    default : create leftout
  517.                     3    default : move
  518.                     4    default : copy
  519.