MacFE code for Anthrax along with minor XP tweaks

This commit is contained in:
amusil%netscape.com 1998-09-03 21:08:25 +00:00
parent da1edc5f6a
commit 09a5166987
10 changed files with 570 additions and 188 deletions

View File

@ -1183,7 +1183,13 @@ void CFrontApp::RegisterMimeType(CMimeMapper * mapper)
if (pdesc)
NPL_RegisterPluginType(mimeName, mapper->GetExtensions(), mapper->GetDescription(), nil, pdesc, true);
return; // XP code will take care of the cdata
#ifdef ANTHRAX
case CMimeMapper::Applet:
NPL_RegisterAppletType(mimeName, mapper->GetAppletName());
break;
#endif
default:
// Disable the previous plug-in, if any
if (pdesc)

View File

@ -106,6 +106,10 @@ static const char* Pref_LoadAction = ".load_action";
static const char* Pref_LatentPlugin = ".latent_plug_in";
static const char* Pref_FileFlags = ".file_flags";
#ifdef ANTHRAX
static const char* Pref_AppletName = ".applet";
#endif
// CreateMapperFor converts an xp pref name into a mimetype mapper.
// Finds an existing mapper or creates a new one, and
// populates its fields from user pref values.
@ -215,6 +219,15 @@ void CMimeMapper::ReadMimePrefs()
::BlockMoveData( value, (Ptr) &fFileType, sizeof(OSType) );
}
}
#ifdef ANTHRAX
err = PREF_GetCharPref( CPrefs::Concat(fBasePref, Pref_AppletName), value, &size );
if (PREF_NOERROR == err)
{
fNumChildrenFound++;
fAppletName = value;
}
#endif
err = PREF_GetCharPref( CPrefs::Concat(fBasePref, Pref_AppName), value, &size );
if (PREF_NOERROR == err)
@ -431,6 +444,10 @@ CMimeMapper::CMimeMapper( const CMimeMapper& clone )
fIsLocked = clone.fIsLocked;
fNumChildrenFound = clone.fNumChildrenFound;
#ifdef ANTHRAX
fAppletName = clone.fAppletName;
#endif
}
// Copies values from the mapper to xp user pref tree.
@ -470,6 +487,10 @@ void CMimeMapper::WriteMimePrefs( Boolean )
PREF_SetCharPref( CPrefs::Concat(fBasePref, Pref_MimeType), fMimeType );
PREF_SetCharPref( CPrefs::Concat(fBasePref, Pref_AppName), fAppName );
PREF_SetCharPref( CPrefs::Concat(fBasePref, Pref_PluginName), fPluginName );
#ifdef ANTHRAX
PREF_SetCharPref( CPrefs::Concat(fBasePref, Pref_AppletName), fAppletName );
++fNumChildrenFound;
#endif
fNumChildrenFound += 3;
// store appsig and filetype as 4-byte character strings, if possible.
// otherwise, store as binary.
@ -508,6 +529,9 @@ CMimeMapper::CMimeMapper(
fDescription = "";
fLatentPlugin = false;
fBasePref = nil;
#ifdef ANTHRAX
fAppletName = "";
#endif
}
// Disposes of all allocated structures
@ -529,9 +553,19 @@ CMimeMapper & CMimeMapper::operator= (const CMimeMapper& mapper)
fDescription = mapper.fDescription;
fLatentPlugin = mapper.fLatentPlugin;
fFileFlags = mapper.fFileFlags;
#ifdef ANTHRAX
fAppletName = mapper.fAppletName;
#endif
return *this;
}
#ifdef ANTHRAX
void CMimeMapper::SetAppletName(const CStr255& newAppletName)
{
fAppletName = newAppletName;
}
#endif /* ANTHRAX */
void CMimeMapper::SetAppName(const CStr255& newName)
{
fAppName = newName;
@ -935,7 +969,12 @@ CMimeMapper* CMimeList::FindMimeType(const FSSpec& inFileSpec)
// on type and/or creator. bing: If we decide to support Mac file
// types for plug-ins, we should check the file type here.
//
#ifdef ANTHRAX
if(map->GetLoadAction() == CMimeMapper::Plugin ||
map->GetLoadAction() == CMimeMapper::Applet)
#else
if (map->GetLoadAction() == CMimeMapper::Plugin)
#endif /* ANTHRAX */
{
if (cinfo && (map->GetMimeName() == cinfo->type))
return map;
@ -1041,7 +1080,12 @@ void CMimeList::HandleRegisterViewerEvent(const AppleEvent &inAppleEvent,
// If the type is being handled by a plug-in, donÕt let the AE override
Boolean result = false;
#ifdef ANTHRAX // is this addition for anthrax correct? - amusil
if (mapper->GetLoadAction() != CMimeMapper::Plugin &&
mapper->GetLoadAction() != CMimeMapper::Applet)
#else
if (mapper->GetLoadAction() != CMimeMapper::Plugin)
#endif /* ANTHRAX */
{
mapper->RegisterViewer(appSign, fileType);
result = true;

View File

@ -28,6 +28,8 @@
#include "PascalString.h"
#include "ICKeys.h" // Needed for fileflags
#define ANTHRAX
class LFileBufferStream;
class CPrefs;
@ -43,7 +45,11 @@ typedef struct URL_Struct_ URL_Struct;
class CMimeMapper {
public:
// All these must be non-zero because of a presumed bug in back end
#ifdef ANTHRAX
enum LoadAction { Save = 0, Launch = 1, Internal = 2, Unknown = 3, Plugin = 4, Applet = 5};
#else
enum LoadAction { Save = 0, Launch = 1, Internal = 2, Unknown = 3, Plugin = 4};
#endif
// ¥¥ Constructors/destructors
void InitMapper();
@ -68,6 +74,9 @@ public:
// ¥¥ Access
// Set functions are used by app setup box
#ifdef ANTHRAX
void SetAppletName(const CStr255& newAppletName);
#endif
void SetAppName(const CStr255& newName);
void SetMimeType(const CStr255& newType);
void SetExtensions(const CStr255& newExtensions);
@ -87,6 +96,9 @@ public:
Boolean IsViewerRegistered() const { return fRegisteredViewer; }
// Get functions
#ifdef ANTHRAX
CStr255 GetAppletName() {return fAppletName;}
#endif
CStr255 GetAppName() {return fAppName;};
CStr255 GetMimeName() {return fMimeType;};
CStr255 GetExtensions() {return fExtensions;};
@ -144,7 +156,10 @@ private:
char* fBasePref; // Corresponding XP pref branch name
Int32 fFileFlags; // IC style FileFlags
Boolean fIsLocked; // If the mimetype pref is locked (for Mission Control functionality)
#ifdef ANTHRAX
CStr255 fAppletName;
#endif
};

View File

@ -54,9 +54,11 @@ enum
eChooseApplicationButton,
eFileTypePopupMenu,
eSaveRButton,
eUnknownRButton,
eResourceCheckbox,
eOutgoingCheckbox
eUnknownRButton
#ifdef ANTHRAX
, eAppletButton,
eAppletPopupMenu
#endif
};
#pragma mark --CMimeCell--
@ -352,6 +354,11 @@ void CMimeTableView::DrawCell(
case CMimeMapper::Plugin:
handlerName = mapper->GetPluginName();
break;
#ifdef ANTHRAX
case CMimeMapper::Applet:
handlerName = mapper->GetAppletName();
break;
#endif /* ANTHRAX */
}
textRect.left = offsetHandler;
@ -448,6 +455,13 @@ private:
void BuildPluginList();
void DeletePluginList();
void BuildFileTypeMenu();
#ifdef ANTHRAX
void SyncAppletControls(Boolean mimeTypeChanged);
void BuildAppletList();
void BuildAppletMenu();
void DeleteAppletList();
#endif
CMimeMapper::LoadAction GetLoadAction();
Boolean mInitialized; // Initialized with fCellInfo yet?
@ -468,8 +482,6 @@ private:
LGARadioButton *mRadioInternal;
LGARadioButton *mRadioUnknown;
LGARadioButton *mRadioPlugin;
LGACheckbox *mSendResouceFork;
LGACheckbox *mOutgoingCheckbox;
// CFilePicker *mAppPicker;
LCaption *mAppName;
LButton *mAppButton;
@ -477,6 +489,12 @@ private:
CStr255 mAppStr;
OSType mAppSig;
Boolean mLocked;
#ifdef ANTHRAX
LGARadioButton *mRadioApplet;
LGAPopup *mAppletPopup;
char** mAppletList;
uint32 mAppletCount;
#endif
}; // class CEditMIMEWindow
//-----------------------------------
@ -485,6 +503,10 @@ CEditMIMEWindow::CEditMIMEWindow(LStream* inStream):
LGADialogBox(inStream),
mModified(false),
mInitialized(false),
#ifdef ANTHRAX
mAppletList(nil),
mAppletCount(0),
#endif
mPluginList(nil),
mPluginCount(0),
mLocked( false )
@ -497,6 +519,9 @@ CEditMIMEWindow::~CEditMIMEWindow()
//-----------------------------------
{
DeletePluginList();
#ifdef ANTHRAX
DeleteAppletList();
#endif
}
@ -536,6 +561,14 @@ void CEditMIMEWindow::FinishCreateSelf()
mRadioPlugin = (LGARadioButton *)FindPaneByID(ePluginRButton);
XP_ASSERT(mRadioPlugin);
#ifdef ANTHRAX
mRadioApplet = (LGARadioButton *)FindPaneByID(eAppletButton);
XP_ASSERT(mRadioApplet);
mAppletPopup = (LGAPopup *)FindPaneByID(eAppletPopupMenu);
XP_ASSERT(mAppletPopup);
#endif /* ANTHRAX */
// mAppPicker = (CFilePicker *)FindPaneByID(eApplicationFilePicker);
// XP_ASSERT(mAppPicker);
@ -546,9 +579,6 @@ void CEditMIMEWindow::FinishCreateSelf()
mAppButton = (LButton *)FindPaneByID(eChooseApplicationButton);
XP_ASSERT(mAppButton);
mSendResouceFork = (LGACheckbox* ) ( FindPaneByID(eResourceCheckbox) );
mOutgoingCheckbox = (LGACheckbox* ) ( FindPaneByID(eOutgoingCheckbox) );
XP_ASSERT( mSendResouceFork );
// mAppMenuLabel = (LCaption *)FindPaneByID(pref8AppMenuLabel);
// XP_ASSERT(mAppMenuLabel);
@ -668,6 +698,82 @@ void CEditMIMEWindow::BuildPluginMenu()
}
}
#ifdef ANTHRAX
void CEditMIMEWindow::DeleteAppletList()
{
if (mAppletList)
{
uint32 index = 0;
while (mAppletList[index++])
{
free(mAppletList[index]);
}
free(mAppletList);
mAppletList = nil;
}
}
void CEditMIMEWindow::BuildAppletList()
{
// Delete the old list
DeleteAppletList();
// Get the new list from XP code - HACK!!!! for now
mAppletList = NPL_FindAppletsForType(mCellInfo->mMapper->GetMimeName());
// Count how many are in the list
mAppletCount = 0;
if (mAppletList)
{
while (mAppletList[mAppletCount])
mAppletCount++;
}
}
void CEditMIMEWindow::BuildAppletMenu()
{
uint32 oldCount = mAppletCount;
BuildAppletList();
if (oldCount || mAppletCount)
{
SetMenuSizeForLGAPopup(mAppletPopup, mAppletCount);
MenuHandle menuH = mAppletPopup->GetMacMenuH();
uint32 index = 0;
uint32 desiredValue = 1; // Default desired value is first item
while (mAppletList[index])
{
SetMenuItemText(menuH, index+1, CStr255(mAppletList[index]));
::EnableItem(menuH, index+1);
if (mCellInfo->mMapper->GetAppletName() == mAppletList[index])
{
desiredValue = index + 1;
}
index++;
}
//
// If the previously-selected applet name is in this list,
// select it; otherwise just select the first item.
// If we didn't change the control value, make sure it
// redraws since the contents of the list have changed.
//
uint32 previousValue = mAppletPopup->GetValue();
if (desiredValue != previousValue)
{
mAppletPopup->SetValue(desiredValue);
}
else
{
mAppletPopup->Refresh();
}
}
}
#endif /* ANTHRAX */
//struct BNDLIds
//{ // Utility structure for bundle parsing
// Int16 localID;
@ -857,6 +963,11 @@ void CEditMIMEWindow::UpdateRadioUItoMapper()
case CMimeMapper::Plugin:
mRadioPlugin->SetValue(1);
break;
#ifdef ANTHRAX
case CMimeMapper::Applet:
mRadioApplet->SetValue(1);
break;
#endif
}
}
@ -997,6 +1108,41 @@ void CEditMIMEWindow::SyncPluginControls(Boolean mimeTypeChanged)
}
#ifdef ANTHRAX
void CEditMIMEWindow::SyncAppletControls(Boolean mimeTypeChanged)
{
if (mimeTypeChanged)
{
BuildAppletMenu();
}
//
// If we have an Applet installed, enable the radio button
//
if (mAppletCount > 0)
{
mRadioApplet->Enable();
}
else
{
mRadioApplet->Disable();
if (mRadioApplet->GetValue() == 1)
mRadioUnknown->SetValue(1);
}
//
// Determine the Applet popup control enabled state
//
if (GetLoadAction() == CMimeMapper::Applet && mAppletCount > 0)
{
mAppletPopup->Enable();
}
else
{
mAppletPopup->Disable();
}
}
#endif /* ANTHRAX */
CMimeMapper::LoadAction CEditMIMEWindow::GetLoadAction()
{
@ -1005,6 +1151,9 @@ CMimeMapper::LoadAction CEditMIMEWindow::GetLoadAction()
if ( mRadioInternal->GetValue() ) return CMimeMapper::Internal;
if ( mRadioUnknown->GetValue() ) return CMimeMapper::Unknown;
if (mRadioPlugin ->GetValue() ) return CMimeMapper::Plugin;
#ifdef ANTHRAX
if(mRadioApplet->GetValue()) return CMimeMapper::Applet;
#endif
return CMimeMapper::Unknown;
}
@ -1014,13 +1163,17 @@ void CEditMIMEWindow::ListenToMessage(MessageT inMessage, void *ioParam)
//-----------------------------------
{
if (!mInitialized)
{
return;
}
if ( ioParam == mRadioLaunch)
SyncApplicationControls(false);
if ( ioParam == mRadioPlugin )
SyncPluginControls(false);
#ifdef ANTHRAX
if(ioParam == mRadioApplet)
SyncAppletControls(false);
#endif
switch (inMessage)
{
// Pick a handler
@ -1029,8 +1182,9 @@ void CEditMIMEWindow::ListenToMessage(MessageT inMessage, void *ioParam)
case eCommunicatorRButton:
case eUnknownRButton:
case ePluginRButton:
case eResourceCheckbox:
case eOutgoingCheckbox:
#ifdef ANTHRAX
case eAppletButton:
#endif
mModified = TRUE;
break;
@ -1068,6 +1222,15 @@ void CEditMIMEWindow::ListenToMessage(MessageT inMessage, void *ioParam)
break;
}
#ifdef ANTHRAX
case eAppletPopupMenu:
{
SyncAppletControls(false);
mModified = TRUE;
break;
}
#endif /* ANTHRAX */
// Edit some text
case msg_EditField2:
{
@ -1083,7 +1246,7 @@ void CEditMIMEWindow::ListenToMessage(MessageT inMessage, void *ioParam)
mModified = TRUE;
break;
}
case msg_OK:
UpdateMapperToUI();
break;
@ -1108,17 +1271,23 @@ void CEditMIMEWindow::UpdateUIToMapper()
UpdateRadioUItoMapper();
SyncTextControls();
SyncInternalControl();
#ifdef ANTHRAX
SyncAppletControls(true);
#endif
SyncApplicationControls(true);
SyncPluginControls(true);
Int32 fileFlags = mCellInfo->mMapper->GetFileFlags();
Boolean flag = ( fileFlags & ICmap_resource_fork_mask ) > 0;
mSendResouceFork->SetValue(flag );
Boolean flag = ( fileFlags & ICmap_resource_fork_mask ) > 0;
flag = (!(fileFlags & ICmap_not_outgoing_mask) )> 0;
mOutgoingCheckbox->SetValue( flag );
mLocked = PREF_PrefIsLocked( CPrefs::Concat(mCellInfo->mMapper->GetBasePref(), ".mimetype") );
if( mLocked )
{
for( PaneIDT i = eDescriptionField ; i<= eOutgoingCheckbox ; i++ )
#ifdef ANTHRAX
for( PaneIDT i = eDescriptionField ; i<= eAppletPopupMenu ; i++ )
#else
for( PaneIDT i = eDescriptionField ; i<= eUnknownRButton ; i++ )
#endif
{
LPane* pane = FindPaneByID( i );
if( pane )
@ -1170,6 +1339,19 @@ void CEditMIMEWindow::UpdateMapperToUI()
mCellInfo->mMapper->SetPluginName(plugin);
}
}
#ifdef ANTHRAX
else if(mRadioApplet->GetValue() == 1)
{
uint32 item = mAppletPopup->GetValue();
XP_ASSERT(item > 0);
if (mAppletList && item > 0 && item <= mAppletCount)
{
char* applet = mAppletList[item - 1]; // Menu is 1-based, list is 0-based
if (applet)
mCellInfo->mMapper->SetAppletName(applet);
}
}
#endif
else
mCellInfo->mMapper->SetPluginName( "\p" );
@ -1179,11 +1361,9 @@ void CEditMIMEWindow::UpdateMapperToUI()
::DisposeIconSuite( mCellInfo->mIcon , true);
mCellInfo->mIcon = nil;
}
// XXX this file flag stuff might no longer be needed, but I'm not sure
Int32 fileFlags = 0;
if( mSendResouceFork->GetValue( ) )
fileFlags = fileFlags | ICmap_resource_fork_mask ;
if( !mOutgoingCheckbox->GetValue() )
fileFlags = fileFlags | ICmap_not_outgoing_mask ;
mCellInfo->mMapper->SetFileFlags( fileFlags );
}
#pragma mark --CBrowserApplicationsMediator--

