NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv); if (NS_FAILED(rv)) return rv;   rv = mailSession->GetAccountManager(getter_AddRefs(mAccountManager)); if (NS_FAILED(rv)) return rv;
am = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); mAccountManager = getter_AddRefs(NS_GetWeakReference(am)); } else am = do_QueryReferent(mAccountManager);  if (am) { am->AddIncomingServerListener(this); am->AddRootFolderListener(this);
nsMsgAccountManagerDataSource::Init(){    nsresult rv=NS_OK;        if (!mAccountManager) {        NS_WITH_SERVICE(nsIMsgMailSession, mailSession,                        kMsgMailSessionCID, &rv);        if (NS_FAILED(rv)) return rv;                // maybe the account manager should be a service too? not sure.        rv = mailSession->GetAccountManager(getter_AddRefs(mAccountManager));        if (NS_FAILED(rv)) return rv;    }        if (! kNC_Child) {      getRDFService()->GetResource(NC_RDF_CHILD, &kNC_Child);      getRDFService()->GetResource(NC_RDF_NAME, &kNC_Name);      getRDFService()->GetResource(NC_RDF_PAGETAG, &kNC_PageTag);      getRDFService()->GetResource(NC_RDF_ACCOUNT, &kNC_Account);      getRDFService()->GetResource(NC_RDF_SERVER, &kNC_Server);      getRDFService()->GetResource(NC_RDF_IDENTITY, &kNC_Identity);      getRDFService()->GetResource(NC_RDF_PAGETITLE_MAIN, &kNC_PageTitleMain);      getRDFService()->GetResource(NC_RDF_PAGETITLE_SERVER, &kNC_PageTitleServer);      getRDFService()->GetResource(NC_RDF_PAGETITLE_COPIES, &kNC_PageTitleCopies);      getRDFService()->GetResource(NC_RDF_PAGETITLE_ADVANCED, &kNC_PageTitleAdvanced);            getRDFService()->GetResource(NC_RDF_ACCOUNTROOT, &kNC_AccountRoot);            // eventually these need to exist in some kind of array      // that's easily extensible      getRDFService()->GetResource(NC_RDF_SETTINGS, &kNC_Settings);    }    return NS_OK;}