Changeset 37eab7f


Ignore:
Timestamp:
Oct 25, 2003, 11:53:43 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
eec69e1
Parents:
8c92848
Message:
Added the loopback message type
Added the loopwrite command
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r8c92848 r37eab7f  
    66        More AIM logout detection
    77        Don't proclaim "interfaces changed" on first build.
     8        Added the 'loopback' message type
     9        Added the 'loopwrite' command
    810       
    9112.0.10
  • commands.c

    r8c92848 r37eab7f  
    134134              "aimzwrite <user>",
    135135              "Send an aim message to a user.\n"),
     136
     137  OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE,
     138              "send a loopback message",
     139              "loopwrite",
     140              "Send a local message.\n"),
    136141
    137142  OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE,
     
    17251730  owl_function_aimwrite_setup(newbuff);
    17261731  owl_free(newbuff);
     1732  return(NULL);
     1733}
     1734
     1735char *owl_command_loopwrite(int argc, char **argv, char *buff)
     1736{
     1737  owl_function_loopwrite_setup();
    17271738  return(NULL);
    17281739}
  • filter.c

    r49d467c r37eab7f  
    162162      match=owl_message_get_realm(m);
    163163    } else if (!strcasecmp(field, "type")) {
    164       match=owl_message_type_to_string(m);
     164      match=owl_message_get_type(m);
    165165    } else if (!strcasecmp(field, "hostname")) {
    166166      match=owl_message_get_hostname(m);
  • functions.c

    r8c92848 r37eab7f  
    208208}
    209209
     210int owl_function_make_outgoing_loopback(char *body)
     211{
     212  owl_message *m;
     213  int followlast;
     214
     215  followlast=owl_global_should_followlast(&g);
     216
     217  /* create the message */
     218  m=owl_malloc(sizeof(owl_message));
     219  owl_message_create_loopback(m, body);
     220  owl_message_set_direction_out(m);
     221
     222  /* add it to the global list and current view */
     223  owl_messagelist_append_element(owl_global_get_msglist(&g), m);
     224  owl_view_consider_message(owl_global_get_current_view(&g), m);
     225
     226  if (followlast) owl_function_lastmsg_noredisplay();
     227
     228  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     229  if (owl_popwin_is_active(owl_global_get_popwin(&g))) {
     230    owl_popwin_refresh(owl_global_get_popwin(&g));
     231  }
     232 
     233  wnoutrefresh(owl_global_get_curs_recwin(&g));
     234  owl_global_set_needrefresh(&g);
     235  return(0);
     236}
     237
    210238void owl_function_zwrite_setup(char *line)
    211239{
     
    280308
    281309  owl_global_set_buffercommand(&g, line);
     310}
     311
     312void owl_function_loopwrite_setup()
     313{
     314  owl_editwin *e;
     315
     316  /* create and setup the editwin */
     317  e=owl_global_get_typwin(&g);
     318  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g));
     319
     320  if (!owl_global_get_lockout_ctrld(&g)) {
     321    owl_function_makemsg("Type your message below.  End with ^D or a dot on a line by itself.  ^C will quit.");
     322  } else {
     323    owl_function_makemsg("Type your message below.  End with a dot on a line by itself.  ^C will quit.");
     324  }
     325
     326  owl_editwin_clear(e);
     327  owl_editwin_set_dotsend(e);
     328  owl_editwin_set_locktext(e, "----> loopwrite\n");
     329
     330  /* make it active */
     331  owl_global_set_typwin_active(&g);
     332
     333  owl_global_set_buffercommand(&g, "loopwrite");
    282334}
    283335
     
    397449  if (owl_global_is_logging(&g)) {
    398450    owl_log_outgoing_aim(to, owl_editwin_get_text(owl_global_get_typwin(&g)));
     451  }
     452}
     453
     454void owl_function_loopwrite()
     455{
     456  owl_message *m;
     457
     458  /* create a message and put it on the message queue.  This simulates
     459   * an incoming message */
     460  m=owl_malloc(sizeof(owl_message));
     461  owl_message_create_loopback(m, owl_editwin_get_text(owl_global_get_typwin(&g)));
     462  owl_message_set_direction_out(m);
     463  owl_global_messagequeue_addmsg(&g, m);
     464
     465  /* display the message as an outgoing message in the receive window */
     466  if (owl_global_is_displayoutgoing(&g)) {
     467    owl_function_make_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g)));
     468  }
     469
     470  /* fake a makemsg */
     471  owl_function_makemsg("loopback message sent");
     472
     473  /* log it if we have logging turned on */
     474  if (owl_global_is_logging(&g)) {
     475    owl_log_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g)));
    399476  }
    400477}
     
    10791156  } else if (!strncmp(buff, "aimwrite ", 9)) {
    10801157    owl_function_aimwrite(buff+9);
     1158  } else if (!strncmp(buff, "loopwrite", 9) || !strncmp(buff, "loopwrite ", 10)) {
     1159    owl_function_loopwrite();
    10811160  } else if (!strncmp(buff, "aimlogin ", 9)) {
    10821161    ptr=owl_sprintf("%s %s", buff, owl_global_get_response(&g));
    10831162    owl_function_command(ptr);
    10841163    owl_free(ptr);
     1164  } else {
     1165    owl_function_error("Internal error: invalid buffercommand %s", buff);
    10851166  }
    10861167}
     
    12821363
    12831364  owl_fmtext_append_normal(&fm, "  Type      : ");
    1284   owl_fmtext_append_bold(&fm, owl_message_type_to_string(m));
     1365  owl_fmtext_append_bold(&fm, owl_message_get_type(m));
    12851366  owl_fmtext_append_normal(&fm, "\n");
    12861367
     
    19462027  owl_context_set_editline(owl_global_get_context(&g), tw);
    19472028  owl_function_activate_keymap("editline");
    1948    
    19492029}
    19502030
  • logging.c

    r15283bb r37eab7f  
    5555}
    5656
    57 void owl_log_outgoing_aim(char *to, char *text) {
     57void owl_log_outgoing_aim(char *to, char *text)
     58{
    5859  FILE *file;
    5960  char filename[MAXPATHLEN], *logpath;
     
    6162
    6263  tobuff=owl_sprintf("aim:%s", to);
     64
     65  /* expand ~ in path names */
     66  logpath = owl_util_substitute(owl_global_get_logpath(&g), "~",
     67                                owl_global_get_homedir(&g));
     68
     69  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
     70  file=fopen(filename, "a");
     71  if (!file) {
     72    owl_function_error("Unable to open file for outgoing logging");
     73    owl_free(logpath);
     74    return;
     75  }
     76  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
     77  if (text[strlen(text)-1]!='\n') {
     78    fprintf(file, "\n");
     79  }
     80  fclose(file);
     81
     82  snprintf(filename, MAXPATHLEN, "%s/all", logpath);
     83  owl_free(logpath);
     84  file=fopen(filename, "a");
     85  if (!file) {
     86    owl_function_error("Unable to open file for outgoing logging");
     87    return;
     88  }
     89  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
     90  if (text[strlen(text)-1]!='\n') {
     91    fprintf(file, "\n");
     92  }
     93  fclose(file);
     94
     95  owl_free(tobuff);
     96}
     97
     98void owl_log_outgoing_loopback(char *text)
     99{
     100  FILE *file;
     101  char filename[MAXPATHLEN], *logpath;
     102  char *tobuff;
     103
     104  tobuff=owl_sprintf("loopback:%s", "loppback");
    63105
    64106  /* expand ~ in path names */
     
    142184    /* we do not yet handle chat rooms */
    143185    from=frombuff=owl_sprintf("aim:%s", owl_message_get_sender(m));
     186  } else if (owl_message_is_type_loopback(m)) {
     187    from=frombuff=owl_strdup("loopback");
    144188  } else {
    145189    from=frombuff=owl_strdup("unknown");
     
    220264    if (owl_message_is_login(m)) fprintf(file, "LOGIN\n\n");
    221265    if (owl_message_is_logout(m)) fprintf(file, "LOGOUT\n\n");
    222   }
     266  } else {
     267    fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m));
     268    fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));
     269    fprintf(file, "%s\n\n", owl_message_get_body(m));
     270  }
     271
    223272  fclose(file);
    224273
     
    245294      if (owl_message_is_login(m)) fprintf(allfile, "LOGIN\n\n");
    246295      if (owl_message_is_logout(m)) fprintf(allfile, "LOGOUT\n\n");
     296    } else {
     297      fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m));
     298      fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));
     299      fprintf(file, "%s\n\n", owl_message_get_body(m));
    247300    }
    248301    fclose(allfile);
  • mainwin.c

    rf2f9314 r37eab7f  
    33static const char fileIdent[] = "$Id$";
    44
    5 void owl_mainwin_init(owl_mainwin *mw) {
     5void owl_mainwin_init(owl_mainwin *mw)
     6{
    67  mw->curtruncated=0;
    78  mw->lastdisplayed=-1;
    89}
    910
    10 void owl_mainwin_redisplay(owl_mainwin *mw) {
     11void owl_mainwin_redisplay(owl_mainwin *mw)
     12{
    1113  owl_message *m;
    1214  int i, p, q, lines, isfull, viewsize;
     
    136138
    137139
    138 int owl_mainwin_is_curmsg_truncated(owl_mainwin *mw) {
     140int owl_mainwin_is_curmsg_truncated(owl_mainwin *mw)
     141{
    139142  if (mw->curtruncated) return(1);
    140143  return(0);
    141144}
    142145
    143 int owl_mainwin_is_last_msg_truncated(owl_mainwin *mw) {
     146int owl_mainwin_is_last_msg_truncated(owl_mainwin *mw)
     147{
    144148  if (mw->lasttruncated) return(1);
    145149  return(0);
    146150}
    147151
    148 int owl_mainwin_get_last_msg(owl_mainwin *mw) {
     152int owl_mainwin_get_last_msg(owl_mainwin *mw)
     153{
    149154  /* return the number of the last message displayed. -1 if none */
    150155  return(mw->lastdisplayed);
  • message.c

    rf4d0975 r37eab7f  
    313313}
    314314
     315void owl_message_set_type_loopback(owl_message *m)
     316{
     317  m->type=OWL_MESSAGE_TYPE_LOOPBACK;
     318}
     319
    315320void owl_message_set_type_zephyr(owl_message *m)
    316321{
     
    329334}
    330335
     336int owl_message_is_type_loopback(owl_message *m)
     337{
     338  if (m->type==OWL_MESSAGE_TYPE_LOOPBACK) return(1);
     339  return(0);
     340}
     341
    331342int owl_message_is_type_zephyr(owl_message *m)
    332343{
     
    345356  if (m->type==OWL_MESSAGE_TYPE_GENERIC) return(1);
    346357  return(0);
    347 }
    348 
    349 char *owl_message_type_to_string(owl_message *m)
    350 {
    351   if (m->type==OWL_MESSAGE_TYPE_ADMIN) return("admin");
    352   if (m->type==OWL_MESSAGE_TYPE_GENERIC) return("generic");
    353   if (m->type==OWL_MESSAGE_TYPE_ZEPHYR) return("zephyr");
    354   if (m->type==OWL_MESSAGE_TYPE_AIM) return("aim");
    355   if (m->type==OWL_MESSAGE_TYPE_JABBER) return("jabber");
    356   if (m->type==OWL_MESSAGE_TYPE_ICQ) return("icq");
    357   if (m->type==OWL_MESSAGE_TYPE_MSN) return("msn");
    358   return("unknown");
    359358}
    360359
     
    449448  return(m->hostname);
    450449}
    451 
    452450
    453451void owl_message_curs_waddstr(owl_message *m, WINDOW *win, int aline, int bline, int acol, int bcol, int color)
     
    597595  case OWL_MESSAGE_TYPE_MSN:
    598596    return("msn");
     597  case OWL_MESSAGE_TYPE_LOOPBACK:
     598    return("loopback");
    599599  default:
    600600    return("unknown");
     
    677677  owl_message_set_body(m, text);
    678678  owl_message_set_attribute(m, "adminheader", header); /* just a hack for now */
     679}
     680
     681/* caller should set the direction */
     682void owl_message_create_loopback(owl_message *m, char *text)
     683{
     684  owl_message_init(m);
     685  owl_message_set_type_loopback(m);
     686  owl_message_set_body(m, text);
     687  owl_message_set_sender(m, "loopback-sender");
     688  owl_message_set_recipient(m, "loopback-recipient");
     689  owl_message_set_isprivate(m);
    679690}
    680691
     
    817828}
    818829
    819 
    820830void owl_message_pretty_zsig(owl_message *m, char *buff)
    821831{
  • owl.h

    r15283bb r37eab7f  
    6565#define OWL_MESSAGE_TYPE_YAHOO      6
    6666#define OWL_MESSAGE_TYPE_MSN        7
     67#define OWL_MESSAGE_TYPE_LOOPBACK   8
    6768
    6869#define OWL_MESSAGE_DIRECTION_NONE  0
  • stylefunc.c

    rec6ff52 r37eab7f  
    199199   
    200200    owl_free(indent);
     201  } else {
     202    char *text, *header, *indent;
     203   
     204    text=owl_message_get_body(m);
     205    header=owl_sprintf("%s from: %s to: %s",
     206                       owl_message_get_type(m),
     207                       owl_message_get_sender(m),
     208                       owl_message_get_recipient(m));
     209   
     210    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     211    owl_text_indent(indent, text, OWL_MSGTAB);
     212    owl_fmtext_append_normal(fm, OWL_TABSTR);
     213    owl_fmtext_append_normal(fm, header);
     214    owl_fmtext_append_normal(fm, "\n");
     215    owl_fmtext_append_normal(fm, indent);
     216    if (text[strlen(text)-1]!='\n') {
     217      owl_fmtext_append_normal(fm, "\n");
     218    }
     219   
     220    owl_free(indent);
     221    owl_free(header);
    201222  }
    202223}
     
    395416   
    396417    owl_free(indent);
     418  } else {
     419    char *text, *header, *indent;
     420   
     421    text=owl_message_get_body(m);
     422    header=owl_sprintf("%s from: %s to: %s",
     423                       owl_message_get_type(m),
     424                       owl_message_get_sender(m),
     425                       owl_message_get_recipient(m));
     426   
     427    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     428    owl_text_indent(indent, text, OWL_MSGTAB);
     429    owl_fmtext_append_normal(fm, OWL_TABSTR);
     430    owl_fmtext_append_normal(fm, header);
     431    owl_fmtext_append_normal(fm, "\n");
     432    owl_fmtext_append_normal(fm, indent);
     433    if (text[strlen(text)-1]!='\n') {
     434      owl_fmtext_append_normal(fm, "\n");
     435    }
     436   
     437    owl_free(indent);
     438    owl_free(header);
    397439  }
    398440}
     
    526568    owl_fmtext_append_normal(fm, "\n");
    527569    if (tmp) owl_free(tmp);
    528   }
     570  } else {
     571    owl_fmtext_append_spaces(fm, OWL_TAB);
     572    owl_fmtext_append_normal(fm, "< LOOPBACK                                     ");
     573   
     574    tmp=owl_strdup(owl_message_get_body(m));
     575    owl_util_tr(tmp, '\n', ' ');
     576    owl_fmtext_append_normal(fm, tmp);
     577    owl_fmtext_append_normal(fm, "\n");
     578    if (tmp) owl_free(tmp);
     579  }   
    529580
    530581}
     
    736787   
    737788    owl_free(indent);
     789  } else {
     790
    738791  }
    739792}
Note: See TracChangeset for help on using the changeset viewer.