Add a dropdown to choose searchengine when in basic mode in

the search sidebar panel.

b  = 86483
r  = matt
sr = alecf
This commit is contained in:
sgehani%netscape.com 2007-09-06 21:58:13 +00:00
Родитель 5d0748fadb
Коммит eceb4b6f2c
2 изменённых файлов: 160 добавлений и 140 удалений

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

@ -334,8 +334,9 @@ nsIRDFResource *InternetSearchDataSource::kNC_Title;
nsIRDFResource *InternetSearchDataSource::kNC_Data;
nsIRDFResource *InternetSearchDataSource::kNC_Name;
nsIRDFResource *InternetSearchDataSource::kNC_Description;
nsIRDFResource *InternetSearchDataSource::kNC_actionButton;
nsIRDFResource *InternetSearchDataSource::kNC_actionBar;
nsIRDFResource *InternetSearchDataSource::kNC_Version;
nsIRDFResource *InternetSearchDataSource::kNC_actionButton;
nsIRDFResource *InternetSearchDataSource::kNC_actionBar;
nsIRDFResource *InternetSearchDataSource::kNC_LastText;
nsIRDFResource *InternetSearchDataSource::kNC_URL;
nsIRDFResource *InternetSearchDataSource::kRDF_InstanceOf;
@ -400,8 +401,9 @@ InternetSearchDataSource::InternetSearchDataSource(void)
gRDFService->GetResource(NC_NAMESPACE_URI "data", &kNC_Data);
gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name);
gRDFService->GetResource(NC_NAMESPACE_URI "Description", &kNC_Description);
gRDFService->GetResource(NC_NAMESPACE_URI "actionButton", &kNC_actionButton);
gRDFService->GetResource(NC_NAMESPACE_URI "actionBar", &kNC_actionBar);
gRDFService->GetResource(NC_NAMESPACE_URI "Version", &kNC_Version);
gRDFService->GetResource(NC_NAMESPACE_URI "actionButton", &kNC_actionButton);
gRDFService->GetResource(NC_NAMESPACE_URI "actionBar", &kNC_actionBar);
gRDFService->GetResource(NC_NAMESPACE_URI "LastText", &kNC_LastText);
gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL);
gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_InstanceOf);
@ -464,8 +466,9 @@ InternetSearchDataSource::~InternetSearchDataSource (void)
NS_IF_RELEASE(kNC_Data);
NS_IF_RELEASE(kNC_Name);
NS_IF_RELEASE(kNC_Description);
NS_IF_RELEASE(kNC_actionButton);
NS_IF_RELEASE(kNC_actionBar);
NS_IF_RELEASE(kNC_Version);
NS_IF_RELEASE(kNC_actionButton);
NS_IF_RELEASE(kNC_actionBar);
NS_IF_RELEASE(kNC_LastText);
NS_IF_RELEASE(kNC_URL);
NS_IF_RELEASE(kRDF_InstanceOf);
@ -3123,29 +3126,39 @@ InternetSearchDataSource::updateDataHintsInGraph(nsIRDFResource *engine, const P
}
}
nsAutoString buttonValue;
if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionButton", buttonValue)))
// save/update version of search engine (if specified)
nsAutoString versionValue;
if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "version", versionValue)))
{
nsCOMPtr<nsIRDFLiteral> descLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(buttonValue.GetUnicode(),
getter_AddRefs(descLiteral))))
{
rv = updateAtom(mInner, engine, kNC_actionButton, descLiteral, nsnull);
}
}
nsCOMPtr<nsIRDFLiteral> versionLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(versionValue.GetUnicode(),
getter_AddRefs(versionLiteral))))
{
rv = updateAtom(mInner, engine, kNC_Version, versionLiteral, nsnull);
}
}
nsAutoString buttonValue;
if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionButton", buttonValue)))
{
nsCOMPtr<nsIRDFLiteral> buttonLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(buttonValue.GetUnicode(),
getter_AddRefs(buttonLiteral))))
{
rv = updateAtom(mInner, engine, kNC_actionButton, buttonLiteral, nsnull);
}
}
nsAutoString barValue;
if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionBar", barValue)))
{
nsCOMPtr<nsIRDFLiteral> descLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(barValue.GetUnicode(),
getter_AddRefs(descLiteral))))
{
rv = updateAtom(mInner, engine, kNC_actionBar, descLiteral, nsnull);
}
}
nsAutoString barValue;
if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionBar", barValue)))
{
nsCOMPtr<nsIRDFLiteral> barLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(barValue.GetUnicode(),
getter_AddRefs(barLiteral))))
{
rv = updateAtom(mInner, engine, kNC_actionBar, barLiteral, nsnull);
}
}
PRBool updatePrivateFiles = PR_FALSE;
@ -5049,8 +5062,14 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRD
nsAutoString site(hrefStr);
#ifdef DEBUG_SEARCH_OUTPUT
printf("HREF: '%s'\n", href);
#ifdef DEBUG_SEARCH_OUTPUT
char *hrefCStr = hrefStr.ToNewCString();
if (hrefCStr)
{
printf("HREF: '%s'\n", hrefCStr);
nsCRT::free(hrefCStr);
hrefCStr = nsnull;
}
#endif
nsCOMPtr<nsIRDFResource> res;

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

