[438] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r568 - trunk/owl/perl/modules

daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:06:10 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Thu, 25 Jan 2007 15:46:29 -0500 (EST)

Author: asedeno
Date: 2007-01-25 15:46:26 -0500 (Thu, 25 Jan 2007)
New Revision: 568

Modified:
   trunk/owl/perl/modules/jabber.pl
Log:
* Added `jmuc presence -a' to show presence for all MUCs
* Updated jmuc docs



Modified: trunk/owl/perl/modules/jabber.pl
===================================================================
--- trunk/owl/perl/modules/jabber.pl	2007-01-25 06:05:34 UTC (rev 567)
+++ trunk/owl/perl/modules/jabber.pl	2007-01-25 20:46:26 UTC (rev 568)
@@ -372,16 +372,22 @@
             summary     => "Jabber MUC related commands.",
             description => "jmuc sends jabber commands related to muc.\n\n"
               . "The following commands are available\n\n"
-              . "join MUC    Join a muc.\n\n"
-              . "part MUC    Part a muc.\n"
+              . "join <muc>  Join a muc.\n\n"
+              . "part <muc>  Part a muc.\n"
               . "            The muc is taken from the current message if not supplied.\n\n"
-              . "invite JID MUC\n"
-              . "            Invite JID to MUC.\n"
+              . "invite <jid> <muc>\n"
+              . "            Invite <jid> to <muc>.\n"
               . "            The muc is taken from the current message if not supplied.\n\n"
-              . "configure MUC\n"
-              . "            Configure [muc].\n"
-              . "            Necessary to initalize a new MUC\n"
-              . "            At present, only the default configuration is supported.",
+              . "configure <muc>\n"
+              . "            Configures a MUC.\n"
+              . "            Necessary to initalize a new MUC.\n"
+              . "            At present, only the default configuration is supported.\n"
+              . "            The muc is taken from the current message if not supplied.\n\n"
+              . "presence <muc>\n"
+              . "            Shows the roster for <muc>.\n"
+              . "            The muc is taken from the current message if not supplied.\n\n"
+              . "presence -a\n"
+              . "            Shows rosters for all MUCs you're participating in.\n\n",
             usage => "jmuc COMMAND ARGS"
         }
     );
@@ -751,18 +757,35 @@
     queue_admin_msg("Accepted default instant configuration for $muc");
 }
 
+sub jmuc_presence_single {
+    my $m = shift;
+    my @jids = $m->Presence();
+    return "JIDs present in " . $m->BaseJID . "\n\t"
+      . join("\n\t", map {$_->GetResource}@jids) . "\n";
+}
+
 sub jmuc_presence {
     my ( $jid, $muc, @args ) = @_;
 
     $muc = shift @args if scalar @args;
     die("Usage: jmuc presence MUC") unless $muc;
 
-    my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc);
-    die("No such muc: $muc") unless $m;
-
-    my @jids = $m->Presence();
-    BarnOwl::popless_ztext("JIDs present in " . $m->BaseJID . "\n\t" .
-                           join("\n\t", map {$_->GetResource}@jids) . "\n");
+    if ($muc eq '-a') {
+        my $str = "";
+        foreach my $jid ($conn->getJIDs()) {
+            $str .= boldify("Conferences for $jid:\n");
+            my $connection = $conn->getConnectionFromJID($jid);
+            foreach my $muc ($connection->MUCs) {
+                $str .= jmuc_presence_single($muc)."\n";
+            }
+        }
+        BarnOwl::popless_ztext($str);
+    }
+    else {
+        my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc);
+        die("No such muc: $muc") unless $m;
+        BarnOwl::popless_ztext(jmuc_presence_single($m));
+    }
 }
 
 


home help back first fref pref prev next nref lref last post