comparison src/pounce.h @ 5857:2fa4aa9c1885

[gaim-migrate @ 6288] Renamed the pounce structures and typedefs to be in sync with the rest of the API. Also added some g_return_*_if_fail() checks in place of the if statements we had. I'll try to get pounces working again. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 13 Jun 2003 23:04:26 +0000
parents 9eb5b13fd412
children 417b1001d2b1
comparison
equal deleted inserted replaced
5856:a479e218c54b 5857:2fa4aa9c1885
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 #ifndef _GAIM_POUNCE_H_ 23 #ifndef _GAIM_POUNCE_H_
24 #define _GAIM_POUNCE_H_ 24 #define _GAIM_POUNCE_H_
25 25
26 typedef struct _GaimPounce GaimPounce;
27
26 /** 28 /**
27 * Events that trigger buddy pounces. 29 * Events that trigger buddy pounces.
28 */ 30 */
29 typedef enum 31 typedef enum
30 { 32 {
38 GAIM_POUNCE_TYPING = 0x40, /**< The buddy started typing. */ 40 GAIM_POUNCE_TYPING = 0x40, /**< The buddy started typing. */
39 GAIM_POUNCE_TYPING_STOPPED = 0x80 /**< The buddy stopped typing. */ 41 GAIM_POUNCE_TYPING_STOPPED = 0x80 /**< The buddy stopped typing. */
40 42
41 } GaimPounceEvent; 43 } GaimPounceEvent;
42 44
43 struct gaim_pounce;
44
45 /** A pounce callback. */ 45 /** A pounce callback. */
46 typedef void (*gaim_pounce_cb)(struct gaim_pounce *, GaimPounceEvent, void *); 46 typedef void (*GaimPounceCb)(GaimPounce *, GaimPounceEvent, void *);
47 47
48 /** 48 /**
49 * A buddy pounce structure. 49 * A buddy pounce structure.
50 * 50 *
51 * Buddy pounces are actions triggered by a buddy-related event. For 51 * Buddy pounces are actions triggered by a buddy-related event. For
52 * example, a sound can be played or an IM window opened when a buddy 52 * example, a sound can be played or an IM window opened when a buddy
53 * signs on or returns from away. Such responses are handled in the 53 * signs on or returns from away. Such responses are handled in the
54 * UI. The events themselves are done in the core. 54 * UI. The events themselves are done in the core.
55 */ 55 */
56 struct gaim_pounce 56 struct _GaimPounce
57 { 57 {
58 GaimPounceEvent events; /**< The event(s) to pounce on. */ 58 GaimPounceEvent events; /**< The event(s) to pounce on. */
59 GaimAccount *pouncer; /**< The user who is pouncing. */ 59 GaimAccount *pouncer; /**< The user who is pouncing. */
60 60
61 char *pouncee; /**< The buddy to pounce on. */ 61 char *pouncee; /**< The buddy to pounce on. */
62 62
63 gaim_pounce_cb callback; /**< The callback function to call when the 63 GaimPounceCb callback; /**< The callback function to call when the
64 event is triggered. */ 64 event is triggered. */
65 void (*free)(void *data); /**< The data free function. */ 65 void (*free)(void *data); /**< The data free function. */
66 void *data; /**< Pounce-specific data. */ 66 void *data; /**< Pounce-specific data. */
67 }; 67 };
68 68
76 * @param data Pounce-specific data. 76 * @param data Pounce-specific data.
77 * @param free The function to free the pounce-specific data. 77 * @param free The function to free the pounce-specific data.
78 * 78 *
79 * @return The new buddy pounce structure. 79 * @return The new buddy pounce structure.
80 */ 80 */
81 struct gaim_pounce *gaim_pounce_new(GaimAccount *pouncer, 81 GaimPounce *gaim_pounce_new(GaimAccount *pouncer, const char *pouncee,
82 const char *pouncee, 82 GaimPounceEvent event, GaimPounceCb cb,
83 GaimPounceEvent event, 83 void *data, void (*free)(void *));
84 gaim_pounce_cb cb, void *data,
85 void (*free)(void *));
86 84
87 /** 85 /**
88 * Destroys a buddy pounce. 86 * Destroys a buddy pounce.
89 * 87 *
90 * @param pounce The buddy pounce. 88 * @param pounce The buddy pounce.
91 */ 89 */
92 void gaim_pounce_destroy(struct gaim_pounce *pounce); 90 void gaim_pounce_destroy(GaimPounce *pounce);
93 91
94 /** 92 /**
95 * Sets the events a pounce should watch for. 93 * Sets the events a pounce should watch for.
96 * 94 *
97 * @param pounce The buddy pounce. 95 * @param pounce The buddy pounce.
98 * @param events The events to watch for. 96 * @param events The events to watch for.
99 */ 97 */
100 void gaim_pounce_set_events(struct gaim_pounce *pounce, 98 void gaim_pounce_set_events(GaimPounce *pounce, GaimPounceEvent events);
101 GaimPounceEvent events);
102 99
103 /** 100 /**
104 * Sets the account that will do the pouncing. 101 * Sets the account that will do the pouncing.
105 * 102 *
106 * @param pounce The buddy pounce. 103 * @param pounce The buddy pounce.
107 * @param pouncer The account that will pounce. 104 * @param pouncer The account that will pounce.
108 */ 105 */
109 void gaim_pounce_set_pouncer(struct gaim_pounce *pounce, 106 void gaim_pounce_set_pouncer(GaimPounce *pounce, GaimAccount *pouncer);
110 GaimAccount *pouncer);
111 107
112 /** 108 /**
113 * Sets the buddy a pounce should pounce on. 109 * Sets the buddy a pounce should pounce on.
114 * 110 *
115 * @param pounce The buddy pounce. 111 * @param pounce The buddy pounce.
116 * @param pouncee The buddy to pounce on. 112 * @param pouncee The buddy to pounce on.
117 */ 113 */
118 void gaim_pounce_set_pouncee(struct gaim_pounce *pounce, const char *buddy); 114 void gaim_pounce_set_pouncee(GaimPounce *pounce, const char *buddy);
119 115
120 /** 116 /**
121 * Sets the callback function to call when the pounce event is triggered. 117 * Sets the callback function to call when the pounce event is triggered.
122 * 118 *
123 * @param pounce The buddy pounce. 119 * @param pounce The buddy pounce.
124 * @param cb The callback function. 120 * @param cb The callback function.
125 */ 121 */
126 void gaim_pounce_set_callback(struct gaim_pounce *pounce, gaim_pounce_cb cb); 122 void gaim_pounce_set_callback(GaimPounce *pounce, GaimPounceCb cb);
127 123
128 /** 124 /**
129 * Sets the pounce-specific data. 125 * Sets the pounce-specific data.
130 * 126 *
131 * @param pounce The buddy pounce. 127 * @param pounce The buddy pounce.
132 * @param data Data specific to the pounce. 128 * @param data Data specific to the pounce.
133 */ 129 */
134 void gaim_pounce_set_data(struct gaim_pounce *pounce, void *data); 130 void gaim_pounce_set_data(GaimPounce *pounce, void *data);
135 131
136 /** 132 /**
137 * Returns the events a pounce should watch for. 133 * Returns the events a pounce should watch for.
138 * 134 *
139 * @param pounce The buddy pounce. 135 * @param pounce The buddy pounce.
140 * 136 *
141 * @return The events the pounce is watching for. 137 * @return The events the pounce is watching for.
142 */ 138 */
143 GaimPounceEvent gaim_pounce_get_events(const struct gaim_pounce *pounce); 139 GaimPounceEvent gaim_pounce_get_events(const GaimPounce *pounce);
144 140
145 /** 141 /**
146 * Returns the account that will do the pouncing. 142 * Returns the account that will do the pouncing.
147 * 143 *
148 * @param pounce The buddy pounce. 144 * @param pounce The buddy pounce.
149 * 145 *
150 * @return The account that will pounce. 146 * @return The account that will pounce.
151 */ 147 */
152 GaimAccount *gaim_pounce_get_pouncer(const struct gaim_pounce *pounce); 148 GaimAccount *gaim_pounce_get_pouncer(const GaimPounce *pounce);
153 149
154 /** 150 /**
155 * Returns the buddy a pounce should pounce on. 151 * Returns the buddy a pounce should pounce on.
156 * 152 *
157 * @param pounce The buddy pounce. 153 * @param pounce The buddy pounce.
158 * 154 *
159 * @return The buddy to pounce on. 155 * @return The buddy to pounce on.
160 */ 156 */
161 const char *gaim_pounce_get_pouncee(const struct gaim_pounce *pounce); 157 const char *gaim_pounce_get_pouncee(const GaimPounce *pounce);
162 158
163 /** 159 /**
164 * Returns the pounce-specific data. 160 * Returns the pounce-specific data.
165 * 161 *
166 * @param pounce The buddy pounce. 162 * @param pounce The buddy pounce.
167 * 163 *
168 * @return The data specific to a buddy pounce. 164 * @return The data specific to a buddy pounce.
169 */ 165 */
170 void *gaim_pounce_get_data(const struct gaim_pounce *pounce); 166 void *gaim_pounce_get_data(const GaimPounce *pounce);
171 167
172 /** 168 /**
173 * Executes a pounce with the specified pouncer, pouncee, and event type. 169 * Executes a pounce with the specified pouncer, pouncee, and event type.
174 * 170 *
175 * @param pouncer The account that will do the pouncing. 171 * @param pouncer The account that will do the pouncing.
176 * @param pouncee The buddy that is being pounced. 172 * @param pouncee The buddy that is being pounced.
177 * @param events The events that triggered the pounce. 173 * @param events The events that triggered the pounce.
178 */ 174 */
179 void gaim_pounce_execute(const GaimAccount *pouncer, 175 void gaim_pounce_execute(const GaimAccount *pouncer, const char *pouncee,
180 const char *pouncee,
181 GaimPounceEvent events); 176 GaimPounceEvent events);
182 177
183 /** 178 /**
184 * Finds a pounce with the specified event(s) and buddy. 179 * Finds a pounce with the specified event(s) and buddy.
185 * 180 *
187 * @param buddy The buddy to match against. 182 * @param buddy The buddy to match against.
188 * @param events The event(s) to match against. 183 * @param events The event(s) to match against.
189 * 184 *
190 * @return The pounce if found, or @c NULL otherwise. 185 * @return The pounce if found, or @c NULL otherwise.
191 */ 186 */
192 struct gaim_pounce *gaim_find_pounce(const GaimAccount *pouncer, 187 GaimPounce *gaim_find_pounce(const GaimAccount *pouncer,
193 const char *pouncee, 188 const char *pouncee, GaimPounceEvent events);
194 GaimPounceEvent events);
195 189
196 /** 190 /**
197 * Returns a list of all registered buddy pounces. 191 * Returns a list of all registered buddy pounces.
198 * 192 *
199 * @return The list of buddy pounces. 193 * @return The list of buddy pounces.