in so many different directories, that I think it's the best way. I've pulled and clobber_all'd my tree and got r=dp on this checkin. Here are the touched files: M mozilla/embedding/browser/activex/src/control/MozillaBrowser.cpp M mozilla/embedding/browser/activex/src/control/MozillaBrowser.h M mozilla/js/src/xpconnect/shell/xpcshell.cpp M mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp M mozilla/xpcom/build/nsXPComInit.cpp M mozilla/xpcom/components/nsComponentManager.cpp M mozilla/xpcom/components/nsIServiceManager.h M mozilla/xpcom/components/nsServiceManager.cpp M mozilla/xpcom/io/nsSpecialSystemDirectory.cpp M mozilla/xpcom/io/nsSpecialSystemDirectory.h M mozilla/xpcom/tests/TestBuffers.cpp M mozilla/xpcom/tests/TestPipes.cpp M mozilla/xpcom/tests/TestShutdown.cpp M mozilla/xpcom/tests/windows/TestHelloXPLoop.cpp M mozilla/xpcom/tools/registry/regExport.cpp M mozilla/xpcom/tools/registry/regxpcom.cpp M mozilla/xpinstall/stub/xpistub.cpp M mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp M mozilla/webshell/embed/ActiveX/MozillaBrowser.h M mozilla/webshell/tests/viewer/nsMacMain.cpp M mozilla/webshell/tests/viewer/nsPhMain.cpp M mozilla/webshell/tests/viewer/nsWinMain.cpp M mozilla/webshell/tests/viewer/unix/gtk/nsGtkMain.cpp M mozilla/xpfe/appshell/src/nsFileLocations.cpp M mozilla/xpfe/bootstrap/nsAppRunner.cpp The heart of this checkin is a change in the signature and symantics of NS_InitXPCOM. The new signature is extern NS_COM nsresult NS_InitXPCOM(nsIServiceManager* *result, nsFileSpec* binDirectory); I filed a bug for this problem: b=23157 The original manifestation of this bug was in mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp It used the current process directory to find resources, which is not correct when the current process is not mozilla.exe. I have added a new type to nsSpecialSystemDirectory, Moz_BinDirectory, and made nsResProtocolHandler use that value. git-svn-id: svn://10.0.0.236/trunk@56916 18797224-902f-48f8-a5cc-f745e15eee43
138 lines
3.4 KiB
C++
138 lines
3.4 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/*
|
|
* The contents of this file are subject to the Netscape Public
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.mozilla.org/NPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
* implied. See the License for the specific language governing
|
|
* rights and limitations under the License.
|
|
*
|
|
* The Original Code is mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
*/
|
|
|
|
#include <iostream.h>
|
|
#include "plstr.h"
|
|
#include "prlink.h"
|
|
#include "nsIComponentManager.h"
|
|
#include "nsIServiceManager.h"
|
|
#include "nsCOMPtr.h"
|
|
|
|
static PRBool gUnreg = PR_FALSE;
|
|
|
|
void print_err(nsresult err)
|
|
{
|
|
switch (err) {
|
|
case NS_ERROR_FACTORY_NOT_LOADED:
|
|
cerr << "Factory not loaded";
|
|
break;
|
|
case NS_NOINTERFACE:
|
|
cerr << "No Interface";
|
|
break;
|
|
case NS_ERROR_NULL_POINTER:
|
|
cerr << "Null pointer";
|
|
break;
|
|
case NS_ERROR_OUT_OF_MEMORY:
|
|
cerr << "Out of memory";
|
|
break;
|
|
default:
|
|
cerr << hex << err << dec;
|
|
}
|
|
}
|
|
|
|
nsresult Register(const char *path)
|
|
{
|
|
nsCOMPtr<nsIFileSpec> spec;
|
|
nsresult res = NS_NewFileSpec(getter_AddRefs(spec));
|
|
if (NS_FAILED(res)) return res;
|
|
res = spec->SetNativePath((char *)path);
|
|
if (NS_FAILED(res)) return res;
|
|
res = nsComponentManager::AutoRegisterComponent(nsIComponentManager::NS_Startup, spec);
|
|
return res;
|
|
}
|
|
|
|
nsresult Unregister(const char *path)
|
|
{
|
|
/* NEEDS IMPLEMENTATION */
|
|
#if 0
|
|
nsresult res = nsComponentManager::AutoUnregisterComponent(path);
|
|
return res;
|
|
#else
|
|
return NS_ERROR_FAILURE;
|
|
#endif
|
|
}
|
|
|
|
int ProcessArgs(int argc, char *argv[])
|
|
{
|
|
int i = 1;
|
|
nsresult res;
|
|
|
|
while (i < argc) {
|
|
if (argv[i][0] == '-') {
|
|
int j;
|
|
for (j = 1; argv[i][j] != '\0'; j++) {
|
|
switch (argv[i][j]) {
|
|
case 'u':
|
|
gUnreg = PR_TRUE;
|
|
break;
|
|
default:
|
|
cerr << "Unknown option '" << argv[i][j] << "'\n";
|
|
}
|
|
}
|
|
i++;
|
|
} else {
|
|
if (gUnreg == PR_TRUE) {
|
|
res = Unregister(argv[i]);
|
|
if (NS_SUCCEEDED(res)) {
|
|
cout << "Successfully unregistered: " << argv[i] << "\n";
|
|
} else {
|
|
cerr << "Unregister failed (";
|
|
print_err(res);
|
|
cerr << "): " << argv[i] << "\n";
|
|
}
|
|
} else {
|
|
res = Register(argv[i]);
|
|
if (NS_SUCCEEDED(res)) {
|
|
cout << "Successfully registered: " << argv[i] << "\n";
|
|
} else {
|
|
cerr << "Register failed (";
|
|
print_err(res);
|
|
cerr << "): " << argv[i] << "\n";
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int ret = 0;
|
|
|
|
NS_InitXPCOM(NULL, NULL);
|
|
|
|
/* With no arguments, RegFactory will autoregister */
|
|
if (argc <= 1)
|
|
{
|
|
nsresult rv = nsComponentManager::AutoRegister(
|
|
nsIComponentManager::NS_Startup,
|
|
NULL /* default location */);
|
|
ret = (NS_FAILED(rv)) ? -1 : 0;
|
|
}
|
|
else
|
|
ret = ProcessArgs(argc, argv);
|
|
|
|
NS_ShutdownXPCOM(NULL);
|
|
return ret;
|
|
}
|