mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
I hate copy and pasted code. write two macros to do all the work for me.
r=alecf
This commit is contained in:
parent
efc7af144c
commit
c00837ec56
@ -1270,77 +1270,4 @@ NS_IMETHODIMP nsAddressBook::ImportAddressBook()
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAddressBook::GetCommandLineArgument(char **aCommandLineArgument)
|
||||
{
|
||||
if (!aCommandLineArgument) return NS_ERROR_FAILURE;
|
||||
|
||||
*aCommandLineArgument = PL_strdup("-addressbook");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAddressBook::GetPrefNameForStartup(char **aPrefNameForStartup)
|
||||
{
|
||||
if (!aPrefNameForStartup) return NS_ERROR_FAILURE;
|
||||
|
||||
*aPrefNameForStartup = PL_strdup("general.startup.addressbook");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAddressBook::GetChromeUrlForTask(char **aChromeUrlForTask)
|
||||
{
|
||||
if (!aChromeUrlForTask) return NS_ERROR_FAILURE;
|
||||
|
||||
*aChromeUrlForTask = PL_strdup("chrome://addressbook/content/");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAddressBook::GetHelpText(char **aHelpText)
|
||||
{
|
||||
if (!aHelpText) return NS_ERROR_FAILURE;
|
||||
|
||||
*aHelpText = PL_strdup("Start with the addressbook.");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsAddressBook::RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType)
|
||||
|
||||
{
|
||||
// Register ourselves into the COMMAND_LINE_ARGUMENT_HANDLERS
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, NS_ADDRESSBOOK_PROGID, "Addressbook Cmd Line Handler", PR_TRUE, PR_TRUE, getter_Copies(prevEntry));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsAddressBook::UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, NS_ADDRESSBOOK_PROGID, PR_TRUE, getter_Copies(prevEntry));
|
||||
|
||||
// Return value is not used from this function.
|
||||
return NS_OK;
|
||||
}
|
||||
CMDLINEHANDLER_IMPL(nsAddressBook,"-addressbook","general.startup.addressbook","chrome://addressbook/content/","Start with the addressbook.",NS_ADDRESSBOOK_PROGID,"Addressbook Cmd Line Handler")
|
||||
|
@ -49,15 +49,8 @@ public:
|
||||
NS_DECL_NSIADDRESSBOOK
|
||||
NS_DECL_NSICMDLINEHANDLER
|
||||
|
||||
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType);
|
||||
|
||||
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation);
|
||||
|
||||
CMDLINEHANDLER_REGISTERPROC_DECLS
|
||||
|
||||
protected:
|
||||
nsresult DoCommand(nsIRDFCompositeDataSource *db, char * command, nsISupportsArray *srcArray,
|
||||
nsISupportsArray *arguments);
|
||||
|
@ -1147,77 +1147,4 @@ nsNntpService::GetDefaultCopiesAndFoldersPrefsToServer(PRBool *aDefaultCopiesAnd
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::GetCommandLineArgument(char **aCommandLineArgument)
|
||||
{
|
||||
if (!aCommandLineArgument) return NS_ERROR_FAILURE;
|
||||
|
||||
*aCommandLineArgument = PL_strdup("-news");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::GetPrefNameForStartup(char **aPrefNameForStartup)
|
||||
{
|
||||
if (!aPrefNameForStartup) return NS_ERROR_FAILURE;
|
||||
|
||||
*aPrefNameForStartup = PL_strdup("general.startup.news");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::GetChromeUrlForTask(char **aChromeUrlForTask)
|
||||
{
|
||||
if (!aChromeUrlForTask) return NS_ERROR_FAILURE;
|
||||
|
||||
*aChromeUrlForTask = PL_strdup("chrome://messenger/content/");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::GetHelpText(char **aHelpText)
|
||||
{
|
||||
if (!aHelpText) return NS_ERROR_FAILURE;
|
||||
|
||||
*aHelpText = PL_strdup("Start with news window.");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsNntpService::RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType)
|
||||
|
||||
{
|
||||
// Register ourselves into the COMMAND_LINE_ARGUMENT_HANDLERS
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, NS_NNTPSERVICE_PROGID, "News Cmd Line Handler", PR_TRUE, PR_TRUE, getter_Copies(prevEntry));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsNntpService::UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
nsXPIDLCString prevEntry;
|
||||
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, NS_NNTPSERVICE_PROGID, PR_TRUE, getter_Copies(prevEntry));
|
||||
|
||||
// Return value is not used from this function.
|
||||
return NS_OK;
|
||||
}
|
||||
CMDLINEHANDLER_IMPL(nsNntpService,"-news","general.startup.news","chrome://messenger/content/","Start with news window.",NS_NNTPSERVICE_PROGID,"News Cmd Line Handler")
|
||||
|
@ -56,14 +56,7 @@ public:
|
||||
nsNntpService();
|
||||
virtual ~nsNntpService();
|
||||
|
||||
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType);
|
||||
|
||||
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation);
|
||||
CMDLINEHANDLER_REGISTERPROC_DECLS
|
||||
|
||||
protected:
|
||||
nsresult ConvertNewsMessageURI2NewsURI(const char *messageURI,
|
||||
|
@ -25,7 +25,63 @@
|
||||
|
||||
|
||||
%{C++
|
||||
|
||||
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#define CMDLINEHANDLER_REGISTERPROC_DECLS \
|
||||
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType); \
|
||||
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation);
|
||||
|
||||
#define CMDLINEHANDLER_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_progid, macro_pretty_name) \
|
||||
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::GetChromeUrlForTask(char **aChromeUrlForTask) \
|
||||
{ \
|
||||
if (!aChromeUrlForTask) return NS_ERROR_FAILURE; \
|
||||
*aChromeUrlForTask = PL_strdup(macro_chrome_url); \
|
||||
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; \
|
||||
} \
|
||||
NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType) \
|
||||
{ \
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \
|
||||
if (NS_FAILED(rv)) return rv; \
|
||||
nsXPIDLCString prevEntry; \
|
||||
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_progid, macro_pretty_name, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \
|
||||
{ \
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \
|
||||
if (NS_FAILED(rv)) return rv; \
|
||||
nsXPIDLCString prevEntry; \
|
||||
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_progid, PR_TRUE, getter_Copies(prevEntry)); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
[scriptable, uuid(ae12670a-1dd1-11b2-80cd-82ec93559deb)]
|
||||
|
@ -25,7 +25,63 @@
|
||||
|
||||
|
||||
%{C++
|
||||
|
||||
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#define CMDLINEHANDLER_REGISTERPROC_DECLS \
|
||||
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType); \
|
||||
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation);
|
||||
|
||||
#define CMDLINEHANDLER_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_progid, macro_pretty_name) \
|
||||
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::GetChromeUrlForTask(char **aChromeUrlForTask) \
|
||||
{ \
|
||||
if (!aChromeUrlForTask) return NS_ERROR_FAILURE; \
|
||||
*aChromeUrlForTask = PL_strdup(macro_chrome_url); \
|
||||
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; \
|
||||
} \
|
||||
NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType) \
|
||||
{ \
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \
|
||||
if (NS_FAILED(rv)) return rv; \
|
||||
nsXPIDLCString prevEntry; \
|
||||
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_progid, macro_pretty_name, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \
|
||||
{ \
|
||||
nsresult rv; \
|
||||
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \
|
||||
if (NS_FAILED(rv)) return rv; \
|
||||
nsXPIDLCString prevEntry; \
|
||||
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_progid, PR_TRUE, getter_Copies(prevEntry)); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
[scriptable, uuid(ae12670a-1dd1-11b2-80cd-82ec93559deb)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user