annotate libpurple/plugins/perl/common/Cmds.xs @ 17037:9a1d36a4573e

Fix a crash when something requests the blist status icon before the UI node has been rendered. The ticker plugin was doing this. Fixes #642.
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 11 May 2007 15:07:13 +0000
parents 39c7bb133a9f
children 4dc66862203f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 #include "module.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 #include "../perl-handlers.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
4 MODULE = Purple::Cmd PACKAGE = Purple::Cmd PREFIX = purple_cmd_
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 PROTOTYPES: ENABLE
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6
16750
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
7 BOOT:
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
8 {
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
9 HV *status_stash = gv_stashpv("Purple::Cmd::Status", 1);
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
10 HV *ret_stash = gv_stashpv("Purple::Cmd::Return", 1);
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
11 HV *p_stash = gv_stashpv("Purple::Cmd::Priority", 1);
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
12 HV *flag_stash = gv_stashpv("Purple::Cmd::Flag", 1);
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
13
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
14 static const constiv *civ, status_const_iv[] = {
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
15 #define const_iv(name) {#name, (IV)PURPLE_CMD_STATUS_##name}
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
16 const_iv(OK),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
17 const_iv(FAILED),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
18 const_iv(NOT_FOUND),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
19 const_iv(WRONG_ARGS),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
20 const_iv(WRONG_PRPL),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
21 const_iv(WRONG_TYPE),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
22 };
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
23 static const constiv ret_const_iv[] = {
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
24 #undef const_iv
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
25 #define const_iv(name) {#name, (IV)PURPLE_CMD_RET_##name}
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
26 const_iv(OK),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
27 const_iv(FAILED),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
28 const_iv(CONTINUE),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
29 };
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
30 static const constiv p_const_iv[] = {
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
31 #undef const_iv
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
32 #define const_iv(name) {#name, (IV)PURPLE_CMD_P_##name}
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
33 const_iv(VERY_LOW),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
34 const_iv(LOW),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
35 const_iv(DEFAULT),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
36 const_iv(PRPL),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
37 const_iv(PLUGIN),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
38 const_iv(ALIAS),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
39 const_iv(HIGH),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
40 const_iv(VERY_HIGH),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
41 };
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
42 static const constiv flag_const_iv[] = {
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
43 #undef const_iv
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
44 #define const_iv(name) {#name, (IV)PURPLE_CMD_FLAG_##name}
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
45 const_iv(IM),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
46 const_iv(CHAT),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
47 const_iv(PRPL_ONLY),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
48 const_iv(ALLOW_WRONG_ARGS),
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
49 };
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
50
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
51 for (civ = status_const_iv + sizeof(status_const_iv) / sizeof(status_const_iv[0]); civ-- > status_const_iv;)
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
52 newCONSTSUB(status_stash, (char *)civ->name, newSViv(civ->iv));
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
53
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
54 for (civ = ret_const_iv + sizeof(ret_const_iv) / sizeof(ret_const_iv[0]); civ-- > ret_const_iv;)
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
55 newCONSTSUB(ret_stash, (char *)civ->name, newSViv(civ->iv));
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
56
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
57 for (civ = p_const_iv + sizeof(p_const_iv) / sizeof(p_const_iv[0]); civ-- > p_const_iv;)
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
58 newCONSTSUB(p_stash, (char *)civ->name, newSViv(civ->iv));
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
59
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
60 for (civ = flag_const_iv + sizeof(flag_const_iv) / sizeof(flag_const_iv[0]); civ-- > flag_const_iv;)
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
61 newCONSTSUB(flag_stash, (char *)civ->name, newSViv(civ->iv));
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
62 }
39c7bb133a9f Remove the const-c and const-xs stuff and replace it with real constants
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
63
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 void
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
65 purple_cmd_help(conv, command)
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
66 Purple::Conversation conv
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 const gchar *command
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 PREINIT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 PPCODE:
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
71 for (l = purple_cmd_help(conv, command); l != NULL; l = l->next) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 XPUSHs(sv_2mortal(newSVpv(l->data, 0)));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 void
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
76 purple_cmd_list(conv)
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
77 Purple::Conversation conv
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 PREINIT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 GList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 PPCODE:
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
81 for (l = purple_cmd_list(conv); l != NULL; l = l->next) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 XPUSHs(sv_2mortal(newSVpv(l->data, 0)));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
85 Purple::Cmd::Id
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
86 purple_cmd_register(plugin, command, args, priority, flag, prpl_id, func, helpstr, data = 0)
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
87 Purple::Plugin plugin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 const gchar *command
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 const gchar *args
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
90 Purple::Cmd::Priority priority
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
91 Purple::Cmd::Flag flag
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 const gchar *prpl_id
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 SV *func
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 const gchar *helpstr
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 SV *data
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 CODE:
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
97 RETVAL = purple_perl_cmd_register(plugin, command, args, priority, flag,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 prpl_id, func, helpstr, data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 OUTPUT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 RETVAL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 void
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
103 purple_cmd_unregister(id)
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
104 Purple::Cmd::Id id
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 CODE:
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
106 purple_perl_cmd_unregister(id);