/* 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.
 */
/***************************************************/
/* File   : Protocols.h                            */
/*                                                 */
/* Purpose: Handle some common protocol stuff,     */
/*          such as inter-application data         */
/*          transfer.                              */
/*                                                 */
/*          Function naming convention is as usual */
/*          a source leafname derived prefix, then */
/*          a code based on the protocol being     */
/*          dealt with:                            */
/*                                                 */
/*          _atats_  App To App Transfer, Save     */
/*          _atatl_  App To App Transfer, Load     */
/*          _pp_     Printer Protocol              */
/*          _auh_    Acorn URI Handler             */
/*          _ih_     Interactive Help              */
/*          _aub_    ANT URL Broadcast             */
/*          _multi_  Message is used in more than  */
/*                   one message protocol scheme   */
/*          _util_   A utility function not        */
/*                   directly connected with a     */
/*                   specific protocol.            */
/*                                                 */
/*          This is followed by the direction, so  */
/*          to speak - i.e. '_got_' for got a      */
/*          message, '_send_' for sending a        */
/*          message. Alternatively, a prefix       */
/*          '_bounced' is used for messages which  */
/*          return as a UserMessage_Acknowledge    */
/*          event.                                 */
/*                                                 */
/*          Because the Plug-In message protocol   */
/*          is such a large and self-contained     */
/*          entity, this is kept separate, in      */
/*          PlugIn.h.                              */
/*                                                 */
/* Author : A.D.Hodgkinson                         */
/*                                                 */
/* History: 29-Aug-97: Created.                    */
/*                                                 */
/*          06-Sep-97: Significant rewriting to    */
/*                     stop various clashes and    */
/*                     increase flexibility.       */
/***************************************************/

/* Enumerations and definitons */

/* For protocols_atats_send_data_save, the routine must know what sort  */
/* of object is being saved so it can remember the relevant information */
/* in the relevant place.                                               */

typedef enum protocols_saving
{
  protocols_saving_nothing = 0,        /* For completeness only, really */
  protocols_saving_document_source,    /* HTML or text document source, must give browser */
  protocols_saving_document_as_text,   /* A page converted to a text file, must give browser */
  protocols_saving_document_as_draw,   /* A page converted to a draw file, must give browser */
  protocols_saving_link,               /* A link as a URI or URL file, must give browser and token */
  protocols_saving_frame_location,     /* The current location as a URI or URL file, must give browser */
  protocols_saving_hotlist_entry,      /* A hotlist link item as a URI or URL file, must give NULL browser and hotlist item */
  protocols_saving_hotlist_selection,  /* A selection of hotlist items as an HTML file, don't need anything else */
  protocols_saving_entire_hotlist,     /* Save the entire hotlist as an HTML file, don't need anything else */
  protocols_saving_image_original,     /* An image in its original form, must give browser and token */
  protocols_saving_image_sprite,       /* An image as a sprite, must given browser and token */
  protocols_saving_object,             /* A page object through the fetcher, must give browser */
  protocols_saving_local_history,      /* A local History save, must give browser */
  protocols_saving_global_history      /* A global History save, don't need anything else */
}
protocols_saving;

/* Function prototypes */

_kernel_oserror * protocols_atats_send_data_open       (int filetype, char * pathname);
_kernel_oserror * protocols_atats_data_open_bounced    (WimpMessage * m);
_kernel_oserror * protocols_atats_send_data_save       (browser_data * b, void * extra, char * leaf, int estimated_size, int filetype, protocols_saving saving, WimpGetPointerInfoBlock * info);
_kernel_oserror * protocols_atats_data_save_bounced    (WimpMessage * m);
_kernel_oserror * protocols_atats_got_ram_fetch        (WimpMessage * m);
_kernel_oserror * protocols_atats_send_ram_transmit    (WimpMessage * m, int transmitted, int last);
_kernel_oserror * protocols_atats_ram_transmit_bounced (WimpMessage * m);
_kernel_oserror * protocols_atats_send_data_load       (WimpMessage * m);
_kernel_oserror * protocols_atats_data_load_bounced    (WimpMessage * m);
_kernel_oserror * protocols_atats_got_data_load_ack    (WimpMessage * m);
_kernel_oserror * protocols_atats_send_any_pendings    (browser_data * b);

_kernel_oserror * protocols_atatl_got_data_open        (WimpMessage * m);
_kernel_oserror * protocols_atatl_got_data_load        (WimpMessage * m);
_kernel_oserror * protocols_atatl_send_data_load_ack   (WimpMessage * m);
_kernel_oserror * protocols_atatl_got_data_save        (WimpMessage * m);
_kernel_oserror * protocols_atatl_ram_fetch_bounced    (WimpMessage * m);
_kernel_oserror * protocols_atatl_got_ram_transmit     (WimpMessage * m);

_kernel_oserror * protocols_pp_send_print_save         (void);
_kernel_oserror * protocols_pp_print_save_bounced      (WimpMessage * m);
_kernel_oserror * protocols_pp_got_print_error         (WimpMessage * m);
_kernel_oserror * protocols_pp_got_print_type_odd      (WimpMessage * m);

_kernel_oserror * protocols_auh_got_process            (WimpMessage * m);
_kernel_oserror * protocols_auh_got_return_result      (WimpMessage * m);
_kernel_oserror * protocols_auh_got_dying              (WimpMessage * m);

int               protocols_ih_send_help_request       (int eventcode, WimpPollBlock * block, IdBlock * idb, void * handle);
_kernel_oserror * protocols_ih_help_request_bounced    (WimpMessage * m);
_kernel_oserror * protocols_ih_got_help_reply          (WimpMessage * m);

_kernel_oserror * protocols_aub_got_open_url           (WimpMessage * m);

_kernel_oserror * protocols_multi_got_data_save_ack    (WimpMessage * m);

void              protocols_util_make_unique_name      (char * buffer, int buffer_size);