1 | #include "owl.h" |
---|
2 | |
---|
3 | static const char fileIdent[] = "$Id$"; |
---|
4 | |
---|
5 | /* In all of these functions, 'fm' is expected to already be |
---|
6 | * initialized. |
---|
7 | */ |
---|
8 | |
---|
9 | void owl_style_basic_format_body(owl_fmtext *fm, owl_message *m) { |
---|
10 | char *indent, *body; |
---|
11 | owl_filter *f; |
---|
12 | int wrap = 0; |
---|
13 | |
---|
14 | /* get the body */ |
---|
15 | body=owl_strdup(owl_message_get_body(m)); |
---|
16 | |
---|
17 | f = owl_global_get_filter(&g, "wordwrap"); |
---|
18 | if(f && owl_filter_message_match(f, m)) |
---|
19 | wrap = 1; |
---|
20 | |
---|
21 | if(wrap) { |
---|
22 | int cols, i, width, word; |
---|
23 | char *tab, *tok, *ws = " \t\n\r"; |
---|
24 | cols = owl_global_get_cols(&g) - OWL_MSGTAB - 1; |
---|
25 | |
---|
26 | tab = owl_malloc(OWL_MSGTAB+1); |
---|
27 | for(i = 0; i < OWL_MSGTAB; i++) { |
---|
28 | tab[i] = ' '; |
---|
29 | } |
---|
30 | tab[OWL_MSGTAB] = 0; |
---|
31 | |
---|
32 | tok = strtok(body, ws); |
---|
33 | tab[OWL_MSGTAB-1] = 0; |
---|
34 | owl_fmtext_append_normal(fm, tab); |
---|
35 | tab[OWL_MSGTAB-1] = ' '; |
---|
36 | width = 0; |
---|
37 | |
---|
38 | while(tok) { |
---|
39 | word = strlen(tok); |
---|
40 | if(word + width + 1 < cols) { |
---|
41 | owl_fmtext_append_normal(fm, " "); |
---|
42 | owl_fmtext_append_normal(fm, tok); |
---|
43 | width += word + 1; |
---|
44 | } else { |
---|
45 | owl_fmtext_append_normal(fm, "\n"); |
---|
46 | owl_fmtext_append_normal(fm, tab); |
---|
47 | owl_fmtext_append_normal(fm, tok); |
---|
48 | width = word; |
---|
49 | } |
---|
50 | tok = strtok(NULL, ws); |
---|
51 | } |
---|
52 | owl_fmtext_append_normal(fm, "\n"); |
---|
53 | |
---|
54 | owl_free(tab); |
---|
55 | } else { |
---|
56 | /* do the indenting into indent */ |
---|
57 | indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10); |
---|
58 | owl_text_indent(indent, body, OWL_MSGTAB); |
---|
59 | owl_fmtext_append_ztext(fm, indent); |
---|
60 | if(body[strlen(body)-1] != '\n') |
---|
61 | owl_fmtext_append_ztext(fm, "\n"); |
---|
62 | owl_free(indent); |
---|
63 | } |
---|
64 | |
---|
65 | owl_free(body); |
---|
66 | } |
---|
67 | |
---|
68 | void owl_stylefunc_basic(owl_fmtext *fm, owl_message *m) |
---|
69 | { |
---|
70 | #ifdef HAVE_LIBZEPHYR |
---|
71 | char *ptr, *zsigbuff, frombuff[LINE]; |
---|
72 | ZNotice_t *n; |
---|
73 | #endif |
---|
74 | |
---|
75 | if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { |
---|
76 | #ifdef HAVE_LIBZEPHYR |
---|
77 | n=owl_message_get_notice(m); |
---|
78 | |
---|
79 | /* edit the from addr for printing */ |
---|
80 | strcpy(frombuff, owl_message_get_sender(m)); |
---|
81 | ptr=strchr(frombuff, '@'); |
---|
82 | if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) { |
---|
83 | *ptr='\0'; |
---|
84 | } |
---|
85 | |
---|
86 | /* set the message for printing */ |
---|
87 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
88 | |
---|
89 | if (owl_message_is_ping(m)) { |
---|
90 | owl_fmtext_append_bold(fm, "PING"); |
---|
91 | owl_fmtext_append_normal(fm, " from "); |
---|
92 | owl_fmtext_append_bold(fm, frombuff); |
---|
93 | owl_fmtext_append_normal(fm, "\n"); |
---|
94 | } else if (owl_message_is_loginout(m)) { |
---|
95 | char *host, *tty; |
---|
96 | |
---|
97 | host=owl_message_get_attribute_value(m, "loginhost"); |
---|
98 | tty=owl_message_get_attribute_value(m, "logintty"); |
---|
99 | |
---|
100 | if (owl_message_is_login(m)) { |
---|
101 | owl_fmtext_append_bold(fm, "LOGIN"); |
---|
102 | } else if (owl_message_is_logout(m)) { |
---|
103 | owl_fmtext_append_bold(fm, "LOGOUT"); |
---|
104 | } |
---|
105 | if (owl_message_is_pseudo(m)) { |
---|
106 | owl_fmtext_append_bold(fm, " (PSEUDO)"); |
---|
107 | } |
---|
108 | owl_fmtext_append_normal(fm, " for "); |
---|
109 | ptr=short_zuser(owl_message_get_instance(m)); |
---|
110 | owl_fmtext_append_bold(fm, ptr); |
---|
111 | owl_free(ptr); |
---|
112 | owl_fmtext_append_normal(fm, " at "); |
---|
113 | owl_fmtext_append_normal(fm, host ? host : ""); |
---|
114 | owl_fmtext_append_normal(fm, " "); |
---|
115 | owl_fmtext_append_normal(fm, tty ? tty : ""); |
---|
116 | owl_fmtext_append_normal(fm, "\n"); |
---|
117 | } else { |
---|
118 | owl_fmtext_append_normal(fm, "From: "); |
---|
119 | if (strcasecmp(owl_message_get_class(m), "message")) { |
---|
120 | owl_fmtext_append_normal(fm, "Class "); |
---|
121 | owl_fmtext_append_normal(fm, owl_message_get_class(m)); |
---|
122 | owl_fmtext_append_normal(fm, " / Instance "); |
---|
123 | owl_fmtext_append_normal(fm, owl_message_get_instance(m)); |
---|
124 | owl_fmtext_append_normal(fm, " / "); |
---|
125 | } |
---|
126 | owl_fmtext_append_normal(fm, frombuff); |
---|
127 | if (strcasecmp(owl_message_get_realm(m), owl_zephyr_get_realm())) { |
---|
128 | owl_fmtext_append_normal(fm, " {"); |
---|
129 | owl_fmtext_append_normal(fm, owl_message_get_realm(m)); |
---|
130 | owl_fmtext_append_normal(fm, "} "); |
---|
131 | } |
---|
132 | |
---|
133 | /* stick on the zsig */ |
---|
134 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
135 | owl_message_pretty_zsig(m, zsigbuff); |
---|
136 | owl_fmtext_append_normal(fm, " ("); |
---|
137 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
138 | owl_fmtext_append_normal(fm, ")"); |
---|
139 | owl_fmtext_append_normal(fm, "\n"); |
---|
140 | owl_free(zsigbuff); |
---|
141 | |
---|
142 | /* then the indented message */ |
---|
143 | owl_style_basic_format_body(fm, m); |
---|
144 | |
---|
145 | /* make personal messages bold for smaat users */ |
---|
146 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { |
---|
147 | if (owl_message_is_personal(m)) { |
---|
148 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
149 | } |
---|
150 | } |
---|
151 | } |
---|
152 | |
---|
153 | #endif |
---|
154 | } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) { |
---|
155 | char *zsigbuff, *foo; |
---|
156 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
157 | owl_fmtext_append_normal(fm, "To: "); |
---|
158 | foo=short_zuser(owl_message_get_recipient(m)); |
---|
159 | owl_fmtext_append_normal(fm, foo); |
---|
160 | owl_free(foo); |
---|
161 | owl_fmtext_append_normal(fm, " (Zsig: "); |
---|
162 | |
---|
163 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
164 | owl_message_pretty_zsig(m, zsigbuff); |
---|
165 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
166 | owl_free(zsigbuff); |
---|
167 | |
---|
168 | owl_fmtext_append_normal(fm, ")"); |
---|
169 | owl_fmtext_append_normal(fm, "\n"); |
---|
170 | owl_style_basic_format_body(fm, m); |
---|
171 | } else if (owl_message_is_type_aim(m)) { |
---|
172 | if (owl_message_is_loginout(m)) { |
---|
173 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
174 | if (owl_message_is_login(m)) { |
---|
175 | owl_fmtext_append_bold(fm, "AIM LOGIN"); |
---|
176 | } else { |
---|
177 | owl_fmtext_append_bold(fm, "AIM LOGOUT"); |
---|
178 | } |
---|
179 | owl_fmtext_append_normal(fm, " for "); |
---|
180 | owl_fmtext_append_normal(fm, owl_message_get_sender(m)); |
---|
181 | owl_fmtext_append_normal(fm, "\n"); |
---|
182 | } else if (owl_message_is_direction_in(m)) { |
---|
183 | owl_fmtext_append_bold(fm, OWL_TABSTR); |
---|
184 | owl_fmtext_append_bold(fm, "AIM from "); |
---|
185 | owl_fmtext_append_bold(fm, owl_message_get_sender(m)); |
---|
186 | owl_fmtext_append_bold(fm, "\n"); |
---|
187 | owl_style_basic_format_body(fm, m); |
---|
188 | } else if (owl_message_is_direction_out(m)) { |
---|
189 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
190 | owl_fmtext_append_normal(fm, "AIM sent to "); |
---|
191 | owl_fmtext_append_normal(fm, owl_message_get_recipient(m)); |
---|
192 | owl_fmtext_append_normal(fm, "\n"); |
---|
193 | owl_style_basic_format_body(fm, m); |
---|
194 | } |
---|
195 | } else if (owl_message_is_type_admin(m)) { |
---|
196 | char *text, *header; |
---|
197 | |
---|
198 | text=owl_message_get_body(m); |
---|
199 | header=owl_message_get_attribute_value(m, "adminheader"); |
---|
200 | |
---|
201 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
202 | owl_fmtext_append_bold(fm, "OWL ADMIN "); |
---|
203 | owl_fmtext_append_ztext(fm, header); |
---|
204 | owl_fmtext_append_normal(fm, "\n"); |
---|
205 | owl_style_basic_format_body(fm, m); |
---|
206 | } else { |
---|
207 | char *header; |
---|
208 | |
---|
209 | header=owl_sprintf("%s from: %s to: %s", |
---|
210 | owl_message_get_type(m), |
---|
211 | owl_message_get_sender(m), |
---|
212 | owl_message_get_recipient(m)); |
---|
213 | |
---|
214 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
215 | owl_fmtext_append_normal(fm, header); |
---|
216 | owl_fmtext_append_normal(fm, "\n"); |
---|
217 | owl_style_basic_format_body(fm, m); |
---|
218 | |
---|
219 | owl_free(header); |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m) |
---|
224 | { |
---|
225 | char *tmp; |
---|
226 | char *baseformat="%s %-13.13s %-11.11s %-12.12s "; |
---|
227 | char *sender, *recip; |
---|
228 | #ifdef HAVE_LIBZEPHYR |
---|
229 | ZNotice_t *n; |
---|
230 | #endif |
---|
231 | |
---|
232 | sender=short_zuser(owl_message_get_sender(m)); |
---|
233 | recip=short_zuser(owl_message_get_recipient(m)); |
---|
234 | |
---|
235 | if (owl_message_is_type_zephyr(m)) { |
---|
236 | #ifdef HAVE_LIBZEPHYR |
---|
237 | n=owl_message_get_notice(m); |
---|
238 | |
---|
239 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
240 | |
---|
241 | if (owl_message_is_loginout(m)) { |
---|
242 | char *host, *tty; |
---|
243 | |
---|
244 | host=owl_message_get_attribute_value(m, "loginhost"); |
---|
245 | tty=owl_message_get_attribute_value(m, "logintty"); |
---|
246 | |
---|
247 | if (owl_message_is_login(m)) { |
---|
248 | tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender); |
---|
249 | owl_fmtext_append_normal(fm, tmp); |
---|
250 | owl_free(tmp); |
---|
251 | } else if (owl_message_is_logout(m)) { |
---|
252 | tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender); |
---|
253 | owl_fmtext_append_normal(fm, tmp); |
---|
254 | owl_free(tmp); |
---|
255 | } |
---|
256 | |
---|
257 | owl_fmtext_append_normal(fm, "at "); |
---|
258 | owl_fmtext_append_normal(fm, host ? host : ""); |
---|
259 | owl_fmtext_append_normal(fm, " "); |
---|
260 | owl_fmtext_append_normal(fm, tty ? tty : ""); |
---|
261 | owl_fmtext_append_normal(fm, "\n"); |
---|
262 | |
---|
263 | } else if (owl_message_is_ping(m)) { |
---|
264 | tmp=owl_sprintf(baseformat, "<", "PING", "", sender); |
---|
265 | owl_fmtext_append_normal(fm, tmp); |
---|
266 | owl_fmtext_append_normal(fm, "\n"); |
---|
267 | owl_free(tmp); |
---|
268 | |
---|
269 | } else { |
---|
270 | if (owl_message_is_direction_in(m)) { |
---|
271 | tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender); |
---|
272 | } else if (owl_message_is_direction_out(m)) { |
---|
273 | tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip); |
---|
274 | } else { |
---|
275 | tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender); |
---|
276 | } |
---|
277 | owl_fmtext_append_normal(fm, tmp); |
---|
278 | if (tmp) owl_free(tmp); |
---|
279 | |
---|
280 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
281 | owl_text_tr(tmp, '\n', ' '); |
---|
282 | owl_fmtext_append_ztext(fm, tmp); |
---|
283 | owl_fmtext_append_normal(fm, "\n"); |
---|
284 | if (tmp) owl_free(tmp); |
---|
285 | } |
---|
286 | |
---|
287 | /* make personal messages bold for smaat users */ |
---|
288 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && |
---|
289 | owl_message_is_personal(m) && |
---|
290 | owl_message_is_direction_in(m)) { |
---|
291 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
292 | } |
---|
293 | |
---|
294 | owl_free(sender); |
---|
295 | owl_free(recip); |
---|
296 | #endif |
---|
297 | } else if (owl_message_is_type_aim(m)) { |
---|
298 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
299 | if (owl_message_is_login(m)) { |
---|
300 | tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m)); |
---|
301 | owl_fmtext_append_normal(fm, tmp); |
---|
302 | owl_fmtext_append_normal(fm, "\n"); |
---|
303 | if (tmp) owl_free(tmp); |
---|
304 | } else if (owl_message_is_logout(m)) { |
---|
305 | tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m)); |
---|
306 | owl_fmtext_append_normal(fm, tmp); |
---|
307 | owl_fmtext_append_normal(fm, "\n"); |
---|
308 | if (tmp) owl_free(tmp); |
---|
309 | } else { |
---|
310 | if (owl_message_is_direction_in(m)) { |
---|
311 | tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m)); |
---|
312 | owl_fmtext_append_normal(fm, tmp); |
---|
313 | if (tmp) owl_free(tmp); |
---|
314 | } else if (owl_message_is_direction_out(m)) { |
---|
315 | tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m)); |
---|
316 | owl_fmtext_append_normal(fm, tmp); |
---|
317 | if (tmp) owl_free(tmp); |
---|
318 | } |
---|
319 | |
---|
320 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
321 | owl_text_tr(tmp, '\n', ' '); |
---|
322 | owl_fmtext_append_normal(fm, tmp); |
---|
323 | owl_fmtext_append_normal(fm, "\n"); |
---|
324 | if (tmp) owl_free(tmp); |
---|
325 | |
---|
326 | /* make personal messages bold for smaat users */ |
---|
327 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) { |
---|
328 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
329 | } |
---|
330 | } |
---|
331 | } else if (owl_message_is_type_admin(m)) { |
---|
332 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
333 | owl_fmtext_append_normal(fm, "< ADMIN "); |
---|
334 | |
---|
335 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
336 | owl_text_tr(tmp, '\n', ' '); |
---|
337 | owl_fmtext_append_normal(fm, tmp); |
---|
338 | owl_fmtext_append_normal(fm, "\n"); |
---|
339 | if (tmp) owl_free(tmp); |
---|
340 | } else { |
---|
341 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
342 | owl_fmtext_append_normal(fm, "< LOOPBACK "); |
---|
343 | |
---|
344 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
345 | owl_text_tr(tmp, '\n', ' '); |
---|
346 | owl_fmtext_append_normal(fm, tmp); |
---|
347 | owl_fmtext_append_normal(fm, "\n"); |
---|
348 | if (tmp) owl_free(tmp); |
---|
349 | } |
---|
350 | |
---|
351 | } |
---|
352 | |
---|
353 | void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m) |
---|
354 | { |
---|
355 | #ifdef HAVE_LIBZEPHYR |
---|
356 | char *body, *indent, *ptr, frombuff[LINE]; |
---|
357 | owl_fmtext fm_first, fm_other, fm_tmp; |
---|
358 | ZNotice_t *n; |
---|
359 | #endif |
---|
360 | char *sender, *hostname, *timestr, *classinst1, *classinst2; |
---|
361 | |
---|
362 | if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { |
---|
363 | #ifdef HAVE_LIBZEPHYR |
---|
364 | n=owl_message_get_notice(m); |
---|
365 | |
---|
366 | /* get the body */ |
---|
367 | body=owl_malloc(strlen(owl_message_get_body(m))+30); |
---|
368 | strcpy(body, owl_message_get_body(m)); |
---|
369 | |
---|
370 | /* add a newline if we need to */ |
---|
371 | if (body[0]!='\0' && body[strlen(body)-1]!='\n') { |
---|
372 | strcat(body, "\n"); |
---|
373 | } |
---|
374 | |
---|
375 | owl_fmtext_init_null(&fm_tmp); |
---|
376 | owl_fmtext_append_ztext(&fm_tmp, body); |
---|
377 | owl_fmtext_init_null(&fm_first); |
---|
378 | owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first); |
---|
379 | |
---|
380 | /* do the indenting into indent */ |
---|
381 | indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10); |
---|
382 | owl_text_indent(indent, body, 31); |
---|
383 | |
---|
384 | owl_fmtext_free(&fm_tmp); |
---|
385 | owl_fmtext_init_null(&fm_tmp); |
---|
386 | owl_fmtext_append_ztext(&fm_tmp, indent); |
---|
387 | owl_fmtext_init_null(&fm_other); |
---|
388 | owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other); |
---|
389 | owl_fmtext_free(&fm_tmp); |
---|
390 | |
---|
391 | /* edit the from addr for printing */ |
---|
392 | strcpy(frombuff, owl_message_get_sender(m)); |
---|
393 | ptr=strchr(frombuff, '@'); |
---|
394 | if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) { |
---|
395 | *ptr='\0'; |
---|
396 | } |
---|
397 | sender=owl_sprintf("%-9.9s", frombuff); |
---|
398 | |
---|
399 | hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m)); |
---|
400 | timestr=owl_strdup("00:00"); |
---|
401 | classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m)); |
---|
402 | classinst2=owl_sprintf("%-9.9s", classinst1); |
---|
403 | |
---|
404 | /* set the message for printing */ |
---|
405 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
406 | |
---|
407 | if (owl_message_is_ping(m) && owl_message_is_private(m)) { |
---|
408 | owl_fmtext_append_bold(fm, "PING"); |
---|
409 | owl_fmtext_append_normal(fm, " from "); |
---|
410 | owl_fmtext_append_bold(fm, frombuff); |
---|
411 | owl_fmtext_append_normal(fm, "\n"); |
---|
412 | } else if (owl_message_is_loginout(m)) { |
---|
413 | char *host, *tty; |
---|
414 | |
---|
415 | host=owl_message_get_attribute_value(m, "loginhost"); |
---|
416 | tty=owl_message_get_attribute_value(m, "logintty"); |
---|
417 | |
---|
418 | if (owl_message_is_login(m)) { |
---|
419 | owl_fmtext_append_bold(fm, "LOGIN"); |
---|
420 | } else if (owl_message_is_logout(m)) { |
---|
421 | owl_fmtext_append_bold(fm, "LOGOUT"); |
---|
422 | } |
---|
423 | if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)"); |
---|
424 | |
---|
425 | owl_fmtext_append_normal(fm, " for "); |
---|
426 | ptr=short_zuser(owl_message_get_instance(m)); |
---|
427 | owl_fmtext_append_bold(fm, ptr); |
---|
428 | owl_free(ptr); |
---|
429 | owl_fmtext_append_normal(fm, " at "); |
---|
430 | owl_fmtext_append_normal(fm, host ? host : ""); |
---|
431 | owl_fmtext_append_normal(fm, " "); |
---|
432 | owl_fmtext_append_normal(fm, tty ? tty : ""); |
---|
433 | owl_fmtext_append_normal(fm, "\n"); |
---|
434 | } else { |
---|
435 | owl_fmtext_append_normal(fm, sender); |
---|
436 | owl_fmtext_append_normal(fm, "|"); |
---|
437 | owl_fmtext_append_normal(fm, hostname); |
---|
438 | owl_fmtext_append_normal(fm, " "); |
---|
439 | owl_fmtext_append_normal(fm, timestr); |
---|
440 | owl_fmtext_append_normal(fm, " "); |
---|
441 | owl_fmtext_append_normal(fm, classinst2); |
---|
442 | |
---|
443 | owl_fmtext_append_normal(fm, " "); |
---|
444 | owl_fmtext_append_fmtext(fm, &fm_first); |
---|
445 | owl_fmtext_append_fmtext(fm, &fm_other); |
---|
446 | |
---|
447 | owl_fmtext_free(&fm_other); |
---|
448 | owl_fmtext_free(&fm_first); |
---|
449 | |
---|
450 | /* make private messages bold for smaat users */ |
---|
451 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { |
---|
452 | if (owl_message_is_personal(m)) { |
---|
453 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
454 | } |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | owl_free(sender); |
---|
459 | owl_free(hostname); |
---|
460 | owl_free(timestr); |
---|
461 | owl_free(classinst1); |
---|
462 | owl_free(classinst2); |
---|
463 | |
---|
464 | owl_free(body); |
---|
465 | owl_free(indent); |
---|
466 | #endif |
---|
467 | } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) { |
---|
468 | char *indent, *text, *zsigbuff, *foo; |
---|
469 | |
---|
470 | text=owl_message_get_body(m); |
---|
471 | |
---|
472 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
473 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
474 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
475 | owl_fmtext_append_normal(fm, "Zephyr sent to "); |
---|
476 | foo=short_zuser(owl_message_get_recipient(m)); |
---|
477 | owl_fmtext_append_normal(fm, foo); |
---|
478 | owl_free(foo); |
---|
479 | owl_fmtext_append_normal(fm, " (Zsig: "); |
---|
480 | |
---|
481 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
482 | owl_message_pretty_zsig(m, zsigbuff); |
---|
483 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
484 | owl_free(zsigbuff); |
---|
485 | |
---|
486 | owl_fmtext_append_normal(fm, ")"); |
---|
487 | owl_fmtext_append_normal(fm, "\n"); |
---|
488 | owl_fmtext_append_ztext(fm, indent); |
---|
489 | if (text[strlen(text)-1]!='\n') { |
---|
490 | owl_fmtext_append_normal(fm, "\n"); |
---|
491 | } |
---|
492 | |
---|
493 | owl_free(indent); |
---|
494 | } else if (owl_message_is_type_aim(m)) { |
---|
495 | char *indent; |
---|
496 | |
---|
497 | if (owl_message_is_loginout(m)) { |
---|
498 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
499 | if (owl_message_is_login(m)) { |
---|
500 | owl_fmtext_append_bold(fm, "AIM LOGIN"); |
---|
501 | } else { |
---|
502 | owl_fmtext_append_bold(fm, "AIM LOGOUT"); |
---|
503 | } |
---|
504 | owl_fmtext_append_normal(fm, " for "); |
---|
505 | owl_fmtext_append_normal(fm, owl_message_get_sender(m)); |
---|
506 | owl_fmtext_append_normal(fm, "\n"); |
---|
507 | } else if (owl_message_is_direction_in(m)) { |
---|
508 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
509 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
510 | owl_fmtext_append_bold(fm, OWL_TABSTR); |
---|
511 | owl_fmtext_append_bold(fm, "AIM from "); |
---|
512 | owl_fmtext_append_bold(fm, owl_message_get_sender(m)); |
---|
513 | owl_fmtext_append_bold(fm, "\n"); |
---|
514 | owl_fmtext_append_bold(fm, indent); |
---|
515 | if (indent[strlen(indent)-1]!='\n') { |
---|
516 | owl_fmtext_append_normal(fm, "\n"); |
---|
517 | } |
---|
518 | owl_free(indent); |
---|
519 | } else if (owl_message_is_direction_out(m)) { |
---|
520 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
521 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
522 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
523 | owl_fmtext_append_normal(fm, "AIM sent to "); |
---|
524 | owl_fmtext_append_normal(fm, owl_message_get_recipient(m)); |
---|
525 | owl_fmtext_append_normal(fm, "\n"); |
---|
526 | owl_fmtext_append_ztext(fm, indent); |
---|
527 | if (indent[strlen(indent)-1]!='\n') { |
---|
528 | owl_fmtext_append_normal(fm, "\n"); |
---|
529 | } |
---|
530 | owl_free(indent); |
---|
531 | } |
---|
532 | } else if (owl_message_is_type_admin(m)) { |
---|
533 | char *text, *header, *indent; |
---|
534 | |
---|
535 | text=owl_message_get_body(m); |
---|
536 | header=owl_message_get_attribute_value(m, "adminheader"); |
---|
537 | |
---|
538 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
539 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
540 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
541 | owl_fmtext_append_bold(fm, "OWL ADMIN "); |
---|
542 | owl_fmtext_append_ztext(fm, header); |
---|
543 | owl_fmtext_append_normal(fm, "\n"); |
---|
544 | owl_fmtext_append_ztext(fm, indent); |
---|
545 | if (text[strlen(text)-1]!='\n') { |
---|
546 | owl_fmtext_append_normal(fm, "\n"); |
---|
547 | } |
---|
548 | |
---|
549 | owl_free(indent); |
---|
550 | } else { |
---|
551 | |
---|
552 | } |
---|
553 | } |
---|