comparison src/protocols/jabber/jabber.c @ 5136:381da05cb5ed

[gaim-migrate @ 5500] this started out as simply adding an option to right-click on a jabber buddy and re-request authorization. Then I ended up chasing the disgusting mess of const vs non-const parameters all over gaim. The end result is that you can now right-click on jabber buddies and re-request auth like you can for ICQ. Also, a lot more things are const that should be, I fixed a bug or two, and I cleaned up one of my least favorite functions in gaim (linkify_text). It is now decidedly less evil. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 15 Apr 2003 04:18:00 +0000
parents 102135caa225
children 376349b04123
comparison
equal deleted inserted replaced
5135:102135caa225 5136:381da05cb5ed
1020 } 1020 }
1021 1021
1022 /* 1022 /*
1023 * Return pointer to jabber_buddy_data if buddy found. Create if necessary. 1023 * Return pointer to jabber_buddy_data if buddy found. Create if necessary.
1024 */ 1024 */
1025 static struct jabber_buddy_data* jabber_find_buddy(struct gaim_connection *gc, char *buddy, gboolean create) 1025 static struct jabber_buddy_data* jabber_find_buddy(struct gaim_connection *gc, const char *buddy, gboolean create)
1026 { 1026 {
1027 struct jabber_data *jd = gc->proto_data; 1027 struct jabber_data *jd = gc->proto_data;
1028 gpointer val; 1028 gpointer val;
1029 char *realwho; 1029 char *realwho;
1030 1030
1050 /* 1050 /*
1051 * find a resource by name, or if no name given, return the "default" resource 1051 * find a resource by name, or if no name given, return the "default" resource
1052 * default being the highest priority one. 1052 * default being the highest priority one.
1053 */ 1053 */
1054 1054
1055 static jab_res_info jabber_find_resource(struct gaim_connection *gc, char *who) 1055 static jab_res_info jabber_find_resource(struct gaim_connection *gc, const char *who)
1056 { 1056 {
1057 GSList *resources; 1057 GSList *resources;
1058 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, who, FALSE); 1058 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, who, FALSE);
1059 jab_res_info jri = NULL; 1059 jab_res_info jri = NULL;
1060 char *res = strstr(who, "/"); 1060 char *res = strstr(who, "/");
1210 1210
1211 jri->thread_id = g_strdup(thread_id); 1211 jri->thread_id = g_strdup(thread_id);
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 static char *jabber_get_convo_thread(gjconn gjc, char *name) 1215 static char *jabber_get_convo_thread(gjconn gjc, const char *name)
1216 { 1216 {
1217 char *ct = NULL; 1217 char *ct = NULL;
1218 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), name); 1218 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), name);
1219 1219
1220 if(jri) { 1220 if(jri) {
2441 } 2441 }
2442 } 2442 }
2443 g_free(xhtml); 2443 g_free(xhtml);
2444 } 2444 }
2445 2445
2446 static int jabber_send_im(struct gaim_connection *gc, char *who, char *message, int len, int flags) 2446 static int jabber_send_im(struct gaim_connection *gc, const char *who, const char *message, int len, int flags)
2447 { 2447 {
2448 xmlnode x, y; 2448 xmlnode x, y;
2449 char *thread_id = NULL; 2449 char *thread_id = NULL;
2450 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc; 2450 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
2451 jab_res_info jri = jabber_find_resource(gc, who); 2451 jab_res_info jri = jabber_find_resource(gc, who);
2684 #endif 2684 #endif
2685 2685
2686 /* 2686 /*
2687 * Unsubscribe a buddy from our presence 2687 * Unsubscribe a buddy from our presence
2688 */ 2688 */
2689 static void jabber_unsubscribe_buddy_from_us(struct gaim_connection *gc, char *name) 2689 static void jabber_unsubscribe_buddy_from_us(struct gaim_connection *gc, const char *name)
2690 { 2690 {
2691 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc; 2691 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
2692 char *realwho; 2692 char *realwho;
2693 2693
2694 if((realwho = get_realwho(gjc, name, FALSE, NULL)) != NULL) { 2694 if((realwho = get_realwho(gjc, name, FALSE, NULL)) != NULL) {
2701 } 2701 }
2702 2702
2703 /* 2703 /*
2704 * Common code for setting ourselves invisible/visible to buddy 2704 * Common code for setting ourselves invisible/visible to buddy
2705 */ 2705 */
2706 static void jabber_invisible_to_buddy_common(struct gaim_connection *gc, char *name, gboolean invisible) 2706 static void jabber_invisible_to_buddy_common(struct gaim_connection *gc, const char *name, gboolean invisible)
2707 { 2707 {
2708 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc; 2708 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
2709 char *realwho; 2709 char *realwho;
2710 2710
2711 if((realwho = get_realwho(gjc, name, FALSE, NULL)) != NULL) { 2711 if((realwho = get_realwho(gjc, name, FALSE, NULL)) != NULL) {
2733 } 2733 }
2734 2734
2735 /* 2735 /*
2736 * Make ourselves temporarily invisible to a buddy 2736 * Make ourselves temporarily invisible to a buddy
2737 */ 2737 */
2738 static void jabber_invisible_to_buddy(struct gaim_connection *gc, char *name) 2738 static void jabber_invisible_to_buddy(struct gaim_connection *gc, const char *name)
2739 { 2739 {
2740 jabber_invisible_to_buddy_common(gc, name, TRUE); 2740 jabber_invisible_to_buddy_common(gc, name, TRUE);
2741 } 2741 }
2742 2742
2743 /* 2743 /*
2744 * Make ourselves visible to a buddy 2744 * Make ourselves visible to a buddy
2745 */ 2745 */
2746 static void jabber_visible_to_buddy(struct gaim_connection *gc, char *name) 2746 static void jabber_visible_to_buddy(struct gaim_connection *gc, const char *name)
2747 { 2747 {
2748 jabber_invisible_to_buddy_common(gc, name, FALSE); 2748 jabber_invisible_to_buddy_common(gc, name, FALSE);
2749 } 2749 }
2750 2750
2751 /* 2751 /*
3101 3101
3102 return buf; 3102 return buf;
3103 } 3103 }
3104 } 3104 }
3105 3105
3106 static void jabber_get_info(struct gaim_connection *gc, char *who) { 3106 static void jabber_get_info(struct gaim_connection *gc, const char *who) {
3107 xmlnode x; 3107 xmlnode x;
3108 char *id; 3108 char *id;
3109 char *realwho; 3109 char *realwho;
3110 struct jabber_data *jd = gc->proto_data; 3110 struct jabber_data *jd = gc->proto_data;
3111 gjconn gjc = jd->gjc; 3111 gjconn gjc = jd->gjc;
3126 gjab_send(gjc, x); 3126 gjab_send(gjc, x);
3127 3127
3128 xmlnode_free(x); 3128 xmlnode_free(x);
3129 } 3129 }
3130 3130
3131 static void jabber_get_error_msg(struct gaim_connection *gc, char *who) { 3131 static void jabber_get_error_msg(struct gaim_connection *gc, const char *who) {
3132 struct jabber_data *jd = gc->proto_data; 3132 struct jabber_data *jd = gc->proto_data;
3133 gjconn gjc = jd->gjc; 3133 gjconn gjc = jd->gjc;
3134 gchar **str_arr = (gchar **) g_new(gpointer, 3); 3134 gchar **str_arr = (gchar **) g_new(gpointer, 3);
3135 gchar **ap = str_arr; 3135 gchar **ap = str_arr;
3136 gchar *realwho, *final; 3136 gchar *realwho, *final;
3154 g_show_info_text(gc, realwho, 2, final, NULL); 3154 g_show_info_text(gc, realwho, 2, final, NULL);
3155 g_free(realwho); 3155 g_free(realwho);
3156 g_free(final); 3156 g_free(final);
3157 } 3157 }
3158 3158
3159 static void jabber_get_away_msg(struct gaim_connection *gc, char *who) { 3159 static void jabber_get_away_msg(struct gaim_connection *gc, const char *who) {
3160 struct jabber_data *jd = gc->proto_data; 3160 struct jabber_data *jd = gc->proto_data;
3161 gjconn gjc = jd->gjc; 3161 gjconn gjc = jd->gjc;
3162 int num_resources; 3162 int num_resources;
3163 gaim_jid gjid; 3163 gaim_jid gjid;
3164 char *buddy = get_realwho(gjc, who, FALSE, &gjid); 3164 char *buddy = get_realwho(gjc, who, FALSE, &gjid);
3259 3259
3260 if(stripped) { 3260 if(stripped) {
3261 g_free(stripped); 3261 g_free(stripped);
3262 g_free(text); 3262 g_free(text);
3263 } 3263 }
3264 } else if(jbd && (jbd->subscription & JABBER_SUB_PENDING || 3264 } else if(jbd && !GAIM_BUDDY_IS_ONLINE(b) &&
3265 (jbd->subscription & JABBER_SUB_PENDING ||
3265 !(jbd->subscription & JABBER_SUB_TO))) { 3266 !(jbd->subscription & JABBER_SUB_TO))) {
3266 ret = g_strdup(_("<b>Status:</b> Not Authorized")); 3267 ret = g_strdup(_("<b>Status:</b> Not Authorized"));
3267 } 3268 }
3268 return ret; 3269 return ret;
3269 } 3270 }
3280 if(jri) 3281 if(jri)
3281 stripped = g_strdup(jabber_get_state_string(jri->state)); 3282 stripped = g_strdup(jabber_get_state_string(jri->state));
3282 } 3283 }
3283 ret = g_markup_escape_text(stripped, strlen(stripped)); 3284 ret = g_markup_escape_text(stripped, strlen(stripped));
3284 g_free(stripped); 3285 g_free(stripped);
3285 } else if(jbd && (jbd->subscription & JABBER_SUB_PENDING || 3286 } else if(jbd && !GAIM_BUDDY_IS_ONLINE(b) &&
3287 (jbd->subscription & JABBER_SUB_PENDING ||
3286 !(jbd->subscription & JABBER_SUB_TO))) { 3288 !(jbd->subscription & JABBER_SUB_TO))) {
3287 ret = g_strdup(_("Not Authorized")); 3289 ret = g_strdup(_("Not Authorized"));
3288 } 3290 }
3289 return ret; 3291 return ret;
3290 } 3292 }
3291 3293
3292 static GList *jabber_buddy_menu(struct gaim_connection *gc, char *who) { 3294 static GList *jabber_buddy_menu(struct gaim_connection *gc, const char *who) {
3293 GList *m = NULL; 3295 GList *m = NULL;
3294 struct proto_buddy_menu *pbm; 3296 struct proto_buddy_menu *pbm;
3295 struct buddy *b = gaim_find_buddy(gc->account, who); 3297 struct buddy *b = gaim_find_buddy(gc->account, who);
3296 3298
3297 if(b->uc == UC_ERROR) 3299 if(b->uc == UC_ERROR)
3328 pbm = g_new0(struct proto_buddy_menu, 1); 3330 pbm = g_new0(struct proto_buddy_menu, 1);
3329 pbm->label = _("Cancel Presence Notification"); 3331 pbm->label = _("Cancel Presence Notification");
3330 pbm->callback = jabber_unsubscribe_buddy_from_us; 3332 pbm->callback = jabber_unsubscribe_buddy_from_us;
3331 pbm->gc = gc; 3333 pbm->gc = gc;
3332 m = g_list_append(m, pbm); 3334 m = g_list_append(m, pbm);
3335
3336 if(jbd && !GAIM_BUDDY_IS_ONLINE(b) &&
3337 !(jbd->subscription & JABBER_SUB_TO)) {
3338 pbm = g_new0(struct proto_buddy_menu, 1);
3339 pbm->label = _("Re-request authorization");
3340 pbm->callback = jabber_add_buddy;
3341 pbm->gc = gc;
3342 m = g_list_append(m, pbm);
3343 }
3333 } 3344 }
3334 3345
3335 return m; 3346 return m;
3336 } 3347 }
3337 3348