Google グループは Usenet の新規の投稿と購読のサポートを終了しました。過去のコンテンツは引き続き閲覧できます。
Dismiss

nsIProcess on MAC/Darwin

閲覧: 49 回
最初の未読メッセージにスキップ

gNeandr

未読、
2009/06/30 8:08:302009/06/30
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

未読、
2009/06/30 8:13:532009/06/30
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

未読、
2009/06/30 11:19:502009/06/30
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

未読、
2009/06/30 11:44:142009/06/30
To:
They are just directories. mFile.append("Contents");
mFile.append("MacOS"); mFile.append(exename)

gNeandr

未読、
2009/06/30 12:08:082009/06/30
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

未読、
2009/06/30 12:14:052009/06/30
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

未読、
2009/06/30 12:21:152009/06/30
To:

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

Benjamin Smedberg

未読、
2009/06/30 12:23:462009/06/30
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

未読、
2009/06/30 12:36:452009/06/30
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

未読、
2009/06/30 12:48:432009/06/30
To:
THANKS!!!!

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


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

gNeandr

未読、
2009/11/09 19:46:052009/11/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

未読、
2009/11/11 9:11:172009/11/11
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

未読、
2009/11/11 15:19:202009/11/11
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 件