Changeset 7483942
- Timestamp:
- Jan 23, 2012, 5:30:46 PM (13 years ago)
- Parents:
- d126a19 (diff), 6df57d4 (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:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rf89cc6f r7483942 479 479 480 480 OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE, 481 "Set, enable or disable both AIM and zephyraway messages",481 "Set, enable or disable all away messages", 482 482 "away [ on | off | toggle ]\n" 483 483 "away <message>", 484 "Turn on or off the AIM and zephyr away message. If\n"484 "Turn on or off all away messages. If\n" 485 485 "'message' is specified turn them on with that message,\n" 486 486 "otherwise use the default.\n" 487 "\n"488 "This command really just runs the 'aaway' and 'zaway'\n"489 "commands together\n"490 487 "\n" 491 488 "SEE ALSO: aaway, zaway"), … … 1531 1528 char *owl_command_away(int argc, const char *const *argv, const char *buff) 1532 1529 { 1533 if ((argc==1) || 1534 ((argc==2) && !strcmp(argv[1], "on"))) { 1530 bool away_off; 1531 const char *message = NULL; 1532 1533 if (argc == 1 || 1534 (argc == 2 && !strcmp(argv[1], "on"))) { 1535 away_off = false; 1535 1536 owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g)); 1536 1537 owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g)); 1538 } else if (argc == 2 && !strcmp(argv[1], "off")) { 1539 away_off = true; 1540 } else if (argc == 2 && !strcmp(argv[1], "toggle")) { 1541 away_off = owl_function_is_away(); 1542 } else { 1543 away_off = false; 1544 message = skiptokens(buff, 1); 1545 } 1546 1547 if (away_off) { 1548 owl_function_aaway_off(); 1549 owl_function_zaway_off(); 1550 owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_off", 0, NULL); 1551 owl_function_makemsg("Away messages off."); 1552 } else if (message != NULL) { 1553 owl_global_set_aaway_msg(&g, message); 1554 owl_global_set_zaway_msg(&g, message); 1537 1555 owl_function_aaway_on(); 1538 1556 owl_function_zaway_on(); 1557 owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 1, &message); 1558 owl_function_makemsg("Away messages set (%s).", message); 1559 } else { 1560 owl_function_aaway_on(); 1561 owl_function_zaway_on(); 1562 owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 0, NULL); 1539 1563 owl_function_makemsg("Away messages set."); 1540 return NULL; 1541 } 1542 1543 if (argc==2 && !strcmp(argv[1], "off")) { 1544 owl_function_aaway_off(); 1545 owl_function_zaway_off(); 1546 return NULL; 1547 } 1548 1549 if (argc==2 && !strcmp(argv[1], "toggle")) { 1550 /* if either one is on, turn it off, otherwise toggle both (turn 1551 * them both on) 1552 */ 1553 if (!owl_global_is_zaway(&g) && !owl_global_is_aaway(&g)) { 1554 owl_function_aaway_toggle(); 1555 owl_function_zaway_toggle(); 1556 owl_function_makemsg("Away messages set."); 1557 } else { 1558 if (owl_global_is_zaway(&g)) owl_function_zaway_toggle(); 1559 if (owl_global_is_aaway(&g)) owl_function_aaway_toggle(); 1560 owl_function_makemsg("Away messages off."); 1561 } 1562 return NULL; 1563 } 1564 1565 buff = skiptokens(buff, 1); 1566 owl_global_set_aaway_msg(&g, buff); 1567 owl_global_set_zaway_msg(&g, buff); 1568 owl_function_aaway_on(); 1569 owl_function_zaway_on(); 1570 owl_function_makemsg("Away messages set."); 1564 } 1565 1571 1566 return NULL; 1572 1567 } -
functions.c
recfbdcc r7483942 993 993 } 994 994 995 bool owl_function_is_away(void) 996 { 997 return owl_global_is_zaway(&g) || 998 owl_global_is_aaway(&g) || 999 owl_perlconfig_perl_call_bool("BarnOwl::Hooks::_get_is_away", 0, NULL); 1000 } 1001 995 1002 void owl_function_quit(void) 996 1003 { -
owl_perl.h
rf271129 r0c71c58 4 4 #include <stdio.h> 5 5 6 #define OWL_PERL_VOID_CALL (void)POPs; 6 /* 7 * This macro defines a convenience wrapper around the boilerplate 8 * of pushing char * arguments on to the stack for perl calling. 9 * 10 * Arguments are 11 * * i - the counter variable to use, which must be declared prior 12 * to calling this macro 13 * * argc - the number of arguments 14 * * argv - an array of char*s, of length at least argc; the arguments 15 * to push on to the stack 16 */ 17 #define OWL_PERL_PUSH_ARGS(i, argc, argv) { \ 18 for (i = 0; i < argc; i++) { \ 19 XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); \ 20 } \ 21 } 7 22 8 23 /* 9 24 * This macro defines a convenience wrapper around the boilerplate of 10 * calling a method on a perl object (SV*) from C.25 * the perlcall methods. 11 26 * 12 27 * Arguments are 13 * * obj - the SV* to call the method on 14 * * meth - a char* method name 15 * * args - a code block responsible for pushing args (other than the object) 16 * * err - a string with a %s format specifier to log in case of error 17 * * fatalp - if true, perl errors terminate BarnOwl 18 * * ret - a code block executed if the call succeeded 28 * * call - the line of code to make the perl call 29 * * args - a code block responsible for pushing args 30 * * err - a string with a %s format specifier to log in case of error 31 * * fatalp - if true, perl errors terminate BarnOwl 32 * * discardret - should be true if no return is expected 33 * (if the call is passed the flag G_DISCARD or G_VOID) 34 * * ret - a code block executed if the call succeeded 19 35 * 20 36 * See also: `perldoc perlcall', `perldoc perlapi' 21 37 */ 22 #define OWL_PERL_CALL_METHOD(obj, meth, args, err, fatalp, ret) { \ 23 int count; \ 24 dSP; \ 25 ENTER; \ 26 SAVETMPS; \ 27 PUSHMARK(SP); \ 28 XPUSHs(obj); \ 29 {args} \ 30 PUTBACK; \ 31 \ 32 count = call_method(meth, G_SCALAR|G_EVAL); \ 33 \ 34 SPAGAIN; \ 35 \ 36 if(count != 1) { \ 37 fprintf(stderr, "perl returned wrong count: %d\n", count); \ 38 abort(); \ 38 #define OWL_PERL_CALL(call, args, err, fatalp, discardret, ret) { \ 39 int count; \ 40 dSP; \ 41 \ 42 ENTER; \ 43 SAVETMPS; \ 44 \ 45 PUSHMARK(SP); \ 46 {args} \ 47 PUTBACK; \ 48 \ 49 count = call; \ 50 \ 51 SPAGAIN; \ 52 \ 53 if (!discardret && count != 1) { \ 54 croak("Perl returned wrong count: %d\n", count); \ 55 } \ 56 \ 57 if (SvTRUE(ERRSV)) { \ 58 if (fatalp) { \ 59 fprintf(stderr, err, SvPV_nolen(ERRSV)); \ 60 exit(-1); \ 61 } else { \ 62 owl_function_error(err, SvPV_nolen(ERRSV)); \ 63 if (!discardret) (void)POPs; \ 64 sv_setsv(ERRSV, &PL_sv_undef); \ 39 65 } \ 40 if (SvTRUE(ERRSV)) { \ 41 if(fatalp) { \ 42 printf(err, SvPV_nolen(ERRSV)); \ 43 exit(-1); \ 44 } else { \ 45 owl_function_error(err, SvPV_nolen(ERRSV)); \ 46 (void)POPs; \ 47 sv_setsv(ERRSV, &PL_sv_undef); \ 48 } \ 49 } else { \ 50 ret; \ 51 } \ 52 PUTBACK; \ 53 FREETMPS; \ 54 LEAVE; \ 66 } else if (!discardret) { \ 67 ret; \ 68 } \ 69 PUTBACK; \ 70 FREETMPS; \ 71 LEAVE; \ 55 72 } 56 73 -
perl/lib/BarnOwl/Hooks.pm
rb8a3e00 r6df57d4 57 57 from every function registered with this hook will be appended and 58 58 displayed in a popup window, with zephyr formatting parsed. 59 60 =item $awayOn 61 62 Called, for all protocol handlers, to go away, with the away message, 63 if any. 64 65 =item $awayOff 66 67 Called, for all protocol handlers, to come back from away. 68 69 =item $getIsAway 70 71 Called to check away status for all protocol handlers. Protocol 72 handlers should return a true value if any account of the user is away 73 for the given protocol, and a false value otherwise. 59 74 60 75 =item $getQuickstart … … 75 90 $receiveMessage $newMessage 76 91 $mainLoop $getBuddyList 77 $getQuickstart); 92 $getQuickstart 93 $awayOn $awayOff $getIsAway); 78 94 79 95 our %EXPORT_TAGS = (all => [@EXPORT_OK]); … … 88 104 our $getBuddyList = BarnOwl::Hook->new; 89 105 our $getQuickstart = BarnOwl::Hook->new; 106 our $awayOn = BarnOwl::Hook->new; 107 our $awayOff = BarnOwl::Hook->new; 108 our $getIsAway = BarnOwl::Hook->new; 90 109 91 110 # Internal startup/shutdown routines called by the C code … … 201 220 } 202 221 222 sub _away_on { 223 $awayOn->run(@_); 224 } 225 226 sub _away_off { 227 $awayOff->run(); 228 } 229 230 sub _get_is_away { 231 my @is_away = grep { $_ } $getIsAway->run(); 232 return scalar @is_away; 233 } 234 203 235 sub _new_command { 204 236 my $command = shift; -
perlconfig.c
r7803326 r57ad328 224 224 CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m) 225 225 { 226 dSP ; 227 int count; 228 SV *msgref, *srv; 229 char *out; 230 231 ENTER ; 232 SAVETMPS; 233 234 PUSHMARK(SP) ; 226 SV *msgref, *rv; 227 char *out = NULL; 228 235 229 msgref = owl_perlconfig_message2hashref(m); 236 XPUSHs(sv_2mortal(msgref)); 237 PUTBACK ; 238 239 count = call_pv(subname, G_SCALAR|G_EVAL); 240 241 SPAGAIN ; 242 243 if (SvTRUE(ERRSV)) { 244 owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV)); 245 /* and clear the error */ 246 sv_setsv (ERRSV, &PL_sv_undef); 247 } 248 249 if (count != 1) { 250 fprintf(stderr, "bad perl! no biscuit! returned wrong count!\n"); 251 abort(); 252 } 253 254 srv = POPs; 255 256 if (srv) { 257 out = g_strdup(SvPV_nolen(srv)); 258 } else { 259 out = NULL; 260 } 261 262 PUTBACK ; 263 FREETMPS ; 264 LEAVE ; 265 230 231 OWL_PERL_CALL((call_pv(subname, G_SCALAR|G_EVAL)) 232 , 233 XPUSHs(sv_2mortal(msgref)); 234 , 235 "Perl Error: '%s'" 236 , 237 false 238 , 239 false 240 , 241 rv = POPs; 242 if (rv && SvPOK(rv)) 243 out = g_strdup(SvPV_nolen(rv)); 244 ); 266 245 return out; 267 246 } … … 273 252 CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv) 274 253 { 275 dSP; 276 unsigned int count, i; 277 SV *msgref, *srv; 278 char *out; 254 SV *msgref, *rv; 255 char *out = NULL; 256 int i; 279 257 280 258 msgref = owl_perlconfig_message2hashref(m); 281 259 282 ENTER; 283 SAVETMPS; 284 285 PUSHMARK(SP); 286 XPUSHs(sv_2mortal(msgref)); 287 for(i=0;i<argc;i++) { 288 XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); 289 } 290 PUTBACK; 291 292 count = call_method(method, G_SCALAR|G_EVAL); 293 294 SPAGAIN; 295 296 if(count != 1) { 297 fprintf(stderr, "perl returned wrong count %u\n", count); 298 abort(); 299 } 300 301 if (SvTRUE(ERRSV)) { 302 owl_function_error("Error: '%s'", SvPV_nolen(ERRSV)); 303 /* and clear the error */ 304 sv_setsv (ERRSV, &PL_sv_undef); 305 } 306 307 srv = POPs; 308 309 if (srv) { 310 out = g_strdup(SvPV_nolen(srv)); 311 } else { 312 out = NULL; 313 } 314 315 PUTBACK; 316 FREETMPS; 317 LEAVE; 318 260 OWL_PERL_CALL(call_method(method, G_SCALAR|G_EVAL) 261 , 262 XPUSHs(sv_2mortal(msgref)); 263 OWL_PERL_PUSH_ARGS(i, argc, argv); 264 , 265 "Perl Error: '%s'" 266 , 267 false 268 , 269 false 270 , 271 rv = POPs; 272 if (rv && SvPOK(rv)) 273 out = g_strdup(SvPV_nolen(rv)); 274 ); 319 275 return out; 320 276 } … … 455 411 void owl_perlconfig_new_command(const char *name) 456 412 { 457 dSP; 458 459 ENTER; 460 SAVETMPS; 461 462 PUSHMARK(SP); 463 XPUSHs(sv_2mortal(owl_new_sv(name))); 464 PUTBACK; 465 466 call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL); 467 468 SPAGAIN; 469 470 if(SvTRUE(ERRSV)) { 471 owl_function_error("%s", SvPV_nolen(ERRSV)); 472 } 473 474 FREETMPS; 475 LEAVE; 413 OWL_PERL_CALL(call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL); 414 , 415 XPUSHs(sv_2mortal(owl_new_sv(name))); 416 , 417 "Perl Error: '%s'" 418 , 419 false 420 , 421 true 422 , 423 ); 424 } 425 426 CALLER_OWN char *owl_perlconfig_perl_call(const char *method, int argc, const char *const *argv) 427 { 428 SV *rv; 429 char *out = NULL; 430 int i; 431 OWL_PERL_CALL(call_pv(method, G_SCALAR|G_EVAL) 432 , 433 OWL_PERL_PUSH_ARGS(i, argc, argv); 434 , 435 "Perl Error: '%s'" 436 , 437 false 438 , 439 false 440 , 441 rv = POPs; 442 if (rv && SvPOK(rv)) 443 out = g_strdup(SvPV_nolen(rv)); 444 ); 445 return out; 446 } 447 448 int owl_perlconfig_perl_call_int(const char *method, int argc, const char *const *argv) 449 { 450 SV *rv; 451 int ret = -1; 452 int i; 453 OWL_PERL_CALL(call_pv(method, G_SCALAR|G_EVAL) 454 , 455 OWL_PERL_PUSH_ARGS(i, argc, argv); 456 , 457 "Perl Error: '%s'" 458 , 459 false 460 , 461 false 462 , 463 rv = POPs; 464 if (rv && SvIOK(rv)) 465 ret = SvIV(rv); 466 ); 467 return ret; 468 } 469 470 bool owl_perlconfig_perl_call_bool(const char *method, int argc, const char *const *argv) 471 { 472 SV *rv; 473 bool ret = false; 474 int i; 475 OWL_PERL_CALL(call_pv(method, G_SCALAR|G_EVAL) 476 , 477 OWL_PERL_PUSH_ARGS(i, argc, argv); 478 , 479 "Perl Error: '%s'" 480 , 481 false 482 , 483 false 484 , 485 rv = POPs; 486 if (rv) 487 ret = SvTRUE(rv); 488 ); 489 return ret; 490 } 491 492 void owl_perlconfig_perl_call_norv(const char *method, int argc, const char *const *argv) 493 { 494 int i; 495 OWL_PERL_CALL(call_pv(method, G_DISCARD|G_EVAL) 496 , 497 OWL_PERL_PUSH_ARGS(i, argc, argv); 498 , 499 "Perl Error: '%s'" 500 , 501 false 502 , 503 true 504 , 505 ); 476 506 } 477 507 … … 479 509 CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv) 480 510 { 481 int i, count; 482 char * ret = NULL; 483 SV *rv; 484 dSP; 485 486 ENTER; 487 SAVETMPS; 488 489 PUSHMARK(SP); 490 for(i=0;i<argc;i++) { 491 XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); 492 } 493 PUTBACK; 494 495 count = call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL); 496 497 SPAGAIN; 498 499 if(SvTRUE(ERRSV)) { 500 owl_function_error("%s", SvPV_nolen(ERRSV)); 501 (void)POPs; 502 } else { 503 if(count != 1) 504 croak("Perl command %s returned more than one value!", cmd->name); 505 rv = POPs; 506 if(SvTRUE(rv)) { 507 ret = g_strdup(SvPV_nolen(rv)); 508 } 509 } 510 511 FREETMPS; 512 LEAVE; 513 514 return ret; 511 int i; 512 SV* rv; 513 char *out = NULL; 514 515 OWL_PERL_CALL(call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL) 516 , 517 OWL_PERL_PUSH_ARGS(i, argc, argv); 518 , 519 "Perl Error: '%s'" 520 , 521 false 522 , 523 false 524 , 525 rv = POPs; 526 if (rv && SvPOK(rv)) 527 out = g_strdup(SvPV_nolen(rv)); 528 ); 529 return out; 515 530 } 516 531 … … 523 538 { 524 539 SV *cb = owl_editwin_get_cbdata(e); 525 SV *text; 526 dSP; 527 528 if(cb == NULL) { 540 SV *text = owl_new_sv(owl_editwin_get_text(e)); 541 542 if (cb == NULL) { 529 543 owl_function_error("Perl callback is NULL!"); 530 544 return; 531 545 } 532 text = owl_new_sv(owl_editwin_get_text(e)); 533 534 ENTER; 535 SAVETMPS; 536 537 PUSHMARK(SP); 538 XPUSHs(sv_2mortal(text)); 539 XPUSHs(sv_2mortal(newSViv(success))); 540 PUTBACK; 541 542 call_sv(cb, G_DISCARD|G_EVAL); 543 544 if(SvTRUE(ERRSV)) { 545 owl_function_error("%s", SvPV_nolen(ERRSV)); 546 } 547 548 FREETMPS; 549 LEAVE; 546 547 OWL_PERL_CALL(call_sv(cb, G_DISCARD|G_EVAL) 548 , 549 XPUSHs(sv_2mortal(text)); 550 XPUSHs(sv_2mortal(newSViv(success))); 551 , 552 "Perl Error: '%s'" 553 , 554 false 555 , 556 true 557 , 558 ); 550 559 } 551 560 -
sepbar.c
r6eb3ed9 r6df57d4 67 67 } 68 68 69 if (owl_ global_is_zaway(&g) || owl_global_is_aaway(&g)) {69 if (owl_function_is_away()) { 70 70 getyx(sepwin, y, x); 71 71 wmove(sepwin, y, x+2); 72 72 wattron(sepwin, A_BOLD); 73 73 wattroff(sepwin, A_REVERSE); 74 if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { 75 waddstr(sepwin, " AWAY "); 76 } else if (owl_global_is_zaway(&g)) { 77 waddstr(sepwin, " Z-AWAY "); 78 } else if (owl_global_is_aaway(&g)) { 79 waddstr(sepwin, " A-AWAY "); 80 } 74 waddstr(sepwin, " AWAY "); 81 75 wattron(sepwin, A_REVERSE); 82 76 wattroff(sepwin, A_BOLD); -
style.c
r14be3a5 r0c71c58 23 23 { 24 24 SV *sv = NULL; 25 OWL_PERL_CALL _METHOD(s->perlobj,26 "description",27 ;,28 "Error in style_get_description: %s",29 0,30 31 32 if (sv) {25 OWL_PERL_CALL(call_method("description", G_SCALAR|G_EVAL), 26 XPUSHs(s->perlobj);, 27 "Error in style_get_description: %s", 28 0, 29 false, 30 sv = SvREFCNT_inc(POPs); 31 ); 32 if (sv) { 33 33 return SvPV_nolen(sv_2mortal(sv)); 34 34 } else { … … 50 50 51 51 /* Call the perl object */ 52 OWL_PERL_CALL_METHOD(s->perlobj, 53 "format_message", 54 XPUSHs(sv_2mortal(owl_perlconfig_message2hashref(m)));, 55 "Error in format_message: %s", 56 0, 57 sv = SvREFCNT_inc(POPs); 58 ); 52 OWL_PERL_CALL(call_method("format_message", G_SCALAR|G_EVAL), 53 XPUSHs(s->perlobj); 54 XPUSHs(sv_2mortal(owl_perlconfig_message2hashref(m)));, 55 "Error in format_message: %s", 56 0, 57 false, 58 sv = SvREFCNT_inc(POPs); 59 ); 59 60 60 if (sv) {61 if (sv) { 61 62 body = SvPV_nolen(sv); 62 63 } else { -
doc/barnowl.1
rbad4496 r8135737 35 35 .TP 36 36 \fB\-c\fP, \fB\-\-config\-file\fP=\fIFILE\fP 37 Specify an alternate config file for \fBBarnOwl\fP to use. By default, 38 \fBBarnOwl\fP uses \fI~/.barnowlconf\fP if it exists, and \fI~/.owlconf\fP otherwise. 37 Specify an alternate config file for \fBBarnOwl\fP to use. The config file is 38 an arbitrary Perl script evaluated in the \fImain\fP package, and if it 39 overrides the \fIBarnOwl::startup\fP method that is run when \fBBarnOwl\fP 40 starts. (Compare \fI~/.owl/startup\fP, which contains \fBBarnOwl\fP commands 41 that are run at startup after the config file is loaded.) 42 43 By default, \fBBarnOwl\fP uses the first of \fI~/.owl/init.pl\fP, 44 \fI~/.barnowlconf\fP, or \fI~/.owlconf\fP that exists. 39 45 40 46 .TP -
global.c
r9078f69 r219f52c 75 75 g_free(cd); 76 76 77 owl_messagelist_create(&(g->msglist));77 g->msglist = owl_messagelist_new(); 78 78 79 79 _owl_global_init_windows(g); … … 109 109 110 110 /* Create the widgets */ 111 owl_mainwin_init(&(g->mw),g->mainpanel.recwin);111 g->mw = owl_mainwin_new(g->mainpanel.recwin); 112 112 owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin); 113 113 owl_sepbar_init(g->mainpanel.sepwin); … … 241 241 /* windows */ 242 242 243 owl_mainwin *owl_global_get_mainwin(owl_global *g) { 244 return(&(g->mw)); 243 owl_mainwin *owl_global_get_mainwin(owl_global *g) 244 { 245 return g->mw; 245 246 } 246 247 … … 256 257 257 258 owl_messagelist *owl_global_get_msglist(owl_global *g) { 258 return (&(g->msglist));259 return g->msglist; 259 260 } 260 261 -
mainwin.c
r099597c rab88b05 4 4 static void owl_mainwin_resized(owl_window *w, void *user_data); 5 5 6 void owl_mainwin_init(owl_mainwin *mw,owl_window *window)6 CALLER_OWN owl_mainwin *owl_mainwin_new(owl_window *window) 7 7 { 8 owl_mainwin *mw = g_new(owl_mainwin, 1); 8 9 mw->curtruncated=0; 9 10 mw->lastdisplayed=-1; … … 16 17 /* For now, we do not bother with connecting up dependencies; that'll be a 17 18 * future refactor of the mainwin */ 19 20 return mw; 18 21 } 19 22 -
messagelist.c
rf271129 r219f52c 1 1 #include "owl.h" 2 2 3 void owl_messagelist_create(owl_messagelist *ml)3 CALLER_OWN owl_messagelist *owl_messagelist_new(void) 4 4 { 5 owl_messagelist *ml = g_new(owl_messagelist, 1); 5 6 ml->list = g_ptr_array_new(); 7 return ml; 6 8 } 7 9 8 void owl_messagelist_ cleanup(owl_messagelist *ml, bool free_messages)10 void owl_messagelist_delete(owl_messagelist *ml, bool free_messages) 9 11 { 10 12 if (free_messages) 11 13 g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL); 12 14 g_ptr_array_free(ml->list, true); 15 g_free(ml); 13 16 } 14 17 -
owl.c
r3b17b57 r8135737 41 41 fprintf(stderr, " -v,--version print the Barnowl version number and exit\n"); 42 42 fprintf(stderr, " -h,--help print this help message\n"); 43 fprintf(stderr, " -c,--config-file specify an alternate config file\n");44 43 fprintf(stderr, " -s,--config-dir specify an alternate config dir (default ~/.owl)\n"); 44 fprintf(stderr, " -c,--config-file specify an alternate config file (default ~/.owl/init.pl)\n"); 45 45 fprintf(stderr, " -t,--tty set the tty name\n"); 46 46 } … … 585 585 ); 586 586 587 owl_function_debugmsg("startup: setting context interactive"); 588 589 owl_global_pop_context(&g); 590 owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL); 591 587 592 /* process the startup file */ 588 593 owl_function_debugmsg("startup: processing startup file"); … … 596 601 owl_function_error("No such style: %s", owl_global_get_default_style(&g)); 597 602 598 owl_function_debugmsg("startup: setting context interactive");599 600 owl_global_pop_context(&g);601 owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL);602 603 603 source = owl_window_redraw_source_new(); 604 604 g_source_attach(source, NULL); -
owl.h
rb9517cf r219f52c 452 452 char *name; 453 453 owl_filter *filter; 454 owl_messagelist ml;454 owl_messagelist *ml; 455 455 const owl_style *style; 456 456 int cachedmsgid; … … 533 533 534 534 typedef struct _owl_global { 535 owl_mainwin mw;535 owl_mainwin *mw; 536 536 owl_popwin *pw; 537 537 owl_msgwin msgwin; … … 551 551 int curmsg_vert_offset; 552 552 owl_view current_view; 553 owl_messagelist msglist;553 owl_messagelist *msglist; 554 554 WINDOW *input_pad; 555 555 owl_mainpanel mainpanel; -
perl/lib/BarnOwl.pm
r7803326 r8135737 329 329 our @all_commands; 330 330 331 if(!$configfile && -f $ENV{HOME} . "/.barnowlconf") { 332 $configfile = $ENV{HOME} . "/.barnowlconf"; 333 } 334 $configfile ||= $ENV{HOME}."/.owlconf"; 331 if(!$configfile) { 332 if (-f get_config_dir() . "/init.pl") { 333 $configfile = get_config_dir() . "/init.pl"; 334 } elsif (-f $ENV{HOME} . "/.barnowlconf") { 335 $configfile = $ENV{HOME} . "/.barnowlconf"; 336 } else { 337 $configfile = $ENV{HOME}."/.owlconf"; 338 } 339 } 335 340 336 341 # populate global variable space for legacy owlconf files -
perl/lib/BarnOwl/ModuleLoader.pm
rf544216 rf34728b 127 127 } 128 128 129 sub complete_module_name { 130 return sort(keys %modules); 131 } 132 129 133 sub register_keybindings { 130 134 BarnOwl::new_command('reload-modules', sub {BarnOwl::ModuleLoader->reload}, { … … 138 142 description => q{Reloads a single module located in ~/.owl/modules or the system modules directory} 139 143 }); 144 145 BarnOwl::Completion::register_completer('reload-module', \&complete_module_name); 140 146 } 141 147 -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
rb8a3e00 r678f607 1482 1482 } 1483 1483 1484 sub complete_jabberlogout { 1485 my $ctx = shift; 1486 if($ctx->word == 1) { 1487 return ("-A", complete_account() ); 1488 } else { 1489 return (); 1490 } 1491 } 1492 1484 1493 BarnOwl::Completion::register_completer(jwrite => sub { BarnOwl::Module::Jabber::complete_jwrite(@_) }); 1494 BarnOwl::Completion::register_completer(jabberlogout => sub { BarnOwl::Module::Jabber::complete_jabberlogout(@_) }); 1485 1495 1486 1496 1; -
util.c
r6646fdb r7b89e8c 262 262 CALLER_OWN char *owl_arg_quote(const char *arg) 263 263 { 264 GString *buf = g_string_new(""); ;264 GString *buf = g_string_new(""); 265 265 owl_string_append_quoted_arg(buf, arg); 266 return g_string_free(buf, false); 267 } 268 269 /* Returns a quoted version of argv. owl_parseline on the result should give 270 * back the input. */ 271 CALLER_OWN char *owl_argv_quote(int argc, const char *const *argv) 272 { 273 int i; 274 GString *buf = g_string_new(""); 275 for (i = 0; i < argc; i++) { 276 if (i > 0) 277 g_string_append_c(buf, ' '); 278 owl_string_append_quoted_arg(buf, argv[i]); 279 } 266 280 return g_string_free(buf, false); 267 281 } -
variable.c
rf271129 rd126a19 116 116 "both,in,out"), 117 117 118 OWLVAR_BOOL( "colorztext" /* %OwlVarStub */, 1, 119 "allow @color() in zephyrs to change color", 120 "Note that only messages received after this variable\n" 121 "is set will be affected." ), 118 OWLVAR_BOOL_FULL( "colorztext" /* %OwlVarStub */, 1, 119 "allow @color() in zephyrs to change color", 120 NULL, NULL, owl_variable_colorztext_set, NULL), 122 121 123 122 OWLVAR_BOOL( "fancylines" /* %OwlVarStub */, 1, … … 496 495 } 497 496 return owl_variable_bool_set_default(v, newval); 497 } 498 499 int owl_variable_colorztext_set(owl_variable *v, const void *newval) 500 { 501 int ret = owl_variable_bool_set_default(v, newval); 502 /* flush the format cache so that we see the update, but only if we're done initializing BarnOwl */ 503 if (owl_global_get_msglist(&g) != NULL) 504 owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); 505 if (owl_global_get_mainwin(&g) != NULL) { 506 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); 507 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 508 } 509 return ret; 498 510 } 499 511 -
view.c
rf271129 r219f52c 6 6 v->filter=f; 7 7 v->style=s; 8 owl_messagelist_create(&(v->ml));8 v->ml = owl_messagelist_new(); 9 9 owl_view_recalculate(v); 10 10 } … … 19 19 { 20 20 if (owl_filter_message_match(v->filter, m)) { 21 owl_messagelist_append_element( &(v->ml), m);21 owl_messagelist_append_element(v->ml, m); 22 22 } 23 23 } … … 30 30 int i, j; 31 31 const owl_messagelist *gml; 32 owl_messagelist *ml;33 32 owl_message *m; 34 33 35 34 gml=owl_global_get_msglist(&g); 36 ml=&(v->ml);37 35 38 36 /* nuke the old list, don't free the messages */ 39 owl_messagelist_ cleanup(ml, false);40 owl_messagelist_create(&(v->ml));37 owl_messagelist_delete(v->ml, false); 38 v->ml = owl_messagelist_new(); 41 39 42 40 /* find all the messages we want */ … … 45 43 m=owl_messagelist_get_element(gml, i); 46 44 if (owl_filter_message_match(v->filter, m)) { 47 owl_messagelist_append_element( ml, m);45 owl_messagelist_append_element(v->ml, m); 48 46 } 49 47 } … … 72 70 owl_message *owl_view_get_element(const owl_view *v, int index) 73 71 { 74 return (owl_messagelist_get_element(&(v->ml), index));72 return owl_messagelist_get_element(v->ml, index); 75 73 } 76 74 77 75 void owl_view_delete_element(owl_view *v, int index) 78 76 { 79 owl_messagelist_delete_element( &(v->ml), index);77 owl_messagelist_delete_element(v->ml, index); 80 78 } 81 79 82 80 void owl_view_undelete_element(owl_view *v, int index) 83 81 { 84 owl_messagelist_undelete_element( &(v->ml), index);82 owl_messagelist_undelete_element(v->ml, index); 85 83 } 86 84 87 85 int owl_view_get_size(const owl_view *v) 88 86 { 89 return (owl_messagelist_get_size(&(v->ml)));87 return owl_messagelist_get_size(v->ml); 90 88 } 91 89 … … 158 156 void owl_view_cleanup(owl_view *v) 159 157 { 160 owl_messagelist_ cleanup(&v->ml, false);158 owl_messagelist_delete(v->ml, false); 161 159 g_free(v->name); 162 160 } -
zephyr.c
rf271129 rd953ede 909 909 g_free(to); 910 910 911 z = owl_zwrite_new (tmpbuff);911 z = owl_zwrite_new_from_line(tmpbuff); 912 912 g_free(tmpbuff); 913 913 if (z == NULL) { -
zwrite.c
rf271129 ref4074b 1 1 #include "owl.h" 2 2 3 CALLER_OWN owl_zwrite *owl_zwrite_new (const char *line)3 CALLER_OWN owl_zwrite *owl_zwrite_new_from_line(const char *line) 4 4 { 5 5 owl_zwrite *z = g_new(owl_zwrite, 1); 6 if (owl_zwrite_create_from_line(z, line) <0) {7 owl_zwrite_delete(z);6 if (owl_zwrite_create_from_line(z, line) != 0) { 7 g_free(z); 8 8 return NULL; 9 9 } … … 11 11 } 12 12 13 CALLER_OWN owl_zwrite *owl_zwrite_new(int argc, const char *const *argv) 14 { 15 owl_zwrite *z = g_new(owl_zwrite, 1); 16 if (owl_zwrite_create(z, argc, argv) != 0) { 17 g_free(z); 18 return NULL; 19 } 20 return z; 21 } 22 13 23 G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line) 14 24 { 15 int argc , badargs, myargc;25 int argc; 16 26 char **argv; 17 const char *const *myargv; 27 int ret; 28 29 /* parse the command line for options */ 30 argv = owl_parseline(line, &argc); 31 if (argc < 0) { 32 owl_function_error("Unbalanced quotes in zwrite"); 33 return -1; 34 } 35 ret = owl_zwrite_create(z, argc, strs(argv)); 36 g_strfreev(argv); 37 return ret; 38 } 39 40 G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create(owl_zwrite *z, int argc, const char *const *argv) 41 { 42 int badargs = 0; 18 43 char *msg = NULL; 19 20 badargs=0;21 44 22 45 /* start with null entries */ … … 31 54 z->noping=0; 32 55 z->recips = g_ptr_array_new(); 33 z->zwriteline = g_strdup(line); 34 35 /* parse the command line for options */ 36 argv=owl_parseline(line, &argc); 37 myargv=strs(argv); 38 if (argc<0) { 39 owl_function_error("Unbalanced quotes in zwrite"); 40 return(-1); 41 } 42 myargc=argc; 43 if (myargc && *(myargv[0])!='-') { 44 z->cmd=g_strdup(myargv[0]); 45 myargc--; 46 myargv++; 47 } 48 while (myargc) { 49 if (!strcmp(myargv[0], "-c")) { 50 if (myargc<2) { 51 badargs=1; 52 break; 53 } 54 z->class=owl_validate_utf8(myargv[1]); 55 myargv+=2; 56 myargc-=2; 57 } else if (!strcmp(myargv[0], "-i")) { 58 if (myargc<2) { 59 badargs=1; 60 break; 61 } 62 z->inst=owl_validate_utf8(myargv[1]); 63 myargv+=2; 64 myargc-=2; 65 } else if (!strcmp(myargv[0], "-r")) { 66 if (myargc<2) { 67 badargs=1; 68 break; 69 } 70 z->realm=owl_validate_utf8(myargv[1]); 71 myargv+=2; 72 myargc-=2; 73 } else if (!strcmp(myargv[0], "-s")) { 74 if (myargc<2) { 75 badargs=1; 76 break; 77 } 78 z->zsig=owl_validate_utf8(myargv[1]); 79 myargv+=2; 80 myargc-=2; 81 } else if (!strcmp(myargv[0], "-O")) { 82 if (myargc<2) { 83 badargs=1; 84 break; 85 } 86 z->opcode=owl_validate_utf8(myargv[1]); 87 myargv+=2; 88 myargc-=2; 89 } else if (!strcmp(myargv[0], "-m")) { 90 if (myargc<2) { 56 z->zwriteline = owl_argv_quote(argc, argv); 57 58 if (argc && *(argv[0])!='-') { 59 z->cmd=g_strdup(argv[0]); 60 argc--; 61 argv++; 62 } 63 while (argc) { 64 if (!strcmp(argv[0], "-c")) { 65 if (argc<2) { 66 badargs=1; 67 break; 68 } 69 z->class=owl_validate_utf8(argv[1]); 70 argv+=2; 71 argc-=2; 72 } else if (!strcmp(argv[0], "-i")) { 73 if (argc<2) { 74 badargs=1; 75 break; 76 } 77 z->inst=owl_validate_utf8(argv[1]); 78 argv+=2; 79 argc-=2; 80 } else if (!strcmp(argv[0], "-r")) { 81 if (argc<2) { 82 badargs=1; 83 break; 84 } 85 z->realm=owl_validate_utf8(argv[1]); 86 argv+=2; 87 argc-=2; 88 } else if (!strcmp(argv[0], "-s")) { 89 if (argc<2) { 90 badargs=1; 91 break; 92 } 93 z->zsig=owl_validate_utf8(argv[1]); 94 argv+=2; 95 argc-=2; 96 } else if (!strcmp(argv[0], "-O")) { 97 if (argc<2) { 98 badargs=1; 99 break; 100 } 101 z->opcode=owl_validate_utf8(argv[1]); 102 argv+=2; 103 argc-=2; 104 } else if (!strcmp(argv[0], "-m")) { 105 if (argc<2) { 91 106 badargs=1; 92 107 break; … … 99 114 100 115 /* Once we have -m, gobble up everything else on the line */ 101 myargv++;102 myargc--;103 msg = g_strjoinv(" ", (char**) myargv);116 argv++; 117 argc--; 118 msg = g_strjoinv(" ", (char**)argv); 104 119 break; 105 } else if (!strcmp( myargv[0], "-C")) {120 } else if (!strcmp(argv[0], "-C")) { 106 121 z->cc=1; 107 myargv++;108 myargc--;109 } else if (!strcmp( myargv[0], "-n")) {122 argv++; 123 argc--; 124 } else if (!strcmp(argv[0], "-n")) { 110 125 z->noping=1; 111 myargv++;112 myargc--;126 argv++; 127 argc--; 113 128 } else { 114 129 /* anything unattached is a recipient */ 115 g_ptr_array_add(z->recips, owl_validate_utf8( myargv[0]));116 myargv++;117 myargc--;130 g_ptr_array_add(z->recips, owl_validate_utf8(argv[0])); 131 argv++; 132 argc--; 118 133 } 119 134 } 120 135 121 g_strfreev(argv);122 123 136 if (badargs) { 137 owl_zwrite_cleanup(z); 124 138 return(-1); 125 139 } … … 129 143 z->recips->len == 0) { 130 144 owl_function_error("You must specify a recipient for zwrite"); 145 owl_zwrite_cleanup(z); 131 146 return(-1); 132 147 } … … 254 269 owl_zwrite z; 255 270 int rv; 256 rv =owl_zwrite_create_from_line(&z, cmd);257 if (rv ) return(rv);271 rv = owl_zwrite_create_from_line(&z, cmd); 272 if (rv != 0) return rv; 258 273 if (!owl_zwrite_is_message_set(&z)) { 259 274 owl_zwrite_set_message(&z, msg);
Note: See TracChangeset
for help on using the changeset viewer.