comparison src/protocols/oscar/oscar.c @ 4269:ff0642fab1d5

[gaim-migrate @ 4520] Our cable was out again, so I was left doing dull stuff. I changed the alias_buddy prpl function so that it takes the alias as well as just the buddy name. It seemed silly not to pass the alias to a function that changes the alias. I added a call back for this prpl function in oscar.c. This has the effect of, when you add/change/remove the alias of a buddy, it also changes the alias in the server list. I changed some normalize calls in oscar.c because I think it's better this way. I could be wrong. I added the ability to re-request authorization from contacts that have not authorized you yet. Just right-click on those mofo's. I shuffled some functions around. oscar.c is a little messy. Our cable was out some today. Here's the message they have when you call their customer support: "All high speed data customers in the 919 and 252 area code may experience flashing status lights on their cable modems with inability to access online services at this time." 919 is basically all of Raleigh. I'm going to estimate at least 10,000 people with Time Warner cable. That's a lot of people. Time Warner sucks. This is from a few hours today: "15566 packets transmitted, 598 packets received, +8 duplicates, 96% packet loss" committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 09 Jan 2003 21:21:00 +0000
parents f68c4203d001
children 32fcf4cf5f80
comparison
equal deleted inserted replaced
4268:69d38d5d06dd 4269:ff0642fab1d5
210 g_free(data); 210 g_free(data);
211 } 211 }
212 212
213 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) { 213 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) {
214 GSList *d = od->direct_ims; 214 GSList *d = od->direct_ims;
215 char *n = g_strdup(normalize(who));
216 struct direct_im *m = NULL; 215 struct direct_im *m = NULL;
217 216
218 while (d) { 217 while (d) {
219 m = (struct direct_im *)d->data; 218 m = (struct direct_im *)d->data;
220 if (!strcmp(n, normalize(m->name))) 219 if (aim_sncmp(who, m->name))
221 break; 220 return m;
222 m = NULL;
223 d = d->next; 221 d = d->next;
224 } 222 }
225 223
226 g_free(n); 224 return NULL;
227 return m;
228 } 225 }
229 226
230 static char *extract_name(const char *name) { 227 static char *extract_name(const char *name) {
231 char *tmp, *x; 228 char *tmp, *x;
232 int i, j; 229 int i, j;
1413 struct oscar_data *od = gc->proto_data; 1410 struct oscar_data *od = gc->proto_data;
1414 aim_userinfo_t *info; 1411 aim_userinfo_t *info;
1415 time_t time_idle = 0, signon = 0; 1412 time_t time_idle = 0, signon = 0;
1416 int type = 0; 1413 int type = 0;
1417 int caps = 0; 1414 int caps = 0;
1418 char *tmp;
1419 va_list ap; 1415 va_list ap;
1420 1416
1421 va_start(ap, fr); 1417 va_start(ap, fr);
1422 info = va_arg(ap, aim_userinfo_t *); 1418 info = va_arg(ap, aim_userinfo_t *);
1423 va_end(ap); 1419 va_end(ap);
1458 } 1454 }
1459 1455
1460 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) 1456 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
1461 signon = time(NULL) - info->sessionlen; 1457 signon = time(NULL) - info->sessionlen;
1462 1458
1463 tmp = g_strdup(normalize(gc->username)); 1459 if (!aim_sncmp(gc->username, info->sn))
1464 if (!strcmp(tmp, normalize(info->sn)))
1465 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", info->sn); 1460 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", info->sn);
1466 g_free(tmp);
1467 1461
1468 serv_got_update(gc, info->sn, 1, info->warnlevel/10, signon, 1462 serv_got_update(gc, info->sn, 1, info->warnlevel/10, signon,
1469 time_idle, type, caps); 1463 time_idle, type, caps);
1470 1464
1471 return 1; 1465 return 1;
1794 flags |= IM_FLAG_AWAY; 1788 flags |= IM_FLAG_AWAY;
1795 1789
1796 if (args->icbmflags & AIM_IMFLAGS_HASICON) { 1790 if (args->icbmflags & AIM_IMFLAGS_HASICON) {
1797 struct icon_req *ir = NULL; 1791 struct icon_req *ir = NULL;
1798 GSList *h = od->hasicons; 1792 GSList *h = od->hasicons;
1799 char *who = normalize(userinfo->sn);
1800 1793
1801 if (!args->iconlen || !args->iconsum || !args->iconstamp) 1794 if (!args->iconlen || !args->iconsum || !args->iconstamp)
1802 return 1; 1795 return 1;
1803 1796
1804 debug_printf("%s has an icon\n", userinfo->sn); 1797 debug_printf("%s has an icon\n", userinfo->sn);
1805 while (h) { 1798 while (h) {
1806 ir = h->data; 1799 ir = h->data;
1807 if (!strcmp(ir->user, who)) 1800 if (!aim_sncmp(userinfo->sn, ir->user))
1808 break; 1801 break;
1809 h = h->next; 1802 h = h->next;
1810 } 1803 }
1811 if (!h) { 1804 if (!h) {
1812 ir = g_new0(struct icon_req, 1); 1805 ir = g_new0(struct icon_req, 1);
1813 ir->user = g_strdup(who); 1806 ir->user = g_strdup(normalize(userinfo->sn));
1814 od->hasicons = g_slist_append(od->hasicons, ir); 1807 od->hasicons = g_slist_append(od->hasicons, ir);
1815 } 1808 }
1816 if ((args->iconlen != ir->length) || 1809 if ((args->iconlen != ir->length) ||
1817 (args->iconsum != ir->checksum) || 1810 (args->iconsum != ir->checksum) ||
1818 (args->iconstamp != ir->timestamp)) 1811 (args->iconstamp != ir->timestamp))
2062 /* 2055 /*
2063 * Authorization Functions 2056 * Authorization Functions
2064 * Most of these are callbacks from dialogs. They're used by both 2057 * Most of these are callbacks from dialogs. They're used by both
2065 * methods of authorization (SSI and old-school channel 4 ICBM) 2058 * methods of authorization (SSI and old-school channel 4 ICBM)
2066 */ 2059 */
2060 /* When you ask other people for authorization */
2067 static void gaim_auth_request(struct name_data *data) { 2061 static void gaim_auth_request(struct name_data *data) {
2068 struct gaim_connection *gc = data->gc; 2062 struct gaim_connection *gc = data->gc;
2069 2063
2070 if (g_slist_find(connections, gc)) { 2064 if (g_slist_find(connections, gc)) {
2071 struct oscar_data *od = gc->proto_data; 2065 struct oscar_data *od = gc->proto_data;
2072 struct buddy *buddy = find_buddy(gc, data->name); 2066 struct buddy *buddy = find_buddy(gc, data->name);
2073 struct group *group = find_group_by_buddy(gc, data->name); 2067 struct group *group = find_group_by_buddy(gc, data->name);
2074 if (buddy && group) { 2068 if (buddy && group) {
2075 debug_printf("ssi: adding buddy %s to group %s\n", buddy->name, group->name); 2069 debug_printf("ssi: adding buddy %s to group %s\n", buddy->name, group->name);
2076 aim_ssi_sendauthrequest(od->sess, od->conn, data->name, "Please authorize me so I can add you to my buddy list."); 2070 aim_ssi_sendauthrequest(od->sess, od->conn, data->name, "Please authorize me so I can add you to my buddy list.");
2077 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 1); 2071 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))
2072 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 1);
2078 } 2073 }
2079 } 2074 }
2080 2075
2081 gaim_free_name_data(data); 2076 gaim_free_name_data(data);
2082 } 2077 }
2088 /* struct oscar_data *od = gc->proto_data; */ 2083 /* struct oscar_data *od = gc->proto_data; */
2089 /* XXX - Take the buddy out of our buddy list */ 2084 /* XXX - Take the buddy out of our buddy list */
2090 } 2085 }
2091 2086
2092 gaim_free_name_data(data); 2087 gaim_free_name_data(data);
2088 }
2089
2090 static void gaim_auth_sendrequest(struct gaim_connection *gc, char *name) {
2091 struct name_data *data = g_new(struct name_data, 1);
2092 struct buddy *buddy;
2093 gchar *dialog_msg, *nombre;
2094
2095 buddy = find_buddy(gc, name);
2096 if (buddy && (get_buddy_alias_only(buddy)))
2097 nombre = g_strdup_printf("%s (%s)", name, get_buddy_alias_only(buddy));
2098 else
2099 nombre = g_strdup(name);
2100
2101 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);
2102 data->gc = gc;
2103 data->name = g_strdup(name);
2104 data->nick = NULL;
2105 do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request, _("Cancel"), gaim_auth_dontrequest, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE);
2106
2107 g_free(dialog_msg);
2108 g_free(nombre);
2093 } 2109 }
2094 2110
2095 /* When other people ask you for authorization */ 2111 /* When other people ask you for authorization */
2096 static void gaim_auth_grant(struct name_data *data) { 2112 static void gaim_auth_grant(struct name_data *data) {
2097 struct gaim_connection *gc = data->gc; 2113 struct gaim_connection *gc = data->gc;
2981 2997
2982 return 1; 2998 return 1;
2983 } 2999 }
2984 3000
2985 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { 3001 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) {
3002 struct gaim_connection *gc = sess->aux_data;
2986 va_list ap; 3003 va_list ap;
2987 aim_userinfo_t *info; 3004 aim_userinfo_t *info;
2988 char *msg; 3005 char *msg;
2989 struct gaim_connection *gc = sess->aux_data;
2990 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); 3006 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn);
2991 char *tmp;
2992 3007
2993 va_start(ap, fr); 3008 va_start(ap, fr);
2994 info = va_arg(ap, aim_userinfo_t *); 3009 info = va_arg(ap, aim_userinfo_t *);
2995 msg = va_arg(ap, char *); 3010 msg = va_arg(ap, char *);
2996 va_end(ap); 3011 va_end(ap);
2997 3012
2998 tmp = g_malloc(BUF_LONG); 3013 serv_got_chat_in(gc, ccon->id, info->sn, 0, msg, time((time_t)NULL));
2999 g_snprintf(tmp, BUF_LONG, "%s", msg);
3000 serv_got_chat_in(gc, ccon->id, info->sn, 0, tmp, time((time_t)NULL));
3001 g_free(tmp);
3002 3014
3003 return 1; 3015 return 1;
3004 } 3016 }
3005 3017
3006 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { 3018 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) {
3013 emailinfo = va_arg(ap, struct aim_emailinfo *); 3025 emailinfo = va_arg(ap, struct aim_emailinfo *);
3014 havenewmail = va_arg(ap, int); 3026 havenewmail = va_arg(ap, int);
3015 va_end(ap); 3027 va_end(ap);
3016 3028
3017 if (emailinfo) { 3029 if (emailinfo) {
3018 debug_printf("Got email info. webmail address for screenname@%s is %s, new email: %hhu, number new: %hu, flag is %hu, havenewmail is %d\n", emailinfo->domain, emailinfo->url, emailinfo->unread, emailinfo->nummsgs, emailinfo->flag, havenewmail); 3030 debug_printf("Got email info. domain is %s, webmail is %s, new email: %hhu, number new: %hu, flag is %hu, havenewmail is %d\n", emailinfo->domain, emailinfo->url, emailinfo->unread, emailinfo->nummsgs, emailinfo->flag, havenewmail);
3019 if (emailinfo->unread) { 3031 if (emailinfo->unread) {
3020 if (havenewmail) 3032 if (havenewmail)
3021 connection_has_mail(gc, emailinfo->nummsgs ? emailinfo->nummsgs : -1, NULL, NULL, emailinfo->url); 3033 connection_has_mail(gc, emailinfo->nummsgs ? emailinfo->nummsgs : -1, NULL, NULL, emailinfo->url);
3022 } else 3034 } else
3023 connection_has_mail(gc, 0, NULL, NULL, emailinfo->url); 3035 connection_has_mail(gc, 0, NULL, NULL, emailinfo->url);
3615 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; 3627 struct oscar_data *odata = (struct oscar_data *)gc->proto_data;
3616 struct direct_im *dim = find_direct_im(odata, name); 3628 struct direct_im *dim = find_direct_im(odata, name);
3617 if (dim) 3629 if (dim)
3618 aim_send_typing(odata->sess, dim->conn, typing); 3630 aim_send_typing(odata->sess, dim->conn, typing);
3619 else { 3631 else {
3620 char *who = normalize(name); 3632 if (g_hash_table_lookup(odata->supports_tn, normalize(name))) {
3621 if (g_hash_table_lookup(odata->supports_tn, who)) {
3622 if (typing == TYPING) 3633 if (typing == TYPING)
3623 aim_mtn_send(odata->sess, 0x0001, name, 0x0002); 3634 aim_mtn_send(odata->sess, 0x0001, name, 0x0002);
3624 else if (typing == TYPED) 3635 else if (typing == TYPED)
3625 aim_mtn_send(odata->sess, 0x0001, name, 0x0001); 3636 aim_mtn_send(odata->sess, 0x0001, name, 0x0001);
3626 else 3637 else
3658 GSList *h = odata->hasicons; 3669 GSList *h = odata->hasicons;
3659 struct icon_req *ir = NULL; 3670 struct icon_req *ir = NULL;
3660 char *who = normalize(name); 3671 char *who = normalize(name);
3661 struct stat st; 3672 struct stat st;
3662 int len; 3673 int len;
3663 3674
3664 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; 3675 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES;
3665 if (odata->icq) 3676 if (odata->icq)
3666 args.flags |= AIM_IMFLAGS_OFFLINE; 3677 args.flags |= AIM_IMFLAGS_OFFLINE;
3667 3678
3668 args.features = gaim_features; 3679 args.features = gaim_features;
3669 args.featureslen = sizeof(gaim_features); 3680 args.featureslen = sizeof(gaim_features);
3670 3681
3671 while (h) { 3682 while (h) {
3672 ir = h->data; 3683 ir = h->data;
3673 if (ir->request && !strcmp(who, ir->user)) 3684 if (ir->request && !strcmp(who, ir->user))
3674 break; 3685 break;
3675 h = h->next; 3686 h = h->next;
3677 if (h) { 3688 if (h) {
3678 ir->request = FALSE; 3689 ir->request = FALSE;
3679 args.flags |= AIM_IMFLAGS_BUDDYREQ; 3690 args.flags |= AIM_IMFLAGS_BUDDYREQ;
3680 debug_printf("sending buddy icon request with message\n"); 3691 debug_printf("sending buddy icon request with message\n");
3681 } 3692 }
3682 3693
3683 if (gc->user->iconfile[0] && !stat(gc->user->iconfile, &st)) { 3694 if (gc->user->iconfile[0] && !stat(gc->user->iconfile, &st)) {
3684 FILE *file = fopen(gc->user->iconfile, "r"); 3695 FILE *file = fopen(gc->user->iconfile, "r");
3685 if (file) { 3696 if (file) {
3686 char *buf = g_malloc(st.st_size); 3697 char *buf = g_malloc(st.st_size);
3687 fread(buf, 1, st.st_size, file); 3698 fread(buf, 1, st.st_size, file);
3688 3699
3689 args.iconlen = st.st_size; 3700 args.iconlen = st.st_size;
3690 args.iconsum = aim_iconsum(buf, st.st_size); 3701 args.iconsum = aim_iconsum(buf, st.st_size);
3691 args.iconstamp = st.st_mtime; 3702 args.iconstamp = st.st_mtime;
3692 3703
3693 args.flags |= AIM_IMFLAGS_HASICON; 3704 args.flags |= AIM_IMFLAGS_HASICON;
3695 3706
3696 fclose(file); 3707 fclose(file);
3697 g_free(buf); 3708 g_free(buf);
3698 } 3709 }
3699 } 3710 }
3700 3711
3701 args.destsn = name; 3712 args.destsn = name;
3702 3713
3703 len = strlen(message); 3714 len = strlen(message);
3704 args.flags |= check_encoding(message); 3715 args.flags |= check_encoding(message);
3705 if (args.flags & AIM_IMFLAGS_UNICODE) { 3716 if (args.flags & AIM_IMFLAGS_UNICODE) {
3706 debug_printf("Sending Unicode IM\n"); 3717 debug_printf("Sending Unicode IM\n");
3707 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); 3718 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err);
3726 } 3737 }
3727 } else { 3738 } else {
3728 args.msg = message; 3739 args.msg = message;
3729 } 3740 }
3730 args.msglen = len; 3741 args.msglen = len;
3731 3742
3732 ret = aim_send_im_ext(odata->sess, &args); 3743 ret = aim_send_im_ext(odata->sess, &args);
3733 } 3744 }
3734 if (ret >= 0) 3745 if (ret >= 0)
3735 return 1; 3746 return 1;
3736 return ret; 3747 return ret;
3981 } 3992 }
3982 } 3993 }
3983 #endif 3994 #endif
3984 } 3995 }
3985 3996
3986 #ifndef NOSSI
3987 static void oscar_move_buddy(struct gaim_connection *gc, const char *name, const char *old_group, const char *new_group) {
3988 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
3989 if (od->sess->ssi.received_data) {
3990 debug_printf("ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group);
3991 aim_ssi_movebuddy(od->sess, od->conn, old_group, new_group, name);
3992 }
3993 }
3994 #endif
3995
3996 static void oscar_remove_buddy(struct gaim_connection *gc, char *name, char *group) { 3997 static void oscar_remove_buddy(struct gaim_connection *gc, char *name, char *group) {
3997 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 3998 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
3998 #ifdef NOSSI 3999 #ifdef NOSSI
3999 aim_remove_buddy(od->sess, od->conn, name); 4000 aim_remove_buddy(od->sess, od->conn, name);
4000 #else 4001 #else
4021 } 4022 }
4022 #endif 4023 #endif
4023 } 4024 }
4024 4025
4025 #ifndef NOSSI 4026 #ifndef NOSSI
4027 static void oscar_move_buddy(struct gaim_connection *gc, const char *name, const char *old_group, const char *new_group) {
4028 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
4029 if (od->sess->ssi.received_data) {
4030 debug_printf("ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group);
4031 aim_ssi_movebuddy(od->sess, od->conn, old_group, new_group, name);
4032 }
4033 }
4034
4035 static void oscar_alias_buddy(struct gaim_connection *gc, const char *name, const char *alias) {
4036 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
4037 if (od->sess->ssi.received_data) {
4038 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name);
4039 if (gname) {
4040 debug_printf("ssi: changing the alias for buddy %s to %s\n", name, alias);
4041 aim_ssi_aliasbuddy(od->sess, od->conn, gname, name, alias);
4042 }
4043 }
4044 }
4045
4026 static void oscar_rename_group(struct gaim_connection *g, const char *old_group, const char *new_group, GList *members) { 4046 static void oscar_rename_group(struct gaim_connection *g, const char *old_group, const char *new_group, GList *members) {
4027 struct oscar_data *od = (struct oscar_data *)g->proto_data; 4047 struct oscar_data *od = (struct oscar_data *)g->proto_data;
4028 4048
4029 if (od->sess->ssi.received_data) { 4049 if (od->sess->ssi.received_data) {
4030 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { 4050 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) {
4104 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname); 4124 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname);
4105 add_buddy(gc, (gname ? gname : "orphans"), curitem->name, alias); 4125 add_buddy(gc, (gname ? gname : "orphans"), curitem->name, alias);
4106 free(alias); 4126 free(alias);
4107 tmp++; 4127 tmp++;
4108 } 4128 }
4109 if (curitem->name && gname && aim_ssi_waitingforauth(sess->ssi.local, gname, curitem->name)) { 4129 if (curitem->name && gname && aim_ssi_waitingforauth(sess->ssi.local, gname, curitem->name))
4110 struct name_data *data = g_new(struct name_data, 1); 4130 gaim_auth_sendrequest(gc, curitem->name);
4111 gchar *dialog_msg, *nombre;
4112 struct buddy *buddy;
4113
4114 buddy = find_buddy(gc, curitem->name);
4115 if (buddy && (get_buddy_alias_only(buddy)))
4116 nombre = g_strdup_printf("%s (%s)", curitem->name, get_buddy_alias_only(buddy));
4117 else
4118 nombre = g_strdup(curitem->name);
4119
4120 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);
4121 data->gc = gc;
4122 data->name = g_strdup(curitem->name);
4123 data->nick = NULL;
4124 do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request, _("Cancel"), gaim_auth_dontrequest, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE);
4125
4126 g_free(dialog_msg);
4127 g_free(nombre);
4128 }
4129 4131
4130 } 4132 }
4131 } break; 4133 } break;
4132 4134
4133 case 0x0001: { /* Group */ 4135 case 0x0001: { /* Group */
4241 4243
4242 } /* end if (gc) */ 4244 } /* end if (gc) */
4243 4245
4244 return 1; 4246 return 1;
4245 } 4247 }
4246 #endif
4247 4248
4248 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { 4249 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) {
4249 struct gaim_connection *gc = sess->aux_data; 4250 struct gaim_connection *gc = sess->aux_data;
4250 va_list ap; 4251 va_list ap;
4251 struct aim_ssi_tmp *retval; 4252 struct aim_ssi_tmp *retval;
4261 switch (retval->ack) { 4262 switch (retval->ack) {
4262 case 0x0000: { /* added successfully */ 4263 case 0x0000: { /* added successfully */
4263 } break; 4264 } break;
4264 4265
4265 case 0x000e: { /* contact requires authorization */ 4266 case 0x000e: { /* contact requires authorization */
4266 if (retval->action == AIM_CB_SSI_ADD) { 4267 if (retval->action == AIM_CB_SSI_ADD)
4267 struct name_data *data = g_new(struct name_data, 1); 4268 gaim_auth_sendrequest(gc, retval->name);
4268 struct buddy *buddy;
4269 gchar *dialog_msg, *nombre;
4270
4271 buddy = find_buddy(gc, retval->name);
4272 if (buddy && (get_buddy_alias_only(buddy)))
4273 nombre = g_strdup_printf("%s (%s)", retval->name, get_buddy_alias_only(buddy));
4274 else
4275 nombre = g_strdup(retval->name);
4276
4277 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);
4278 data->gc = gc;
4279 data->name = g_strdup(retval->name);
4280 data->nick = NULL;
4281 do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request, _("Cancel"), gaim_auth_dontrequest, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE);
4282
4283 g_free(dialog_msg);
4284 g_free(nombre);
4285 }
4286 } break; 4269 } break;
4287 4270
4288 default: { /* La la la */ 4271 default: { /* La la la */
4289 debug_printf("ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); 4272 debug_printf("ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack);
4290 /* Should remove buddy from local list and give an error message? */ 4273 /* Should remove buddy from local list and give an error message? */
4416 debug_printf("ssi: %s added you to their buddy list\n", sn); 4399 debug_printf("ssi: %s added you to their buddy list\n", sn);
4417 show_got_added(gc, NULL, sn, (buddy ? get_buddy_alias_only(buddy) : NULL), NULL); 4400 show_got_added(gc, NULL, sn, (buddy ? get_buddy_alias_only(buddy) : NULL), NULL);
4418 4401
4419 return 1; 4402 return 1;
4420 } 4403 }
4404 #endif
4421 4405
4422 static GList *oscar_chat_info(struct gaim_connection *gc) { 4406 static GList *oscar_chat_info(struct gaim_connection *gc) {
4423 GList *m = NULL; 4407 GList *m = NULL;
4424 struct proto_chat_entry *pce; 4408 struct proto_chat_entry *pce;
4425 4409
4901 } else 4885 } else
4902 oscar_get_info(gc, who); 4886 oscar_get_info(gc, who);
4903 } 4887 }
4904 4888
4905 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) { 4889 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) {
4890 struct oscar_data *od = gc->proto_data;
4906 GList *m = NULL; 4891 GList *m = NULL;
4907 struct proto_buddy_menu *pbm; 4892 struct proto_buddy_menu *pbm;
4908 char *n = g_strdup(normalize(gc->username));
4909 struct oscar_data *odata = gc->proto_data;
4910 4893
4911 pbm = g_new0(struct proto_buddy_menu, 1); 4894 pbm = g_new0(struct proto_buddy_menu, 1);
4912 pbm->label = _("Get Info"); 4895 pbm->label = _("Get Info");
4913 pbm->callback = oscar_get_info; 4896 pbm->callback = oscar_get_info;
4914 pbm->gc = gc; 4897 pbm->gc = gc;
4915 m = g_list_append(m, pbm); 4898 m = g_list_append(m, pbm);
4916 4899
4917 if (odata->icq) { 4900 if (od->icq) {
4918 pbm = g_new0(struct proto_buddy_menu, 1); 4901 pbm = g_new0(struct proto_buddy_menu, 1);
4919 pbm->label = _("Get Status Msg"); 4902 pbm->label = _("Get Status Msg");
4920 pbm->callback = oscar_get_away_msg; 4903 pbm->callback = oscar_get_away_msg;
4921 pbm->gc = gc; 4904 pbm->gc = gc;
4922 m = g_list_append(m, pbm); 4905 m = g_list_append(m, pbm);
4925 pbm->label = _("Get Away Msg"); 4908 pbm->label = _("Get Away Msg");
4926 pbm->callback = oscar_get_away_msg; 4909 pbm->callback = oscar_get_away_msg;
4927 pbm->gc = gc; 4910 pbm->gc = gc;
4928 m = g_list_append(m, pbm); 4911 m = g_list_append(m, pbm);
4929 4912
4930 if (strcmp(n, normalize(who))) { 4913 if (aim_sncmp(gc->username, who)) {
4931 pbm = g_new0(struct proto_buddy_menu, 1); 4914 pbm = g_new0(struct proto_buddy_menu, 1);
4932 pbm->label = _("Direct IM"); 4915 pbm->label = _("Direct IM");
4933 pbm->callback = oscar_ask_direct_im; 4916 pbm->callback = oscar_ask_direct_im;
4934 pbm->gc = gc; 4917 pbm->gc = gc;
4935 m = g_list_append(m, pbm); 4918 m = g_list_append(m, pbm);
4946 pbm->label = _("Get Capabilities"); 4929 pbm->label = _("Get Capabilities");
4947 pbm->callback = oscar_get_caps; 4930 pbm->callback = oscar_get_caps;
4948 pbm->gc = gc; 4931 pbm->gc = gc;
4949 m = g_list_append(m, pbm); 4932 m = g_list_append(m, pbm);
4950 4933
4951 g_free(n);
4952
4953 return m; 4934 return m;
4954 } 4935 }
4955 4936
4956 static GList *oscar_edit_buddy_menu(struct gaim_connection *gc, char *who) 4937 static GList *oscar_edit_buddy_menu(struct gaim_connection *gc, char *who)
4957 { 4938 {
4939 struct oscar_data *od = gc->proto_data;
4958 GList *m = NULL; 4940 GList *m = NULL;
4959 struct proto_buddy_menu *pbm; 4941 struct proto_buddy_menu *pbm;
4960 struct oscar_data *odata = gc->proto_data; 4942
4961 4943 if (od->icq) {
4962 if (odata->icq) {
4963 pbm = g_new0(struct proto_buddy_menu, 1); 4944 pbm = g_new0(struct proto_buddy_menu, 1);
4964 pbm->label = _("Get Info"); 4945 pbm->label = _("Get Info");
4965 pbm->callback = oscar_get_info; 4946 pbm->callback = oscar_get_info;
4966 pbm->gc = gc; 4947 pbm->gc = gc;
4967 m = g_list_append(m, pbm); 4948 m = g_list_append(m, pbm);
4949
4950 if (od->sess->ssi.received_data) {
4951 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who);
4952 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) {
4953 pbm = g_new0(struct proto_buddy_menu, 1);
4954 pbm->label = _("Re-Request Authorization");
4955 pbm->callback = gaim_auth_sendrequest;
4956 pbm->gc = gc;
4957 m = g_list_append(m, pbm);
4958 }
4959 }
4968 } 4960 }
4969 4961
4970 return m; 4962 return m;
4971 } 4963 }
4972 4964
5024 aim_ssi_setpermdeny(od->sess, od->conn, gc->permdeny, 0xffffffff); 5016 aim_ssi_setpermdeny(od->sess, od->conn, gc->permdeny, 0xffffffff);
5025 #endif 5017 #endif
5026 } 5018 }
5027 5019
5028 static void oscar_add_permit(struct gaim_connection *gc, char *who) { 5020 static void oscar_add_permit(struct gaim_connection *gc, char *who) {
5021 #ifdef NOSSI
5022 if (gc->permdeny == 3)
5023 oscar_set_permit_deny(gc);
5024 #else
5029 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 5025 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
5030 #ifdef NOSSI
5031 if (gc->permdeny != 3) return;
5032 oscar_set_permit_deny(gc);
5033 #else
5034 debug_printf("ssi: About to add a permit\n"); 5026 debug_printf("ssi: About to add a permit\n");
5035 if (od->sess->ssi.received_data) 5027 if (od->sess->ssi.received_data)
5036 aim_ssi_addpermit(od->sess, od->conn, who); 5028 aim_ssi_addpermit(od->sess, od->conn, who);
5037 #endif 5029 #endif
5038 } 5030 }
5039 5031
5040 static void oscar_add_deny(struct gaim_connection *gc, char *who) { 5032 static void oscar_add_deny(struct gaim_connection *gc, char *who) {
5033 #ifdef NOSSI
5034 if (gc->permdeny == 4)
5035 oscar_set_permit_deny(gc);
5036 #else
5041 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 5037 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
5042 #ifdef NOSSI
5043 if (gc->permdeny != 4) return;
5044 oscar_set_permit_deny(gc);
5045 #else
5046 debug_printf("ssi: About to add a deny\n"); 5038 debug_printf("ssi: About to add a deny\n");
5047 if (od->sess->ssi.received_data) 5039 if (od->sess->ssi.received_data)
5048 aim_ssi_adddeny(od->sess, od->conn, who); 5040 aim_ssi_adddeny(od->sess, od->conn, who);
5049 #endif 5041 #endif
5050 } 5042 }
5051 5043
5052 static void oscar_rem_permit(struct gaim_connection *gc, char *who) { 5044 static void oscar_rem_permit(struct gaim_connection *gc, char *who) {
5045 #ifdef NOSSI
5046 if (gc->permdeny == 3)
5047 oscar_set_permit_deny(gc);
5048 #else
5053 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 5049 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
5054 #ifdef NOSSI
5055 if (gc->permdeny != 3) return;
5056 oscar_set_permit_deny(gc);
5057 #else
5058 debug_printf("ssi: About to delete a permit\n"); 5050 debug_printf("ssi: About to delete a permit\n");
5059 if (od->sess->ssi.received_data) 5051 if (od->sess->ssi.received_data)
5060 aim_ssi_delpermit(od->sess, od->conn, who); 5052 aim_ssi_delpermit(od->sess, od->conn, who);
5061 #endif 5053 #endif
5062 } 5054 }
5063 5055
5064 static void oscar_rem_deny(struct gaim_connection *gc, char *who) { 5056 static void oscar_rem_deny(struct gaim_connection *gc, char *who) {
5057 #ifdef NOSSI
5058 if (gc->permdeny == 4)
5059 oscar_set_permit_deny(gc);
5060 #else
5065 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 5061 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
5066 #ifdef NOSSI
5067 if (gc->permdeny != 4) return;
5068 oscar_set_permit_deny(gc);
5069 #else
5070 debug_printf("ssi: About to delete a deny\n"); 5062 debug_printf("ssi: About to delete a deny\n");
5071 if (od->sess->ssi.received_data) 5063 if (od->sess->ssi.received_data)
5072 aim_ssi_deldeny(od->sess, od->conn, who); 5064 aim_ssi_deldeny(od->sess, od->conn, who);
5073 #endif 5065 #endif
5074 } 5066 }
5106 } 5098 }
5107 } 5099 }
5108 5100
5109 static void oscar_format_screenname(struct gaim_connection *gc, char *nick) { 5101 static void oscar_format_screenname(struct gaim_connection *gc, char *nick) {
5110 struct oscar_data *od = gc->proto_data; 5102 struct oscar_data *od = gc->proto_data;
5111 if (!strcmp(normalize(nick), normalize(gc->username))) { 5103 if (!aim_sncmp(gc->username, nick)) {
5112 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { 5104 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) {
5113 od->setnick = TRUE; 5105 od->setnick = TRUE;
5114 od->newsn = g_strdup(nick); 5106 od->newsn = g_strdup(nick);
5115 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); 5107 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH);
5116 } else { 5108 } else {
5280 ret->dir_search = oscar_dir_search; 5272 ret->dir_search = oscar_dir_search;
5281 ret->set_idle = oscar_set_idle; 5273 ret->set_idle = oscar_set_idle;
5282 ret->change_passwd = oscar_change_passwd; 5274 ret->change_passwd = oscar_change_passwd;
5283 ret->add_buddy = oscar_add_buddy; 5275 ret->add_buddy = oscar_add_buddy;
5284 ret->add_buddies = oscar_add_buddies; 5276 ret->add_buddies = oscar_add_buddies;
5277 ret->remove_buddy = oscar_remove_buddy;
5278 ret->remove_buddies = oscar_remove_buddies;
5285 #ifndef NOSSI 5279 #ifndef NOSSI
5286 ret->group_buddy = oscar_move_buddy; 5280 ret->group_buddy = oscar_move_buddy;
5281 ret->alias_buddy = oscar_alias_buddy;
5287 ret->rename_group = oscar_rename_group; 5282 ret->rename_group = oscar_rename_group;
5288 #endif 5283 #endif
5284 ret->add_permit = oscar_add_permit;
5285 ret->add_deny = oscar_add_deny;
5286 ret->rem_permit = oscar_rem_permit;
5287 ret->rem_deny = oscar_rem_deny;
5288 ret->set_permit_deny = oscar_set_permit_deny;
5289 ret->file_transfer_cancel = oscar_file_transfer_cancel; 5289 ret->file_transfer_cancel = oscar_file_transfer_cancel;
5290 ret->file_transfer_in = oscar_file_transfer_in; 5290 ret->file_transfer_in = oscar_file_transfer_in;
5291 ret->file_transfer_out = oscar_file_transfer_out; 5291 ret->file_transfer_out = oscar_file_transfer_out;
5292 ret->file_transfer_data_chunk = oscar_file_transfer_data_chunk; 5292 ret->file_transfer_data_chunk = oscar_file_transfer_data_chunk;
5293 ret->file_transfer_nextfile = oscar_file_transfer_nextfile; 5293 ret->file_transfer_nextfile = oscar_file_transfer_nextfile;
5294 ret->file_transfer_done = oscar_file_transfer_done; 5294 ret->file_transfer_done = oscar_file_transfer_done;
5295 ret->remove_buddy = oscar_remove_buddy;
5296 ret->remove_buddies = oscar_remove_buddies;
5297 ret->add_permit = oscar_add_permit;
5298 ret->add_deny = oscar_add_deny;
5299 ret->rem_permit = oscar_rem_permit;
5300 ret->rem_deny = oscar_rem_deny;
5301 ret->set_permit_deny = oscar_set_permit_deny;
5302 ret->warn = oscar_warn; 5295 ret->warn = oscar_warn;
5303 ret->chat_info = oscar_chat_info; 5296 ret->chat_info = oscar_chat_info;
5304 ret->join_chat = oscar_join_chat; 5297 ret->join_chat = oscar_join_chat;
5305 ret->chat_invite = oscar_chat_invite; 5298 ret->chat_invite = oscar_chat_invite;
5306 ret->chat_leave = oscar_chat_leave; 5299 ret->chat_leave = oscar_chat_leave;