nsXPIDLString dn; rv = aMessage->GetDn (getter_Copies (dn)); NS_ENSURE_SUCCESS(rv, rv);  nsXPIDLCString uri; rv = mDirectoryQuery->CreateCardURI (mUrl, NS_ConvertUCS2toUTF8(dn).get(), getter_Copies (uri)); NS_ENSURE_SUCCESS(rv, rv); NS_ConvertUTF8toUCS2 v (uri.get ());  _propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), v.get ()); if (_propertyValue == NULL) return NS_ERROR_OUT_OF_MEMORY; } else if (n.Equals(NS_LITERAL_CSTRING("card:nsIAbCard"))) {
nsresult nsAbQueryLDAPMessageListener::OnLDAPMessageSearchEntry (nsILDAPMessage *aMessage,        nsIAbDirectoryQueryResult** result){    nsresult rv;    nsCOMPtr<nsISupportsArray> propertyValues;    CharPtrArrayGuard properties;    rv = mQueryArguments->GetReturnProperties (properties.GetSizeAddr(), properties.GetArrayAddr());    NS_ENSURE_SUCCESS(rv, rv);    CharPtrArrayGuard attrs;    rv = aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr());    NS_ENSURE_SUCCESS(rv, rv);    nsCAutoString n;    for (PRUint32 i = 0; i < properties.GetSize(); i++)    {        n.Assign (properties[i]);        nsAbDirectoryQueryPropertyValue* _propertyValue = 0;        if (n.Equals(NS_LITERAL_CSTRING("card:URI")))        {            // Meta property            //            nsXPIDLString dn;            rv = aMessage->GetDn (getter_Copies (dn));            NS_ENSURE_SUCCESS(rv, rv);            nsXPIDLCString uri;            rv = mDirectoryQuery->CreateCardURI (mUrl, NS_ConvertUCS2toUTF8(dn).get(), getter_Copies (uri));            NS_ENSURE_SUCCESS(rv, rv);            NS_ConvertUTF8toUCS2 v (uri.get ());            _propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), v.get ());            if (_propertyValue == NULL)                return NS_ERROR_OUT_OF_MEMORY;        }        else if (n.Equals(NS_LITERAL_CSTRING("card:nsIAbCard")))        {            // Meta property            //            nsXPIDLString dn;            rv = aMessage->GetDn (getter_Copies (dn));            NS_ENSURE_SUCCESS(rv, rv);            nsCOMPtr<nsIAbCard> card;            rv = mDirectoryQuery->CreateCard (mUrl, NS_ConvertUCS2toUTF8(dn).get(), getter_AddRefs (card));            NS_ENSURE_SUCCESS(rv, rv);            PRBool hasSetCardProperty = PR_FALSE;            rv = MozillaLdapPropertyRelator::createCardPropertyFromLDAPMessage (aMessage,                    card,                    &hasSetCardProperty);            NS_ENSURE_SUCCESS(rv, rv);            if (hasSetCardProperty == PR_FALSE)                continue;            _propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), card);            if (_propertyValue == NULL)                return NS_ERROR_OUT_OF_MEMORY;        }        else        {            const MozillaLdapPropertyRelation* p =                MozillaLdapPropertyRelator::findLdapPropertyFromMozilla (n.get ());            if (!p)                continue;            for (PRUint32 j = 0; j < attrs.GetSize(); j++)            {                if (nsCRT::strcasecmp (p->ldapProperty, attrs[j]) == 0)                {                    PRUnicharPtrArrayGuard vals;                    rv = aMessage->GetValues (attrs[j], vals.GetSizeAddr(), vals.GetArrayAddr());                    NS_ENSURE_SUCCESS(rv, rv);                    if (vals.GetSize() == 0)                        break;                    _propertyValue = new nsAbDirectoryQueryPropertyValue(n.get (), vals[0]);                    if (_propertyValue == NULL)                        return NS_ERROR_OUT_OF_MEMORY;                    break;                }            }        }        if (_propertyValue)        {            nsCOMPtr<nsIAbDirectoryQueryPropertyValue> propertyValue;            propertyValue = _propertyValue;            if (!propertyValues)            {                NS_NewISupportsArray(getter_AddRefs(propertyValues));            }            propertyValues->AppendElement (propertyValue);        }    }    if (!propertyValues)        return NS_OK;    return QueryResultStatus (propertyValues, result,nsIAbDirectoryQueryResult::queryResultMatch);}