PlugIn 11.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/* 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   : PlugIn.h                               */
/*                                                 */
/* Purpose: Supporting the generic RISC OS browser */
/*          Plug-In interface.                     */
/*                                                 */
/* Author : A.D.Hodgkinson                         */
/*                                                 */
/* History: 28-Sep-97: Created.                    */
/***************************************************/

26 27 28 29 30 31 32 33 34 35 36 37
/* Structures - queue of ready-to-launch Plug-Ins */

typedef struct plugin_queue
{
  struct plugin_queue * next;

  browser_data        * browser;
  HStream             * token;
  BBox                  position;
}
plugin_queue;

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/* For the Plug-In streaming protocol, where quite a lot of */
/* information needs to be retained for a long time.        */

typedef struct plugin_stream
{
  unsigned int   browser_instance_handle; /* The browser owning the Object   */
  HStream      * token;                   /* HStream representing the Object */

  unsigned int   plugin_instance_handle;
  unsigned int   plugin_stream_handle;
  unsigned int   plugin_task_handle;      /* ...So we know who to talk to later */

  unsigned int   stream_flags;            /* From flags word of Message_PlugIn_StreamNew */

  string_value   url;                     /* These will be allocated in RMA, */
  string_value   mime;                    /* so great care must be taken to  */
  string_value   target;                  /* ensure they're always freed up. */
  string_value   filename;

57 58 59 60 61 62 63
  int            eos;
  int            last_modified;
  int            notify;                  /* From a Message_PlugIn_URLAccess */

  unsigned int   active            :1;    /* 1 if the stream is open, else 0 (e.g. waiting for message protocol to complete) */
  unsigned int   will_close_itself :1;    /* 1 if the stream will close itself, else close it (e.g. at window close time)    */
  unsigned int   abandoned         :1;    /* 1 if the stream fetch was closed forcibly (abandoned), else 0.                  */
64 65 66
}
plugin_stream;

67 68
/* Message definitions - needs string_value to be known, */
/* found in MiscDefs.h.                                  */
69 70 71 72
/*                                                       */
/* These definitions are uncommented, as it is assumed   */
/* that the reader is completely familiar with the       */
/* Plug-In specification already.                        */
73

74
#define Message_PlugIn_Open                        0x4d540
75

76
#define MPlugIn_Open_OpenAsHelperNotPlugIn         (1<<0);
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

typedef struct MPlugIn_Open
{
  unsigned int flags;
  unsigned int reserved;

  int          browser_instance_handle;
  int          parent_window_handle;

  BBox         parent_area;

  int          file_type;
  string_value file_name;
}
MPlugIn_Open;

93
/* Plug-In opening */
94

95 96 97 98 99 100 101 102 103
#define Message_PlugIn_Opening                     0x4d541

#define MPlugIn_Opening_CanAcceptInputFocus        (1u<<0)
#define MPlugIn_Opening_WantsCodeResourceFetched   (1u<<1)
#define MPlugIn_Opening_WantsDataResourceFetched   (1u<<2)
#define MPlugIn_Opening_WillDeleteParamsItself     (1u<<3)
#define MPlugIn_Opening_PlugInHasMoreWorkToDo      (1u<<4)
#define MPlugIn_Opening_ActionBeyondStop           (1u<<5)
#define MPlugIn_Opening_OpenedAsHelperNotPlugIn    (1u<<6)
104 105 106 107 108 109 110 111 112 113

typedef struct MPlugIn_Opening
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;
}
MPlugIn_Opening;

114 115 116
/* Request Plug-In to close */

#define Message_PlugIn_Close                       0x4d542
117

118
#define MPlugIn_Close_WouldLikePlugInToExit        (1u<<0)
119 120 121 122 123 124 125 126 127 128

typedef struct MPlugIn_Close
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;
}
MPlugIn_Close;

129 130 131 132 133 134 135
/* Plug-In closing */

#define Message_PlugIn_Closed                      0x4d543

#define MPlugIn_Closed_PlugInWillExitAfterThis     (1u<<0)
#define MPlugIn_Closed_NotAReply                   (1u<<1)
#define MPlugIn_Closed_ErrorHeldInMessageBlock     (1u<<2)
136 137 138 139 140 141 142 143 144 145 146 147 148

typedef struct MPlugIn_Closed
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  int          errnum;
  char         errmess[sizeof(WimpMessage) - 36];
}
MPlugIn_Closed;

149 150 151
/* Request Plug-In moves */

#define Message_PlugIn_Reshape                     0x4d544
152 153 154 155 156 157 158 159 160 161 162 163 164

typedef struct MPlugIn_Reshape
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  int          parent_window_handle;
  BBox         parent_area;
}
MPlugIn_Reshape;

165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
/* Plug-In requesting that it be resized */

#define Message_PlugIn_ReshapeRequest              0x4d545

typedef struct MPlugIn_ReshapeRequest
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  unsigned int width;
  unsigned int height;
}
MPlugIn_ReshapeRequest;

181
#define MPlugIn_StreamNew_StreamTypeMask           (3u<<0)
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
#define MPlugIn_StreamNew_StreamTypeNormal         (0u<<0)
#define MPlugIn_StreamNew_StreamTypeSeekOnly       (1u<<0)
#define MPlugIn_StreamNew_StreamTypeAsFile         (2u<<0)
#define MPlugIn_StreamNew_StreamTypeAsFileOnly     (3u<<0)
#define MPlugIn_StreamNew_StreamIsSeekable         (1u<<4)

/* Open a new stream */

#define Message_PlugIn_StreamNew                   0x4d548

