summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/addrbook/src/nsAbOutlookInterface.cpp
blob: 7000c9031756b79e91e94260d87fa4c8f8c7cf74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * 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 "nsAbOutlookInterface.h"
#include "nsAbWinHelper.h"
#include "nsComponentManagerUtils.h"

NS_IMPL_ISUPPORTS(nsAbOutlookInterface, nsIAbOutlookInterface)

nsAbOutlookInterface::nsAbOutlookInterface(void) {}

nsAbOutlookInterface::~nsAbOutlookInterface(void) {}

NS_IMETHODIMP
nsAbOutlookInterface::GetFolderURIs(const nsACString& aURI,
                                    nsTArray<nsCString>& uris) {
  uris.Clear();
  nsresult rv = NS_OK;

  nsAbWinHelperGuard mapiAddBook;
  nsMapiEntryArray folders;
  NS_ENSURE_SUCCESS(rv, rv);
  if (!mapiAddBook->IsOK() || !mapiAddBook->GetFolders(folders)) {
    return NS_ERROR_FAILURE;
  }

  uris.SetCapacity(folders.mNbEntries);

  for (ULONG i = 0; i < folders.mNbEntries; ++i) {
    nsAutoCString entryId;
    nsAutoCString uri(kOutlookDirectoryScheme);
    folders.mEntries[i].ToString(entryId);
    uri.Append(entryId);
    uris.AppendElement(uri);
  }
  return NS_OK;
}