PRUnichar *ustring = mStr.ToNewUnicode(); moz->MyBrowser->mPrefs->SetUnicharPref( "intl.charset.default", ustring );
moz->MyBrowser->mPrefs->SetUnicharPref( "intl.charset.default", mStr.get() );
static void mozilla_modify( PtWidget_t *widget, PtArg_t const *argt ) {	PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;	switch( argt->type )  {		case Pt_ARG_MOZ_GET_URL:			MozLoadURL(moz, (char *)(argt->value));			break;		case Pt_ARG_MOZ_NAVIGATE_PAGE:			if (moz->MyBrowser->WebNavigation)			{				if (argt->value == WWW_DIRECTION_FWD)					moz->MyBrowser->WebNavigation->GoForward();				else					moz->MyBrowser->WebNavigation->GoBack();			}			break;		case Pt_ARG_MOZ_STOP:			if (moz->MyBrowser->WebNavigation)        moz->MyBrowser->WebNavigation->Stop(nsIWebNavigation::STOP_ALL);			break;		case Pt_ARG_MOZ_RELOAD:			if (moz->MyBrowser->WebNavigation)    			moz->MyBrowser->WebNavigation->Reload(0);			break;		case Pt_ARG_MOZ_PRINT: {			nsCOMPtr<nsIDOMWindow> window;			moz->MyBrowser->WebBrowser->GetContentDOMWindow(getter_AddRefs(window));			nsCOMPtr<nsIWebBrowserPrint> print( do_GetInterface( moz->MyBrowser->WebBrowser ) );									WWWRequest *pPageInfo = ( WWWRequest * ) argt->value;			PpPrintContext_t *pc = moz_construct_print_context( pPageInfo );			nsresult rv;			nsCOMPtr<nsIPrintOptions> printService =			             do_GetService(kPrintOptionsCID, &rv);			printService->SetEndPageRange( (PRInt32) pc ); /* use SetEndPageRange/GetEndPageRange to convey the print context */			print->Print( window, printService, moz->MyBrowser->WebBrowserContainer );		    }		    break;		case Pt_ARG_MOZ_OPTION:			mozilla_set_pref( widget, (char*)argt->len, (char*)argt->value );			break;		case Pt_ARG_MOZ_ENCODING: {			nsCString mStr( (char*)argt->value );			PRUnichar *ustring = mStr.ToNewUnicode();			moz->MyBrowser->mPrefs->SetUnicharPref( "intl.charset.default", ustring );			}			break;		case Pt_ARG_MOZ_COMMAND:			switch ((int)(argt->value)) {				case Pt_MOZ_COMMAND_CUT: {					nsCOMPtr<nsIContentViewer> viewer;					moz->MyBrowser->rootDocShell->GetContentViewer(getter_AddRefs(viewer));					nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));					edit->CutSelection();					}					break;				case Pt_MOZ_COMMAND_COPY: {					nsCOMPtr<nsIContentViewer> viewer;					moz->MyBrowser->rootDocShell->GetContentViewer(getter_AddRefs(viewer));					nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));					edit->CopySelection();					}					break;				case Pt_MOZ_COMMAND_PASTE: {					nsCOMPtr<nsIContentViewer> viewer;					moz->MyBrowser->rootDocShell->GetContentViewer(getter_AddRefs(viewer));					nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));					edit->Paste();					}					break;				case Pt_MOZ_COMMAND_SELECTALL: {					nsCOMPtr<nsIContentViewer> viewer;					moz->MyBrowser->rootDocShell->GetContentViewer(getter_AddRefs(viewer));					nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));					edit->SelectAll();					}					break;				case Pt_MOZ_COMMAND_CLEAR: {					nsCOMPtr<nsIContentViewer> viewer;					moz->MyBrowser->rootDocShell->GetContentViewer(getter_AddRefs(viewer));					nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));					edit->ClearSelection();					}					break;				case Pt_MOZ_COMMAND_FIND: {					PtWebCommand_t *wdata = ( PtWebCommand_t * ) argt->len;					nsCString searchString( wdata->FindInfo.szString );					nsCOMPtr<nsIWebBrowserFind> finder( do_GetInterface( moz->MyBrowser->WebBrowser ) );					PRUnichar *u = searchString.ToNewUnicode( );					finder->SetSearchString( u );					finder->SetMatchCase( wdata->FindInfo.flags & FINDFLAG_MATCH_CASE );					finder->SetFindBackwards( wdata->FindInfo.flags & FINDFLAG_GO_BACKWARDS );					finder->SetWrapFind( wdata->FindInfo.flags & FINDFLAG_START_AT_TOP );//				finder->SetEntireWord( entireWord ); /* not defined in voyager */					PRBool didFind;					finder->FindNext( &didFind );					Recycle( u );					break;					}				}			break;		case Pt_ARG_MOZ_WEB_DATA_URL:				moz->MyBrowser->WebBrowserContainer->OpenStream( moz->MyBrowser->WebBrowser, "file://", "text/html" );				strcpy( moz->url, (char*)argt->value );				break;		case Pt_ARG_MOZ_UNKNOWN_RESP: {				PtMozUnknownResp_t *data = ( PtMozUnknownResp_t * ) argt->value;				switch( data->response ) {					case WWW_RESPONSE_OK:						if( moz->MyBrowser->app_launcher ) {							if( moz->download_dest ) free( moz->download_dest );							moz->download_dest = strdup( data->filename );							moz->MyBrowser->app_launcher->SaveToDisk( NULL, PR_TRUE );							}						break;					case WWW_RESPONSE_CANCEL: {							moz->MyBrowser->app_launcher->Cancel( );							moz->MyBrowser->app_launcher->CloseProgressWindow( );							moz->MyBrowser->app_launcher = NULL;							}						break;					}				}				break;		case Pt_ARG_MOZ_DOWNLOAD: {				moz->MyBrowser->WebBrowserContainer->mSkipOnState = 1; /* ignore nsIWebProgressListener's CWebBrowserContainer::OnStateChange() for a while */				moz->MyBrowser->WebNavigation->LoadURI( NS_ConvertASCIItoUCS2( (char*) argt->value ).get(), nsIWebNavigation::LOAD_FLAGS_NONE);				if( moz->download_dest ) free( moz->download_dest );				moz->download_dest = strdup( (char*)argt->len );				}				break;		case Pt_ARG_MOZ_WEB_DATA: {				WWWRequest *req = ( WWWRequest * ) argt->value;				char *hdata;				int len;				if( strcmp( moz->url, req->DataHdr.url ) ) break;				hdata = (char*) argt->len;				len = req->DataHdr.length;				switch( req->DataHdr.type ) {					case WWW_DATA_HEADER:						if( !moz->MyBrowser->WebBrowserContainer->IsStreaming( ) ) break;						/* request the document body */						if( moz->web_data_req_cb ) {							PtCallbackInfo_t  cbinfo;							PtMozillaDataRequestCb_t cb;							memset( &cbinfo, 0, sizeof( cbinfo ) );							cbinfo.reason = Pt_CB_MOZ_WEB_DATA_REQ;							cbinfo.cbdata = &cb;							cb.type = WWW_DATA_BODY;							cb.length = 32768;							strcpy( cb.url, moz->url );							PtInvokeCallbackList( moz->web_data_req_cb, (PtWidget_t *)moz, &cbinfo);							}						break;					case WWW_DATA_BODY: {						if( !moz->MyBrowser->WebBrowserContainer->IsStreaming( ) ) break;						if( len )							moz->MyBrowser->WebBrowserContainer->AppendToStream( hdata, len );						else moz->MyBrowser->WebBrowserContainer->CloseStream( );						/* request the next piece of the body */						PtCallbackInfo_t  cbinfo;						PtMozillaDataRequestCb_t cb;						memset( &cbinfo, 0, sizeof( cbinfo ) );						cbinfo.reason = Pt_CB_MOZ_WEB_DATA_REQ;						cbinfo.cbdata = &cb;						cb.type = len ? WWW_DATA_BODY : WWW_DATA_CLOSE;						cb.length = 32768;						strcpy( cb.url, moz->url );						PtInvokeCallbackList( moz->web_data_req_cb, (PtWidget_t *)moz, &cbinfo);						}						break;					case WWW_DATA_CLOSE:						if( !moz->MyBrowser->WebBrowserContainer->IsStreaming( ) ) break;						moz->MyBrowser->WebBrowserContainer->CloseStream( );						break;					}				}			break;			}	return;	}