View File

@ -43,6 +43,7 @@ typedef enum { NP_FullPage = 1, NP_Embedded } NPPageType;
typedef void* NPReference;
#define NPRefFromStart ((NPReference)NULL)
#define ANTHRAX
/* it's lame that this is supposed to support more than plugins but
it has plugin specific junk (wdata) in it -jg */
@ -124,7 +125,8 @@ extern XP_Bool NPL_IsForcingRedraw();
#ifdef ANTHRAX
extern char** NPL_FindAppletsForType(const char* typeToFind);
extern char* NPL_FindAppletEnabledForMimetype(const char* mimetype);
extern NPError NPL_RegisterAppletType(NPMIMEType type);
extern NPError NPL_RegisterAppletType(NPMIMEType type, char* filename);
extern void NPL_InstallAppletHandler(char* appletName, char* mimetype, char* extension);
#endif /* ANTHRAX */
PR_EXTERN(void) NPL_SetPluginWindow(void *data);

View File

@ -27,10 +27,6 @@
#include "laystyle.h"
#include "layers.h"
#ifdef ANTHRAX /* 9.23.97 amusil */
#include "prefapi.h"
#endif /* ANTHRAX */
#ifdef XP_WIN16
#define SIZE_LIMIT 32000
#endif /* XP_WIN16 */
@ -183,78 +179,30 @@ lo_FormatEmbed(MWContext *context, lo_DocState *state, PA_Tag *tag)
{
LO_EmbedStruct *embed;
#ifdef ANTHRAX
LO_ObjectStruct* object;
PA_Block buff;
NET_cinfo* fileInfo;
char* str;
char* appletName;
uint32 src_len;
/* check to see if the type maps to an applet */
buff = lo_FetchParamValue(context, tag, PARAM_TYPE);
if(buff == NULL)
{
/* get SRC */
buff = lo_FetchParamValue(context, tag, PARAM_SRC);
PA_LOCK(str, char *, buff);
/* if we didn't find a type param, look for an association in the SRC */
fileInfo = NET_cinfo_find_type(str);
str = fileInfo->type;
}
else
PA_LOCK(str, char *, buff);
/* check to see if this mimetype has an applet handler */
if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL)
{
PA_UNLOCK(buff);
if(buff)
XP_FREE(buff);
embed = (LO_EmbedStruct *)lo_NewElement(context, state, LO_EMBED, NULL, 0);
if (embed == NULL)
{
return;
}
/* just pass it to our object handler */
lo_FormatObject(context, state, tag);
/* manually close the java app - this is normally done in lo_ProcessObjectTag */
lo_CloseJavaApp(context, state, state->current_java);
XP_FREE(appletName);
}
else
{
PA_UNLOCK(buff);
if(buff)
XP_FREE(buff);
#endif /* ANTHRAX */
embed->objTag.type = LO_EMBED;
embed->objTag.ele_id = NEXT_ELEMENT;
embed->objTag.x = state->x;
embed->objTag.x_offset = 0;
embed->objTag.y = state->y;
embed->objTag.y_offset = 0;
embed->objTag.width = 0;
embed->objTag.height = 0;
embed->objTag.next = NULL;
embed->objTag.prev = NULL;
embed = (LO_EmbedStruct *)lo_NewElement(context, state, LO_EMBED, NULL, 0);
if (embed == NULL)
{
return;
}
LO_NVList_Init( &embed->attributes );
LO_NVList_Init( &embed->parameters );
embed->objTag.type = LO_EMBED;
embed->objTag.ele_id = NEXT_ELEMENT;
embed->objTag.x = state->x;
embed->objTag.x_offset = 0;
embed->objTag.y = state->y;
embed->objTag.y_offset = 0;
embed->objTag.width = 0;
embed->objTag.height = 0;
embed->objTag.next = NULL;
embed->objTag.prev = NULL;
embed->attributes.n = PA_FetchAllNameValues(tag,
&(embed->attributes.names), &(embed->attributes.values), CS_FE_ASCII);
LO_NVList_Init( &embed->attributes );
LO_NVList_Init( &embed->parameters );
embed->attributes.n = PA_FetchAllNameValues(tag,
&(embed->attributes.names), &(embed->attributes.values), CS_FE_ASCII);
lo_FormatEmbedInternal(context, state, tag, embed, FALSE, FALSE);
#ifdef ANTHRAX
}
#endif /* ANTHRAX */
lo_FormatEmbedInternal(context, state, tag, embed, FALSE, FALSE);
}
@ -347,8 +295,6 @@ lo_FormatEmbedObject(MWContext* context, lo_DocState* state,
if (param_count > 0)
{
int i;
/* Add all <PARAM> tag parameters to the parameters list */
embed->parameters.names = (char**) PA_ALLOC(param_count*sizeof(char*));
embed->parameters.values = (char**) PA_ALLOC(param_count*sizeof(char*));

View File

@ -42,9 +42,11 @@ Bool lo_CheckObjectBlockage(MWContext*, lo_DocState*, lo_ObjectStack*);
static void lo_SetClassID(PA_Tag* tag, char* appletName);
static char* lo_GetNextName(char** index);
static char* lo_GetNextValue(char** index);
static void lo_SetJavaArgs(char* tag, LO_JavaAppStruct* current_java);
static void lo_SetArgs(char* tag, lo_ObjectStack* top);
static void lo_itoa(uint32 n, char* s);
static void lo_ReverseString(char* s);
static void lo_AddParam(PA_Tag* tag, char* aName, char* aValue);
static void lo_RemoveParam(PA_Tag* tag, char* name);
#endif /* ANTHRAX */
void
@ -60,7 +62,6 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag)
char* pluginName;
#ifdef ANTHRAX
XP_Bool javaMimetypeHandler = FALSE;
char* appletName;
NET_cinfo* fileInfo;
#endif /* ANTHRAX */
@ -256,7 +257,7 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag)
We do a lookup and if there is an association, the name
of the applet is placed into "appletName".
NOTE: PREF_CopyCharPref() allocates memory for appletName
NOTE: NPL_FindAppletEnabledForMimetype() allocates memory for appletName
and we must free it.
9.23.97 amusil
@ -265,13 +266,31 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag)
if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL)
{
/* Set the type */
type = LO_JAVA;
type = LO_EMBED;
sub_type = LO_JAVA;
/* set the CLASSID to whatever was put into "appletName" */
lo_SetClassID(tag, appletName);
/*lo_SetClassID(tag, appletName);*/
lo_AddParam(tag, "CODE", appletName);
lo_SetArgs((char*)tag->data, top);
lo_RemoveParam(tag, "type");
lo_RemoveParam(tag, "src");
lo_RemoveParam(tag, "data");
lo_AddParam(tag, "TYPE", JAVA_PLUGIN_MIMETYPE);
/* do the same for the clone_tag */
if(top->clone_tag)
{
lo_AddParam(top->clone_tag, "CODE", appletName);
lo_RemoveParam(top->clone_tag, "type");
lo_RemoveParam(top->clone_tag, "src");
lo_RemoveParam(top->clone_tag, "data");
lo_AddParam(top->clone_tag, "TYPE", JAVA_PLUGIN_MIMETYPE);
}
/* set this so that we know later to translate the DATA/SRC param to a Java arg */
javaMimetypeHandler = TRUE;
XP_FREE(appletName);
}
#endif /* ANTHRAX */
@ -323,14 +342,30 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag)
if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL)
{
/* Set the type */
type = LO_JAVA;
type = LO_EMBED;
sub_type = LO_JAVA;
/* set the CLASSID to whatever was put into "appletName" */
lo_SetClassID(tag, appletName);
/*lo_SetClassID(tag, appletName);*/
/* set this so that we know later to translate the DATA/SRC param to a Java arg */
javaMimetypeHandler = TRUE;
XP_FREE(appletName); /* do we need to free this regardless? */
lo_SetArgs((char*)tag->data, top);
lo_RemoveParam(tag, "type");
lo_RemoveParam(tag, "src");
lo_RemoveParam(tag, "data");
lo_AddParam(tag, "TYPE", JAVA_PLUGIN_MIMETYPE);
lo_AddParam(tag, "CODE", appletName);
/* do the same for the clone_tag */
if(top->clone_tag)
{
lo_AddParam(top->clone_tag, "CODE", appletName);
lo_RemoveParam(top->clone_tag, "type");
lo_RemoveParam(top->clone_tag, "src");
lo_RemoveParam(top->clone_tag, "data");
lo_AddParam(top->clone_tag, "TYPE", JAVA_PLUGIN_MIMETYPE);
}
XP_FREE(appletName); /* do we need to free this regardless? */
}
if(buff)
XP_FREE(buff);
@ -341,10 +376,10 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag)
if (type == LO_EMBED)
{
object->lo_element.lo_plugin.type = LO_EMBED;
if(sub_type == LO_JAVA)
{
object->lo_element.lo_plugin.sub_type = LO_JAVA;
}
if(sub_type == LO_JAVA)
{
object->lo_element.lo_plugin.sub_type = LO_JAVA;
}
}
else if (type == LO_BUILTIN)
{
@ -364,18 +399,6 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag)
object->lo_element.lo_plugin.type = LO_JAVA;
lo_FormatJavaObject(context, state, tag, (LO_JavaAppStruct*) object);
/*
If we determined previously that this is an applet to mimetype
association, we must set up the SRC or DATA as an arg for the
applet.
9.8.97 amusil
*/
#ifdef ANTHRAX
if(javaMimetypeHandler)
lo_SetJavaArgs((char*)tag->data, state->current_java);
#endif /* ANTHRAX */
}
}
#endif /* JAVA */
@ -1129,7 +1152,6 @@ static void lo_SetClassID(PA_Tag* tag, char* appletName)
{
uint32 appletNameLen, oldTagLen, newTagLen;
char* tagData;
char foo;
appletNameLen = XP_STRLEN(appletName);
oldTagLen = XP_STRLEN((char*)tag->data);
@ -1273,23 +1295,21 @@ static char* lo_GetNextValue(char** tag)
/*
lo_SetJavaArgs
lo_SetArgs
--------------
Extracts every param and passes them as arguements to the Java applet.
Extracts every param and passes them as arguments to the Java applet.
Here is the mapping: <... X=Y ...> becomes equivalent to <PARAM NAME=x VALUE=y>
NOTE: lo_GetNextName() lo_GetNextValue() and allocates new memory for the return values.
10.7.97 amusil
*/
#ifdef JAVA
static void lo_SetJavaArgs(char* tag, LO_JavaAppStruct* current_java)
static void lo_SetArgs(char* tag, lo_ObjectStack* top)
{
char* paramName;
char* paramValue;
char* index;
Bool is_percent;
int32 val;
index = tag;
while(TRUE)
@ -1299,52 +1319,26 @@ static void lo_SetJavaArgs(char* tag, LO_JavaAppStruct* current_java)
break;
/* always map data to src */
if(!strcasecomp(paramName, "data"))
if(!XP_STRCASECMP(paramName, "data"))
{
XP_FREE(paramName);
paramName = XP_STRDUP("src");
}
paramValue = lo_GetNextValue(&index);
/* Check if the user specified a % for height and width */
if(!strcasecmp(paramName, "height"))
{
val = lo_ValueOrPercent(paramValue, &is_percent);
if(is_percent)
{
XP_FREE(paramValue);
/* int32 cannot exceed 10 digits */
paramValue = XP_ALLOC(11 * sizeof(char));
lo_itoa(current_java->height, paramValue);
}
}
if(!strcasecmp(paramName, "width"))
{
val = lo_ValueOrPercent(paramValue, &is_percent);
if(is_percent)
{
XP_FREE(paramValue);
/* int32 cannot exceed 10 digits */
paramValue = XP_ALLOC(11 * sizeof(char));
lo_itoa(current_java->width, paramValue);
}
}
/* increment and resize array */
++(current_java->parameters.n);
current_java->parameters.names = XP_REALLOC(current_java->parameters.names, current_java->parameters.n*sizeof(char*));
XP_ASSERT(current_java->parameters.names);
current_java->parameters.values = XP_REALLOC(current_java->parameters.values, current_java->parameters.n*sizeof(char*));
XP_ASSERT(current_java->parameters.values);
++(top->parameters.n);
top->parameters.names = XP_REALLOC(top->parameters.names, top->parameters.n*sizeof(char*));
XP_ASSERT(top->parameters.names);
top->parameters.values = XP_REALLOC(top->parameters.values, top->parameters.n*sizeof(char*));
XP_ASSERT(top->parameters.values);
/* point the new array elements to the newly allocated paramName and paramValue */
current_java->parameters.names[current_java->parameters.n-1] = paramName;
current_java->parameters.values[current_java->parameters.n-1] = paramValue;
top->parameters.names[top->parameters.n-1] = paramName;
top->parameters.values[top->parameters.n-1] = paramValue;
}
}
#endif
static void lo_itoa(uint32 n, char* s)
{
@ -1376,4 +1370,63 @@ static void lo_ReverseString(char* s)
}
}
static void lo_RemoveParam(PA_Tag* tag, char* name)
{
char* start, *end;
char* tagData = (char*)tag->data;
start = XP_STRCASESTR(tagData, name);
if(start != NULL)
{
end = start;
/* advance to the = */
while(*end != '=')
++end;
/* skip the = */
++end;
/* advance through whitespace */
while(*end == ' ')
++end;
/* advance until we hit whitespace again */
while(*end != ' ')
++end;
/* clear it out */
while(start != end)
{
*start = ' ';
++start;
}
}
}
static void lo_AddParam(PA_Tag* tag, char* aName, char* aValue)
{
uint32 nameLen, valueLen, oldTagLen, newTagLen;
char* tagData;
nameLen = XP_STRLEN(aName);
valueLen = XP_STRLEN(aValue);
oldTagLen = XP_STRLEN((char*)(tag->data));
newTagLen = oldTagLen + nameLen + valueLen + 3;
tag->data = XP_REALLOC(tag->data, newTagLen+1);
/* Remove the '>' character */
tagData = (char*)(tag->data);
tagData[oldTagLen-1] = 0;
/* Add "aName=aValue" */
XP_STRCAT(tagData, " ");
XP_STRCAT(tagData, aName);
XP_STRCAT(tagData, "=");
XP_STRCAT(tagData, aValue);
XP_STRCAT(tagData, " >");
tag->data_len = newTagLen;
}
#endif /* ANTHRAX */

