3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync/* ***** BEGIN LICENSE BLOCK *****
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * The contents of this file are subject to the Mozilla Public License Version
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * 1.1 (the "License"); you may not use this file except in compliance with
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * the License. You may obtain a copy of the License at
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * http://www.mozilla.org/MPL/
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Software distributed under the License is distributed on an "AS IS" basis,
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * for the specific language governing rights and limitations under the
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * License.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * The Original Code is Java XPCOM Bindings.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * The Initial Developer of the Original Code is IBM Corporation.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Portions created by the Initial Developer are Copyright (C) 2006
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * IBM Corporation. All Rights Reserved.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Contributor(s):
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Javier Pedemonte (jhpedemonte@gmail.com)
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Alternatively, the contents of this file may be used under the terms of
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * either the GNU General Public License Version 2 or later (the "GPL"), or
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * in which case the provisions of the GPL or the LGPL are applicable instead
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * of those above. If you wish to allow use of your version of this file only
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * under the terms of either the GPL or the LGPL, and not to allow others to
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * use your version of this file under the terms of the MPL, indicate your
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * decision by deleting the provisions above and replace them with the notice
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * and other provisions required by the GPL or the LGPL. If you do not delete
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * the provisions above, a recipient may use your version of this file under
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * the terms of any one of the MPL, the GPL or the LGPL.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * ***** END LICENSE BLOCK ***** */
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsyncpackage org.mozilla.xpcom;
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsyncimport java.io.File;
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsyncpublic interface IGRE {
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync /**
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Initializes libXUL for embedding purposes.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <p>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * NOTE: This function must be called from the "main" thread.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <p>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * NOTE: At the present time, this function may only be called once in
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * a given process. Use <code>termEmbedding</code> to clean up and free
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * resources allocated by <code>initEmbedding</code>.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * @param aLibXULDirectory The directory in which the libXUL shared library
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * was found.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * @param aAppDirectory The directory in which the application components
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * and resources can be found. This will map to
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * the "resource:app" directory service key.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * @param aAppDirProvider A directory provider for the application. This
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * provider will be aggregated by a libXUL provider
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * which will provide the base required GRE keys.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * @throws XPCOMException if a failure occurred during initialization
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync */
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync void initEmbedding(File aLibXULDirectory, File aAppDirectory,
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync IAppFileLocProvider aAppDirProvider) throws XPCOMException;
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync /**
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Terminates libXUL embedding.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <p>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * NOTE: Release any references to XPCOM objects that you may be holding
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * before calling this function.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync */
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync void termEmbedding();
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync /**
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Lock a profile directory using platform-specific semantics.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * @param aDirectory The profile directory to lock.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * @return A lock object. The directory will remain locked until the lock is
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * released by invoking the <code>release</code> method, or by the
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * termination of the JVM, whichever comes first.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync *
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * @throws XPCOMException if a failure occurred
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync */
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync ProfileLock lockProfileDirectory(File aDirectory) throws XPCOMException;
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync /**
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Fire notifications to inform the toolkit about a new profile. This
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * method should be called after <code>initEmbedding</code> if the
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * embedder wishes to run with a profile.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <p>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Normally the embedder should call <code>lockProfileDirectory</code>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * to lock the directory before calling this method.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <p>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * NOTE: There are two possibilities for selecting a profile:
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <ul>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <li>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Select the profile before calling <code>initEmbedding</code>.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * The aAppDirProvider object passed to <code>initEmbedding</code>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * should provide the NS_APP_USER_PROFILE_50_DIR key, and
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * may also provide the following keys:
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <ul>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <li>NS_APP_USER_PROFILE_LOCAL_50_DIR
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <li>NS_APP_PROFILE_DIR_STARTUP
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <li>NS_APP_PROFILE_LOCAL_DIR_STARTUP
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * </ul>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * In this scenario <code>notifyProfile</code> should be called
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * immediately after <code>initEmbedding</code>. Component
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * registration information will be stored in the profile and
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * JS components may be stored in the fastload cache.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * </li>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * <li>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * Select a profile some time after calling <code>initEmbedding</code>.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * In this case the embedder must install a directory service
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * provider which provides NS_APP_USER_PROFILE_50_DIR and optionally
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * NS_APP_USER_PROFILE_LOCAL_50_DIR. Component registration information
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * will be stored in the application directory and JS components will not
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * fastload.
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * </li>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync * </ul>
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync */
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync void notifyProfile();
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync}
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync
3ac4cd918f9ffed59c4cc988665d1e09c5d7304avboxsync