1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is
17 * Christopher Blizzard.
18 * Portions created by the Initial Developer are Copyright (C) 2001
19 * the Initial Developer. All Rights Reserved.
22 * Christopher Blizzard <blizzard@mozilla.org>
23 * Ramiro Estrugo <ramiro@eazel.com>
24 * Brian Edmond <briane@qnx.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
41 #include "nsCWebBrowser.h"
42 #include "nsILocalFile.h"
43 #include "nsISelectionController.h"
44 #include "nsEmbedAPI.h"
46 #include "nsWidgetsCID.h"
47 #include "nsIAppShell.h"
49 #include "nsIContentViewer.h"
50 #include "nsIMarkupDocumentViewer.h"
53 #include <nsProfileDirServiceProvider.h>
55 #include "nsIDocumentLoaderFactory.h"
56 #include "nsILoadGroup.h"
57 #include "nsIHistoryEntry.h"
59 #include "nsIWebBrowserPrint.h"
60 #include "nsIPrintOptions.h"
62 #include "nsIDOMEventTarget.h"
63 #include "nsIDOMEventListener.h"
64 #include "nsIDOMKeyListener.h"
65 #include "nsIDOMMouseListener.h"
66 #include "nsIDOMMouseEvent.h"
67 #include "nsIDOMWindow.h"
68 #include "nsNetUtil.h"
69 #include "nsIFocusController.h"
70 #include <nsIWebBrowserFind.h>
72 #include "nsReadableUtils.h"
74 #include "nsIPresShell.h"
76 #include "nsIDirectoryService.h"
77 #include "nsAppDirectoryServiceDefs.h"
79 #include "nsIURIFixup.h"
80 #include "nsPIDOMWindow.h"
82 #include "nsIServiceManager.h"
83 #include "nsIComponentRegistrar.h"
84 #include "nsUnknownContentTypeHandler.h"
86 #include "EmbedPrivate.h"
87 #include "EmbedWindow.h"
88 #include "EmbedDownload.h"
89 #include "HeaderSniffer.h"
90 #include "PromptService.h"
91 #include "PtMozilla.h"
93 //#include "nsUnknownContentTypeHandler.h"
95 #ifdef _BUILD_STATIC_BIN
96 #include "nsStaticComponent.h"
98 ph_getModuleInfo(nsStaticModuleInfo
**info
, PRUint32
*count
);
101 // Macro for converting from nscolor to PtColor_t
102 // Photon RGB values are stored as 00 RR GG BB
103 // nscolor RGB values are 00 BB GG RR
104 #define NS_TO_PH_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
105 #define PH_TO_NS_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
108 static NS_DEFINE_CID(kAppShellCID
, NS_APPSHELL_CID
);
110 #define NS_PROMPTSERVICE_CID \
111 {0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
112 static NS_DEFINE_CID(kPromptServiceCID
, NS_PROMPTSERVICE_CID
);
114 static void mozilla_set_pref( PtWidget_t
*widget
, char *option
, char *value
);
115 static void mozilla_get_pref( PtWidget_t
*widget
, char *option
, char *value
);
116 static void fix_translation_string( char *string
);
118 PtWidgetClass_t
*PtCreateMozillaClass( void );
120 PtWidgetClassRef_t __PtMozilla
= { NULL
, PtCreateMozillaClass
};
121 PtWidgetClassRef_t
*PtMozilla
= &__PtMozilla
;
125 char *g_Print_Left_Header_String
, *g_Print_Right_Header_String
, *g_Print_Left_Footer_String
, *g_Print_Right_Footer_String
;
128 MozSetPreference(PtWidget_t
*widget
, int type
, char *pref
, void *data
)
130 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*) widget
;
131 nsIPref
*prefs
= moz
->EmbedRef
->GetPrefs();
135 case Pt_MOZ_PREF_CHAR
:
136 prefs
->SetCharPref(pref
, (char *)data
);
138 case Pt_MOZ_PREF_BOOL
:
139 prefs
->SetBoolPref(pref
, (int)data
);
141 case Pt_MOZ_PREF_INT
:
142 prefs
->SetIntPref(pref
, (int)data
);
144 case Pt_MOZ_PREF_COLOR
:
146 // prefs->SetColorPrefDWord(pref, (uint32) data);
152 MozLoadURL(PtMozillaWidget_t
*moz
, char *url
)
154 // If the widget isn't realized, just return.
155 if (!(PtWidgetFlags((PtWidget_t
*)moz
) & Pt_REALIZED
))
158 moz
->EmbedRef
->SetURI(url
);
159 moz
->EmbedRef
->LoadCurrentURI();
162 /* watch for an Ph_EV_INFO event in order to detect an Ph_OFFSCREEN_INVALID */
163 static int EvInfo( PtWidget_t
*widget
, void *data
, PtCallbackInfo_t
*cbinfo
)
165 if( cbinfo
->event
&& cbinfo
->event
->type
== Ph_EV_INFO
&& cbinfo
->event
->subtype
== Ph_OFFSCREEN_INVALID
) {
166 PtMozillaWidget_t
*moz
= ( PtMozillaWidget_t
* ) widget
;
167 nsIPref
*pref
= moz
->EmbedRef
->GetPrefs();
168 PRBool displayInternalChange
= PR_FALSE
;
169 pref
->GetBoolPref("browser.display.internaluse.graphics_changed", &displayInternalChange
);
170 pref
->SetBoolPref("browser.display.internaluse.graphics_changed", !displayInternalChange
);
175 const char* const kPersistContractID
= "@mozilla.org/embedding/browser/nsWebBrowserPersist;1";
177 void MozSaveTarget( char *url
, PtMozillaWidget_t
*moz
)
180 nsCOMPtr
<nsIWebBrowserPersist
> webPersist(do_CreateInstance(kPersistContractID
, &rv
));
181 if( !webPersist
) return;
183 nsCOMPtr
<nsIURI
> uri
;
184 NS_NewURI( getter_AddRefs(uri
), url
);
186 /* create a temporary file */
189 nsCOMPtr
<nsILocalFile
> tmpFile
;
190 NS_NewNativeLocalFile(nsDependentCString( tmp_path
), PR_TRUE
, getter_AddRefs(tmpFile
));
192 /* create a download object, use to sniff the headers for a location indication */
193 HeaderSniffer
*sniffer
= new HeaderSniffer( webPersist
, moz
, uri
, tmpFile
);
195 webPersist
->SetProgressListener( sniffer
);
196 webPersist
->SaveURI( uri
, nsnull
, nsnull
, nsnull
, nsnull
, tmpFile
);
199 // defaults function, called on creation of a widget
201 mozilla_defaults( PtWidget_t
*widget
)
203 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*) widget
;
204 PtBasicWidget_t
*basic
= (PtBasicWidget_t
*) widget
;
205 PtContainerWidget_t
*cntr
= (PtContainerWidget_t
*) widget
;
207 moz
->EmbedRef
= new EmbedPrivate();
208 moz
->EmbedRef
->Init(widget
);
209 moz
->EmbedRef
->Setup();
211 moz
->disable_new_windows
= 0;
212 moz
->disable_exception_dlg
= 0;
213 moz
->text_zoom
= 100;
214 moz
->actual_text_zoom
= 100;
218 basic
->flags
= Pt_ALL_OUTLINES
| Pt_ALL_BEVELS
| Pt_FLAT_FILL
;
219 widget
->resize_flags
&= ~Pt_RESIZE_XY_BITS
; // fixed size.
220 widget
->anchor_flags
= Pt_TOP_ANCHORED_TOP
| Pt_LEFT_ANCHORED_LEFT
| \
221 Pt_BOTTOM_ANCHORED_TOP
| Pt_RIGHT_ANCHORED_LEFT
| Pt_ANCHORS_INVALID
;
223 cntr
->flags
|= Pt_CHILD_GETTING_FOCUS
;
225 PtAddEventHandler( widget
, Ph_EV_INFO
, EvInfo
, NULL
);
228 // widget destroy function
230 mozilla_destroy( PtWidget_t
*widget
)
232 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*) widget
;
236 moz
->EmbedRef
->Destroy();
237 delete moz
->EmbedRef
;
241 static int child_getting_focus( PtWidget_t
*widget
, PtWidget_t
*child
, PhEvent_t
*ev
) {
242 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*) widget
;
243 nsCOMPtr
<nsPIDOMWindow
> piWin
;
245 moz
->EmbedRef
->GetPIDOMWindow( getter_AddRefs( piWin
) );
246 if( !piWin
) return Pt_CONTINUE
;
248 nsIFocusController
*focusController
= piWin
->GetRootFocusController();
249 if( focusController
)
250 focusController
->SetActive( PR_TRUE
);
252 if( moz
->toActivate
) {
260 static int child_losing_focus( PtWidget_t
*widget
, PtWidget_t
*child
, PhEvent_t
*ev
) {
261 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*) widget
;
262 nsCOMPtr
<nsPIDOMWindow
> piWin
;
264 moz
->EmbedRef
->GetPIDOMWindow( getter_AddRefs( piWin
) );
265 if( !piWin
) return Pt_CONTINUE
;
267 nsIFocusController
*focusController
= piWin
->GetRootFocusController();
268 if( focusController
)
269 focusController
->SetActive( PR_FALSE
);
278 mozilla_extent(PtWidget_t
*widget
)
280 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*) widget
;
282 PtSuperClassExtent(PtContainer
, widget
);
284 moz
->EmbedRef
->Position(widget
->area
.pos
.x
, widget
->area
.pos
.y
);
285 moz
->EmbedRef
->Size(widget
->area
.size
.w
, widget
->area
.size
.h
);
288 // set resources function
290 mozilla_modify( PtWidget_t
*widget
, PtArg_t
const *argt
, PtResourceRec_t
const *mod
)
292 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*)widget
;
293 nsIPref
*pref
= moz
->EmbedRef
->GetPrefs();
297 case Pt_ARG_MOZ_GET_URL
:
298 MozLoadURL(moz
, (char *)(argt
->value
));
301 case Pt_ARG_MOZ_NAVIGATE_PAGE
:
304 if (argt
->value
== Pt_WEB_DIRECTION_FWD
)
305 moz
->EmbedRef
->Forward();
306 else if (argt
->value
== Pt_WEB_DIRECTION_BACK
)
307 moz
->EmbedRef
->Back();
312 PtWidgetDim(widget
, &dim
);
313 dim
.w
= (argt
->value
* dim
.w
)/100;
314 dim
.h
= (argt
->value
* dim
.h
)/100;
316 if (argt
->value
== Pt_WEB_DIRECTION_UP
)
317 moz
->EmbedRef
->ScrollUp(dim
.h
);
318 else if (argt
->value
== Pt_WEB_DIRECTION_DOWN
)
319 moz
->EmbedRef
->ScrollDown(dim
.h
);
320 else if (argt
->value
== Pt_WEB_DIRECTION_LEFT
)
321 moz
->EmbedRef
->ScrollLeft(dim
.w
);
322 else if (argt
->value
== Pt_WEB_DIRECTION_RIGHT
)
323 moz
->EmbedRef
->ScrollRight(dim
.w
);
328 case Pt_ARG_MOZ_STOP
:
330 moz
->EmbedRef
->Stop();
333 case Pt_ARG_MOZ_RELOAD
:
335 moz
->EmbedRef
->Reload(0);
338 case Pt_ARG_MOZ_PRINT
:
340 PpPrintContext_t
*pc
= ( PpPrintContext_t
* ) argt
->value
;
341 moz
->EmbedRef
->Print(pc
);
345 case Pt_ARG_MOZ_OPTION
:
346 mozilla_set_pref(widget
, (char*)argt
->len
, (char*)argt
->value
);
349 case Pt_ARG_MOZ_ENCODING
: {
350 char translation
[1024];
351 strcpy( translation
, (char*)argt
->value
);
352 fix_translation_string( translation
);
353 pref
->SetUnicharPref( "intl.charset.default", NS_ConvertASCIItoUTF16( translation
).get());
354 pref
->SavePrefFile( nsnull
);
358 case Pt_ARG_MOZ_COMMAND
: {
359 PtWebClient2Command_t
*wdata
= ( PtWebClient2Command_t
* ) argt
->len
;
360 switch ((int)(argt
->value
))
362 case Pt_MOZ_COMMAND_CUT
: {
363 moz
->EmbedRef
->Cut(wdata
?wdata
->ClipboardInfo
.input_group
:1);
366 case Pt_MOZ_COMMAND_COPY
: {
367 moz
->EmbedRef
->Copy(wdata
?wdata
->ClipboardInfo
.input_group
:1);
370 case Pt_MOZ_COMMAND_PASTE
: {
371 moz
->EmbedRef
->Paste(wdata
?wdata
->ClipboardInfo
.input_group
:1);
374 case Pt_MOZ_COMMAND_SELECTALL
: {
375 moz
->EmbedRef
->SelectAll();
378 case Pt_MOZ_COMMAND_CLEAR
: {
379 moz
->EmbedRef
->Clear();
383 case Pt_MOZ_COMMAND_FIND
: {
384 nsCOMPtr
<nsIWebBrowserFind
> finder( do_GetInterface( moz
->EmbedRef
->mWindow
->mWebBrowser
) );
385 finder
->SetSearchString( NS_ConvertASCIItoUTF16(wdata
->FindInfo
.string
).get() );
386 finder
->SetMatchCase( wdata
->FindInfo
.flags
& Pt_WEB_FIND_MATCH_CASE
);
387 finder
->SetFindBackwards( wdata
->FindInfo
.flags
& Pt_WEB_FIND_GO_BACKWARDS
);
388 finder
->SetWrapFind( wdata
->FindInfo
.flags
& Pt_WEB_FIND_START_AT_TOP
);
389 finder
->SetEntireWord( wdata
->FindInfo
.flags
& Pt_WEB_FIND_MATCH_WHOLE_WORDS
);
392 finder
->FindNext( &didFind
);
396 case Pt_MOZ_COMMAND_SAVEAS
: {
397 char *dirname
= ( char * ) calloc( 1, strlen( wdata
->SaveasInfo
.filename
+ 7 ) );
399 sprintf( dirname
, "%s_files", wdata
->SaveasInfo
.filename
);
400 moz
->EmbedRef
->SaveAs( wdata
->SaveasInfo
.filename
, dirname
);
409 case Pt_ARG_MOZ_WEB_DATA_URL
:
411 // moz->MyBrowser->WebBrowserContainer->OpenStream( moz->MyBrowser->WebBrowser, "file://", "text/html" );
412 // strcpy( moz->url, (char*)argt->value );
416 case Pt_ARG_MOZ_UNKNOWN_RESP
: {
417 PtWebClient2UnknownData_t
*unknown
= ( PtWebClient2UnknownData_t
* ) argt
->value
;
418 if( unknown
->response
== Pt_WEB_RESPONSE_CANCEL
) {
419 EmbedDownload
*d
= FindDownload( moz
, unknown
->download_ticket
);
421 if( d
->mLauncher
) d
->mLauncher
->Cancel(NS_BINDING_ABORTED
); /* this will also call the EmbedDownload destructor */
422 else if( d
->mPersist
) d
->mPersist
->CancelSave(); /* this will also call the EmbedDownload destructor */
423 else delete d
; /* just in case neither d->mLauncher or d->mPersist was set */
429 case Pt_ARG_MOZ_DOWNLOAD
:
431 MozSaveTarget( (char*)argt
->value
, moz
);
435 case Pt_ARG_MOZ_WEB_DATA
: {
437 WWWRequest
*req
= ( WWWRequest
* ) argt
->value
;
441 if( strcmp( moz
->url
, req
->DataHdr
.url
) ) break;
443 hdata
= (char*) argt
->len
;
444 len
= req
->DataHdr
.length
;
446 switch( req
->DataHdr
.type
) {
447 case Pt_WEB_DATA_HEADER
:
448 if( !moz
->MyBrowser
->WebBrowserContainer
->IsStreaming( ) ) break;
450 /* request the document body */
451 if( moz
->web_data_req_cb
) {
452 PtCallbackInfo_t cbinfo
;
453 PtMozillaDataRequestCb_t cb
;
455 memset( &cbinfo
, 0, sizeof( cbinfo
) );
456 cbinfo
.reason
= Pt_CB_MOZ_WEB_DATA_REQ
;
458 cb
.type
= Pt_WEB_DATA_BODY
;
461 PtInvokeCallbackList( moz
->web_data_req_cb
, (PtWidget_t
*)moz
, &cbinfo
);
464 case Pt_WEB_DATA_BODY
: {
465 if( !moz
->MyBrowser
->WebBrowserContainer
->IsStreaming( ) ) break;
467 moz
->MyBrowser
->WebBrowserContainer
->AppendToStream( hdata
, len
);
468 else moz
->MyBrowser
->WebBrowserContainer
->CloseStream( );
470 /* request the next piece of the body */
471 PtCallbackInfo_t cbinfo
;
472 PtMozillaDataRequestCb_t cb
;
474 memset( &cbinfo
, 0, sizeof( cbinfo
) );
475 cbinfo
.reason
= Pt_CB_MOZ_WEB_DATA_REQ
;
477 cb
.type
= len
? Pt_WEB_DATA_BODY
: Pt_WEB_DATA_CLOSE
;
480 PtInvokeCallbackList( moz
->web_data_req_cb
, (PtWidget_t
*)moz
, &cbinfo
);
483 case Pt_WEB_DATA_CLOSE
:
484 if( !moz
->MyBrowser
->WebBrowserContainer
->IsStreaming( ) ) break;
485 moz
->MyBrowser
->WebBrowserContainer
->CloseStream( );
497 // get resources function
499 mozilla_get_info( PtWidget_t
*widget
, PtArg_t
*argt
, PtResourceRec_t
const *mod
)
501 PtMozillaWidget_t
*moz
= (PtMozillaWidget_t
*) widget
;
502 nsIPref
*pref
= moz
->EmbedRef
->GetPrefs();
506 case Pt_ARG_MOZ_NAVIGATE_PAGE
:
507 moz
->navigate_flags
= 0;
508 if (moz
->EmbedRef
->CanGoBack())
509 moz
->navigate_flags
|= ( 1 << Pt_WEB_DIRECTION_BACK
);
510 if (moz
->EmbedRef
->CanGoForward())
511 moz
->navigate_flags
|= ( 1 << Pt_WEB_DIRECTION_FWD
);
512 *((int **)argt
->value
) = &moz
->navigate_flags
;
515 case Pt_ARG_MOZ_OPTION
:
516 mozilla_get_pref( widget
, (char*)argt
->len
, (char*) argt
->value
);
519 case Pt_ARG_MOZ_GET_CONTEXT
: {
520 if( argt
->len
& Pt_MOZ_CONTEXT_LINK
)
521 *(char**) argt
->value
= moz
->rightClickUrl_link
;
522 else if( argt
->len
& Pt_MOZ_CONTEXT_IMAGE
)
523 *(char**) argt
->value
= moz
->rightClickUrl_image
;
524 else *(char**) argt
->value
= moz
->rightClickUrl_link
;
528 case Pt_ARG_MOZ_ENCODING
:
530 PRUnichar
*charset
= nsnull
;
531 static char encoding
[256];
532 pref
->GetLocalizedUnicharPref( "intl.charset.default", &charset
);
533 strcpy( encoding
, NS_ConvertUTF16toUTF8(charset
).get() );
534 *(char**)argt
->value
= encoding
;
538 case Pt_ARG_MOZ_GET_HISTORY
:
540 PtWebClientHistory_t
*hist_info
= (PtWebClientHistory_t
*)argt
->len
;
541 PtWebClientHistoryData_t
*HistoryReplyBuf
= (PtWebClientHistoryData_t
*) argt
->value
;
544 moz
->EmbedRef
->mSessionHistory
->GetCount( &total
);
546 for( i
=total
-2, j
=0; i
>=0 && j
<hist_info
->num
; i
--, j
++)
548 nsIHistoryEntry
*entry
;
549 moz
->EmbedRef
->mSessionHistory
->GetEntryAtIndex( i
, PR_FALSE
, &entry
);
553 entry
->GetTitle( &title
);
554 entry
->GetURI( &url
);
556 nsString
stitle( title
);
557 HistoryReplyBuf
[j
].title
= strdup( ToNewCString(stitle
) );
559 nsCAutoString specString
;
560 url
->GetSpec(specString
);
561 HistoryReplyBuf
[j
].url
= strdup( (char *) specString
.get() );
567 return (Pt_CONTINUE
);
572 mozilla_set_pref( PtWidget_t
*widget
, char *option
, char *value
)
574 PtMozillaWidget_t
*moz
= ( PtMozillaWidget_t
* ) widget
;
575 nsIPref
*pref
= moz
->EmbedRef
->GetPrefs();
578 mozilla_get_pref( widget
, option
, buffer
);
579 if( buffer
[0] && !strcmp( value
, buffer
) )
580 return; /* the option is already set */
583 if( !strcmp( option
, "A:visited color" ) ) {
584 pref
->SetUnicharPref( "browser.visited_color", NS_ConvertASCIItoUTF16(value
).get() );
586 else if( !strcmp( option
, "A:link color" ) ) {
587 pref
->SetUnicharPref( "browser.anchor_color", NS_ConvertASCIItoUTF16(value
).get() );
590 /* the mozserver already has A:link color == browser.anchor_color for this */
591 // else if( !strcmp( option, "A:active color" ) ) {
592 // pref->SetUnicharPref( "browser.anchor_color", NS_ConvertASCIItoUTF16(value).get() );
595 else if( !strcmp( option
, "BODY color" ) ) {
596 pref
->SetUnicharPref( "browser.display.foreground_color", NS_ConvertASCIItoUTF16(value
).get() );
598 else if( !strcmp( option
, "BODY background" ) ) {
599 pref
->SetUnicharPref( "browser.display.background_color", NS_ConvertASCIItoUTF16(value
).get() );
601 else if( !strcmp( option
, "bIgnoreDocumentAttributes" ) )
602 pref
->SetBoolPref( "browser.display.use_document_colors", stricmp( value
, "TRUE" ) ? PR_FALSE
: PR_TRUE
);
603 else if( !strcmp( option
, "bUnderlineLinks" ) ) {
604 pref
->SetBoolPref( "browser.underline_anchors", !stricmp( value
, "TRUE" ) ? PR_TRUE
: PR_FALSE
);
606 else if( !strcmp( option
, "iUserTextSize" ) ) {
607 moz
->text_zoom
= atoi( value
);
608 nsCOMPtr
<nsIDOMWindow
> domWindow
;
609 moz
->EmbedRef
->mWindow
->mWebBrowser
->GetContentDOMWindow(getter_AddRefs(domWindow
));
611 domWindow
->SetTextZoom( moz
->text_zoom
/100. );
613 domWindow
->GetTextZoom( &vv
);
614 moz
->actual_text_zoom
= (int) ( vv
* 100 );
617 else if( !strcmp( option
, "BODY font-family" ) ) {
618 /* set the current font */
619 char *font_default
= NULL
;
620 char preference
[256];
622 pref
->CopyCharPref( "font.default.x-western", &font_default
);
623 if( !font_default
) font_default
= "serif";
625 sprintf( preference
, "font.name.%s.x-western", font_default
);
626 pref
->SetCharPref( preference
, value
);
628 else if( !strcmp( option
, "PRE font-family" ) ) {
629 pref
->SetCharPref( "font.name.monospace.x-western", value
);
631 else if( !strcmp( option
, "H* font-family" ) ) {
632 /* do not set these - use the BODY font-family instead */
636 else if( !strcmp( option
, "socks_server" ) ) ; /* not used */
637 else if( !strcmp( option
, "socks_port" ) ) ; /* not used */
638 else if( !strcmp( option
, "socks_user" ) ) ; /* not used */
639 else if( !strcmp( option
, "socks_app" ) ) ; /* not used */
643 else if( !strcmp( option
, "enable_proxy" ) ) {
644 if( value
&& !stricmp( value
, "yes" ) )
645 pref
->SetIntPref( "network.proxy.type", 1 );
646 else pref
->SetIntPref( "network.proxy.type", 0 );
648 else if( !strcmp( option
, "http_proxy_host" ) ) {
649 pref
->SetCharPref( "network.proxy.http", value
);
651 else if( !strcmp( option
, "http_proxy_port" ) ) {
652 pref
->SetIntPref( "network.proxy.http_port", atoi(value
) );
654 else if( !strcmp( option
, "proxy_overrides" ) ) {
655 pref
->SetCharPref( "network.proxy.no_proxies_on", value
);
657 else if( !strcmp( option
, "https_proxy_host" ) ) {
658 pref
->SetCharPref( "network.proxy.ssl", value
);
660 else if( !strcmp( option
, "https_proxy_port" ) ) {
661 pref
->SetIntPref( "network.proxy.ssl_port", atoi(value
) );
666 else if( !strcmp( option
, "ftp_proxy_host" ) )
667 pref
->SetCharPref( "network.proxy.ftp", value
);
668 else if( !strcmp( option
, "ftp_proxy_port" ) )
669 pref
->SetIntPref( "network.proxy.ftp_port", atoi(value
) );
670 else if( !strcmp( option
, "email_address" ) ) ; /* not used */
673 else if( !strcmp( option
, "gopher_proxy_host" ) )
674 pref
->SetCharPref( "network.proxy.gopher", value
);
675 else if( !strcmp( option
, "gopher_proxy_port" ) )
676 pref
->SetIntPref( "network.proxy.gopher_port", atoi(value
) );
679 else if( !strcmp( option
, "max_connections" ) )
680 pref
->SetIntPref( "network.http.max-connections", atoi( value
) );
682 /* Disk-cache options */
683 else if( !strcmp( option
, "main_cache_kb_size" ) )
684 pref
->SetIntPref( "browser.cache.disk.capacity", atoi( value
) );
685 else if( !strcmp( option
, "enable_disk_cache" ) )
686 pref
->SetBoolPref( "browser.cache.disk.enable", !stricmp( value
, "TRUE" ) ? PR_TRUE
: PR_FALSE
);
687 else if( !strcmp( option
, "dcache_verify_policy" ) ) {
688 int n
= atoi( value
), moz_value
=3;
689 if( n
== 0 ) moz_value
= 2; /* never */
690 else if( n
== 1 ) moz_value
= 0; /* once */
691 else if( n
== 2 ) moz_value
= 1; /* always */
693 // mozilla wants: 0 = once-per-session, 1 = each-time, 2 = never, 3 = when-appropriate/automatically
694 pref
->SetIntPref( "browser.cache.check_doc_frequency", moz_value
);
696 else if( !strcmp( option
, "main_cache_dir" ) ) ; /* not used */
697 else if( !strcmp( option
, "main_index_file" ) ) ; /* not used */
698 else if( !strcmp( option
, "clear_main_cache_on_exit" ) ) ; /* not used */
699 else if( !strcmp( option
, "keep_index_file_updated" ) ) ; /* not used */
701 /* memory cache options */
702 else if( !strcmp( option
, "memory_cache_kb_size" ) || !strcmp( option
, "image_cache_size_KB" ) ) {
703 int kb
= atoi( value
);
704 if( kb
<= 0 ) kb
= 100; /* have a minimum threshold */
705 pref
->SetIntPref( "browser.cache.memory.capacity", kb
);
708 /* Miscellaneous options */
709 else if( !strcmp( option
, "History_Expire" ) )
710 pref
->SetIntPref( "browser.history_expire_days", atoi( value
) );
711 else if( !strcmp( option
, "Page_History_Length" ) )
712 pref
->SetIntPref( "browser.sessionhistory.max_entries", atoi( value
) );
717 else if( !strcmp( option
, "bAutoLoadImages" ) ) ; /* not used */
718 else if( !strcmp( option
, "iReformatHandling" ) ) ; /* not used */
719 else if( !strcmp( option
, "BODY margin-top" ) ) ; /* not used */
720 else if( !strcmp( option
, "BODY margin-right" ) ) ; /* not used */
721 else if( !strcmp( option
, "iScrollbarSize" ) ) ; /* not used */
722 else if( !strcmp( option
, "top_focus_color" ) ) ; /* not used */
723 else if( !strcmp( option
, "bot_focus_color" ) ) ; /* not used */
724 else if( !strcmp( option
, "top_border_color" ) ) ; /* not used */
725 else if( !strcmp( option
, "bot_border_color" ) ) ; /* not used */
726 else if( !strcmp( option
, "bview_source" ) ) ; /* not used */
727 else if( !strcmp( option
, "underline_width" ) ) ; /* not used */
728 else if( !strcmp( option
, "bkey_mode" ) ) ; /* not used */
729 else if( !strcmp( option
, "mono_form_font" ) ) ; /* not used */
730 else if( !strcmp( option
, "form_font" ) ) ; /* not used */
731 else if( !strcmp( option
, "frame_spacing" ) ) ; /* not used */
732 else if( !strcmp( option
, "disable_new_windows" ) ) /* disable new windows*/
734 if (strcmp(value
, "TRUE") == 0)
735 moz
->disable_new_windows
= 1;
737 moz
->disable_new_windows
= 0;
739 else if( !strcmp( option
, "disable_exception_dlg" ) ) /* disable exception dialogs */
741 if (strcmp(value
, "TRUE") == 0)
742 moz
->disable_exception_dlg
= 1;
744 moz
->disable_exception_dlg
= 0;
747 else if( !strcmp( option
, "bDisableHighlight" ) ) ; /* not used */
749 /* HTTP cookie options */
750 else if( !strcmp( option
, "cookiejar_path" ) ) ; /* not used */
751 else if( !strcmp( option
, "cookiejar_name" ) ) ; /* not used */
752 else if( !strcmp( option
, "cookiejar_size" ) ) ; /* not used */
753 else if( !strcmp( option
, "cookiejar_save_always" ) ) ; /* not used */
755 /* Authentication options */
756 else if( !strcmp( option
, "max_password_guesses" ) ) ; /* not used */
759 else if( !strcmp( option
, "file_display_dir" ) ) ; /* not used */
762 else if( !strcmp( option
, "bProgressiveImageDisplay" ) ) ; /* not used */
763 else if( !strcmp( option
, "quantize_jpegs" ) ) ; /* not used */
764 else if( !strcmp( option
, "concurrent_decodes" ) ) ; /* not used */
768 else if( !strcmp( option
, "Print_Header_Font" ) ) ; /* not used */
769 else if( !strcmp( option
, "Print_Header_Font_Size" ) ) ; /* not used */
770 else if( !strcmp( option
, "Print_Left_Header_String" ) ) {
771 if( g_Print_Left_Header_String
) free( g_Print_Left_Header_String
);
772 g_Print_Left_Header_String
= strdup( value
);
774 else if( !strcmp( option
, "Print_Right_Header_String" ) ) {
775 if( g_Print_Right_Header_String
) free( g_Print_Right_Header_String
);
776 g_Print_Right_Header_String
= strdup( value
);
778 else if( !strcmp( option
, "Print_Left_Footer_String" ) ) {
779 if( g_Print_Left_Footer_String
) free( g_Print_Left_Footer_String
);
780 g_Print_Left_Footer_String
= strdup( value
);
782 else if( !strcmp( option
, "Print_Right_Footer_String" ) ) {
783 if( g_Print_Right_Footer_String
) free( g_Print_Right_Footer_String
);
784 g_Print_Right_Footer_String
= strdup( value
);
788 /* Miscellaneous options */
789 else if( !strcmp( option
, "Global_History_File" ) ) ; /* not used */
790 else if( !strcmp( option
, "IBeam_Cursor" ) ) ; /* not used */
791 else if( !strcmp( option
, "Image_Cache_Size_KB" ) ) ; /* not used */
792 else if( !strcmp( option
, "ImageMap_Cursor" ) ) ; /* not used */
793 else if( !strcmp( option
, "ImageMap_Cursor_NoLink" ) ) ; /* not used */
794 else if( !strcmp( option
, "Link_Cursor" ) ) ; /* not used */
795 else if( !strcmp( option
, "LinkWait_Cursor" ) ) ; /* not used */
796 else if( !strcmp( option
, "Normal_Cursor" ) ) ; /* not used */
797 else if( !strcmp( option
, "NormalWait_Cursor" ) ) ; /* not used */
798 else if( !strcmp( option
, "Page_Cache_Size" ) ) ; /* not used */
799 else if( !strcmp( option
, "Safe_Memory_Free" ) ) ; /* not used */
800 else if( !strcmp( option
, "Site_History_Length" ) ) ; /* not used */
801 else if( !strcmp( option
, "Show_Server_Errors" ) ) ; /* not used */
802 else if( !strcmp( option
, "Use_Anti_Alias" ) ) ; /* not used */
803 else if( !strcmp( option
, "Use_Explicit_Accept_Headers" ) ) ; /* not used */
804 else if( !strcmp( option
, "Visitation_Horizon" ) ) ; /* not used */
806 else if( !strcmp( option
, "Print_Frame" ) )
807 pref
->SetCharPref( "user.print.print_frame", value
);
808 else if( !strcmp( option
, "SetPrintBGColors" ) )
809 pref
->SetCharPref( "user.print.SetPrintBGColors", value
);
810 else if( !strcmp( option
, "SetPrintBGImages" ) )
811 pref
->SetCharPref( "user.print.SetPrintBGImages", value
);
813 pref
->SavePrefFile( nsnull
);
816 static void mozilla_get_pref( PtWidget_t
*widget
, char *option
, char *value
) {
817 PtMozillaWidget_t
*moz
= ( PtMozillaWidget_t
* ) widget
;
818 nsIPref
*pref
= moz
->EmbedRef
->GetPrefs();
821 if( !strcmp( option
, "A:link color" ) || !strcmp( option
, "A:active color" ) ) {
822 nsXPIDLCString colorStr
;
823 if( pref
->CopyCharPref( "browser.anchor_color", getter_Copies(colorStr
) ) == NS_OK
)
824 strcpy( value
, colorStr
);
826 else if( !strcmp( option
, "A:visited color" ) ) {
827 nsXPIDLCString colorStr
;
828 if( pref
->CopyCharPref( "browser.visited_color", getter_Copies(colorStr
) ) == NS_OK
)
829 strcpy( value
, colorStr
);
831 else if( !strcmp( option
, "BODY color" ) ) {
832 nsXPIDLCString colorStr
;
833 if( pref
->CopyCharPref( "browser.display.foreground_color", getter_Copies(colorStr
) ) == NS_OK
)
834 strcpy( value
, colorStr
);
836 else if( !strcmp( option
, "BODY background" ) ) {
837 nsXPIDLCString colorStr
;
838 if( pref
->CopyCharPref( "browser.display.background_color", getter_Copies(colorStr
) ) == NS_OK
)
839 strcpy( value
, colorStr
);
841 else if( !strcmp( option
, "bIgnoreDocumentAttributes" ) ) {
843 pref
->GetBoolPref( "browser.display.use_document_colors", &val
);
844 sprintf( value
, "%s", val
== PR_TRUE
? "FALSE" : "TRUE" );
846 else if( !strcmp( option
, "disable_new_windows" ) ) {
847 sprintf( value
, "%s", (moz
->disable_new_windows
== 1) ? "TRUE" : "FALSE" );
849 else if( !strcmp( option
, "disable_exception_dlg" ) ) {
850 sprintf( value
, "%s", (moz
->disable_exception_dlg
== 1) ? "TRUE" : "FALSE" );
852 else if( !strcmp( option
, "bUnderlineLinks" ) ) {
854 pref
->GetBoolPref( "browser.underline_anchors", &val
);
855 sprintf( value
, "%s", val
== PR_TRUE
? "TRUE" : "FALSE" );
857 else if( !strcmp( option
, "iUserTextSize" ) ) {
858 sprintf( value
, "%d", moz
->text_zoom
);
860 else if( !strcmp( option
, "BODY font-family" ) || !strcmp( option
, "H* font-family" ) ) {
861 /* set the current font */
862 char *font_default
= NULL
, *font
;
863 char preference
[256];
865 pref
->CopyCharPref( "font.default.x-western", &font_default
);
866 if( !font_default
) font_default
= "serif";
868 sprintf( preference
, "font.name.%s.x-western", font_default
);
869 if( pref
->CopyCharPref( preference
, &font
) == NS_OK
)
870 strcpy( value
, font
);
872 else if( !strcmp( option
, "PRE font-family" ) ) {
873 /* set the current font */
875 if( pref
->CopyCharPref( "font.name.monospace.x-western", &font
) == NS_OK
)
876 strcpy( value
, font
);
880 else if( !strcmp( option
, "http_proxy_host" ) ) {
882 if( pref
->CopyCharPref( "network.proxy.http", &s
) == NS_OK
)
885 else if( !strcmp( option
, "http_proxy_port" ) ) {
887 pref
->GetIntPref( "network.proxy.http_port", &n
);
888 sprintf( value
, "%d", n
);
890 else if( !strcmp( option
, "proxy_overrides" ) ) {
892 if( pref
->CopyCharPref( "network.proxy.no_proxies_on", &s
) == NS_OK
)
895 else if( !strcmp( option
, "https_proxy_host" ) ) {
897 if( pref
->CopyCharPref( "network.proxy.ssl", &s
) == NS_OK
)
900 else if( !strcmp( option
, "https_proxy_port" ) ) {
902 pref
->GetIntPref( "network.proxy.ssl_port", &n
);
903 sprintf( value
, "%d", n
);
908 else if( !strcmp( option
, "ftp_proxy_host" ) ) {
910 if( pref
->CopyCharPref( "network.proxy.ftp", &s
) == NS_OK
)
913 else if( !strcmp( option
, "ftp_proxy_port" ) ) {
915 pref
->GetIntPref( "network.proxy.ftp_port", &n
);
916 sprintf( value
, "%d", n
);
920 else if( !strcmp( option
, "gopher_proxy_host" ) ) {
922 if( pref
->CopyCharPref( "network.proxy.gopher", &s
) == NS_OK
)
925 else if( !strcmp( option
, "gopher_proxy_port" ) ) {
927 pref
->GetIntPref( "gopher_proxy_port", &n
);
928 sprintf( value
, "%d", n
);
932 else if( !strcmp( option
, "max_connections" ) ) {
934 pref
->GetIntPref( "network.http.max-connections", &n
);
935 sprintf( value
, "%d", n
);
938 /* Disk-cache options */
939 else if( !strcmp( option
, "main_cache_kb_size" ) ) {
941 pref
->GetIntPref( "browser.cache.disk.capacity", &n
);
942 sprintf( value
, "%d", n
);
944 else if( !strcmp( option
, "enable_disk_cache" ) ) {
946 pref
->GetBoolPref( "browser.cache.disk.enable", &val
);
947 sprintf( value
, "%s", val
== PR_TRUE
? "TRUE" : "FALSE" );
949 else if( !strcmp( option
, "dcache_verify_policy" ) ) {
950 int n
, voyager_value
= 0;
951 pref
->GetIntPref( "browser.cache.check_doc_frequency", &n
);
952 // 0 = once-per-session, 1 = each-time, 2 = never, 3 = when-appropriate/automatically
953 if( n
== 0 ) voyager_value
= 1; /* voyager: 1 = once per session */
954 else if( n
== 1 ) voyager_value
= 2; /* voyager: 2 = always */
955 else if( n
== 2 ) voyager_value
= 0; /* voyager: 0 = never */
956 else voyager_value
= 1; /* mapp the when-appropriate/automatically to the once per session */
957 sprintf( value
, "%d", voyager_value
);
960 /* Miscellaneous options */
961 else if( !strcmp( option
, "History_Expire" ) ) {
963 pref
->GetIntPref( "browser.history_expire_days", &n
);
964 sprintf( value
, "%d", n
);
966 else if( !strcmp( option
, "Page_History_Length" ) ) {
968 pref
->GetIntPref( "browser.sessionhistory.max_entries", &n
);
969 sprintf( value
, "%d", n
);
972 else if( !strcmp( option
, "clear_main_cache_on_exit" ) ) {
973 strcpy( value
, "FALSE" ); /* even if not used, match this with the default value */
975 else if( !strcmp( option
, "quantize_jpegs" ) ) {
976 strcpy( value
, "FALSE" ); /* even if not used, match this with the default value */
978 else if( !strcmp( option
, "ServerId" ) ) {
979 strcpy( value
, "mozserver" );
985 int sProfileDirCreated
;
986 static int StartupProfile( char *sProfileDir
)
988 // initialize profiles
992 nsCOMPtr
<nsILocalFile
> profileDir
;
993 PRBool exists
= PR_FALSE
;
994 PRBool isDir
= PR_FALSE
;
995 profileDir
= do_CreateInstance(NS_LOCAL_FILE_CONTRACTID
);
996 rv
= profileDir
->InitWithNativePath(nsDependentCString(sProfileDir
));
998 return NS_ERROR_FAILURE
;
999 profileDir
->Exists(&exists
);
1000 profileDir
->IsDirectory(&isDir
);
1001 // if it exists and it isn't a directory then give up now.
1004 rv
= profileDir
->Create(nsIFile::DIRECTORY_TYPE
, 0700);
1006 return NS_ERROR_FAILURE
;
1007 sProfileDirCreated
= 1;
1009 else if (exists
&& !isDir
)
1010 return NS_ERROR_FAILURE
;
1012 nsCOMPtr
<nsProfileDirServiceProvider
> locProvider
;
1013 NS_NewProfileDirServiceProvider(PR_TRUE
, getter_AddRefs(locProvider
));
1015 return NS_ERROR_FAILURE
;
1017 // Directory service holds an strong reference to any
1018 // provider that is registered with it. Let it hold the
1019 // only ref. locProvider won't die when we leave this scope.
1020 rv
= locProvider
->Register();
1023 rv
= locProvider
->SetProfileDir(profileDir
);
1031 // startup the mozilla embedding engine
1032 static int StartupEmbedding()
1036 #ifdef _BUILD_STATIC_BIN
1037 // Initialize XPCOM's module info table
1038 NSGetStaticModuleInfo
= ph_getModuleInfo
;
1041 rv
= NS_InitEmbedding(nsnull
, nsnull
);
1042 if( NS_FAILED( rv
) ) return -1;
1045 profile_dir
= (char *)alloca(strlen(getenv("HOME")) + strlen("/.ph/mozilla") + 1);
1046 sprintf(profile_dir
, "%s/.ph/mozilla", getenv("HOME"));
1047 rv
= StartupProfile( profile_dir
);
1048 if( NS_FAILED( rv
) )
1049 NS_WARNING("Warning: Failed to start up profiles.\n");
1051 nsCOMPtr
<nsIAppShell
> appShell
;
1052 appShell
= do_CreateInstance(kAppShellCID
);
1054 NS_WARNING("Failed to create appshell in EmbedPrivate::PushStartup!\n");
1057 nsIAppShell
* sAppShell
= appShell
.get();
1058 NS_ADDREF(sAppShell
);
1059 sAppShell
->Create(0, nsnull
);
1060 sAppShell
->Spinup();
1064 /* the translation string that is passed by voyager ( Pt_ARG_WEB_ENCODING ) ( taken from /usr/photon/translations/charsets ->mime field ) */
1065 /* is required to be in a different form by the mozilla browser */
1066 static void fix_translation_string( char *string
) {
1067 /* for instance it has to be windows-1252 not Windows-1252 */
1068 if( !strncmp( string
, "Windows", 7 ) ) *string
= 'w';
1071 // PtMozilla class creation function
1072 PtWidgetClass_t
*PtCreateMozillaClass( void )
1074 static const PtResourceRec_t resources
[] =
1076 { Pt_ARG_MOZ_GET_URL
, mozilla_modify
, Pt_QUERY_PREVENT
},
1077 { Pt_ARG_MOZ_NAVIGATE_PAGE
, mozilla_modify
, mozilla_get_info
},
1078 { Pt_ARG_MOZ_RELOAD
, mozilla_modify
, Pt_QUERY_PREVENT
},
1079 { Pt_ARG_MOZ_STOP
, mozilla_modify
, Pt_QUERY_PREVENT
},
1080 { Pt_ARG_MOZ_PRINT
, mozilla_modify
, Pt_QUERY_PREVENT
},
1081 { Pt_ARG_MOZ_COMMAND
, mozilla_modify
, Pt_QUERY_PREVENT
},
1082 { Pt_ARG_MOZ_OPTION
, mozilla_modify
, mozilla_get_info
},
1083 { Pt_ARG_MOZ_GET_CONTEXT
, NULL
, mozilla_get_info
},
1084 { Pt_ARG_MOZ_GET_HISTORY
, NULL
, mozilla_get_info
},
1085 { Pt_ARG_MOZ_ENCODING
, mozilla_modify
, mozilla_get_info
},
1086 { Pt_ARG_MOZ_WEB_DATA_URL
, mozilla_modify
, Pt_QUERY_PREVENT
},
1087 { Pt_ARG_MOZ_WEB_DATA
, mozilla_modify
, Pt_QUERY_PREVENT
},
1088 { Pt_ARG_MOZ_UNKNOWN_RESP
, mozilla_modify
, Pt_QUERY_PREVENT
},
1089 { Pt_ARG_MOZ_DOWNLOAD
, mozilla_modify
, Pt_QUERY_PREVENT
},
1090 { Pt_ARG_MOZ_AUTH_CTRL
, NULL
, NULL
, Pt_ARG_IS_POINTER( PtMozillaWidget_t
, moz_auth_ctrl
) },
1091 { Pt_ARG_MOZ_UNKNOWN_CTRL
, NULL
, NULL
, Pt_ARG_IS_POINTER( PtMozillaWidget_t
, moz_unknown_ctrl
) },
1092 { Pt_CB_MOZ_INFO
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, info_cb
) },
1093 { Pt_CB_MOZ_START
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, start_cb
) },
1094 { Pt_CB_MOZ_COMPLETE
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, complete_cb
) },
1095 { Pt_CB_MOZ_PROGRESS
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, progress_cb
) },
1096 { Pt_CB_MOZ_URL
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, url_cb
) },
1097 { Pt_CB_MOZ_EVENT
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, event_cb
) },
1098 { Pt_CB_MOZ_NET_STATE
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, net_state_cb
) },
1099 { Pt_CB_MOZ_NEW_WINDOW
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, new_window_cb
) },
1100 { Pt_CB_MOZ_NEW_AREA
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, resize_cb
) },
1101 { Pt_CB_MOZ_DESTROY
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, destroy_cb
) },
1102 { Pt_CB_MOZ_VISIBILITY
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, visibility_cb
) },
1103 { Pt_CB_MOZ_OPEN
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, open_cb
) },
1104 { Pt_CB_MOZ_DIALOG
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, dialog_cb
) },
1105 { Pt_CB_MOZ_AUTHENTICATE
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, auth_cb
) },
1106 { Pt_CB_MOZ_PROMPT
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, prompt_cb
) },
1107 { Pt_CB_MOZ_CONTEXT
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, context_cb
) },
1108 { Pt_CB_MOZ_PRINT_STATUS
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, print_status_cb
) },
1109 { Pt_CB_MOZ_WEB_DATA_REQ
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, web_data_req_cb
) },
1110 { Pt_CB_MOZ_UNKNOWN
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, web_unknown_cb
) },
1111 { Pt_CB_MOZ_ERROR
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, web_error_cb
) },
1112 { Pt_CB_MOZ_DOWNLOAD
, NULL
, NULL
, Pt_ARG_IS_CALLBACK_LIST(PtMozillaWidget_t
, web_download_cb
) }
1115 static const PtArg_t args
[] =
1117 { Pt_SET_VERSION
, 200},
1118 { Pt_SET_STATE_LEN
, sizeof( PtMozillaWidget_t
) },
1119 { Pt_SET_DFLTS_F
, (long)mozilla_defaults
},
1120 { Pt_SET_EXTENT_F
, (long)mozilla_extent
},
1121 { Pt_SET_FLAGS
, Pt_RECTANGULAR
, Pt_RECTANGULAR
},
1122 { Pt_SET_DESTROY_F
, (long) mozilla_destroy
},
1123 { Pt_SET_CHILD_GETTING_FOCUS_F
, ( long ) child_getting_focus
},
1124 { Pt_SET_CHILD_LOSING_FOCUS_F
, ( long ) child_losing_focus
},
1125 { Pt_SET_RESOURCES
, (long) resources
},
1126 { Pt_SET_NUM_RESOURCES
, sizeof( resources
)/sizeof( resources
[0] ) },
1127 { Pt_SET_DESCRIPTION
, (long) "PtMozilla" },
1130 if (StartupEmbedding() == -1)
1133 Init_nsUnknownContentTypeHandler_Factory( );
1135 nsCOMPtr
<nsIFactory
> promptFactory
;
1136 NS_NewPromptServiceFactory(getter_AddRefs(promptFactory
));
1138 nsCOMPtr
<nsIComponentRegistrar
> registrar
;
1139 NS_GetComponentRegistrar(getter_AddRefs(registrar
));
1140 registrar
->RegisterFactory(kPromptServiceCID
, "Prompt Service",
1141 "@mozilla.org/embedcomp/prompt-service;1",
1143 PtMozilla
->wclass
= PtCreateWidgetClass(PtContainer
, 0, sizeof(args
)/sizeof(args
[0]), args
);
1145 return (PtMozilla
->wclass
);