/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the toolbox library for writing desktop applications in C. It may be     *
 * used freely in the creation of programs for RISC OS.                     *
 *                                                                          *
 * Copyright  Acorn Computers Ltd, 1994                                    *
 *                                                                          *
 ***************************************************************************/



/*
 * Name        : fileinfo.h
 * Description : C veneers to the Methods provided by the fileinfo class
 */



#ifndef __fileinfo_h
#define __fileinfo_h


#ifndef __kernel_h
#include "kernel.h"
#endif

#ifndef __toolbox_h
#include "toolbox.h"
#endif

#ifndef __window_h
#include "window.h"
#endif

/****************************************************************************
 * FileInfo Templates                                                       *
 ****************************************************************************/

/*-- flags --*/

#define FileInfo_GenerateShowEvent    0x00000001
#define FileInfo_GenerateHideEvent    0x00000002


/*-- templates --*/

typedef struct
{
  int           flags;
  char          *title;
  int           max_title;
  int           modified;
  int           filetype;
  char          *filename;
  int           filesize;
  char          utc[5];
  char          *window;
} FileInfoTemplate;


/****************************************************************************
 * FileInfo SWI Calls                                                       *
 ****************************************************************************/

#define FileInfo_SWIChunkBase    0x82ac0
#define FileInfo_ObjectClass     FileInfo_SWIChunkBase
#define FileInfo_ClassSWI        (FileInfo_SWIChunkBase + 0)
#define FileInfo_PostFilter      (FileInfo_SWIChunkBase + 1)
#define FileInfo_PreFilter       (FileInfo_SWIChunkBase + 2)

/****************************************************************************
 * FileInfo SWI constants                                                   *
 ****************************************************************************/

#define FileInfo_Directory      0x1000
#define FileInfo_Application    0x2000

/****************************************************************************
 * FileInfo Methods                                                         *
 ****************************************************************************/

#define FileInfo_GetWindowId        0
#define FileInfo_SetModified        1
#define FileInfo_GetModified        2
#define FileInfo_SetFileType        3
#define FileInfo_GetFileType        4
#define FileInfo_SetFileName        5
#define FileInfo_GetFileName        6
#define FileInfo_SetFileSize        7
#define FileInfo_GetFileSize        8
#define FileInfo_SetDate            9
#define FileInfo_GetDate           10
#define FileInfo_SetTitle          11
#define FileInfo_GetTitle          12


/****************************************************************************
 * FileInfo Toolbox Events                                                  *
 ****************************************************************************/

#define FileInfo_AboutToBeShown     FileInfo_SWIChunkBase
#define FileInfo_DialogueCompleted  (FileInfo_SWIChunkBase + 1)

typedef struct
{
  ToolboxEventHeader hdr;
  int                show_type;
  union
  {
    TopLeft               pos;
    WindowShowObjectBlock full;
  } info;
} FileInfoAboutToBeShownEvent;


typedef struct
{
  ToolboxEventHeader hdr;
} FileInfoDialogueCompletedEvent;




/****************************************************************************
 * The following functions provide veneers to the methods that are          *
 * associated with this particular class.  Please read the User Interface   *
 * Toolbox manual for more detailed information on their functionality.     *
 ****************************************************************************/


#ifdef __cplusplus
  extern "C" {
#endif


/*
 * Name        : fileinfo_get_window_id
 * Description : Gets the underlyling window object ID for the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 * Out         : ObjectId *window
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_get_window_id ( unsigned int flags,
                                                 ObjectId fileinfo,
                                                 ObjectId *window
                                               );


/*
 * Name        : fileinfo_set_modified
 * Description : Set the modified flag for the specified fileinfo object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               int modified
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_set_modified ( unsigned int flags,
                                                ObjectId fileinfo,
                                                int modified
                                              );


/*
 * Name        : fileinfo_get_modified
 * Description : Gets the modified flag for the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 * Out         : int *modified
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_get_modified ( unsigned int flags,
                                                ObjectId fileinfo,
                                                int *modified
                                              );


/*
 * Name        : fileinfo_set_file_type
 * Description : Sets the file type for the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               int file_type
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_set_file_type ( unsigned int flags,
                                                 ObjectId fileinfo,
                                                 int file_type
                                               );


/*
 * Name        : fileinfo_get_file_type
 * Description : Gets the file type for the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 * Out         : int *file_type
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_get_file_type ( unsigned int flags,
                                                 ObjectId fileinfo,
                                                 int *file_type
                                               );


/*
 * Name        : fileinfo_set_file_name
 * Description : Sets the filename for the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               const char *file_name
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_set_file_name ( unsigned int flags,
                                                 ObjectId fileinfo,
                                                 const char *file_name
                                               );


/*
 * Name        : fileinfo_get_file_name
 * Description : Gets the filename from the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               char *buffer
 *               int buff_size
 * Out         : int *nbytes
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_get_file_name ( unsigned int flags,
                                                 ObjectId fileinfo,
                                                 char *buffer,
                                                 int buff_size,
                                                 int *nbytes
                                               );


/*
 * Name        : fileinfo_set_file_size
 * Description : Sets the file size for the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               int file_size
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_set_file_size ( unsigned int flags,
                                                 ObjectId fileinfo,
                                                 int file_size
                                               );


/*
 * Name        : fileinfo_get_file_size
 * Description : Gets the file size from the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 * Out         : int *file_size
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_get_file_size ( unsigned int flags,
                                                 ObjectId fileinfo,
                                                 int *file_size
                                               );


/*
 * Name        : fileinfo_set_date
 * Description : Set the date for the specified file info object (using a 5 byte UTC)
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               const int *UTC
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_set_date ( unsigned int flags,
                                            ObjectId fileinfo,
                                            const int *UTC
                                          );


/*
 * Name        : fileinfo_get_date
 * Description : Gets the date for the specified file info object (a 5 byte UTC)
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               int *UTC
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_get_date ( unsigned int flags,
                                            ObjectId fileinfo,
                                            int *UTC
                                          );


/*
 * Name        : fileinfo_set_title
 * Description : Sets the title for the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               const char *title
 * Out         : None
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_set_title ( unsigned int flags,
                                             ObjectId fileinfo,
                                             const char *title
                                           );


/*
 * Name        : fileinfo_get_title
 * Description : Gets the title from the specified file info object
 * In          : unsigned int flags
 *               ObjectId fileinfo
 *               char *buffer
 *               int buff_size
 * Out         : int *nbytes
 * Returns     : pointer to error block
 */

extern _kernel_oserror *fileinfo_get_title ( unsigned int flags,
                                             ObjectId fileinfo,
                                             char *buffer,
                                             int buff_size,
                                             int *nbytes
                                           );


#ifdef __cplusplus
  }
#endif



#endif
