зеркало из https://github.com/mozilla/gecko-dev.git
Bug 276588 - Rework command line handling in the toolkit to use a generic API - see COMMANDLINES_20050109_BRANCH for more detailed cvs logs r=darin,caillon,mscott,mconnor
This commit is contained in:
Родитель
0d40b9624f
Коммит
2b9b2e1cc4
|
@ -42,11 +42,13 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "prenv.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <limits.h>
|
||||
|
@ -65,6 +67,8 @@ static const char* const sNewsProtocols[] = {
|
|||
nsresult
|
||||
nsMailGNOMEIntegration::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// GConf _must_ be available, or we do not allow CreateInstance to succeed.
|
||||
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
@ -76,37 +80,16 @@ nsMailGNOMEIntegration::Init()
|
|||
// the locale encoding. If it's not set, they use UTF-8.
|
||||
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nsnull;
|
||||
|
||||
// Get the path we were launched from.
|
||||
nsCOMPtr<nsICmdLineService> cmdService =
|
||||
do_GetService("@mozilla.org/appshell/commandLineService;1");
|
||||
if (!cmdService)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
nsCOMPtr<nsIFile> appPath;
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(appPath));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString programName;
|
||||
cmdService->GetProgramName(getter_Copies(programName));
|
||||
rv = appPath->AppendNative(NS_LITERAL_CSTRING("thunderbird"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make sure we have an absolute pathname.
|
||||
if (programName[0] != '/') {
|
||||
// First search PATH if we were just launched as 'thunderbird-bin'.
|
||||
// If we were launched as './thunderbird-bin', this will just return
|
||||
// the original string.
|
||||
|
||||
gchar *appPath = g_find_program_in_path(programName.get());
|
||||
|
||||
// Now resolve it.
|
||||
char resolvedPath[PATH_MAX] = "";
|
||||
if (realpath(appPath, resolvedPath)) {
|
||||
mAppPath.Assign(resolvedPath);
|
||||
}
|
||||
|
||||
g_free(appPath);
|
||||
} else {
|
||||
mAppPath.Assign(programName);
|
||||
}
|
||||
|
||||
// strip "-bin" off of the binary name
|
||||
if (StringEndsWith(mAppPath, NS_LITERAL_CSTRING("-bin")))
|
||||
mAppPath.SetLength(mAppPath.Length() - 4);
|
||||
rv = appPath->GetNativePath(mAppPath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool isDefault;
|
||||
nsMailGNOMEIntegration::GetIsDefaultMailClient(&isDefault);
|
||||
|
|
Загрузка…
Ссылка в новой задаче