suite/profile/nsSuiteDirectoryProvider.h
author Gregory Szorc <gps@mozilla.com>
Thu, 28 Feb 2013 15:16:49 +0100
changeset 15059 c8c0954ad5947fb552ce84b6cafeac9c8e1f0465
parent 14699 ccc5dae566c9c84d52ed60706fe10713b6ff639f
child 20452 c4202cb87f5d9ef517065b545cbbf8c697718070
permissions -rw-r--r--
Bug 845089 - Convert build system to moz.build files on a CLOSED TREE; r=Callek

/* 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/. */

#ifndef SuiteDirectoryProvider_h__
#define SuiteDirectoryProvider_h__

#include "nsCOMArray.h"
#include "nsIDirectoryService.h"
#include "nsIFile.h"
#include "nsISimpleEnumerator.h"
#include "nsStringAPI.h"
#include "nsCOMPtr.h"
#include "nsIProperties.h"

#define NS_SUITEDIRECTORYPROVIDER_CONTRACTID "@mozilla.org/suite/directory-provider;1"
// {9aa21826-9d1d-433d-8c10-f313b26fa9dd}
#define NS_SUITEDIRECTORYPROVIDER_CID \
  { 0x9aa21826, 0x9d1d, 0x433d, { 0x8c, 0x10, 0xf3, 0x13, 0xb2, 0x6f, 0xa9, 0xdd } }

class nsSuiteDirectoryProvider : public nsIDirectoryServiceProvider2
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIDIRECTORYSERVICEPROVIDER
  NS_DECL_NSIDIRECTORYSERVICEPROVIDER2

private:
  void EnsureProfileFile(const nsACString& aLeafName,
			 nsIFile* aParentDir, nsIFile* aTarget);

  void AppendDistroSearchDirs(nsIProperties* aDirSvc,
                              nsCOMArray<nsIFile> &array);

  void AppendFileKey(const char *key, nsIProperties* aDirSvc,
                     nsCOMArray<nsIFile> &array);

  class AppendingEnumerator : public nsISimpleEnumerator
  {
  public:
    NS_DECL_ISUPPORTS
    NS_DECL_NSISIMPLEENUMERATOR

    AppendingEnumerator(nsISimpleEnumerator* aBase,
                        const char* const aLeafName);

  private:
    void GetNext();

    nsCOMPtr<nsISimpleEnumerator> mBase;
    nsDependentCString            mLeafName;
    nsCOMPtr<nsIFile>             mNext;
  };
};

#endif