Changeset 1cf32e7d
- Timestamp:
- Mar 28, 2007, 9:32:11 PM (17 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- b3a40c7
- Parents:
- 3066d23 (diff), a387d12e (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. - Files:
-
- 15 added
- 12 edited
- 44 moved
Legend:
- Unmodified
- Added
- Removed
-
BUGS
r69d66aa7 r0337203 5 5 * reply to resource names from ichat (foo's computer) fails badly [hartmans] 6 6 * viewuser doesn't work with AIM or Jabber 7 * jmuc join'ing a MUC you're already in has weird behavior [nelhage] -
Makefile.in
ra956288 r702aee7 31 31 32 32 EXE = barnowl 33 PERL_MODULES = Jabber 34 MODULE_DIRS = $(PERL_MODULES:%=perl/modules/%) 33 35 34 36 BASE_OBJS = $(BASE_SRCS:.c=.o) … … 57 59 ./tester reg 58 60 59 clean: libfaimclean 61 clean: libfaimclean modules_clean 60 62 $(RM) $(EXE) tester *.o $(AUTOGEN) owl_prototypes.h.new 61 63 62 64 distclean: clean libfaimdistclean 63 65 $(RM) config.cache config.log config.status Makefile config.h TAGS *~ core 66 67 .PHONY: $(MODULE_DIRS) 68 69 modules: $(MODULE_DIRS) 70 modules_clean: 71 for i in $(MODULE_DIRS); do \ 72 cd $$i; test ! -f Makefile || make clean; \ 73 done 74 75 $(MODULE_DIRS): %: %/Makefile 76 ( cd $@ && make $(notdir $@).par ) 77 78 $(MODULE_DIRS:=/Makefile): %/Makefile: %/Makefile.PL 79 ( cd $(dir $@) && perl -I../../lib Makefile.PL ) 64 80 65 81 proto: owl_prototypes.h … … 104 120 (cd libfaim; $(MAKE) distclean) 105 121 106 all: $(EXE) 122 all: $(EXE) $(MODULE_DIRS) 107 123 108 124 install: all installdirs 109 125 ${INSTALL_PROGRAM} $(EXE) ${DESTDIR}${bindir}/$(EXE) 110 126 ${INSTALL_DATA} doc/owl.1 ${DESTDIR}${mandir}/man1/barnowl.1 111 tar -C perl -c . | tar -C ${DESTDIR}${datadir} -x 127 ${INSTALL} -d ${DESTDIR}${datadir}/lib 128 ${INSTALL} -d ${DESTDIR}${datadir}/modules 129 tar -C perl/lib --exclude .svn -c . | tar -C ${DESTDIR}${datadir}/lib -x 130 for i in $(PERL_MODULES); do \ 131 ${INSTALL_DATA} perl/modules/$$i/$$i.par ${DESTDIR}${datadir}/modules/$$i.par; \ 132 done 112 133 113 134 installdirs: mkinstalldirs -
fmtext.c
r801b7ac ra387d12e 9 9 { 10 10 f->textlen=0; 11 f->textbuff=owl_strdup(""); 11 f->bufflen=5; 12 f->textbuff=owl_malloc(5); 12 13 f->fmbuff=owl_malloc(5); 13 14 f->fgcolorbuff=owl_malloc(5); 14 15 f->bgcolorbuff=owl_malloc(5); 16 f->textbuff[0]=0; 15 17 f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE; 16 18 f->fgcolorbuff[0]=OWL_COLOR_DEFAULT; … … 18 20 } 19 21 22 /* Clear the data from an fmtext, but don't deallocate memory. This 23 fmtext can then be appended to again. */ 24 void owl_fmtext_clear(owl_fmtext *f) 25 { 26 f->textlen = 0; 27 f->textbuff[0] = 0; 28 f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE; 29 f->fgcolorbuff[0]=OWL_COLOR_DEFAULT; 30 f->bgcolorbuff[0]=OWL_COLOR_DEFAULT; 31 } 32 20 33 /* Internal function. Set the attribute 'attr' from index 'first' to 21 34 * index 'last' … … 59 72 } 60 73 74 void _owl_fmtext_realloc(owl_fmtext *f, int newlen) /*noproto*/ 75 { 76 if(newlen + 1 > f->bufflen) { 77 f->textbuff=owl_realloc(f->textbuff, newlen+1); 78 f->fmbuff=owl_realloc(f->fmbuff, newlen+1); 79 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1); 80 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1); 81 f->bufflen = newlen+1; 82 } 83 } 84 61 85 /* append text to the end of 'f' with attribute 'attr' and color 62 86 * 'color' … … 65 89 { 66 90 int newlen; 67 68 91 newlen=strlen(f->textbuff)+strlen(text); 69 f->textbuff=owl_realloc(f->textbuff, newlen+2); 70 f->fmbuff=owl_realloc(f->fmbuff, newlen+2); 71 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+2); 72 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+2); 73 92 _owl_fmtext_realloc(f, newlen); 93 74 94 strcat(f->textbuff, text); 75 95 _owl_fmtext_set_attr(f, attr, f->textlen, newlen); … … 154 174 155 175 newlen=strlen(f->textbuff)+(stop-start+1); 156 f->textbuff=owl_realloc(f->textbuff, newlen+1); 157 f->fmbuff=owl_realloc(f->fmbuff, newlen+1); 158 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1); 159 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1); 176 _owl_fmtext_realloc(f, newlen); 160 177 161 178 strncat(f->textbuff, in->textbuff+start, stop-start+1); -
functions.c
ra5fc448 r0337203 1035 1035 1036 1036 /* execute the commands in shutdown */ 1037 ret = owl_perlconfig_execute("BarnOwl::Hooks:: shutdown();");1037 ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();"); 1038 1038 if (ret) owl_free(ret); 1039 1039 … … 3365 3365 3366 3366 if(aim && zephyr) { 3367 if(owl_perlconfig_is_function("BarnOwl::Hooks:: get_blist")) {3368 char * perlblist = owl_perlconfig_execute("BarnOwl::Hooks:: get_blist()");3367 if(owl_perlconfig_is_function("BarnOwl::Hooks::_get_blist")) { 3368 char * perlblist = owl_perlconfig_execute("BarnOwl::Hooks::_get_blist()"); 3369 3369 if(perlblist) { 3370 3370 owl_fmtext_append_ztext(&fm, perlblist); -
global.c
r8e401cae ra387d12e 108 108 109 109 owl_obarray_init(&(g->obarray)); 110 111 owl_message_init_fmtext_cache(); 110 112 } 111 113 -
message.c
r963542b ra387d12e 13 13 static const char fileIdent[] = "$Id$"; 14 14 15 static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE]; 16 static owl_fmtext_cache * fmtext_cache_next = fmtext_cache; 17 18 void owl_message_init_fmtext_cache () 19 { 20 int i; 21 for(i = 0; i < OWL_FMTEXT_CACHE_SIZE; i++) { 22 owl_fmtext_init_null(&(fmtext_cache[i].fmtext)); 23 fmtext_cache[i].message = NULL; 24 } 25 } 26 27 owl_fmtext_cache * owl_message_next_fmtext() /*noproto*/ 28 { 29 if(fmtext_cache_next->message != NULL) { 30 owl_message_invalidate_format(fmtext_cache_next->message); 31 } 32 owl_fmtext_cache * f = fmtext_cache_next; 33 fmtext_cache_next++; 34 if(fmtext_cache_next - fmtext_cache == OWL_FMTEXT_CACHE_SIZE) 35 fmtext_cache_next = fmtext_cache; 36 return f; 37 } 38 15 39 void owl_message_init(owl_message *m) 16 40 { … … 19 43 m->delete=0; 20 44 m->zwriteline=NULL; 21 m->invalid_format=1;22 45 23 46 owl_message_set_hostname(m, ""); … … 29 52 m->timestr[strlen(m->timestr)-1]='\0'; 30 53 31 /* initialize the fmtext */ 32 owl_fmtext_init_null(&(m->fmtext)); 54 m->fmtext = NULL; 33 55 } 34 56 … … 106 128 void owl_message_invalidate_format(owl_message *m) 107 129 { 108 m->invalid_format=1; 130 if(m->fmtext) { 131 m->fmtext->message = NULL; 132 owl_fmtext_clear(&(m->fmtext->fmtext)); 133 m->fmtext=NULL; 134 } 109 135 } 110 136 … … 112 138 { 113 139 owl_message_format(m); 114 return(&(m->fmtext ));140 return(&(m->fmtext->fmtext)); 115 141 } 116 142 … … 120 146 owl_view *v; 121 147 122 if (m->invalid_format) { 148 if (!m->fmtext) { 149 m->fmtext = owl_message_next_fmtext(); 150 m->fmtext->message = m; 123 151 /* for now we assume there's just the one view and use that style */ 124 152 v=owl_global_get_current_view(&g); 125 153 s=owl_view_get_style(v); 126 154 127 owl_fmtext_free(&(m->fmtext)); 128 owl_fmtext_init_null(&(m->fmtext)); 129 owl_style_get_formattext(s, &(m->fmtext), m); 130 m->invalid_format=0; 155 owl_style_get_formattext(s, &(m->fmtext->fmtext), m); 131 156 } 132 157 } … … 392 417 char *owl_message_get_text(owl_message *m) 393 418 { 394 return(owl_fmtext_get_text(&(m->fmtext )));419 return(owl_fmtext_get_text(&(m->fmtext->fmtext))); 395 420 } 396 421 … … 437 462 if (m == NULL) return(0); 438 463 owl_message_format(m); 439 return(owl_fmtext_num_lines(&(m->fmtext )));464 return(owl_fmtext_num_lines(&(m->fmtext->fmtext))); 440 465 } 441 466 … … 504 529 owl_fmtext_init_null(&b); 505 530 506 owl_fmtext_truncate_lines(&(m->fmtext ), aline, bline-aline+1, &a);531 owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a); 507 532 owl_fmtext_truncate_cols(&a, acol, bcol, &b); 508 533 if (fgcolor!=OWL_COLOR_DEFAULT) { … … 698 723 owl_message_format(m); /* is this necessary? */ 699 724 700 return (owl_fmtext_search(&(m->fmtext ), string));725 return (owl_fmtext_search(&(m->fmtext->fmtext), string)); 701 726 } 702 727 … … 989 1014 owl_list_free_simple(&(m->attributes)); 990 1015 991 owl_ fmtext_free(&(m->fmtext));992 } 1016 owl_message_invalidate_format(m); 1017 } -
owl.c
r2058d7a r72c210f 318 318 /* execute the startup function in the configfile */ 319 319 owl_function_debugmsg("startup: executing perl startup, if applicable"); 320 perlout = owl_perlconfig_execute("BarnOwl::Hooks:: startup();");320 perlout = owl_perlconfig_execute("BarnOwl::Hooks::_startup();"); 321 321 if (perlout) owl_free(perlout); 322 322 … … 397 397 398 398 owl_function_debugmsg("startup: set style for the view: %s", owl_global_get_default_style(&g)); 399 owl_view_set_style(owl_global_get_current_view(&g), 400 owl_global_get_style_by_name(&g, owl_global_get_default_style(&g))); 399 s = owl_global_get_style_by_name(&g, owl_global_get_default_style(&g)); 400 if(s) 401 owl_view_set_style(owl_global_get_current_view(&g), s); 402 else 403 owl_function_error("No such style: %s", owl_global_get_default_style(&g)); 401 404 402 405 owl_function_debugmsg("startup: setting context interactive"); -
owl.h
rd08162a ra387d12e 249 249 typedef struct _owl_fmtext { 250 250 int textlen; 251 int bufflen; 251 252 char *textbuff; 252 253 char *fmbuff; … … 329 330 } owl_pair; 330 331 332 struct _owl_fmtext_cache; 333 331 334 typedef struct _owl_message { 332 335 int id; … … 335 338 ZNotice_t notice; 336 339 #endif 337 owl_fmtext fmtext; /* this is now only a CACHED copy */ 338 int invalid_format; /* indicates whether fmtext needs to be regenerated */ 340 struct _owl_fmtext_cache * fmtext; 339 341 int delete; 340 342 char *hostname; … … 344 346 char *zwriteline; 345 347 } owl_message; 348 349 #define OWL_FMTEXT_CACHE_SIZE 1000 350 /* We cache the saved fmtexts for the last bunch of messages we 351 rendered */ 352 typedef struct _owl_fmtext_cache { 353 owl_message * message; 354 owl_fmtext fmtext; 355 } owl_fmtext_cache; 346 356 347 357 typedef struct _owl_style { -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r3066d23 r2cedb7a 1 # -*- mode: cperl; cperl-indent-level: 4; indent-tabs-mode: nil -*- 1 use strict; 2 2 use warnings; 3 use strict; 4 5 package BarnOwl::Jabber; 3 4 package BarnOwl::Module::Jabber; 5 6 =head1 NAME 7 8 BarnOwl::Module::Jabber 9 10 =head1 DESCRIPTION 11 12 This module implements Jabber support for barnowl. 13 14 =cut 15 16 use BarnOwl; 17 use BarnOwl::Hooks; 18 use BarnOwl::Message::Jabber; 19 use BarnOwl::Module::Jabber::Connection; 20 use BarnOwl::Module::Jabber::ConnectionManager; 6 21 7 22 use Authen::SASL qw(Perl); … … 10 25 use Net::DNS; 11 26 use Getopt::Long; 27 28 our $VERSION = 0.1; 12 29 13 30 BEGIN { … … 38 55 ################################################################################ 39 56 40 41 ################################################################################ 42 ################################################################################ 43 package BarnOwl::Jabber::Connection; 44 45 use base qw(Net::Jabber::Client); 46 47 sub new { 48 my $class = shift; 49 50 my %args = (); 51 if(BarnOwl::getvar('debug') eq 'on') { 52 $args{debuglevel} = 1; 53 $args{debugfile} = 'jabber.log'; 54 } 55 my $self = $class->SUPER::new(%args); 56 $self->{_BARNOWL_MUCS} = []; 57 return $self; 58 } 59 60 =head2 MUCJoin 61 62 Extends MUCJoin to keep track of the MUCs we're joined to as 63 Net::Jabber::MUC objects. Takes the same arguments as 64 L<Net::Jabber::MUC/new> and L<Net::Jabber::MUC/Connect> 65 66 =cut 67 68 sub MUCJoin { 69 my $self = shift; 70 my $muc = Net::Jabber::MUC->new(connection => $self, @_); 71 $muc->Join(@_); 72 73 # Add MUC to list of MUCs, unless we're just changing nicks. 74 push @{$self->MUCs}, $muc unless grep {$_->BaseJID eq $muc->BaseJID} $self->MUCs; 75 } 76 77 =head2 MUCLeave ARGS 78 79 Leave a MUC. The MUC is specified in the same form as L</FindMUC> 80 81 =cut 82 83 sub MUCLeave { 84 my $self = shift; 85 my $muc = $self->FindMUC(@_); 86 return unless $muc; 87 88 $muc->Leave(); 89 $self->{_BARNOWL_MUCS} = [grep {$_->BaseJID ne $muc->BaseJID} $self->MUCs]; 90 } 91 92 =head2 FindMUC ARGS 93 94 Return the Net::Jabber::MUC object representing a specific MUC we're 95 joined to, undef if it doesn't exists. ARGS can be either JID => $JID, 96 or Room => $room, Server => $server. 97 98 =cut 99 100 sub FindMUC { 101 my $self = shift; 102 103 my %args; 104 while($#_ >= 0) { $args{ lc(pop(@_)) } = pop(@_); } 105 106 my $jid; 107 if($args{jid}) { 108 $jid = $args{jid}; 109 } elsif($args{room} && $args{server}) { 110 $jid = Net::Jabber::JID->new(userid => $args{room}, 111 server => $args{server}); 112 } 113 $jid = $jid->GetJID('base') if UNIVERSAL::isa($jid, 'Net::XMPP::JID'); 114 115 foreach my $muc ($self->MUCs) { 116 return $muc if $muc->BaseJID eq $jid; 117 } 118 return undef; 119 } 120 121 =head2 MUCs 122 123 Returns a list (or arrayref in scalar context) of Net::Jabber::MUC 124 objects we believe ourself to be connected to. 125 126 =cut 127 128 sub MUCs { 129 my $self = shift; 130 my $mucs = $self->{_BARNOWL_MUCS}; 131 return wantarray ? @$mucs : $mucs; 132 } 133 134 ################################################################################ 135 ################################################################################ 136 package BarnOwl::Jabber::ConnectionManager; 137 sub new { 138 my $class = shift; 139 return bless { }, $class; 140 } 141 142 sub addConnection { 143 my $self = shift; 144 my $jidStr = shift; 145 146 my $client = BarnOwl::Jabber::Connection->new; 147 148 $self->{$jidStr}->{Client} = $client; 149 $self->{$jidStr}->{Roster} = $client->Roster(); 150 $self->{$jidStr}->{Status} = "available"; 151 return $client; 152 } 153 154 sub removeConnection { 155 my $self = shift; 156 my $jidStr = shift; 157 return 0 unless exists $self->{$jidStr}; 158 159 $self->{$jidStr}->{Client}->Disconnect() 160 if $self->{$jidStr}->{Client}; 161 delete $self->{$jidStr}; 162 163 return 1; 164 } 165 166 sub connected { 167 my $self = shift; 168 return scalar keys %{ $self }; 169 } 170 171 sub getJIDs { 172 my $self = shift; 173 return keys %{ $self }; 174 } 175 176 sub jidExists { 177 my $self = shift; 178 my $jidStr = shift; 179 return exists $self->{$jidStr}; 180 } 181 182 sub sidExists { 183 my $self = shift; 184 my $sid = shift || ""; 185 foreach my $c ( values %{ $self } ) { 186 return 1 if ($c->{Client}->{SESSION}->{id} eq $sid); 187 } 188 return 0; 189 } 190 191 sub getConnectionFromSid { 192 my $self = shift; 193 my $sid = shift; 194 foreach my $c (values %{ $self }) { 195 return $c->{Client} if $c->{Client}->{SESSION}->{id} eq $sid; 196 } 197 return undef; 198 } 199 200 sub getConnectionFromJID { 201 my $self = shift; 202 my $jid = shift; 203 $jid = $jid->GetJID('full') if UNIVERSAL::isa($jid, 'Net::XMPP::JID'); 204 return $self->{$jid}->{Client} if exists $self->{$jid}; 205 } 206 207 sub getRosterFromSid { 208 my $self = shift; 209 my $sid = shift; 210 foreach my $c (values %{ $self }) { 211 return $c->{Roster} 212 if $c->{Client}->{SESSION}->{id} eq $sid; 213 } 214 return undef; 215 } 216 217 sub getRosterFromJID { 218 my $self = shift; 219 my $jid = shift; 220 $jid = $jid->GetJID('full') if UNIVERSAL::isa($jid, 'Net::XMPP::JID'); 221 return $self->{$jid}->{Roster} if exists $self->{$jid}; 222 } 223 ################################################################################ 224 225 package BarnOwl::Jabber; 226 227 our $conn = new BarnOwl::Jabber::ConnectionManager unless $conn;; 57 our $conn = BarnOwl::Module::Jabber::ConnectionManager->new unless $conn;; 228 58 our %vars; 229 59 … … 231 61 if ( *BarnOwl::queue_message{CODE} ) { 232 62 register_owl_commands(); 233 register_keybindings() unless $BarnOwl::reload;234 register_filters() unless $BarnOwl::reload;235 push @::onMainLoop, sub { BarnOwl::Jabber::onMainLoop(@_) };236 push @::onGetBuddyList, sub { BarnOwl::Jabber::onGetBuddyList(@_) };63 register_keybindings(); 64 register_filters(); 65 $BarnOwl::Hooks::mainLoop->add(\&onMainLoop); 66 $BarnOwl::Hooks::getBuddyList->add(\&onGetBuddyList); 237 67 $vars{show} = ''; 238 68 } else { … … 243 73 } 244 74 245 push @::onStartSubs, sub { BarnOwl::Jabber::onStart(@_) };75 $BarnOwl::Hooks::startup->add(\&onStart); 246 76 247 77 sub onMainLoop { … … 305 135 $blistStr .= " [" . ( $rq{show} ? $rq{show} : 'online' ) . "]"; 306 136 $blistStr .= " " . $rq{status} if $rq{status}; 307 $blistStr = boldify($blistStr);137 $blistStr = BarnOwl::Style::boldify($blistStr); 308 138 } 309 139 else { … … 328 158 my $roster = $conn->getRosterFromJID($jid); 329 159 if ($roster) { 330 $blist .= "\n" . boldify("Jabber Roster for $jid\n");160 $blist .= "\n" . BarnOwl::Style::boldify("Jabber Roster for $jid\n"); 331 161 332 162 foreach my $group ( $roster->groups() ) { … … 499 329 # when we reload 500 330 $client->SetMessageCallBacks( 501 chat => sub { BarnOwl:: Jabber::process_incoming_chat_message(@_) },502 error => sub { BarnOwl:: Jabber::process_incoming_error_message(@_) },503 groupchat => sub { BarnOwl:: Jabber::process_incoming_groupchat_message(@_) },504 headline => sub { BarnOwl:: Jabber::process_incoming_headline_message(@_) },505 normal => sub { BarnOwl:: Jabber::process_incoming_normal_message(@_) }331 chat => sub { BarnOwl::Module::Jabber::process_incoming_chat_message(@_) }, 332 error => sub { BarnOwl::Module::Jabber::process_incoming_error_message(@_) }, 333 groupchat => sub { BarnOwl::Module::Jabber::process_incoming_groupchat_message(@_) }, 334 headline => sub { BarnOwl::Module::Jabber::process_incoming_headline_message(@_) }, 335 normal => sub { BarnOwl::Module::Jabber::process_incoming_normal_message(@_) } 506 336 ); 507 337 $client->SetPresenceCallBacks( 508 available => sub { BarnOwl:: Jabber::process_presence_available(@_) },509 unavailable => sub { BarnOwl:: Jabber::process_presence_available(@_) },510 subscribe => sub { BarnOwl:: Jabber::process_presence_subscribe(@_) },511 subscribed => sub { BarnOwl:: Jabber::process_presence_subscribed(@_) },512 unsubscribe => sub { BarnOwl:: Jabber::process_presence_unsubscribe(@_) },513 unsubscribed => sub { BarnOwl:: Jabber::process_presence_unsubscribed(@_) },514 error => sub { BarnOwl:: Jabber::process_presence_error(@_) });338 available => sub { BarnOwl::Module::Jabber::process_presence_available(@_) }, 339 unavailable => sub { BarnOwl::Module::Jabber::process_presence_available(@_) }, 340 subscribe => sub { BarnOwl::Module::Jabber::process_presence_subscribe(@_) }, 341 subscribed => sub { BarnOwl::Module::Jabber::process_presence_subscribed(@_) }, 342 unsubscribe => sub { BarnOwl::Module::Jabber::process_presence_unsubscribe(@_) }, 343 unsubscribed => sub { BarnOwl::Module::Jabber::process_presence_unsubscribed(@_) }, 344 error => sub { BarnOwl::Module::Jabber::process_presence_error(@_) }); 515 345 516 346 my $status = $client->Connect( %{ $vars{jlogin_connhash} } ); … … 802 632 my $str = ""; 803 633 foreach my $jid ($conn->getJIDs()) { 804 $str .= boldify("Conferences for $jid:\n");634 $str .= BarnOwl::Style::boldify("Conferences for $jid:\n"); 805 635 my $connection = $conn->getConnectionFromJID($jid); 806 636 foreach my $muc ($connection->MUCs) { … … 1026 856 my $m = j2o( $j, { direction => 'out' } ); 1027 857 if ( $vars{jwrite}{type} ne 'groupchat') { 1028 BarnOwl::add_ and_log_message($m);858 BarnOwl::add_message($m); 1029 859 } 1030 860 … … 1309 1139 } 1310 1140 1311 sub boldify($) {1312 my $str = shift;1313 1314 return '@b(' . $str . ')' if ( $str !~ /\)/ );1315 return '@b<' . $str . '>' if ( $str !~ /\>/ );1316 return '@b{' . $str . '}' if ( $str !~ /\}/ );1317 return '@b[' . $str . ']' if ( $str !~ /\]/ );1318 1319 my $txt = "$str";1320 $txt =~ s{[)]}{)\@b[)]\@b(}g;1321 return '@b(' . $txt . ')';1322 }1323 1324 1141 sub getServerFromJID { 1325 1142 my $jid = shift; … … 1459 1276 } 1460 1277 1461 #####################################################################1462 #####################################################################1463 1464 package BarnOwl::Message::Jabber;1465 1466 our @ISA = qw( BarnOwl::Message );1467 1468 sub jtype { shift->{jtype} };1469 sub from { shift->{from} };1470 sub to { shift->{to} };1471 sub room { shift->{room} };1472 sub status { shift->{status} }1473 1474 sub login_extra {1475 my $self = shift;1476 my $show = $self->{show};1477 my $status = $self->status;1478 my $s = "";1479 $s .= $show if $show;1480 $s .= ", $status" if $status;1481 return $s;1482 }1483 1484 sub long_sender {1485 my $self = shift;1486 return $self->from;1487 }1488 1489 sub context {1490 return shift->room;1491 }1492 1493 sub smartfilter {1494 my $self = shift;1495 my $inst = shift;1496 1497 my ($filter, $ftext);1498 1499 if($self->jtype eq 'chat') {1500 my $user;1501 if($self->direction eq 'in') {1502 $user = $self->from;1503 } else {1504 $user = $self->to;1505 }1506 return smartfilter_user($user, $inst);1507 } elsif ($self->jtype eq 'groupchat') {1508 my $room = $self->room;1509 $filter = "jabber-room-$room";1510 $ftext = qq{type ^jabber\$ and room ^$room\$};1511 BarnOwl::filter("$filter $ftext");1512 return $filter;1513 } elsif ($self->login ne 'none') {1514 return smartfilter_user($self->from, $inst);1515 }1516 }1517 1518 sub smartfilter_user {1519 my $user = shift;1520 my $inst = shift;1521 1522 $user = Net::Jabber::JID->new($user)->GetJID( $inst ? 'full' : 'base' );1523 my $filter = "jabber-user-$user";1524 my $ftext =1525 qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) }1526 . qq{or ( direction ^out\$ and to ^$user ) ) };1527 BarnOwl::filter("$filter $ftext");1528 return $filter;1529 1530 }1531 1532 1533 1278 1; -
perl/modules/Jabber/lib/Net/Jabber.pm
r0ff8d110 rc2bed55 61 61 For a client: 62 62 use Net::Jabber; 63 my $client = new Net::Jabber::Client();63 my $client = Net::Jabber::Client->new(); 64 64 65 65 For a component: 66 66 use Net::Jabber; 67 my $component = new Net::Jabber::Component();67 my $component = Net::Jabber::Component->new(); 68 68 69 69 =head1 METHODS -
perl/modules/Jabber/lib/Net/Jabber/Component.pm
r0ff8d110 rc2bed55 54 54 use Net::Jabber; 55 55 56 $Con = new Net::Jabber::Component();56 $Con = Net::Jabber::Component->new(); 57 57 58 58 $Con->Execute(hostname=>"jabber.org", -
perl/modules/Jabber/lib/Net/Jabber/Data.pm
r0ff8d110 rc2bed55 56 56 Net::Jabber::Client module. 57 57 58 my $xdb = new Net::Jabber::XDB(%hash);58 my $xdb = Net::Jabber::XDB->new(%hash); 59 59 60 60 There has been a change from the old way of handling the callbacks. … … 83 83 use Net::Jabber; 84 84 85 my $xdb = new Net::Jabber::XDB();85 my $xdb = Net::Jabber::XDB->new(); 86 86 $data = $xdb->NewData("jabber:iq:auth"); 87 87 -
perl/modules/Jabber/lib/Net/Jabber/Dialback.pm
r0ff8d110 rc2bed55 38 38 the XML::Stream hash. For example: 39 39 40 my $dialback = new Net::Jabber::Dialback(%hash);40 my $dialback = Net::Jabber::Dialback->new(%hash); 41 41 42 42 You now have access to all of the retrieval functions available. … … 46 46 use Net::Jabber qw(Server); 47 47 48 $DB = new Net::Jabber::Dialback("verify");49 $DB = new Net::Jabber::Dialback("result");48 $DB = Net::Jabber::Dialback->new("verify"); 49 $DB = Net::Jabber::Dialback->new("result"); 50 50 51 51 Please see the specific documentation for Net::Jabber::Dialback::Result … … 98 98 { 99 99 my ($temp) = @_; 100 return new Net::Jabber::Dialback::Result()100 return Net::Jabber::Dialback::Result->new() 101 101 if ($temp eq "result"); 102 return new Net::Jabber::Dialback::Verify()102 return Net::Jabber::Dialback::Verify->new() 103 103 if ($temp eq "verify"); 104 104 105 105 my @temp = @{$temp}; 106 return new Net::Jabber::Dialback::Result(@temp)106 return Net::Jabber::Dialback::Result->new(@temp) 107 107 if ($temp[0] eq "db:result"); 108 return new Net::Jabber::Dialback::Verify(@temp)108 return Net::Jabber::Dialback::Verify->new(@temp) 109 109 if ($temp[0] eq "db:verify"); 110 110 } -
perl/modules/Jabber/lib/Net/Jabber/Dialback/Result.pm
r0ff8d110 rc2bed55 38 38 the XML::Stream hash. For example: 39 39 40 my $dialback = new Net::Jabber::Dialback::Result(%hash);40 my $dialback = Net::Jabber::Dialback::Result->new(%hash); 41 41 42 42 There has been a change from the old way of handling the callbacks. … … 63 63 use Net::Jabber qw(Server); 64 64 65 $Result = new Net::Jabber::Dialback::Result();65 $Result = Net::Jabber::Dialback::Result->new(); 66 66 67 67 Now you can call the creation functions below to populate the tag before -
perl/modules/Jabber/lib/Net/Jabber/Dialback/Verify.pm
r0ff8d110 rc2bed55 38 38 the XML::Stream hash. For example: 39 39 40 my $dialback = new Net::Jabber::Dialback::Verify(%hash);40 my $dialback = Net::Jabber::Dialback::Verify->new(%hash); 41 41 42 42 There has been a change from the old way of handling the callbacks. … … 63 63 use Net::Jabber qw(Server); 64 64 65 $Verify = new Net::Jabber::Dialback::Verify();65 $Verify = Net::Jabber::Dialback::Verify->new(); 66 66 67 67 Now you can call the creation functions below to populate the tag before -
perl/modules/Jabber/lib/Net/Jabber/IQ.pm
r0ff8d110 rc2bed55 63 63 sub RemoveX { my $self = shift; $self->RemoveChild(@_); } 64 64 65 sub _new_jid { my $self = shift; return new Net::Jabber::JID(@_); }66 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }67 sub _iq { my $self = shift; return new Net::Jabber::IQ(@_); }65 sub _new_jid { my $self = shift; return Net::Jabber::JID->new(@_); } 66 sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); } 67 sub _iq { my $self = shift; return Net::Jabber::IQ->new(@_); } 68 68 69 69 1; -
perl/modules/Jabber/lib/Net/Jabber/Key.pm
r0ff8d110 rc2bed55 41 41 =head2 Basic Functions 42 42 43 $Key = new Net::Jabber::Key();43 $Key = Net::Jabber::Key->new(); 44 44 45 45 $key = $Key->Generate(); … … 97 97 my $self = { }; 98 98 99 $self->{DEBUG} = new Net::Jabber::Debug(usedefault=>1,100 header=>"NJ::Key");99 $self->{DEBUG} = Net::Jabber::Debug->new(usedefault=>1, 100 header=>"NJ::Key"); 101 101 102 102 $self->{VERSION} = $VERSION; -
perl/modules/Jabber/lib/Net/Jabber/Log.pm
r0ff8d110 rc2bed55 38 38 XML::Parser Tree array. For example: 39 39 40 my $log = new Net::Jabber::Log(@tree);40 my $log = Net::Jabber::Log->new(@tree); 41 41 42 42 There has been a change from the old way of handling the callbacks. … … 59 59 use Net::Jabber; 60 60 61 $Log = new Net::Jabber::Log();61 $Log = Net::Jabber::Log->new(); 62 62 63 63 Now you can call the creation functions below to populate the tag before … … 176 176 bless($self, $proto); 177 177 178 $self->{DEBUG} = new Net::Jabber::Debug(usedefault=>1,179 178 $self->{DEBUG} = Net::Jabber::Debug->new(usedefault=>1, 179 header=>"NJ::Log"); 180 180 181 181 if ("@_" ne ("")) -
perl/modules/Jabber/lib/Net/Jabber/Message.pm
r0ff8d110 rc2bed55 58 58 sub RemoveX { my $self = shift; $self->RemoveChild(@_); } 59 59 60 sub _new_jid { my $self = shift; return new Net::Jabber::JID(@_); }61 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }62 sub _message { my $self = shift; return new Net::Jabber::Message(@_); }60 sub _new_jid { my $self = shift; return Net::Jabber::JID->new(@_); } 61 sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); } 62 sub _message { my $self = shift; return Net::Jabber::Message->new(@_); } 63 63 64 64 1; -
perl/modules/Jabber/lib/Net/Jabber/Presence.pm
r0ff8d110 rc2bed55 58 58 sub RemoveX { my $self = shift; $self->RemoveChild(@_); } 59 59 60 sub _new_jid { my $self = shift; return new Net::Jabber::JID(@_); }61 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }62 sub _presence { my $self = shift; return new Net::Jabber::Presence(@_); }60 sub _new_jid { my $self = shift; return Net::Jabber::JID->new(@_); } 61 sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); } 62 sub _presence { my $self = shift; return Net::Jabber::Presence->new(@_); } 63 63 64 64 1; -
perl/modules/Jabber/lib/Net/Jabber/Protocol.pm
r0ff8d110 rc2bed55 78 78 79 79 use Net::Jabber qw( Client ); 80 $Con = new Net::Jabber::Client(); # From80 $Con = Net::Jabber::Client->new(); # From 81 81 $status = $Con->Connect(hostname=>"jabber.org"); # Net::Jabber::Client 82 82 … … 84 84 85 85 use Net::Jabber qw( Component ); 86 $Con = new Net::Jabber::Component(); #86 $Con = Net::Jabber::Component->new(); # 87 87 $status = $Con->Connect(hostname=>"jabber.org", # From 88 88 secret=>"bob"); # Net::Jabber::Component … … 1660 1660 if exists($Net::Jabber::Query::TAGS{'http://jabber.org/protocol/feature-neg'}); 1661 1661 1662 my $query = new Net::Jabber::Query($tag);1662 my $query = Net::Jabber::Query->new($tag); 1663 1663 $query->SetXMLNS("http://jabber.org/protocol/feature-neg"); 1664 1664 my $xdata = $query->NewX("jabber:x:data"); … … 2183 2183 while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); } 2184 2184 2185 my $query = new Net::Jabber::Stanza("query");2185 my $query = Net::Jabber::Stanza->new("query"); 2186 2186 $query->SetXMLNS("jabber:iq:rpc"); 2187 2187 -
perl/modules/Jabber/lib/Net/Jabber/Server.pm
r0ff8d110 rc2bed55 54 54 use Net::Jabber qw(Server); 55 55 56 $Server = new Net::Jabber::Server();56 $Server = Net::Jabber::Server->new(); 57 57 58 58 $Server->Start(); … … 155 155 bless($self, $proto); 156 156 157 $self->{KEY} = new Net::Jabber::Key();157 $self->{KEY} = Net::Jabber::Key->new(); 158 158 159 159 $self->{DEBUG} = 160 new Net::Jabber::Debug(level=>exists($args{debuglevel}) ? $args{debuglevel} : -1,161 file=>exists($args{debugfile}) ? $args{debugfile} : "stdout",162 time=>exists($args{debugtime}) ? $args{debugtime} : 0,163 setdefault=>1,164 header=>"NJ::Server"165 );160 Net::Jabber::Debug->new(level=>exists($args{debuglevel}) ? $args{debuglevel} : -1, 161 file=>exists($args{debugfile}) ? $args{debugfile} : "stdout", 162 time=>exists($args{debugtime}) ? $args{debugtime} : 0, 163 setdefault=>1, 164 header=>"NJ::Server" 165 ); 166 166 167 167 $self->{SERVER} = { hostname => "localhost", … … 329 329 $self->{DEBUG}->Log2("dbresultHandler: dbresult(",$dbresult->GetXML(),")"); 330 330 331 my $dbverify = new Net::Jabber::Dialback::Verify();331 my $dbverify = Net::Jabber::Dialback::Verify->new(); 332 332 $dbverify->SetVerify(to=>$dbresult->GetFrom(), 333 333 from=>$dbresult->GetTo(), -
perl/modules/Jabber/lib/Net/Jabber/Stanza.pm
r0ff8d110 rc2bed55 1738 1738 sub RemoveQuery { my $self = shift; $self->RemoveChild(@_); } 1739 1739 1740 sub _new_jid { my $self = shift; return new Net::Jabber::JID(@_); }1741 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }1740 sub _new_jid { my $self = shift; return Net::Jabber::JID->new(@_); } 1741 sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); } 1742 1742 1743 1743 -
perl/modules/Jabber/lib/Net/Jabber/XDB.pm
r0ff8d110 rc2bed55 44 44 XML::Parser Tree array. For example: 45 45 46 my $xdb = new Net::Jabber::XDB(@tree);46 my $xdb = Net::Jabber::XDB->new(@tree); 47 47 48 48 There has been a change from the old way of handling the callbacks. … … 65 65 use Net::Jabber; 66 66 67 $XDB = new Net::Jabber::XDB();67 $XDB = Net::Jabber::XDB->new(); 68 68 $XDBType = $XDB->NewData( type ); 69 69 $XDBType->SetXXXXX("yyyyy"); … … 418 418 while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); } 419 419 420 my $reply = new Net::Jabber::XDB();420 my $reply = Net::Jabber::XDB->new(); 421 421 422 422 $reply->SetID($self->GetID()) if ($self->GetID() ne ""); -
perl/modules/Jabber/lib/Net/XMPP.pm
r0ff8d110 rc2bed55 61 61 62 62 use Net::XMPP; 63 my $client = new Net::XMPP::Client();63 my $client = Net::XMPP::Client->new(); 64 64 65 65 =head1 METHODS -
perl/modules/Jabber/lib/Net/XMPP/Client.pm
r0ff8d110 rc2bed55 54 54 use Net::XMPP; 55 55 56 $Con = new Net::XMPP::Client();56 $Con = Net::XMPP::Client->new(); 57 57 58 58 $Con->SetCallbacks(...); -
perl/modules/Jabber/lib/Net/XMPP/Connection.pm
reaf9ed0 rc2bed55 81 81 82 82 $self->{DEBUG} = 83 new Net::XMPP::Debug(level => $self->_arg("debuglevel",-1),84 file => $self->_arg("debugfile","stdout"),85 time => $self->_arg("debugtime",0),86 setdefault => 1,87 header => "XMPP::Conn"88 );83 Net::XMPP::Debug->new(level => $self->_arg("debuglevel",-1), 84 file => $self->_arg("debugfile","stdout"), 85 time => $self->_arg("debugtime",0), 86 setdefault => 1, 87 header => "XMPP::Conn" 88 ); 89 89 90 90 $self->{SERVER} = {}; … … 98 98 99 99 $self->{STREAM} = 100 new XML::Stream(style => "node",101 debugfh => $self->{DEBUG}->GetHandle(),102 debuglevel => $self->{DEBUG}->GetLevel(),103 debugtime => $self->{DEBUG}->GetTime(),104 );100 XML::Stream->new(style => "node", 101 debugfh => $self->{DEBUG}->GetHandle(), 102 debuglevel => $self->{DEBUG}->GetLevel(), 103 debugtime => $self->{DEBUG}->GetTime(), 104 ); 105 105 106 106 $self->{RCVDB}->{currentID} = 0; -
perl/modules/Jabber/lib/Net/XMPP/Debug.pm
r0ff8d110 rc2bed55 39 39 =head2 Basic Functions 40 40 41 $Debug = new Net::XMPP::Debug();41 $Debug = Net::XMPP::Debug->new(); 42 42 43 43 $Debug->Init(level=>2, … … 86 86 =head1 EXAMPLE 87 87 88 $Debug = new Net::XMPP:Debug(level=>2,88 $Debug = Net::XMPP:Debug->new(level=>2, 89 89 header=>"Example"); 90 90 -
perl/modules/Jabber/lib/Net/XMPP/IQ.pm
r0ff8d110 rc2bed55 62 62 use Net::XMPP; 63 63 64 $IQ = new Net::XMPP::IQ();64 $IQ = Net::XMPP::IQ->new(); 65 65 $IQType = $IQ->NewChild( type ); 66 66 $IQType->SetXXXXX("yyyyy"); … … 291 291 } 292 292 293 sub _iq { my $self = shift; return new Net::XMPP::IQ(); }293 sub _iq { my $self = shift; return Net::XMPP::IQ->new(); } 294 294 295 295 $FUNCTIONS{Error}->{path} = 'error/text()'; -
perl/modules/Jabber/lib/Net/XMPP/JID.pm
r0ff8d110 rc2bed55 42 42 43 43 sub foo { 44 my $foo = new Net::XMPP::Foo(@_);44 my $foo = Net::XMPP::Foo->new(@_); 45 45 my $from = $foo->GetFrom(); 46 my $JID = new Net::XMPP::JID($from);46 my $JID = Net::XMPP::JID->new($from); 47 47 . 48 48 . … … 56 56 use Net::XMPP; 57 57 58 $JID = new Net::XMPP::JID();58 $JID = Net::XMPP::JID->new(); 59 59 60 60 Now you can call the creation functions below to populate the tag -
perl/modules/Jabber/lib/Net/XMPP/Message.pm
r0ff8d110 rc2bed55 55 55 use Net::XMPP; 56 56 57 $Mess = new Net::XMPP::Message();57 $Mess = Net::XMPP::Message->new(); 58 58 59 59 Now you can call the creation functions below to populate the tag … … 315 315 } 316 316 317 sub _message { my $self = shift; return new Net::XMPP::Message(); }317 sub _message { my $self = shift; return Net::XMPP::Message->new(); } 318 318 319 319 -
perl/modules/Jabber/lib/Net/XMPP/Presence.pm
r0ff8d110 rc2bed55 55 55 use Net::XMPP; 56 56 57 $Pres = new Net::XMPP::Presence();57 $Pres = Net::XMPP::Presence->new(); 58 58 59 59 Now you can call the creation functions below to populate the tag … … 270 270 } 271 271 272 sub _presence { my $self = shift; return new Net::XMPP::Presence(); }272 sub _presence { my $self = shift; return Net::XMPP::Presence->new(); } 273 273 274 274 -
perl/modules/Jabber/lib/Net/XMPP/Protocol.pm
r3405394 rc2bed55 74 74 75 75 use Net::XMPP qw( Client ); 76 $Con = new Net::XMPP::Client(); # From76 $Con = Net::XMPP::Client->new(); # From 77 77 $status = $Con->Connect(hostname=>"jabber.org"); # Net::XMPP::Client 78 78 … … 2049 2049 my $self = shift; 2050 2050 2051 return new Net::XMPP::PrivacyLists(connection=>$self);2051 return Net::XMPP::PrivacyLists->new(connection=>$self); 2052 2052 } 2053 2053 … … 2372 2372 my $self = shift; 2373 2373 2374 return new Net::XMPP::Roster(connection=>$self);2374 return Net::XMPP::Roster->new(connection=>$self); 2375 2375 } 2376 2376 -
perl/modules/Jabber/lib/Net/XMPP/Roster.pm
r17b7fc5 rc2bed55 41 41 =head2 Basic Functions 42 42 43 my $Client = new Net::XMPP::Client(...);44 45 my $Roster = new Net::XMPP::Roster(connection=>$Client);43 my $Client = Net::XMPP::Client->new(...); 44 45 my $Roster = Net::XMPP::Roster->new(connection=>$Client); 46 46 or 47 47 my $Roster = $Client->Roster(); … … 544 544 ($#{$self->{JIDS}->{$jid}->{groups}} > -1)); 545 545 546 push(@jids, new Net::XMPP::JID($jid));546 push(@jids, Net::XMPP::JID->new($jid)); 547 547 } 548 548 } … … 555 555 foreach my $jid (keys(%{$self->{GROUPS}->{$group}})) 556 556 { 557 push(@jids, new Net::XMPP::JID($jid));557 push(@jids, Net::XMPP::JID->new($jid)); 558 558 } 559 559 } -
perl/modules/Jabber/lib/Net/XMPP/Stanza.pm
r0ff8d110 rc2bed55 216 216 use vars qw( $AUTOLOAD %FUNCTIONS $DEBUG ); 217 217 218 $DEBUG = new Net::XMPP::Debug(usedefault=>1,219 header=>"XMPP");218 $DEBUG = Net::XMPP::Debug->new(usedefault=>1, 219 header=>"XMPP"); 220 220 221 221 # XXX need to look at evals and $@ … … 1412 1412 { 1413 1413 my $self = shift; 1414 return new Net::XMPP::JID(@_);1414 return Net::XMPP::JID->new(@_); 1415 1415 } 1416 1416 … … 1424 1424 { 1425 1425 my $self = shift; 1426 return new Net::XMPP::Stanza(@_);1426 return Net::XMPP::Stanza->new(@_); 1427 1427 } 1428 1428 -
perl/modules/Jabber/lib/XML/Stream.pm
ra75309a rc2bed55 681 681 if ($NETDNS) 682 682 { 683 my $res = new Net::DNS::Resolver();683 my $res = Net::DNS::Resolver->new(); 684 684 my $query = $res->query($self->{SIDS}->{newconnection}->{srv}.".".$self->{SIDS}->{newconnection}->{hostname},"SRV"); 685 685 -
perlconfig.c
r1cc95709 r0337203 422 422 } else { 423 423 char *ptr = NULL; 424 if (owl_perlconfig_is_function("BarnOwl::Hooks:: receive_msg")) {424 if (owl_perlconfig_is_function("BarnOwl::Hooks::_receive_msg")) { 425 425 ptr = owl_perlconfig_call_with_message(subname?subname 426 426 :"BarnOwl::_receive_msg_legacy_wrap", m); … … 506 506 void owl_perlconfig_mainloop() 507 507 { 508 if (!owl_perlconfig_is_function("BarnOwl::Hooks:: mainloop_hook"))508 if (!owl_perlconfig_is_function("BarnOwl::Hooks::_mainloop_hook")) 509 509 return; 510 510 dSP ; 511 511 PUSHMARK(SP) ; 512 call_pv("BarnOwl::Hooks:: mainloop_hook", G_DISCARD|G_EVAL);512 call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL); 513 513 if(SvTRUE(ERRSV)) { 514 514 STRLEN n_a; -
perlwrap.pm
r37dd88c r1cf32e7d 7 7 # XXX NOTE: This file is sourced before almost any barnowl 8 8 # architecture is loaded. This means, for example, that it cannot 9 # execute any owl commands. Any code that needs to do so, should 10 # create a function wrapping it and push it onto @onStartSubs 11 9 # execute any owl commands. Any code that needs to do so should live 10 # in BarnOwl::Hooks::_startup 12 11 13 12 use strict; … … 15 14 16 15 package BarnOwl; 17 18 16 19 17 BEGIN { … … 44 42 my ($m) = @_; 45 43 $m->legacy_populate_global(); 46 return &BarnOwl::Hooks:: receive_msg($m);44 return &BarnOwl::Hooks::_receive_msg($m); 47 45 } 48 46 … … 204 202 205 203 sub smartfilter { 206 die("smartfilter not supported for this message ");204 die("smartfilter not supported for this message\n"); 207 205 } 208 206 … … 351 349 ##################################################################### 352 350 ################################################################################ 353 package BarnOwl; 354 355 ################################################################################ 356 # Mainloop hook 357 ################################################################################ 358 359 our $shutdown; 360 $shutdown = 0; 361 our $reload; 362 $reload = 0; 363 364 #Run this on start and reload. Adds modules 365 sub onStart 366 { 367 _load_owlconf(); 368 reload_init(); 369 loadModules(); 370 } 371 ################################################################################ 372 # Reload Code, taken from /afs/sipb/user/jdaniel/project/owl/perl 373 ################################################################################ 374 sub reload_hook (@) 375 { 376 BarnOwl::Hooks::startup(); 377 return 1; 378 } 379 380 sub reload 381 { 382 # Use $reload to tell modules that we're performing a reload. 383 { 384 local $reload = 1; 385 BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE}; 386 } 387 388 @BarnOwl::Hooks::onMainLoop = (); 389 @BarnOwl::Hooks::onStartSubs = (); 390 391 # Do reload 392 package main; 393 if (-r $BarnOwl::configfile) { 394 undef $@; 395 do $BarnOwl::configfile; 396 BarnOwl::error("Error reloading $BarnOwl::configfile: $@") if $@; 397 } 398 BarnOwl::reload_hook(@_); 399 package BarnOwl; 400 } 401 402 sub reload_init () 403 { 404 BarnOwl::command('alias reload perl BarnOwl::reload()'); 405 BarnOwl::command('bindkey global "C-x C-r" command reload'); 406 } 407 408 ################################################################################ 409 # Loads modules from ~/.owl/modules and owl's data directory 410 ################################################################################ 411 412 sub loadModules () { 413 my @modules; 414 my $rv; 415 foreach my $dir ( BarnOwl::get_data_dir() . "/modules", 416 $ENV{HOME} . "/.owl/modules" ) 417 { 418 opendir( MODULES, $dir ); 419 420 # source ./modules/*.pl 421 @modules = sort grep( /\.pl$/, readdir(MODULES) ); 422 423 foreach my $mod (@modules) { 424 unless ($rv = do "$dir/$mod") { 425 BarnOwl::error("Couldn't load $dir/$mod:\n $@") if $@; 426 BarnOwl::error("Couldn't run $dir/$mod:\n $!") unless defined $rv; 427 } 428 } 429 closedir(MODULES); 430 } 431 } 351 352 package BarnOwl::Hook; 353 354 sub new { 355 my $class = shift; 356 return bless [], $class; 357 } 358 359 sub run { 360 my $self = shift; 361 my @args = @_; 362 return map {$_->(@args)} @$self; 363 } 364 365 sub add { 366 my $self = shift; 367 my $func = shift; 368 die("Not a coderef!") unless ref($func) eq 'CODE'; 369 push @$self, $func; 370 } 371 372 sub clear { 373 my $self = shift; 374 @$self = (); 375 } 376 377 package BarnOwl::Hooks; 378 379 use Exporter; 380 381 our @EXPORT_OK = qw($startup $shutdown 382 $receiveMessage $mainLoop 383 $getBuddyList); 384 385 our %EXPORT_TAGS = (all => [@EXPORT_OK]); 386 387 our $startup = BarnOwl::Hook->new; 388 our $shutdown = BarnOwl::Hook->new; 389 our $receiveMessage = BarnOwl::Hook->new; 390 our $mainLoop = BarnOwl::Hook->new; 391 our $getBuddyList = BarnOwl::Hook->new; 392 393 # Internal startup/shutdown routines called by the C code 432 394 433 395 sub _load_owlconf { 434 # Only do this the first time435 return if $BarnOwl::reload;436 396 # load the config file 437 397 if ( -r $BarnOwl::configfile ) { … … 451 411 } 452 412 453 package BarnOwl::Hooks; 454 455 # Arrays of subrefs to be called at specific times. 456 our @onStartSubs = (); 457 our @onReceiveMsg = (); 458 our @onMainLoop = (); 459 our @onGetBuddyList = (); 460 461 # Functions to call hook lists 462 sub runHook($@) 463 { 464 my $hook = shift; 465 my @args = @_; 466 $_->(@args) for (@$hook); 467 } 468 469 sub runHook_accumulate($@) 470 { 471 my $hook = shift; 472 my @args = @_; 473 return join("\n", map {$_->(@args)} @$hook); 474 } 475 476 ################################################################################ 477 # Startup and Shutdown code 478 ################################################################################ 479 sub startup 480 { 481 # Modern versions of owl provides a great place to have startup stuff. 482 # Put things in ~/.owl/startup 483 484 #So that the user's .owlconf can have startsubs, we don't clear 485 #onStartSubs; reload does however 486 @onReceiveMsg = (); 487 @onMainLoop = (); 488 @onGetBuddyList = (); 489 490 BarnOwl::onStart(); 491 492 runHook(\@onStartSubs); 493 413 sub _startup { 414 _load_owlconf(); 415 416 if(eval {require BarnOwl::ModuleLoader}) { 417 eval { 418 BarnOwl::ModuleLoader->load_all; 419 }; 420 BarnOwl::error("Error loading modules: $@") if $@; 421 } else { 422 BarnOwl::error("Can't load BarnOwl::ModuleLoader, loadable module support disabled:\n$@"); 423 } 424 425 $startup->run(0); 494 426 BarnOwl::startup() if *BarnOwl::startup{CODE}; 495 427 } 496 428 497 sub shutdown 498 { 499 # Modern versions of owl provides a great place to have shutdown stuff. 500 # Put things in ~/.owl/shutdown 501 502 # use $shutdown to tell modules that that's what we're doing. 503 $BarnOwl::shutdown = 1; 429 sub _shutdown { 430 $shutdown->run; 431 432 BarnOwl::shutdown() if *BarnOwl::shutdown{CODE}; 433 } 434 435 sub _receive_msg { 436 my $m = shift; 437 438 $receiveMessage->run($m); 439 440 BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE}; 441 } 442 443 sub _mainloop_hook { 444 $mainLoop->run; 504 445 BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE}; 505 506 BarnOwl::shutdown() if *BarnOwl::shutdown{CODE}; 507 } 508 509 sub mainloop_hook 510 { 511 runHook(\@onMainLoop); 512 BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE}; 513 } 514 515 ################################################################################ 516 # Hooks into receive_msg() 517 ################################################################################ 518 519 sub receive_msg 520 { 521 my $m = shift; 522 runHook(\@onReceiveMsg, $m); 523 BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE}; 524 } 525 526 ################################################################################ 527 # Hooks into get_blist() 528 ################################################################################ 529 530 sub get_blist 531 { 532 return runHook_accumulate(\@onGetBuddyList); 446 } 447 448 sub _get_blist { 449 return join("\n", $getBuddyList->run); 533 450 } 534 451 … … 644 561 # switch to package main when we're done 645 562 package main; 646 # alias the hooks 647 { 648 no strict 'refs'; 649 foreach my $hook qw (onStartSubs 650 onReceiveMsg 651 onMainLoop 652 onGetBuddyList ) { 653 *{"main::".$hook} = \*{"BarnOwl::Hooks::".$hook}; 654 *{"owl::".$hook} = \*{"BarnOwl::Hooks::".$hook}; 655 } 656 } 563 564 # Shove a bunch of fake entries into @INC so modules can use or 565 # require them without choking 566 $::INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm 567 BarnOwl/Message.pm BarnOwl/Style.pm)); 657 568 658 569 1; 570 -
logging.c
r5c30091 r3066d23 363 363 if (owl_message_is_type_zephyr(m)) { 364 364 if (personal) { 365 if (owl_message_is_type_zephyr(m)) { 366 from=frombuff=short_zuser(owl_message_get_sender(m)); 367 } 365 from=frombuff=short_zuser(owl_message_get_sender(m)); 368 366 } else { 369 367 from=frombuff=owl_strdup(owl_message_get_class(m)); … … 384 382 from=frombuff=owl_sprintf("jabber:%s",owl_message_get_recipient(m)); 385 383 } 386 387 384 } else { 388 385 from=frombuff=owl_strdup("unknown"); -
perlglue.xs
rb6c067a r3066d23 121 121 { 122 122 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { 123 croak("Usage: owl::queue_message($message)");123 croak("Usage: BarnOwl::queue_message($message)"); 124 124 } 125 125 … … 136 136 { 137 137 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { 138 croak("Usage: owl::add_message($message)");138 croak("Usage: BarnOwl::add_message($message)"); 139 139 } 140 140 … … 142 142 m = owl_perlconfig_hashref2message(msg); 143 143 owl_function_add_message(m); 144 } 145 } 146 147 void log_message(msg) 148 SV *msg 149 PREINIT: 150 owl_message *m; 151 CODE: 152 { 153 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { 154 croak("Usage: BarnOwl::log_message($message)"); 155 } 156 157 m = owl_perlconfig_hashref2message(msg); 158 owl_log_message(m); 159 owl_message_free(m); 160 } 161 162 void add_and_log_message(msg) 163 SV *msg 164 PREINIT: 165 owl_message *m; 166 CODE: 167 { 168 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { 169 croak("Usage: BarnOwl::add_and_log_message($message)"); 170 } 171 172 m = owl_perlconfig_hashref2message(msg); 173 owl_log_message(m); 174 if (owl_global_is_displayoutgoing(&g)) { 175 owl_function_add_message(m); 176 } else { 177 owl_message_free(m); 144 178 } 145 179 }
Note: See TracChangeset
for help on using the changeset viewer.