[9f183ff] | 1 | use strict; |
---|
[2cedb7a] | 2 | use warnings; |
---|
| 3 | |
---|
| 4 | package BarnOwl::Module::Jabber; |
---|
| 5 | |
---|
| 6 | =head1 NAME |
---|
[9f183ff] | 7 | |
---|
[2cedb7a] | 8 | BarnOwl::Module::Jabber |
---|
| 9 | |
---|
| 10 | =head1 DESCRIPTION |
---|
| 11 | |
---|
[b8a3e00] | 12 | This module implements Jabber support for BarnOwl. |
---|
[2cedb7a] | 13 | |
---|
| 14 | =cut |
---|
| 15 | |
---|
[d474ee9] | 16 | use BarnOwl; |
---|
| 17 | use BarnOwl::Hooks; |
---|
[3e34a69] | 18 | use BarnOwl::Module::Jabber::Impl; |
---|
[6a6dd47] | 19 | |
---|
[e0ffe77] | 20 | use utf8; |
---|
| 21 | |
---|
[2cedb7a] | 22 | our $VERSION = 0.1; |
---|
| 23 | |
---|
[d474ee9] | 24 | sub onStart { |
---|
| 25 | if ( *BarnOwl::queue_message{CODE} ) { |
---|
| 26 | register_owl_commands(); |
---|
| 27 | register_keybindings(); |
---|
| 28 | register_filters(); |
---|
| 29 | $BarnOwl::Hooks::getQuickstart->add("BarnOwl::Module::Jabber::onGetQuickstart"); |
---|
| 30 | |
---|
| 31 | BarnOwl::new_variable_bool("jabber:show_offline_buddies", |
---|
| 32 | { default => 1, |
---|
| 33 | summary => 'Show offline or pending buddies.'}); |
---|
| 34 | BarnOwl::new_variable_bool("jabber:show_logins", |
---|
| 35 | { default => 0, |
---|
| 36 | summary => 'Show login/logout messages.'}); |
---|
| 37 | BarnOwl::new_variable_bool("jabber:spew", |
---|
| 38 | { default => 0, |
---|
| 39 | summary => 'Display unrecognized Jabber messages.'}); |
---|
| 40 | BarnOwl::new_variable_int("jabber:auto_away_timeout", |
---|
| 41 | { default => 5, |
---|
| 42 | summary => 'After minutes idle, auto away.', |
---|
| 43 | }); |
---|
| 44 | BarnOwl::new_variable_int("jabber:auto_xa_timeout", |
---|
| 45 | { default => 15, |
---|
| 46 | summary => 'After minutes idle, auto extended away.' |
---|
| 47 | }); |
---|
| 48 | BarnOwl::new_variable_bool("jabber:reconnect", |
---|
| 49 | { default => 1, |
---|
| 50 | summary => 'Auto-reconnect when disconnected from servers.' |
---|
| 51 | }); |
---|
| 52 | |
---|
| 53 | BarnOwl::Module::Jabber::Impl::onStart(); |
---|
| 54 | } else { |
---|
| 55 | # Our owl doesn't support queue_message. Unfortunately, this |
---|
| 56 | # means it probably *also* doesn't support BarnOwl::error. So just |
---|
| 57 | # give up silently. |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | $BarnOwl::Hooks::startup->add("BarnOwl::Module::Jabber::onStart"); |
---|
| 62 | |
---|
| 63 | sub _make_stub { |
---|
| 64 | my $func = shift; |
---|
| 65 | return sub { |
---|
| 66 | no strict 'refs'; |
---|
| 67 | &{"BarnOwl::Module::Jabber::Impl::$func"}; |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | sub register_owl_commands() { |
---|
| 72 | BarnOwl::new_command( |
---|
| 73 | jabberlogin => _make_stub("cmd_login"), |
---|
| 74 | { |
---|
| 75 | summary => "Log in to Jabber", |
---|
| 76 | usage => "jabberlogin <jid> [<password>]" |
---|
| 77 | } |
---|
| 78 | ); |
---|
| 79 | BarnOwl::new_command( |
---|
| 80 | jabberlogout => _make_stub("cmd_logout"), |
---|
| 81 | { |
---|
| 82 | summary => "Log out of Jabber", |
---|
| 83 | usage => "jabberlogout [-A|<jid>]", |
---|
| 84 | description => "jabberlogout logs you out of Jabber.\n\n" |
---|
| 85 | . "If you are connected to one account, no further arguments are necessary.\n\n" |
---|
| 86 | . "-A Log out of all accounts.\n" |
---|
| 87 | . "<jid> Which account to log out of.\n" |
---|
| 88 | } |
---|
| 89 | ); |
---|
| 90 | BarnOwl::new_command( |
---|
| 91 | jwrite => _make_stub("cmd_jwrite"), |
---|
| 92 | { |
---|
| 93 | summary => "Send a Jabber Message", |
---|
| 94 | usage => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>] [-m <message>]" |
---|
| 95 | } |
---|
| 96 | ); |
---|
| 97 | BarnOwl::new_command( |
---|
| 98 | jaway => _make_stub("cmd_jaway"), |
---|
| 99 | { |
---|
| 100 | summary => "Set Jabber away / presence information", |
---|
| 101 | usage => "jaway [-s online|dnd|...] [<message>]" |
---|
| 102 | } |
---|
| 103 | ); |
---|
| 104 | BarnOwl::new_command( |
---|
| 105 | jlist => _make_stub("cmd_jlist"), |
---|
| 106 | { |
---|
| 107 | summary => "Show your Jabber roster.", |
---|
| 108 | usage => "jlist" |
---|
| 109 | } |
---|
| 110 | ); |
---|
| 111 | BarnOwl::new_command( |
---|
| 112 | jmuc => _make_stub("cmd_jmuc"), |
---|
| 113 | { |
---|
| 114 | summary => "Jabber MUC related commands.", |
---|
| 115 | description => "jmuc sends Jabber commands related to MUC.\n\n" |
---|
| 116 | . "The following commands are available\n\n" |
---|
| 117 | . "join <muc>[/<nick>]\n" |
---|
| 118 | . " Join a MUC (with a given nickname, or otherwise your JID).\n\n" |
---|
| 119 | . "part <muc> Part a MUC.\n" |
---|
| 120 | . " The MUC is taken from the current message if not supplied.\n\n" |
---|
| 121 | . "invite <jid> [<muc>]\n" |
---|
| 122 | . " Invite <jid> to <muc>.\n" |
---|
| 123 | . " The MUC is taken from the current message if not supplied.\n\n" |
---|
| 124 | . "configure [<muc>]\n" |
---|
| 125 | . " Configures a MUC.\n" |
---|
| 126 | . " Necessary to initalize a new MUC.\n" |
---|
| 127 | . " At present, only the default configuration is supported.\n" |
---|
| 128 | . " The MUC is taken from the current message if not supplied.\n\n" |
---|
| 129 | . "presence [<muc>]\n" |
---|
| 130 | . " Shows the roster for <muc>.\n" |
---|
| 131 | . " The MUC is taken from the current message if not supplied.\n\n" |
---|
| 132 | . "presence -a\n" |
---|
| 133 | . " Shows rosters for all MUCs you're participating in.\n\n", |
---|
| 134 | usage => "jmuc <command> [<args>]" |
---|
| 135 | } |
---|
| 136 | ); |
---|
| 137 | BarnOwl::new_command( |
---|
| 138 | jroster => _make_stub("cmd_jroster"), |
---|
| 139 | { |
---|
| 140 | summary => "Jabber roster related commands.", |
---|
| 141 | description => "jroster sends Jabber commands related to rosters.\n\n" |
---|
| 142 | . "The following commands are available\n\n" |
---|
| 143 | . "sub <jid> Subscribe to <jid>'s presence. (implicit add)\n\n" |
---|
| 144 | . "add <jid> Adds <jid> to your roster.\n\n" |
---|
| 145 | . "unsub <jid> Unsubscribe from <jid>'s presence.\n\n" |
---|
| 146 | . "remove <jid> Removes <jid> from your roster. (implicit unsub)\n\n" |
---|
| 147 | . "auth <jid> Authorizes <jid> to subscribe to your presence.\n\n" |
---|
| 148 | . "deauth <jid> De-authorizes <jid>'s subscription to your presence.\n\n" |
---|
| 149 | . "The following arguments are supported for all commands\n\n" |
---|
| 150 | . "-a <jid> Specify which account to make the roster changes on.\n" |
---|
| 151 | . " Required if you're signed into more than one account.\n\n" |
---|
| 152 | . "The following arguments only work with the add and sub commands.\n\n" |
---|
| 153 | . "-g <group> Add <jid> to group <group>.\n" |
---|
| 154 | . " May be specified more than once, will not remove <jid> from any groups.\n\n" |
---|
| 155 | . "-p Purge. Removes <jid> from all groups.\n" |
---|
| 156 | . " May be combined with -g.\n\n" |
---|
| 157 | . "-n <name> Sets <name> as <jid>'s short name.\n\n" |
---|
| 158 | . "Note: Unless -n is used, you can specify multiple <jid> arguments.\n", |
---|
| 159 | usage => "jroster <command> <args>" |
---|
| 160 | } |
---|
| 161 | ); |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | sub register_keybindings { |
---|
| 165 | BarnOwl::bindkey(qw(recv j command start-command), 'jwrite '); |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | sub register_filters { |
---|
| 169 | BarnOwl::filter(qw(jabber type ^jabber$)); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | sub onGetQuickstart { |
---|
| 173 | return <<'EOF' |
---|
| 174 | @b(Jabber:) |
---|
| 175 | Type ':jabberlogin @b(username@mit.edu)' to log in to Jabber. The command |
---|
| 176 | ':jroster sub @b(somebody@gmail.com)' will request that they let you message |
---|
| 177 | them. Once you get a message saying you are subscribed, you can message |
---|
| 178 | them by typing ':jwrite @b(somebody@gmail.com)' or just 'j @b(somebody)'. |
---|
| 179 | EOF |
---|
| 180 | } |
---|
| 181 | |
---|
[84296f6] | 182 | 1; |
---|