Changeset 1b6b2f3


Ignore:
Timestamp:
Oct 27, 2006, 1:17:18 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
e74c01c
Parents:
dd16bdd
Message:
Refactoring the editwin code somewhat, and adding the ability to hang
arbitrary reply commands off of messages.
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r216c734 r1b6b2f3  
    23792379  if (argc==2) {
    23802380    owl_global_set_buffercommand(&g, argv[1]);
    2381     owl_global_set_buffercallback(&g, owl_function_aimlogin);
     2381    owl_global_set_buffercallback(&g, &owl_callback_aimlogin);
    23822382    owl_function_start_password("AIM Password: ");
    23832383    return(NULL);
  • functions.c

    r4211f50b r1b6b2f3  
    320320
    321321  owl_global_set_buffercommand(&g, line);
    322   owl_global_set_buffercallback(&g, &owl_function_zwrite);
     322  owl_global_set_buffercallback(&g, &owl_callback_zwrite);
    323323}
    324324
     
    351351
    352352  owl_global_set_buffercommand(&g, line);
    353   owl_global_set_buffercallback(&g, &owl_function_aimwrite);
     353  owl_global_set_buffercallback(&g, &owl_callback_aimwrite);
    354354}
    355355
     
    376376
    377377  owl_global_set_buffercommand(&g, "loopwrite");
    378   owl_global_set_buffercallback(&g, &owl_function_loopwrite);
     378  owl_global_set_buffercallback(&g, &owl_callback_loopwrite);
     379}
     380
     381void owl_callback_zwrite(owl_editwin *e) {
     382  owl_function_zwrite(owl_editwin_get_command(e),
     383                      owl_editwin_get_text(e));
    379384}
    380385
     
    486491}
    487492
     493void owl_callback_aimwrite(owl_editwin *e) {
     494  owl_function_aimwrite(owl_editwin_get_command(e),
     495                        owl_editwin_get_text(e));
     496}
     497
    488498void owl_function_aimwrite(char *line, char *msg)
    489499{
     
    562572}
    563573
    564 void owl_function_loopwrite(char *line, char *msg)
     574void owl_callback_loopwrite(owl_editwin *e) {
     575  owl_function_loopwrite(owl_editwin_get_text(e));
     576}
     577
     578void owl_function_loopwrite(char *msg)
    565579{
    566580  owl_message *min, *mout;
     
    932946    owl_function_error("Error subscribing to login messages from file.");
    933947  }
     948}
     949
     950void owl_callback_aimlogin(owl_editwin *e) {
     951  owl_function_aimlogin(owl_editwin_get_command(e),
     952                        owl_global_get_response(&g));
    934953}
    935954
     
    13241343void owl_function_run_buffercommand()
    13251344{
    1326   char *buff;
    1327   void (*cb)(char*, char*);
    1328 
    1329   buff=owl_global_get_buffercommand(&g);
    1330   cb=owl_global_get_buffercallback(&g);
    1331   if(!cb) {
    1332     owl_function_error("Internal error: No callback for buffercommand %s", buff);
    1333   } else {
    1334     cb(buff, owl_editwin_get_text(owl_global_get_typwin(&g)));
    1335   }
     1345  owl_editwin_do_callback(owl_global_get_typwin(&g));
    13361346}
    13371347
     
    21672177      }
    21682178      if (cc) owl_free(cc);
    2169     }
    2170 
    2171     /* aim */
    2172     if (owl_message_is_type_aim(m)) {
     2179    } else if (owl_message_is_type_aim(m)) {
     2180      /* aim */
    21732181      if (owl_message_is_direction_out(m)) {
    21742182        buff=owl_sprintf("aimwrite %s", owl_message_get_recipient(m));
     
    21762184        buff=owl_sprintf("aimwrite %s", owl_message_get_sender(m));
    21772185      }
    2178     }
    2179    
     2186    } else {
     2187      char *cmd;
     2188      if((type==0 && (cmd=owl_message_get_attribute_value(m, "replycmd")))
     2189         || (type==1 && (cmd=owl_message_get_attribute_value(m, "replysendercmd")))) {
     2190        buff = owl_strdup(cmd);
     2191      }
     2192    }
     2193
    21802194    if (enter) {
    21812195      owl_history *hist = owl_global_get_cmd_history(&g);
  • global.c

    r4211f50b r1b6b2f3  
    6868  g->searchstring=NULL;
    6969  g->starttime=time(NULL); /* assumes we call init only a start time */
    70   g->buffercommand=NULL;
    7170  g->newmsgproc_pid=0;
    7271 
     
    241240
    242241void owl_global_set_buffercommand(owl_global *g, char *command) {
    243   if (g->buffercommand) owl_free(g->buffercommand);
    244   g->buffercommand=owl_strdup(command);
     242  owl_editwin_set_command(owl_global_get_typwin(g), command);
    245243}
    246244
    247245char *owl_global_get_buffercommand(owl_global *g) {
    248   if (g->buffercommand) return(g->buffercommand);
    249   return("");
    250 }
    251 
    252 void owl_global_set_buffercallback(owl_global *g, void (*cb)(char*,char*)) {
    253   g->buffercallback = cb;
    254 }
    255 
    256 void (*owl_global_get_buffercallback(owl_global *g))(char*,char*) {
    257   return g->buffercallback;
     246  return owl_editwin_get_command(owl_global_get_typwin(g));
     247}
     248
     249void owl_global_set_buffercallback(owl_global *g, void (*cb)(owl_editwin*)) {
     250  owl_editwin_set_callback(owl_global_get_typwin(g), cb);
     251}
     252
     253void (*owl_global_get_buffercallback(owl_global *g))(owl_editwin*) {
     254  return owl_editwin_get_callback(owl_global_get_typwin(g));
    258255}
    259256
  • owl.h

    r39c036d r1b6b2f3  
    442442  int dotsend;
    443443  int echochar;
     444
     445  char *command;
     446  void (*callback)(struct _owl_editwin*);
     447  void *cbdata;
    444448} owl_editwin;
    445449
     
    536540  int haveconfig;
    537541  int config_format;
    538   char *buffercommand;
    539   void (*buffercallback)(char *cmd, char *msg);
     542  void *buffercbdata;
    540543  owl_editwin tw;
    541544  owl_viewwin vw;
  • perlglue.xs

    rdd16bdd r1b6b2f3  
    100100                owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd);
    101101
    102 void queue_message(msg)
     102void queue_message(msg) 
    103103        SV *msg
    104104        PREINIT:
     
    111111                I32 len;
    112112        CODE:
     113        {
    113114                if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
    114115                        croak("Usage: owl::queue_message($message)");
     
    131132                        }
    132133                }
     134                owl_message_set_isprivate(m);
     135                if(owl_message_is_type_admin(m)) {
     136                        if(!owl_message_get_attribute_value(m, "adminheader"))
     137                                owl_message_set_attribute(m, "adminheader", "");
     138                }
    133139
    134140                owl_global_messagequeue_addmsg(&g, m);
     141        }
Note: See TracChangeset for help on using the changeset viewer.