View File

@ -90,9 +90,14 @@
/* Added to encapsulate code that was previously in six different places in LO_LayoutTag()! */
static void lo_ProcessFontTag( lo_DocState *state, PA_Tag *tag, int32 fontSpecifier, int32 attrSpecifier );
static void lo_AddParam(PA_Tag* tag, char* aName, char* aValue);
#ifdef OJI
#define JAVA_PLUGIN_MIMETYPE "application/x-java-vm"
static void lo_AddParam(PA_Tag* tag, char* aName, char* aValue);
#endif
#ifdef ANTHRAX
static void lo_RemoveParam(PA_Tag* tag, char* name);
#endif
/*************************************
@ -1316,7 +1321,7 @@ static void
lo_process_span_tag(MWContext *context, lo_DocState *state, PA_Tag *tag)
{
LO_SpanStruct *span;
PA_Block buff;
PA_Block buf;
lo_DocLists *doc_lists;
doc_lists = lo_GetCurrentDocLists(state);
@ -6605,6 +6610,12 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
case P_EMBED:
if (tag->is_end == FALSE && !state->hide_content)
{
#ifdef ANTHRAX
PA_Block buff;
NET_cinfo* fileInfo;
char* str;
char* appletName;
#endif
/*
* If we have started loading an EMBED we are
* out if the HEAD section of the HTML
@ -6612,7 +6623,44 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
*/
state->top_state->in_head = FALSE;
state->top_state->in_body = TRUE;
#ifdef ANTHRAX
/* determine the mimetype */
buff = lo_FetchParamValue(context, tag, PARAM_TYPE);
if(buff == NULL)
{
/* get SRC */
buff = lo_FetchParamValue(context, tag, PARAM_SRC);
PA_LOCK(str, char *, buff);
/* if we didn't find a type param, look for an association in the SRC */
fileInfo = NET_cinfo_find_type(str);
str = fileInfo->type;
}
else
PA_LOCK(str, char *, buff);
/* check to see if this mimetype has an applet handler */
if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL)
{
PA_UNLOCK(buff);
if(buff)
XP_FREE(buff);
//lo_AddParam(tag, "CODE", appletName);
//lo_RemoveParam(tag, "type");
//lo_AddParam(tag, "TYPE", "application/x-java-vm");
//lo_FormatEmbed(context, state, tag);
lo_ProcessObjectTag(context, state, tag, FALSE);
tag->is_end = TRUE;
lo_ProcessObjectTag(context, state, tag, FALSE);
}
else
lo_FormatEmbed(context, state, tag);
#else
lo_FormatEmbed(context, state, tag);
#endif /* ANTHRAX */
}
break;
@ -7581,7 +7629,41 @@ void lo_PostLayoutTag(MWContext * context, lo_DocState *state, PA_Tag *tag, XP_B
#endif /* PICS_SUPPORT */
}
#ifdef OJI
#ifdef ANTHRAX
static void lo_RemoveParam(PA_Tag* tag, char* name)
{
char* start, *end;
char* tagData = (char*)tag->data;
start = XP_STRCASESTR(tagData, name);
if(start != NULL)
{
end = start;
/* advance to the = */
while(*end != '=')
++end;
/* skip the = */
++end;
/* advance through whitespace */
while(*end == ' ')
++end;
/* advance until we hit whitespace again */
while(*end != ' ')
++end;
/* clear it out */
while(start != end)
{
*start = ' ';
++start;
}
}
}
#endif
static void lo_AddParam(PA_Tag* tag, char* aName, char* aValue)
{
uint32 nameLen, valueLen, oldTagLen, newTagLen;
@ -7607,5 +7689,4 @@ static void lo_AddParam(PA_Tag* tag, char* aName, char* aValue)
tag->data_len = newTagLen;
}
#endif /* OJI */

