2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2000-02-04 07:33:46 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
2000-02-04 07:33:46 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2000-02-04 07:33:46 +03:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-02-04 07:33:46 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2000-02-04 07:33:46 +03:00
|
|
|
* Seth Spitzer <sspitzer@netscape.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-02-04 07:33:46 +03:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
|
2000-02-05 02:07:27 +03:00
|
|
|
%{C++
|
2000-02-06 15:21:22 +03:00
|
|
|
|
2000-02-05 02:07:27 +03:00
|
|
|
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
2000-02-26 06:52:06 +03:00
|
|
|
#define PREF_STARTUP_PREFIX "general.startup."
|
2000-02-06 15:21:22 +03:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsICategoryManager.h"
|
|
|
|
#include "nsIFileSpec.h"
|
|
|
|
#include "nsXPIDLString.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
2000-02-08 04:11:13 +03:00
|
|
|
#include "nsIServiceManager.h"
|
2000-02-06 15:21:22 +03:00
|
|
|
|
2001-03-12 23:43:02 +03:00
|
|
|
struct nsModuleComponentInfo; // forward declaration
|
|
|
|
|
2000-02-06 15:21:22 +03:00
|
|
|
#define CMDLINEHANDLER_REGISTERPROC_DECLS \
|
2001-03-12 23:43:02 +03:00
|
|
|
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info); \
|
|
|
|
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info);
|
2000-02-06 15:21:22 +03:00
|
|
|
|
2000-04-12 00:19:32 +04:00
|
|
|
#define CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args)\
|
|
|
|
NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \
|
|
|
|
{ \
|
|
|
|
if (!aDefaultArgs) return NS_ERROR_FAILURE; \
|
2001-09-29 12:28:41 +04:00
|
|
|
*aDefaultArgs = ToNewUnicode(nsDependentCString(macro_default_args)); \
|
2000-04-12 00:19:32 +04:00
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CMDLINEHANDLER_GETCHROMEURL_IMPL(macro_class,macro_chrome_url)\
|
|
|
|
NS_IMETHODIMP macro_class::GetChromeUrlForTask(char **aChromeUrlForTask) \
|
|
|
|
{ \
|
|
|
|
if (!aChromeUrlForTask) return NS_ERROR_FAILURE; \
|
|
|
|
*aChromeUrlForTask = PL_strdup(macro_chrome_url); \
|
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
2000-09-14 03:57:52 +04:00
|
|
|
#define CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_help_text, macro_contractid, macro_pretty_name, macro_handles_args, macro_open_window_with_args)\
|
2000-02-06 15:21:22 +03:00
|
|
|
NS_IMETHODIMP macro_class::GetCommandLineArgument(char **aCommandLineArgument) \
|
|
|
|
{ \
|
|
|
|
if (!aCommandLineArgument) return NS_ERROR_FAILURE; \
|
|
|
|
*aCommandLineArgument = PL_strdup(macro_cmd_line_arg); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
|
|
|
NS_IMETHODIMP macro_class::GetPrefNameForStartup(char **aPrefNameForStartup) \
|
|
|
|
{ \
|
|
|
|
if (!aPrefNameForStartup) return NS_ERROR_FAILURE; \
|
|
|
|
*aPrefNameForStartup = PL_strdup(macro_pref_name); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
|
|
|
NS_IMETHODIMP macro_class::GetHelpText(char **aHelpText) \
|
|
|
|
{ \
|
|
|
|
if (!aHelpText) return NS_ERROR_FAILURE; \
|
|
|
|
*aHelpText = PL_strdup(macro_help_text); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2000-02-08 04:11:13 +03:00
|
|
|
NS_IMETHODIMP macro_class::GetHandlesArgs(PRBool *aHandlesArgs) \
|
|
|
|
{ \
|
|
|
|
if (!aHandlesArgs) return NS_ERROR_FAILURE; \
|
|
|
|
*aHandlesArgs = macro_handles_args; \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2000-02-08 06:12:39 +03:00
|
|
|
NS_IMETHODIMP macro_class::GetOpenWindowWithArgs(PRBool *aOpenWindowWithArgs) \
|
|
|
|
{ \
|
|
|
|
if (!aOpenWindowWithArgs) return NS_ERROR_FAILURE; \
|
|
|
|
*aOpenWindowWithArgs = macro_open_window_with_args; \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2001-03-12 23:43:02 +03:00
|
|
|
NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info) \
|
2000-02-06 15:21:22 +03:00
|
|
|
{ \
|
|
|
|
nsresult rv; \
|
2000-09-15 03:20:49 +04:00
|
|
|
nsCOMPtr<nsICategoryManager> catman = do_GetService("@mozilla.org/categorymanager;1", &rv); \
|
2000-02-06 15:21:22 +03:00
|
|
|
if (NS_FAILED(rv)) return rv; \
|
|
|
|
nsXPIDLCString prevEntry; \
|
2000-09-14 03:57:52 +04:00
|
|
|
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_pretty_name, macro_contractid, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \
|
2000-02-06 15:21:22 +03:00
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2001-03-12 23:43:02 +03:00
|
|
|
NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info) \
|
2000-02-06 15:21:22 +03:00
|
|
|
{ \
|
|
|
|
nsresult rv; \
|
2000-09-15 03:20:49 +04:00
|
|
|
nsCOMPtr<nsICategoryManager> catman = do_GetService("@mozilla.org/categorymanager;1", &rv); \
|
2000-02-06 15:21:22 +03:00
|
|
|
if (NS_FAILED(rv)) return rv; \
|
2001-06-06 01:25:57 +04:00
|
|
|
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_contractid, PR_TRUE); \
|
2000-02-06 15:21:22 +03:00
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
2000-09-14 03:57:52 +04:00
|
|
|
#define CMDLINEHANDLER2_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_contractid, macro_pretty_name, macro_handles_args, macro_open_window_with_args) \
|
|
|
|
CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_help_text, macro_contractid, macro_pretty_name, macro_handles_args, macro_open_window_with_args)\
|
2000-04-12 00:19:32 +04:00
|
|
|
CMDLINEHANDLER_GETCHROMEURL_IMPL(macro_class,macro_chrome_url)
|
|
|
|
|
2000-09-14 03:57:52 +04:00
|
|
|
#define CMDLINEHANDLER_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_contractid, macro_pretty_name, macro_handles_args, macro_default_args, macro_open_window_with_args) \
|
2000-04-12 00:19:32 +04:00
|
|
|
CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args)\
|
2000-09-14 03:57:52 +04:00
|
|
|
CMDLINEHANDLER2_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_contractid, macro_pretty_name, macro_handles_args, macro_open_window_with_args)
|
2000-02-16 09:22:03 +03:00
|
|
|
|
2000-04-12 00:19:32 +04:00
|
|
|
//Creates a version without the GetChromeUrlForTaskFunction
|
2000-09-14 03:57:52 +04:00
|
|
|
#define CMDLINEHANDLER3_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_help_text, macro_contractid, macro_pretty_name, macro_handles_args, macro_default_args, macro_open_window_with_args)\
|
2000-04-12 00:19:32 +04:00
|
|
|
CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args)\
|
2000-09-14 03:57:52 +04:00
|
|
|
CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_help_text, macro_contractid, macro_pretty_name, macro_handles_args, macro_open_window_with_args)\
|
2000-04-12 00:19:32 +04:00
|
|
|
|
|
|
|
|
2000-02-05 02:07:27 +03:00
|
|
|
%}
|
|
|
|
|
|
|
|
[scriptable, uuid(ae12670a-1dd1-11b2-80cd-82ec93559deb)]
|
2000-02-04 07:33:46 +03:00
|
|
|
interface nsICmdLineHandler : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute string commandLineArgument;
|
|
|
|
readonly attribute string prefNameForStartup;
|
|
|
|
readonly attribute string chromeUrlForTask;
|
|
|
|
readonly attribute string helpText;
|
2000-02-08 04:11:13 +03:00
|
|
|
|
|
|
|
readonly attribute boolean handlesArgs;
|
|
|
|
readonly attribute wstring defaultArgs;
|
2000-02-08 06:12:39 +03:00
|
|
|
readonly attribute boolean openWindowWithArgs;
|
2000-02-04 07:33:46 +03:00
|
|
|
};
|
|
|
|
|