Binary files freehoo/.ChangeLog.swp and freehoo-patched/.ChangeLog.swp differ diff -pruN freehoo/src/fh-utils.h freehoo-patched/src/fh-utils.h --- freehoo/src/fh-utils.h 2004-10-21 22:56:10.000000000 +0530 +++ freehoo-patched/src/fh-utils.h 2005-02-14 02:38:35.000000000 +0530 @@ -35,22 +35,10 @@ int temp_rl_point; */ #define PRINTF_MESSAGE(format, args...) \ { \ - if (rl_end >= 0) \ - { \ - temp_rl_point = rl_point; \ - rl_kill_text (0, rl_end); \ - rl_redisplay (); \ - } \ - \ - printf ("\r" format, ##args); \ - \ - if (rl_end >= 0) \ - { \ - rl_do_undo (); \ - rl_point = temp_rl_point; \ - rl_reset_line_state (); \ - } \ + printf ("\r"); \ + printf (format, ##args); \ \ + rl_reset_line_state (); \ rl_forced_update_display (); \ bell (); \ } diff -pruN freehoo/src/interpreter.c freehoo-patched/src/interpreter.c --- freehoo/src/interpreter.c 2005-02-14 04:32:24.000000000 +0530 +++ freehoo-patched/src/interpreter.c 2005-02-14 13:52:58.000000000 +0530 @@ -32,6 +32,7 @@ #include #include +#include #include "freehoo.h" #include "interpreter.h" @@ -48,6 +49,61 @@ char *commands[] = { "?send", "?who", "? "?send-file", FH_ROBOT, NULL }; +char * autocomplete_buddy_regex = + /* regex header */ + "^\\ *\\?(" + + /* commands which accept 1st arg as buddy */ + "send|send\\-file|ignore|unignore|add|remove|reject|color\\-buddy|ping|buzz|forward|vconf\\-start|" + + /* commands which accpet 1st arg and beyond as buddies */ + "(forward|vconf\\-start)\\ +[a-zA-Z0-9_\\-\\ ]*|" + + /* commands which accept 2nd arg and beyond + * as buddies, but first as non buddy.. like + * confroom or virtual buddy (not yet buddy) + */ + "(alias|conf\\-start)\\ +[a-zA-Z0-9_\\-\\ ]+|" + + /* command which accept 2nd arg only as + * buddy, 1st arg being non buddy, like + * confroom + */ + "(conf\\-add)\\ +[a-zA-Z0-9_\\-]+" + + /* regex footer, possibly along with the + * half-d00d! at the end */ + ")\\ +[a-zA-Z0-9_\\-]*$" ; + +char * autocomplete_conf_regex = + /* regex header */ + "^\\ *\\?(" + + /* commands which accept 1st arg as confroom*/ + "conf\\-add|conf\\-join|conf\\-decline|conf\\-end|conf\\-send" + + /* regex footer, possibly along with the + * half conf-room*/ + ")\\ +[a-zA-Z0-9_\\-]*$" ; + +char * autocomplete_file_regex = + /* regex header */ + "^\\ *\\?(" + + /* commands which accept 1st arg as filename*/ + "send\\-file" + + /* buddy name */ + ")\\ +[a-zA-Z0-9_\\-]+\\ +" + + /* regex footer, possibly along with the + * half filename*/ + "[a-zA-Z0-9_\\-]*$" ; + +char * autocomplete_cmd_regex = + /* still in first word or no words yet*/ + "^\\ *\\??[a-zA-Z0-9_\\-]*$" ; + extern YList *conferences; SCM dynamic_commands = SCM_UNSPECIFIED; @@ -200,7 +256,7 @@ get_nth_buddy(int index) } char * -command_generator (const char *text, int stat) +command_generator (const char *text, int state) { static int i, len; static int buddy_index, toggle_index; @@ -209,29 +265,95 @@ command_generator (const char *text, int char *dynamic_command; char *name; yahoo_account *temp_buddy; + regex_t preg; + char curr_char = rl_line_buffer[rl_point]; + conf_room *rooms; + YList *conflist = NULL; + static char complete_buddy = 0, + complete_conf = 0, + complete_toggle = 0, + complete_file = 0, + complete_cmd = 0; // flags because regex is expensive - if (!stat) + if (!state) { len = strlen (text); i = 0; buddy_index = 0; toggle_index = 0; dynamic_cmd_index = 0; - } + complete_buddy = 0; + complete_conf = 0; + complete_toggle = 0; + complete_cmd = 0; + complete_file = 0; + conflist = get_fh_conferences(); + + + rl_line_buffer[rl_point] = '\0'; /* the effect should be such + * that the cursor position + * is at the end of line for + * the auto completion regex + * above (note the $ at end) + */ + + /* check for the d00d's need in the context */ + regcomp(&preg,autocomplete_buddy_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_buddy = 1; + } + regfree(&preg); - // if your command takes buddy_name as argument then you - // will have to add ur command in this check list - if ((strncmp (rl_line_buffer, "?remove ", 8) == 0) - || (strncmp (rl_line_buffer, "?send ", 6) == 0) - || (strncmp (rl_line_buffer, "?reject ", 8) == 0) - || (strncmp (rl_line_buffer, "?add ", 5) == 0) - || (strncmp (rl_line_buffer, "?ignore ", 8) == 0) - || (strncmp (rl_line_buffer, "?unignore ", 10) == 0)) - { + /* check for a conf need in the context */ + regcomp(&preg,autocomplete_conf_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_conf = 1; + } + regfree(&preg); + + /* check for a file need in the context */ + regcomp(&preg,autocomplete_file_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_file = 1; + } + regfree(&preg); + + rl_line_buffer[rl_point] = curr_char; /* what effect? :-) */ + + /* ?toggle is pardoned for now */ + if (strncmp (rl_line_buffer, "?toggle ", 8) == 0) + { + complete_toggle = 1; + } + + regcomp(&preg,autocomplete_cmd_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_conf = 1; + complete_cmd = 1; + complete_buddy = 1; + } + regfree(&preg); + + /* if no context available, default to buddy completion */ + if(!complete_buddy && !complete_cmd && !complete_conf && !complete_cmd && !complete_file && !complete_toggle) + complete_buddy = 1; + } + + // if your command takes buddy_name as argument then you + // will have to squeeze in your command in this regex + + if(complete_file) + return rl_filename_completion_function(text,state); - while((temp_buddy = (yahoo_account *) get_nth_buddy (i))) + if(complete_buddy) + { + while((temp_buddy = (yahoo_account *) get_nth_buddy (buddy_index))) { - i++; + buddy_index++; name = temp_buddy->yahoo_id; if (!name || (name[0] == 0)) continue; @@ -239,12 +361,22 @@ command_generator (const char *text, int if (strncasecmp (name, text, len) == 0) return strdup (name); } - - return NULL; } - - // ?toggle argument tabs - if (strncmp (rl_line_buffer, "?toggle ", 8) == 0) + + if ( complete_conf) + { + /* conf rooms */ + if(conflist) + { + rooms = (conf_room *)conflist->data; + if(rooms && rooms->room_name && + !strncasecmp(rooms->room_name,text,len)) + return strdup(rooms->room_name); + conflist = conflist->next; + } + } + + if (complete_toggle) { switch (toggle_index) { @@ -265,16 +397,17 @@ command_generator (const char *text, int if (strncasecmp ("status", text, len) == 0) return strdup ("status"); default: - return NULL; + break; + /* return NULL; */ // fallthrough needed now } } - // for dynamic commands - if (gh_list_p (dynamic_commands)) - { - dynamic_commands_count = gh_length (dynamic_commands); - while (dynamic_cmd_index < dynamic_commands_count) - { + if(complete_cmd) { + if (gh_list_p (dynamic_commands)) + { + dynamic_commands_count = gh_length (dynamic_commands); + while (dynamic_cmd_index < dynamic_commands_count) + { dynamic_command = gh_scm2newstr (gh_list_ref (gh_list_ref (dynamic_commands, gh_ulong2scm (dynamic_cmd_index++)), @@ -283,29 +416,18 @@ command_generator (const char *text, int if (dynamic_command && strncasecmp (dynamic_command, text, len) == 0) return strdup (dynamic_command); } - } + } - // for normal command - while ((name = commands[i])) - { - i++; - if (strncasecmp (name, text, len) == 0) - return (char *) strdup (name); - } - - while((temp_buddy = (yahoo_account *) get_nth_buddy (buddy_index))) - { - buddy_index++; - - name = temp_buddy->yahoo_id; - if (!name || (name[0] == 0)) - continue; - - if (strncasecmp (name, text, len) == 0) - return strdup (name); + // for normal command + while ((name = commands[i])) + { + i++; + if (strncasecmp (name, text, len) == 0) + return (char *) strdup (name); + } } - return (char *) NULL; + return (char *) NULL; /* in the end */ } char ** @@ -352,6 +474,7 @@ interpreter (char *line) if (strlen (line) == 0) { + set_current_target_buddy(""); return; } @@ -1442,3 +1565,9 @@ command_send_file (char *line) printf ("File [%s] uploaded\n", filepath) ; */ } + +char * +complete_none (char *text,int state) +{ + return (char *)NULL; +} diff -pruN freehoo/src/interpreter.c~ freehoo-patched/src/interpreter.c~ --- freehoo/src/interpreter.c~ 2004-09-02 13:27:58.000000000 +0530 +++ freehoo-patched/src/interpreter.c~ 2005-02-14 13:50:18.000000000 +0530 @@ -32,6 +32,7 @@ #include #include +#include #include "freehoo.h" #include "interpreter.h" @@ -48,6 +49,61 @@ char *commands[] = { "?send", "?who", "? "?send-file", FH_ROBOT, NULL }; +char * autocomplete_buddy_regex = + /* regex header */ + "^\\ *\\?(" + + /* commands which accept 1st arg as buddy */ + "send|send\\-file|ignore|unignore|add|remove|reject|color\\-buddy|ping|buzz|forward|vconf\\-start|" + + /* commands which accpet 1st arg and beyond as buddies */ + "(forward|vconf\\-start)\\ +[a-zA-Z0-9_\\-\\ ]*|" + + /* commands which accept 2nd arg and beyond + * as buddies, but first as non buddy.. like + * confroom or virtual buddy (not yet buddy) + */ + "(alias|conf\\-start)\\ +[a-zA-Z0-9_\\-\\ ]+|" + + /* command which accept 2nd arg only as + * buddy, 1st arg being non buddy, like + * confroom + */ + "(conf\\-add)\\ +[a-zA-Z0-9_\\-]+" + + /* regex footer, possibly along with the + * half-d00d! at the end */ + ")\\ +[a-zA-Z0-9_\\-]*$" ; + +char * autocomplete_conf_regex = + /* regex header */ + "^\\ *\\?(" + + /* commands which accept 1st arg as confroom*/ + "conf\\-add|conf\\-join|conf\\-decline|conf\\-end|conf\\-send" + + /* regex footer, possibly along with the + * half conf-room*/ + ")\\ +[a-zA-Z0-9_\\-]*$" ; + +char * autocomplete_file_regex = + /* regex header */ + "^\\ *\\?(" + + /* commands which accept 1st arg as filename*/ + "send\\-file" + + /* buddy name */ + ")\\ +[a-zA-Z0-9_\\-]+\\ +" + + /* regex footer, possibly along with the + * half filename*/ + "[a-zA-Z0-9_\\-]*$" ; + +char * autocomplete_cmd_regex = + /* still in first word or no words yet*/ + "^\\ *\\??[a-zA-Z0-9_\\-]*$" ; + extern YList *conferences; SCM dynamic_commands = SCM_UNSPECIFIED; @@ -200,7 +256,7 @@ get_nth_buddy(int index) } char * -command_generator (const char *text, int stat) +command_generator (const char *text, int state) { static int i, len; static int buddy_index, toggle_index; @@ -209,26 +265,106 @@ command_generator (const char *text, int char *dynamic_command; char *name; yahoo_account *temp_buddy; + regex_t preg; + char curr_char = rl_line_buffer[rl_point]; + conf_room *rooms; + YList *conflist = NULL; + static char complete_buddy = 0, + complete_conf = 0, + complete_toggle = 0, + complete_file = 0, + complete_cmd = 0; // flags because regex is expensive - if (!stat) + if (!state) { len = strlen (text); i = 0; buddy_index = 0; toggle_index = 0; dynamic_cmd_index = 0; - } + complete_buddy = 0; + complete_conf = 0; + complete_toggle = 0; + complete_cmd = 0; + complete_file = 0; + conflist = get_fh_conferences(); + + + rl_line_buffer[rl_point] = '\0'; /* the effect should be such + * that the cursor position + * is at the end of line for + * the auto completion regex + * above (note the $ at end) + */ + + /* check for the d00d's need in the context */ + regcomp(&preg,autocomplete_buddy_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_buddy = 1; + } + regfree(&preg); + + /* check for a conf need in the context */ + regcomp(&preg,autocomplete_conf_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_conf = 1; + } + regfree(&preg); - // if your command takes buddy_name as argument then you - // will have to add ur command in this check list - if ((strncmp (rl_line_buffer, "?remove ", 8) == 0) - || (strncmp (rl_line_buffer, "?send ", 6) == 0) - || (strncmp (rl_line_buffer, "?reject ", 8) == 0) - || (strncmp (rl_line_buffer, "?add ", 5) == 0) - || (strncmp (rl_line_buffer, "?ignore ", 8) == 0) - || (strncmp (rl_line_buffer, "?unignore ", 10) == 0)) + /* check for a file need in the context */ + regcomp(&preg,autocomplete_file_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_file = 1; + } + regfree(&preg); + + rl_line_buffer[rl_point] = curr_char; /* what effect? :-) */ + + /* ?toggle is pardoned for now */ + if (strncmp (rl_line_buffer, "?toggle ", 8) == 0) + { + complete_toggle = 1; + } + + regcomp(&preg,autocomplete_cmd_regex,REG_EXTENDED|REG_ICASE); + if ( !regexec(&preg,rl_line_buffer,0,NULL,0)) + { + complete_conf = 1; + complete_cmd = 1; + complete_buddy = 1; + } + regfree(&preg); + + /* if no context available, default to buddy completion */ + if(!complete_buddy && !complete_cmd && !complete_conf && !complete_cmd && !complete_file && !complete_toggle) + complete_buddy = 1; + } + + // if your command takes buddy_name as argument then you + // will have to squeeze in your command in this regex + + if(complete_file) + return rl_filename_completion_function(text,state); + + if(complete_buddy) { + while((temp_buddy = (yahoo_account *) get_nth_buddy (buddy_index))) + { + buddy_index++; + name = temp_buddy->yahoo_id; + if (!name || (name[0] == 0)) + continue; + if (strncasecmp (name, text, len) == 0) + return strdup (name); + } + } + + if(complete_buddy) + { while((temp_buddy = (yahoo_account *) get_nth_buddy (i))) { i++; @@ -239,12 +375,21 @@ command_generator (const char *text, int if (strncasecmp (name, text, len) == 0) return strdup (name); } - - return NULL; } - - // ?toggle argument tabs - if (strncmp (rl_line_buffer, "?toggle ", 8) == 0) + if ( complete_conf) + { + /* conf rooms */ + if(conflist) + { + rooms = (conf_room *)conflist->data; + if(rooms && rooms->room_name && + !strncasecmp(rooms->room_name,text,len)) + return strdup(rooms->room_name); + conflist = conflist->next; + } + } + + if (complete_toggle) { switch (toggle_index) { @@ -265,16 +410,17 @@ command_generator (const char *text, int if (strncasecmp ("status", text, len) == 0) return strdup ("status"); default: - return NULL; + break; + /* return NULL; */ // fallthrough needed now } } - // for dynamic commands - if (gh_list_p (dynamic_commands)) - { - dynamic_commands_count = gh_length (dynamic_commands); - while (dynamic_cmd_index < dynamic_commands_count) - { + if(complete_cmd) { + if (gh_list_p (dynamic_commands)) + { + dynamic_commands_count = gh_length (dynamic_commands); + while (dynamic_cmd_index < dynamic_commands_count) + { dynamic_command = gh_scm2newstr (gh_list_ref (gh_list_ref (dynamic_commands, gh_ulong2scm (dynamic_cmd_index++)), @@ -283,29 +429,18 @@ command_generator (const char *text, int if (dynamic_command && strncasecmp (dynamic_command, text, len) == 0) return strdup (dynamic_command); } - } + } - // for normal command - while ((name = commands[i])) - { - i++; - if (strncasecmp (name, text, len) == 0) - return (char *) strdup (name); - } - - while((temp_buddy = (yahoo_account *) get_nth_buddy (buddy_index))) - { - buddy_index++; - - name = temp_buddy->yahoo_id; - if (!name || (name[0] == 0)) - continue; - - if (strncasecmp (name, text, len) == 0) - return strdup (name); + // for normal command + while ((name = commands[i])) + { + i++; + if (strncasecmp (name, text, len) == 0) + return (char *) strdup (name); + } } - return (char *) NULL; + return (char *) NULL; /* in the end */ } char ** @@ -352,6 +487,7 @@ interpreter (char *line) if (strlen (line) == 0) { + set_current_target_buddy(""); return; } @@ -1442,3 +1578,9 @@ command_send_file (char *line) printf ("File [%s] uploaded\n", filepath) ; */ } + +char * +complete_none (char *text,int state) +{ + return (char *)NULL; +} diff -pruN freehoo/src/interpreter.h freehoo-patched/src/interpreter.h --- freehoo/src/interpreter.h 2004-08-24 19:14:12.000000000 +0530 +++ freehoo-patched/src/interpreter.h 2005-02-14 13:48:55.000000000 +0530 @@ -45,6 +45,7 @@ char *command_generator (const char *tex char **complete_text (char *text, int start, int end); void syntax_error (void); void interpreter (char *line); +char *complete_none(char *text,int state); void command_show_help (char *line); void command_status (char *line); diff -pruN freehoo/src/interpreter.h~ freehoo-patched/src/interpreter.h~ --- freehoo/src/interpreter.h~ 1970-01-01 05:30:00.000000000 +0530 +++ freehoo-patched/src/interpreter.h~ 2005-02-14 13:34:12.000000000 +0530 @@ -0,0 +1,75 @@ +/* + interpreter.h: file contains read-eval-print loop and + supportive functions + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +#ifndef _INTERPRETER_H +#define _INTERPRETER_H + +#define EX_DYNAMIC_COMMANDS "fh-commands" + +unsigned char get_bell_state (void); +unsigned char get_who_state (void); +unsigned char get_session_mode (void); +unsigned char get_status_mode (void); + +void toggle_bell (void); +void toggle_who (void); +void toggle_session (void); +void toggle_status (void); + +int get_current_status (void); +void set_current_status (int current_status_value); + +char *get_current_status_custom_message (void); +void set_current_status_custom_message (char *current_status_custom_message_value); + +void register_command (SCM command); +void unregister_command (SCM command); +void *get_nth_buddy(int index); +char *command_generator (const char *text, int stat); +char **complete_text (char *text, int start, int end); +void syntax_error (void); +void interpreter (char *line); +rl_compentry_func_t complete_none; + +void command_show_help (char *line); +void command_status (char *line); +void command_send_message (char *line); +void command_send_file (char *line); +void command_buddy_add (char *line); +void command_buddy_remove (char *line); +void command_buddy_reject (char *line); +void command_buddy_ignore (char *line); +void command_buddy_unignore (char *line); +void command_default_handler (char *command, char *line); +void command_eval_scheme_str (char *line); +void command_load_scheme_file (char *line); +void command_toggle (char *line); +void command_bell (); +void command_dynamic_commands (char *dynamic_command, char *line); + +void command_default_handler (char *command, char *line); +void command_conf_add (char *line); +void command_conf_begin (char *line); +void command_conf_quit (char *line); +void command_conf_decline (char *line); +void command_conf_join (char *line); +void command_conf_list (char *line); +void command_conf_send (char *line); + +#endif diff -pruN freehoo/src/yahoo-backend.c freehoo-patched/src/yahoo-backend.c --- freehoo/src/yahoo-backend.c 2005-01-27 07:37:59.000000000 +0530 +++ freehoo-patched/src/yahoo-backend.c 2005-02-14 13:33:24.000000000 +0530 @@ -1646,6 +1646,7 @@ messenger_main (int argc, char *argv[]) rl_callback_handler_install (get_default_prompt (), interpreter); rl_attempted_completion_function = (CPPFunction *) complete_text; + rl_completion_entry_function = complete_none; main_loop (); LOG (("Exited loop")); @@ -1713,6 +1714,13 @@ get_fh_buddies () } YList * +get_fh_conferences () +{ + return conferences; +} + + +YList * get_fh_ignores () { return ignores; diff -pruN freehoo/src/yahoo-backend.h freehoo-patched/src/yahoo-backend.h --- freehoo/src/yahoo-backend.h 2004-09-02 20:34:44.000000000 +0530 +++ freehoo-patched/src/yahoo-backend.h 2005-02-14 11:23:33.000000000 +0530 @@ -112,6 +112,7 @@ void fh_quit (); int get_yahoo_session_id (); yahoo_local_account *get_fh_session (); YList *get_fh_buddies (); +YList *get_fh_conferences (); YList *get_fh_ignores (); #endif /* _YAHOO_BACKEND_H */