Ignore:
Timestamp:
Oct 17, 2009, 12:35:12 AM (15 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
6a9fbca
Parents:
ec70b79
git-author:
Alejandro R. Sedeño <asedeno@mit.edu> (10/16/09 23:25:57)
git-committer:
Alejandro R. Sedeño <asedeno@mit.edu> (10/17/09 00:35:12)
Message:
Tweak jabberlogin.

* Disallow logging into the same jabber account twice unless you are
  explicitly specifying a resource.
Location:
perl/modules/Jabber/lib/BarnOwl/Module
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    rec70b79 r8ff511d  
    352352sub cmd_login {
    353353    my $cmd = shift;
     354    my $jidStr = shift;
    354355    my $jid = new Net::Jabber::JID;
    355     $jid->SetJID(shift);
     356    $jid->SetJID($jidStr);
    356357    my $password = '';
    357358    $password = shift if @_;
     
    359360    my $uid           = $jid->GetUserID();
    360361    my $componentname = $jid->GetServer();
    361     my $resource      = $jid->GetResource() || 'owl';
     362    my $resource      = $jid->GetResource();
     363
     364    if ($resource eq '') {
     365        my $cjidStr = $conn->baseJIDExists($jidStr);
     366        if ($cjidStr) {
     367            BarnOwl::error("Already logged in as $cjidStr.");
     368            return;
     369        }
     370    }
     371
     372    $resource ||= 'owl';
    362373    $jid->SetResource($resource);
    363     my $jidStr = $jid->GetJID('full');
     374    $jidStr = $jid->GetJID('full');
    364375
    365376    if ( !$uid || !$componentname ) {
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm

    r6b580b0 r8ff511d  
    7373}
    7474
     75sub baseJIDExists {
     76    my $self = shift;
     77    my $jidStr = shift;
     78    my $jid = new Net::Jabber::JID;
     79    $jid->SetJID($jidStr);
     80    my $baseJID = $jid->GetJID('base');
     81
     82    foreach my $cjidStr ( keys %{ $self } ) {
     83        my $cJID = new Net::Jabber::JID;
     84        $cJID->SetJID($cjidStr);
     85        return $cjidStr if ($cJID->GetJID('base') eq $baseJID);
     86    }
     87    return 0;
     88}
     89
    7590sub sidExists {
    7691    my $self = shift;
Note: See TracChangeset for help on using the changeset viewer.