Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/hooks.c @ 1683:b09f82f61745
Split HOOK_INTERNAL
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Tue, 19 Jan 2010 16:09:27 +0200 |
parents | 41c26b7d2890 |
children | e6e89b1d7831 |
comparison
equal
deleted
inserted
replaced
1682:d1e8fb14ce2d | 1683:b09f82f61745 |
---|---|
500 #endif | 500 #endif |
501 | 501 |
502 //hlog_write_status(NULL, 0, status); | 502 //hlog_write_status(NULL, 0, status); |
503 } | 503 } |
504 | 504 |
505 | 505 void hk_postconnect(void) |
506 /* Internal commands */ | |
507 | |
508 void hook_execute_internal(const char *hookname) | |
509 { | 506 { |
510 const char *hook_command; | 507 const char *hook_command; |
511 char *buf; | |
512 char *cmdline; | 508 char *cmdline; |
513 | 509 |
514 #ifdef MODULES_ENABLE | 510 #ifdef MODULES_ENABLE |
515 { | 511 { |
516 GSList *h = hk_handler_queue; | 512 GSList *h = hk_handler_queue; |
517 if (h) { | 513 if (h) { |
518 hk_arg_t args[] = { | 514 hk_arg_t args[] = { |
519 { "hook", hookname }, | 515 { "hook", "hook-post-connect" }, |
520 { NULL, NULL }, | 516 { NULL, NULL }, |
521 }; | 517 }; |
522 while (h) { | 518 while (h) { |
523 hook_list_data_t *data = h->data; | 519 hook_list_data_t *data = h->data; |
524 if (data->flags & HOOK_INTERNAL) | 520 if (data->flags & HOOK_POST_CONNECT) |
525 (data->handler) (HOOK_INTERNAL, args, data->userdata); | 521 (data->handler) (HOOK_POST_CONNECT, args, data->userdata); |
526 h = g_slist_next (h); | 522 h = g_slist_next (h); |
527 } | 523 } |
528 } | 524 } |
529 } | 525 } |
530 #endif | 526 #endif |
531 | 527 |
532 hook_command = settings_opt_get(hookname); | 528 hook_command = settings_opt_get("hook-post-connect"); |
533 if (!hook_command) | 529 if (!hook_command) |
534 return; | 530 return; |
535 | 531 |
536 buf = g_strdup_printf("Running %s...", hookname); | 532 scr_LogPrint(LPRINT_LOGNORM, "Running hook-post-connect..."); |
537 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | |
538 | 533 |
539 cmdline = from_utf8(hook_command); | 534 cmdline = from_utf8(hook_command); |
540 if (process_command(cmdline, TRUE) == 255) | 535 if (process_command(cmdline, TRUE) == 255) |
541 mcabber_set_terminate_ui(); | 536 mcabber_set_terminate_ui(); |
542 | 537 |
543 g_free(cmdline); | 538 g_free(cmdline); |
544 g_free(buf); | 539 } |
545 } | 540 |
546 | 541 void hk_predisconnect(void) |
542 { | |
543 const char *hook_command; | |
544 char *cmdline; | |
545 | |
546 #ifdef MODULES_ENABLE | |
547 { | |
548 GSList *h = hk_handler_queue; | |
549 if (h) { | |
550 hk_arg_t args[] = { | |
551 { "hook", "hook-pre-disconnect" }, | |
552 { NULL, NULL }, | |
553 }; | |
554 while (h) { | |
555 hook_list_data_t *data = h->data; | |
556 if (data->flags & HOOK_PRE_DISCONNECT) | |
557 (data->handler) (HOOK_PRE_DISCONNECT, args, data->userdata); | |
558 h = g_slist_next (h); | |
559 } | |
560 } | |
561 } | |
562 #endif | |
563 | |
564 hook_command = settings_opt_get("hook-pre-disconnect"); | |
565 if (!hook_command) | |
566 return; | |
567 | |
568 scr_LogPrint(LPRINT_LOGNORM, "Running hook-pre-disconnect..."); | |
569 | |
570 cmdline = from_utf8(hook_command); | |
571 if (process_command(cmdline, TRUE) == 255) | |
572 mcabber_set_terminate_ui(); | |
573 | |
574 g_free(cmdline); | |
575 } | |
547 | 576 |
548 /* External commands */ | 577 /* External commands */ |
549 | 578 |
550 // hk_ext_cmd_init() | 579 // hk_ext_cmd_init() |
551 // Initialize external command variable. | 580 // Initialize external command variable. |