Bug 1356881 - find mailinglists (groups) also in OS X and Outlook addressbooks. r=Paenglab, r=jorgk
This commit is contained in:
Родитель
26a4ffd76d
Коммит
7ae674efe3
|
@ -120,6 +120,9 @@ interface nsIAbDirectory : nsIAbCollection {
|
|||
// Check if directory contains directory
|
||||
boolean hasDirectory(in nsIAbDirectory dir);
|
||||
|
||||
// Check if directory contains a mailinglist by name
|
||||
boolean hasMailListWithName(in wstring aName);
|
||||
|
||||
/**
|
||||
* Adds a card to the database.
|
||||
*
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsAbDirProperty.h"
|
||||
#include "nsAbDirProperty.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsDirPrefs.h"
|
||||
|
@ -13,6 +13,7 @@
|
|||
#include "nsComponentManagerUtils.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIAbManager.h"
|
||||
#include "nsArrayUtils.h"
|
||||
|
||||
// From nsDirPrefs
|
||||
#define kDefaultPosition 1
|
||||
|
@ -295,6 +296,47 @@ NS_IMETHODIMP
|
|||
nsAbDirProperty::HasDirectory(nsIAbDirectory *dir, bool *hasDir)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbDirProperty::HasMailListWithName(const char16_t *aName, bool *aHasList)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
NS_ENSURE_ARG_POINTER(aHasList);
|
||||
|
||||
*aHasList = false;
|
||||
|
||||
bool supportsLists = false;
|
||||
nsresult rv = GetSupportsMailingLists(&supportsLists);
|
||||
if (NS_FAILED(rv) || !supportsLists)
|
||||
return NS_OK;
|
||||
|
||||
if (m_IsMailList)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIMutableArray> addressLists;
|
||||
rv = GetAddressLists(getter_AddRefs(addressLists));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t listCount = 0;
|
||||
rv = addressLists->GetLength(&listCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (uint32_t i = 0; i < listCount; i++)
|
||||
{
|
||||
nsCOMPtr<nsIAbDirectory> listDir(do_QueryElementAt(addressLists, i, &rv));
|
||||
if (NS_SUCCEEDED(rv) && listDir)
|
||||
{
|
||||
nsAutoString listName;
|
||||
rv = listDir->GetDirName(listName);
|
||||
if (NS_SUCCEEDED(rv) && listName.Equals(aName))
|
||||
{
|
||||
*aHasList = true;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbDirProperty::CreateNewDirectory(const nsAString &aDirName,
|
||||
const nsACString &aURI,
|
||||
|
|
|
@ -587,6 +587,22 @@ NS_IMETHODIMP nsAbMDBDirectory::HasDirectory(nsIAbDirectory *dir, bool *hasDir)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBDirectory::HasMailListWithName(const char16_t *aName, bool *aHasList)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHasList);
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> database;
|
||||
nsresult rv = GetDatabase(getter_AddRefs(database));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = database->FindMailListbyUnicodeName(aName, aHasList);
|
||||
if (NS_SUCCEEDED(rv) && *aHasList)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBDirectory::AddMailList(nsIAbDirectory *list, nsIAbDirectory **addedList)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(addedList);
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
NS_IMETHOD DeleteCards(nsIArray *cards) override;
|
||||
NS_IMETHOD HasCard(nsIAbCard *cards, bool *hasCard) override;
|
||||
NS_IMETHOD HasDirectory(nsIAbDirectory *dir, bool *hasDir) override;
|
||||
NS_IMETHOD HasMailListWithName(const char16_t *aName, bool *aHasList) override;
|
||||
NS_IMETHOD AddMailList(nsIAbDirectory *list, nsIAbDirectory **addedList) override;
|
||||
NS_IMETHOD AddCard(nsIAbCard *card, nsIAbCard **addedCard) override;
|
||||
NS_IMETHOD ModifyCard(nsIAbCard *aModifiedCard) override;
|
||||
|
|
|
@ -466,12 +466,12 @@ NS_IMETHODIMP nsAbManager::GetUserProfileDirectory(nsIFile **userDir)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbManager::MailListNameExists(const char16_t *name, bool *exist)
|
||||
NS_IMETHODIMP nsAbManager::MailListNameExists(const char16_t *aName, bool *aExists)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(exist);
|
||||
NS_ENSURE_ARG_POINTER(aExists);
|
||||
|
||||
*exist = false;
|
||||
*aExists = false;
|
||||
|
||||
// now get the top-level book
|
||||
nsCOMPtr<nsIAbDirectory> topDirectory;
|
||||
|
@ -482,29 +482,23 @@ NS_IMETHODIMP nsAbManager::MailListNameExists(const char16_t *name, bool *exist)
|
|||
rv = topDirectory->GetChildNodes(getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupports> item;
|
||||
nsCOMPtr<nsIAbMDBDirectory> directory;
|
||||
|
||||
bool hasMore;
|
||||
// XXX Make this not MDB specific.
|
||||
while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore)
|
||||
{
|
||||
nsCOMPtr<nsISupports> item;
|
||||
rv = enumerator->GetNext(getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
directory = do_QueryInterface(item, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIAddrDatabase> database;
|
||||
rv = directory->GetDatabase(getter_AddRefs(database));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = database->FindMailListbyUnicodeName(name, exist);
|
||||
if (NS_SUCCEEDED(rv) && *exist)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(item, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
rv = directory->HasMailListWithName(aName, aExists);
|
||||
if (NS_SUCCEEDED(rv) && *aExists)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aExists = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче