예제 #1
0
파일: privacy.c 프로젝트: VoxOx/VoxOx
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();
    }
}
예제 #2
0
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;
}