зеркало из https://github.com/mozilla/gecko-dev.git
update delegate factory to create the object first, then QI
(so object creation is not dependant on the interface)
This commit is contained in:
Родитель
47ad451eae
Коммит
a951b56ce1
|
@ -52,45 +52,43 @@ nsMsgFilterDelegateFactory::~nsMsgFilterDelegateFactory()
|
||||||
/* void CreateDelegate (in nsIRDFResource aOuter, in string aKey, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult aResult); */
|
/* void CreateDelegate (in nsIRDFResource aOuter, in string aKey, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult aResult); */
|
||||||
NS_IMETHODIMP nsMsgFilterDelegateFactory::CreateDelegate(nsIRDFResource *aOuter, const char *aKey, const nsIID & aIID, void * *aResult)
|
NS_IMETHODIMP nsMsgFilterDelegateFactory::CreateDelegate(nsIRDFResource *aOuter, const char *aKey, const nsIID & aIID, void * *aResult)
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
*aResult = nsnull;
|
||||||
|
|
||||||
// if it's a folder, then we return a filter list..
|
// if it's a folder, then we return a filter list..
|
||||||
// otherwise make sure it's in the form
|
// otherwise make sure it's in the form
|
||||||
// mailbox://userid@server/foldername#filter4
|
// mailbox://userid@server/foldername#filter4
|
||||||
|
|
||||||
#ifdef DEBUG_alecf
|
|
||||||
nsXPIDLCString outerValue;
|
|
||||||
aOuter->GetValue(getter_Copies(outerValue));
|
|
||||||
printf("nsMsgFilterDelegateFactory::CreateDelegate(%s, %s, ..)\n",
|
|
||||||
outerValue, aKey);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*aResult = nsnull;
|
nsXPIDLCString uri;
|
||||||
|
aOuter->GetValueConst(getter_Shares(uri));
|
||||||
|
|
||||||
nsresult rv;
|
// if it has '#filter' then it's a filter, otherwise we'll assume
|
||||||
if (aIID.Equals(NS_GET_IID(nsIMsgFilterList))) {
|
// that it's a folder.
|
||||||
nsIMsgFilterList *filterList;
|
nsCAutoString uriStr(uri);
|
||||||
rv = getFilterListDelegate(aOuter, &filterList);
|
|
||||||
#ifdef DEBUG_alecf
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
printf(" creating nsIMsgFilterList delegate\n");
|
|
||||||
#endif
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
*aResult = (void *)filterList;
|
|
||||||
|
|
||||||
} else if (aIID.Equals(NS_GET_IID(nsIMsgFilter))) {
|
nsCOMPtr<nsISupports> resultSupports;
|
||||||
nsIMsgFilter *filter;
|
|
||||||
rv = getFilterDelegate(aOuter, &filter);
|
if (uriStr.Find("#filter") != -1) {
|
||||||
#ifdef DEBUG_alecf
|
nsCOMPtr<nsIMsgFilter> filter;
|
||||||
|
rv = getFilterDelegate(aOuter, getter_AddRefs(filter));
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
printf(" creating nsIMsgFilter delegate\n");
|
resultSupports = filter;
|
||||||
#endif
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// probably a folder, get the filter list
|
||||||
|
nsCOMPtr<nsIMsgFilterList> filterList;
|
||||||
|
rv = getFilterListDelegate(aOuter, getter_AddRefs(filterList));
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
*aResult = (void *)filter;
|
resultSupports = filterList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*aResult)
|
if (resultSupports)
|
||||||
return NS_ERROR_FAILURE;
|
return resultSupports->QueryInterface(aIID, aResult);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -103,7 +101,8 @@ nsMsgFilterDelegateFactory::getFilterListDelegate(nsIRDFResource *aOuter,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgFilterList> filterList;
|
nsCOMPtr<nsIMsgFilterList> filterList;
|
||||||
folder->GetFilterList(getter_AddRefs(filterList));
|
rv = folder->GetFilterList(getter_AddRefs(filterList));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
*aResult = filterList;
|
*aResult = filterList;
|
||||||
NS_ADDREF(*aResult);
|
NS_ADDREF(*aResult);
|
||||||
|
@ -132,10 +131,6 @@ nsMsgFilterDelegateFactory::getFilterDelegate(nsIRDFResource *aOuter,
|
||||||
if (!filterTag)
|
if (!filterTag)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
#ifdef DEBUG_alecf
|
|
||||||
printf("nsMsgFilterDelegateFactory: found #: %s\n", filterTag);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PRInt32 filterNumber = getFilterNumber(filterTag);
|
PRInt32 filterNumber = getFilterNumber(filterTag);
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgFilterList> filterList;
|
nsCOMPtr<nsIMsgFilterList> filterList;
|
||||||
|
@ -143,10 +138,6 @@ nsMsgFilterDelegateFactory::getFilterDelegate(nsIRDFResource *aOuter,
|
||||||
|
|
||||||
// now that we have the filter list and index, retrieve the filter.
|
// now that we have the filter list and index, retrieve the filter.
|
||||||
|
|
||||||
#ifdef DEBUG_alecf
|
|
||||||
printf("Retrieving filter #%d\n" , filterNumber);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgFilter> filter;
|
nsCOMPtr<nsIMsgFilter> filter;
|
||||||
rv = filterList->GetFilterAt(filterNumber, getter_AddRefs(filter));
|
rv = filterList->GetFilterAt(filterNumber, getter_AddRefs(filter));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче