File:  [Public] / Amaya / amaya / amaya.h
Revision 1.116: download - view: text, annotated - select for diffs
Thu Oct 21 10:16:36 1999 UTC (24 years, 8 months ago) by cvs
Branches: MAIN
CVS tags: HEAD
Bug fixes:
- local CSS files are now managed like remote ones.
- protect the TtaFileUnlink function
- warnings
Irene

/*
 *
 *  (c) COPYRIGHT MIT and INRIA, 1996.
 *  Please first read the full copyright statement in file COPYRIGHT.
 *
 */

#ifndef AMAYA_H 
#define AMAYA_H

/* Thot interface */
#include "thot_gui.h"
#include "thot_sys.h"
#include "appstruct.h"
#include "application.h"
#include "attribute.h"
#include "browser.h"
#include "content.h"
#include "dialog.h"
#include "fileaccess.h"
#include "interface.h"
#include "libmsg.h"
#include "message.h"
#include "presentation.h"
#include "selection.h"
#include "reference.h"
#include "tree.h"
#include "view.h"
#include "uconvert.h"
#include "undo.h"
/* Included headerfiles */
#include "EDITOR.h"
#include "HTML.h"
#include "TextFile.h"
#include "amayamsg.h"

#define MAX_LENGTH     512
#define NAME_LENGTH     32

#define HTAppName     TEXT ("amaya")
#define HTAppVersion  TEXT ("V2.2")
#define URL_STR       TEXT ("/")
#define URL_SEP       TEXT ('/')


/* Number of views used in Amaya */
#define AMAYA_MAX_VIEW_DOC  7

/* The structures used for request callbacks */

typedef void   TIcbf (Document doc, int status, char *urlName,
		      char *outputfile, const char *content_type,
		      const char *data_block, int data_block_size,
		      void *context);

typedef void  TTcbf (Document doc, int status, STRING urlName,
                     STRING outputfile, const STRING content_type,
                     void *context);

/* How are Network accesses provided ? */
#ifdef AMAYA_JAVA
#include "libjava.h"
#else
#ifdef AMAYA_ILU
#include "libilu.h"
#else
#include "libwww.h"
#endif
#endif

/* The different events to open a new document */
typedef enum _ClickEvent {
  CE_ABSOLUTE, CE_RELATIVE, CE_FORM_POST, CE_FORM_GET,
  CE_HELP, CE_MAKEBOOK, CE_LOG , CE_TEMPLATE, CE_INIT,
} ClickEvent;

#define NO               0
#define YES              1

/* dialogue */
#define URLForm          1
#define OpenForm         2
#define URLName          3
#define LocalName        4
#define DirSelect        5
#define DocSelect        6
#define StopCommand      7
#define SaveForm         8
#define DirSave          9
#define DocSave         10
#define ToggleSave      11
#define NameSave        12
#define ImgDirSave      13
#define Label1          14
#define Label2          15
#define Label3          16
#define Label4          17
#define ConfirmForm     18
#define ConfirmText     19
#define AttrHREFForm    20
#define AttrHREFText    21
#define FormAnswer      22
#define AnswerText      24
#define NameText        25
#define PasswordText    26
#define FilterText      27
#define ClassForm       28
#define ClassSelect     29
#define AClassForm      30
#define AClassSelect    31
#define ConfirmSave     32
#define ConfirmSaveList 33
#define OptionMenu	34
#define MAX_SUBMENUS    400
/* MAX_SUBMENUS references reserved for submenus of Option menu */
#define About1		435
#define About2		436
#define About3		437
#define Version		438
#define AboutForm      	439
#define TableForm       440
#define TableRows       441
#define TableCols       442
#define TableBorder     443
#define MAX_REF         444

/* The possible GET/POST/PUT request modes */

