/*
 * ROX-Filer, filer for the ROX desktop project
 * By Thomas Leonard, <tal197@users.sourceforge.net>.
 */

/* global.h is included by most of the other source files, just after
 * including config.h and the system header files, but before any other
 * ROX-Filer header files.
 */

#include <glib.h>

//#define UNIT_TESTS

/* We put all the global typedefs here to avoid creating dependencies
 * between header files.
 */

/* Each filer window has one of these all to itself */
typedef struct _FilerWindow FilerWindow;

/* There is one Directory object per cached disk directory inode number.
 * Multiple FilerWindows may share a single Directory. Directories
 * are cached, so a Directory may exist without any filer windows
 * referencing it at all.
 */
typedef struct _Directory Directory;

/* Each item in a directory has a DirItem. This contains information from
 * stat()ing the file, plus a few other bits. There may be several of these
 * for a single file, if it appears (hard-linked) in several directories.
 */
typedef struct _DirItem DirItem;

/* Widgets which can display directories implement the View interface.
 * This should be used in preference to the old collection interface because
 * it isn't specific to a particular type of display.
 */
typedef struct _ViewIface ViewIface;

/* A ViewIter specifies a single item in a View, rather like an index.
 * They can be used to iterate over all the items in a View, and remain
 * valid until the View is changed. If allocated on the stack, they do not need
 * to be freed.
 */
typedef struct _ViewIter ViewIter;

/* This contains the pixbufs for an image, in various sizes.
 * Despite the name, it now contains neither pixmaps nor masks!
 */
typedef struct _MaskedPixmap MaskedPixmap;

/* Each MIME type (eg 'text/plain') has one of these. It contains
 * a link to the image and the type's name (used so that the image can
 * be refreshed, among other things).
 */
typedef struct _MIME_type MIME_type;

/* Icon is an abstract base class for icons.
 * It contains the name and path of the icon, as well as its DirItem.
 */
typedef struct _Icon Icon;

/* Each option has a static Option structure. This is initialised by
 * calling option_add_int() or similar. See options.c for details.
 * This structure is read-only.
 */
typedef struct _Option Option;

/* A filesystem cache provides a quick and easy way to load files.
 * When a cache is created, functions to load and update files are
 * registered to it. Requesting an object from the cache will load
 * or update it as needed, or return the cached copy if the current
 * version of the file is already cached.
 * Caches are used to access directories, images and XML files.
 */
typedef struct _GFSCache GFSCache;

/* Each cached XML file is represented by one of these */
typedef struct _XMLwrapper XMLwrapper;

/* A filename where " " has been replaced by "%20", etc.
 * This is really just a string, but we try to catch type errors.
 */
typedef struct _EscapedPath EscapedPath;

/* The minibuffer is a text field which appears at the bottom of
 * a filer window. It has various modes of operation:
 */
typedef enum {
	MINI_NONE,
	MINI_PATH,
	MINI_SHELL,
	MINI_SELECT_IF,
	MINI_FILTER,
	MINI_TEMP_FILTER,
	MINI_SELECT_BY_NAME,
	MINI_REG_SELECT,
} MiniType;

/* The next three correspond to the styles on the Display submenu: */

typedef enum {		/* Values used in options, must start at 0 */
	LARGE_ICONS	= 0,
	SMALL_ICONS	= 1,
	HUGE_ICONS	= 2,
	AUTO_SIZE_ICONS	= 3,
	UNKNOWN_STYLE
} DisplayStyle;

typedef enum {		/* Values used in options, must start at 0 */
	DETAILS_NONE		= 0,
	DETAILS_SIZE		= 2,
	DETAILS_PERMISSIONS	= 3,
	DETAILS_TYPE		= 4,
	DETAILS_TIMES		= 5,
	DETAILS_UNKNOWN		= -1,
} DetailsType;

typedef enum {		/* Values used in options */
	SORT_NAME = 0,
	SORT_TYPE = 1,
	SORT_DATEM = 2,
	SORT_SIZE = 3,
	SORT_OWNER = 4,
	SORT_GROUP = 5,
	SORT_DATEC = 6,
	SORT_DATEA = 7,
	SORT_PERM = 8,
	SORT_UNKNOWN = -1,
} SortType;

/* Each DirItem has a base type with indicates what kind of object it is.
 * If the base_type is TYPE_FILE, then the MIME type field gives the exact
 * type.
 */
enum
{
	/* Base types - this also determines the sort order */
	TYPE_ERROR,
	TYPE_UNKNOWN,		/* Not scanned yet */
	TYPE_DIRECTORY,
	TYPE_PIPE,
	TYPE_SOCKET,
	TYPE_FILE,
	TYPE_CHAR_DEVICE,
	TYPE_BLOCK_DEVICE,
	TYPE_DOOR,

	/* These are purely for colour allocation */
	TYPE_EXEC,
};

typedef enum
{
	OPEN_SHIFT        = 0x01, /* Do ShiftOpen */
	OPEN_SAME_WINDOW  = 0x02, /* Directories open in same window */
	OPEN_CLOSE_WINDOW = 0x04, /* local use, Opening files closes the window */
	OPEN_FROM_MINI    = 0x08, /* local use, Non-dir => close minibuffer */
	OPEN_LINK_WINDOW  = 0x10,
} OpenFlags;

/* The namespaces for the SOAP messages */
#define SOAP_ENV_NS_OLD "http://www.w3.org/2001/06/soap-envelope"
#define SOAP_ENV_NS "http://www.w3.org/2001/12/soap-envelope"
#define SOAP_RPC_NS "http://www.w3.org/2001/12/soap-rpc"
#define ROX_NS "http://www.absolutelinux.org/index.html"

/* Stock icons */
#define ROX_STOCK_BOOKMARKS    "arox-bookmarks"
#define ROX_STOCK_COMPRESS     "arox-compress"
#define ROX_STOCK_COPY         "arox-copy"
#define ROX_STOCK_COPYHERE     "arox-copy-here"
#define ROX_STOCK_COUNT        "arox-count"
#define ROX_STOCK_DELETE       "arox-delete"
#define ROX_STOCK_FIND         "arox-find"
#define ROX_STOCK_HOME         "arox-home"
#define ROX_STOCK_ICON         "arox-icon"
#define ROX_STOCK_LINK         "arox-link"
#define ROX_STOCK_MOUNT        "rox-mount"
#define ROX_STOCK_MOUNTED      "rox-mounted"
#define ROX_STOCK_PERMISSIONS  "arox-permissions"
#define ROX_STOCK_PROPERTIES   "arox-properties"
#define ROX_STOCK_REFRESH      "arox-refresh"
#define ROX_STOCK_RENAME       "arox-rename"
#define ROX_STOCK_RESIZE       "arox-resize"
#define ROX_STOCK_SENDTO       "arox-send-to"
#define ROX_STOCK_SHOW_DETAILS "arox-show-details"
#define ROX_STOCK_SHOW_HIDDEN  "arox-show-hidden"
#define ROX_STOCK_QTFM         "arox-qtfm"
#define ROX_STOCK_SYMLINK      "rox-symlink"
#define ROX_STOCK_XATTR        "rox-xattr"

#define D(f, ...) g_print("#"#f"\n", __VA_ARGS__);
#define DD(a) g_print("#"#a"\n");

#include <libxml/tree.h>