View File

@ -1366,7 +1366,10 @@ np_posturlinternal(NPP npp, const char* relativeURL, const char *target,
}
}
else
return NPERR_OUT_OF_MEMORY_ERROR;
{
err = NPERR_OUT_OF_MEMORY_ERROR;
goto error;
}
/*
* FTP protocol requires that the data be in a file.
@ -3163,7 +3166,7 @@ NPL_NewPresentStream(FO_Present_Types format_out, void* type, URL_Struct* urls,
strLen = XP_STRLEN(fileName);
newTag = XP_ALLOC((36+strLen)*sizeof(char));
newTag = (char*)XP_ALLOC((36+strLen)*sizeof(char));
newTag[0] = 0;
XP_STRCAT(newTag, "<embed src=");
@ -5363,7 +5366,7 @@ NPL_FindAppletsForType(const char* mimetype)
*/
NPError
NPL_RegisterAppletType(NPMIMEType type)
NPL_RegisterAppletType(NPMIMEType type, char* filename)
{
/*
* Is this Applet the wildcard (a.k.a. null) plugin?
@ -5373,10 +5376,11 @@ NPL_RegisterAppletType(NPMIMEType type)
*/
XP_Bool wildtype = (strcmp(type, "*") == 0);
np_handle* handle = NULL;
char* newPref;
for(handle = np_alist; handle != NULL; handle = handle->next)
{
if(!XP_STRCMP(handle->name, type))
if(!XP_STRCMP(handle->name, type) && !XP_STRCMP(handle->filename, filename))
break;
}
@ -5387,6 +5391,7 @@ NPL_RegisterAppletType(NPMIMEType type)
return NPERR_OUT_OF_MEMORY_ERROR;
StrAllocCopy(handle->name, type);
StrAllocCopy(handle->filename, filename);
handle->pdesc = NULL;
handle->next = np_alist;
@ -5397,27 +5402,77 @@ NPL_RegisterAppletType(NPMIMEType type)
/* EmbedStream does some Windows FE work and then calls NPL_NewStream */
if (!wildtype)
NET_RegisterContentTypeConverter(type, FO_PRESENT, handle, EmbedStream);
NET_RegisterContentTypeConverter(type, FO_EMBED, handle, EmbedStream); /* XXX I dont think this does anything useful */
#else
if (!wildtype)
{
NET_RegisterContentTypeConverter(type, FO_PRESENT, handle, NPL_NewPresentStream);
#ifdef XP_UNIX
/* While printing we use the FO_SAVE_AS_POSTSCRIPT format type. We want
* plugin to possibly handle that case too. Hence this.
*/
NET_RegisterContentTypeConverter(type, FO_SAVE_AS_POSTSCRIPT, handle,
NPL_NewPresentStream);
#endif /* XP_UNIX */
}
NET_RegisterContentTypeConverter(type, FO_EMBED, handle, NPL_NewEmbedStream);
#endif
NET_RegisterContentTypeConverter(type, FO_PLUGIN, handle, np_newpluginstream);
NET_RegisterContentTypeConverter(type, FO_BYTERANGE, handle, np_newbyterangestream);
newPref = np_CreateMimePref(type, "load_action");
PREF_SetIntPref(newPref, 5);
XP_FREE(newPref);
return NPERR_NO_ERROR;
}
void
NPL_InstallAppletHandler(char* appletName, char* mimetype, char* extension)
{
char* newPref;
char buffer[100];
int32 numApplets;
int bufLen = 100;
/* check if it's an entirely new mimetype */
newPref = np_CreateMimePref(mimetype, "mimetype");
if(PREF_GetCharPref(newPref, buffer, &bufLen) != PREF_OK)
{
PREF_SetCharPref(newPref, mimetype);
XP_FREE(newPref);
newPref = np_CreateMimePref(mimetype, "extension");
PREF_SetCharPref(newPref, extension);
}
XP_FREE(newPref);
newPref = np_CreateMimePref(mimetype, "num_applets");
/* check if this is the first applet installed for this mimetype */
if(PREF_GetIntPref(newPref, &numApplets) != PREF_OK)
{
/* First Applet installed for mimetype */
PREF_SetIntPref(newPref, 1);
XP_FREE(newPref);
newPref = np_CreateMimePref(mimetype, "applet1");
PREF_SetCharPref(newPref, appletName);
XP_FREE(newPref);
newPref = np_CreateMimePref(mimetype, "applet");
PREF_SetCharPref(newPref, appletName);
XP_FREE(newPref);
}
else
{
char appletN[] = { 'a', 'p', 'p', 'l', 'e', 't', '1', '\0'};
++numApplets;
PREF_SetIntPref(newPref, numApplets);
XP_FREE(newPref);
XP_ASSERT(numApplets < 10);
appletN[6] = (numApplets+48);
newPref = np_CreateMimePref(mimetype, appletN);
PREF_SetCharPref(newPref, appletName);
XP_FREE(newPref);
/* Set the new Applet as the default */
newPref = np_CreateMimePref(mimetype, "applet");
PREF_SetCharPref(newPref, appletName);
XP_FREE(newPref);
}
NPL_RegisterAppletType(mimetype, appletName);
}
/* ANTHRAX STATIC FUNCTIONS */
/*
@ -5500,7 +5555,7 @@ static char* np_CreateMimePref(const char* mimetype, const char* pref)
len = XP_STRLEN("mime..") + XP_STRLEN(mimetype) + XP_STRLEN(pref);
prefName = XP_ALLOC((len+1)*sizeof(char));
prefName = (char*)XP_ALLOC((len+1)*sizeof(char));
XP_ASSERT(prefName);
if(!prefName)
return NULL;