Use generic/automatic remoting in xremote

RESOLVED FIXED in mozilla1.8beta2

Status

()

Toolkit
Startup and Profile System
RESOLVED FIXED
13 years ago
9 years ago

People

(Reporter: bsmedberg, Assigned: bsmedberg)

Tracking

unspecified
mozilla1.8beta2
x86
Linux
Points:
---
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 2 obsolete attachments)

(Assignee)

Description

13 years ago
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
layer.

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.
(Assignee)

Comment 1

13 years ago
Created attachment 176285 [details] [diff] [review]
xremote support for generic commandline remoting, rev. 1

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 mozilla.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
nsISuiteRemoteService).
Attachment #176285 - Flags: first-review?(blizzard)
(Assignee)

Comment 2

13 years ago
Created attachment 176288 [details] [diff] [review]
Forgot xpfe/bootstrap

I forgot xpfe/bootstrap in the first patch.

Comment 3

13 years ago
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
(Assignee)

Comment 4

13 years ago
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.

Comment 5

13 years ago
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?
(Assignee)

Comment 7

13 years ago
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.

Comment 8

13 years ago
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 X.org 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...
(Assignee)

Comment 10

13 years ago
*** 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["@mozilla.org/uriloader/external-protocol-service;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
>+ * http://www.mozilla.org/MPL/
>+ *
>+ * 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 mozilla.org 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:
toolkit/components/remote/Makefile.in
toolkit/components/remote/nsGTKRemoteService.cpp
toolkit/components/remote/nsGTKRemoteService.h
xpfe/components/xremote/public/nsISuiteRemoteService.idl



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

>+#define MOZILLA_VERSION_PROP   "_MOZILLA_VERSION"
>+#define MOZILLA_LOCK_PROP      "_MOZILLA_LOCK"
>+#define MOZILLA_COMMAND_PROP   "_MOZILLA_COMMAND"
>+#define MOZILLA_RESPONSE_PROP  "_MOZILLA_RESPONSE"
>+#define MOZILLA_USER_PROP      "_MOZILLA_USER"
>+#define MOZILLA_PROFILE_PROP   "_MOZILLA_PROFILE"
>+#define MOZILLA_PROGRAM_PROP   "_MOZILLA_PROGRAM"
>+
>+#ifdef MOZ_XUL_APP
>+#define MOZILLA_COMMANDLINE_PROP "_MOZILLA_COMMANDLINE"
>+#endif
>+

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+
(Assignee)

Comment 12

13 years ago
Created attachment 179290 [details] [diff] [review]
xremote support for generic commandline remoting, rev. 1.1

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+
(Assignee)

Comment 14

13 years ago
Fixed, with two bustage changes: first, I didn't add widget/src/xremoteclient to
the root /Makefile.in (it is part of tier_50_dirs now). Second, I didn't add any
EXTRA_DSO_LDOPTS to toolkit/components/remote/Makefile.in, 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.
Status: NEW → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → FIXED

Comment 15

13 years ago
Checked in AIX bustage fix (with r+sr=tor).

Checking in nsGTKRemoteService.h;
/cvsroot/mozilla/toolkit/components/remote/nsGTKRemoteService.h,v  <-- 
nsGTKRemoteService.h
new revision: 1.2; previous revision: 1.1
done

Comment 16

13 years ago
Hmm, something is wrong after the checkins (while trying to compile sunbird):

gmake[6]: Entering directory
`/home/admin/mozilla-head/mozilla/xpfe/components/xremote/src'
XRemoteService.cpp
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
function)
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
`/home/admin/mozilla-head/mozilla/xpfe/components/xremote/src'
(Assignee)

Comment 17

13 years ago
Reopening for libxul fixup, and I can patch Sunbird if they haven't already.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
(Assignee)

Comment 18

13 years ago
Created attachment 179972 [details] [diff] [review]
Integrate new component in libxul, rev. 1
Attachment #179972 - Flags: first-review?(darin)
Attachment #179972 - Flags: approval1.8b2?

Updated

13 years ago
Attachment #179972 - Flags: first-review?(darin) → first-review+

Comment 19

13 years ago
Comment on attachment 179972 [details] [diff] [review]
Integrate new component in libxul, rev. 1

a=asa
Attachment #179972 - Flags: approval1.8b2? → approval1.8b2+

Comment 20

13 years ago
Landed "Integrate new component in libxul" patch on trunk.

Does that make this bug fixed?
(Assignee)

Updated

13 years ago
Status: REOPENED → RESOLVED
Last Resolved: 13 years ago13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.8beta2
Created attachment 180158 [details] [diff] [review]
fix sunbird

sunbird is still broken. This patch fixes it for me.
Attachment #180158 - Flags: first-review?(benjamin)
(Assignee)

Updated

13 years ago
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.
(Assignee)

Comment 23

12 years ago
*** Bug 297618 has been marked as a duplicate of this bug. ***

Comment 24

12 years ago
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
instance,

firefox -remote
'openURL(http://www.news.com.au/story/0,10117,15739502-13762,00.html)'

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.
(Assignee)

Comment 25

12 years ago
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.

Comment 26

12 years ago
Filed bug 298960.
(Assignee)

Updated

11 years ago
Flags: in-testsuite?
Blocks: 407800

Updated

9 years ago
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.