[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); |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | void owl_stylefunc_default(owl_fmtext *fm, owl_message *m) |
---|
| 205 | { |
---|
[09489b89] | 206 | #ifdef HAVE_LIBZEPHYR |
---|
[bd3f232] | 207 | char *body, *indent, *ptr, *zsigbuff, frombuff[LINE]; |
---|
| 208 | ZNotice_t *n; |
---|
[09489b89] | 209 | #endif |
---|
[bd3f232] | 210 | |
---|
| 211 | if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { |
---|
[09489b89] | 212 | #ifdef HAVE_LIBZEPHYR |
---|
[bd3f232] | 213 | n=owl_message_get_notice(m); |
---|
[09489b89] | 214 | |
---|
[bd3f232] | 215 | /* get the body */ |
---|
| 216 | body=owl_malloc(strlen(owl_message_get_body(m))+30); |
---|
| 217 | strcpy(body, owl_message_get_body(m)); |
---|
| 218 | |
---|
| 219 | /* add a newline if we need to */ |
---|
| 220 | if (body[0]!='\0' && body[strlen(body)-1]!='\n') { |
---|
| 221 | strcat(body, "\n"); |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | /* do the indenting into indent */ |
---|
| 225 | indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10); |
---|
| 226 | owl_text_indent(indent, body, OWL_MSGTAB); |
---|
| 227 | |
---|
| 228 | /* edit the from addr for printing */ |
---|
| 229 | strcpy(frombuff, owl_message_get_sender(m)); |
---|
| 230 | ptr=strchr(frombuff, '@'); |
---|
[09489b89] | 231 | if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) { |
---|
[bd3f232] | 232 | *ptr='\0'; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | /* set the message for printing */ |
---|
| 236 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 237 | |
---|
[8b32593] | 238 | if (owl_message_is_ping(m) && owl_message_is_private(m)) { |
---|
[bd3f232] | 239 | owl_fmtext_append_bold(fm, "PING"); |
---|
| 240 | owl_fmtext_append_normal(fm, " from "); |
---|
| 241 | owl_fmtext_append_bold(fm, frombuff); |
---|
| 242 | owl_fmtext_append_normal(fm, "\n"); |
---|
[8b32593] | 243 | } else if (owl_message_is_loginout(m)) { |
---|
[778d0a9] | 244 | char *ptr, *host, *tty; |
---|
[bd3f232] | 245 | int len; |
---|
[778d0a9] | 246 | |
---|
[bd3f232] | 247 | ptr=owl_zephyr_get_field(n, 1, &len); |
---|
[778d0a9] | 248 | host=owl_malloc(len+10); |
---|
[bd3f232] | 249 | strncpy(host, ptr, len); |
---|
| 250 | host[len]='\0'; |
---|
[778d0a9] | 251 | |
---|
[bd3f232] | 252 | ptr=owl_zephyr_get_field(n, 3, &len); |
---|
[778d0a9] | 253 | tty=owl_malloc(len+10); |
---|
[bd3f232] | 254 | strncpy(tty, ptr, len); |
---|
| 255 | tty[len]='\0'; |
---|
| 256 | |
---|
[8b32593] | 257 | if (owl_message_is_login(m)) { |
---|
[bd3f232] | 258 | owl_fmtext_append_bold(fm, "LOGIN"); |
---|
[8b32593] | 259 | } else if (owl_message_is_logout(m)) { |
---|
[bd3f232] | 260 | owl_fmtext_append_bold(fm, "LOGOUT"); |
---|
| 261 | } |
---|
| 262 | owl_fmtext_append_normal(fm, " for "); |
---|
[03955f3] | 263 | ptr=short_zuser(owl_message_get_instance(m)); |
---|
[bd3f232] | 264 | owl_fmtext_append_bold(fm, ptr); |
---|
| 265 | owl_free(ptr); |
---|
| 266 | owl_fmtext_append_normal(fm, " at "); |
---|
| 267 | owl_fmtext_append_normal(fm, host); |
---|
| 268 | owl_fmtext_append_normal(fm, " "); |
---|
| 269 | owl_fmtext_append_normal(fm, tty); |
---|
| 270 | owl_fmtext_append_normal(fm, "\n"); |
---|
[778d0a9] | 271 | |
---|
| 272 | owl_free(host); |
---|
| 273 | owl_free(tty); |
---|
[bd3f232] | 274 | } else { |
---|
| 275 | owl_fmtext_append_normal(fm, owl_message_get_class(m)); |
---|
| 276 | owl_fmtext_append_normal(fm, " / "); |
---|
| 277 | owl_fmtext_append_normal(fm, owl_message_get_instance(m)); |
---|
| 278 | owl_fmtext_append_normal(fm, " / "); |
---|
| 279 | owl_fmtext_append_bold(fm, frombuff); |
---|
| 280 | if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) { |
---|
| 281 | owl_fmtext_append_normal(fm, " {"); |
---|
| 282 | owl_fmtext_append_normal(fm, owl_message_get_realm(m)); |
---|
| 283 | owl_fmtext_append_normal(fm, "} "); |
---|
| 284 | } |
---|
[03955f3] | 285 | if (strcmp(owl_message_get_opcode(m), "")) { |
---|
[bd3f232] | 286 | owl_fmtext_append_normal(fm, " ["); |
---|
| 287 | owl_fmtext_append_normal(fm, owl_message_get_opcode(m)); |
---|
| 288 | owl_fmtext_append_normal(fm, "] "); |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | /* stick on the zsig */ |
---|
| 292 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
| 293 | owl_message_pretty_zsig(m, zsigbuff); |
---|
| 294 | owl_fmtext_append_normal(fm, " ("); |
---|
| 295 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
| 296 | owl_fmtext_append_normal(fm, ")"); |
---|
| 297 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 298 | owl_free(zsigbuff); |
---|
| 299 | |
---|
| 300 | /* then the indented message */ |
---|
| 301 | owl_fmtext_append_ztext(fm, indent); |
---|
| 302 | |
---|
| 303 | /* make private messages bold for smaat users */ |
---|
| 304 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { |
---|
| 305 | if (owl_message_is_personal(m)) { |
---|
| 306 | owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD); |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | owl_free(body); |
---|
| 312 | owl_free(indent); |
---|
[09489b89] | 313 | #endif |
---|
[bd3f232] | 314 | } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) { |
---|
| 315 | char *indent, *text, *zsigbuff, *foo; |
---|
| 316 | |
---|
| 317 | text=owl_message_get_body(m); |
---|
| 318 | |
---|
| 319 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 320 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 321 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 322 | owl_fmtext_append_normal(fm, "Zephyr sent to "); |
---|
| 323 | foo=short_zuser(owl_message_get_recipient(m)); |
---|
| 324 | owl_fmtext_append_normal(fm, foo); |
---|
| 325 | owl_free(foo); |
---|
| 326 | owl_fmtext_append_normal(fm, " (Zsig: "); |
---|
| 327 | |
---|
| 328 | zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); |
---|
| 329 | owl_message_pretty_zsig(m, zsigbuff); |
---|
| 330 | owl_fmtext_append_ztext(fm, zsigbuff); |
---|
| 331 | owl_free(zsigbuff); |
---|
| 332 | |
---|
| 333 | owl_fmtext_append_normal(fm, ")"); |
---|
| 334 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 335 | owl_fmtext_append_ztext(fm, indent); |
---|
| 336 | if (text[strlen(text)-1]!='\n') { |
---|
| 337 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | owl_free(indent); |
---|
| 341 | } else if (owl_message_is_type_aim(m)) { |
---|
| 342 | char *indent; |
---|
| 343 | |
---|
| 344 | if (owl_message_is_loginout(m)) { |
---|
| 345 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 346 | if (owl_message_is_login(m)) { |
---|
| 347 | owl_fmtext_append_bold(fm, "AIM LOGIN"); |
---|
| 348 | } else { |
---|
| 349 | owl_fmtext_append_bold(fm, "AIM LOGOUT"); |
---|
| 350 | } |
---|
| 351 | owl_fmtext_append_normal(fm, " for "); |
---|
| 352 | owl_fmtext_append_normal(fm, owl_message_get_sender(m)); |
---|
| 353 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 354 | } else if (owl_message_is_direction_in(m)) { |
---|
| 355 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 356 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 357 | owl_fmtext_append_bold(fm, OWL_TABSTR); |
---|
| 358 | owl_fmtext_append_bold(fm, "AIM from "); |
---|
| 359 | owl_fmtext_append_bold(fm, owl_message_get_sender(m)); |
---|
| 360 | owl_fmtext_append_bold(fm, "\n"); |
---|
| 361 | owl_fmtext_append_bold(fm, indent); |
---|
| 362 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 363 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 364 | } |
---|
| 365 | owl_free(indent); |
---|
| 366 | } else if (owl_message_is_direction_out(m)) { |
---|
| 367 | indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); |
---|
| 368 | owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); |
---|
| 369 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 370 | owl_fmtext_append_normal(fm, "AIM sent to "); |
---|
| 371 | owl_fmtext_append_normal(fm, owl_message_get_recipient(m)); |
---|
| 372 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 373 | owl_fmtext_append_ztext(fm, indent); |
---|
| 374 | if (indent[strlen(indent)-1]!='\n') { |
---|
| 375 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 376 | } |
---|
| 377 | owl_free(indent); |
---|
| 378 | } |
---|
| 379 | } else if (owl_message_is_type_admin(m)) { |
---|
| 380 | char *text, *header, *indent; |
---|
| 381 | |
---|
| 382 | text=owl_message_get_body(m); |
---|
| 383 | header=owl_message_get_attribute_value(m, "adminheader"); |
---|
| 384 | |
---|
| 385 | indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); |
---|
| 386 | owl_text_indent(indent, text, OWL_MSGTAB); |
---|
| 387 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
| 388 | owl_fmtext_append_bold(fm, "OWL ADMIN "); |
---|
| 389 | owl_fmtext_append_ztext(fm, header); |
---|
| 390 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 391 | owl_fmtext_append_ztext(fm, indent); |
---|
| 392 | if (text[strlen(text)-1]!='\n') { |
---|
| 393 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | owl_free(indent); |
---|
| 397 | } |
---|
| 398 | } |
---|
[8b32593] | 399 | |
---|
| 400 | void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m) |
---|
| 401 | { |
---|
| 402 | char *tmp; |
---|
[5ea6fea] | 403 | char *baseformat="%s %-13.13s %-11.11s %-12.12s "; |
---|
| 404 | char *sender, *recip; |
---|
[09489b89] | 405 | #ifdef HAVE_LIBZEPHYR |
---|
[778d0a9] | 406 | ZNotice_t *n; |
---|
[09489b89] | 407 | #endif |
---|
[8b32593] | 408 | |
---|
[5ea6fea] | 409 | sender=short_zuser(owl_message_get_sender(m)); |
---|
| 410 | recip=short_zuser(owl_message_get_recipient(m)); |
---|
| 411 | |
---|
[8b32593] | 412 | if (owl_message_is_type_zephyr(m)) { |
---|
[09489b89] | 413 | #ifdef HAVE_LIBZEPHYR |
---|
[778d0a9] | 414 | n=owl_message_get_notice(m); |
---|
| 415 | |
---|
[8b32593] | 416 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
[778d0a9] | 417 | |
---|
| 418 | if (owl_message_is_loginout(m)) { |
---|
| 419 | char *ptr, *host, *tty; |
---|
| 420 | int len; |
---|
| 421 | |
---|
| 422 | ptr=owl_zephyr_get_field(n, 1, &len); |
---|
| 423 | host=owl_malloc(len+10); |
---|
| 424 | strncpy(host, ptr, len); |
---|
| 425 | host[len]='\0'; |
---|
| 426 | |
---|
| 427 | ptr=owl_zephyr_get_field(n, 3, &len); |
---|
| 428 | tty=owl_malloc(len+10); |
---|
| 429 | strncpy(tty, ptr, len); |
---|
| 430 | tty[len]='\0'; |
---|
| 431 | |
---|
| 432 | if (owl_message_is_login(m)) { |
---|
| 433 | tmp=owl_sprintf(baseformat, "<", "LOGIN", "", sender); |
---|
| 434 | owl_fmtext_append_normal(fm, tmp); |
---|
| 435 | owl_free(tmp); |
---|
| 436 | } else if (owl_message_is_logout(m)) { |
---|
| 437 | tmp=owl_sprintf(baseformat, "<", "LOGOUT", "", sender); |
---|
| 438 | owl_fmtext_append_normal(fm, tmp); |
---|
| 439 | owl_free(tmp); |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | owl_fmtext_append_normal(fm, "at "); |
---|
| 443 | owl_fmtext_append_normal(fm, host); |
---|
| 444 | owl_fmtext_append_normal(fm, " "); |
---|
| 445 | owl_fmtext_append_normal(fm, tty); |
---|
[8b32593] | 446 | owl_fmtext_append_normal(fm, "\n"); |
---|
[778d0a9] | 447 | |
---|
| 448 | owl_free(host); |
---|
| 449 | owl_free(tty); |
---|
| 450 | |
---|
[8b32593] | 451 | } else if (owl_message_is_ping(m)) { |
---|
[5ea6fea] | 452 | tmp=owl_sprintf(baseformat, "<", "PING", "", sender); |
---|
[8b32593] | 453 | owl_fmtext_append_normal(fm, tmp); |
---|
| 454 | owl_fmtext_append_normal(fm, "\n"); |
---|
[5ea6fea] | 455 | owl_free(tmp); |
---|
[778d0a9] | 456 | |
---|
[8b32593] | 457 | } else { |
---|
| 458 | if (owl_message_is_direction_in(m)) { |
---|
[5ea6fea] | 459 | tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender); |
---|
[8b32593] | 460 | } else if (owl_message_is_direction_out(m)) { |
---|
[5ea6fea] | 461 | tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip); |
---|
[8b32593] | 462 | } else { |
---|
[5ea6fea] | 463 | tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender); |
---|
[8b32593] | 464 | } |
---|
| 465 | owl_fmtext_append_normal(fm, tmp); |
---|
| 466 | if (tmp) owl_free(tmp); |
---|
| 467 | |
---|
| 468 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
| 469 | owl_util_tr(tmp, '\n', ' '); |
---|
[65e3901] | 470 | owl_fmtext_append_ztext(fm, tmp); |
---|
[8b32593] | 471 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 472 | if (tmp) owl_free(tmp); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | /* make personal messages bold for smaat users */ |
---|
[c3ab155] | 476 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && |
---|
| 477 | owl_message_is_personal(m) && |
---|
| 478 | owl_message_is_direction_in(m)) { |
---|
[8b32593] | 479 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
| 480 | } |
---|
[5ea6fea] | 481 | |
---|
| 482 | owl_free(sender); |
---|
| 483 | owl_free(recip); |
---|
[09489b89] | 484 | #endif |
---|
[8b32593] | 485 | } else if (owl_message_is_type_aim(m)) { |
---|
| 486 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
| 487 | if (owl_message_is_login(m)) { |
---|
[5ea6fea] | 488 | tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m)); |
---|
[8b32593] | 489 | owl_fmtext_append_normal(fm, tmp); |
---|
| 490 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 491 | if (tmp) owl_free(tmp); |
---|
| 492 | } else if (owl_message_is_logout(m)) { |
---|
[5ea6fea] | 493 | tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m)); |
---|
[8b32593] | 494 | owl_fmtext_append_normal(fm, tmp); |
---|
| 495 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 496 | if (tmp) owl_free(tmp); |
---|
| 497 | } else { |
---|
| 498 | if (owl_message_is_direction_in(m)) { |
---|
[5ea6fea] | 499 | tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m)); |
---|
[8b32593] | 500 | owl_fmtext_append_normal(fm, tmp); |
---|
| 501 | if (tmp) owl_free(tmp); |
---|
| 502 | } else if (owl_message_is_direction_out(m)) { |
---|
[5ea6fea] | 503 | tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m)); |
---|
[8b32593] | 504 | owl_fmtext_append_normal(fm, tmp); |
---|
| 505 | if (tmp) owl_free(tmp); |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
| 509 | owl_util_tr(tmp, '\n', ' '); |
---|
| 510 | owl_fmtext_append_normal(fm, tmp); |
---|
| 511 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 512 | if (tmp) owl_free(tmp); |
---|
| 513 | |
---|
[0c502e9] | 514 | /* make personal messages bold for smaat users */ |
---|
[9c4ec91] | 515 | if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) { |
---|
[0c502e9] | 516 | owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD); |
---|
| 517 | } |
---|
[8b32593] | 518 | } |
---|
| 519 | } else if (owl_message_is_type_admin(m)) { |
---|
| 520 | owl_fmtext_append_spaces(fm, OWL_TAB); |
---|
| 521 | owl_fmtext_append_normal(fm, "< ADMIN "); |
---|
| 522 | |
---|
| 523 | tmp=owl_strdup(owl_message_get_body(m)); |
---|
| 524 | owl_util_tr(tmp, '\n', ' '); |
---|
| 525 | owl_fmtext_append_normal(fm, tmp); |
---|
| 526 | owl_fmtext_append_normal(fm, "\n"); |
---|
| 527 | if (tmp) owl_free(tmp); |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | } |
---|