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

Need to get the plugin's URL somehow???

165 views
Skip to first unread message

Robert Platt

unread,
Oct 11, 2005, 9:42:15 PM10/11/05
to

I know about the "NPN_GetValue" function, but it does not provide the
plugin's URL.

We need to get the location of the plugin on a website so that it can
download relative files.

It is crazy that such a simple thing is so difficult to do???

This feature need to be added to the "NPN_GetValue" function and then
documented.

Cheers very much,

Robert Platt
www.navgen.com


Robert Platt

unread,
Oct 13, 2005, 2:36:21 PM10/13/05
to

I have found the solution myself by doing some extensive searching.

Here was the first lead:

http://www.mail-archive.com/mozill...@mozilla.org/msg05838.html

Which takes us to this page:

http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess

Then from the main plugin page:

http://www.mozilla.org/projects/plugins/

We have the following bullet point:

npruntime (new scriptability API) Sample Plugin Source - How-To for Visual
Studio

Follow the instructions on the how-to to get the sample to work:

http://www.mozilla.org/projects/plugins/npruntime-sample-in-visual-studio.html

Now finally to get the plugin's URL use the following code:

// Get the window object.
NPN_GetValue( m_pNPInstance, NPNVWindowNPObject, &sWindowObj );
// Create a "location" identifier.
NPIdentifier identifier = NPN_GetStringIdentifier( "location" );
// Declare a local variant value.
NPVariant variantValue;
// Get the location property from the window object (which is another
object).
bool b1 = NPN_GetProperty( m_pNPInstance, sWindowObj, identifier,
&variantValue );
// Get a pointer to the "location" object.
NPObject *locationObj = variantValue.value.objectValue;
// Create a "href" identifier.
identifier = NPN_GetStringIdentifier( "href" );
// Get the location property from the location object.
bool b2 = NPN_GetProperty( m_pNPInstance, locationObj, identifier,
&variantValue );

This code is just a rough example. Remember to release any references after
using them.

Therefore I hope I have solved this problem for others as well as I have
done for myself.

This functionality is only available in the newer API which is not fully
documented, therefore was hard to find.

Good luck everyone :)

Robert

"Robert Platt" <ra...@btinternet.com> wrote in message
news:dihpj3$n2...@ripley.aoltw.net...

Christian Biesinger

unread,
Oct 13, 2005, 5:27:19 PM10/13/05
to Robert Platt
[posted + mailed]

Robert Platt wrote:
> I know about the "NPN_GetValue" function, but it does not provide the
> plugin's URL.

Why is the src/data attribute in the array passed to NPP_New not
sufficient? Wouldn't you want to resolve relative URLS as relative to
the plugin URL, not relative to the page url?

Robert Platt

unread,
Oct 14, 2005, 12:33:50 AM10/14/05
to
Hi Christian,

Yes, good point, there are so many ways to go about this, but I decided that
my base URL for the plugin would be the location of xhtml page that directly
loads it, even if it is inside another page in a set of frames (this frames
point is important).

I decided that the actual plugin xhtml object tag location is the base URL
because it is the initiator of the whole shebang.

I checked the "src/data" args but it can only give out what you give in, so
if you pass a relative address, you don't really know where the base URL is.
So what was important for me was the absolute starting address of the xhtml
page. Then using any relative urls given as params, all the URLs can be
fully determined :)

I have now solved the problem using the new plugin scripting functionality
that was omitted from the official documentation web sites. I am hoping
that other people can reuse the solution that I have posted on this news
group.

Cheers,

Robert


"Christian Biesinger" <cbies...@web.de> wrote in message
news:434ED137...@web.de...

Christian Biesinger

unread,
Oct 14, 2005, 4:14:24 PM10/14/05
to
Robert Platt wrote:
> I checked the "src/data" args but it can only give out what you give in, so
> if you pass a relative address, you don't really know where the base URL is.

Hmm, ok, I thought we passed the absolute URL there, but apparently
that's only the case for some other attributes.

> that was omitted from the official documentation web sites.

What page is that?

Robert Platt

unread,
Oct 17, 2005, 5:53:34 AM10/17/05
to
There are two online sources that I found for docs:

http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/

http://developer.mozilla.org/en/docs/Gecko_Plugin_API_Reference

But I found the info I needed here (on a separate page):

http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess

With the very, very, very handy tutorial here:

http://www.mozilla.org/projects/plugins/npruntime-sample-in-visual-studio.html

Cheers,

Robert

"Christian Biesinger" <cbies...@web.de> wrote in message

news:dip3fs$h8...@ripley.aoltw.net...

Christian Biesinger

unread,
Nov 8, 2005, 6:56:26 PM11/8/05
to Robert Platt
[posted + mailed]

Hi again,
this is a really late reply, sorry about that...

Robert Platt wrote:
> I know about the "NPN_GetValue" function, but it does not provide the
> plugin's URL.
>
> We need to get the location of the plugin on a website so that it can
> download relative files.

You could, instead, pass a relative URI to NPN_GetURL; that should
suffice, right?

-biesi

Robert Platt

unread,
Nov 10, 2005, 8:51:19 PM11/10/05
to
Hi Christian,

I found a solution and posted it on the forum for others to see.

I looked at "NPN_GetURL" but it has several problems.

Cheers anyway,

Robert

"Christian Biesinger" <cbies...@web.de> wrote in message

news:43713B2A...@web.de...

0 new messages