Mercurial > pidgin
comparison src/plugins.c @ 2345:a49e8f1afbc4
[gaim-migrate @ 2358]
you say potato, i say potato
you say tomato, i say tomato
potato, potato
tomato, tomato
let's call the whole thing off.
*sigh*. it just doesn't work as well when it's typed. but you wouldn't want to hear me sing it.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Sat, 22 Sep 2001 09:14:27 +0000 |
| parents | 13d5d7e829c9 |
| children | 571971659533 |
comparison
equal
deleted
inserted
replaced
| 2344:19ea44f74a88 | 2345:a49e8f1afbc4 |
|---|---|
| 643 } | 643 } |
| 644 } | 644 } |
| 645 | 645 |
| 646 #endif /* GAIM_PLUGINS */ | 646 #endif /* GAIM_PLUGINS */ |
| 647 | 647 |
| 648 char *event_name(enum gaim_event event) | 648 static char *event_name(enum gaim_event event) |
| 649 { | 649 { |
| 650 static char buf[128]; | 650 static char buf[128]; |
| 651 switch (event) { | 651 switch (event) { |
| 652 case event_signon: | 652 case event_signon: |
| 653 sprintf(buf, "event_signon"); | 653 sprintf(buf, "event_signon"); |
| 731 sprintf(buf, "event_im_displayed_sent"); | 731 sprintf(buf, "event_im_displayed_sent"); |
| 732 break; | 732 break; |
| 733 case event_im_displayed_rcvd: | 733 case event_im_displayed_rcvd: |
| 734 sprintf(buf, "event_im_displayed_rcvd"); | 734 sprintf(buf, "event_im_displayed_rcvd"); |
| 735 break; | 735 break; |
| 736 case event_chat_send_invite: | |
| 737 sprintf(buf, "event_chat_send_invite"); | |
| 738 break; | |
| 736 default: | 739 default: |
| 737 sprintf(buf, "event_unknown"); | 740 sprintf(buf, "event_unknown"); |
| 738 break; | 741 break; |
| 739 } | 742 } |
| 740 return buf; | 743 return buf; |
| 742 | 745 |
| 743 int plugin_event(enum gaim_event event, void *arg1, void *arg2, void *arg3, void *arg4) | 746 int plugin_event(enum gaim_event event, void *arg1, void *arg2, void *arg3, void *arg4) |
| 744 { | 747 { |
| 745 #ifdef USE_PERL | 748 #ifdef USE_PERL |
| 746 char buf[BUF_LONG]; | 749 char buf[BUF_LONG]; |
| 747 char *tmp; | |
| 748 #endif | 750 #endif |
| 749 #ifdef GAIM_PLUGINS | 751 #ifdef GAIM_PLUGINS |
| 750 GList *c = callbacks; | 752 GList *c = callbacks; |
| 751 struct gaim_callback *g; | 753 struct gaim_callback *g; |
| 752 | 754 |
| 753 while (c) { | 755 while (c) { |
| 756 void (*zero)(void *); | |
| 757 void (*one)(void *, void *); | |
| 758 void (*two)(void *, void *, void *); | |
| 759 void (*three)(void *, void *, void *, void *); | |
| 760 void (*four)(void *, void *, void *, void *, void *); | |
| 761 | |
| 754 g = (struct gaim_callback *)c->data; | 762 g = (struct gaim_callback *)c->data; |
| 755 if (g->event == event && g->function !=NULL) { | 763 if (g->event == event && g->function !=NULL) { |
| 756 switch (event) { | 764 switch (event) { |
| 757 | 765 |
| 758 /* struct gaim_connection * */ | |
| 759 case event_signon: | |
| 760 case event_signoff: | |
| 761 { | |
| 762 void (*function) (struct gaim_connection *, void *) = | |
| 763 g->function; | |
| 764 (*function)(arg1, g->data); | |
| 765 } | |
| 766 break; | |
| 767 | |
| 768 /* no args */ | 766 /* no args */ |
| 769 case event_blist_update: | 767 case event_blist_update: |
| 770 case event_quit: | 768 case event_quit: |
| 771 { | 769 zero = g->function; |
| 772 void (*function)(void *) = g->function; | 770 (*zero)(g->data); |
| 773 (*function)(g->data); | |
| 774 } | |
| 775 break; | 771 break; |
| 776 | 772 |
| 777 /* struct gaim_connection *, char **, char **, guint32 */ | 773 /* one arg */ |
| 778 case event_im_recv: | 774 case event_signon: |
| 779 { | 775 case event_signoff: |
| 780 void (*function)(struct gaim_connection *, char **, char **, | 776 case event_new_conversation: |
| 781 guint32, void *) = g->function; | 777 case event_error: |
| 782 (*function)(arg1, arg2, arg3, (guint32)arg4, g->data); | 778 one = g->function; |
| 783 } | 779 (*one)(arg1, g->data); |
| 784 break; | 780 break; |
| 785 | 781 |
| 786 /* struct gaim_connection *, char *, char ** */ | 782 /* two args */ |
| 787 case event_im_send: | |
| 788 case event_im_displayed_sent: | |
| 789 case event_chat_send: | |
| 790 { | |
| 791 void (*function)(struct gaim_connection *, char *, char **, | |
| 792 void *) = g->function; | |
| 793 (*function)(arg1, arg2, arg3, g->data); | |
| 794 } | |
| 795 break; | |
| 796 | |
| 797 /* struct gaim_connection *, char * */ | |
| 798 case event_chat_join: | |
| 799 case event_chat_leave: | |
| 800 case event_buddy_signon: | 783 case event_buddy_signon: |
| 801 case event_buddy_signoff: | 784 case event_buddy_signoff: |
| 802 case event_buddy_away: | 785 case event_buddy_away: |
| 803 case event_buddy_back: | 786 case event_buddy_back: |
| 804 case event_buddy_idle: | 787 case event_buddy_idle: |
| 805 case event_buddy_unidle: | 788 case event_buddy_unidle: |
| 789 case event_chat_leave: | |
| 806 case event_set_info: | 790 case event_set_info: |
| 807 { | 791 case event_draw_menu: |
| 808 void (*function)(struct gaim_connection *, char *, void *) = | 792 two = g->function; |
| 809 g->function; | 793 (*two)(arg1, arg2, g->data); |
| 810 (*function)(arg1, arg2, g->data); | |
| 811 } | |
| 812 break; | 794 break; |
| 813 | 795 |
| 814 /* char * */ | 796 /* three args */ |
| 815 case event_new_conversation: | 797 case event_im_send: |
| 816 { | 798 case event_im_displayed_sent: |
| 817 void (*function)(char *, void *) = g->function; | 799 case event_chat_join: |
| 818 (*function)(arg1, g->data); | |
| 819 } | |
| 820 break; | |
| 821 | |
| 822 /* struct gaim_connection *, char *, char *, char * */ | |
| 823 case event_chat_invited: | |
| 824 case event_chat_recv: | |
| 825 { | |
| 826 void (*function)(struct gaim_connection *, char *, char *, | |
| 827 char *, void *) = g->function; | |
| 828 (*function)(arg1, arg2, arg3, arg4, g->data); | |
| 829 } | |
| 830 break; | |
| 831 | |
| 832 /* struct gaim_connection *, char *, char * */ | |
| 833 case event_chat_buddy_join: | 800 case event_chat_buddy_join: |
| 834 case event_chat_buddy_leave: | 801 case event_chat_buddy_leave: |
| 802 case event_chat_send: | |
| 835 case event_away: | 803 case event_away: |
| 836 case event_back: | 804 case event_back: |
| 837 { | 805 case event_warned: |
| 838 void (*function)(struct gaim_connection *, char *, char *, | 806 three = g->function; |
| 839 void *) = g->function; | 807 (*three)(arg1, arg2, arg3, g->data); |
| 840 (*function)(arg1, arg2, arg3, g->data); | |
| 841 } | |
| 842 break; | 808 break; |
| 843 | 809 |
| 844 /* struct gaim_connection *, char *, char *, guint32 */ | 810 /* four args */ |
| 811 case event_im_recv: | |
| 812 case event_chat_recv: | |
| 845 case event_im_displayed_rcvd: | 813 case event_im_displayed_rcvd: |
| 846 { | 814 case event_chat_send_invite: |
| 847 void (*function)(struct gaim_connection *, char *, char *, | 815 case event_chat_invited: |
| 848 guint32, void *) = g->function; | 816 four = g->function; |
| 849 (*function)(arg1, arg2, arg3, (guint32)arg4, g->data); | 817 (*four)(arg1, arg2, arg3, arg4, g->data); |
| 850 } | |
| 851 break; | |
| 852 | |
| 853 /* struct gaim_connection *, char *, int */ | |
| 854 case event_warned: | |
| 855 { | |
| 856 void (*function)(struct gaim_connection *, char *, int, | |
| 857 void *) = g->function; | |
| 858 (*function)(arg1, arg2, (int)arg3, g->data); | |
| 859 } | |
| 860 break; | |
| 861 | |
| 862 /* int */ | |
| 863 case event_error: | |
| 864 { | |
| 865 void (*function)(int, void *) = g->function; | |
| 866 (*function)((int)arg1, g->data); | |
| 867 } | |
| 868 break; | |
| 869 /* GtkWidget *, char * */ | |
| 870 case event_draw_menu: | |
| 871 { | |
| 872 void(*function)(GtkWidget *, char *) = g->function; | |
| 873 (*function)(arg1, arg2); | |
| 874 } | |
| 875 break; | 818 break; |
| 876 | 819 |
| 877 default: | 820 default: |
| 878 debug_printf("unknown event %d\n", event); | 821 debug_printf("unknown event %d\n", event); |
| 879 break; | 822 break; |
| 883 } | 826 } |
| 884 #endif /* GAIM_PLUGINS */ | 827 #endif /* GAIM_PLUGINS */ |
| 885 #ifdef USE_PERL | 828 #ifdef USE_PERL |
| 886 switch (event) { | 829 switch (event) { |
| 887 case event_signon: | 830 case event_signon: |
| 888 g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); | |
| 889 break; | |
| 890 case event_signoff: | 831 case event_signoff: |
| 891 g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); | |
| 892 break; | |
| 893 case event_away: | 832 case event_away: |
| 894 g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); | |
| 895 break; | |
| 896 case event_back: | 833 case event_back: |
| 897 g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); | 834 g_snprintf(buf, sizeof buf, "%p", arg1); |
| 898 break; | 835 break; |
| 899 case event_im_recv: | 836 case event_im_recv: |
| 900 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", | 837 g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, |
| 901 ((struct gaim_connection *)arg1)->username, | |
| 902 *(char **)arg2 ? *(char **)arg2 : "(null)", | 838 *(char **)arg2 ? *(char **)arg2 : "(null)", |
| 903 *(char **)arg3 ? *(char **)arg3 : "(null)"); | 839 *(char **)arg3 ? *(char **)arg3 : "(null)"); |
| 904 break; | 840 break; |
| 905 case event_im_send: | 841 case event_im_send: |
| 906 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", | 842 g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, |
| 907 ((struct gaim_connection *)arg1)->username, (char *)arg2, | 843 (char *)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); |
| 908 *(char **)arg3 ? *(char **)arg3 : "(null)"); | |
| 909 break; | 844 break; |
| 910 case event_buddy_signon: | 845 case event_buddy_signon: |
| 911 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | |
| 912 break; | |
| 913 case event_buddy_signoff: | 846 case event_buddy_signoff: |
| 914 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | |
| 915 break; | |
| 916 case event_set_info: | 847 case event_set_info: |
| 917 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | |
| 918 break; | |
| 919 case event_buddy_away: | 848 case event_buddy_away: |
| 920 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | |
| 921 break; | |
| 922 case event_buddy_back: | 849 case event_buddy_back: |
| 923 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | |
| 924 break; | |
| 925 case event_buddy_idle: | 850 case event_buddy_idle: |
| 926 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | |
| 927 break; | |
| 928 case event_buddy_unidle: | 851 case event_buddy_unidle: |
| 929 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | 852 g_snprintf(buf, sizeof buf, "%p \"%s\"", arg1, (char *)arg2); |
| 930 break; | |
| 931 case event_blist_update: | |
| 932 buf[0] = 0; | |
| 933 break; | 853 break; |
| 934 case event_chat_invited: | 854 case event_chat_invited: |
| 935 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg2, (char *)arg3, | 855 g_snprintf(buf, sizeof buf, "%p \"%s\" \"%s\" %s", arg1, |
| 936 arg4 ? (char *)arg4 : ""); | 856 (char *)arg2, (char *)arg3, arg4 ? (char *)arg4 : ""); |
| 937 break; | 857 break; |
| 938 case event_chat_join: | 858 case event_chat_join: |
| 939 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | 859 case event_chat_buddy_join: |
| 860 case event_chat_buddy_leave: | |
| 861 g_snprintf(buf, sizeof buf, "%p %d \"%s\"", arg1, (int)arg2, (char *)arg3); | |
| 940 break; | 862 break; |
| 941 case event_chat_leave: | 863 case event_chat_leave: |
| 942 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | 864 g_snprintf(buf, sizeof buf, "%p %d", arg1, (int)arg2); |
| 943 break; | |
| 944 case event_chat_buddy_join: | |
| 945 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\"", (char *)arg2, (char *)arg3); | |
| 946 break; | |
| 947 case event_chat_buddy_leave: | |
| 948 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\"", (char *)arg2, (char *)arg3); | |
| 949 break; | 865 break; |
| 950 case event_chat_recv: | 866 case event_chat_recv: |
| 951 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg2, (char *)arg3, | 867 case event_chat_send_invite: |
| 952 (char *)arg4); | 868 g_snprintf(buf, sizeof buf, "%p %d \"%s\" %s", arg1, |
| 869 (int)arg2, (char *)arg3, (char *)arg4); | |
| 953 break; | 870 break; |
| 954 case event_chat_send: | 871 case event_chat_send: |
| 955 g_snprintf(buf, sizeof buf, "\"%s\" %s", (char *)arg2, | 872 g_snprintf(buf, sizeof buf, "%p %d %s", arg1, (int)arg2, |
| 956 *(char **)arg3 ? *(char **)arg3 : "(null)"); | 873 *(char **)arg3 ? *(char **)arg3 : "(null)"); |
| 957 break; | 874 break; |
| 958 case event_warned: | 875 case event_warned: |
| 959 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %d", | 876 g_snprintf(buf, sizeof buf, "%p \"%s\" %d", arg1, arg2 ? (char *)arg2 : "", (int)arg3); |
| 960 ((struct gaim_connection *)arg1)->username, | |
| 961 arg2 ? (char *)arg2 : "", (int)arg3); | |
| 962 break; | |
| 963 case event_error: | |
| 964 g_snprintf(buf, sizeof buf, "%d", (int)arg1); | |
| 965 break; | 877 break; |
| 966 case event_quit: | 878 case event_quit: |
| 967 buf[0] = 0; | 879 buf[0] = 0; |
| 968 break; | 880 break; |
| 969 case event_new_conversation: | 881 case event_new_conversation: |
| 970 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); | 882 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); |
| 971 break; | 883 break; |
| 972 case event_draw_menu: | |
| 973 g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); | |
| 974 break; | |
| 975 case event_im_displayed_sent: | 884 case event_im_displayed_sent: |
| 976 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", | 885 g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, |
| 977 ((struct gaim_connection *)arg1)->username, (char *)arg2, | 886 (char *)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); |
| 978 *(char **)arg3 ? *(char **)arg3 : "(null)"); | |
| 979 break; | 887 break; |
| 980 case event_im_displayed_rcvd: | 888 case event_im_displayed_rcvd: |
| 981 g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", | 889 g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, |
| 982 ((struct gaim_connection *)arg1)->username, (char *)arg2, | 890 (char *)arg2, (char *)arg3 ? (char *)arg3 : "(null)"); |
| 983 (char *)arg3 ? (char *)arg3 : "(null)"); | |
| 984 break; | 891 break; |
| 985 default: | 892 default: |
| 986 break; | 893 return 0; |
| 987 } | 894 } |
| 988 tmp = event_name(event); | 895 return perl_event(event_name(event), buf); |
| 989 debug_printf("%s: %s\n", tmp, buf); | |
| 990 return perl_event(tmp, buf); | |
| 991 #else | 896 #else |
| 992 return 0; | 897 return 0; |
| 993 #endif | 898 #endif |
| 994 } | 899 } |
| 995 | 900 |
