Remove old NSPR20 and MOCHA #ifdefs

This commit is contained in:
cyeh%netscape.com 1998-09-29 21:35:57 +00:00
Родитель 80d86afa27
Коммит 7dae289923
6 изменённых файлов: 0 добавлений и 2745 удалений

Просмотреть файл

@ -81,11 +81,7 @@ static DDSURFACEDESC ddsd;
extern "C" {
#ifndef NSPR20
PR_LOG_DEFINE(APPLET);
#else
extern PRLogModuleInfo *APPLET;
#endif
#ifdef LAYPROBE_API
extern "C" {

Просмотреть файл

@ -1,757 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "feembed.h"
#include "cntritem.h"
#include "ngdwtrst.h"
#include "cxdc.h"
#include "npapi.h"
#include "np.h"
#include "presentm.h"
#include "helper.h"
#include "il_icons.h"
#include "extgen.h"
#include "libevent.h"
extern "C" int MK_DISK_FULL; // defined in allxpstr.c
extern char *FE_FindFileExt(char * path);
extern "C" {
BOOL wfe_IsTypePlugin(NPEmbeddedApp* pEmbeddedApp)
{
CNetscapeCntrItem *pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data;
return (pEmbeddedApp->type == NP_Plugin) ? TRUE : FALSE;
}
CNetscapeCntrItem *wfe_GetCntrPtr(void* pDataObj) // where pDataObj is an URL struct
{
NPEmbeddedApp* pEmbeddedApp = (NPEmbeddedApp*)((URL_Struct*)pDataObj)->fe_data;
return (CNetscapeCntrItem *)pEmbeddedApp->fe_data;
}
NPError FE_PluginGetValue(MWContext *pContext, NPEmbeddedApp *pApp,
NPNVariable variable, void *pRetVal)
{
NPError ret = NPERR_NO_ERROR;
switch (variable) {
case NPNVnetscapeWindow:
{
if (pContext->type != MWContextPrint)
*(HWND *)pRetVal = PANECX(pContext)->GetPane();
else
ret = NPERR_INVALID_PARAM;
}
break;
default:
*(void **)pRetVal = NULL;
break;
}
return ret;
}
// wrapper for plugin-related FE entry point invented after EmbedUrlExit()
void FE_EmbedURLExit(URL_Struct *urls, int status, MWContext *cx)
{
#ifdef MOZ_NGLAYOUT
XP_ASSERT(0);
#else
EmbedUrlExit(urls, status, cx);
#endif
}
#ifdef MOZ_NGLAYOUT
XP_ASSERT(0);
#else
void EmbedUrlExit(URL_Struct *pUrl, int iStatus, MWContext *pContext)
{
// The embedded item is finished downloading, and possibly has an error and stuff.
NPEmbeddedApp* pEmbeddedApp = (NPEmbeddedApp*)pUrl->fe_data;
if (!pEmbeddedApp) {
NET_FreeURLStruct(pUrl);
return;
}
CNetscapeCntrItem *pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data;
// if an EMBED tag's SRC attribute is a LOCAL file which does not exist,
// pItem is NULL. Bandaid against GPF for 2.0, but later we must fix the
// FE_GetEmbedSize() and NP_EmbedCreate() combo that cause this problem.
if(pItem != NULL) {
if(wfe_IsTypePlugin(pEmbeddedApp))
{
pItem->m_bLoading = FALSE;
NET_FreeURLStruct(pUrl);
return;
}
#ifdef MOCHA
{
/* only wait on applets if onload flag */
lo_TopState *top_state = lo_FetchTopState(XP_DOCID(pContext));
if (top_state != NULL && top_state->mocha_loading_embeds_count)
{
top_state->mocha_loading_embeds_count--;
ET_SendLoadEvent(pContext, EVENT_XFER_DONE, NULL, NULL,
LO_DOCUMENT_LAYER_ID, FALSE);
}
}
#endif /* MOCHA */
// else must be an OLE stream exit
if(iStatus != MK_DATA_LOADED) {
// Load error.
pItem->m_bBroken = TRUE;
}
else if(pUrl->server_status != 0 && pUrl->server_status / 100 != 2 && pUrl->server_status / 100 != 3 && iStatus == MK_DATA_LOADED) {
// Server error.
pItem->m_bBroken = TRUE;
}
// If the item isn't broken, we can load it up.
if(pItem->m_bBroken == FALSE) {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
if(FALSE == pItem->CreateFromFile(pItem->m_csFileName)) {
// Couldn't create for some reason!
pItem->m_bBroken = TRUE;
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
pItem->m_bLoading = FALSE;
// Get the width and height out of our newly created item, if it isn't broken.
// We need to do this two different ways, depending on what type of context we
// are in.
CSize csExtents;
// New way.
CDCCX *pCX = VOID2CX(pContext->fe.cx, CDCCX);
if(pItem->m_bBroken == FALSE) {
pItem->GetExtent(&csExtents);
csExtents.cx = CASTINT(pCX->Metric2TwipsX(csExtents.cx));
csExtents.cy = CASTINT(pCX->Metric2TwipsY(csExtents.cy));
}
else {
LTRB Rect;
int32 x, y;
// pCX->DisplayIcon(Rect.left, Rect.right, IL_IMAGE_BAD_DATA, &x, &y);
pCX->GetIconDimensions(&x, &y, IL_IMAGE_BAD_DATA);
csExtents.cx = CASTINT(x);
csExtents.cy = CASTINT(y);
}
// Need to flush all delayed display, and blocked layout.
// Do all blocks.
POSITION rIndex = pItem->m_cplUnblock.GetHeadPosition();
LO_EmbedStruct *pLayoutData = NULL;
while(rIndex != NULL && iStatus != MK_INTERRUPTED) {
pLayoutData = (LO_EmbedStruct *)pItem->m_cplUnblock.GetNext(rIndex);
if ((pEmbeddedApp->type == NP_OLE) && pItem->m_lpObject) {
if ( pLayoutData->objTag.width)
csExtents.cx = pLayoutData->objTag.width;
if ( pLayoutData->objTag.height)
csExtents.cy = pLayoutData->objTag.height;
pLayoutData->objTag.width = csExtents.cx;
pLayoutData->objTag.height = csExtents.cy;
}
LO_ClearEmbedBlock(ABSTRACTCX(pContext)->GetDocumentContext(), pLayoutData);
}
pItem->m_cplUnblock.RemoveAll();
#ifdef LAYERS
rIndex = pItem->m_cplElements.GetHeadPosition();
while (rIndex != NULL) {
pLayoutData = (LO_EmbedStruct *)pItem->m_cplElements.GetNext(rIndex);
// An OLE container is windowless until it is activated.
LO_SetEmbedType(pLayoutData, PR_FALSE);
}
#endif // LAYERS
// Do all needed display.
rIndex = pItem->m_cplDisplay.GetHeadPosition();
while(rIndex != NULL) {
pLayoutData = (LO_EmbedStruct *)pItem->m_cplDisplay.GetNext(rIndex);
if ((pEmbeddedApp->type == NP_OLE) && pItem->m_lpObject) {
if ( pLayoutData->objTag.width )
csExtents.cx = pLayoutData->objTag.width;
if ( pLayoutData->objTag.height)
csExtents.cy = pLayoutData->objTag.height;
pLayoutData->objTag.width = csExtents.cx;
pLayoutData->objTag.height = csExtents.cy;
}
#ifdef LAYERS
if (pContext->compositor) {
XP_Rect rect;
CL_GetLayerBbox(pLayoutData->objTag.layer, &rect);
CL_UpdateLayerRect(CL_GetLayerCompositor(pLayoutData->objTag.layer),
pLayoutData->objTag.layer, &rect, PR_FALSE);
}
else
#endif /* LAYERS */
pContext->funcs->DisplayEmbed(pContext, FE_VIEW, pLayoutData);
}
pItem->m_cplDisplay.RemoveAll();
}
// And well, hey, get rid of the url.
NET_FreeURLStruct(pUrl);
}
#endif /* MOZ_NGLAYOUT */
static void wfe_PluginStream(URL_Struct *pUrlData, MWContext *pContext)
{
NPEmbeddedApp* pEmbeddedApp = (NPEmbeddedApp*)pUrlData->fe_data;
ASSERT(pEmbeddedApp);
// Make sure the type is set properly
pEmbeddedApp->type = NP_Plugin;
// Need to flush all delayed display, and blocked layout.
CNetscapeCntrItem *pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data;
ASSERT(pItem);
if (!pItem->m_cplUnblock.IsEmpty()) {
// There had better only be one item here
ASSERT(pItem->m_cplUnblock.GetCount() == 1);
POSITION rIndex = pItem->m_cplUnblock.GetHeadPosition();
LO_EmbedStruct* pLayoutData = (LO_EmbedStruct *)pItem->m_cplUnblock.GetNext(rIndex);
// Unblock layout
LO_ClearEmbedBlock(ABSTRACTCX(pContext)->GetDocumentContext(), pLayoutData);
pItem->m_cplUnblock.RemoveAll();
}
// Display the plugin if necessarily
if (!pItem->m_cplDisplay.IsEmpty()) {
// There had better only be one item here
ASSERT(pItem->m_cplDisplay.GetCount() == 1);
POSITION rIndex = pItem->m_cplDisplay.GetHeadPosition();
LO_EmbedStruct* pLayoutData = (LO_EmbedStruct *)pItem->m_cplDisplay.GetNext(rIndex);
#ifdef LAYERS
int32 lXSave, lYSave;
XP_Rect rect;
// I don't like the fact that this code has to be here. At some
// level, it goes against the rule that all drawing has to be
// driven by the compositor through layout. The easy fix is that
// we do the same coordinate space conversion that's done in
// layout. -- Vidur
if (pContext->compositor) {
/* Convert layer-relative coordinates for element to document
coordinates, since that's what the FE uses. */
rect.top = rect.left = rect.right = rect.bottom = 0;
CL_LayerToWindowRect(pContext->compositor, pLayoutData->objTag.layer, &rect);
CL_WindowToDocumentRect(pContext->compositor, &rect);
/* Save old, layer-relative coordinates */
lXSave = pLayoutData->objTag.x;
lYSave = pLayoutData->objTag.y;
/* Temporarily shift element to document coordinates */
pLayoutData->objTag.x = rect.left - pLayoutData->objTag.x_offset;
pLayoutData->objTag.y = rect.top - pLayoutData->objTag.y_offset;
}
#endif /* LAYERS */
// Display the plugin
pContext->funcs->DisplayEmbed(pContext, FE_VIEW, pLayoutData);
#ifdef LAYERS
if (pContext->compositor) {
pLayoutData->objTag.x = lXSave;
pLayoutData->objTag.y = lYSave;
}
#endif /* LAYERS */
pItem->m_cplDisplay.RemoveAll();
}
}
BOOL WildMime(const char *pOne, const char *pTwo) {
// Purpose: Compare two mime types to see if they can be considered
// equivalent.
// Arguments: csOne A fully qualified mime type, no wilds.
// csTwo A mime type, can be wild, or subtype wild.
// Returns: BOOL TRUE A match.
// FALSE No match.
// Comments: Mime types are case insensitive.
// Revision History:
// 01-04-95 created GAB
//
// First, just get rid of any wilds right now.
if(*pTwo == '*') {
return(TRUE);
}
// Okay, only have subtype wilds left, split the mime types up
// into minor, major parts.
char *p1 = strdup(pOne);
char *pmin1 = strchr(p1, '/');
if(pmin1) {
*pmin1 = '\0';
pmin1++;
} else {
pmin1 = p1;
}
char *p2 = strdup(pTwo);
char *pmin2 = strchr(p2, '/');
if(pmin2) {
*pmin2 = '\0';
pmin2++;
} else {
pmin2 = p2;
}
// If majors don't match, there is no hope.
if(stricmp(p1, p2) != 0) {
free(p1);
free(p2);
return(FALSE);
}
// Okay, let's get rid of sub type wilds right now.
if(*pmin2 == '*') {
free(p1);
free(p2);
return(TRUE);
}
// See if the minors match up.
BOOL bRetVal = FALSE;
if(stricmp(pmin1, pmin2) == 0) {
bRetVal = TRUE;
}
free(p1);
free(p2);
return(bRetVal);
}
static BOOL wfe_IsRegisteredForPlugin(int iFormatOut, URL_Struct *pUrlStruct, MWContext *pContext)
{
// Find the callers mime/type in the iFormatOut registry list,
// and return true if found.
CString csMimeType = pUrlStruct->content_type;
// Find the relevant mime type in our list.
// There should always be a wild on the end of the list, but if not, duh.
XP_List *list = NET_GetRegConverterList(iFormatOut);
ContentTypeConverter *pConv;
while(pConv = (ContentTypeConverter *)XP_ListNextObject(list))
{
// Do a wild compare on the mime types
if(WildMime(csMimeType, pConv->format_in))
{
// May have found an appropriate converter.
// Only when the viewer is not automated,
// and the mime types are a case insensitive
// match, return TRUE.
// ZZZ: Make sure it's a plug-in and not an automated viewer.
// We're doing it this demented way because pConv->bAutomated is
// getting stomped and points to garbage
if ((pConv->bAutomated == FALSE) && NPL_FindPluginEnabledForType(pConv->format_in)) {
// only check for can handle by OLE when there is no plugin register for
// the mine type.
// Find out can we handle by OLE.
if (strcmp(pConv->format_in, "*") == 0)
/* there previously was a call to FE_FileType here, but it is clearly
unnecessary given the check of fe_CanHandlebyOLE we've added. byrd.
reminder - we should overhaul/remove FE_FileType and it's other call.
&&
FE_FileType(pUrlStruct->address, pUrlStruct->content_type,
pUrlStruct->content_encoding))
*/
{
if(iFormatOut == FO_EMBED){
/* don't have to worry about FO_CACHE_AND_EMBED since cache bit cleared by NET_CacheConverter */
/* also, don't want to interfere w/ full-page case... */
char* ext[1];
ext[0] = FE_FindFileExt(pUrlStruct->address);
if(ext[0] && fe_CanHandleByOLE(ext,1))
return FALSE;
else
return TRUE;
}
else return FALSE;
}
else
return TRUE;
}
// Only when the viewer is not automated,
// and the handler is for wildcard MIME type,
// and OLE doesn't want it, return TRUE.
// ZZZ: See above comment
if ((pConv->bAutomated == FALSE) && XP_STRCMP(pConv->format_in, "*") == 0 &&
NPL_FindPluginEnabledForType("*")) {
// the following code is copied from EmbedStream(), OLE related stuff
// BUG: this code needs to be shared code!
// extract the extension of the file name
char aExt[_MAX_EXT];
size_t stExt = 0;
DWORD dwFlags = EXT_NO_PERIOD;
#ifdef XP_WIN16
dwFlags |= EXT_DOT_THREE;
#endif
aExt[0] = '\0';
stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pUrlStruct->address, pUrlStruct->content_type);
CString csFinalExtension = aExt;
// Check to see if the embedded file matches any known extensions.
// If not, then consider the file of no use to the user.
// Use new way if we are in a different style of context.
if(wfe_IsExtensionRegistrationValid(csFinalExtension, ABSTRACTCX(pContext)->GetDialogOwner(), FALSE) == FALSE) {
return TRUE;
}
}
}
}
return FALSE;
}
NET_StreamClass *EmbedStream(int iFormatOut, void *pDataObj, URL_Struct *pUrlData, MWContext *pContext)
{
NPEmbeddedApp* pEmbeddedApp = NULL;
CNetscapeCntrItem* pItem = NULL;
NET_StreamClass * pStream = NULL;
if(wfe_IsRegisteredForPlugin(iFormatOut, pUrlData, pContext)) {
if(!ABSTRACTCX(pContext)->IsPrintContext()) {
if (iFormatOut == FO_EMBED) {
// NPL_NewEmbedStream() sets pUrlData->fe_data to NPEmbeddedApp*, so
// it is not valid until NPL_NewEmbedStream() returns
pStream = NPL_NewEmbedStream((FO_Present_Types)iFormatOut,
pDataObj, pUrlData, pContext);
} else if (iFormatOut == FO_PRESENT) {
// NPL_NewPresentStream() sets pUrlData->fe_data to NPEmbeddedApp*, so
// it is not valid until NPL_NewPresentStream() returns
pStream = NPL_NewPresentStream((FO_Present_Types)iFormatOut,
pDataObj, pUrlData, pContext);
} else {
ASSERT(FALSE);
return NULL;
}
// If we fail to load for some reason, show a broken icon.
if(!pStream) {
if(pItem)
pItem->m_bBroken = TRUE;
return NULL;
}
pEmbeddedApp = (NPEmbeddedApp*)pUrlData->fe_data;
if(pEmbeddedApp)
pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data;
}
// pDataObj gets its fe_data member written by libplugin in
// the full screen case
//
// It's possible that the context is different. This happens for full-page
// plug-ins when we decide to display the plugin in it's own window
if (pItem && pItem->GetDocument()) {
CDCCX* pDC = pItem->GetDocument()->GetContext();
if (pDC && pDC->GetContext() != pContext) {
TRACE0("Context changed in EmbedStream()!\n");
pContext = pDC->GetContext();
}
}
wfe_PluginStream(pUrlData, pContext);
return pStream;
}
// if the MIME type isn't registered to a plugin,
// assume it must be handled by OLE
pEmbeddedApp = (NPEmbeddedApp*)pUrlData->fe_data;
if(pEmbeddedApp == NULL) // our OLE support doesn't do full page
return NULL;
// Explicitly type it as an embedded OLE object
pEmbeddedApp->type = NP_OLE;
pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data;
pItem->m_bIsOleItem = TRUE;
// Formulate a file name that will suckle data from the net.
char *pFormulateName = fe_URLtoLocalName(pItem->m_csAddress, pUrlData ? pUrlData->content_type : NULL);
char *pLocalName = NULL;
if(((CNetscapeApp *)AfxGetApp())->m_pTempDir != NULL && pFormulateName != NULL) {
StrAllocCopy(pLocalName, ((CNetscapeApp *)AfxGetApp())->m_pTempDir);
StrAllocCat(pLocalName, "\\");
StrAllocCat(pLocalName, pFormulateName);
// If this file exists, then we must attempt another temp file.
if(-1 != _access(pLocalName, 0)) {
// Retain the extension.
char aExt[_MAX_EXT];
size_t stExt = 0;
DWORD dwFlags = 0;
#ifdef XP_WIN16
dwFlags |= EXT_DOT_THREE;
#endif
aExt[0] = '\0';
stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pUrlData->address, pUrlData->content_type);
if(pLocalName) {
XP_FREE(pLocalName);
pLocalName = NULL;
}
pLocalName = WH_TempFileName(xpTemporary, "E", aExt);
}
}
else {
// Retain the extension.
char aExt[_MAX_EXT];
size_t stExt = 0;
DWORD dwFlags = 0;
#ifdef XP_WIN16
dwFlags |= EXT_DOT_THREE;
#endif
aExt[0] = '\0';
stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pUrlData->address, pUrlData->content_type);
if(pLocalName) {
XP_FREE(pLocalName);
pLocalName = NULL;
}
pLocalName = WH_TempFileName(xpTemporary, "E", aExt);
}
if(pFormulateName != NULL) {
XP_FREE(pFormulateName);
pFormulateName = NULL;
}
// Correctly extract the extension from the created file name.
char aExt[_MAX_EXT];
size_t stExt = 0;
DWORD dwFlags = EXT_NO_PERIOD;
#ifdef XP_WIN16
dwFlags |= EXT_DOT_THREE;
#endif
aExt[0] = '\0';
stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pLocalName, pUrlData->content_type);
CString csFinalExtension = aExt;
// Check to see if the embedded file matches any known extensions.
// If not, then consider the file of no use to the user.
// Use new way if we are in a different style of context.
if(pEmbeddedApp->type == NP_OLE && pItem->m_isFullPage) {
//; do nothing for full page OLE. Because the security dialog already shown on external_viewer_disk_stream.
}
else {
if(wfe_IsExtensionRegistrationValid(csFinalExtension, ABSTRACTCX(pContext)->GetDialogOwner(), TRUE) == FALSE) {
// Broken....
XP_FREE(pLocalName);
pItem->m_bBroken = TRUE;
return(NULL);
}
}
// Open up the file for writing.
pItem->m_csFileName = pLocalName;
XP_FREE(pLocalName);
CFileException cfe;
if(FALSE == pItem->m_cfOutput.Open(pItem->m_csFileName, CFile::modeCreate | CFile::modeWrite, &cfe)) {
// Couldn't open.
pItem->m_bBroken = TRUE;
return(NULL);
}
// Create the stream class that will handle the download.
// Send the embed along for the download.
pItem->m_bLoading = TRUE;
return(NET_NewStream("EmbeddedItemCheeseSpankDior",
EmbedWrite,
EmbedComplete,
EmbedAbort,
EmbedReady,
(void *)pUrlData,
pContext));
}
unsigned int EmbedReady(NET_StreamClass *stream) {
void *pDataObj=stream->data_object;
// pDataObj is an URL struct
if(wfe_IsTypePlugin((NPEmbeddedApp*)((URL_Struct*)pDataObj)->fe_data))
return NPL_WriteReady(stream);
// The the netowrk library how much we're willing to write to our new embedded item.
return(MAX_WRITE_READY);
}
int EmbedWrite(NET_StreamClass *stream, const char *pWriteData, int32 lLength) {
void *pDataObj=stream->data_object;
// pDataObj is an URL struct
if(wfe_IsTypePlugin((NPEmbeddedApp*)((URL_Struct*)pDataObj)->fe_data))
return NPL_Write(stream, (unsigned char *)pWriteData, lLength);
// Serialize some more information for the embedded item.
CNetscapeCntrItem *pItem = wfe_GetCntrPtr(pDataObj);
TRY {
pItem->m_cfOutput.Write(pWriteData, CASTUINT(lLength));
}
CATCH(CFileException, e) {
// Couldn't write for some reason.
pItem->m_bBroken = TRUE;
return(MK_DISK_FULL);
}
END_CATCH
return(MK_DATA_LOADED);
}
void EmbedComplete(NET_StreamClass *stream) {
void *pDataObj=stream->data_object;
// pDataObj is an URL struct
if(wfe_IsTypePlugin((NPEmbeddedApp*)((URL_Struct*)pDataObj)->fe_data))
{
NPL_Complete(stream);
return;
}
// The load is complete.
// Close our file.
CNetscapeCntrItem *pItem = wfe_GetCntrPtr(pDataObj);
TRY {
pItem->m_cfOutput.Close();
}
CATCH(CFileException, e) {
// Some error.
pItem->m_bBroken = TRUE;
}
END_CATCH
}
void EmbedAbort(NET_StreamClass *stream, int iStatus) {
void *pDataObj=stream->data_object;
// pDataObj is an URL struct
if(wfe_IsTypePlugin((NPEmbeddedApp*)((URL_Struct*)pDataObj)->fe_data))
{
NPL_Abort(stream, iStatus);
return;
}
// The load was aborted.
// Do a normal close, then mark ourselves as broken.
EmbedComplete(stream);
CNetscapeCntrItem *pItem = wfe_GetCntrPtr(pDataObj);
pItem->m_bBroken = TRUE;
}
};
BOOL wfe_IsExtensionRegistrationValid(CString& csExtension, CWnd *pWnd, BOOL bAskDialog) {
// Purpose: Determine if an extension will present the user with a useful embedded item.
// Arguments: csExtension The extension of the data file.
// pWnd The calling window
// Returns: BOOL TRUE The extension has an application present that can handle it.
// FALSE Either the extension is not presently registered,
// the registered viewer is no longer present locally, or
// the application isn't trusted (CanSpawn).
// Comments: Troy's handywork.
// Revision History:
// 02-07-95 created GAB
// 04-10-95 modified to check and see if execution of the application has
// been cleared by the user.
//
char szExt[_MAX_EXT], szValue[_MAX_PATH];
long cb;
OFSTRUCT of;
// First, try the system registry.
wsprintf(szExt, ".%s", (LPCSTR)csExtension);
cb = sizeof(szValue);
if(RegQueryValue(HKEY_CLASSES_ROOT, szExt, szValue, &cb) == ERROR_SUCCESS) {
CString strKey = szValue;
strKey += "\\shell\\open\\command";
cb = sizeof(szValue);
if(RegQueryValue(HKEY_CLASSES_ROOT, strKey, szValue, &cb) == ERROR_SUCCESS) {
// Just use the app name, ignore switches.
// char *pAppName = strtok(szValue, " ");
// mwh this is becuase in Win 32 directory name can have space.
// still need to fix the cause that the directory has '.'
char *pAppName = strchr(szValue, '.');
if (pAppName) {
char *next = strchr(pAppName, ' ');
*next = '\0'; // NULL terminated the string.
// mhw to get around the problem, that some shell command have "".
if (*(next-1) == '"') *(next-1) = 0;
if (szValue[0] == '"')
pAppName = &szValue[1];
else
pAppName = szValue;
if(pAppName) {
if(OpenFile(pAppName, &of, OF_EXIST) != HFILE_ERROR) {
// See if we can spawn this app.
if(bAskDialog == TRUE)
return(((CNetscapeApp *)AfxGetApp())->m_pSpawn->CanSpawn(CString(pAppName), pWnd));
else
return TRUE;
}
}
}
}
}
// Second try win.ini win16 associations.
if(::GetProfileString("Extensions", csExtension, "", szValue, sizeof(szValue))) {
char *pAppName = strtok(szValue, " ");
if(pAppName != NULL) {
if(OpenFile(pAppName, &of, OF_EXIST) != HFILE_ERROR) {
// see if we can spawn this app.
if(bAskDialog == TRUE)
return(((CNetscapeApp *)AfxGetApp())->m_pSpawn->CanSpawn(CString(pAppName), pWnd));
else
return TRUE;
}
}
}
// Neither will work, nothing will work.
return(FALSE);
}

