Summary:ASTERISK-03654: [patch] JabberPops
Reporter:Matt O'Gorman (mogorman)Labels:
Date Opened:2005-03-08 14:44:16.000-0600Date Closed:2011-06-07 14:05:19
Versions:Frequency of
Environment:Attachments:( 0) app_jabberpop.c
( 1) jabberpop.conf.sample
( 2) patch.diff.txt
Description:Allows for asterisk to act as client to a jabber server for sending messages.  It requires the iksemel library, I had it working with 1.1 but I am using 1.2 version you can grab it at  http://iksemel.jabberstudio.org/ or several distros have libraries, this is just a little part of bigger project i am working on, just really proof that this is easy enough and has uses in asterisk.  You call the app as such

jabberpop(Jabberuser|message), Jabberuser being person to send message to, message being what he receives it is configurable via jabberpop.conf.  Any thoughts or suggestions would be appreciated.


Disclaimer on file. ^_^
Comments:By: Tilghman Lesher (tilghman) 2005-03-08 16:50:55.000-0600

state() and log_state() both need to be declared static (or else be given public interface names and move the module to a res_* that returns usecount=1).  Other than that, nice work.  It would also be useful to be able to retrieve a state, for presence applications.

By: Joshua C. Colp (jcolp) 2005-03-08 17:13:34.000-0600

oej and I talked today about doing unified presence and messaging today, I would hold off on doing presence until we have a concrete architecture in asterisk unless you feel like converting your own to the new architecture when it is released. You're welcome to do so regardless. Great contribution.

By: Matt O'Gorman (mogorman) 2005-03-08 20:54:37.000-0600

New patch has that little fix.  I am working on res_jabber.c as well as its underlying layer res_xml.c.  As for allowing presence, and other advanced features, I am writing all of the features of a Jabber client into res_jabber, and hopefully leave res_xml with a viable parser for things other than jabber, rss anyone?  Anyways to be honest as you can tell from my previous patches I am not the best coder, so I will leave other people to implement those features from my libraries, I will probably only create my little apps.

By: Clod Patry (junky) 2005-03-08 21:30:57.000-0600

can i delete the old app_jabberpop.c ?

By: Matt O'Gorman (mogorman) 2005-03-08 21:36:16.000-0600

yes, like i said only diff between the two is static

By: Matt O'Gorman (mogorman) 2005-03-09 11:02:41.000-0600

Everything updated and fixed, and made it so when you compile asterisk for your machine if you dont have libiksemel it wont build and asterisk will finish cleanly.

By: Olle Johansson (oej) 2005-03-13 09:35:28.000-0600

I like this patch, use system() for a similar app today. However, I would like to see an option to see a choice between a message and a dialog. The reason for a dialog is to have the ability have one chat window open and receive all incoming pops in that one window.

Long term, we might be doing things like this with support of the manager proxy, so we can support jabber to SIP/simple and IAX2 messaging in Asterisk.

By: masteryoda305 (masteryoda305) 2005-03-15 11:53:04.000-0600

Do I have to be running CVS Head for this patch to work? I tried installing it on the 1.0.7 release but it wouldn't compile or load.

By: Matt O'Gorman (mogorman) 2005-03-15 12:35:49.000-0600

no but you need lib iksemel.  if you dont have it just passes over it. kinda like building zaptel

By: Olle Johansson (oej) 2005-03-16 13:11:26.000-0600

btw, matt, three space indents? Tsss, tsss. Coding guidelines :-)

By: Olle Johansson (oej) 2005-03-16 13:15:09.000-0600

If there's no config, the jabberpop_load_config returns -1. If that's the case, should we really register the app? I think not.

By: Matt O'Gorman (mogorman) 2005-03-16 13:15:48.000-0600

hmm i was using a my mac to edit... subethaedit(very clean little text editor) must be doing three space indents by default. my bad.....

By: Matt O'Gorman (mogorman) 2005-03-16 13:16:33.000-0600

you say potato, i say potato (doesn't really work over text)

By: masteryoda305 (masteryoda305) 2005-03-16 18:52:36.000-0600

I'm getting this when I install this for 1.0.7rc

app_jabberpop.so]Mar 16 18:16:16 WARNING[7211]: loader.c:258 ast_load_resource: /usr/lib/asterisk/modules/app_jabberpop.so: undefined symbol: ast_config_load
Mar 16 18:16:16 WARNING[7211]: loader.c:440 load_modules: Loading module app_jabberpop.so failed!
Ouch ... error while writing audio data: : Broken pipe
root@jediphone:~# file /usr/lib/asterisk/modules/app_jabberpop.so

I guess you would call me a noob. Do I have to change anything to make this work? (This time with right-thread goodness)

By: Matt O'Gorman (mogorman) 2005-03-16 21:27:46.000-0600

You do not have the config file in place, although it should handle for that.  So put the config file jabberpop.conf and place and it should work, I did run it in stable the other day so i dont see why it would not work.

By: masteryoda305 (masteryoda305) 2005-03-16 23:43:46.000-0600

I had the jabberpop.conf file in place and it still was not loading, with that same symbol error "ast_config_load." I looked in the config.h file, saw that there was a function called "config_load", and changed it to that. That worked, asterisk loaded.

Now I can't get the function to actually work. I don't see the dummy jabber come online and I don't get the messages. I'm calling the function with:

