Changeset ec6ff52


Ignore:
Timestamp:
Oct 17, 2003, 5:16:25 PM (17 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:
836ea3a3
Parents:
a053de8
Message:
Added the 'show errors' command
Added the error queue
Converted most makemsg's to error instead
Started writing an internal VT style (far from done)
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • Makefile.in

    rf4d0975 rec6ff52  
    2323     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
    2424     keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
    25      aim.c buddy.c buddylist.c timer.c style.c stylefunc.c
     25     aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c
    2626OWL_SRC = owl.c
    2727TESTER_SRC = tester.c
  • aim.c

    r257a22f rec6ff52  
    2626};
    2727
    28 /*
    2928static char *msgerrreasons[] = {
    3029        "Invalid error",
     
    5554};
    5655static int msgerrreasonslen = 25;
    57 */
    5856
    5957static void faimtest_debugcb(aim_session_t *sess, int level, const char *format, va_list va);
     
    245243
    246244  /* I don't know how to check for an error yet */
    247   return(0);
     245  return(ret);
    248246}
    249247
     
    15981596 
    15991597  /* printf("snac threw error (reason 0x%04x: %s)\n", reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */
     1598  owl_function_makemsg(msgerrreasons[reason]);
    16001599 
    16011600  return 1;
  • commands.c

    r2404c3a rec6ff52  
    585585              "show version\n"
    586586              "show view [<view>]\n"
    587               "show status\n",
     587              "show status\n"
     588              "show errors\n",
    588589
    589590              "Show colors will display a list of valid colors for the\n"
     
    600601              "for formatting messages.\n\n"
    601602              "Show variables will list the names of all variables.\n\n"
     603              "Show errors will show a list of errors ecountered by Owl.\n\n"
    602604              "SEE ALSO: filter, view, alias, bindkey, help\n"),
    603605 
     
    19221924  } else if (!strcmp(argv[1], "status")) {
    19231925    owl_function_status();
     1926  } else if (!strcmp(argv[1], "errors")) {
     1927    owl_function_showerrs();
    19241928  } else {
    19251929    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
  • functions.c

    r8a54409 rec6ff52  
    6767  v=owl_global_get_current_view(&g);
    6868  if (viewname && strcmp(viewname, owl_view_get_name(v))) {
    69     owl_function_makemsg("No view named '%s'", viewname);
     69    owl_function_error("No view named '%s'", viewname);
    7070    return;
    7171  }
     
    218218  ret=owl_zwrite_create_from_line(&z, line);
    219219  if (ret) {
    220     owl_function_makemsg("Error in zwrite arugments");
     220    owl_function_error("Error in zwrite arugments");
    221221    owl_zwrite_free(&z);
    222222    return;
     
    343343  ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
    344344  if (ret) {
    345     owl_function_makemsg("Error in zcrypt, possibly no key found.  Message not sent.");
     345    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
    346346    owl_function_beep();
    347347    owl_free(cryptmsg);
     
    379379void owl_function_aimwrite(char *to)
    380380{
     381  int ret;
     382 
    381383  /*  send the message */
    382   owl_aim_send_im(to, owl_editwin_get_text(owl_global_get_typwin(&g)));
    383   owl_function_makemsg("AIM message sent.");
     384  ret=owl_aim_send_im(to, owl_editwin_get_text(owl_global_get_typwin(&g)));
     385  if (!ret) {
     386    owl_function_makemsg("AIM message sent.");
     387  } else {
     388    owl_function_error("Could not send AIM message.");
     389  }
    384390
    385391  /* display the message as an outgoing message in the receive window */
     
    410416    f=owl_global_get_filter(&g, filter);
    411417    if (!f) {
    412       owl_function_makemsg("No %s filter defined", filter);
     418      owl_function_error("No %s filter defined", filter);
    413419      return;
    414420    }
     
    434440
    435441  if (!found) {
    436     owl_function_makemsg("already at last%s message%s%s",
     442    owl_function_error("already at last%s message%s%s",
    437443                         skip_deleted?" non-deleted":"",
    438444                         filter?" in ":"", filter?filter:"");
     
    460466    f=owl_global_get_filter(&g, filter);
    461467    if (!f) {
    462       owl_function_makemsg("No %s filter defined", filter);
     468      owl_function_error("No %s filter defined", filter);
    463469      return;
    464470    }
     
    483489
    484490  if (!found) {
    485     owl_function_makemsg("already at first%s message%s%s",
     491    owl_function_error("already at first%s message%s%s",
    486492                         skip_deleted?" non-deleted":"",
    487493                         filter?" in ":"", filter?filter:"");
     
    538544  /* bail if there's no current message */
    539545  if (owl_view_get_size(v) < 1) {
    540     owl_function_makemsg("No current message to delete");
     546    owl_function_error("No current message to delete");
    541547    return;
    542548  }
     
    565571 
    566572  if (owl_view_get_size(v) < 1) {
    567     owl_function_makemsg("No current message to undelete");
     573    owl_function_error("No current message to undelete");
    568574    return;
    569575  }
     
    677683  } else {
    678684    owl_function_beep();
    679     owl_function_makemsg("Already full left");
     685    owl_function_error("Already full left");
    680686  }
    681687}
     
    697703    owl_function_makemsg("Subscribed to messages from file.");
    698704  } else if (ret==-1) {
    699     owl_function_makemsg("Could not open file.");
     705    owl_function_error("Could not open file.");
    700706  } else {
    701     owl_function_makemsg("Error subscribing to messages from file.");
     707    owl_function_error("Error subscribing to messages from file.");
    702708  }
    703709}
     
    713719    owl_function_makemsg("Subscribed to login messages from file.");
    714720  } else if (ret==-1) {
    715     owl_function_makemsg("Could not open file for login subscriptions.");
     721    owl_function_error("Could not open file for login subscriptions.");
    716722  } else {
    717     owl_function_makemsg("Error subscribing to login messages from file.");
     723    owl_function_error("Error subscribing to login messages from file.");
    718724  }
    719725}
     
    776782}
    777783
    778 void owl_function_makemsg(char *fmt, ...)
    779 {
    780   va_list ap;
    781   char buff[2048];
    782 
    783   if (!owl_global_get_curs_msgwin(&g)) return;
    784 
    785   va_start(ap, fmt);
    786   werase(owl_global_get_curs_msgwin(&g));
    787  
    788   vsnprintf(buff, 2048, fmt, ap);
    789   owl_function_debugmsg("makemsg: %s", buff);
    790   waddstr(owl_global_get_curs_msgwin(&g), buff); 
    791   wnoutrefresh(owl_global_get_curs_msgwin(&g));
    792   owl_global_set_needrefresh(&g);
    793   va_end(ap);
    794 }
    795 
    796 void owl_function_errormsg(char *fmt, ...)
    797 {
    798   va_list ap;
    799   char buff[2048];
    800 
    801   if (!owl_global_get_curs_msgwin(&g)) return;
    802 
    803   va_start(ap, fmt);
    804   werase(owl_global_get_curs_msgwin(&g));
    805  
    806   vsnprintf(buff, 2048, fmt, ap);
    807   owl_function_debugmsg("ERROR: %s", buff);
    808   waddstr(owl_global_get_curs_msgwin(&g), buff); 
    809   waddstr(owl_global_get_curs_msgwin(&g), "ERROR: "); 
    810   wnoutrefresh(owl_global_get_curs_msgwin(&g));
    811   owl_global_set_needrefresh(&g);
    812   va_end(ap);
    813 }
    814 
    815784void owl_function_openurl()
    816785{
     
    824793
    825794  if (webbrowser < 0 || webbrowser == OWL_WEBBROWSER_NONE) {
    826     owl_function_makemsg("No browser selected");
     795    owl_function_error("No browser selected");
    827796    return;
    828797  }
     
    833802
    834803  if (!m || owl_view_get_size(v)==0) {
    835     owl_function_makemsg("No current message selected");
     804    owl_function_error("No current message selected");
    836805    return;
    837806  }
     
    882851  } else {
    883852    owl_function_beep();
    884     owl_function_makemsg("Could not find URL to open.");
     853    owl_function_error("Could not find URL to open.");
    885854    return;
    886855  }
     
    890859    if (*ptr1 == '"' || *ptr1 == '\\') {
    891860      owl_function_beep();
    892       owl_function_makemsg("URL contains invalid characters.");
     861      owl_function_error("URL contains invalid characters.");
    893862      return;
    894863    }
     
    11621131  ret=owl_zephyr_sub(class, inst, recip);
    11631132  if (ret) {
    1164     owl_function_makemsg("Error subscribing.");
     1133    owl_function_error("Error subscribing.");
    11651134  } else {
    11661135    owl_function_makemsg("Subscribed.");
     
    11741143  ret=owl_zephyr_unsub(class, inst, recip);
    11751144  if (ret) {
    1176     owl_function_makemsg("Error subscribing.");
     1145    owl_function_error("Error subscribing.");
    11771146  } else {
    11781147    owl_function_makemsg("Unsubscribed.");
     
    12781247  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
    12791248  if (!m || owl_view_get_size(v)==0) {
    1280     owl_function_makemsg("No message selected\n");
     1249    owl_function_error("No message selected\n");
    12811250    return;
    12821251  }
     
    14431412
    14441413  if (!m || owl_view_get_size(v)==0) {
    1445     owl_function_makemsg("No current message");
     1414    owl_function_error("No current message");
    14461415    return;
    14471416  }
     
    14721441    /* Bail if the curmsg isn't the last one displayed */
    14731442    if (curmsg != owl_mainwin_get_last_msg(owl_global_get_mainwin(&g))) {
    1474       owl_function_makemsg("The entire message is already displayed");
     1443      owl_function_error("The entire message is already displayed");
    14751444      return;
    14761445    }
     
    14781447    /* Bail if we're not truncated */
    14791448    if (!owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) {
    1480       owl_function_makemsg("The entire message is already displayed");
     1449      owl_function_error("The entire message is already displayed");
    14811450      return;
    14821451    }
     
    16471616    owl_global_set_needrefresh(&g);
    16481617  } else {
    1649     owl_function_makemsg("No message with id %d: unable to mark for (un)delete",id);
     1618    owl_function_error("No message with id %d: unable to mark for (un)delete",id);
    16501619  }
    16511620}
     
    16641633  f=owl_global_get_filter(&g, "trash");
    16651634  if (!f) {
    1666     owl_function_makemsg("No trash filter defined");
     1635    owl_function_error("No trash filter defined");
    16671636    return;
    16681637  }
     
    17871756 
    17881757  if (owl_view_get_size(owl_global_get_current_view(&g))==0) {
    1789     owl_function_makemsg("No message selected");
     1758    owl_function_error("No message selected");
    17901759  } else {
    17911760    char *class, *inst, *to, *cc=NULL;
     
    17931762    m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g));
    17941763    if (!m) {
    1795       owl_function_makemsg("No message selected");
     1764      owl_function_error("No message selected");
    17961765      return;
    17971766    }
     
    18011770    if (f) {
    18021771      if (owl_filter_message_match(f, m)) {
    1803         owl_function_makemsg("Sorry, replies to this message have been disabled by the reply-lockout filter");
     1772        owl_function_error("Sorry, replies to this message have been disabled by the reply-lockout filter");
    18041773        return;
    18051774      }
     
    18081777    /* admin */
    18091778    if (owl_message_is_type_admin(m)) {
    1810       owl_function_makemsg("You cannot reply to an admin message");
     1779      owl_function_error("You cannot reply to an admin message");
    18111780      return;
    18121781    }
     
    20041973
    20051974  if (argc<2) {
    2006     owl_function_makemsg("Wrong number of arguments to the exec command");
     1975    owl_function_error("Wrong number of arguments to the exec command");
    20071976    return NULL;
    20081977  }
     
    20472016
    20482017  if (argc<2) {
    2049     owl_function_makemsg("Wrong number of arguments to perl command");
     2018    owl_function_error("Wrong number of arguments to perl command");
    20502019    return NULL;
    20512020  }
     
    20932062  f=owl_global_get_filter(&g, filtname);
    20942063  if (!f) {
    2095     owl_function_makemsg("Unknown filter");
     2064    owl_function_error("Unknown filter %s", filtname);
    20962065    return;
    20972066  }
     
    21422111  f=owl_global_get_filter(&g, filtname);
    21432112  if (!f) {
    2144     owl_function_makemsg("Unknown filter");
     2113    owl_function_error("Unknown filter %s", filtname);
    21452114    return;
    21462115  }
     
    21722141
    21732142  if (argc < 2) {
    2174     owl_function_makemsg("Wrong number of arguments to filter command");
     2143    owl_function_error("Wrong number of arguments to filter command");
    21752144    return;
    21762145  }
     
    21802149  /* don't touch the all filter */
    21812150  if (!strcmp(argv[1], "all")) {
    2182     owl_function_makemsg("You may not change the 'all' filter.");
     2151    owl_function_error("You may not change the 'all' filter.");
    21832152    return;
    21842153  }
     
    21882157    f=owl_global_get_filter(&g, argv[1]);
    21892158    if (!f) {
    2190       owl_function_makemsg("The filter '%s' does not exist.", argv[1]);
     2159      owl_function_error("The filter '%s' does not exist.", argv[1]);
    21912160      return;
    21922161    }
     
    22022171  if (ret==-1) {
    22032172    owl_free(f);
    2204     owl_function_makemsg("Invalid filter syntax");
     2173    owl_function_error("Invalid filter syntax");
    22052174    return;
    22062175  }
     
    22622231  f=owl_global_get_filter(&g, name);
    22632232  if (!f) {
    2264     owl_function_makemsg("There is no filter with that name");
     2233    owl_function_error("There is no filter named %s", name);
    22652234    return;
    22662235  }
     
    25102479
    25112480  if (!m || owl_view_get_size(v)==0) {
    2512     owl_function_makemsg("No message selected\n");
     2481    owl_function_error("No message selected\n");
    25132482    return(NULL);
    25142483  }
     
    25712540
    25722541  if (!m || owl_view_get_size(v)==0) {
    2573     owl_function_makemsg("No message selected\n");
     2542    owl_function_error("No message selected\n");
    25742543    return;
    25752544  }
     
    25792548      || owl_message_is_loginout(m)
    25802549      || !owl_message_is_type_zephyr(m)) {
    2581     owl_function_makemsg("smartzpunt doesn't support this message type.");
     2550    owl_function_error("smartzpunt doesn't support this message type.");
    25822551    return;
    25832552  }
     
    25882557      || (!strcasecmp(mclass, "message") && !strcasecmp(minst, "personal"))
    25892558      || (type && (!minst || !*minst|| *minst==' '))) {
    2590     owl_function_makemsg("smartzpunt can't safely do this for <%s,%s>",
     2559    owl_function_error("smartzpunt can't safely do this for <%s,%s>",
    25912560                         mclass, minst);
    25922561  } else {
     
    26142583  f=owl_global_get_filter(&g, name);
    26152584  if (!f) {
    2616     owl_function_makemsg("Unknown filter");
     2585    owl_function_error("Unknown filter");
    26172586    return;
    26182587  }
     
    26202589  /* don't touch the all filter */
    26212590  if (!strcmp(name, "all")) {
    2622     owl_function_makemsg("You may not change the 'all' filter.");
     2591    owl_function_error("You may not change the 'all' filter.");
    26232592    return;
    26242593  }
     
    26832652  owl_free(buff);
    26842653  if (ret) {
    2685     owl_function_makemsg("Error creating filter for zpunt");
     2654    owl_function_error("Error creating filter for zpunt");
    26862655    owl_filter_free(f);
    26872656    return;
     
    27162685{
    27172686  if (!owl_keyhandler_activate(owl_global_get_keyhandler(&g), keymap)) {
    2718     owl_function_makemsg("Unable to activate keymap '%s'", keymap);
     2687    owl_function_error("Unable to activate keymap '%s'", keymap);
    27192688  }
    27202689}
     
    28182787 
    28192788  if (viewsize==0) {
    2820     owl_function_makemsg("No messages present");
     2789    owl_function_error("No messages present");
    28212790    return;
    28222791  }
     
    28322801  /* bounds check */
    28332802  if (start>=viewsize || start<0) {
    2834     owl_function_makemsg("No further matches found");
     2803    owl_function_error("No further matches found");
    28352804    return;
    28362805  }
     
    28562825  }
    28572826  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2858   owl_function_makemsg("No matches found");
     2827  owl_function_error("No matches found");
    28592828}
    28602829
     
    29182887      tmp=owl_global_get_homedir(&g);
    29192888      if (!tmp) {
    2920         owl_function_makemsg("Could not determine home directory");
     2889        owl_function_error("Could not determine home directory");
    29212890        return;
    29222891      }
     
    29292898    f=fopen(ourfile, "r");
    29302899    if (!f) {
    2931       owl_function_makemsg("Error opening file %s: %s",
     2900      owl_function_error("Error opening file %s: %s",
    29322901                           ourfile,
    29332902                           strerror(errno) ? strerror(errno) : "");
     
    29622931      ret=ZLocateUser(buff, &numlocs, ZAUTH);
    29632932      if (ret!=ZERR_NONE) {
    2964         owl_function_makemsg("Error getting location for %s", buff);
     2933        owl_function_error("Error getting location for %s", buff);
    29652934        continue;
    29662935      }
     
    30152984  file=fopen(filename, "w");
    30162985  if (!file) {
    3017     owl_function_makemsg("Error opening file");
     2986    owl_function_error("Error opening file");
    30182987    return;
    30192988  }
     
    31073076  file=fopen(filename, "a");
    31083077  if (!file) {
    3109     owl_function_makemsg("Error opening startupfile for new command");
     3078    owl_function_error("Error opening startupfile for new command");
    31103079    owl_free(filename);
    31113080    return;
     
    31633132  s=owl_global_get_style_by_name(&g, stylename);
    31643133  if (!s) {
    3165     owl_function_makemsg("No style named %s", stylename);
     3134    owl_function_error("No style named %s", stylename);
    31663135    return;
    31673136  }
     
    31703139  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    31713140  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    3172  
    31733141}
    31743142
     
    31913159  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    31923160}
     3161
     3162void owl_function_error(char *fmt, ...)
     3163{
     3164  va_list ap;
     3165  char buff[2048], buff2[2048];
     3166  char *date;
     3167  time_t now;
     3168
     3169  now=time(NULL);
     3170  date=owl_strdup(ctime(&now));
     3171  date[strlen(date)-1]='\0';
     3172
     3173  va_start(ap, fmt);
     3174
     3175  vsnprintf(buff, 2048, fmt, ap);
     3176  sprintf(buff2, "%s %s", date, buff);
     3177  owl_function_debugmsg("ERROR: %s", buff);
     3178  if (owl_global_get_curs_msgwin(&g)) {
     3179    werase(owl_global_get_curs_msgwin(&g));
     3180    waddstr(owl_global_get_curs_msgwin(&g), buff); 
     3181    wnoutrefresh(owl_global_get_curs_msgwin(&g));
     3182    owl_global_set_needrefresh(&g);
     3183  }
     3184  owl_errqueue_append_err(owl_global_get_errqueue(&g), buff2);
     3185  va_end(ap);
     3186  owl_free(date);
     3187}
     3188
     3189void owl_function_showerrs()
     3190{
     3191  owl_fmtext fm;
     3192
     3193  owl_fmtext_init_null(&fm);
     3194  owl_fmtext_append_normal(&fm, "Errors:\n\n");
     3195  owl_errqueue_to_fmtext(owl_global_get_errqueue(&g), &fm);
     3196  owl_function_popless_fmtext(&fm);
     3197}
     3198
     3199void owl_function_makemsg(char *fmt, ...)
     3200{
     3201  va_list ap;
     3202  char buff[2048];
     3203
     3204  if (!owl_global_get_curs_msgwin(&g)) return;
     3205
     3206  va_start(ap, fmt);
     3207  werase(owl_global_get_curs_msgwin(&g));
     3208 
     3209  vsnprintf(buff, 2048, fmt, ap);
     3210  owl_function_debugmsg("makemsg: %s", buff);
     3211  waddstr(owl_global_get_curs_msgwin(&g), buff); 
     3212  wnoutrefresh(owl_global_get_curs_msgwin(&g));
     3213  owl_global_set_needrefresh(&g);
     3214  va_end(ap);
     3215}
  • global.c

    r2404c3a rec6ff52  
    102102  g->haveaim=0;
    103103  owl_global_set_no_doaimevents(g);
     104
     105  owl_errqueue_init(&(g->errqueue));
    104106}
    105107
     
    832834  return(&(g->aim_buddyinfo_timer));
    833835}
     836
     837owl_errqueue *owl_global_get_errqueue(owl_global *g)
     838{
     839  return(&(g->errqueue));
     840}
  • owl.c

    rf4d0975 rec6ff52  
    159159                            "Basic message formatting.");
    160160  owl_global_add_style(&g, s);
    161 
     161#if 0
     162  s=owl_malloc(sizeof(owl_style));
     163  owl_style_create_internal(s, "vt", &owl_stylefunc_vt,
     164                            "VT message formatting.");
     165  owl_global_add_style(&g, s);
     166#endif
    162167  s=owl_malloc(sizeof(owl_style));
    163168  owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline,
     
    544549  fprintf(stderr, "  -c      specify an alternate config file\n");
    545550  fprintf(stderr, "  -t      set the tty name\n");
    546  
    547551}
  • owl.h

    rc5f3b46 rec6ff52  
    2121static const char owl_h_fileIdent[] = "$Id$";
    2222
    23 #define OWL_VERSION         2.0.8
    24 #define OWL_VERSION_STRING "2.0.8"
     23#define OWL_VERSION         2.0.9-pre-1
     24#define OWL_VERSION_STRING "2.0.9-pre-1"
    2525
    2626#define OWL_DEBUG 0
     
    408408} owl_timer;
    409409
     410typedef struct _owl_errqueue {
     411  owl_list errlist;
     412} owl_errqueue;
     413
    410414typedef struct _owl_global {
    411415  owl_mainwin mw;
     
    419423  owl_cmddict cmds;
    420424  owl_context ctx;
     425  owl_errqueue errqueue;
    421426  int lines, cols;
    422427  int curmsg, topmsg;
  • stylefunc.c

    r03955f3 rec6ff52  
    529529
    530530}
     531
     532void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
     533{
     534#ifdef HAVE_LIBZEPHYR
     535  char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];
     536  owl_fmtext fm_first, fm_other, fm_tmp;
     537  ZNotice_t *n;
     538#endif
     539  char *sender, *hostname, *timestr, *classinst1, *classinst2;
     540
     541  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     542#ifdef HAVE_LIBZEPHYR
     543    n=owl_message_get_notice(m);
     544
     545    /* get the body */
     546    body=owl_malloc(strlen(owl_message_get_body(m))+30);
     547    strcpy(body, owl_message_get_body(m));
     548   
     549    /* add a newline if we need to */
     550    if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
     551      strcat(body, "\n");
     552    }
     553
     554    owl_fmtext_init_null(&fm_tmp);
     555    owl_fmtext_append_ztext(&fm_tmp, body);
     556    owl_fmtext_init_null(&fm_first);
     557    owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
     558
     559    /* do the indenting into indent */
     560    indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
     561    owl_text_indent(indent, body, 31);
     562
     563    owl_fmtext_free(&fm_tmp);
     564    owl_fmtext_init_null(&fm_tmp);
     565    owl_fmtext_append_ztext(&fm_tmp, indent);
     566    owl_fmtext_init_null(&fm_other);
     567    owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
     568    owl_fmtext_free(&fm_tmp);
     569   
     570    /* edit the from addr for printing */
     571    strcpy(frombuff, owl_message_get_sender(m));
     572    ptr=strchr(frombuff, '@');
     573    if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
     574      *ptr='\0';
     575    }
     576    sender=owl_sprintf("%-9.9s", frombuff);
     577
     578    hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
     579    timestr=owl_strdup("00:00");
     580    classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
     581    classinst2=owl_sprintf("%-9.9s", classinst1);
     582   
     583    /* set the message for printing */
     584    owl_fmtext_append_normal(fm, OWL_TABSTR);
     585   
     586    if (owl_message_is_ping(m) && owl_message_is_private(m)) {
     587      owl_fmtext_append_bold(fm, "PING");
     588      owl_fmtext_append_normal(fm, " from ");
     589      owl_fmtext_append_bold(fm, frombuff);
     590      owl_fmtext_append_normal(fm, "\n");
     591    } else if (owl_message_is_loginout(m)) {
     592      char *ptr, *host, *tty;
     593      int len;
     594
     595      ptr=owl_zephyr_get_field(n, 1, &len);
     596      host=owl_malloc(len+10);
     597      strncpy(host, ptr, len);
     598      host[len]='\0';
     599
     600      ptr=owl_zephyr_get_field(n, 3, &len);
     601      tty=owl_malloc(len+10);
     602      strncpy(tty, ptr, len);
     603      tty[len]='\0';
     604     
     605      if (owl_message_is_login(m)) {
     606        owl_fmtext_append_bold(fm, "LOGIN");
     607      } else if (owl_message_is_logout(m)) {
     608        owl_fmtext_append_bold(fm, "LOGOUT");
     609      }
     610      owl_fmtext_append_normal(fm, " for ");
     611      ptr=short_zuser(owl_message_get_instance(m));
     612      owl_fmtext_append_bold(fm, ptr);
     613      owl_free(ptr);
     614      owl_fmtext_append_normal(fm, " at ");
     615      owl_fmtext_append_normal(fm, host);
     616      owl_fmtext_append_normal(fm, " ");
     617      owl_fmtext_append_normal(fm, tty);
     618      owl_fmtext_append_normal(fm, "\n");
     619
     620      owl_free(host);
     621      owl_free(tty);
     622    } else {
     623      owl_fmtext_append_normal(fm, sender);
     624      owl_fmtext_append_normal(fm, "|");
     625      owl_fmtext_append_normal(fm, hostname);
     626      owl_fmtext_append_normal(fm, " ");
     627      owl_fmtext_append_normal(fm, timestr);
     628      owl_fmtext_append_normal(fm, " ");
     629      owl_fmtext_append_normal(fm, classinst2);
     630
     631      owl_fmtext_append_normal(fm, "   ");
     632      owl_fmtext_append_fmtext(fm, &fm_first);
     633      owl_fmtext_append_fmtext(fm, &fm_other);
     634
     635      owl_fmtext_free(&fm_other);
     636      owl_fmtext_free(&fm_first);
     637     
     638      /* make private messages bold for smaat users */
     639      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
     640        if (owl_message_is_personal(m)) {
     641          owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
     642        }
     643      }
     644    }
     645
     646    owl_free(sender);
     647    owl_free(hostname);
     648    owl_free(timestr);
     649    owl_free(classinst1);
     650    owl_free(classinst2);
     651   
     652    owl_free(body);
     653    owl_free(indent);
     654#endif
     655  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
     656    char *indent, *text, *zsigbuff, *foo;
     657   
     658    text=owl_message_get_body(m);
     659   
     660    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     661    owl_text_indent(indent, text, OWL_MSGTAB);
     662    owl_fmtext_append_normal(fm, OWL_TABSTR);
     663    owl_fmtext_append_normal(fm, "Zephyr sent to ");
     664    foo=short_zuser(owl_message_get_recipient(m));
     665    owl_fmtext_append_normal(fm, foo);
     666    owl_free(foo);
     667    owl_fmtext_append_normal(fm, "  (Zsig: ");
     668   
     669    zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
     670    owl_message_pretty_zsig(m, zsigbuff);
     671    owl_fmtext_append_ztext(fm, zsigbuff);
     672    owl_free(zsigbuff);
     673   
     674    owl_fmtext_append_normal(fm, ")");
     675    owl_fmtext_append_normal(fm, "\n");
     676    owl_fmtext_append_ztext(fm, indent);
     677    if (text[strlen(text)-1]!='\n') {
     678      owl_fmtext_append_normal(fm, "\n");
     679    }
     680   
     681    owl_free(indent);
     682  } else if (owl_message_is_type_aim(m)) {
     683    char *indent;
     684   
     685    if (owl_message_is_loginout(m)) {
     686      owl_fmtext_append_normal(fm, OWL_TABSTR);
     687      if (owl_message_is_login(m)) {
     688        owl_fmtext_append_bold(fm, "AIM LOGIN");
     689      } else {
     690        owl_fmtext_append_bold(fm, "AIM LOGOUT");
     691      }
     692      owl_fmtext_append_normal(fm, " for ");
     693      owl_fmtext_append_normal(fm, owl_message_get_sender(m));
     694      owl_fmtext_append_normal(fm, "\n");
     695    } else if (owl_message_is_direction_in(m)) {
     696      indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
     697      owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
     698      owl_fmtext_append_bold(fm, OWL_TABSTR);
     699      owl_fmtext_append_bold(fm, "AIM from ");
     700      owl_fmtext_append_bold(fm, owl_message_get_sender(m));
     701      owl_fmtext_append_bold(fm, "\n");
     702      owl_fmtext_append_bold(fm, indent);
     703      if (indent[strlen(indent)-1]!='\n') {
     704        owl_fmtext_append_normal(fm, "\n");
     705      }
     706      owl_free(indent);
     707    } else if (owl_message_is_direction_out(m)) {
     708      indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
     709      owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
     710      owl_fmtext_append_normal(fm, OWL_TABSTR);
     711      owl_fmtext_append_normal(fm, "AIM sent to ");
     712      owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
     713      owl_fmtext_append_normal(fm, "\n");
     714      owl_fmtext_append_ztext(fm, indent);
     715      if (indent[strlen(indent)-1]!='\n') {
     716        owl_fmtext_append_normal(fm, "\n");
     717      }
     718      owl_free(indent);
     719    }
     720  } else if (owl_message_is_type_admin(m)) {
     721    char *text, *header, *indent;
     722   
     723    text=owl_message_get_body(m);
     724    header=owl_message_get_attribute_value(m, "adminheader");
     725   
     726    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     727    owl_text_indent(indent, text, OWL_MSGTAB);
     728    owl_fmtext_append_normal(fm, OWL_TABSTR);
     729    owl_fmtext_append_bold(fm, "OWL ADMIN ");
     730    owl_fmtext_append_ztext(fm, header);
     731    owl_fmtext_append_normal(fm, "\n");
     732    owl_fmtext_append_ztext(fm, indent);
     733    if (text[strlen(text)-1]!='\n') {
     734      owl_fmtext_append_normal(fm, "\n");
     735    }
     736   
     737    owl_free(indent);
     738  }
     739}
  • zephyr.c

    rf1e629d rec6ff52  
    381381  ZFreeNotice(&notice);
    382382  if (ret!=ZERR_NONE) {
    383     owl_function_makemsg("Error sending zephyr");
     383    owl_function_error("Error sending zephyr");
    384384    return(ret);
    385385  }
     
    413413
    414414  if (retnotice->z_kind == SERVNAK) {
    415     owl_function_makemsg("Authorization failure sending zephyr");
     415    owl_function_error("Authorization failure sending zephyr");
    416416  } else if ((retnotice->z_kind != SERVACK) || !retnotice->z_message_len) {
    417     owl_function_makemsg("Detected server failure while receiving acknowledgement");
     417    owl_function_error("Detected server failure while receiving acknowledgement");
    418418  } else if (!strcmp(retnotice->z_message, ZSRVACK_SENT)) {
    419419    if (!strcasecmp(retnotice->z_opcode, "ping")) {
     
    422422               !strcasecmp(retnotice->z_class_inst, "personal")) {
    423423      tmp=short_zuser(retnotice->z_recipient);
    424       owl_function_makemsg("Message sent to %s.", tmp);
     424      owl_function_error("Message sent to %s.", tmp);
    425425      free(tmp);
    426426    } else {
    427       owl_function_makemsg("Message sent to -c %s -i %s\n", retnotice->z_class, retnotice->z_class_inst);
     427      owl_function_error("Message sent to -c %s -i %s\n", retnotice->z_class, retnotice->z_class_inst);
    428428    }
    429429  } else if (!strcmp(retnotice->z_message, ZSRVACK_NOTSENT)) {
    430430    if (strcasecmp(retnotice->z_class, "message")) {
    431       owl_function_makemsg("Not logged in or not subscribing to class %s, instance %s",
     431      owl_function_error("Not logged in or not subscribing to class %s, instance %s",
    432432                           retnotice->z_class, retnotice->z_class_inst);
    433433    } else {
    434434      tmp = short_zuser(retnotice->z_recipient);
    435       owl_function_makemsg("%s: Not logged in or subscribing to messages.",
     435      owl_function_error("%s: Not logged in or subscribing to messages.",
    436436                           tmp);
    437437      owl_free(tmp);
    438438    }
    439439  } else {
    440     owl_function_makemsg("Internal error on ack (%s)", retnotice->z_message);
     440    owl_function_error("Internal error on ack (%s)", retnotice->z_message);
    441441  }
    442442}
     
    532532  ret=ZLocateUser(user,&numlocs,auth?ZAUTH:ZNOAUTH);
    533533  if (ret != ZERR_NONE) {
    534     owl_function_makemsg("Error locating user");
     534    owl_function_error("Error locating user %s", user);
    535535  }
    536536
     
    568568  file=fopen(subsfile, "r");
    569569  if (!file) {
    570     owl_function_makemsg("Error opening file %s", subsfile);
     570    owl_function_error("Error opening file %s", subsfile);
    571571    owl_free(line);
    572572    return;
     
    574574  while (fgets(buff, LINE, file)!=NULL) {
    575575    if (!strcasecmp(buff, line)) {
    576       owl_function_makemsg("Subscription already present in %s", subsfile);
     576      owl_function_error("Subscription already present in %s", subsfile);
    577577      owl_free(line);
    578578      return;
     
    584584  file=fopen(subsfile, "a");
    585585  if (!file) {
    586     owl_function_makemsg("Error opening file %s for writing", subsfile);
     586    owl_function_error("Error opening file %s for writing", subsfile);
    587587    owl_free(line);
    588588    return;
     
    691691  owl_free(filename);
    692692  if (!file) {
    693     owl_function_makemsg("Error opening zephyr buddy file for append");
     693    owl_function_error("Error opening zephyr buddy file for append");
    694694    return;
    695695  }
Note: See TracChangeset for help on using the changeset viewer.