Changeset 89db90e for protocols/purple/purple.c
- Timestamp:
- 2015-03-12T09:10:16Z (10 years ago)
- Children:
- fc650a8
- Parents:
- 0e4c3dd (diff), 3bb333c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/purple.c
r0e4c3dd r89db90e 23 23 24 24 #include "bitlbee.h" 25 #include "bpurple.h" 25 26 #include "help.h" 26 27 … … 42 43 { 43 44 GSList *i; 45 struct purple_data *pd; 44 46 45 47 for (i = purple_connections; i; i = i->next) { 46 if (((struct im_connection *) i->data)->proto_data == pa) { 48 pd = ((struct im_connection *) i->data)->proto_data; 49 if (pd->account == pa) { 47 50 return i->data; 48 51 } … … 290 293 { 291 294 struct im_connection *ic = imcb_new(acc); 292 PurpleAccount *pa;295 struct purple_data *pd; 293 296 294 297 if ((local_bee != NULL && local_bee != acc->bee) || … … 306 309 purple_connections = g_slist_prepend(purple_connections, ic); 307 310 308 ic->proto_data = pa = purple_account_new(acc->user, (char *) acc->prpl->data); 309 purple_account_set_password(pa, acc->pass); 310 purple_sync_settings(acc, pa); 311 312 purple_account_set_enabled(pa, "BitlBee", TRUE); 311 ic->proto_data = pd = g_new0(struct purple_data, 1); 312 pd->account = purple_account_new(acc->user, (char *) acc->prpl->data); 313 purple_account_set_password(pd->account, acc->pass); 314 purple_sync_settings(acc, pd->account); 315 316 purple_account_set_enabled(pd->account, "BitlBee", TRUE); 313 317 } 314 318 315 319 static void purple_logout(struct im_connection *ic) 316 320 { 317 PurpleAccount *pa= ic->proto_data;318 319 purple_account_set_enabled(p a, "BitlBee", FALSE);321 struct purple_data *pd = ic->proto_data; 322 323 purple_account_set_enabled(pd->account, "BitlBee", FALSE); 320 324 purple_connections = g_slist_remove(purple_connections, ic); 321 purple_accounts_remove(pa); 325 purple_accounts_remove(pd->account); 326 g_free(pd); 322 327 } 323 328 … … 325 330 { 326 331 PurpleConversation *conv; 332 struct purple_data *pd = ic->proto_data; 327 333 328 334 if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, 329 who, ic->proto_data)) == NULL) {335 who, pd->account)) == NULL) { 330 336 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, 331 ic->proto_data, who);337 pd->account, who); 332 338 } 333 339 … … 339 345 static GList *purple_away_states(struct im_connection *ic) 340 346 { 341 PurpleAccount *pa= ic->proto_data;347 struct purple_data *pd = ic->proto_data; 342 348 GList *st, *ret = NULL; 343 349 344 for (st = purple_account_get_status_types(p a); st; st = st->next) {350 for (st = purple_account_get_status_types(pd->account); st; st = st->next) { 345 351 PurpleStatusPrimitive prim = purple_status_type_get_primitive(st->data); 346 352 if (prim != PURPLE_STATUS_AVAILABLE && prim != PURPLE_STATUS_OFFLINE) { … … 354 360 static void purple_set_away(struct im_connection *ic, char *state_txt, char *message) 355 361 { 356 PurpleAccount *pa= ic->proto_data;357 GList *status_types = purple_account_get_status_types(p a), *st;362 struct purple_data *pd = ic->proto_data; 363 GList *status_types = purple_account_get_status_types(pd->account), *st; 358 364 PurpleStatusType *pst = NULL; 359 365 GList *args = NULL; … … 378 384 } 379 385 380 purple_account_set_status_list(pa, st ? purple_status_type_get_id(pst) : "away", 386 purple_account_set_status_list(pd->account, 387 st ? purple_status_type_get_id(pst) : "away", 381 388 TRUE, args); 382 389 … … 447 454 PurpleBuddy *pb; 448 455 PurpleGroup *pg = NULL; 456 struct purple_data *pd = ic->proto_data; 449 457 450 458 if (group && !(pg = purple_find_group(group))) { … … 453 461 } 454 462 455 pb = purple_buddy_new( (PurpleAccount *) ic->proto_data, who, NULL);463 pb = purple_buddy_new(pd->account, who, NULL); 456 464 purple_blist_add_buddy(pb, NULL, pg, NULL); 457 purple_account_add_buddy( (PurpleAccount *) ic->proto_data, pb);458 459 purple_gg_buddylist_export( ((PurpleAccount *) ic->proto_data)->gc);465 purple_account_add_buddy(pd->account, pb); 466 467 purple_gg_buddylist_export(pd->account->gc); 460 468 } 461 469 … … 463 471 { 464 472 PurpleBuddy *pb; 465 466 pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who); 473 struct purple_data *pd = ic->proto_data; 474 475 pb = purple_find_buddy(pd->account, who); 467 476 if (pb != NULL) { 468 477 PurpleGroup *group; 469 478 470 479 group = purple_buddy_get_group(pb); 471 purple_account_remove_buddy( (PurpleAccount *) ic->proto_data, pb, group);480 purple_account_remove_buddy(pd->account, pb, group); 472 481 473 482 purple_blist_remove_buddy(pb); 474 483 } 475 484 476 purple_gg_buddylist_export( ((PurpleAccount *) ic->proto_data)->gc);485 purple_gg_buddylist_export(pd->account->gc); 477 486 } 478 487 479 488 static void purple_add_permit(struct im_connection *ic, char *who) 480 489 { 481 PurpleAccount *pa= ic->proto_data;482 483 purple_privacy_permit_add(p a, who, FALSE);490 struct purple_data *pd = ic->proto_data; 491 492 purple_privacy_permit_add(pd->account, who, FALSE); 484 493 } 485 494 486 495 static void purple_add_deny(struct im_connection *ic, char *who) 487 496 { 488 PurpleAccount *pa= ic->proto_data;489 490 purple_privacy_deny_add(p a, who, FALSE);497 struct purple_data *pd = ic->proto_data; 498 499 purple_privacy_deny_add(pd->account, who, FALSE); 491 500 } 492 501 493 502 static void purple_rem_permit(struct im_connection *ic, char *who) 494 503 { 495 PurpleAccount *pa= ic->proto_data;496 497 purple_privacy_permit_remove(p a, who, FALSE);504 struct purple_data *pd = ic->proto_data; 505 506 purple_privacy_permit_remove(pd->account, who, FALSE); 498 507 } 499 508 500 509 static void purple_rem_deny(struct im_connection *ic, char *who) 501 510 { 502 PurpleAccount *pa= ic->proto_data;503 504 purple_privacy_deny_remove(p a, who, FALSE);511 struct purple_data *pd = ic->proto_data; 512 513 purple_privacy_deny_remove(pd->account, who, FALSE); 505 514 } 506 515 507 516 static void purple_get_info(struct im_connection *ic, char *who) 508 517 { 509 serv_get_info(purple_account_get_connection(ic->proto_data), who); 518 struct purple_data *pd = ic->proto_data; 519 520 serv_get_info(purple_account_get_connection(pd->account), who); 510 521 } 511 522 … … 517 528 { 518 529 PurpleTypingState state = PURPLE_NOT_TYPING; 519 PurpleAccount *pa= ic->proto_data;530 struct purple_data *pd = ic->proto_data; 520 531 521 532 if (flags & OPT_TYPING) { … … 525 536 } 526 537 527 serv_send_typing(purple_account_get_connection(p a), who, state);538 serv_send_typing(purple_account_get_connection(pd->account), who, state); 528 539 529 540 return 1; … … 559 570 /* There went my nice afternoon. :-( */ 560 571 561 PurpleAccount *pa= ic->proto_data;562 PurplePlugin *prpl = purple_plugins_find_with_id(p a->protocol_id);572 struct purple_data *pd = ic->proto_data; 573 PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id); 563 574 PurplePluginProtocolInfo *pi = prpl->info->extra_info; 564 PurpleBuddy *pb = purple_find_buddy( (PurpleAccount *) ic->proto_data, who);575 PurpleBuddy *pb = purple_find_buddy(pd->account, who); 565 576 PurpleMenuAction *mi; 566 577 GList *menu; … … 597 608 PurpleConversation *pc = gc->data; 598 609 PurpleConvChat *pcc = PURPLE_CONV_CHAT(pc); 599 600 serv_chat_invite(purple_account_get_connection(gc->ic->proto_data), 610 struct purple_data *pd = gc->ic->proto_data; 611 612 serv_chat_invite(purple_account_get_connection(pd->account), 601 613 purple_conv_chat_get_id(pcc), 602 614 message && *message ? message : "Please join my chat", … … 623 635 set_t **sets) 624 636 { 625 PurpleAccount *pa= ic->proto_data;626 PurplePlugin *prpl = purple_plugins_find_with_id(p a->protocol_id);637 struct purple_data *pd = ic->proto_data; 638 PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id); 627 639 PurplePluginProtocolInfo *pi = prpl->info->extra_info; 628 640 GHashTable *chat_hash; … … 631 643 632 644 if (!pi->chat_info || !pi->chat_info_defaults || 633 !(info = pi->chat_info(purple_account_get_connection(p a)))) {645 !(info = pi->chat_info(purple_account_get_connection(pd->account)))) { 634 646 imcb_error(ic, "Joining chatrooms not supported by this protocol"); 635 647 return NULL; 636 648 } 637 649 638 if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, room, pa))) { 650 if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, 651 room, pd->account))) { 639 652 purple_conversation_destroy(conv); 640 653 } 641 654 642 chat_hash = pi->chat_info_defaults(purple_account_get_connection(pa), room); 655 chat_hash = pi->chat_info_defaults( 656 purple_account_get_connection(pd->account), room 657 ); 643 658 644 659 for (l = info; l; l = l->next) { … … 654 669 } 655 670 656 serv_join_chat(purple_account_get_connection(p a), chat_hash);671 serv_join_chat(purple_account_get_connection(pd->account), chat_hash); 657 672 658 673 return NULL; … … 1033 1048 } 1034 1049 1050 /* So it turns out some requests have no account context at all, because 1051 * libpurple hates us. This means that query_del_by_conn() won't remove those 1052 * on logout, and will segfault if the user replies. That's why this exists. 1053 */ 1054 static void prplcb_close_request(PurpleRequestType type, void *data) 1055 { 1056 if (type == PURPLE_REQUEST_ACTION) { 1057 struct prplcb_request_action_data *pqad = data; 1058 query_del(local_bee->ui_data, pqad->bee_data); 1059 } 1060 /* Add the request input handler here when that becomes a thing */ 1061 } 1062 1035 1063 /* 1036 1064 static void prplcb_request_test() … … 1047 1075 NULL, 1048 1076 NULL, 1049 NULL,1077 prplcb_close_request, 1050 1078 NULL, 1051 1079 };
Note: See TracChangeset
for help on using the changeset viewer.