Changes in / [9a7b4f2:e2cbbbe]
- Files:
-
- 1 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rd564c3d r8a5b5a1 1 #include <getopt.h> 1 2 #include <stdio.h> 2 3 #include <stdlib.h> … … 91 92 "Use 'show keymaps' to see the existing keymaps.\n" 92 93 "Key sequences may be things like M-C-t or NPAGE.\n\n" 93 "Ex.: bindkey recv C-b command zwrite -c barnowl"), 94 "Ex.: bindkey recv C-b command zwrite -c barnowl" 95 "SEE ALSO: bindkey"), 96 97 OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY, 98 "removes a binding in a keymap", 99 "bindkey <keymap> <keyseq>", 100 "Removes a binding of a key sequence within a keymap.\n" 101 "Use 'show keymaps' to see the existing keymaps.\n" 102 "Ex.: unbindkey recv H" 103 "SEE ALSO: bindkey"), 94 104 95 105 OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE, … … 583 593 OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE, 584 594 "view only messages similar to the current message", 585 "smartnarrow [-i | --instance] ",595 "smartnarrow [-i | --instance] [-r | --relatde]", 586 596 "If the curmsg is a personal message narrow\n" 587 597 " to the conversation with that user.\n" … … 591 601 " to the class.\n" 592 602 "If the curmsg is a class message and '-i' is specified\n" 593 " then narrow to the class and instance.\n"), 603 " then narrow to the class and instance.\n" 604 "If '-r' or '--related' is specified, behave as though the\n" 605 " 'narrow-related' variable was inverted."), 594 606 595 607 OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE, … … 897 909 "", ""), 898 910 899 OWLCMD_VOID_CTX("editline:done", owl_command_editline_done, 900 OWL_CTX_EDITLINE, 901 "completes the command (eg, executes command being composed)", 902 "", ""), 903 904 OWLCMD_VOID_CTX("editresponse:done", owl_command_editresponse_done, 905 OWL_CTX_EDITRESPONSE, 906 "completes the response to a question", 907 "", ""), 911 OWLCMD_ALIAS ("editline:done", "edit:done"), 912 OWLCMD_ALIAS ("editresponse:done", "edit:done"), 908 913 909 914 OWLCMD_VOID_CTX("edit:move-up-line", owl_editwin_key_up, … … 918 923 919 924 OWLCMD_VOID_CTX("edit:done", owl_command_edit_done, 920 OWL_CTX_EDIT MULTI,921 " completes the command (eg, sends message being composed)",925 OWL_CTX_EDIT, 926 "Finishes entering text in the editwin.", 922 927 "", ""), 923 928 … … 1236 1241 argc-=2; argv+=2; 1237 1242 } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) { 1238 filter = owl_function_smartfilter(0 );1243 filter = owl_function_smartfilter(0, 0); 1239 1244 argc-=2; argv+=2; 1240 1245 } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) { 1241 filter = owl_function_smartfilter(1 );1246 filter = owl_function_smartfilter(1, 0); 1242 1247 argc-=2; argv+=2; 1243 1248 } else { … … 1266 1271 argc-=2; argv+=2; 1267 1272 } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) { 1268 filter = owl_function_smartfilter(0 );1273 filter = owl_function_smartfilter(0, 0); 1269 1274 argc-=2; argv+=2; 1270 1275 } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) { 1271 filter = owl_function_smartfilter(1 );1276 filter = owl_function_smartfilter(1, 0); 1272 1277 argc-=2; argv+=2; 1273 1278 } else { … … 1285 1290 char *filtname = NULL; 1286 1291 1287 if (argc == 1) { 1288 filtname = owl_function_smartfilter(0); 1289 } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) { 1290 filtname = owl_function_smartfilter(1); 1291 } else { 1292 owl_function_makemsg("Wrong number of arguments for %s", argv[0]); 1293 } 1292 char opt; 1293 int instance = 0, related = 0, i; 1294 char **tmp_argv = owl_malloc(sizeof(char *) * argc); 1295 1296 for (i = 0; i < argc; i++) 1297 tmp_argv[i] = owl_strdup(argv[i]); 1298 1299 static struct option options[] = { 1300 {"instance", 0, 0, 'i'}, 1301 {"related", 0, 0, 'r'}, 1302 {NULL, 0, 0, 0}}; 1303 while ((opt = getopt_long(argc, tmp_argv, "ir", options, NULL)) != -1) { 1304 switch (opt) { 1305 case 'i': 1306 instance = 1; 1307 break; 1308 case 'r': 1309 related = 1; 1310 break; 1311 default: 1312 owl_function_makemsg("Wrong number of arguments for %s (%c)", argv[0], opt); 1313 goto done; 1314 } 1315 } 1316 1317 for (i = 0; i < argc; i++) 1318 owl_free(tmp_argv[i]); 1319 owl_free(tmp_argv); 1320 1321 filtname = owl_function_smartfilter(instance, related); 1322 1294 1323 if (filtname) { 1295 1324 owl_function_change_currentview_filter(filtname); 1296 1325 owl_free(filtname); 1297 1326 } 1327 1328 done: 1329 optind = 0; /* reset getopt */ 1298 1330 return NULL; 1299 1331 } … … 1304 1336 1305 1337 if (argc == 1) { 1306 filtname = owl_function_smartfilter(0 );1338 filtname = owl_function_smartfilter(0, 0); 1307 1339 } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) { 1308 filtname = owl_function_smartfilter(1 );1340 filtname = owl_function_smartfilter(1, 0); 1309 1341 } else { 1310 1342 owl_function_makemsg("Wrong number of arguments for %s", argv[0]); … … 1672 1704 return NULL; 1673 1705 } 1706 1707 1708 char *owl_command_unbindkey(int argc, const char *const *argv, const char *buf) 1709 { 1710 owl_keymap *km; 1711 int ret; 1712 1713 if (argc < 3) { 1714 owl_function_makemsg("Usage: bindkey <keymap> <binding>"); 1715 return NULL; 1716 } 1717 km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]); 1718 if (!km) { 1719 owl_function_makemsg("No such keymap '%s'", argv[1]); 1720 return NULL; 1721 } 1722 ret = owl_keymap_remove_binding(km, argv[2]); 1723 if (ret == -1) { 1724 owl_function_makemsg("Unable to unbind '%s' in keymap '%s'.", 1725 argv[2], argv[1]); 1726 return NULL; 1727 } else if (ret == -2) { 1728 owl_function_makemsg("No such binding '%s' in keymap '%s'.", 1729 argv[2], argv[1]); 1730 } 1731 return NULL; 1732 } 1733 1674 1734 1675 1735 void owl_command_quit(void) … … 2220 2280 return NULL; 2221 2281 } 2222 filtname = owl_function_classinstfilt(argv[1], NULL );2282 filtname = owl_function_classinstfilt(argv[1], NULL, owl_global_is_narrow_related(&g)); 2223 2283 owl_function_change_currentview_filter(filtname); 2224 2284 owl_free(filtname); … … 2332 2392 } 2333 2393 2334 filtname=owl_function_classinstfilt(argv[1], NULL );2394 filtname=owl_function_classinstfilt(argv[1], NULL, owl_global_is_narrow_related(&g)); 2335 2395 (void) owl_function_color_filter(filtname, argv[2], (argc == 4 ? argv[3] : NULL)); 2336 2396 return NULL; … … 2524 2584 /* if we get two arguments, ask for the password */ 2525 2585 if (argc==2) { 2526 owl_ global_set_buffercommand(&g, argv[1]);2527 owl_ global_set_buffercallback(&g, &owl_callback_aimlogin);2528 owl_ function_start_password("AIM Password: ");2586 owl_editwin *e = owl_function_start_password("AIM Password: "); 2587 owl_editwin_set_cbdata(e, owl_strdup(argv[1]), owl_free); 2588 owl_editwin_set_callback(e, owl_callback_aimlogin); 2529 2589 return(NULL); 2530 2590 } else { … … 2655 2715 } 2656 2716 2657 owl_editwin_fullclear(e);2658 2717 owl_global_set_needrefresh(&g); 2718 owl_global_pop_context(&g); 2719 2659 2720 owl_global_set_typwin_inactive(&g); 2660 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL); 2661 2662 owl_global_pop_context(&g); 2721 owl_editwin_delete(e); 2663 2722 } 2664 2723 … … 2710 2769 } 2711 2770 2712 void owl_command_edit line_done(owl_editwin *e)2771 void owl_command_edit_done(owl_editwin *e) 2713 2772 { 2714 2773 owl_history *hist=owl_editwin_get_history(e); 2715 char *rv, *cmd; 2716 2717 owl_history_store(hist, owl_editwin_get_text(e)); 2718 owl_history_reset(hist); 2719 owl_global_set_typwin_inactive(&g); 2720 owl_global_pop_context(&g); 2721 cmd = owl_strdup(owl_editwin_get_text(e)); 2722 owl_editwin_fullclear(e); 2723 rv = owl_function_command(cmd); 2724 owl_free(cmd); 2725 2726 owl_global_set_needrefresh(&g); 2727 2728 if (rv) { 2729 owl_function_makemsg("%s", rv); 2730 owl_free(rv); 2731 } 2732 } 2733 2734 2735 void owl_command_editresponse_done(owl_editwin *e) 2736 { 2737 owl_function_run_buffercommand(); 2738 2739 owl_global_set_typwin_inactive(&g); 2740 owl_global_pop_context(&g); 2741 owl_editwin_fullclear(e); 2742 owl_global_set_needrefresh(&g); 2743 } 2744 2745 2746 void owl_command_edit_done(owl_editwin *e) 2747 { 2748 owl_history *hist=owl_editwin_get_history(e); 2749 2750 owl_history_store(hist, owl_editwin_get_text(e)); 2751 owl_history_reset(hist); 2752 2753 owl_function_run_buffercommand(); 2754 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL); 2755 owl_editwin_fullclear(e); 2774 2775 if (hist) { 2776 owl_history_store(hist, owl_editwin_get_text(e)); 2777 owl_history_reset(hist); 2778 } 2779 2756 2780 owl_global_set_typwin_inactive(&g); 2757 2781 owl_global_pop_context(&g); 2758 2782 owl_global_set_needrefresh(&g); 2783 2784 owl_editwin_do_callback(e); 2785 owl_editwin_delete(e); 2759 2786 } 2760 2787 -
configure.ac
r9a7b4f2 r9a7b4f2 98 98 AC_MSG_NOTICE([Adding perl LIBS ${FOO}]) 99 99 LIBS=${LIBS}\ ${FOO} 100 AC_CHECK_LIB([perl], [perl_alloc],, AC_MSG_ERROR([No libperl found])) 101 102 AX_PROG_PERL_MODULES([Class::Accessor::Fast],, 103 [AC_MSG_ERROR([cannot find perl module Class::Accessor::Fast.])]) 104 AX_PROG_PERL_MODULES([PAR],, 105 [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])]) 100 106 101 107 dnl Add CFLAGS and LDFLAGS for glib-2.0 … … 135 141 AC_PROG_INSTALL 136 142 AC_PROG_RANLIB 143 AC_CHECK_PROG([HAVE_ZIP], [zip], [yes], [no]) 144 if test "x${HAVE_ZIP}" = "xno"; then 145 AC_MSG_ERROR([cannot find a 'zip' binary.]) 146 fi 137 147 138 148 AC_CONFIG_FILES([Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile]) -
editwin.c
rf449096 r21dd391 35 35 oe_excursion *excursions; 36 36 37 char *command;38 37 void (*callback)(struct _owl_editwin*); 38 void (*destroy_cbdata)(void *); 39 39 void *cbdata; 40 40 }; … … 45 45 static void oe_restore_excursion(owl_editwin *e, oe_excursion *x); 46 46 static void oe_restore_mark_only(owl_editwin *e, oe_excursion *x); 47 static int oe_count_glyphs(const char *s);48 47 static int oe_char_width(gunichar c, int column); 49 48 static int oe_region_width(owl_editwin *e, int start, int end, int width); … … 58 57 static int oe_copy_region(owl_editwin *e); 59 58 static char *oe_chunk(owl_editwin *e, int start, int end); 59 static void oe_destroy_cbdata(owl_editwin *e); 60 60 61 61 #define INCR 4096 … … 63 63 #define WHITESPACE " \n\t" 64 64 65 owl_editwin *owl_editwin_allocate(void)65 static owl_editwin *owl_editwin_allocate(void) 66 66 { 67 67 owl_editwin *e; … … 75 75 owl_free(e->buff); 76 76 owl_free(e->killbuf); 77 owl_free(e->command);78 77 /* just in case someone forgot to clean up */ 79 78 while (e->excursions) { 80 79 oe_release_excursion(e, e->excursions); 81 80 } 81 oe_destroy_cbdata(e); 82 82 83 83 owl_free(e); 84 }85 86 static int oe_count_glyphs(const char *s)87 {88 int count = 0;89 const char *p;90 91 for(p = s; *p != 0; p = g_utf8_find_next_char(p, NULL))92 if (!g_unichar_ismark(g_utf8_get_char(p)))93 count++;94 95 return count;96 84 } 97 85 … … 116 104 } 117 105 118 /* initialize the editwin e. 119 * 'win' is an already initialzed curses window that will be used by editwin 120 */ 121 void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style, owl_history *hist) 106 static void _owl_editwin_init(owl_editwin *e, 107 WINDOW *win, 108 int winlines, 109 int wincols, 110 int style, 111 owl_history *hist) 122 112 { 123 113 e->buff=owl_malloc(INCR); … … 145 135 e->echochar='\0'; 146 136 147 /* We get initialized multiple times, but we need to hold on to148 the callbacks, so we can't NULL them here. */149 /*150 e->command = NULL;151 e->callback = NULL;152 e->cbdata = NULL;153 */154 137 if (win) werase(win); 138 } 139 140 owl_editwin *owl_editwin_new(WINDOW *win, int winlines, int wincols, int style, owl_history *hist) 141 { 142 owl_editwin *e = owl_editwin_allocate(); 143 144 _owl_editwin_init(e, win, winlines, wincols, style, hist); 145 return e; 155 146 } 156 147 … … 188 179 } 189 180 190 void owl_editwin_set_command(owl_editwin *e, const char *command)191 {192 if(e->command) owl_free(e->command);193 e->command = owl_strdup(command);194 }195 196 const char *owl_editwin_get_command(owl_editwin *e)197 {198 if(e->command) return e->command;199 return "";200 }201 202 181 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*)) 203 182 { … … 210 189 } 211 190 212 void owl_editwin_set_cbdata(owl_editwin *e, void *data) 213 { 191 static void oe_destroy_cbdata(owl_editwin *e) { 192 if (e->destroy_cbdata) 193 e->destroy_cbdata(e->cbdata); 194 e->cbdata = NULL; 195 e->destroy_cbdata = NULL; 196 } 197 198 void owl_editwin_set_cbdata(owl_editwin *e, void *data, void (*destroy)(void *)) 199 { 200 oe_destroy_cbdata(e); 214 201 e->cbdata = data; 202 e->destroy_cbdata = destroy; 215 203 } 216 204 … … 259 247 } 260 248 261 void owl_editwin_new_style(owl_editwin *e, int newstyle, owl_history *h)262 {263 e->hist = h;264 265 if (e->style==newstyle) return;266 267 if (newstyle==OWL_EDITWIN_STYLE_MULTILINE) {268 e->style=newstyle;269 } else if (newstyle==OWL_EDITWIN_STYLE_ONELINE) {270 e->style=newstyle;271 272 /* nuke everything after the first line */273 owl_editwin_move_to_top(e);274 owl_editwin_move_to_end_of_line(e);275 owl_editwin_replace(e, oe_count_glyphs(e->buff + e->index), "");276 }277 }278 279 /* completly reinitialize the buffer */280 void owl_editwin_fullclear(owl_editwin *e)281 {282 owl_free(e->buff);283 owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);284 }285 286 249 /* clear all text except for locktext and put the cursor at the 287 250 * beginning … … 302 265 303 266 owl_free(e->buff); 304 owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);267 _owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist); 305 268 306 269 if (lock > 0) { -
functions.c
r9a7b4f2 r9a7b4f2 278 278 } 279 279 280 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data )280 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data, void (*cleanup)(void *)) 281 281 { 282 282 owl_editwin *e; … … 284 284 285 285 /* create and setup the editwin */ 286 e = owl_global_get_typwin(&g); 287 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, 288 owl_global_get_msg_history(&g)); 289 owl_editwin_clear(e); 286 e = owl_global_set_typwin_active(&g, OWL_EDITWIN_STYLE_MULTILINE, 287 owl_global_get_msg_history(&g)); 290 288 owl_editwin_set_dotsend(e); 291 289 s = owl_sprintf("----> %s\n", line); … … 293 291 owl_free(s); 294 292 295 /* make it active */ 296 owl_global_set_typwin_active(&g); 297 298 owl_editwin_set_cbdata(owl_global_get_typwin(&g), data); 299 owl_global_set_buffercallback(&g, callback); 293 owl_editwin_set_cbdata(e, data, cleanup); 294 owl_editwin_set_callback(e, callback); 300 295 owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti"); 301 296 } … … 313 308 noun); 314 309 315 owl_function_start_edit_win(line, callback, NULL); 316 owl_global_set_buffercommand(&g, line); 310 owl_function_start_edit_win(line, callback, 311 owl_strdup(line), 312 owl_free); 317 313 } 318 314 … … 350 346 351 347 void owl_callback_zwrite(owl_editwin *e) { 352 owl_function_zwrite(owl_editwin_get_command(e), 348 char *command = owl_editwin_get_cbdata(e); 349 owl_function_zwrite(command, 353 350 owl_editwin_get_text(e)); 354 351 } … … 459 456 460 457 void owl_callback_aimwrite(owl_editwin *e) { 461 owl_function_aimwrite(owl_editwin_get_command(e), 458 char *command = owl_editwin_get_cbdata(e); 459 owl_function_aimwrite(command, 462 460 owl_editwin_get_text(e)); 463 461 } … … 894 892 895 893 void owl_callback_aimlogin(owl_editwin *e) { 896 owl_function_aimlogin(owl_editwin_get_command(e), 894 char *user = owl_editwin_get_cbdata(e); 895 owl_function_aimlogin(user, 897 896 owl_editwin_get_text(e)); 898 897 } … … 1193 1192 { 1194 1193 owl_global_set_resize_pending(&g); 1195 }1196 1197 void owl_function_run_buffercommand(void)1198 {1199 owl_editwin_do_callback(owl_global_get_typwin(&g));1200 1194 } 1201 1195 … … 1917 1911 } 1918 1912 1913 void owl_callback_command(owl_editwin *e) 1914 { 1915 char *rv; 1916 const char *line = owl_editwin_get_text(e); 1917 1918 rv = owl_function_command(line); 1919 if (rv) { 1920 owl_function_makemsg("%s", rv); 1921 owl_free(rv); 1922 } 1923 } 1924 1919 1925 void owl_function_start_command(const char *line) 1920 1926 { 1921 1927 owl_editwin *tw; 1922 1928 1923 tw=owl_global_get_typwin(&g); 1924 owl_global_set_typwin_active(&g); 1925 owl_editwin_new_style(tw, OWL_EDITWIN_STYLE_ONELINE, 1926 owl_global_get_cmd_history(&g)); 1929 tw = owl_global_set_typwin_active(&g, OWL_EDITWIN_STYLE_ONELINE, owl_global_get_cmd_history(&g)); 1927 1930 1928 1931 owl_editwin_set_locktext(tw, "command: "); … … 1933 1936 1934 1937 owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline"); 1935 } 1936 1937 void owl_function_start_question(const char *line) 1938 owl_editwin_set_callback(tw, owl_callback_command); 1939 } 1940 1941 owl_editwin *owl_function_start_question(const char *line) 1938 1942 { 1939 1943 owl_editwin *tw; 1940 1944 1941 tw=owl_global_get_typwin(&g); 1942 owl_global_set_typwin_active(&g); 1943 owl_editwin_new_style(tw, OWL_EDITWIN_STYLE_ONELINE, owl_global_get_cmd_history(&g)); 1945 tw = owl_global_set_typwin_active(&g, OWL_EDITWIN_STYLE_ONELINE, owl_global_get_cmd_history(&g)); 1944 1946 1945 1947 owl_editwin_set_locktext(tw, line); … … 1948 1950 owl_editwin_redisplay(tw); 1949 1951 1950 owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editline"); 1951 } 1952 1953 void owl_function_start_password(const char *line) 1952 owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse"); 1953 return tw; 1954 } 1955 1956 owl_editwin *owl_function_start_password(const char *line) 1954 1957 { 1955 1958 owl_editwin *tw; 1956 1959 1957 tw=owl_global_get_typwin(&g); 1958 owl_global_set_typwin_active(&g); 1959 owl_editwin_new_style(tw, OWL_EDITWIN_STYLE_ONELINE, owl_global_get_cmd_history(&g)); 1960 tw = owl_global_set_typwin_active(&g, OWL_EDITWIN_STYLE_ONELINE, NULL); 1961 1960 1962 owl_editwin_set_echochar(tw, '*'); 1961 1963 … … 1966 1968 1967 1969 owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse"); 1970 return tw; 1968 1971 } 1969 1972 … … 2289 2292 * instance is NULL then catch all messgaes in the class. Returns the 2290 2293 * name of the filter, which the caller must free. 2294 * If 'related' is nonzero, encompass unclasses and .d classes as well. 2291 2295 */ 2292 char *owl_function_classinstfilt(const char *c, const char *i )2296 char *owl_function_classinstfilt(const char *c, const char *i, int related) 2293 2297 { 2294 2298 owl_filter *f; … … 2297 2301 char *class, *instance = NULL; 2298 2302 2299 class = owl_util_baseclass(c); 2300 if(i) { 2301 instance = owl_util_baseclass(i); 2303 if (related) { 2304 class = owl_util_baseclass(c); 2305 if (i) { 2306 instance = owl_util_baseclass(i); 2307 } 2308 } else { 2309 class = owl_strdup(c); 2310 if (i) { 2311 instance = owl_strdup(i); 2312 } 2302 2313 } 2303 2314 2304 2315 /* name for the filter */ 2305 2316 if (!instance) { 2306 filtname = owl_sprintf(" class-%s", class);2307 } else { 2308 filtname = owl_sprintf(" class-%s-instance-%s", class, instance);2317 filtname = owl_sprintf("%sclass-%s", related ? "related-" : "", class); 2318 } else { 2319 filtname = owl_sprintf("%sclass-%s-instance-%s", related ? "related-" : "", class, instance); 2309 2320 } 2310 2321 /* downcase it */ … … 2338 2349 } 2339 2350 2340 argbuff = owl_sprintf( "class ^(un)*%s(\\.d)*$", tmpclass);2351 argbuff = owl_sprintf(related ? "class ^(un)*%s(\\.d)*$" : "class ^%s$", tmpclass); 2341 2352 if (tmpinstance) { 2342 2353 char *tmp = argbuff; 2343 argbuff = owl_sprintf( "%s and ( instance ^(un)*%s(\\.d)*$ )", tmp, tmpinstance);2354 argbuff = owl_sprintf(related ? "%s and ( instance ^(un)*%s(\\.d)*$ )" : "%s and instance ^%s$", tmp, tmpinstance); 2344 2355 owl_free(tmp); 2345 2356 } … … 2512 2523 * name to the AIM conversation with that user 2513 2524 */ 2514 char *owl_function_smartfilter(int type )2525 char *owl_function_smartfilter(int type, int invert_related) 2515 2526 { 2516 2527 const owl_view *v; 2517 2528 const owl_message *m; 2518 2529 char *zperson, *filtname=NULL; 2519 const char *argv[1]; 2520 2530 const char *argv[2]; 2531 int related = owl_global_is_narrow_related(&g) ^ invert_related; 2532 2521 2533 v=owl_global_get_current_view(&g); 2522 2534 m=owl_view_get_element(v, owl_global_get_curmsg(&g)); … … 2562 2574 /* narrow class MESSAGE, instance foo, recip * messages to class, inst */ 2563 2575 if (!strcasecmp(owl_message_get_class(m), "message")) { 2564 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m) );2576 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m), related); 2565 2577 return(filtname); 2566 2578 } … … 2568 2580 /* otherwise narrow to the class */ 2569 2581 if (type==0) { 2570 filtname=owl_function_classinstfilt(owl_message_get_class(m), NULL );2582 filtname=owl_function_classinstfilt(owl_message_get_class(m), NULL, related); 2571 2583 } else if (type==1) { 2572 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m) );2584 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m), related); 2573 2585 } 2574 2586 return(filtname); … … 2576 2588 2577 2589 /* pass it off to perl */ 2578 if(type) { 2579 argv[0] = "-i"; 2580 }; 2581 return owl_perlconfig_message_call_method(m, "smartfilter", type ? 1 : 0, argv); 2590 argv[0] = type ? "1" : "0"; 2591 argv[1] = related ? "1" : "0"; 2592 return owl_perlconfig_message_call_method(m, "smartfilter", 2, argv); 2582 2593 } 2583 2594 … … 3418 3429 int i, j; 3419 3430 owl_list anyone; 3420 owl_message *m;3421 3431 owl_zbuddylist *zbl; 3432 GList **zaldlist; 3433 GList *zaldptr; 3434 ZAsyncLocateData_t *zald; 3422 3435 const char *user; 3423 ZLocations_t location[200];3424 int numlocs, ret;3425 3436 3426 3437 if (!owl_global_is_havezephyr(&g)) return; 3427 3428 zbl=owl_global_get_zephyr_buddylist(&g); 3438 owl_global_set_pseudologin_notify(&g, notify); 3439 zbl = owl_global_get_zephyr_buddylist(&g); 3440 zaldlist = owl_global_get_zaldlist(&g); 3441 3442 /* Clear the existing ZALDs first. */ 3443 zaldptr = g_list_first(*zaldlist); 3444 while (zaldptr) { 3445 ZFreeALD(zaldptr->data); 3446 owl_free(zaldptr->data); 3447 zaldptr = g_list_next(zaldptr); 3448 } 3449 g_list_free(*zaldlist); 3450 *zaldlist = NULL; 3429 3451 3430 3452 owl_list_create(&anyone); 3431 ret=owl_zephyr_get_anyone_list(&anyone, NULL); 3432 3433 j=owl_list_get_size(&anyone); 3434 for (i=0; i<j; i++) { 3435 user=owl_list_get_element(&anyone, i); 3436 ret=ZLocateUser(zstr(user), &numlocs, ZAUTH); 3437 if (ret!=ZERR_NONE) { 3438 owl_function_error("Error getting location for %s", user); 3439 continue; 3440 } 3441 numlocs=200; 3442 ret=ZGetLocations(location, &numlocs); 3443 if (ret==0) { 3444 if ((numlocs>0) && !owl_zbuddylist_contains_user(zbl, user)) { 3445 /* Send a PSEUDO LOGIN! */ 3446 if (notify) { 3447 m=owl_malloc(sizeof(owl_message)); 3448 owl_message_create_pseudo_zlogin(m, 0, user, location[0].host, location[0].time, location[0].tty); 3449 owl_global_messagequeue_addmsg(&g, m); 3450 } 3451 owl_zbuddylist_adduser(zbl, user); 3452 owl_function_debugmsg("owl_function_zephyr_buddy_check: login for %s ", user); 3453 } else if ((numlocs==0) && owl_zbuddylist_contains_user(zbl, user)) { 3454 /* I don't think this ever happens (if there are 0 locations we should get an error from 3455 * ZGetLocations) 3456 */ 3457 owl_function_error("owl_function_zephyr_buddy_check: exceptional case logout for %s ",user); 3458 } 3459 } else if ((ret==ZERR_NOLOCATIONS) && owl_zbuddylist_contains_user(zbl, user)) { 3460 /* Send a PSEUDO LOGOUT! */ 3461 if (notify) { 3462 m=owl_malloc(sizeof(owl_message)); 3463 owl_message_create_pseudo_zlogin(m, 1, user, "", "", ""); 3464 owl_global_messagequeue_addmsg(&g, m); 3465 } 3466 owl_zbuddylist_deluser(zbl, user); 3467 owl_function_debugmsg("owl_function_zephyr_buddy_check: logout for %s ",user); 3453 owl_zephyr_get_anyone_list(&anyone, NULL); 3454 j = owl_list_get_size(&anyone); 3455 for (i = 0; i < j; i++) { 3456 user = owl_list_get_element(&anyone, i); 3457 zald = owl_malloc(sizeof(ZAsyncLocateData_t)); 3458 if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) { 3459 *zaldlist = g_list_append(*zaldlist, zald); 3460 } else { 3461 owl_free(zald); 3468 3462 } 3469 3463 } -
global.c
r2ee9e8d r98d296d 45 45 g->rightshift=0; 46 46 47 g->tw = owl_editwin_allocate(); 48 owl_editwin_init(g->tw, NULL, owl_global_get_typwin_lines(g), g->cols, OWL_EDITWIN_STYLE_ONELINE, NULL); 47 g->tw = NULL; 49 48 50 49 owl_keyhandler_init(&g->kh); … … 58 57 g->curmsg_vert_offset=0; 59 58 g->resizepending=0; 60 g->typwinactive=0;61 59 g->direction=OWL_DIRECTION_DOWNWARDS; 62 60 g->zaway=0; … … 111 109 owl_zbuddylist_create(&(g->zbuddies)); 112 110 111 g->zaldlist = NULL; 112 g->pseudologin_notify = 0; 113 113 114 owl_obarray_init(&(g->obarray)); 114 115 … … 171 172 _owl_panel_set_window(&g->typpan, newwin(typwin_lines, cols, g->recwinlines+2, 0)); 172 173 173 owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols); 174 if (g->tw) 175 owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols); 174 176 175 177 idlok(owl_global_get_curs_typwin(g), FALSE); … … 324 326 } 325 327 326 /* buffercommand */327 328 void owl_global_set_buffercommand(owl_global *g, const char *command) {329 owl_editwin_set_command(owl_global_get_typwin(g), command);330 }331 332 const char *owl_global_get_buffercommand(const owl_global *g) {333 return owl_editwin_get_command(owl_global_get_typwin(g));334 }335 336 void owl_global_set_buffercallback(owl_global *g, void (*cb)(owl_editwin*)) {337 owl_editwin_set_callback(owl_global_get_typwin(g), cb);338 }339 340 void (*owl_global_get_buffercallback(const owl_global *g))(owl_editwin*) {341 return owl_editwin_get_callback(owl_global_get_typwin(g));342 }343 344 328 /* refresh */ 345 329 … … 381 365 /* typwin */ 382 366 383 int owl_global_is_typwin_active(const owl_global *g) { 384 if (g->typwinactive==1) return(1); 385 return(0); 386 } 387 388 void owl_global_set_typwin_active(owl_global *g) { 389 int d = owl_global_get_typewindelta(g); 390 if (d > 0) 367 owl_editwin *owl_global_set_typwin_active(owl_global *g, int style, owl_history *hist) { 368 int d; 369 d = owl_global_get_typewindelta(g); 370 if (d > 0 && style == OWL_EDITWIN_STYLE_MULTILINE) 391 371 owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d); 392 372 393 g->typwinactive=1; 373 g->tw = owl_editwin_new(owl_global_get_curs_typwin(g), 374 owl_global_get_typwin_lines(g), 375 g->cols, 376 style, 377 hist); 378 return g->tw; 394 379 } 395 380 396 381 void owl_global_set_typwin_inactive(owl_global *g) { 397 382 int d = owl_global_get_typewindelta(g); 398 if (d > 0 )383 if (d > 0 && owl_editwin_get_style(g->tw) == OWL_EDITWIN_STYLE_MULTILINE) 399 384 owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d); 400 385 401 g->typwinactive=0; 386 werase(owl_global_get_curs_typwin(g)); 387 g->tw = NULL; 402 388 } 403 389 … … 531 517 owl_mainwin_redisplay(&(g->mw)); 532 518 sepbar(NULL); 533 owl_editwin_redisplay(g->tw); 519 if (g->tw) 520 owl_editwin_redisplay(g->tw); 521 else 522 werase(owl_global_get_curs_typwin(g)); 523 534 524 owl_function_full_redisplay(); 535 525 … … 968 958 } 969 959 960 GList **owl_global_get_zaldlist(owl_global *g) 961 { 962 return &(g->zaldlist); 963 } 964 965 int owl_global_get_pseudologin_notify(owl_global *g) 966 { 967 return g->pseudologin_notify; 968 } 969 970 void owl_global_set_pseudologin_notify(owl_global *g, int notify) 971 { 972 g->pseudologin_notify = notify; 973 } 974 970 975 struct termios *owl_global_get_startup_tio(owl_global *g) 971 976 { -
keybinding.c
r920201c r8a921b5 14 14 int owl_keybinding_init(owl_keybinding *kb, const char *keyseq, const char *command, void (*function_fn)(void), const char *desc) 15 15 { 16 char **ktokens;17 int nktokens, i;18 19 16 owl_function_debugmsg("owl_keybinding_init: creating binding for <%s> with desc: <%s>", keyseq, desc); 20 17 if (command && !function_fn) { … … 25 22 return(-1); 26 23 } 24 25 if (owl_keybinding_make_keys(kb, keyseq) != 0) { 26 return(-1); 27 } 28 29 if (command) kb->command = owl_strdup(command); 30 kb->function_fn = function_fn; 31 if (desc) kb->desc = owl_strdup(desc); 32 else kb->desc = NULL; 33 return(0); 34 } 35 36 int owl_keybinding_make_keys(owl_keybinding *kb, const char *keyseq) 37 { 38 char **ktokens; 39 int nktokens, i; 27 40 28 41 ktokens = atokenize(keyseq, " ", &nktokens); … … 42 55 } 43 56 kb->len = nktokens; 44 45 57 atokenize_delete(ktokens, nktokens); 46 47 if (command) kb->command = owl_strdup(command);48 kb->function_fn = function_fn;49 if (desc) kb->desc = owl_strdup(desc);50 else kb->desc = NULL;51 58 return(0); 52 59 } -
keymap.c
rbb0d439 r8a921b5 51 51 } 52 52 return owl_list_append_element(&km->bindings, kb); 53 } 53 54 } 55 56 /* removes the binding associated with the keymap */ 57 int owl_keymap_remove_binding(owl_keymap *km, const char *keyseq) 58 { 59 owl_keybinding *kb, *curkb; 60 int i; 61 62 if ((kb = owl_malloc(sizeof(owl_keybinding))) == NULL) return(-1); 63 if (0 != owl_keybinding_make_keys(kb, keyseq)) { 64 owl_free(kb); 65 return(-1); 66 } 67 68 for (i = owl_list_get_size(&km->bindings)-1; i >= 0; i--) { 69 curkb = owl_list_get_element(&km->bindings, i); 70 if (owl_keybinding_equal(curkb, kb)) { 71 owl_list_remove_element(&km->bindings, i); 72 owl_keybinding_delete(curkb); 73 return(0); 74 } 75 } 76 return(-2); 77 } 78 54 79 55 80 /* returns a summary line describing this keymap. the caller must free. */ -
keys.c
r8830df47 r8a5b5a1 246 246 BIND_CMD("M-n", "smartnarrow", "narrow to a view based on the current message"); 247 247 BIND_CMD("M-N", "smartnarrow -i", "narrow to a view based on the current message, and consider instance pair"); 248 BIND_CMD("M-m", "smartnarrow -r", "like M-n but with 'narrow-related' temporarily flipped."); 249 BIND_CMD("M-M", "smartnarrow -ri", "like M-N but with 'narrow-related' temporarily flipped."); 248 250 BIND_CMD("M-p", "view personal", ""); 249 251 -
owl.c
rf449096 r98d296d 629 629 /* leave the cursor in the appropriate window */ 630 630 if (!owl_popwin_is_active(owl_global_get_popwin(&g)) 631 && owl_global_ is_typwin_active(&g)) {631 && owl_global_get_typwin(&g)) { 632 632 owl_function_set_cursor(typwin); 633 633 } else { -
owl.h
r03c5bdd r98d296d 559 559 int resizepending; 560 560 int recwinlines; 561 int typwinactive;562 561 char *thishost; 563 562 char *homedir; … … 604 603 owl_zbuddylist zbuddies; 605 604 owl_timer zephyr_buddycheck_timer; 605 GList *zaldlist; 606 int pseudologin_notify; 606 607 struct termios startup_tio; 607 608 owl_obarray obarray; -
perl/lib/BarnOwl/Style/Default.pm
rad0dedd r0fe69d2 168 168 ? '@color(cyan)' : ''; 169 169 170 my $chars = $oneline ? qr/[[:cntrl:]]/ : qr/[^[:print:] ]|[\r\cK\f]/;170 my $chars = $oneline ? qr/[[:cntrl:]]/ : qr/[^[:print:]\n]|[\r\cK\f]/; 171 171 172 172 $s =~ s/($chars)/ … … 179 179 180 180 As above, but always be conservative, and replace with a '?' instead 181 of something m more elaborate.181 of something more elaborate. 182 182 183 183 =cut -
perlconfig.c
r8f2d9bf r1b1cd2c 574 574 FREETMPS; 575 575 LEAVE; 576 577 SvREFCNT_dec(cb); 578 owl_editwin_set_cbdata(e, NULL); 576 } 577 578 void owl_perlconfig_dec_refcnt(void *data) 579 { 580 SV *v = data; 581 SvREFCNT_dec(v); 579 582 } 580 583 -
perlglue.xs
r8c59178 r9186c75 172 172 SV *callback 173 173 PREINIT: 174 owl_editwin *e; 174 175 CODE: 175 176 { … … 177 178 croak("Callback must be a subref"); 178 179 179 owl_function_start_question(line); 180 181 owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(callback)); 182 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 180 e = owl_function_start_question(line); 181 182 owl_editwin_set_cbdata(e, 183 newSVsv(callback), 184 owl_perlconfig_dec_refcnt); 185 owl_editwin_set_callback(e, owl_perlconfig_edit_callback); 183 186 } 184 187 … … 188 191 SV *callback 189 192 PREINIT: 193 owl_editwin *e; 190 194 CODE: 191 195 { … … 193 197 croak("Callback must be a subref"); 194 198 195 owl_function_start_password(line); 196 197 owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(callback)); 198 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 199 e = owl_function_start_password(line); 200 201 owl_editwin_set_cbdata(e, 202 newSVsv(callback), 203 owl_perlconfig_dec_refcnt); 204 owl_editwin_set_callback(e, owl_perlconfig_edit_callback); 199 205 } 200 206 … … 208 214 croak("Callback must be a subref"); 209 215 210 owl_function_start_edit_win(line, owl_perlconfig_edit_callback, newSVsv(callback)); 216 owl_function_start_edit_win(line, 217 owl_perlconfig_edit_callback, 218 newSVsv(callback), 219 owl_perlconfig_dec_refcnt); 211 220 } 212 221 … … 542 551 int count; 543 552 const char *string; 544 CODE: 545 RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string); 553 PREINIT: 554 owl_editwin *e; 555 CODE: 556 e = owl_global_get_typwin(&g); 557 if (e) { 558 RETVAL = owl_editwin_replace(e, count, string); 559 } else { 560 RETVAL = 0; 561 } 546 562 OUTPUT: 547 563 RETVAL … … 550 566 point_move(delta) 551 567 int delta; 552 CODE: 553 RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta); 568 PREINIT: 569 owl_editwin *e; 570 CODE: 571 e = owl_global_get_typwin(&g); 572 if (e) { 573 RETVAL = owl_editwin_point_move(e, delta); 574 } else { 575 RETVAL = 0; 576 } 554 577 OUTPUT: 555 578 RETVAL … … 558 581 replace_region(string) 559 582 const char *string; 560 CODE: 561 RETVAL = owl_editwin_replace_region(owl_global_get_typwin(&g), string); 583 PREINIT: 584 owl_editwin *e; 585 CODE: 586 e = owl_global_get_typwin(&g); 587 if (e) { 588 RETVAL = owl_editwin_replace_region(e, string); 589 } else { 590 RETVAL = 0; 591 } 562 592 OUTPUT: 563 593 RETVAL … … 567 597 PREINIT: 568 598 char *region; 569 CODE: 570 region = owl_editwin_get_region(owl_global_get_typwin(&g)); 599 owl_editwin *e; 600 CODE: 601 e = owl_global_get_typwin(&g); 602 if (e) { 603 region = owl_editwin_get_region(owl_global_get_typwin(&g)); 604 } else { 605 region = NULL; 606 } 571 607 RETVAL = region; 572 608 OUTPUT: … … 581 617 PREINIT: 582 618 int count; 619 owl_editwin *e; 583 620 owl_editwin_excursion *x; 584 621 CODE: 585 622 { 623 e = owl_global_get_typwin(&g); 624 if(!e) 625 croak("The edit window is not currently active!"); 626 586 627 x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); 587 628 PUSHMARK(SP); … … 605 646 int 606 647 current_column() 607 CODE: 608 RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g)); 648 PREINIT: 649 owl_editwin *e; 650 CODE: 651 e = owl_global_get_typwin(&g); 652 if (e) { 653 RETVAL = owl_editwin_current_column(e); 654 } else { 655 RETVAL = 0; 656 } 609 657 OUTPUT: 610 658 RETVAL … … 612 660 int 613 661 point() 614 CODE: 615 RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g)); 662 PREINIT: 663 owl_editwin *e; 664 CODE: 665 e = owl_global_get_typwin(&g); 666 if (e) { 667 RETVAL = owl_editwin_get_point(e); 668 } else { 669 RETVAL = 0; 670 } 616 671 OUTPUT: 617 672 RETVAL … … 619 674 int 620 675 mark() 621 CODE: 622 RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g)); 623 OUTPUT: 624 RETVAL 676 PREINIT: 677 owl_editwin *e; 678 CODE: 679 e = owl_global_get_typwin(&g); 680 if (e) { 681 RETVAL = owl_editwin_get_mark(e); 682 } else { 683 RETVAL = 0; 684 } 685 OUTPUT: 686 RETVAL -
popexec.c
r4cca591 r125fd21 96 96 if (!pe->pid && !pe->winactive) { 97 97 owl_select_remove_io_dispatch(d); 98 pe->dispatch = NULL; 98 99 return; 99 100 } … … 114 115 } 115 116 owl_select_remove_io_dispatch(d); 117 pe->dispatch = NULL; 116 118 return; 117 119 } … … 157 159 158 160 pe->winactive = 0; 159 if (pe->dispatch ->fd > 0) {161 if (pe->dispatch) { 160 162 owl_select_remove_io_dispatch(pe->dispatch); 163 pe->dispatch = NULL; 161 164 } 162 165 if (pe->pid) { -
scripts/add-changelog
r68ab07c r51dbfb5 1 1 #!/bin/sh 2 2 version=$1; shift 3 4 if [ -z "$version" ] || [ "$#" = 0 ]; then 5 echo "Usage: $0 VERSION REV-LIST-ARGS" > &2 6 exit 1; 7 fi 3 8 4 9 ( -
scripts/do-release
rd771d1b r51dbfb5 4 4 echo "$@" >&2 5 5 exit 1 6 } 7 8 usage() { 9 cat >&2 <<EOF 10 Usage: %0 [options] 11 Generate a barnowl release tarball. 12 13 OPTIONS: 14 -f Don't require a changelog entry for the new release. 15 --no-tag Don't create and sign a git tag for the new release 16 --git Do a beta release for the current git revision. 17 EOF 6 18 } 7 19 … … 15 27 --no-tag) no_tag=1 ;; 16 28 --git) git=1 ;; 29 -h|--help) usage ;; 17 30 esac 18 31 done -
scripts/locker-build
r2b6622a6 r51dbfb5 3 3 ######################################################### 4 4 # Build script to build BarnOwl for the locker. 5 6 # Usage: locker-build [-n] [-o OUTPUT-TGZ] SOURCE-TARBALL7 # -n is a dry-run, and drops to a shell in the build directory8 # -o does the install into a temporary directory and tars it into the9 # specified tarball instead.10 # SOURCE-TARBALL is a source tarball, created by do-release11 12 5 die() { 13 6 echo "$@" 2>&1; … … 22 15 23 16 usage () { 24 echo "Usage: $0 [-n] [-o OUTPUT-TGZ] SOURCE-TARBALL" 17 cat >&2 <<EOF 18 Usage: $0 [-n] [-o OUTPUT-TGZ] SOURCE-TARBALL 19 -n is a dry-run, and drops to a shell in the build directory 20 -o does the install into a temporary directory and tars it into the 21 specified tarball instead. 22 23 SOURCE-TARBALL is a source tarball, created by do-release. 24 EOF 25 25 exit 2; 26 26 } -
variable.c
r66a8cd6 r66e409c 358 358 "normal,top,neartop,center,paged,pagedcenter" ), 359 359 360 OWLVAR_BOOL( "narrow-related" /* %OwlVarStub:narrow_related */, 1, 361 "Make smartnarrow use broader filters", 362 "Causes smartfiler to narrow to messages \"related\" to \n" 363 "the current message, as well as ones to the same place.\n\n" 364 "for Zephyr, this controls whether to narrow to e.g. class-help or\n" 365 "class-help.d alone, or to related-class-help, which includes\n" 366 "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" ), 360 367 361 368 OWLVAR_BOOL( "_followlast" /* %OwlVarStub */, 0, -
zephyr.c
rc230bc1 rf25812b 1299 1299 } 1300 1300 1301 #ifdef HAVE_LIBZEPHYR 1302 void owl_zephyr_process_pseudologin(ZNotice_t *n) 1303 { 1304 owl_message *m; 1305 owl_zbuddylist *zbl; 1306 GList **zaldlist; 1307 GList *zaldptr; 1308 ZAsyncLocateData_t *zald = NULL; 1309 ZLocations_t location; 1310 int numlocs, ret, notify; 1311 1312 /* Find a ZALD to match this notice. */ 1313 zaldlist = owl_global_get_zaldlist(&g); 1314 zaldptr = g_list_first(*zaldlist); 1315 while (zaldptr) { 1316 if (ZCompareALDPred(n, zaldptr->data)) { 1317 zald = zaldptr->data; 1318 *zaldlist = g_list_remove(*zaldlist, zaldptr->data); 1319 break; 1320 } 1321 zaldptr = g_list_next(zaldptr); 1322 } 1323 if (zald) { 1324 /* Deal with notice. */ 1325 notify = owl_global_get_pseudologin_notify(&g); 1326 zbl = owl_global_get_zephyr_buddylist(&g); 1327 ret = ZParseLocations(n, zald, &numlocs, NULL); 1328 if (ret == ZERR_NONE) { 1329 if (numlocs > 0 && !owl_zbuddylist_contains_user(zbl, zald->user)) { 1330 if (notify) { 1331 numlocs = 1; 1332 ret = ZGetLocations(&location, &numlocs); 1333 if (ret == ZERR_NONE) { 1334 /* Send a PSEUDO LOGIN! */ 1335 m = owl_malloc(sizeof(owl_message)); 1336 owl_message_create_pseudo_zlogin(m, 0, zald->user, 1337 location.host, 1338 location.time, 1339 location.tty); 1340 owl_global_messagequeue_addmsg(&g, m); 1341 } 1342 owl_zbuddylist_adduser(zbl, zald->user); 1343 owl_function_debugmsg("owl_function_zephyr_buddy_check: login for %s ", zald->user); 1344 } 1345 } else if (numlocs == 0 && owl_zbuddylist_contains_user(zbl, zald->user)) { 1346 /* Send a PSEUDO LOGOUT! */ 1347 if (notify) { 1348 m = owl_malloc(sizeof(owl_message)); 1349 owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", ""); 1350 owl_global_messagequeue_addmsg(&g, m); 1351 } 1352 owl_zbuddylist_deluser(zbl, zald->user); 1353 owl_function_debugmsg("owl_function_zephyr_buddy_check: logout for %s ", zald->user); 1354 } 1355 } 1356 ZFreeALD(zald); 1357 owl_free(zald); 1358 } 1359 } 1360 #else 1361 void owl_zephyr_process_pseudologin(void *n) 1362 { 1363 } 1364 #endif 1365 1301 1366 /* 1302 1367 * Process zephyrgrams from libzephyr's queue. To prevent starvation, … … 1333 1398 } 1334 1399 1400 /* if it is a LOCATE message, it's for pseudologins. */ 1401 if (strcmp(notice.z_opcode, LOCATE_LOCATE) == 0) { 1402 owl_zephyr_process_pseudologin(¬ice); 1403 ZFreeNotice(¬ice); 1404 continue; 1405 } 1406 1335 1407 /* create the new message */ 1336 1408 m=owl_malloc(sizeof(owl_message));
Note: See TracChangeset
for help on using the changeset viewer.