/*synchronous request*/
#define AMAYA_SYNC	1	/*0x000001 */  
/*synchronous request with incremental callbacks */
#define AMAYA_ISYNC	2	/*0x000010 */  
/*asynchronous request */
#define AMAYA_ASYNC	4	/*0x000100 */
/*asynchronous request with incremental callbacks */
#define AMAYA_IASYNC	8	/*0x001000 */
/* send the form using the POST HTTP method */
#define AMAYA_FORM_POST 16	/*0x010000 */
/* send the form using the GET HTTP method */
#define AMAYA_FORM_GET  32	/*0x100000 */
/* bypass caching */
#define AMAYA_NOCACHE	64
/* don't follow redirections */
#define AMAYA_NOREDIR	128
#ifndef AMAYA_JAVA
/* Prevents a stop race condition in ASYNC transfers */
#define AMAYA_ASYNC_SAFE_STOP  256
#define AMAYA_LOAD_CSS   512
#define AMAYA_FLUSH_REQUEST 1024
#define AMAYA_USE_PRECONDITIONS 2048
#else
#define AMAYA_ASYNC_SAFE_STOP  0
#define AMAYA_LOAD_CSS   0
#define AMAYA_USE_PRECONDITIONS 0
#endif /* ! AMAYA_JAVA */

/*
 * Flags to indicate the action to take when the network options
 * are modified
 */
#define AMAYA_CACHE_RESTART 1
#define AMAYA_PROXY_RESTART 2
#define AMAYA_LANNEG_RESTART 4
#define AMAYA_SAFEPUT_RESTART 8

/*
 * Flags to indicate the status of the network requests associated
 * to a document.
 */

#define AMAYA_NET_INACTIVE 1
#define AMAYA_NET_ERROR    2
#define AMAYA_NET_ACTIVE   4

/*
 * Flags for HTParse, specifying which parts of the URL are needed
 */
#define AMAYA_PARSE_ACCESS      16  /* Access scheme, e.g. "HTTP" */
#define AMAYA_PARSE_HOST        8   /* Host name, e.g. "www.w3.org" */
#define AMAYA_PARSE_PATH        4   /* URL Path, e.g. "pub/WWW/TheProject.html" */
#define AMAYA_PARSE_ANCHOR      2   /* Fragment identifier, e.g. "news" */
#define AMAYA_PARSE_PUNCTUATION 1   /* Include delimiters, e.g, "/" and ":" */
#define AMAYA_PARSE_ALL         31  /* All the parts */

