Beispiel #1
0
static void gaym_add_permit(GaimConnection * gc, const char *name)
{
    if (!gaym_nick_check(name)) {
        gaim_privacy_permit_remove(gc->account, name, TRUE);
        gaim_notify_error(gc, _("Invalid User Name"), name,
                          _("Invalid user name not added."));
    } else {
        gaym_privacy_change(gc, name);
    }
}
Beispiel #2
0
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);
            }
        }
    }
}
Beispiel #3
0
void
gaim_privacy_deny(GaimAccount *account, const char *who, gboolean local,
                  gboolean restore)
{
    GSList *list;

    switch (account->perm_deny) {
    case GAIM_PRIVACY_ALLOW_ALL:
        if (!restore) {
            /* Empty the deny-list. */
            for (list = account->deny; list != NULL; ) {
                char *person = list->data;
                list = list->next;
                gaim_privacy_deny_remove(account, person, local);
            }
        }
        gaim_privacy_deny_add(account, who, local);
        account->perm_deny = GAIM_PRIVACY_DENY_USERS;
        break;
    case GAIM_PRIVACY_ALLOW_USERS:
        gaim_privacy_permit_remove(account, who, local);
        break;
    case GAIM_PRIVACY_DENY_USERS:
        gaim_privacy_deny_add(account, who, local);
        break;
    case GAIM_PRIVACY_DENY_ALL:
        break;
    case GAIM_PRIVACY_ALLOW_BUDDYLIST:
        if (gaim_find_buddy(account, who)) {
            add_buddies_in_permit(account, local);
            gaim_privacy_permit_remove(account, who, local);
            account->perm_deny = GAIM_PRIVACY_ALLOW_USERS;
        }
        break;
    default:
        g_return_if_reached();
    }
}
Beispiel #4
0
/* This makes sure that only all the buddies are in the permit list. */
static void
add_buddies_in_permit(GaimAccount *account, gboolean local)
{
    GSList *list, *iter;
    /* Remove anyone in the permit list who is not in the buddylist */
    for (list = account->permit; list != NULL; ) {
        char *person = list->data;
        list = list->next;
        if (!gaim_find_buddy(account, person))
            gaim_privacy_permit_remove(account, person, local);
    }
    /* Now make sure everyone in the buddylist is in the permit list */
    for (iter = list = gaim_find_buddies(account, NULL); iter; iter = iter->next) {
        GaimBuddy *buddy = iter->data;
        if (!g_slist_find_custom(account->permit, buddy->name, (GCompareFunc)g_utf8_collate))
            gaim_privacy_permit_add(account, buddy->name, local);
    }
    g_slist_free(list);
}