Просмотреть файл

@ -1,264 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define JMC_INIT_IMGCB_ID 1
#ifndef NSPR20
#include "coremem.h"
#include "stdafx.h"
#else
#include "stdafx.h"
#include "coremem.h"
#endif
#include "feimage.h"
#include "il_types.h"
#include "cxdc.h"
#include "cxicon.h"
JMC_PUBLIC_API(void)
_IMGCB_NewPixmap(struct IMGCB* self, jint op, void* displayContext, jint width, jint height, IL_Pixmap* image, IL_Pixmap* mask)
{
MWContext *pContext = (MWContext *)displayContext;
CAbstractCX *dispCxt = (CAbstractCX *) pContext->fe.cx;
FEBitmapInfo *imageInfo;
imageInfo = new FEBitmapInfo;
if (!imageInfo) return;
NI_PixmapHeader* imageHeader = &image->header;
imageInfo->targetWidth = CASTINT(width);
imageInfo->targetHeight = CASTINT(height);
imageInfo->width = CASTINT(width);
imageHeader->width = width;
imageInfo->height = CASTINT(height);
imageHeader->height = height;
imageInfo->hBitmap = NULL;
image->client_data = imageInfo;
if ((imageInfo->bmpInfo = dispCxt->NewPixmap(image, FALSE)) == NULL) {// error
delete imageInfo;
image->client_data = NULL;
return;
}
if (mask) {
FEBitmapInfo * maskInfo;
NI_PixmapHeader* maskHeader = &mask->header;
maskInfo = new FEBitmapInfo;
if (!maskInfo) {
delete imageInfo;
return;
}
maskHeader->width = imageHeader->width;
maskHeader->height = imageHeader->height;
mask->client_data = maskInfo;
maskInfo->hBitmap = NULL;
if ((maskInfo->bmpInfo = dispCxt->NewPixmap(mask, TRUE)) == NULL) {// error
#ifndef USE_DIB_SECTION
if (image->bits) {
CDCCX::HugeFree(image->bits);
image->bits = NULL;
}
#endif
delete imageInfo;
delete maskInfo;
mask->client_data = NULL;
return;
}
maskInfo->width = CASTINT(maskHeader->width);
maskInfo->height = CASTINT(maskHeader->height);
maskInfo->pContext = dispCxt; // Not used.
maskInfo->IsMask = TRUE;
}
imageInfo->pContext = dispCxt; // Not used.
imageInfo->IsMask = FALSE;
}
JMC_PUBLIC_API(void)
_IMGCB_UpdatePixmap(struct IMGCB* self, jint op, void* a, IL_Pixmap* b, jint c, jint d, jint e, jint f)
{
}
JMC_PUBLIC_API(void)
_IMGCB_ControlPixmapBits(struct IMGCB* self, jint op, void* displayContext,
IL_Pixmap* image, IL_PixmapControl c)
{
if (c == IL_RELEASE_BITS) {
MWContext *pContext = (MWContext *)displayContext;
XP_ASSERT(pContext);
if (!pContext)
return;
ABSTRACTCX(pContext)->ImageComplete(image);
}
}
JMC_PUBLIC_API(void)
_IMGCB_DestroyPixmap(struct IMGCB* self, jint op, void* displayContext, IL_Pixmap* pixmap)
{
FEBitmapInfo *imageInfo;
imageInfo = (FEBitmapInfo*)pixmap->client_data;
if (imageInfo)
delete imageInfo;
#ifndef USE_DIB_SECTION
if (pixmap->bits) {
CDCCX::HugeFree(pixmap->bits);
pixmap->bits = NULL;
}
#endif
pixmap->client_data = NULL;
}
JMC_PUBLIC_API(void)
_IMGCB_DisplayPixmap(struct IMGCB* self, jint op, void* displayContext, IL_Pixmap* image, IL_Pixmap* mask,
jint x, jint y, jint x_offset, jint y_offset, jint width, jint height,
jint scalewidth, jint scaleheight)
{
MWContext *pContext = (MWContext *)displayContext;
CDCCX *dispCxt = (CDCCX *) pContext->fe.cx;
LTRB Rect;
dispCxt->DisplayPixmap( image, mask, x, y, x_offset, y_offset, width, height, scalewidth, scaleheight, Rect);
}
JMC_PUBLIC_API(void)
_IMGCB_DisplayIcon(struct IMGCB* self, jint op, void* displayContext, jint x, jint y, jint iconNumber)
{
MWContext *pContext = (MWContext *)displayContext;
CDCCX *dispCxt = (CDCCX *) pContext->fe.cx;
dispCxt->DisplayIcon( x, y, CASTINT(iconNumber));
}
// The width and height are *write-only* we don't care what the original
// values are. But, CDCCX::GetIconDimensions() is going to give us
// x and y as int32's not int's so jump through a few hoops to get the
// sizes right.
//
extern JMC_PUBLIC_API(void)
_IMGCB_GetIconDimensions(struct IMGCB* self, jint op, void* displayContext, int* width, int* height, jint iconNumber)
{
int32 lWidth = 0;
int32 lHeight = 0;
MWContext *pContext = (MWContext *)displayContext;
CDCCX *dispCxt = (CDCCX *)pContext->fe.cx;
dispCxt->GetIconDimensions( &lWidth, &lHeight, CASTINT(iconNumber));
if(width) {
*width = CASTINT(lWidth);
}
if(height) {
*height = CASTINT(lHeight);
}
}
JMC_PUBLIC_API(void)
_IMGCB_init(struct IMGCB* self, struct JMCException* *exceptionThrown)
{
}
JMC_PUBLIC_API(void*)
_IMGCB_getBackwardCompatibleInterface(struct IMGCB* self, const JMCInterfaceID* iid,
struct JMCException* *exceptionThrown)
{
return NULL;
}
void
ImageGroupObserver(XP_Observable observable,
XP_ObservableMsg message,
void *message_data,
void *closure)
{
MWContext *pXPCX = (MWContext *)closure;
switch(message) {
case IL_STARTED_LOADING:
ABSTRACTCX(pXPCX)->SetImagesLoading(TRUE);
break;
case IL_ABORTED_LOADING:
ABSTRACTCX(pXPCX)->SetImagesDelayed(TRUE);
break;
case IL_FINISHED_LOADING:
ABSTRACTCX(pXPCX)->SetImagesLoading(FALSE);
break;
case IL_STARTED_LOOPING:
ABSTRACTCX(pXPCX)->SetImagesLooping(TRUE);
break;
case IL_FINISHED_LOOPING:
ABSTRACTCX(pXPCX)->SetImagesLooping(FALSE);
break;
default:
break;
}
FE_UpdateStopState(pXPCX);
}
void
FE_MochaImageGroupObserver(XP_Observable observable,
XP_ObservableMsg message,
void *message_data,
void *closure)
{
IL_GroupMessageData *data = (IL_GroupMessageData *)message_data;
MWContext *pXPCX = (MWContext *)data->display_context;
// If we are passed a NULL display context, the MWContext has been
// destroyed.
if (!pXPCX)
return;
switch(message) {
case IL_STARTED_LOADING:
ABSTRACTCX(pXPCX)->SetMochaImagesLoading(TRUE);
break;
case IL_ABORTED_LOADING:
ABSTRACTCX(pXPCX)->SetMochaImagesDelayed(TRUE);
break;
case IL_FINISHED_LOADING:
ABSTRACTCX(pXPCX)->SetMochaImagesLoading(FALSE);
break;
case IL_STARTED_LOOPING:
ABSTRACTCX(pXPCX)->SetMochaImagesLooping(TRUE);
break;
case IL_FINISHED_LOOPING:
ABSTRACTCX(pXPCX)->SetMochaImagesLooping(FALSE);
break;
default:
break;
}
FE_UpdateStopState(pXPCX);
}

