[bd3f232] | 1 | #include "owl.h" |
---|
| 2 | |
---|
| 3 | static const char fileIdent[] = "$Id$"; |
---|
| 4 | |
---|
[5639bf2] | 5 | /* In all of these functions, 'fm' is expected to already be |
---|
| 6 | * initialized. |
---|
| 7 | */ |
---|
| 8 | |
---|
[bd3f232] | 9 | void owl_stylefunc_basic(owl_fmtext *fm, owl_message *m) |
---|
| 10 | { |
---|
[09489b89] | 11 | #ifdef HAVE_LIBZEPHYR |
---|
[bd3f232] | 12 | char *body, *indent, *ptr, *zsigbuff, frombuff[LINE]; |
---|
| 13 | ZNotice_t *n; |
---|
[09489b89] | 14 | #endif |
---|
[bd3f232] | 15 | |
---|
| 16 | if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { |
---|
[09489b89] | 17 | #ifdef HAVE_LIBZEPHYR |
---|
[bd3f232] | 18 | n=owl_message_get_notice(m); |
---|
[09489b89] | 19 | |
---|
[bd3f232] | 20 | /* get the body */ |
---|
| 21 | body=owl_strdup(owl_message_get_body(m)); |
---|
| 22 | body=realloc(body, strlen(body)+30); |
---|
| 23 | |
---|
| 24 | /* add a newline if we need to */ |
---|
| 25 | if (body[0]!='\0' && body[strlen(body)-1]!='\n') { |
---|
| 26 | strcat(body, "\n"); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | /* do the indenting into indent */ |
---|
| 30 | indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10); |
---|
| 31 | owl_text_indent(indent, body, OWL_MSGTAB); |
---|
| 32 | |
---|
| 33 | /* edit the from addr for printing */ |
---|
| 34 | strcpy(frombuff, owl_message_get_sender(m)); |
---|
| 35 | ptr=strchr(frombuff, '@'); |
---|
[09489b89] | 36 | if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) { |
---|
[bd3f232] | 37 | *ptr='\0'; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | /* set the message for printing */ |
---|
| 41 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 42 | |
---|
[8b32593] | 43 | if (owl_message_is_ping(m)) { |
---|
[bd3f232] | 44 | owl_fmtext_append_bold(fm, "PING"); |
---|
| 45 | owl_fmtext_append_normal(fm, " from "); |
---|
| 46 | owl_fmtext_append_bold(fm, frombuff); |
---|
| 47 | owl_fmtext_append_normal(fm, "\n"); |
---|
[8b32593] | 48 | } else if (owl_message_is_loginout(m)) { |
---|
[778d0a9] | 49 | char *ptr, *host, *tty; |
---|
[bd3f232] | 50 | int len; |
---|
[778d0a9] | 51 | |
---|
[bd3f232] | 52 | ptr=owl_zephyr_get_field(n, 1, &len); |
---|
[778d0a9] | 53 | host=owl_malloc(len+10); |
---|
[bd3f232] | 54 | strncpy(host, ptr, len); |
---|
| 55 | host[len]='\0'; |
---|
[778d0a9] | 56 | |
---|
[bd3f232] | 57 | ptr=owl_zephyr_get_field(n, 3, &len); |
---|
[778d0a9] | 58 | tty=owl_malloc(len+10); |
---|
[bd3f232] | 59 | strncpy(tty, ptr, len); |
---|
| 60 | tty[len]='\0'; |
---|
[8b32593] | 61 | |
---|
| 62 | if (owl_message_is_login(m)) { |
---|
[bd3f232] | 63 | owl_fmtext_append_bold(fm, "LOGIN"); |
---|
[8b32593] | 64 | } else if (owl_message_is_logout(m)) { |
---|
[bd3f232] | 65 | owl_fmtext_append_bold(fm, "LOGOUT"); |
---|
| 66 | } |
---|
| 67 | owl_fmtext_append_normal(fm, " for "); |
---|
| 68 | ptr=short_zuser(owl_message_get_instance(m)); |
---|
| 69 | owl_fmtext_append_bold(fm, ptr); |
---|
| 70 | owl_free(ptr); |
---|
| 71 | owl_fmtext_append_normal(fm, " at "); |
---|
| 72 | owl_fmtext_append_normal(fm, host); |
---|
| 73 | owl_fmtext_append_normal(fm, " "); |
---|
| 74 | owl_fmtext_append_normal(fm, tty); |
---|
| 75 | owl_fmtext_append_normal(fm, "\n"); |
---|
[778d0a9] | 76 | |
---|
| 77 | owl_free(host); |
---|
| 78 | owl_free(tty); |
---|
[bd3f232] | 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); |
---|
[03955f3] | 89 | if (strcasecmp(owl_message_get_realm(m), owl_zephyr_get_realm())) { |
---|
[bd3f232] | 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_fmtext_append_ztext(fm, indent); |
---|
| 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 | owl_free(body); |
---|
| 116 | owl_free(indent); |
---|
[09489b89] | 117 | #endif |
---|
[bd3f232] | 118 | } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) { |
---|
| 119 | char *indent, *text, *zsigbuff, *foo; |
---|
| 120 | |
---|
| 121 | text=owl_message_get_body(m); |
---|
| 122 | |
---|
| 123 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 124 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 125 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 126 | owl_fmtext_append_normal(fm, "To: "); |
---|
| 127 | foo=short_zuser(owl_message_get_recipient(m)); |
---|
| 128 | owl_fmtext_append_normal(fm, foo); |
---|
| 129 | owl_free(foo); |
---|
| 130 | owl_fmtext_append_normal(fm, " (Zsig: "); |
---|
| 131 | |
---|
| 132 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
| 133 | owl_message_pretty_zsig(m, zsigbuff); |
---|
| 134 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
| 135 | owl_free(zsigbuff); |
---|
| 136 | |
---|
| 137 | owl_fmtext_append_normal(fm, ")"); |
---|
| 138 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 139 | owl_fmtext_append_ztext(fm, indent); |
---|
| 140 | if (text[strlen(text)-1]!='\n') { |
---|
| 141 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | owl_free(indent); |
---|
| 145 | } else if (owl_message_is_type_aim(m)) { |
---|
| 146 | char *indent; |
---|
| 147 | |
---|
| 148 | if (owl_message_is_loginout(m)) { |
---|
| 149 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 150 | if (owl_message_is_login(m)) { |
---|
| 151 | owl_fmtext_append_bold(fm, "AIM LOGIN"); |
---|
| 152 | } else { |
---|
| 153 | owl_fmtext_append_bold(fm, "AIM LOGOUT"); |
---|
| 154 | } |
---|
| 155 | owl_fmtext_append_normal(fm, " for "); |
---|
| 156 | owl_fmtext_append_normal(fm, owl_message_get_sender(m)); |
---|
| 157 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 158 | } else if (owl_message_is_direction_in(m)) { |
---|
| 159 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 160 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 161 | owl_fmtext_append_bold(fm, OWL_TABSTR); |
---|
| 162 | owl_fmtext_append_bold(fm, "AIM from "); |
---|
| 163 | owl_fmtext_append_bold(fm, owl_message_get_sender(m)); |
---|
| 164 | owl_fmtext_append_bold(fm, "\n"); |
---|
| 165 | owl_fmtext_append_bold(fm, indent); |
---|
| 166 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 167 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 168 | } |
---|
| 169 | owl_free(indent); |
---|
| 170 | } else if (owl_message_is_direction_out(m)) { |
---|
| 171 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 172 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 173 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 174 | owl_fmtext_append_normal(fm, "AIM sent to "); |
---|
| 175 | owl_fmtext_append_normal(fm, owl_message_get_recipient(m)); |
---|
| 176 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 177 | owl_fmtext_append_ztext(fm, indent); |
---|
| 178 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 179 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 180 | } |
---|
| 181 | owl_free(indent); |
---|
| 182 | } |
---|
| 183 | } else if (owl_message_is_type_admin(m)) { |
---|
| 184 | char *text, *header, *indent; |
---|
| 185 | |
---|
| 186 | text=owl_message_get_body(m); |
---|
| 187 | header=owl_message_get_attribute_value(m, "adminheader"); |
---|
| 188 | |
---|
| 189 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 190 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 191 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 192 | owl_fmtext_append_bold(fm, "OWL ADMIN "); |
---|
| 193 | owl_fmtext_append_ztext(fm, header); |
---|
| 194 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 195 | owl_fmtext_append_ztext(fm, indent); |
---|
| 196 | if (text[strlen(text)-1]!='\n') { |
---|
| 197 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | owl_free(indent); |
---|
[37eab7f] | 201 | } else { |
---|
| 202 | char *text, *header, *indent; |
---|
| 203 | |
---|
| 204 | text=owl_message_get_body(m); |
---|
| 205 | header=owl_sprintf("%s from: %s to: %s", |
---|
| 206 | owl_message_get_type(m), |
---|
| 207 | owl_message_get_sender(m), |
---|
| 208 | owl_message_get_recipient(m)); |
---|
| 209 | |
---|
| 210 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 211 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 212 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 213 | owl_fmtext_append_normal(fm, header); |
---|
| 214 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 215 | owl_fmtext_append_normal(fm, indent); |
---|
| 216 | if (text[strlen(text)-1]!='\n') { |
---|
| 217 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | owl_free(indent); |
---|
| 221 | owl_free(header); |
---|
[bd3f232] | 222 | } |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | void owl_stylefunc_default(owl_fmtext *fm, owl_message *m) |
---|
| 226 | { |
---|
[25dd31a] | 227 | char *shorttimestr; |
---|
[09489b89] | 228 | #ifdef HAVE_LIBZEPHYR |
---|
[bd3f232] | 229 | char *body, *indent, *ptr, *zsigbuff, frombuff[LINE]; |
---|
| 230 | ZNotice_t *n; |
---|
[09489b89] | 231 | #endif |
---|
[bd3f232] | 232 | |
---|
[25dd31a] | 233 | shorttimestr=owl_message_get_shorttimestr(m); |
---|
| 234 | |
---|
[bd3f232] | 235 | if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { |
---|
[09489b89] | 236 | #ifdef HAVE_LIBZEPHYR |
---|
[bd3f232] | 237 | n=owl_message_get_notice(m); |
---|
[09489b89] | 238 | |
---|
[bd3f232] | 239 | /* get the body */ |
---|
| 240 | body=owl_malloc(strlen(owl_message_get_body(m))+30); |
---|
| 241 | strcpy(body, owl_message_get_body(m)); |
---|
| 242 | |
---|
| 243 | /* add a newline if we need to */ |
---|
| 244 | if (body[0]!='\0' && body[strlen(body)-1]!='\n') { |
---|
| 245 | strcat(body, "\n"); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | /* do the indenting into indent */ |
---|
| 249 | indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10); |
---|
| 250 | owl_text_indent(indent, body, OWL_MSGTAB); |
---|
| 251 | |
---|
| 252 | /* edit the from addr for printing */ |
---|
| 253 | strcpy(frombuff, owl_message_get_sender(m)); |
---|
| 254 | ptr=strchr(frombuff, '@'); |
---|
[09489b89] | 255 | if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) { |
---|
[bd3f232] | 256 | *ptr='\0'; |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | /* set the message for printing */ |
---|
| 260 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 261 | |
---|
[8b32593] | 262 | if (owl_message_is_ping(m) && owl_message_is_private(m)) { |
---|
[bd3f232] | 263 | owl_fmtext_append_bold(fm, "PING"); |
---|
| 264 | owl_fmtext_append_normal(fm, " from "); |
---|
| 265 | owl_fmtext_append_bold(fm, frombuff); |
---|
| 266 | owl_fmtext_append_normal(fm, "\n"); |
---|
[8b32593] | 267 | } else if (owl_message_is_loginout(m)) { |
---|
[778d0a9] | 268 | char *ptr, *host, *tty; |
---|
[bd3f232] | 269 | int len; |
---|
[778d0a9] | 270 | |
---|
[bd3f232] | 271 | ptr=owl_zephyr_get_field(n, 1, &len); |
---|
[778d0a9] | 272 | host=owl_malloc(len+10); |
---|
[bd3f232] | 273 | strncpy(host, ptr, len); |
---|
| 274 | host[len]='\0'; |
---|
[778d0a9] | 275 | |
---|
[bd3f232] | 276 | ptr=owl_zephyr_get_field(n, 3, &len); |
---|
[778d0a9] | 277 | tty=owl_malloc(len+10); |
---|
[bd3f232] | 278 | strncpy(tty, ptr, len); |
---|
| 279 | tty[len]='\0'; |
---|
| 280 | |
---|
[8b32593] | 281 | if (owl_message_is_login(m)) { |
---|
[bd3f232] | 282 | owl_fmtext_append_bold(fm, "LOGIN"); |
---|
[8b32593] | 283 | } else if (owl_message_is_logout(m)) { |
---|
[bd3f232] | 284 | owl_fmtext_append_bold(fm, "LOGOUT"); |
---|
| 285 | } |
---|
| 286 | owl_fmtext_append_normal(fm, " for "); |
---|
[03955f3] | 287 | ptr=short_zuser(owl_message_get_instance(m)); |
---|
[bd3f232] | 288 | owl_fmtext_append_bold(fm, ptr); |
---|
| 289 | owl_free(ptr); |
---|
| 290 | owl_fmtext_append_normal(fm, " at "); |
---|
| 291 | owl_fmtext_append_normal(fm, host); |
---|
| 292 | owl_fmtext_append_normal(fm, " "); |
---|
| 293 | owl_fmtext_append_normal(fm, tty); |
---|
[c7041b3] | 294 | owl_fmtext_append_normal(fm, " "); |
---|
| 295 | owl_fmtext_append_normal(fm, shorttimestr); |
---|
[bd3f232] | 296 | owl_fmtext_append_normal(fm, "\n"); |
---|
[778d0a9] | 297 | |
---|
| 298 | owl_free(host); |
---|
| 299 | owl_free(tty); |
---|
[bd3f232] | 300 | } else { |
---|
| 301 | owl_fmtext_append_normal(fm, owl_message_get_class(m)); |
---|
| 302 | owl_fmtext_append_normal(fm, " / "); |
---|
| 303 | owl_fmtext_append_normal(fm, owl_message_get_instance(m)); |
---|
| 304 | owl_fmtext_append_normal(fm, " / "); |
---|
| 305 | owl_fmtext_append_bold(fm, frombuff); |
---|
| 306 | if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) { |
---|
| 307 | owl_fmtext_append_normal(fm, " {"); |
---|
| 308 | owl_fmtext_append_normal(fm, owl_message_get_realm(m)); |
---|
[25dd31a] | 309 | owl_fmtext_append_normal(fm, "}"); |
---|
[bd3f232] | 310 | } |
---|
[03955f3] | 311 | if (strcmp(owl_message_get_opcode(m), "")) { |
---|
[bd3f232] | 312 | owl_fmtext_append_normal(fm, " ["); |
---|
| 313 | owl_fmtext_append_normal(fm, owl_message_get_opcode(m)); |
---|
[25dd31a] | 314 | owl_fmtext_append_normal(fm, "]"); |
---|
[bd3f232] | 315 | } |
---|
[25dd31a] | 316 | |
---|
| 317 | owl_fmtext_append_normal(fm, " "); |
---|
| 318 | owl_fmtext_append_normal(fm, shorttimestr); |
---|
| 319 | |
---|
[bd3f232] | 320 | /* stick on the zsig */ |
---|
| 321 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
| 322 | owl_message_pretty_zsig(m, zsigbuff); |
---|
| 323 | owl_fmtext_append_normal(fm, " ("); |
---|
| 324 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
| 325 | owl_fmtext_append_normal(fm, ")"); |
---|
| 326 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 327 | owl_free(zsigbuff); |
---|
| 328 | |
---|
| 329 | /* then the indented message */ |
---|
| 330 | owl_fmtext_append_ztext(fm, indent); |
---|
| 331 | |
---|
| 332 | /* make private messages bold for smaat users */ |
---|
| 333 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { |
---|
| 334 | if (owl_message_is_personal(m)) { |
---|
| 335 | owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD); |
---|
| 336 | } |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | owl_free(body); |
---|
| 341 | owl_free(indent); |
---|
[09489b89] | 342 | #endif |
---|
[bd3f232] | 343 | } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) { |
---|
| 344 | char *indent, *text, *zsigbuff, *foo; |
---|
| 345 | |
---|
| 346 | text=owl_message_get_body(m); |
---|
| 347 | |
---|
| 348 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 349 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 350 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 351 | owl_fmtext_append_normal(fm, "Zephyr sent to "); |
---|
| 352 | foo=short_zuser(owl_message_get_recipient(m)); |
---|
| 353 | owl_fmtext_append_normal(fm, foo); |
---|
| 354 | owl_free(foo); |
---|
[25dd31a] | 355 | |
---|
| 356 | owl_fmtext_append_normal(fm, " "); |
---|
| 357 | owl_fmtext_append_normal(fm, shorttimestr); |
---|
| 358 | |
---|
[bd3f232] | 359 | owl_fmtext_append_normal(fm, " (Zsig: "); |
---|
| 360 | |
---|
| 361 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
| 362 | owl_message_pretty_zsig(m, zsigbuff); |
---|
| 363 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
| 364 | owl_free(zsigbuff); |
---|
| 365 | |
---|
| 366 | owl_fmtext_append_normal(fm, ")"); |
---|
| 367 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 368 | owl_fmtext_append_ztext(fm, indent); |
---|
| 369 | if (text[strlen(text)-1]!='\n') { |
---|
| 370 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | owl_free(indent); |
---|
| 374 | } else if (owl_message_is_type_aim(m)) { |
---|
| 375 | char *indent; |
---|
| 376 | |
---|
| 377 | if (owl_message_is_loginout(m)) { |
---|
| 378 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 379 | if (owl_message_is_login(m)) { |
---|
| 380 | owl_fmtext_append_bold(fm, "AIM LOGIN"); |
---|
| 381 | } else { |
---|
| 382 | owl_fmtext_append_bold(fm, "AIM LOGOUT"); |
---|
| 383 | } |
---|
| 384 | owl_fmtext_append_normal(fm, " for "); |
---|
| 385 | owl_fmtext_append_normal(fm, owl_message_get_sender(m)); |
---|
[c7041b3] | 386 | owl_fmtext_append_normal(fm, " "); |
---|
| 387 | owl_fmtext_append_normal(fm, shorttimestr); |
---|
[bd3f232] | 388 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 389 | } else if (owl_message_is_direction_in(m)) { |
---|
| 390 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 391 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 392 | owl_fmtext_append_bold(fm, OWL_TABSTR); |
---|
| 393 | owl_fmtext_append_bold(fm, "AIM from "); |
---|
| 394 | owl_fmtext_append_bold(fm, owl_message_get_sender(m)); |
---|
[25dd31a] | 395 | |
---|
| 396 | owl_fmtext_append_normal(fm, " "); |
---|
| 397 | owl_fmtext_append_normal(fm, shorttimestr); |
---|
| 398 | |
---|
[bd3f232] | 399 | owl_fmtext_append_bold(fm, "\n"); |
---|
| 400 | owl_fmtext_append_bold(fm, indent); |
---|
| 401 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 402 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 403 | } |
---|
| 404 | owl_free(indent); |
---|
| 405 | } else if (owl_message_is_direction_out(m)) { |
---|
| 406 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 407 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 408 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 409 | owl_fmtext_append_normal(fm, "AIM sent to "); |
---|
| 410 | owl_fmtext_append_normal(fm, owl_message_get_recipient(m)); |
---|
[25dd31a] | 411 | owl_fmtext_append_normal(fm, " "); |
---|
| 412 | owl_fmtext_append_normal(fm, shorttimestr); |
---|
[bd3f232] | 413 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 414 | owl_fmtext_append_ztext(fm, indent); |
---|
| 415 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 416 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 417 | } |
---|
| 418 | owl_free(indent); |
---|
| 419 | } |
---|
| 420 | } else if (owl_message_is_type_admin(m)) { |
---|
| 421 | char *text, *header, *indent; |
---|
| 422 | |
---|
| 423 | text=owl_message_get_body(m); |
---|
| 424 | header=owl_message_get_attribute_value(m, "adminheader"); |
---|
| 425 | |
---|
| 426 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 427 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 428 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 429 | owl_fmtext_append_bold(fm, "OWL ADMIN "); |
---|
| 430 | owl_fmtext_append_ztext(fm, header); |
---|
| 431 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 432 | owl_fmtext_append_ztext(fm, indent); |
---|
| 433 | if (text[strlen(text)-1]!='\n') { |
---|
| 434 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | owl_free(indent); |
---|
[37eab7f] | 438 | } else { |
---|
| 439 | char *text, *header, *indent; |
---|
| 440 | |
---|
| 441 | text=owl_message_get_body(m); |
---|
| 442 | header=owl_sprintf("%s from: %s to: %s", |
---|
| 443 | owl_message_get_type(m), |
---|
| 444 | owl_message_get_sender(m), |
---|
| 445 | owl_message_get_recipient(m)); |
---|
| 446 | |
---|
| 447 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 448 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 449 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 450 | owl_fmtext_append_normal(fm, header); |
---|
[25dd31a] | 451 | owl_fmtext_append_normal(fm, " "); |
---|
| 452 | owl_fmtext_append_normal(fm, shorttimestr); |
---|
[37eab7f] | 453 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 454 | owl_fmtext_append_normal(fm, indent); |
---|
| 455 | if (text[strlen(text)-1]!='\n') { |
---|
| 456 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | owl_free(indent); |
---|
| 460 | owl_free(header); |
---|
[bd3f232] | 461 | } |
---|
[25dd31a] | 462 | owl_free(shorttimestr); |
---|
[bd3f232] | 463 | } |
---|
[8b32593] | 464 | |
---|
| 465 | void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m) |
---|
| 466 | { |
---|
| 467 | char *tmp; |
---|
[5ea6fea] | 468 | char *baseformat="%s %-13.13s %-11.11s %-12.12s "; |
---|
| 469 | char *sender, *recip; |
---|
[09489b89] | 470 | #ifdef HAVE_LIBZEPHYR |
---|
[778d0a9] | 471 | ZNotice_t *n; |
---|
[09489b89] | 472 | #endif |
---|
[8b32593] | 473 | |
---|
[5ea6fea] | 474 | sender=short_zuser(owl_message_get_sender(m)); |
---|
| 475 | recip=short_zuser(owl_message_get_recipient(m)); |
---|
| 476 | |
---|
[8b32593] | 477 | if (owl_message_is_type_zephyr(m)) { |
---|
[09489b89] | 478 | #ifdef HAVE_LIBZEPHYR |
---|
[778d0a9] | 479 | n=owl_message_get_notice(m); |
---|
| 480 | |
---|
[8b32593] | 481 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
[778d0a9] | 482 | |
---|
| 483 | if (owl_message_is_loginout(m)) { |
---|
| 484 | char *ptr, *host, *tty; |
---|
| 485 | int len; |
---|
| 486 | |
---|
| 487 | ptr=owl_zephyr_get_field(n, 1, &len); |
---|
| 488 | host=owl_malloc(len+10); |
---|
| 489 | strncpy(host, ptr, len); |
---|
| 490 | host[len]='\0'; |
---|
| 491 | |
---|
| 492 | ptr=owl_zephyr_get_field(n, 3, &len); |
---|
| 493 | tty=owl_malloc(len+10); |
---|
| 494 | strncpy(tty, ptr, len); |
---|
| 495 | tty[len]='\0'; |
---|
| 496 | |
---|
| 497 | if (owl_message_is_login(m)) { |
---|
| 498 | tmp=owl_sprintf(baseformat, "<", "LOGIN", "", sender); |
---|
| 499 | owl_fmtext_append_normal(fm, tmp); |
---|
| 500 | owl_free(tmp); |
---|
| 501 | } else if (owl_message_is_logout(m)) { |
---|
| 502 | tmp=owl_sprintf(baseformat, "<", "LOGOUT", "", sender); |
---|
| 503 | owl_fmtext_append_normal(fm, tmp); |
---|
| 504 | owl_free(tmp); |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | owl_fmtext_append_normal(fm, "at "); |
---|
| 508 | owl_fmtext_append_normal(fm, host); |
---|
| 509 | owl_fmtext_append_normal(fm, " "); |
---|
| 510 | owl_fmtext_append_normal(fm, tty); |
---|
[8b32593] | 511 | owl_fmtext_append_normal(fm, "\n"); |
---|
[778d0a9] | 512 | |
---|
| 513 | owl_free(host); |
---|
| 514 | owl_free(tty); |
---|
| 515 | |
---|
[8b32593] | 516 | } else if (owl_message_is_ping(m)) { |
---|
[5ea6fea] | 517 | tmp=owl_sprintf(baseformat, "<", "PING", "", sender); |
---|
[8b32593] | 518 | owl_fmtext_append_normal(fm, tmp); |
---|
| 519 | owl_fmtext_append_normal(fm, "\n"); |
---|
[5ea6fea] | 520 | owl_free(tmp); |
---|
[778d0a9] | 521 | |
---|
[8b32593] | 522 | } else { |
---|
| 523 | if (owl_message_is_direction_in(m)) { |
---|
[5ea6fea] | 524 | tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender); |
---|
[8b32593] | 525 | } else if (owl_message_is_direction_out(m)) { |
---|
[5ea6fea] | 526 | tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip); |
---|
[8b32593] | 527 | } else { |
---|
[5ea6fea] | 528 | tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender); |
---|
[8b32593] | 529 | } |
---|
| 530 | owl_fmtext_append_normal(fm, tmp); |
---|
| 531 | if (tmp) owl_free(tmp); |
---|
| 532 | |
---|
| 533 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
[e3d9c77] | 534 | owl_text_tr(tmp, '\n', ' '); |
---|
[65e3901] | 535 | owl_fmtext_append_ztext(fm, tmp); |
---|
[8b32593] | 536 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 537 | if (tmp) owl_free(tmp); |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | /* make personal messages bold for smaat users */ |
---|
[c3ab155] | 541 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && |
---|
| 542 | owl_message_is_personal(m) && |
---|
| 543 | owl_message_is_direction_in(m)) { |
---|
[8b32593] | 544 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
| 545 | } |
---|
[5ea6fea] | 546 | |
---|
| 547 | owl_free(sender); |
---|
| 548 | owl_free(recip); |
---|
[09489b89] | 549 | #endif |
---|
[8b32593] | 550 | } else if (owl_message_is_type_aim(m)) { |
---|
| 551 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
| 552 | if (owl_message_is_login(m)) { |
---|
[5ea6fea] | 553 | tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m)); |
---|
[8b32593] | 554 | owl_fmtext_append_normal(fm, tmp); |
---|
| 555 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 556 | if (tmp) owl_free(tmp); |
---|
| 557 | } else if (owl_message_is_logout(m)) { |
---|
[5ea6fea] | 558 | tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m)); |
---|
[8b32593] | 559 | owl_fmtext_append_normal(fm, tmp); |
---|
| 560 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 561 | if (tmp) owl_free(tmp); |
---|
| 562 | } else { |
---|
| 563 | if (owl_message_is_direction_in(m)) { |
---|
[5ea6fea] | 564 | tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m)); |
---|
[8b32593] | 565 | owl_fmtext_append_normal(fm, tmp); |
---|
| 566 | if (tmp) owl_free(tmp); |
---|
| 567 | } else if (owl_message_is_direction_out(m)) { |
---|
[5ea6fea] | 568 | tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m)); |
---|
[8b32593] | 569 | owl_fmtext_append_normal(fm, tmp); |
---|
| 570 | if (tmp) owl_free(tmp); |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
[e3d9c77] | 574 | owl_text_tr(tmp, '\n', ' '); |
---|
[8b32593] | 575 | owl_fmtext_append_normal(fm, tmp); |
---|
| 576 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 577 | if (tmp) owl_free(tmp); |
---|
| 578 | |
---|
[0c502e9] | 579 | /* make personal messages bold for smaat users */ |
---|
[9c4ec91] | 580 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) { |
---|
[0c502e9] | 581 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
| 582 | } |
---|
[8b32593] | 583 | } |
---|
| 584 | } else if (owl_message_is_type_admin(m)) { |
---|
| 585 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
| 586 | owl_fmtext_append_normal(fm, "< ADMIN "); |
---|
| 587 | |
---|
| 588 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
[e3d9c77] | 589 | owl_text_tr(tmp, '\n', ' '); |
---|
[8b32593] | 590 | owl_fmtext_append_normal(fm, tmp); |
---|
| 591 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 592 | if (tmp) owl_free(tmp); |
---|
[37eab7f] | 593 | } else { |
---|
| 594 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
| 595 | owl_fmtext_append_normal(fm, "< LOOPBACK "); |
---|
| 596 | |
---|
| 597 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
[e3d9c77] | 598 | owl_text_tr(tmp, '\n', ' '); |
---|
[37eab7f] | 599 | owl_fmtext_append_normal(fm, tmp); |
---|
| 600 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 601 | if (tmp) owl_free(tmp); |
---|
| 602 | } |
---|
[8b32593] | 603 | |
---|
| 604 | } |
---|
[ec6ff52] | 605 | |
---|
| 606 | void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m) |
---|
| 607 | { |
---|
| 608 | #ifdef HAVE_LIBZEPHYR |
---|
| 609 | char *body, *indent, *ptr, *zsigbuff, frombuff[LINE]; |
---|
| 610 | owl_fmtext fm_first, fm_other, fm_tmp; |
---|
| 611 | ZNotice_t *n; |
---|
| 612 | #endif |
---|
| 613 | char *sender, *hostname, *timestr, *classinst1, *classinst2; |
---|
| 614 | |
---|
| 615 | if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { |
---|
| 616 | #ifdef HAVE_LIBZEPHYR |
---|
| 617 | n=owl_message_get_notice(m); |
---|
| 618 | |
---|
| 619 | /* get the body */ |
---|
| 620 | body=owl_malloc(strlen(owl_message_get_body(m))+30); |
---|
| 621 | strcpy(body, owl_message_get_body(m)); |
---|
| 622 | |
---|
| 623 | /* add a newline if we need to */ |
---|
| 624 | if (body[0]!='\0' && body[strlen(body)-1]!='\n') { |
---|
| 625 | strcat(body, "\n"); |
---|
| 626 | } |
---|
| 627 | |
---|
| 628 | owl_fmtext_init_null(&fm_tmp); |
---|
| 629 | owl_fmtext_append_ztext(&fm_tmp, body); |
---|
| 630 | owl_fmtext_init_null(&fm_first); |
---|
| 631 | owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first); |
---|
| 632 | |
---|
| 633 | /* do the indenting into indent */ |
---|
| 634 | indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10); |
---|
| 635 | owl_text_indent(indent, body, 31); |
---|
| 636 | |
---|
| 637 | owl_fmtext_free(&fm_tmp); |
---|
| 638 | owl_fmtext_init_null(&fm_tmp); |
---|
| 639 | owl_fmtext_append_ztext(&fm_tmp, indent); |
---|
| 640 | owl_fmtext_init_null(&fm_other); |
---|
| 641 | owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other); |
---|
| 642 | owl_fmtext_free(&fm_tmp); |
---|
| 643 | |
---|
| 644 | /* edit the from addr for printing */ |
---|
| 645 | strcpy(frombuff, owl_message_get_sender(m)); |
---|
| 646 | ptr=strchr(frombuff, '@'); |
---|
| 647 | if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) { |
---|
| 648 | *ptr='\0'; |
---|
| 649 | } |
---|
| 650 | sender=owl_sprintf("%-9.9s", frombuff); |
---|
| 651 | |
---|
| 652 | hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m)); |
---|
| 653 | timestr=owl_strdup("00:00"); |
---|
| 654 | classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m)); |
---|
| 655 | classinst2=owl_sprintf("%-9.9s", classinst1); |
---|
| 656 | |
---|
| 657 | /* set the message for printing */ |
---|
| 658 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 659 | |
---|
| 660 | if (owl_message_is_ping(m) && owl_message_is_private(m)) { |
---|
| 661 | owl_fmtext_append_bold(fm, "PING"); |
---|
| 662 | owl_fmtext_append_normal(fm, " from "); |
---|
| 663 | owl_fmtext_append_bold(fm, frombuff); |
---|
| 664 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 665 | } else if (owl_message_is_loginout(m)) { |
---|
| 666 | char *ptr, *host, *tty; |
---|
| 667 | int len; |
---|
| 668 | |
---|
| 669 | ptr=owl_zephyr_get_field(n, 1, &len); |
---|
| 670 | host=owl_malloc(len+10); |
---|
| 671 | strncpy(host, ptr, len); |
---|
| 672 | host[len]='\0'; |
---|
| 673 | |
---|
| 674 | ptr=owl_zephyr_get_field(n, 3, &len); |
---|
| 675 | tty=owl_malloc(len+10); |
---|
| 676 | strncpy(tty, ptr, len); |
---|
| 677 | tty[len]='\0'; |
---|
| 678 | |
---|
| 679 | if (owl_message_is_login(m)) { |
---|
| 680 | owl_fmtext_append_bold(fm, "LOGIN"); |
---|
| 681 | } else if (owl_message_is_logout(m)) { |
---|
| 682 | owl_fmtext_append_bold(fm, "LOGOUT"); |
---|
| 683 | } |
---|
| 684 | owl_fmtext_append_normal(fm, " for "); |
---|
| 685 | ptr=short_zuser(owl_message_get_instance(m)); |
---|
| 686 | owl_fmtext_append_bold(fm, ptr); |
---|
| 687 | owl_free(ptr); |
---|
| 688 | owl_fmtext_append_normal(fm, " at "); |
---|
| 689 | owl_fmtext_append_normal(fm, host); |
---|
| 690 | owl_fmtext_append_normal(fm, " "); |
---|
| 691 | owl_fmtext_append_normal(fm, tty); |
---|
| 692 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 693 | |
---|
| 694 | owl_free(host); |
---|
| 695 | owl_free(tty); |
---|
| 696 | } else { |
---|
| 697 | owl_fmtext_append_normal(fm, sender); |
---|
| 698 | owl_fmtext_append_normal(fm, "|"); |
---|
| 699 | owl_fmtext_append_normal(fm, hostname); |
---|
| 700 | owl_fmtext_append_normal(fm, " "); |
---|
| 701 | owl_fmtext_append_normal(fm, timestr); |
---|
| 702 | owl_fmtext_append_normal(fm, " "); |
---|
| 703 | owl_fmtext_append_normal(fm, classinst2); |
---|
| 704 | |
---|
| 705 | owl_fmtext_append_normal(fm, " "); |
---|
| 706 | owl_fmtext_append_fmtext(fm, &fm_first); |
---|
| 707 | owl_fmtext_append_fmtext(fm, &fm_other); |
---|
| 708 | |
---|
| 709 | owl_fmtext_free(&fm_other); |
---|
| 710 | owl_fmtext_free(&fm_first); |
---|
| 711 | |
---|
| 712 | /* make private messages bold for smaat users */ |
---|
| 713 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { |
---|
| 714 | if (owl_message_is_personal(m)) { |
---|
| 715 | owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD); |
---|
| 716 | } |
---|
| 717 | } |
---|
| 718 | } |
---|
| 719 | |
---|
| 720 | owl_free(sender); |
---|
| 721 | owl_free(hostname); |
---|
| 722 | owl_free(timestr); |
---|
| 723 | owl_free(classinst1); |
---|
| 724 | owl_free(classinst2); |
---|
| 725 | |
---|
| 726 | owl_free(body); |
---|
| 727 | owl_free(indent); |
---|
| 728 | #endif |
---|
| 729 | } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) { |
---|
| 730 | char *indent, *text, *zsigbuff, *foo; |
---|
| 731 | |
---|
| 732 | text=owl_message_get_body(m); |
---|
| 733 | |
---|
| 734 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 735 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 736 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 737 | owl_fmtext_append_normal(fm, "Zephyr sent to "); |
---|
| 738 | foo=short_zuser(owl_message_get_recipient(m)); |
---|
| 739 | owl_fmtext_append_normal(fm, foo); |
---|
| 740 | owl_free(foo); |
---|
| 741 | owl_fmtext_append_normal(fm, " (Zsig: "); |
---|
| 742 | |
---|
| 743 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
| 744 | owl_message_pretty_zsig(m, zsigbuff); |
---|
| 745 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
| 746 | owl_free(zsigbuff); |
---|
| 747 | |
---|
| 748 | owl_fmtext_append_normal(fm, ")"); |
---|
| 749 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 750 | owl_fmtext_append_ztext(fm, indent); |
---|
| 751 | if (text[strlen(text)-1]!='\n') { |
---|
| 752 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | owl_free(indent); |
---|
| 756 | } else if (owl_message_is_type_aim(m)) { |
---|
| 757 | char *indent; |
---|
| 758 | |
---|
| 759 | if (owl_message_is_loginout(m)) { |
---|
| 760 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 761 | if (owl_message_is_login(m)) { |
---|
| 762 | owl_fmtext_append_bold(fm, "AIM LOGIN"); |
---|
| 763 | } else { |
---|
| 764 | owl_fmtext_append_bold(fm, "AIM LOGOUT"); |
---|
| 765 | } |
---|
| 766 | owl_fmtext_append_normal(fm, " for "); |
---|
| 767 | owl_fmtext_append_normal(fm, owl_message_get_sender(m)); |
---|
| 768 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 769 | } else if (owl_message_is_direction_in(m)) { |
---|
| 770 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 771 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 772 | owl_fmtext_append_bold(fm, OWL_TABSTR); |
---|
| 773 | owl_fmtext_append_bold(fm, "AIM from "); |
---|
| 774 | owl_fmtext_append_bold(fm, owl_message_get_sender(m)); |
---|
| 775 | owl_fmtext_append_bold(fm, "\n"); |
---|
| 776 | owl_fmtext_append_bold(fm, indent); |
---|
| 777 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 778 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 779 | } |
---|
| 780 | owl_free(indent); |
---|
| 781 | } else if (owl_message_is_direction_out(m)) { |
---|
| 782 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 783 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 784 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 785 | owl_fmtext_append_normal(fm, "AIM sent to "); |
---|
| 786 | owl_fmtext_append_normal(fm, owl_message_get_recipient(m)); |
---|
| 787 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 788 | owl_fmtext_append_ztext(fm, indent); |
---|
| 789 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 790 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 791 | } |
---|
| 792 | owl_free(indent); |
---|
| 793 | } |
---|
| 794 | } else if (owl_message_is_type_admin(m)) { |
---|
| 795 | char *text, *header, *indent; |
---|
| 796 | |
---|
| 797 | text=owl_message_get_body(m); |
---|
| 798 | header=owl_message_get_attribute_value(m, "adminheader"); |
---|
| 799 | |
---|
| 800 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 801 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 802 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 803 | owl_fmtext_append_bold(fm, "OWL ADMIN "); |
---|
| 804 | owl_fmtext_append_ztext(fm, header); |
---|
| 805 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 806 | owl_fmtext_append_ztext(fm, indent); |
---|
| 807 | if (text[strlen(text)-1]!='\n') { |
---|
| 808 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 809 | } |
---|
| 810 | |
---|
| 811 | owl_free(indent); |
---|
[37eab7f] | 812 | } else { |
---|
| 813 | |
---|
[ec6ff52] | 814 | } |
---|
| 815 | } |
---|