зеркало из https://github.com/mozilla/pjs.git
Bug 410610 - Can't open a local HTML file that has accents (special unicode characters) in its filename, r=luser+Neil
This commit is contained in:
Родитель
ee7de8b1d4
Коммит
9f0a58843c
|
@ -686,30 +686,7 @@ nsToolkitProfileService::CreateProfile(nsILocalFile* aRootDir,
|
|||
return NS_ERROR_FILE_NOT_DIRECTORY;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIFile> profileDefaultsDir;
|
||||
nsCOMPtr<nsIFile> profileDirParent;
|
||||
nsCAutoString profileDirName;
|
||||
|
||||
rv = rootDir->GetParent(getter_AddRefs(profileDirParent));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = rootDir->GetNativeLeafName(profileDirName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool dummy;
|
||||
rv = gDirServiceProvider->GetFile(NS_APP_PROFILE_DEFAULTS_50_DIR, &dummy,
|
||||
getter_AddRefs(profileDefaultsDir));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = profileDefaultsDir->CopyToNative(profileDirParent,
|
||||
profileDirName);
|
||||
if (NS_FAILED(rv)) {
|
||||
// if copying failed, lets just ensure that the profile directory exists.
|
||||
rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = rootDir->SetPermissions(0700);
|
||||
rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ endif
|
|||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
CPPSRCS += nsNativeAppSupportWin.cpp
|
||||
DEFINES += -DWIN32_LEAN_AND_MEAN
|
||||
DEFINES += -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
CMMSRCS = nsNativeAppSupportCocoa.mm
|
||||
|
|
|
@ -392,7 +392,7 @@ static void Output(PRBool isError, const char *fmt, ... )
|
|||
flags |= MB_ICONERROR;
|
||||
else
|
||||
flags |= MB_ICONINFORMATION;
|
||||
MessageBox(NULL, msg, "XULRunner", flags);
|
||||
MessageBoxA(NULL, msg, "XULRunner", flags);
|
||||
PR_smprintf_free(msg);
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -129,7 +129,7 @@ struct Mutex {
|
|||
: 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
|
||||
|
@ -328,8 +328,8 @@ private:
|
|||
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 );
|
||||
|
@ -487,7 +487,7 @@ struct MessageWindow {
|
|||
// ctor/dtor are simplistic
|
||||
MessageWindow() {
|
||||
// Try to find window.
|
||||
mHandle = ::FindWindow( className(), 0 );
|
||||
mHandle = ::FindWindowA( className(), 0 );
|
||||
}
|
||||
|
||||
// Act like an HWND.
|
||||
|
@ -512,7 +512,7 @@ struct MessageWindow {
|
|||
|
||||
// Create: Register class and create window.
|
||||
NS_IMETHOD Create() {
|
||||
WNDCLASS classStruct = { 0, // style
|
||||
WNDCLASSA classStruct = { 0, // style
|
||||
&MessageWindow::WindowProc, // lpfnWndProc
|
||||
0, // cbClsExtra
|
||||
0, // cbWndExtra
|
||||
|
@ -524,10 +524,10 @@ struct MessageWindow {
|
|||
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
|
||||
|
@ -721,7 +721,7 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ nsNativeAppSupportWin::StartDDE() {
|
|||
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.
|
||||
|
@ -992,26 +992,26 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
|
|||
// 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 );
|
||||
|
@ -1109,12 +1109,12 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
|
|||
}
|
||||
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.
|
||||
|
@ -1163,26 +1163,26 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
|
|||
// 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 );
|
||||
|
@ -1204,7 +1204,7 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
|
|||
// 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.
|
||||
|
@ -1219,17 +1219,16 @@ static PRInt32 advanceToEndOfQuotedArg( const char *p, PRInt32 offset, PRInt32 l
|
|||
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 ) {
|
||||
|
@ -1246,12 +1245,12 @@ void nsNativeAppSupportWin::ParseDDEArg( const char* args, int index, nsCString&
|
|||
// 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 );
|
||||
|
@ -1260,15 +1259,15 @@ void nsNativeAppSupportWin::ParseDDEArg( const char* args, int index, nsCString&
|
|||
}
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -235,7 +235,7 @@ AllocConvertUTF8toUTF16(const char *arg)
|
|||
|
||||
ConvertUTF8toUTF16 convert(s);
|
||||
convert.write(arg, len);
|
||||
s[len] = '\0';
|
||||
convert.write_terminator();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ AllocConvertUTF16toUTF8(const WCHAR *arg)
|
|||
|
||||
ConvertUTF16toUTF8 convert(s);
|
||||
convert.write(arg, len);
|
||||
s[len] = '\0';
|
||||
convert.write_terminator();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ printf("\n****Inside ShowOSAlert ***\n");
|
|||
message_copy[copy_len] = 0;
|
||||
|
||||
#if defined (XP_WIN)
|
||||
MessageBox(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
|
||||
MessageBoxA(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
|
||||
#elif (XP_MAC)
|
||||
short buttonClicked;
|
||||
StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked);
|
||||
|
|
Загрузка…
Ссылка в новой задаче