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
Родитель 91cba3e42d
Коммит e445180e90
3 изменённых файлов: 52 добавлений и 29 удалений

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

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

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

@ -528,6 +528,20 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
if(!ReadSectionHeader(reader, g_TOKEN_Directories, 1, &dirCount))
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

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

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