profile/dirserviceprovider/public/nsProfileDirServiceProvider.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/profile/dirserviceprovider/public/nsProfileDirServiceProvider.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +// Interfaces Needed
    1.10 +#include "nsIDirectoryService.h"
    1.11 +#include "nsIFile.h"
    1.12 +
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include "nsDirectoryServiceUtils.h"
    1.15 +#include "nsComponentManagerUtils.h"
    1.16 +#include "nsServiceManagerUtils.h"
    1.17 +
    1.18 +#ifdef MOZILLA_INTERNAL_API
    1.19 +#include "nsString.h"
    1.20 +#else
    1.21 +#include "nsEmbedString.h"
    1.22 +#endif
    1.23 +
    1.24 +// Forward Declarations
    1.25 +class nsProfileLock;
    1.26 +
    1.27 +// --------------------------------------------------------------------------------------
    1.28 +// nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for
    1.29 +// profile-relative file locations.
    1.30 +// --------------------------------------------------------------------------------------
    1.31 +
    1.32 +class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider
    1.33 +{  
    1.34 +  NS_DECL_ISUPPORTS
    1.35 +  NS_DECL_NSIDIRECTORYSERVICEPROVIDER
    1.36 +
    1.37 +  friend nsresult NS_NewProfileDirServiceProvider(bool, nsProfileDirServiceProvider**);
    1.38 +
    1.39 +public:
    1.40 +
    1.41 +   /**
    1.42 +    * SetProfileDir
    1.43 +    *
    1.44 +    * @param aProfileDir   The directory containing the profile files.
    1.45 +    *                      It does not need to exist before calling this
    1.46 +    *                      method. If it does not, it will be created and
    1.47 +    *                      defaults will be copied to it. 
    1.48 +    * @param aLocalProfileDir
    1.49 +    *                      Directory for local profile data, e.g. Cache.
    1.50 +    *                      If null, aProfileDir will be used for this purpose.
    1.51 +    */
    1.52 +
    1.53 +   virtual nsresult        SetProfileDir(nsIFile* aProfileDir,
    1.54 +                                         nsIFile* aLocalProfileDir = nullptr);
    1.55 +
    1.56 +  /**
    1.57 +   * Register
    1.58 +   *
    1.59 +   * Convenience method to register the provider with directory service.
    1.60 +   * The service holds strong references to registered providers so consumers
    1.61 +   * don't need to hold a reference to this object after calling Register().
    1.62 +   */
    1.63 +
    1.64 +  virtual nsresult         Register();
    1.65 +
    1.66 +  /**
    1.67 +   * Shutdown
    1.68 +   *
    1.69 +   * This method must be called before shutting down XPCOM if this object
    1.70 +   * was created with aNotifyObservers == true. If this object was
    1.71 +   * created with aNotifyObservers == false, this method is a no-op.
    1.72 +   */
    1.73 +
    1.74 +  virtual nsresult         Shutdown();
    1.75 +
    1.76 +protected:
    1.77 +                           nsProfileDirServiceProvider(bool aNotifyObservers = true);
    1.78 +   virtual                 ~nsProfileDirServiceProvider();
    1.79 +
    1.80 +  nsresult                 Initialize();
    1.81 +  nsresult                 InitProfileDir(nsIFile* profileDir);
    1.82 +  nsresult                 InitNonSharedProfileDir();
    1.83 +  nsresult                 EnsureProfileFileExists(nsIFile *aFile, nsIFile *destDir);
    1.84 +  nsresult                 UndefineFileLocations();
    1.85 +
    1.86 +protected:
    1.87 +
    1.88 +  nsCOMPtr<nsIFile>        mProfileDir;
    1.89 +  nsCOMPtr<nsIFile>        mLocalProfileDir;
    1.90 +  nsProfileLock*           mProfileDirLock;
    1.91 +  bool                     mNotifyObservers;
    1.92 +
    1.93 +  bool                     mSharingEnabled;
    1.94 +#ifndef MOZILLA_INTERNAL_API
    1.95 +  nsEmbedString            mNonSharedDirName;
    1.96 +#else
    1.97 +  nsString                 mNonSharedDirName;
    1.98 +#endif
    1.99 +  nsCOMPtr<nsIFile>        mNonSharedProfileDir;
   1.100 +};
   1.101 +
   1.102 +
   1.103 +// --------------------------------------------------------------------------------------
   1.104 +
   1.105 +/**
   1.106 + * Global method to create an instance of nsProfileDirServiceProvider
   1.107 + *
   1.108 + * @param aNotifyObservers    If true, will send out profile startup
   1.109 + *                            notifications when the profile directory is set.
   1.110 + *                            See notifications.txt
   1.111 + */
   1.112 + 
   1.113 +nsresult NS_NewProfileDirServiceProvider(bool aNotifyObservers,
   1.114 +                                         nsProfileDirServiceProvider** aProvider);
   1.115 +

mercurial