From 49cab81fca86747e48f4240ab3d65f82b0756606 Mon Sep 17 00:00:00 2001 From: Philippe De Swert Date: Tue, 13 May 2014 13:15:25 +0300 Subject: [PATCH] [gconf] Remove gconf schemas file from packaging as it is not used. Contributes: JB#19322 Signed-off-by: Philippe De Swert --- rpm/usb-moded.spec | 2 -- src/usb_moded-network.c | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/rpm/usb-moded.spec b/rpm/usb-moded.spec index 084aee0..4e28f6b 100644 --- a/rpm/usb-moded.spec +++ b/rpm/usb-moded.spec @@ -265,7 +265,6 @@ install -m 644 -D src/usb_moded-appsync-dbus.h %{buildroot}/%{_includedir}/%{nam install -m 644 -D usb_moded.pc %{buildroot}/%{_libdir}/pkgconfig/usb_moded.pc install -d %{buildroot}/%{_docdir}/%{name}/html/ install -m 644 docs/html/* %{buildroot}/%{_docdir}/%{name}/html/ -install -m 644 -D debian/%{name}.schemas %{buildroot}/%{_sysconfdir}/gconf/schemas/%{name}.schemas install -m 644 -D debian/manpage.1 %{buildroot}/%{_mandir}/man1/usb-moded.1 install -m 644 -D debian/usb_moded.conf %{buildroot}/%{_sysconfdir}/dbus-1/system.d/usb_moded.conf install -m 644 -D %{SOURCE2} %{buildroot}/%{_sysconfdir}/modprobe.d/usb_moded.conf @@ -296,7 +295,6 @@ systemctl daemon-reload || : %defattr(-,root,root,-) %doc debian/copyright %config(noreplace) %{_sysconfdir}/dbus-1/system.d/usb_moded.conf -%config(noreplace) %{_sysconfdir}/gconf/schemas/%{name}.schemas %config(noreplace) %{_sysconfdir}/modprobe.d/usb_moded.conf %ghost %config(noreplace) %{_sysconfdir}/modprobe.d/g_ether.conf %{_sbindir}/usb_moded diff --git a/src/usb_moded-network.c b/src/usb_moded-network.c index ac40d14..50b672f 100644 --- a/src/usb_moded-network.c +++ b/src/usb_moded-network.c @@ -354,7 +354,7 @@ static int write_udhcpd_conf(struct ipforward_data *ipforward, struct mode_list_ /** * Connman message handling */ -static const char * connman_parse_manager_reply(DBusMessage *reply) +static const char * connman_parse_manager_reply(DBusMessage *reply, const char *req_service) { DBusMessageIter iter, subiter, origiter; int type; @@ -378,9 +378,9 @@ static const char * connman_parse_manager_reply(DBusMessage *reply) { dbus_message_iter_get_basic(&iter, &service); log_debug("service = %s\n", service); - if(strstr(service, "cellular")) + if(strstr(service, req_service)) { - log_debug("cellular service found!\n"); + log_debug("%s service found!\n", req_service); return(strdup(service)); } iter = origiter; @@ -501,20 +501,45 @@ static int connman_fill_connection_data(DBusMessage *reply, struct ipforward_dat /** * Turn on cellular connection if it is not on */ -static int connman_set_cellular_online(DBusConnection *dbus_conn_connman, const char *service) +static int connman_set_cellular_online(DBusConnection *dbus_conn_connman, const char *service, int retry) { - DBusMessage *msg = NULL; + DBusMessage *msg = NULL, *reply; DBusError error; int ret = 0; + const char *wifi = NULL; dbus_error_init(&error); + if(!retry) + { + if ((msg = dbus_message_new_method_call("net.connman", "/", "net.connman.Manager", "GetServices")) != NULL) + { + if ((reply = dbus_connection_send_with_reply_and_block(dbus_conn_connman, msg, -1, NULL)) != NULL) + { + wifi = connman_parse_manager_reply(reply, "wifi"); + dbus_message_unref(reply); + } + dbus_message_unref(msg); + } + + if(wifi != NULL) + { + /* we must make sure that wifi is disconnected as sometimes cellular will not come up otherwise */ + if ((msg = dbus_message_new_method_call("net.connman", wifi, "net.connman.Service", "Disconnect")) != NULL) + { + /* we don't care for the reply, which is empty anyway if all goes well */ + ret = !dbus_connection_send(dbus_conn_connman, msg, NULL); + dbus_connection_flush(dbus_conn_connman); + dbus_message_unref(msg); + } + } + } if ((msg = dbus_message_new_method_call("net.connman", service, "net.connman.Service", "Connect")) != NULL) { /* we don't care for the reply, which is empty anyway if all goes well */ ret = !dbus_connection_send(dbus_conn_connman, msg, NULL); /* sleep for the connection to come up */ - sleep(3); + sleep(5); /* make sure the message is sent before cleaning up and closing the connection */ dbus_connection_flush(dbus_conn_connman); dbus_message_unref(msg); @@ -543,7 +568,7 @@ static int connman_get_connection_data(struct ipforward_data *ipforward) { if ((reply = dbus_connection_send_with_reply_and_block(dbus_conn_connman, msg, -1, NULL)) != NULL) { - service = connman_parse_manager_reply(reply); + service = connman_parse_manager_reply(reply, "cellular"); dbus_message_unref(reply); } dbus_message_unref(msg); @@ -559,7 +584,7 @@ static int connman_get_connection_data(struct ipforward_data *ipforward) { if(connman_fill_connection_data(reply, ipforward)) { - if(!connman_set_cellular_online(dbus_conn_connman, service) && !online) + if(!connman_set_cellular_online(dbus_conn_connman, service, online) && !online) { online = 1; goto try_again;