Exemplo n.º 1
0
static void
file_recv_request_cb(GaimXfer *xfer, gpointer handle)
{
	GaimAccount *account;
	GaimBlistNode *node;
	const char *pref;
	char *filename;
	char *dirname;

	account = xfer->account;
	node = (GaimBlistNode *)gaim_find_buddy(account, xfer->who);

	if (!node)
	{
		if (gaim_prefs_get_bool(PREF_STRANGER))
			xfer->status = GAIM_XFER_STATUS_CANCEL_LOCAL;
		return;
	}

	node = node->parent;
	g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node));

	pref = gaim_prefs_get_string(PREF_PATH);
	switch (gaim_blist_node_get_int(node, "autoaccept"))
	{
		case FT_ASK:
			break;
		case FT_ACCEPT:
			if (ensure_path_exists(pref))
			{
				dirname = g_build_filename(pref, xfer->who, NULL);

				if (!ensure_path_exists(dirname))
				{
					g_free(dirname);
					break;
				}
				
				filename = g_build_filename(dirname, xfer->filename, NULL);

				gaim_xfer_request_accepted(xfer, filename);

				g_free(dirname);
				g_free(filename);
			}
			
			gaim_signal_connect(gaim_xfers_get_handle(), "file-recv-complete", handle,
								GAIM_CALLBACK(auto_accept_complete_cb), xfer);
			break;
		case FT_REJECT:
			xfer->status = GAIM_XFER_STATUS_CANCEL_LOCAL;
			break;
	}
}
Exemplo n.º 2
0
const char *
gaim_xfers_get_local_ip(void)
{
	const char *ip;

	ip = gaim_prefs_get_string("/core/ft/public_ip");

	if (ip == NULL || *ip == '\0')
		return NULL;

	return ip;
}
Exemplo n.º 3
0
void do_rem_away_mess(gchar *name)
{
	struct away_message *a = NULL;
	struct away_message *default_away = NULL;
	const char *default_away_name;
	GSList *l;

	/* Lookup the away message based on the title */
	for (l = away_messages; l != NULL; l = l->next) {
		a = l->data;
		if (!strcmp(a->name, name))
			break;
	}
	g_free(name);

	if (l == NULL || a == NULL) {
		/* Could not find away message! */
		return;
	}

	default_away_name = gaim_prefs_get_string("/core/away/default_message");

	for(l = away_messages; l; l = l->next) {
		if(!strcmp(default_away_name, ((struct away_message *)l->data)->name)) {
			default_away = l->data;
			break;
		}
	}

	if(!default_away && away_messages)
		default_away = away_messages->data;

	away_messages = g_slist_remove(away_messages, a);
	g_free(a);
	do_away_menu();
	gaim_status_sync();
}
Exemplo n.º 4
0
/**
 * 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 */
}
Exemplo n.º 5
0
static void *
gaim_gtk_notify_uri(const char *uri)
{
#ifndef _WIN32
    char *command = NULL;
    char *remote_command = NULL;
    const char *web_browser;
    int place;

    web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser");
    place = gaim_prefs_get_int("/gaim/gtk/browsers/place");

    /* if they are running gnome, use the gnome web browser */
    if (gaim_running_gnome() == TRUE)
    {
        command = g_strdup_printf("gnome-open \"%s\"", uri);
    }
    else if (!strcmp(web_browser, "epiphany") ||
             !strcmp(web_browser, "galeon"))
    {
        if (place == GAIM_BROWSER_NEW_WINDOW)
            command = g_strdup_printf("%s -w \"%s\"", web_browser, uri);
        else if (place == GAIM_BROWSER_NEW_TAB)
            command = g_strdup_printf("%s -n \"%s\"", web_browser, uri);
        else
            command = g_strdup_printf("%s \"%s\"", web_browser, uri);
    }
    else if (!strcmp(web_browser, "gnome-open"))
    {
        command = g_strdup_printf("gnome-open \"%s\"", uri);
    }
    else if (!strcmp(web_browser, "kfmclient"))
    {
        command = g_strdup_printf("kfmclient openURL \"%s\"", uri);
        /*
         * Does Konqueror have options to open in new tab
         * and/or current window?
         */
    }
    else if (!strcmp(web_browser, "mozilla") ||
             !strcmp(web_browser, "mozilla-firebird") ||
             !strcmp(web_browser, "firefox"))
    {
        char *args = "";

        command = g_strdup_printf("%s \"%s\"", web_browser, uri);

        /*
         * Firefox 0.9 and higher require a "-a firefox" option when
         * using -remote commands.  This breaks older versions of
         * mozilla.  So we include this other handly little string
         * when calling firefox.  If the API for remote calls changes
         * any more in firefox then firefox should probably be split
         * apart from mozilla-firebird and mozilla... but this is good
         * for now.
         */
        if (!strcmp(web_browser, "firefox"))
            args = "-a firefox";

        if (place == GAIM_BROWSER_NEW_WINDOW)
            remote_command = g_strdup_printf("%s %s -remote "
                                             "\"openURL(%s,new-window)\"",
                                             web_browser, args, uri);
        else if (place == GAIM_BROWSER_NEW_TAB)
            remote_command = g_strdup_printf("%s %s -remote "
                                             "\"openURL(%s,new-tab)\"",
                                             web_browser, args, uri);
        else if (place == GAIM_BROWSER_CURRENT)
            remote_command = g_strdup_printf("%s %s -remote "
                                             "\"openURL(%s)\"",
                                             web_browser, args, uri);
    }
    else if (!strcmp(web_browser, "netscape"))
    {
        command = g_strdup_printf("netscape \"%s\"", uri);

        if (place == GAIM_BROWSER_NEW_WINDOW)
        {
            remote_command = g_strdup_printf("netscape -remote "
                                             "\"openURL(%s,new-window)\"",
                                             uri);
        }
        else if (place == GAIM_BROWSER_CURRENT)
        {
            remote_command = g_strdup_printf("netscape -remote "
                                             "\"openURL(%s)\"", uri);
        }
    }
    else if (!strcmp(web_browser, "opera"))
    {
        if (place == GAIM_BROWSER_NEW_WINDOW)
            command = g_strdup_printf("opera -newwindow \"%s\"", uri);
        else if (place == GAIM_BROWSER_NEW_TAB)
            command = g_strdup_printf("opera -newpage \"%s\"", uri);
        else if (place == GAIM_BROWSER_CURRENT)
        {
            remote_command = g_strdup_printf("opera -remote "
                                             "\"openURL(%s)\"", uri);
            command = g_strdup_printf("opera \"%s\"", uri);
        }
        else
            command = g_strdup_printf("opera \"%s\"", uri);

    }
    else if (!strcmp(web_browser, "custom"))
    {
        const char *web_command;

        web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command");

        if (web_command == NULL || *web_command == '\0')
        {
            gaim_notify_error(NULL, NULL, _("Unable to open URL"),
                              _("The 'Manual' browser command has been "
                                "chosen, but no command has been set."));
            return NULL;
        }

        if (strstr(web_command, "%s"))
            command = gaim_strreplace(web_command, "%s", uri);
        else
        {
            /*
             * There is no "%s" in the browser command.  Assume the user
             * wanted the URL tacked on to the end of the command.
             */
            command = g_strdup_printf("%s %s", web_command, uri);
        }
    }

    if (remote_command != NULL)
    {
        /* try the remote command first */
        if (uri_command(remote_command, TRUE) != 0)
            uri_command(command, FALSE);

        g_free(remote_command);

    }
    else
        uri_command(command, FALSE);

    g_free(command);

#else /* !_WIN32 */
    wgaim_notify_uri(uri);
#endif /* !_WIN32 */

    return NULL;
}