Changeset 37eab7f for functions.c


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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.