Closed Bug 280725 Opened 20 years ago Closed 20 years ago

Use generic/automatic remoting in xremote


(Toolkit :: Startup and Profile System, defect)

Not set





(Reporter: benjamin, Assigned: benjamin)




(3 files, 2 obsolete files)

This is a bug, following up the command-lines rework I did for the toolkit. The
goal is to have xremote automatically remote a command line the same way windows
does. The "-remote" flag would still be supported as a backwards-compatibility

I originally thought I didn't have time for this in 1.8, but with the extra
6-week beta I think I do. I need to land early to get enough testing time.
This patch appears to work properly on suite and firefox... I'm building tbird
now. The general outline is thus:

The widget code itself doesn't need to know about xremote any more. The xremote
client code still lives in widget/src/xremoteclient, but it is built as part of
tier 50.

There is a new "kind" of xremote command, which uses a different xwindow
property, and remotes an entire command line with working directory. It is only
available for toolkit apps. All of the xremote hacks in are no
longer needed. The xremote version number is bumped from "5.0" to "5.1" for
toolkit apps.

The xremote glue code is unforked between gtk/gtk2, and lives in
toolkit/components/remote. It is built by all apps (including seamonkey).

The old style of xremote requests are still supported by all apps, but the
handling of these requests is pushed into app-specific code. For the toolkit
apps, this is the nsICommandLineHandlers. For the suite, this code lives in
xpfe/components/xremote (the nsIXRemoteService interface has been renamed
Attachment #176285 - Flags: first-review?(blizzard)
Attached patch Forgot xpfe/bootstrap (obsolete) — Splinter Review
I forgot xpfe/bootstrap in the first patch.
Did you test connecting to a mozilla application running in a locale different
from the locale in which xremote command is invoked? See bug 229755
re: multiple locales, no I didn't, and I'm inclined to WONTFIX that bug.
Multiple users/machines xremoting to one display is not a use-case I think we
should worry about.
That bug is  primarily about  passing a non-ASCII command line between a client
and a server (so that bug has to be fixed at least for a single locale/machine
case. perhaps, you fixed it with your patch), but a client and a server can be
on differen machines/locales so that multiple locales/machines issue come out of
that   bug. 
would it be possible to pass a wide string, or an UTF-8 string, over X-Remote,
irrespective of what the locale is?
For the toolkit my patch treats all xremote strings as native charset and runs
NS_CopyNativeToUnicode on them. It doesn't touch seamonkey's (broken) behavior.
re comment #6:
Yes. see my patch for bug 229755. That patch works only where UTF8_STRING is
supported (i.e. where XFree86 or recent a version of implementations is
used: virtually all Linux/*BSD/Mac OS X). I'm not sure what AIX/Solaris/HPUX etc
have these days. It's also possible to make it work where UTF8_STRING is not
supported although it's a bit more complicated (but not as complicated as what I
wrote in bug 229755).
(In reply to comment #7)
> For the toolkit my patch treats all xremote strings as native charset and runs
> NS_CopyNativeToUnicode on them. It doesn't touch seamonkey's (broken) behavior.

the approach described in comment 8 does sound like a better way to do this to me...
*** Bug 263868 has been marked as a duplicate of this bug. ***
Attachment #176285 - Flags: first-review?(blizzard) → first-review?(caillon)
Comment on attachment 176285 [details] [diff] [review]
xremote support for generic commandline remoting, rev. 1

>Index: mail/components/nsMailDefaultHandler.js

>+function mayOpenURI(uri) {
>+  var ext = Components.classes[";1"]
>+    .getService(Components.interfaces.nsIExternalProtocolService);
>+  return ext.isExposedProtocol(uri.scheme);
>+function openURI(uri)

Nit: pick a style for function declarations (brace on same line or not).

>@@ -57,16 +91,90 @@ var nsMailDefaultHandler = {
>     throw Components.results.NS_ERROR_NO_INTERFACE;
>   },
>   /* nsICommandLineHandler */
>   handle : function mdh_handle(cmdLine) {
>     var uri;
>+    try {
>+      var remoteCommand = cmdLine.handleFlagWithParam("remote", true);
>+    }
>+    catch (e) {
>+      throw NS_ERROR_ABORT;

Is NS_ERROR_ABORT guaranteed defined here?

>Index: widget/src/xremoteclient/XRemoteClient.cpp

>@@ -513,16 +569,20 @@ XRemoteClient::FindBestWindow(const char
>                 XFree(data_return);
>                 continue;
>             }
>             XFree(data_return);
>         }
>     }
>+    // Check to see if the window supports the new command-line passing
>+    // protocol, if that is requested.

Nit: one too many blank lines

>@@ -566,134 +626,213 @@ XRemoteClient::FreeLock(Window aWindow)

>+/* like strcpy, but return the char after the final null */
>+static char*
>+estrcpy(char* s, char* d)
>+  while (*s)
>+    *d++ = *s++;
>+  *d++ = '\0';
>+  return d + 1;

Don't you want |return d|?  The post-increment takes care of the +1 for you.


>Index: widget/src/xremoteclient/nsRemoteClient.h
>RCS file: widget/src/xremoteclient/nsRemoteClient.h
>diff -N widget/src/xremoteclient/nsRemoteClient.h
>--- /dev/null	1 Jan 1970 00:00:00 -0000
>+++ widget/src/xremoteclient/nsRemoteClient.h	4 Mar 2005 15:25:18 -0000
>@@ -0,0 +1,104 @@
>+/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
>+/* vim:expandtab:shiftwidth=4:tabstop=4:
>+ */
>+/* ***** BEGIN LICENSE BLOCK *****
>+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
>+ *
>+ * The contents of this file are subject to the Mozilla 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
>+ *
>+ *
>+ * 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.
>+ *
>+ * The Original Code is code.
>+ *
>+ * The Initial Developer of the Original Code is
>+ * Christopher Blizzard. Portions created Christopher Blizzard are Copyright (C) Christopher Blizzard.  All Rights Reserved.
>+ * Portions created by the Initial Developer are Copyright (C) 2001
>+ * the Initial Developer. All Rights Reserved.

Wanna fix this?

Same for:

>Index: toolkit/components/remote/nsGTKRemoteService.cpp

>+#ifdef MOZ_XUL_APP

Does it make sense to just define and get this atom even ifndef MOZ_XUL_APP? 
We won't use it, but getting it isn't going to waste any resources now that its
all retrieved one on trip to the xserver, and it will reduce the amount of
#ifdef-age.  Your call I guess.

>Index: xpfe/components/xremote/src/XRemoteService.cpp
>@@ -1021,27 +700,27 @@ XRemoteService::XfeDoCommand(nsCString &
>   // pass the second argument as parameter
>   arg->SetData(NS_ConvertUTF8toUCS2(restArgument));
>   // someone requested opening mail/news
>   if (aArgument.LowerCaseEqualsLiteral("openinbox")) {
>     // check to see if it's already running
>-    nsCOMPtr<nsIDOMWindowInternal> domWindow;
>+    nsCOMPtr<nsIDOMWindowInternal> aWindow;

Hmm, not sure I like this renaming.  Traditionally aFoo gets applied only to
items passed into the current function directly as an argument.

Think the rest is fine, but it would really be good to get a second set of eyes
on this code (blizzard ideally, but...)
Attachment #176285 - Flags: first-review?(caillon) → first-review+
Bryner, can you look at this today? I would like to checkin before the weekend
to get a little time to squash any regressions before the freeze next week.
Attachment #176285 - Attachment is obsolete: true
Attachment #176288 - Attachment is obsolete: true
Attachment #179290 - Flags: second-review?(bryner)
Comment on attachment 179290 [details] [diff] [review]
xremote support for generic commandline remoting, rev. 1.1

Looks good.
Attachment #179290 - Flags: second-review?(bryner) → second-review+
Fixed, with two bustage changes: first, I didn't add widget/src/xremoteclient to
the root / (it is part of tier_50_dirs now). Second, I didn't add any
EXTRA_DSO_LDOPTS to toolkit/components/remote/, because it built and
worked for me without them. But not for btek, so I added them. I also added
installer packaging for the new files.
Closed: 20 years ago
Resolution: --- → FIXED
Checked in AIX bustage fix (with r+sr=tor).

Checking in nsGTKRemoteService.h;
/cvsroot/mozilla/toolkit/components/remote/nsGTKRemoteService.h,v  <-- 
new revision: 1.2; previous revision: 1.1
Hmm, something is wrong after the checkins (while trying to compile sunbird):

gmake[6]: Entering directory
ccache g++ -o XRemoteService.o -c -I../../../../dist/include/system_wrappers
-include ../../../../config/gcc_hidden.h -DOSTYPE=\"Linux2.6.10-1\"
-DOSARCH=\"Linux\" -DBUILD_ID=0000000000  -I../../../../dist/include/xpcom
-I../../../../dist/include/string -I../../../../dist/include/dom
-I../../../../dist/include/widget -I../../../../dist/include/uriloader
-I../../../../dist/include/docshell -I../../../../dist/include/pref
-I../../../../dist/include/windowwatcher -I../../../../dist/include/necko
-I../../../../dist/include/appshell -I../../../../dist/include/toolkitcomps
-I../../../../dist/include/appcomps -I../../../../dist/include/exthandler
-I../../../../dist/include/profile -I../../../../dist/include/appcomps
-I../../../../dist/include -I../../../../dist/include/nspr   
-I/usr/X11R6/include   -fPIC  -I/usr/X11R6/include -fno-rtti -fno-exceptions
-Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic
-fshort-wchar -pthread  -DDEBUG -D_DEBUG -DDEBUG_admin -DTRACING -g -fno-inline
 -I/usr/X11R6/include -DMOZILLA_CLIENT -include ../../../../mozilla-config.h
-Wp,-MD,.deps/XRemoteService.pp XRemoteService.cpp
XRemoteService.cpp:73:31: nsICmdLineHandler.h: No such file or directory
XRemoteService.cpp: In member function `nsresult
XRemoteService::XfeDoCommand(nsCString&, nsIDOMWindow*)':
XRemoteService.cpp:738: error: `nsICmdLineHandler' undeclared (first use this
XRemoteService.cpp:738: error: (Each undeclared identifier is reported only once
for each function it appears in.)
XRemoteService.cpp:738: error: template argument 1 is invalid
XRemoteService.cpp:738: error: invalid type in declaration before '=' token
XRemoteService.cpp:739: error: cannot convert `const nsGetServiceByContractID'
to `int' in initialization
XRemoteService.cpp:745: error: base operand of `->' is not a pointer
XRemoteService.cpp:748: error: base operand of `->' is not a pointer
gmake[6]: *** [XRemoteService.o] Error 1
gmake[6]: Leaving directory
Reopening for libxul fixup, and I can patch Sunbird if they haven't already.
Resolution: FIXED → ---
Attachment #179972 - Flags: first-review?(darin)
Attachment #179972 - Flags: approval1.8b2?
Attachment #179972 - Flags: first-review?(darin) → first-review+
Comment on attachment 179972 [details] [diff] [review]
Integrate new component in libxul, rev. 1

Attachment #179972 - Flags: approval1.8b2? → approval1.8b2+
Landed "Integrate new component in libxul" patch on trunk.

Does that make this bug fixed?
Closed: 20 years ago20 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.8beta2
Attached patch fix sunbirdSplinter Review
sunbird is still broken. This patch fixes it for me.
Attachment #180158 - Flags: first-review?(benjamin)
Attachment #180158 - Flags: first-review?(benjamin)
Attachment #180158 - Flags: first-review+
Attachment #180158 - Flags: approval1.8b2?
Attachment #180158 - Flags: approval1.8b2? → approval1.8b2+
Comment on attachment 180158 [details] [diff] [review]
fix sunbird

patch checked in.
*** Bug 297618 has been marked as a duplicate of this bug. ***
Could this checkin be the reason why firefox will no longer remotely open urls
with commas in them, or handle quoted urls?  The timing seems about right. For

firefox -remote

now chops off everything after the "0,", where it used to work. Quoting the url
inside the parens doesn't help; it gives "Error: Failed to send command: 500
command not parseable", where quoting used to work (and was useful when using
additional arguments such as ,new-tab). This breaks -remote on a lot of common urls.
Akkana, it is likely that the usage you describe was broken by this patch.
Please file a followup bug with a list of old usages that no longer work, and
I'll take a look or find someone to do so.
Filed bug 298960.
Flags: in-testsuite?
Blocks: 407800
Component: XRE Startup → Startup and Profile System
QA Contact: nobody → startup
You need to log in before you can comment on or make changes to this bug.