fix bug 106122. build xpt file search path based on NS_XPCOM_COMPONENTS_DIR *and* NS_APP_PLUGINS_DIR_LIST. Also, correctly detect that search path has changed - even when the change is just appended items. r=ccarlen sr=jst.

This commit is contained in:
jband%netscape.com 2001-11-11 19:01:00 +00:00
Родитель c1c4da44f0
Коммит bcdff78ce9
3 изменённых файлов: 52 добавлений и 29 удалений

Просмотреть файл

@ -163,25 +163,45 @@ xptiInterfaceInfoManager::~xptiInterfaceInfoManager()
static PRBool static PRBool
GetDirectoryFromDirService(const char* codename, nsILocalFile** aDir) GetDirectoryFromDirService(const char* codename, nsILocalFile** aDir)
{ {
NS_ASSERTION(codename,"loser!");
NS_ASSERTION(aDir,"loser!"); NS_ASSERTION(aDir,"loser!");
// We must make a new nsILocalFile each time because the caller *will*
// modify it.
nsCOMPtr<nsIProperties> dirService = nsCOMPtr<nsIProperties> dirService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
if(dirService) if(!dirService)
return PR_FALSE;
return NS_SUCCEEDED(dirService->Get(codename, NS_GET_IID(nsILocalFile),
(void**) aDir));
}
static PRBool
AppendFromDirServiceList(const char* codename, nsISupportsArray* aPath)
{
NS_ASSERTION(codename,"loser!");
NS_ASSERTION(aPath,"loser!");
nsCOMPtr<nsIProperties> dirService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
if(!dirService)
return PR_FALSE;
nsCOMPtr<nsISimpleEnumerator> fileList;
dirService->Get(codename, NS_GET_IID(nsISimpleEnumerator),
getter_AddRefs(fileList));
if(!fileList)
return PR_FALSE;
PRBool more;
while(NS_SUCCEEDED(fileList->HasMoreElements(&more)) && more)
{ {
nsCOMPtr<nsILocalFile> dir; nsCOMPtr<nsILocalFile> dir;
dirService->Get(codename, NS_GET_IID(nsIFile), getter_AddRefs(dir)); fileList->GetNext(getter_AddRefs(dir));
if(dir) if(!dir || !aPath->AppendElement(dir))
{ return PR_FALSE;
NS_ADDREF(*aDir = dir);
return PR_TRUE;
}
} }
return PR_FALSE; return PR_TRUE;
} }
// static // static
PRBool xptiInterfaceInfoManager::BuildFileSearchPath(nsISupportsArray** aPath) PRBool xptiInterfaceInfoManager::BuildFileSearchPath(nsISupportsArray** aPath)
@ -199,11 +219,7 @@ PRBool xptiInterfaceInfoManager::BuildFileSearchPath(nsISupportsArray** aPath)
nsCOMPtr<nsILocalFile> dir; nsCOMPtr<nsILocalFile> dir;
// XXX We'd like to get the *right* path from the embedding. // Always put components directory first
// For now we'll add the following...
// Add components dir
if(NS_FAILED(GetDirectoryFromDirService(NS_XPCOM_COMPONENT_DIR, if(NS_FAILED(GetDirectoryFromDirService(NS_XPCOM_COMPONENT_DIR,
getter_AddRefs(dir))) || getter_AddRefs(dir))) ||
@ -212,19 +228,10 @@ PRBool xptiInterfaceInfoManager::BuildFileSearchPath(nsISupportsArray** aPath)
return PR_FALSE; return PR_FALSE;
} }
#if 0 // Add additional plugins dirs
// XXX Let's not do this untill we're sure about what we want to do.
// XXX Without this block we are compatible with previous versions.
// Add plugins dir
// No error checking here since this is optional in some embeddings // No error checking here since this is optional in some embeddings
if(NS_SUCCEEDED(GetDirectoryFromDirService(NS_APP_PLUGINS_DIR, (void) AppendFromDirServiceList(NS_APP_PLUGINS_DIR_LIST, searchPath);
getter_AddRefs(dir))))
{
searchPath->AppendElement(dir);
}
#endif
NS_ADDREF(*aPath = searchPath); NS_ADDREF(*aPath = searchPath);

Просмотреть файл

@ -528,6 +528,20 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
if(!ReadSectionHeader(reader, g_TOKEN_Directories, 1, &dirCount)) if(!ReadSectionHeader(reader, g_TOKEN_Directories, 1, &dirCount))
goto out; goto out;
else
{
// To validate that the directory list matches the current search path
// we first confirm that the list lengths match.
nsCOMPtr<nsISupportsArray> searchPath;
aMgr->GetSearchPath(getter_AddRefs(searchPath));
PRUint32 searchPathCount;
searchPath->Count(&searchPathCount);
if(dirCount != (int) searchPathCount)
goto out;
}
// Read the directory records // Read the directory records

Просмотреть файл

@ -733,6 +733,9 @@ public:
PRBool GetApplicationDir(nsILocalFile** aDir); PRBool GetApplicationDir(nsILocalFile** aDir);
PRBool GetCloneOfManifestDir(nsILocalFile** aDir); PRBool GetCloneOfManifestDir(nsILocalFile** aDir);
void GetSearchPath(nsISupportsArray** aSearchPath)
{NS_ADDREF(*aSearchPath = mSearchPath);}
static PRLock* GetResolveLock(xptiInterfaceInfoManager* self = nsnull) static PRLock* GetResolveLock(xptiInterfaceInfoManager* self = nsnull)
{if(!self && !(self = GetInterfaceInfoManagerNoAddRef())) {if(!self && !(self = GetInterfaceInfoManagerNoAddRef()))
return nsnull; return nsnull;
@ -803,7 +806,6 @@ private:
PRLock* mAutoRegLock; PRLock* mAutoRegLock;
nsCOMPtr<nsILocalFile> mManifestDir; nsCOMPtr<nsILocalFile> mManifestDir;
nsCOMPtr<nsISupportsArray> mSearchPath; nsCOMPtr<nsISupportsArray> mSearchPath;
}; };
/***************************************************************************/ /***************************************************************************/