Changeset 987cf3f for functions.c
- Timestamp:
- Jul 4, 2010, 12:15:12 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- efc460e
- Parents:
- aeadc74
- git-author:
- Nelson Elhage <nelhage@mit.edu> (06/20/10 16:47:23)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (07/04/10 12:15:12)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r13ebf92 r987cf3f 223 223 * that. 224 224 */ 225 owl_message *owl_function_make_outgoing_zephyr(const char *body, const char *zwriteline, const char *zsig)225 owl_message *owl_function_make_outgoing_zephyr(const owl_zwrite *z) 226 226 { 227 227 owl_message *m; 228 owl_zwrite zw;229 230 owl_zwrite_create_from_line(&zw, zwriteline);231 owl_zwrite_set_zsig(&zw, zsig);232 228 233 229 /* create the message */ 234 230 m=owl_malloc(sizeof(owl_message)); 235 236 owl_message_create_from_zwrite(m, &zw, body); 237 owl_zwrite_cleanup(&zw); 231 owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z)); 238 232 239 233 return(m); … … 296 290 } 297 291 298 static void owl_function_write_setup(const char * line, const char *noun, void (*callback)(owl_editwin *))292 static void owl_function_write_setup(const char *noun) 299 293 { 300 294 … … 307 301 "End with a dot on a line by itself. ^C will quit.", 308 302 noun); 309 310 owl_function_start_edit_win(line, callback, 303 } 304 305 void owl_function_zwrite_setup(owl_zwrite *z) 306 { 307 /* send a ping if necessary */ 308 if (owl_global_is_txping(&g)) { 309 owl_zwrite_send_ping(z); 310 } 311 312 313 owl_function_write_setup("zephyr"); 314 owl_function_start_edit_win(z->zwriteline, 315 &owl_callback_zwrite, 316 z, (void(*)(void*))owl_zwrite_delete); 317 } 318 319 void owl_function_aimwrite_setup(const char *line) 320 { 321 owl_function_write_setup("message"); 322 owl_function_start_edit_win(line, 323 &owl_callback_aimwrite, 311 324 owl_strdup(line), 312 325 owl_free); 313 } 314 315 void owl_function_zwrite_setup(const char *line) 316 { 317 owl_zwrite z; 318 int ret; 319 320 /* check the arguments */ 321 ret=owl_zwrite_create_from_line(&z, line); 322 if (ret) { 323 owl_function_error("Error in zwrite arguments"); 324 owl_zwrite_cleanup(&z); 325 return; 326 } 327 328 /* send a ping if necessary */ 329 if (owl_global_is_txping(&g)) { 330 owl_zwrite_send_ping(&z); 331 } 332 owl_zwrite_cleanup(&z); 333 334 owl_function_write_setup(line, "zephyr", &owl_callback_zwrite); 335 } 336 337 void owl_function_aimwrite_setup(const char *line) 338 { 339 owl_function_write_setup(line, "message", &owl_callback_aimwrite); 326 340 327 } 341 328 342 329 void owl_function_loopwrite_setup(void) 343 330 { 344 owl_function_write_setup("loopwrite", "message", owl_callback_loopwrite); 331 owl_function_write_setup("message"); 332 owl_function_start_edit_win("loopwrite", 333 &owl_callback_loopwrite, 334 "loopwrite", NULL); 345 335 } 346 336 347 337 void owl_callback_zwrite(owl_editwin *e) { 348 char *command = owl_editwin_get_cbdata(e); 349 owl_function_zwrite(command, 350 owl_editwin_get_text(e)); 338 owl_zwrite *z = owl_editwin_get_cbdata(e); 339 owl_function_zwrite(z, owl_editwin_get_text(e)); 351 340 } 352 341 … … 354 343 * the message is expected to be set from the zwrite line itself 355 344 */ 356 void owl_function_zwrite(const char *line, const char *msg) 357 { 358 owl_zwrite z; 359 const char *mymsg; 345 void owl_function_zwrite(owl_zwrite *z, const char *msg) 346 { 360 347 owl_message *m; 361 348 362 if( !strncmp(line, "zcrypt", strlen("zcrypt"))) {363 owl_function_zcrypt( line, msg);349 if(strcmp(z->cmd, "zcrypt") == 0) { 350 owl_function_zcrypt(z, msg); 364 351 return; 365 352 } 366 353 367 354 /* create the zwrite and send the message */ 368 owl_zwrite_create_from_line(&z, line); 369 owl_zwrite_populate_zsig(&z); 355 owl_zwrite_populate_zsig(z); 370 356 if (msg) { 371 owl_zwrite_set_message( &z, msg);372 } 373 owl_zwrite_send_message( &z);357 owl_zwrite_set_message(z, msg); 358 } 359 owl_zwrite_send_message(z); 374 360 owl_function_makemsg("Waiting for ack..."); 375 361 376 362 /* If it's personal */ 377 if (owl_zwrite_is_personal( &z)) {363 if (owl_zwrite_is_personal(z)) { 378 364 /* create the outgoing message */ 379 mymsg=owl_zwrite_get_message(&z); 380 m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 365 m=owl_function_make_outgoing_zephyr(z); 381 366 382 367 if (m) { … … 386 371 } 387 372 } 388 389 /* free the zwrite */390 owl_zwrite_cleanup(&z);391 373 } 392 374 … … 394 376 * the message is expected to be set from the zwrite line itself 395 377 */ 396 void owl_function_zcrypt(const char *line, const char *msg) 397 { 398 owl_zwrite z; 399 const char *mymsg; 378 void owl_function_zcrypt(owl_zwrite *z, const char *msg) 379 { 400 380 char *cryptmsg; 401 381 owl_message *m; … … 405 385 406 386 /* create the zwrite and send the message */ 407 owl_zwrite_create_from_line(&z, line); 408 owl_zwrite_populate_zsig(&z); 387 owl_zwrite_populate_zsig(z); 409 388 if (msg) { 410 owl_zwrite_set_message(&z, msg); 411 } 412 413 mymsg=owl_zwrite_get_message(&z); 389 owl_zwrite_set_message(z, msg); 390 } 391 414 392 415 393 zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir()); 416 394 argv[0] = "zcrypt"; 417 395 argv[1] = "-E"; 418 argv[2] = "-c"; argv[3] = owl_zwrite_get_class( &z);419 argv[4] = "-i"; argv[5] = owl_zwrite_get_instance( &z);396 argv[2] = "-c"; argv[3] = owl_zwrite_get_class(z); 397 argv[4] = "-i"; argv[5] = owl_zwrite_get_instance(z); 420 398 argv[6] = NULL; 421 399 422 rv = call_filter(zcrypt, argv, mymsg, &cryptmsg, &status);400 rv = call_filter(zcrypt, argv, owl_zwrite_get_message(z), &cryptmsg, &status); 423 401 424 402 owl_free(zcrypt); … … 428 406 owl_function_error("Error in zcrypt, possibly no key found. Message not sent."); 429 407 owl_function_beep(); 430 owl_zwrite_cleanup(&z);431 408 return; 432 409 } 433 410 434 owl_zwrite_set_message( &z, cryptmsg);435 owl_zwrite_set_opcode( &z, "crypt");411 owl_zwrite_set_message(z, cryptmsg); 412 owl_zwrite_set_opcode(z, "crypt"); 436 413 437 owl_zwrite_send_message( &z);414 owl_zwrite_send_message(z); 438 415 owl_function_makemsg("Waiting for ack..."); 439 416 440 417 /* If it's personal */ 441 if (owl_zwrite_is_personal( &z)) {418 if (owl_zwrite_is_personal(z)) { 442 419 /* create the outgoing message */ 443 mymsg=owl_zwrite_get_message(&z); 444 m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 420 m=owl_function_make_outgoing_zephyr(z); 445 421 if (m) { 446 422 owl_global_messagequeue_addmsg(&g, m); … … 452 428 /* free the zwrite */ 453 429 owl_free(cryptmsg); 454 owl_zwrite_cleanup(&z);455 430 } 456 431
Note: See TracChangeset
for help on using the changeset viewer.