[home] [archives] [categories] [links]
[gallery] [twitter]  
subscribe   RSS

Prowl module for ejabberd

@ 2010-07-31.16:57
Categories: Geek
Tags: , , , , ,

Push for instant messaging is pretty essential for a mobile device. I find it a bit irritating that with Apple’s new “multitasking” features in iOS 4, they did not include an api for instant messaging apps. So basically the only way to receive push messages for your instant message client is to use a proxy service. This creates obvious privacy concerns, since you’re just sending your username and password to a third party. Most people are okay with this, but I am not. Since I am already running an XMPP server (ejabberd), I decided I should write a module to send me push notifications directly from the server. To do this, I decided to use Prowl, the same app/service I use for push messaging from my IMAP server. I’ve never written anything in Erlang before, so it took some time to read the docs and muster the energy to dive right in. After a bit of learning and experimenting I have created the first version of mod_offline_prowl for ejabberd. Feel free to use it if you like, I am releasing the full source via GPL for the world to use.

As for implementing it, it’s pretty straight forward, compile it using the included build.sh, and copy the beam file (ebin/mod_offline_prowl.beam) to your ejabberd’s ebin directory (on Debian it’s /usr/lib/ejabberd/ebin). Then configure ejabberd to use it by adding it to the modules section with a list of JIDs and their Prowl API keys like so:

{mod_offline_prowl, [
   {apikeys, [
      {"user1@example.com", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},
      {"user2@example.com", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},
      {"user3@example.com", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
   ]}
]}

You can download the current source here: mod_offline_prowl.tgz

Update:
Added url redirection. Download here: mod_offline_prowl.0.0.2.tgz

7 Comments

2010-08-01 @ 01:30
Isaac comments:

Of course, none of this is necessary with Android (open system)


2010-08-01 @ 17:31
Bob comments:

Android is only an open system in the loosest sense. Like the iPhone, it requires extra work to actually have full control of your device, and unless you do such you are also limited to using the Android Marketplace.
If you want a phone that has a truly open system, go with something like the Nokia N900, which uses a distribution of Linux without locking the user out of it.

However, back to the ejabberd module, it would take very little work to modify it be useful for other platforms. For example, in the next version I plan to add support to send offline messages through email.


2010-08-02 @ 14:01
Badlop comments:

Hi, I’ve linked to this page from:
http://www.ejabberd.im/mod_offline_prowl


2011-04-27 @ 09:47
AndyH comments:

Hi!

Just tried your module, but it doesn’t work for me :( I’m getting the following error (I replaced my jids and the api_key):

=ERROR REPORT==== 2011-04-27 15:42:38 ===
E(:ejabberd_hooks:294) : {undef,
[{lists,keyfind,
[“jid@jabberserver.tld”,1,
[{"jid@jabberserver.tld",
"api_key"}]]},
{mod_offline_prowl,send_notice,3},
{ejabberd_hooks,run1,3},
{ejabberd_sm,route,3},
{ejabberd_local,route,3},
{ejabberd_router,route,3},
{ejabberd_c2s,session_established2,2},
{p1_fsm,handle_msg,10}]}
running hook: {offline_message_hook,
[{jid,”jid”,”jabberserver.tld”,”Miranda”,”ah”,
“jabberserver.tld”,”Miranda”},
{jid,”jid”,”jabberserver.tld”,[],”jid”,
“jabberserver.tld”,[]},
{xmlelement,”message”,
[{"xml:lang","de"},
{"type","chat"},
{"to","jid@jabberserver.tld"},
{"id","mir_46"}],
[{xmlelement,”body”,[],
[{xmlcdata,
<>}]}]}]}

Any Ideas?


2011-04-27 @ 12:48
Bob comments:

Please send me a copy of your ejabberd.cfg through the contact link on this site.


2012-04-17 @ 09:43
Fredman comments:

Hi there!,

I’m trying to use your wonderful solution. Compilation of program was easy, the config excerpt, clear, but the module does not start.

Can you see what is wrong?

thanks in advance…

This is what ejabberd.log shows:
—————————————————————————————–
=INFO REPORT==== 2012-04-17 15:30:59 ===
I(:mod_offline_prowl:44) : Starting mod_offline_prowl

=ERROR REPORT==== 2012-04-17 15:30:59 ===
E(:gen_mod:73) : {badarg,
[{erlang,register,[mod_offline_prowl,]},
{mod_offline_prowl,start,2},
{gen_mod,start_module,3},
{lists,foreach,2},
{ejabberd_app,start,2},
{application_master,start_it_old,4}]}

=INFO REPORT==== 2012-04-17 15:30:59 ===
I(:ejabberd_app:72) : ejabberd 2.1.5 is started in the node ejabberd@myserver

——————————————————————————


2012-04-18 @ 11:02
Fredman comments:

Ok,

I finally found the solution:

In may Jabberd v 2.1.5, I had to change the “start” section, this way:

start(Host, Opts) ->
?INFO_MSG(“Starting mod_offline_prowl”, [] ),

register(gen_mod:get_module_proc(Host, ?PROCNAME),
spawn(?MODULE, init, [Host, Opts])),
ok.

It worked for me…


RSS feed for comments on this post.

Valid XHTML 1.0 Transitional Powered by WordPress