Example #1
0
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;
}
Example #2
0
/*
 * helpers
 */
static GaimConnection *get_mockprpl_gc(const char *username) {
  GaimAccount *acct = gaim_accounts_find(username, MOCKPRPL_ID);
  if (acct && gaim_account_is_connected(acct))
    return acct->gc;
  else
    return NULL;
}
Example #3
0
static GaimChat *gaym_find_blist_chat(GaimAccount * account,
                                      const char *name)
{
    char *chat_name;
    GaimChat *chat;
    GaimPlugin *prpl;
    GaimPluginProtocolInfo *prpl_info = NULL;
    struct proto_chat_entry *pce;
    GaimBlistNode *node, *group;
    GList *parts;

    GaimBuddyList *gaimbuddylist = gaim_get_blist();

    g_return_val_if_fail(gaimbuddylist != NULL, NULL);
    g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL);

    if (!gaim_account_is_connected(account))
        return NULL;

    prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
    prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);

    for (group = gaimbuddylist->root; group != NULL; group = group->next) {
        for (node = group->child; node != NULL; node = node->next) {
            if (GAIM_BLIST_NODE_IS_CHAT(node)) {

                chat = (GaimChat *) node;

                if (account != chat->account)
                    continue;

                parts =
                    prpl_info->
                    chat_info(gaim_account_get_connection(chat->account));

                pce = parts->data;
                chat_name = g_hash_table_lookup(chat->components,
                                                pce->identifier);

                if (chat->account == account && chat_name != NULL &&
                    name != NULL
                    && g_pattern_match_simple(chat_name, name)) {

                    return chat;
                }
            }
        }
    }

    return NULL;
}
Example #4
0
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;
}
Example #5
0
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;
}
Example #6
0
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;
}
Example #7
0
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;
}