Changes in / [e488ec5:26ad412]
- Files:
-
- 1 added
- 26 deleted
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
rf93cc34 rde18326 15 15 autom4te.cache 16 16 barnowl.bin 17 tester.bin18 17 zcrypt 19 18 blib … … 31 30 owl_prototypes.h 32 31 owl_prototypes.h.new 32 perl_tester 33 33 perlglue.c 34 34 perlwrap.c -
Makefile.am
r9d27ee8 r5aa33fd 1 1 ACLOCAL_AMFLAGS = -I m4 2 CFLAGS += $(EXTRA_CFLAGS)3 2 4 3 GIT_DESCRIPTION := $(if $(wildcard .git),$(shell git describe --match='barnowl-*' HEAD 2>/dev/null)) … … 19 18 $(GEN_C) $(GEN_H) 20 19 21 man_MANS = doc/barnowl.122 doc_DATA = doc/intro.txt doc/advanced.txt23 24 20 barnowl_bin_LDADD = libfaim/libfaim.a 25 21 … … 39 35 $(GIT_FLAGS) 40 36 41 CODELIST_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \37 BASE_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \ 42 38 commands.c global.c text.c fmtext.c editwin.c util.c logging.c \ 43 39 perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \ … … 45 41 keypress.c keymap.c keybinding.c cmd.c context.c \ 46 42 aim.c buddy.c buddylist.c style.c errqueue.c \ 47 zbuddylist.c popexec.c select.c wcwidth.c \ 48 glib_compat.c mainpanel.c msgwin.c sepbar.c 49 50 NORMAL_SRCS = filterproc.c window.c windowcb.c 51 52 BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS) 43 zbuddylist.c popexec.c obarray.c select.c wcwidth.c \ 44 glib_compat.c filterproc.c 53 45 54 46 GEN_C = varstubs.c perlglue.c … … 72 64 $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@ 73 65 74 owl_prototypes.h.new: codelist.pl varstubs.c $( CODELIST_SRCS)66 owl_prototypes.h.new: codelist.pl varstubs.c $(BASE_SRCS) 75 67 $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@ 76 68 -
README
raeadc74 r62c91c1 1 1 BarnOwl - owl, with more ponies 2 2 3 Source is freely available from http://github.com/barnowl/barnowl/ 3 Based on owl 2.1.11, by James Kretchmar (http://www.ktools.org) 4 4 5 Based on owl 2.1.11, by James Kretchmar (http://www.ktools.org) 5 This project is a work in progress. 6 We guarantee no stability of form or function. 6 7 7 8 Notes: -
cmd.c
r1cc9b615 r8d4b521 52 52 cmd = owl_malloc(sizeof(owl_cmd)); 53 53 owl_cmd_create_alias(cmd, alias_from, alias_to); 54 owl_perlconfig_new_command(cmd->name);55 54 owl_dict_insert_element(cd, cmd->name, cmd, (void (*)(void *))owl_cmd_delete); 56 55 return(0); … … 74 73 } else if (NULL != (cmd = owl_dict_find_element(cd, argv[0]))) { 75 74 retval = owl_cmd_execute(cmd, cd, ctx, argc, argv, buff); 76 /* redraw the sepbar; TODO: don't violate layering */77 owl_global_sepbar_dirty(&g);78 75 } else { 79 76 owl_function_makemsg("Unknown command '%s'.", buff); … … 92 89 if (argc < 0) { 93 90 owl_free(tmpbuff); 91 sepbar(NULL); 94 92 owl_function_makemsg("Unbalanced quotes"); 95 93 return NULL; … … 106 104 owl_parse_delete(argv, argc); 107 105 owl_free(tmpbuff); 106 sepbar(NULL); 108 107 return retval; 109 108 } -
commands.c
r987cf3f r7ba9e0de 106 106 OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE, 107 107 "send a zephyr", 108 "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opc ode] [<user> ...] [-m <message...>]",108 "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] [-m <message...>]", 109 109 "Zwrite send a zephyr to the one or more users specified.\n\n" 110 110 "The following options are available:\n\n" … … 136 136 "Send a local message.\n"), 137 137 138 OWLCMD_ARGS("zcrypt", owl_command_z write, OWL_CTX_INTERACTIVE,138 OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE, 139 139 "send an encrypted zephyr", 140 "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opc ode] [-m <message...>]\n",140 "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [-m <message...>]\n", 141 141 "Behaves like zwrite but uses encryption. Not for use with\n" 142 142 "personal messages\n"), … … 148 148 "allow editing.\n\n" 149 149 "If 'sender' is specified, reply to the sender.\n\n" 150 "If 'all' or no args are specified, reply public ly to the\n"150 "If 'all' or no args are specified, reply publically to the\n" 151 151 "same class/instance for non-personal messages and to the\n" 152 152 "sender for personal messages.\n\n" … … 266 266 "zpunt <class> <instance> [recipient]\n" 267 267 "zpunt <instance>", 268 "The zpunt command will sup press messagesto the specified\n"268 "The zpunt command will supress message to the specified\n" 269 269 "zephyr triplet. In the second usage messages are suppressed\n" 270 270 "for class MESSAGE and the named instance.\n\n" … … 283 283 "punt <filter-text>", 284 284 "punt <filter-text (multiple words)>\n" 285 "The punt command will sup press messagesto the specified\n"285 "The punt command will supress message to the specified\n" 286 286 "filter\n\n" 287 287 "SEE ALSO: unpunt, zpunt, show zpunts\n"), … … 586 586 "name style after the -s argument.\n" 587 587 "\n" 588 "The other usages listed above are abbre viated forms that simply set\n"588 "The other usages listed above are abbreivated forms that simply set\n" 589 589 "the filter of the current view. The -d option allows you to write a\n" 590 590 "filter expression that will be dynamically created by owl and then\n" … … 594 594 OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE, 595 595 "view only messages similar to the current message", 596 "smartnarrow [-i | --instance] [-r | --relat ed]",596 "smartnarrow [-i | --instance] [-r | --relatde]", 597 597 "If the curmsg is a personal message narrow\n" 598 598 " to the conversation with that user.\n" … … 614 614 " message, the filter is to that instance.\n" 615 615 "If the curmsg is a class message, the filter is that class.\n" 616 "If the curmsg is a class message and '-i' is speci fied\n"616 "If the curmsg is a class message and '-i' is specied\n" 617 617 " the filter is to that class and instance.\n"), 618 618 … … 674 674 "for formatting messages.\n\n" 675 675 "Show variables will list the names of all variables.\n\n" 676 "Show errors will show a list of errors e ncountered by Owl.\n\n"676 "Show errors will show a list of errors ecountered by Owl.\n\n" 677 677 "SEE ALSO: filter, view, alias, bindkey, help\n"), 678 678 … … 743 743 "set the search highlight string without searching", 744 744 "setsearch <string>", 745 "The setsearch command highlights all occur rences of its\n"745 "The setsearch command highlights all occurences of its\n" 746 746 "argument and makes it the default argument for future\n" 747 747 "search commands, but does not move the cursor. With\n" … … 1371 1371 { 1372 1372 owl_function_full_redisplay(); 1373 owl_global_set_needrefresh(&g); 1373 1374 } 1374 1375 … … 1386 1387 { 1387 1388 owl_global_set_rightshift(&g, shift); 1389 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 1390 owl_global_set_needrefresh(&g); 1388 1391 } 1389 1392 … … 1911 1914 char *owl_command_zwrite(int argc, const char *const *argv, const char *buff) 1912 1915 { 1913 owl_zwrite *z;1916 owl_zwrite z; 1914 1917 1915 1918 if (!owl_global_is_havezephyr(&g)) { … … 1918 1921 } 1919 1922 /* check for a zwrite -m */ 1920 z = owl_zwrite_new(buff); 1921 if (!z) { 1922 owl_function_error("Error in zwrite arguments"); 1923 return NULL; 1924 } 1925 1926 if (owl_zwrite_is_message_set(z)) { 1927 owl_function_zwrite(z, NULL); 1928 owl_zwrite_delete(z); 1929 return NULL; 1930 } 1923 owl_zwrite_create_from_line(&z, buff); 1924 if (owl_zwrite_is_message_set(&z)) { 1925 owl_function_zwrite(buff, NULL); 1926 owl_zwrite_cleanup(&z); 1927 return (NULL); 1928 } 1929 owl_zwrite_cleanup(&z); 1931 1930 1932 1931 if (argc < 2) { 1933 owl_zwrite_delete(z);1934 1932 owl_function_makemsg("Not enough arguments to the zwrite command."); 1935 1933 } else { 1936 owl_function_zwrite_setup( z);1934 owl_function_zwrite_setup(buff); 1937 1935 } 1938 1936 return(NULL); … … 2024 2022 } 2025 2023 2024 char *owl_command_zcrypt(int argc, const char *const *argv, const char *buff) 2025 { 2026 owl_zwrite z; 2027 2028 if (!owl_global_is_havezephyr(&g)) { 2029 owl_function_makemsg("Zephyr is not available"); 2030 return(NULL); 2031 } 2032 /* check for a zcrypt -m */ 2033 owl_zwrite_create_from_line(&z, buff); 2034 if (owl_zwrite_is_message_set(&z)) { 2035 owl_function_zcrypt(buff, NULL); 2036 owl_zwrite_cleanup(&z); 2037 return (NULL); 2038 } 2039 owl_zwrite_cleanup(&z); 2040 2041 if (argc < 2) { 2042 owl_function_makemsg("Not enough arguments to the zcrypt command."); 2043 } else { 2044 owl_function_zwrite_setup(buff); 2045 } 2046 return(NULL); 2047 } 2048 2026 2049 char *owl_command_reply(int argc, const char *const *argv, const char *buff) 2027 2050 { … … 2161 2184 argc--; 2162 2185 argv++; 2186 } else if (!strcmp(argv[0], "-r")) { 2187 const char *foo; 2188 foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g))); 2189 owl_function_change_currentview_filter(foo); 2163 2190 } else if (!strcmp(argv[0], "-s")) { 2164 2191 if (argc<2) { … … 2690 2717 } 2691 2718 2719 owl_global_set_needrefresh(&g); 2692 2720 owl_global_pop_context(&g); 2693 2721 … … 2710 2738 owl_editwin_clear(e); 2711 2739 owl_editwin_insert_string(e, ptr); 2740 owl_editwin_redisplay(e); 2741 owl_global_set_needrefresh(&g); 2712 2742 } else { 2713 2743 owl_function_beep(); … … 2725 2755 owl_editwin_clear(e); 2726 2756 owl_editwin_insert_string(e, ptr); 2757 owl_editwin_redisplay(e); 2758 owl_global_set_needrefresh(&g); 2727 2759 } else { 2728 2760 owl_function_beep(); … … 2734 2766 buff = skiptokens(buff, 1); 2735 2767 owl_editwin_insert_string(e, buff); 2768 owl_editwin_redisplay(e); 2769 owl_global_set_needrefresh(&g); 2736 2770 return NULL; 2737 2771 } … … 2748 2782 owl_global_set_typwin_inactive(&g); 2749 2783 owl_global_pop_context(&g); 2784 owl_global_set_needrefresh(&g); 2750 2785 2751 2786 owl_editwin_do_callback(e); … … 2769 2804 void owl_command_popless_quit(owl_viewwin *vw) 2770 2805 { 2771 owl_viewwin_cleanup(vw);2772 2806 owl_popwin_close(owl_global_get_popwin(&g)); 2773 2807 owl_global_pop_context(&g); 2774 } 2808 owl_viewwin_cleanup(vw); 2809 owl_global_set_needrefresh(&g); 2810 } -
configure.ac
r04af908 r263320f 35 35 [with_zephyr=check]) 36 36 37 AC_ARG_WITH([krb4],38 AS_HELP_STRING([--with-krb4],39 [Build with kerberos IV]))40 41 37 AS_IF([test "x$with_zephyr" != xno], 42 [AS_IF([test "x$with_krb4" != "xno"], 43 [AC_MSG_CHECKING([for Kerberos IV]) 44 AS_IF([krb5-config krb4 --libs >/dev/null 2>&1], 45 [AC_MSG_RESULT([yes]) 46 AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV]) 47 CFLAGS="${CFLAGS} `krb5-config krb4 --cflags`" 48 LIBS="${LIBS} `krb5-config krb4 --libs`" 49 ], 50 [AC_MSG_RESULT([no]) 51 AS_IF([test "x$with_krb4" = "xyes"], 52 [AC_MSG_ERROR([Kerberos IV requested but not found])]) 53 PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto]) 54 CFLAGS="${CFLAGS} ${LIBCRYPTO_CFLAGS}" 55 LIBS="${LIBS} ${LIBCRYPTO_LIBS}" 56 ])]) 38 [AC_MSG_CHECKING([for Kerberos IV]) 39 AS_IF([krb5-config krb4 --libs >/dev/null 2>&1], 40 [AC_MSG_RESULT([yes]) 41 AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV]) 42 CFLAGS="${CFLAGS} `krb5-config krb4 --cflags`" 43 LIBS="${LIBS} `krb5-config krb4 --libs`" 44 ], 45 [AC_MSG_RESULT([no]) 46 PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto]) 47 CFLAGS="${CFLAGS} ${LIBCRYPTO_CFLAGS}" 48 LIBS="${LIBS} ${LIBCRYPTO_LIBS}" 49 ]) 57 50 AC_CHECK_LIB([zephyr], [ZGetSender], 58 51 [LIBS="$LIBS -lzephyr" … … 115 108 116 109 dnl Add CFLAGS and LDFLAGS for glib-2.0 117 PKG_CHECK_MODULES(GLIB, [glib-2.0 gobject-2.0])110 PKG_CHECK_MODULES(GLIB,glib-2.0) 118 111 119 112 AC_MSG_NOTICE([Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}]) … … 138 131 test "$HAVE_DES_ECB_ENCRYPT"]) 139 132 140 CFLAGS="$CFLAGS -D_XOPEN_SOURCE"141 142 133 AC_SUBST([LIBFAIM_CFLAGS]) 143 134 -
context.c
r07b59ea r2a17b63 9 9 ctx->mode = OWL_CTX_STARTUP; 10 10 ctx->data = NULL; 11 ctx->cursor = NULL;12 11 return 0; 13 12 } -
doc/code.txt
r44cc9ab r1286893 86 86 Meta. At any one time, there is exactly one active 87 87 keymap which determines where keybindings are looked for 88 (along with its parents).88 (along with its submaps). 89 89 90 90 list: Simple list abstraction. (Uses realloc to resize the list.) -
editwin.c
r3f11c00 r9d7a720 28 28 int cursorx; 29 29 int winlines, wincols, fillcol, wrapcol; 30 owl_window *win; 31 gulong repaint_id; 32 gulong resized_id; 30 WINDOW *curswin; 33 31 int style; 34 32 int lock; … … 42 40 }; 43 41 44 static void oe_set_window(owl_editwin *e, owl_window *w, int winlines, int wincols);45 static void oe_redraw(owl_window *win, WINDOW *curswin, void *user_data);46 42 static void oe_reframe(owl_editwin *e); 47 43 static void oe_save_excursion(owl_editwin *e, oe_excursion *x); … … 62 58 static char *oe_chunk(owl_editwin *e, int start, int end); 63 59 static void oe_destroy_cbdata(owl_editwin *e); 64 static void oe_dirty(owl_editwin *e);65 static void oe_window_resized(owl_window *w, owl_editwin *e);66 60 67 61 #define INCR 4096 … … 79 73 void owl_editwin_delete(owl_editwin *e) 80 74 { 81 if (e->win) {82 g_signal_handler_disconnect(e->win, e->repaint_id);83 g_signal_handler_disconnect(e->win, e->resized_id);84 }85 75 owl_free(e->buff); 86 76 owl_free(e->killbuf); … … 101 91 } 102 92 e->index = index; 103 oe_dirty(e);104 93 } 105 94 … … 116 105 117 106 static void _owl_editwin_init(owl_editwin *e, 107 WINDOW *win, 118 108 int winlines, 119 109 int wincols, … … 140 130 e->style=OWL_EDITWIN_STYLE_MULTILINE; 141 131 } 132 owl_editwin_set_curswin(e, win, winlines, wincols); 142 133 e->lock=0; 143 134 e->dotsend=0; 144 135 e->echochar='\0'; 145 } 146 147 owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist) 136 137 if (win) werase(win); 138 } 139 140 owl_editwin *owl_editwin_new(WINDOW *win, int winlines, int wincols, int style, owl_history *hist) 148 141 { 149 142 owl_editwin *e = owl_editwin_allocate(); 150 143 151 _owl_editwin_init(e, winlines, wincols, style, hist); 152 oe_set_window(e, win, winlines, wincols); 144 _owl_editwin_init(e, win, winlines, wincols, style, hist); 153 145 return e; 154 146 } 155 147 156 static void oe_window_resized(owl_window *w, owl_editwin *e) 157 { 158 /* update the sizes */ 159 owl_window_get_position(w, &e->winlines, &e->wincols, NULL, NULL); 160 } 161 162 static void oe_set_window(owl_editwin *e, owl_window *w, int winlines, int wincols) 163 { 164 e->win=w; 148 void owl_editwin_set_curswin(owl_editwin *e, WINDOW *w, int winlines, int wincols) 149 { 150 e->curswin=w; 165 151 e->winlines=winlines; 166 152 e->wincols=wincols; … … 170 156 else 171 157 e->wrapcol = 0; 172 if (e->win) {173 e->repaint_id = g_signal_connect(w, "redraw", G_CALLBACK(oe_redraw), e);174 e->resized_id = g_signal_connect(w, "resized", G_CALLBACK(oe_window_resized), e);175 owl_window_dirty(e->win);176 }177 158 } 178 159 … … 184 165 { 185 166 e->echochar=ch; 186 oe_dirty(e); 167 } 168 169 WINDOW *owl_editwin_get_curswin(owl_editwin *e) 170 { 171 return(e->curswin); 187 172 } 188 173 … … 254 239 e->lock=e->bufflen; 255 240 oe_set_index(e, e->lock); 256 o e_dirty(e);241 owl_editwin_redisplay(e); 257 242 } 258 243 … … 280 265 281 266 owl_free(e->buff); 282 _owl_editwin_init(e, e-> winlines, e->wincols, e->style, e->hist);267 _owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist); 283 268 284 269 if (lock > 0) { … … 301 286 { 302 287 e->topindex = -1; 303 oe_dirty(e);304 288 } 305 289 … … 483 467 484 468 oe_restore_excursion(e, &x); 485 oe_dirty(e); 486 } 487 488 static void oe_addnec(owl_editwin *e, WINDOW *curswin, int count) 469 } 470 471 static void oe_addnec(owl_editwin *e, int count) 489 472 { 490 473 int i; 491 474 492 475 for (i = 0; i < count; i++) 493 waddch( curswin, e->echochar);494 } 495 496 static void oe_mvaddnec(owl_editwin *e, WINDOW *curswin,int y, int x, int count)497 { 498 wmove( curswin, y, x);499 oe_addnec(e, c urswin, count);476 waddch(e->curswin, e->echochar); 477 } 478 479 static void oe_mvaddnec(owl_editwin *e, int y, int x, int count) 480 { 481 wmove(e->curswin, y, x); 482 oe_addnec(e, count); 500 483 } 501 484 502 485 /* regenerate the text on the curses window */ 503 static void oe_redraw(owl_window *win, WINDOW *curswin, void *user_data)486 void owl_editwin_redisplay(owl_editwin *e) 504 487 { 505 488 int x = -1, y = -1, t, hard; 506 489 int line, index, lineindex, times = 0; 507 owl_editwin *e = user_data;508 490 509 491 do { 510 werase( curswin);492 werase(e->curswin); 511 493 512 494 if (e->topindex == -1 || e->index < e->topindex) … … 523 505 if (index - lineindex) { 524 506 if (!e->echochar) 525 mvwaddnstr( curswin, line, 0,507 mvwaddnstr(e->curswin, line, 0, 526 508 e->buff + lineindex, 527 509 index - lineindex); 528 510 else { 529 511 if(lineindex < e->lock) { 530 mvwaddnstr( curswin, line, 0,512 mvwaddnstr(e->curswin, line, 0, 531 513 e->buff + lineindex, 532 514 MIN(index - lineindex, 533 515 e->lock - lineindex)); 534 516 if (e->lock < index) 535 oe_addnec(e, curswin,517 oe_addnec(e, 536 518 oe_region_width(e, e->lock, index, 537 519 oe_region_width(e, lineindex, e->lock, 0))); 538 520 } else 539 oe_mvaddnec(e, curswin,line, 0, oe_region_width(e, lineindex, index, 0));521 oe_mvaddnec(e, line, 0, oe_region_width(e, lineindex, index, 0)); 540 522 } 541 523 if (!hard) 542 waddch( curswin, '\\');524 waddch(e->curswin, '\\'); 543 525 } 544 526 line++; … … 549 531 } while(x == -1 && times < 3); 550 532 551 wmove( curswin, y, x);533 wmove(e->curswin, y, x); 552 534 e->cursorx = x; 553 535 } … … 642 624 if (start <= e->topindex) 643 625 owl_editwin_recenter(e); 644 645 oe_dirty(e);646 626 647 627 return change; … … 877 857 878 858 e->goal_column = goal_column; 879 oe_dirty(e);880 859 881 860 return distance; … … 1232 1211 return; 1233 1212 } 1213 owl_editwin_redisplay(e); 1234 1214 } 1235 1215 … … 1366 1346 } 1367 1347 1368 static void oe_dirty(owl_editwin *e)1369 {1370 if (e->win) owl_window_dirty(e->win);1371 }1372 1373 1348 1374 1349 -
functions.c
rd12a8c7 rd12a8c7 216 216 /* redisplay etc. */ 217 217 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 218 owl_global_set_needrefresh(&g); 218 219 } 219 220 … … 222 223 * that. 223 224 */ 224 owl_message *owl_function_make_outgoing_zephyr(const owl_zwrite *z)225 owl_message *owl_function_make_outgoing_zephyr(const char *body, const char *zwriteline, const char *zsig) 225 226 { 226 227 owl_message *m; 228 owl_zwrite zw; 229 230 owl_zwrite_create_from_line(&zw, zwriteline); 231 owl_zwrite_set_zsig(&zw, zsig); 227 232 228 233 /* create the message */ 229 234 m=owl_malloc(sizeof(owl_message)); 230 owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z)); 235 236 owl_message_create_from_zwrite(m, &zw, body); 237 owl_zwrite_cleanup(&zw); 231 238 232 239 return(m); … … 286 293 owl_editwin_set_cbdata(e, data, cleanup); 287 294 owl_editwin_set_callback(e, callback); 288 owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti" , owl_global_get_typwin_window(&g));289 } 290 291 static void owl_function_write_setup(const char * noun)295 owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti"); 296 } 297 298 static void owl_function_write_setup(const char *line, const char *noun, void (*callback)(owl_editwin *)) 292 299 { 293 300 … … 300 307 "End with a dot on a line by itself. ^C will quit.", 301 308 noun); 302 } 303 304 void owl_function_zwrite_setup(owl_zwrite *z) 305 { 309 310 owl_function_start_edit_win(line, callback, 311 owl_strdup(line), 312 owl_free); 313 } 314 315 void owl_function_zwrite_setup(const char *line) 316 { 317 owl_zwrite z; 318 int ret; 319 320 /* check the arguments */ 321 ret=owl_zwrite_create_from_line(&z, line); 322 if (ret) { 323 owl_function_error("Error in zwrite arguments"); 324 owl_zwrite_cleanup(&z); 325 return; 326 } 327 306 328 /* send a ping if necessary */ 307 329 if (owl_global_is_txping(&g)) { 308 owl_zwrite_send_ping(z); 309 } 310 311 312 owl_function_write_setup("zephyr"); 313 owl_function_start_edit_win(z->zwriteline, 314 &owl_callback_zwrite, 315 z, (void(*)(void*))owl_zwrite_delete); 330 owl_zwrite_send_ping(&z); 331 } 332 owl_zwrite_cleanup(&z); 333 334 owl_function_write_setup(line, "zephyr", &owl_callback_zwrite); 316 335 } 317 336 318 337 void owl_function_aimwrite_setup(const char *line) 319 338 { 320 owl_function_write_setup("message"); 321 owl_function_start_edit_win(line, 322 &owl_callback_aimwrite, 323 owl_strdup(line), 324 owl_free); 325 339 owl_function_write_setup(line, "message", &owl_callback_aimwrite); 326 340 } 327 341 328 342 void owl_function_loopwrite_setup(void) 329 343 { 330 owl_function_write_setup("message"); 331 owl_function_start_edit_win("loopwrite", 332 &owl_callback_loopwrite, 333 "loopwrite", NULL); 344 owl_function_write_setup("loopwrite", "message", owl_callback_loopwrite); 334 345 } 335 346 336 347 void owl_callback_zwrite(owl_editwin *e) { 337 owl_zwrite *z = owl_editwin_get_cbdata(e); 338 owl_function_zwrite(z, owl_editwin_get_text(e)); 348 char *command = owl_editwin_get_cbdata(e); 349 owl_function_zwrite(command, 350 owl_editwin_get_text(e)); 339 351 } 340 352 … … 342 354 * the message is expected to be set from the zwrite line itself 343 355 */ 344 void owl_function_zwrite(owl_zwrite *z, const char *msg) 345 { 356 void owl_function_zwrite(const char *line, const char *msg) 357 { 358 owl_zwrite z; 359 const char *mymsg; 346 360 owl_message *m; 347 361 348 if( strcmp(z->cmd, "zcrypt") == 0) {349 owl_function_zcrypt( z, msg);362 if(!strncmp(line, "zcrypt", strlen("zcrypt"))) { 363 owl_function_zcrypt(line, msg); 350 364 return; 351 365 } 352 366 353 367 /* create the zwrite and send the message */ 354 owl_zwrite_populate_zsig(z); 368 owl_zwrite_create_from_line(&z, line); 369 owl_zwrite_populate_zsig(&z); 355 370 if (msg) { 356 owl_zwrite_set_message( z, msg);357 } 358 owl_zwrite_send_message( z);371 owl_zwrite_set_message(&z, msg); 372 } 373 owl_zwrite_send_message(&z); 359 374 owl_function_makemsg("Waiting for ack..."); 360 375 361 376 /* If it's personal */ 362 if (owl_zwrite_is_personal( z)) {377 if (owl_zwrite_is_personal(&z)) { 363 378 /* create the outgoing message */ 364 m=owl_function_make_outgoing_zephyr(z); 379 mymsg=owl_zwrite_get_message(&z); 380 m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 365 381 366 382 if (m) { … … 370 386 } 371 387 } 388 389 /* free the zwrite */ 390 owl_zwrite_cleanup(&z); 372 391 } 373 392 … … 375 394 * the message is expected to be set from the zwrite line itself 376 395 */ 377 void owl_function_zcrypt(owl_zwrite *z, const char *msg) 378 { 396 void owl_function_zcrypt(const char *line, const char *msg) 397 { 398 owl_zwrite z; 399 const char *mymsg; 379 400 char *cryptmsg; 380 401 owl_message *m; … … 382 403 char *zcrypt; 383 404 int rv, status; 384 char *old_msg;385 405 386 406 /* create the zwrite and send the message */ 387 owl_zwrite_populate_zsig(z); 407 owl_zwrite_create_from_line(&z, line); 408 owl_zwrite_populate_zsig(&z); 388 409 if (msg) { 389 owl_zwrite_set_message(z, msg); 390 } 391 old_msg = owl_strdup(owl_zwrite_get_message(z)); 410 owl_zwrite_set_message(&z, msg); 411 } 412 413 mymsg=owl_zwrite_get_message(&z); 392 414 393 415 zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir()); 394 416 argv[0] = "zcrypt"; 395 417 argv[1] = "-E"; 396 argv[2] = "-c"; argv[3] = owl_zwrite_get_class( z);397 argv[4] = "-i"; argv[5] = owl_zwrite_get_instance( z);418 argv[2] = "-c"; argv[3] = owl_zwrite_get_class(&z); 419 argv[4] = "-i"; argv[5] = owl_zwrite_get_instance(&z); 398 420 argv[6] = NULL; 399 421 400 rv = call_filter(zcrypt, argv, owl_zwrite_get_message(z), &cryptmsg, &status);422 rv = call_filter(zcrypt, argv, mymsg, &cryptmsg, &status); 401 423 402 424 owl_free(zcrypt); … … 404 426 if (rv || status) { 405 427 if(cryptmsg) owl_free(cryptmsg); 406 owl_free(old_msg);407 428 owl_function_error("Error in zcrypt, possibly no key found. Message not sent."); 408 429 owl_function_beep(); 430 owl_zwrite_cleanup(&z); 409 431 return; 410 432 } 411 433 412 owl_zwrite_set_message _raw(z, cryptmsg);413 owl_zwrite_set_opcode( z, "crypt");414 415 owl_zwrite_send_message( z);434 owl_zwrite_set_message(&z, cryptmsg); 435 owl_zwrite_set_opcode(&z, "crypt"); 436 437 owl_zwrite_send_message(&z); 416 438 owl_function_makemsg("Waiting for ack..."); 417 439 418 440 /* If it's personal */ 419 if (owl_zwrite_is_personal( z)) {420 /* Create the outgoing message. Restore the un-crypted message for display.*/421 owl_zwrite_set_message_raw(z, old_msg);422 m=owl_function_make_outgoing_zephyr( z);441 if (owl_zwrite_is_personal(&z)) { 442 /* create the outgoing message */ 443 mymsg=owl_zwrite_get_message(&z); 444 m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 423 445 if (m) { 424 446 owl_global_messagequeue_addmsg(&g, m); … … 430 452 /* free the zwrite */ 431 453 owl_free(cryptmsg); 454 owl_zwrite_cleanup(&z); 432 455 } 433 456 … … 785 808 { 786 809 owl_global_set_rightshift(&g, owl_global_get_rightshift(&g)+10); 810 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 811 owl_global_set_needrefresh(&g); 787 812 } 788 813 … … 794 819 if (shift > 0) { 795 820 owl_global_set_rightshift(&g, MAX(shift - 10, 0)); 821 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 822 owl_global_set_needrefresh(&g); 796 823 } else { 797 824 owl_function_beep(); … … 1196 1223 if (owl_global_is_bell(&g)) { 1197 1224 beep(); 1225 owl_global_set_needrefresh(&g); /* do we really need this? */ 1198 1226 } 1199 1227 } … … 1224 1252 } 1225 1253 1226 static void _dirty_everything(owl_window *w) { 1227 if (!owl_window_is_realized(w)) 1228 return; 1229 owl_window_dirty(w); 1230 owl_window_children_foreach(w, (GFunc)_dirty_everything, NULL); 1254 void owl_function_set_cursor(WINDOW *win) 1255 { 1256 /* Be careful that this window is actually empty, otherwise panels get confused */ 1257 if (is_wintouched(win)) { 1258 owl_function_debugmsg("Warning: owl_function_set_cursor called on dirty window"); 1259 update_panels(); 1260 } 1261 wnoutrefresh(win); 1231 1262 } 1232 1263 1233 1264 void owl_function_full_redisplay(void) 1234 1265 { 1235 _dirty_everything(owl_window_get_screen()); 1266 touchwin(owl_global_get_curs_recwin(&g)); 1267 touchwin(owl_global_get_curs_sepwin(&g)); 1268 touchwin(owl_global_get_curs_typwin(&g)); 1269 touchwin(owl_global_get_curs_msgwin(&g)); 1270 1271 sepbar(""); 1272 owl_function_makemsg(""); 1273 1274 owl_global_set_needrefresh(&g); 1236 1275 } 1237 1276 … … 1245 1284 1246 1285 owl_popwin_up(pw); 1247 owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL); 1248 owl_viewwin_init_text(v, owl_popwin_get_content(pw), text); 1286 owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless"); 1287 owl_viewwin_init_text(v, owl_popwin_get_curswin(pw), 1288 owl_popwin_get_lines(pw), owl_popwin_get_cols(pw), 1289 text); 1290 owl_viewwin_redisplay(v); 1291 owl_global_set_needrefresh(&g); 1249 1292 } 1250 1293 … … 1258 1301 1259 1302 owl_popwin_up(pw); 1260 owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL); 1261 owl_viewwin_init_fmtext(v, owl_popwin_get_content(pw), fm); 1303 owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless"); 1304 owl_viewwin_init_fmtext(v, owl_popwin_get_curswin(pw), 1305 owl_popwin_get_lines(pw), owl_popwin_get_cols(pw), 1306 fm); 1307 owl_viewwin_redisplay(v); 1308 owl_global_set_needrefresh(&g); 1262 1309 } 1263 1310 … … 1519 1566 /* redisplay */ 1520 1567 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 1568 owl_global_set_needrefresh(&g); 1521 1569 } 1522 1570 … … 1524 1572 { 1525 1573 owl_global_set_typwin_lines(&g, newsize); 1526 owl_ mainpanel_layout_contents(&g.mainpanel);1574 owl_global_set_relayout_pending(&g); 1527 1575 } 1528 1576 … … 1638 1686 } 1639 1687 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 1688 owl_global_set_needrefresh(&g); 1640 1689 } else { 1641 1690 owl_function_error("No message with id %d: unable to mark for (un)delete",id); … … 1673 1722 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 1674 1723 owl_function_makemsg("%i messages marked for deletion", count); 1724 owl_global_set_needrefresh(&g); 1675 1725 } 1676 1726 … … 1877 1927 1878 1928 owl_editwin_set_locktext(tw, "command: "); 1929 owl_global_set_needrefresh(&g); 1879 1930 1880 1931 owl_editwin_insert_string(tw, line); 1881 1882 owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline", owl_global_get_typwin_window(&g)); 1932 owl_editwin_redisplay(tw); 1933 1934 owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline"); 1883 1935 owl_editwin_set_callback(tw, owl_callback_command); 1884 1936 } … … 1891 1943 1892 1944 owl_editwin_set_locktext(tw, line); 1893 1894 owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_typwin_window(&g)); 1945 owl_global_set_needrefresh(&g); 1946 1947 owl_editwin_redisplay(tw); 1948 1949 owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse"); 1895 1950 return tw; 1896 1951 } … … 1905 1960 1906 1961 owl_editwin_set_locktext(tw, line); 1907 1908 owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_typwin_window(&g)); 1962 owl_global_set_needrefresh(&g); 1963 1964 owl_editwin_redisplay(tw); 1965 1966 owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse"); 1909 1967 return tw; 1910 1968 } … … 1941 1999 pclose(p); 1942 2000 1943 if (type == OWL_OUTPUT_RETURN) { 2001 if (type == OWL_OUTPUT_POPUP) { 2002 owl_function_popless_text(out); 2003 } else if (type == OWL_OUTPUT_RETURN) { 1944 2004 owl_free(newbuff); 1945 2005 return out; 1946 2006 } else if (type == OWL_OUTPUT_ADMINMSG) { 1947 2007 owl_function_adminmsg(buff, out); 2008 } else { 2009 owl_function_popless_text(out); 1948 2010 } 1949 2011 owl_free(out); … … 1978 2040 } else if (type == OWL_OUTPUT_RETURN) { 1979 2041 return perlout; 2042 } else { 2043 owl_function_popless_text(perlout); 1980 2044 } 1981 2045 owl_free(perlout); … … 2069 2133 } 2070 2134 owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3])); 2135 owl_global_set_needrefresh(&g); 2071 2136 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2072 2137 return; … … 2083 2148 } 2084 2149 owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3])); 2150 owl_global_set_needrefresh(&g); 2085 2151 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2086 2152 return; … … 2111 2177 owl_function_change_currentview_filter(argv[1]); 2112 2178 } 2179 owl_global_set_needrefresh(&g); 2113 2180 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2114 2181 } … … 2438 2505 2439 2506 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2440 }2441 2442 static char *owl_function_smartfilter_cc(const owl_message *m) {2443 const char *ccs;2444 char *filtname;2445 char *text;2446 owl_filter *f;2447 2448 ccs = owl_message_get_attribute_value(m, "zephyr_ccs");2449 2450 filtname = owl_sprintf("conversation-%s", ccs);2451 owl_text_tr(filtname, ' ', '-');2452 2453 if (owl_global_get_filter(&g, filtname)) {2454 return filtname;2455 }2456 2457 text = owl_sprintf("type ^zephyr$ and filter personal and "2458 "zephyr_ccs ^%s%s%s$",2459 owl_getquoting(ccs), ccs, owl_getquoting(ccs));2460 2461 f = owl_filter_new_fromstring(filtname, text);2462 2463 owl_global_add_filter(&g, f);2464 2465 owl_free(text);2466 2467 return filtname;2468 2507 } 2469 2508 … … 2521 2560 if (owl_message_is_type_zephyr(m)) { 2522 2561 if (owl_message_is_personal(m) || owl_message_is_loginout(m)) { 2523 if (owl_message_get_attribute_value(m, "zephyr_ccs") != NULL) {2524 return owl_function_smartfilter_cc(m);2525 }2526 2527 2562 if (owl_message_is_direction_in(m)) { 2528 2563 zperson=short_zuser(owl_message_get_sender(m)); … … 2654 2689 owl_filter_set_fgcolor(f, owl_util_string_to_color(fgcolor)); 2655 2690 2691 owl_global_set_needrefresh(&g); 2656 2692 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2657 2693 return(0); … … 2817 2853 km = owl_keyhandler_get_keymap(kh, kmname); 2818 2854 owl_fmtext_append_bold(&fm, "\n\n----------------------------------------------------------------------------------------------------\n\n"); 2819 owl_keymap_get_details(km, &fm , 0);2855 owl_keymap_get_details(km, &fm); 2820 2856 } 2821 2857 owl_fmtext_append_normal(&fm, "\n"); … … 2843 2879 km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), name); 2844 2880 if (km) { 2845 owl_keymap_get_details(km, &fm , 1);2881 owl_keymap_get_details(km, &fm); 2846 2882 } else { 2847 2883 owl_fmtext_append_normal(&fm, "No such keymap...\n"); … … 3367 3403 { 3368 3404 va_list ap; 3369 char *str; 3405 char buff[2048]; 3406 3407 if (!owl_global_get_curs_msgwin(&g)) return; 3370 3408 3371 3409 va_start(ap, fmt); 3372 str = g_strdup_vprintf(fmt, ap); 3410 werase(owl_global_get_curs_msgwin(&g)); 3411 3412 vsnprintf(buff, 2048, fmt, ap); 3413 owl_function_debugmsg("makemsg: %s", buff); 3414 waddstr(owl_global_get_curs_msgwin(&g), buff); 3415 owl_global_set_needrefresh(&g); 3373 3416 va_end(ap); 3374 3375 owl_function_debugmsg("makemsg: %s", str);3376 owl_msgwin_set_text(&g.msgwin, str);3377 3417 } 3378 3418 -
global.c
r26ad412 r26ad412 13 13 #endif 14 14 15 static void _owl_global_init_windows(owl_global *g);16 17 15 void owl_global_init(owl_global *g) { 18 16 struct hostent *hent; … … 20 18 char *cd; 21 19 22 g_type_init(); 20 g->malloced=0; 21 g->freed=0; 23 22 24 23 gethostname(hostname, MAXHOSTNAMELEN); … … 30 29 } 31 30 32 g->lines=LINES;33 g->cols=COLS;34 /* We shouldn't need this if we initialize lines and cols before the first35 * owl_window_get_screen, but to be safe, we synchronize. */36 owl_window_resize(owl_window_get_screen(), g->lines, g->cols);37 38 31 g->context_stack = NULL; 39 owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL , NULL);32 owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL); 40 33 41 34 g->curmsg=0; 42 35 g->topmsg=0; 43 36 g->markedmsgid=-1; 37 g->needrefresh=1; 44 38 g->startupargs=NULL; 45 39 46 40 owl_variable_dict_setup(&(g->vars)); 41 42 g->lines=LINES; 43 g->cols=COLS; 47 44 48 45 g->rightshift=0; … … 56 53 g->filterlist = NULL; 57 54 owl_list_create(&(g->puntlist)); 58 g->messagequeue = g_queue_new();55 owl_list_create(&(g->messagequeue)); 59 56 owl_dict_create(&(g->styledict)); 60 57 g->curmsg_vert_offset=0; 61 58 g->resizepending=0; 59 g->relayoutpending = 0; 62 60 g->direction=OWL_DIRECTION_DOWNWARDS; 63 61 g->zaway=0; … … 81 79 g->nextmsgid=0; 82 80 81 _owl_global_setup_windows(g); 82 83 83 /* Fill in some variables which don't have constant defaults */ 84 84 /* TODO: come back later and check passwd file first */ … … 92 92 93 93 owl_messagelist_create(&(g->msglist)); 94 95 _owl_global_init_windows(g);94 owl_mainwin_init(&(g->mw)); 95 owl_popwin_init(&(g->pw)); 96 96 97 97 g->aim_screenname=NULL; … … 112 112 g->zaldlist = NULL; 113 113 g->pseudologin_notify = 0; 114 115 owl_obarray_init(&(g->obarray)); 114 116 115 117 owl_message_init_fmtext_cache(); … … 118 120 g->timerlist = NULL; 119 121 g->interrupted = FALSE; 120 }121 122 static void _owl_global_init_windows(owl_global *g)123 {124 /* Create the main window */125 owl_mainpanel_init(&(g->mainpanel));126 127 /* Create the widgets */128 owl_mainwin_init(&(g->mw), g->mainpanel.recwin);129 owl_popwin_init(&(g->pw));130 owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);131 owl_sepbar_init(g->mainpanel.sepwin);132 133 owl_window_set_default_cursor(g->mainpanel.sepwin);134 122 135 123 /* set up a pad for input */ … … 138 126 keypad(g->input_pad, 1); 139 127 meta(g->input_pad, 1); 140 }141 142 void owl_global_sepbar_dirty(owl_global *g)143 {144 owl_window_dirty(g->mainpanel.sepwin);145 128 } 146 129 … … 175 158 } 176 159 160 void _owl_global_setup_windows(owl_global *g) { 161 int cols, typwin_lines; 162 163 cols=g->cols; 164 typwin_lines=owl_global_get_typwin_lines(g); 165 166 /* set the new window sizes */ 167 g->recwinlines=g->lines-(typwin_lines+2); 168 if (g->recwinlines<0) { 169 /* gotta deal with this */ 170 g->recwinlines=0; 171 } 172 173 /* create the new windows */ 174 _owl_panel_set_window(&g->recpan, newwin(g->recwinlines, cols, 0, 0)); 175 _owl_panel_set_window(&g->seppan, newwin(1, cols, g->recwinlines, 0)); 176 _owl_panel_set_window(&g->msgpan, newwin(1, cols, g->recwinlines+1, 0)); 177 _owl_panel_set_window(&g->typpan, newwin(typwin_lines, cols, g->recwinlines+2, 0)); 178 179 if (g->tw) 180 owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols); 181 182 idlok(owl_global_get_curs_typwin(g), FALSE); 183 idlok(owl_global_get_curs_recwin(g), FALSE); 184 idlok(owl_global_get_curs_sepwin(g), FALSE); 185 idlok(owl_global_get_curs_msgwin(g), FALSE); 186 187 wmove(owl_global_get_curs_typwin(g), 0, 0); 188 } 189 177 190 owl_context *owl_global_get_context(owl_global *g) { 178 191 if (!g->context_stack) … … 181 194 } 182 195 183 static void owl_global_activate_context(owl_global *g, owl_context *c) { 184 if (!c) 196 static void owl_global_lookup_keymap(owl_global *g) { 197 owl_context *c = owl_global_get_context(g); 198 if (!c || !c->keymap) 185 199 return; 186 200 187 if (c->keymap) { 188 if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) { 189 owl_function_error("Unable to activate keymap '%s'", c->keymap); 190 } 191 } 192 owl_window_set_cursor(c->cursor); 193 } 194 195 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap, owl_window *cursor) { 201 if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) { 202 owl_function_error("Unable to activate keymap '%s'", c->keymap); 203 } 204 } 205 206 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) { 196 207 owl_context *c; 197 208 if (!(mode & OWL_CTX_MODE_BITS)) … … 200 211 c->mode = mode; 201 212 c->data = data; 202 c->cursor = cursor ? g_object_ref(cursor) : NULL;203 213 c->keymap = owl_strdup(keymap); 204 214 g->context_stack = g_list_prepend(g->context_stack, c); 205 owl_global_ activate_context(g, owl_global_get_context(g));215 owl_global_lookup_keymap(g); 206 216 } 207 217 … … 213 223 g->context_stack = g_list_delete_link(g->context_stack, 214 224 g->context_stack); 215 if (c->cursor)216 g_object_unref(c->cursor);217 225 owl_free(c->keymap); 218 226 owl_free(c); 219 owl_global_ activate_context(g, owl_global_get_context(g));227 owl_global_lookup_keymap(g); 220 228 } 221 229 … … 229 237 230 238 int owl_global_get_recwin_lines(const owl_global *g) { 231 return g->mainpanel.recwinlines;239 return(g->recwinlines); 232 240 } 233 241 … … 295 303 } 296 304 297 /* underlying owl_windows */ 298 299 owl_window *owl_global_get_typwin_window(const owl_global *g) { 300 return g->mainpanel.typwin; 305 /* curses windows */ 306 307 WINDOW *owl_global_get_curs_recwin(const owl_global *g) { 308 return panel_window(g->recpan); 309 } 310 311 WINDOW *owl_global_get_curs_sepwin(const owl_global *g) { 312 return panel_window(g->seppan); 313 } 314 315 WINDOW *owl_global_get_curs_msgwin(const owl_global *g) { 316 return panel_window(g->msgpan); 317 } 318 319 WINDOW *owl_global_get_curs_typwin(const owl_global *g) { 320 return panel_window(g->typpan); 301 321 } 302 322 … … 307 327 } 308 328 329 /* refresh */ 330 331 int owl_global_is_needrefresh(const owl_global *g) { 332 if (g->needrefresh==1) return(1); 333 return(0); 334 } 335 336 void owl_global_set_needrefresh(owl_global *g) { 337 g->needrefresh=1; 338 } 339 340 void owl_global_set_noneedrefresh(owl_global *g) { 341 g->needrefresh=0; 342 } 343 309 344 /* variable dictionary */ 310 345 … … 322 357 323 358 void owl_global_set_rightshift(owl_global *g, int i) { 324 g->rightshift = i; 325 owl_mainwin_redisplay(owl_global_get_mainwin(g)); 359 g->rightshift=i; 326 360 } 327 361 … … 338 372 owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d); 339 373 340 if (g->typwin_erase_id) { 341 g_signal_handler_disconnect(owl_global_get_typwin_window(g), g->typwin_erase_id); 342 g->typwin_erase_id = 0; 343 } 344 345 g->tw = owl_editwin_new(owl_global_get_typwin_window(g), 374 g->tw = owl_editwin_new(owl_global_get_curs_typwin(g), 346 375 owl_global_get_typwin_lines(g), 347 376 g->cols, … … 356 385 owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d); 357 386 358 if (!g->typwin_erase_id) { 359 g->typwin_erase_id = 360 g_signal_connect(owl_global_get_typwin_window(g), "redraw", G_CALLBACK(owl_window_erase_cb), NULL); 361 } 362 owl_window_dirty(owl_global_get_typwin_window(g)); 363 387 werase(owl_global_get_curs_typwin(g)); 364 388 g->tw = NULL; 365 389 } … … 369 393 void owl_global_set_resize_pending(owl_global *g) { 370 394 g->resizepending=1; 395 } 396 397 void owl_global_set_relayout_pending(owl_global *g) { 398 g->relayoutpending = 1; 371 399 } 372 400 … … 448 476 * fail. 449 477 */ 450 void owl_global_get_terminal_size(int *lines, int *cols) {478 static void _owl_global_get_size(int *lines, int *cols) { 451 479 struct winsize size; 452 480 /* get the new size */ … … 465 493 } 466 494 467 void owl_global_ check_resize(owl_global *g) {468 /* resize the screen. If lines or colsis 0 use the terminal size */495 void owl_global_resize(owl_global *g, int x, int y) { 496 /* resize the screen. If x or y is 0 use the terminal size */ 469 497 if (!g->resizepending) return; 470 498 g->resizepending = 0; 471 499 472 owl_global_get_terminal_size(&g->lines, &g->cols); 473 owl_window_resize(owl_window_get_screen(), g->lines, g->cols); 500 _owl_global_get_size(&g->lines, &g->cols); 501 if (x != 0) { 502 g->lines = x; 503 } 504 if (y != 0) { 505 g->cols = y; 506 } 507 508 resizeterm(g->lines, g->cols); 474 509 475 510 owl_function_debugmsg("New size is %i lines, %i cols.", g->lines, g->cols); 511 owl_global_set_relayout_pending(g); 512 } 513 514 void owl_global_relayout(owl_global *g) { 515 owl_popwin *pw; 516 owl_viewwin *vw; 517 518 if (!g->relayoutpending) return; 519 g->relayoutpending = 0; 520 521 owl_function_debugmsg("Relayouting..."); 522 523 /* re-initialize the windows */ 524 _owl_global_setup_windows(g); 525 526 /* in case any styles rely on the current width */ 527 owl_messagelist_invalidate_formats(owl_global_get_msglist(g)); 528 529 /* recalculate the topmsg to make sure the current message is on 530 * screen */ 531 owl_function_calculate_topmsg(OWL_DIRECTION_NONE); 532 533 /* recreate the popwin */ 534 pw = owl_global_get_popwin(g); 535 if (owl_popwin_is_active(pw)) { 536 /* 537 * This is somewhat hacky; we probably want a proper windowing layer. We 538 * destroy the popwin and recreate it. Then the viewwin is redirected to 539 * the new window. 540 */ 541 vw = owl_global_get_viewwin(g); 542 owl_popwin_close(pw); 543 owl_popwin_up(pw); 544 owl_viewwin_set_curswin(vw, owl_popwin_get_curswin(pw), 545 owl_popwin_get_lines(pw), owl_popwin_get_cols(pw)); 546 owl_viewwin_redisplay(vw); 547 } 548 549 /* refresh stuff */ 550 g->needrefresh=1; 551 owl_mainwin_redisplay(&(g->mw)); 552 sepbar(NULL); 553 if (g->tw) 554 owl_editwin_redisplay(g->tw); 555 else 556 werase(owl_global_get_curs_typwin(g)); 557 558 owl_function_full_redisplay(); 559 560 owl_function_makemsg(""); 476 561 } 477 562 … … 543 628 544 629 void owl_global_set_curmsg_vert_offset(owl_global *g, int i) { 545 g->curmsg_vert_offset =i;630 g->curmsg_vert_offset=i; 546 631 } 547 632 … … 779 864 void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m) 780 865 { 781 g_queue_push_tail(g->messagequeue, m);866 owl_list_append_element(&(g->messagequeue), m); 782 867 } 783 868 … … 790 875 owl_message *out; 791 876 792 if ( g_queue_is_empty(g->messagequeue))793 return NULL;794 o ut = g_queue_pop_head(g->messagequeue);795 return out;877 if (owl_list_get_size(&(g->messagequeue))==0) return(NULL); 878 out=owl_list_get_element(&(g->messagequeue), 0); 879 owl_list_remove_element(&(g->messagequeue), 0); 880 return(out); 796 881 } 797 882 798 883 int owl_global_messagequeue_pending(owl_global *g) 799 884 { 800 return !g_queue_is_empty(g->messagequeue); 885 if (owl_list_get_size(&(g->messagequeue))==0) return(0); 886 return(1); 801 887 } 802 888 … … 926 1012 } 927 1013 1014 const char * owl_global_intern(owl_global *g, const char * string) 1015 { 1016 return owl_obarray_insert(&(g->obarray), string); 1017 } 1018 928 1019 owl_list *owl_global_get_io_dispatch_list(owl_global *g) 929 1020 { … … 961 1052 } filters[] = { 962 1053 { "personal", 963 "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message ) )" }, 1054 "private ^true$ and ( not type ^zephyr$ or " 1055 "( class ^message and ( instance ^personal$ or instance ^urgent$ ) ) )" }, 964 1056 { "trash", 965 1057 "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" }, -
keymap.c
r44cc9ab r8a921b5 1 1 #include <string.h> 2 2 #include "owl.h" 3 4 static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm);5 static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm);6 3 7 4 /* returns 0 on success */ … … 12 9 if ((km->desc = owl_strdup(desc)) == NULL) return(-1); 13 10 if (0 != owl_list_create(&km->bindings)) return(-1); 14 km-> parent= NULL;11 km->submap = NULL; 15 12 km->default_fn = default_fn; 16 13 km->prealways_fn = prealways_fn; … … 27 24 } 28 25 29 void owl_keymap_set_ parent(owl_keymap *km, const owl_keymap *parent)30 { 31 km-> parent = parent;26 void owl_keymap_set_submap(owl_keymap *km, const owl_keymap *submap) 27 { 28 km->submap = submap; 32 29 } 33 30 … … 89 86 90 87 /* Appends details about the keymap to fm */ 91 void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm, int recurse) 92 { 88 void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm) 89 { 90 int i, nbindings; 91 const owl_keybinding *kb; 92 93 93 owl_fmtext_append_bold(fm, "KEYMAP - "); 94 94 owl_fmtext_append_bold(fm, km->name); … … 99 99 owl_fmtext_append_normal(fm, "\n"); 100 100 } 101 if (km-> parent) {102 owl_fmtext_append_normal(fm, OWL_TABSTR "Has parent: ");103 owl_fmtext_append_normal(fm, km-> parent->name);101 if (km->submap) { 102 owl_fmtext_append_normal(fm, OWL_TABSTR "Has submap: "); 103 owl_fmtext_append_normal(fm, km->submap->name); 104 104 owl_fmtext_append_normal(fm, "\n"); 105 105 } … … 119 119 120 120 owl_fmtext_append_bold(fm, "\nKey bindings:\n\n"); 121 if (recurse) {122 _owl_keymap_format_with_parents(km, fm);123 } else {124 _owl_keymap_format_bindings(km, fm);125 }126 }127 128 static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm)129 {130 while (km) {131 _owl_keymap_format_bindings(km, fm);132 km = km->parent;133 if (km) {134 owl_fmtext_append_bold(fm, "\nInherited from ");135 owl_fmtext_append_bold(fm, km->name);136 owl_fmtext_append_bold(fm, ":\n\n");137 }138 }139 }140 141 static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm)142 {143 int i, nbindings;144 const owl_keybinding *kb;145 146 121 nbindings = owl_list_get_size(&km->bindings); 147 122 for (i=0; i<nbindings; i++) { … … 273 248 } 274 249 275 /* deal with the always_fn for the map and parents */276 for (km=kh->active; km; km=km-> parent) {250 /* deal with the always_fn for the map and submaps */ 251 for (km=kh->active; km; km=km->submap) { 277 252 if (km->prealways_fn) { 278 253 km->prealways_fn(j); … … 281 256 282 257 /* search for a match. goes through active keymap and then 283 * through parents... TODO: clean this up so we can pull258 * through submaps... TODO: clean this up so we can pull 284 259 * keyhandler and keymap apart. */ 285 for (km=kh->active; km; km=km-> parent) {260 for (km=kh->active; km; km=km->submap) { 286 261 for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) { 287 262 kb = owl_list_get_element(&km->bindings, i); -
keys.c
r5cc7e5e r8a5b5a1 30 30 "Text editing and command window", 31 31 owl_keys_editwin_default, NULL, owl_keys_editwin_postalways); 32 owl_keymap_set_ parent(km_editwin, km_global);32 owl_keymap_set_submap(km_editwin, km_global); 33 33 /* 34 34 BIND_CMD("F1", "help", ""); … … 99 99 "Multi-line text editing", 100 100 owl_keys_editwin_default, NULL, owl_keys_editwin_postalways); 101 owl_keymap_set_ parent(km_ew_multi, km_editwin);101 owl_keymap_set_submap(km_ew_multi, km_editwin); 102 102 103 103 BIND_CMD("UP", "edit:move-up-line", ""); … … 129 129 "Single-line text editing", 130 130 owl_keys_editwin_default, NULL, owl_keys_editwin_postalways); 131 owl_keymap_set_ parent(km_ew_onel, km_editwin);131 owl_keymap_set_submap(km_ew_onel, km_editwin); 132 132 133 133 BIND_CMD("C-u", "edit:delete-all", "Clears the entire line"); … … 154 154 "Single-line response to question", 155 155 owl_keys_editwin_default, NULL, owl_keys_editwin_postalways); 156 owl_keymap_set_ parent(km_ew_onel, km_editwin);156 owl_keymap_set_submap(km_ew_onel, km_editwin); 157 157 158 158 BIND_CMD("C-u", "edit:delete-all", "Clears the entire line"); … … 169 169 "Pop-up window (eg, help)", 170 170 owl_keys_default_invalid, NULL, owl_keys_popless_postalways); 171 owl_keymap_set_ parent(km_viewwin, km_global);171 owl_keymap_set_submap(km_viewwin, km_global); 172 172 173 173 BIND_CMD("SPACE", "popless:scroll-down-page", ""); … … 222 222 "Main window / message list", 223 223 owl_keys_default_invalid, owl_keys_recwin_prealways, NULL); 224 owl_keymap_set_ parent(km_mainwin, km_global);224 owl_keymap_set_submap(km_mainwin, km_global); 225 225 BIND_CMD("C-x C-c", "start-command quit", ""); 226 226 BIND_CMD("F1", "help", ""); … … 338 338 owl_editwin_post_process_char(e, j); 339 339 } 340 owl_global_set_needrefresh(&g); 340 341 } 341 342 342 343 void owl_keys_popless_postalways(owl_input j) { 344 owl_viewwin *v = owl_global_get_viewwin(&g); 345 const owl_popwin *pw = owl_global_get_popwin(&g); 346 347 if (pw && owl_popwin_is_active(pw) && v) { 348 owl_viewwin_redisplay(v); 349 owl_global_set_needrefresh(&g); 350 } 343 351 } 344 352 -
logging.c
r839697d r91634ec 128 128 char filename[MAXPATHLEN], *logpath; 129 129 char *to, *temp; 130 GList *cc;131 130 132 131 /* expand ~ in path names */ … … 136 135 if (owl_message_is_type_zephyr(m)) { 137 136 /* If this has CC's, do all but the "recipient" which we'll do below */ 138 cc = owl_message_get_cc_without_recipient(m); 139 while (cc != NULL) { 140 temp = short_zuser(cc->data); 141 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp); 142 owl_log_append(m, filename); 143 144 owl_free(cc->data); 145 cc = g_list_delete_link(cc, cc); 146 } 147 137 to = owl_message_get_cc_without_recipient(m); 138 if (to != NULL) { 139 temp = strtok(to, " "); 140 while (temp != NULL) { 141 temp = short_zuser(temp); 142 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp); 143 owl_log_append(m, filename); 144 temp = strtok(NULL, " "); 145 } 146 owl_free(to); 147 } 148 148 to = short_zuser(owl_message_get_recipient(m)); 149 149 } else if (owl_message_is_type_jabber(m)) { … … 325 325 * the sender, as well. 326 326 */ 327 char *temp; 328 GList *cc; 327 char *cc, *temp; 329 328 cc = owl_message_get_cc_without_recipient(m); 330 while (cc != NULL) { 331 temp = short_zuser(cc->data); 332 if (strcasecmp(temp, frombuff) != 0) { 333 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp); 334 owl_log_append(m, filename); 329 if (cc != NULL) { 330 temp = strtok(cc, " "); 331 while (temp != NULL) { 332 temp = short_zuser(temp); 333 if (strcasecmp(temp, frombuff) != 0) { 334 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp); 335 owl_log_append(m, filename); 336 } 337 temp = strtok(NULL, " "); 335 338 } 336 337 owl_free(cc->data); 338 cc = g_list_delete_link(cc, cc); 339 owl_free(cc); 339 340 } 340 341 } -
mainwin.c
r5cc7e5e rf449096 1 1 #include "owl.h" 2 2 3 static void owl_mainwin_redraw(owl_window *w, WINDOW *recwin, void *user_data); 4 static void owl_mainwin_resized(owl_window *w, void *user_data); 5 6 void owl_mainwin_init(owl_mainwin *mw, owl_window *window) 3 void owl_mainwin_init(owl_mainwin *mw) 7 4 { 8 5 mw->curtruncated=0; 9 6 mw->lastdisplayed=-1; 10 mw->window = g_object_ref(window);11 /* for now, just assume this object lasts forever */12 g_signal_connect(window, "redraw", G_CALLBACK(owl_mainwin_redraw), mw);13 g_signal_connect(window, "resized", G_CALLBACK(owl_mainwin_resized), mw);14 owl_window_dirty(window);15 16 /* For now, we do not bother with connecting up dependencies; that'll be a17 * future refactor of the mainwin */18 }19 20 static void owl_mainwin_resized(owl_window *w, void *user_data)21 {22 owl_mainwin *mw = user_data;23 24 /* in case any styles rely on the current width */25 owl_messagelist_invalidate_formats(owl_global_get_msglist(&g));26 27 /* recalculate the topmsg to make sure the current message is on28 * screen */29 owl_function_calculate_topmsg(OWL_DIRECTION_NONE);30 31 /* Schedule a redraw */32 owl_window_dirty(mw->window);33 7 } 34 8 35 9 void owl_mainwin_redisplay(owl_mainwin *mw) 36 {37 owl_window_dirty(mw->window);38 }39 40 static void owl_mainwin_redraw(owl_window *w, WINDOW *recwin, void *user_data)41 10 { 42 11 owl_message *m; … … 44 13 int x, y, savey, recwinlines, start; 45 14 int topmsg, curmsg, markedmsgid, fgcolor, bgcolor; 15 WINDOW *recwin; 46 16 const owl_view *v; 47 17 GList *fl; 48 18 const owl_filter *f; 49 owl_mainwin *mw = user_data;50 19 20 recwin = owl_global_get_curs_recwin(&g); 51 21 topmsg = owl_global_get_topmsg(&g); 52 22 curmsg = owl_global_get_curmsg(&g); … … 73 43 mw->curtruncated=0; 74 44 mw->lastdisplayed=-1; 45 owl_global_set_needrefresh(&g); 75 46 return; 76 47 } … … 117 88 if (y+lines > recwinlines-1) { 118 89 isfull=1; 119 owl_message_curs_waddstr(m, recwin,90 owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g), 120 91 start, 121 92 start+recwinlines-y, … … 125 96 } else { 126 97 /* otherwise print the whole thing */ 127 owl_message_curs_waddstr(m, recwin,98 owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g), 128 99 start, 129 100 start+lines, … … 168 139 } 169 140 mw->lastdisplayed=i-1; 141 142 owl_global_set_needrefresh(&g); 170 143 } 171 144 -
message.c
rc314f39 r9a7b4f2 61 61 owl_pair *p = NULL, *pair = NULL; 62 62 63 attrname = g_intern_string(attrname);64 65 63 /* look for an existing pair with this key, */ 66 64 j=owl_list_get_size(&(m->attributes)); 67 65 for (i=0; i<j; i++) { 68 66 p=owl_list_get_element(&(m->attributes), i); 69 if ( owl_pair_get_key(p) == attrname) {67 if (!strcmp(owl_pair_get_key(p), attrname)) { 70 68 owl_free(owl_pair_get_value(p)); 71 69 pair = p; … … 76 74 if(pair == NULL) { 77 75 pair = owl_malloc(sizeof(owl_pair)); 78 owl_pair_create(pair, attrname, NULL);76 owl_pair_create(pair, owl_global_intern(&g, attrname), NULL); 79 77 owl_list_append_element(&(m->attributes), pair); 80 78 } … … 89 87 int i, j; 90 88 owl_pair *p; 91 GQuark quark;92 93 quark = g_quark_try_string(attrname);94 if (quark == 0)95 /* don't bother inserting into string table */96 return NULL;97 attrname = g_quark_to_string(quark);98 89 99 90 j=owl_list_get_size(&(m->attributes)); 100 91 for (i=0; i<j; i++) { 101 92 p=owl_list_get_element(&(m->attributes), i); 102 if ( owl_pair_get_key(p) == attrname) {93 if (!strcmp(owl_pair_get_key(p), attrname)) { 103 94 return(owl_pair_get_value(p)); 104 95 } … … 505 496 void owl_message_set_hostname(owl_message *m, const char *hostname) 506 497 { 507 m->hostname = g_intern_string(hostname);498 m->hostname=owl_global_intern(&g, hostname); 508 499 } 509 500 … … 593 584 594 585 /* caller must free return value */ 595 GList*owl_message_get_cc_without_recipient(const owl_message *m)596 { 597 char *cc, * shortuser, *recip;586 char *owl_message_get_cc_without_recipient(const owl_message *m) 587 { 588 char *cc, *out, *end, *shortuser, *recip; 598 589 const char *user; 599 GList *out = NULL;600 590 601 591 cc = owl_message_get_cc(m); … … 604 594 605 595 recip = short_zuser(owl_message_get_recipient(m)); 596 out = owl_malloc(strlen(cc) + 2); 597 end = out; 606 598 607 599 user = strtok(cc, " "); … … 609 601 shortuser = short_zuser(user); 610 602 if (strcasecmp(shortuser, recip) != 0) { 611 out = g_list_prepend(out, owl_strdup(user)); 603 strcpy(end, user); 604 end[strlen(user)] = ' '; 605 end += strlen(user) + 1; 612 606 } 613 607 owl_free(shortuser); 614 608 user = strtok(NULL, " "); 615 609 } 610 end[0] = '\0'; 616 611 617 612 owl_free(recip); 618 613 owl_free(cc); 614 615 if (strlen(out) == 0) { 616 owl_free(out); 617 out = NULL; 618 } 619 619 620 620 return(out); … … 732 732 owl_message_set_recipient(m, "looprecip"); 733 733 owl_message_set_isprivate(m); 734 }735 736 void owl_message_save_ccs(owl_message *m) {737 GList *cc;738 char *tmp;739 740 cc = owl_message_get_cc_without_recipient(m);741 742 if (cc != NULL) {743 GString *recips = g_string_new("");744 cc = g_list_prepend(cc, short_zuser(owl_message_get_sender(m)));745 cc = g_list_prepend(cc, short_zuser(owl_message_get_recipient(m)));746 cc = g_list_sort(cc, (GCompareFunc)strcasecmp);747 748 while(cc != NULL) {749 /* Collapse any identical entries */750 while (cc->next && strcasecmp(cc->data, cc->next->data) == 0) {751 owl_free(cc->data);752 cc = g_list_delete_link(cc, cc);753 }754 755 tmp = short_zuser(cc->data);756 g_string_append(recips, tmp);757 758 owl_free(tmp);759 owl_free(cc->data);760 cc = g_list_delete_link(cc, cc);761 762 if (cc)763 g_string_append_c(recips, ' ');764 }765 766 owl_message_set_attribute(m, "zephyr_ccs", recips->str);767 g_string_free(recips, true);768 }769 734 } 770 735 … … 904 869 } 905 870 } 906 907 owl_message_save_ccs(m);908 871 } 909 872 #else … … 1000 963 owl_message_set_isprivate(m); 1001 964 } 1002 1003 owl_message_save_ccs(m);1004 965 } 1005 966 -
owl.c
r205e164 rd12a8c7 137 137 tcgetattr(0, &tio); 138 138 tio.c_iflag &= ~(ISTRIP|IEXTEN); 139 tio.c_cc[VQUIT] = fpathconf(STDIN, _PC_VDISABLE);140 tio.c_cc[VSUSP] = fpathconf(STDIN, _PC_VDISABLE);139 tio.c_cc[VQUIT] = 0; 140 tio.c_cc[VSUSP] = 0; 141 141 tcsetattr(0, TCSAFLUSH, &tio); 142 142 … … 240 240 /* log the message if we need to */ 241 241 owl_log_message(m); 242 /* redraw the sepbar; TODO: don't violate layering */243 owl_global_sepbar_dirty(&g);244 242 245 243 return 1; … … 274 272 /* this should be optimized to not run if the new messages won't be displayed */ 275 273 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 274 sepbar(NULL); 275 owl_global_set_needrefresh(&g); 276 276 } 277 277 return newmsgs; … … 428 428 { 429 429 /* if a resize has been scheduled, deal with it */ 430 owl_global_check_resize(&g); 430 owl_global_resize(&g, 0, 0); 431 /* also handle relayouts */ 432 owl_global_relayout(&g); 433 431 434 /* update the terminal if we need to */ 432 owl_window_redraw_scheduled(); 435 if (owl_global_is_needrefresh(&g)) { 436 /* these are here in case a relayout changes the windows */ 437 WINDOW *sepwin = owl_global_get_curs_sepwin(&g); 438 WINDOW *typwin = owl_global_get_curs_typwin(&g); 439 440 /* push all changed windows to screen */ 441 update_panels(); 442 /* leave the cursor in the appropriate window */ 443 if (!owl_popwin_is_active(owl_global_get_popwin(&g)) 444 && owl_global_get_typwin(&g)) { 445 owl_function_set_cursor(typwin); 446 } else { 447 owl_function_set_cursor(sepwin); 448 } 449 doupdate(); 450 owl_global_set_noneedrefresh(&g); 451 } 433 452 return 0; 434 453 } … … 498 517 499 518 owl_global_pop_context(&g); 500 owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL , NULL);519 owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL); 501 520 502 521 perlerr=owl_perlconfig_initperl(opts.configfile, &argc, &argv, &env); … … 542 561 "-----------------------------------------------------------------m-m---\n" 543 562 ); 563 sepbar(NULL); 544 564 545 565 /* process the startup file */ … … 565 585 566 586 owl_global_pop_context(&g); 567 owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv", NULL); 587 owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv"); 588 589 /* If we ever deprecate the mainloop hook, remove this. */ 590 owl_select_add_timer(0, 1, owl_perlconfig_mainloop, NULL, NULL); 568 591 569 592 owl_select_add_pre_select_action(owl_refresh_pre_select_action, NULL, NULL); -
owl.h
r26ad412 r26ad412 60 60 typedef void HV; 61 61 #endif 62 63 #include "window.h"64 62 65 63 #ifdef GIT_VERSION … … 310 308 void *data; /* determined by mode */ 311 309 char *keymap; 312 owl_window *cursor;313 310 } owl_context; 314 311 … … 347 344 348 345 typedef struct _owl_zwrite { 349 char *cmd;350 346 char *zwriteline; 351 347 char *class; … … 398 394 int lasttruncated; 399 395 int lastdisplayed; 400 owl_window *window;401 396 } owl_mainwin; 402 397 … … 406 401 int topline; 407 402 int rightshift; 408 owl_window *window;409 gulong sig_redraw_id;403 int winlines, wincols; 404 WINDOW *curswin; 410 405 void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); 411 406 void *onclose_hook_data; … … 413 408 414 409 typedef struct _owl_popwin { 415 owl_window *border; 416 owl_window *content; 410 PANEL *borderpanel; 411 PANEL *poppanel; 412 int lines; 413 int cols; 417 414 int active; 418 415 } owl_popwin; 419 420 typedef struct _owl_msgwin {421 char *msg;422 owl_window *window;423 gulong redraw_id;424 } owl_msgwin;425 416 426 417 typedef struct _owl_messagelist { … … 472 463 typedef struct _owl_editwin_excursion owl_editwin_excursion; 473 464 474 typedef struct _owl_mainpanel {475 owl_window *panel;476 owl_window *typwin;477 owl_window *sepwin;478 owl_window *msgwin;479 owl_window *recwin;480 int recwinlines;481 } owl_mainpanel;482 483 465 typedef struct _owl_keybinding { 484 466 int *keys; /* keypress stack */ … … 494 476 char *desc; /* description */ 495 477 owl_list bindings; /* key bindings */ 496 const struct _owl_keymap * parent; /* parent*/478 const struct _owl_keymap *submap; /* submap */ 497 479 void (*default_fn)(owl_input j); /* default action (takes a keypress) */ 498 480 void (*prealways_fn)(owl_input j); /* always called before a keypress is received */ … … 539 521 short **pairs; 540 522 } owl_colorpair_mgr; 523 524 typedef struct _owl_obarray { 525 owl_list strings; 526 } owl_obarray; 541 527 542 528 typedef struct _owl_io_dispatch { … … 564 550 } owl_popexec; 565 551 566 typedef struct _OwlGlobalNotifier OwlGlobalNotifier;567 568 552 typedef struct _owl_global { 569 553 owl_mainwin mw; 570 554 owl_popwin pw; 571 owl_msgwin msgwin;572 555 owl_history cmdhist; /* command history */ 573 556 owl_history msghist; /* outgoing message history */ … … 587 570 owl_messagelist msglist; 588 571 WINDOW *input_pad; 589 owl_mainpanel mainpanel;590 gulong typwin_erase_id;572 PANEL *recpan, *seppan, *msgpan, *typpan; 573 int needrefresh; 591 574 int rightshift; 592 575 volatile sig_atomic_t resizepending; 576 int relayoutpending; 577 int recwinlines; 593 578 char *thishost; 594 579 char *homedir; … … 614 599 owl_colorpair_mgr cpmgr; 615 600 pid_t newmsgproc_pid; 601 int malloced, freed; 616 602 owl_regex search_re; 617 603 aim_session_t aimsess; … … 624 610 char *aim_screenname_for_filters; /* currently logged in AIM screen name */ 625 611 owl_buddylist buddylist; /* list of logged in AIM buddies */ 626 GQueue *messagequeue;/* for queueing up aim and other messages */612 owl_list messagequeue; /* for queueing up aim and other messages */ 627 613 owl_dict styledict; /* global dictionary of available styles */ 628 614 char *response; /* response to the last question asked */ … … 637 623 int pseudologin_notify; 638 624 struct termios startup_tio; 625 owl_obarray obarray; 639 626 owl_list io_dispatch_list; 640 627 owl_list psa_list; -
perl/lib/BarnOwl/Hooks.pm
r3aa0522 rb30c256 79 79 our %EXPORT_TAGS = (all => [@EXPORT_OK]); 80 80 81 use BarnOwl::MainLoopCompatHook;82 83 81 our $startup = BarnOwl::Hook->new; 84 82 our $shutdown = BarnOwl::Hook->new; 85 83 our $receiveMessage = BarnOwl::Hook->new; 86 84 our $newMessage = BarnOwl::Hook->new; 87 our $mainLoop = BarnOwl:: MainLoopCompatHook->new;85 our $mainLoop = BarnOwl::Hook->new; 88 86 our $getBuddyList = BarnOwl::Hook->new; 89 87 our $getQuickstart = BarnOwl::Hook->new; … … 164 162 } 165 163 166 $mainLoop->check_owlconf();167 164 $startup->run(0); 168 165 BarnOwl::startup() if *BarnOwl::startup{CODE}; … … 189 186 190 187 BarnOwl::new_msg($m) if *BarnOwl::new_msg{CODE}; 188 } 189 190 sub _mainloop_hook { 191 $mainLoop->run; 192 BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE}; 191 193 } 192 194 -
perl/lib/BarnOwl/Message/Generic.pm
r5d1324f ree183be 6 6 use base qw( BarnOwl::Message ); 7 7 8 sub body { "" }9 10 8 11 9 1; -
perl/lib/BarnOwl/Style/Default.pm
r08544e0 r0fe69d2 32 32 my $m = shift; 33 33 return $m->is_personal && $m->direction eq "in"; 34 }35 36 sub maybe {37 my $x = shift;38 return defined($x) ? $x : "";39 34 } 40 35 … … 104 99 $header .= ' / ' . $self->humanize($m->subcontext, 1); 105 100 } 106 $header .= ' / @b{' . maybe($m->pretty_sender). '}';101 $header .= ' / @b{' . $m->pretty_sender . '}'; 107 102 } 108 103 -
perl/lib/BarnOwl/Timer.pm
r8d16e58 ree183be 21 21 } 22 22 23 sub stop {24 my $self = shift;25 if(defined($self->{timer})) {26 BarnOwl::Internal::remove_timer($self->{timer});27 undef $self->{timer};28 }29 }30 31 23 sub do_callback { 32 24 my $self = shift; … … 36 28 sub DESTROY { 37 29 my $self = shift; 38 $self->stop; 30 if(defined($self->{timer})) { 31 BarnOwl::Internal::remove_timer($self->{timer}); 32 } 39 33 } 40 34 -
perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
r2f25537 rc854e74 20 20 sub to { shift->{to} }; 21 21 sub room { shift->{room} }; 22 sub nick { shift->{nick} };23 22 sub subject { shift->{subject} }; 24 23 sub status { shift->{status} } … … 42 41 sub long_sender { 43 42 my $self = shift; 44 if ($self->jtype eq 'groupchat' && $self->nick) {45 my $from_jid = Net::Jabber::JID->new($self->from);46 if ($from_jid->GetJID('base') eq $self->room &&47 $from_jid->GetResource() eq $self->nick) {48 return $self->nick;49 }50 }51 43 return $self->from; 52 44 } … … 85 77 } elsif ($self->jtype eq 'groupchat') { 86 78 my $room = $self->room; 87 if ($inst) { 88 my $subject = $self->subject; 89 $filter = "jabber-room-$room-subject-$subject"; 90 BarnOwl::command(qw[filter], $filter, 91 qw[type ^jabber$ and room], "^\Q$room\E\$", 92 qw[and subject], "^\Q$subject\E\$"); 93 } else { 94 $filter = "jabber-room-$room"; 95 BarnOwl::command(qw[filter], $filter, 96 qw[type ^jabber$ and room], "^\Q$room\E\$"); 97 } 79 $filter = "jabber-room-$room"; 80 BarnOwl::command(qw[filter], $filter, 81 qw[type ^jabber$ and room], "^\Q$room\E\$"); 98 82 return $filter; 99 83 } elsif ($self->login ne 'none') { -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r2f25537 r8789410 285 285 { 286 286 summary => "Send a Jabber Message", 287 usage => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>] [-m <message>]"287 usage => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]" 288 288 } 289 289 ); … … 308 308 description => "jmuc sends Jabber commands related to MUC.\n\n" 309 309 . "The following commands are available\n\n" 310 . "join <muc>[/<nick>]\n" 311 . " Join a MUC (with a given nickname, or otherwise your JID).\n\n" 310 . "join <muc> Join a MUC.\n\n" 312 311 . "part <muc> Part a MUC.\n" 313 312 . " The MUC is taken from the current message if not supplied.\n\n" … … 378 377 my $cjidStr = $conn->baseJIDExists($jidStr); 379 378 if ($cjidStr) { 380 die("Already logged in as $cjidStr.\n"); 379 BarnOwl::error("Already logged in as $cjidStr."); 380 return; 381 381 } 382 382 } … … 387 387 388 388 if ( !$uid || !$componentname ) { 389 die("usage: $cmd JID\n"); 389 BarnOwl::error("usage: $cmd JID"); 390 return; 390 391 } 391 392 392 393 if ( $conn->jidActive($jidStr) ) { 393 die("Already logged in as $jidStr.\n"); 394 BarnOwl::error("Already logged in as $jidStr."); 395 return; 394 396 } elsif ($conn->jidExists($jidStr)) { 395 397 return $conn->tryReconnect($jidStr, 1); … … 524 526 sub cmd_jlist { 525 527 if ( !( scalar $conn->getJIDs() ) ) { 526 die("You are not logged in to Jabber.\n"); 528 BarnOwl::error("You are not logged in to Jabber."); 529 return; 527 530 } 528 531 BarnOwl::popless_ztext( onGetBuddyList() ); … … 531 534 sub cmd_jwrite { 532 535 if ( !$conn->connected() ) { 533 die("You are not logged in to Jabber.\n"); 536 BarnOwl::error("You are not logged in to Jabber."); 537 return; 534 538 } 535 539 … … 539 543 my $jwrite_thread = ""; 540 544 my $jwrite_subject = ""; 541 my $jwrite_body;542 545 my ($to, $from); 543 546 my $jwrite_type = "chat"; … … 551 554 'subject=s' => \$jwrite_subject, 552 555 'account=s' => \$from, 553 'id=s' => \$jwrite_sid, 554 'message=s' => \$jwrite_body, 556 'id=s' => \$jwrite_sid, 555 557 ) or die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n"); 556 558 $jwrite_type = 'groupchat' if $gc; 557 559 558 560 if ( scalar @ARGV != 1 ) { 559 die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n"); 561 BarnOwl::error( 562 "Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]"); 563 return; 560 564 } 561 565 else { … … 566 570 567 571 unless(scalar @candidates) { 568 die("Unable to resolve JID $to \n");572 die("Unable to resolve JID $to"); 569 573 } 570 574 … … 573 577 unless(scalar @candidates) { 574 578 if(!$from) { 575 die("You must specify an account with -a \n");579 die("You must specify an account with -a"); 576 580 } else { 577 die("Unable to resolve account $from \n");581 die("Unable to resolve account $from"); 578 582 } 579 583 } … … 590 594 type => $jwrite_type 591 595 }; 592 593 if (defined($jwrite_body)) {594 process_owl_jwrite($jwrite_body);595 return;596 }597 596 598 597 if(scalar @candidates > 1) { … … 632 631 my $func = $jmuc_commands{$cmd}; 633 632 if ( !$func ) { 634 die("jmuc: Unknown command: $cmd\n"); 633 BarnOwl::error("jmuc: Unknown command: $cmd"); 634 return; 635 635 } 636 636 … … 654 654 } 655 655 else { 656 die("You must specify an account with -a <jid>\n");656 BarnOwl::error('You must specify an account with -a <jid>'); 657 657 } 658 658 return $func->( $jid, $muc, @ARGV ); … … 667 667 668 668 $muc = shift @ARGV 669 or die("Usage: jmuc join <muc> [-p <password>] [-a <account>] \n");669 or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]"); 670 670 671 671 die("Error: Must specify a fully-qualified MUC name (e.g. barnowl\@conference.mit.edu)\n") … … 680 680 MaxChars => 0 681 681 }); 682 $completion_jids{$muc ->GetJID('base')} = 1;682 $completion_jids{$muc} = 1; 683 683 return; 684 684 } … … 688 688 689 689 $muc = shift @args if scalar @args; 690 die("Usage: jmuc part [<muc>] [-a <account>] \n") unless $muc;690 die("Usage: jmuc part [<muc>] [-a <account>]") unless $muc; 691 691 692 692 if($conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc)) { 693 693 queue_admin_msg("$jid has left $muc."); 694 694 } else { 695 die("Error: Not joined to $muc \n");695 die("Error: Not joined to $muc"); 696 696 } 697 697 } … … 703 703 $muc = shift @args if scalar @args; 704 704 705 die( "Usage: jmuc invite <jid> [<muc>] [-a <account>]\n")705 die('Usage: jmuc invite <jid> [<muc>] [-a <account>]') 706 706 unless $muc && $invite_jid; 707 707 … … 718 718 my ( $jid, $muc, @args ) = @_; 719 719 $muc = shift @args if scalar @args; 720 die("Usage: jmuc configure [<muc>] \n") unless $muc;720 die("Usage: jmuc configure [<muc>]") unless $muc; 721 721 my $iq = Net::Jabber::IQ->new(); 722 722 $iq->SetTo($muc); … … 759 759 760 760 $muc = shift @args if scalar @args; 761 die("Usage: jmuc presence [<muc>] \n") unless $muc;761 die("Usage: jmuc presence [<muc>]") unless $muc; 762 762 763 763 if ($muc eq '-a') { … … 774 774 else { 775 775 my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc); 776 die("No such muc: $muc \n") unless $m;776 die("No such muc: $muc") unless $m; 777 777 BarnOwl::popless_ztext(jmuc_presence_single($m)); 778 778 } … … 801 801 my $func = $jroster_commands{$cmd}; 802 802 if ( !$func ) { 803 die("jroster: Unknown command: $cmd\n"); 803 BarnOwl::error("jroster: Unknown command: $cmd"); 804 return; 804 805 } 805 806 … … 824 825 } 825 826 else { 826 die("You must specify an account with -a <jid>\n");827 BarnOwl::error('You must specify an account with -a <jid>'); 827 828 } 828 829 return $func->( $jid, $name, \@groups, $purgeGroups, @ARGV ); … … 848 849 } 849 850 else { 850 die("You must specify an account with -a <jid>\n");851 BarnOwl::error('You must specify an account with -a <jid>'); 851 852 } 852 853 … … 1233 1234 $completion_jids{$room} = 1; 1234 1235 1235 my $muc;1236 if ($dir eq 'in') {1237 my $connection = $conn->getConnectionFromSid($props{sid});1238 $muc = $connection->FindMUC(jid => $from);1239 } else {1240 my $connection = $conn->getConnectionFromJID($props{from});1241 $muc = $connection->FindMUC(jid => $to);1242 }1243 $props{from} = $muc->GetFullJID($from) || $props{from};1244 1236 $props{sender} = $nick || $room; 1245 1237 $props{recipient} = $room; … … 1339 1331 return $givenJIDStr if ($conn->jidExists($givenJIDStr) ); 1340 1332 return resolveConnectedJID($givenJID->GetJID('base')) if $loose; 1341 die("Invalid account: $givenJIDStr \n");1333 die("Invalid account: $givenJIDStr"); 1342 1334 } 1343 1335 … … 1392 1384 # Not one of ours. 1393 1385 else { 1394 die("Invalid account: $givenJIDStr \n");1386 die("Invalid account: $givenJIDStr"); 1395 1387 } 1396 1388 … … 1438 1430 if($from) { 1439 1431 $from_jid = resolveConnectedJID($from, 1); 1440 die("Unable to resolve account $from \n") unless $from_jid;1432 die("Unable to resolve account $from") unless $from_jid; 1441 1433 $to_jid = resolveDestJID($to, $from_jid); 1442 1434 push @matches, [$from_jid, $to_jid] if $to_jid; -
perl/modules/Makefile.am
r1fd469d4 r636de2a 1 MODULES = Jabber IRC WordWrap Twitter1 MODULES = Jabber IRC WordWrap 2 2 3 3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/inc) $(MODULES:=/lib) -
perlconfig.c
r5aa33fd r5aa33fd 584 584 } 585 585 586 void owl_perlconfig_mainloop(owl_timer *t, void *data) 587 { 588 dSP; 589 if (!owl_perlconfig_is_function("BarnOwl::Hooks::_mainloop_hook")) 590 return; 591 PUSHMARK(SP) ; 592 call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL); 593 if(SvTRUE(ERRSV)) { 594 owl_function_error("%s", SvPV_nolen(ERRSV)); 595 } 596 return; 597 } 598 586 599 void owl_perlconfig_io_dispatch(const owl_io_dispatch *d, void *data) 587 600 { -
popexec.c
r07b59ea r125fd21 27 27 28 28 owl_popwin_up(pw); 29 owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL); 30 owl_viewwin_init_text(v, owl_popwin_get_content(pw), ""); 29 owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless"); 30 owl_viewwin_init_text(v, owl_popwin_get_curswin(pw), 31 owl_popwin_get_lines(pw), owl_popwin_get_cols(pw), 32 ""); 33 owl_viewwin_redisplay(v); 34 owl_global_set_needrefresh(&g); 31 35 owl_viewwin_set_onclose_hook(v, owl_popexec_viewwin_onclose, pe); 32 36 pe->refcount++; … … 107 111 if (pe->winactive) { 108 112 owl_viewwin_append_text(pe->vwin, "\n"); 113 owl_viewwin_redisplay(pe->vwin); 114 owl_global_set_needrefresh(&g); 109 115 } 110 116 owl_select_remove_io_dispatch(d); … … 133 139 if (pe->winactive) { 134 140 owl_viewwin_append_text(pe->vwin, buf); 141 owl_viewwin_redisplay(pe->vwin); 142 owl_global_set_needrefresh(&g); 135 143 } 136 144 owl_free(buf); -
popwin.c
r05ca0d8 r0881cdd 4 4 { 5 5 pw->active=0; 6 pw->lines=0; 7 pw->cols=0; 6 8 return(0); 7 9 } … … 9 11 int owl_popwin_up(owl_popwin *pw) 10 12 { 11 pw->border = owl_window_new(NULL); 12 pw->content = owl_window_new(pw->border); 13 g_signal_connect(pw->border, "redraw", G_CALLBACK(owl_popwin_draw_border), 0); 14 owl_signal_connect_object(owl_window_get_screen(), "resized", G_CALLBACK(owl_popwin_size_border), pw->border, 0); 15 owl_signal_connect_object(pw->border, "resized", G_CALLBACK(owl_popwin_size_content), pw->content, 0); 13 int glines, gcols, startcol, startline; 14 WINDOW *popwin, *borderwin; 16 15 17 /* bootstrap sizing */ 18 owl_popwin_size_border(owl_window_get_screen(), pw->border); 16 /* calculate the size of the popwin */ 17 glines=owl_global_get_lines(&g); 18 gcols=owl_global_get_cols(&g); 19 19 20 owl_window_show_all(pw->border); 20 pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; 21 startline = (glines-pw->lines)/2; 21 22 22 pw->active=1; 23 return(0); 24 } 23 pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2; 24 startcol = (gcols-pw->cols)/2; 25 25 26 void owl_popwin_size_border(owl_window *parent, void *user_data) 27 { 28 int lines, cols, startline, startcol; 29 int glines, gcols; 30 owl_window *border = user_data; 26 borderwin = newwin(pw->lines, pw->cols, startline, startcol); 27 pw->borderpanel = new_panel(borderwin); 28 popwin = newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1); 29 pw->poppanel = new_panel(popwin); 31 30 32 owl_window_get_position(parent, &glines, &gcols, 0, 0); 33 34 lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2; 35 startline = (glines-lines)/2; 36 cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2; 37 startcol = (gcols-cols)/2; 38 39 owl_window_set_position(border, lines, cols, startline, startcol); 40 } 41 42 void owl_popwin_size_content(owl_window *parent, void *user_data) 43 { 44 int lines, cols; 45 owl_window *content = user_data; 46 owl_window_get_position(parent, &lines, &cols, 0, 0); 47 owl_window_set_position(content, lines-2, cols-2, 1, 1); 48 } 49 50 void owl_popwin_draw_border(owl_window *w, WINDOW *borderwin, void *user_data) 51 { 52 int lines, cols; 53 owl_window_get_position(w, &lines, &cols, 0, 0); 31 werase(popwin); 32 werase(borderwin); 54 33 if (owl_global_is_fancylines(&g)) { 55 34 box(borderwin, 0, 0); … … 58 37 wmove(borderwin, 0, 0); 59 38 waddch(borderwin, '+'); 60 wmove(borderwin, lines-1, 0);39 wmove(borderwin, pw->lines-1, 0); 61 40 waddch(borderwin, '+'); 62 wmove(borderwin, lines-1,cols-1);41 wmove(borderwin, pw->lines-1, pw->cols-1); 63 42 waddch(borderwin, '+'); 64 wmove(borderwin, 0, cols-1);43 wmove(borderwin, 0, pw->cols-1); 65 44 waddch(borderwin, '+'); 66 45 } 46 47 owl_global_set_needrefresh(&g); 48 pw->active=1; 49 return(0); 67 50 } 68 51 69 52 int owl_popwin_close(owl_popwin *pw) 70 53 { 71 owl_window_unlink(pw->border); 72 g_object_unref(pw->border); 73 g_object_unref(pw->content); 54 WINDOW *popwin, *borderwin; 74 55 75 pw->border = 0; 76 pw->content = 0; 56 popwin = panel_window(pw->poppanel); 57 borderwin = panel_window(pw->borderpanel); 58 59 del_panel(pw->poppanel); 60 del_panel(pw->borderpanel); 61 delwin(popwin); 62 delwin(borderwin); 63 77 64 pw->active=0; 65 owl_global_set_needrefresh(&g); 78 66 return(0); 79 67 } … … 84 72 } 85 73 86 owl_window *owl_popwin_get_content(const owl_popwin *pw)74 WINDOW *owl_popwin_get_curswin(const owl_popwin *pw) 87 75 { 88 return p w->content;76 return panel_window(pw->poppanel); 89 77 } 78 79 int owl_popwin_get_lines(const owl_popwin *pw) 80 { 81 return(pw->lines-2); 82 } 83 84 int owl_popwin_get_cols(const owl_popwin *pw) 85 { 86 return(pw->cols-2); 87 } -
stubgen.pl
rea7daa8 rd7cc50b 12 12 my $altvarname = $2; 13 13 $altvarname = $3 if ($3); 14 my $detailname = $altvarname;15 $detailname =~ s/[^a-zA-Z0-9]/-/g;16 $detailname =~ s/^[^a-zA-Z]+//;17 14 if ($vartype =~ /^BOOL/) { 18 print <<EOT; 19 void owl_global_set_${altvarname}_on(owl_global *g) { 20 owl_variable_set_bool_on(&g->vars, "$altvarname"); 21 } 22 void owl_global_set_${altvarname}_off(owl_global *g) { 23 owl_variable_set_bool_off(&g->vars, "$altvarname"); 24 } 25 int owl_global_is_$altvarname(const owl_global *g) { 26 return owl_variable_get_bool(&g->vars, "$varname"); 27 } 28 EOT 15 print "void owl_global_set_${altvarname}_on(owl_global *g) {\n"; 16 print " owl_variable_set_bool_on(&g->vars, \"$varname\");\n}\n"; 17 print "void owl_global_set_${altvarname}_off(owl_global *g) {\n"; 18 print " owl_variable_set_bool_off(&g->vars, \"$varname\");\n}\n"; 19 print "int owl_global_is_$altvarname(const owl_global *g) {\n"; 20 print " return owl_variable_get_bool(&g->vars, \"$varname\");\n}\n"; 29 21 } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) { 30 print <<EOT; 31 void owl_global_set_${altvarname}(owl_global *g, const char *text) { 32 owl_variable_set_string(&g->vars, "$altvarname", text); 33 } 34 const char *owl_global_get_$altvarname(const owl_global *g) { 35 return owl_variable_get_string(&g->vars, "$varname"); 36 } 37 EOT 22 print "void owl_global_set_$altvarname(owl_global *g, const char *text) {\n"; 23 print " owl_variable_set_string(&g->vars, \"$varname\", text);\n}\n"; 24 print "const char *owl_global_get_$altvarname(const owl_global *g) {\n"; 25 print " return owl_variable_get_string(&g->vars, \"$varname\");\n}\n"; 38 26 } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) { 39 print <<EOT; 40 void owl_global_set_${altvarname}(owl_global *g, int n) { 41 owl_variable_set_int(&g->vars, "$altvarname", n); 42 } 43 int owl_global_get_$altvarname(const owl_global *g) { 44 return owl_variable_get_int(&g->vars, "$varname"); 45 } 46 EOT 27 print "void owl_global_set_$altvarname(owl_global *g, int n) {\n"; 28 print " owl_variable_set_int(&g->vars, \"$varname\", n);\n}\n"; 29 print "int owl_global_get_$altvarname(const owl_global *g) {\n"; 30 print " return owl_variable_get_int(&g->vars, \"$varname\");\n}\n"; 47 31 } 48 32 } -
tester.c
r95414bf r95414bf 105 105 numfailures += owl_variable_regtest(); 106 106 numfailures += owl_filter_regtest(); 107 numfailures += owl_obarray_regtest(); 107 108 numfailures += owl_editwin_regtest(); 108 109 if (numfailures) { … … 367 368 } 368 369 370 371 int owl_obarray_regtest(void) { 372 int numfailed = 0; 373 const char *p,*p2; 374 375 owl_obarray oa; 376 owl_obarray_init(&oa); 377 378 printf("# BEGIN testing owl_obarray\n"); 379 380 p = owl_obarray_insert(&oa, "test"); 381 FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test")); 382 p2 = owl_obarray_insert(&oa, "test"); 383 FAIL_UNLESS("returned string is equal", p2 && !strcmp(p2, "test")); 384 FAIL_UNLESS("returned the same string", p2 && p == p2); 385 386 p = owl_obarray_insert(&oa, "test2"); 387 FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test2")); 388 p2 = owl_obarray_find(&oa, "test2"); 389 FAIL_UNLESS("returned the same string", p2 && !strcmp(p2, "test2")); 390 391 p = owl_obarray_find(&oa, "nothere"); 392 FAIL_UNLESS("Didn't find a string that isn't there", p == NULL); 393 394 printf("# END testing owl_obarray (%d failures)\n", numfailed); 395 396 return numfailed; 397 } 398 369 399 int owl_editwin_regtest(void) { 370 400 int numfailed = 0; -
util.c
rc1f1e1e r9a7b4f2 8 8 #include <sys/types.h> 9 9 10 #include <glib-object.h> 10 void sepbar(const char *in) 11 { 12 WINDOW *sepwin; 13 const owl_messagelist *ml; 14 const owl_view *v; 15 int x, y, i; 16 const char *foo, *appendtosepbar; 17 18 sepwin=owl_global_get_curs_sepwin(&g); 19 ml=owl_global_get_msglist(&g); 20 v=owl_global_get_current_view(&g); 21 22 werase(sepwin); 23 wattron(sepwin, A_REVERSE); 24 if (owl_global_is_fancylines(&g)) { 25 whline(sepwin, ACS_HLINE, owl_global_get_cols(&g)); 26 } else { 27 whline(sepwin, '-', owl_global_get_cols(&g)); 28 } 29 30 if (owl_global_is_sepbar_disable(&g)) { 31 getyx(sepwin, y, x); 32 wmove(sepwin, y, owl_global_get_cols(&g)-1); 33 return; 34 } 35 36 wmove(sepwin, 0, 2); 37 38 if (owl_messagelist_get_size(ml) == 0) 39 waddstr(sepwin, " (-/-) "); 40 else 41 wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1, 42 owl_view_get_size(v), 43 owl_messagelist_get_size(ml)); 44 45 foo=owl_view_get_filtname(v); 46 if (strcmp(foo, owl_global_get_view_home(&g))) 47 wattroff(sepwin, A_REVERSE); 48 wprintw(sepwin, " %s ", owl_view_get_filtname(v)); 49 if (strcmp(foo, owl_global_get_view_home(&g))) 50 wattron(sepwin, A_REVERSE); 51 52 if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { 53 getyx(sepwin, y, x); 54 wmove(sepwin, y, x+2); 55 wattron(sepwin, A_BOLD); 56 waddstr(sepwin, " <truncated> "); 57 wattroff(sepwin, A_BOLD); 58 } 59 60 i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); 61 if ((i != -1) && 62 (i < owl_view_get_size(v)-1)) { 63 getyx(sepwin, y, x); 64 wmove(sepwin, y, x+2); 65 wattron(sepwin, A_BOLD); 66 waddstr(sepwin, " <more> "); 67 wattroff(sepwin, A_BOLD); 68 } 69 70 if (owl_global_get_rightshift(&g)>0) { 71 getyx(sepwin, y, x); 72 wmove(sepwin, y, x+2); 73 wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g)); 74 } 75 76 if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { 77 getyx(sepwin, y, x); 78 wmove(sepwin, y, x+2); 79 wattron(sepwin, A_BOLD); 80 wattroff(sepwin, A_REVERSE); 81 if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { 82 waddstr(sepwin, " AWAY "); 83 } else if (owl_global_is_zaway(&g)) { 84 waddstr(sepwin, " Z-AWAY "); 85 } else if (owl_global_is_aaway(&g)) { 86 waddstr(sepwin, " A-AWAY "); 87 } 88 wattron(sepwin, A_REVERSE); 89 wattroff(sepwin, A_BOLD); 90 } 91 92 if (owl_global_get_curmsg_vert_offset(&g)) { 93 getyx(sepwin, y, x); 94 wmove(sepwin, y, x+2); 95 wattron(sepwin, A_BOLD); 96 wattroff(sepwin, A_REVERSE); 97 waddstr(sepwin, " SCROLL "); 98 wattron(sepwin, A_REVERSE); 99 wattroff(sepwin, A_BOLD); 100 } 101 102 if (in) { 103 getyx(sepwin, y, x); 104 wmove(sepwin, y, x+2); 105 waddstr(sepwin, in); 106 } 107 108 appendtosepbar = owl_global_get_appendtosepbar(&g); 109 if (appendtosepbar && *appendtosepbar) { 110 getyx(sepwin, y, x); 111 wmove(sepwin, y, x+2); 112 waddstr(sepwin, " "); 113 waddstr(sepwin, owl_global_get_appendtosepbar(&g)); 114 waddstr(sepwin, " "); 115 } 116 117 getyx(sepwin, y, x); 118 wmove(sepwin, y, owl_global_get_cols(&g)-1); 119 120 wattroff(sepwin, A_BOLD); 121 wattroff(sepwin, A_REVERSE); 122 } 11 123 12 124 char **atokenize(const char *buffer, const char *sep, int *i) … … 674 786 return buf; 675 787 } 676 677 gulong owl_dirty_window_on_signal(owl_window *w, gpointer sender, const gchar *detailed_signal)678 {679 return owl_signal_connect_object(sender, detailed_signal, G_CALLBACK(owl_window_dirty), w, G_CONNECT_SWAPPED);680 }681 682 typedef struct { /*noproto*/683 GObject *sender;684 gulong signal_id;685 } SignalData;686 687 static void _closure_invalidated(gpointer data, GClosure *closure);688 689 /*690 * GObject's g_signal_connect_object has a documented bug. This function is691 * identical except it does not leak the signal handler.692 */693 gulong owl_signal_connect_object(gpointer sender, const gchar *detailed_signal, GCallback c_handler, gpointer receiver, GConnectFlags connect_flags)694 {695 g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (sender), 0);696 g_return_val_if_fail (detailed_signal != NULL, 0);697 g_return_val_if_fail (c_handler != NULL, 0);698 699 if (receiver) {700 SignalData *sdata;701 GClosure *closure;702 gulong signal_id;703 704 g_return_val_if_fail (G_IS_OBJECT (receiver), 0);705 706 closure = ((connect_flags & G_CONNECT_SWAPPED) ? g_cclosure_new_object_swap : g_cclosure_new_object) (c_handler, receiver);707 signal_id = g_signal_connect_closure (sender, detailed_signal, closure, connect_flags & G_CONNECT_AFTER);708 709 /* Register the missing hooks */710 sdata = g_slice_new0(SignalData);711 sdata->sender = sender;712 sdata->signal_id = signal_id;713 714 g_closure_add_invalidate_notifier(closure, sdata, _closure_invalidated);715 716 return signal_id;717 } else {718 return g_signal_connect_data(sender, detailed_signal, c_handler, NULL, NULL, connect_flags);719 }720 }721 722 /*723 * There are three ways the signal could come to an end:724 *725 * 1. The user explicitly disconnects it with the returned signal_id.726 * - In that case, the disconnection unref's the closure, causing it727 * to first be invalidated. The handler's already disconnected, so728 * we have no work to do.729 * 2. The sender gets destroyed.730 * - GObject will disconnect each signal which then goes into the above731 * case. Our handler does no work.732 * 3. The receiver gets destroyed.733 * - The GClosure was created by g_cclosure_new_object_{,swap} which gets734 * invalidated when the receiver is destroyed. We then follow through case 1735 * again, but *this* time, the handler has not been disconnected. We then736 * clean up ourselves.737 *738 * We can't actually hook into this process earlier with weakrefs as GObject739 * will, on object dispose, first disconnect signals, then invalidate closures,740 * and notify weakrefs last.741 */742 static void _closure_invalidated(gpointer data, GClosure *closure)743 {744 SignalData *sdata = data;745 if (g_signal_handler_is_connected(sdata->sender, sdata->signal_id)) {746 g_signal_handler_disconnect(sdata->sender, sdata->signal_id);747 }748 g_slice_free(SignalData, sdata);749 }750 -
variable.c
r26ad412 r26ad412 110 110 111 111 OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH, 112 "specifi es which kind of messages should be logged",112 "specifices which kind of messages should be logged", 113 113 "Can be one of 'both', 'in', or 'out'. If 'in' is\n" 114 114 "selected, only incoming messages are logged, if 'out'\n" … … 138 138 "location of users in your .anyone file. If a user is present\n" 139 139 "but sent no login message, or a user is not present that sent no\n" 140 "logout message, a pseudo login or logout message wil lbe created\n",140 "logout message, a pseudo login or logout message wil be created\n", 141 141 NULL, owl_variable_pseudologins_set, NULL), 142 142 … … 151 151 152 152 "If non empty, any messages matching the given filter will be logged.\n" 153 "This is a completely separate mechanis m from the other logging\n"153 "This is a completely separate mechanisim from the other logging\n" 154 154 "variables like logging, classlogging, loglogins, loggingdirection,\n" 155 155 "etc. If you want this variable to control all logging, make sure\n" … … 199 199 OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL, 200 200 "name of a program to run when new messages are present", 201 "The named program will be run when owl rece ives new\n"201 "The named program will be run when owl recevies new.\n" 202 202 "messages. It will not be run again until the first\n" 203 203 "instance exits"), … … 214 214 "Called every time you start a zephyrgram without an\n" 215 215 "explicit zsig. The default setting implements the policy\n" 216 "descri bed in the documentation for the 'zsig' variable.\n"),216 "descripted in the documentation for the 'zsig' variable.\n"), 217 217 218 218 OWLVAR_STRING( "zsig" /* %OwlVarStub */, "", … … 298 298 "number of seconds after AIM login to ignore login messages", 299 299 "This specifies the number of seconds to wait after an\n" 300 "AIM login before allowing the rec eipt of AIM login notifications.\n"300 "AIM login before allowing the recipt of AIM login notifications.\n" 301 301 "By default this is set to 15. If you would like to view login\n" 302 302 "notifications of buddies as soon as you login, set it to 0 instead."), … … 401 401 int rv; 402 402 rv = owl_variable_int_set_default(v, newval); 403 if (0 == rv) owl_ mainpanel_layout_contents(&g.mainpanel);403 if (0 == rv) owl_global_set_relayout_pending(&g); 404 404 return(rv); 405 405 } -
viewwin.c
r0b9e607 rfe4c786 4 4 #define BOTTOM_OFFSET 1 5 5 6 static void owl_viewwin_redraw(owl_window *w, WINDOW *curswin, void *user_data);7 8 6 /* initialize the viewwin e. 'win' is an already initialzed curses 9 7 * window that will be used by viewwin 10 8 */ 11 void owl_viewwin_init_text(owl_viewwin *v, owl_window *win, const char *text)9 void owl_viewwin_init_text(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const char *text) 12 10 { 13 11 owl_fmtext_init_null(&(v->fmtext)); … … 21 19 v->topline=0; 22 20 v->rightshift=0; 21 v->winlines=winlines; 22 v->wincols=wincols; 23 v->curswin=win; 23 24 v->onclose_hook = NULL; 24 25 owl_viewwin_set_window(v, win);26 25 } 27 26 … … 29 28 owl_fmtext_append_normal(&(v->fmtext), text); 30 29 v->textlines=owl_fmtext_num_lines(&(v->fmtext)); 31 owl_window_dirty(v->window);32 30 } 33 31 … … 35 33 * window that will be used by viewwin 36 34 */ 37 void owl_viewwin_init_fmtext(owl_viewwin *v, owl_window *win, const owl_fmtext *fmtext)35 void owl_viewwin_init_fmtext(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const owl_fmtext *fmtext) 38 36 { 39 37 char *text; … … 48 46 v->topline=0; 49 47 v->rightshift=0; 50 51 owl_viewwin_set_window(v, win); 48 v->winlines=winlines; 49 v->wincols=wincols; 50 v->curswin=win; 52 51 } 53 52 54 void owl_viewwin_set_ window(owl_viewwin *v, owl_window *w)53 void owl_viewwin_set_curswin(owl_viewwin *v, WINDOW *w, int winlines, int wincols) 55 54 { 56 if (v->window) { 57 g_signal_handler_disconnect(v->window, v->sig_redraw_id); 58 g_object_unref(v->window); 59 } 60 v->window = w; 61 if (w) { 62 g_object_ref(v->window); 63 v->sig_redraw_id = g_signal_connect(w, "redraw", G_CALLBACK(owl_viewwin_redraw), v); 64 } 55 v->curswin=w; 56 v->winlines=winlines; 57 v->wincols=wincols; 65 58 } 66 59 … … 71 64 72 65 /* regenerate text on the curses window. */ 73 static void owl_viewwin_redraw(owl_window *w, WINDOW *curswin, void *user_data)66 void owl_viewwin_redisplay(owl_viewwin *v) 74 67 { 75 68 owl_fmtext fm1, fm2; 76 owl_viewwin *v = user_data;77 int winlines, wincols;78 69 79 owl_window_get_position(w, &winlines, &wincols, 0, 0); 70 /* avoid segfault when screen too small to create curswin */ 71 if (v->curswin == NULL) 72 return; 80 73 81 werase( curswin);82 wmove( curswin, 0, 0);74 werase(v->curswin); 75 wmove(v->curswin, 0, 0); 83 76 84 77 owl_fmtext_init_null(&fm1); 85 78 owl_fmtext_init_null(&fm2); 86 79 87 owl_fmtext_truncate_lines(&(v->fmtext), v->topline, winlines-BOTTOM_OFFSET, &fm1);88 owl_fmtext_truncate_cols(&fm1, v->rightshift, wincols-1+v->rightshift, &fm2);80 owl_fmtext_truncate_lines(&(v->fmtext), v->topline, v->winlines-BOTTOM_OFFSET, &fm1); 81 owl_fmtext_truncate_cols(&fm1, v->rightshift, v->wincols-1+v->rightshift, &fm2); 89 82 90 owl_fmtext_curs_waddstr_without_search(&fm2, curswin);83 owl_fmtext_curs_waddstr_without_search(&fm2, v->curswin); 91 84 92 85 /* print the message at the bottom */ 93 wmove( curswin,winlines-1, 0);94 wattrset( curswin, A_REVERSE);95 if (v->textlines - v->topline > winlines-BOTTOM_OFFSET) {96 waddstr( curswin, "--More-- (Space to see more, 'q' to quit)");86 wmove(v->curswin, v->winlines-1, 0); 87 wattrset(v->curswin, A_REVERSE); 88 if (v->textlines - v->topline > v->winlines-BOTTOM_OFFSET) { 89 waddstr(v->curswin, "--More-- (Space to see more, 'q' to quit)"); 97 90 } else { 98 waddstr( curswin, "--End-- (Press 'q' to quit)");91 waddstr(v->curswin, "--End-- (Press 'q' to quit)"); 99 92 } 100 wattroff( curswin, A_REVERSE);93 wattroff(v->curswin, A_REVERSE); 101 94 102 95 owl_fmtext_cleanup(&fm1); … … 106 99 void owl_viewwin_pagedown(owl_viewwin *v) 107 100 { 108 int winlines; 109 owl_window_get_position(v->window, &winlines, 0, 0, 0); 110 v->topline+=winlines - BOTTOM_OFFSET; 111 if ( (v->topline+winlines-BOTTOM_OFFSET) > v->textlines) { 112 v->topline = v->textlines - winlines + BOTTOM_OFFSET; 101 v->topline+=v->winlines - BOTTOM_OFFSET; 102 if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) { 103 v->topline = v->textlines - v->winlines + BOTTOM_OFFSET; 113 104 } 114 owl_window_dirty(v->window);115 105 } 116 106 117 107 void owl_viewwin_linedown(owl_viewwin *v) 118 108 { 119 int winlines;120 owl_window_get_position(v->window, &winlines, 0, 0, 0);121 109 v->topline++; 122 if ( (v->topline+ winlines-BOTTOM_OFFSET) > v->textlines) {123 v->topline = v->textlines - winlines + BOTTOM_OFFSET;110 if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) { 111 v->topline = v->textlines - v->winlines + BOTTOM_OFFSET; 124 112 } 125 owl_window_dirty(v->window);126 113 } 127 114 128 115 void owl_viewwin_pageup(owl_viewwin *v) 129 116 { 130 int winlines; 131 owl_window_get_position(v->window, &winlines, 0, 0, 0); 132 v->topline-=winlines; 117 v->topline-=v->winlines; 133 118 if (v->topline<0) v->topline=0; 134 owl_window_dirty(v->window);135 119 } 136 120 … … 139 123 v->topline--; 140 124 if (v->topline<0) v->topline=0; 141 owl_window_dirty(v->window);142 125 } 143 126 … … 145 128 { 146 129 v->rightshift+=n; 147 owl_window_dirty(v->window);148 130 } 149 131 … … 152 134 v->rightshift-=n; 153 135 if (v->rightshift<0) v->rightshift=0; 154 owl_window_dirty(v->window);155 136 } 156 137 … … 159 140 v->topline=0; 160 141 v->rightshift=0; 161 owl_window_dirty(v->window);162 142 } 163 143 164 144 void owl_viewwin_bottom(owl_viewwin *v) 165 145 { 166 int winlines; 167 owl_window_get_position(v->window, &winlines, 0, 0, 0); 168 v->topline = v->textlines - winlines + BOTTOM_OFFSET; 169 owl_window_dirty(v->window); 146 v->topline = v->textlines - v->winlines + BOTTOM_OFFSET; 170 147 } 171 148 172 149 void owl_viewwin_cleanup(owl_viewwin *v) 173 150 { 174 owl_viewwin_set_window(v, NULL);175 151 if (v->onclose_hook) { 176 152 v->onclose_hook(v, v->onclose_hook_data); -
zcrypt.c
r3c2c7fc r60fcd71 88 88 89 89 cipher_pair ciphers[NCIPHER] = { 90 [CIPHER_DES] ={ do_encrypt_des, do_decrypt_des},91 [CIPHER_AES] ={ do_encrypt_aes, do_decrypt_aes},90 [CIPHER_DES] { do_encrypt_des, do_decrypt_des}, 91 [CIPHER_AES] { do_encrypt_aes, do_decrypt_aes}, 92 92 }; 93 93 … … 113 113 int mode = M_NONE; 114 114 115 extern int optind, opterr; 116 extern char *optarg; 115 117 char c; 116 118 -
zephyr.c
r8ab1f28 r8ab1f28 265 265 266 266 if (stat(subsfile, &statbuff) != 0) { 267 owl_free(subsfile);268 267 if (error_on_nofile == 1) 269 268 return -1; … … 381 380 subsfile = owl_zephyr_dotfile(".anyone", filename); 382 381 383 if (stat(subsfile, &statbuff) == -1) { 384 owl_free(subsfile); 382 if (stat(subsfile, &statbuff) == -1) 385 383 return 0; 386 }387 384 388 385 ZResetAuthentication(); … … 859 856 char *tmpbuff, *myuser, *to; 860 857 owl_message *mout; 861 owl_zwrite *z;862 858 863 859 /* bail if it doesn't look like a message we should reply to. Some … … 895 891 owl_free(to); 896 892 897 z = owl_zwrite_new(tmpbuff);898 owl_zwrite_set_message(z, owl_global_get_zaway_msg(&g));899 owl_zwrite_set_zsig(z, "Automated reply:");900 901 893 /* display the message as an admin message in the receive window */ 902 mout=owl_function_make_outgoing_zephyr( z);894 mout=owl_function_make_outgoing_zephyr(owl_global_get_zaway_msg(&g), tmpbuff, "Automated reply:"); 903 895 owl_global_messagequeue_addmsg(&g, mout); 904 896 owl_free(tmpbuff); 905 owl_zwrite_delete(z);906 897 #endif 907 898 } -
zwrite.c
r7bfc613 rc230bc1 5 5 #include "owl.h" 6 6 7 owl_zwrite *owl_zwrite_new(const char *line)8 {9 owl_zwrite *z = owl_malloc(sizeof *z);10 if (owl_zwrite_create_from_line(z, line) < 0) {11 owl_zwrite_delete(z);12 return NULL;13 }14 return z;15 }16 17 7 int owl_zwrite_create_from_line(owl_zwrite *z, const char *line) 18 8 { … … 25 15 26 16 /* start with null entries */ 27 z->cmd=NULL;28 17 z->realm=NULL; 29 18 z->class=NULL; … … 46 35 myargc=argc; 47 36 if (myargc && *(myargv[0])!='-') { 48 z->cmd=owl_strdup(myargv[0]);49 37 myargc--; 50 38 myargv++; … … 199 187 } 200 188 201 /* Set the message with no post-processing*/202 void owl_zwrite_set_message_raw(owl_zwrite *z, const char *msg)203 {204 if (z->message) owl_free(z->message);205 z->message = owl_validate_utf8(msg);206 }207 208 189 void owl_zwrite_set_message(owl_zwrite *z, const char *msg) 209 190 { … … 369 350 } 370 351 371 void owl_zwrite_delete(owl_zwrite *z)372 {373 owl_zwrite_cleanup(z);374 owl_free(z);375 }376 377 352 void owl_zwrite_cleanup(owl_zwrite *z) 378 353 {
Note: See TracChangeset
for help on using the changeset viewer.