Esempio n. 1
0
/*
 * Core function to login to the server.
 */
static int
ifcore_login(lua_State *lua)
{
	const char *s, *u, *w, *p;
	int r;

	if (lua_gettop(lua) != 1)
		luaL_error(lua, "wrong number of arguments");

	luaL_checktype(lua, 1, LUA_TTABLE);

	if (!(s = get_table_string("server")))
		luaL_error(lua, "no mail server specified");
	if (!(u = get_table_string("username")))
		luaL_error(lua, "no username specified");
	if (!(w = get_table_string("password")))
		luaL_error(lua, "no password specified");
	p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl"));

	r = request_login(s, p, get_table_string("ssl"), u, w);

	lua_pop(lua, 1);

	if (r == STATUS_RESPONSE_NONE)
		return 0;

	lua_pushboolean(lua, (r == STATUS_RESPONSE_OK ||
	    r == STATUS_RESPONSE_PREAUTH));

	return 1;
}
Esempio n. 2
0
/**
 * @brief Login::process_state
 *      Calls the right function according to the state.
 * @date
 *      Created:  Filipe, 7 Mar 2014
 *      Modified: Filipe, 7 Mar 2014
 */
void Login::process_state()
{
    if(state == persistent)
    {
        request_persistent();
    }
    else if(state == rsa)
    {
        request_rsa();
    }
    else if(state == login)
    {
        request_login();
    }
    else if(state == cookies)
    {
        request_cookies();
    }
    else if(state == profile)
    {
        request_profile();
    }
    else if(state == complete)
    {
        login_complete();
    }
}
Esempio n. 3
0
/*
 * Core function to login to the server.
 */
static int
ifcore_login(lua_State *lua)
{
	session *s = NULL;
	int t, r;

	if (lua_gettop(lua) != 6)
		luaL_error(lua, "wrong number of arguments");
	luaL_checktype(lua, 1, LUA_TSTRING);
	luaL_checktype(lua, 2, LUA_TSTRING);
	t = lua_type(lua, 3);
	luaL_argcheck(lua, t == LUA_TSTRING || t == LUA_TNIL, 3,
	    "string or nil expected");
	t = lua_type(lua, 4);
	luaL_argcheck(lua, t == LUA_TSTRING || t == LUA_TNIL, 4,
	    "string or nil expected");
	t = lua_type(lua, 5);
	luaL_argcheck(lua, t == LUA_TSTRING || t == LUA_TNIL, 5,
	    "string or nil expected");
	t = lua_type(lua, 6);
	luaL_argcheck(lua, t == LUA_TSTRING || t == LUA_TNIL, 6,
	    "string or nil expected");

	r = request_login(&s, lua_tostring(lua, 1), lua_tostring(lua, 2),
	    lua_tostring(lua, 3), lua_tostring(lua, 4), lua_tostring(lua, 5),
	    lua_tostring(lua, 6));

	lua_pop(lua, 5);

	if (r == -1)
		return 0;

	lua_pushboolean(lua, (r == STATUS_OK || r == STATUS_PREAUTH));
	lua_pushlightuserdata(lua, (void *)(s));

	return 2;
}