Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nsIAbDirectory GetChildCards returns 0x0c1f30001

3 views
Skip to first unread message

Henrik Kaare Poulsen

unread,
Jan 26, 2009, 3:55:58 PM1/26/09
to
Dear all,

I am trying to open and enumerate an addressbook in TB3 out of mozilla
comm-central hg (aka TB3):

nsCOMPtr<nsIAbDirectory> myAbDirectory;
nsCOMPtr<nsIRDFService> rdfService;
rdfService=do_GetService("@mozilla.org/rdf/rdf-service;1", &rv);
nsCOMPtr<nsIRDFResource> rs;
gchar *szAB=g_strconcat("moz-abmdbdirectory://", sz, NULL);
nsCString csc;
rv = NS_CStringSetData(csc, szAB);
rv=rdfService->GetResource(csc, getter_AddRefs(rs));
myAbDirectory = do_QueryInterface(rs, &rv);
nsCOMPtr<nsISimpleEnumerator> cards;
rv=myAbDirectory->GetChildCards(getter_AddRefs(cards));
if (NS_FAILED(rv)) ...

Here I get rv = 0x0c1f30001

In TB2 this worked, but with
nsCOMPtr<nsIEnumerator> cards;

Does anyone have clue what the error message means,
and why this would work in TB2 but not TB3 ?

/Henrik

Mark Banner

unread,
Jan 26, 2009, 4:59:28 PM1/26/09
to
On 01/26/2009 20:55, Henrik Kaare Poulsen wrote:
> Dear all,
>
> I am trying to open and enumerate an addressbook in TB3 out of mozilla
> comm-central hg (aka TB3):
>
> nsCOMPtr<nsIAbDirectory> myAbDirectory;
> nsCOMPtr<nsIRDFService> rdfService;
> rdfService=do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
> nsCOMPtr<nsIRDFResource> rs;
> gchar *szAB=g_strconcat("moz-abmdbdirectory://", sz, NULL);
> nsCString csc;
> rv = NS_CStringSetData(csc, szAB);
> rv=rdfService->GetResource(csc, getter_AddRefs(rs));
> myAbDirectory = do_QueryInterface(rs,&rv);
> nsCOMPtr<nsISimpleEnumerator> cards;
> rv=myAbDirectory->GetChildCards(getter_AddRefs(cards));
> if (NS_FAILED(rv)) ...
>
> Here I get rv = 0x0c1f30001

This is: NS_ERROR_NOT_INITIALIZED

For future reference see:
http://silver.warwickcompsoc.co.uk/mozilla/misc/nserror?0xC1F30001
(although I think this site is out of date)
http://mxr.mozilla.org/comm-central/source/mozilla/xpcom/base/nsError.h
http://mxr.mozilla.org/comm-central/source/mailnews/base/public/msgCore.h

> In TB2 this worked, but with
> nsCOMPtr<nsIEnumerator> cards;
>
> Does anyone have clue what the error message means,
> and why this would work in TB2 but not TB3 ?

It failed because the myAbDirectory hasn't been initialised correctly
because of the way the rdf sources are currently working. I thought I
had a bug on it but I can't find it at the moment.

The issue is really we're half-way through removing rdf from the address
book. If we had completely removed it, then we wouldn't have the problem.

To resolve your issue what you need to do is:

nsCOMPtr<nsIAbManager> abMgr(do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);

// This gets all address books which also forces an initialisation.
nsCOMPtr<nsISimpleEnumerator> directories;
rv = abMgr->GetDirectories(getter_AddRefs(directories));
NS_ENSURE_SUCCESS(rv, rv);

nsCOMPtr<nsIAbDirectory> myAbDirectory;
rv = abMgr->GetDirectory(csc, getter_AddRefs(myAbDirectory));
NS_ENSURE_SUCCESS(rv, rv);


Note: using nsIAbManager (available in 3.x) hides you from the rdf
interfaces and will probably help future-proof a little bit (though I'm
not guaranteeing those interfaces will stay the same post 3.x).

Standard8

Henrik Kaare Poulsen

unread,
Jan 26, 2009, 6:16:17 PM1/26/09
to
Hi Mark,

Thanks for your quick answer!
It is most appreciated by a wannabe-newbe like me...

> For future reference see:http://silver.warwickcompsoc.co.uk/mozilla/misc/nserror?0xC1F30001
> (although I think this site is out of date)

Indeed it is out of date. This was my reference in the past, but I
guess it is of no use these days...

>http://mxr.mozilla.org/comm-central/source/mozilla/xpcom/base/nsError.hhttp://mxr.mozilla.org/comm-central/source/mailnews/base/public/msgCo...
Will try to look at those in the future

