Re: problem getting URI from nsIwebNavigation

2005-07-25 Thread Anatoly Kaverin

Hello Niky, thnx for your help.

We have access to service manager inside the mozilla plug-in and maybe
we have an error with quering interface nsIComponentManager instead
of using nsComponentManager.
We are using nsIComponentManager from mozilla SDK.
But we still can't get URI, below is our code:

nsresult res;
nsIComponentManager * picmCM = nsnull;
 
 gServiceManager-QueryInterface(NS_GET_IID(nsIComponentManager), (void 
**)picmCM);

 if(picmCM)
{
 nsIWebBrowser *piwbWebBrowser = nsnull;
 res = 
picmCM-CreateInstanceByContractID(@mozilla.org/embedding/browser/nsWebBrowser;1,
  nsnull, NS_GET_IID(nsIWebBrowser), (void**) piwbWebBrowser);

 if(NS_OK == res)
 {
  nsIWebNavigation *piwnWebNavigation = nsnull;
  nsIURI *piuURI = nsnull;
  nsCString csString;

  res = piwbWebBrowser-QueryInterface(NS_GET_IID (nsIWebNavigation),
   (void**)piwnWebNavigation);
  if(NS_OK == res)
  {
   res = piwnWebNavigation-GetCurrentURI(piuURI); //res == NS_ERROR_UNEXPECTED
   if(NS_OK == res)
   {
res = piuURI-GetSpec(csString);

piuURI-Release();
   }
   else if(NS_ERROR_UNEXPECTED == res) 
MessageBox(NULL, Error with URI, Error, MB_OK);

   piwnWebNavigation-Release();
  }
 }
 picmCM-Release();
}

We just can't get - what wrong with this nsIURI


Here is what we use in our embedded Gecko app, and it seems to work
fine:

//-
//Temp vars
nsIWebNavigation *piwnWebNavigation = nsnull;
nsIURI *piuURI = nsnull;
nsCString csString;
//QIing for the web navigation object
piwbWebBrowser-QueryInterface (NS_GET_IID (nsIWebNavigation),
(void**)
piwnWebNavigation);
//Getting the URI object
piwnWebNavigation-GetCurrentURI (piuURI);
//Getting URL from URI object
piuURI-GetSpec (csString);
//Releasing
piuURI-Release ();
piwnWebNavigation-Release ();
**NOTE**
piwbWebBrowser is an nsIWebBrowser object created earlier in the app
with:
rv = nsComponentManager::CreateInstance
(@mozilla.org/embedding/browser/nsWebBrowser;1, nsnull, NS_GET_IID
(nsIWebBrowser), (void**) piwbWebBrowser);
//-

Also, I noticed that if I tried to get the nsIURI object BEFORE the
web page had completely loaded, I got NULL for that object.  So I had
to wait till I was notified that the web page was completely loaded
before I tried to do this.  This could maybe be your problem?

Hope this helps.

Niky Williams

Anatoly Kaverin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]


hi to everyone.
i'm newbie to XPCOM and faced with problem of getting current url
from

page


and control over navigation. We decided to use nsIWebNavigation
interface for these purposes.

below is our code:

nsIWebNavigation * nsWN = NULL;

if (gServiceManager)
{
nsresult res;
res =

gServiceManager-GetServiceByContractID(@mozilla.org/embedding/browse
r/nsWe bBrowser;1,


NS_GET_IID(nsIWebNavigation), (void **)nsWN);
if(NS_OK == res)
{
MessageBox(NULL, Interface Pointer Received Succesfully,

WebNavigation,


MB_OK);
nsIURI *url = NULL;
res = nsWN-GetCurrentURI(url);   //res =

NS_ERROR_UNEXPECTED


if(NS_OK == res)
MessageBox(NULL, URI received, URI msg, MB_OK);
res = nsWN-GetReferringURI(url); //res =

NS_ERROR_UNEXPECTED


if(NS_OK == res)
MessageBox(NULL, URI REF received, URI msg, MB_OK);
nsEmbedCString path;
if(url)
url-GetPath(path);
MessageBox(NULL, path.get(), path of page, MB_OK);
}
else if (NS_NOINTERFACE == res)
MessageBox(NULL, NOINTERFACE, WebNavigation, MB_OK);
}
NS_IF_RELEASE(nsWN);
-

With Best Regards,
Anatoly Kaverin,
VerificationEngine developer
http://www.vengine.com
C O M O D O group
[EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]

With Best Regards,
Anatoly Kaverin, 
VerificationEngine developer

http://www.vengine.com
C O M O D O group
[EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]


___
Mozilla-xpcom mailing list
Mozilla-xpcom@mozilla.org
http://mail.mozilla.org/listinfo/mozilla-xpcom


Re: problem getting URI from nsIwebNavigation

2005-07-25 Thread Christian Biesinger

Anatoly Kaverin wrote:

But we still can't get URI, below is our code:


You are writing an extension for Firefox or Mozilla?

Which URI do you want? There might be a lot or nsIWebNavigation 
instances - each tab has one, for example. Which of those webnavigations 
do you want to access?


___
Mozilla-xpcom mailing list
Mozilla-xpcom@mozilla.org
http://mail.mozilla.org/listinfo/mozilla-xpcom


Re: nsIEditorObserver crashes Firefox

2005-07-25 Thread Filip Dalüge

Hi Neil,
I just encountered the same problem. I rather use DOM MutationEvents as 
an alternative solution now.


For example:


var editor = document.getElementById(Editor);
editor.makeEditable(text, false);
var doc = editor.contentDocument;


 function modified() {
dump(...);
 }


doc.addEventListener(DOMNodeInserted, modified, false);
doc.addEventListener(DOMCharacterDataModified, modified, false);


Look at 
http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-mutationevents

for more information.

Best wishes,
Filip
___
Mozilla-xpcom mailing list
Mozilla-xpcom@mozilla.org
http://mail.mozilla.org/listinfo/mozilla-xpcom