Just installed xmpp4moz

12 views
Skip to first unread message

Backpack

unread,
Oct 16, 2009, 3:58:11 PM10/16/09
to SamePlace/xmpp4moz
Hi Massimo, I just installed xmpp4moz and want to play with it, what
should I do? What is the easiest way to start doing stuff with it? You
know connect to a jabber server and send messages back and forth in
real time.

I've googled my fingers off trying to find info about a basic tutorial
and couldn't find one.

Just basic html/javascript stuff, nothing xul related.

Any help would be greatly appreciated.

Massimiliano Mirra

unread,
Oct 16, 2009, 4:23:38 PM10/16/09
to same...@googlegroups.com
George,
did http://wiki.github.com/bard/sameplace/creating-sameplace-extensions
turn up among the results? It's no tutorial but (hopefully) it has
useful stuff.

Whether you're in XUL or in HTML it shouldn't really matter as long as
you import chrome://xmpp4moz/content/xmpp.js. Then it's
XMPP.send(account, <message to='someone'><body>hello</body></message>)
and so on. If you can say something about your use case I can try to
be more precise.

Best,
m.

Backpack

unread,
Oct 16, 2009, 4:31:36 PM10/16/09
to SamePlace/xmpp4moz
Oh man, I've read all docs everywhere, even went to archive.org to get
your old hyperstruct docs.

See, all I want is to test xmpp4moz in html, nothing about extensions
or xul, no no no, juts plain html and javascript.

I know it has something to do with xmpp-incoming and xmpp-outgoing
DIVs but the tutorial federico set up is no longer available (I got it
from archive.org)

So, starting from that basic tutorial, say I have the html ready, the
divs ready and the script ready. Where do I put my JID and how do I
start the thing to connect to my jabber server?

Thanks for your time

On Oct 16, 4:23 pm, Massimiliano Mirra <hyperstr...@gmail.com> wrote:
> George,
> didhttp://wiki.github.com/bard/sameplace/creating-sameplace-extensions
> turn up among the results? It's no tutorial but (hopefully) it has
> useful stuff.
>
> Whether you're in XUL or in HTML it shouldn't really matter as long as
> you import chrome://xmpp4moz/content/xmpp.js.  Then it's
> XMPP.send(account, <message to='someone'><body>hello</body></message>)
> and so on.  If you can say something about your use case I can try to
> be more precise.
>
> Best,
> m.
>

Massimiliano Mirra

