コード例 #1
0
ファイル: python-session.c プロジェクト: dmilith/ekg2-bsd
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;
}
コード例 #2
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;
}