typedef struct MPlugIn_StreamNew
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  int          plugin_stream_instance_handle;
  int          browser_stream_instance_handle;

  string_value url;

  int          eos;
  int          last_modified;
  int          notify;

  string_value mime_type;
  string_value window_target;
}
MPlugIn_StreamNew;

/* Close a stream */

#define Message_PlugIn_StreamDestroy               0x4d549

#define MPlugIn_StreamDestroy_Reason_Success       0
#define MPlugIn_StreamDestroy_Reason_Error         1
#define MPlugIn_StreamDestroy_Reason_User          2

typedef struct MPlugIn_StreamDestroy
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  int          plugin_stream_instance_handle;
  int          browser_stream_instance_handle;

  string_value url;

  int          eos;
  int          last_modified;
  int          notify;

  int          reason;
}
MPlugIn_StreamDestroy;

/* Confirm file has been written */

#define Message_PlugIn_StreamAsFile                0x4d54c

typedef struct MPlugIn_StreamAsFile
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  int          plugin_stream_instance_handle;
  int          browser_stream_instance_handle;

  string_value url;

  int          eos;
  int          last_modified;
  int          notify;

  string_value pathname;
}
MPlugIn_StreamAsFile;

/* Plug-In URL request */

#define Message_PlugIn_URLAccess                   0x4d54d
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288

#define MPlugIn_URLAccess_ReturnNotifyWhenComplete (1u<<0);
#define MPlugIn_URLAccess_POSTToURL                (1u<<1);
#define MPlugIn_URLAccess_POSTAFile                (1u<<2);

typedef struct MPlugIn_URLAccess
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  string_value url;
  string_value target;

  int          notify_data;
  int          data_length;
  string_value data_pointer;
}
MPlugIn_URLAccess;

289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
/* Plug-In status message */

#define Message_PlugIn_Status                      0x4d54f

typedef struct MPlugIn_Status
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  string_value status;
}
MPlugIn_Status;

/* Plug-In busy / idle indication */

#define Message_PlugIn_Busy                        0x4d550

#define MPlugIn_Busy_IsBusy                        (1u<<0);
#define MPlugIn_Busy_StatusWordIsValid             (1u<<1);

#define MPlugIn_Busy_State_Stop                    0;
#define MPlugIn_Busy_State_Play                    1;
#define MPlugIn_Busy_State_Pause                   2;
#define MPlugIn_Busy_State_FastForward             3;
#define MPlugIn_Busy_State_Rewind                  4;
#define MPlugIn_Busy_State_Record                  5;

typedef struct MPlugIn_Busy
{
  unsigned int flags;

  int          plugin_instance_handle;
  int          browser_instance_handle;

  unsigned int state;
}
MPlugIn_Busy;

329
/* Parameters file definitions */
330

331 332 333 334 335 336 337 338 339
#define PlugIn_ParamType_Terminator      0
#define PlugIn_ParamType_DataFromPARAM   1
#define PlugIn_ParamType_URLFromPARAM    2
#define PlugIn_ParamType_ObjectFromPARAM 3
#define PlugIn_ParamType_BrowserSpecial  4
#define PlugIn_ParamType_DataFromOBJECT  5
#define PlugIn_ParamType_URLFromOBJECT   6
#define PlugIn_ParamType_DataFromAPPLET  5
#define PlugIn_ParamType_URLFromAPPLET   6
340 341 342 343

/* Function prototypes */

const char      * plugin_return_string                (WimpMessage * m, string_value * sv);
344
_kernel_oserror * plugin_write_params                 (browser_data * b, HStream * t, char * buffer, int buffer_size, BBox * position);
345

346 347 348 349
_kernel_oserror * plugin_add_queue_item               (browser_data * b, HStream * t, BBox * position);
_kernel_oserror * plugin_remove_item                  (plugin_queue * remove);
_kernel_oserror * plugin_flush_queue                  (browser_data * b, int start_now);

350 351 352 353
_kernel_oserror * plugin_open_bounced                 (WimpMessage * m);
_kernel_oserror * plugin_got_opening                  (WimpMessage * m);
_kernel_oserror * plugin_send_close                   (unsigned int b, unsigned int task, unsigned int instance);

354
_kernel_oserror * plugin_got_reshape_request          (WimpMessage * m);
355 356 357 358
_kernel_oserror * plugin_send_original_reshape        (unsigned int b, unsigned int task, unsigned int instance, BBox * position);

_kernel_oserror * plugin_got_url_access               (WimpMessage * m);

359 360 361
_kernel_oserror * plugin_got_status                   (WimpMessage * m);
_kernel_oserror * plugin_got_busy                     (WimpMessage * m);

362 363 364 365 366 367 368 369 370 371 372 373
_kernel_oserror * plugin_setup_stream                 (unsigned int owner, browser_data * fetcher, const char * url);
_kernel_oserror * plugin_start_new_stream             (unsigned int b, const char * data, unsigned int instance, unsigned int task);
_kernel_oserror * plugin_send_original_stream_new     (browser_data * b);
_kernel_oserror * plugin_got_stream_new               (WimpMessage * m);
_kernel_oserror * plugin_stream_new_bounced           (WimpMessage * m);
_kernel_oserror * plugin_send_original_stream_destroy (browser_data * b, int reason);
_kernel_oserror * plugin_abort_stream                 (browser_data * b);
_kernel_oserror * plugin_fetch_completed              (browser_data * b);

_kernel_oserror * plugin_obtain_instance              (browser_data * b, HStream * t, unsigned int * instance);
void              plugin_flush_instance_entries       (browser_data * b);

374
void              plugin_shutdown                     (void);