unread,
Oct 16, 2009, 4:55:07 PM10/16/09
to same...@googlegroups.com
Ok, I see the problem. You're in content, not in chrome. XMPP
interactions in content still have to be initiated from chrome with
XMPP.connectPanel(). After that, packets are sent with
document.getElementById('xmpp-outgoing').textContent = '<message
to="someone"><body>hello</body></message>' and are received by
registering a DOM mutation event on #xmpp-incoming. Allowing content
to initiate XMPP interactions wouldn't be too hard, the page could
throw a custom event or use an 'xmpp' global object, but the web
integration feature didn't generate much interest so I never got
around to implementing any of that. :(

m.

Backpack

unread,
Oct 16, 2009, 5:04:00 PM10/16/09
to SamePlace/xmpp4moz
The web integration feature is the most important thing for me as I
need a basic and easy way to communicate to a jabber bot from a web
page, nothing else.

Believe me when I say xmpp integration in web pages is the next wave,
as soon as HTML5 WebSockets is available in all modern browsers.

Meantime, xmpp4moz is a good alternative.

So, how should I enable XMPP.connectPanel() from content?

I already know about xmpp-outgoing and xmpp-incoming as explained in
the chat tutorial from federico. But I see nowhere in that script
where to setup the account info.

Baby steps, html in place, javascript in place, divs in place, what
next?



On Oct 16, 4:55 pm, Massimiliano Mirra <hyperstr...@gmail.com> wrote:
> Ok, I see the problem.  You're in content, not in chrome.  XMPP
> interactions in content still have to be initiated from chrome with
> XMPP.connectPanel().  After that, packets are sent with
> document.getElementById('xmpp-outgoing').textContent = '<message
> to="someone"><body>hello</body></message>' and are received by
> registering a DOM mutation event on #xmpp-incoming.  Allowing content
> to initiate XMPP interactions wouldn't be too hard, the page could
> throw a custom event or use an 'xmpp' global object, but the web
> integration feature didn't generate much interest so I never got
> around to implementing any of that. :(
>
> m.
>

Backpack

unread,
Oct 16, 2009, 5:05:59 PM10/16/09
to SamePlace/xmpp4moz
This is federico's script:

function chatInit() {

document.getElementById('xmpp-incoming').addEventListener
('DOMNodeInserted', function(event) {
var my_user;
var stanza = new XML(event.target.textContent);
switch(stanza.localName()) {
case 'presence':
var el = document.getElementById('presence');
my_user = stanza.@to;
el.textContent = stanza.@from;
break;
case 'message':
var el = document.createElement('li');
el.innerHTML = stanza.x.content.@from + ': ' +
stanza.x.content;
document.getElementById('messagelog').appendChild(el);
break;
};
}, false);

document.getElementById('submitbutton').addEventListener('click',
function(event) {
var msg_el = document.getElementById('messagebox');
var message = '<message><x><content from="' + my_user + '">' +
msg_el.value + '</content></x></message>';
document.getElementById('xmpp-outgoing').textContent =
message;
msg_el.value ='';
}, false);

};

What should we do to start the conversation with our jabber server?


On Oct 16, 4:55 pm, Massimiliano Mirra <hyperstr...@gmail.com> wrote:
> Ok, I see the problem.  You're in content, not in chrome.  XMPP
> interactions in content still have to be initiated from chrome with
> XMPP.connectPanel().  After that, packets are sent with
> document.getElementById('xmpp-outgoing').textContent = '<message
> to="someone"><body>hello</body></message>' and are received by
> registering a DOM mutation event on #xmpp-incoming.  Allowing content
> to initiate XMPP interactions wouldn't be too hard, the page could
> throw a custom event or use an 'xmpp' global object, but the web
> integration feature didn't generate much interest so I never got
> around to implementing any of that. :(
>
> m.
>

Backpack

unread,
Oct 16, 2009, 5:06:57 PM10/16/09
to SamePlace/xmpp4moz
Here, his chat basic app (view source to bring old memories)

http://www.pixzone.com/sandbox/sp/chat.html



On Oct 16, 4:55 pm, Massimiliano Mirra <hyperstr...@gmail.com> wrote:
> Ok, I see the problem.  You're in content, not in chrome.  XMPP
> interactions in content still have to be initiated from chrome with
> XMPP.connectPanel().  After that, packets are sent with
> document.getElementById('xmpp-outgoing').textContent = '<message
> to="someone"><body>hello</body></message>' and are received by
> registering a DOM mutation event on #xmpp-incoming.  Allowing content
> to initiate XMPP interactions wouldn't be too hard, the page could
> throw a custom event or use an 'xmpp' global object, but the web
> integration feature didn't generate much interest so I never got
> around to implementing any of that. :(
>
> m.
>

Massimiliano Mirra

unread,
Oct 16, 2009, 5:07:31 PM10/16/09
to same...@googlegroups.com
The feature is just not there, you would have to hack xmpp4moz itself
to add it. Again, sorry. :(

Backpack

unread,
Oct 16, 2009, 5:21:02 PM10/16/09
to SamePlace/xmpp4moz
Ok, I guess I'm gonna fork xmpp4moz, all I need is a basic interface
similar to WebSockets but specific to xmpp and usable in javascript,
like:

Object xmppchannel:

xmppchannel.open(account)
xmppchannel.send(message)
xmppchannel.close()

Events:

xmppchannel.onopen(event)
xmppchannel.onmessage(event)
xmppchannel.onerror(event)
xmppchannel.onclose(event)

So we do all the processing in javascript libraries, the extension
will only be used to connect to the jabber server moving messages back
and forth, nothing else.

Of course I know nothing about extensions, so I'll ask you to be my
mentor if you don't mind. I'll try to take as little time from you as
possible, I know we're all busy in our own projects.

Thanks for your time.



On Oct 16, 5:07 pm, Massimiliano Mirra <hyperstr...@gmail.com> wrote:
> The feature is just not there, you would have to hack xmpp4moz itself
> to add it.  Again, sorry. :(
>

Massimiliano Mirra

unread,
Oct 16, 2009, 5:30:11 PM10/16/09
to same...@googlegroups.com
On Fri, Oct 16, 2009 at 11:21 PM, Backpack <georg...@gmail.com> wrote:
>
> Ok, I guess I'm gonna fork xmpp4moz, all I need is a basic interface
> similar to WebSockets but specific to xmpp and usable in javascript,
> like:
>
> Object xmppchannel:
>
> xmppchannel.open(account)
> xmppchannel.send(message)
> xmppchannel.close()
>
> Events:
>
> xmppchannel.onopen(event)
> xmppchannel.onmessage(event)
> xmppchannel.onerror(event)
> xmppchannel.onclose(event)
>
> So we do all the processing in javascript libraries, the extension
> will only be used to connect to the jabber server moving messages back
> and forth, nothing else.
>
> Of course I know nothing about extensions, so I'll ask you to be my
> mentor if you don't mind. I'll try to take as little time from you as
> possible, I know we're all busy in our own projects.

I'm afraid I can't, trust me if I had time to invest on it right now
I'd gladly spare you XPCOM & friends and serve you the solution on a
silver plate in a matter of days (nothing would make me happier than
seeing the original vision finally exploited).

Marco Pivetta

unread,
Oct 17, 2009, 4:00:22 PM10/17/09
to same...@googlegroups.com
I made some workaround to allow communication between the window and the chrome scopes with a FireFox extension. This requires the extension to perform a
window.MyXMPPWrapper=getANewXMPPWrapperInstance();
every time the window.DOMContentLoaded event is fired... It's some kind of "GreaseMonkey emulation".
Please be VERY CAREFUL with it. You are sharing chrome (privileged) scope with the window (unprivileged) scope. So remember that the user should NEVER be able to define variables or anything in the chrome scope. Every change should be kept local or you should put heavy validation on incoming parameters of your functions :)
Tell me if you need more details, I could link you to the sources if you want to read them... I don't really remind where every related row is placed, but I'll search it for you if you haven't understood what I mean ^_^''

2009/10/16 Massimiliano Mirra <hyper...@gmail.com>:
> Making Ogame a better place...

Backpack

unread,
Oct 17, 2009, 7:34:44 PM10/17/09
to SamePlace/xmpp4moz
Hi Marco, I would like to see the source for sure, I am researching
right now building an xmpp jetpack feature, since it is easier to deal
with. Anything you can provide to support an xmpp extension would be
greatly appreciated.

Thanks


On Oct 17, 4:00 pm, Marco Pivetta <ocram...@gmail.com> wrote:
> I made some workaround to allow communication between the window and the
> chrome scopes with a FireFox extension. This requires the extension to
> perform a
> *window.MyXMPPWrapper=getANewXMPPWrapperInstance();*
> every time the window.DOMContentLoaded event is fired... It's some kind of
> "GreaseMonkey emulation".
> Please be *VERY CAREFUL* with it. You are sharing chrome (privileged) scope
> with the window (unprivileged) scope. So remember that the user should NEVER
> be able to define variables or anything in the chrome scope. Every change
> should be kept local or you should put heavy validation on incoming
> parameters of your functions :)
> Tell me if you need more details, I could link you to the sources if you
> want to read them... I don't really remind where every related row is
> placed, but I'll search it for you if you haven't understood what I mean
> ^_^''
>
> 2009/10/16 Massimiliano Mirra <hyperstr...@gmail.com>:
>
>
>
>
>
> > On Fri, Oct 16, 2009 at 11:21 PM, Backpack <georgen...@gmail.com> wrote:
>
> >> Ok, I guess I'm gonna fork xmpp4moz, all I need is a basic interface
> >> similar to WebSockets but specific to xmpp and usable in javascript,
> >> like:
>
> >> Object xmppchannel:
>
> >> xmppchannel.open(account)
> >> xmppchannel.send(message)
> >> xmppchannel.close()
>
> >> Events:
>
> >> xmppchannel.onopen(event)
> >> xmppchannel.onmessage(event)
> >> xmppchannel.onerror(event)
> >> xmppchannel.onclose(event)
>
> >> So we do all the processing in javascript libraries, the extension
> >> will only be used to connect to the jabber server moving messages back
> >> and forth, nothing else.
>
> >> Of course I know nothing about extensions, so I'll ask you to be my
> >> mentor if you don't mind. I'll try to take as little time from you as
> >> possible, I know we're all busy in our own projects.
>
> > I'm afraid I can't, trust me if I had time to invest on it right now
> > I'd gladly spare you XPCOM & friends and serve you the solution on a
> > silver plate in a matter of days (nothing would make me happier than
> > seeing the original vision finally exploited).
>
> --
> Marco Pivetta - Ocramius Aethril
> Standard Ogame Project - StOgamehttp://www.stogame.net

Marco Pivetta

unread,
Oct 18, 2009, 4:51:55 PM10/18/09
to same...@googlegroups.com
My XMPP wrapper (stores incoming stanzas and allows calling simple stuff like XMPP.send(...) with a window scope callback).
http://www.mozdev.org/source/browse/standardogame/src/StOgame%40stogame.net/content/classes/XMPPConnection.class.js?rev=1.4
Don't try to understand it at all... Just think that some methods of it will be pushed into the unprivileged scope. I just need this class to allow some kind of multi-window object sharing and logging (SQLite... still missing but imminent!) :)

And here the injector (initializes DOMContentLoaded listener, and, when needed, injects the result of account.ogameaccount.get() in the sandbox.unsafeWindow (window, unprivileged scope).
http://www.mozdev.org/source/browse/standardogame/src/StOgame%40stogame.net/content/Loader.js?rev=1.7;content-type=text%2Fplain

account.ogameaccount.get() returns a set of objects and functions that can be used by the end user and that cannot harm anyone or anything in the chrome scope.

To do that, just imagine you have an object called MyPrivateObject in your chrome or private scope.
Now let's imagine you want some fields/methods of that object to be available in another object, but the private scope has not to be modified!

MyPrivateObject={
 "a": "blah",
 "b": "blah",
 "c": function(){ /* SOMETHING I DON'T WANT TO BE CHANGED! */ },
 "get": function(){
  var mpo=this;
  return {
   "a": function(){return mpo.a;},
   "b": function(){return mpo.b;},
   "c": function(){return mpo.get();}
  }
 }



now let's say
MyPublicObject.PrivateObjectStuff=MyPrivateObject.get();


whoever is using MyPublicObject should not be able to modify MyPrivateObject fields :)

That's just some kind of cloaking, but works fine for me ^_^''
Please remember: do NEVER use a syntax like MyPublicObject.PrivateObjectStuff.a=MyPrivateObject.a;
That would create a way to modify MyPrivateObject! Use unnamed objects :)
Hope it will help :)
Just feel free to ask anything, I'm not good at explaining stuff, I'm just a coder, and in this moment I'm a bit sleepy =_=

Good Luck! :)
2009/10/18 Backpack <georg...@gmail.com>

Marco Pivetta

unread,
Oct 19, 2009, 7:05:17 AM10/19/09
to same...@googlegroups.com
Woha, sorry, I made a mistake:
  return {
   "a": function(){return mpo.a;},
   "b": function(){return mpo.b;},
   "c": function(){return mpo.get();}
  }

should be

  return {
   "a": function(){return mpo.a.toString();},
   "b": function(){return mpo.b
.toString();},
   "c": function(){return mpo.get();}
  }


2009/10/18 Marco Pivetta <ocra...@gmail.com>
Sent from Treviso, TV, Italy

Backpack

unread,
Oct 19, 2009, 9:34:36 AM10/19/09
to SamePlace/xmpp4moz
Hi Marco, right now I am working on a java applet implementation and a
Jetpack feature. So the extension will be put in the back burner for
the moment.

Thanks for your help.


On Oct 19, 7:05 am, Marco Pivetta <ocram...@gmail.com> wrote:
> Woha, sorry, I made a mistake:
> *  return {
>    "a": function(){return mpo.a;},
>    "b": function(){return mpo.b;},
>    "c": function(){return mpo.get();}
>   }
>
> should be
> **
>   return {
>    "a": function(){return mpo.a.toString();},
>    "b": function(){return mpo.b**.toString()**;},
>    "c": function(){return mpo.get();}
>   }*
>
> 2009/10/18 Marco Pivetta <ocram...@gmail.com>
>
>
>
Reply all
Reply to author
Forward
0 new messages