mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 06:45:42 +00:00
r=mkaply, darin, weilbacher, sr=blizzard (platform specific) Group patch from mkaply, darin, and Peter Weilbacher - OS/2 bustage
This commit is contained in:
parent
734755d36f
commit
d0d98288f4
@ -44,18 +44,14 @@
|
|||||||
#define INCL_DOSERRORS
|
#define INCL_DOSERRORS
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
|
|
||||||
#ifdef XPCOM_GLUE
|
|
||||||
#include "nsStringSupport.h"
|
|
||||||
#else
|
|
||||||
#include "nsString.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "nsNativeAppSupportBase.h"
|
#include "nsNativeAppSupportBase.h"
|
||||||
#include "nsNativeAppSupportOS2.h"
|
#include "nsNativeAppSupportOS2.h"
|
||||||
#include "nsICmdLineService.h"
|
#include "nsICmdLineService.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
|
#include "nsIServiceManagerUtils.h"
|
||||||
#include "nsICmdLineHandler.h"
|
#include "nsICmdLineHandler.h"
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
#include "nsXPCOM.h"
|
#include "nsXPCOM.h"
|
||||||
@ -76,21 +72,26 @@
|
|||||||
#include "nsIPromptService.h"
|
#include "nsIPromptService.h"
|
||||||
#include "nsNetCID.h"
|
#include "nsNetCID.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsXPCOM.h"
|
|
||||||
#include "nsPaletteOS2.h"
|
#ifdef XPCOM_GLUE
|
||||||
|
#include "nsStringSupport.h"
|
||||||
|
#else
|
||||||
|
#include "nsString.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// These are needed to load a URL in a browser window.
|
// These are needed to load a URL in a browser window.
|
||||||
#include "nsIDOMLocation.h"
|
#include "nsIDOMLocation.h"
|
||||||
#include "nsIJSContextStack.h"
|
#include "nsIJSContextStack.h"
|
||||||
#include "nsIWindowMediator.h"
|
#include "nsIWindowMediator.h"
|
||||||
|
|
||||||
|
#include "nsPaletteOS2.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
|
|
||||||
|
|
||||||
// getting from nsAppRunner. Use to help track down arguments.
|
// getting from nsAppRunner. Use to help track down arguments.
|
||||||
extern char ** __argv;
|
extern char ** __argv;
|
||||||
extern int __argc;
|
extern int __argc;
|
||||||
@ -392,7 +393,8 @@ private:
|
|||||||
ULONG dwData1,
|
ULONG dwData1,
|
||||||
ULONG dwData2 );
|
ULONG dwData2 );
|
||||||
static void HandleRequest( LPBYTE request, PRBool newWindow = PR_TRUE );
|
static void HandleRequest( LPBYTE request, PRBool newWindow = PR_TRUE );
|
||||||
static nsCString ParseDDEArg( HSZ args, int index );
|
static void ParseDDEArg( HSZ args, int index, nsCString& string);
|
||||||
|
static void ParseDDEArg( const char* args, int index, nsCString& aString);
|
||||||
static void ActivateLastWindow();
|
static void ActivateLastWindow();
|
||||||
static HDDEDATA CreateDDEData( DWORD value );
|
static HDDEDATA CreateDDEData( DWORD value );
|
||||||
static HDDEDATA CreateDDEData( LPBYTE value, DWORD len );
|
static HDDEDATA CreateDDEData( LPBYTE value, DWORD len );
|
||||||
@ -1229,7 +1231,7 @@ nsNativeAppSupportOS2::Start( PRBool *aResult ) {
|
|||||||
* then make sure to clean up the message queue.
|
* then make sure to clean up the message queue.
|
||||||
*/
|
*/
|
||||||
MQINFO mqinfo;
|
MQINFO mqinfo;
|
||||||
HAB hab;
|
HAB hab = NULLHANDLE;
|
||||||
HMQ hmqCurrent = WinQueryQueueInfo( HMQ_CURRENT, &mqinfo,
|
HMQ hmqCurrent = WinQueryQueueInfo( HMQ_CURRENT, &mqinfo,
|
||||||
sizeof( MQINFO ) );
|
sizeof( MQINFO ) );
|
||||||
if( !hmqCurrent )
|
if( !hmqCurrent )
|
||||||
@ -1467,7 +1469,7 @@ static nsCString hszValue( DWORD instance, HSZ hsz ) {
|
|||||||
|
|
||||||
|
|
||||||
// Utility function to escape double-quotes within a string.
|
// Utility function to escape double-quotes within a string.
|
||||||
static void escapeQuotes( nsAString &aString ) {
|
static void escapeQuotes( nsString &aString ) {
|
||||||
PRInt32 offset = -1;
|
PRInt32 offset = -1;
|
||||||
while( 1 ) {
|
while( 1 ) {
|
||||||
// Find next '"'.
|
// Find next '"'.
|
||||||
@ -1532,12 +1534,12 @@ nsNativeAppSupportOS2::HandleDDENotification( ULONG idInst, // DDEML instanc
|
|||||||
PRBool new_window = PR_FALSE;
|
PRBool new_window = PR_FALSE;
|
||||||
|
|
||||||
// Get the URL from the first argument in the command.
|
// Get the URL from the first argument in the command.
|
||||||
nsCAutoString url( ParseDDEArg( hsz2, 0 ) );
|
nsCAutoString url;
|
||||||
|
ParseDDEArg(hsz2, 0, url);
|
||||||
// Read the 3rd argument in the command to determine if a
|
// Read the 3rd argument in the command to determine if a
|
||||||
// new window is to be used.
|
// new window is to be used.
|
||||||
nsCAutoString windowID( ParseDDEArg( hsz2, 2 ) );
|
nsCAutoString windowID;
|
||||||
|
ParseDDEArg(hsz2, 2, windowID);
|
||||||
// "0" means to open the URL in a new window.
|
// "0" means to open the URL in a new window.
|
||||||
if ( windowID.Equals( "0" ) ) {
|
if ( windowID.Equals( "0" ) ) {
|
||||||
new_window = PR_TRUE;
|
new_window = PR_TRUE;
|
||||||
@ -1628,7 +1630,7 @@ nsNativeAppSupportOS2::HandleDDENotification( ULONG idInst, // DDEML instanc
|
|||||||
// title
|
// title
|
||||||
outpt.Append( NS_LITERAL_CSTRING("\",\"") );
|
outpt.Append( NS_LITERAL_CSTRING("\",\"") );
|
||||||
// Now copy the current page title to the return string
|
// Now copy the current page title to the return string
|
||||||
outpt.Append( NS_LossyConvertUCS2toASCII( title.get() ));
|
outpt.Append( NS_LossyConvertUCS2toASCII( title ));
|
||||||
// Fill out the return string with the remainin ",""
|
// Fill out the return string with the remainin ",""
|
||||||
outpt.Append( NS_LITERAL_CSTRING( "\",\"\"" ));
|
outpt.Append( NS_LITERAL_CSTRING( "\",\"\"" ));
|
||||||
|
|
||||||
@ -1646,8 +1648,8 @@ nsNativeAppSupportOS2::HandleDDENotification( ULONG idInst, // DDEML instanc
|
|||||||
}
|
}
|
||||||
case topicActivate: {
|
case topicActivate: {
|
||||||
// Activate a Nav window...
|
// Activate a Nav window...
|
||||||
nsCString windowID = ParseDDEArg( hsz2, 0 );
|
nsCAutoString windowID;
|
||||||
|
ParseDDEArg(hsz2, 0, windowID);
|
||||||
// 4294967295 is decimal for 0xFFFFFFFF which is also a
|
// 4294967295 is decimal for 0xFFFFFFFF which is also a
|
||||||
// correct value to do that Activate last window stuff
|
// correct value to do that Activate last window stuff
|
||||||
if ( windowID.Equals( "-1" ) ||
|
if ( windowID.Equals( "-1" ) ||
|
||||||
@ -1700,13 +1702,13 @@ nsNativeAppSupportOS2::HandleDDENotification( ULONG idInst, // DDEML instanc
|
|||||||
// Default is to open in current window.
|
// Default is to open in current window.
|
||||||
PRBool new_window = PR_FALSE;
|
PRBool new_window = PR_FALSE;
|
||||||
|
|
||||||
// Get the URL from the first argument in the command.
|
nsCAutoString url;
|
||||||
HSZ args = WinDdeCreateStringHandle( (PSZ)request, CP_WINANSI );
|
ParseDDEArg((const char*) request, 0, url);
|
||||||
nsCAutoString url( ParseDDEArg( args, 0 ) );
|
|
||||||
|
|
||||||
// Read the 3rd argument in the command to determine if a
|
// Read the 3rd argument in the command to determine if a
|
||||||
// new window is to be used.
|
// new window is to be used.
|
||||||
nsCAutoString windowID( ParseDDEArg( args, 2 ) );
|
nsCAutoString windowID;
|
||||||
|
ParseDDEArg((const char*) request, 2, windowID);
|
||||||
|
|
||||||
// "0" means to open the URL in a new window.
|
// "0" means to open the URL in a new window.
|
||||||
if ( windowID.Equals( "0" ) ) {
|
if ( windowID.Equals( "0" ) ) {
|
||||||
@ -1720,8 +1722,7 @@ nsNativeAppSupportOS2::HandleDDENotification( ULONG idInst, // DDEML instanc
|
|||||||
#endif
|
#endif
|
||||||
// Now handle it.
|
// Now handle it.
|
||||||
HandleRequest( LPBYTE( url.get() ), new_window );
|
HandleRequest( LPBYTE( url.get() ), new_window );
|
||||||
// Release the args string.
|
|
||||||
WinDdeFreeStringHandle( args );
|
|
||||||
// Release the data.
|
// Release the data.
|
||||||
// DdeUnaccessData( hdata );
|
// DdeUnaccessData( hdata );
|
||||||
result = (HDDEDATA)DDE_FACK;
|
result = (HDDEDATA)DDE_FACK;
|
||||||
@ -1757,32 +1758,25 @@ static PRInt32 advanceToEndOfQuotedArg( const char *p, PRInt32 offset, PRInt32 l
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility to parse out argument from a DDE item string.
|
void nsNativeAppSupportOS2::ParseDDEArg( const char* args, int index, nsCString& aString) {
|
||||||
nsCString nsNativeAppSupportOS2::ParseDDEArg( HSZ args, int index ) {
|
if ( args ) {
|
||||||
nsCString result;
|
int argLen = strlen(args);
|
||||||
DWORD argLen = WinDdeQueryString( args, NULL, NULL, CP_WINANSI );
|
nsDependentCString temp(args, argLen);
|
||||||
if ( argLen ) {
|
|
||||||
nsCString temp;
|
|
||||||
// Ensure result's buffer is sufficiently big.
|
|
||||||
temp.SetLength( argLen + 1 );
|
|
||||||
// Now get the string contents.
|
|
||||||
WinDdeQueryString( args, temp.BeginWriting(), temp.Length(), CP_WINANSI );
|
|
||||||
// Parse out the given arg.
|
|
||||||
const char *p = temp.get();
|
|
||||||
// offset points to the comma preceding the desired arg.
|
// offset points to the comma preceding the desired arg.
|
||||||
PRInt32 offset = -1;
|
PRInt32 offset = -1;
|
||||||
// Skip commas till we get to the arg we want.
|
// Skip commas till we get to the arg we want.
|
||||||
while( index-- ) {
|
while( index-- ) {
|
||||||
// If this arg is quoted, then go to closing quote.
|
// If this arg is quoted, then go to closing quote.
|
||||||
offset = advanceToEndOfQuotedArg( p, offset, argLen );
|
offset = advanceToEndOfQuotedArg( args, offset, argLen);
|
||||||
// Find next comma.
|
// Find next comma.
|
||||||
offset = temp.FindChar( ',', offset );
|
offset = temp.FindChar( ',', offset );
|
||||||
if ( offset == kNotFound ) {
|
if ( offset == kNotFound ) {
|
||||||
// No more commas, give up.
|
// No more commas, give up.
|
||||||
return result;
|
aString = args;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The desired argument starts just past the preceding comma,
|
// The desired argument starts just past the preceding comma,
|
||||||
// which offset points to, and extends until the following
|
// which offset points to, and extends until the following
|
||||||
// comma (or the end of the string).
|
// comma (or the end of the string).
|
||||||
@ -1791,7 +1785,7 @@ nsCString nsNativeAppSupportOS2::ParseDDEArg( HSZ args, int index ) {
|
|||||||
// deal with that before searching for the terminating comma.
|
// deal with that before searching for the terminating comma.
|
||||||
// We advance offset so it ends up pointing to the start of
|
// We advance offset so it ends up pointing to the start of
|
||||||
// the argument we want.
|
// the argument we want.
|
||||||
PRInt32 end = advanceToEndOfQuotedArg( p, offset++, argLen );
|
PRInt32 end = advanceToEndOfQuotedArg( args, offset++, argLen );
|
||||||
// Find next comma (or end of string).
|
// Find next comma (or end of string).
|
||||||
end = temp.FindChar( ',', end );
|
end = temp.FindChar( ',', end );
|
||||||
if ( end == kNotFound ) {
|
if ( end == kNotFound ) {
|
||||||
@ -1799,9 +1793,24 @@ nsCString nsNativeAppSupportOS2::ParseDDEArg( HSZ args, int index ) {
|
|||||||
end = argLen;
|
end = argLen;
|
||||||
}
|
}
|
||||||
// Extract result.
|
// Extract result.
|
||||||
result.Assign( p + offset, end - offset );
|
aString.Assign( args + offset, end - offset );
|
||||||
}
|
}
|
||||||
return result;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility to parse out argument from a DDE item string.
|
||||||
|
void nsNativeAppSupportOS2::ParseDDEArg( HSZ args, int index, nsCString& aString) {
|
||||||
|
DWORD argLen = WinDdeQueryString( args, NULL, NULL, CP_WINANSI );
|
||||||
|
// there wasn't any string, so return empty string
|
||||||
|
if ( !argLen ) return;
|
||||||
|
// Ensure result's buffer is sufficiently big.
|
||||||
|
char *temp = (char *) malloc(argLen + 1);
|
||||||
|
if ( !temp ) return;
|
||||||
|
// Now get the string contents.
|
||||||
|
WinDdeQueryString( args, temp, argLen + 1, CP_WINANSI );
|
||||||
|
// Parse out the given arg.
|
||||||
|
ParseDDEArg(temp, index, aString);
|
||||||
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsNativeAppSupportOS2::ActivateLastWindow() {
|
void nsNativeAppSupportOS2::ActivateLastWindow() {
|
||||||
@ -1975,8 +1984,7 @@ nsNativeAppSupportOS2::HandleRequest( LPBYTE request, PRBool newWindow ) {
|
|||||||
if (NS_FAILED(rv) || !defaultArgs) return;
|
if (NS_FAILED(rv) || !defaultArgs) return;
|
||||||
|
|
||||||
if (defaultArgs) {
|
if (defaultArgs) {
|
||||||
nsCAutoString url;
|
NS_LossyConvertUCS2toASCII url( defaultArgs );
|
||||||
url.AssignWithConversion( defaultArgs );
|
|
||||||
OpenBrowserWindow(url.get());
|
OpenBrowserWindow(url.get());
|
||||||
} else {
|
} else {
|
||||||
OpenBrowserWindow("about:blank");
|
OpenBrowserWindow("about:blank");
|
||||||
@ -1993,21 +2001,12 @@ nsNativeAppSupportOS2::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||||||
int justCounting = 1;
|
int justCounting = 1;
|
||||||
char **argv = 0;
|
char **argv = 0;
|
||||||
// Flags, etc.
|
// Flags, etc.
|
||||||
int init = 1;
|
int between = 1, quoted = 0, bSlashCount = 0;
|
||||||
int between, quoted, bSlashCount;
|
int argc = 0;
|
||||||
int argc;
|
char *p = (char*)request;
|
||||||
char *p;
|
|
||||||
nsCAutoString arg;
|
nsCAutoString arg;
|
||||||
// We loop if we've not finished the second pass through.
|
// We loop if we've not finished the second pass through.
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
// Initialize if required.
|
|
||||||
if ( init ) {
|
|
||||||
p = (char*)request;
|
|
||||||
between = 1;
|
|
||||||
argc = quoted = bSlashCount = 0;
|
|
||||||
|
|
||||||
init = 0;
|
|
||||||
}
|
|
||||||
if ( between ) {
|
if ( between ) {
|
||||||
// We are traversing whitespace between args.
|
// We are traversing whitespace between args.
|
||||||
// Check for start of next arg.
|
// Check for start of next arg.
|
||||||
@ -2108,9 +2107,11 @@ nsNativeAppSupportOS2::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
|
|||||||
// Allocate argv array.
|
// Allocate argv array.
|
||||||
argv = new char*[ argc ];
|
argv = new char*[ argc ];
|
||||||
|
|
||||||
// Start second pass
|
// Start second pass, initialize again
|
||||||
justCounting = 0;
|
justCounting = 0;
|
||||||
init = 1;
|
p = (char*)request;
|
||||||
|
between = 1;
|
||||||
|
argc = quoted = bSlashCount = 0;
|
||||||
} else {
|
} else {
|
||||||
// Quit.
|
// Quit.
|
||||||
break;
|
break;
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#define nsXPIDLString nsXPIDLString_local
|
#define nsXPIDLString nsXPIDLString_local
|
||||||
#define nsGetterCopies nsGetterCopies_local
|
#define nsGetterCopies nsGetterCopies_local
|
||||||
#define NS_ConvertUCS2toUTF8 NS_ConvertUCS2toUTF8_local
|
#define NS_ConvertUCS2toUTF8 NS_ConvertUCS2toUTF8_local
|
||||||
|
#define NS_ConvertASCIItoUTF16 NS_ConvertASCIItoUTF16_local
|
||||||
#define NS_LossyConvertUCS2toASCII NS_LossyConvertUCS2toASCII_local
|
#define NS_LossyConvertUCS2toASCII NS_LossyConvertUCS2toASCII_local
|
||||||
#define getter_Copies getter_Copies_local
|
#define getter_Copies getter_Copies_local
|
||||||
|
|
||||||
@ -331,11 +332,23 @@ class NS_LossyConvertUCS2toASCII : public nsCString
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NS_ConvertASCIItoUTF16 : public nsString
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_ConvertASCIItoUTF16(const char *str, PRUint32 len)
|
||||||
|
{
|
||||||
|
nsEmbedCString temp;
|
||||||
|
temp.Assign(str, len);
|
||||||
|
NS_CStringToUTF16(temp, NS_CSTRING_ENCODING_ASCII, *this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#define NS_LITERAL_CSTRING(s) nsDependentCString(s)
|
#define NS_LITERAL_CSTRING(s) nsDependentCString(s)
|
||||||
|
|
||||||
// only used by nsNativeAppSupport{Win,OS2}.cpp
|
#ifdef HAVE_CPP_2BYTE_WCHAR_T
|
||||||
#if defined(XP_WIN) || defined(XP_OS2)
|
#define NS_LITERAL_STRING(s) nsDependentString((const PRUnichar*)L##s)
|
||||||
#define NS_LITERAL_STRING(s) nsDependentString(L##s)
|
#else
|
||||||
|
#define NS_LITERAL_STRING(s) NS_ConvertASCIItoUTF16(s, sizeof(s)-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EmptyCString() nsCString()
|
#define EmptyCString() nsCString()
|
||||||
|
Loading…
Reference in New Issue
Block a user