Пример #1
0
static BINDING_FUNCTION(binding_ignore_query)
{
    if (!window_current->target)
        return;

    command_exec_format(window_current->target, window_current->session, 0, ("/ignore \"%s\""), window_current->target);
}
Пример #2
0
static void bind_exec(struct binding *b) {
	if (b->function)
		b->function(b->arg);
	else {
		command_exec_format(window_current->target, window_current->session, 0,
				("%s%s"), ((b->action[0] == '/') ? "" : "/"), b->action);
	}
}
Пример #3
0
/* 
 * ncurses_contacts_mouse_handler()
 * 
 * handler for mouse events
 */
void ncurses_contacts_mouse_handler(int x, int y, int mouse_state) 
{
	window_t *w = window_find_sa(NULL, "__contacts", 1);
	ncurses_window_t *n;

	if (mouse_state == EKG_SCROLLED_UP) {
		binding_helper_scroll(w, -5);
		return;
	} else if (mouse_state == EKG_SCROLLED_DOWN) {
		binding_helper_scroll(w, 5);
		return;
	}

	if (mouse_state == EKG_BUTTON3_CLICKED)
		binding_next_contacts_group(NULL);

	if (!w || mouse_state != EKG_BUTTON1_DOUBLE_CLICKED)
		return;

	n = w->priv_data;

	if (!w->nowrap) {
		/* here new code, should work also with w->nowrap == 1 */
		y -= 1;		/* ??? */

		if (y < 0 || y >= n->lines_count)
			return;

		y = n->lines[n->start + y].backlog;
	} else {
		/* here old code */

		if (y > n->backlog_size)
			return;

		y = n->backlog_size - (n->start + y);
	}

	if (y >= n->backlog_size) {
		/* error */
		return;
	}

	command_exec_format(NULL, NULL, 0, ("/query \"%s\""), n->backlog[y]->priv_data);
	return;
}
Пример #4
0
PyObject *ekg_session_status_set(ekg_sessionObj * self, PyObject * pyargs)
{
	char *status = NULL;
	char *descr = NULL;
	const char *command;

	if (!PyArg_ParseTuple(pyargs, "s|s", &status, &descr))
		return NULL;

	command = ekg_status_string(ekg_status_int(status), 1);
	if (descr == NULL)
		descr = xstrdup("-");

	command_exec_format(NULL, session_find(self->name), 0, "/%s %s", command, descr);
	xfree(descr); xfree(status); /* ? */
	Py_RETURN_TRUE;
}
Пример #5
0
/*
 * msg_queue_flush()
 *
 * wysy³a wiadomo¶ci z kolejki.
 *
 * 0 je¶li wys³ano, -1 je¶li nast±pi³ b³±d przy wysy³aniu, -2 je¶li
 * kolejka pusta.
 */
