source: stylefunc.c @ 855dc8d

barnowl_perlaimdebianrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 855dc8d was bc9436f, checked in by Nelson Elhage <nelhage@mit.edu>, 14 years ago
Refactoring rendering the body of messages into a separate function. (The stylefunc code scares me)
  • Property mode set to 100644
File size: 23.3 KB
Line 
1#include "owl.h"
2
3static const char fileIdent[] = "$Id$";
4
5/* In all of these functions, 'fm' is expected to already be
6 * initialized.
7 */
8
9void owl_style_basic_format_body(owl_fmtext *fm, owl_message *m) {
10  char *indent, *body;
11
12  /* get the body */
13  body=owl_strdup(owl_message_get_body(m));
14  body=realloc(body, strlen(body)+30);
15
16  /* add a newline if we need to */
17  if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
18    strcat(body, "\n");
19  }
20
21  /* do the indenting into indent */
22  indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
23  owl_text_indent(indent, body, OWL_MSGTAB);
24  owl_fmtext_append_ztext(fm, indent);
25
26  owl_free(indent);
27  owl_free(body);
28}
29 
30void owl_stylefunc_basic(owl_fmtext *fm, owl_message *m)
31{
32#ifdef HAVE_LIBZEPHYR
33  char *ptr, *zsigbuff, frombuff[LINE];
34  ZNotice_t *n;
35#endif
36
37  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
38#ifdef HAVE_LIBZEPHYR
39    n=owl_message_get_notice(m);
40 
41    /* edit the from addr for printing */
42    strcpy(frombuff, owl_message_get_sender(m));
43    ptr=strchr(frombuff, '@');
44    if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
45      *ptr='\0';
46    }
47   
48    /* set the message for printing */
49    owl_fmtext_append_normal(fm, OWL_TABSTR);
50   
51    if (owl_message_is_ping(m)) {
52      owl_fmtext_append_bold(fm, "PING");
53      owl_fmtext_append_normal(fm, " from ");
54      owl_fmtext_append_bold(fm, frombuff);
55      owl_fmtext_append_normal(fm, "\n");
56    } else if (owl_message_is_loginout(m)) {
57      char *host, *tty;
58
59      host=owl_message_get_attribute_value(m, "loginhost");
60      tty=owl_message_get_attribute_value(m, "logintty");
61     
62      if (owl_message_is_login(m)) {
63        owl_fmtext_append_bold(fm, "LOGIN");
64      } else if (owl_message_is_logout(m)) {
65        owl_fmtext_append_bold(fm, "LOGOUT");
66      }
67      if (owl_message_is_pseudo(m)) {
68        owl_fmtext_append_bold(fm, " (PSEUDO)");
69      }
70      owl_fmtext_append_normal(fm, " for ");
71      ptr=short_zuser(owl_message_get_instance(m));
72      owl_fmtext_append_bold(fm, ptr);
73      owl_free(ptr);
74      owl_fmtext_append_normal(fm, " at ");
75      owl_fmtext_append_normal(fm, host ? host : "");
76      owl_fmtext_append_normal(fm, " ");
77      owl_fmtext_append_normal(fm, tty ? tty : "");
78      owl_fmtext_append_normal(fm, "\n");
79    } else {
80      owl_fmtext_append_normal(fm, "From: ");
81      if (strcasecmp(owl_message_get_class(m), "message")) {
82        owl_fmtext_append_normal(fm, "Class ");
83        owl_fmtext_append_normal(fm, owl_message_get_class(m));
84        owl_fmtext_append_normal(fm, " / Instance ");
85        owl_fmtext_append_normal(fm, owl_message_get_instance(m));
86        owl_fmtext_append_normal(fm, " / ");
87      }
88      owl_fmtext_append_normal(fm, frombuff);
89      if (strcasecmp(owl_message_get_realm(m), owl_zephyr_get_realm())) {
90        owl_fmtext_append_normal(fm, " {");
91        owl_fmtext_append_normal(fm, owl_message_get_realm(m));
92        owl_fmtext_append_normal(fm, "} ");
93      }
94     
95      /* stick on the zsig */
96      zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
97      owl_message_pretty_zsig(m, zsigbuff);
98      owl_fmtext_append_normal(fm, "    (");
99      owl_fmtext_append_ztext(fm, zsigbuff);
100      owl_fmtext_append_normal(fm, ")");
101      owl_fmtext_append_normal(fm, "\n");
102      owl_free(zsigbuff);
103     
104      /* then the indented message */
105      owl_style_basic_format_body(fm, m);
106     
107      /* make personal messages bold for smaat users */
108      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
109        if (owl_message_is_personal(m)) {
110          owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
111        }
112      }
113    }
114   
115#endif
116  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
117    char *zsigbuff, *foo;
118    owl_fmtext_append_normal(fm, OWL_TABSTR);
119    owl_fmtext_append_normal(fm, "To: ");
120    foo=short_zuser(owl_message_get_recipient(m));
121    owl_fmtext_append_normal(fm, foo);
122    owl_free(foo);
123    owl_fmtext_append_normal(fm, "  (Zsig: ");
124   
125    zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
126    owl_message_pretty_zsig(m, zsigbuff);
127    owl_fmtext_append_ztext(fm, zsigbuff);
128    owl_free(zsigbuff);
129   
130    owl_fmtext_append_normal(fm, ")");
131    owl_fmtext_append_normal(fm, "\n");
132    owl_style_basic_format_body(fm, m);
133  } else if (owl_message_is_type_aim(m)) {
134    if (owl_message_is_loginout(m)) {
135      owl_fmtext_append_normal(fm, OWL_TABSTR);
136      if (owl_message_is_login(m)) {
137        owl_fmtext_append_bold(fm, "AIM LOGIN");
138      } else {
139        owl_fmtext_append_bold(fm, "AIM LOGOUT");
140      }
141      owl_fmtext_append_normal(fm, " for ");
142      owl_fmtext_append_normal(fm, owl_message_get_sender(m));
143      owl_fmtext_append_normal(fm, "\n");
144    } else if (owl_message_is_direction_in(m)) {
145      owl_fmtext_append_bold(fm, OWL_TABSTR);
146      owl_fmtext_append_bold(fm, "AIM from ");
147      owl_fmtext_append_bold(fm, owl_message_get_sender(m));
148      owl_fmtext_append_bold(fm, "\n");
149      owl_style_basic_format_body(fm, m);
150    } else if (owl_message_is_direction_out(m)) {
151      owl_fmtext_append_normal(fm, OWL_TABSTR);
152      owl_fmtext_append_normal(fm, "AIM sent to ");
153      owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
154      owl_fmtext_append_normal(fm, "\n");
155      owl_style_basic_format_body(fm, m);
156    }
157  } else if (owl_message_is_type_admin(m)) {
158    char *text, *header;
159   
160    text=owl_message_get_body(m);
161    header=owl_message_get_attribute_value(m, "adminheader");
162
163    owl_fmtext_append_normal(fm, OWL_TABSTR);
164    owl_fmtext_append_bold(fm, "OWL ADMIN ");
165    owl_fmtext_append_ztext(fm, header);
166    owl_fmtext_append_normal(fm, "\n");
167    owl_style_basic_format_body(fm, m);
168  } else {
169    char *header;
170
171    header=owl_sprintf("%s from: %s to: %s",
172                       owl_message_get_type(m),
173                       owl_message_get_sender(m),
174                       owl_message_get_recipient(m));
175
176    owl_fmtext_append_normal(fm, OWL_TABSTR);
177    owl_fmtext_append_normal(fm, header);
178    owl_fmtext_append_normal(fm, "\n");
179    owl_style_basic_format_body(fm, m);
180   
181    owl_free(header);
182  }
183}
184
185void owl_stylefunc_default(owl_fmtext *fm, owl_message *m)
186{
187  char *shorttimestr;
188#ifdef HAVE_LIBZEPHYR
189  char *ptr, *zsigbuff, frombuff[LINE];
190  ZNotice_t *n;
191#endif
192
193  shorttimestr=owl_message_get_shorttimestr(m);
194
195  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
196#ifdef HAVE_LIBZEPHYR
197    n=owl_message_get_notice(m);
198
199    /* edit the from addr for printing */
200    strcpy(frombuff, owl_message_get_sender(m));
201    ptr=strchr(frombuff, '@');
202    if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
203      *ptr='\0';
204    }
205   
206    /* set the message for printing */
207    owl_fmtext_append_normal(fm, OWL_TABSTR);
208   
209    if (owl_message_is_ping(m) && owl_message_is_private(m)) {
210      owl_fmtext_append_bold(fm, "PING");
211      owl_fmtext_append_normal(fm, " from ");
212      owl_fmtext_append_bold(fm, frombuff);
213      owl_fmtext_append_normal(fm, "\n");
214    } else if (owl_message_is_loginout(m)) {
215      char *host, *tty;
216     
217      host=owl_message_get_attribute_value(m, "loginhost");
218      tty=owl_message_get_attribute_value(m, "logintty");
219     
220      if (owl_message_is_login(m)) {
221        owl_fmtext_append_bold(fm, "LOGIN");
222      } else if (owl_message_is_logout(m)) {
223        owl_fmtext_append_bold(fm, "LOGOUT");
224      }
225
226      if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
227       
228      owl_fmtext_append_normal(fm, " for ");
229      ptr=short_zuser(owl_message_get_instance(m));
230      owl_fmtext_append_bold(fm, ptr);
231      owl_free(ptr);
232      owl_fmtext_append_normal(fm, " at ");
233      owl_fmtext_append_normal(fm, host ? host : "");
234      owl_fmtext_append_normal(fm, " ");
235      owl_fmtext_append_normal(fm, tty ? tty : "");
236      owl_fmtext_append_normal(fm, " ");
237      owl_fmtext_append_normal(fm, shorttimestr);
238      owl_fmtext_append_normal(fm, "\n");
239    } else {
240      owl_fmtext_append_normal(fm, owl_message_get_class(m));
241      owl_fmtext_append_normal(fm, " / ");
242      owl_fmtext_append_normal(fm, owl_message_get_instance(m));
243      owl_fmtext_append_normal(fm, " / ");
244      owl_fmtext_append_bold(fm, frombuff);
245      if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) {
246        owl_fmtext_append_normal(fm, " {");
247        owl_fmtext_append_normal(fm, owl_message_get_realm(m));
248        owl_fmtext_append_normal(fm, "}");
249      }
250      if (strcmp(owl_message_get_opcode(m), "")) {
251        owl_fmtext_append_normal(fm, " [");
252        owl_fmtext_append_normal(fm, owl_message_get_opcode(m));
253        owl_fmtext_append_normal(fm, "]");
254      }
255
256      owl_fmtext_append_normal(fm, "  ");
257      owl_fmtext_append_normal(fm, shorttimestr);
258
259      /* stick on the zsig */
260      zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
261      owl_message_pretty_zsig(m, zsigbuff);
262      owl_fmtext_append_normal(fm, "    (");
263      owl_fmtext_append_ztext(fm, zsigbuff);
264      owl_fmtext_append_normal(fm, ")");
265      owl_fmtext_append_normal(fm, "\n");
266      owl_free(zsigbuff);
267     
268      owl_style_basic_format_body(fm, m);
269     
270      /* make private messages bold for smaat users */
271      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
272        if (owl_message_is_personal(m)) {
273          owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
274        }
275      }
276    }
277   
278#endif
279  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
280    char *zsigbuff, *foo;
281   
282    owl_fmtext_append_normal(fm, OWL_TABSTR);
283    owl_fmtext_append_normal(fm, "Zephyr sent to ");
284    foo=short_zuser(owl_message_get_recipient(m));
285    owl_fmtext_append_normal(fm, foo);
286    owl_free(foo);
287
288    owl_fmtext_append_normal(fm, "  ");
289    owl_fmtext_append_normal(fm, shorttimestr);
290
291    owl_fmtext_append_normal(fm, "  (Zsig: ");
292   
293    zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
294    owl_message_pretty_zsig(m, zsigbuff);
295    owl_fmtext_append_ztext(fm, zsigbuff);
296    owl_free(zsigbuff);
297   
298    owl_fmtext_append_normal(fm, ")");
299    owl_fmtext_append_normal(fm, "\n");
300    owl_style_basic_format_body(fm, m);
301  } else if (owl_message_is_type_aim(m)) {
302    if (owl_message_is_loginout(m)) {
303      owl_fmtext_append_normal(fm, OWL_TABSTR);
304      if (owl_message_is_login(m)) {
305        owl_fmtext_append_bold(fm, "AIM LOGIN");
306      } else {
307        owl_fmtext_append_bold(fm, "AIM LOGOUT");
308      }
309      owl_fmtext_append_normal(fm, " for ");
310      owl_fmtext_append_normal(fm, owl_message_get_sender(m));
311      owl_fmtext_append_normal(fm, " ");
312      owl_fmtext_append_normal(fm, shorttimestr);
313      owl_fmtext_append_normal(fm, "\n");
314    } else if (owl_message_is_direction_in(m)) {
315      owl_fmtext_append_bold(fm, OWL_TABSTR);
316      owl_fmtext_append_bold(fm, "AIM from ");
317      owl_fmtext_append_bold(fm, owl_message_get_sender(m));
318     
319      owl_fmtext_append_normal(fm, "  ");
320      owl_fmtext_append_normal(fm, shorttimestr);
321
322      owl_fmtext_append_bold(fm, "\n");
323      owl_style_basic_format_body(fm, m);
324    } else if (owl_message_is_direction_out(m)) {
325      owl_fmtext_append_normal(fm, OWL_TABSTR);
326      owl_fmtext_append_normal(fm, "AIM sent to ");
327      owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
328      owl_fmtext_append_normal(fm, "  ");
329      owl_fmtext_append_normal(fm, shorttimestr);
330      owl_fmtext_append_normal(fm, "\n");
331      owl_style_basic_format_body(fm, m);
332    }
333  } else if (owl_message_is_type_admin(m)) {
334    char *header;
335   
336    header=owl_message_get_attribute_value(m, "adminheader");
337   
338    owl_fmtext_append_normal(fm, OWL_TABSTR);
339    owl_fmtext_append_bold(fm, "OWL ADMIN ");
340    owl_fmtext_append_ztext(fm, header);
341    owl_fmtext_append_normal(fm, "\n");
342    owl_style_basic_format_body(fm, m);
343  } else {
344    char *header;
345   
346    header=owl_sprintf("%s from: %s to: %s",
347                       owl_message_get_type(m),
348                       owl_message_get_sender(m),
349                       owl_message_get_recipient(m));
350   
351    owl_fmtext_append_normal(fm, OWL_TABSTR);
352    owl_fmtext_append_normal(fm, header);
353    owl_fmtext_append_normal(fm, "  ");
354    owl_fmtext_append_normal(fm, shorttimestr);
355    owl_fmtext_append_normal(fm, "\n");
356    owl_style_basic_format_body(fm, m);
357  }
358  owl_free(shorttimestr);
359}
360
361void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
362{
363  char *tmp;
364  char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
365  char *sender, *recip;
366#ifdef HAVE_LIBZEPHYR
367  ZNotice_t *n;
368#endif
369
370  sender=short_zuser(owl_message_get_sender(m));
371  recip=short_zuser(owl_message_get_recipient(m));
372 
373  if (owl_message_is_type_zephyr(m)) {
374#ifdef HAVE_LIBZEPHYR
375    n=owl_message_get_notice(m);
376   
377    owl_fmtext_append_spaces(fm, OWL_TAB);
378
379    if (owl_message_is_loginout(m)) {
380      char *host, *tty;
381     
382      host=owl_message_get_attribute_value(m, "loginhost");
383      tty=owl_message_get_attribute_value(m, "logintty");
384
385      if (owl_message_is_login(m)) {
386        tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender);
387        owl_fmtext_append_normal(fm, tmp);
388        owl_free(tmp);
389      } else if (owl_message_is_logout(m)) {
390        tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender);
391        owl_fmtext_append_normal(fm, tmp);
392        owl_free(tmp);
393      }
394
395      owl_fmtext_append_normal(fm, "at ");
396      owl_fmtext_append_normal(fm, host ? host : "");
397      owl_fmtext_append_normal(fm, " ");
398      owl_fmtext_append_normal(fm, tty ? tty : "");
399      owl_fmtext_append_normal(fm, "\n");
400
401    } else if (owl_message_is_ping(m)) {
402      tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
403      owl_fmtext_append_normal(fm, tmp);
404      owl_fmtext_append_normal(fm, "\n");
405      owl_free(tmp);
406
407    } else {
408      if (owl_message_is_direction_in(m)) {
409        tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
410      } else if (owl_message_is_direction_out(m)) {
411        tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
412      } else {
413        tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
414      }
415      owl_fmtext_append_normal(fm, tmp);
416      if (tmp) owl_free(tmp);
417     
418      tmp=owl_strdup(owl_message_get_body(m));
419      owl_text_tr(tmp, '\n', ' ');
420      owl_fmtext_append_ztext(fm, tmp);
421      owl_fmtext_append_normal(fm, "\n");
422      if (tmp) owl_free(tmp);
423    }
424     
425    /* make personal messages bold for smaat users */
426    if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
427        owl_message_is_personal(m) &&
428        owl_message_is_direction_in(m)) {
429      owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
430    }
431
432    owl_free(sender);
433    owl_free(recip);
434#endif
435  } else if (owl_message_is_type_aim(m)) {
436    owl_fmtext_append_spaces(fm, OWL_TAB);
437    if (owl_message_is_login(m)) {
438      tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
439      owl_fmtext_append_normal(fm, tmp);
440      owl_fmtext_append_normal(fm, "\n");
441      if (tmp) owl_free(tmp);
442    } else if (owl_message_is_logout(m)) {
443      tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
444      owl_fmtext_append_normal(fm, tmp);
445      owl_fmtext_append_normal(fm, "\n");
446      if (tmp) owl_free(tmp);
447    } else {
448      if (owl_message_is_direction_in(m)) {
449        tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
450        owl_fmtext_append_normal(fm, tmp);
451        if (tmp) owl_free(tmp);
452      } else if (owl_message_is_direction_out(m)) {
453        tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
454        owl_fmtext_append_normal(fm, tmp);
455        if (tmp) owl_free(tmp);
456      }
457     
458      tmp=owl_strdup(owl_message_get_body(m));
459      owl_text_tr(tmp, '\n', ' ');
460      owl_fmtext_append_normal(fm, tmp);
461      owl_fmtext_append_normal(fm, "\n");
462      if (tmp) owl_free(tmp);
463
464      /* make personal messages bold for smaat users */
465      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
466        owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
467      }
468    }
469  } else if (owl_message_is_type_admin(m)) {
470    owl_fmtext_append_spaces(fm, OWL_TAB);
471    owl_fmtext_append_normal(fm, "< ADMIN                                  ");
472   
473    tmp=owl_strdup(owl_message_get_body(m));
474    owl_text_tr(tmp, '\n', ' ');
475    owl_fmtext_append_normal(fm, tmp);
476    owl_fmtext_append_normal(fm, "\n");
477    if (tmp) owl_free(tmp);
478  } else {
479    owl_fmtext_append_spaces(fm, OWL_TAB);
480    owl_fmtext_append_normal(fm, "< LOOPBACK                               ");
481   
482    tmp=owl_strdup(owl_message_get_body(m));
483    owl_text_tr(tmp, '\n', ' ');
484    owl_fmtext_append_normal(fm, tmp);
485    owl_fmtext_append_normal(fm, "\n");
486    if (tmp) owl_free(tmp);
487  }   
488
489}
490
491void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
492{
493#ifdef HAVE_LIBZEPHYR
494  char *body, *indent, *ptr, frombuff[LINE];
495  owl_fmtext fm_first, fm_other, fm_tmp;
496  ZNotice_t *n;
497#endif
498  char *sender, *hostname, *timestr, *classinst1, *classinst2;
499
500  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
501#ifdef HAVE_LIBZEPHYR
502    n=owl_message_get_notice(m);
503
504    /* get the body */
505    body=owl_malloc(strlen(owl_message_get_body(m))+30);
506    strcpy(body, owl_message_get_body(m));
507   
508    /* add a newline if we need to */
509    if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
510      strcat(body, "\n");
511    }
512
513    owl_fmtext_init_null(&fm_tmp);
514    owl_fmtext_append_ztext(&fm_tmp, body);
515    owl_fmtext_init_null(&fm_first);
516    owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
517
518    /* do the indenting into indent */
519    indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
520    owl_text_indent(indent, body, 31);
521
522    owl_fmtext_free(&fm_tmp);
523    owl_fmtext_init_null(&fm_tmp);
524    owl_fmtext_append_ztext(&fm_tmp, indent);
525    owl_fmtext_init_null(&fm_other);
526    owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
527    owl_fmtext_free(&fm_tmp);
528   
529    /* edit the from addr for printing */
530    strcpy(frombuff, owl_message_get_sender(m));
531    ptr=strchr(frombuff, '@');
532    if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
533      *ptr='\0';
534    }
535    sender=owl_sprintf("%-9.9s", frombuff);
536
537    hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
538    timestr=owl_strdup("00:00");
539    classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
540    classinst2=owl_sprintf("%-9.9s", classinst1);
541   
542    /* set the message for printing */
543    owl_fmtext_append_normal(fm, OWL_TABSTR);
544   
545    if (owl_message_is_ping(m) && owl_message_is_private(m)) {
546      owl_fmtext_append_bold(fm, "PING");
547      owl_fmtext_append_normal(fm, " from ");
548      owl_fmtext_append_bold(fm, frombuff);
549      owl_fmtext_append_normal(fm, "\n");
550    } else if (owl_message_is_loginout(m)) {
551      char *host, *tty;
552     
553      host=owl_message_get_attribute_value(m, "loginhost");
554      tty=owl_message_get_attribute_value(m, "logintty");
555     
556      if (owl_message_is_login(m)) {
557        owl_fmtext_append_bold(fm, "LOGIN");
558      } else if (owl_message_is_logout(m)) {
559        owl_fmtext_append_bold(fm, "LOGOUT");
560      }
561      if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
562
563      owl_fmtext_append_normal(fm, " for ");
564      ptr=short_zuser(owl_message_get_instance(m));
565      owl_fmtext_append_bold(fm, ptr);
566      owl_free(ptr);
567      owl_fmtext_append_normal(fm, " at ");
568      owl_fmtext_append_normal(fm, host ? host : "");
569      owl_fmtext_append_normal(fm, " ");
570      owl_fmtext_append_normal(fm, tty ? tty : "");
571      owl_fmtext_append_normal(fm, "\n");
572    } else {
573      owl_fmtext_append_normal(fm, sender);
574      owl_fmtext_append_normal(fm, "|");
575      owl_fmtext_append_normal(fm, hostname);
576      owl_fmtext_append_normal(fm, " ");
577      owl_fmtext_append_normal(fm, timestr);
578      owl_fmtext_append_normal(fm, " ");
579      owl_fmtext_append_normal(fm, classinst2);
580
581      owl_fmtext_append_normal(fm, "   ");
582      owl_fmtext_append_fmtext(fm, &fm_first);
583      owl_fmtext_append_fmtext(fm, &fm_other);
584
585      owl_fmtext_free(&fm_other);
586      owl_fmtext_free(&fm_first);
587     
588      /* make private messages bold for smaat users */
589      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
590        if (owl_message_is_personal(m)) {
591          owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
592        }
593      }
594    }
595
596    owl_free(sender);
597    owl_free(hostname);
598    owl_free(timestr);
599    owl_free(classinst1);
600    owl_free(classinst2);
601   
602    owl_free(body);
603    owl_free(indent);
604#endif
605  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
606    char *indent, *text, *zsigbuff, *foo;
607   
608    text=owl_message_get_body(m);
609   
610    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
611    owl_text_indent(indent, text, OWL_MSGTAB);
612    owl_fmtext_append_normal(fm, OWL_TABSTR);
613    owl_fmtext_append_normal(fm, "Zephyr sent to ");
614    foo=short_zuser(owl_message_get_recipient(m));
615    owl_fmtext_append_normal(fm, foo);
616    owl_free(foo);
617    owl_fmtext_append_normal(fm, "  (Zsig: ");
618   
619    zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
620    owl_message_pretty_zsig(m, zsigbuff);
621    owl_fmtext_append_ztext(fm, zsigbuff);
622    owl_free(zsigbuff);
623   
624    owl_fmtext_append_normal(fm, ")");
625    owl_fmtext_append_normal(fm, "\n");
626    owl_fmtext_append_ztext(fm, indent);
627    if (text[strlen(text)-1]!='\n') {
628      owl_fmtext_append_normal(fm, "\n");
629    }
630   
631    owl_free(indent);
632  } else if (owl_message_is_type_aim(m)) {
633    char *indent;
634   
635    if (owl_message_is_loginout(m)) {
636      owl_fmtext_append_normal(fm, OWL_TABSTR);
637      if (owl_message_is_login(m)) {
638        owl_fmtext_append_bold(fm, "AIM LOGIN");
639      } else {
640        owl_fmtext_append_bold(fm, "AIM LOGOUT");
641      }
642      owl_fmtext_append_normal(fm, " for ");
643      owl_fmtext_append_normal(fm, owl_message_get_sender(m));
644      owl_fmtext_append_normal(fm, "\n");
645    } else if (owl_message_is_direction_in(m)) {
646      indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
647      owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
648      owl_fmtext_append_bold(fm, OWL_TABSTR);
649      owl_fmtext_append_bold(fm, "AIM from ");
650      owl_fmtext_append_bold(fm, owl_message_get_sender(m));
651      owl_fmtext_append_bold(fm, "\n");
652      owl_fmtext_append_bold(fm, indent);
653      if (indent[strlen(indent)-1]!='\n') {
654        owl_fmtext_append_normal(fm, "\n");
655      }
656      owl_free(indent);
657    } else if (owl_message_is_direction_out(m)) {
658      indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
659      owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
660      owl_fmtext_append_normal(fm, OWL_TABSTR);
661      owl_fmtext_append_normal(fm, "AIM sent to ");
662      owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
663      owl_fmtext_append_normal(fm, "\n");
664      owl_fmtext_append_ztext(fm, indent);
665      if (indent[strlen(indent)-1]!='\n') {
666        owl_fmtext_append_normal(fm, "\n");
667      }
668      owl_free(indent);
669    }
670  } else if (owl_message_is_type_admin(m)) {
671    char *text, *header, *indent;
672   
673    text=owl_message_get_body(m);
674    header=owl_message_get_attribute_value(m, "adminheader");
675   
676    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
677    owl_text_indent(indent, text, OWL_MSGTAB);
678    owl_fmtext_append_normal(fm, OWL_TABSTR);
679    owl_fmtext_append_bold(fm, "OWL ADMIN ");
680    owl_fmtext_append_ztext(fm, header);
681    owl_fmtext_append_normal(fm, "\n");
682    owl_fmtext_append_ztext(fm, indent);
683    if (text[strlen(text)-1]!='\n') {
684      owl_fmtext_append_normal(fm, "\n");
685    }
686   
687    owl_free(indent);
688  } else {
689
690  }
691}
Note: See TracBrowser for help on using the repository browser.