comparison src/protocols/oscar/oscar.c @ 4337:368b75c4092f

[gaim-migrate @ 4601] Uh, so now you can have custom authorization request and authorization denied messages. Yay. Also, if you deny authorization but cancel the text input box, it ignores the authorization request. This is the same as just clicking on "ignore" in Windows ICQ. I should have done this sooner. It was a lot easier than I thought. King Missle is weird... Also, I like this teddy bear. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 18 Jan 2003 04:20:36 +0000
parents 446293c92da3
children 051265d35a36
comparison
equal deleted inserted replaced
4336:446293c92da3 4337:368b75c4092f
2056 * Authorization Functions 2056 * Authorization Functions
2057 * 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
2058 * methods of authorization (SSI and old-school channel 4 ICBM) 2058 * methods of authorization (SSI and old-school channel 4 ICBM)
2059 */ 2059 */
2060 /* When you ask other people for authorization */ 2060 /* When you ask other people for authorization */
2061 static void gaim_auth_request(struct name_data *data) { 2061 static void gaim_auth_request(struct name_data *data, char *msg) {
2062 struct gaim_connection *gc = data->gc; 2062 struct gaim_connection *gc = data->gc;
2063 2063
2064 if (g_slist_find(connections, gc)) { 2064 if (g_slist_find(connections, gc)) {
2065 struct oscar_data *od = gc->proto_data; 2065 struct oscar_data *od = gc->proto_data;
2066 struct buddy *buddy = find_buddy(gc, data->name); 2066 struct buddy *buddy = find_buddy(gc, data->name);
2067 struct group *group = find_group_by_buddy(gc, data->name); 2067 struct group *group = find_group_by_buddy(gc, data->name);
2068 if (buddy && group) { 2068 if (buddy && group) {
2069 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);
2070 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, msg ? msg : _("Please authorize me so I can add you to my buddy list."));
2071 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) 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); 2072 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 1);
2073 } 2073 }
2074 } 2074 }
2075 2075 }
2076 gaim_free_name_data(data); 2076
2077 static void gaim_auth_request_msgprompt(struct name_data *data) {
2078 do_prompt_dialog(_("Authorization Request Message:"), _("Please authorize me!"), data, gaim_auth_request, gaim_free_name_data);
2077 } 2079 }
2078 2080
2079 static void gaim_auth_dontrequest(struct name_data *data) { 2081 static void gaim_auth_dontrequest(struct name_data *data) {
2080 struct gaim_connection *gc = data->gc; 2082 struct gaim_connection *gc = data->gc;
2081 2083
2100 2102
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); 2103 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; 2104 data->gc = gc;
2103 data->name = g_strdup(name); 2105 data->name = g_strdup(name);
2104 data->nick = NULL; 2106 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); 2107 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);
2106 2108
2107 g_free(dialog_msg); 2109 g_free(dialog_msg);
2108 g_free(nombre); 2110 g_free(nombre);
2109 } 2111 }
2110 2112
2128 2130
2129 gaim_free_name_data(data); 2131 gaim_free_name_data(data);
2130 } 2132 }
2131 2133
2132 /* When other people ask you for authorization */ 2134 /* When other people ask you for authorization */
2133 static void gaim_auth_dontgrant(struct name_data *data) { 2135 static void gaim_auth_dontgrant(struct name_data *data, char *msg) {
2134 struct gaim_connection *gc = data->gc; 2136 struct gaim_connection *gc = data->gc;
2135 2137
2136 if (g_slist_find(connections, gc)) { 2138 if (g_slist_find(connections, gc)) {
2137 struct oscar_data *od = gc->proto_data; 2139 struct oscar_data *od = gc->proto_data;
2138 gchar *message;
2139 message = g_strdup_printf(_("No reason given."));
2140 #ifdef NOSSI 2140 #ifdef NOSSI
2141 aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, message); 2141 aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given."));
2142 #else 2142 #else
2143 aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x00, message); 2143 aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x00, msg ? msg : _("No reason given."));
2144 #endif 2144 #endif
2145 g_free(message); 2145 }
2146 } 2146 }
2147 2147
2148 gaim_free_name_data(data); 2148 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) {
2149 do_prompt_dialog(_("Authorization Denied Message:"), _("No reason given."), data, gaim_auth_dontgrant, gaim_free_name_data);
2149 } 2150 }
2150 2151
2151 /* When someone sends you contacts */ 2152 /* When someone sends you contacts */
2152 static void gaim_icq_contactadd(struct name_data *data) { 2153 static void gaim_icq_contactadd(struct name_data *data) {
2153 struct gaim_connection *gc = data->gc; 2154 struct gaim_connection *gc = data->gc;
2206 } break; 2207 } break;
2207 2208
2208 case 0x06: { /* Someone requested authorization */ 2209 case 0x06: { /* Someone requested authorization */
2209 if (i >= 6) { 2210 if (i >= 6) {
2210 struct name_data *data = g_new(struct name_data, 1); 2211 struct name_data *data = g_new(struct name_data, 1);
2211 gchar *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason: %s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); 2212 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."));
2212 debug_printf("Received an authorization request from UIN %lu\n", args->uin); 2213 debug_printf("Received an authorization request from UIN %lu\n", args->uin);
2213 data->gc = gc; 2214 data->gc = gc;
2214 data->name = g_strdup_printf("%lu", args->uin); 2215 data->name = g_strdup_printf("%lu", args->uin);
2215 data->nick = NULL; 2216 data->nick = NULL;
2216 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 2217 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);
2217 g_free(dialog_msg); 2218 g_free(dialog_msg);
2218 } 2219 }
2219 } break; 2220 } break;
2220 2221
2221 case 0x07: { /* Someone has denied you authorization */ 2222 case 0x07: { /* Someone has denied you authorization */
4356 if (buddy && (get_buddy_alias_only(buddy))) 4357 if (buddy && (get_buddy_alias_only(buddy)))
4357 nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy)); 4358 nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy));
4358 else 4359 else
4359 nombre = g_strdup(sn); 4360 nombre = g_strdup(sn);
4360 4361
4361 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason: %s"), nombre, msg ? msg : _("No reason given.")); 4362 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."));
4362 data = g_new(struct name_data, 1); 4363 data = g_new(struct name_data, 1);
4363 data->gc = gc; 4364 data->gc = gc;
4364 data->name = g_strdup(sn); 4365 data->name = g_strdup(sn);
4365 data->nick = NULL; 4366 data->nick = NULL;
4366 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 4367 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);
4367 4368
4368 g_free(dialog_msg); 4369 g_free(dialog_msg);
4369 g_free(nombre); 4370 g_free(nombre);
4370 4371
4371 return 1; 4372 return 1;
5188 struct buddy *buddy = curb->data; 5189 struct buddy *buddy = curb->data;
5189 if (aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { 5190 if (aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) {
5190 if (get_buddy_alias_only(buddy)) 5191 if (get_buddy_alias_only(buddy))
5191 nombre = g_strdup_printf(" %s (%s)", buddy->name, get_buddy_alias_only(buddy)); 5192 nombre = g_strdup_printf(" %s (%s)", buddy->name, get_buddy_alias_only(buddy));
5192 else 5193 else
5193 nombre = g_strdup(buddy->name); 5194 nombre = g_strdup_printf(" %s", buddy->name);
5194 tmp = g_strdup_printf("%s<BR>%s", text, nombre); 5195 tmp = g_strdup_printf("%s<BR>%s", text, nombre);
5195 g_free(text); 5196 g_free(text);
5196 text = tmp; 5197 text = tmp;
5197 g_free(nombre); 5198 g_free(nombre);
5198 num++; 5199 num++;