--- a/toolkit/xre/nsNativeAppSupportWin.cpp
+++ b/toolkit/xre/nsNativeAppSupportWin.cpp
@@ -124,17 +124,17 @@ activateWindow( nsIDOMWindowInternal *wi
#endif
// Simple Win32 mutex wrapper.
struct Mutex {
Mutex( const char *name )
: mName( name ),
mHandle( 0 ),
mState( -1 ) {
- mHandle = CreateMutex( 0, FALSE, mName.get() );
+ mHandle = CreateMutexA( 0, FALSE, mName.get() );
#if MOZ_DEBUG_DDE
printf( "CreateMutex error = 0x%08X\n", (int)GetLastError() );
#endif
}
~Mutex() {
if ( mHandle ) {
// Make sure we release it if we own it.
Unlock();
@@ -323,18 +323,18 @@ private:
UINT uFmt,
HCONV hconv,
HSZ hsz1,
HSZ hsz2,
HDDEDATA hdata,
ULONG dwData1,
ULONG dwData2 );
static void HandleCommandLine(const char* aCmdLineString, nsIFile* aWorkingDir, PRUint32 aState);
- static void ParseDDEArg( HSZ args, int index, nsCString& string);
- static void ParseDDEArg( const char* args, int index, nsCString& aString);
+ static void ParseDDEArg( HSZ args, int index, nsString& string);
+ static void ParseDDEArg( const WCHAR* args, int index, nsString& aString);
static void ActivateLastWindow();
static HDDEDATA CreateDDEData( DWORD value );
static HDDEDATA CreateDDEData( LPBYTE value, DWORD len );
static PRBool InitTopicStrings();
static int FindTopic( HSZ topic );
static nsresult OpenWindow( const char *urlstr, const char *args );
static nsresult OpenBrowserWindow();
static nsresult ReParent( nsISupports *window, HWND newParent );
@@ -482,17 +482,17 @@ PRBool nsNativeAppSupportWin::mCanHandle
char nsNativeAppSupportWin::mMutexName[ 128 ] = { 0 };
// Message window encapsulation.
struct MessageWindow {
// ctor/dtor are simplistic
MessageWindow() {
// Try to find window.
- mHandle = ::FindWindow( className(), 0 );
+ mHandle = ::FindWindowA( className(), 0 );
}
// Act like an HWND.
operator HWND() {
return mHandle;
}
// Class name: appName + "MessageWindow"
@@ -507,32 +507,32 @@ struct MessageWindow {
"MessageWindow" );
mClassName = classNameBuffer;
}
return mClassName;
}
// Create: Register class and create window.
NS_IMETHOD Create() {
- WNDCLASS classStruct = { 0, // style
+ WNDCLASSA classStruct = { 0, // style
&MessageWindow::WindowProc, // lpfnWndProc
0, // cbClsExtra
0, // cbWndExtra
0, // hInstance
0, // hIcon
0, // hCursor
0, // hbrBackground
0, // lpszMenuName
className() }; // lpszClassName
// Register the window class.
- NS_ENSURE_TRUE( ::RegisterClass( &classStruct ), NS_ERROR_FAILURE );
+ NS_ENSURE_TRUE( ::RegisterClassA( &classStruct ), NS_ERROR_FAILURE );
// Create the window.
- NS_ENSURE_TRUE( ( mHandle = ::CreateWindow( className(),
+ NS_ENSURE_TRUE( ( mHandle = ::CreateWindowA(className(),
0, // title
WS_CAPTION, // style
0,0,0,0, // x, y, cx, cy
0, // parent
0, // menu
0, // instance
0 ) ), // create struct
NS_ERROR_FAILURE );
@@ -716,17 +716,17 @@ nsNativeAppSupportWin::Start( PRBool *aR
startupLock.Unlock();
return rv;
}
PRBool
nsNativeAppSupportWin::InitTopicStrings() {
for ( int i = 0; i < topicCount; i++ ) {
- if ( !( mTopics[ i ] = DdeCreateStringHandle( mInstance, const_cast<char *>(topicNames[ i ]), CP_WINANSI ) ) ) {
+ if ( !( mTopics[ i ] = DdeCreateStringHandleA( mInstance, const_cast<char *>(topicNames[ i ]), CP_WINANSI ) ) ) {
return PR_FALSE;
}
}
return PR_TRUE;
}
int
nsNativeAppSupportWin::FindTopic( HSZ topic ) {
@@ -756,17 +756,17 @@ nsNativeAppSupportWin::StartDDE() {
// Initialize DDE.
NS_ENSURE_TRUE( DMLERR_NO_ERROR == DdeInitialize( &mInstance,
nsNativeAppSupportWin::HandleDDENotification,
APPCLASS_STANDARD,
0 ),
NS_ERROR_FAILURE );
// Allocate DDE strings.
- NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandle( mInstance, (char*) gAppData->name, CP_WINANSI ) ) && InitTopicStrings(),
+ NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandleA( mInstance, (char*) gAppData->name, CP_WINANSI ) ) && InitTopicStrings(),
NS_ERROR_FAILURE );
// Next step is to register a DDE service.
NS_ENSURE_TRUE( DdeNameService( mInstance, mApplication, 0, DNS_REGISTER ), NS_ERROR_FAILURE );
#if MOZ_DEBUG_DDE
printf( "DDE server started\n" );
#endif
@@ -987,36 +987,36 @@ nsNativeAppSupportWin::HandleDDENotifica
}
} else if ( uType & XCLASS_DATA ) {
if ( uType == XTYP_REQUEST ) {
switch ( FindTopic( hsz1 ) ) {
case topicOpenURL: {
// Open a given URL...
// Get the URL from the first argument in the command.
- nsCAutoString url;
+ nsAutoString url;
ParseDDEArg(hsz2, 0, url);
// Read the 3rd argument in the command to determine if a
// new window is to be used.
- nsCAutoString windowID;
+ nsAutoString windowID;
ParseDDEArg(hsz2, 2, windowID);
// "" means to open the URL in a new window.
- if ( windowID.Equals( "" ) ) {
- url.Insert("mozilla -new-window ", 0);
+ if ( windowID.IsEmpty() ) {
+ url.Insert(NS_LITERAL_STRING("mozilla -new-window "), 0);
}
else {
- url.Insert("mozilla -url ", 0);
+ url.Insert(NS_LITERAL_STRING("mozilla -url "), 0);
}
#if MOZ_DEBUG_DDE
- printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() );
+ printf( "Handling dde XTYP_REQUEST request: [%s]...\n", NS_ConvertUTF16toUTF8(url).get() );
#endif
// Now handle it.
- HandleCommandLine(url.get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
+ HandleCommandLine(NS_ConvertUTF16toUTF8(url).get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
// Return pseudo window ID.
result = CreateDDEData( 1 );
break;
}
case topicGetWindowInfo: {
// This topic has to get the current URL, get the current
// page title and then format the output into the DDE
@@ -1104,22 +1104,22 @@ nsNativeAppSupportWin::HandleDDENotifica
#if MOZ_DEBUG_DDE
printf( "WWW_GetWindowInfo->%s\n", outpt.get() );
#endif
} while ( PR_FALSE );
break;
}
case topicActivate: {
// Activate a Nav window...
- nsCAutoString windowID;
+ nsAutoString windowID;
ParseDDEArg(hsz2, 0, windowID);
// 4294967295 is decimal for 0xFFFFFFFF which is also a
// correct value to do that Activate last window stuff
- if ( windowID.Equals( "-1" ) ||
- windowID.Equals( "4294967295" ) ) {
+ if ( windowID.EqualsLiteral( "-1" ) ||
+ windowID.EqualsLiteral( "4294967295" ) ) {
// We only support activating the most recent window (or a new one).
ActivateLastWindow();
// Return pseudo window ID.
result = CreateDDEData( 1 );
}
break;
}
case topicVersion: {
@@ -1158,36 +1158,36 @@ nsNativeAppSupportWin::HandleDDENotifica
DWORD bytes;
LPBYTE request = DdeAccessData( hdata, &bytes );
#if MOZ_DEBUG_DDE
printf( "Handling dde request: [%s]...\n", (char*)request );
#endif
// Default is to open in current window.
PRBool new_window = PR_FALSE;
- nsCAutoString url;
- ParseDDEArg((const char*) request, 0, url);
+ nsAutoString url;
+ ParseDDEArg((const WCHAR*) request, 0, url);
// Read the 3rd argument in the command to determine if a
// new window is to be used.
- nsCAutoString windowID;
- ParseDDEArg((const char*) request, 2, windowID);
+ nsAutoString windowID;
+ ParseDDEArg((const WCHAR*) request, 2, windowID);
// "" means to open the URL in a new window.
- if ( windowID.Equals( "" ) ) {
- url.Insert("mozilla -new-window ", 0);
+ if ( windowID.IsEmpty() ) {
+ url.Insert(NS_LITERAL_STRING("mozilla -new-window "), 0);
}
else {
- url.Insert("mozilla -url ", 0);
+ url.Insert(NS_LITERAL_STRING("mozilla -url "), 0);
}
#if MOZ_DEBUG_DDE
- printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() );
+ printf( "Handling dde XTYP_REQUEST request: [%s]...\n", NS_ConvertUTF16toUTF8(url).get() );
#endif
// Now handle it.
- HandleCommandLine(url.get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
+ HandleCommandLine(NS_ConvertUTF16toUTF8(url).get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
// Release the data.
DdeUnaccessData( hdata );
result = (HDDEDATA)DDE_FACK;
} else {
result = (HDDEDATA)DDE_FNOTPROCESSED;
}
} else if ( uType & XCLASS_NOTIFICATION ) {
@@ -1199,81 +1199,80 @@ nsNativeAppSupportWin::HandleDDENotifica
}
// Utility function to advance to end of quoted string.
// p+offset must point to the comma preceding the arg on entry.
// On return, p+result points to the closing '"' (or end of the string
// if the closing '"' is missing) if the arg is quoted. If the arg
// is not quoted, then p+result will point to the first character
// of the arg.
-static PRInt32 advanceToEndOfQuotedArg( const char *p, PRInt32 offset, PRInt32 len ) {
+static PRInt32 advanceToEndOfQuotedArg( const WCHAR *p, PRInt32 offset, PRInt32 len ) {
// Check whether the current arg is quoted.
if ( p[++offset] == '"' ) {
// Advance past the closing quote.
while ( offset < len && p[++offset] != '"' ) {
// If the current character is a backslash, then the
// next character can't be a *real* '"', so skip it.
if ( p[offset] == '\\' ) {
offset++;
}
}
}
return offset;
}
-void nsNativeAppSupportWin::ParseDDEArg( const char* args, int index, nsCString& aString) {
+void nsNativeAppSupportWin::ParseDDEArg( const WCHAR* args, int index, nsString& aString) {
if ( args ) {
- int argLen = strlen(args);
- nsDependentCString temp(args, argLen);
+ nsDependentString temp(args);
// offset points to the comma preceding the desired arg.
PRInt32 offset = -1;
// Skip commas till we get to the arg we want.
while( index-- ) {
// If this arg is quoted, then go to closing quote.
- offset = advanceToEndOfQuotedArg( args, offset, argLen);
+ offset = advanceToEndOfQuotedArg( args, offset, temp.Length());
// Find next comma.
offset = temp.FindChar( ',', offset );
if ( offset == kNotFound ) {
// No more commas, give up.
aString = args;
return;
}
}
// The desired argument starts just past the preceding comma,
// which offset points to, and extends until the following
// comma (or the end of the string).
//
// Since the argument might be enclosed in quotes, we need to
// deal with that before searching for the terminating comma.
// We advance offset so it ends up pointing to the start of
// the argument we want.
- PRInt32 end = advanceToEndOfQuotedArg( args, offset++, argLen );
+ PRInt32 end = advanceToEndOfQuotedArg( args, offset++, temp.Length() );
// Find next comma (or end of string).
end = temp.FindChar( ',', end );
if ( end == kNotFound ) {
// Arg is the rest of the string.
- end = argLen;
+ end = temp.Length();
}
// Extract result.
aString.Assign( args + offset, end - offset );
}
return;
}
// Utility to parse out argument from a DDE item string.
-void nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index, nsCString& aString) {
- DWORD argLen = DdeQueryString( mInstance, args, NULL, NULL, CP_WINANSI );
+void nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index, nsString& aString) {
+ DWORD argLen = DdeQueryStringW( mInstance, args, NULL, NULL, CP_WINUNICODE );
// there wasn't any string, so return empty string
if ( !argLen ) return;
- nsCAutoString temp;
+ nsAutoString temp;
// Ensure result's buffer is sufficiently big.
temp.SetLength( argLen );
// Now get the string contents.
- DdeQueryString( mInstance, args, temp.BeginWriting(), temp.Length(), CP_WINANSI );
+ DdeQueryString( mInstance, args, temp.BeginWriting(), temp.Length(), CP_WINUNICODE );
// Parse out the given arg.
ParseDDEArg(temp.get(), index, aString);
return;
}
void nsNativeAppSupportWin::ActivateLastWindow() {
nsCOMPtr<nsIDOMWindowInternal> navWin;
GetMostRecentWindow( NS_LITERAL_STRING("navigator:browser").get(), getter_AddRefs( navWin ) );