@ -39,135 +39,136 @@
class InternetSearchDataSource : public nsIInternetSearchService,
public nsIRDFDataSource,
public nsIRDFDataSource,
public nsIStreamListener,
public nsIObserver,
public nsSupportsWeakReference
public nsSupportsWeakReference
{
private:
static PRInt32 gRefCnt;
static PRBool mEngineListBuilt;
static PRInt32 gRefCnt;
static PRBool mEngineListBuilt;
// pseudo-constants
static nsIRDFResource *kNC_SearchResult;
static nsIRDFResource *kNC_SearchEngineRoot;
static nsIRDFResource *kNC_LastSearchRoot;
static nsIRDFResource *kNC_LastSearchMode;
static nsIRDFResource *kNC_SearchCategoryRoot;
static nsIRDFResource *kNC_SearchResultsSitesRoot;
static nsIRDFResource *kNC_FilterSearchURLsRoot;
static nsIRDFResource *kNC_FilterSearchSitesRoot;
static nsIRDFResource *kNC_SearchType;
static nsIRDFResource *kNC_Ref;
static nsIRDFResource *kNC_Child;
static nsIRDFResource *kNC_Title;
static nsIRDFResource *kNC_Data;
static nsIRDFResource *kNC_Name;
static nsIRDFResource *kNC_Description;
static nsIRDFResource *kNC_actionButton;
static nsIRDFResource *kNC_actionBar;
static nsIRDFResource *kNC_LastText;
static nsIRDFResource *kNC_URL;
static nsIRDFResource *kRDF_InstanceOf;
static nsIRDFResource *kRDF_type;
static nsIRDFResource *kNC_loading;
static nsIRDFResource *kNC_HTML;
static nsIRDFResource *kNC_Icon;
static nsIRDFResource *kNC_StatusIcon;
static nsIRDFResource *kNC_Banner;
static nsIRDFResource *kNC_Site;
static nsIRDFResource *kNC_Relevance;
static nsIRDFResource *kNC_Date;
static nsIRDFResource *kNC_RelevanceSort;
static nsIRDFResource *kNC_PageRank;
static nsIRDFResource *kNC_Engine;
static nsIRDFResource *kNC_Price;
static nsIRDFResource *kNC_PriceSort;
static nsIRDFResource *kNC_Availability;
static nsIRDFResource *kNC_BookmarkSeparator;
static nsIRDFResource *kNC_Update;
static nsIRDFResource *kNC_UpdateIcon;
static nsIRDFResource *kNC_UpdateCheckDays;
static nsIRDFResource *kWEB_LastPingDate;
static nsIRDFResource *kWEB_LastPingModDate;
static nsIRDFResource *kWEB_LastPingContentLen;
// pseudo-constants
static nsIRDFResource *kNC_SearchResult;
static nsIRDFResource *kNC_SearchEngineRoot;
static nsIRDFResource *kNC_LastSearchRoot;
static nsIRDFResource *kNC_LastSearchMode;
static nsIRDFResource *kNC_SearchCategoryRoot;
static nsIRDFResource *kNC_SearchResultsSitesRoot;
static nsIRDFResource *kNC_FilterSearchURLsRoot;
static nsIRDFResource *kNC_FilterSearchSitesRoot;
static nsIRDFResource *kNC_SearchType;
static nsIRDFResource *kNC_Ref;
static nsIRDFResource *kNC_Child;
static nsIRDFResource *kNC_Title;
static nsIRDFResource *kNC_Data;
static nsIRDFResource *kNC_Name;
static nsIRDFResource *kNC_Description;
static nsIRDFResource *kNC_Version;
static nsIRDFResource *kNC_actionButton;
static nsIRDFResource *kNC_actionBar;
static nsIRDFResource *kNC_LastText;
static nsIRDFResource *kNC_URL;
static nsIRDFResource *kRDF_InstanceOf;
static nsIRDFResource *kRDF_type;
static nsIRDFResource *kNC_loading;
static nsIRDFResource *kNC_HTML;
static nsIRDFResource *kNC_Icon;
static nsIRDFResource *kNC_StatusIcon;
static nsIRDFResource *kNC_Banner;
static nsIRDFResource *kNC_Site;
static nsIRDFResource *kNC_Relevance;
static nsIRDFResource *kNC_Date;
static nsIRDFResource *kNC_RelevanceSort;
static nsIRDFResource *kNC_PageRank;
static nsIRDFResource *kNC_Engine;
static nsIRDFResource *kNC_Price;
static nsIRDFResource *kNC_PriceSort;
static nsIRDFResource *kNC_Availability;
static nsIRDFResource *kNC_BookmarkSeparator;
static nsIRDFResource *kNC_Update;
static nsIRDFResource *kNC_UpdateIcon;
static nsIRDFResource *kNC_UpdateCheckDays;
static nsIRDFResource *kWEB_LastPingDate;
static nsIRDFResource *kWEB_LastPingModDate;
static nsIRDFResource *kWEB_LastPingContentLen;
static nsIRDFResource *kNC_SearchCommand_AddToBookmarks;
static nsIRDFResource *kNC_SearchCommand_FilterResult;
static nsIRDFResource *kNC_SearchCommand_FilterSite;
static nsIRDFResource *kNC_SearchCommand_ClearFilters;
static nsIRDFResource *kNC_SearchCommand_AddToBookmarks;
static nsIRDFResource *kNC_SearchCommand_FilterResult;
static nsIRDFResource *kNC_SearchCommand_FilterSite;
static nsIRDFResource *kNC_SearchCommand_ClearFilters;
static nsIRDFLiteral *kTrueLiteral;
static nsIRDFLiteral *kTrueLiteral;
protected:
static nsIRDFDataSource *mInner;
static nsCOMPtr<nsIRDFDataSource> mLocalstore;
static nsCOMPtr<nsISupportsArray> mUpdateArray;
nsCOMPtr<nsITimer> mTimer;
static nsCOMPtr<nsILoadGroup> mBackgroundLoadGroup;
static nsCOMPtr<nsILoadGroup> mLoadGroup;
static nsCOMPtr<nsIRDFDataSource> categoryDataSource;
static nsCOMPtr<nsIPref> prefs;
PRBool busySchedule;
nsCOMPtr<nsIRDFResource> busyResource;
nsString mQueryEncodingStr;
static nsIRDFDataSource *mInner;
static nsCOMPtr<nsIRDFDataSource> mLocalstore;
static nsCOMPtr<nsISupportsArray> mUpdateArray;
nsCOMPtr<nsITimer> mTimer;
static nsCOMPtr<nsILoadGroup> mBackgroundLoadGroup;
static nsCOMPtr<nsILoadGroup> mLoadGroup;
static nsCOMPtr<nsIRDFDataSource> categoryDataSource;
static nsCOMPtr<nsIPref> prefs;
PRBool busySchedule;
nsCOMPtr<nsIRDFResource> busyResource;
nsString mQueryEncodingStr;
friend int PR_CALLBACK searchModePrefCallback(const char *pref, void *aClosure);
friend int PR_CALLBACK searchModePrefCallback(const char *pref, void *aClosure);
// helper methods
nsresult GetSearchEngineToPing(nsIRDFResource **theResource, nsCString &updateURL);
PRBool isEngineURI(nsIRDFResource* aResource);
PRBool isSearchURI(nsIRDFResource* aResource);
PRBool isSearchCategoryURI(nsIRDFResource* aResource);
PRBool isSearchCategoryEngineURI(nsIRDFResource* aResource);
PRBool isSearchCategoryEngineBasenameURI(nsIRDFNode *aResource);
PRBool isSearchCommand(nsIRDFResource* aResource);
nsresult resolveSearchCategoryEngineURI(nsIRDFResource *source, nsIRDFResource **trueEngine);
nsresult BeginSearchRequest(nsIRDFResource *source, PRBool doNetworkRequest);
nsresult FindData(nsIRDFResource *engine, nsIRDFLiteral **data);
nsresult updateDataHintsInGraph(nsIRDFResource *engine, const PRUnichar *data);
nsresult updateAtom(nsIRDFDataSource *db, nsIRDFResource *src, nsIRDFResource *prop, nsIRDFNode *newValue, PRBool *dirtyFlag);
nsresult validateEngine(nsIRDFResource *engine);
nsresult DoSearch(nsIRDFResource *source, nsIRDFResource *engine, const nsString &fullURL, const nsString &text);
nsresult MapEncoding(const nsString &numericEncoding, nsString &stringEncoding);
nsresult SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon, const PRUnichar *hint, const PRUnichar *data, PRBool checkMacFileType);
nsresult GetSearchEngineList(nsIFile *spec, PRBool checkMacFileType);
nsresult GetCategoryList();
nsresult GetSearchFolder(nsIFile **spec);
nsresult ReadFileContents(const nsFileSpec &baseFilename, nsString & sourceContents);
nsresult GetData(const PRUnichar *data, const char *sectionToFind, PRUint32 sectionNum, const char *attribToFind, nsString &value);
nsresult GetNumInterpretSections(const PRUnichar *data, PRUint32 &numInterpretSections);
nsresult GetInputs(const PRUnichar *data, nsString &userVar, const nsString &text, nsString &input);
nsresult GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult);
nsresult validateEngineNow(nsIRDFResource *engine);
nsresult webSearchFinalize(nsIChannel *channel, nsIInternetSearchContext *context);
nsresult ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRDFResource *engine, const PRUnichar *htmlPage);
nsresult SetHint(nsIRDFResource *mParent, nsIRDFResource *hintRes);
nsresult ConvertEntities(nsString &str, PRBool removeHTMLFlag = PR_TRUE, PRBool removeCRLFsFlag = PR_TRUE, PRBool trimWhiteSpaceFlag = PR_TRUE);
nsresult saveContents(nsIChannel* channel, nsIInternetSearchContext *context, PRUint32 contextType);
char * getSearchURI(nsIRDFResource *src);
nsresult addToBookmarks(nsIRDFResource *src);
nsresult filterResult(nsIRDFResource *src);
nsresult filterSite(nsIRDFResource *src);
nsresult clearFilters(void);
PRBool isSearchResultFiltered(const nsString &href);
// helper methods
nsresult GetSearchEngineToPing(nsIRDFResource **theResource, nsCString &updateURL);
PRBool isEngineURI(nsIRDFResource* aResource);
PRBool isSearchURI(nsIRDFResource* aResource);
PRBool isSearchCategoryURI(nsIRDFResource* aResource);
PRBool isSearchCategoryEngineURI(nsIRDFResource* aResource);
PRBool isSearchCategoryEngineBasenameURI(nsIRDFNode *aResource);
PRBool isSearchCommand(nsIRDFResource* aResource);
nsresult resolveSearchCategoryEngineURI(nsIRDFResource *source, nsIRDFResource **trueEngine);
nsresult BeginSearchRequest(nsIRDFResource *source, PRBool doNetworkRequest);
nsresult FindData(nsIRDFResource *engine, nsIRDFLiteral **data);
nsresult updateDataHintsInGraph(nsIRDFResource *engine, const PRUnichar *data);
nsresult updateAtom(nsIRDFDataSource *db, nsIRDFResource *src, nsIRDFResource *prop, nsIRDFNode *newValue, PRBool *dirtyFlag);
nsresult validateEngine(nsIRDFResource *engine);
nsresult DoSearch(nsIRDFResource *source, nsIRDFResource *engine, const nsString &fullURL, const nsString &text);
nsresult MapEncoding(const nsString &numericEncoding, nsString &stringEncoding);
nsresult SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon, const PRUnichar *hint, const PRUnichar *data, PRBool checkMacFileType);
nsresult GetSearchEngineList(nsIFile *spec, PRBool checkMacFileType);
nsresult GetCategoryList();
nsresult GetSearchFolder(nsIFile **spec);
nsresult ReadFileContents(const nsFileSpec &baseFilename, nsString & sourceContents);
nsresult GetData(const PRUnichar *data, const char *sectionToFind, PRUint32 sectionNum, const char *attribToFind, nsString &value);
nsresult GetNumInterpretSections(const PRUnichar *data, PRUint32 &numInterpretSections);
nsresult GetInputs(const PRUnichar *data, nsString &userVar, const nsString &text, nsString &input);
nsresult GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult);
nsresult validateEngineNow(nsIRDFResource *engine);
nsresult webSearchFinalize(nsIChannel *channel, nsIInternetSearchContext *context);
nsresult ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRDFResource *engine, const PRUnichar *htmlPage);
nsresult SetHint(nsIRDFResource *mParent, nsIRDFResource *hintRes);
nsresult ConvertEntities(nsString &str, PRBool removeHTMLFlag = PR_TRUE, PRBool removeCRLFsFlag = PR_TRUE, PRBool trimWhiteSpaceFlag = PR_TRUE);
nsresult saveContents(nsIChannel* channel, nsIInternetSearchContext *context, PRUint32 contextType);
char * getSearchURI(nsIRDFResource *src);
nsresult addToBookmarks(nsIRDFResource *src);
nsresult filterResult(nsIRDFResource *src);
nsresult filterSite(nsIRDFResource *src);
nsresult clearFilters(void);
PRBool isSearchResultFiltered(const nsString &href);
static void FireTimer(nsITimer* aTimer, void* aClosure);
static void FireTimer(nsITimer* aTimer, void* aClosure);
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERNETSEARCHSERVICE
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIRDFDATASOURCE
NS_DECL_NSIOBSERVER
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERNETSEARCHSERVICE
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIRDFDATASOURCE
NS_DECL_NSIOBSERVER
InternetSearchDataSource(void);
virtual ~InternetSearchDataSource(void);
NS_METHOD Init();
NS_METHOD DeferredInit();
InternetSearchDataSource(void);
virtual ~InternetSearchDataSource(void);
NS_METHOD Init();
NS_METHOD DeferredInit();
};
#endif // nsinternetsearchdatasource__h____