comparison libpurple/plugins/tcl/tcl_cmds.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 31a6bfedf7be
children 4ca97b26a8fb
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
1 /** 1 /**
2 * @file tcl_cmds.c Commands for the Gaim Tcl plugin bindings 2 * @file tcl_cmds.c Commands for the Purple Tcl plugin bindings
3 * 3 *
4 * gaim 4 * purple
5 * 5 *
6 * Copyright (C) 2003 Ethan Blanton <eblanton@cs.purdue.edu> 6 * Copyright (C) 2003 Ethan Blanton <eblanton@cs.purdue.edu>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
32 #include "savedstatuses.h" 32 #include "savedstatuses.h"
33 #include "debug.h" 33 #include "debug.h"
34 #include "prefs.h" 34 #include "prefs.h"
35 #include "core.h" 35 #include "core.h"
36 36
37 #include "tcl_gaim.h" 37 #include "tcl_purple.h"
38 38
39 static GaimAccount *tcl_validate_account(Tcl_Obj *obj, Tcl_Interp *interp); 39 static PurpleAccount *tcl_validate_account(Tcl_Obj *obj, Tcl_Interp *interp);
40 static GaimConversation *tcl_validate_conversation(Tcl_Obj *obj, Tcl_Interp *interp); 40 static PurpleConversation *tcl_validate_conversation(Tcl_Obj *obj, Tcl_Interp *interp);
41 static GaimConnection *tcl_validate_gc(Tcl_Obj *obj, Tcl_Interp *interp); 41 static PurpleConnection *tcl_validate_gc(Tcl_Obj *obj, Tcl_Interp *interp);
42 42
43 static GaimAccount *tcl_validate_account(Tcl_Obj *obj, Tcl_Interp *interp) 43 static PurpleAccount *tcl_validate_account(Tcl_Obj *obj, Tcl_Interp *interp)
44 { 44 {
45 GaimAccount *account; 45 PurpleAccount *account;
46 GList *cur; 46 GList *cur;
47 47
48 account = gaim_tcl_ref_get(interp, obj, GaimTclRefAccount); 48 account = purple_tcl_ref_get(interp, obj, PurpleTclRefAccount);
49 49
50 if (account == NULL) 50 if (account == NULL)
51 return NULL; 51 return NULL;
52 52
53 for (cur = gaim_accounts_get_all(); cur != NULL; cur = g_list_next(cur)) { 53 for (cur = purple_accounts_get_all(); cur != NULL; cur = g_list_next(cur)) {
54 if (account == cur->data) 54 if (account == cur->data)
55 return account; 55 return account;
56 } 56 }
57 if (interp != NULL) 57 if (interp != NULL)
58 Tcl_SetStringObj(Tcl_GetObjResult(interp), "invalid account", -1); 58 Tcl_SetStringObj(Tcl_GetObjResult(interp), "invalid account", -1);
59 return NULL; 59 return NULL;
60 } 60 }
61 61
62 static GaimConversation *tcl_validate_conversation(Tcl_Obj *obj, Tcl_Interp *interp) 62 static PurpleConversation *tcl_validate_conversation(Tcl_Obj *obj, Tcl_Interp *interp)
63 { 63 {
64 GaimConversation *convo; 64 PurpleConversation *convo;
65 GList *cur; 65 GList *cur;
66 66
67 convo = gaim_tcl_ref_get(interp, obj, GaimTclRefConversation); 67 convo = purple_tcl_ref_get(interp, obj, PurpleTclRefConversation);
68 68
69 if (convo == NULL) 69 if (convo == NULL)
70 return NULL; 70 return NULL;
71 71
72 for (cur = gaim_get_conversations(); cur != NULL; cur = g_list_next(cur)) { 72 for (cur = purple_get_conversations(); cur != NULL; cur = g_list_next(cur)) {
73 if (convo == cur->data) 73 if (convo == cur->data)
74 return convo; 74 return convo;
75 } 75 }
76 if (interp != NULL) 76 if (interp != NULL)
77 Tcl_SetStringObj(Tcl_GetObjResult(interp), "invalid conversation", -1); 77 Tcl_SetStringObj(Tcl_GetObjResult(interp), "invalid conversation", -1);
78 return NULL; 78 return NULL;
79 } 79 }
80 80
81 static GaimConnection *tcl_validate_gc(Tcl_Obj *obj, Tcl_Interp *interp) 81 static PurpleConnection *tcl_validate_gc(Tcl_Obj *obj, Tcl_Interp *interp)
82 { 82 {
83 GaimConnection *gc; 83 PurpleConnection *gc;
84 GList *cur; 84 GList *cur;
85 85
86 gc = gaim_tcl_ref_get(interp, obj, GaimTclRefConnection); 86 gc = purple_tcl_ref_get(interp, obj, PurpleTclRefConnection);
87 87
88 if (gc == NULL) 88 if (gc == NULL)
89 return NULL; 89 return NULL;
90 90
91 for (cur = gaim_connections_get_all(); cur != NULL; cur = g_list_next(cur)) { 91 for (cur = purple_connections_get_all(); cur != NULL; cur = g_list_next(cur)) {
92 if (gc == cur->data) 92 if (gc == cur->data)
93 return gc; 93 return gc;
94 } 94 }
95 return NULL; 95 return NULL;
96 } 96 }
112 CMD_ACCOUNT_USERNAME } cmd; 112 CMD_ACCOUNT_USERNAME } cmd;
113 const char *listopts[] = { "-all", "-online", NULL }; 113 const char *listopts[] = { "-all", "-online", NULL };
114 enum { CMD_ACCOUNTLIST_ALL, CMD_ACCOUNTLIST_ONLINE } listopt; 114 enum { CMD_ACCOUNTLIST_ALL, CMD_ACCOUNTLIST_ONLINE } listopt;
115 const char *alias; 115 const char *alias;
116 const GList *cur; 116 const GList *cur;
117 GaimAccount *account; 117 PurpleAccount *account;
118 GaimStatus *status; 118 PurpleStatus *status;
119 GaimStatusType *status_type; 119 PurpleStatusType *status_type;
120 GaimValue *value; 120 PurpleValue *value;
121 char *attr_id; 121 char *attr_id;
122 int error; 122 int error;
123 int b, i; 123 int b, i;
124 124
125 if (objc < 2) { 125 if (objc < 2) {
136 Tcl_WrongNumArgs(interp, 2, objv, "account"); 136 Tcl_WrongNumArgs(interp, 2, objv, "account");
137 return TCL_ERROR; 137 return TCL_ERROR;
138 } 138 }
139 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 139 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
140 return TCL_ERROR; 140 return TCL_ERROR;
141 alias = gaim_account_get_alias(account); 141 alias = purple_account_get_alias(account);
142 Tcl_SetStringObj(result, alias ? (char *)alias : "", -1); 142 Tcl_SetStringObj(result, alias ? (char *)alias : "", -1);
143 break; 143 break;
144 case CMD_ACCOUNT_CONNECT: 144 case CMD_ACCOUNT_CONNECT:
145 if (objc != 3) { 145 if (objc != 3) {
146 Tcl_WrongNumArgs(interp, 2, objv, "account"); 146 Tcl_WrongNumArgs(interp, 2, objv, "account");
147 return TCL_ERROR; 147 return TCL_ERROR;
148 } 148 }
149 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 149 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
150 return TCL_ERROR; 150 return TCL_ERROR;
151 if (!gaim_account_is_connected(account)) 151 if (!purple_account_is_connected(account))
152 gaim_account_connect(account); 152 purple_account_connect(account);
153 Tcl_SetObjResult(interp, 153 Tcl_SetObjResult(interp,
154 gaim_tcl_ref_new(GaimTclRefConnection, 154 purple_tcl_ref_new(PurpleTclRefConnection,
155 gaim_account_get_connection(account))); 155 purple_account_get_connection(account)));
156 break; 156 break;
157 case CMD_ACCOUNT_CONNECTION: 157 case CMD_ACCOUNT_CONNECTION:
158 if (objc != 3) { 158 if (objc != 3) {
159 Tcl_WrongNumArgs(interp, 2, objv, "account"); 159 Tcl_WrongNumArgs(interp, 2, objv, "account");
160 return TCL_ERROR; 160 return TCL_ERROR;
161 } 161 }
162 162
163 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 163 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
164 return TCL_ERROR; 164 return TCL_ERROR;
165 Tcl_SetObjResult(interp, 165 Tcl_SetObjResult(interp,
166 gaim_tcl_ref_new(GaimTclRefConnection, 166 purple_tcl_ref_new(PurpleTclRefConnection,
167 gaim_account_get_connection(account))); 167 purple_account_get_connection(account)));
168 break; 168 break;
169 case CMD_ACCOUNT_DISCONNECT: 169 case CMD_ACCOUNT_DISCONNECT:
170 if (objc != 3) { 170 if (objc != 3) {
171 Tcl_WrongNumArgs(interp, 2, objv, "account"); 171 Tcl_WrongNumArgs(interp, 2, objv, "account");
172 return TCL_ERROR; 172 return TCL_ERROR;
173 } 173 }
174 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 174 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
175 return TCL_ERROR; 175 return TCL_ERROR;
176 gaim_account_disconnect(account); 176 purple_account_disconnect(account);
177 break; 177 break;
178 case CMD_ACCOUNT_ENABLED: 178 case CMD_ACCOUNT_ENABLED:
179 if (objc != 3 && objc != 4) { 179 if (objc != 3 && objc != 4) {
180 Tcl_WrongNumArgs(interp, 2, objv, "account ?enabled?"); 180 Tcl_WrongNumArgs(interp, 2, objv, "account ?enabled?");
181 return TCL_ERROR; 181 return TCL_ERROR;
182 } 182 }
183 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 183 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
184 return TCL_ERROR; 184 return TCL_ERROR;
185 if (objc == 3) { 185 if (objc == 3) {
186 Tcl_SetBooleanObj(result, 186 Tcl_SetBooleanObj(result,
187 gaim_account_get_enabled(account, 187 purple_account_get_enabled(account,
188 gaim_core_get_ui())); 188 purple_core_get_ui()));
189 } else { 189 } else {
190 if ((error = Tcl_GetBooleanFromObj(interp, objv[3], &b)) != TCL_OK) 190 if ((error = Tcl_GetBooleanFromObj(interp, objv[3], &b)) != TCL_OK)
191 return TCL_ERROR; 191 return TCL_ERROR;
192 gaim_account_set_enabled(account, gaim_core_get_ui(), b); 192 purple_account_set_enabled(account, purple_core_get_ui(), b);
193 } 193 }
194 break; 194 break;
195 case CMD_ACCOUNT_FIND: 195 case CMD_ACCOUNT_FIND:
196 if (objc != 4) { 196 if (objc != 4) {
197 Tcl_WrongNumArgs(interp, 2, objv, "username protocol"); 197 Tcl_WrongNumArgs(interp, 2, objv, "username protocol");
198 return TCL_ERROR; 198 return TCL_ERROR;
199 } 199 }
200 account = gaim_accounts_find(Tcl_GetString(objv[2]), 200 account = purple_accounts_find(Tcl_GetString(objv[2]),
201 Tcl_GetString(objv[3])); 201 Tcl_GetString(objv[3]));
202 Tcl_SetObjResult(interp, 202 Tcl_SetObjResult(interp,
203 gaim_tcl_ref_new(GaimTclRefAccount, account)); 203 purple_tcl_ref_new(PurpleTclRefAccount, account));
204 break; 204 break;
205 case CMD_ACCOUNT_HANDLE: 205 case CMD_ACCOUNT_HANDLE:
206 if (objc != 2) { 206 if (objc != 2) {
207 Tcl_WrongNumArgs(interp, 2, objv, ""); 207 Tcl_WrongNumArgs(interp, 2, objv, "");
208 return TCL_ERROR; 208 return TCL_ERROR;
209 } 209 }
210 Tcl_SetIntObj(result, (int)gaim_accounts_get_handle()); 210 Tcl_SetIntObj(result, (int)purple_accounts_get_handle());
211 break; 211 break;
212 case CMD_ACCOUNT_ISCONNECTED: 212 case CMD_ACCOUNT_ISCONNECTED:
213 if (objc != 3) { 213 if (objc != 3) {
214 Tcl_WrongNumArgs(interp, 2, objv, "account"); 214 Tcl_WrongNumArgs(interp, 2, objv, "account");
215 return TCL_ERROR; 215 return TCL_ERROR;
216 } 216 }
217 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 217 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
218 return TCL_ERROR; 218 return TCL_ERROR;
219 Tcl_SetBooleanObj(result, gaim_account_is_connected(account)); 219 Tcl_SetBooleanObj(result, purple_account_is_connected(account));
220 break; 220 break;
221 case CMD_ACCOUNT_LIST: 221 case CMD_ACCOUNT_LIST:
222 listopt = CMD_ACCOUNTLIST_ALL; 222 listopt = CMD_ACCOUNTLIST_ALL;
223 if (objc > 3) { 223 if (objc > 3) {
224 Tcl_WrongNumArgs(interp, 2, objv, "?option?"); 224 Tcl_WrongNumArgs(interp, 2, objv, "?option?");
227 if (objc == 3) { 227 if (objc == 3) {
228 if ((error = Tcl_GetIndexFromObj(interp, objv[2], listopts, "option", 0, (int *)&listopt)) != TCL_OK) 228 if ((error = Tcl_GetIndexFromObj(interp, objv[2], listopts, "option", 0, (int *)&listopt)) != TCL_OK)
229 return error; 229 return error;
230 } 230 }
231 list = Tcl_NewListObj(0, NULL); 231 list = Tcl_NewListObj(0, NULL);
232 for (cur = gaim_accounts_get_all(); cur != NULL; cur = g_list_next(cur)) { 232 for (cur = purple_accounts_get_all(); cur != NULL; cur = g_list_next(cur)) {
233 account = cur->data; 233 account = cur->data;
234 if (listopt == CMD_ACCOUNTLIST_ONLINE && !gaim_account_is_connected(account)) 234 if (listopt == CMD_ACCOUNTLIST_ONLINE && !purple_account_is_connected(account))
235 continue; 235 continue;
236 elem = gaim_tcl_ref_new(GaimTclRefAccount, account); 236 elem = purple_tcl_ref_new(PurpleTclRefAccount, account);
237 Tcl_ListObjAppendElement(interp, list, elem); 237 Tcl_ListObjAppendElement(interp, list, elem);
238 } 238 }
239 Tcl_SetObjResult(interp, list); 239 Tcl_SetObjResult(interp, list);
240 break; 240 break;
241 case CMD_ACCOUNT_PRESENCE: 241 case CMD_ACCOUNT_PRESENCE:
243 Tcl_WrongNumArgs(interp, 2, objv, "account"); 243 Tcl_WrongNumArgs(interp, 2, objv, "account");
244 return TCL_ERROR; 244 return TCL_ERROR;
245 } 245 }
246 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 246 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
247 return TCL_ERROR; 247 return TCL_ERROR;
248 Tcl_SetObjResult(interp, gaim_tcl_ref_new(GaimTclRefPresence, 248 Tcl_SetObjResult(interp, purple_tcl_ref_new(PurpleTclRefPresence,
249 gaim_account_get_presence(account))); 249 purple_account_get_presence(account)));
250 break; 250 break;
251 case CMD_ACCOUNT_PROTOCOL: 251 case CMD_ACCOUNT_PROTOCOL:
252 if (objc != 3) { 252 if (objc != 3) {
253 Tcl_WrongNumArgs(interp, 2, objv, "account"); 253 Tcl_WrongNumArgs(interp, 2, objv, "account");
254 return TCL_ERROR; 254 return TCL_ERROR;
255 } 255 }
256 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 256 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
257 return TCL_ERROR; 257 return TCL_ERROR;
258 Tcl_SetStringObj(result, (char *)gaim_account_get_protocol_id(account), -1); 258 Tcl_SetStringObj(result, (char *)purple_account_get_protocol_id(account), -1);
259 break; 259 break;
260 case CMD_ACCOUNT_STATUS: 260 case CMD_ACCOUNT_STATUS:
261 if (objc < 3) { 261 if (objc < 3) {
262 Tcl_WrongNumArgs(interp, 2, objv, "account ?status_id name value ...?"); 262 Tcl_WrongNumArgs(interp, 2, objv, "account ?status_id name value ...?");
263 return TCL_ERROR; 263 return TCL_ERROR;
264 } 264 }
265 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 265 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
266 return TCL_ERROR; 266 return TCL_ERROR;
267 if (objc == 3) { 267 if (objc == 3) {
268 Tcl_SetObjResult(interp, 268 Tcl_SetObjResult(interp,
269 gaim_tcl_ref_new(GaimTclRefStatus, 269 purple_tcl_ref_new(PurpleTclRefStatus,
270 gaim_account_get_active_status(account))); 270 purple_account_get_active_status(account)));
271 } else { 271 } else {
272 GList *l = NULL; 272 GList *l = NULL;
273 if (objc % 2) { 273 if (objc % 2) {
274 Tcl_SetStringObj(result, "name without value setting status", -1); 274 Tcl_SetStringObj(result, "name without value setting status", -1);
275 return TCL_ERROR; 275 return TCL_ERROR;
276 } 276 }
277 status = gaim_account_get_status(account, Tcl_GetString(objv[3])); 277 status = purple_account_get_status(account, Tcl_GetString(objv[3]));
278 if (status == NULL) { 278 if (status == NULL) {
279 Tcl_SetStringObj(result, "invalid status for account", -1); 279 Tcl_SetStringObj(result, "invalid status for account", -1);
280 return TCL_ERROR; 280 return TCL_ERROR;
281 } 281 }
282 for (i = 4; i < objc; i += 2) { 282 for (i = 4; i < objc; i += 2) {
283 attr_id = Tcl_GetString(objv[i]); 283 attr_id = Tcl_GetString(objv[i]);
284 value = gaim_status_get_attr_value(status, attr_id); 284 value = purple_status_get_attr_value(status, attr_id);
285 if (value == NULL) { 285 if (value == NULL) {
286 Tcl_SetStringObj(result, "invalid attribute for account", -1); 286 Tcl_SetStringObj(result, "invalid attribute for account", -1);
287 return TCL_ERROR; 287 return TCL_ERROR;
288 } 288 }
289 switch (gaim_value_get_type(value)) { 289 switch (purple_value_get_type(value)) {
290 case GAIM_TYPE_BOOLEAN: 290 case PURPLE_TYPE_BOOLEAN:
291 error = Tcl_GetBooleanFromObj(interp, objv[i + 1], &b); 291 error = Tcl_GetBooleanFromObj(interp, objv[i + 1], &b);
292 if (error != TCL_OK) 292 if (error != TCL_OK)
293 return error; 293 return error;
294 l = g_list_append(l, attr_id); 294 l = g_list_append(l, attr_id);
295 l = g_list_append(l, GINT_TO_POINTER(b)); 295 l = g_list_append(l, GINT_TO_POINTER(b));
296 break; 296 break;
297 case GAIM_TYPE_INT: 297 case PURPLE_TYPE_INT:
298 error = Tcl_GetIntFromObj(interp, objv[i + 1], &b); 298 error = Tcl_GetIntFromObj(interp, objv[i + 1], &b);
299 if (error != TCL_OK) 299 if (error != TCL_OK)
300 return error; 300 return error;
301 l = g_list_append(l, attr_id); 301 l = g_list_append(l, attr_id);
302 l = g_list_append(l, GINT_TO_POINTER(b)); 302 l = g_list_append(l, GINT_TO_POINTER(b));
303 break; 303 break;
304 case GAIM_TYPE_STRING: 304 case PURPLE_TYPE_STRING:
305 l = g_list_append(l, attr_id); 305 l = g_list_append(l, attr_id);
306 l = g_list_append(l, Tcl_GetString(objv[i + 1])); 306 l = g_list_append(l, Tcl_GetString(objv[i + 1]));
307 break; 307 break;
308 default: 308 default:
309 Tcl_SetStringObj(result, "unknown GaimValue type", -1); 309 Tcl_SetStringObj(result, "unknown PurpleValue type", -1);
310 return TCL_ERROR; 310 return TCL_ERROR;
311 } 311 }
312 } 312 }
313 gaim_account_set_status_list(account, Tcl_GetString(objv[3]), TRUE, l); 313 purple_account_set_status_list(account, Tcl_GetString(objv[3]), TRUE, l);
314 g_list_free(l); 314 g_list_free(l);
315 } 315 }
316 break; 316 break;
317 case CMD_ACCOUNT_STATUS_TYPE: 317 case CMD_ACCOUNT_STATUS_TYPE:
318 if (objc != 4 && objc != 5) { 318 if (objc != 4 && objc != 5) {
320 return TCL_ERROR; 320 return TCL_ERROR;
321 } 321 }
322 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 322 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
323 return TCL_ERROR; 323 return TCL_ERROR;
324 if (objc == 4) { 324 if (objc == 4) {
325 status_type = gaim_account_get_status_type(account, 325 status_type = purple_account_get_status_type(account,
326 Tcl_GetString(objv[3])); 326 Tcl_GetString(objv[3]));
327 } else { 327 } else {
328 GaimStatusPrimitive primitive; 328 PurpleStatusPrimitive primitive;
329 if (strcmp(Tcl_GetString(objv[3]), "-primitive")) { 329 if (strcmp(Tcl_GetString(objv[3]), "-primitive")) {
330 Tcl_SetStringObj(result, "bad option \"", -1); 330 Tcl_SetStringObj(result, "bad option \"", -1);
331 Tcl_AppendObjToObj(result, objv[3]); 331 Tcl_AppendObjToObj(result, objv[3]);
332 Tcl_AppendToObj(result, 332 Tcl_AppendToObj(result,
333 "\": should be -primitive", -1); 333 "\": should be -primitive", -1);
334 return TCL_ERROR; 334 return TCL_ERROR;
335 } 335 }
336 primitive = gaim_primitive_get_type_from_id(Tcl_GetString(objv[4])); 336 primitive = purple_primitive_get_type_from_id(Tcl_GetString(objv[4]));
337 status_type = gaim_account_get_status_type_with_primitive(account, 337 status_type = purple_account_get_status_type_with_primitive(account,
338 primitive); 338 primitive);
339 } 339 }
340 if (status_type == NULL) { 340 if (status_type == NULL) {
341 Tcl_SetStringObj(result, "status type not found", -1); 341 Tcl_SetStringObj(result, "status type not found", -1);
342 return TCL_ERROR; 342 return TCL_ERROR;
343 } 343 }
344 Tcl_SetObjResult(interp, 344 Tcl_SetObjResult(interp,
345 gaim_tcl_ref_new(GaimTclRefStatusType, 345 purple_tcl_ref_new(PurpleTclRefStatusType,
346 status_type)); 346 status_type));
347 break; 347 break;
348 case CMD_ACCOUNT_STATUS_TYPES: 348 case CMD_ACCOUNT_STATUS_TYPES:
349 if (objc != 3) { 349 if (objc != 3) {
350 Tcl_WrongNumArgs(interp, 2, objv, "account"); 350 Tcl_WrongNumArgs(interp, 2, objv, "account");
351 return TCL_ERROR; 351 return TCL_ERROR;
352 } 352 }
353 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 353 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
354 return TCL_ERROR; 354 return TCL_ERROR;
355 list = Tcl_NewListObj(0, NULL); 355 list = Tcl_NewListObj(0, NULL);
356 for (cur = gaim_account_get_status_types(account); cur != NULL; 356 for (cur = purple_account_get_status_types(account); cur != NULL;
357 cur = g_list_next(cur)) { 357 cur = g_list_next(cur)) {
358 Tcl_ListObjAppendElement(interp, list, 358 Tcl_ListObjAppendElement(interp, list,
359 gaim_tcl_ref_new(GaimTclRefStatusType, 359 purple_tcl_ref_new(PurpleTclRefStatusType,
360 cur->data)); 360 cur->data));
361 } 361 }
362 Tcl_SetObjResult(interp, list); 362 Tcl_SetObjResult(interp, list);
363 break; 363 break;
364 case CMD_ACCOUNT_USERNAME: 364 case CMD_ACCOUNT_USERNAME:
366 Tcl_WrongNumArgs(interp, 2, objv, "account"); 366 Tcl_WrongNumArgs(interp, 2, objv, "account");
367 return TCL_ERROR; 367 return TCL_ERROR;
368 } 368 }
369 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 369 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
370 return TCL_ERROR; 370 return TCL_ERROR;
371 Tcl_SetStringObj(result, (char *)gaim_account_get_username(account), -1); 371 Tcl_SetStringObj(result, (char *)purple_account_get_username(account), -1);
372 break; 372 break;
373 } 373 }
374 374
375 return TCL_OK; 375 return TCL_OK;
376 } 376 }
377 377
378 static GaimBlistNode *tcl_list_to_buddy(Tcl_Interp *interp, int count, Tcl_Obj **elems) 378 static PurpleBlistNode *tcl_list_to_buddy(Tcl_Interp *interp, int count, Tcl_Obj **elems)
379 { 379 {
380 GaimBlistNode *node = NULL; 380 PurpleBlistNode *node = NULL;
381 GaimAccount *account; 381 PurpleAccount *account;
382 char *name; 382 char *name;
383 char *type; 383 char *type;
384 384
385 if (count < 3) { 385 if (count < 3) {
386 Tcl_SetStringObj(Tcl_GetObjResult(interp), "list too short", -1); 386 Tcl_SetStringObj(Tcl_GetObjResult(interp), "list too short", -1);
391 name = Tcl_GetString(elems[1]); 391 name = Tcl_GetString(elems[1]);
392 if ((account = tcl_validate_account(elems[2], interp)) == NULL) 392 if ((account = tcl_validate_account(elems[2], interp)) == NULL)
393 return NULL; 393 return NULL;
394 394
395 if (!strcmp(type, "buddy")) { 395 if (!strcmp(type, "buddy")) {
396 node = (GaimBlistNode *)gaim_find_buddy(account, name); 396 node = (PurpleBlistNode *)purple_find_buddy(account, name);
397 } else if (!strcmp(type, "group")) { 397 } else if (!strcmp(type, "group")) {
398 node = (GaimBlistNode *)gaim_blist_find_chat(account, name); 398 node = (PurpleBlistNode *)purple_blist_find_chat(account, name);
399 } 399 }
400 400
401 return node; 401 return node;
402 } 402 }
403 403
404 int tcl_cmd_buddy(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 404 int tcl_cmd_buddy(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
405 { 405 {
406 Tcl_Obj *list, *tclgroup, *tclgrouplist, *tclcontact, *tclcontactlist, *tclbud, **elems, *result; 406 Tcl_Obj *list, *tclgroup, *tclgrouplist, *tclcontact, *tclcontactlist, *tclbud, **elems, *result;
407 const char *cmds[] = { "alias", "handle", "info", "list", NULL }; 407 const char *cmds[] = { "alias", "handle", "info", "list", NULL };
408 enum { CMD_BUDDY_ALIAS, CMD_BUDDY_HANDLE, CMD_BUDDY_INFO, CMD_BUDDY_LIST } cmd; 408 enum { CMD_BUDDY_ALIAS, CMD_BUDDY_HANDLE, CMD_BUDDY_INFO, CMD_BUDDY_LIST } cmd;
409 GaimBuddyList *blist; 409 PurpleBuddyList *blist;
410 GaimBlistNode *node, *gnode, *bnode; 410 PurpleBlistNode *node, *gnode, *bnode;
411 GaimAccount *account; 411 PurpleAccount *account;
412 GaimBuddy *bud; 412 PurpleBuddy *bud;
413 GaimChat *cnode; 413 PurpleChat *cnode;
414 int error, all = 0, count; 414 int error, all = 0, count;
415 415
416 if (objc < 2) { 416 if (objc < 2) {
417 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 417 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
418 return TCL_ERROR; 418 return TCL_ERROR;
430 } 430 }
431 if ((error = Tcl_ListObjGetElements(interp, objv[2], &count, &elems)) != TCL_OK) 431 if ((error = Tcl_ListObjGetElements(interp, objv[2], &count, &elems)) != TCL_OK)
432 return error; 432 return error;
433 if ((node = tcl_list_to_buddy(interp, count, elems)) == NULL) 433 if ((node = tcl_list_to_buddy(interp, count, elems)) == NULL)
434 return TCL_ERROR; 434 return TCL_ERROR;
435 if (node->type == GAIM_BLIST_CHAT_NODE) 435 if (node->type == PURPLE_BLIST_CHAT_NODE)
436 Tcl_SetStringObj(result, ((GaimChat *)node)->alias, -1); 436 Tcl_SetStringObj(result, ((PurpleChat *)node)->alias, -1);
437 else if (node->type == GAIM_BLIST_BUDDY_NODE) 437 else if (node->type == PURPLE_BLIST_BUDDY_NODE)
438 Tcl_SetStringObj(result, (char *)gaim_buddy_get_alias((GaimBuddy *)node), -1); 438 Tcl_SetStringObj(result, (char *)purple_buddy_get_alias((PurpleBuddy *)node), -1);
439 return TCL_OK; 439 return TCL_OK;
440 break; 440 break;
441 case CMD_BUDDY_HANDLE: 441 case CMD_BUDDY_HANDLE:
442 if (objc != 2) { 442 if (objc != 2) {
443 Tcl_WrongNumArgs(interp, 2, objv, ""); 443 Tcl_WrongNumArgs(interp, 2, objv, "");
444 return TCL_ERROR; 444 return TCL_ERROR;
445 } 445 }
446 Tcl_SetIntObj(result, (int)gaim_blist_get_handle()); 446 Tcl_SetIntObj(result, (int)purple_blist_get_handle());
447 break; 447 break;
448 case CMD_BUDDY_INFO: 448 case CMD_BUDDY_INFO:
449 if (objc != 3 && objc != 4) { 449 if (objc != 3 && objc != 4) {
450 Tcl_WrongNumArgs(interp, 2, objv, "( buddy | account username )"); 450 Tcl_WrongNumArgs(interp, 2, objv, "( buddy | account username )");
451 return TCL_ERROR; 451 return TCL_ERROR;
461 Tcl_SetStringObj(result, "invalid buddy", -1); 461 Tcl_SetStringObj(result, "invalid buddy", -1);
462 return TCL_ERROR; 462 return TCL_ERROR;
463 } 463 }
464 if ((account = tcl_validate_account(elems[2], interp)) == NULL) 464 if ((account = tcl_validate_account(elems[2], interp)) == NULL)
465 return TCL_ERROR; 465 return TCL_ERROR;
466 serv_get_info(gaim_account_get_connection(account), Tcl_GetString(elems[1])); 466 serv_get_info(purple_account_get_connection(account), Tcl_GetString(elems[1]));
467 } else { 467 } else {
468 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 468 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
469 return TCL_ERROR; 469 return TCL_ERROR;
470 serv_get_info(gaim_account_get_connection(account), Tcl_GetString(objv[3])); 470 serv_get_info(purple_account_get_connection(account), Tcl_GetString(objv[3]));
471 } 471 }
472 break; 472 break;
473 case CMD_BUDDY_LIST: 473 case CMD_BUDDY_LIST:
474 if (objc == 3) { 474 if (objc == 3) {
475 if (!strcmp("-all", Tcl_GetString(objv[2]))) { 475 if (!strcmp("-all", Tcl_GetString(objv[2]))) {
479 Tcl_AppendStringsToObj(result, "unknown option: ", Tcl_GetString(objv[2]), NULL); 479 Tcl_AppendStringsToObj(result, "unknown option: ", Tcl_GetString(objv[2]), NULL);
480 return TCL_ERROR; 480 return TCL_ERROR;
481 } 481 }
482 } 482 }
483 list = Tcl_NewListObj(0, NULL); 483 list = Tcl_NewListObj(0, NULL);
484 blist = gaim_get_blist(); 484 blist = purple_get_blist();
485 for (gnode = blist->root; gnode != NULL; gnode = gnode->next) { 485 for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
486 tclgroup = Tcl_NewListObj(0, NULL); 486 tclgroup = Tcl_NewListObj(0, NULL);
487 Tcl_ListObjAppendElement(interp, tclgroup, Tcl_NewStringObj("group", -1)); 487 Tcl_ListObjAppendElement(interp, tclgroup, Tcl_NewStringObj("group", -1));
488 Tcl_ListObjAppendElement(interp, tclgroup, 488 Tcl_ListObjAppendElement(interp, tclgroup,
489 Tcl_NewStringObj(((GaimGroup *)gnode)->name, -1)); 489 Tcl_NewStringObj(((PurpleGroup *)gnode)->name, -1));
490 tclgrouplist = Tcl_NewListObj(0, NULL); 490 tclgrouplist = Tcl_NewListObj(0, NULL);
491 for (node = gnode->child; node != NULL; node = node->next) { 491 for (node = gnode->child; node != NULL; node = node->next) {
492 switch (node->type) { 492 switch (node->type) {
493 case GAIM_BLIST_CONTACT_NODE: 493 case PURPLE_BLIST_CONTACT_NODE:
494 tclcontact = Tcl_NewListObj(0, NULL); 494 tclcontact = Tcl_NewListObj(0, NULL);
495 Tcl_IncrRefCount(tclcontact); 495 Tcl_IncrRefCount(tclcontact);
496 Tcl_ListObjAppendElement(interp, tclcontact, Tcl_NewStringObj("contact", -1)); 496 Tcl_ListObjAppendElement(interp, tclcontact, Tcl_NewStringObj("contact", -1));
497 tclcontactlist = Tcl_NewListObj(0, NULL); 497 tclcontactlist = Tcl_NewListObj(0, NULL);
498 Tcl_IncrRefCount(tclcontactlist); 498 Tcl_IncrRefCount(tclcontactlist);
499 count = 0; 499 count = 0;
500 for (bnode = node->child; bnode != NULL; bnode = bnode ->next) { 500 for (bnode = node->child; bnode != NULL; bnode = bnode ->next) {
501 if (bnode->type != GAIM_BLIST_BUDDY_NODE) 501 if (bnode->type != PURPLE_BLIST_BUDDY_NODE)
502 continue; 502 continue;
503 bud = (GaimBuddy *)bnode; 503 bud = (PurpleBuddy *)bnode;
504 if (!all && !gaim_account_is_connected(bud->account)) 504 if (!all && !purple_account_is_connected(bud->account))
505 continue; 505 continue;
506 count++; 506 count++;
507 tclbud = Tcl_NewListObj(0, NULL); 507 tclbud = Tcl_NewListObj(0, NULL);
508 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj("buddy", -1)); 508 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj("buddy", -1));
509 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj(bud->name, -1)); 509 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj(bud->name, -1));
510 Tcl_ListObjAppendElement(interp, tclbud, gaim_tcl_ref_new(GaimTclRefAccount, bud->account)); 510 Tcl_ListObjAppendElement(interp, tclbud, purple_tcl_ref_new(PurpleTclRefAccount, bud->account));
511 Tcl_ListObjAppendElement(interp, tclcontactlist, tclbud); 511 Tcl_ListObjAppendElement(interp, tclcontactlist, tclbud);
512 } 512 }
513 if (count) { 513 if (count) {
514 Tcl_ListObjAppendElement(interp, tclcontact, tclcontactlist); 514 Tcl_ListObjAppendElement(interp, tclcontact, tclcontactlist);
515 Tcl_ListObjAppendElement(interp, tclgrouplist, tclcontact); 515 Tcl_ListObjAppendElement(interp, tclgrouplist, tclcontact);
516 } 516 }
517 Tcl_DecrRefCount(tclcontact); 517 Tcl_DecrRefCount(tclcontact);
518 Tcl_DecrRefCount(tclcontactlist); 518 Tcl_DecrRefCount(tclcontactlist);
519 break; 519 break;
520 case GAIM_BLIST_CHAT_NODE: 520 case PURPLE_BLIST_CHAT_NODE:
521 cnode = (GaimChat *)node; 521 cnode = (PurpleChat *)node;
522 if (!all && !gaim_account_is_connected(cnode->account)) 522 if (!all && !purple_account_is_connected(cnode->account))
523 continue; 523 continue;
524 tclbud = Tcl_NewListObj(0, NULL); 524 tclbud = Tcl_NewListObj(0, NULL);
525 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj("chat", -1)); 525 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj("chat", -1));
526 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj(cnode->alias, -1)); 526 Tcl_ListObjAppendElement(interp, tclbud, Tcl_NewStringObj(cnode->alias, -1));
527 Tcl_ListObjAppendElement(interp, tclbud, gaim_tcl_ref_new(GaimTclRefAccount, cnode->account)); 527 Tcl_ListObjAppendElement(interp, tclbud, purple_tcl_ref_new(PurpleTclRefAccount, cnode->account));
528 Tcl_ListObjAppendElement(interp, tclgrouplist, tclbud); 528 Tcl_ListObjAppendElement(interp, tclgrouplist, tclbud);
529 break; 529 break;
530 default: 530 default:
531 gaim_debug(GAIM_DEBUG_WARNING, "tcl", "Unexpected buddy type %d", node->type); 531 purple_debug(PURPLE_DEBUG_WARNING, "tcl", "Unexpected buddy type %d", node->type);
532 continue; 532 continue;
533 } 533 }
534 } 534 }
535 Tcl_ListObjAppendElement(interp, tclgroup, tclgrouplist); 535 Tcl_ListObjAppendElement(interp, tclgroup, tclgrouplist);
536 Tcl_ListObjAppendElement(interp, list, tclgroup); 536 Tcl_ListObjAppendElement(interp, list, tclgroup);
546 { 546 {
547 const char *cmds[] = { "register", "unregister", NULL }; 547 const char *cmds[] = { "register", "unregister", NULL };
548 enum { CMD_CMD_REGISTER, CMD_CMD_UNREGISTER } cmd; 548 enum { CMD_CMD_REGISTER, CMD_CMD_UNREGISTER } cmd;
549 struct tcl_cmd_handler *handler; 549 struct tcl_cmd_handler *handler;
550 Tcl_Obj *result = Tcl_GetObjResult(interp); 550 Tcl_Obj *result = Tcl_GetObjResult(interp);
551 GaimCmdId id; 551 PurpleCmdId id;
552 int error; 552 int error;
553 553
554 if (objc < 2) { 554 if (objc < 2) {
555 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 555 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
556 return TCL_ERROR; 556 return TCL_ERROR;
611 Tcl_Obj *result = Tcl_GetObjResult(interp), *list, *elem; 611 Tcl_Obj *result = Tcl_GetObjResult(interp), *list, *elem;
612 const char *cmds[] = { "account", "displayname", "handle", "list", NULL }; 612 const char *cmds[] = { "account", "displayname", "handle", "list", NULL };
613 enum { CMD_CONN_ACCOUNT, CMD_CONN_DISPLAYNAME, CMD_CONN_HANDLE, CMD_CONN_LIST } cmd; 613 enum { CMD_CONN_ACCOUNT, CMD_CONN_DISPLAYNAME, CMD_CONN_HANDLE, CMD_CONN_LIST } cmd;
614 int error; 614 int error;
615 GList *cur; 615 GList *cur;
616 GaimConnection *gc; 616 PurpleConnection *gc;
617 617
618 if (objc < 2) { 618 if (objc < 2) {
619 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 619 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
620 return TCL_ERROR; 620 return TCL_ERROR;
621 } 621 }
630 return TCL_ERROR; 630 return TCL_ERROR;
631 } 631 }
632 if ((gc = tcl_validate_gc(objv[2], interp)) == NULL) 632 if ((gc = tcl_validate_gc(objv[2], interp)) == NULL)
633 return TCL_ERROR; 633 return TCL_ERROR;
634 Tcl_SetObjResult(interp, 634 Tcl_SetObjResult(interp,
635 gaim_tcl_ref_new(GaimTclRefAccount, 635 purple_tcl_ref_new(PurpleTclRefAccount,
636 gaim_connection_get_account(gc))); 636 purple_connection_get_account(gc)));
637 break; 637 break;
638 case CMD_CONN_DISPLAYNAME: 638 case CMD_CONN_DISPLAYNAME:
639 if (objc != 3) { 639 if (objc != 3) {
640 Tcl_WrongNumArgs(interp, 2, objv, "gc"); 640 Tcl_WrongNumArgs(interp, 2, objv, "gc");
641 return TCL_ERROR; 641 return TCL_ERROR;
642 } 642 }
643 if ((gc = tcl_validate_gc(objv[2], interp)) == NULL) 643 if ((gc = tcl_validate_gc(objv[2], interp)) == NULL)
644 return TCL_ERROR; 644 return TCL_ERROR;
645 Tcl_SetStringObj(result, (char *)gaim_connection_get_display_name(gc), -1); 645 Tcl_SetStringObj(result, (char *)purple_connection_get_display_name(gc), -1);
646 break; 646 break;
647 case CMD_CONN_HANDLE: 647 case CMD_CONN_HANDLE:
648 if (objc != 2) { 648 if (objc != 2) {
649 Tcl_WrongNumArgs(interp, 2, objv, ""); 649 Tcl_WrongNumArgs(interp, 2, objv, "");
650 return TCL_ERROR; 650 return TCL_ERROR;
651 } 651 }
652 Tcl_SetIntObj(result, (int)gaim_connections_get_handle()); 652 Tcl_SetIntObj(result, (int)purple_connections_get_handle());
653 break; 653 break;
654 case CMD_CONN_LIST: 654 case CMD_CONN_LIST:
655 if (objc != 2) { 655 if (objc != 2) {
656 Tcl_WrongNumArgs(interp, 2, objv, ""); 656 Tcl_WrongNumArgs(interp, 2, objv, "");
657 return TCL_ERROR; 657 return TCL_ERROR;
658 } 658 }
659 list = Tcl_NewListObj(0, NULL); 659 list = Tcl_NewListObj(0, NULL);
660 for (cur = gaim_connections_get_all(); cur != NULL; cur = g_list_next(cur)) { 660 for (cur = purple_connections_get_all(); cur != NULL; cur = g_list_next(cur)) {
661 elem = gaim_tcl_ref_new(GaimTclRefConnection, cur->data); 661 elem = purple_tcl_ref_new(PurpleTclRefConnection, cur->data);
662 Tcl_ListObjAppendElement(interp, list, elem); 662 Tcl_ListObjAppendElement(interp, list, elem);
663 } 663 }
664 Tcl_SetObjResult(interp, list); 664 Tcl_SetObjResult(interp, list);
665 break; 665 break;
666 } 666 }
675 enum { CMD_CONV_FIND, CMD_CONV_HANDLE, CMD_CONV_LIST, CMD_CONV_NEW, CMD_CONV_WRITE , CMD_CONV_NAME, CMD_CONV_TITLE, CMD_CONV_SEND } cmd; 675 enum { CMD_CONV_FIND, CMD_CONV_HANDLE, CMD_CONV_LIST, CMD_CONV_NEW, CMD_CONV_WRITE , CMD_CONV_NAME, CMD_CONV_TITLE, CMD_CONV_SEND } cmd;
676 const char *styles[] = { "send", "recv", "system", NULL }; 676 const char *styles[] = { "send", "recv", "system", NULL };
677 enum { CMD_CONV_WRITE_SEND, CMD_CONV_WRITE_RECV, CMD_CONV_WRITE_SYSTEM } style; 677 enum { CMD_CONV_WRITE_SEND, CMD_CONV_WRITE_RECV, CMD_CONV_WRITE_SYSTEM } style;
678 const char *newopts[] = { "-chat", "-im" }; 678 const char *newopts[] = { "-chat", "-im" };
679 enum { CMD_CONV_NEW_CHAT, CMD_CONV_NEW_IM } newopt; 679 enum { CMD_CONV_NEW_CHAT, CMD_CONV_NEW_IM } newopt;
680 GaimConversation *convo; 680 PurpleConversation *convo;
681 GaimAccount *account; 681 PurpleAccount *account;
682 GaimConversationType type; 682 PurpleConversationType type;
683 GList *cur; 683 GList *cur;
684 char *opt, *from, *what; 684 char *opt, *from, *what;
685 int error, argsused, flags = 0; 685 int error, argsused, flags = 0;
686 686
687 if (objc < 2) { 687 if (objc < 2) {
699 return TCL_ERROR; 699 return TCL_ERROR;
700 } 700 }
701 account = NULL; 701 account = NULL;
702 if ((account = tcl_validate_account(objv[2], interp)) == NULL) 702 if ((account = tcl_validate_account(objv[2], interp)) == NULL)
703 return TCL_ERROR; 703 return TCL_ERROR;
704 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, 704 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
705 Tcl_GetString(objv[3]), 705 Tcl_GetString(objv[3]),
706 account); 706 account);
707 Tcl_SetObjResult(interp, gaim_tcl_ref_new(GaimTclRefConversation, convo)); 707 Tcl_SetObjResult(interp, purple_tcl_ref_new(PurpleTclRefConversation, convo));
708 break; 708 break;
709 case CMD_CONV_HANDLE: 709 case CMD_CONV_HANDLE:
710 if (objc != 2) { 710 if (objc != 2) {
711 Tcl_WrongNumArgs(interp, 2, objv, ""); 711 Tcl_WrongNumArgs(interp, 2, objv, "");
712 return TCL_ERROR; 712 return TCL_ERROR;
713 } 713 }
714 Tcl_SetIntObj(result, (int)gaim_conversations_get_handle()); 714 Tcl_SetIntObj(result, (int)purple_conversations_get_handle());
715 break; 715 break;
716 case CMD_CONV_LIST: 716 case CMD_CONV_LIST:
717 list = Tcl_NewListObj(0, NULL); 717 list = Tcl_NewListObj(0, NULL);
718 for (cur = gaim_get_conversations(); cur != NULL; cur = g_list_next(cur)) { 718 for (cur = purple_get_conversations(); cur != NULL; cur = g_list_next(cur)) {
719 elem = gaim_tcl_ref_new(GaimTclRefConversation, cur->data); 719 elem = purple_tcl_ref_new(PurpleTclRefConversation, cur->data);
720 Tcl_ListObjAppendElement(interp, list, elem); 720 Tcl_ListObjAppendElement(interp, list, elem);
721 } 721 }
722 Tcl_SetObjResult(interp, list); 722 Tcl_SetObjResult(interp, list);
723 break; 723 break;
724 case CMD_CONV_NEW: 724 case CMD_CONV_NEW:
725 if (objc < 4) { 725 if (objc < 4) {
726 Tcl_WrongNumArgs(interp, 2, objv, "?options? account name"); 726 Tcl_WrongNumArgs(interp, 2, objv, "?options? account name");
727 return TCL_ERROR; 727 return TCL_ERROR;
728 } 728 }
729 argsused = 2; 729 argsused = 2;
730 type = GAIM_CONV_TYPE_IM; 730 type = PURPLE_CONV_TYPE_IM;
731 while (argsused < objc) { 731 while (argsused < objc) {
732 opt = Tcl_GetString(objv[argsused]); 732 opt = Tcl_GetString(objv[argsused]);
733 if (*opt == '-') { 733 if (*opt == '-') {
734 if ((error = Tcl_GetIndexFromObj(interp, objv[argsused], newopts, 734 if ((error = Tcl_GetIndexFromObj(interp, objv[argsused], newopts,
735 "option", 0, (int *)&newopt)) != TCL_OK) 735 "option", 0, (int *)&newopt)) != TCL_OK)
736 return error; 736 return error;
737 argsused++; 737 argsused++;
738 switch (newopt) { 738 switch (newopt) {
739 case CMD_CONV_NEW_CHAT: 739 case CMD_CONV_NEW_CHAT:
740 type = GAIM_CONV_TYPE_CHAT; 740 type = PURPLE_CONV_TYPE_CHAT;
741 break; 741 break;
742 case CMD_CONV_NEW_IM: 742 case CMD_CONV_NEW_IM:
743 type = GAIM_CONV_TYPE_IM; 743 type = PURPLE_CONV_TYPE_IM;
744 break; 744 break;
745 } 745 }
746 } else { 746 } else {
747 break; 747 break;
748 } 748 }
751 Tcl_WrongNumArgs(interp, 2, objv, "?options? account name"); 751 Tcl_WrongNumArgs(interp, 2, objv, "?options? account name");
752 return TCL_ERROR; 752 return TCL_ERROR;
753 } 753 }
754 if ((account = tcl_validate_account(objv[argsused++], interp)) == NULL) 754 if ((account = tcl_validate_account(objv[argsused++], interp)) == NULL)
755 return TCL_ERROR; 755 return TCL_ERROR;
756 convo = gaim_conversation_new(type, account, Tcl_GetString(objv[argsused])); 756 convo = purple_conversation_new(type, account, Tcl_GetString(objv[argsused]));
757 Tcl_SetObjResult(interp, gaim_tcl_ref_new(GaimTclRefConversation, convo)); 757 Tcl_SetObjResult(interp, purple_tcl_ref_new(PurpleTclRefConversation, convo));
758 break; 758 break;
759 case CMD_CONV_WRITE: 759 case CMD_CONV_WRITE:
760 if (objc != 6) { 760 if (objc != 6) {
761 Tcl_WrongNumArgs(interp, 2, objv, "conversation style from what"); 761 Tcl_WrongNumArgs(interp, 2, objv, "conversation style from what");
762 return TCL_ERROR; 762 return TCL_ERROR;
768 from = Tcl_GetString(objv[4]); 768 from = Tcl_GetString(objv[4]);
769 what = Tcl_GetString(objv[5]); 769 what = Tcl_GetString(objv[5]);
770 770
771 switch (style) { 771 switch (style) {
772 case CMD_CONV_WRITE_SEND: 772 case CMD_CONV_WRITE_SEND:
773 flags = GAIM_MESSAGE_SEND; 773 flags = PURPLE_MESSAGE_SEND;
774 break; 774 break;
775 case CMD_CONV_WRITE_RECV: 775 case CMD_CONV_WRITE_RECV:
776 flags = GAIM_MESSAGE_RECV; 776 flags = PURPLE_MESSAGE_RECV;
777 break; 777 break;
778 case CMD_CONV_WRITE_SYSTEM: 778 case CMD_CONV_WRITE_SYSTEM:
779 flags = GAIM_MESSAGE_SYSTEM; 779 flags = PURPLE_MESSAGE_SYSTEM;
780 break; 780 break;
781 } 781 }
782 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) 782 if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT)
783 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), from, what, flags, time(NULL)); 783 purple_conv_chat_write(PURPLE_CONV_CHAT(convo), from, what, flags, time(NULL));
784 else 784 else
785 gaim_conv_im_write(GAIM_CONV_IM(convo), from, what, flags, time(NULL)); 785 purple_conv_im_write(PURPLE_CONV_IM(convo), from, what, flags, time(NULL));
786 break; 786 break;
787 case CMD_CONV_NAME: 787 case CMD_CONV_NAME:
788 if (objc != 3) { 788 if (objc != 3) {
789 Tcl_WrongNumArgs(interp, 2, objv, "conversation"); 789 Tcl_WrongNumArgs(interp, 2, objv, "conversation");
790 return TCL_ERROR; 790 return TCL_ERROR;
791 } 791 }
792 792
793 if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL) 793 if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL)
794 return TCL_ERROR; 794 return TCL_ERROR;
795 Tcl_SetStringObj(result, (char *)gaim_conversation_get_name(convo), -1); 795 Tcl_SetStringObj(result, (char *)purple_conversation_get_name(convo), -1);
796 break; 796 break;
797 case CMD_CONV_TITLE: 797 case CMD_CONV_TITLE:
798 if (objc != 3) { 798 if (objc != 3) {
799 Tcl_WrongNumArgs(interp, 2, objv, "conversation"); 799 Tcl_WrongNumArgs(interp, 2, objv, "conversation");
800 return TCL_ERROR; 800 return TCL_ERROR;
801 } 801 }
802 802
803 if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL) 803 if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL)
804 return TCL_ERROR; 804 return TCL_ERROR;
805 Tcl_SetStringObj(result, (char *)gaim_conversation_get_title(convo), -1); 805 Tcl_SetStringObj(result, (char *)purple_conversation_get_title(convo), -1);
806 break; 806 break;
807 case CMD_CONV_SEND: 807 case CMD_CONV_SEND:
808 if (objc != 4) { 808 if (objc != 4) {
809 Tcl_WrongNumArgs(interp, 2, objv, "conversation message"); 809 Tcl_WrongNumArgs(interp, 2, objv, "conversation message");
810 return TCL_ERROR; 810 return TCL_ERROR;
811 } 811 }
812 if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL) 812 if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL)
813 return TCL_ERROR; 813 return TCL_ERROR;
814 what = Tcl_GetString(objv[3]); 814 what = Tcl_GetString(objv[3]);
815 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) 815 if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT)
816 gaim_conv_chat_send(GAIM_CONV_CHAT(convo), what); 816 purple_conv_chat_send(PURPLE_CONV_CHAT(convo), what);
817 else 817 else
818 gaim_conv_im_send(GAIM_CONV_IM(convo), what); 818 purple_conv_im_send(PURPLE_CONV_IM(convo), what);
819 break; 819 break;
820 } 820 }
821 821
822 return TCL_OK; 822 return TCL_OK;
823 } 823 }
841 case CMD_CORE_HANDLE: 841 case CMD_CORE_HANDLE:
842 if (objc != 2) { 842 if (objc != 2) {
843 Tcl_WrongNumArgs(interp, 2, objv, ""); 843 Tcl_WrongNumArgs(interp, 2, objv, "");
844 return TCL_ERROR; 844 return TCL_ERROR;
845 } 845 }
846 Tcl_SetIntObj(result, (int)gaim_get_core()); 846 Tcl_SetIntObj(result, (int)purple_get_core());
847 break; 847 break;
848 case CMD_CORE_QUIT: 848 case CMD_CORE_QUIT:
849 if (objc != 2) { 849 if (objc != 2) {
850 Tcl_WrongNumArgs(interp, 2, objv, ""); 850 Tcl_WrongNumArgs(interp, 2, objv, "");
851 return TCL_ERROR; 851 return TCL_ERROR;
852 } 852 }
853 gaim_core_quit(); 853 purple_core_quit();
854 break; 854 break;
855 } 855 }
856 856
857 return TCL_OK; 857 return TCL_OK;
858 } 858 }
860 int tcl_cmd_debug(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 860 int tcl_cmd_debug(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
861 { 861 {
862 char *category, *message; 862 char *category, *message;
863 int lev; 863 int lev;
864 const char *levels[] = { "-misc", "-info", "-warning", "-error", NULL }; 864 const char *levels[] = { "-misc", "-info", "-warning", "-error", NULL };
865 GaimDebugLevel levelind[] = { GAIM_DEBUG_MISC, GAIM_DEBUG_INFO, GAIM_DEBUG_WARNING, GAIM_DEBUG_ERROR }; 865 PurpleDebugLevel levelind[] = { PURPLE_DEBUG_MISC, PURPLE_DEBUG_INFO, PURPLE_DEBUG_WARNING, PURPLE_DEBUG_ERROR };
866 int error; 866 int error;
867 867
868 if (objc != 4) { 868 if (objc != 4) {
869 Tcl_WrongNumArgs(interp, 1, objv, "level category message"); 869 Tcl_WrongNumArgs(interp, 1, objv, "level category message");
870 return TCL_ERROR; 870 return TCL_ERROR;
875 return error; 875 return error;
876 876
877 category = Tcl_GetString(objv[2]); 877 category = Tcl_GetString(objv[2]);
878 message = Tcl_GetString(objv[3]); 878 message = Tcl_GetString(objv[3]);
879 879
880 gaim_debug(levelind[lev], category, "%s\n", message); 880 purple_debug(levelind[lev], category, "%s\n", message);
881 881
882 return TCL_OK; 882 return TCL_OK;
883 } 883 }
884 884
885 int tcl_cmd_notify(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 885 int tcl_cmd_notify(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
886 { 886 {
887 int error, type; 887 int error, type;
888 const char *opts[] = { "-error", "-warning", "-info", NULL }; 888 const char *opts[] = { "-error", "-warning", "-info", NULL };
889 GaimNotifyMsgType optind[] = { GAIM_NOTIFY_MSG_ERROR, GAIM_NOTIFY_MSG_WARNING, GAIM_NOTIFY_MSG_INFO }; 889 PurpleNotifyMsgType optind[] = { PURPLE_NOTIFY_MSG_ERROR, PURPLE_NOTIFY_MSG_WARNING, PURPLE_NOTIFY_MSG_INFO };
890 char *title, *msg1, *msg2; 890 char *title, *msg1, *msg2;
891 891
892 if (objc < 4 || objc > 5) { 892 if (objc < 4 || objc > 5) {
893 Tcl_WrongNumArgs(interp, 1, objv, "?type? title primary secondary"); 893 Tcl_WrongNumArgs(interp, 1, objv, "?type? title primary secondary");
894 return TCL_ERROR; 894 return TCL_ERROR;
906 title = Tcl_GetString(objv[2]); 906 title = Tcl_GetString(objv[2]);
907 msg1 = Tcl_GetString(objv[3]); 907 msg1 = Tcl_GetString(objv[3]);
908 msg2 = Tcl_GetString(objv[4]); 908 msg2 = Tcl_GetString(objv[4]);
909 } 909 }
910 910
911 gaim_notify_message(_tcl_plugin, optind[type], title, msg1, msg2, NULL, NULL); 911 purple_notify_message(_tcl_plugin, optind[type], title, msg1, msg2, NULL, NULL);
912 912
913 return TCL_OK; 913 return TCL_OK;
914 } 914 }
915 915
916 int tcl_cmd_plugins(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 916 int tcl_cmd_plugins(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
932 case CMD_PLUGINS_HANDLE: 932 case CMD_PLUGINS_HANDLE:
933 if (objc != 2) { 933 if (objc != 2) {
934 Tcl_WrongNumArgs(interp, 2, objv, ""); 934 Tcl_WrongNumArgs(interp, 2, objv, "");
935 return TCL_ERROR; 935 return TCL_ERROR;
936 } 936 }
937 Tcl_SetIntObj(result, (int)gaim_plugins_get_handle()); 937 Tcl_SetIntObj(result, (int)purple_plugins_get_handle());
938 break; 938 break;
939 } 939 }
940 940
941 return TCL_OK; 941 return TCL_OK;
942 } 942 }
946 Tcl_Obj *result, *list, *elem, **elems; 946 Tcl_Obj *result, *list, *elem, **elems;
947 const char *cmds[] = { "get", "set", "type", NULL }; 947 const char *cmds[] = { "get", "set", "type", NULL };
948 enum { CMD_PREFS_GET, CMD_PREFS_SET, CMD_PREFS_TYPE } cmd; 948 enum { CMD_PREFS_GET, CMD_PREFS_SET, CMD_PREFS_TYPE } cmd;
949 /* char *types[] = { "none", "boolean", "int", "string", "stringlist", NULL }; */ 949 /* char *types[] = { "none", "boolean", "int", "string", "stringlist", NULL }; */
950 /* enum { TCL_PREFS_NONE, TCL_PREFS_BOOL, TCL_PREFS_INT, TCL_PREFS_STRING, TCL_PREFS_STRINGLIST } type; */ 950 /* enum { TCL_PREFS_NONE, TCL_PREFS_BOOL, TCL_PREFS_INT, TCL_PREFS_STRING, TCL_PREFS_STRINGLIST } type; */
951 GaimPrefType preftype; 951 PurplePrefType preftype;
952 GList *cur; 952 GList *cur;
953 int error, intval, nelem, i; 953 int error, intval, nelem, i;
954 954
955 if (objc < 2) { 955 if (objc < 2) {
956 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 956 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
965 case CMD_PREFS_GET: 965 case CMD_PREFS_GET:
966 if (objc != 3) { 966 if (objc != 3) {
967 Tcl_WrongNumArgs(interp, 1, objv, "path"); 967 Tcl_WrongNumArgs(interp, 1, objv, "path");
968 return TCL_ERROR; 968 return TCL_ERROR;
969 } 969 }
970 preftype = gaim_prefs_get_type(Tcl_GetString(objv[2])); 970 preftype = purple_prefs_get_type(Tcl_GetString(objv[2]));
971 switch (preftype) { 971 switch (preftype) {
972 case GAIM_PREF_NONE: 972 case PURPLE_PREF_NONE:
973 Tcl_SetStringObj(result, "pref type none", -1); 973 Tcl_SetStringObj(result, "pref type none", -1);
974 return TCL_ERROR; 974 return TCL_ERROR;
975 break; 975 break;
976 case GAIM_PREF_BOOLEAN: 976 case PURPLE_PREF_BOOLEAN:
977 Tcl_SetBooleanObj(result, gaim_prefs_get_bool(Tcl_GetString(objv[2]))); 977 Tcl_SetBooleanObj(result, purple_prefs_get_bool(Tcl_GetString(objv[2])));
978 break; 978 break;
979 case GAIM_PREF_INT: 979 case PURPLE_PREF_INT:
980 Tcl_SetIntObj(result, gaim_prefs_get_int(Tcl_GetString(objv[2]))); 980 Tcl_SetIntObj(result, purple_prefs_get_int(Tcl_GetString(objv[2])));
981 break; 981 break;
982 case GAIM_PREF_STRING: 982 case PURPLE_PREF_STRING:
983 Tcl_SetStringObj(result, (char *)gaim_prefs_get_string(Tcl_GetString(objv[2])), -1); 983 Tcl_SetStringObj(result, (char *)purple_prefs_get_string(Tcl_GetString(objv[2])), -1);
984 break; 984 break;
985 case GAIM_PREF_STRING_LIST: 985 case PURPLE_PREF_STRING_LIST:
986 cur = gaim_prefs_get_string_list(Tcl_GetString(objv[2])); 986 cur = purple_prefs_get_string_list(Tcl_GetString(objv[2]));
987 list = Tcl_NewListObj(0, NULL); 987 list = Tcl_NewListObj(0, NULL);
988 while (cur != NULL) { 988 while (cur != NULL) {
989 elem = Tcl_NewStringObj((char *)cur->data, -1); 989 elem = Tcl_NewStringObj((char *)cur->data, -1);
990 Tcl_ListObjAppendElement(interp, list, elem); 990 Tcl_ListObjAppendElement(interp, list, elem);
991 cur = g_list_next(cur); 991 cur = g_list_next(cur);
992 } 992 }
993 Tcl_SetObjResult(interp, list); 993 Tcl_SetObjResult(interp, list);
994 break; 994 break;
995 default: 995 default:
996 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype); 996 purple_debug(PURPLE_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype);
997 Tcl_SetStringObj(result, "unknown pref type", -1); 997 Tcl_SetStringObj(result, "unknown pref type", -1);
998 return TCL_ERROR; 998 return TCL_ERROR;
999 } 999 }
1000 break; 1000 break;
1001 case CMD_PREFS_SET: 1001 case CMD_PREFS_SET:
1002 if (objc != 4) { 1002 if (objc != 4) {
1003 Tcl_WrongNumArgs(interp, 1, objv, "path value"); 1003 Tcl_WrongNumArgs(interp, 1, objv, "path value");
1004 return TCL_ERROR; 1004 return TCL_ERROR;
1005 } 1005 }
1006 preftype = gaim_prefs_get_type(Tcl_GetString(objv[2])); 1006 preftype = purple_prefs_get_type(Tcl_GetString(objv[2]));
1007 switch (preftype) { 1007 switch (preftype) {
1008 case GAIM_PREF_NONE: 1008 case PURPLE_PREF_NONE:
1009 Tcl_SetStringObj(result, "bad path or pref type none", -1); 1009 Tcl_SetStringObj(result, "bad path or pref type none", -1);
1010 return TCL_ERROR; 1010 return TCL_ERROR;
1011 break; 1011 break;
1012 case GAIM_PREF_BOOLEAN: 1012 case PURPLE_PREF_BOOLEAN:
1013 if ((error = Tcl_GetBooleanFromObj(interp, objv[3], &intval)) != TCL_OK) 1013 if ((error = Tcl_GetBooleanFromObj(interp, objv[3], &intval)) != TCL_OK)
1014 return error; 1014 return error;
1015 gaim_prefs_set_bool(Tcl_GetString(objv[2]), intval); 1015 purple_prefs_set_bool(Tcl_GetString(objv[2]), intval);
1016 break; 1016 break;
1017 case GAIM_PREF_INT: 1017 case PURPLE_PREF_INT:
1018 if ((error = Tcl_GetIntFromObj(interp, objv[3], &intval)) != TCL_OK) 1018 if ((error = Tcl_GetIntFromObj(interp, objv[3], &intval)) != TCL_OK)
1019 return error; 1019 return error;
1020 gaim_prefs_set_int(Tcl_GetString(objv[2]), intval); 1020 purple_prefs_set_int(Tcl_GetString(objv[2]), intval);
1021 break; 1021 break;
1022 case GAIM_PREF_STRING: 1022 case PURPLE_PREF_STRING:
1023 gaim_prefs_set_string(Tcl_GetString(objv[2]), Tcl_GetString(objv[3])); 1023 purple_prefs_set_string(Tcl_GetString(objv[2]), Tcl_GetString(objv[3]));
1024 break; 1024 break;
1025 case GAIM_PREF_STRING_LIST: 1025 case PURPLE_PREF_STRING_LIST:
1026 if ((error = Tcl_ListObjGetElements(interp, objv[3], &nelem, &elems)) != TCL_OK) 1026 if ((error = Tcl_ListObjGetElements(interp, objv[3], &nelem, &elems)) != TCL_OK)
1027 return error; 1027 return error;
1028 cur = NULL; 1028 cur = NULL;
1029 for (i = 0; i < nelem; i++) { 1029 for (i = 0; i < nelem; i++) {
1030 cur = g_list_append(cur, (gpointer)Tcl_GetString(elems[i])); 1030 cur = g_list_append(cur, (gpointer)Tcl_GetString(elems[i]));
1031 } 1031 }
1032 gaim_prefs_set_string_list(Tcl_GetString(objv[2]), cur); 1032 purple_prefs_set_string_list(Tcl_GetString(objv[2]), cur);
1033 g_list_free(cur); 1033 g_list_free(cur);
1034 break; 1034 break;
1035 default: 1035 default:
1036 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype); 1036 purple_debug(PURPLE_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype);
1037 return TCL_ERROR; 1037 return TCL_ERROR;
1038 } 1038 }
1039 break; 1039 break;
1040 case CMD_PREFS_TYPE: 1040 case CMD_PREFS_TYPE:
1041 if (objc != 3) { 1041 if (objc != 3) {
1042 Tcl_WrongNumArgs(interp, 1, objv, "path"); 1042 Tcl_WrongNumArgs(interp, 1, objv, "path");
1043 return TCL_ERROR; 1043 return TCL_ERROR;
1044 } 1044 }
1045 preftype = gaim_prefs_get_type(Tcl_GetString(objv[2])); 1045 preftype = purple_prefs_get_type(Tcl_GetString(objv[2]));
1046 switch (preftype) { 1046 switch (preftype) {
1047 case GAIM_PREF_NONE: 1047 case PURPLE_PREF_NONE:
1048 Tcl_SetStringObj(result, "none", -1); 1048 Tcl_SetStringObj(result, "none", -1);
1049 break; 1049 break;
1050 case GAIM_PREF_BOOLEAN: 1050 case PURPLE_PREF_BOOLEAN:
1051 Tcl_SetStringObj(result, "boolean", -1); 1051 Tcl_SetStringObj(result, "boolean", -1);
1052 break; 1052 break;
1053 case GAIM_PREF_INT: 1053 case PURPLE_PREF_INT:
1054 Tcl_SetStringObj(result, "int", -1); 1054 Tcl_SetStringObj(result, "int", -1);
1055 break; 1055 break;
1056 case GAIM_PREF_STRING: 1056 case PURPLE_PREF_STRING:
1057 Tcl_SetStringObj(result, "string", -1); 1057 Tcl_SetStringObj(result, "string", -1);
1058 break; 1058 break;
1059 case GAIM_PREF_STRING_LIST: 1059 case PURPLE_PREF_STRING_LIST:
1060 Tcl_SetStringObj(result, "stringlist", -1); 1060 Tcl_SetStringObj(result, "stringlist", -1);
1061 break; 1061 break;
1062 default: 1062 default:
1063 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype); 1063 purple_debug(PURPLE_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype);
1064 Tcl_SetStringObj(result, "unknown", -1); 1064 Tcl_SetStringObj(result, "unknown", -1);
1065 } 1065 }
1066 break; 1066 break;
1067 } 1067 }
1068 1068
1079 CMD_PRESENCE_CONTEXT, CMD_PRESENCE_CONVERSATION, 1079 CMD_PRESENCE_CONTEXT, CMD_PRESENCE_CONVERSATION,
1080 CMD_PRESENCE_IDLE, CMD_PRESENCE_LOGIN, CMD_PRESENCE_ONLINE, 1080 CMD_PRESENCE_IDLE, CMD_PRESENCE_LOGIN, CMD_PRESENCE_ONLINE,
1081 CMD_PRESENCE_STATUS, CMD_PRESENCE_STATUSES } cmd; 1081 CMD_PRESENCE_STATUS, CMD_PRESENCE_STATUSES } cmd;
1082 Tcl_Obj *result = Tcl_GetObjResult(interp); 1082 Tcl_Obj *result = Tcl_GetObjResult(interp);
1083 Tcl_Obj *list, *elem; 1083 Tcl_Obj *list, *elem;
1084 GaimPresence *presence; 1084 PurplePresence *presence;
1085 const GList *cur; 1085 const GList *cur;
1086 int error, idle, idle_time, login_time; 1086 int error, idle, idle_time, login_time;
1087 1087
1088 if (objc < 2) { 1088 if (objc < 2) {
1089 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 1089 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
1097 case CMD_PRESENCE_ACCOUNT: 1097 case CMD_PRESENCE_ACCOUNT:
1098 if (objc != 3) { 1098 if (objc != 3) {
1099 Tcl_WrongNumArgs(interp, 2, objv, "presence"); 1099 Tcl_WrongNumArgs(interp, 2, objv, "presence");
1100 return TCL_ERROR; 1100 return TCL_ERROR;
1101 } 1101 }
1102 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1102 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1103 return TCL_ERROR; 1103 return TCL_ERROR;
1104 Tcl_SetObjResult(interp, gaim_tcl_ref_new(GaimTclRefAccount, 1104 Tcl_SetObjResult(interp, purple_tcl_ref_new(PurpleTclRefAccount,
1105 gaim_presence_get_account(presence))); 1105 purple_presence_get_account(presence)));
1106 break; 1106 break;
1107 case CMD_PRESENCE_ACTIVE_STATUS: 1107 case CMD_PRESENCE_ACTIVE_STATUS:
1108 if (objc != 3 && objc != 4 && objc != 5) { 1108 if (objc != 3 && objc != 4 && objc != 5) {
1109 Tcl_WrongNumArgs(interp, 2, objv, "presence [?status_id? | ?-primitive primitive?]"); 1109 Tcl_WrongNumArgs(interp, 2, objv, "presence [?status_id? | ?-primitive primitive?]");
1110 return TCL_ERROR; 1110 return TCL_ERROR;
1111 } 1111 }
1112 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1112 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1113 return TCL_ERROR; 1113 return TCL_ERROR;
1114 if (objc == 3) { 1114 if (objc == 3) {
1115 Tcl_SetObjResult(interp, 1115 Tcl_SetObjResult(interp,
1116 gaim_tcl_ref_new(GaimTclRefStatus, 1116 purple_tcl_ref_new(PurpleTclRefStatus,
1117 gaim_presence_get_active_status(presence))); 1117 purple_presence_get_active_status(presence)));
1118 } else if (objc == 4) { 1118 } else if (objc == 4) {
1119 Tcl_SetBooleanObj(result, 1119 Tcl_SetBooleanObj(result,
1120 gaim_presence_is_status_active(presence, 1120 purple_presence_is_status_active(presence,
1121 Tcl_GetString(objv[3]))); 1121 Tcl_GetString(objv[3])));
1122 } else { 1122 } else {
1123 GaimStatusPrimitive primitive; 1123 PurpleStatusPrimitive primitive;
1124 if (strcmp(Tcl_GetString(objv[3]), "-primitive")) { 1124 if (strcmp(Tcl_GetString(objv[3]), "-primitive")) {
1125 Tcl_SetStringObj(result, "bad option \"", -1); 1125 Tcl_SetStringObj(result, "bad option \"", -1);
1126 Tcl_AppendObjToObj(result, objv[3]); 1126 Tcl_AppendObjToObj(result, objv[3]);
1127 Tcl_AppendToObj(result, 1127 Tcl_AppendToObj(result,
1128 "\": should be -primitive", -1); 1128 "\": should be -primitive", -1);
1129 return TCL_ERROR; 1129 return TCL_ERROR;
1130 } 1130 }
1131 primitive = gaim_primitive_get_type_from_id(Tcl_GetString(objv[4])); 1131 primitive = purple_primitive_get_type_from_id(Tcl_GetString(objv[4]));
1132 if (primitive == GAIM_STATUS_UNSET) { 1132 if (primitive == PURPLE_STATUS_UNSET) {
1133 Tcl_SetStringObj(result, "invalid primitive ", -1); 1133 Tcl_SetStringObj(result, "invalid primitive ", -1);
1134 Tcl_AppendObjToObj(result, objv[4]); 1134 Tcl_AppendObjToObj(result, objv[4]);
1135 return TCL_ERROR; 1135 return TCL_ERROR;
1136 } 1136 }
1137 Tcl_SetBooleanObj(result, gaim_presence_is_status_primitive_active(presence, primitive)); 1137 Tcl_SetBooleanObj(result, purple_presence_is_status_primitive_active(presence, primitive));
1138 break; 1138 break;
1139 } 1139 }
1140 break; 1140 break;
1141 case CMD_PRESENCE_AVAILABLE: 1141 case CMD_PRESENCE_AVAILABLE:
1142 if (objc != 3) { 1142 if (objc != 3) {
1143 Tcl_WrongNumArgs(interp, 2, objv, "presence"); 1143 Tcl_WrongNumArgs(interp, 2, objv, "presence");
1144 return TCL_ERROR; 1144 return TCL_ERROR;
1145 } 1145 }
1146 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1146 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1147 return TCL_ERROR; 1147 return TCL_ERROR;
1148 Tcl_SetBooleanObj(result, gaim_presence_is_available(presence)); 1148 Tcl_SetBooleanObj(result, purple_presence_is_available(presence));
1149 break; 1149 break;
1150 case CMD_PRESENCE_CHAT_USER: 1150 case CMD_PRESENCE_CHAT_USER:
1151 if (objc != 3) { 1151 if (objc != 3) {
1152 Tcl_WrongNumArgs(interp, 2, objv, "presence"); 1152 Tcl_WrongNumArgs(interp, 2, objv, "presence");
1153 return TCL_ERROR; 1153 return TCL_ERROR;
1154 } 1154 }
1155 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1155 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1156 return TCL_ERROR; 1156 return TCL_ERROR;
1157 Tcl_SetStringObj(result, gaim_presence_get_chat_user(presence), -1); 1157 Tcl_SetStringObj(result, purple_presence_get_chat_user(presence), -1);
1158 break; 1158 break;
1159 case CMD_PRESENCE_CONTEXT: 1159 case CMD_PRESENCE_CONTEXT:
1160 if (objc != 3) { 1160 if (objc != 3) {
1161 Tcl_WrongNumArgs(interp, 2, objv, "presence"); 1161 Tcl_WrongNumArgs(interp, 2, objv, "presence");
1162 return TCL_ERROR; 1162 return TCL_ERROR;
1163 } 1163 }
1164 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1164 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1165 return TCL_ERROR; 1165 return TCL_ERROR;
1166 switch (gaim_presence_get_context(presence)) { 1166 switch (purple_presence_get_context(presence)) {
1167 case GAIM_PRESENCE_CONTEXT_UNSET: 1167 case PURPLE_PRESENCE_CONTEXT_UNSET:
1168 Tcl_SetStringObj(result, "unset", -1); 1168 Tcl_SetStringObj(result, "unset", -1);
1169 break; 1169 break;
1170 case GAIM_PRESENCE_CONTEXT_ACCOUNT: 1170 case PURPLE_PRESENCE_CONTEXT_ACCOUNT:
1171 Tcl_SetStringObj(result, "account", -1); 1171 Tcl_SetStringObj(result, "account", -1);
1172 break; 1172 break;
1173 case GAIM_PRESENCE_CONTEXT_CONV: 1173 case PURPLE_PRESENCE_CONTEXT_CONV:
1174 Tcl_SetStringObj(result, "conversation", -1); 1174 Tcl_SetStringObj(result, "conversation", -1);
1175 break; 1175 break;
1176 case GAIM_PRESENCE_CONTEXT_BUDDY: 1176 case PURPLE_PRESENCE_CONTEXT_BUDDY:
1177 Tcl_SetStringObj(result, "buddy", -1); 1177 Tcl_SetStringObj(result, "buddy", -1);
1178 break; 1178 break;
1179 } 1179 }
1180 break; 1180 break;
1181 case CMD_PRESENCE_CONVERSATION: 1181 case CMD_PRESENCE_CONVERSATION:
1182 if (objc != 3) { 1182 if (objc != 3) {
1183 Tcl_WrongNumArgs(interp, 2, objv, "presence"); 1183 Tcl_WrongNumArgs(interp, 2, objv, "presence");
1184 return TCL_ERROR; 1184 return TCL_ERROR;
1185 } 1185 }
1186 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1186 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1187 return TCL_ERROR; 1187 return TCL_ERROR;
1188 Tcl_SetObjResult(interp, gaim_tcl_ref_new(GaimTclRefConversation, 1188 Tcl_SetObjResult(interp, purple_tcl_ref_new(PurpleTclRefConversation,
1189 gaim_presence_get_conversation(presence))); 1189 purple_presence_get_conversation(presence)));
1190 break; 1190 break;
1191 case CMD_PRESENCE_IDLE: 1191 case CMD_PRESENCE_IDLE:
1192 if (objc < 3 || objc > 5) { 1192 if (objc < 3 || objc > 5) {
1193 Tcl_WrongNumArgs(interp, 2, objv, "presence ?idle? ?time?"); 1193 Tcl_WrongNumArgs(interp, 2, objv, "presence ?idle? ?time?");
1194 return TCL_ERROR; 1194 return TCL_ERROR;
1195 } 1195 }
1196 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1196 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1197 return TCL_ERROR; 1197 return TCL_ERROR;
1198 if (objc == 3) { 1198 if (objc == 3) {
1199 if (gaim_presence_is_idle(presence)) { 1199 if (purple_presence_is_idle(presence)) {
1200 idle_time = gaim_presence_get_idle_time (presence); 1200 idle_time = purple_presence_get_idle_time (presence);
1201 Tcl_SetIntObj(result, idle_time); 1201 Tcl_SetIntObj(result, idle_time);
1202 } else { 1202 } else {
1203 result = Tcl_NewListObj(0, NULL); 1203 result = Tcl_NewListObj(0, NULL);
1204 Tcl_SetObjResult(interp, result); 1204 Tcl_SetObjResult(interp, result);
1205 } 1205 }
1206 break; 1206 break;
1207 } 1207 }
1208 if ((error = Tcl_GetBooleanFromObj(interp, objv[3], &idle)) != TCL_OK) 1208 if ((error = Tcl_GetBooleanFromObj(interp, objv[3], &idle)) != TCL_OK)
1209 return TCL_ERROR; 1209 return TCL_ERROR;
1210 if (objc == 4) { 1210 if (objc == 4) {
1211 gaim_presence_set_idle(presence, idle, time(NULL)); 1211 purple_presence_set_idle(presence, idle, time(NULL));
1212 } else if (objc == 5) { 1212 } else if (objc == 5) {
1213 if ((error = Tcl_GetIntFromObj(interp, 1213 if ((error = Tcl_GetIntFromObj(interp,
1214 objv[4], 1214 objv[4],
1215 &idle_time)) != TCL_OK) 1215 &idle_time)) != TCL_OK)
1216 return TCL_ERROR; 1216 return TCL_ERROR;
1217 gaim_presence_set_idle(presence, idle, idle_time); 1217 purple_presence_set_idle(presence, idle, idle_time);
1218 } 1218 }
1219 break; 1219 break;
1220 case CMD_PRESENCE_LOGIN: 1220 case CMD_PRESENCE_LOGIN:
1221 if (objc != 3 && objc != 4) { 1221 if (objc != 3 && objc != 4) {
1222 Tcl_WrongNumArgs(interp, 2, objv, "presence ?time?"); 1222 Tcl_WrongNumArgs(interp, 2, objv, "presence ?time?");
1223 return TCL_ERROR; 1223 return TCL_ERROR;
1224 } 1224 }
1225 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1225 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1226 return TCL_ERROR; 1226 return TCL_ERROR;
1227 if (objc == 3) { 1227 if (objc == 3) {
1228 Tcl_SetIntObj(result, gaim_presence_get_login_time(presence)); 1228 Tcl_SetIntObj(result, purple_presence_get_login_time(presence));
1229 } else { 1229 } else {
1230 if ((error == Tcl_GetIntFromObj(interp, 1230 if ((error == Tcl_GetIntFromObj(interp,
1231 objv[3], 1231 objv[3],
1232 &login_time)) != TCL_OK) 1232 &login_time)) != TCL_OK)
1233 return TCL_ERROR; 1233 return TCL_ERROR;
1234 gaim_presence_set_login_time(presence, login_time); 1234 purple_presence_set_login_time(presence, login_time);
1235 } 1235 }
1236 break; 1236 break;
1237 case CMD_PRESENCE_ONLINE: 1237 case CMD_PRESENCE_ONLINE:
1238 if (objc != 3) { 1238 if (objc != 3) {
1239 Tcl_WrongNumArgs(interp, 2, objv, "presence"); 1239 Tcl_WrongNumArgs(interp, 2, objv, "presence");
1240 return TCL_ERROR; 1240 return TCL_ERROR;
1241 } 1241 }
1242 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1242 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1243 return TCL_ERROR; 1243 return TCL_ERROR;
1244 Tcl_SetBooleanObj(result, gaim_presence_is_online(presence)); 1244 Tcl_SetBooleanObj(result, purple_presence_is_online(presence));
1245 break; 1245 break;
1246 case CMD_PRESENCE_STATUS: 1246 case CMD_PRESENCE_STATUS:
1247 if (objc != 4) { 1247 if (objc != 4) {
1248 Tcl_WrongNumArgs(interp, 2, objv, "presence status_id"); 1248 Tcl_WrongNumArgs(interp, 2, objv, "presence status_id");
1249 return TCL_ERROR; 1249 return TCL_ERROR;
1250 } 1250 }
1251 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1251 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1252 return TCL_ERROR; 1252 return TCL_ERROR;
1253 Tcl_SetObjResult(interp, 1253 Tcl_SetObjResult(interp,
1254 gaim_tcl_ref_new(GaimTclRefStatus, 1254 purple_tcl_ref_new(PurpleTclRefStatus,
1255 gaim_presence_get_status(presence, 1255 purple_presence_get_status(presence,
1256 Tcl_GetString(objv[3])))); 1256 Tcl_GetString(objv[3]))));
1257 break; 1257 break;
1258 case CMD_PRESENCE_STATUSES: 1258 case CMD_PRESENCE_STATUSES:
1259 if (objc != 3) { 1259 if (objc != 3) {
1260 Tcl_WrongNumArgs(interp, 2, objv, "presence"); 1260 Tcl_WrongNumArgs(interp, 2, objv, "presence");
1261 return TCL_ERROR; 1261 return TCL_ERROR;
1262 } 1262 }
1263 if ((presence = gaim_tcl_ref_get(interp, objv[2], GaimTclRefPresence)) == NULL) 1263 if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
1264 return TCL_ERROR; 1264 return TCL_ERROR;
1265 list = Tcl_NewListObj(0, NULL); 1265 list = Tcl_NewListObj(0, NULL);
1266 for (cur = gaim_presence_get_statuses(presence); cur != NULL; 1266 for (cur = purple_presence_get_statuses(presence); cur != NULL;
1267 cur = g_list_next(cur)) { 1267 cur = g_list_next(cur)) {
1268 elem = gaim_tcl_ref_new(GaimTclRefStatus, cur->data); 1268 elem = purple_tcl_ref_new(PurpleTclRefStatus, cur->data);
1269 Tcl_ListObjAppendElement(interp, list, elem); 1269 Tcl_ListObjAppendElement(interp, list, elem);
1270 } 1270 }
1271 Tcl_SetObjResult(interp, list); 1271 Tcl_SetObjResult(interp, list);
1272 break; 1272 break;
1273 } 1273 }
1279 { 1279 {
1280 Tcl_Obj *result = Tcl_GetObjResult(interp); 1280 Tcl_Obj *result = Tcl_GetObjResult(interp);
1281 const char *cmds[] = { "current", "handle", NULL }; 1281 const char *cmds[] = { "current", "handle", NULL };
1282 enum { CMD_SAVEDSTATUS_CURRENT, CMD_SAVEDSTATUS_HANDLE } cmd; 1282 enum { CMD_SAVEDSTATUS_CURRENT, CMD_SAVEDSTATUS_HANDLE } cmd;
1283 int error; 1283 int error;
1284 GaimSavedStatus *saved_status; 1284 PurpleSavedStatus *saved_status;
1285 1285
1286 if (objc < 2) { 1286 if (objc < 2) {
1287 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 1287 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
1288 return TCL_ERROR; 1288 return TCL_ERROR;
1289 } 1289 }
1295 case CMD_SAVEDSTATUS_CURRENT: 1295 case CMD_SAVEDSTATUS_CURRENT:
1296 if (objc != 2) { 1296 if (objc != 2) {
1297 Tcl_WrongNumArgs(interp, 2, objv, ""); 1297 Tcl_WrongNumArgs(interp, 2, objv, "");
1298 return TCL_ERROR; 1298 return TCL_ERROR;
1299 } 1299 }
1300 if ((saved_status = gaim_savedstatus_get_current()) == NULL) 1300 if ((saved_status = purple_savedstatus_get_current()) == NULL)
1301 return TCL_ERROR; 1301 return TCL_ERROR;
1302 Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(gaim_savedstatus_get_title(saved_status), -1)); 1302 Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(purple_savedstatus_get_title(saved_status), -1));
1303 Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(gaim_savedstatus_get_type(saved_status))); 1303 Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(purple_savedstatus_get_type(saved_status)));
1304 Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(gaim_savedstatus_get_message(saved_status), -1)); 1304 Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(purple_savedstatus_get_message(saved_status), -1));
1305 break; 1305 break;
1306 case CMD_SAVEDSTATUS_HANDLE: 1306 case CMD_SAVEDSTATUS_HANDLE:
1307 if (objc != 2) { 1307 if (objc != 2) {
1308 Tcl_WrongNumArgs(interp, 2, objv, ""); 1308 Tcl_WrongNumArgs(interp, 2, objv, "");
1309 return TCL_ERROR; 1309 return TCL_ERROR;
1310 } 1310 }
1311 Tcl_SetIntObj(result, (int)gaim_savedstatuses_get_handle()); 1311 Tcl_SetIntObj(result, (int)purple_savedstatuses_get_handle());
1312 break; 1312 break;
1313 } 1313 }
1314 1314
1315 return TCL_OK; 1315 return TCL_OK;
1316 } 1316 }
1317 1317
1318 int tcl_cmd_send_im(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 1318 int tcl_cmd_send_im(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
1319 { 1319 {
1320 GaimConnection *gc; 1320 PurpleConnection *gc;
1321 char *who, *text; 1321 char *who, *text;
1322 1322
1323 if (objc != 4) { 1323 if (objc != 4) {
1324 Tcl_WrongNumArgs(interp, 1, objv, "gc who text"); 1324 Tcl_WrongNumArgs(interp, 1, objv, "gc who text");
1325 return TCL_ERROR; 1325 return TCL_ERROR;
1393 int tcl_cmd_status(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 1393 int tcl_cmd_status(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
1394 { 1394 {
1395 const char *cmds[] = { "attr", "type", NULL }; 1395 const char *cmds[] = { "attr", "type", NULL };
1396 enum { CMD_STATUS_ATTR, CMD_STATUS_TYPE } cmd; 1396 enum { CMD_STATUS_ATTR, CMD_STATUS_TYPE } cmd;
1397 Tcl_Obj *result = Tcl_GetObjResult(interp); 1397 Tcl_Obj *result = Tcl_GetObjResult(interp);
1398 GaimStatus *status; 1398 PurpleStatus *status;
1399 GaimStatusType *status_type; 1399 PurpleStatusType *status_type;
1400 GaimValue *value; 1400 PurpleValue *value;
1401 const char *attr; 1401 const char *attr;
1402 int error, v; 1402 int error, v;
1403 1403
1404 if (objc < 2) { 1404 if (objc < 2) {
1405 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 1405 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
1413 case CMD_STATUS_ATTR: 1413 case CMD_STATUS_ATTR:
1414 if (objc != 4 && objc != 5) { 1414 if (objc != 4 && objc != 5) {
1415 Tcl_WrongNumArgs(interp, 2, objv, "status attr_id ?value?"); 1415 Tcl_WrongNumArgs(interp, 2, objv, "status attr_id ?value?");
1416 return TCL_ERROR; 1416 return TCL_ERROR;
1417 } 1417 }
1418 if ((status = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatus)) == NULL) 1418 if ((status = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatus)) == NULL)
1419 return TCL_ERROR; 1419 return TCL_ERROR;
1420 attr = Tcl_GetString(objv[3]); 1420 attr = Tcl_GetString(objv[3]);
1421 value = gaim_status_get_attr_value(status, attr); 1421 value = purple_status_get_attr_value(status, attr);
1422 if (value == NULL) { 1422 if (value == NULL) {
1423 Tcl_SetStringObj(result, "no such attribute", -1); 1423 Tcl_SetStringObj(result, "no such attribute", -1);
1424 return TCL_ERROR; 1424 return TCL_ERROR;
1425 } 1425 }
1426 switch (gaim_value_get_type(value)) { 1426 switch (purple_value_get_type(value)) {
1427 case GAIM_TYPE_BOOLEAN: 1427 case PURPLE_TYPE_BOOLEAN:
1428 if (objc == 4) { 1428 if (objc == 4) {
1429 Tcl_SetBooleanObj(result, gaim_value_get_boolean(value)); 1429 Tcl_SetBooleanObj(result, purple_value_get_boolean(value));
1430 } else { 1430 } else {
1431 if ((error = Tcl_GetBooleanFromObj(interp, objv[4], &v)) != TCL_OK) 1431 if ((error = Tcl_GetBooleanFromObj(interp, objv[4], &v)) != TCL_OK)
1432 return error; 1432 return error;
1433 gaim_status_set_attr_boolean(status, attr, v); 1433 purple_status_set_attr_boolean(status, attr, v);
1434 } 1434 }
1435 break; 1435 break;
1436 case GAIM_TYPE_INT: 1436 case PURPLE_TYPE_INT:
1437 if (objc == 4) { 1437 if (objc == 4) {
1438 Tcl_SetIntObj(result, gaim_value_get_int(value)); 1438 Tcl_SetIntObj(result, purple_value_get_int(value));
1439 } else { 1439 } else {
1440 if ((error = Tcl_GetIntFromObj(interp, objv[4], &v)) != TCL_OK) 1440 if ((error = Tcl_GetIntFromObj(interp, objv[4], &v)) != TCL_OK)
1441 return error; 1441 return error;
1442 gaim_status_set_attr_int(status, attr, v ); 1442 purple_status_set_attr_int(status, attr, v );
1443 } 1443 }
1444 break; 1444 break;
1445 case GAIM_TYPE_STRING: 1445 case PURPLE_TYPE_STRING:
1446 if (objc == 4) 1446 if (objc == 4)
1447 Tcl_SetStringObj(result, gaim_value_get_string(value), -1); 1447 Tcl_SetStringObj(result, purple_value_get_string(value), -1);
1448 else 1448 else
1449 gaim_status_set_attr_string(status, attr, Tcl_GetString(objv[4])); 1449 purple_status_set_attr_string(status, attr, Tcl_GetString(objv[4]));
1450 break; 1450 break;
1451 default: 1451 default:
1452 Tcl_SetStringObj(result, "attribute has unknown type", -1); 1452 Tcl_SetStringObj(result, "attribute has unknown type", -1);
1453 return TCL_ERROR; 1453 return TCL_ERROR;
1454 } 1454 }
1456 case CMD_STATUS_TYPE: 1456 case CMD_STATUS_TYPE:
1457 if (objc != 3) { 1457 if (objc != 3) {
1458 Tcl_WrongNumArgs(interp, 2, objv, "status"); 1458 Tcl_WrongNumArgs(interp, 2, objv, "status");
1459 return TCL_ERROR; 1459 return TCL_ERROR;
1460 } 1460 }
1461 if ((status = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatus)) == NULL) 1461 if ((status = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatus)) == NULL)
1462 return TCL_ERROR; 1462 return TCL_ERROR;
1463 status_type = gaim_status_get_type(status); 1463 status_type = purple_status_get_type(status);
1464 Tcl_SetObjResult(interp, gaim_tcl_ref_new(GaimTclRefStatusType, 1464 Tcl_SetObjResult(interp, purple_tcl_ref_new(PurpleTclRefStatusType,
1465 status_type)); 1465 status_type));
1466 break; 1466 break;
1467 } 1467 }
1468 1468
1469 return TCL_OK; 1469 return TCL_OK;
1472 int tcl_cmd_status_attr(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 1472 int tcl_cmd_status_attr(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
1473 { 1473 {
1474 const char *cmds[] = { "id", "name", NULL }; 1474 const char *cmds[] = { "id", "name", NULL };
1475 enum { CMD_STATUS_ATTR_ID, CMD_STATUS_ATTR_NAME } cmd; 1475 enum { CMD_STATUS_ATTR_ID, CMD_STATUS_ATTR_NAME } cmd;
1476 Tcl_Obj *result = Tcl_GetObjResult(interp); 1476 Tcl_Obj *result = Tcl_GetObjResult(interp);
1477 GaimStatusAttr *attr; 1477 PurpleStatusAttr *attr;
1478 int error; 1478 int error;
1479 1479
1480 if (objc < 2) { 1480 if (objc < 2) {
1481 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); 1481 Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
1482 return TCL_ERROR; 1482 return TCL_ERROR;
1489 case CMD_STATUS_ATTR_ID: 1489 case CMD_STATUS_ATTR_ID:
1490 if (objc != 3) { 1490 if (objc != 3) {
1491 Tcl_WrongNumArgs(interp, 2, objv, "attr"); 1491 Tcl_WrongNumArgs(interp, 2, objv, "attr");
1492 return TCL_ERROR; 1492 return TCL_ERROR;
1493 } 1493 }
1494 if ((attr = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusAttr)) == NULL) 1494 if ((attr = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusAttr)) == NULL)
1495 return TCL_ERROR; 1495 return TCL_ERROR;
1496 Tcl_SetStringObj(result, gaim_status_attr_get_id(attr), -1); 1496 Tcl_SetStringObj(result, purple_status_attr_get_id(attr), -1);
1497 break; 1497 break;
1498 case CMD_STATUS_ATTR_NAME: 1498 case CMD_STATUS_ATTR_NAME:
1499 if (objc != 3) { 1499 if (objc != 3) {
1500 Tcl_WrongNumArgs(interp, 2, objv, "attr"); 1500 Tcl_WrongNumArgs(interp, 2, objv, "attr");
1501 return TCL_ERROR; 1501 return TCL_ERROR;
1502 } 1502 }
1503 if ((attr = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusAttr)) == NULL) 1503 if ((attr = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusAttr)) == NULL)
1504 return TCL_ERROR; 1504 return TCL_ERROR;
1505 Tcl_SetStringObj(result, gaim_status_attr_get_name(attr), -1); 1505 Tcl_SetStringObj(result, purple_status_attr_get_name(attr), -1);
1506 break; 1506 break;
1507 } 1507 }
1508 1508
1509 return TCL_OK; 1509 return TCL_OK;
1510 } 1510 }
1520 CMD_STATUS_TYPE_ID, CMD_STATUS_TYPE_INDEPENDENT, 1520 CMD_STATUS_TYPE_ID, CMD_STATUS_TYPE_INDEPENDENT,
1521 CMD_STATUS_TYPE_NAME, CMD_STATUS_TYPE_PRIMARY_ATTR, 1521 CMD_STATUS_TYPE_NAME, CMD_STATUS_TYPE_PRIMARY_ATTR,
1522 CMD_STATUS_TYPE_PRIMITIVE, CMD_STATUS_TYPE_SAVEABLE, 1522 CMD_STATUS_TYPE_PRIMITIVE, CMD_STATUS_TYPE_SAVEABLE,
1523 CMD_STATUS_TYPE_USER_SETTABLE } cmd; 1523 CMD_STATUS_TYPE_USER_SETTABLE } cmd;
1524 Tcl_Obj *result = Tcl_GetObjResult(interp); 1524 Tcl_Obj *result = Tcl_GetObjResult(interp);
1525 GaimStatusType *status_type; 1525 PurpleStatusType *status_type;
1526 Tcl_Obj *list, *elem; 1526 Tcl_Obj *list, *elem;
1527 const GList *cur; 1527 const GList *cur;
1528 int error; 1528 int error;
1529 1529
1530 if (objc < 2) { 1530 if (objc < 2) {
1539 case CMD_STATUS_TYPE_AVAILABLE: 1539 case CMD_STATUS_TYPE_AVAILABLE:
1540 if (objc != 3) { 1540 if (objc != 3) {
1541 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1541 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1542 return TCL_ERROR; 1542 return TCL_ERROR;
1543 } 1543 }
1544 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1544 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1545 return TCL_ERROR; 1545 return TCL_ERROR;
1546 Tcl_SetBooleanObj(result, gaim_status_type_is_available(status_type)); 1546 Tcl_SetBooleanObj(result, purple_status_type_is_available(status_type));
1547 break; 1547 break;
1548 case CMD_STATUS_TYPE_ATTR: 1548 case CMD_STATUS_TYPE_ATTR:
1549 if (objc != 4) { 1549 if (objc != 4) {
1550 Tcl_WrongNumArgs(interp, 2, objv, "statustype attr"); 1550 Tcl_WrongNumArgs(interp, 2, objv, "statustype attr");
1551 return TCL_ERROR; 1551 return TCL_ERROR;
1552 } 1552 }
1553 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1553 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1554 return TCL_ERROR; 1554 return TCL_ERROR;
1555 Tcl_SetObjResult(interp, 1555 Tcl_SetObjResult(interp,
1556 gaim_tcl_ref_new(GaimTclRefStatusAttr, 1556 purple_tcl_ref_new(PurpleTclRefStatusAttr,
1557 gaim_status_type_get_attr(status_type, 1557 purple_status_type_get_attr(status_type,
1558 Tcl_GetStringFromObj(objv[3], NULL)))); 1558 Tcl_GetStringFromObj(objv[3], NULL))));
1559 break; 1559 break;
1560 case CMD_STATUS_TYPE_ATTRS: 1560 case CMD_STATUS_TYPE_ATTRS:
1561 if (objc != 3) { 1561 if (objc != 3) {
1562 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1562 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1563 return TCL_ERROR; 1563 return TCL_ERROR;
1564 } 1564 }
1565 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1565 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1566 return TCL_ERROR; 1566 return TCL_ERROR;
1567 list = Tcl_NewListObj(0, NULL); 1567 list = Tcl_NewListObj(0, NULL);
1568 for (cur = gaim_status_type_get_attrs(status_type); 1568 for (cur = purple_status_type_get_attrs(status_type);
1569 cur != NULL; cur = g_list_next(cur)) { 1569 cur != NULL; cur = g_list_next(cur)) {
1570 elem = gaim_tcl_ref_new(GaimTclRefStatusAttr, cur->data); 1570 elem = purple_tcl_ref_new(PurpleTclRefStatusAttr, cur->data);
1571 Tcl_ListObjAppendElement(interp, list, elem); 1571 Tcl_ListObjAppendElement(interp, list, elem);
1572 } 1572 }
1573 Tcl_SetObjResult(interp, list); 1573 Tcl_SetObjResult(interp, list);
1574 break; 1574 break;
1575 case CMD_STATUS_TYPE_EXCLUSIVE: 1575 case CMD_STATUS_TYPE_EXCLUSIVE:
1576 if (objc != 3) { 1576 if (objc != 3) {
1577 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1577 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1578 return TCL_ERROR; 1578 return TCL_ERROR;
1579 } 1579 }
1580 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1580 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1581 return TCL_ERROR; 1581 return TCL_ERROR;
1582 Tcl_SetBooleanObj(result, gaim_status_type_is_exclusive(status_type)); 1582 Tcl_SetBooleanObj(result, purple_status_type_is_exclusive(status_type));
1583 break; 1583 break;
1584 case CMD_STATUS_TYPE_ID: 1584 case CMD_STATUS_TYPE_ID:
1585 if (objc != 3) { 1585 if (objc != 3) {
1586 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1586 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1587 return TCL_ERROR; 1587 return TCL_ERROR;
1588 } 1588 }
1589 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1589 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1590 return TCL_ERROR; 1590 return TCL_ERROR;
1591 Tcl_SetStringObj(result, gaim_status_type_get_id(status_type), -1); 1591 Tcl_SetStringObj(result, purple_status_type_get_id(status_type), -1);
1592 break; 1592 break;
1593 case CMD_STATUS_TYPE_INDEPENDENT: 1593 case CMD_STATUS_TYPE_INDEPENDENT:
1594 if (objc != 3) { 1594 if (objc != 3) {
1595 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1595 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1596 return TCL_ERROR; 1596 return TCL_ERROR;
1597 } 1597 }
1598 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1598 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1599 return TCL_ERROR; 1599 return TCL_ERROR;
1600 Tcl_SetBooleanObj(result, gaim_status_type_is_independent(status_type)); 1600 Tcl_SetBooleanObj(result, purple_status_type_is_independent(status_type));
1601 break; 1601 break;
1602 case CMD_STATUS_TYPE_NAME: 1602 case CMD_STATUS_TYPE_NAME:
1603 if (objc != 3) { 1603 if (objc != 3) {
1604 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1604 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1605 return TCL_ERROR; 1605 return TCL_ERROR;
1606 } 1606 }
1607 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1607 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1608 return TCL_ERROR; 1608 return TCL_ERROR;
1609 Tcl_SetStringObj(result, gaim_status_type_get_name(status_type), -1); 1609 Tcl_SetStringObj(result, purple_status_type_get_name(status_type), -1);
1610 break; 1610 break;
1611 case CMD_STATUS_TYPE_PRIMITIVE: 1611 case CMD_STATUS_TYPE_PRIMITIVE:
1612 if (objc != 3) { 1612 if (objc != 3) {
1613 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1613 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1614 return TCL_ERROR; 1614 return TCL_ERROR;
1615 } 1615 }
1616 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1616 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1617 return TCL_ERROR; 1617 return TCL_ERROR;
1618 Tcl_SetStringObj(result, gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type)), -1); 1618 Tcl_SetStringObj(result, purple_primitive_get_id_from_type(purple_status_type_get_primitive(status_type)), -1);
1619 break; 1619 break;
1620 case CMD_STATUS_TYPE_PRIMARY_ATTR: 1620 case CMD_STATUS_TYPE_PRIMARY_ATTR:
1621 if (objc != 3) { 1621 if (objc != 3) {
1622 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1622 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1623 return TCL_ERROR; 1623 return TCL_ERROR;
1624 } 1624 }
1625 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1625 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1626 return TCL_ERROR; 1626 return TCL_ERROR;
1627 Tcl_SetStringObj(result, gaim_status_type_get_primary_attr(status_type), -1); 1627 Tcl_SetStringObj(result, purple_status_type_get_primary_attr(status_type), -1);
1628 break; 1628 break;
1629 case CMD_STATUS_TYPE_SAVEABLE: 1629 case CMD_STATUS_TYPE_SAVEABLE:
1630 if (objc != 3) { 1630 if (objc != 3) {
1631 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1631 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1632 return TCL_ERROR; 1632 return TCL_ERROR;
1633 } 1633 }
1634 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1634 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1635 return TCL_ERROR; 1635 return TCL_ERROR;
1636 Tcl_SetBooleanObj(result, gaim_status_type_is_saveable(status_type)); 1636 Tcl_SetBooleanObj(result, purple_status_type_is_saveable(status_type));
1637 break; 1637 break;
1638 case CMD_STATUS_TYPE_USER_SETTABLE: 1638 case CMD_STATUS_TYPE_USER_SETTABLE:
1639 if (objc != 3) { 1639 if (objc != 3) {
1640 Tcl_WrongNumArgs(interp, 2, objv, "statustype"); 1640 Tcl_WrongNumArgs(interp, 2, objv, "statustype");
1641 return TCL_ERROR; 1641 return TCL_ERROR;
1642 } 1642 }
1643 if ((status_type = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatusType)) == NULL) 1643 if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
1644 return TCL_ERROR; 1644 return TCL_ERROR;
1645 Tcl_SetBooleanObj(result, gaim_status_type_is_user_settable(status_type)); 1645 Tcl_SetBooleanObj(result, purple_status_type_is_user_settable(status_type));
1646 break; 1646 break;
1647 } 1647 }
1648 1648
1649 return TCL_OK; 1649 return TCL_OK;
1650 } 1650 }
1651 1651
1652 static gboolean unload_self(gpointer data) 1652 static gboolean unload_self(gpointer data)
1653 { 1653 {
1654 GaimPlugin *plugin = data; 1654 PurplePlugin *plugin = data;
1655 gaim_plugin_unload(plugin); 1655 purple_plugin_unload(plugin);
1656 return FALSE; 1656 return FALSE;
1657 } 1657 }
1658 1658
1659 int tcl_cmd_unload(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 1659 int tcl_cmd_unload(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
1660 { 1660 {
1661 GaimPlugin *plugin; 1661 PurplePlugin *plugin;
1662 if (objc != 1) { 1662 if (objc != 1) {
1663 Tcl_WrongNumArgs(interp, 1, objv, ""); 1663 Tcl_WrongNumArgs(interp, 1, objv, "");
1664 return TCL_ERROR; 1664 return TCL_ERROR;
1665 } 1665 }
1666 1666