Changeset 9d2f010 for perl


Ignore:
Timestamp:
Feb 18, 2008, 8:54:45 PM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
2f69081, 61abb18
Parents:
b4fcc06 (diff), 6b580b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merging in the select branch, part 2. select.c
Location:
perl
Files:
6 edited

Legend:

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

    rcab045b r9c7a701  
    6969}
    7070
    71 sub mainloop_hook {
     71#sub mainloop_hook {
     72#    return unless defined $irc;
     73#    eval {
     74#        $irc->do_one_loop();
     75#    };
     76#    return;
     77#}
     78
     79sub OwlProcess {
    7280    return unless defined $irc;
    7381    eval {
     
    7684    return;
    7785}
     86
    7887
    7988sub register_handlers {
     
    109118$BarnOwl::Hooks::startup->add(\&startup);
    110119$BarnOwl::Hooks::shutdown->add(\&shutdown);
    111 $BarnOwl::Hooks::mainLoop->add(\&mainloop_hook);
     120#$BarnOwl::Hooks::mainLoop->add(\&mainloop_hook);
    112121
    113122################################################################################
     
    165174        BarnOwl::admin_message("IRC", "Connected to $alias as $nick");
    166175        $ircnets{$alias} = $conn;
     176        my $fd = $conn->getSocket()->fileno();
     177        BarnOwl::add_dispatch($fd, \&OwlProcess);
     178        $conn->{FD} = $fd;
    167179    } else {
    168180        die("IRC::Connection->connect failed: $!");
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r5ff830a r9c7a701  
    6969}
    7070
     71sub getSocket
     72{
     73    my $self = shift;
     74    return $self->conn->socket;
     75}
     76
    7177################################################################################
    7278############################### IRC callbacks ##################################
     
    168174    my $self = shift;
    169175    delete $BarnOwl::Module::IRC::ircnets{$self->alias};
    170 
     176    BarnOwl::remove_dispatch($self->{FD});
    171177    BarnOwl::admin_message('IRC',
    172178                           "[" . $self->alias . "] Disconnected from server");
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r879e7e94 r6b580b0  
    116116            BarnOwl::error("Connection for $jid undefined -- error in reload?");
    117117        }
    118 
     118        # We keep this in the mainloop hook for keep-alives
    119119        my $status = $client->Process(0);
    120120        if ( !defined($status) ) {
     
    124124        if ($::shutdown) {
    125125            do_logout($jid);
    126             return;
    127         }
     126            next;
     127        }
     128
    128129        if ($vars{status_changed}) {
    129130            my $p = new Net::Jabber::Presence;
     
    387388                $conn->renameConnection($jidStr, $fullJid);
    388389                queue_admin_msg("Connected to jabber as $fullJid");
     390                # The remove_dispatch() method is called from the
     391                # ConnectionManager's removeConnection() method.
     392                $client->{fileno} = $client->getSocket()->fileno();
     393                #queue_admin_msg("Connected to jabber as $fullJid ($client->{fileno})");
     394                BarnOwl::add_dispatch($client->{fileno}, sub { $client->OwlProcess() });
    389395            }
    390396        }
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm

    r892568b r6b580b0  
    110110
    111111
     112=head2 getSID
     113
     114Returns the StreamID for this connection.
     115
     116=cut
     117
     118sub getStreamID {
     119    my $self = shift;
     120    return $self->{SESSION}->{id} || "";
     121}
     122
     123=head2 getSocket
     124
     125Returns the IO::Socket for this connection.
     126
     127=cut
     128
     129sub getSocket {
     130    my $self = shift;
     131    my $sid = getStreamID($self);
     132    return $self->{STREAM}->GetSock($sid) || -1;
     133}
     134
     135=head2 OwlProcess
     136
     137Non-blocking connection processing. For use in a select loop.
     138
     139=cut
     140
     141sub OwlProcess {
     142    my $self = shift;
     143    my $status = $self->Process(0);
     144    if ( !defined($status) ) {
     145        my $jid = $self->{SESSION}->{FULLJID};
     146        BarnOwl::error("Jabber account $jid disconnected!");
     147        BarnOwl::Module::Jabber::do_logout($jid);
     148    }
     149}
     150
    112151=head1 SEE ALSO
    113152
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm

    r7f33c18 r6b580b0  
    3737    return 0 unless exists $self->{$jidStr};
    3838
     39    BarnOwl::remove_dispatch($self->{$jidStr}->{Client}->{fileno}) if $self->{$jidStr}->{Client}->{fileno};
    3940    $self->{$jidStr}->{Client}->Disconnect()
    4041      if $self->{$jidStr}->{Client};
     
    5152    return 0 if $oldJidStr eq $newJidStr;
    5253
    53     $self->{$newJidStr} = $self->{$oldJidStr}; 
     54    $self->{$newJidStr} = $self->{$oldJidStr};
    5455    delete $self->{$oldJidStr};
    5556    return 1;
  • perl/lib/BarnOwl/ModuleLoader.pm

    rb0c8011 rb4fcc06  
    2424                $modules{$1} = 1;
    2525            } elsif(-d "$dir/$f" && -d "$dir/$f/lib") {
    26                 push @INC, "$dir/$f/lib" unless grep m{^$dir/$f/lib$}, @INC;
     26                unshift @INC, "$dir/$f/lib" unless grep m{^$dir/$f/lib$}, @INC;
    2727                $modules{$f} = 1;
    2828            }
Note: See TracChangeset for help on using the changeset viewer.