Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 3730:a20bf3d247ff
[gaim-migrate @ 3868]
Pretty do_ask_dialog. I also "fixed" the "hitting yes calls the 'no' function
anyway" behavior.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 17 Oct 2002 21:29:53 +0000 |
parents | dd48b1ac5bd8 |
children | b32474e522fa |
comparison
equal
deleted
inserted
replaced
3729:a8f0c169e529 | 3730:a20bf3d247ff |
---|---|
1453 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0, 0); | 1453 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0, 0); |
1454 | 1454 |
1455 return 1; | 1455 return 1; |
1456 } | 1456 } |
1457 | 1457 |
1458 static void cancel_direct_im(gpointer w, struct ask_direct *d) { | 1458 static void cancel_direct_im(struct ask_direct *d) { |
1459 debug_printf("Freeing DirectIM prompts.\n"); | 1459 debug_printf("Freeing DirectIM prompts.\n"); |
1460 | 1460 |
1461 g_free(d->sn); | 1461 g_free(d->sn); |
1462 g_free(d); | 1462 g_free(d); |
1463 } | 1463 } |
1685 aim_conn_kill(od->sess, &oft->conn); | 1685 aim_conn_kill(od->sess, &oft->conn); |
1686 g_free(oft->sn); | 1686 g_free(oft->sn); |
1687 g_free(oft); | 1687 g_free(oft); |
1688 } | 1688 } |
1689 | 1689 |
1690 static int accept_direct_im(gpointer w, struct ask_direct *d) { | 1690 static int accept_direct_im(struct ask_direct *d) { |
1691 struct gaim_connection *gc = d->gc; | 1691 struct gaim_connection *gc = d->gc; |
1692 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 1692 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
1693 struct direct_im *dim; | 1693 struct direct_im *dim; |
1694 char *host; int port = 4443; | 1694 char *host; int port = 4443; |
1695 int i; | 1695 int i; |
1696 | 1696 |
1697 debug_printf("Accepted DirectIM.\n"); | 1697 debug_printf("Accepted DirectIM.\n"); |
1698 | 1698 |
1699 dim = find_direct_im(od, d->sn); | 1699 dim = find_direct_im(od, d->sn); |
1700 if (dim) { | 1700 if (dim) { |
1701 cancel_direct_im(w, d); /* 40 */ | 1701 cancel_direct_im(d); /* 40 */ |
1702 return TRUE; | 1702 return TRUE; |
1703 } | 1703 } |
1704 dim = g_new0(struct direct_im, 1); | 1704 dim = g_new0(struct direct_im, 1); |
1705 dim->gc = d->gc; | 1705 dim->gc = d->gc; |
1706 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | 1706 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1707 | 1707 |
1708 dim->conn = aim_directim_connect(od->sess, d->sn, NULL, d->cookie); | 1708 dim->conn = aim_directim_connect(od->sess, d->sn, NULL, d->cookie); |
1709 if (!dim->conn) { | 1709 if (!dim->conn) { |
1710 g_free(dim); | 1710 g_free(dim); |
1711 cancel_direct_im(w, d); | 1711 cancel_direct_im(d); |
1712 return TRUE; | 1712 return TRUE; |
1713 } | 1713 } |
1714 | 1714 |
1715 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | 1715 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
1716 gaim_directim_incoming, 0); | 1716 gaim_directim_incoming, 0); |
1729 dim->conn->fd = proxy_connect(host, port, oscar_directim_callback, dim); | 1729 dim->conn->fd = proxy_connect(host, port, oscar_directim_callback, dim); |
1730 g_free(host); | 1730 g_free(host); |
1731 if (dim->conn->fd < 0) { | 1731 if (dim->conn->fd < 0) { |
1732 aim_conn_kill(od->sess, &dim->conn); | 1732 aim_conn_kill(od->sess, &dim->conn); |
1733 g_free(dim); | 1733 g_free(dim); |
1734 cancel_direct_im(w, d); | 1734 cancel_direct_im(d); |
1735 return TRUE; | 1735 return TRUE; |
1736 } | 1736 } |
1737 | 1737 |
1738 cancel_direct_im(w, d); | 1738 cancel_direct_im(d); |
1739 | 1739 |
1740 return TRUE; | 1740 return TRUE; |
1741 } | 1741 } |
1742 | 1742 |
1743 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { | 1743 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
1927 d->sn = g_strdup(userinfo->sn); | 1927 d->sn = g_strdup(userinfo->sn); |
1928 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); | 1928 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); |
1929 memcpy(d->cookie, args->cookie, 8); | 1929 memcpy(d->cookie, args->cookie, 8); |
1930 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", | 1930 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", |
1931 userinfo->sn, gc->username); | 1931 userinfo->sn, gc->username); |
1932 do_ask_dialog(buf, d, accept_direct_im, cancel_direct_im); | 1932 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); |
1933 } else { | 1933 } else { |
1934 debug_printf("Unknown reqclass %d\n", args->reqclass); | 1934 debug_printf("Unknown reqclass %d\n", args->reqclass); |
1935 } | 1935 } |
1936 | 1936 |
1937 return 1; | 1937 return 1; |
1938 } | 1938 } |
1939 | 1939 |
1940 /* | 1940 /* |
1941 * Next 2 functions are for when other people ask you for authorization | 1941 * Next 2 functions are for when other people ask you for authorization |
1942 */ | 1942 */ |
1943 static void gaim_icq_authgrant(gpointer w, struct channel4_data *data) { | 1943 static void gaim_icq_authgrant(struct channel4_data *data) { |
1944 char message; | 1944 char message; |
1945 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; | 1945 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; |
1946 message = 0; | 1946 message = 0; |
1947 aim_send_im_ch4(od->sess, data->uin, AIM_ICQMSG_AUTHGRANTED, &message); | 1947 aim_send_im_ch4(od->sess, data->uin, AIM_ICQMSG_AUTHGRANTED, &message); |
1948 show_got_added(data->gc, NULL, data->uin, NULL, NULL); | 1948 show_got_added(data->gc, NULL, data->uin, NULL, NULL); |
1949 g_free(data->uin); | 1949 g_free(data->uin); |
1950 data->uin = NULL; | 1950 g_free(data); |
1951 } | 1951 } |
1952 | 1952 |
1953 static void gaim_icq_authdeny(gpointer w, struct channel4_data *data) { | 1953 static void gaim_icq_authdeny(struct channel4_data *data) { |
1954 if (data->uin) { | 1954 gchar *message; |
1955 gchar *message; | 1955 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; |
1956 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; | 1956 message = g_strdup_printf("No reason given."); |
1957 message = g_strdup_printf("No reason given."); | 1957 aim_send_im_ch4(od->sess, data->uin, AIM_ICQMSG_AUTHDENIED, message); |
1958 aim_send_im_ch4(od->sess, data->uin, AIM_ICQMSG_AUTHDENIED, message); | 1958 g_free(data->uin); |
1959 g_free(data->uin); | 1959 g_free(message); |
1960 g_free(message); | |
1961 } | |
1962 g_free(data); | 1960 g_free(data); |
1963 } | 1961 } |
1964 | 1962 |
1965 /* | 1963 /* |
1966 * For when other people ask you for authorization | 1964 * For when other people ask you for authorization |
1967 */ | 1965 */ |
1968 static void gaim_icq_authask(struct gaim_connection *gc, fu32_t uin, char *msg) { | 1966 static void gaim_icq_authask(struct gaim_connection *gc, fu32_t uin, char *msg) { |
1969 struct channel4_data *data = g_new(struct channel4_data, 1); | 1967 struct channel4_data *data = g_new(struct channel4_data, 1); |
1970 /* The first 6 chars of the message are some type of alien gibberish, so skip them */ | 1968 /* The first 6 chars of the message are some type of alien gibberish, so skip them */ |
1971 char *dialog_msg = g_strdup_printf("The user %lu wants to add you to their buddy list for the following reason:\n\n%s", uin, (msg && strlen(msg)>6) ? msg+6 : "No reason given."); | 1969 char *dialog_msg = g_strdup_printf("The user %lu wants to add you to their buddy list for the following reason:", uin, (msg && strlen(msg)>6) ? msg+6 : "No reason given."); |
1972 debug_printf("Received an authorization request from UIN %lu\n", uin); | 1970 debug_printf("Received an authorization request from UIN %lu\n", uin); |
1973 data->gc = gc; | 1971 data->gc = gc; |
1974 data->uin = g_strdup_printf("%lu", uin); | 1972 data->uin = g_strdup_printf("%lu", uin); |
1975 do_ask_dialog(dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny); | 1973 do_ask_dialog(dialog_msg, (msg && strlen(msg) > 6) ? msg+6 : _("No reason given."), data, _("Authorize"), gaim_icq_authgrant, _("Deny"), gaim_icq_authdeny); |
1976 g_free(dialog_msg); | 1974 g_free(dialog_msg); |
1977 } | 1975 } |
1978 | 1976 |
1979 /* | 1977 /* |
1980 * Next 2 functions are for when someone sends you contacts | 1978 * Next 2 functions are for when someone sends you contacts |
1981 */ | 1979 */ |
1982 static void gaim_icq_contactadd(gpointer w, struct channel4_data *data) { | 1980 static void gaim_icq_contactadd(struct channel4_data *data) { |
1983 show_add_buddy(data->gc, data->uin, NULL, data->nick); | 1981 show_add_buddy(data->gc, data->uin, NULL, data->nick); |
1984 } | 1982 free(data->uin); |
1985 | 1983 free(data->nick); |
1986 static void gaim_icq_contactdontadd(gpointer w, struct channel4_data *data) { | 1984 g_free(data); |
1985 } | |
1986 | |
1987 static void gaim_icq_contactdontadd(struct channel4_data *data) { | |
1987 free(data->uin); | 1988 free(data->uin); |
1988 free(data->nick); | 1989 free(data->nick); |
1989 g_free(data); | 1990 g_free(data); |
1990 } | 1991 } |
1991 | 1992 |
2048 num = 0; | 2049 num = 0; |
2049 for (i=0; i<strlen(text[0]); i++) | 2050 for (i=0; i<strlen(text[0]); i++) |
2050 num = num*10 + text[0][i]-48; | 2051 num = num*10 + text[0][i]-48; |
2051 for (i=0; i<num; i++) { | 2052 for (i=0; i<num; i++) { |
2052 struct channel4_data *data = g_new(struct channel4_data, 1); | 2053 struct channel4_data *data = g_new(struct channel4_data, 1); |
2053 gchar *message = g_strdup_printf("ICQ user %lu has sent you a contact: %s (%s)\nDo you want to add this contact to your contact list?", args->uin, text[i*2+2], text[i*2+1]); | 2054 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]); |
2054 data->gc = gc; | 2055 data->gc = gc; |
2055 data->uin = g_strdup(text[i*2+2]); | 2056 data->uin = g_strdup(text[i*2+2]); |
2056 data->nick = g_strdup(text[i*2+1]); | 2057 data->nick = g_strdup(text[i*2+1]); |
2057 do_ask_dialog(message, data, gaim_icq_contactadd, gaim_icq_contactdontadd); | 2058 do_ask_dialog(message, "Do you want to add this contact to your Buddy List?", data, _("Add"), gaim_icq_contactadd, _("Deny"), gaim_icq_contactdontadd); |
2058 g_free(message); | 2059 g_free(message); |
2059 } | 2060 } |
2060 g_strfreev(text); | 2061 g_strfreev(text); |
2061 } | 2062 } |
2062 } break; | 2063 } break; |
4321 struct ask_do_dir_im { | 4322 struct ask_do_dir_im { |
4322 char *who; | 4323 char *who; |
4323 struct gaim_connection *gc; | 4324 struct gaim_connection *gc; |
4324 }; | 4325 }; |
4325 | 4326 |
4326 static void oscar_cancel_direct_im(gpointer obj, struct ask_do_dir_im *data) { | 4327 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
4327 g_free(data); | 4328 g_free(data); |
4328 } | 4329 } |
4329 | 4330 |
4330 static void oscar_direct_im(gpointer obj, struct ask_do_dir_im *data) { | 4331 static void oscar_direct_im(struct ask_do_dir_im *data) { |
4331 struct gaim_connection *gc = data->gc; | 4332 struct gaim_connection *gc = data->gc; |
4332 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 4333 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4333 struct direct_im *dim; | 4334 struct direct_im *dim; |
4334 | 4335 |
4335 dim = find_direct_im(od, data->who); | 4336 dim = find_direct_im(od, data->who); |
4364 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { | 4365 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { |
4365 char buf[BUF_LONG]; | 4366 char buf[BUF_LONG]; |
4366 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | 4367 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); |
4367 data->who = who; | 4368 data->who = who; |
4368 data->gc = gc; | 4369 data->gc = gc; |
4369 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s." | 4370 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who); |
4370 " Doing this will let them see your IP address, and may be" | 4371 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); |
4371 " a security risk. Do you wish to continue?"), who); | |
4372 do_ask_dialog(buf, data, oscar_direct_im, oscar_cancel_direct_im); | |
4373 } | 4372 } |
4374 | 4373 |
4375 static void oscar_get_away_msg(struct gaim_connection *gc, char *who) { | 4374 static void oscar_get_away_msg(struct gaim_connection *gc, char *who) { |
4376 struct oscar_data *od = gc->proto_data; | 4375 struct oscar_data *od = gc->proto_data; |
4377 od->evilhack = g_slist_append(od->evilhack, g_strdup(normalize(who))); | 4376 od->evilhack = g_slist_append(od->evilhack, g_strdup(normalize(who))); |