Back to index

lightning-sunbird  0.9+nobinonly
PtMozilla.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard.  All Rights Reserved.
00018  * Portions created by the Initial Developer are Copyright (C) 2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Christopher Blizzard <blizzard@mozilla.org>
00023  *   Brian Edmond <briane@qnx.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 
00040 #ifndef __PT_MOZILLA_H_INCLUDED
00041 #define __PT_MOZILLA_H_INCLUDED
00042 
00043 #include <stdlib.h>
00044 #include <string.h>
00045 
00046 #include <photon/PtWebClient.h>
00047 #include <photon/PpProto.h>
00048 
00049 #if 0
00050 #include "nsIInputStream.h"
00051 #include "nsILoadGroup.h"
00052 #include "nsIChannel.h"
00053 #include "nsIContentViewer.h"
00054 #include "nsIStreamListener.h"
00055 #include "nsISHistory.h"
00056 #include "nsIHistoryEntry.h"
00057 #endif
00058 
00059 /*
00060  * PtMozilla public
00061  */
00062 
00063 extern PtWidgetClassRef_t *PtMozilla;
00064 
00065 class EmbedDownload; /* forward declaration */
00066 
00067 /* Resources */
00068 
00069 #define Pt_ARG_MOZ_GET_URL                              Pt_RESOURCE( 104,  0 )
00070 #define Pt_ARG_MOZ_NAVIGATE_PAGE          Pt_RESOURCE( 104,  1 )
00071 #define Pt_ARG_MOZ_RELOAD                                      Pt_RESOURCE( 104,  2 )
00072 #define Pt_ARG_MOZ_STOP                                               Pt_RESOURCE( 104,  3 )
00073 #define Pt_ARG_MOZ_PRINT                                       Pt_RESOURCE( 104,  4 )
00074 #define Pt_ARG_MOZ_COMMAND         Pt_RESOURCE( 104,  5 )
00075 #define Pt_ARG_MOZ_OPTION                                      Pt_RESOURCE( 104,  6 )
00076 #define Pt_ARG_MOZ_ENCODING                             Pt_RESOURCE( 104,  7 )
00077 #define Pt_ARG_MOZ_WEB_DATA                             Pt_RESOURCE( 104,  8 )
00078 #define Pt_ARG_MOZ_WEB_DATA_URL                  Pt_RESOURCE( 104,  9 )
00079 #define Pt_ARG_MOZ_GET_CONTEXT                   Pt_RESOURCE( 104,  10 )
00080 #define Pt_ARG_MOZ_UNKNOWN_RESP                  Pt_RESOURCE( 104,  11 )
00081 #define Pt_ARG_MOZ_DOWNLOAD                             Pt_RESOURCE( 104,  12 )
00082 #define Pt_ARG_MOZ_GET_HISTORY                   Pt_RESOURCE( 104,  13 )
00083 #define Pt_ARG_MOZ_AUTH_CTRL                            Pt_RESOURCE( 104, 14 ) // used internally for authentification
00084 #define Pt_ARG_MOZ_UNKNOWN_CTRL                  Pt_RESOURCE( 104, 15 ) // used internally for downloading
00085 #define Pt_ARG_MOZ_SCROLL_TO                     Pt_RESOURCE( 104, 16 )
00086 
00087 #define Pt_CB_MOZ_PROGRESS                              Pt_RESOURCE( 104,  20 )
00088 #define Pt_CB_MOZ_START                                               Pt_RESOURCE( 104,  21 )
00089 #define Pt_CB_MOZ_COMPLETE                              Pt_RESOURCE( 104,  22 )
00090 #define Pt_CB_MOZ_NET_STATE         Pt_RESOURCE( 104,  23 )
00091 #define Pt_CB_MOZ_URL                                                        Pt_RESOURCE( 104,  24 )
00092 #define Pt_CB_MOZ_INFO                                                Pt_RESOURCE( 104,  25 )
00093 #define Pt_CB_MOZ_OPEN             Pt_RESOURCE( 104,  26 )
00094 #define Pt_CB_MOZ_NEW_WINDOW              Pt_RESOURCE( 104,  27 )
00095 #define Pt_CB_MOZ_DIALOG                         Pt_RESOURCE( 104,  28 )
00096 #define Pt_CB_MOZ_AUTHENTICATE            Pt_RESOURCE( 104,  29 )
00097 #define Pt_CB_MOZ_PROMPT                         Pt_RESOURCE( 104,  30 )
00098 #define Pt_CB_MOZ_NEW_AREA                Pt_RESOURCE( 104,  31 )
00099 #define Pt_CB_MOZ_VISIBILITY        Pt_RESOURCE( 104,  32 )
00100 #define Pt_CB_MOZ_DESTROY                 Pt_RESOURCE( 104,  33 )
00101 #define Pt_CB_MOZ_EVENT                          Pt_RESOURCE( 104,  35 )
00102 #define Pt_CB_MOZ_CONTEXT                 Pt_RESOURCE( 104,  36 )
00103 #define Pt_CB_MOZ_PRINT_STATUS            Pt_RESOURCE( 104,  37 )
00104 #define Pt_CB_MOZ_WEB_DATA_REQ            Pt_RESOURCE( 104,  38 )
00105 #define Pt_CB_MOZ_UNKNOWN                                      Pt_RESOURCE( 104,  39 )
00106 #define Pt_CB_MOZ_ERROR                                               Pt_RESOURCE( 104,  40 )
00107 #define Pt_CB_MOZ_DOWNLOAD                              Pt_RESOURCE( 104,  41 )
00108 
00109 
00110 #define MAX_URL_LENGTH                                         1024
00111 
00112 typedef enum
00113 {
00114   MOZ_EMBED_FLAG_RELOADNORMAL = 0,
00115   MOZ_EMBED_FLAG_RELOADBYPASSCACHE = 1,
00116   MOZ_EMBED_FLAG_RELOADBYPASSPROXY = 2,
00117   MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE = 3,
00118   MOZ_EMBED_FLAG_RELOADCHARSETCHANGE = 4
00119 } MozEmbedReloadFlags;
00120 
00121 // progress callback, can be itemized or full
00122 #define Pt_MOZ_PROGRESS            1
00123 #define Pt_MOZ_PROGRESS_ALL 2
00124 typedef struct mozilla_progress_t
00125 {
00126        int    type; // unused at this time
00127        int32_t       cur;
00128        int32_t       max;
00129 } PtMozillaProgressCb_t;
00130 
00131 // url change callback, also used for open callback
00132 // the open callback returns Pt_END to cancel the open of that site
00133 typedef struct mozilla_url_t
00134 {
00135        char *url;
00136 } PtMozillaUrlCb_t;
00137 
00138 // info callback for Java Script, link messages, titles
00139 #define Pt_MOZ_INFO_TITLE          1
00140 #define Pt_MOZ_INFO_JSSTATUS       2
00141 #define Pt_MOZ_INFO_LINK           3
00142 #define Pt_MOZ_INFO_SSL                   4 // uses status field
00143        // status can be
00144        #define Pt_SSL_STATE_IS_INSECURE   0x1
00145        #define Pt_SSL_STATE_IS_BROKEN            0x2
00146        #define Pt_SSL_STATE_IS_SECURE            0x4
00147        #define Pt_SSL_STATE_SECURE_HIGH   0x8
00148        #define Pt_SSL_STATE_SECURE_MED           0x10
00149        #define Pt_SSL_STATE_SECURE_LOW           0x20
00150 #define Pt_MOZ_INFO_CONNECT 5
00151 
00152 typedef struct mozilla_info_t
00153 {
00154        int                         type;
00155        unsigned long status;
00156        char                 *data;
00157 } PtMozillaInfoCb_t;
00158 
00159 // authentication callback, fill username and password in
00160 // return Pt_END from the callback to cancel authentication
00161 typedef struct mozilla_authenticate_t
00162 {
00163        char *title;
00164        char *realm;
00165        char user[128];
00166        char pass[128];
00167 } PtMozillaAuthenticateCb_t;
00168 
00169 // dialog callback, the _CHECK ones use message and expect an answer in ret_value
00170 // the CONFIRM dialogs must return Pt_CONTINUE to confirm and Pt_END to deny
00171 #define Pt_MOZ_DIALOG_ALERT               1
00172 #define Pt_MOZ_DIALOG_ALERT_CHECK  2
00173 #define Pt_MOZ_DIALOG_CONFIRM             3
00174 #define Pt_MOZ_DIALOG_CONFIRM_CHECK       4
00175 typedef struct mozilla_dialog_t
00176 {
00177        int    type;
00178        PtWidget_t *parent;
00179        char   *title;
00180        char   *text;
00181        char   *checkbox_message;
00182        int    ret_value;
00183 } PtMozillaDialogCb_t;
00184 
00185 // raw net state callback
00186 // flags can be:
00187 //            STATE_START
00188 //            STATE_REDIRECTING
00189 //            STATE_TRANSFERRING
00190 //            STATE_NEGOTIATING
00191 //            STATE_STOP
00192 //            STATE_IS_REQUEST
00193 //            STATE_IS_DOCUMENT
00194 //            STATE_IS_NETWORK
00195 //            STATE_IS_WINDOW
00196 typedef struct mozilla_net_state_t
00197 {
00198         int                 flags;
00199         unsigned int        status;
00200               const char *url;
00201               char *message;
00202 } PtMozillaNetStateCb_t;
00203 
00204 // new window callback
00205 typedef enum
00206 {
00207   Pt_MOZ_FLAG_DEFAULTCHROME = 1U,
00208   Pt_MOZ_FLAG_WINDOWBORDERSON = 2U,
00209   Pt_MOZ_FLAG_WINDOWCLOSEON = 4U,
00210   Pt_MOZ_FLAG_WINDOWRESIZEON = 8U,
00211   Pt_MOZ_FLAG_MENUBARON = 16U,
00212   Pt_MOZ_FLAG_TOOLBARON = 32U,
00213   Pt_MOZ_FLAG_LOCATIONBARON = 64U,
00214   Pt_MOZ_FLAG_STATUSBARON = 128U,
00215   Pt_MOZ_FLAG_PERSONALTOOLBARON = 256U,
00216   Pt_MOZ_FLAG_SCROLLBARSON = 512U,
00217   Pt_MOZ_FLAG_TITLEBARON = 1024U,
00218   Pt_MOZ_FLAG_EXTRACHROMEON = 2048U,
00219   Pt_MOZ_FLAG_ALLCHROME = 4094U,
00220   Pt_MOZ_FLAG_WINDOWRAISED = 33554432U,
00221   Pt_MOZ_FLAG_WINDOWLOWERED = 67108864U,
00222   Pt_MOZ_FLAG_CENTERSCREEN = 134217728U,
00223   Pt_MOZ_FLAG_DEPENDENT = 268435456U,
00224   Pt_MOZ_FLAG_MODAL = 536870912U,
00225   Pt_MOZ_FLAG_OPENASDIALOG = 1073741824U,
00226   Pt_MOZ_FLAG_OPENASCHROME = 2147483648U
00227 } PtMozillaWindowFlags;
00228 typedef struct mozilla_new_window_t
00229 {
00230        PtWidget_t           *widget;
00231        unsigned int  window_flags;
00232        PhDim_t                            window_size;
00233 } PtMozillaNewWindowCb_t;
00234 
00235 typedef struct mozilla_prompt_t
00236 {
00237        char *title;
00238        char *text;
00239        char *dflt_resp;
00240        char response[128];
00241 } PtMozillaPromptCb_t;
00242 
00243 /* for PtMozillaNewAreaCb_t flags */
00244 #define Pt_MOZ_NEW_AREA_SET_SIZE                               0x1
00245 #define Pt_MOZ_NEW_AREA_SET_POSITION                    0x2
00246 #define Pt_MOZ_NEW_AREA_SET_AREA                               0x4
00247 
00248 typedef struct mozilla_new_area_t
00249 {
00250        PhArea_t area;
00251        unsigned int flags;
00252 } PtMozillaNewAreaCb_t;
00253 
00254 typedef struct mozilla_visibility_t
00255 {
00256        int show;
00257 } PtMozillaVisibilityCb_t;
00258 
00259 // context menu
00260 #define Pt_MOZ_CONTEXT_NONE        0x0
00261 #define Pt_MOZ_CONTEXT_LINK        0x1
00262 #define Pt_MOZ_CONTEXT_IMAGE       0x2
00263 #define Pt_MOZ_CONTEXT_DOCUMENT    0x4    
00264 #define Pt_MOZ_CONTEXT_TEXT        0x8
00265 #define Pt_MOZ_CONTEXT_INPUT       0x10
00266 typedef struct mozilla_context_t
00267 {
00268        unsigned flags;
00269        PRInt32 x, y;
00270 } PtMozillaContextCb_t;
00271 
00272 typedef struct mozilla_data_request_cb_t {
00273        int type;
00274        int length;
00275        char *url;
00276 } PtMozillaDataRequestCb_t;
00277 
00278 typedef struct {
00279        short   response;
00280        char    filename[PATH_MAX];
00281        char    url[MAX_URL_LENGTH];
00282        } PtMozUnknownResp_t;
00283 
00284 typedef struct mozilla_event_t
00285 {
00286        int flag;
00287 } PtMozillaEvent_t;
00288 
00289 // print status
00290 #define Pt_MOZ_PRINT_START         1
00291 #define Pt_MOZ_PRINT_COMPLETE      2
00292 #define Pt_MOZ_PRINT_PROGRESS      3
00293 typedef struct mozilla_print_status_t
00294 {
00295        int status;
00296        unsigned int cur;
00297        unsigned int max;
00298 } PtMozillaPrintStatusCb_t;
00299 
00300 // convienience functions
00301 #define Pt_MOZ_PREF_BOOL    1
00302 #define Pt_MOZ_PREF_CHAR    2
00303 #define Pt_MOZ_PREF_INT            3
00304 #define Pt_MOZ_PREF_COLOR   4
00305 void MozSetPreference(PtWidget_t *widget, int type, char *pref, void *data);
00306 
00307 // mozilla commands
00308 enum
00309 {
00310        Pt_MOZ_COMMAND_CUT,
00311        Pt_MOZ_COMMAND_COPY,
00312        Pt_MOZ_COMMAND_PASTE,
00313        Pt_MOZ_COMMAND_SELECTALL,
00314        Pt_MOZ_COMMAND_CLEAR,
00315        Pt_MOZ_COMMAND_FIND,
00316        Pt_MOZ_COMMAND_SAVEAS
00317 };
00318 
00319 typedef struct {
00320        short   response;
00321        char    user[255];
00322        char    pass[255];
00323        PtModalCtrl_t ctrl;
00324        } PtMozillaAuthCtrl_t;
00325 
00326 typedef struct {
00327        short response, waiting;
00328        char *filename;
00329        long download_ticket;
00330        PtModalCtrl_t ctrl;
00331        } PtMozillaUnknownCtrl_t;
00332 
00333 class EmbedPrivate;
00334 
00335 typedef struct Pt_mozilla_client_widget 
00336 {
00337        PtContainerWidget_t  container;
00338 
00339        // Mozilla interfaces
00340        EmbedPrivate *EmbedRef;
00341 
00342        char                        url[MAX_URL_LENGTH];
00343        int                         navigate_flags;
00344        char                        disable_exception_dlg, disable_new_windows, toActivate, spare[1];
00345 
00346        int fDownloadCount;
00347        EmbedDownload **fDownload;
00348 
00349        /* text_zoom is the text zooming as set by the client ( 100 = 100% ) */
00350        short int            text_zoom;
00351        /* actual_text_zoom is the text zooming as returned by the browser - when a window is being created
00352               the client tries to set the text zooming, but there is no content loaded. Use actual_text_zoom
00353               to remember to set the zooming when the content is loaded */
00354        short int actual_text_zoom;
00355 
00356        char *rightClickUrl_image; /* keep the url the user clicked on, to provide it latter for Pt_ARG_WEB_GET_CONTEXT */
00357        char *rightClickUrl_link; /* keep the url the user clicked on, to provide it latter for Pt_ARG_WEB_GET_CONTEXT */
00358 
00359        PtMozillaAuthCtrl_t *moz_auth_ctrl;
00360        PtMozillaUnknownCtrl_t *moz_unknown_ctrl;
00361 
00362        // callbacks
00363        PtCallbackList_t     *title_cb;
00364        PtCallbackList_t     *net_state_cb;
00365        PtCallbackList_t     *info_cb;
00366        PtCallbackList_t     *progress_cb;
00367        PtCallbackList_t     *start_cb;
00368        PtCallbackList_t     *complete_cb;
00369        PtCallbackList_t     *url_cb;
00370        PtCallbackList_t     *event_cb;
00371        PtCallbackList_t     *resize_cb;
00372        PtCallbackList_t     *new_window_cb;
00373        PtCallbackList_t     *destroy_cb;
00374        PtCallbackList_t     *visibility_cb; /* obsolete - delete it latter */
00375        PtCallbackList_t     *open_cb;
00376        PtCallbackList_t     *dialog_cb;
00377        PtCallbackList_t     *auth_cb;
00378        PtCallbackList_t     *prompt_cb;
00379        PtCallbackList_t     *context_cb;
00380        PtCallbackList_t     *print_status_cb;
00381        PtCallbackList_t     *web_data_req_cb;
00382        PtCallbackList_t     *web_unknown_cb;
00383        PtCallbackList_t     *web_error_cb;
00384        PtCallbackList_t     *web_download_cb;
00385 } PtMozillaWidget_t;
00386 
00387 /* Widget union */
00388 typedef union Pt_mozilla_union 
00389 {
00390        PtWidget_t                         core;
00391        PtBasicWidget_t                    basic;
00392        PtContainerWidget_t         cntnr;
00393        PtMozillaWidget_t           moz;
00394 } PtMozillaUnion_t;
00395 
00396 
00397 #endif