explicitly attempt to start empdd from empc on startup
this fixes autoconnection on more pedantic systems: gentoo doesn't seem to need it, yet fedora does? by making StartServiceByName the first call, it's easier to know if empdd needs a connect() method call and then to send it before any other method calls so that startup remains smooth behind the scenes
This commit is contained in:
parent
5cd08a5df9
commit
71427769de
|
@ -3669,6 +3669,62 @@ static const Eldbus_Service_Interface_Desc base_desc =
|
|||
EMPC_METHOD_BASE, empc_methods, empc_signals, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static void
|
||||
empd_send_connect(void)
|
||||
{
|
||||
const char *h, *pass = NULL, *p = NULL;
|
||||
char host[PATH_MAX] = {0};
|
||||
int port = DEFAULT_PORT;
|
||||
|
||||
pass = getenv("MPD_PASSWORD");
|
||||
p = getenv("MPD_PORT");
|
||||
h = getenv("MPD_HOST");
|
||||
if (h)
|
||||
{
|
||||
if (!p)
|
||||
p = strchr(h, ':');
|
||||
if (p)
|
||||
{
|
||||
if (p - h > PATH_MAX - 1)
|
||||
{
|
||||
fprintf(stderr, "MPD_HOST longer than 4096 chars? I don't believe you.\n");
|
||||
/* FIXME */
|
||||
error_o_doom();
|
||||
return;
|
||||
}
|
||||
port = strtol(p + 1, NULL, 10);
|
||||
memcpy(host, h, p - h);
|
||||
h = host;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (!stat("/var/lib/mpd/socket", &st))
|
||||
h = "/var/lib/mpd/socket";
|
||||
else if (!stat("/run/mpd/socket", &st))
|
||||
h = "/run/mpd/socket";
|
||||
}
|
||||
empd_empdd_connect_call(empd_proxy, h ?: "", port, pass ?: "");
|
||||
}
|
||||
|
||||
static void
|
||||
empd_name_start(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
|
||||
{
|
||||
unsigned flag = 0;
|
||||
|
||||
if ((!eldbus_message_arguments_get(msg, "u", &flag)) || (!flag))
|
||||
{
|
||||
error_o_doom();
|
||||
return;
|
||||
}
|
||||
if (flag == ELDBUS_NAME_START_REPLY_SUCCESS)
|
||||
empd_send_connect();
|
||||
else
|
||||
empd_empdd_is_connected_call(empd_proxy, empc_isconnected, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -3718,8 +3774,9 @@ main(int argc, char *argv[])
|
|||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||
|
||||
dbus_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
|
||||
empd_proxy = empd_empdd_proxy_get(dbus_conn, EMPDD_METHOD_BASE, NULL);
|
||||
eldbus_name_start(dbus_conn, EMPDD_METHOD_BASE, 0, empd_name_start, NULL);
|
||||
empc_proxy = empd_empc_proxy_get(dbus_conn, EMPC_METHOD_BASE, NULL);
|
||||
empd_proxy = empd_empdd_proxy_get(dbus_conn, EMPDD_METHOD_BASE, NULL);
|
||||
eldbus_name_request(dbus_conn, EMPC_METHOD_BASE, 0, dbus_request_name, NULL);
|
||||
eldbus_name_owner_changed_callback_add(dbus_conn, EMPC_METHOD_BASE, dbus_name_changed, NULL, EINA_FALSE);
|
||||
empc_iface = eldbus_service_interface_register(dbus_conn, "/", &base_desc);
|
||||
|
@ -3744,8 +3801,6 @@ main(int argc, char *argv[])
|
|||
E_LIST_HANDLER_APPEND(handlers, EMPD_EMPDD_DATABASE_UPDATE_END_EVENT, empc_database_end, NULL);
|
||||
E_LIST_HANDLER_APPEND(handlers, EMPD_EMPC_BACKGROUND_CHANGED_EVENT, empc_bg_changed, NULL);
|
||||
|
||||
empd_empdd_is_connected_call(empd_proxy, empc_isconnected, NULL);
|
||||
|
||||
win = elm_win_add(NULL, "empc", ELM_WIN_BASIC);
|
||||
elm_object_style_set(win, "empc");
|
||||
elm_win_title_set(win, "empc");
|
||||
|
|
Loading…
Reference in New Issue