int msg_queue_flush(const char *session)
{
	msg_queue_t *m;
	int ret = -1;

	if (!msgs_queue)
		return -2;

	for (m = msgs_queue; m; m = m->next)
		m->mark = 1;

	for (m = msgs_queue; m; m = m->next) {
		session_t *s;
		char *cmd = "/msg \"%s\" %s";

		/* czy wiadomo¶æ dodano w trakcie opró¿niania kolejki? */
		if (!m->mark)
			continue;

		if (session && xstrcmp(m->session, session)) 
			continue;
				/* wiadomo¶æ wysy³ana z nieistniej±cej ju¿ sesji? usuwamy. */
		else if (!(s = session_find(m->session))) {
			m = msgs_queue_removei(m);
			continue;
		}

		switch (m->mclass) {
			case EKG_MSGCLASS_SENT_CHAT:
				cmd = "/chat \"%s\" %s";
				break;
			case EKG_MSGCLASS_SENT:
				break;
			default:
				debug_error("msg_queue_flush(), unsupported message mclass in query: %d\n", m->mclass);
		}
		command_exec_format(NULL, s, 1, cmd, m->rcpts, m->message);

		m = msgs_queue_removei(m);
		ret = 0;
	}

	return ret;
}
Пример #6
0
static EKG2_DBUS_IFACE_HANDLER(ekg2_dbus_iface_im_ekg2_session_setStatus)
{
	static const char status_errory[][20] = { "OK", "wrong argument", "session not found" };
	char *error;
	EKG2_DBUS_CALL_HANDLER_VARIABLES;
	DBusMessageIter iter;
	char const *param, *cmd;
	int current_type, st;
	session_t *s;

	EKG2_DBUS_INIT_REPLY;

	dbus_message_iter_init (msg, &iter);
	if ((current_type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_STRING)
	{
		error = status_errory[1];
		EKG2_DBUS_ADD_STRING(&error);
		goto send_and_return;
	} else {
		dbus_message_iter_get_basic (&iter, &param);
		if ((s = session_find(param)) == NULL)
		{
			error = status_errory[2];
			EKG2_DBUS_ADD_STRING(&error);
			goto send_and_return;
		}
	}

	dbus_message_iter_next (&iter);
	if ((current_type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_STRING)
	{
		error = status_errory[1];
		EKG2_DBUS_ADD_STRING(&error);
		goto send_and_return;
	} 
	dbus_message_iter_get_basic (&iter, &param);
	st = ekg_status_int(param);

	dbus_message_iter_next (&iter);
	if ((current_type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_STRING)
	{
		error = status_errory[1];
		EKG2_DBUS_ADD_STRING(&error);
		goto send_and_return;
	} 
	dbus_message_iter_get_basic (&iter, &param);

	/* session_unidle(s); */
	/* should we use status provided in dbus parameter
	 * or keep current status
	 */
	cmd = ekg_status_string(st, 1);
	debug ("changing to: %s %s\n", cmd, param);
	command_exec_format(NULL, s, 1, ("/%s %s"), cmd, param);

	error = status_errory[0];
	EKG2_DBUS_ADD_STRING(&error);

send_and_return:
	EKG2_DBUS_SEND_REPLY;

	return DBUS_HANDLER_RESULT_HANDLED;
}
Пример #7
0
static COMMAND(xmsg_msg)
{
	char fn[sizeof(XMSG_TMPFILE_PATH)];
	int fd;
	char *msg = (char*) params[1];
	const char *uid;
	int fs;
	int n;
	const char *msgcmd = session_get(session, "send_cmd");
	char *msgx = NULL, *mymsg;
	
	if (!(uid = get_uid(session, target))) {
		printq("invalid_session");
		return -1;
	}

	if (!msgcmd || *msgcmd == '\0') {
		printq("xmsg_nosendcmd", session_name(session));
		return -1;
	}
	
	xstrcpy(fn, XMSG_TMPFILE_PATH);
	
	fd = mkstemp(fn);
	if (fd == -1)
		xerrn("Unable to create temp file");
	{
		const char *charset = session_get(session, "charset");

		if (charset)
			msgx = ekg_convert_string(msg, NULL, charset);
		mymsg = (msgx ? msgx : msg);
	}
	fs = xstrlen(mymsg);

	while (fs > 0) {
		if ((n = write(fd, mymsg, fs)) == -1) {
			unlink(fn);
			close(fd);
			xfree(msgx);
			xerrn("Unable to write message into temp file");
		}
		fs -= n;
		mymsg += n;
	}

	xfree(msgx);	
	close(fd);
	if ((command_exec_format(NULL, session, 1, "!^%s \"%s\" \"%s\"", msgcmd, target+XMSG_UID_DIROFFSET, fn)))
		xerr("msgcmd exec failed");
	
	{
		char **rcpts	= xcalloc(2, sizeof(char *));
		int class	= (xstrcmp(name, "chat") ? EKG_MSGCLASS_SENT : EKG_MSGCLASS_SENT_CHAT);

		rcpts[0]	= xstrdup(uid);
		rcpts[1]	= NULL;

		protocol_message_emit(session, session->uid, rcpts, params[1], NULL, time(NULL), class, NULL, EKG_NO_BEEP, 0);

		array_free(rcpts);
	}
			
	return 0;
}