comparison src/protocols/oscar/oscar.c @ 5205:fefad67de2c7

[gaim-migrate @ 5573] I had a damn good commit message, but it was eaten. Let's try it again. Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short. There are lots'a cool thingies here. Okay now, this isn't as cool as the previous message, but: 1) There's now a single entry function for all plugin types. It returns a detailed information structure on the plugin. This removes a lot of the ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so if you use it, well, you shouldn't have used it anyway, but now you can't! bwahahaha. Use AIM/ICQ. 2) There are now 3 types of plugins: Standard, Loader, and Protocol plugins. Standard plugins are, well, standard, compiled plugins. Loader plugins load other plugins. For example, the perl support is now a loader plugin. It loads perl scripts. In the future, we'll have Ruby and Python loader plugins. Protocol plugins are, well, protocol plugins... yeah... 3) Plugins have unique IDs, so they can be referred to or automatically updated from a plugin database in the future. Neat, huh? 4) Plugins will have dependency support in the future, and can be hidden, so if you have, say, a logging core plugin, it won't have to show up, but then you load the GTK+ logging plugin and it'll auto-load the core plugin. Core/UI split plugins! 5) There will eventually be custom plugin signals and RPC of some sort, for the core/ui split plugins. So, okay, back up .gaimrc. I'd like to thank my parents for their support, javabsp for helping convert a bunch of protocol plugins, and Etan for helping convert a bunch of standard plugins. Have fun. If you have any problems, please let me know, but you probably won't have anything major happen. You will have to convert your plugins, though, and I'm not guaranteeing that all perl scripts will still work. I'll end up changing the perl script API eventually, so I know they won't down the road. Don't worry, though. It'll be mass cool. faceprint wants me to just commit the damn code already. So, here we go!!! .. .. I need a massage. From a young, cute girl. Are there any young, cute girls in the audience? IM me plz k thx. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 25 Apr 2003 06:47:33 +0000
parents f2cd55078be3
children 0a6912730d56
comparison
equal deleted inserted replaced
5204:44de70702205 5205:fefad67de2c7
66 #define UC_AB 0x20 66 #define UC_AB 0x20
67 #define UC_WIRELESS 0x40 67 #define UC_WIRELESS 0x40
68 68
69 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" 69 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3"
70 70
71 static struct prpl *my_protocol = NULL; 71 static GaimPlugin *my_protocol = NULL;
72 72
73 /* For win32 compatability */ 73 /* For win32 compatability */
74 G_MODULE_IMPORT GSList *connections; 74 G_MODULE_IMPORT GSList *connections;
75 G_MODULE_IMPORT int report_idle; 75 G_MODULE_IMPORT int report_idle;
76 76
506 506
507 if (!g_slist_find(connections, gc)) { 507 if (!g_slist_find(connections, gc)) {
508 /* oh boy. this is probably bad. i guess the only thing we 508 /* oh boy. this is probably bad. i guess the only thing we
509 * can really do is return? */ 509 * can really do is return? */
510 debug_printf("oscar callback for closed connection (2).\n"); 510 debug_printf("oscar callback for closed connection (2).\n");
511 debug_printf("gc = %p\n", gc);
511 return; 512 return;
512 } 513 }
513 514
514 if (condition & GAIM_INPUT_READ) { 515 if (condition & GAIM_INPUT_READ) {
515 if (conn->type == AIM_CONN_TYPE_LISTENER) { 516 if (conn->type == AIM_CONN_TYPE_LISTENER) {
636 aim_conn_t *conn; 637 aim_conn_t *conn;
637 char buf[256]; 638 char buf[256];
638 struct gaim_connection *gc = new_gaim_conn(account); 639 struct gaim_connection *gc = new_gaim_conn(account);
639 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1); 640 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1);
640 641
642 debug_printf("oscar_login: gc = %p\n", gc);
643
641 if (isdigit(*account->username)) { 644 if (isdigit(*account->username)) {
642 od->icq = TRUE; 645 od->icq = TRUE;
643 gc->password[8] = 0; 646 gc->password[8] = 0;
644 } else { 647 } else {
645 gc->flags |= OPT_CONN_HTML; 648 gc->flags |= OPT_CONN_HTML;
2302 d->gc = gc; 2305 d->gc = gc;
2303 d->sn = g_strdup(userinfo->sn); 2306 d->sn = g_strdup(userinfo->sn);
2304 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); 2307 strncpy(d->ip, args->verifiedip, sizeof(d->ip));
2305 memcpy(d->cookie, args->cookie, 8); 2308 memcpy(d->cookie, args->cookie, 8);
2306 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, gc->username); 2309 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, gc->username);
2307 do_ask_dialog(buf, _("This requires a direct connection between the two computers and is necessary for IM Images. Because your IP address will be revealed, this may be considered a privacy risk."), d, _("Connect"), accept_direct_im, _("Cancel"), cancel_direct_im, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 2310 do_ask_dialog(buf, _("This requires a direct connection between the two computers and is necessary for IM Images. Because your IP address will be revealed, this may be considered a privacy risk."), d, _("Connect"), accept_direct_im, _("Cancel"), cancel_direct_im, my_protocol->handle, FALSE);
2308 } else { 2311 } else {
2309 debug_printf("Unknown reqclass %hu\n", args->reqclass); 2312 debug_printf("Unknown reqclass %hu\n", args->reqclass);
2310 } 2313 }
2311 2314
2312 return 1; 2315 return 1;
2362 2365
2363 dialog_msg = g_strdup_printf(_("The user %s requires authorization before being added to a buddy list. Do you want to send an authorization request?"), (nombre ? nombre : name)); 2366 dialog_msg = g_strdup_printf(_("The user %s requires authorization before being added to a buddy list. Do you want to send an authorization request?"), (nombre ? nombre : name));
2364 data->gc = gc; 2367 data->gc = gc;
2365 data->name = g_strdup(name); 2368 data->name = g_strdup(name);
2366 data->nick = NULL; 2369 data->nick = NULL;
2367 do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request_msgprompt, _("Cancel"), gaim_auth_dontrequest, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 2370 do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request_msgprompt, _("Cancel"), gaim_auth_dontrequest, my_protocol->handle, FALSE);
2368 2371
2369 g_free(dialog_msg); 2372 g_free(dialog_msg);
2370 g_free(nombre); 2373 g_free(nombre);
2371 } 2374 }
2372 2375
2474 gchar *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); 2477 gchar *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given."));
2475 debug_printf("Received an authorization request from UIN %lu\n", args->uin); 2478 debug_printf("Received an authorization request from UIN %lu\n", args->uin);
2476 data->gc = gc; 2479 data->gc = gc;
2477 data->name = g_strdup_printf("%lu", args->uin); 2480 data->name = g_strdup_printf("%lu", args->uin);
2478 data->nick = NULL; 2481 data->nick = NULL;
2479 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 2482 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->handle, FALSE);
2480 g_free(dialog_msg); 2483 g_free(dialog_msg);
2481 } 2484 }
2482 } break; 2485 } break;
2483 2486
2484 case 0x07: { /* Someone has denied you authorization */ 2487 case 0x07: { /* Someone has denied you authorization */
2536 struct name_data *data = g_new(struct name_data, 1); 2539 struct name_data *data = g_new(struct name_data, 1);
2537 gchar *message = g_strdup_printf(_("ICQ user %lu has sent you a contact: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]); 2540 gchar *message = g_strdup_printf(_("ICQ user %lu has sent you a contact: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]);
2538 data->gc = gc; 2541 data->gc = gc;
2539 data->name = g_strdup(text[i*2+1]); 2542 data->name = g_strdup(text[i*2+1]);
2540 data->nick = g_strdup(text[i*2+2]); 2543 data->nick = g_strdup(text[i*2+2]);
2541 do_ask_dialog(message, _("Do you want to add this contact to your Buddy List?"), data, _("Add"), gaim_icq_contactadd, _("Decline"), gaim_free_name_data, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 2544 do_ask_dialog(message, _("Do you want to add this contact to your Buddy List?"), data, _("Add"), gaim_icq_contactadd, _("Decline"), gaim_free_name_data, my_protocol->handle, FALSE);
2542 g_free(message); 2545 g_free(message);
2543 } 2546 }
2544 g_strfreev(text); 2547 g_strfreev(text);
2545 } 2548 }
2546 } break; 2549 } break;
4838 dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list. Do you want to add them?"), nombre); 4841 dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list. Do you want to add them?"), nombre);
4839 data = g_new(struct name_data, 1); 4842 data = g_new(struct name_data, 1);
4840 data->gc = gc; 4843 data->gc = gc;
4841 data->name = g_strdup(sn); 4844 data->name = g_strdup(sn);
4842 data->nick = NULL; 4845 data->nick = NULL;
4843 do_ask_dialog(_("Authorization Given"), dialog_msg, data, _("Yes"), gaim_icq_contactadd, _("No"), gaim_free_name_data, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 4846 do_ask_dialog(_("Authorization Given"), dialog_msg, data, _("Yes"), gaim_icq_contactadd, _("No"), gaim_free_name_data, my_protocol->handle, FALSE);
4844 4847
4845 g_free(dialog_msg); 4848 g_free(dialog_msg);
4846 g_free(nombre); 4849 g_free(nombre);
4847 4850
4848 return 1; 4851 return 1;
4872 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); 4875 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given."));
4873 data = g_new(struct name_data, 1); 4876 data = g_new(struct name_data, 1);
4874 data->gc = gc; 4877 data->gc = gc;
4875 data->name = g_strdup(sn); 4878 data->name = g_strdup(sn);
4876 data->nick = NULL; 4879 data->nick = NULL;
4877 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 4880 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->handle, FALSE);
4878 4881
4879 g_free(dialog_msg); 4882 g_free(dialog_msg);
4880 g_free(nombre); 4883 g_free(nombre);
4881 4884
4882 return 1; 4885 return 1;
5408 char buf[BUF_LONG]; 5411 char buf[BUF_LONG];
5409 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); 5412 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1);
5410 data->who = g_strdup(who); 5413 data->who = g_strdup(who);
5411 data->gc = gc; 5414 data->gc = gc;
5412 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who); 5415 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who);
5413 do_ask_dialog(buf, _("Because this reveals your IP address, it may be considered a privacy risk. Do you wish to continue?"), data, _("Connect"), oscar_direct_im, _("Cancel"), oscar_cancel_direct_im, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 5416 do_ask_dialog(buf, _("Because this reveals your IP address, it may be considered a privacy risk. Do you wish to continue?"), data, _("Connect"), oscar_direct_im, _("Cancel"), oscar_cancel_direct_im, my_protocol->handle, FALSE);
5414 } 5417 }
5415 5418
5416 static void oscar_set_permit_deny(struct gaim_connection *gc) { 5419 static void oscar_set_permit_deny(struct gaim_connection *gc) {
5417 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 5420 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
5418 #ifdef NOSSI 5421 #ifdef NOSSI
5821 gaim_input_remove(dim->watcher); 5824 gaim_input_remove(dim->watcher);
5822 aim_conn_kill(od->sess, &dim->conn); 5825 aim_conn_kill(od->sess, &dim->conn);
5823 g_free(dim); 5826 g_free(dim);
5824 } 5827 }
5825 5828
5826 G_MODULE_EXPORT void oscar_init(struct prpl *ret) { 5829 static GaimPluginProtocolInfo prpl_info =
5830 {
5831 GAIM_PROTO_OSCAR,
5832 OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE,
5833 NULL,
5834 NULL,
5835 oscar_list_icon,
5836 oscar_list_emblems,
5837 oscar_status_text,
5838 oscar_tooltip_text,
5839 oscar_away_states,
5840 oscar_actions,
5841 oscar_buddy_menu,
5842 oscar_chat_info,
5843 oscar_login,
5844 oscar_close,
5845 oscar_send_im,
5846 oscar_set_info,
5847 oscar_send_typing,
5848 oscar_get_info,
5849 oscar_set_away,
5850 oscar_get_away,
5851 oscar_set_dir,
5852 NULL,
5853 oscar_dir_search,
5854 oscar_set_idle,
5855 oscar_change_passwd,
5856 oscar_add_buddy,
5857 oscar_add_buddies,
5858 oscar_remove_buddy,
5859 oscar_remove_buddies,
5860 oscar_add_permit,
5861 oscar_add_deny,
5862 oscar_rem_permit,
5863 oscar_rem_deny,
5864 oscar_set_permit_deny,
5865 oscar_warn,
5866 oscar_join_chat,
5867 oscar_chat_invite,
5868 oscar_chat_leave,
5869 NULL,
5870 oscar_chat_send,
5871 oscar_keepalive,
5872 NULL,
5873 NULL,
5874 NULL,
5875 #ifndef NOSSI
5876 oscar_alias_buddy,
5877 oscar_move_buddy,
5878 oscar_rename_group,
5879 #else
5880 NULL,
5881 NULL,
5882 NULL,
5883 #endif
5884 NULL,
5885 oscar_convo_closed,
5886 NULL
5887 };
5888
5889 static GaimPluginInfo info =
5890 {
5891 2, /**< api_version */
5892 GAIM_PLUGIN_PROTOCOL, /**< type */
5893 NULL, /**< ui_requirement */
5894 0, /**< flags */
5895 NULL, /**< dependencies */
5896 GAIM_PRIORITY_DEFAULT, /**< priority */
5897
5898 "prpl-oscar", /**< id */
5899 "AIM/ICQ", /**< name */
5900 VERSION, /**< version */
5901 /** summary */
5902 N_("AIM/ICQ Protocol Plugin"),
5903 /** description */
5904 N_("AIM/ICQ Protocol Plugin"),
5905 NULL, /**< author */
5906 WEBSITE, /**< homepage */
5907
5908 NULL, /**< load */
5909 NULL, /**< unload */
5910 NULL, /**< destroy */
5911
5912 NULL, /**< ui_info */
5913 &prpl_info /**< extra_info */
5914 };
5915
5916 static void
5917 __init_plugin(GaimPlugin *plugin)
5918 {
5827 struct proto_user_opt *puo; 5919 struct proto_user_opt *puo;
5828 ret->protocol = PROTO_OSCAR;
5829 ret->options = OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE;
5830 ret->name = g_strdup("AIM/ICQ");
5831 ret->list_icon = oscar_list_icon;
5832 ret->list_emblems = oscar_list_emblems;
5833 ret->tooltip_text = oscar_tooltip_text;
5834 ret->status_text = oscar_status_text;
5835 ret->away_states = oscar_away_states;
5836 ret->actions = oscar_actions;
5837 ret->buddy_menu = oscar_buddy_menu;
5838 ret->login = oscar_login;
5839 ret->close = oscar_close;
5840 ret->send_im = oscar_send_im;
5841 ret->send_typing = oscar_send_typing;
5842 ret->set_info = oscar_set_info;
5843 ret->get_info = oscar_get_info;
5844 ret->set_away = oscar_set_away;
5845 ret->get_away = oscar_get_away;
5846 ret->set_dir = oscar_set_dir;
5847 ret->get_dir = NULL; /* Oscar really doesn't have this */
5848 ret->dir_search = oscar_dir_search;
5849 ret->set_idle = oscar_set_idle;
5850 ret->change_passwd = oscar_change_passwd;
5851 ret->add_buddy = oscar_add_buddy;
5852 ret->add_buddies = oscar_add_buddies;
5853 ret->remove_buddy = oscar_remove_buddy;
5854 ret->remove_buddies = oscar_remove_buddies;
5855 #ifndef NOSSI
5856 ret->group_buddy = oscar_move_buddy;
5857 ret->alias_buddy = oscar_alias_buddy;
5858 ret->rename_group = oscar_rename_group;
5859 #endif
5860 ret->add_permit = oscar_add_permit;
5861 ret->add_deny = oscar_add_deny;
5862 ret->rem_permit = oscar_rem_permit;
5863 ret->rem_deny = oscar_rem_deny;
5864 ret->set_permit_deny = oscar_set_permit_deny;
5865
5866 ret->warn = oscar_warn;
5867 ret->chat_info = oscar_chat_info;
5868 ret->join_chat = oscar_join_chat;
5869 ret->chat_invite = oscar_chat_invite;
5870 ret->chat_leave = oscar_chat_leave;
5871 ret->chat_whisper = NULL;
5872 ret->chat_send = oscar_chat_send;
5873 ret->keepalive = oscar_keepalive;
5874 ret->convo_closed = oscar_convo_closed;
5875 5920
5876 puo = g_new0(struct proto_user_opt, 1); 5921 puo = g_new0(struct proto_user_opt, 1);
5877 puo->label = g_strdup("Auth Host:"); 5922 puo->label = g_strdup("Auth Host:");
5878 puo->def = g_strdup("login.oscar.aol.com"); 5923 puo->def = g_strdup("login.oscar.aol.com");
5879 puo->pos = USEROPT_AUTH; 5924 puo->pos = USEROPT_AUTH;
5880 ret->user_opts = g_list_append(ret->user_opts, puo); 5925 prpl_info.user_opts = g_list_append(prpl_info.user_opts, puo);
5881 5926
5882 puo = g_new0(struct proto_user_opt, 1); 5927 puo = g_new0(struct proto_user_opt, 1);
5883 puo->label = g_strdup("Auth Port:"); 5928 puo->label = g_strdup("Auth Port:");
5884 puo->def = g_strdup("5190"); 5929 puo->def = g_strdup("5190");
5885 puo->pos = USEROPT_AUTHPORT; 5930 puo->pos = USEROPT_AUTH;
5886 ret->user_opts = g_list_append(ret->user_opts, puo); 5931 prpl_info.user_opts = g_list_append(prpl_info.user_opts, puo);
5887 5932
5888 my_protocol = ret; 5933 my_protocol = plugin;
5889 } 5934 }
5890 5935
5891 #ifndef STATIC 5936 GAIM_INIT_PLUGIN(oscar, __init_plugin, info);
5892
5893 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl)
5894 {
5895 oscar_init(prpl);
5896 prpl->plug->desc.api_version = PLUGIN_API_VERSION;
5897 }
5898
5899 #endif