Changeset d09e5a1 for functions.c


Ignore:
Timestamp:
May 31, 2003, 3:33:42 PM (18 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
5e53c4a
Parents:
c86a35c
Message:
Added libfaim
Added basic AIM support, including the "aimlogin", "aimwrite" and
   "aimlogout" commands
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r801c7cb rd09e5a1  
    1010#include <sys/wait.h>
    1111#include <errno.h>
     12#include <signal.h>
    1213#include "owl.h"
    1314
     
    124125}
    125126
     127void owl_function_make_outgoing_aim(char *body, char *to)
     128{
     129  owl_message *m;
     130  int followlast;
     131 
     132  followlast=owl_global_should_followlast(&g);
     133
     134  /* create the message */
     135  m=owl_malloc(sizeof(owl_message));
     136  owl_message_create_aim(m, owl_global_get_aim_screenname(&g), body);
     137  owl_message_set_recipient(m, to);
     138  owl_message_set_direction_out(m);
     139
     140  /* add it to the global list and current view */
     141  owl_messagelist_append_element(owl_global_get_msglist(&g), m);
     142  owl_view_consider_message(owl_global_get_current_view(&g), m);
     143
     144  if (followlast) owl_function_lastmsg_noredisplay();
     145
     146  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     147  if (owl_popwin_is_active(owl_global_get_popwin(&g))) {
     148    owl_popwin_refresh(owl_global_get_popwin(&g));
     149  }
     150 
     151  wnoutrefresh(owl_global_get_curs_recwin(&g));
     152  owl_global_set_needrefresh(&g);
     153}
     154
    126155void owl_function_zwrite_setup(char *line)
    127156{
     
    166195}
    167196
     197void owl_function_aimwrite_setup(char *line)
     198{
     199  owl_editwin *e;
     200  char buff[1024];
     201
     202  /* check the arguments */
     203
     204  /* create and setup the editwin */
     205  e=owl_global_get_typwin(&g);
     206  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g));
     207
     208  if (!owl_global_get_lockout_ctrld(&g)) {
     209    owl_function_makemsg("Type your message below.  End with ^D or a dot on a line by itself.  ^C will quit.");
     210  } else {
     211    owl_function_makemsg("Type your message below.  End with a dot on a line by itself.  ^C will quit.");
     212  }
     213
     214  owl_editwin_clear(e);
     215  owl_editwin_set_dotsend(e);
     216  strcpy(buff, "----> ");
     217  strcat(buff, line);
     218  strcat(buff, "\n");
     219  owl_editwin_set_locktext(e, buff);
     220
     221  /* make it active */
     222  owl_global_set_typwin_active(&g);
     223}
     224
     225
     226
    168227void owl_function_zcrypt_setup(char *line)
    169228{
     
    241300  owl_zwrite_free(&z);
    242301}
     302
     303
     304void owl_function_aimwrite(char *to)
     305{
     306  /*  send the message */
     307  owl_aim_send_im(to, owl_editwin_get_text(owl_global_get_typwin(&g)));
     308  owl_function_makemsg("AIM message sent.");
     309
     310  /* display the message as an outgoing message in the receive window */
     311  if (owl_global_is_displayoutgoing(&g)) {
     312    owl_function_make_outgoing_aim(owl_editwin_get_text(owl_global_get_typwin(&g)), to);
     313  }
     314
     315  /* not yet */
     316#if 0
     317  /* log it if we have logging turned on */
     318  if (owl_global_is_logging(&g)) {
     319    owl_log_outgoing(to, owl_editwin_get_text(owl_global_get_typwin(&g)));
     320  }
     321#endif
     322}
     323
    243324
    244325
     
    619700  ret = owl_config_execute("owl::shutdown();");
    620701  if (ret) owl_free(ret);
     702
     703  /* signal our child process, if any */
     704  if (owl_global_get_newmsgproc_pid(&g)) {
     705    kill(owl_global_get_newmsgproc_pid(&g), SIGHUP);
     706  }
    621707
    622708  /* final clean up */
     
    10051091  buff=owl_global_get_buffercommand(&g);
    10061092  if (!strncmp(buff, "zwrite ", 7)) {
    1007 
    10081093    owl_function_zwrite(buff);
     1094  } else if (!strncmp(buff, "aimwrite ", 9)) {
     1095    owl_function_aimwrite(buff+9);
    10091096  }
    10101097}
     
    11931280  } else if (owl_message_is_type_generic(m)) {
    11941281    owl_fmtext_append_normal(&fm, "Type      : generic\n");
     1282  } else if (owl_message_is_type_aim(m)) {
     1283    owl_fmtext_append_normal(&fm, "Type      : aim\n");
    11951284  } else {
    11961285    owl_fmtext_append_normal(&fm, "Type      : unknown\n");
     
    16801769    }
    16811770
    1682     /* for now we disable replies to zcrypt messages, since we can't
    1683        support an encrypted reply */
    1684     if (!strcasecmp(owl_message_get_opcode(m), "crypt")) {
    1685       owl_function_makemsg("Replies to zcrypt messages are not enabled in this release");
     1771    /* admin */
     1772    if (owl_message_is_type_admin(m)) {
     1773      owl_function_makemsg("You cannot reply to an admin message");
    16861774      return;
    16871775    }
    16881776
    1689     if (owl_message_is_direction_out(m)) {
    1690       owl_function_zwrite_setup(owl_message_get_zwriteline(m));
    1691       owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m));
    1692     } else if (owl_message_is_type_admin(m)) {
    1693       owl_function_makemsg("You cannot reply to an admin message");
    1694     } else {
     1777    /* zephyr */
     1778    if (owl_message_is_type_zephyr(m)) {
     1779      /* for now we disable replies to zcrypt messages, since we can't
     1780         support an encrypted reply */
     1781      if (!strcasecmp(owl_message_get_opcode(m), "crypt")) {
     1782        owl_function_makemsg("Replies to zcrypt messages are not enabled in this release");
     1783        return;
     1784      }
     1785
     1786      if (owl_message_is_direction_out(m)) {
     1787        owl_function_zwrite_setup(owl_message_get_zwriteline(m));
     1788        owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m));
     1789        return;
     1790      }
     1791     
    16951792      if (owl_message_is_login(m)) {
    16961793        class="MESSAGE";
     
    17141811        }
    17151812      }
    1716      
     1813       
    17171814      /* create the command line */
    17181815      buff = owl_strdup("zwrite");
     
    17451842      }
    17461843      if (cc) owl_free(cc);
    1747 
    1748       if (enter) {
    1749         owl_history *hist = owl_global_get_cmd_history(&g);
    1750         owl_history_store(hist, buff);
    1751         owl_history_reset(hist);
    1752         owl_function_command_norv(buff);
    1753       } else {
    1754         owl_function_start_command(buff);
    1755       }
    1756       owl_free(buff);
    1757     }
     1844    }
     1845
     1846    /* aim */
     1847    if (owl_message_is_type_aim(m)) {
     1848      buff=owl_sprintf("aimwrite %s", owl_message_get_sender(m));
     1849    }
     1850
     1851    if (enter) {
     1852      owl_history *hist = owl_global_get_cmd_history(&g);
     1853      owl_history_store(hist, buff);
     1854      owl_history_reset(hist);
     1855      owl_function_command_norv(buff);
     1856    } else {
     1857      owl_function_start_command(buff);
     1858    }
     1859    owl_free(buff);
    17581860  }
    17591861}
Note: See TracChangeset for help on using the changeset viewer.