forked from pool/MozillaThunderbird
307 lines
9.9 KiB
Diff
307 lines
9.9 KiB
Diff
Index: widget/public/nsIXRemoteClient.idl
|
|
===================================================================
|
|
RCS file: /cvsroot/mozilla/widget/public/nsIXRemoteClient.idl,v
|
|
retrieving revision 1.2
|
|
diff -u -p -6 -r1.2 nsIXRemoteClient.idl
|
|
--- widget/public/nsIXRemoteClient.idl 8 Apr 2004 14:01:15 -0000 1.2
|
|
+++ widget/public/nsIXRemoteClient.idl 22 Feb 2005 08:18:43 -0000
|
|
@@ -26,13 +26,13 @@
|
|
[scriptable, uuid(0bafc924-1dd2-11b2-8345-b59762ae0df7)]
|
|
interface nsIXRemoteClient : nsISupports
|
|
{
|
|
/**
|
|
* Initializes the client
|
|
*/
|
|
- void init();
|
|
+ void init(in string aDisplay);
|
|
|
|
/**
|
|
* Sends a command to a running instance. If it returns false then
|
|
* there is no running instance.
|
|
*
|
|
* @param aProgram This is the preferred program that we want to use
|
|
Index: widget/src/xremoteclient/XRemoteClient.cpp
|
|
===================================================================
|
|
RCS file: /cvsroot/mozilla/widget/src/xremoteclient/XRemoteClient.cpp,v
|
|
retrieving revision 1.14
|
|
diff -u -p -6 -r1.14 XRemoteClient.cpp
|
|
--- widget/src/xremoteclient/XRemoteClient.cpp 8 Apr 2004 14:01:16 -0000 1.14
|
|
+++ widget/src/xremoteclient/XRemoteClient.cpp 22 Feb 2005 08:19:31 -0000
|
|
@@ -77,20 +77,20 @@ XRemoteClient::~XRemoteClient()
|
|
|
|
#ifndef XREMOTE_STANDALONE
|
|
NS_IMPL_ISUPPORTS1(XRemoteClient, nsIXRemoteClient)
|
|
#endif
|
|
|
|
NS_IMETHODIMP
|
|
-XRemoteClient::Init (void)
|
|
+XRemoteClient::Init (const char *aDisplay)
|
|
{
|
|
PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("XRemoteClient::Init"));
|
|
|
|
if (mInitialized)
|
|
return NS_OK;
|
|
// try to open the display
|
|
- mDisplay = XOpenDisplay(0);
|
|
+ mDisplay = XOpenDisplay(aDisplay);
|
|
if (!mDisplay)
|
|
return NS_ERROR_FAILURE;
|
|
|
|
// get our atoms
|
|
mMozVersionAtom = XInternAtom(mDisplay, MOZILLA_VERSION_PROP, False);
|
|
mMozLockAtom = XInternAtom(mDisplay, MOZILLA_LOCK_PROP, False);
|
|
Index: widget/src/xremoteclient/mozilla-xremote-client.cpp
|
|
===================================================================
|
|
RCS file: /cvsroot/mozilla/widget/src/xremoteclient/mozilla-xremote-client.cpp,v
|
|
retrieving revision 1.3
|
|
diff -u -p -6 -r1.3 mozilla-xremote-client.cpp
|
|
--- widget/src/xremoteclient/mozilla-xremote-client.cpp 8 Apr 2004 14:01:16 -0000 1.3
|
|
+++ widget/src/xremoteclient/mozilla-xremote-client.cpp 22 Feb 2005 08:21:37 -0000
|
|
@@ -37,29 +37,42 @@
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <plgetopt.h>
|
|
#include "XRemoteClient.h"
|
|
+#include <string.h>
|
|
|
|
static void print_usage(void);
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
nsresult rv;
|
|
XRemoteClient client;
|
|
char *browser = 0;
|
|
char *profile = 0;
|
|
char *username = 0;
|
|
char *command = 0;
|
|
+ char *display = 0;
|
|
+ PRInt32 i = 0;
|
|
|
|
if (argc < 2) {
|
|
print_usage();
|
|
return 4;
|
|
}
|
|
|
|
+ for (i=1; i < argc - 1; i++) {
|
|
+ if (strcmp(argv[i], "--display") == 0) {
|
|
+ display = argv[i + 1];
|
|
+ /* Now remove the --display parameters from the command line */
|
|
+ memmove(&argv[i], &argv[i + 2], sizeof(argv[i])*(argc - (i + 2)));
|
|
+ argc -= 2;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
PLOptStatus os;
|
|
PLOptState *opt = PL_CreateOptState(argc, argv, "ha:u:p:");
|
|
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {
|
|
if (PL_OPT_BAD == os) {
|
|
print_usage();
|
|
return 4;
|
|
@@ -83,13 +96,13 @@ int main(int argc, char **argv)
|
|
command = strdup(opt->value);
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
- rv = client.Init();
|
|
+ rv = client.Init(display);
|
|
// failed to connect to the X server
|
|
if (NS_FAILED(rv))
|
|
return 1;
|
|
|
|
// send the command - it doesn't get any easier than this
|
|
PRBool success = PR_FALSE;
|
|
@@ -120,10 +133,11 @@ int main(int argc, char **argv)
|
|
// else, everything is fine.
|
|
return 0;
|
|
}
|
|
|
|
/* static */
|
|
void print_usage(void) {
|
|
- fprintf(stderr, "Usage: mozilla-xremote-client [-a firefox|thunderbird|mozilla|any]\n");
|
|
+ fprintf(stderr, "Usage: mozilla-xremote-client [--display DISPLAY]\n");
|
|
+ fprintf(stderr, " [-a firefox|thunderbird|mozilla|any]\n");
|
|
fprintf(stderr, " [-u <username>]\n");
|
|
fprintf(stderr, " [-p <profile>] COMMAND\n");
|
|
}
|
|
Index: toolkit/xre/nsAppRunner.cpp
|
|
===================================================================
|
|
RCS file: /cvsroot/mozilla/toolkit/xre/nsAppRunner.cpp,v
|
|
retrieving revision 1.27.2.1.4.40
|
|
diff -u -p -6 -r1.27.2.1.4.40 nsAppRunner.cpp
|
|
--- toolkit/xre/nsAppRunner.cpp 2 Nov 2004 23:27:24 -0000 1.27.2.1.4.40
|
|
+++ toolkit/xre/nsAppRunner.cpp 25 Feb 2005 07:49:37 -0000
|
|
@@ -977,13 +977,13 @@ DumpVersion()
|
|
}
|
|
|
|
#ifdef MOZ_ENABLE_XREMOTE
|
|
// use int here instead of a PR type since it will be returned
|
|
// from main - just to keep types consistent
|
|
static int
|
|
-HandleRemoteArgument(const char* remote)
|
|
+HandleRemoteArgument(const char* remote, const char* display)
|
|
{
|
|
nsresult rv;
|
|
ArgResult ar;
|
|
|
|
const char *profile = 0;
|
|
nsCAutoString program(gAppData->appName);
|
|
@@ -1019,13 +1019,13 @@ HandleRemoteArgument(const char* remote)
|
|
{ // scope the comptr so we don't hold on to XPCOM objects beyond shutdown
|
|
// try to get the X remote client
|
|
nsCOMPtr<nsIXRemoteClient> client (do_CreateInstance(NS_XREMOTECLIENT_CONTRACTID));
|
|
NS_ENSURE_TRUE(client, 1);
|
|
|
|
// try to init - connects to the X server and stuff
|
|
- rv = client->Init();
|
|
+ rv = client->Init(display);
|
|
if (NS_FAILED(rv)) {
|
|
PR_fprintf(PR_STDERR, "Error: Failed to connect to X server.\n");
|
|
return 1;
|
|
}
|
|
|
|
nsXPIDLCString response;
|
|
@@ -1521,12 +1521,13 @@ public:
|
|
~ScopedFPHandler() { PR_OS2_UnsetFloatExcpHandler(&excpreg); }
|
|
};
|
|
#endif
|
|
|
|
int xre_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|
{
|
|
+ ArgResult ar;
|
|
nsresult rv;
|
|
NS_TIMELINE_MARK("enter main");
|
|
|
|
#if defined(DEBUG) && defined(XP_WIN32)
|
|
// Disable small heap allocator to get heapwalk() giving us
|
|
// accurate heap numbers. Win2k non-debug does not use small heap allocator.
|
|
@@ -1633,12 +1634,21 @@ int xre_main(int argc, char* argv[], con
|
|
|
|
em->Register();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
+ // save display argument here to reserve it for -remote
|
|
+ // handling (it will be removed from gtk_init)
|
|
+ const char *display = nsnull;
|
|
+ ar = CheckArg("display", &display);
|
|
+ if (ar == ARG_BAD) {
|
|
+ PR_fprintf(PR_STDERR, "Error: argument --display requires a display number\n");
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
|
|
// setup for private colormap. Ideally we'd like to do this
|
|
// in nsAppShell::Create, but we need to get in before gtk
|
|
// has been initialized to make sure everything is running
|
|
// consistently.
|
|
if (CheckArg("install"))
|
|
@@ -1695,19 +1705,19 @@ int xre_main(int argc, char* argv[], con
|
|
}
|
|
|
|
#ifdef MOZ_ENABLE_XREMOTE
|
|
// handle -remote now that xpcom is fired up
|
|
|
|
const char* xremotearg;
|
|
- ArgResult ar = CheckArg("remote", &xremotearg);
|
|
+ ar = CheckArg("remote", &xremotearg);
|
|
if (ar == ARG_BAD) {
|
|
PR_fprintf(PR_STDERR, "Error: -remote requires an argument\n");
|
|
return 1;
|
|
}
|
|
if (ar) {
|
|
- return HandleRemoteArgument(xremotearg);
|
|
+ return HandleRemoteArgument(xremotearg, display);
|
|
}
|
|
#endif
|
|
|
|
nsCOMPtr<nsIProfileLock> profileLock;
|
|
PRBool startOffline = PR_FALSE;
|
|
|
|
Index: xpfe/bootstrap/nsAppRunner.cpp
|
|
===================================================================
|
|
RCS file: /cvsroot/mozilla/xpfe/bootstrap/nsAppRunner.cpp,v
|
|
retrieving revision 1.413.2.1.4.1
|
|
diff -u -p -6 -r1.413.2.1.4.1 nsAppRunner.cpp
|
|
--- xpfe/bootstrap/nsAppRunner.cpp 10 Jun 2004 20:43:39 -0000 1.413.2.1.4.1
|
|
+++ xpfe/bootstrap/nsAppRunner.cpp 28 Feb 2005 09:11:26 -0000
|
|
@@ -1402,13 +1402,13 @@ static nsresult DumpVersion(char *appnam
|
|
return rv;
|
|
}
|
|
|
|
#ifdef MOZ_ENABLE_XREMOTE
|
|
// use int here instead of a PR type since it will be returned
|
|
// from main - just to keep types consistent
|
|
-static int HandleRemoteArguments(int argc, char* argv[], PRBool *aArgUsed)
|
|
+static int HandleRemoteArguments(int argc, char* argv[], char* display, PRBool *aArgUsed)
|
|
{
|
|
int i = 0;
|
|
|
|
const char *remote = 0;
|
|
const char *profile = 0;
|
|
const char *program = 0;
|
|
@@ -1463,13 +1463,13 @@ static int HandleRemoteArguments(int arg
|
|
nsCOMPtr<nsIXRemoteClient> client (do_CreateInstance(NS_XREMOTECLIENT_CONTRACTID));
|
|
if (!client)
|
|
return 1;
|
|
|
|
nsresult rv;
|
|
// try to init - connects to the X server and stuff
|
|
- rv = client->Init();
|
|
+ rv = client->Init(display);
|
|
if (NS_FAILED(rv)) {
|
|
PR_fprintf(PR_STDERR, "Error: Failed to connect to X server.\n");
|
|
return 1;
|
|
}
|
|
|
|
// Make sure to set a username if possible
|
|
@@ -1656,12 +1656,28 @@ int main(int argc, char* argv[])
|
|
fprintf(stderr, "%s: XInitThreads failure.", argv[0]);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
#endif /* MOZ_X11 */
|
|
|
|
+ // save --display parameter for possible -remote handling
|
|
+ // (it will be lost after gtk_init)
|
|
+ char *display = 0;
|
|
+ char *param = 0;
|
|
+ for (int i=1; i<argc; i++) {
|
|
+ if ((PL_strncasecmp(argv[i], "-display", 7) == 0)
|
|
+ || (PL_strncasecmp(argv[i], "--display", 8) == 0)) {
|
|
+ if ((param = PL_strchr(argv[i], '=')) != NULL)
|
|
+ display = PL_strdup(++param);
|
|
+ else
|
|
+ display = PL_strdup(argv[i + 1]);
|
|
+ if (! *display)
|
|
+ display = nsnull;
|
|
+ }
|
|
+ }
|
|
+
|
|
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
|
|
// setup for private colormap. Ideally we'd like to do this
|
|
// in nsAppShell::Create, but we need to get in before gtk
|
|
// has been initialized to make sure everything is running
|
|
// consistently.
|
|
for (int i=1; i<argc; i++)
|
|
@@ -1749,13 +1765,13 @@ int main(int argc, char* argv[])
|
|
#ifdef MOZ_ENABLE_XREMOTE
|
|
// handle -remote now that xpcom is fired up
|
|
int remoterv;
|
|
PRBool argused = PR_FALSE;
|
|
// argused will be true if someone tried to use a -remote flag. We
|
|
// always exit in that case.
|
|
- remoterv = HandleRemoteArguments(argc, argv, &argused);
|
|
+ remoterv = HandleRemoteArguments(argc, argv, display, &argused);
|
|
|
|
if (argused) {
|
|
#ifdef XPCOM_GLUE
|
|
GRE_Shutdown();
|
|
#else
|
|
NS_ShutdownXPCOM(nsnull);
|