Mercurial > pidgin
comparison libpurple/protocols/toc/toc.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 | 0b6f337a46d5 |
| children | fa8aeab4ca5a |
comparison
equal
deleted
inserted
replaced
| 15821:84b0f9b23ede | 15822:32c366eeeb99 |
|---|---|
| 1 /* | 1 /* |
| 2 * gaim | 2 * purple |
| 3 * | 3 * |
| 4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | 4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
| 5 * | 5 * |
| 6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
| 30 #include "prpl.h" | 30 #include "prpl.h" |
| 31 #include "request.h" | 31 #include "request.h" |
| 32 #include "util.h" | 32 #include "util.h" |
| 33 #include "version.h" | 33 #include "version.h" |
| 34 | 34 |
| 35 static GaimPlugin *my_protocol = NULL; | 35 static PurplePlugin *my_protocol = NULL; |
| 36 | 36 |
| 37 #define REVISION "penguin" | 37 #define REVISION "penguin" |
| 38 | 38 |
| 39 #define TYPE_SIGNON 1 | 39 #define TYPE_SIGNON 1 |
| 40 #define TYPE_DATA 2 | 40 #define TYPE_DATA 2 |
| 71 #define UC_UNCONFIRMED 0x08 | 71 #define UC_UNCONFIRMED 0x08 |
| 72 #define UC_NORMAL 0x10 | 72 #define UC_NORMAL 0x10 |
| 73 #define UC_WIRELESS 0x20 | 73 #define UC_WIRELESS 0x20 |
| 74 | 74 |
| 75 struct ft_request { | 75 struct ft_request { |
| 76 GaimConnection *gc; | 76 PurpleConnection *gc; |
| 77 char *user; | 77 char *user; |
| 78 char UID[2048]; | 78 char UID[2048]; |
| 79 char *cookie; | 79 char *cookie; |
| 80 char *ip; | 80 char *ip; |
| 81 int port; | 81 int port; |
| 117 #define USEROPT_AUTH 0 | 117 #define USEROPT_AUTH 0 |
| 118 #define USEROPT_AUTHPORT 1 | 118 #define USEROPT_AUTHPORT 1 |
| 119 | 119 |
| 120 #define TOC_CONNECT_STEPS 3 | 120 #define TOC_CONNECT_STEPS 3 |
| 121 | 121 |
| 122 static void toc_login_callback(gpointer, gint, GaimInputCondition); | 122 static void toc_login_callback(gpointer, gint, PurpleInputCondition); |
| 123 static void toc_callback(gpointer, gint, GaimInputCondition); | 123 static void toc_callback(gpointer, gint, PurpleInputCondition); |
| 124 | 124 |
| 125 /* ok. this function used to take username/password, and return 0 on success. | 125 /* ok. this function used to take username/password, and return 0 on success. |
| 126 * now, it takes username/password, and returns NULL on error or a new gaim_connection | 126 * now, it takes username/password, and returns NULL on error or a new purple_connection |
| 127 * on success. */ | 127 * on success. */ |
| 128 static void toc_login(GaimAccount *account) | 128 static void toc_login(PurpleAccount *account) |
| 129 { | 129 { |
| 130 GaimConnection *gc; | 130 PurpleConnection *gc; |
| 131 struct toc_data *tdt; | 131 struct toc_data *tdt; |
| 132 char buf[80]; | 132 char buf[80]; |
| 133 | 133 |
| 134 gc = gaim_account_get_connection(account); | 134 gc = purple_account_get_connection(account); |
| 135 gc->proto_data = tdt = g_new0(struct toc_data, 1); | 135 gc->proto_data = tdt = g_new0(struct toc_data, 1); |
| 136 gc->flags |= GAIM_CONNECTION_HTML; | 136 gc->flags |= PURPLE_CONNECTION_HTML; |
| 137 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | 137 gc->flags |= PURPLE_CONNECTION_AUTO_RESP; |
| 138 | 138 |
| 139 g_snprintf(buf, sizeof buf, _("Looking up %s"), | 139 g_snprintf(buf, sizeof buf, _("Looking up %s"), |
| 140 gaim_account_get_string(account, "server", TOC_HOST)); | 140 purple_account_get_string(account, "server", TOC_HOST)); |
| 141 gaim_connection_update_progress(gc, buf, 0, TOC_CONNECT_STEPS); | 141 purple_connection_update_progress(gc, buf, 0, TOC_CONNECT_STEPS); |
| 142 | 142 |
| 143 gaim_debug(GAIM_DEBUG_INFO, "toc", "Client connects to TOC\n"); | 143 purple_debug(PURPLE_DEBUG_INFO, "toc", "Client connects to TOC\n"); |
| 144 if (gaim_proxy_connect(gc, account, | 144 if (purple_proxy_connect(gc, account, |
| 145 gaim_account_get_string(account, "server", TOC_HOST), | 145 purple_account_get_string(account, "server", TOC_HOST), |
| 146 gaim_account_get_int(account, "port", TOC_PORT), | 146 purple_account_get_int(account, "port", TOC_PORT), |
| 147 toc_login_callback, gc) != 0 || !account->gc) { | 147 toc_login_callback, gc) != 0 || !account->gc) { |
| 148 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), | 148 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), |
| 149 gaim_account_get_string(account, "server", TOC_HOST)); | 149 purple_account_get_string(account, "server", TOC_HOST)); |
| 150 gaim_connection_error(gc, buf); | 150 purple_connection_error(gc, buf); |
| 151 return; | 151 return; |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) | 155 static void toc_login_callback(gpointer data, gint source, PurpleInputCondition cond) |
| 156 { | 156 { |
| 157 GaimConnection *gc = data; | 157 PurpleConnection *gc = data; |
| 158 struct toc_data *tdt; | 158 struct toc_data *tdt; |
| 159 char buf[80]; | 159 char buf[80]; |
| 160 struct sockaddr_in name; | 160 struct sockaddr_in name; |
| 161 socklen_t namelen; | 161 socklen_t namelen; |
| 162 | 162 |
| 163 if (!GAIM_CONNECTION_IS_VALID(gc)) { | 163 if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 164 if (source >= 0) | 164 if (source >= 0) |
| 165 close(source); | 165 close(source); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 tdt = gc->proto_data; | 169 tdt = gc->proto_data; |
| 170 | 170 |
| 171 if (source == -1) { | 171 if (source == -1) { |
| 172 /* we didn't successfully connect. tdt->toc_fd is valid here */ | 172 /* we didn't successfully connect. tdt->toc_fd is valid here */ |
| 173 gaim_connection_error(gc, _("Unable to connect.")); | 173 purple_connection_error(gc, _("Unable to connect.")); |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 tdt->toc_fd = source; | 176 tdt->toc_fd = source; |
| 177 | 177 |
| 178 /* | 178 /* |
| 181 * doesn't work because that hostname resolves to multiple IP addresses. | 181 * doesn't work because that hostname resolves to multiple IP addresses. |
| 182 */ | 182 */ |
| 183 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0) | 183 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0) |
| 184 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip)); | 184 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip)); |
| 185 else | 185 else |
| 186 strncpy(tdt->toc_ip, gaim_account_get_string(gc->account, "server", TOC_HOST), sizeof(tdt->toc_ip)); | 186 strncpy(tdt->toc_ip, purple_account_get_string(gc->account, "server", TOC_HOST), sizeof(tdt->toc_ip)); |
| 187 | 187 |
| 188 gaim_debug(GAIM_DEBUG_INFO, "toc", | 188 purple_debug(PURPLE_DEBUG_INFO, "toc", |
| 189 "Client sends \"FLAPON\\r\\n\\r\\n\"\n"); | 189 "Client sends \"FLAPON\\r\\n\\r\\n\"\n"); |
| 190 if (write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { | 190 if (write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { |
| 191 gaim_connection_error(gc, _("Disconnected.")); | 191 purple_connection_error(gc, _("Disconnected.")); |
| 192 return; | 192 return; |
| 193 } | 193 } |
| 194 tdt->state = STATE_FLAPON; | 194 tdt->state = STATE_FLAPON; |
| 195 | 195 |
| 196 /* i know a lot of people like to look at gaim to see how TOC works. so i'll comment | 196 /* i know a lot of people like to look at purple to see how TOC works. so i'll comment |
| 197 * on what this does. it's really simple. when there's data ready to be read from the | 197 * on what this does. it's really simple. when there's data ready to be read from the |
| 198 * toc_fd file descriptor, toc_callback is called, with gc passed as its data arg. */ | 198 * toc_fd file descriptor, toc_callback is called, with gc passed as its data arg. */ |
| 199 gc->inpa = gaim_input_add(tdt->toc_fd, GAIM_INPUT_READ, toc_callback, gc); | 199 gc->inpa = purple_input_add(tdt->toc_fd, PURPLE_INPUT_READ, toc_callback, gc); |
| 200 | 200 |
| 201 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(gc->account)); | 201 g_snprintf(buf, sizeof(buf), _("Signon: %s"), purple_account_get_username(gc->account)); |
| 202 gaim_connection_update_progress(gc, buf, 1, TOC_CONNECT_STEPS); | 202 purple_connection_update_progress(gc, buf, 1, TOC_CONNECT_STEPS); |
| 203 } | 203 } |
| 204 | 204 |
| 205 static void toc_close(GaimConnection *gc) | 205 static void toc_close(PurpleConnection *gc) |
| 206 { | 206 { |
| 207 if (gc->inpa > 0) | 207 if (gc->inpa > 0) |
| 208 gaim_input_remove(gc->inpa); | 208 purple_input_remove(gc->inpa); |
| 209 gc->inpa = 0; | 209 gc->inpa = 0; |
| 210 close(((struct toc_data *)gc->proto_data)->toc_fd); | 210 close(((struct toc_data *)gc->proto_data)->toc_fd); |
| 211 g_free(gc->proto_data); | 211 g_free(gc->proto_data); |
| 212 } | 212 } |
| 213 | 213 |
| 214 static void toc_build_config(GaimAccount *account, char *s, int len, gboolean show) | 214 static void toc_build_config(PurpleAccount *account, char *s, int len, gboolean show) |
| 215 { | 215 { |
| 216 GaimBlistNode *gnode, *cnode, *bnode; | 216 PurpleBlistNode *gnode, *cnode, *bnode; |
| 217 GaimGroup *g; | 217 PurpleGroup *g; |
| 218 GaimBuddy *b; | 218 PurpleBuddy *b; |
| 219 GSList *plist = account->permit; | 219 GSList *plist = account->permit; |
| 220 GSList *dlist = account->deny; | 220 GSList *dlist = account->deny; |
| 221 | 221 |
| 222 int pos = 0; | 222 int pos = 0; |
| 223 | 223 |
| 224 if (!account->perm_deny) | 224 if (!account->perm_deny) |
| 225 account->perm_deny = 1; | 225 account->perm_deny = 1; |
| 226 | 226 |
| 227 pos += g_snprintf(&s[pos], len - pos, "m %d\n", account->perm_deny); | 227 pos += g_snprintf(&s[pos], len - pos, "m %d\n", account->perm_deny); |
| 228 for(gnode = gaim_get_blist()->root; gnode && len > pos; gnode = gnode->next) { | 228 for(gnode = purple_get_blist()->root; gnode && len > pos; gnode = gnode->next) { |
| 229 g = (GaimGroup *)gnode; | 229 g = (PurpleGroup *)gnode; |
| 230 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | 230 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
| 231 continue; | 231 continue; |
| 232 if(gaim_group_on_account(g, account)) { | 232 if(purple_group_on_account(g, account)) { |
| 233 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); | 233 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); |
| 234 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 234 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 235 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | 235 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
| 236 continue; | 236 continue; |
| 237 for(bnode = gnode->child; bnode && len > pos; bnode = bnode->next) { | 237 for(bnode = gnode->child; bnode && len > pos; bnode = bnode->next) { |
| 238 b = (GaimBuddy *)bnode; | 238 b = (PurpleBuddy *)bnode; |
| 239 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | 239 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
| 240 continue; | 240 continue; |
| 241 if(b->account == account) { | 241 if(b->account == account) { |
| 242 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", | 242 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", |
| 243 b->name, | 243 b->name, |
| 244 (show && b->alias) ? ":" : "", | 244 (show && b->alias) ? ":" : "", |
| 351 ret[j] = '\0'; | 351 ret[j] = '\0'; |
| 352 | 352 |
| 353 return ret; | 353 return ret; |
| 354 } | 354 } |
| 355 | 355 |
| 356 static int sflap_send(GaimConnection *gc, const char *buf, int olen, int type) | 356 static int sflap_send(PurpleConnection *gc, const char *buf, int olen, int type) |
| 357 { | 357 { |
| 358 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | 358 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 359 int len; | 359 int len; |
| 360 int slen = 0; | 360 int slen = 0; |
| 361 int ret; | 361 int ret; |
| 380 * get hit though, hopefully. If it gets hit on an IM | 380 * get hit though, hopefully. If it gets hit on an IM |
| 381 * It'll lose the last " and the message won't go through, | 381 * It'll lose the last " and the message won't go through, |
| 382 * but this'll stop a segfault. | 382 * but this'll stop a segfault. |
| 383 */ | 383 */ |
| 384 if (len > MSG_LEN) { | 384 if (len > MSG_LEN) { |
| 385 gaim_debug(GAIM_DEBUG_WARNING, "toc", "message too long, truncating\n"); | 385 purple_debug(PURPLE_DEBUG_WARNING, "toc", "message too long, truncating\n"); |
| 386 escaped[MSG_LEN - 1] = '\0'; | 386 escaped[MSG_LEN - 1] = '\0'; |
| 387 len = MSG_LEN; | 387 len = MSG_LEN; |
| 388 } | 388 } |
| 389 | 389 |
| 390 if (olen < 0) | 390 if (olen < 0) |
| 391 gaim_debug(GAIM_DEBUG_INFO, "toc", "C: %s\n", escaped); | 391 purple_debug(PURPLE_DEBUG_INFO, "toc", "C: %s\n", escaped); |
| 392 | 392 |
| 393 hdr.ast = '*'; | 393 hdr.ast = '*'; |
| 394 hdr.type = type; | 394 hdr.type = type; |
| 395 hdr.seqno = htons(tdt->seqno++ & 0xffff); | 395 hdr.seqno = htons(tdt->seqno++ & 0xffff); |
| 396 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); | 396 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); |
| 412 g_free(escaped); | 412 g_free(escaped); |
| 413 | 413 |
| 414 return ret; | 414 return ret; |
| 415 } | 415 } |
| 416 | 416 |
| 417 static int toc_send_raw(GaimConnection *gc, const char *buf, int len) | 417 static int toc_send_raw(PurpleConnection *gc, const char *buf, int len) |
| 418 { | 418 { |
| 419 return sflap_send(gc, buf, len, 2); | 419 return sflap_send(gc, buf, len, 2); |
| 420 } | 420 } |
| 421 | 421 |
| 422 static int wait_reply(GaimConnection *gc, char *buffer, size_t buflen) | 422 static int wait_reply(PurpleConnection *gc, char *buffer, size_t buflen) |
| 423 { | 423 { |
| 424 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | 424 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 425 struct sflap_hdr *hdr; | 425 struct sflap_hdr *hdr; |
| 426 int ret; | 426 int ret; |
| 427 | 427 |
| 428 if (read(tdt->toc_fd, buffer, sizeof(struct sflap_hdr)) < 0) { | 428 if (read(tdt->toc_fd, buffer, sizeof(struct sflap_hdr)) < 0) { |
| 429 gaim_debug(GAIM_DEBUG_ERROR, "toc", "Couldn't read flap header\n"); | 429 purple_debug(PURPLE_DEBUG_ERROR, "toc", "Couldn't read flap header\n"); |
| 430 return -1; | 430 return -1; |
| 431 } | 431 } |
| 432 | 432 |
| 433 hdr = (struct sflap_hdr *)buffer; | 433 hdr = (struct sflap_hdr *)buffer; |
| 434 | 434 |
| 435 if (buflen < ntohs(hdr->len)) { | 435 if (buflen < ntohs(hdr->len)) { |
| 436 /* fake like there's a read error */ | 436 /* fake like there's a read error */ |
| 437 gaim_debug(GAIM_DEBUG_ERROR, "toc", | 437 purple_debug(PURPLE_DEBUG_ERROR, "toc", |
| 438 "buffer too small (have %d, need %d)\n", | 438 "buffer too small (have %d, need %d)\n", |
| 439 buflen, ntohs(hdr->len)); | 439 buflen, ntohs(hdr->len)); |
| 440 return -1; | 440 return -1; |
| 441 } | 441 } |
| 442 | 442 |
| 471 static void toc_got_info(void *data, const char *url_text, size_t len) | 471 static void toc_got_info(void *data, const char *url_text, size_t len) |
| 472 { | 472 { |
| 473 if (!url_text) | 473 if (!url_text) |
| 474 return; | 474 return; |
| 475 | 475 |
| 476 gaim_notify_formatted(data, NULL, _("Buddy Information"), NULL, | 476 purple_notify_formatted(data, NULL, _("Buddy Information"), NULL, |
| 477 url_text, NULL, NULL); | 477 url_text, NULL, NULL); |
| 478 } | 478 } |
| 479 | 479 |
| 480 static char *show_error_message() | 480 static char *show_error_message() |
| 481 { | 481 { |
| 565 | 565 |
| 566 return buf; | 566 return buf; |
| 567 } | 567 } |
| 568 | 568 |
| 569 static void | 569 static void |
| 570 parse_toc_buddy_list(GaimAccount *account, char *config) | 570 parse_toc_buddy_list(PurpleAccount *account, char *config) |
| 571 { | 571 { |
| 572 char *c; | 572 char *c; |
| 573 char current[256]; | 573 char current[256]; |
| 574 GList *buddies = NULL; | 574 GList *buddies = NULL; |
| 575 | 575 |
| 583 do { | 583 do { |
| 584 if (c == NULL) | 584 if (c == NULL) |
| 585 break; | 585 break; |
| 586 if (*c == 'g') { | 586 if (*c == 'g') { |
| 587 char *utf8 = NULL; | 587 char *utf8 = NULL; |
| 588 utf8 = gaim_utf8_try_convert(c + 2); | 588 utf8 = purple_utf8_try_convert(c + 2); |
| 589 if (utf8 == NULL) { | 589 if (utf8 == NULL) { |
| 590 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); | 590 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); |
| 591 } else { | 591 } else { |
| 592 g_strlcpy(current, utf8, sizeof(current)); | 592 g_strlcpy(current, utf8, sizeof(current)); |
| 593 g_free(utf8); | 593 g_free(utf8); |
| 594 } | 594 } |
| 595 if (!gaim_find_group(current)) { | 595 if (!purple_find_group(current)) { |
| 596 GaimGroup *g = gaim_group_new(current); | 596 PurpleGroup *g = purple_group_new(current); |
| 597 gaim_blist_add_group(g, NULL); | 597 purple_blist_add_group(g, NULL); |
| 598 } | 598 } |
| 599 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ | 599 } else if (*c == 'b') { /*&& !purple_find_buddy(user, c + 2)) {*/ |
| 600 char nm[80], sw[388], *a, *utf8 = NULL; | 600 char nm[80], sw[388], *a, *utf8 = NULL; |
| 601 | 601 |
| 602 if ((a = strchr(c + 2, ':')) != NULL) { | 602 if ((a = strchr(c + 2, ':')) != NULL) { |
| 603 *a++ = '\0'; /* nul the : */ | 603 *a++ = '\0'; /* nul the : */ |
| 604 } | 604 } |
| 605 | 605 |
| 606 g_strlcpy(nm, c + 2, sizeof(nm)); | 606 g_strlcpy(nm, c + 2, sizeof(nm)); |
| 607 if (a) { | 607 if (a) { |
| 608 utf8 = gaim_utf8_try_convert(a); | 608 utf8 = purple_utf8_try_convert(a); |
| 609 if (utf8 == NULL) { | 609 if (utf8 == NULL) { |
| 610 gaim_debug(GAIM_DEBUG_ERROR, "toc blist", | 610 purple_debug(PURPLE_DEBUG_ERROR, "toc blist", |
| 611 "Failed to convert alias for " | 611 "Failed to convert alias for " |
| 612 "'%s' to UTF-8\n", nm); | 612 "'%s' to UTF-8\n", nm); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 if (utf8 == NULL) { | 615 if (utf8 == NULL) { |
| 619 * but who cares? */ | 619 * but who cares? */ |
| 620 g_strlcpy(sw, utf8, sizeof(sw)); | 620 g_strlcpy(sw, utf8, sizeof(sw)); |
| 621 g_free(utf8); | 621 g_free(utf8); |
| 622 } | 622 } |
| 623 | 623 |
| 624 if (!gaim_find_buddy(account, nm)) { | 624 if (!purple_find_buddy(account, nm)) { |
| 625 GaimBuddy *b = gaim_buddy_new(account, nm, sw); | 625 PurpleBuddy *b = purple_buddy_new(account, nm, sw); |
| 626 GaimGroup *g = gaim_find_group(current); | 626 PurpleGroup *g = purple_find_group(current); |
| 627 gaim_blist_add_buddy(b, NULL, g, NULL); | 627 purple_blist_add_buddy(b, NULL, g, NULL); |
| 628 buddies = g_list_append(buddies, b); | 628 buddies = g_list_append(buddies, b); |
| 629 } | 629 } |
| 630 } else if (*c == 'p') { | 630 } else if (*c == 'p') { |
| 631 gaim_privacy_permit_add(account, c + 2, TRUE); | 631 purple_privacy_permit_add(account, c + 2, TRUE); |
| 632 } else if (*c == 'd') { | 632 } else if (*c == 'd') { |
| 633 gaim_privacy_deny_add(account, c + 2, TRUE); | 633 purple_privacy_deny_add(account, c + 2, TRUE); |
| 634 } else if (!strncmp("toc", c, 3)) { | 634 } else if (!strncmp("toc", c, 3)) { |
| 635 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); | 635 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); |
| 636 gaim_debug(GAIM_DEBUG_MISC, "toc blist", | 636 purple_debug(PURPLE_DEBUG_MISC, "toc blist", |
| 637 "permdeny: %d\n", account->perm_deny); | 637 "permdeny: %d\n", account->perm_deny); |
| 638 if (account->perm_deny == 0) | 638 if (account->perm_deny == 0) |
| 639 account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; | 639 account->perm_deny = PURPLE_PRIVACY_ALLOW_ALL; |
| 640 } else if (*c == 'm') { | 640 } else if (*c == 'm') { |
| 641 sscanf(c + 2, "%d", &account->perm_deny); | 641 sscanf(c + 2, "%d", &account->perm_deny); |
| 642 gaim_debug(GAIM_DEBUG_MISC, "toc blist", | 642 purple_debug(PURPLE_DEBUG_MISC, "toc blist", |
| 643 "permdeny: %d\n", account->perm_deny); | 643 "permdeny: %d\n", account->perm_deny); |
| 644 if (account->perm_deny == 0) | 644 if (account->perm_deny == 0) |
| 645 account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; | 645 account->perm_deny = PURPLE_PRIVACY_ALLOW_ALL; |
| 646 } | 646 } |
| 647 } while ((c = strtok(NULL, "\n"))); | 647 } while ((c = strtok(NULL, "\n"))); |
| 648 | 648 |
| 649 if (account->gc) { | 649 if (account->gc) { |
| 650 if (buddies != NULL) { | 650 if (buddies != NULL) { |
| 651 gaim_account_add_buddies(account, buddies); | 651 purple_account_add_buddies(account, buddies); |
| 652 g_list_free(buddies); | 652 g_list_free(buddies); |
| 653 } | 653 } |
| 654 serv_set_permit_deny(account->gc); | 654 serv_set_permit_deny(account->gc); |
| 655 } | 655 } |
| 656 g_list_free(buddies); | 656 g_list_free(buddies); |
| 657 } | 657 } |
| 658 | 658 |
| 659 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) | 659 static void toc_callback(gpointer data, gint source, PurpleInputCondition condition) |
| 660 { | 660 { |
| 661 GaimConnection *gc = (GaimConnection *)data; | 661 PurpleConnection *gc = (PurpleConnection *)data; |
| 662 GaimAccount *account = gaim_connection_get_account(gc); | 662 PurpleAccount *account = purple_connection_get_account(gc); |
| 663 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | 663 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 664 struct sflap_hdr *hdr; | 664 struct sflap_hdr *hdr; |
| 665 struct signon so; | 665 struct signon so; |
| 666 char buf[8 * 1024], *c; | 666 char buf[8 * 1024], *c; |
| 667 char snd[BUF_LEN * 2]; | 667 char snd[BUF_LEN * 2]; |
| 668 const char *username = gaim_account_get_username(account); | 668 const char *username = purple_account_get_username(account); |
| 669 char *password; | 669 char *password; |
| 670 GaimBuddy *buddy; | 670 PurpleBuddy *buddy; |
| 671 | 671 |
| 672 /* there's data waiting to be read, so read it. */ | 672 /* there's data waiting to be read, so read it. */ |
| 673 if (wait_reply(gc, buf, 8 * 1024) <= 0) { | 673 if (wait_reply(gc, buf, 8 * 1024) <= 0) { |
| 674 gaim_connection_error(gc, _("Connection Closed")); | 674 purple_connection_error(gc, _("Connection Closed")); |
| 675 return; | 675 return; |
| 676 } | 676 } |
| 677 | 677 |
| 678 if (tdt->state == STATE_FLAPON) { | 678 if (tdt->state == STATE_FLAPON) { |
| 679 hdr = (struct sflap_hdr *)buf; | 679 hdr = (struct sflap_hdr *)buf; |
| 680 if (hdr->type != TYPE_SIGNON) | 680 if (hdr->type != TYPE_SIGNON) |
| 681 gaim_debug(GAIM_DEBUG_ERROR, "toc", "hdr->type != TYPE_SIGNON\n"); | 681 purple_debug(PURPLE_DEBUG_ERROR, "toc", "hdr->type != TYPE_SIGNON\n"); |
| 682 else | 682 else |
| 683 gaim_debug(GAIM_DEBUG_INFO, "toc", | 683 purple_debug(PURPLE_DEBUG_INFO, "toc", |
| 684 "TOC sends Client FLAP SIGNON\n"); | 684 "TOC sends Client FLAP SIGNON\n"); |
| 685 tdt->seqno = ntohs(hdr->seqno); | 685 tdt->seqno = ntohs(hdr->seqno); |
| 686 tdt->state = STATE_SIGNON_REQUEST; | 686 tdt->state = STATE_SIGNON_REQUEST; |
| 687 | 687 |
| 688 gaim_debug(GAIM_DEBUG_INFO, "toc", "Client sends TOC FLAP SIGNON\n"); | 688 purple_debug(PURPLE_DEBUG_INFO, "toc", "Client sends TOC FLAP SIGNON\n"); |
| 689 g_snprintf(so.username, sizeof(so.username), "%s", username); | 689 g_snprintf(so.username, sizeof(so.username), "%s", username); |
| 690 so.ver = htonl(1); | 690 so.ver = htonl(1); |
| 691 so.tag = htons(1); | 691 so.tag = htons(1); |
| 692 so.namelen = htons(strlen(so.username)); | 692 so.namelen = htons(strlen(so.username)); |
| 693 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { | 693 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { |
| 694 gaim_connection_error(gc, _("Disconnected.")); | 694 purple_connection_error(gc, _("Disconnected.")); |
| 695 return; | 695 return; |
| 696 } | 696 } |
| 697 | 697 |
| 698 gaim_debug(GAIM_DEBUG_INFO, "toc", | 698 purple_debug(PURPLE_DEBUG_INFO, "toc", |
| 699 "Client sends TOC \"toc_signon\" message\n"); | 699 "Client sends TOC \"toc_signon\" message\n"); |
| 700 /* i hate icq. */ | 700 /* i hate icq. */ |
| 701 if (username[0] >= '0' && username[0] <= '9') | 701 if (username[0] >= '0' && username[0] <= '9') |
| 702 password = g_strndup(gaim_connection_get_password(gc), 8); | 702 password = g_strndup(purple_connection_get_password(gc), 8); |
| 703 else | 703 else |
| 704 password = g_strdup(gaim_connection_get_password(gc)); | 704 password = g_strdup(purple_connection_get_password(gc)); |
| 705 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | 705 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
| 706 AUTH_HOST, AUTH_PORT, gaim_normalize(account, username), | 706 AUTH_HOST, AUTH_PORT, purple_normalize(account, username), |
| 707 roast_password(password), LANGUAGE, REVISION); | 707 roast_password(password), LANGUAGE, REVISION); |
| 708 g_free(password); | 708 g_free(password); |
| 709 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | 709 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 710 gaim_connection_error(gc, _("Disconnected.")); | 710 purple_connection_error(gc, _("Disconnected.")); |
| 711 return; | 711 return; |
| 712 } | 712 } |
| 713 | 713 |
| 714 gaim_connection_update_progress(gc, _("Waiting for reply..."), 2, TOC_CONNECT_STEPS); | 714 purple_connection_update_progress(gc, _("Waiting for reply..."), 2, TOC_CONNECT_STEPS); |
| 715 return; | 715 return; |
| 716 } | 716 } |
| 717 | 717 |
| 718 if (tdt->state == STATE_SIGNON_REQUEST) { | 718 if (tdt->state == STATE_SIGNON_REQUEST) { |
| 719 gaim_debug(GAIM_DEBUG_INFO, "toc", "TOC sends client SIGN_ON reply\n"); | 719 purple_debug(PURPLE_DEBUG_INFO, "toc", "TOC sends client SIGN_ON reply\n"); |
| 720 if (g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { | 720 if (g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { |
| 721 gaim_debug(GAIM_DEBUG_ERROR, "toc", | 721 purple_debug(PURPLE_DEBUG_ERROR, "toc", |
| 722 "Didn't get SIGN_ON! buf was: %s\n", | 722 "Didn't get SIGN_ON! buf was: %s\n", |
| 723 buf + sizeof(struct sflap_hdr)); | 723 buf + sizeof(struct sflap_hdr)); |
| 724 if (!g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { | 724 if (!g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
| 725 strtok(buf + sizeof(struct sflap_hdr), ":"); | 725 strtok(buf + sizeof(struct sflap_hdr), ":"); |
| 726 gaim_connection_error(gc, show_error_message()); | 726 purple_connection_error(gc, show_error_message()); |
| 727 } else | 727 } else |
| 728 gaim_connection_error(gc, _("Authentication failed")); | 728 purple_connection_error(gc, _("Authentication failed")); |
| 729 return; | 729 return; |
| 730 } | 730 } |
| 731 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ | 731 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ |
| 732 gaim_debug(GAIM_DEBUG_INFO, "toc", | 732 purple_debug(PURPLE_DEBUG_INFO, "toc", |
| 733 "TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); | 733 "TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); |
| 734 | 734 |
| 735 /* we used to check for the CONFIG here, but we'll wait until we've sent our | 735 /* we used to check for the CONFIG here, but we'll wait until we've sent our |
| 736 * version of the config and then the toc_init_done message. we'll come back to | 736 * version of the config and then the toc_init_done message. we'll come back to |
| 737 * the callback in a better state if we get CONFIG anyway */ | 737 * the callback in a better state if we get CONFIG anyway */ |
| 738 | 738 |
| 739 tdt->state = STATE_ONLINE; | 739 tdt->state = STATE_ONLINE; |
| 740 | 740 |
| 741 gaim_connection_set_state(gc, GAIM_CONNECTED); | 741 purple_connection_set_state(gc, PURPLE_CONNECTED); |
| 742 | 742 |
| 743 /* | 743 /* |
| 744 * Add me to my buddy list so that we know the time when | 744 * Add me to my buddy list so that we know the time when |
| 745 * the server thinks I signed on. | 745 * the server thinks I signed on. |
| 746 */ | 746 */ |
| 747 buddy = gaim_buddy_new(account, username, NULL); | 747 buddy = purple_buddy_new(account, username, NULL); |
| 748 /* XXX - Pick a group to add to */ | 748 /* XXX - Pick a group to add to */ |
| 749 /* gaim_blist_add(buddy, NULL, g, NULL); */ | 749 /* purple_blist_add(buddy, NULL, g, NULL); */ |
| 750 gaim_account_add_buddy(gc, buddy); | 750 purple_account_add_buddy(gc, buddy); |
| 751 | 751 |
| 752 /* Client sends TOC toc_init_done message */ | 752 /* Client sends TOC toc_init_done message */ |
| 753 gaim_debug(GAIM_DEBUG_INFO, "toc", | 753 purple_debug(PURPLE_DEBUG_INFO, "toc", |
| 754 "Client sends TOC toc_init_done message\n"); | 754 "Client sends TOC toc_init_done message\n"); |
| 755 g_snprintf(snd, sizeof snd, "toc_init_done"); | 755 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 756 sflap_send(gc, snd, -1, TYPE_DATA); | 756 sflap_send(gc, snd, -1, TYPE_DATA); |
| 757 | 757 |
| 758 /* | 758 /* |
| 763 sflap_send(gc, snd, -1, TYPE_DATA); | 763 sflap_send(gc, snd, -1, TYPE_DATA); |
| 764 | 764 |
| 765 return; | 765 return; |
| 766 } | 766 } |
| 767 | 767 |
| 768 gaim_debug(GAIM_DEBUG_INFO, "toc", "S: %s\n", | 768 purple_debug(PURPLE_DEBUG_INFO, "toc", "S: %s\n", |
| 769 buf + sizeof(struct sflap_hdr)); | 769 buf + sizeof(struct sflap_hdr)); |
| 770 | 770 |
| 771 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ | 771 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ |
| 772 | 772 |
| 773 if (!g_ascii_strcasecmp(c, "SIGN_ON")) { | 773 if (!g_ascii_strcasecmp(c, "SIGN_ON")) { |
| 774 /* we should only get here after a PAUSE */ | 774 /* we should only get here after a PAUSE */ |
| 775 if (tdt->state != STATE_PAUSE) | 775 if (tdt->state != STATE_PAUSE) |
| 776 gaim_debug(GAIM_DEBUG_ERROR, "toc", | 776 purple_debug(PURPLE_DEBUG_ERROR, "toc", |
| 777 "got SIGN_ON but not PAUSE!\n"); | 777 "got SIGN_ON but not PAUSE!\n"); |
| 778 else { | 778 else { |
| 779 tdt->state = STATE_ONLINE; | 779 tdt->state = STATE_ONLINE; |
| 780 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | 780 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
| 781 AUTH_HOST, AUTH_PORT, | 781 AUTH_HOST, AUTH_PORT, |
| 782 gaim_normalize(account, gaim_account_get_username(account)), | 782 purple_normalize(account, purple_account_get_username(account)), |
| 783 roast_password(gaim_connection_get_password(gc)), | 783 roast_password(purple_connection_get_password(gc)), |
| 784 LANGUAGE, REVISION); | 784 LANGUAGE, REVISION); |
| 785 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | 785 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 786 gaim_connection_error(gc, _("Disconnected.")); | 786 purple_connection_error(gc, _("Disconnected.")); |
| 787 return; | 787 return; |
| 788 } | 788 } |
| 789 g_snprintf(snd, sizeof snd, "toc_init_done"); | 789 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 790 sflap_send(gc, snd, -1, TYPE_DATA); | 790 sflap_send(gc, snd, -1, TYPE_DATA); |
| 791 gaim_notify_info(gc, NULL, | 791 purple_notify_info(gc, NULL, |
| 792 _("TOC has come back from its pause. You may " | 792 _("TOC has come back from its pause. You may " |
| 793 "now send messages again."), NULL); | 793 "now send messages again."), NULL); |
| 794 } | 794 } |
| 795 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { | 795 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { |
| 796 c = strtok(NULL, ":"); | 796 c = strtok(NULL, ":"); |
| 810 message = away; | 810 message = away; |
| 811 while (*message && (*message != ':')) | 811 while (*message && (*message != ':')) |
| 812 message++; | 812 message++; |
| 813 message++; | 813 message++; |
| 814 | 814 |
| 815 a = (away && (*away == 'T')) ? GAIM_MESSAGE_AUTO_RESP : 0; | 815 a = (away && (*away == 'T')) ? PURPLE_MESSAGE_AUTO_RESP : 0; |
| 816 | 816 |
| 817 serv_got_im(gc, c, message, a, time(NULL)); | 817 serv_got_im(gc, c, message, a, time(NULL)); |
| 818 } else if (!g_ascii_strcasecmp(c, "UPDATE_BUDDY")) { | 818 } else if (!g_ascii_strcasecmp(c, "UPDATE_BUDDY")) { |
| 819 char *l, *uc, *tmp; | 819 char *l, *uc, *tmp; |
| 820 gboolean logged_in; | 820 gboolean logged_in; |
| 859 | 859 |
| 860 /* | 860 /* |
| 861 * If we have info for ourselves then set our display name, warning | 861 * If we have info for ourselves then set our display name, warning |
| 862 * level and official time of login. | 862 * level and official time of login. |
| 863 */ | 863 */ |
| 864 tmp = g_strdup(gaim_normalize(account, gaim_account_get_username(gc->account))); | 864 tmp = g_strdup(purple_normalize(account, purple_account_get_username(gc->account))); |
| 865 if (!strcmp(tmp, gaim_normalize(account, c))) { | 865 if (!strcmp(tmp, purple_normalize(account, c))) { |
| 866 gaim_connection_set_display_name(gc, c); | 866 purple_connection_set_display_name(gc, c); |
| 867 /* XXX - What should the second parameter be here? */ | 867 /* XXX - What should the second parameter be here? */ |
| 868 /* gaim_prpl_got_account_warning_level(account, NULL, evil);*/ | 868 /* purple_prpl_got_account_warning_level(account, NULL, evil);*/ |
| 869 gaim_prpl_got_account_login_time(account, signon); | 869 purple_prpl_got_account_login_time(account, signon); |
| 870 } | 870 } |
| 871 g_free(tmp); | 871 g_free(tmp); |
| 872 | 872 |
| 873 gaim_prpl_got_user_status(account, c, (logged_in ? "online" : "offline"), NULL); | 873 purple_prpl_got_user_status(account, c, (logged_in ? "online" : "offline"), NULL); |
| 874 gaim_prpl_got_user_login_time(account, c, signon); | 874 purple_prpl_got_user_login_time(account, c, signon); |
| 875 if (time_idle > 0) | 875 if (time_idle > 0) |
| 876 gaim_prpl_got_user_idle(account, c, TRUE, time_idle); | 876 purple_prpl_got_user_idle(account, c, TRUE, time_idle); |
| 877 else | 877 else |
| 878 gaim_prpl_got_user_idle(account, c, FALSE, 0); | 878 purple_prpl_got_user_idle(account, c, FALSE, 0); |
| 879 } else if (!g_ascii_strcasecmp(c, "ERROR")) { | 879 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
| 880 gaim_notify_error(gc, NULL, show_error_message(), NULL); | 880 purple_notify_error(gc, NULL, show_error_message(), NULL); |
| 881 } else if (!g_ascii_strcasecmp(c, "EVILED")) { | 881 } else if (!g_ascii_strcasecmp(c, "EVILED")) { |
| 882 int lev; | 882 int lev; |
| 883 char *name; | 883 char *name; |
| 884 | 884 |
| 885 sscanf(strtok(NULL, ":"), "%d", &lev); | 885 sscanf(strtok(NULL, ":"), "%d", &lev); |
| 886 name = strtok(NULL, ":"); | 886 name = strtok(NULL, ":"); |
| 887 | 887 |
| 888 /* gaim_prpl_got_account_warning_level(account, name, lev); */ | 888 /* purple_prpl_got_account_warning_level(account, name, lev); */ |
| 889 } else if (!g_ascii_strcasecmp(c, "CHAT_JOIN")) { | 889 } else if (!g_ascii_strcasecmp(c, "CHAT_JOIN")) { |
| 890 char *name; | 890 char *name; |
| 891 int id; | 891 int id; |
| 892 | 892 |
| 893 sscanf(strtok(NULL, ":"), "%d", &id); | 893 sscanf(strtok(NULL, ":"), "%d", &id); |
| 894 name = strtok(NULL, ":"); | 894 name = strtok(NULL, ":"); |
| 895 | 895 |
| 896 serv_got_joined_chat(gc, id, name); | 896 serv_got_joined_chat(gc, id, name); |
| 897 } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { | 897 } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { |
| 898 int id; | 898 int id; |
| 899 GaimMessageFlags flags; | 899 PurpleMessageFlags flags; |
| 900 char *m, *who, *whisper; | 900 char *m, *who, *whisper; |
| 901 | 901 |
| 902 sscanf(strtok(NULL, ":"), "%d", &id); | 902 sscanf(strtok(NULL, ":"), "%d", &id); |
| 903 who = strtok(NULL, ":"); | 903 who = strtok(NULL, ":"); |
| 904 whisper = strtok(NULL, ":"); | 904 whisper = strtok(NULL, ":"); |
| 905 m = whisper; | 905 m = whisper; |
| 906 while (*m && (*m != ':')) | 906 while (*m && (*m != ':')) |
| 907 m++; | 907 m++; |
| 908 m++; | 908 m++; |
| 909 | 909 |
| 910 flags = (whisper && (*whisper == 'T')) ? GAIM_MESSAGE_WHISPER : 0; | 910 flags = (whisper && (*whisper == 'T')) ? PURPLE_MESSAGE_WHISPER : 0; |
| 911 | 911 |
| 912 serv_got_chat_in(gc, id, who, flags, m, time((time_t)NULL)); | 912 serv_got_chat_in(gc, id, who, flags, m, time((time_t)NULL)); |
| 913 } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { | 913 } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
| 914 int id; | 914 int id; |
| 915 char *in, *buddy; | 915 char *in, *buddy; |
| 916 GSList *bcs = gc->buddy_chats; | 916 GSList *bcs = gc->buddy_chats; |
| 917 GaimConversation *b = NULL; | 917 PurpleConversation *b = NULL; |
| 918 GaimConvChat *chat; | 918 PurpleConvChat *chat; |
| 919 | 919 |
| 920 sscanf(strtok(NULL, ":"), "%d", &id); | 920 sscanf(strtok(NULL, ":"), "%d", &id); |
| 921 in = strtok(NULL, ":"); | 921 in = strtok(NULL, ":"); |
| 922 | 922 |
| 923 chat = GAIM_CONV_CHAT(b); | 923 chat = PURPLE_CONV_CHAT(b); |
| 924 | 924 |
| 925 while (bcs) { | 925 while (bcs) { |
| 926 b = (GaimConversation *)bcs->data; | 926 b = (PurpleConversation *)bcs->data; |
| 927 if (id == gaim_conv_chat_get_id(chat)) | 927 if (id == purple_conv_chat_get_id(chat)) |
| 928 break; | 928 break; |
| 929 bcs = bcs->next; | 929 bcs = bcs->next; |
| 930 b = NULL; | 930 b = NULL; |
| 931 } | 931 } |
| 932 | 932 |
| 933 if (!b) | 933 if (!b) |
| 934 return; | 934 return; |
| 935 | 935 |
| 936 if (in && (*in == 'T')) | 936 if (in && (*in == 'T')) |
| 937 while ((buddy = strtok(NULL, ":")) != NULL) | 937 while ((buddy = strtok(NULL, ":")) != NULL) |
| 938 gaim_conv_chat_add_user(chat, buddy, NULL, GAIM_CBFLAGS_NONE, TRUE); | 938 purple_conv_chat_add_user(chat, buddy, NULL, PURPLE_CBFLAGS_NONE, TRUE); |
| 939 else | 939 else |
| 940 while ((buddy = strtok(NULL, ":")) != NULL) | 940 while ((buddy = strtok(NULL, ":")) != NULL) |
| 941 gaim_conv_chat_remove_user(chat, buddy, NULL); | 941 purple_conv_chat_remove_user(chat, buddy, NULL); |
| 942 } else if (!g_ascii_strcasecmp(c, "CHAT_INVITE")) { | 942 } else if (!g_ascii_strcasecmp(c, "CHAT_INVITE")) { |
| 943 char *name, *who, *message; | 943 char *name, *who, *message; |
| 944 int id; | 944 int id; |
| 945 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, | 945 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 946 g_free, g_free); | 946 g_free, g_free); |
| 953 g_hash_table_replace(components, g_strdup("id"), g_strdup_printf("%d", id)); | 953 g_hash_table_replace(components, g_strdup("id"), g_strdup_printf("%d", id)); |
| 954 | 954 |
| 955 serv_got_chat_invite(gc, name, who, message, components); | 955 serv_got_chat_invite(gc, name, who, message, components); |
| 956 } else if (!g_ascii_strcasecmp(c, "CHAT_LEFT")) { | 956 } else if (!g_ascii_strcasecmp(c, "CHAT_LEFT")) { |
| 957 GSList *bcs = gc->buddy_chats; | 957 GSList *bcs = gc->buddy_chats; |
| 958 GaimConversation *b = NULL; | 958 PurpleConversation *b = NULL; |
| 959 int id; | 959 int id; |
| 960 | 960 |
| 961 sscanf(strtok(NULL, ":"), "%d", &id); | 961 sscanf(strtok(NULL, ":"), "%d", &id); |
| 962 | 962 |
| 963 while (bcs) { | 963 while (bcs) { |
| 964 b = (GaimConversation *)bcs->data; | 964 b = (PurpleConversation *)bcs->data; |
| 965 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) | 965 if (id == purple_conv_chat_get_id(PURPLE_CONV_CHAT(b))) |
| 966 break; | 966 break; |
| 967 b = NULL; | 967 b = NULL; |
| 968 bcs = bcs->next; | 968 bcs = bcs->next; |
| 969 } | 969 } |
| 970 | 970 |
| 971 if (!b) | 971 if (!b) |
| 972 return; | 972 return; |
| 973 | 973 |
| 974 if (b->window) { | 974 if (b->window) { |
| 975 char error_buf[BUF_LONG]; | 975 char error_buf[BUF_LONG]; |
| 976 gaim_conversation_set_account(b, NULL); | 976 purple_conversation_set_account(b, NULL); |
| 977 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" | 977 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
| 978 " from chat room %s."), b->name); | 978 " from chat room %s."), b->name); |
| 979 gaim_notify_error(gc, NULL, error_buf, NULL); | 979 purple_notify_error(gc, NULL, error_buf, NULL); |
| 980 } else | 980 } else |
| 981 serv_got_chat_left(gc, id); | 981 serv_got_chat_left(gc, id); |
| 982 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { | 982 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { |
| 983 char *name, *url, tmp[256]; | 983 char *name, *url, tmp[256]; |
| 984 | 984 |
| 985 name = strtok(NULL, ":"); | 985 name = strtok(NULL, ":"); |
| 986 url = strtok(NULL, ":"); | 986 url = strtok(NULL, ":"); |
| 987 | 987 |
| 988 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, | 988 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
| 989 gaim_account_get_int(gc->account, "port", TOC_PORT), | 989 purple_account_get_int(gc->account, "port", TOC_PORT), |
| 990 url); | 990 url); |
| 991 gaim_url_fetch(tmp, FALSE, NULL, FALSE, toc_got_info, gc); | 991 purple_url_fetch(tmp, FALSE, NULL, FALSE, toc_got_info, gc); |
| 992 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { | 992 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
| 993 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { | 993 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { |
| 994 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | 994 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { |
| 995 gaim_notify_info(gc, NULL, _("Password Change Successful"), NULL); | 995 purple_notify_info(gc, NULL, _("Password Change Successful"), NULL); |
| 996 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { | 996 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { |
| 997 tdt->state = STATE_PAUSE; | 997 tdt->state = STATE_PAUSE; |
| 998 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { | 998 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { |
| 999 #if 0 | 999 #if 0 |
| 1000 char *user, *uuid, *cookie; | 1000 char *user, *uuid, *cookie; |
| 1065 | 1065 |
| 1066 g_free(tmp); | 1066 g_free(tmp); |
| 1067 for (i--; i >= 0; i--) | 1067 for (i--; i >= 0; i--) |
| 1068 g_free(messages[i]); | 1068 g_free(messages[i]); |
| 1069 | 1069 |
| 1070 gaim_debug(GAIM_DEBUG_MISC, "toc", | 1070 purple_debug(PURPLE_DEBUG_MISC, "toc", |
| 1071 "English translation of RVOUS_PROPOSE: %s requests " | 1071 "English translation of RVOUS_PROPOSE: %s requests " |
| 1072 "Send File (i.e. send a file to you); %s:%d " | 1072 "Send File (i.e. send a file to you); %s:%d " |
| 1073 "(verified_ip:port), %d files at total size of " | 1073 "(verified_ip:port), %d files at total size of " |
| 1074 "%d bytes.\n", user, vip, port, files, totalsize); | 1074 "%d bytes.\n", user, vip, port, files, totalsize); |
| 1075 accept_file_dialog(ft); | 1075 accept_file_dialog(ft); |
| 1120 break; | 1120 break; |
| 1121 frombase64(strtok(NULL, ":"), &messages[i], NULL); | 1121 frombase64(strtok(NULL, ":"), &messages[i], NULL); |
| 1122 } | 1122 } |
| 1123 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); | 1123 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); |
| 1124 | 1124 |
| 1125 gaim_debug(GAIM_DEBUG_MISC, "toc", | 1125 purple_debug(PURPLE_DEBUG_MISC, "toc", |
| 1126 "received icon of length %d\n", icon->len); | 1126 "received icon of length %d\n", icon->len); |
| 1127 g_free(icon); | 1127 g_free(icon); |
| 1128 for (i--; i >= 0; i--) | 1128 for (i--; i >= 0; i--) |
| 1129 g_free(messages[i]); | 1129 g_free(messages[i]); |
| 1130 } else if (!strcmp(uuid, IMAGE_UID)) { | 1130 } else if (!strcmp(uuid, IMAGE_UID)) { |
| 1131 /* aka Direct IM */ | 1131 /* aka Direct IM */ |
| 1132 } else { | 1132 } else { |
| 1133 gaim_debug(GAIM_DEBUG_ERROR, "toc", | 1133 purple_debug(PURPLE_DEBUG_ERROR, "toc", |
| 1134 "Don't know what to do with RVOUS UUID %s\n", uuid); | 1134 "Don't know what to do with RVOUS UUID %s\n", uuid); |
| 1135 /* do we have to do anything here? i think it just times out */ | 1135 /* do we have to do anything here? i think it just times out */ |
| 1136 } | 1136 } |
| 1137 #endif | 1137 #endif |
| 1138 } else { | 1138 } else { |
| 1139 gaim_debug(GAIM_DEBUG_ERROR, "toc", | 1139 purple_debug(PURPLE_DEBUG_ERROR, "toc", |
| 1140 "don't know what to do with %s\n", c); | 1140 "don't know what to do with %s\n", c); |
| 1141 } | 1141 } |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags flags) | 1144 static int toc_send_im(PurpleConnection *gc, const char *name, const char *message, PurpleMessageFlags flags) |
| 1145 { | 1145 { |
| 1146 char *buf1, *buf2; | 1146 char *buf1, *buf2; |
| 1147 | 1147 |
| 1148 #if 1 | 1148 #if 1 |
| 1149 /* This is the old, non-i18n way */ | 1149 /* This is the old, non-i18n way */ |
| 1150 buf1 = escape_text(message); | 1150 buf1 = escape_text(message); |
| 1151 if (strlen(buf1) + 52 > MSG_LEN) { | 1151 if (strlen(buf1) + 52 > MSG_LEN) { |
| 1152 g_free(buf1); | 1152 g_free(buf1); |
| 1153 return -E2BIG; | 1153 return -E2BIG; |
| 1154 } | 1154 } |
| 1155 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", gaim_normalize(gc->account, name), buf1, | 1155 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", purple_normalize(gc->account, name), buf1, |
| 1156 ((flags & GAIM_MESSAGE_AUTO_RESP) ? " auto" : "")); | 1156 ((flags & PURPLE_MESSAGE_AUTO_RESP) ? " auto" : "")); |
| 1157 g_free(buf1); | 1157 g_free(buf1); |
| 1158 #else | 1158 #else |
| 1159 /* This doesn't work yet. See the comments below for details */ | 1159 /* This doesn't work yet. See the comments below for details */ |
| 1160 buf1 = gaim_strreplace(message, "\"", "\\\""); | 1160 buf1 = purple_strreplace(message, "\"", "\\\""); |
| 1161 | 1161 |
| 1162 /* | 1162 /* |
| 1163 * We still need to determine what encoding should be used and send the | 1163 * We still need to determine what encoding should be used and send the |
| 1164 * message in that encoding. This should be done the same as in | 1164 * message in that encoding. This should be done the same as in |
| 1165 * oscar_encoding_check() in oscar.c. There is no encoding flag sent | 1165 * oscar_encoding_check() in oscar.c. There is no encoding flag sent |
| 1174 if (strlen(buf1) + 52 > MSG_LEN) { | 1174 if (strlen(buf1) + 52 > MSG_LEN) { |
| 1175 g_free(buf1); | 1175 g_free(buf1); |
| 1176 return -E2BIG; | 1176 return -E2BIG; |
| 1177 } | 1177 } |
| 1178 | 1178 |
| 1179 buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", gaim_normalize(gc->account, name), buf1, | 1179 buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", purple_normalize(gc->account, name), buf1, |
| 1180 ((flags & GAIM_MESSAGE_AUTO_RESP) ? "auto" : "")); | 1180 ((flags & PURPLE_MESSAGE_AUTO_RESP) ? "auto" : "")); |
| 1181 g_free(buf1); | 1181 g_free(buf1); |
| 1182 #endif | 1182 #endif |
| 1183 | 1183 |
| 1184 sflap_send(gc, buf2, -1, TYPE_DATA); | 1184 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1185 g_free(buf2); | 1185 g_free(buf2); |
| 1186 | 1186 |
| 1187 return 1; | 1187 return 1; |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 static void toc_set_config(GaimConnection *gc) | 1190 static void toc_set_config(PurpleConnection *gc) |
| 1191 { | 1191 { |
| 1192 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; | 1192 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
| 1193 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); | 1193 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
| 1194 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); | 1194 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
| 1195 sflap_send(gc, snd, -1, TYPE_DATA); | 1195 sflap_send(gc, snd, -1, TYPE_DATA); |
| 1196 g_free(buf); | 1196 g_free(buf); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 static void toc_get_info(GaimConnection *gc, const char *name) | 1199 static void toc_get_info(PurpleConnection *gc, const char *name) |
| 1200 { | 1200 { |
| 1201 char buf[BUF_LEN * 2]; | 1201 char buf[BUF_LEN * 2]; |
| 1202 g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(gc->account, name)); | 1202 g_snprintf(buf, MSG_LEN, "toc_get_info %s", purple_normalize(gc->account, name)); |
| 1203 sflap_send(gc, buf, -1, TYPE_DATA); | 1203 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1204 } | 1204 } |
| 1205 | 1205 |
| 1206 /* Should be implemented as an Account Action? */ | 1206 /* Should be implemented as an Account Action? */ |
| 1207 static void toc_get_dir(GaimBlistNode *node, gpointer data) | 1207 static void toc_get_dir(PurpleBlistNode *node, gpointer data) |
| 1208 { | 1208 { |
| 1209 GaimBuddy *buddy; | 1209 PurpleBuddy *buddy; |
| 1210 GaimConnection *gc; | 1210 PurpleConnection *gc; |
| 1211 char buf[BUF_LEN * 2]; | 1211 char buf[BUF_LEN * 2]; |
| 1212 | 1212 |
| 1213 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | 1213 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 1214 | 1214 |
| 1215 buddy = (GaimBuddy *) node; | 1215 buddy = (PurpleBuddy *) node; |
| 1216 gc = gaim_account_get_connection(buddy->account); | 1216 gc = purple_account_get_connection(buddy->account); |
| 1217 | 1217 |
| 1218 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", | 1218 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", |
| 1219 gaim_normalize(buddy->account, buddy->name)); | 1219 purple_normalize(buddy->account, buddy->name)); |
| 1220 sflap_send(gc, buf, -1, TYPE_DATA); | 1220 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 #if 0 | 1223 #if 0 |
| 1224 /* Should be implemented as an Account Action */ | 1224 /* Should be implemented as an Account Action */ |
| 1225 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, | 1225 static void toc_set_dir(PurpleConnection *g, const char *first, const char *middle, const char *last, |
| 1226 const char *maiden, const char *city, const char *state, const char *country, int web) | 1226 const char *maiden, const char *city, const char *state, const char *country, int web) |
| 1227 { | 1227 { |
| 1228 char *buf3, buf2[BUF_LEN * 4], buf[BUF_LEN]; | 1228 char *buf3, buf2[BUF_LEN * 4], buf[BUF_LEN]; |
| 1229 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, | 1229 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, |
| 1230 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); | 1230 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); |
| 1235 } | 1235 } |
| 1236 #endif | 1236 #endif |
| 1237 | 1237 |
| 1238 #if 0 | 1238 #if 0 |
| 1239 /* Should be implemented as an Account Action */ | 1239 /* Should be implemented as an Account Action */ |
| 1240 static void toc_dir_search(GaimConnection *g, const char *first, const char *middle, const char *last, | 1240 static void toc_dir_search(PurpleConnection *g, const char *first, const char *middle, const char *last, |
| 1241 const char *maiden, const char *city, const char *state, const char *country, const char *email) | 1241 const char *maiden, const char *city, const char *state, const char *country, const char *email) |
| 1242 { | 1242 { |
| 1243 char buf[BUF_LONG]; | 1243 char buf[BUF_LONG]; |
| 1244 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, | 1244 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, |
| 1245 last, maiden, city, state, country, email); | 1245 last, maiden, city, state, country, email); |
| 1246 gaim_debug(GAIM_DEBUG_INFO, "toc", | 1246 purple_debug(PURPLE_DEBUG_INFO, "toc", |
| 1247 "Searching for: %s,%s,%s,%s,%s,%s,%s\n", | 1247 "Searching for: %s,%s,%s,%s,%s,%s,%s\n", |
| 1248 first, middle, last, maiden, | 1248 first, middle, last, maiden, |
| 1249 city, state, country); | 1249 city, state, country); |
| 1250 sflap_send(g, buf, -1, TYPE_DATA); | 1250 sflap_send(g, buf, -1, TYPE_DATA); |
| 1251 } | 1251 } |
| 1252 #endif | 1252 #endif |
| 1253 | 1253 |
| 1254 static void toc_set_status(GaimAccount *account, GaimStatus *status) | 1254 static void toc_set_status(PurpleAccount *account, PurpleStatus *status) |
| 1255 { | 1255 { |
| 1256 #if 0 /* do we care about TOC any more? */ | 1256 #if 0 /* do we care about TOC any more? */ |
| 1257 char buf[BUF_LEN * 2]; | 1257 char buf[BUF_LEN * 2]; |
| 1258 if (gc->away) { | 1258 if (gc->away) { |
| 1259 g_free(gc->away); | 1259 g_free(gc->away); |
| 1269 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | 1269 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); |
| 1270 sflap_send(g, buf, -1, TYPE_DATA); | 1270 sflap_send(g, buf, -1, TYPE_DATA); |
| 1271 #endif | 1271 #endif |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 static void toc_set_info(GaimConnection *g, const char *info) | 1274 static void toc_set_info(PurpleConnection *g, const char *info) |
| 1275 { | 1275 { |
| 1276 char buf[BUF_LEN * 2], *buf2; | 1276 char buf[BUF_LEN * 2], *buf2; |
| 1277 buf2 = escape_text(info); | 1277 buf2 = escape_text(info); |
| 1278 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); | 1278 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); |
| 1279 g_free(buf2); | 1279 g_free(buf2); |
| 1280 sflap_send(g, buf, -1, TYPE_DATA); | 1280 sflap_send(g, buf, -1, TYPE_DATA); |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 static void toc_change_passwd(GaimConnection *g, const char *orig, const char *new) | 1283 static void toc_change_passwd(PurpleConnection *g, const char *orig, const char *new) |
| 1284 { | 1284 { |
| 1285 char buf[BUF_LEN * 2]; | 1285 char buf[BUF_LEN * 2]; |
| 1286 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | 1286 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); |
| 1287 sflap_send(g, buf, -1, TYPE_DATA); | 1287 sflap_send(g, buf, -1, TYPE_DATA); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 static void | 1290 static void |
| 1291 toc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | 1291 toc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 1292 { | 1292 { |
| 1293 char buf[BUF_LEN * 2]; | 1293 char buf[BUF_LEN * 2]; |
| 1294 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(gc->account, buddy->name)); | 1294 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", purple_normalize(gc->account, buddy->name)); |
| 1295 sflap_send(gc, buf, -1, TYPE_DATA); | 1295 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1296 toc_set_config(gc); | 1296 toc_set_config(gc); |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 static void toc_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) | 1299 static void toc_add_buddies(PurpleConnection *gc, GList *buddies, GList *groups) |
| 1300 { | 1300 { |
| 1301 char buf[BUF_LEN * 2]; | 1301 char buf[BUF_LEN * 2]; |
| 1302 int n; | 1302 int n; |
| 1303 GList *cur; | 1303 GList *cur; |
| 1304 | 1304 |
| 1305 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 1305 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 1306 for (cur = buddies; cur != NULL; cur = cur->next) { | 1306 for (cur = buddies; cur != NULL; cur = cur->next) { |
| 1307 GaimBuddy *buddy = cur->data; | 1307 PurpleBuddy *buddy = cur->data; |
| 1308 | 1308 |
| 1309 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { | 1309 if (strlen(purple_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { |
| 1310 sflap_send(gc, buf, -1, TYPE_DATA); | 1310 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1311 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 1311 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 1312 } | 1312 } |
| 1313 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddy->name)); | 1313 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", purple_normalize(gc->account, buddy->name)); |
| 1314 } | 1314 } |
| 1315 sflap_send(gc, buf, -1, TYPE_DATA); | 1315 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 static void toc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | 1318 static void toc_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 1319 { | 1319 { |
| 1320 char buf[BUF_LEN * 2]; | 1320 char buf[BUF_LEN * 2]; |
| 1321 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(gc->account, buddy->name)); | 1321 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", purple_normalize(gc->account, buddy->name)); |
| 1322 sflap_send(gc, buf, -1, TYPE_DATA); | 1322 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1323 toc_set_config(gc); | 1323 toc_set_config(gc); |
| 1324 } | 1324 } |
| 1325 | 1325 |
| 1326 static void toc_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) | 1326 static void toc_remove_buddies(PurpleConnection *gc, GList *buddies, GList *groups) |
| 1327 { | 1327 { |
| 1328 char buf[BUF_LEN * 2]; | 1328 char buf[BUF_LEN * 2]; |
| 1329 int n; | 1329 int n; |
| 1330 GList *cur; | 1330 GList *cur; |
| 1331 | 1331 |
| 1332 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | 1332 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
| 1333 for (cur = buddies; cur != NULL; cur = cur->next) { | 1333 for (cur = buddies; cur != NULL; cur = cur->next) { |
| 1334 GaimBuddy *buddy = cur->data; | 1334 PurpleBuddy *buddy = cur->data; |
| 1335 | 1335 |
| 1336 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { | 1336 if (strlen(purple_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { |
| 1337 sflap_send(gc, buf, -1, TYPE_DATA); | 1337 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1338 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | 1338 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
| 1339 } | 1339 } |
| 1340 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddy->name)); | 1340 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", purple_normalize(gc->account, buddy->name)); |
| 1341 } | 1341 } |
| 1342 sflap_send(gc, buf, -1, TYPE_DATA); | 1342 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1343 toc_set_config(gc); | 1343 toc_set_config(gc); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 static void toc_set_idle(GaimConnection *g, int time) | 1346 static void toc_set_idle(PurpleConnection *g, int time) |
| 1347 { | 1347 { |
| 1348 char buf[BUF_LEN * 2]; | 1348 char buf[BUF_LEN * 2]; |
| 1349 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | 1349 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); |
| 1350 sflap_send(g, buf, -1, TYPE_DATA); | 1350 sflap_send(g, buf, -1, TYPE_DATA); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 static void toc_warn(GaimConnection *g, const char *name, int anon) | 1353 static void toc_warn(PurpleConnection *g, const char *name, int anon) |
| 1354 { | 1354 { |
| 1355 char send[BUF_LEN * 2]; | 1355 char send[BUF_LEN * 2]; |
| 1356 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); | 1356 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); |
| 1357 sflap_send(g, send, -1, TYPE_DATA); | 1357 sflap_send(g, send, -1, TYPE_DATA); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 static GList *toc_chat_info(GaimConnection *gc) | 1360 static GList *toc_chat_info(PurpleConnection *gc) |
| 1361 { | 1361 { |
| 1362 GList *m = NULL; | 1362 GList *m = NULL; |
| 1363 struct proto_chat_entry *pce; | 1363 struct proto_chat_entry *pce; |
| 1364 | 1364 |
| 1365 pce = g_new0(struct proto_chat_entry, 1); | 1365 pce = g_new0(struct proto_chat_entry, 1); |
| 1376 m = g_list_append(m, pce); | 1376 m = g_list_append(m, pce); |
| 1377 | 1377 |
| 1378 return m; | 1378 return m; |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 GHashTable *toc_chat_info_defaults(GaimConnection *gc, const char *chat_name) | 1381 GHashTable *toc_chat_info_defaults(PurpleConnection *gc, const char *chat_name) |
| 1382 { | 1382 { |
| 1383 GHashTable *defaults; | 1383 GHashTable *defaults; |
| 1384 | 1384 |
| 1385 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | 1385 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
| 1386 | 1386 |
| 1388 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | 1388 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); |
| 1389 | 1389 |
| 1390 return defaults; | 1390 return defaults; |
| 1391 } | 1391 } |
| 1392 | 1392 |
| 1393 static void toc_join_chat(GaimConnection *g, GHashTable *data) | 1393 static void toc_join_chat(PurpleConnection *g, GHashTable *data) |
| 1394 { | 1394 { |
| 1395 char buf[BUF_LONG]; | 1395 char buf[BUF_LONG]; |
| 1396 char *name, *exchange; | 1396 char *name, *exchange; |
| 1397 char *id; | 1397 char *id; |
| 1398 | 1398 |
| 1407 } | 1407 } |
| 1408 | 1408 |
| 1409 sflap_send(g, buf, -1, TYPE_DATA); | 1409 sflap_send(g, buf, -1, TYPE_DATA); |
| 1410 } | 1410 } |
| 1411 | 1411 |
| 1412 static void toc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) | 1412 static void toc_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name) |
| 1413 { | 1413 { |
| 1414 char buf[BUF_LONG]; | 1414 char buf[BUF_LONG]; |
| 1415 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, | 1415 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
| 1416 message ? message : "", gaim_normalize(gc->account, name)); | 1416 message ? message : "", purple_normalize(gc->account, name)); |
| 1417 sflap_send(gc, buf, -1, TYPE_DATA); | 1417 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1418 } | 1418 } |
| 1419 | 1419 |
| 1420 static void toc_chat_leave(GaimConnection *g, int id) | 1420 static void toc_chat_leave(PurpleConnection *g, int id) |
| 1421 { | 1421 { |
| 1422 GSList *bcs = g->buddy_chats; | 1422 GSList *bcs = g->buddy_chats; |
| 1423 GaimConversation *b = NULL; | 1423 PurpleConversation *b = NULL; |
| 1424 char buf[BUF_LEN * 2]; | 1424 char buf[BUF_LEN * 2]; |
| 1425 | 1425 |
| 1426 while (bcs) { | 1426 while (bcs) { |
| 1427 b = (GaimConversation *)bcs->data; | 1427 b = (PurpleConversation *)bcs->data; |
| 1428 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) | 1428 if (id == purple_conv_chat_get_id(PURPLE_CONV_CHAT(b))) |
| 1429 break; | 1429 break; |
| 1430 b = NULL; | 1430 b = NULL; |
| 1431 bcs = bcs->next; | 1431 bcs = bcs->next; |
| 1432 } | 1432 } |
| 1433 | 1433 |
| 1434 if (!b) | 1434 if (!b) |
| 1435 return; /* can this happen? */ | 1435 return; /* can this happen? */ |
| 1436 | 1436 |
| 1437 if (gaim_conversation_get_account(b) == NULL) { | 1437 if (purple_conversation_get_account(b) == NULL) { |
| 1438 /* TOC already kicked us out of this room */ | 1438 /* TOC already kicked us out of this room */ |
| 1439 serv_got_chat_left(g, id); | 1439 serv_got_chat_left(g, id); |
| 1440 } | 1440 } |
| 1441 else { | 1441 else { |
| 1442 g_snprintf(buf, 255, "toc_chat_leave %d", id); | 1442 g_snprintf(buf, 255, "toc_chat_leave %d", id); |
| 1443 sflap_send(g, buf, -1, TYPE_DATA); | 1443 sflap_send(g, buf, -1, TYPE_DATA); |
| 1444 } | 1444 } |
| 1445 } | 1445 } |
| 1446 | 1446 |
| 1447 static void toc_chat_whisper(GaimConnection *gc, int id, const char *who, const char *message) | 1447 static void toc_chat_whisper(PurpleConnection *gc, int id, const char *who, const char *message) |
| 1448 { | 1448 { |
| 1449 char *buf1, *buf2; | 1449 char *buf1, *buf2; |
| 1450 buf1 = escape_text(message); | 1450 buf1 = escape_text(message); |
| 1451 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(gc->account, who), buf1); | 1451 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, purple_normalize(gc->account, who), buf1); |
| 1452 g_free(buf1); | 1452 g_free(buf1); |
| 1453 sflap_send(gc, buf2, -1, TYPE_DATA); | 1453 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1454 g_free(buf2); | 1454 g_free(buf2); |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 static int toc_chat_send(GaimConnection *g, int id, const char *message, GaimMessageFlags flags) | 1457 static int toc_chat_send(PurpleConnection *g, int id, const char *message, PurpleMessageFlags flags) |
| 1458 { | 1458 { |
| 1459 char *buf1, *buf2; | 1459 char *buf1, *buf2; |
| 1460 buf1 = escape_text(message); | 1460 buf1 = escape_text(message); |
| 1461 if (strlen(buf1) > 2000) { | 1461 if (strlen(buf1) > 2000) { |
| 1462 g_free(buf1); | 1462 g_free(buf1); |
| 1467 sflap_send(g, buf2, -1, TYPE_DATA); | 1467 sflap_send(g, buf2, -1, TYPE_DATA); |
| 1468 g_free(buf2); | 1468 g_free(buf2); |
| 1469 return 0; | 1469 return 0; |
| 1470 } | 1470 } |
| 1471 | 1471 |
| 1472 static void toc_keepalive(GaimConnection *gc) | 1472 static void toc_keepalive(PurpleConnection *gc) |
| 1473 { | 1473 { |
| 1474 sflap_send(gc, "", 0, TYPE_KEEPALIVE); | 1474 sflap_send(gc, "", 0, TYPE_KEEPALIVE); |
| 1475 } | 1475 } |
| 1476 | 1476 |
| 1477 static const char * | 1477 static const char * |
| 1478 toc_normalize(const GaimAccount *account, const char *str) | 1478 toc_normalize(const PurpleAccount *account, const char *str) |
| 1479 { | 1479 { |
| 1480 static char buf[BUF_LEN]; | 1480 static char buf[BUF_LEN]; |
| 1481 char *tmp1, *tmp2; | 1481 char *tmp1, *tmp2; |
| 1482 int i, j; | 1482 int i, j; |
| 1483 | 1483 |
| 1499 g_free(tmp1); | 1499 g_free(tmp1); |
| 1500 | 1500 |
| 1501 return buf; | 1501 return buf; |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 static const char *toc_list_icon(GaimAccount *a, GaimBuddy *b) | 1504 static const char *toc_list_icon(PurpleAccount *a, PurpleBuddy *b) |
| 1505 { | 1505 { |
| 1506 if (!b || (b && b->name && b->name[0] == '+')) { | 1506 if (!b || (b && b->name && b->name[0] == '+')) { |
| 1507 if (a != NULL && isdigit(*gaim_account_get_username(a))) | 1507 if (a != NULL && isdigit(*purple_account_get_username(a))) |
| 1508 return "icq"; | 1508 return "icq"; |
| 1509 else | 1509 else |
| 1510 return "aim"; | 1510 return "aim"; |
| 1511 } | 1511 } |
| 1512 | 1512 |
| 1513 if (b && b->name && isdigit(b->name[0])) | 1513 if (b && b->name && isdigit(b->name[0])) |
| 1514 return "icq"; | 1514 return "icq"; |
| 1515 return "aim"; | 1515 return "aim"; |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 static const char* toc_list_emblem(GaimBuddy *b) | 1518 static const char* toc_list_emblem(PurpleBuddy *b) |
| 1519 { | 1519 { |
| 1520 if (b->uc & UC_AOL) | 1520 if (b->uc & UC_AOL) |
| 1521 return "aol"; | 1521 return "aol"; |
| 1522 if (b->uc & UC_ADMIN) | 1522 if (b->uc & UC_ADMIN) |
| 1523 return "admin"; | 1523 return "admin"; |
| 1524 if (b->uc & UC_WIRELESS) | 1524 if (b->uc & UC_WIRELESS) |
| 1525 return "mobile"; | 1525 return "mobile"; |
| 1526 return NULL | 1526 return NULL |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 static GList *toc_blist_node_menu(GaimBlistNode *node) | 1529 static GList *toc_blist_node_menu(PurpleBlistNode *node) |
| 1530 { | 1530 { |
| 1531 GList *m = NULL; | 1531 GList *m = NULL; |
| 1532 GaimMenuAction *act; | 1532 PurpleMenuAction *act; |
| 1533 | 1533 |
| 1534 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | 1534 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
| 1535 act = gaim_menu_action_new(_("Get Dir Info"), | 1535 act = purple_menu_action_new(_("Get Dir Info"), |
| 1536 toc_get_dir, NULL, NULL); | 1536 toc_get_dir, NULL, NULL); |
| 1537 m = g_list_append(m, act); | 1537 m = g_list_append(m, act); |
| 1538 } | 1538 } |
| 1539 | 1539 |
| 1540 return m; | 1540 return m; |
| 1541 } | 1541 } |
| 1542 | 1542 |
| 1543 static void toc_add_permit(GaimConnection *gc, const char *who) | 1543 static void toc_add_permit(PurpleConnection *gc, const char *who) |
| 1544 { | 1544 { |
| 1545 char buf2[BUF_LEN * 2]; | 1545 char buf2[BUF_LEN * 2]; |
| 1546 if (gc->account->perm_deny != 3) | 1546 if (gc->account->perm_deny != 3) |
| 1547 return; | 1547 return; |
| 1548 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(gc->account, who)); | 1548 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", purple_normalize(gc->account, who)); |
| 1549 sflap_send(gc, buf2, -1, TYPE_DATA); | 1549 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1550 toc_set_config(gc); | 1550 toc_set_config(gc); |
| 1551 } | 1551 } |
| 1552 | 1552 |
| 1553 static void toc_add_deny(GaimConnection *gc, const char *who) | 1553 static void toc_add_deny(PurpleConnection *gc, const char *who) |
| 1554 { | 1554 { |
| 1555 char buf2[BUF_LEN * 2]; | 1555 char buf2[BUF_LEN * 2]; |
| 1556 if (gc->account->perm_deny != 4) | 1556 if (gc->account->perm_deny != 4) |
| 1557 return; | 1557 return; |
| 1558 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(gc->account, who)); | 1558 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", purple_normalize(gc->account, who)); |
| 1559 sflap_send(gc, buf2, -1, TYPE_DATA); | 1559 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1560 toc_set_config(gc); | 1560 toc_set_config(gc); |
| 1561 } | 1561 } |
| 1562 | 1562 |
| 1563 static void toc_set_permit_deny(GaimConnection *gc) | 1563 static void toc_set_permit_deny(PurpleConnection *gc) |
| 1564 { | 1564 { |
| 1565 char buf2[BUF_LEN * 2]; | 1565 char buf2[BUF_LEN * 2]; |
| 1566 GSList *list; | 1566 GSList *list; |
| 1567 int at; | 1567 int at; |
| 1568 | 1568 |
| 1590 sflap_send(gc, buf2, -1, TYPE_DATA); | 1590 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1591 | 1591 |
| 1592 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | 1592 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); |
| 1593 list = gc->account->permit; | 1593 list = gc->account->permit; |
| 1594 while (list) { | 1594 while (list) { |
| 1595 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); | 1595 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", purple_normalize(gc->account, list->data)); |
| 1596 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | 1596 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1597 sflap_send(gc, buf2, -1, TYPE_DATA); | 1597 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1598 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | 1598 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); |
| 1599 } | 1599 } |
| 1600 list = list->next; | 1600 list = list->next; |
| 1608 sflap_send(gc, buf2, -1, TYPE_DATA); | 1608 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1609 | 1609 |
| 1610 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | 1610 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); |
| 1611 list = gc->account->deny; | 1611 list = gc->account->deny; |
| 1612 while (list) { | 1612 while (list) { |
| 1613 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); | 1613 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", purple_normalize(gc->account, list->data)); |
| 1614 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | 1614 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1615 sflap_send(gc, buf2, -1, TYPE_DATA); | 1615 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1616 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | 1616 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); |
| 1617 } | 1617 } |
| 1618 list = list->next; | 1618 list = list->next; |
| 1623 break; | 1623 break; |
| 1624 } | 1624 } |
| 1625 toc_set_config(gc); | 1625 toc_set_config(gc); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 static void toc_rem_permit(GaimConnection *gc, const char *who) | 1628 static void toc_rem_permit(PurpleConnection *gc, const char *who) |
| 1629 { | 1629 { |
| 1630 if (gc->account->perm_deny != 3) | 1630 if (gc->account->perm_deny != 3) |
| 1631 return; | 1631 return; |
| 1632 toc_set_permit_deny(gc); | 1632 toc_set_permit_deny(gc); |
| 1633 } | 1633 } |
| 1634 | 1634 |
| 1635 static void toc_rem_deny(GaimConnection *gc, const char *who) | 1635 static void toc_rem_deny(PurpleConnection *gc, const char *who) |
| 1636 { | 1636 { |
| 1637 if (gc->account->perm_deny != 4) | 1637 if (gc->account->perm_deny != 4) |
| 1638 return; | 1638 return; |
| 1639 toc_set_permit_deny(gc); | 1639 toc_set_permit_deny(gc); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 static GList *toc_away_states(GaimAccount *account) | 1642 static GList *toc_away_states(PurpleAccount *account) |
| 1643 { | 1643 { |
| 1644 #if 0 /* do we care about TOC any more? */ | 1644 #if 0 /* do we care about TOC any more? */ |
| 1645 return g_list_append(NULL, GAIM_AWAY_CUSTOM); | 1645 return g_list_append(NULL, PURPLE_AWAY_CUSTOM); |
| 1646 #else | 1646 #else |
| 1647 return NULL; | 1647 return NULL; |
| 1648 #endif | 1648 #endif |
| 1649 } | 1649 } |
| 1650 | 1650 |
| 1651 static void | 1651 static void |
| 1652 show_set_info(GaimPluginAction *action) | 1652 show_set_info(PurplePluginAction *action) |
| 1653 { | 1653 { |
| 1654 GaimConnection *gc = (GaimConnection *) action->context; | 1654 PurpleConnection *gc = (PurpleConnection *) action->context; |
| 1655 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); | 1655 purple_account_request_change_user_info(purple_connection_get_account(gc)); |
| 1656 } | 1656 } |
| 1657 | 1657 |
| 1658 static void | 1658 static void |
| 1659 change_pass(GaimPluginAction *action) | 1659 change_pass(PurplePluginAction *action) |
| 1660 { | 1660 { |
| 1661 GaimConnection *gc = (GaimConnection *) action->context; | 1661 PurpleConnection *gc = (PurpleConnection *) action->context; |
| 1662 gaim_account_request_change_password(gaim_connection_get_account(gc)); | 1662 purple_account_request_change_password(purple_connection_get_account(gc)); |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 static GList *toc_actions(GaimPlugin *plugin, gpointer context) | 1665 static GList *toc_actions(PurplePlugin *plugin, gpointer context) |
| 1666 { | 1666 { |
| 1667 GList *m = NULL; | 1667 GList *m = NULL; |
| 1668 GaimPluginAction *act; | 1668 PurplePluginAction *act; |
| 1669 | 1669 |
| 1670 act = gaim_plugin_action_new(_("Set User Info"), | 1670 act = purple_plugin_action_new(_("Set User Info"), |
| 1671 show_set_info); | 1671 show_set_info); |
| 1672 m = g_list_append(m, act); | 1672 m = g_list_append(m, act); |
| 1673 | 1673 |
| 1674 #if 0 | 1674 #if 0 |
| 1675 act = gaim_plugin_action_new(_("Set Dir Info"), | 1675 act = purple_plugin_action_new(_("Set Dir Info"), |
| 1676 show_set_dir); | 1676 show_set_dir); |
| 1677 m = g_list_append(m, act); | 1677 m = g_list_append(m, act); |
| 1678 #endif | 1678 #endif |
| 1679 | 1679 |
| 1680 act = gaim_plugin_action_new(_("Change Password"), | 1680 act = purple_plugin_action_new(_("Change Password"), |
| 1681 change_pass); | 1681 change_pass); |
| 1682 m = g_list_append(m, act); | 1682 m = g_list_append(m, act); |
| 1683 | 1683 |
| 1684 return m; | 1684 return m; |
| 1685 } | 1685 } |
| 1723 }; | 1723 }; |
| 1724 | 1724 |
| 1725 struct file_transfer { | 1725 struct file_transfer { |
| 1726 struct file_header hdr; | 1726 struct file_header hdr; |
| 1727 | 1727 |
| 1728 GaimConnection *gc; | 1728 PurpleConnection *gc; |
| 1729 | 1729 |
| 1730 char *user; | 1730 char *user; |
| 1731 char *cookie; | 1731 char *cookie; |
| 1732 char *ip; | 1732 char *ip; |
| 1733 int port; | 1733 int port; |
| 1743 gint inpa; | 1743 gint inpa; |
| 1744 }; | 1744 }; |
| 1745 | 1745 |
| 1746 static void debug_header(struct file_transfer *ft) { | 1746 static void debug_header(struct file_transfer *ft) { |
| 1747 struct file_header *f = (struct file_header *)ft; | 1747 struct file_header *f = (struct file_header *)ft; |
| 1748 gaim_debug(GAIM_DEBUG_MISC, "toc", "FT HEADER:\n" | 1748 purple_debug(PURPLE_DEBUG_MISC, "toc", "FT HEADER:\n" |
| 1749 "\t%s %d 0x%04x\n" | 1749 "\t%s %d 0x%04x\n" |
| 1750 "\t%s %d %d\n" | 1750 "\t%s %d %d\n" |
| 1751 "\t%d %d %d %d %d %d\n" | 1751 "\t%d %d %d %d %d %d\n" |
| 1752 "\t%d %d %d %d %d %d %d %d\n" | 1752 "\t%d %d %d %d %d %d %d %d\n" |
| 1753 "\t%s\n" | 1753 "\t%s\n" |
| 1767 f->dummy, f->macfileinfo, | 1767 f->dummy, f->macfileinfo, |
| 1768 ntohs(f->nencode), ntohs(f->nlanguage), | 1768 ntohs(f->nencode), ntohs(f->nlanguage), |
| 1769 f->name); | 1769 f->name); |
| 1770 } | 1770 } |
| 1771 | 1771 |
| 1772 static void toc_send_file_callback(gpointer data, gint source, GaimInputCondition cond) | 1772 static void toc_send_file_callback(gpointer data, gint source, PurpleInputCondition cond) |
| 1773 { | 1773 { |
| 1774 char buf[BUF_LONG]; | 1774 char buf[BUF_LONG]; |
| 1775 int rt, i; | 1775 int rt, i; |
| 1776 | 1776 |
| 1777 struct file_transfer *ft = data; | 1777 struct file_transfer *ft = data; |
| 1793 | 1793 |
| 1794 if (ft->files == 1) { | 1794 if (ft->files == 1) { |
| 1795 ft->file = g_fopen(ft->filename, "w"); | 1795 ft->file = g_fopen(ft->filename, "w"); |
| 1796 if (!ft->file) { | 1796 if (!ft->file) { |
| 1797 buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename); | 1797 buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename); |
| 1798 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); | 1798 purple_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 1799 g_free(buf); | 1799 g_free(buf); |
| 1800 gaim_input_remove(ft->inpa); | 1800 purple_input_remove(ft->inpa); |
| 1801 close(source); | 1801 close(source); |
| 1802 g_free(ft->filename); | 1802 g_free(ft->filename); |
| 1803 g_free(ft->user); | 1803 g_free(ft->user); |
| 1804 g_free(ft->ip); | 1804 g_free(ft->ip); |
| 1805 g_free(ft->cookie); | 1805 g_free(ft->cookie); |
| 1810 ft->file = g_fopen(buf, "w"); | 1810 ft->file = g_fopen(buf, "w"); |
| 1811 g_free(buf); | 1811 g_free(buf); |
| 1812 if (!ft->file) { | 1812 if (!ft->file) { |
| 1813 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, | 1813 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, |
| 1814 ft->hdr.name); | 1814 ft->hdr.name); |
| 1815 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); | 1815 purple_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 1816 g_free(buf); | 1816 g_free(buf); |
| 1817 gaim_input_remove(ft->inpa); | 1817 purple_input_remove(ft->inpa); |
| 1818 close(source); | 1818 close(source); |
| 1819 g_free(ft->filename); | 1819 g_free(ft->filename); |
| 1820 g_free(ft->user); | 1820 g_free(ft->user); |
| 1821 g_free(ft->ip); | 1821 g_free(ft->ip); |
| 1822 g_free(ft->cookie); | 1822 g_free(ft->cookie); |
| 1827 return; | 1827 return; |
| 1828 } | 1828 } |
| 1829 | 1829 |
| 1830 rt = read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); | 1830 rt = read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); |
| 1831 if (rt < 0) { | 1831 if (rt < 0) { |
| 1832 gaim_notify_error(ft->gc, NULL, | 1832 purple_notify_error(ft->gc, NULL, |
| 1833 _("File transfer failed; other side probably " | 1833 _("File transfer failed; other side probably " |
| 1834 "canceled."), NULL); | 1834 "canceled."), NULL); |
| 1835 gaim_input_remove(ft->inpa); | 1835 purple_input_remove(ft->inpa); |
| 1836 close(source); | 1836 close(source); |
| 1837 g_free(ft->user); | 1837 g_free(ft->user); |
| 1838 g_free(ft->ip); | 1838 g_free(ft->ip); |
| 1839 g_free(ft->cookie); | 1839 g_free(ft->cookie); |
| 1840 if (ft->file) | 1840 if (ft->file) |
| 1856 write(source, ft, 256); | 1856 write(source, ft, 256); |
| 1857 debug_header(ft); | 1857 debug_header(ft); |
| 1858 ft->recvsize = 0; | 1858 ft->recvsize = 0; |
| 1859 fclose(ft->file); | 1859 fclose(ft->file); |
| 1860 if (ft->hdr.filesleft == 0) { | 1860 if (ft->hdr.filesleft == 0) { |
| 1861 gaim_input_remove(ft->inpa); | 1861 purple_input_remove(ft->inpa); |
| 1862 close(source); | 1862 close(source); |
| 1863 g_free(ft->filename); | 1863 g_free(ft->filename); |
| 1864 g_free(ft->user); | 1864 g_free(ft->user); |
| 1865 g_free(ft->ip); | 1865 g_free(ft->ip); |
| 1866 g_free(ft->cookie); | 1866 g_free(ft->cookie); |
| 1867 g_free(ft); | 1867 g_free(ft); |
| 1868 } | 1868 } |
| 1869 } | 1869 } |
| 1870 } | 1870 } |
| 1871 | 1871 |
| 1872 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) | 1872 static void toc_send_file_connect(gpointer data, gint src, PurpleInputCondition cond) |
| 1873 { | 1873 { |
| 1874 struct file_transfer *ft = data; | 1874 struct file_transfer *ft = data; |
| 1875 | 1875 |
| 1876 if (src == -1) { | 1876 if (src == -1) { |
| 1877 gaim_notify_error(ft->gc, NULL, | 1877 purple_notify_error(ft->gc, NULL, |
| 1878 _("Could not connect for transfer."), NULL); | 1878 _("Could not connect for transfer."), NULL); |
| 1879 g_free(ft->filename); | 1879 g_free(ft->filename); |
| 1880 g_free(ft->cookie); | 1880 g_free(ft->cookie); |
| 1881 g_free(ft->user); | 1881 g_free(ft->user); |
| 1882 g_free(ft->ip); | 1882 g_free(ft->ip); |
| 1883 g_free(ft); | 1883 g_free(ft); |
| 1884 return; | 1884 return; |
| 1885 } | 1885 } |
| 1886 | 1886 |
| 1887 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_send_file_callback, ft); | 1887 ft->inpa = purple_input_add(src, PURPLE_INPUT_READ, toc_send_file_callback, ft); |
| 1888 } | 1888 } |
| 1889 | 1889 |
| 1890 static void toc_send_file(gpointer a, struct file_transfer *old_ft) | 1890 static void toc_send_file(gpointer a, struct file_transfer *old_ft) |
| 1891 { | 1891 { |
| 1892 struct file_transfer *ft; | 1892 struct file_transfer *ft; |
| 1893 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | 1893 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); |
| 1894 GaimAccount *account; | 1894 PurpleAccount *account; |
| 1895 char buf[BUF_LEN * 2]; | 1895 char buf[BUF_LEN * 2]; |
| 1896 | 1896 |
| 1897 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) | 1897 if (purple_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 1898 return; | 1898 return; |
| 1899 ft = g_new0(struct file_transfer, 1); | 1899 ft = g_new0(struct file_transfer, 1); |
| 1900 if (old_ft->files == 1) | 1900 if (old_ft->files == 1) |
| 1901 ft->filename = g_strdup(dirname); | 1901 ft->filename = g_strdup(dirname); |
| 1902 else | 1902 else |
| 1911 gtk_widget_destroy(old_ft->window); | 1911 gtk_widget_destroy(old_ft->window); |
| 1912 | 1912 |
| 1913 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); | 1913 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); |
| 1914 sflap_send(ft->gc, buf, -1, TYPE_DATA); | 1914 sflap_send(ft->gc, buf, -1, TYPE_DATA); |
| 1915 | 1915 |
| 1916 if (gaim_proxy_connect(ft->gc, account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { | 1916 if (purple_proxy_connect(ft->gc, account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { |
| 1917 gaim_notify_error(ft->gc, NULL, | 1917 purple_notify_error(ft->gc, NULL, |
| 1918 _("Could not connect for transfer."), NULL); | 1918 _("Could not connect for transfer."), NULL); |
| 1919 g_free(ft->filename); | 1919 g_free(ft->filename); |
| 1920 g_free(ft->cookie); | 1920 g_free(ft->cookie); |
| 1921 g_free(ft->user); | 1921 g_free(ft->user); |
| 1922 g_free(ft->ip); | 1922 g_free(ft->ip); |
| 1923 g_free(ft); | 1923 g_free(ft); |
| 1924 return; | 1924 return; |
| 1925 } | 1925 } |
| 1926 } | 1926 } |
| 1927 | 1927 |
| 1928 static void toc_get_file_callback(gpointer data, gint source, GaimInputCondition cond) | 1928 static void toc_get_file_callback(gpointer data, gint source, PurpleInputCondition cond) |
| 1929 { | 1929 { |
| 1930 char buf[BUF_LONG]; | 1930 char buf[BUF_LONG]; |
| 1931 | 1931 |
| 1932 struct file_transfer *ft = data; | 1932 struct file_transfer *ft = data; |
| 1933 | 1933 |
| 1934 if (cond & GAIM_INPUT_WRITE) { | 1934 if (cond & PURPLE_INPUT_WRITE) { |
| 1935 int remain = MIN(ntohl(ft->hdr.totsize) - ft->recvsize, 1024); | 1935 int remain = MIN(ntohl(ft->hdr.totsize) - ft->recvsize, 1024); |
| 1936 int i; | 1936 int i; |
| 1937 for (i = 0; i < remain; i++) | 1937 for (i = 0; i < remain; i++) |
| 1938 fscanf(ft->file, "%c", &buf[i]); | 1938 fscanf(ft->file, "%c", &buf[i]); |
| 1939 write(source, buf, remain); | 1939 write(source, buf, remain); |
| 1940 ft->recvsize += remain; | 1940 ft->recvsize += remain; |
| 1941 if (ft->recvsize == ntohl(ft->hdr.totsize)) { | 1941 if (ft->recvsize == ntohl(ft->hdr.totsize)) { |
| 1942 gaim_input_remove(ft->inpa); | 1942 purple_input_remove(ft->inpa); |
| 1943 ft->inpa = gaim_input_add(source, GAIM_INPUT_READ, | 1943 ft->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
| 1944 toc_get_file_callback, ft); | 1944 toc_get_file_callback, ft); |
| 1945 } | 1945 } |
| 1946 return; | 1946 return; |
| 1947 } | 1947 } |
| 1948 | 1948 |
| 1979 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 1979 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 1980 debug_header(ft); | 1980 debug_header(ft); |
| 1981 | 1981 |
| 1982 if (ft->hdr.hdrtype != htons(0x120c)) { | 1982 if (ft->hdr.hdrtype != htons(0x120c)) { |
| 1983 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); | 1983 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); |
| 1984 gaim_notify_error(ft->gc, NULL, buf, NULL); | 1984 purple_notify_error(ft->gc, NULL, buf, NULL); |
| 1985 gaim_input_remove(ft->inpa); | 1985 purple_input_remove(ft->inpa); |
| 1986 close(source); | 1986 close(source); |
| 1987 g_free(ft->filename); | 1987 g_free(ft->filename); |
| 1988 g_free(ft->user); | 1988 g_free(ft->user); |
| 1989 g_free(ft->ip); | 1989 g_free(ft->ip); |
| 1990 g_free(ft->cookie); | 1990 g_free(ft->cookie); |
| 2004 if (ft->hdr.hdrtype == 0x0101) { | 2004 if (ft->hdr.hdrtype == 0x0101) { |
| 2005 read(source, ft, 8); | 2005 read(source, ft, 8); |
| 2006 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 2006 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 2007 debug_header(ft); | 2007 debug_header(ft); |
| 2008 | 2008 |
| 2009 gaim_input_remove(ft->inpa); | 2009 purple_input_remove(ft->inpa); |
| 2010 ft->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, | 2010 ft->inpa = purple_input_add(source, PURPLE_INPUT_WRITE, |
| 2011 toc_get_file_callback, ft); | 2011 toc_get_file_callback, ft); |
| 2012 return; | 2012 return; |
| 2013 } | 2013 } |
| 2014 | 2014 |
| 2015 if (ft->hdr.hdrtype == 0x0202) { | 2015 if (ft->hdr.hdrtype == 0x0202) { |
| 2016 read(source, ft, 8); | 2016 read(source, ft, 8); |
| 2017 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 2017 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 2018 debug_header(ft); | 2018 debug_header(ft); |
| 2019 | 2019 |
| 2020 gaim_input_remove(ft->inpa); | 2020 purple_input_remove(ft->inpa); |
| 2021 close(source); | 2021 close(source); |
| 2022 g_free(ft->filename); | 2022 g_free(ft->filename); |
| 2023 g_free(ft->user); | 2023 g_free(ft->user); |
| 2024 g_free(ft->ip); | 2024 g_free(ft->ip); |
| 2025 g_free(ft->cookie); | 2025 g_free(ft->cookie); |
| 2028 g_free(ft); | 2028 g_free(ft); |
| 2029 return; | 2029 return; |
| 2030 } | 2030 } |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 static void toc_get_file_connect(gpointer data, gint src, GaimInputCondition cond) | 2033 static void toc_get_file_connect(gpointer data, gint src, PurpleInputCondition cond) |
| 2034 { | 2034 { |
| 2035 struct file_transfer *ft = data; | 2035 struct file_transfer *ft = data; |
| 2036 struct file_header *hdr; | 2036 struct file_header *hdr; |
| 2037 char *buf; | 2037 char *buf; |
| 2038 char *basename; | 2038 char *basename; |
| 2039 | 2039 |
| 2040 if (src == -1) { | 2040 if (src == -1) { |
| 2041 gaim_notify_error(ft->gc, NULL, | 2041 purple_notify_error(ft->gc, NULL, |
| 2042 _("Could not connect for transfer."), NULL); | 2042 _("Could not connect for transfer."), NULL); |
| 2043 fclose(ft->file); | 2043 fclose(ft->file); |
| 2044 g_free(ft->filename); | 2044 g_free(ft->filename); |
| 2045 g_free(ft->cookie); | 2045 g_free(ft->cookie); |
| 2046 g_free(ft->user); | 2046 g_free(ft->user); |
| 2069 hdr->flags = 0x02; | 2069 hdr->flags = 0x02; |
| 2070 hdr->lnameoffset = 0x1A; | 2070 hdr->lnameoffset = 0x1A; |
| 2071 hdr->lsizeoffset = 0x10; | 2071 hdr->lsizeoffset = 0x10; |
| 2072 g_snprintf(hdr->name, 64, "listing.txt"); | 2072 g_snprintf(hdr->name, 64, "listing.txt"); |
| 2073 if (write(src, hdr, 256) < 0) { | 2073 if (write(src, hdr, 256) < 0) { |
| 2074 gaim_notify_error(ft->gc, NULL, | 2074 purple_notify_error(ft->gc, NULL, |
| 2075 _("Could not write file header. The file will " | 2075 _("Could not write file header. The file will " |
| 2076 "not be transferred."), NULL); | 2076 "not be transferred."), NULL); |
| 2077 fclose(ft->file); | 2077 fclose(ft->file); |
| 2078 g_free(ft->filename); | 2078 g_free(ft->filename); |
| 2079 g_free(ft->cookie); | 2079 g_free(ft->cookie); |
| 2081 g_free(ft->ip); | 2081 g_free(ft->ip); |
| 2082 g_free(ft); | 2082 g_free(ft); |
| 2083 return; | 2083 return; |
| 2084 } | 2084 } |
| 2085 | 2085 |
| 2086 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_get_file_callback, ft); | 2086 ft->inpa = purple_input_add(src, PURPLE_INPUT_READ, toc_get_file_callback, ft); |
| 2087 } | 2087 } |
| 2088 | 2088 |
| 2089 static void toc_get_file(gpointer a, struct file_transfer *old_ft) | 2089 static void toc_get_file(gpointer a, struct file_transfer *old_ft) |
| 2090 { | 2090 { |
| 2091 struct file_transfer *ft; | 2091 struct file_transfer *ft; |
| 2092 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | 2092 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); |
| 2093 GaimAccount *account; | 2093 PurpleAccount *account; |
| 2094 char *buf, buf2[BUF_LEN * 2]; | 2094 char *buf, buf2[BUF_LEN * 2]; |
| 2095 | 2095 |
| 2096 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) | 2096 if (purple_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 2097 return; | 2097 return; |
| 2098 ft = g_new0(struct file_transfer, 1); | 2098 ft = g_new0(struct file_transfer, 1); |
| 2099 ft->filename = g_strdup(dirname); | 2099 ft->filename = g_strdup(dirname); |
| 2100 ft->file = g_fopen(ft->filename, "r"); | 2100 ft->file = g_fopen(ft->filename, "r"); |
| 2101 if (!ft->file) { | 2101 if (!ft->file) { |
| 2102 buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename); | 2102 buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename); |
| 2103 gaim_notify_error(ft->gc, NULL, buf, NULL); | 2103 purple_notify_error(ft->gc, NULL, buf, NULL); |
| 2104 g_free(buf); | 2104 g_free(buf); |
| 2105 g_free(ft->filename); | 2105 g_free(ft->filename); |
| 2106 g_free(ft); | 2106 g_free(ft); |
| 2107 return; | 2107 return; |
| 2108 } | 2108 } |
| 2109 if (g_stat(dirname, &ft->st)) { | 2109 if (g_stat(dirname, &ft->st)) { |
| 2110 buf = g_strdup_printf("Unable to examine %s.", dirname); | 2110 buf = g_strdup_printf("Unable to examine %s.", dirname); |
| 2111 gaim_notify_error(ft->gc, NULL, buf, NULL); | 2111 purple_notify_error(ft->gc, NULL, buf, NULL); |
| 2112 g_free(buf); | 2112 g_free(buf); |
| 2113 g_free(ft->filename); | 2113 g_free(ft->filename); |
| 2114 g_free(ft); | 2114 g_free(ft); |
| 2115 return; | 2115 return; |
| 2116 } | 2116 } |
| 2123 gtk_widget_destroy(old_ft->window); | 2123 gtk_widget_destroy(old_ft->window); |
| 2124 | 2124 |
| 2125 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); | 2125 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); |
| 2126 sflap_send(ft->gc, buf2, -1, TYPE_DATA); | 2126 sflap_send(ft->gc, buf2, -1, TYPE_DATA); |
| 2127 | 2127 |
| 2128 if (gaim_proxy_connect(ft->gc, account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { | 2128 if (purple_proxy_connect(ft->gc, account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { |
| 2129 gaim_notify_error(ft->gc, NULL, | 2129 purple_notify_error(ft->gc, NULL, |
| 2130 _("Could not connect for transfer."), NULL); | 2130 _("Could not connect for transfer."), NULL); |
| 2131 fclose(ft->file); | 2131 fclose(ft->file); |
| 2132 g_free(ft->filename); | 2132 g_free(ft->filename); |
| 2133 g_free(ft->cookie); | 2133 g_free(ft->cookie); |
| 2134 g_free(ft->user); | 2134 g_free(ft->user); |
| 2158 g_free(ft); | 2158 g_free(ft); |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 | 2161 |
| 2162 static void toc_accept_ft(struct ft_request *fr) { | 2162 static void toc_accept_ft(struct ft_request *fr) { |
| 2163 if(g_list_find(gaim_connections_get_all(), fr->gc)) { | 2163 if(g_list_find(purple_connections_get_all(), fr->gc)) { |
| 2164 GtkWidget *window; | 2164 GtkWidget *window; |
| 2165 char buf[BUF_LEN]; | 2165 char buf[BUF_LEN]; |
| 2166 | 2166 |
| 2167 struct file_transfer *ft = g_new0(struct file_transfer, 1); | 2167 struct file_transfer *ft = g_new0(struct file_transfer, 1); |
| 2168 ft->gc = fr->gc; | 2168 ft->gc = fr->gc; |
| 2171 ft->ip = g_strdup(fr->ip); | 2171 ft->ip = g_strdup(fr->ip); |
| 2172 ft->port = fr->port; | 2172 ft->port = fr->port; |
| 2173 ft->files = fr->files; | 2173 ft->files = fr->files; |
| 2174 | 2174 |
| 2175 ft->window = window = gtk_file_selection_new(_("Save As...")); | 2175 ft->window = window = gtk_file_selection_new(_("Save As...")); |
| 2176 g_snprintf(buf, sizeof(buf), "%s/%s", gaim_home_dir(), fr->filename ? fr->filename : ""); | 2176 g_snprintf(buf, sizeof(buf), "%s/%s", purple_home_dir(), fr->filename ? fr->filename : ""); |
| 2177 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | 2177 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); |
| 2178 g_signal_connect(G_OBJECT(window), "destroy", | 2178 g_signal_connect(G_OBJECT(window), "destroy", |
| 2179 G_CALLBACK(cancel_callback), ft); | 2179 G_CALLBACK(cancel_callback), ft); |
| 2180 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), | 2180 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), |
| 2181 "clicked", G_CALLBACK(cancel_callback), ft); | 2181 "clicked", G_CALLBACK(cancel_callback), ft); |
| 2207 g_snprintf(buf, sizeof(buf), | 2207 g_snprintf(buf, sizeof(buf), |
| 2208 ngettext( | 2208 ngettext( |
| 2209 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", | 2209 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", |
| 2210 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", | 2210 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", |
| 2211 ft->files), | 2211 ft->files), |
| 2212 ft->user, gaim_account_get_username(ft->gc->account), ft->files, | 2212 ft->user, purple_account_get_username(ft->gc->account), ft->files, |
| 2213 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", | 2213 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", |
| 2214 (ft->message) ? ft->message : ""); | 2214 (ft->message) ? ft->message : ""); |
| 2215 } else { | 2215 } else { |
| 2216 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); | 2216 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); |
| 2217 } | 2217 } |
| 2218 | 2218 |
| 2219 gaim_request_accept_cancel(ft->gc, NULL, buf, NULL, | 2219 purple_request_accept_cancel(ft->gc, NULL, buf, NULL, |
| 2220 GAIM_DEFAULT_ACTION_NONE, ft, | 2220 PURPLE_DEFAULT_ACTION_NONE, ft, |
| 2221 G_CALLBACK(toc_accept_ft), | 2221 G_CALLBACK(toc_accept_ft), |
| 2222 G_CALLBACK(toc_reject_ft)); | 2222 G_CALLBACK(toc_reject_ft)); |
| 2223 } | 2223 } |
| 2224 #endif | 2224 #endif |
| 2225 | 2225 |
| 2226 static GaimPluginProtocolInfo prpl_info = | 2226 static PurplePluginProtocolInfo prpl_info = |
| 2227 { | 2227 { |
| 2228 0, | 2228 0, |
| 2229 NULL, /* user_splits */ | 2229 NULL, /* user_splits */ |
| 2230 NULL, /* protocol_options */ | 2230 NULL, /* protocol_options */ |
| 2231 NO_BUDDY_ICONS, /* icon_spec */ | 2231 NO_BUDDY_ICONS, /* icon_spec */ |
| 2286 NULL, /* offline_message */ | 2286 NULL, /* offline_message */ |
| 2287 NULL, /* whiteboard_prpl_ops */ | 2287 NULL, /* whiteboard_prpl_ops */ |
| 2288 toc_send_raw, /* send_raw */ | 2288 toc_send_raw, /* send_raw */ |
| 2289 }; | 2289 }; |
| 2290 | 2290 |
| 2291 static GaimPluginInfo info = | 2291 static PurplePluginInfo info = |
| 2292 { | 2292 { |
| 2293 GAIM_PLUGIN_MAGIC, | 2293 PURPLE_PLUGIN_MAGIC, |
| 2294 GAIM_MAJOR_VERSION, | 2294 PURPLE_MAJOR_VERSION, |
| 2295 GAIM_MINOR_VERSION, | 2295 PURPLE_MINOR_VERSION, |
| 2296 GAIM_PLUGIN_PROTOCOL, /**< type */ | 2296 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
| 2297 NULL, /**< ui_requirement */ | 2297 NULL, /**< ui_requirement */ |
| 2298 0, /**< flags */ | 2298 0, /**< flags */ |
| 2299 NULL, /**< dependencies */ | 2299 NULL, /**< dependencies */ |
| 2300 GAIM_PRIORITY_DEFAULT, /**< priority */ | 2300 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 2301 | 2301 |
| 2302 "prpl-toc", /**< id */ | 2302 "prpl-toc", /**< id */ |
| 2303 "TOC", /**< name */ | 2303 "TOC", /**< name */ |
| 2304 VERSION, /**< version */ | 2304 VERSION, /**< version */ |
| 2305 /** summary */ | 2305 /** summary */ |
| 2306 N_("TOC Protocol Plugin"), | 2306 N_("TOC Protocol Plugin"), |
| 2307 /** description */ | 2307 /** description */ |
| 2308 N_("TOC Protocol Plugin"), | 2308 N_("TOC Protocol Plugin"), |
| 2309 NULL, /**< author */ | 2309 NULL, /**< author */ |
| 2310 GAIM_WEBSITE, /**< homepage */ | 2310 PURPLE_WEBSITE, /**< homepage */ |
| 2311 | 2311 |
| 2312 NULL, /**< load */ | 2312 NULL, /**< load */ |
| 2313 NULL, /**< unload */ | 2313 NULL, /**< unload */ |
| 2314 NULL, /**< destroy */ | 2314 NULL, /**< destroy */ |
| 2315 | 2315 |
| 2318 NULL, | 2318 NULL, |
| 2319 toc_actions | 2319 toc_actions |
| 2320 }; | 2320 }; |
| 2321 | 2321 |
| 2322 static void | 2322 static void |
| 2323 init_plugin(GaimPlugin *plugin) | 2323 init_plugin(PurplePlugin *plugin) |
| 2324 { | 2324 { |
| 2325 GaimAccountOption *option; | 2325 PurpleAccountOption *option; |
| 2326 | 2326 |
| 2327 option = gaim_account_option_string_new(_("Server"), "server", TOC_HOST); | 2327 option = purple_account_option_string_new(_("Server"), "server", TOC_HOST); |
| 2328 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2328 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 2329 option); | 2329 option); |
| 2330 | 2330 |
| 2331 option = gaim_account_option_int_new(_("Port"), "port", TOC_PORT); | 2331 option = purple_account_option_int_new(_("Port"), "port", TOC_PORT); |
| 2332 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2332 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 2333 option); | 2333 option); |
| 2334 | 2334 |
| 2335 my_protocol = plugin; | 2335 my_protocol = plugin; |
| 2336 } | 2336 } |
| 2337 | 2337 |
| 2338 GAIM_INIT_PLUGIN(toc, init_plugin, info); | 2338 PURPLE_INIT_PLUGIN(toc, init_plugin, info); |