exten => 8899,1,jabberpop(chris@####,This is a sentence)

Sorry I'm pestering you guys about this. But this looks like something easy I should be able to get working and its kinda irritating me that I can't do it. Thanks.

By: Matt O'Gorman (mogorman) 2005-03-17 07:12:12.000-0600

you can reach me on irc mogorman or you can send me an email to mogorman@digium.com and I will help assist you.

By: Olle Johansson (oej) 2005-03-18 01:15:25.000-0600

Assisting in testing a new patch is hardly "pestering" :-) Thank you for your help in testing this!

By: k3v (k3v) 2005-03-19 17:48:37.000-0600

I'm having trouble registering.  The username is in the struct, but it's not in the xml (self-closing tag).  Using CVS 20050311 and the files attached to this bug.

<?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='mydomain.com' version='1.0'>
<iq type='set'><query xmlns='jabber:iq:auth'><username/><resource/><password>thepass</password></query></iq><presence><status>Online</status></presence>

<?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='mydomain.com' version='1.0' id='4h431y1g9xiwmsxu71o75w16mf1idt5ib9lc8nsi'>
<stream:features xmlns:stream='http://etherx.jabber.org/streams'><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms></stream:features>
<iq xmlns='jabber:client' type='error'><error code='401'/><query xmlns='jabber:iq:auth'><username/><resource/><password>thepass</password></query></iq>
<stream:error xmlns:stream='http://etherx.jabber.org/streams'><not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></stream:stream>

(gdb) p jabuser
$3 = {host = 0x82a31d5 "mydomain.com", username = 0x82a3049 "theuser",
 password = 0x8259ee1 "thepass", senderid = 0x0, prefix = 0xb74fe037 "",
 suffix = 0xb74fe037 "", my_jid = 0x834a57c, p = 0x8270f2c,
 stack = 0x834a560, port = 5222}

By: k3v (k3v) 2005-03-21 01:18:12.000-0600

update:  username needs to be user@domain/resource, I had just user, so iksemel is confused.  I still have issues authing and sending messages (server reports connection close after accepting auth), but I'm adding some log callbacks to try to track it down.

By: Clod Patry (junky) 2005-04-11 15:18:23

For which are using astxs:
astxs -append=EXTOBJ:"-liksemel" app_jabberpop.c -install -autoload

By: Steve Murphy (murf) 2005-05-05 13:08:02

OK, Jabber expert... could we add something to asterisk, so that asterisk could update a jabber client with "on the phone" type status? This could be a cool "presence" sort of information. When you get or make a call, some sort of call could be made to a jabber client, to notify of a status change. When you hang up, another call to remove status... Is something like this possible?

This is "Way Out There", isn't it? But wouldn't it be cool if any IM client could detect "on phone" type presence information, and either throttle or notify any connecting parties?

whatcha think?

By: Olle Johansson (oej) 2005-06-02 02:02:45

murf: that's where we are heading. It should be possible to write a small perl daemon now, that logs in to your jabber account and the * manager, updating jabber as you get calls.

In the future, I would love having a better integration.

By: Steve Murphy (murf) 2005-06-02 09:02:25

Hmmm. Can two different processes on the same machine /same network,  log in to the same account? I know MS messenger doesn't allow more than one login. I can't quite imagine how you would interact with the jabber server, if the daemon logged in first and was reporting phone presence info. That's the problem I imagine... How would people initiate a IM session with you, or vice-versa, if asterisk/daemon is logged in?  Seems to me you'd need to mod an existing client (like Gaim) to get the proper affect... where am I wrong?

By: ckruetze (ckruetze) 2005-06-02 09:49:18

murf: You have to tell the Jabber server that the status is on the phone without logging in as the user. I think it works like this (not 100% sure, since I haven't used jabber that much):

1. Jabber server is running
2. User X logs in
3. Your program interacts with the server and tells the server user X is on the phone. This happens through a "manager interface" of the Jabber server not as a client.
4. The server not only notifies all people who have you on there buddy list, but also your client that your status is now "On the phone".

In the Microsoft world you can do something like the above. Get your clients to register to your Live Communication Server and then write a small add-on for the server to check the user status within * and set it to "On the phone" when you want.

By: Olle Johansson (oej) 2005-06-02 10:19:52

I can run multiple clients to the Jabber server. Have to play around with changing status from one...

By: ckruetze (ckruetze) 2005-06-02 10:48:18

But how do we expand the multiple client solution?
With 20 users do we run 20 Jabber clients on the * server?
How do we tell the Jabber clients on the server when to run and when not to run?
And how do users change passwords for their Jabber clients without breaking the server client?
How do we stop people from talking to the clients on the server?

I think a solution utalizing a IM client on the server will only work for one or two home users, but not for offices.

By: Olle Johansson (oej) 2005-06-02 10:49:02

Hmmm. If I start a second Jabber client, that one can change status, but it takes over from the first one. The first one is still workable, but I can't change my status from that instance.

By: Olle Johansson (oej) 2005-06-02 10:56:50

You are right. I wonder if there's another way to interface using the protocol or if we have to interface directly to the jabber server. Need to check how the SIPtoJabber gateway in SER works... Time to read protocols and source, people!

By: Kevin P. Fleming (kpfleming) 2005-06-03 18:41:17

Closed per bug poster's request.