Changeset 15b34fd for functions.c
- Timestamp:
- Jan 4, 2005, 11:04:52 PM (19 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 180cd15
- Parents:
- 95474d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r95474d7 r15b34fd 164 164 } 165 165 166 void owl_function_adminmsg(char *header, char *body) 167 { 168 owl_message *m; 169 int followlast; 170 171 followlast=owl_global_should_followlast(&g); 172 m=owl_malloc(sizeof(owl_message)); 173 owl_message_create_admin(m, header, body); 166 167 /* Add the given message to Owl's internal queue. If displayoutgoing 168 * is disabled, the message is NOT added to any internal queue, -1 is 169 * returned and THE CALLER IS EXPECTED TO FREE THE GIVEN MESSAGE. 170 * Otherwise 0 is returned and the caller need do nothing more 171 */ 172 int owl_function_add_message(owl_message *m) 173 { 174 /* if displayoutgoing is disabled, nuke the message and move on */ 175 if (! owl_global_is_displayoutgoing(&g)) { 176 return(-1); 177 } 178 179 /* add it to the global list and current view */ 174 180 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 175 181 owl_view_consider_message(owl_global_get_current_view(&g), m); 176 182 177 if (followlast) owl_function_lastmsg_noredisplay(); 178 183 /* do followlast if necessary */ 184 if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay(); 185 186 /* redisplay etc. */ 179 187 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 180 188 if (owl_popwin_is_active(owl_global_get_popwin(&g))) { 181 189 owl_popwin_refresh(owl_global_get_popwin(&g)); 182 190 } 183 184 191 wnoutrefresh(owl_global_get_curs_recwin(&g)); 185 192 owl_global_set_needrefresh(&g); 186 } 187 188 void owl_function_make_outgoing_zephyr(char *body, char *zwriteline, char *zsig) 193 return(0); 194 } 195 196 /* Create an admin message, append it to the global list of messages 197 * and redisplay if necessary. 198 */ 199 void owl_function_adminmsg(char *header, char *body) 189 200 { 190 201 owl_message *m; 191 int followlast; 202 203 m=owl_malloc(sizeof(owl_message)); 204 owl_message_create_admin(m, header, body); 205 206 /* add it to the global list and current view */ 207 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 208 owl_view_consider_message(owl_global_get_current_view(&g), m); 209 210 /* do followlast if necessary */ 211 if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay(); 212 213 /* redisplay etc. */ 214 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 215 if (owl_popwin_is_active(owl_global_get_popwin(&g))) { 216 owl_popwin_refresh(owl_global_get_popwin(&g)); 217 } 218 wnoutrefresh(owl_global_get_curs_recwin(&g)); 219 owl_global_set_needrefresh(&g); 220 } 221 222 /* Create an outgoing zephyr message and return a pointer to it. Does 223 * not put it on the global queue, use owl_function_add_message() for 224 * that. 225 */ 226 owl_message *owl_function_make_outgoing_zephyr(char *body, char *zwriteline, char *zsig) 227 { 228 owl_message *m; 192 229 owl_zwrite z; 193 230 194 followlast=owl_global_should_followlast(&g);195 196 231 /* create a zwrite for the purpose of filling in other message fields */ 197 232 owl_zwrite_create_from_line(&z, zwriteline); … … 200 235 m=owl_malloc(sizeof(owl_message)); 201 236 owl_message_create_from_zwriteline(m, zwriteline, body, zsig); 202 203 /* add it to the global list and current view */ 204 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 205 owl_view_consider_message(owl_global_get_current_view(&g), m); 206 207 if (followlast) owl_function_lastmsg_noredisplay(); 208 209 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 210 if (owl_popwin_is_active(owl_global_get_popwin(&g))) { 211 owl_popwin_refresh(owl_global_get_popwin(&g)); 212 } 237 owl_zwrite_free(&z); 238 239 return(m); 240 } 241 242 /* Create an outgoing AIM message, returns a pointer to the created 243 * message or NULL if we're not logged into AIM (and thus unable to 244 * create the message). Does not put it on the global queue. Use 245 * owl_function_add_message() for that . 246 */ 247 owl_message *owl_function_make_outgoing_aim(char *body, char *to) 248 { 249 owl_message *m; 250 251 /* error if we're not logged into aim */ 252 if (!owl_global_is_aimloggedin(&g)) return(NULL); 213 253 214 wnoutrefresh(owl_global_get_curs_recwin(&g));215 owl_global_set_needrefresh(&g);216 owl_zwrite_free(&z);217 }218 219 int owl_function_make_outgoing_aim(char *body, char *to)220 {221 owl_message *m;222 int followlast;223 224 225 if (!owl_global_is_aimloggedin(&g)) {226 return(-1);227 }228 229 followlast=owl_global_should_followlast(&g);230 231 /* create the message */232 254 m=owl_malloc(sizeof(owl_message)); 233 255 owl_message_create_aim(m, … … 237 259 OWL_MESSAGE_DIRECTION_OUT, 238 260 0); 239 240 /* add it to the global list and current view */ 241 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 242 owl_view_consider_message(owl_global_get_current_view(&g), m); 243 244 if (followlast) owl_function_lastmsg_noredisplay(); 245 246 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 247 if (owl_popwin_is_active(owl_global_get_popwin(&g))) { 248 owl_popwin_refresh(owl_global_get_popwin(&g)); 249 } 250 251 wnoutrefresh(owl_global_get_curs_recwin(&g)); 252 owl_global_set_needrefresh(&g); 253 return(0); 254 } 255 256 int owl_function_make_outgoing_loopback(char *body) 261 return(m); 262 } 263 264 /* Create an outgoing loopback message and return a pointer to it. 265 * Does not append it to the global queue, use 266 * owl_function_add_message() for that. 267 */ 268 owl_message *owl_function_make_outgoing_loopback(char *body) 257 269 { 258 270 owl_message *m; 259 int followlast;260 261 followlast=owl_global_should_followlast(&g);262 271 263 272 /* create the message */ … … 266 275 owl_message_set_direction_out(m); 267 276 268 /* add it to the global list and current view */ 269 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 270 owl_view_consider_message(owl_global_get_current_view(&g), m); 271 272 if (followlast) owl_function_lastmsg_noredisplay(); 273 274 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 275 if (owl_popwin_is_active(owl_global_get_popwin(&g))) { 276 owl_popwin_refresh(owl_global_get_popwin(&g)); 277 } 278 279 wnoutrefresh(owl_global_get_curs_recwin(&g)); 280 owl_global_set_needrefresh(&g); 281 return(0); 277 return(m); 282 278 } 283 279 … … 386 382 { 387 383 owl_zwrite z; 388 int i, j;389 384 char *mymsg; 385 owl_message *m; 390 386 391 387 /* create the zwrite and send the message */ … … 394 390 owl_zwrite_set_message(&z, msg); 395 391 } 396 397 392 owl_zwrite_send_message(&z); 398 393 owl_function_makemsg("Waiting for ack..."); 399 394 400 mymsg=owl_zwrite_get_message(&z); 401 402 /* display the message as an outgoing message in the receive window */ 403 if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) { 404 owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 405 } 406 407 /* log it if we have logging turned on */ 408 if (owl_global_is_logging(&g) && owl_zwrite_is_personal(&z)) { 409 j=owl_zwrite_get_numrecips(&z); 410 for (i=0; i<j; i++) { 411 owl_log_outgoing_zephyr(owl_zwrite_get_recip_n(&z, i), mymsg); 395 /* If it's personal */ 396 if (owl_zwrite_is_personal(&z)) { 397 /* create the outgoing message */ 398 mymsg=owl_zwrite_get_message(&z); 399 m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 400 401 /* log it */ 402 owl_log_message(m); 403 404 /* add it or nuke it */ 405 if (owl_global_is_displayoutgoing(&g)) { 406 owl_function_add_message(m); 407 } else { 408 owl_message_free(m); 412 409 } 413 410 } … … 423 420 { 424 421 owl_zwrite z; 425 int i, j;426 422 char *mymsg; 427 423 char *cryptmsg; 424 owl_message *m; 428 425 #ifdef OWL_ENABLE_ZCRYPT 429 426 int ret; … … 457 454 owl_function_makemsg("Waiting for ack..."); 458 455 459 /* display the message as an outgoing message in the receive window */ 460 if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) { 461 owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 462 } 463 464 /* log it if we have logging turned on */ 465 if (owl_global_is_logging(&g) && owl_zwrite_is_personal(&z)) { 466 j=owl_zwrite_get_numrecips(&z); 467 for (i=0; i<j; i++) { 468 owl_log_outgoing_zephyr(owl_zwrite_get_recip_n(&z, i), mymsg); 456 /* If it's personal */ 457 if (owl_zwrite_is_personal(&z)) { 458 /* create the outgoing message */ 459 mymsg=owl_zwrite_get_message(&z); 460 m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 461 462 /* log it */ 463 owl_log_message(m); 464 465 /* add it or nuke it */ 466 if (owl_global_is_displayoutgoing(&g)) { 467 owl_function_add_message(m); 468 } else { 469 owl_message_free(m); 469 470 } 470 471 } … … 479 480 int ret; 480 481 char *msg, *format_msg; 482 owl_message *m; 481 483 482 484 /* make a formatted copy of the message */ … … 493 495 } 494 496 495 /* display the message as an outgoing message in the receive window */ 497 /* create the outgoing message */ 498 m=owl_function_make_outgoing_aim(msg, to); 499 500 /* log it */ 501 owl_log_message(m); 502 503 /* display it or nuke it */ 496 504 if (owl_global_is_displayoutgoing(&g)) { 497 owl_function_make_outgoing_aim(msg, to); 498 } 499 500 /* log it if we have logging turned on */ 501 if (owl_global_is_logging(&g)) { 502 owl_log_outgoing_aim(to, msg); 505 owl_function_add_message(m); 506 } else { 507 owl_message_free(m); 503 508 } 504 509 … … 510 515 int ret; 511 516 char *format_msg; 517 owl_message *m; 512 518 513 519 /* make a formatted copy of the message */ … … 523 529 } 524 530 525 /* display the message as an outgoing message in the receive window */ 526 if (owl_global_is_displayoutgoing(&g)) { 527 owl_function_make_outgoing_aim(msg, to); 528 } 529 530 /* log it if we have logging turned on */ 531 if (owl_global_is_logging(&g)) { 532 owl_log_outgoing_aim(to, msg); 533 } 534 531 /* create the message */ 532 m=owl_function_make_outgoing_aim(msg, to); 533 if (m) { 534 /* log it */ 535 owl_log_message(m); 536 537 /* display it or nuke it */ 538 if (owl_global_is_displayoutgoing(&g)) { 539 owl_function_add_message(m); 540 } else { 541 owl_message_free(m); 542 } 543 } else { 544 owl_function_error("Could not create AIM message"); 545 } 535 546 owl_free(format_msg); 536 547 } … … 538 549 void owl_function_loopwrite() 539 550 { 540 owl_message *m ;551 owl_message *min, *mout; 541 552 542 553 /* create a message and put it on the message queue. This simulates 543 554 * an incoming message */ 544 m=owl_malloc(sizeof(owl_message)); 545 owl_message_create_loopback(m, owl_editwin_get_text(owl_global_get_typwin(&g))); 546 owl_message_set_direction_in(m); 547 owl_global_messagequeue_addmsg(&g, m); 548 549 /* display the message as an outgoing message in the receive window */ 555 min=owl_malloc(sizeof(owl_message)); 556 owl_message_create_loopback(min, owl_editwin_get_text(owl_global_get_typwin(&g))); 557 owl_message_set_direction_in(min); 558 owl_global_messagequeue_addmsg(&g, min); 559 560 mout=owl_function_make_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g))); 561 owl_log_message(mout); 550 562 if (owl_global_is_displayoutgoing(&g)) { 551 owl_function_make_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g))); 563 owl_function_add_message(mout); 564 } else { 565 owl_message_free(mout); 552 566 } 553 567 554 568 /* fake a makemsg */ 555 569 owl_function_makemsg("loopback message sent"); 556 557 /* log it if we have logging turned on */558 if (owl_global_is_logging(&g)) {559 owl_log_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g)));560 }561 570 } 562 571
Note: See TracChangeset
for help on using the changeset viewer.