if (plugin) {
g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Got HAL condition %s on %s: %s", condition, udi, detail);
- //hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Got HAL condition %s on %s: %s", condition, udi, detail);
- if (strcmp("ButtonPressed", condition) == 0) {
- if (strcmp(USBDEV_PATH, udi) == 0) {
- //mtetherd_status_plugin_usb_plugged_show(plugin);
+ if (g_strcmp0("ButtonPressed", condition) == 0) {
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "is ButtonPressed");
+ if (g_strcmp0(USBDEV_PATH, udi) == 0) {
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "is %s", USBDEV_PATH);
mtetherd_status_plugin_usb_plugged(plugin);
}
}
}
libhal_free_string(interface);
}
- //plugin->priv->net_on = TRUE;
- //enable_button_set_text(plugin->priv->enable_button, plugin->priv->net_on);
}
}
if (plugin) {
g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Got HAL device added on %s", udi);
mtetherd_status_plugin_device_removed(plugin, udi);
- //plugin->priv->net_on = FALSE;
- //enable_button_set_text(plugin->priv->enable_button, plugin->priv->net_on);
}
}
break;
}
if (arg) {
- g_debug("Launching %s", arg);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Launching %s", arg);
const char *command[] = { BIN_DIR "/sudo", arg, NULL };
if (!mtetherd_launch_script(command)) {
g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error launching USB networking script");
GError *err = NULL;
GdkPixbuf *icon = gdk_pixbuf_new_from_file(IMAGE_DIR "/mtetherd-net-icon.png", &err);
if (err) {
- g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Can't load mtetherd icon: %s", err->message);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't load mtetherd icon: %s", err->message);
g_error_free(err);
err = NULL;
}
GtkWidget *image = gtk_image_new_from_pixbuf(icon);
hildon_button_set_image(HILDON_BUTTON(plugin->priv->enable_button), image);
hildon_button_set_image_position(HILDON_BUTTON(plugin->priv->enable_button), GTK_POS_LEFT);
+ gtk_button_set_alignment(GTK_BUTTON(plugin->priv->enable_button), 0, 0.5);
g_object_unref(icon);
}
mtetherd_status_plugin_enable_button_set_text(plugin);
}
if (mtetherd_hal_init(plugin)) {
- plugin->priv->usb_plugged = mtetherd_usb_state(plugin);
plugin->priv->devices = mtetherd_device_list_new();
mtetherd_hal_device_scan(plugin);
+ // Set initial button status
+ mtetherd_status_plugin_usb_plugged(plugin);
} else {
- plugin->priv->usb_plugged = FALSE;
+ // For debugging
+ plugin->priv->usb_plugged = TRUE;
+ mtetherd_status_plugin_usb_plugged_show(plugin);
}
-
- // Update the button status
- mtetherd_status_plugin_usb_plugged_show(plugin);
}
- hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Initialized mtetherd status plugin");
+ //hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Initialized mtetherd status plugin");
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "Initialized mtetherd status plugin");
}
void mtetherd_status_plugin_device_added(MTetherDStatusPlugin *plugin, MTetherDDevice *device) {
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "mtetherd_status_plugin_device_added(%p, %p)", plugin, device);
if (plugin && plugin->priv) {
const gchar *interface = mtetherd_device_get_interface(device);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "interface=%s", interface);
if (mtetherd_device_ok(interface)) {
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "ok");
if (mtetherd_device_list_add(plugin->priv->devices, device)) {
if (g_strcmp0(USBNET_INTERFACE, interface) == 0) {
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "is USB");
plugin->priv->usbnet_state = MTETHERD_STATUS_PLUGIN_USB_NET_ENABLED;
mtetherd_status_plugin_enable_button_set_text(plugin);
}
hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Starting network on %s", interface);
- g_debug("Launching %s", SBIN_DIR "/mtetherd-net-setup.sh");
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Launching %s", SBIN_DIR "/mtetherd-net-setup.sh");
gchar *addr = mtetherd_device_get_addr(device);
gchar *netmask = mtetherd_device_get_netmask(device);
gchar *dhcp_start = mtetherd_device_get_dhcp_start(device);
gchar *dhcp_end = mtetherd_device_get_dhcp_end(device);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "addr=%s netmask=%s dhcp_start=%s dhcp_end=%s", addr, netmask, dhcp_start, dhcp_end);
const char *command[] = { BIN_DIR "/sudo", SBIN_DIR "/mtetherd-net-setup.sh", interface, addr, netmask, dhcp_start, dhcp_end, NULL };
if (!mtetherd_launch_script(command)) {
g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error launching USB networking setup script");
g_free(netmask);
g_free(dhcp_start);
g_free(dhcp_end);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "done");
} else {
g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error adding network interface to list: Maximum number of devices exceeded");
}
}
void mtetherd_status_plugin_device_removed(MTetherDStatusPlugin *plugin, const gchar *udi) {
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "mtetherd_status_plugin_device_removed(%s)", udi);
if (plugin && plugin->priv) {
MTetherDDevice *device = mtetherd_device_list_find(plugin->priv->devices, udi);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "device=%p", device);
if (device) {
const gchar *interface = mtetherd_device_get_interface(device);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "interface=%s", interface);
if (g_strcmp0(USBNET_INTERFACE, interface) == 0) {
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "is USB");
plugin->priv->usbnet_state = MTETHERD_STATUS_PLUGIN_USB_NET_DISABLED;
mtetherd_status_plugin_enable_button_set_text(plugin);
}
hildon_banner_show_informationf(GTK_WIDGET(plugin), NULL, "Shutting down network on %s", interface);
- g_debug("Launching %s", SBIN_DIR "/mtetherd-net-shutdown.sh");
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Launching %s", SBIN_DIR "/mtetherd-net-shutdown.sh");
const char *command[] = { BIN_DIR "/sudo", SBIN_DIR "/mtetherd-net-shutdown.sh", interface, NULL };
if (!mtetherd_launch_script(command)) {
g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error launching USB networking shutdown script");
}
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "done");
}
if (!mtetherd_device_list_remove(plugin->priv->devices, udi)) {
g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Error removing network interface from list: Not found");
}
void mtetherd_status_plugin_usb_plugged(MTetherDStatusPlugin *plugin) {
+ plugin->priv->usb_plugged = mtetherd_usb_state(plugin);
+ g_log(MTETHERD_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "USB plugged status: %s", plugin->priv->usb_plugged ? "on" : "off");
mtetherd_status_plugin_usb_plugged_show(plugin);
}