Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nsIProcess on MAC/Darwin

49 views
Skip to first unread message

gNeandr

unread,
Jun 30, 2009, 8:08:30 AM6/30/09
to
With an extension I need to run another program (eg. Thunderbird from FX environment).

For that I'm using:

const go4Process = Components.classes["@mozilla.org/process/util;1"]
                            .createInstance(Components.interfaces.nsIProcess);
      go4Process.init(app);
      go4Process.run(false, new Array( "-parameter"), 1);


where app is an object initialized with app.initWithPath(fileName) for the application location.


That works fine with WIN platform, but fails with MAC/Darwin, throwing at go4Process.init(app)  :
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIProcess.init]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://etc...

Any help/pointers ??

Dave Townsend

unread,
Jun 30, 2009, 8:13:53 AM6/30/09
to

If fileName must point to an executable, likely you have given it the
path to an app bundle. You must descend into this
(Content/MacOS/<exename>) to get something you can give to nsIProcess.

gNeandr

unread,
Jun 30, 2009, 11:19:50 AM6/30/09
to
Thanks Dave,

also I need to ask back about (Content/MacOS/<exename>)

The following fails:
var mFile =
Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("LocApp", Components.interfaces.nsIFile);

mFile.append({appName} + ".app");
go4Process.init(mFile);

But the mFile.path also has only:
/Applications/{appName }.app

But don't find any pointer how to set/get that Content/MacOS/


Hope you can help here. Maybe a code snippet anywhere??

G�nter

Dave Townsend

unread,
Jun 30, 2009, 11:44:14 AM6/30/09
to
They are just directories. mFile.append("Contents");
mFile.append("MacOS"); mFile.append(exename)

gNeandr

unread,
Jun 30, 2009, 12:08:08 PM6/30/09
to
Hm,

now I have:

var mFile = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("LocApp", Components.interfaces.nsIFile);

mFile.append("Contents");
mFile.append("MacOS");

mFile.append(appName + ".app";);
go4Process.init(mFile);

and that gives with mFile.path:
/Applications/Contents/MacOS/appName.app

and the 'go4Process.init' fails.

The go4Process is:

const go4Process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);

... just to be sure I'm on:.

Darwin(x86-gcc3)
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.11)
Gecko/2009060214

Dave Townsend

unread,
Jun 30, 2009, 12:14:05 PM6/30/09
to
It is extremely unlikely that the executable name inside the app bundle
is appName.app. I suggest you look to see what it is.

gNeandr

unread,
Jun 30, 2009, 12:21:15 PM6/30/09
to

Sure, it's "Postbox.app" ... and the location is "/Applications" .. as
shown with Finder informations

Benjamin Smedberg

unread,
Jun 30, 2009, 12:23:46 PM6/30/09
to
On 6/30/09 12:21 PM, gNeandr wrote:
>
> Sure, it's "Postbox.app" ... and the location is "/Applications" .. as
> shown with Finder informations

No. The *bundle* name is Postbox.app. The binary inside is going to be
something like /Applcations/Postbox.app/Contents/MacOS/PostBox

You can use 'Show Package Contents' in the finder context menu to see what's
inside a bundle.

--BDS

gNeandr

unread,
Jun 30, 2009, 12:36:45 PM6/30/09
to
Ok,
all very new to be, sorry.

But using the context menu I find something like:

/Applications/Postbox.app/Contents/MacOS/PostBox/postbox.bin

which is said a "excecutable Unix file".

I'll go for that and hope it does ;-)

Thanks for the moment!!!

gNeandr

unread,
Jun 30, 2009, 12:48:43 PM6/30/09
to
THANKS!!!!

It does the job.
:-) :-) G�nter :-) :-)


[30.06.2009 18:23] �Benjamin Smedberg� wrote:

gNeandr

unread,
Nov 9, 2009, 7:46:05 PM11/9/09
to
Hi Ben,

coming back to this .. about starting an application from within a MOZ app.
This was mend for Postbox on MAC/OSX and basically it did it's job.

Here comes the problem:
To enable Thunderbird/Postbox (TB/PB) to process some special cmdline
handling we have used the concept outlined at
https://developer.mozilla.org/en/Chrome/Command_Line

It's working, does it job with WINDOWS and LINUX(Ubuntu) and "partly" on
MAC/OSX.

WIN/LX vs OSX is this:
If TB/PB has not been started before, the cmdline handler works well,
if it's already started TB/PB gives an error dialog with:

restartMessageNoUnlockerMac=A copy of %S is already open. Only one copy
of %S can be open at a time.

The idea was using special command line parameters so we can pass
'action with parameters' from Firefox to TB/PB for searching messages,
sending and composing. That should be possible also if a copy of TB/PB
is running already.

Because it works well with Windows and Linux, the open question is: why
doesn't it work with MAC/OSX .. or better how to solve this one?

G�nter

[30.06.2009 18:23] �Benjamin Smedberg� wrote:

Benjamin Smedberg

unread,
Nov 11, 2009, 9:11:17 AM11/11/09
to
On 11/9/09 7:46 PM, gNeandr wrote:

> WIN/LX vs OSX is this:
> If TB/PB has not been started before, the cmdline handler works well,
> if it's already started TB/PB gives an error dialog with:
>
> restartMessageNoUnlockerMac=A copy of %S is already open. Only one copy
> of %S can be open at a time.
>
> The idea was using special command line parameters so we can pass
> 'action with parameters' from Firefox to TB/PB for searching messages,
> sending and composing. That should be possible also if a copy of TB/PB
> is running already.

It is not. On Windows and Linux, if you launch a new binary of the
application we will automatically remote it to the existing instance. On
Mac, the system does that for us automatically with the dock UI and such, so
there is no explicit remoting code in Mozilla. The solution to your problem
is to send some sort of Apple Event to the running instance, although this
is not a very well-understood codepath, so I don't have a lot of good
pointers how to do arbitrary processing based on Apple Events.

--BDS


gNeandr

unread,
Nov 11, 2009, 3:19:20 PM11/11/09
to
Hope there are some MAC/OSX specialists around to solve that problem.
Not only our situation requires to 'pass actions/paramters' to a running instance (eg. thunderbird-bin) but I think others as well.

How about issuing a string like
    "thunderbird -mail mailto:m...@isp.net?subject=hi"  or 
    "thunderbird -compose "to=f...@nowhere.net"

as outlined with https://developer.mozilla.org/en/Command_Line_Options#options ?

Günter

0 new messages