> It failed because the myAbDirectory hasn't been initialised correctly
> because of the way the rdf sources are currently working. I thought I
> had a bug on it but I can't find it at the moment.
>
> The issue is really we're half-way through removing rdf from the address
> book. If we had completely removed it, then we wouldn't have the problem.

Great, I will try to stay away from RDF in the future...

> To resolve your issue what you need to do is:
> nsCOMPtr<nsIAbManager> abMgr(do_GetService(NS_ABMANAGER_CONTRACTID, &rv);

> // This gets all address books which also forces an initialisation.
> nsCOMPtr<nsISimpleEnumerator> directories;
> rv = abMgr->GetDirectories(getter_AddRefs(directories));

Unfortunatly, here I get a 0x80004005.
Guess this is the very general NS_ERROR_FAILURE.

Any suggestions?

/Henrik

Henrik Kaare Poulsen

unread,
Mar 17, 2009, 4:39:22 AM3/17/09
to
With a fresh checkout from mercury, the suggested code still returns
failure

nsCOMPtr<nsIAbManager> abMgr(do_GetService("@mozilla.org/abmanager;1",
&rv));
MOZ_ERROR_CHECK_FALSE(rv, "do_GetService @mozilla.org/abmanager;1");


nsCOMPtr<nsISimpleEnumerator> directories;
rv = abMgr->GetDirectories(getter_AddRefs(directories));

MOZ_ERROR_CHECK_FALSE(rv, "nsIAbManager->GetDirectories");
Fails with 0x080004005 (NS_ERROR_FAILURE)

Any suggestions would be much appreciated!

/Henrik

Mark Banner

unread,
Mar 17, 2009, 6:19:05 AM3/17/09
to

Have you tried with a fresh profile?

That code is pretty much the same as other examples we have in the code
that you're running:

http://hg.mozilla.org/comm-central/annotate/d9fef5145cba/mailnews/base/src/nsMsgContentPolicy.cpp#l159
http://hg.mozilla.org/comm-central/annotate/d9fef5145cba/mailnews/addrbook/src/nsAbAddressCollector.cpp#l78

Therefore I'm thinking there is something in your profile that is
causing the directory initialisation to fail.

Standard8

jenn...@gmail.com

unread,
Mar 17, 2009, 9:34:55 PM3/17/09
to
On Jan 27, 7:16 am, Henrik Kaare Poulsen <bluez...@gmail.com> wrote:
> Hi Mark,
>
> Thanks for your quick answer!
> It is most appreciated by a wannabe-newbe like me...
>
> > For future reference see:http://silver.warwickcompsoc.co.uk/mozilla/misc/nserror?0xC1F30001
> > (although I think this site is out of date)
>
> Indeed it is out of date. This was my reference in the past, but I
> guess it is of no use these days...
>
> >http://mxr.mozilla.org/comm-central/source/mozilla/xpcom/base/nsError......

>
> Will try to look at those in the future
>
> > It failed because the myAbDirectory hasn't been initialised correctly
> > because of the way the rdf sources are currently working. I thought I
> > had a bug on it but I can't find it at the moment.
>
> > The issue is really we're half-way through removing rdf from the address
> > book. If we had completely removed it, then we wouldn't have the problem.
>
> Great, I will try to stay away from RDF in the future...
>
> > To resolve your issue what you need to do is:
> > nsCOMPtr<nsIAbManager> abMgr(do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
> > // This gets all address books which also forces an initialisation.
> > nsCOMPtr<nsISimpleEnumerator> directories;
> > rv = abMgr->GetDirectories(getter_AddRefs(directories));
>
> Unfortunatly, here I get a 0x80004005.
> Guess this is the very general NS_ERROR_FAILURE.
>
> Any suggestions?
>
> /Henrik

Hi Henrik, i got the same error when compiling mozilla-sync with TB3
(shredder).
I think the causes is prefs.js which should be in thunderbird
profile.
You can rename the file XXX/mailnews/mailnews.js as prefs.js and move
it to thunderbird profile.
Then everything will fine, have a try.
When running TB3, it will always rewrite the prefs.js.

Mark Banner

unread,
Mar 18, 2009, 3:06:17 AM3/18/09
to
On 18/03/2009 01:34, jenn...@gmail.com wrote:
> Hi Henrik, i got the same error when compiling mozilla-sync with TB3
> (shredder).
> I think the causes is prefs.js which should be in thunderbird
> profile.
> You can rename the file XXX/mailnews/mailnews.js as prefs.js and move
> it to thunderbird profile.
> Then everything will fine, have a try.
> When running TB3, it will always rewrite the prefs.js.

prefs.js is created by Thunderbird on first run if it doesn't exist.

Copying mailnews.js over prefs.js will overwrite whatever settings you
have. It is also entirely unnecessary, mailnews.js is included in the
build so Thunderbird has those settings by default.

Standard8

0 new messages