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