Просмотреть файл

@ -1,854 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "prefapi.h"
#include "netsdoc.h"
#include "template.h"
#ifdef MOZ_LDAP
#include "dirprefs.h"
#endif
#ifdef MOZ_MAIL_NEWS
#include "compfrm.h"
#endif
#ifdef EDITOR
//#include "edview.h"
#endif
#include "prefs.h" //To access g_bReloadChangeColor;
#ifdef NSPR20
#include "private/prpriv.h"
#endif
// This is the NSPR priority of the main GUI thread (ie. mozilla)
#ifndef NSPR20
#ifdef XP_WIN32
#define MOZILLA_THREAD_PRIORITY 15
#else
#define MOZILLA_THREAD_PRIORITY 2
#endif
#else
#ifdef XP_WIN32
#define MOZILLA_THREAD_PRIORITY PR_PRIORITY_NORMAL
#else
#define MOZILLA_THREAD_PRIORITY PR_PRIORITY_LOW
#endif
#endif
#if defined(OJI) || defined(JAVA) || defined(MOCHA)
#ifndef XP_PC
#define XP_PC
#endif
#ifdef XP_WIN32
#ifndef HW_THREADS
#define HW_THREADS
#endif
#else
#ifndef SW_THREADS
#define SW_THREADS
#endif
#endif
#ifndef X386
#define X386
#endif
#include "nspr.h"
#include "plevent.h"
#endif /* OJI || JAVA || MOCHA */
#if defined(OJI)
#include "jvmmgr.h"
#elif defined(JAVA)
#include "java.h"
#endif
#if defined(XP_PC) && !defined(_WIN32)
#if defined(JAVA) || defined(OJI)
extern "C" PR_PUBLIC_API(void) SuspendAllJavaThreads(void);
#endif
#endif
// Shared event queue used to pass messages between the java threads and
// the main navigator thread...
extern "C" {
PREventQueue *mozilla_event_queue;
PRThread *mozilla_thread;
};
//
// Call layout with the red green and blue values of the current COLORREF
//
MODULE_PRIVATE void
wfe_SetLayoutColor(int type, COLORREF color)
{
#ifndef MOZ_NGLAYOUT
uint8 red = GetRValue(color);
uint8 green = GetGValue(color);
uint8 blue = GetBValue(color);
LO_SetDefaultColor(type, red, green, blue);
if( type != LO_COLOR_BG )
g_bReloadChangeColor = TRUE;
#endif /* MOZ_NGLAYOUT */
}
void OpenDraftExit (URL_Struct *url_struct, int/*status*/,MWContext *pContext)
{
XP_ASSERT (url_struct && pContext);
if (!url_struct) return;
NET_FreeURLStruct ( url_struct );
}
#ifdef MOZ_LDAP
// This function handles callbacks for all of the *bad* things which we
// are caching in netscape.h...In general, we should try to move these but
// the mnprefs.cpp & mnwizard.cpp are such a mess that I am punting for now
int PR_CALLBACK
DirServerListChanged(const char *pref, void *data)
{
theApp.m_directories = DIR_GetDirServers();
return TRUE;
}
#endif // MOZ_LDAP
// This function handles callbacks for all of the *bad* things which we
// are caching in netscape.h...In general, we should try to move these but
// the mnprefs.cpp & mnwizard.cpp are such a mess that I am punting for now
int PR_CALLBACK
WinFEPrefChangedFunc(const char *pref, void *data)
{
if (!strcmpi(pref,"browser.startup.homepage")) {
LPSTR lpszHomePage = NULL;
PREF_CopyCharPref("browser.startup.homepage", &lpszHomePage);
theApp.m_pHomePage = lpszHomePage;
if (lpszHomePage)
XP_FREE(lpszHomePage);
} else if (!strcmpi(pref,"browser.cache.directory")) {
LPSTR lpszCacheDir;
PREF_CopyCharPref("browser.cache.directory",&lpszCacheDir);
theApp.m_pCacheDir = lpszCacheDir;
if (lpszCacheDir)
XP_FREE(lpszCacheDir);
} else if (!strcmpi(pref,"browser.bookmark_location")) {
LPSTR lpszPref;
PREF_CopyCharPref("browser.bookmark_location",&lpszPref);
theApp.m_pBookmarkFile = lpszPref;
if (lpszPref)
XP_FREE(lpszPref);
}
else if (!strcmpi(pref,"mime.types.all_defined")) { //Begin CRN_MIME
fe_UpdateMControlMimeTypes();
}//End CRN_MIME
return PREF_NOERROR;
};
#ifdef XP_WIN16
/////////////////////////////////////////////////////////////////////////////
// 16-bit RTL helper functions
//
// These functions are used by NSPR to access RTL functions that are
// not available from 16-bit DLLs... They provide the necessary
// "mov DS, SS" entry prolog to fix "DS == SS" which is assumed
// by the MS RTL...
//
#ifdef DEBUG
extern "C" int _heapchk();
extern "C" {
extern unsigned long hcCount;
extern unsigned long hcMallocCount;
extern unsigned long hcFreeCount;
extern unsigned long hcLimit;
}
static void chk()
{
static unsigned long checkCount;
if (_heapchk() != _HEAPOK)
__asm { int 3 }
hcCount += 1;
if (hcCount >= hcLimit)
__asm { int 3 }
}
extern "C" static void aFchkstk(void)
{
}
#endif
#if defined(XP_WIN16)
// Only used when debug build on win16.
BOOL PR_CALLBACK DefaultBlockingHook(void) {
MSG msg;
BOOL ret = FALSE;
/*
* Only dispatch messages if the current thread is mozilla...
*/
if (mozilla_thread == PR_CurrentThread()) {
/* get the next message if any */
ret = (BOOL)PeekMessage(&msg,NULL,0,0,PM_NOREMOVE);
/* if we got one, process it */
if (ret) {
ret = theApp.NSPumpMessage();
}
}
/* TRUE if we got a message */
return ret;
}
#endif
#ifdef MOZ_USE_MS_MALLOC
/*--------------------------------------------------------------------------*/
/* 32-bit aligned memory management routines */
/*--------------------------------------------------------------------------*/
/* */
/* The strategy for aligning memory to 32-bit boundaries is to allocate an */
/* extra 32-bits for each allocation - A 16-bit header and a 16-bit padding */
/* */
/* If the memory returned from _fmalloc() is not 32-bit aligned, then the */
/* pointer is adjusted forward by 2 bytes to correctly align the memory. */
/* The resulting 2-byte header is initialized to PR_NON_ALIGNED_HEADER. */
/* There is also an "extra" 2 byte padding at the end of the block which */
/* are unused. */
/* */
/* If the memory returned from _fmalloc() is already 32-aligned, then the */
/* pointer is adjusted forward by 4 bytes to maintain alignment. The first */
/* 2 bytes are filled with a pad value in DEBUG mode and the next 2 bytes */
/* are initialized to PR_ALIGNED_HEADER */
/* */
/*--------------------------------------------------------------------------*/
#define PR_HEADER_SIZE 4
#define PR_ALIGNED_PAD 0xDEAD
#define PR_ALIGNED_HEADER 0xAD04
#define PR_NONALIGNED_HEADER 0xAD02
#define PR_IS_ALIGNED(p) ( !(OFFSETOF(p) & 0x03) )
#define PR_GET_HEADER_WORD(p) ( *((WORD*)(((char *)(p))-2)) )
#define PR_GET_HEADER_PAD(p) ( *((WORD*)(((char *)(p))-4)) )
#define PR_GET_ROOT(p) ( (void *)(((unsigned long)(p)) - (unsigned long)(PR_GET_HEADER_WORD(p) & 0x000F)) )
//
// This macro verifies that a memory block is 32-bit aligned and contains
// the proper header values...
//
#ifdef DEBUG
#define PR_VALIDATE_BLOCK(p) ASSERT( PR_IS_ALIGNED(p) ); \
if (p) { \
if (PR_GET_HEADER_WORD(p) == PR_ALIGNED_HEADER) { \
ASSERT( PR_GET_HEADER_PAD(p) == PR_ALIGNED_PAD ); \
} else { \
ASSERT( PR_GET_HEADER_WORD(p) == PR_NONALIGNED_HEADER ); \
} \
}
#else
#define PR_VALIDATE_BLOCK(p)
#endif
void * malloc(size_t size) {
char *p;
/* allocate a 16-bit aligned block of memory */
p = (char *)_fmalloc(size + PR_HEADER_SIZE);
/* Memory is already 32-bit aligned */
if ( PR_IS_ALIGNED(p) ) {
#ifdef DEBUG
*((WORD *)p) = PR_ALIGNED_PAD;
#endif
p = ((char *)p) + 2;
*((WORD *)p) = PR_ALIGNED_HEADER;
}
/* Align memory to 32-bit boundary */
else {
*((WORD *)p) = PR_NONALIGNED_HEADER;
}
p = ((char *)p) + 2;
PR_VALIDATE_BLOCK(p);
return (void *)p;
}
void free(void *p) {
void *h;
if (p) {
PR_VALIDATE_BLOCK(p);
h = PR_GET_ROOT(p);
ASSERT( (OFFSETOF(p) - OFFSETOF(h)) <= PR_HEADER_SIZE );
} else {
h = NULL;
}
_ffree(h);
}
void * realloc(void *p, size_t size) {
size_t old_size;
void *new_block;
void *h;
if (p) {
PR_VALIDATE_BLOCK(p);
h = PR_GET_ROOT(p);
old_size = _fmsize(h) - (PR_GET_HEADER_WORD(p) == PR_ALIGNED_HEADER ? 4 : 2);
ASSERT( (OFFSETOF(p) - OFFSETOF(h)) <= PR_HEADER_SIZE );
} else {
h = NULL;
old_size = 0;
}
/* allocate a 32-bit aligned block of memory */
new_block = malloc(size);
if (p && new_block) {
/* copy the original data into the new block of memory */
memcpy(new_block, p, (old_size < size ? old_size : size));
/* free the old block of memory */
_ffree(h);
}
p = new_block;
PR_VALIDATE_BLOCK(p);
return p;
}
void * calloc(size_t size, size_t number) {
void *p;
long bytes;
bytes = (long)size * (long)number;
ASSERT(bytes < 0xFFF0L);
/* allocate a 32-bit aligned block of memory */
p = malloc((size_t)bytes);
if (p) {
memset(p, 0x00, (size_t)bytes);
}
PR_VALIDATE_BLOCK(p);
return p;
}
#endif
/*--------------------------------------------------------------------------*/
void * PR_CALLBACK __ns_malloc(size_t size) {
return malloc(size);
}
void PR_CALLBACK __ns_free(void *p) {
free(p);
}
void* PR_CALLBACK __ns_realloc(void *p, size_t size) {
return realloc(p, size);
}
void* PR_CALLBACK __ns_calloc(size_t size, size_t number) {
return calloc(size, number);
}
int PR_CALLBACK __ns_gethostname(char * name, int namelen) {
return gethostname(name, namelen);
}
struct hostent * PR_CALLBACK __ns_gethostbyname(const char * name) {
return gethostbyname(name);
}
struct hostent * PR_CALLBACK __ns_gethostbyaddr(const char * addr, int len, int type) {
return gethostbyaddr(addr, len, type);
}
char* PR_CALLBACK __ns_getenv(const char *varname)
{
return getenv(varname);
}
int PR_CALLBACK __ns_putenv(const char *varname)
{
return putenv(varname);
}
int PR_CALLBACK __ns_auxOutput(const char *string)
{
#ifdef DEBUG
::OutputDebugString(string);
#endif
return 0;
}
void PR_CALLBACK __ns_exit(int exitCode)
{
ASSERT(0);
exit(exitCode);
}
size_t PR_CALLBACK __ns_strftime(char *s, size_t len, const char *fmt, const struct tm *p)
{
return strftime(s, len, fmt, p);
}
u_long PR_CALLBACK __ns_ntohl(u_long netlong)
{
return ntohl(netlong);
}
u_short PR_CALLBACK __ns_ntohs(u_short netshort)
{
return ntohs(netshort);
}
int PR_CALLBACK __ns_closesocket(SOCKET s)
{
return closesocket(s);
}
int PR_CALLBACK __ns_setsockopt(SOCKET s, int level, int optname, const char FAR * optval, int optlen)
{
return setsockopt(s, level, optname, optval, optlen);
}
SOCKET PR_CALLBACK __ns_socket(int af, int type, int protocol)
{
return socket(af, type, protocol);
}
int PR_CALLBACK __ns_getsockname(SOCKET s, struct sockaddr FAR *name, int FAR * namelen)
{
return getsockname(s, name, namelen);
}
u_long PR_CALLBACK __ns_htonl(u_long hostlong)
{
return htonl(hostlong);
}
u_short PR_CALLBACK __ns_htons(u_short hostshort)
{
return htons(hostshort);
}
unsigned long PR_CALLBACK __ns_inet_addr(const char FAR * cp)
{
return inet_addr(cp);
}
int PR_CALLBACK __ns_WSAGetLastError(void)
{
return WSAGetLastError();
}
int PR_CALLBACK __ns_connect(SOCKET s, const struct sockaddr FAR *name, int namelen)
{
return connect(s, name, namelen);
}
int PR_CALLBACK __ns_recv(SOCKET s, char FAR * buf, int len, int flags)
{
return recv(s, buf, len, flags);
}
int PR_CALLBACK __ns_ioctlsocket(SOCKET s, long cmd, u_long FAR *argp)
{
return ioctlsocket(s, cmd, argp);
}
int PR_CALLBACK __ns_recvfrom(SOCKET s, char FAR * buf, int len, int flags, struct sockaddr FAR *from, int FAR * fromlen)
{
return recvfrom(s, buf, len, flags, from, fromlen);
}
int PR_CALLBACK __ns_send(SOCKET s, const char FAR * buf, int len, int flags)
{
return send(s, buf, len, flags);
}
int PR_CALLBACK __ns_sendto(SOCKET s, const char FAR * buf, int len, int flags, const struct sockaddr FAR *to, int tolen)
{
return sendto(s, buf, len, flags, to, tolen);
}
SOCKET PR_CALLBACK __ns_accept(SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen)
{
return accept(s, addr, addrlen);
}
int PR_CALLBACK __ns_listen(SOCKET s, int backlog)
{
return listen(s, backlog);
}
int PR_CALLBACK __ns_bind(SOCKET s, const struct sockaddr FAR *addr, int namelen)
{
return bind(s, addr, namelen);
}
int PR_CALLBACK __ns_select(int nfds, fd_set FAR *readfds, fd_set FAR *writefds, fd_set FAR *exceptfds, const struct timeval FAR *timeout)
{
return select(nfds, readfds, writefds, exceptfds, timeout);
}
int PR_CALLBACK __ns_getsockopt(SOCKET s, int level, int optname, char FAR * optval, int FAR *optlen)
{
return getsockopt(s, level, optname, optval, optlen);
}
struct protoent * PR_CALLBACK __ns_getprotobyname(const char FAR * name)
{
return getprotobyname(name);
}
int PR_CALLBACK __ns_WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
long lEvent)
{
return WSAAsyncSelect(s, hWnd, wMsg, lEvent);
}
void PR_CALLBACK __ns_WSASetLastError(int iError)
{
WSASetLastError(iError);
}
int PR_CALLBACK MozillaNonblockingNetTicklerCallback(void)
{
// We need to tickle the network and the UI if we
// are stuck in java networking code.
MSG msg;
if (PR_CurrentThread() == mozilla_thread) {
/* get the next message if any */
if (PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) {
(void) theApp.NSPumpMessage();
return FALSE;
}
}
return TRUE;
}
#endif /* XP_WIN16 */
void fe_InitJava()
{
}
void fe_InitNSPR(void* stackBase)
{
#ifdef XP_WIN16
#if !defined(NSPR20)
//
// The 16-bit MS RTL prohibits 16-bit DLLs from calling some RTL functions.
// ie.
// malloc/free
// strftime
// sscanf
// etc...
// To fix this limitation, function pointers are passed to NSPR which
// route the RTL functions "into the EXE" where the actual RTL function
// is available. (Oh what a tangled web we weave :-( )
//
static struct PRMethodCallbackStr DLLCallbacks = {
__ns_malloc,
__ns_realloc,
__ns_calloc,
__ns_free,
__ns_gethostname,
__ns_gethostbyname,
__ns_gethostbyaddr,
__ns_getenv,
__ns_putenv,
__ns_auxOutput,
__ns_exit,
__ns_strftime,
__ns_ntohl,
__ns_ntohs,
__ns_closesocket,
__ns_setsockopt,
__ns_socket,
__ns_getsockname,
__ns_htonl,
__ns_htons,
__ns_inet_addr,
__ns_WSAGetLastError,
__ns_connect,
__ns_recv,
__ns_ioctlsocket,
__ns_recvfrom,
__ns_send,
__ns_sendto,
__ns_accept,
__ns_listen,
__ns_bind,
__ns_select,
__ns_getsockopt,
__ns_getprotobyname,
__ns_WSAAsyncSelect,
__ns_WSASetLastError
};
// Perform the 16-bit ONLY callback initialization...
PR_MDInit(&DLLCallbacks);
#endif /* NSPR20 */
#endif /* XP_WIN16 */
#if defined(OJI) || defined(JAVA) || defined(MOCHA)
#ifndef NSPR20
// Initialize the NSPR library
PR_Init( "mozilla", MOZILLA_THREAD_PRIORITY, 1, stackBase);
mozilla_thread = PR_CurrentThread();
#else
PR_STDIO_INIT()
mozilla_thread = PR_CurrentThread();
PR_SetThreadGCAble();
PR_SetThreadPriority(mozilla_thread, MOZILLA_THREAD_PRIORITY);
PL_InitializeEventsLib("mozilla");
#endif
#endif /* OJI || JAVA || MOCHA */
}
BOOL fe_ShutdownJava()
{
BOOL bRetval = TRUE;
#if defined(OJI)
(void)JVM_ShutdownJVM();
// XXX set pCmdUI->Enable(FALSE);
#elif defined(JAVA)
bRetval = (LJ_ShutdownJava() == LJJavaStatus_Enabled);
#if defined(XP_PC) && !defined(_WIN32)
SuspendAllJavaThreads();
#endif
#endif
return(bRetval);
}
//
// Register our document icons
//
static const CString strMARKUP_KEY = "NetscapeMarkup";
BOOL fe_RegisterOLEIcon ( LPSTR szCLSIDObject, // Class ID of the Object
LPSTR szObjectName, // Human Readable Object Name
LPSTR szIconPath ) // Path and Index of Icon
{
HKEY hKey;
LONG lRes = 0L;
char lpszCLSID[] = "CLSID"; // OLE Class ID Section of eg DB
char lpszDefIcon[] = "\\DefaultIcon"; // Default Icon Subkey
char lpBuffer[64]; // Working buffer
// Open the reg db for the "CLSID" key, this top-level key
// is where OLE2 and other OLE aware apps will look for
// this information.
lRes = RegOpenKey(HKEY_CLASSES_ROOT, lpszCLSID, &hKey);
if (ERROR_SUCCESS != lRes)
{
TRACE("RegOpenKey failed.\n");
return FALSE;
}
// Register the Object
// Set the value of the CLSID Entry to the Human Readable
// name of the Object
lRes = RegSetValue( hKey,
szCLSIDObject,
REG_SZ,
szObjectName,
lstrlen(szObjectName)
);
if (ERROR_SUCCESS != lRes) // bail on failure
{
RegCloseKey(hKey);
return FALSE;
}
// Build "defaulticon" subkey string "{ <class id> }\\DefaultIcon"
lstrcpy (lpBuffer, szCLSIDObject);
lstrcat (lpBuffer, lpszDefIcon);
// Set Object's default icon entry to point to the
// default icon for the object
lRes = RegSetValue( hKey,
lpBuffer,
REG_SZ,
szIconPath,
lstrlen(szIconPath)
);
if (ERROR_SUCCESS != lRes) // bail on failure
{
RegCloseKey(hKey);
return FALSE;
}
// Close the reg db
RegCloseKey(hKey);
//
//
//
lRes = RegOpenKey(HKEY_CLASSES_ROOT, (const char*)strMARKUP_KEY, &hKey);
if (ERROR_SUCCESS != lRes)
{
TRACE("RegOpenKey failed.\n");
return FALSE;
}
// Set Object's default icon entry to point to the
// default icon for the object
lRes = RegSetValue( hKey,
lpszCLSID,
REG_SZ,
szCLSIDObject,
lstrlen(szCLSIDObject)
);
if (ERROR_SUCCESS != lRes) // bail on failure
{
RegCloseKey(hKey);
return FALSE;
}
// Set Object's default icon entry to point to the
// default icon for the object
lRes = RegSetValue( hKey,
"DefaultIcon",
REG_SZ,
szIconPath,
lstrlen(szIconPath)
);
if (ERROR_SUCCESS != lRes) // bail on failure
{
RegCloseKey(hKey);
return FALSE;
}
// Close the reg db
RegCloseKey(hKey);
return TRUE;
}
#if defined(XP_WIN16)
/****************************************************************************/
/* */
/* BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! */
/* */
/* The following code is duplicated from ns\modules\applet\src\lj_embed.c */
/* It is ONLY required for 16-bit until JAVA becomes integrated into the */
/* build! */
/* */
/* BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! BEWARE! */
/* */
/****************************************************************************/
#if defined(MOCHA) && !defined(JAVA)
#include "prevent.h"
#include "prlog.h"
PR_LOG_DEFINE(Event);
/*
* There is currently a race between which thread destroys synchronous
* events. See bug 32832 for a full description.
*/
void
LJ_ProcessEvent()
{
PREvent* event;
for (;;) {
PR_LOG_BEGIN(Event, debug, ("$$$ getting event\n"));
event = PR_GetEvent(mozilla_event_queue);
if (event == NULL) {
return;
}
if(event->synchronousResult) {
PR_HandleEvent(event);
PR_LOG_END(Event, debug, ("$$$ done with sync event\n"));
}
else {
PR_HandleEvent(event);
PR_LOG_END(Event, debug, ("$$$ done with async event\n"));
PR_DestroyEvent(event);
}
}
}
#endif // MOCHA && !JAVA
#endif // XP_WIN16
#ifdef XP_WIN16
#if defined(NSPR20)
#include "private\prpriv.h"
#endif
void fe_yield(void)
{
PR_Sleep(PR_INTERVAL_NO_WAIT);
}
#endif

