nsresult rv;
nsresult rv = NS_OK;
NS_IMETHODIMP nsMsgImapModule::GetClassObject(nsIComponentManager *aCompMgr,                               const nsCID& aClass,                               const nsIID& aIID,                               void** r_classObj){    nsresult rv;    // Defensive programming: Initialize *r_classObj in case of error below    if (!r_classObj)        return NS_ERROR_INVALID_POINTER;    *r_classObj = NULL;    // Do one-time-only initialization if necessary    if (!mInitialized)     {        rv = Initialize();        if (NS_FAILED(rv)) // Initialization failed! yikes!            return rv;    }    // Choose the appropriate factory, based on the desired instance    // class type (aClass).    nsCOMPtr<nsIGenericFactory> fact;    if (aClass.Equals(kCImapUrl))    {        if (!mImapUrlFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapUrlFactory), &nsImapUrlConstructor);        fact = mImapUrlFactory;    }    else if (aClass.Equals(kCImapProtocol))    {        if (!mImapProtocolFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapProtocolFactory), &nsImapProtocolConstructor);        fact = mImapProtocolFactory;    }    else if (aClass.Equals(kCImapHostSessionList))    {        if (!mImapHostSessionFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapHostSessionFactory), &nsIMAPHostSessionListConstructor);        fact = mImapHostSessionFactory;    }    else if (aClass.Equals(kCImapIncomingServer))    {        if (!mImapIncomingServerFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapIncomingServerFactory), &nsImapIncomingServerConstructor);        fact = mImapIncomingServerFactory;    }    else if (aClass.Equals(kCImapService))    {        if (!mImapServiceFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapServiceFactory), &nsImapServiceConstructor);        fact = mImapServiceFactory;    }    else if (aClass.Equals(kCImapResource))    {        if (!mImapMailFolderFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapMailFolderFactory), &nsImapMailFolderConstructor);        fact = mImapMailFolderFactory;    }    else if (aClass.Equals(kCImapMockChannel))    {        if (!mImapMockChannelFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapMockChannelFactory), &nsImapMockChannelConstructor);        fact = mImapMockChannelFactory;    }    else if (aClass.Equals(kCImapMessageResource))     {        if (!mImapMessageFactory)            rv = NS_NewGenericFactory(getter_AddRefs(mImapMessageFactory), &nsImapMessageConstructor);        fact = mImapMessageFactory;    }            if (fact)        rv = fact->QueryInterface(aIID, r_classObj);    return rv;}