THOT_EXPORT int          appArgc;
THOT_EXPORT STRING       *appArgv;
THOT_EXPORT CHAR_T       TempFileDirectory[MAX_LENGTH];
THOT_EXPORT CHAR_T       Answer_text[MAX_LENGTH];
THOT_EXPORT CHAR_T       Answer_name[NAME_LENGTH];
THOT_EXPORT CHAR_T       Answer_password[NAME_LENGTH];
THOT_EXPORT CHAR_T       Display_password[NAME_LENGTH];
THOT_EXPORT CHAR_T       ScanFilter[NAME_LENGTH]; /* to scan directories    */
THOT_EXPORT STRING       LastURLName;	/* last URL requested               */
THOT_EXPORT STRING       DirectoryName;	/* local path of the document       */
THOT_EXPORT STRING       DocumentName;	/* document name                    */
THOT_EXPORT STRING       SavePath;	/* saving path                      */
THOT_EXPORT STRING       SaveName;	/* saving name of the document      */
THOT_EXPORT STRING       ObjectName;	/* document name                    */
THOT_EXPORT STRING       SaveImgsURL;	/* where to save remote Images      */
THOT_EXPORT STRING       TargetName;
THOT_EXPORT STRING       SavingFile;	/* complete path or URL of the document */
THOT_EXPORT int          Lg_password;
THOT_EXPORT int          BaseDialog;
THOT_EXPORT int          ReturnOption;
THOT_EXPORT int          NumberRows;
THOT_EXPORT int          NumberCols;
THOT_EXPORT int          TBorder;
THOT_EXPORT int          ReturnOptionMenu;
THOT_EXPORT Document     CurrentDocument;
THOT_EXPORT Document     SavingDocument;
THOT_EXPORT Document     SavingObject;
THOT_EXPORT Document     AttrHREFdocument;
THOT_EXPORT Document     DocBook;
THOT_EXPORT Document     IncludedDocument;
THOT_EXPORT Element      AttrHREFelement;
THOT_EXPORT STRING       AttrHREFvalue;
THOT_EXPORT Document     SelectionDoc;
THOT_EXPORT ThotBool	 IsNewAnchor;
THOT_EXPORT ThotBool	 UseLastTarget;
THOT_EXPORT ThotBool	 LinkAsCSS;
THOT_EXPORT ThotBool	 SaveAsHTML;
THOT_EXPORT ThotBool	 SaveAsXHTML;
THOT_EXPORT ThotBool	 SaveAsText;
THOT_EXPORT ThotBool     CopyImages;	/* should we copy images in Save As */
THOT_EXPORT ThotBool     UpdateURLs;	/* should we update URLs in Save As */
THOT_EXPORT ThotBool     UserAnswer;
THOT_EXPORT ThotBool     InNewWindow;
THOT_EXPORT ThotBool     SelectionInPRE;
THOT_EXPORT ThotBool     SelectionInComment;
THOT_EXPORT ThotBool     SelectionInEM;
THOT_EXPORT ThotBool     SelectionInSTRONG;
THOT_EXPORT ThotBool     SelectionInCITE;
THOT_EXPORT ThotBool     SelectionInABBR;
THOT_EXPORT ThotBool     SelectionInACRONYM;
THOT_EXPORT ThotBool     SelectionInINS;
THOT_EXPORT ThotBool     SelectionInDEL;
THOT_EXPORT ThotBool     SelectionInDFN;
THOT_EXPORT ThotBool     SelectionInCODE;
THOT_EXPORT ThotBool     SelectionInVAR;
THOT_EXPORT ThotBool     SelectionInSAMP;
THOT_EXPORT ThotBool     SelectionInKBD;
THOT_EXPORT ThotBool     SelectionInI;
THOT_EXPORT ThotBool     SelectionInB;
THOT_EXPORT ThotBool     SelectionInTT;
THOT_EXPORT ThotBool     SelectionInBIG;
THOT_EXPORT ThotBool     SelectionInSMALL;
THOT_EXPORT ThotBool     SelectionInSub;
THOT_EXPORT ThotBool     SelectionInSup;
THOT_EXPORT ThotBool     SelectionInQuote;
THOT_EXPORT ThotBool     SelectionInBDO;
THOT_EXPORT ThotBool     HTMLErrorsFound;

typedef enum
{
  docHTML,
  docHTMLRO,
  docText,
  docTextRO,
  docImage,
  docImageRO,
  docCSS,
  docCSSRO,
  docSource,
  docSourceRO
} DocumentType;


/* a record for data associated with a request */
typedef struct _DocumentMetaDataElement
{
  STRING form_data;  /* form data associated with a URL */
  ClickEvent method;  /* method used to send this data */
} DocumentMetaDataElement;

#define DocumentTableLength 10
/* URL of each loaded document */
THOT_EXPORT STRING     DocumentURLs[DocumentTableLength];
/* Any formdata associated with a URL */
THOT_EXPORT DocumentMetaDataElement *DocumentMeta[DocumentTableLength];
/* Type of document */
THOT_EXPORT DocumentType DocumentTypes[DocumentTableLength];
/* identifier of the document displaying the source code */
THOT_EXPORT Document DocumentSource[DocumentTableLength];
/* The whole document is loaded when the corresponding entry in FilesLoading is 0 */
THOT_EXPORT int          FilesLoading[DocumentTableLength];
/* Status (error, success) of the download of the objects of a document */
THOT_EXPORT int          DocNetworkStatus[DocumentTableLength];

