gboolean gaim_privacy_check(GaimAccount *account, const char *who) { GSList *list; switch (account->perm_deny) { case GAIM_PRIVACY_ALLOW_ALL: return TRUE; case GAIM_PRIVACY_DENY_ALL: return FALSE; case GAIM_PRIVACY_ALLOW_USERS: who = gaim_normalize(account, who); for (list=account->permit; list!=NULL; list=list->next) { if (!gaim_utf8_strcasecmp(who, (char *)list->data)) return TRUE; } return FALSE; case GAIM_PRIVACY_DENY_USERS: who = gaim_normalize(account, who); for (list=account->deny; list!=NULL; list=list->next) { if (!gaim_utf8_strcasecmp(who, (char *)list->data )) return FALSE; } return TRUE; case GAIM_PRIVACY_ALLOW_BUDDYLIST: return (gaim_find_buddy(account, who) != NULL); default: g_return_val_if_reached(TRUE); } }
void gaym_privacy_change(GaimConnection * gc, const char *name) { /** * don't allow adding self to permit/deny lists */ if (name) { if (!gaim_utf8_strcasecmp(gc->account->username, name)) { gaim_privacy_deny_remove(gc->account, gc->account->username, TRUE); gaim_privacy_permit_remove(gc->account, gc->account->username, TRUE); gaim_debug_info("gaym", "declining to add self to permit/deny list\n"); return; } } GSList *rooms = NULL; for (rooms = gc->buddy_chats; rooms; rooms = rooms->next) { GaimConversation *convo = rooms->data; GaimConvChat *chat = gaim_conversation_get_chat_data(convo); GList *people = NULL; for (people = chat->in_room; people; people = people->next) { GaimConvChatBuddy *buddy = people->data; GaimConversationUiOps *ops = gaim_conversation_get_ui_ops(convo); if (name) { if (!gaim_utf8_strcasecmp(name, buddy->name)) { if (gaym_privacy_check(gc, buddy->name) && gaym_botfilter_check(gc, buddy->name, NULL, TRUE)) { gaim_conv_chat_unignore(GAIM_CONV_CHAT(convo), buddy->name); } else { gaim_conv_chat_ignore(GAIM_CONV_CHAT(convo), buddy->name); } ops->chat_update_user((convo), buddy->name); } } else { if (gaym_privacy_check(gc, buddy->name) && gaym_botfilter_check(gc, buddy->name, NULL, TRUE)) { gaim_conv_chat_unignore(GAIM_CONV_CHAT(convo), buddy->name); } else { gaim_conv_chat_ignore(GAIM_CONV_CHAT(convo), buddy->name); } ops->chat_update_user((convo), buddy->name); } } } }
gboolean gaim_privacy_permit_remove(GaimAccount *account, const char *who, gboolean local_only) { GSList *l; char *name; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); name = g_strdup(normalize(who)); for (l = account->permit; l != NULL; l = l->next) { if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) break; } g_free(name); if (l == NULL) return FALSE; account->permit = g_slist_remove(account->permit, l->data); g_free(l->data); if (!local_only && gaim_account_is_connected(account)) serv_rem_deny(gaim_account_get_connection(account), who); gaim_blist_save(); if (privacy_ops != NULL && privacy_ops->permit_removed != NULL) privacy_ops->permit_removed(account, who); return TRUE; }
void gaym_buddy_status(struct gaym_conn *gaym, char *name, gboolean online, char *info) { char *bio = NULL; char *thumbnail = NULL; char *stats = NULL; char *url = NULL; struct gaym_fetch_thumbnail_data *data; if (!gaym || !gaym->account || !gaym->buddies || !name) { return; } if (info) { bio = gaym_bio_strdup(info); if (bio) { bio = g_strstrip(bio); } thumbnail = gaym_thumbnail_strdup(info); if (thumbnail) { thumbnail = g_strstrip(thumbnail); } stats = gaym_stats_strdup(info); if (stats) { stats = g_strstrip(stats); } } GaimConnection *gc = gaim_account_get_connection(gaym->account); if (!gc) { return; } struct gaym_buddy *ib = g_hash_table_lookup(gaym->buddies, name); char *normalized = g_strdup(gaim_normalize(gaym->account, name)); char *im_thumbnail = g_hash_table_lookup(gaym->im_thumbnail_needed, normalized); if (thumbnail) { if ((ib && gaim_utf8_strcasecmp(thumbnail, ib->thumbnail)) || im_thumbnail) { char *hashurl = NULL; hashurl = g_hash_table_lookup(gaym->confighash, "mini-profile-panel.thumbnail-prefix"); g_return_if_fail(hashurl != NULL); data = g_new0(struct gaym_fetch_thumbnail_data, 1); data->gc = gaim_account_get_connection(gaym->account); data->who = g_strdup(name); url = g_strdup_printf("%s%s", hashurl, thumbnail); gaim_url_fetch(url, FALSE, "Mozilla/4.0", FALSE, gaym_fetch_thumbnail_cb, data); g_free(url); } }
void yahoo_process_chat_exit(GaimConnection *gc, struct yahoo_packet *pkt) { char *who = NULL; char *room = NULL; GSList *l; struct yahoo_data *yd; yd = gc->proto_data; for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; if (pair->key == 104) room = yahoo_string_decode(gc, pair->value, TRUE); if (pair->key == 109) who = pair->value; } if (who && room) { GaimConversation *c = gaim_find_chat(gc, YAHOO_CHAT_ID); if (c && !gaim_utf8_strcasecmp(gaim_conversation_get_name(c), room)) gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL); } if (room) g_free(room); }
GaimPounce * gaim_find_pounce(const GaimAccount *pouncer, const char *pouncee, GaimPounceEvent events) { GaimPounce *pounce = NULL; GList *l; char *norm_pouncee; g_return_val_if_fail(pouncer != NULL, NULL); g_return_val_if_fail(pouncee != NULL, NULL); g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL); norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); for (l = gaim_pounces_get_all(); l != NULL; l = l->next) { pounce = (GaimPounce *)l->data; if ((gaim_pounce_get_events(pounce) & events) && (gaim_pounce_get_pouncer(pounce) == pouncer) && !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), norm_pouncee)) { break; } pounce = NULL; } g_free(norm_pouncee); return pounce; }
/** * Return TRUE if the member names match */ gboolean sendercmp(const char *sender, const PendingMessage * pending) { if (!gaim_utf8_strcasecmp(pending->sender, sender)) { return TRUE; } else { return FALSE; } }
/** * Return TRUE if the accounts match */ gboolean usercmp(GaimAccount * account, const PendingMessage * pending) { if (!gaim_utf8_strcasecmp(pending->username, account->username)) { return TRUE; } else { return FALSE; } }
static void dequeue_message(GtkTreeIter *iter) { gchar *name; GSList *templist; GaimConversation *cnv; gboolean orig_while_away; orig_while_away = gaim_prefs_get_bool("/core/sound/while_away"); if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", FALSE); gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), iter, 0, &name, -1); gaim_debug(GAIM_DEBUG_INFO, "away", "Dequeueing messages from %s.\n", name); templist = message_queue; while (templist) { struct queued_message *qm = templist->data; if (templist->data) { if (!gaim_utf8_strcasecmp(qm->name, name)) { GaimAccount *account = NULL; if (g_list_index(gaim_accounts_get_all(), qm->account) >= 0) account = qm->account; cnv = gaim_find_conversation_with_account(name, account); if (!cnv) cnv = gaim_conversation_new(GAIM_CONV_IM, account, qm->name); else gaim_conversation_set_account(cnv, account); gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, qm->message, qm->flags, qm->tm); g_free(qm->message); g_free(qm); templist = message_queue = g_slist_remove(message_queue, qm); } else { templist = templist->next; } } } g_free(name); /* In GTK 2.2, _store_remove actually returns whether iter is valid or not * after the remove, but in GTK 2.0 it is a void function. */ gtk_list_store_remove(awayqueuestore, iter); if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", orig_while_away); }
static GaimConversation *yahoo_find_conference(GaimConnection *gc, const char *name) { struct yahoo_data *yd; GSList *l; yd = gc->proto_data; for (l = yd->confs; l; l = l->next) { GaimConversation *c = l->data; if (!gaim_utf8_strcasecmp(gaim_conversation_get_name(c), name)) return c; } return NULL; }
GaimConversation * jabber_find_unnormalized_conv(const char *name, GaimAccount *account) { GaimConversation *c = NULL; GList *cnv; g_return_val_if_fail(name != NULL, NULL); for(cnv = gaim_get_conversations(); cnv; cnv = cnv->next) { c = (GaimConversation*)cnv->data; if(gaim_conversation_get_type(c) == GAIM_CONV_TYPE_IM && !gaim_utf8_strcasecmp(name, gaim_conversation_get_name(c)) && account == gaim_conversation_get_account(c)) return c; } return NULL; }
gboolean gaim_privacy_permit_remove(GaimAccount *account, const char *who, gboolean local_only) { GSList *l; const char *name; GaimBuddy *buddy; char *del; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); name = gaim_normalize(account, who); for (l = account->permit; l != NULL; l = l->next) { if (!gaim_utf8_strcasecmp(name, (char *)l->data)) break; } if (l == NULL) return FALSE; /* We should not free l->data just yet. There can be occasions where * l->data == who. In such cases, freeing l->data here can cause crashes * later when who is used. */ del = l->data; account->permit = g_slist_delete_link(account->permit, l); if (!local_only && gaim_account_is_connected(account)) serv_rem_permit(gaim_account_get_connection(account), who); if (privacy_ops != NULL && privacy_ops->permit_removed != NULL) privacy_ops->permit_removed(account, who); gaim_blist_schedule_save(); buddy = gaim_find_buddy(account, name); if (buddy != NULL) { gaim_signal_emit(gaim_blist_get_handle(), "buddy-privacy-changed", buddy); } g_free(del); return TRUE; }
gboolean gaim_privacy_deny_remove(GaimAccount *account, const char *who, gboolean local_only) { GSList *l; const char *normalized; char *name; GaimBuddy *buddy; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); normalized = gaim_normalize(account, who); for (l = account->deny; l != NULL; l = l->next) { if (!gaim_utf8_strcasecmp(normalized, (char *)l->data)) break; } buddy = gaim_find_buddy(account, normalized); if (l == NULL) return FALSE; name = l->data; account->deny = g_slist_delete_link(account->deny, l); if (!local_only && gaim_account_is_connected(account)) serv_rem_deny(gaim_account_get_connection(account), name); if (privacy_ops != NULL && privacy_ops->deny_removed != NULL) privacy_ops->deny_removed(account, who); if (buddy != NULL) { gaim_signal_emit(gaim_blist_get_handle(), "buddy-privacy-changed", buddy); } g_free(name); gaim_blist_schedule_save(); return TRUE; }
gboolean gaim_privacy_permit_add(GaimAccount *account, const char *who, gboolean local_only) { GSList *l; char *name; GaimBuddy *buddy; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); name = g_strdup(gaim_normalize(account, who)); for (l = account->permit; l != NULL; l = l->next) { if (!gaim_utf8_strcasecmp(name, (char *)l->data)) break; } if (l != NULL) { g_free(name); return FALSE; } account->permit = g_slist_append(account->permit, name); if (!local_only && gaim_account_is_connected(account)) serv_add_permit(gaim_account_get_connection(account), who); if (privacy_ops != NULL && privacy_ops->permit_added != NULL) privacy_ops->permit_added(account, who); gaim_blist_schedule_save(); /* This lets the UI know a buddy has had its privacy setting changed */ buddy = gaim_find_buddy(account, name); if (buddy != NULL) { gaim_signal_emit(gaim_blist_get_handle(), "buddy-privacy-changed", buddy); } return TRUE; }
void gaim_pounce_execute(const GaimAccount *pouncer, const char *pouncee, GaimPounceEvent events) { GaimPounce *pounce; GaimPounceHandler *handler; GList *l, *l_next; char *norm_pouncee; g_return_if_fail(pouncer != NULL); g_return_if_fail(pouncee != NULL); g_return_if_fail(events != GAIM_POUNCE_NONE); norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); for (l = gaim_pounces_get_all(); l != NULL; l = l_next) { pounce = (GaimPounce *)l->data; l_next = l->next; if ((gaim_pounce_get_events(pounce) & events) && (gaim_pounce_get_pouncer(pounce) == pouncer) && !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), norm_pouncee)) { handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); if (handler != NULL && handler->cb != NULL) { handler->cb(pounce, events, gaim_pounce_get_data(pounce)); if (!gaim_pounce_get_save(pounce)) gaim_pounce_destroy(pounce); } } } g_free(norm_pouncee); }
gboolean gaim_privacy_deny_remove(GaimAccount *account, const char *who, gboolean local_only) { GSList *l; char *name; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); name = g_strdup(normalize(who)); for (l = account->deny; l != NULL; l = l->next) { if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) break; } g_free(name); if (l == NULL) return FALSE; account->deny = g_slist_remove(account->deny, l->data); g_free(l->data); if (!local_only && gaim_account_is_connected(account)) { gaim_debug(GAIM_DEBUG_INFO, "privacy", "Removing %s from server-side deny list\n", who); serv_rem_deny(gaim_account_get_connection(account), who); } gaim_blist_save(); if (privacy_ops != NULL && privacy_ops->deny_removed != NULL) privacy_ops->deny_removed(account, who); return TRUE; }
gboolean gaym_privacy_check(GaimConnection * gc, const char *nick) { /** * returns TRUE if allowed through, FALSE otherwise */ GSList *list; gboolean permitted = FALSE; switch (gc->account->perm_deny) { case 0: gaim_debug_warning("gaym", "Privacy setting was 0. If you can " "reproduce this, please file a bug report.\n"); permitted = TRUE; break; case GAIM_PRIVACY_ALLOW_ALL: permitted = TRUE; break; case GAIM_PRIVACY_DENY_ALL: gaim_debug_info("gaym", "%s blocked data received from %s (GAIM_PRIVACY_DENY_ALL)\n", gc->account->username, nick); break; case GAIM_PRIVACY_ALLOW_USERS: for (list = gc->account->permit; list != NULL; list = list->next) { if (!gaim_utf8_strcasecmp (nick, gaim_normalize(gc->account, (char *) list->data))) { permitted = TRUE; gaim_debug_info("gaym", "%s allowed data received from %s (GAIM_PRIVACY_ALLOW_USERS)\n", gc->account->username, nick); break; } } break; case GAIM_PRIVACY_DENY_USERS: /* seeing we're letting everyone through, except the deny list */ permitted = TRUE; for (list = gc->account->deny; list != NULL; list = list->next) { if (!gaim_utf8_strcasecmp (nick, gaim_normalize(gc->account, (char *) list->data))) { permitted = FALSE; gaim_debug_info("gaym", "%s blocked data received from %s (GAIM_PRIVACY_DENY_USERS)\n", gc->account->username, nick); break; } } break; case GAIM_PRIVACY_ALLOW_BUDDYLIST: if (gaim_find_buddy(gc->account, nick) != NULL) { permitted = TRUE; } else { gaim_debug_info("gaym", "%s blocked data received from %s (GAIM_PRIVACY_ALLOW_BUDDYLIST)\n", gc->account->username, nick); } break; default: gaim_debug_warning("gaym", "Privacy setting was unknown. If you can " "reproduce this, please file a bug report.\n"); permitted = FALSE; break; } /** * don't block/ignore self */ if (!gaim_utf8_strcasecmp(gc->account->username, nick)) { permitted = TRUE; gaim_debug_info("gaym", "declining to block/ignore self\n"); return permitted; } return permitted; }
void synchronize_deny_list(GaimConnection * gc, GHashTable * confighash) { char *srvdeny = NULL; gchar **srvdenylist = NULL; GSList *list; gint i = 0; gboolean needsync = FALSE; g_return_if_fail(confighash != NULL); srvdeny = g_hash_table_lookup(confighash, "connect-list.ignore.members"); if (!srvdeny) { srvdeny = ""; } srvdenylist = g_strsplit(srvdeny, ",", -1); /** * The nicks come in here as if they came from the IRC server * so they need to be converted to GayM format */ for (i = 0; srvdenylist[i]; i++) { gcom_nick_to_gaym(srvdenylist[i]); } /* Add server deny list from config.txt to local deny list */ for (i = 0; srvdenylist[i]; i++) { needsync = TRUE; for (list = gc->account->deny; list != NULL; list = list->next) { if (!gaim_utf8_strcasecmp (srvdenylist[i], gaim_normalize(gc->account, (char *) list->data))) { needsync = FALSE; break; } } if (needsync) { if (!gaim_privacy_deny_add(gc->account, srvdenylist[i], TRUE)) { gaim_debug_error("gaym", "Failed to add %s to local deny list from server.\n", srvdenylist[i]); } else { gaim_debug_misc("gaym", "Added %s to local deny list from server.\n", srvdenylist[i]); } } } /* Add local deny list not found in config.txt to server deny list */ for (list = gc->account->deny; list != NULL; list = list->next) { needsync = TRUE; for (i = 0; srvdenylist[i]; i++) { if (!gaim_utf8_strcasecmp (srvdenylist[i], gaim_normalize(gc->account, (char *) list->data))) { needsync = FALSE; break; } } if (needsync) { gaym_server_store_deny(gc, (char *) list->data, TRUE); } } g_strfreev(srvdenylist); return; }
void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt) { struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; GaimConversation *c = NULL; GSList *l; GList *members = NULL; char *room = NULL; char *topic = NULL; char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber; if (pkt->status == -1) { gaim_notify_error(gc, NULL, _("Failed to join chat"), _("Maybe the room is full?")); return; } for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 104: room = pair->value; break; case 105: topic = pair->value; break; case 128: someid = pair->value; break; case 108: /* number of joiners */ break; case 129: someotherid = pair->value; break; case 130: somebase64orhashosomething = pair->value; break; case 126: somenegativenumber = pair->value; break; case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */ break; case 61: /*this looks similiar to 130 */ break; /* the previous section was just room info. this next section is info about individual room members, (including us) */ case 109: /* the yahoo id */ members = g_list_append(members, pair->value); break; case 110: /* age */ break; case 141: /* nickname */ break; case 142: /* location */ break; case 113: /* bitmask */ break; } } if (!room) return; if (yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name)) yahoo_c_leave(gc, YAHOO_CHAT_ID); c = gaim_find_chat(gc, YAHOO_CHAT_ID); if (!c) { c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_chat_set_topic(GAIM_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_chat_add_users(GAIM_CHAT(c), members); } else { yahoo_chat_add_users(GAIM_CHAT(c), members); } g_list_free(members); }
static gboolean gaym_nick_equal(const char *nick1, const char *nick2) { return (gaim_utf8_strcasecmp(nick1, nick2) == 0); }
void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt) { GaimAccount *account = gaim_connection_get_account(gc); struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; GaimConversation *c = NULL; GSList *l; GList *members = NULL; GList *roomies = NULL; char *room = NULL; char *topic = NULL; char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber; if (pkt->status == -1) { /* We can't join */ struct yahoo_pair *pair = pkt->hash->data; gchar const *failed_to_join = _("Failed to join chat"); switch (atoi(pair->value)) { case 0xFFFFFFFA: /* -6 */ gaim_notify_error(gc, NULL, failed_to_join, _("Unknown room")); break; case 0xFFFFFFF1: /* -15 */ gaim_notify_error(gc, NULL, failed_to_join, _("Maybe the room is full")); break; case 0xFFFFFFDD: /* -35 */ gaim_notify_error(gc, NULL, failed_to_join, _("Not available")); break; default: gaim_notify_error(gc, NULL, failed_to_join, _("Unknown error. You may need to logout and wait five minutes before being able to rejoin a chatroom")); } return; } for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 104: room = yahoo_string_decode(gc, pair->value, TRUE); break; case 105: topic = yahoo_string_decode(gc, pair->value, TRUE); break; case 128: someid = pair->value; break; case 108: /* number of joiners */ break; case 129: someotherid = pair->value; break; case 130: somebase64orhashosomething = pair->value; break; case 126: somenegativenumber = pair->value; break; case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */ break; case 61: /*this looks similar to 130 */ break; /* the previous section was just room info. this next section is info about individual room members, (including us) */ case 109: /* the yahoo id */ members = g_list_append(members, pair->value); break; case 110: /* age */ break; case 141: /* nickname */ break; case 142: /* location */ break; case 113: /* bitmask */ break; } } if (room && yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name)) yahoo_chat_leave(gc, room, gaim_connection_get_display_name(gc), FALSE); c = gaim_find_chat(gc, YAHOO_CHAT_ID); if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members && ((g_list_length(members) > 1) || !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) { int i; GList *flags = NULL; for (i = 0; i < g_list_length(members); i++) flags = g_list_append(flags, GINT_TO_POINTER(GAIM_CBFLAGS_NONE)); if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) { /* this might be a hack, but oh well, it should nicely */ char *tmpmsg; gaim_conversation_set_name(c, room); c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room); gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL)); g_free(tmpmsg); } else { c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); } g_list_free(flags); } else if (c) { yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); } if (account->deny && c) { GaimConversationUiOps *ops = gaim_conversation_get_ui_ops(c); for (l = account->deny; l != NULL; l = l->next) { for (roomies = members; roomies; roomies = roomies->next) { if (!gaim_utf8_strcasecmp((char *)l->data, roomies->data)) { gaim_debug_info("yahoo", "Ignoring room member %s in room %s\n" , roomies->data, room ? room : ""); gaim_conv_chat_ignore(GAIM_CONV_CHAT(c),roomies->data); ops->chat_update_user(c, roomies->data); } } } } g_list_free(roomies); g_list_free(members); g_free(room); g_free(topic); }
void gaym_buddy_status(struct gaym_conn *gaym, char *name, gboolean online, char *info, gboolean fetch_thumbnail) { char *bio = NULL; char *thumbnail = NULL; char *stats = NULL; char *url = NULL; struct gaym_fetch_thumbnail_data *data; gboolean gaymuser = FALSE; if (!gaym || !gaym->account || !gaym->buddies || !name) { return; } if (info) { #ifdef GAYM_TOKEN gaymuser = gaym_stats_find_gaym_token(info); #endif bio = gaym_bio_strdup(info); if (bio) { bio = g_strstrip(bio); } thumbnail = gaym_thumbnail_strdup(info); if (thumbnail) { thumbnail = g_strstrip(thumbnail); } stats = gaym_stats_strdup(info); if (stats) { stats = g_strstrip(stats); } } GaimConnection *gc = gaim_account_get_connection(gaym->account); if (!gc) { return; } struct gaym_buddy *ib = g_hash_table_lookup(gaym->buddies, name); if (!ib) ib = g_hash_table_lookup(gaym->channel_members, name); char *normalized = g_strdup(gaim_normalize(gaym->account, name)); if (thumbnail && fetch_thumbnail) { if (!ib || gaim_utf8_strcasecmp(thumbnail, ib->thumbnail)) { char *hashurl = NULL; hashurl = g_hash_table_lookup(gaym->confighash, "mini-profile-panel.thumbnail-prefix"); g_return_if_fail(hashurl != NULL); data = g_new0(struct gaym_fetch_thumbnail_data, 1); data->gc = gaim_account_get_connection(gaym->account); data->who = g_strdup(gaim_normalize(gaym->account, name)); data->filename = g_strdup(g_strrstr(thumbnail, "/")); gaim_debug_misc("gayminfo", "Found filename: %s\n", data->filename); url = g_strdup_printf("%s%s", hashurl, thumbnail); gaim_util_fetch_url(url, FALSE, "Mozilla/4.0", FALSE, gaym_fetch_thumbnail_cb, data); g_free(url); } }
void gaym_buddy_status(struct gaym_conn *gaym, char *name, gboolean online, char *info) { char *bio = NULL; char *thumbnail = NULL; char *stats = NULL; char *url = NULL; struct gaym_fetch_thumbnail_data *data; gboolean gaymuser=FALSE; if (!gaym || !gaym->account || !gaym->buddies || !name) { return; } if (info) { #ifdef GAYM_TOKEN gaymuser = gaym_stats_find_gaym_token(info); #endif bio = gaym_bio_strdup(info); if (bio) { bio = g_strstrip(bio); } thumbnail = gaym_thumbnail_strdup(info); if (thumbnail) { thumbnail = g_strstrip(thumbnail); } stats = gaym_stats_strdup(info); if (stats) { stats = g_strstrip(stats); } } GaimConnection *gc = gaim_account_get_connection(gaym->account); if (!gc) { return; } struct gaym_buddy *ib = g_hash_table_lookup(gaym->buddies, name); char *normalized = g_strdup(gaim_normalize(gaym->account, name)); if (thumbnail) { gboolean do_fetch = 1; GError *err = NULL; if (!ib || gaim_utf8_strcasecmp(thumbnail, ib->thumbnail)) { char *dirname = g_build_filename(gaim_user_dir(), "icons", "gaym", gaim_normalize(gaym->account, name), NULL); GDir *gdir = g_dir_open(dirname, 0, &err); if (gdir) { const char *filename; while ((filename = g_dir_read_name(gdir))) /* don't free filename: owned by glib.*/ { char *thumbnail_base = g_path_get_basename(thumbnail); gaim_debug_misc("gaym", "compared %s and %s\n", thumbnail_base, filename); if (!gaim_utf8_strcasecmp(thumbnail_base, filename)) { do_fetch = 0; break; } g_free(thumbnail_base); } g_dir_close(gdir); } if (do_fetch) { gaim_debug_misc("gaym", "********************************************\n"); gaim_debug_misc("gaym", "*****************FETCH**********************\n"); gaim_debug_misc("gaym", "********************************************\n"); char *hashurl = NULL; hashurl = g_hash_table_lookup(gaym->confighash, "mini-profile-panel.thumbnail-prefix"); g_return_if_fail(hashurl != NULL); data = g_new0(struct gaym_fetch_thumbnail_data, 1); data->gc = gaim_account_get_connection(gaym->account); data->who = g_strdup(gaim_normalize(gaym->account, name)); data->filename = g_strdup(g_strrstr(thumbnail, "/")); gaim_debug_misc("gayminfo", "Found filename: %s\n", data->filename); url = g_strdup_printf("%s%s", hashurl, thumbnail); gaim_url_fetch(url, FALSE, "Mozilla/4.0", FALSE, gaym_fetch_thumbnail_cb, data); g_free(url); } } }
/** * This is our callback for the receiving-im-msg signal. * * We return TRUE to block the IM, FALSE to accept the IM */ static gboolean receiving_im_msg_cb(GaimAccount * account, char **sender, char **buffer, int *flags, void *data) { gboolean retval = FALSE; /* assume the sender is allowed */ gboolean found = FALSE; gint pos = -1; char *botmsg = NULL; PendingMessage *pending = NULL; GSList *slist = NULL; GSList *search = NULL; GaimConnection *connection = NULL; /* expire any old entries in pending */ expire_pending_list(); connection = gaim_account_get_connection(account); /* not good, but don't do anything */ if (!connection || !sender) { return retval; } /* if there is already an open conversation, allowed it */ if (gaim_find_conversation_with_account(*sender, account)) { return retval; } /* don't make buddies use the challenge/response system */ if (gaim_find_buddy(account, *sender)) { return retval; } /* don't make permit list members use the challenge/response system */ for (slist = account->permit; slist != NULL; slist = slist->next) { if (!gaim_utf8_strcasecmp (*sender, gaim_normalize(account, (char *) slist->data))) { return retval; } } /* if there is no question or no answer, allow the sender */ const char *question = gaim_prefs_get_string("/plugins/core/bot/challenger/question"); const char *answer = gaim_prefs_get_string("/plugins/core/bot/challenger/answer"); if (!question || !answer) { return retval; } /* blank / null message ... can this even happen? */ if (!*buffer) { return retval; } /* search if this sender is already in pending */ for (search = pending_list; search; search = search->next) { pending = search->data; pos = g_slist_position(pending_list, search); if (protocmp(account, pending) && usercmp(account, pending) && sendercmp(*sender, pending)) { found = TRUE; break; } } if (!found) { /** * its the first time through, save the nick/msg to the * queue and ask the question */ GTimeVal *now = NULL; now = g_new0(GTimeVal, 1); g_get_current_time(now); PendingMessage *newpend = NULL; newpend = g_new0(PendingMessage, 1); newpend->tv_sec = now->tv_sec; newpend->protocol = g_strdup(account->protocol_id); newpend->username = g_strdup(account->username); newpend->sender = g_strdup(*sender); newpend->message = g_strdup(*buffer); pending_list = g_slist_append(pending_list, newpend); botmsg = g_strdup_printf(_ ("Bot Challenger engaged: you are now being ignored! Your message will be delivered if you can correctly answer the following question within %i minutes: %s"), BOT_MAX_MINUTES, question); send_auto_reply(account, *sender, botmsg); g_free(now); g_free(botmsg); retval = TRUE; } else { if (gaim_utf8_strcasecmp(*buffer, answer)) { /** * Sorry, thanks for playing, please try again */ retval = TRUE; } else { botmsg = _ ("Bot Challenger accepted your answer and delivered your original message. You may now speak freely."); send_auto_reply(account, *sender, botmsg); if (gaim_prefs_get_bool ("/plugins/core/bot/challenger/auto_add_permit")) { if (!gaim_privacy_permit_add(account, *sender, FALSE)) { gaim_debug_info("bot-challenger", "Unable to add %s/%s/%s to permit list\n", *sender, pending->username, pending->protocol); } } /** * Free what is currently in the buffer (the correct answer) * and replace it with the user's first message that was * queued, pending the correct answer. I think some other * process is supposed to free the buffer after its sent. */ g_free(*buffer); *buffer = pending->message; /* Clean up everything else except pending->message */ free_pending(search, FALSE); retval = FALSE; /* Don't block this message */ } } debug_pending_list(); return retval; /* returning TRUE will block the IM */ }