Просмотреть файл

@ -1,862 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "hiddenfr.h"
#include "template.h"
#ifdef MOZ_MAIL_NEWS
#include "wfemsg.h"
#endif
#include "timer.h"
#ifdef MOZ_MAIL_NEWS
#include "addrfrm.h"
#endif
#include "feselect.h"
#include "postal.h"
#include "ssl.h"
#ifdef MOZ_MAIL_NEWS
#include "nscpmapi.h" // rhp - for MAPI
#include "mapihook.h" // rhp - for MAPI
#include "mapismem.h"
#include "abapi.h" // rhp - for Address Book API
#include "abhook.h" // rhp - for Address Book API
#endif
extern "C" {
#include "layprobe.h"
}
#include "mozprobe.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHiddenFrame
#ifndef _AFXDLL
#undef new
#endif
IMPLEMENT_DYNCREATE(CHiddenFrame, CFrameWnd)
#ifndef _AFXDLL
#define new DEBUG_NEW
#endif
#define EXITING -10 //multi-instance code return values
#define RUNNING 10
const UINT NEAR msg_FoundDNS = RegisterWindowMessage("NetscapeDNSFound");
const UINT NEAR msg_ExitStatus = RegisterWindowMessage("ExitingNetscape");
UINT NEAR msg_ForceIOSelect = (UINT)-1;
UINT NEAR msg_NetActivity = (UINT)-1;
const UINT NEAR msg_AltMailBiffNotification = RegisterWindowMessage("Netscape Mail System");
// Net dike.
int gNetFloodStage = 0;
CHiddenFrame::CHiddenFrame()
{
// Attempt to make the registration of this as late as possible as to
// get the highest possible ID (see NSPumpMessage).
msg_ForceIOSelect = RegisterWindowMessage("NetscapeForceIOSelect");
msg_NetActivity = RegisterWindowMessage("NetscapeSocketSelect");
}
CHiddenFrame::~CHiddenFrame()
{
}
LONG CHiddenFrame::OnRequestExitStatus(WPARAM wParam/*0*/,LPARAM lParam/*0*/)
{
return (theApp.m_bExitStatus ? EXITING :RUNNING );
}
BEGIN_MESSAGE_MAP(CHiddenFrame, CFrameWnd)
//{{AFX_MSG_MAP(CHiddenFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
ON_REGISTERED_MESSAGE(msg_NetActivity, OnNetworkActivity)
ON_REGISTERED_MESSAGE(msg_FoundDNS, OnFoundDNS)
ON_REGISTERED_MESSAGE(msg_ForceIOSelect, OnForceIOSelect)
ON_REGISTERED_MESSAGE(msg_ExitStatus, OnRequestExitStatus)
ON_MESSAGE(MSG_TASK_NOTIFY, OnTaskNotify)
ON_WM_DESTROY()
ON_WM_ENDSESSION()
//}}AFX_MSG_MAP
#ifdef MOZ_MAIL_NEWS
ON_REGISTERED_MESSAGE(msg_AltMailBiffNotification, OnAltMailBiffNotification)
#endif
ON_WM_QUERYENDSESSION() //~~av
ON_MESSAGE(WM_COPYDATA, OnProcessIPCHook) // rhp - for MAPI
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHiddenFrame message handlers
#define HIDDENTIME 333
struct HiddenMessage {
UINT m_uMsg;
WPARAM m_wParam;
LPARAM m_lParam;
};
void wfe_HiddenRepost(void *pData)
{
HiddenMessage *pMsg = (HiddenMessage *)pData;
if(pMsg) {
if(theApp.m_pMainWnd && theApp.m_pMainWnd->GetSafeHwnd()) {
theApp.m_pMainWnd->PostMessage(pMsg->m_uMsg, pMsg->m_wParam, pMsg->m_lParam);
}
memset(pMsg, 0, sizeof(*pMsg));
delete pMsg;
pMsg = NULL;
}
}
void wfe_PostDelayedMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, uint32 uMilli = HIDDENTIME)
{
HiddenMessage *pMsg = new HiddenMessage;
if(pMsg) {
memset(pMsg, 0, sizeof(*pMsg));
pMsg->m_uMsg = uMsg;
pMsg->m_wParam = wParam;
pMsg->m_lParam = lParam;
void *pSet = FE_SetTimeout(wfe_HiddenRepost, (void *)pMsg, uMilli);
if(NULL == pSet) {
delete pMsg;
pMsg = NULL;
}
}
}
#ifdef MOZ_MAIL_NEWS
LONG CHiddenFrame::OnAltMailBiffNotification(WPARAM wParam, LPARAM lParam)
{
switch(wParam) {
case INBOX_STATE_NOMAIL:
FE_UpdateBiff(MSG_BIFF_NoMail);
break;
case INBOX_STATE_UNKNOWN:
FE_UpdateBiff(MSG_BIFF_Unknown);
break;
case INBOX_STATE_NEWMAIL:
FE_UpdateBiff(MSG_BIFF_NewMail);
break;
default:
break;
}
return(1);
}
#endif // MOZ_MAIL_NEWS
LONG CHiddenFrame::OnForceIOSelect(WPARAM wParam, LPARAM lParam)
{
// Net dike. (see hiddenfr.h)
// This code protects external message loops from the flood
// of network messages we would normally handle, thus
// keeping the app responsive while in a different
// message loop. External message loops being loops
// other than CNetscapeApp::NSPumpMessage.
BOOL bDoHandle = TRUE;
if(::GetMessageTime() != (LONG)theApp.GetMessageTime()) {
// Message came from different message loop than one
// found in CNetscapeApp::NSPumpMessage.
BOOL bReposted = FALSE;
// In the CNetscapeApp::NSPumpMessage this variable is
// usually incremented on EVERY MESSAGE. Note the
// difference here that we are incrementing it only
// on receipt of a network message, causing a much
// smaller window for these messages to get through.
// A small counter-balance is that we are going to
// repost the message, which causes this function
// to be entered again at some later time (thus
// incrementing the counter, etc).
// CNetscapeApp::NSPumpMessage only peeks and
// does not generate the overhead of yet another
// message, unlike this suboptimal code.
gNetFloodStage++;
// 1 : NET_FLOWCONTROL, we force a network event to be
// handled regardless of the queue state.
if((gNetFloodStage % NET_FLOWCONTROL) != 0) {
// See if there are messages not our own in the queue.
MSG msg;
if(::PeekMessage(&msg, NULL, 0, NET_MESSAGERANGE, PM_NOREMOVE)) {
// There are, repost till next time.
// We use a 1 millisecond timeout, based on what we know
// timers actually do. Timers don't fire until the
// queue is empty; thus the message will repost once
// all other stuff is done.
bDoHandle = FALSE;
wfe_PostDelayedMessage(msg_ForceIOSelect, wParam, lParam, 1);
}
}
}
if(bDoHandle) {
SelectType stType = (SelectType)wParam;
PRFileDesc *iFD = (PRFileDesc *)lParam;
int iNetlibType = NET_SOCKET_FD;
if(stType == FileSelect) {
iNetlibType = NET_LOCAL_FILE_FD;
}
else if(stType == NetlibSelect) {
iNetlibType = NET_EVERYTIME_TYPE;
}
// Must be socket or have in select list to continue.
// We don't check sockets here, as it is too difficult to
// segregate them out into their different select NetLib
// categories (see feselect.cpp).
//
// LJM removed call to HasSelect for nspr20 port
// if(iNetlibType == NET_SOCKET_FD || selecttracker.HasSelect(stType, iFD)) {
if(iNetlibType == NET_SOCKET_FD) {
int iWantMore = 1;
BOOL bCalledNetlib = FALSE;
if(winfeInProcessNet == FALSE) {
winfeInProcessNet = TRUE;
iWantMore = NET_ProcessNet(iFD, iNetlibType);
bCalledNetlib = TRUE;
winfeInProcessNet = FALSE;
}
if(bCalledNetlib == FALSE) {
// Wait to repost message, as we are in the callstack of netlib.
// If a dialog is up, then we don't want to max the CPU by posting
// of the same message over and over and the user can't hit
// a button.
wfe_PostDelayedMessage(msg_ForceIOSelect, wParam, lParam);
}
// LJM removed call to SSL_DataPending for NSPR20 port
else if(0 != iWantMore && (NET_SOCKET_FD != iNetlibType)) {
// Sockets don't need reposting if actually called netlib,
// as they will post messages themselves when data is ready.
// This is not true if they have SSL data buffered.
// However, we do repost for files, as they are ready for more.
PostMessage(msg_ForceIOSelect, wParam, lParam);
}
}
}
// Always handled.
return(1);
}
LONG CHiddenFrame::OnNetworkActivity(UINT socket, LONG lParam)
{
XP_ASSERT(0);
#ifdef NSPR20_DISABLED
return(OnForceIOSelect((WPARAM)SocketSelect, (LPARAM)socket));
#endif
return 0;
}
LONG CHiddenFrame::OnFoundDNS(WPARAM wParam, LONG lParam)
{
int iError = WSAGETASYNCERROR(lParam);
// Go through the DNS cache, find the correct task ID.
// The find should always be successful.
// Be sure to initalize values.
POSITION pos = NULL;
CString key;
CDNSObj *obj = NULL;
int i_found = 0;
LONG return_value = 1;
for(pos = DNSCacheMap.GetStartPosition(); pos != NULL;) {
DNSCacheMap.GetNextAssoc(pos, key, (CObject *&)obj);
if(!obj)
return return_value;
// Since the handle is not unique for the session only
// compare handles that are currently in use (i.e. active entries)
if(!obj->i_finished && obj->m_handle == (HANDLE)wParam) {
i_found = 1;
break;
}
// Clear out object if we didn't break.
// That way we don't retain value if we leave the loop.
obj = NULL;
}
if(!obj)
return return_value;
TRACE("%s error=%d h_name=%d task=%d\n", obj->m_host, iError,
(obj->m_hostent->h_name != NULL) ? 1 : 0, obj->m_handle);
// If by chance we couldn't find it, we have a problem.
//
ASSERT(i_found == 1);
/* temp fix */
if(!i_found)
return return_value;
// Mark this as completed.
//
obj->i_finished = 1;
// If there was an error, set it.
if (iError) {
TRACE("DNS Lookup failed! \n");
obj->m_iError = iError;
return_value = 0;
}
/* call ProcessNet for each socket in the list */
/* use a for loop so that we don't reference the "obj"
* after our last call to processNet. We need to do
* this because the "obj" can get free'd by the call
* chain after all the sockets have been removed from
* sock_list
*/
PRFileDesc *tmp_sock;
int count = XP_ListCount(obj->m_sock_list);
for(; count; count--) {
tmp_sock = (PRFileDesc *) XP_ListRemoveTopObject(obj->m_sock_list);
// Make sure we call into the Netlib on this socket in particular,
// NET_SOCKET_FD type.
OnForceIOSelect((WPARAM)SocketSelect, (LPARAM)tmp_sock);
}
return(return_value);
}
void CHiddenFrame::OnDestroy()
{
#ifdef _WIN32
if (sysInfo.m_bWin4) {
// Kill this biff taskbar icon
NOTIFYICONDATA nid;
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = GetSafeHwnd();
nid.uID = ID_TOOLS_INBOX;
nid.uFlags = 0;
Shell_NotifyIcon( NIM_DELETE, &nid );
}
#endif
CFrameWnd::OnDestroy();
}
/****************************************************************************
*
* Task notification handling functions
*
****************************************************************************/
/****************************************************************************
*
* CHiddenFrame::OnTaskNotify
*
* PARAMETERS:
* wParam - icon ID
* lParam - mouse event
*
* RETURNS:
* Non-zero if message is processed.
*
* DESCRIPTION:
* This is the handler for the notification messages we received from
* task bar icons.
*
****************************************************************************/
LONG CHiddenFrame::OnTaskNotify(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
case ID_TOOLS_WEB:
{
HandleWebNotification(lParam);
}
break;
#ifdef MOZ_MAIL_NEWS
case ID_TOOLS_MAIL:
{
HandleMailNotification(lParam);
}
break;
case ID_TOOLS_INBOX:
{
HandleInboxNotification(lParam);
}
break;
#endif /* MOZ_MAIL_NEWS */
#ifdef EDITOR
case ID_TOOLS_EDITOR:
{
HandleEditorNotification(lParam);
}
break;
#endif // EDITOR
#ifdef MOZ_MAIL_NEWS
case ID_TOOLS_NEWS:
{
HandleNewsNotification(lParam);
}
break;
case ID_FILE_NEWMESSAGE:
{
HandleComposeNotification(lParam);
}
break;
case ID_TOOLS_ADDRESSBOOK:
{
HandleAddressBookNotification(lParam);
}
break;
#endif /* MOZ_MAIL_NEWS */
}
return(1L);
} // END OF FUNCTION CHiddenFrame::OnTaskNotify()
#ifdef MOZ_MAIL_NEWS
/****************************************************************************
*
* CHiddenFrame::HandleMailNotification
*
* PARAMETERS:
* lMessage - mouse notification message
*
* RETURNS:
* void
*
* DESCRIPTION:
* This is the mouse event notification handler for the mail icon
* located in the Task Bar.
*
****************************************************************************/
void CHiddenFrame::HandleMailNotification(LONG lMessage)
{
switch (lMessage)
{
case WM_LBUTTONUP:
{
if(!theApp.m_bKioskMode) { // TODO: is this still relevant?
WFE_MSGOpenInbox();
}
}
break;
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
break;
}
} // END OF FUNCTION CHiddenFrame::HandleMailNotification()
/****************************************************************************
*
* CHiddenFrame::HandleInboxNotification
*
* PARAMETERS:
* lMessage - mouse notification message
*
* RETURNS:
* void
*
* DESCRIPTION:
* This is the mouse event notification handler for the inbox icon
* located in the Task Bar.
*
****************************************************************************/
void CHiddenFrame::HandleInboxNotification(LONG lMessage)
{
switch (lMessage)
{
case WM_LBUTTONUP:
{
// Single click on mail icon means bring forth the mail window,
// check mail too if it wasn't already open.
if(!theApp.m_bKioskMode) // TODO: is this still relevant?
{
WFE_MSGOpenInbox(TRUE);
}
}
break;
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
break;
}
} // END OF FUNCTION CHiddenFrame::HandleMailNotification()
#endif /* MOZ_MAIL_NEWS */
/****************************************************************************
*
* CHiddenFrame::HandleWebNotification
*
* PARAMETERS:
* lMessage - mouse notification message
*
* RETURNS:
* void
*
* DESCRIPTION:
* This is the mouse event notification handler for the Web icon
* located in the Task Bar.
*
****************************************************************************/
void CHiddenFrame::HandleWebNotification(LONG lMessage)
{
switch (lMessage)
{
case WM_LBUTTONUP:
{
/* CAbstractCX *pCX = FEU_GetLastActiveFrameContext(MWContextAny);
CFrameWnd * pFrame = FEU_GetLastActiveFrame(MWContextAny);
if (pFrame && IsKindOf(RUNTIME_CLASS(CGenericFrame))) {
((CGenericFrame*)pFrame)->OnToolsWeb();
} else {
theApp.m_ViewTmplate->OpenDocumentFile( NULL );
}*/
BOOL bHandledMessage = FALSE;
CFrameWnd * pFrame = FEU_GetLastActiveFrame(MWContextAny);
if(pFrame)
if(pFrame->SendMessage(WM_COMMAND, WPARAM(ID_TOOLS_WEB), 0))
bHandledMessage = TRUE;
if(!bHandledMessage)
theApp.m_ViewTmplate->OpenDocumentFile( NULL );
}
break;
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
break;
}
} // END OF FUNCTION CHiddenFrame::HandleWebNotification()
#ifdef MOZ_MAIL_NEWS
/****************************************************************************
*
* CHiddenFrame::HandleNewsNotification
*
* PARAMETERS:
* lMessage - mouse notification message
*
* RETURNS:
* void
*
* DESCRIPTION:
* This is the mouse event notification handler for the news icon
* located in the Task Bar.
*
****************************************************************************/
void CHiddenFrame::HandleNewsNotification(LONG lMessage)
{
switch (lMessage)
{
case WM_LBUTTONUP:
{
if(!theApp.m_bKioskMode) { // TODO: is this still relevant?
WFE_MSGOpenNews();
}
}
break;
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
break;
}
} // END OF FUNCTION CHiddenFrame::HandleNewsNotification()
#endif /* MOZ_MAIL_NEWS */
#ifdef EDITOR
/****************************************************************************
*
* CHiddenFrame::HandleEditorNotification
*
* PARAMETERS:
* lMessage - mouse notification message
*
* RETURNS:
* void
*
* DESCRIPTION:
* This is the mouse event notification handler for the Compose icon
* located in the Task Bar.
*
****************************************************************************/
void CHiddenFrame::HandleEditorNotification(LONG lMessage)
{
switch (lMessage)
{
case WM_LBUTTONUP:
{
// Find last active editor/browser and find or launch new editor from there
// 2/17/96 - fixed bug 45611. Was creating disabled editor window when invoked from a
// Mail window. We need to look for any active frame, not just Browser frame.
// We send a message instead of assuming that it's a generic frame because the
// the inplace frame could be the last active frame.
CFrameWnd * pFrame = FEU_GetLastActiveFrame(MWContextAny, TRUE);
if (pFrame) {
pFrame->SendMessage(WM_COMMAND, WPARAM(ID_TOOLS_EDITOR), 0);
} else {
// there should always be an active frame.
ASSERT(FALSE); // FE_CreateNewEditWindow(NULL, NULL);
}
}
break;
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
break;
}
} // END OF FUNCTION CHiddenFrame::HandleWebNotification()
#endif
#ifdef MOZ_MAIL_NEWS
/****************************************************************************
*
* CHiddenFrame::HandleComposeNotification
*
* PARAMETERS:
* lMessage - mouse notification message
*
* RETURNS:
* void
*
* DESCRIPTION:
* This is the mouse event notification handler for the compose icon
* located in the Task Bar.
*
****************************************************************************/
void CHiddenFrame::HandleComposeNotification(LONG lMessage)
{
switch (lMessage)
{
case WM_LBUTTONUP:
{
CGenericFrame * pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
ASSERT(pFrame != NULL);
if (pFrame != NULL)
{
CAbstractCX * pCX = pFrame->GetMainContext();
if (pCX)
{
MSG_Mail ( pCX->GetContext() );
}
}
}
break;
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
break;
}
} // END OF FUNCTION CHiddenFrame::HandleNewsNotification()
void CHiddenFrame::HandleAddressBookNotification(LONG lMessage)
{
switch (lMessage)
{
case WM_LBUTTONUP:
CAddrFrame::Open();
break;
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
break;
}
} // END OF FUNCTION CHiddenFrame::HandleAddressBookNotification()
#endif /* MOZ_MAIL_NEWS */
//~~av
// added this message handler not to allow it to fall through the default
// MFC processing. Needed for bug 44748 fix when it crashed on system shutdown
// if plugin was running
BOOL CHiddenFrame::OnQueryEndSession()
{
return TRUE;
}
void CHiddenFrame::OnEndSession(BOOL bEnding)
{
if(bEnding) {
#ifdef MOZ_MAIL_NEWS
WFE_MSGShutdown();
#endif /* MOZ_MAIL_NEWS */
// Close all frames, and we'll exit.
PostMessage(WM_COMMAND, ID_APP_SUPER_EXIT, 0);
}
}
static LONG ProcessNetscapeProbeHook( WPARAM, LPARAM );
// rhp - 12/5/97
// This will simply turn around and call the function
// LONG ProcessNetscapeMAPIHook(WPARAM wParam, LPARAM lParam);
// and return the result. This is all for MAPI support in
// Communicator
//
LONG CHiddenFrame::OnProcessIPCHook(WPARAM wParam, LPARAM lParam)
{
PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT) lParam;
if (!pcds)
return(-1);
#ifdef MOZ_MAIL_NEWS
// Now check for what type of IPC message this really is?
if ((pcds->dwData > NSCP_MAPIStartRequestID) && (pcds->dwData < NSCP_MAPIEndRequestID))
{
return ( ProcessNetscapeMAPIHook(wParam, lParam) );
}
else if ((pcds->dwData > NSCP_NABStartRequestID) && (pcds->dwData < NSCP_NABEndRequestID))
{
return ( ProcessNetscapeNABHook(wParam, lParam) ); // 3-17: Address book API
}
#endif
// Not MAPI/NAB, try layout probe API...
else if ((pcds->dwData > NSCP_Probe_StartRequestID) && (pcds->dwData < NSCP_Probe_EndRequestID))
{
return ( ProcessNetscapeProbeHook(wParam, lParam) );
}
return(-1);
}
#ifdef MOZ_MAIL_NEWS
// rhp - new stuff for Address call...
void CHiddenFrame::AddressDialog(LPSTR winText,
MAPIAddressCallbackProc mapiCB,
MAPIAddressGetAddrProc getProc)
{
CAddrDialog AddressDialog(this, TRUE, winText, mapiCB, getProc);
AddressDialog.DoModal();
}
#endif /* MOZ_MAIL_NEWS */
/* Ordinal2Context
*
* Takes a simple ordinal (position in list) and returns the MWContext
* associated with that browser window. This is required by the
* layout probe server proc.
*/
static MWContext *Ordinal2Context( long context ) {
MWContext *result = 0;
// Loop through context list.
MWContext *pTraverseContext = NULL;
CAbstractCX *pTraverseCX = NULL;
XP_List *pTraverse = XP_GetGlobalContextList();
while (!result && ( pTraverseContext = (MWContext *)XP_ListNextObject(pTraverse) )) {
if(pTraverseContext != NULL && ABSTRACTCX(pTraverseContext) != NULL) {
pTraverseCX = ABSTRACTCX(pTraverseContext);
if(pTraverseCX->GetContext()->type == MWContextBrowser &&
pTraverseCX->IsFrameContext() == TRUE &&
pTraverseCX->IsDestroyed() == FALSE) {
CWinCX *pWinCX = (CWinCX *)pTraverseCX;
if(pWinCX->GetFrame()->GetFrameWnd() != NULL) {
// This is a context for a frame window. Decrement count
// and quit when it hits zero.
if ( --context == 0 ) {
// Result is the associated context.
result = pWinCX->GetContext();
}
}
}
}
}
return result;
}
static LONG ProcessNetscapeProbeHook( WPARAM wParam, LPARAM lParam ) {
static BOOL triedProbe = FALSE;
static HINSTANCE hProbe = 0;
static PROBESERVERPROC serverProc = 0;
static PROBEAPITABLE fnTbl = { LO_QA_CreateProbe,
LO_QA_DestroyProbe,
LO_QA_GotoFirstElement,
LO_QA_GotoNextElement,
LO_QA_GotoChildElement,
LO_QA_GotoParentElement,
LO_QA_GetElementType,
LO_QA_GetElementXPosition,
LO_QA_GetElementYPosition,
LO_QA_GetElementWidth,
LO_QA_GetElementHeight,
LO_QA_HasURL,
LO_QA_HasText,
LO_QA_HasColor,
LO_QA_HasChild,
LO_QA_HasParent,
LO_QA_GetText,
LO_QA_GetTextLength,
(BOOL(*)(long,long*,PROBECOLORTYPE))LO_QA_GetColor,
Ordinal2Context };
// Try one time to get the layout probe hook.
if ( !triedProbe ) {
triedProbe = TRUE;
// First, load the DLL.
hProbe = LoadLibrary( mozProbeDLLName );
if ( hProbe ) {
// Get the entry point for the server proc.
serverProc = (PROBESERVERPROC)GetProcAddress( hProbe, mozProbeServerProcName );
if ( !serverProc ) {
// Something wrong, free the DLL.
FreeLibrary( hProbe );
}
}
}
// If possible, process the layout probe hook.
if ( serverProc ) {
return ( serverProc(wParam, lParam, &fnTbl) );
}
return -1;
}

Просмотреть файл

@ -1660,14 +1660,12 @@ int CNetscapeApp::Run()
}
#ifdef XP_WIN16
#if defined(OJI) || defined(JAVA) || defined(MOCHA)
/*
** On Win16 the only way for another thread to run is to explicitly
** yield...
*/
extern void fe_yield(void);
fe_yield();
#endif /* OJI || JAVA || MOCHA */
#endif /* XP_WIN16 */
do {
@ -1794,14 +1792,12 @@ BOOL CNetscapeApp::OnIdle(LONG lCount)
// already sends a WM_IDLEUPDATECMDUI to each of the frames
#ifdef XP_WIN16
#if defined(OJI) || defined(JAVA) || defined(MOCHA)
/*
** On Win16 the only way for another thread to run is to explicitly
** yield...
*/
extern void fe_yield(void);
fe_yield();
#endif /* OJI || JAVA || MOCHA */
// Update the UI of the frames.
if(lCount == 0) {