THOT_EXPORT Document     W3Loading;	/* the document being loaded */
THOT_EXPORT Document     BackupDocument;	/* the current backup */

/* button indexes */
THOT_EXPORT int iStop;
THOT_EXPORT int iBack;
THOT_EXPORT int iForward;
THOT_EXPORT int iReload;
THOT_EXPORT int iHome;
THOT_EXPORT int iEditor;
THOT_EXPORT int iSave;
THOT_EXPORT int iPrint;
THOT_EXPORT int iFind;
THOT_EXPORT int iI;
THOT_EXPORT int iB;
THOT_EXPORT int iT;
THOT_EXPORT int iImage;
THOT_EXPORT int iH1;
THOT_EXPORT int iH2;
THOT_EXPORT int iH3;
THOT_EXPORT int iBullet;
THOT_EXPORT int iNum;
THOT_EXPORT int iDL;
THOT_EXPORT int iLink;
THOT_EXPORT int iTable;

#define IMAGE_NOT_LOADED        0
#define IMAGE_LOCAL		1
#define IMAGE_LOADED		2
#define IMAGE_MODIFIED		3


#ifdef __STDC__
typedef void (*LoadedImageCallback)(Document doc, Element el, char *file, void *extra);
#else
typedef void (*LoadedImageCallback)();
#endif

typedef struct _ElemImage
  {
     Element             currentElement;/* first element using this image */
     struct _ElemImage  *nextElement;
     LoadedImageCallback callback;	/* Callback for non-standard handling */
     void		*extra;		/* any extra info for the CallBack */
  }
ElemImage;

typedef struct _LoadedImageDesc
  {
     STRING          originalName;	/* complete URL of the image                */
     STRING          localName;	/* local name (without path) of the image   */
     struct _LoadedImageDesc *prevImage;/* double linked list                       */
     struct _LoadedImageDesc *nextImage;/* easier to unchain                        */
     Document            document;	/* document concerned                       */
     struct _ElemImage  *elImage;	/* first element using this image           */
     int                 imageType;     /* the type of the image                    */
     int                 status;	/* the status of the image loading          */
  }
LoadedImageDesc;

/* the structure used for storing the context of the 
   FetchAndDisplayImages_callback function */
typedef struct _FetchImage_context {
  STRING base_url;
  LoadedImageDesc    *desc;
} FetchImage_context;


THOT_EXPORT LoadedImageDesc *ImageURLs;
THOT_EXPORT LoadedImageDesc *ImageLocal;

#define BROWSING       0
#define SELECTING      1
#define SEARCHING      2
#define VIEWS          3
#define CREATING       4
#define LINKS          5
#define CHANGING       6
#define TABLES         7
#define MATH           8
#define IMAGEMAPS      9
#define CSS           10
#define ATTRIBUTES    11
#define SPELLCHECKING 12
#define PUBLISHING    13
#define PRINTING      14
#define NUMBERING     15
#define MAKEBOOK      16
#define CONFIGURE     17

/* The default Amaya HOME pages (page shown at boot time */

#if defined(_I18N_) || defined(__JIS__)
#   ifdef _WINDOWS
#         define AMAYA_PAGE  L"\\amaya\\AmayaPage.html"
#   else  /* _WINDOWS */
#         define AMAYA_PAGE  L"/amaya/AmayaPage.html"
#   endif /* _WINDOWS */
#   define   AMAYA_PAGE_DOC       L"http://www.w3.org/Amaya/User/"
#else /*  !_I18N_ */
#     ifdef _WINDOWS
#           define AMAYA_PAGE  "\\amaya\\AmayaPage.html"
#     else  /* _WINDOWS */
#           define AMAYA_PAGE "/amaya/AmayaPage.html"
#     endif /* _WINDOWS */
#     define   AMAYA_PAGE_DOC       "http://www.w3.org/Amaya/User/"
#endif /* !_I18N_ */

#endif /* AMAYA_H */

Webmaster