Tom, I have found the solution of the problem.
yes, I am checking the value of rv after each call of
AddCategoryEntry. And It was returning succes. And then I installed a
tool Component Viewer(Which you only told me ) And I found that my
component was not registered properly.
So I made one change in the AddCategoryEntry Function. I made 2nd and
3rd parameter same.
Initially my code was like this:
rv = catman->AddCategoryEntry("content-policy","WebLock",
WebLock_ContractID,PR_TRUE,PR_TRUE,&previous);
And I changed it to
rv = catman->AddCategoryEntry("content-policy",WebLock_ContractID,
WebLock_ContractID,PR_TRUE,PR_TRUE,&previous);
And it started working for me. and now I am getting the notifications
for each site I visit. But I do not understand why was it not working
when 2nd and 3rd parameter were different.
Your suggestions have been very helpfull for me. Yea, initially I was
using Netscape 7.0 and then You told me it is not going to work for
7.0 because it is built on Mozill 1.0.
Thanks for your suggestions once again.
"Tom Lee" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> "Arun" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I am trying to write a componant which will be used to block sites. I
> > derived my componant from nsIContentPolicy Interface and registerd the
> > "content-policy" category during the registration process. It should
> > call ShouldLoad function of nsIContentPolicy when I visit a web site
> > but it is not doing so.
> >
> > This is done in the registration function
> >
> > nsCOMPtr<nsICategoryManager> catman;
> > rv =
> servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,NS_GET_IID(nsI
> CategoryManager), getter_AddRefs(catman));
> >
> > rv = catman->AddCategoryEntry("xpcom-startup","WebLock",
> > WebLock_ContractID,PR_TRUE,PR_TRUE,&previous);
> >
> >
> > rv = catman->AddCategoryEntry("content-policy","WebLock",
> > WebLock_ContractID,PR_TRUE,PR_TRUE,&previous);
> >
> > and then I have ShouldLoad function. but it never gets executed.
> >
> > any ideas why it does not work?
> >
> > It however works for the "xpcom-startup" category and I am getting the
> > notifications when I start the browser.
> > I am using netscape 7.1 which is build on Mozilla 1.4
>
>
> Hi Arun,
>
> First take it from me - you should use Mozilla build 1.02 with Netscape 7.x.
> You will pull your hair out if you do not ,as there are many version
> mismatch problems - believe me when I say that.
>
> I have had problems with the "AddCategoryEntry" method on Netscape 7.x. Are
> you checking the result (rv) after you add the category? Also I would make
> sure that you are utilizing a try-catch block. I would bet my pay check
> that "AddCategoryEntry" is failing.
>
> This is the only way I got my registration functionality to work for
> Netscape 7.x - regardless of whatever you read in any book.
>
>
>
> NS_GENERIC_FACTORY_CONSTRUCTOR(nsPinpointCitationToolbar)
>
>
>
> static NS_METHOD nsSagebrushToolbarRegistration(nsIComponentManager
> *aCompMgr,
> nsIFile *aPath,
> const char *registryLocation,
> const char *componentType,
> const nsModuleComponentInfo
> *info)
> {
> return NS_OK;
> }
> static NS_METHOD nsSagebrushToolbarUnregistration(nsIComponentManager
> *aCompMgr,
> nsIFile *aPath,
> const char *registryLocation,
> const nsModuleComponentInfo
> *info)
> {
> return NS_OK;
> }
>
> NS_DECL_CLASSINFO(nsPinpointCitationToolbar)
> static const nsModuleComponentInfo components[] =
> {
> { "Pinpoint Citation Toolbar",
> NS_SAGEBRUSH_CID,
> sagebrush_ContractID,
> nsPinpointCitationToolbarConstructor,
> nsSagebrushToolbarRegistration,
> nsSagebrushToolbarUnregistration
> }
> };
>
> NS_IMPL_NSGETMODULE(nsPinpointCitationToolbar, components)