discomfitor pushed a commit to branch master. http://git.enlightenment.org/apps/empc.git/commit/?id=71427769dec951e073fa7c73fc2435efac381992
commit 71427769dec951e073fa7c73fc2435efac381992 Author: Mike Blumenkrantz <zm...@osg.samsung.com> Date: Sun Sep 6 22:17:52 2015 -0400 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 --- src/bin/empc.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/src/bin/empc.c b/src/bin/empc.c index dc538fb..3a83b3b 100644 --- a/src/bin/empc.c +++ b/src/bin/empc.c @@ -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"); --