forked from enlightenment/enlightenment
add pulse_disconnect() function and properly send disconnect events when disconnecting during pulse auth
SVN revision: 77505
This commit is contained in:
parent
0d3c51e8bc
commit
d40acc5046
|
@ -37,6 +37,7 @@ void pulse_shutdown(void);
|
||||||
|
|
||||||
Pulse *pulse_new(void);
|
Pulse *pulse_new(void);
|
||||||
Eina_Bool pulse_connect(Pulse *conn);
|
Eina_Bool pulse_connect(Pulse *conn);
|
||||||
|
void pulse_disconnect(Pulse *conn);
|
||||||
void pulse_free(Pulse *conn);
|
void pulse_free(Pulse *conn);
|
||||||
void pulse_cb_set(Pulse *conn, uint32_t tagnum, Pulse_Cb cb);
|
void pulse_cb_set(Pulse *conn, uint32_t tagnum, Pulse_Cb cb);
|
||||||
void pulse_server_info_free(Pulse_Server_Info *ev);
|
void pulse_server_info_free(Pulse_Server_Info *ev);
|
||||||
|
|
|
@ -33,8 +33,7 @@ msg_recv_creds(Pulse *conn, Pulse_Tag *tag)
|
||||||
if (errno != EAGAIN)
|
if (errno != EAGAIN)
|
||||||
{
|
{
|
||||||
ERR("%d: %s", errno, strerror(errno));
|
ERR("%d: %s", errno, strerror(errno));
|
||||||
ecore_main_fd_handler_del(conn->fdh);
|
pulse_disconnect(conn);
|
||||||
conn->fdh = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -84,8 +83,7 @@ msg_recv(Pulse *conn, Pulse_Tag *tag)
|
||||||
if (errno != EAGAIN)
|
if (errno != EAGAIN)
|
||||||
{
|
{
|
||||||
ERR("%d: %s", errno, strerror(errno));
|
ERR("%d: %s", errno, strerror(errno));
|
||||||
ecore_main_fd_handler_del(conn->fdh);
|
pulse_disconnect(conn);
|
||||||
conn->fdh = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -138,8 +136,7 @@ msg_sendmsg_creds(Pulse *conn, Pulse_Tag *tag)
|
||||||
if (errno != EAGAIN)
|
if (errno != EAGAIN)
|
||||||
{
|
{
|
||||||
ERR("%d: %s", errno, strerror(errno));
|
ERR("%d: %s", errno, strerror(errno));
|
||||||
ecore_main_fd_handler_del(conn->fdh);
|
pulse_disconnect(conn);
|
||||||
conn->fdh = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -165,8 +162,7 @@ msg_send_creds(Pulse *conn, Pulse_Tag *tag)
|
||||||
if (errno != EAGAIN)
|
if (errno != EAGAIN)
|
||||||
{
|
{
|
||||||
ERR("%d: %s", errno, strerror(errno));
|
ERR("%d: %s", errno, strerror(errno));
|
||||||
ecore_main_fd_handler_del(conn->fdh);
|
pulse_disconnect(conn);
|
||||||
conn->fdh = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -198,8 +194,7 @@ msg_send(Pulse *conn, Pulse_Tag *tag)
|
||||||
if (errno != EAGAIN)
|
if (errno != EAGAIN)
|
||||||
{
|
{
|
||||||
ERR("%d: %s", errno, strerror(errno));
|
ERR("%d: %s", errno, strerror(errno));
|
||||||
ecore_main_fd_handler_del(conn->fdh);
|
pulse_disconnect(conn);
|
||||||
conn->fdh = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -196,11 +196,7 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh)
|
||||||
if (!tag->dsize)
|
if (!tag->dsize)
|
||||||
{
|
{
|
||||||
ERR("Kicked!");
|
ERR("Kicked!");
|
||||||
conn->state = PA_STATE_INIT;
|
pulse_disconnect(conn);
|
||||||
ecore_main_fd_handler_del(conn->fdh);
|
|
||||||
conn->fdh = NULL;
|
|
||||||
close(conn->fd);
|
|
||||||
ecore_event_add(PULSE_EVENT_DISCONNECTED, conn, pulse_fake_free, NULL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tag->data = malloc(tag->dsize);
|
tag->data = malloc(tag->dsize);
|
||||||
|
@ -275,6 +271,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
|
||||||
if (!wprev->auth)
|
if (!wprev->auth)
|
||||||
msg_sendmsg_creds(conn, wprev);
|
msg_sendmsg_creds(conn, wprev);
|
||||||
|
|
||||||
|
|
||||||
if (wprev->auth && msg_send(conn, wprev))
|
if (wprev->auth && msg_send(conn, wprev))
|
||||||
{
|
{
|
||||||
conn->state++;
|
conn->state++;
|
||||||
|
@ -354,10 +351,7 @@ con(Pulse *conn, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev)
|
||||||
fd = ecore_con_server_fd_get(ev->server);
|
fd = ecore_con_server_fd_get(ev->server);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
conn->state = PA_STATE_INIT;
|
pulse_disconnect(conn);
|
||||||
ecore_con_server_del(ev->server);
|
|
||||||
conn->svr = NULL;
|
|
||||||
ecore_event_add(PULSE_EVENT_DISCONNECTED, conn, pulse_fake_free, NULL);
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
conn->fd = dup(fd);
|
conn->fd = dup(fd);
|
||||||
|
@ -752,6 +746,27 @@ pulse_connect(Pulse *conn)
|
||||||
return !!conn->svr;
|
return !!conn->svr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pulse_disconnect(Pulse *conn)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(conn);
|
||||||
|
if (conn->state == PA_STATE_INIT) return;
|
||||||
|
conn->state = PA_STATE_INIT;
|
||||||
|
if (conn->fdh)
|
||||||
|
{
|
||||||
|
ecore_main_fd_handler_del(conn->fdh);
|
||||||
|
conn->fdh = NULL;
|
||||||
|
close(conn->fd);
|
||||||
|
conn->fd = -1;
|
||||||
|
}
|
||||||
|
else if (conn->svr)
|
||||||
|
{
|
||||||
|
ecore_con_server_del(conn->svr);
|
||||||
|
conn->svr = NULL;
|
||||||
|
}
|
||||||
|
ecore_event_add(PULSE_EVENT_DISCONNECTED, conn, pulse_fake_free, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pulse_server_info_free(Pulse_Server_Info *ev)
|
pulse_server_info_free(Pulse_Server_Info *ev)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue