-/*
- * dhcpcd-gtk
- * Copyright 2009 Roy Marples <roy@marples.name>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+=/*
+ * dhcpcd-gtk
+ * Copyright 2009 Roy Marples <roy@marples.name>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
/* TODO: Animate the icon from carrier -> address
* maybe use network-idle -> network-transmit ->
if (error) {
g_critical("%s: %s", msg, error->message);
dialog = gtk_message_dialog_new(NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s: %s",
- msg,
- error->message);
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s: %s",
+ msg,
+ error->message);
} else {
g_critical("%s", msg);
dialog = gtk_message_dialog_new(NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s",
- msg);
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s",
+ msg);
}
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
otype = dbus_g_type_get_collection("GPtrArray", otype);
if (!dbus_g_proxy_call(dbus, "ScanResults", &error,
- G_TYPE_STRING, ifm->ifname, G_TYPE_INVALID,
- otype, &array, G_TYPE_INVALID))
+ G_TYPE_STRING, ifm->ifname, G_TYPE_INVALID,
+ otype, &array, G_TYPE_INVALID))
error_exit(_("ScanResults"), error);
for (i = 0; i < array->len; i++) {
reason = N_("Disassociated from");
showssid = TRUE;
} else
- reason = N_("Not associated");
+ reason = N_("Not associated");
} else
reason = N_("Cable unplugged");
showip = FALSE;
ani_timer = g_timeout_add(500, animate_carrier, NULL);
} else {
gtk_status_icon_set_from_icon_name(status_icon,
- "network-offline");
+ "network-offline");
}
}
gtk_status_icon_set_tooltip(status_icon, msgs);
notify_notification_close(nn, NULL);
if (gtk_status_icon_get_visible(status_icon))
nn = notify_notification_new_with_status_icon(title,
- msg,
- icon,
- status_icon);
+ msg,
+ icon,
+ status_icon);
else
nn = notify_notification_new(title, msg, icon, NULL);
notify_notification_set_timeout(nn, 5000);
otype = dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE);
otype = dbus_g_type_get_map("GHashTable", G_TYPE_STRING, otype);
if (!dbus_g_proxy_call(dbus, "GetInterfaces", &error,
- G_TYPE_INVALID,
- otype, &ifs, G_TYPE_INVALID))
+ G_TYPE_INVALID,
+ otype, &ifs, G_TYPE_INVALID))
error_exit("GetInterfaces", error);
g_hash_table_foreach(ifs, foreach_make_ifm, NULL);
g_hash_table_unref(ifs);
g_strfreev(interface_order);
interface_order = NULL;
if (!dbus_g_proxy_call(dbus, "ListInterfaces", &error,
- G_TYPE_INVALID,
- G_TYPE_STRV, &interface_order, G_TYPE_INVALID))
+ G_TYPE_INVALID,
+ G_TYPE_STRV, &interface_order, G_TYPE_INVALID))
error_exit("ListInterfaces", error);
interfaces = g_list_sort(interfaces, if_msg_comparer);
if (!ifm->wireless)
continue;
if (!dbus_g_proxy_call(dbus, "ScanResults", &error,
- G_TYPE_STRING, ifm->ifname, G_TYPE_INVALID,
- otype, &array, G_TYPE_INVALID))
+ G_TYPE_STRING, ifm->ifname, G_TYPE_INVALID,
+ otype, &array, G_TYPE_INVALID))
{
g_message("ScanResults: %s", error->message);
g_clear_error(&error);
if (!refresh)
return;
if (!dbus_g_proxy_call(dbus, "GetDhcpcdVersion", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &version, G_TYPE_INVALID))
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &version, G_TYPE_INVALID))
error_exit(_("GetDhcpcdVersion"), error);
g_message(_("Connected to %s-%s"), "dhcpcd", version);
g_free(version);
if (bus == NULL || error != NULL)
error_exit(_("Could not connect to system bus"), error);
dbus = dbus_g_proxy_new_for_name(bus,
- DHCPCD_SERVICE,
- DHCPCD_PATH,
- DHCPCD_SERVICE);
+ DHCPCD_SERVICE,
+ DHCPCD_PATH,
+ DHCPCD_SERVICE);
g_message(_("Connecting to dhcpcd-dbus ..."));
while (--tries > 0) {
g_clear_error(&error);
if (dbus_g_proxy_call_with_timeout(dbus,
- "GetVersion",
- 500,
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING,
- &version,
- G_TYPE_INVALID))
+ "GetVersion",
+ 500,
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING,
+ &version,
+ G_TYPE_INVALID))
break;
}
if (tries == 0)
menu_init(status_icon);
if (!dbus_g_proxy_call(dbus, "GetStatus", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &version, G_TYPE_INVALID))
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &version, G_TYPE_INVALID))
error_exit(_("GetStatus"), error);
check_status(version);
g_free(version);
otype = dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE);
dbus_g_proxy_add_signal(dbus, "Event",
- otype, G_TYPE_INVALID);
+ otype, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(dbus, "Event",
- G_CALLBACK(dhcpcd_event),
- bus, NULL);
+ G_CALLBACK(dhcpcd_event),
+ bus, NULL);
dbus_g_proxy_add_signal(dbus, "StatusChanged",
- G_TYPE_STRING, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(dbus, "StatusChanged",
- G_CALLBACK(dhcpcd_status),
- bus, NULL);
+ G_CALLBACK(dhcpcd_status),
+ bus, NULL);
dbus_g_proxy_add_signal(dbus, "ScanResults",
- G_TYPE_STRING, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(dbus, "ScanResults",
- G_CALLBACK(dhcpcd_scan_results),
- bus, NULL);
+ G_CALLBACK(dhcpcd_scan_results),
+ bus, NULL);
gtk_main();
return 0;
static const char *copyright = "Copyright (c) 2009 Roy Marples";
-static const char *authors[] = {
- "Roy Marples <roy@marples.name>",
- NULL
-};
+static const char *authors[] = { "Roy Marples <roy@marples.name>", NULL };
static void
on_quit(_unused GtkMenuItem *item, _unused gpointer data)
gtk_about_dialog_set_email_hook(email_hook, NULL, NULL);
gtk_about_dialog_set_url_hook(url_hook, NULL, NULL);
gtk_show_about_dialog(NULL,
- "version", VERSION,
- "copyright", copyright,
- "website-label", "dhcpcd Website",
- "website", "http://roy.marples.name/projects/dhcpcd",
- "authors", authors,
- "logo-icon-name", GTK_STOCK_NETWORK,
- NULL);
+ "version", VERSION,
+ "copyright", copyright,
+ "website-label", "dhcpcd Website",
+ "website", "http://roy.marples.name/projects/dhcpcd",
+ "authors", authors,
+ "logo-icon-name", GTK_STOCK_NETWORK,
+ NULL);
}
static void
else
icon = "network-wireless-encrypted";
image = gtk_image_new_from_icon_name(icon,
- GTK_ICON_SIZE_MENU);
+ GTK_ICON_SIZE_MENU);
gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0);
bar = gtk_progress_bar_new();
gtk_widget_show(image);
gtk_widget_show(box);
g_signal_connect(G_OBJECT(item), "activate",
- G_CALLBACK(ssid_hook), gl->data);
+ G_CALLBACK(ssid_hook), gl->data);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
}
}
#if 0
item = gtk_image_menu_item_new_with_label(ifm->name);
image = gtk_image_new_from_icon_name("network-wireless",
- GTK_ICON_SIZE_MENU);
+ GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
}
gtk_widget_show_all(GTK_WIDGET(menu));
gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
- gtk_status_icon_position_menu, icon,
- 1, gtk_get_current_event_time());
+ gtk_status_icon_position_menu, icon,
+ 1, gtk_get_current_event_time());
}
static void
item = gtk_image_menu_item_new_with_mnemonic(_("_Quit"));
image = gtk_image_new_from_icon_name(GTK_STOCK_QUIT,
- GTK_ICON_SIZE_MENU);
+ GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
g_signal_connect(G_OBJECT(item), "activate",
- G_CALLBACK(on_quit), icon);
+ G_CALLBACK(on_quit), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
item = gtk_separator_menu_item_new();
item = gtk_image_menu_item_new_with_mnemonic(_("_Help"));
image = gtk_image_new_from_icon_name(GTK_STOCK_HELP,
- GTK_ICON_SIZE_MENU);
+ GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
g_signal_connect(G_OBJECT(item), "activate",
- G_CALLBACK(on_help), icon);
+ G_CALLBACK(on_help), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
item = gtk_image_menu_item_new_with_mnemonic(_("_About"));
image = gtk_image_new_from_icon_name(GTK_STOCK_ABOUT,
- GTK_ICON_SIZE_MENU);
+ GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
g_signal_connect(G_OBJECT(item), "activate",
- G_CALLBACK(on_about), icon);
+ G_CALLBACK(on_about), icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
gtk_widget_show_all(GTK_WIDGET(menu));
gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
- gtk_status_icon_position_menu, data, button, atime);
+ gtk_status_icon_position_menu, data, button, atime);
if (button == 0)
gtk_menu_shell_select_first(GTK_MENU_SHELL(menu), FALSE);
}
menu_init(GtkStatusIcon *icon)
{
g_signal_connect_object(G_OBJECT(icon), "activate",
- G_CALLBACK(on_activate), icon, 0);
+ G_CALLBACK(on_activate), icon, 0);
g_signal_connect_object(G_OBJECT(icon), "popup_menu",
- G_CALLBACK(on_popup), icon, 0);
+ G_CALLBACK(on_popup), icon, 0);
}
char *nssid;
otype = dbus_g_type_get_struct("GValueArray",
- G_TYPE_INT,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INVALID);
+ G_TYPE_INT,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
otype = dbus_g_type_get_collection("GPtrArray", otype);
error = NULL;
if (!dbus_g_proxy_call(dbus, "ListNetworks", &error,
- G_TYPE_STRING, ifname, G_TYPE_INVALID,
- otype, &array, G_TYPE_INVALID))
+ G_TYPE_STRING, ifname, G_TYPE_INVALID,
+ otype, &array, G_TYPE_INVALID))
{
g_warning("ListNetworks: %s", error->message);
g_error_free(error);
}
if (!dbus_g_proxy_call(dbus, "AddNetwork", &error,
- G_TYPE_STRING, ifname, G_TYPE_INVALID,
- G_TYPE_INT, &id, G_TYPE_INVALID))
+ G_TYPE_STRING, ifname, G_TYPE_INVALID,
+ G_TYPE_INT, &id, G_TYPE_INVALID))
{
g_warning("AddNetwork: %s", error->message);
g_error_free(error);
nssid = g_strconcat("\"", ssid, "\"", NULL);
if (!dbus_g_proxy_call(dbus, "SetNetwork", &error,
- G_TYPE_STRING, ifname,
- G_TYPE_INT, id,
- G_TYPE_STRING, "ssid",
- G_TYPE_STRING, nssid,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
+ G_TYPE_STRING, ifname,
+ G_TYPE_INT, id,
+ G_TYPE_STRING, "ssid",
+ G_TYPE_STRING, nssid,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID))
{
g_warning("SetNetwork: %s", error->message);
g_free(nssid);
static int
configure_network(const char *ifname, int id, const char *mgmt,
- const char *var, const char *val,
- gboolean quote)
+ const char *var, const char *val,
+ gboolean quote)
{
GError *error;
char *str;
return -1;
dbus_g_proxy_call(dbus, "SetNetwork", &error,
- G_TYPE_STRING, ifname,
- G_TYPE_INT, id,
- G_TYPE_STRING, "key_mgmt",
- G_TYPE_STRING, mgmt,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ G_TYPE_STRING, ifname,
+ G_TYPE_INT, id,
+ G_TYPE_STRING, "key_mgmt",
+ G_TYPE_STRING, mgmt,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
error = NULL;
if (quote)
else
str = NULL;
if (!dbus_g_proxy_call(dbus, "SetNetwork", &error,
- G_TYPE_STRING, ifname,
- G_TYPE_INT, id,
- G_TYPE_STRING, var,
- G_TYPE_STRING, quote ? str : val,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
+ G_TYPE_STRING, ifname,
+ G_TYPE_INT, id,
+ G_TYPE_STRING, var,
+ G_TYPE_STRING, quote ? str : val,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID))
{
g_warning("SetNetwork: %s", error->message);
g_free(str);
g_error_free(error);
dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Failed to set password, probably too short."));
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Failed to set password, probably too short."));
gtk_window_set_title(GTK_WINDOW(dialog),
- _("Error setting password"));
+ _("Error setting password"));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return -1;
g_free(str);
if (!dbus_g_proxy_call(dbus, "EnableNetwork", &error,
- G_TYPE_STRING, ifname,
- G_TYPE_INT, id,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
+ G_TYPE_STRING, ifname,
+ G_TYPE_INT, id,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID))
{
g_warning("EnableNetwork: %s", error->message);
g_error_free(error);
}
if (!dbus_g_proxy_call(dbus, "SaveConfig", &error,
- G_TYPE_STRING, ifname,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
+ G_TYPE_STRING, ifname,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID))
{
g_warning("SaveConfig: %s", error->message);
if (!warned) {
warned = TRUE;
dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Failed to save wpa_supplicant configuration.\n\nYou should add update_config=1 to /etc/wpa_supplicant.conf.\nThis warning will not appear again until program restarted."));
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Failed to save wpa_supplicant configuration.\n\nYou should add update_config=1 to /etc/wpa_supplicant.conf.\nThis warning will not appear again until program restarted."));
gtk_window_set_title(GTK_WINDOW(dialog),
- _("Error saving configuration"));
+ _("Error saving configuration"));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
g_error_free(error);
}
/*
- if (!dbus_g_proxy_call(dbus, "Disconnect", &error,
- G_TYPE_STRING, ifname,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- {
- g_warning("Disconnect: %s", error->message);
- g_error_free(error);
- }
+ if (!dbus_g_proxy_call(dbus, "Disconnect", &error,
+ G_TYPE_STRING, ifname,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID))
+ {
+ g_warning("Disconnect: %s", error->message);
+ g_error_free(error);
+ }
*/
if (!dbus_g_proxy_call(dbus, "Reassociate", &error,
- G_TYPE_STRING, ifname,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
+ G_TYPE_STRING, ifname,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID))
{
g_warning("Reassociate: %s", error->message);
g_error_free(error);
gint result, id, retval;
dialog = gtk_dialog_new_with_buttons(ifa->ssid,
- NULL,
- GTK_DIALOG_MODAL,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
- NULL);
+ NULL,
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ NULL);
gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
gtk_window_set_icon_name(GTK_WINDOW(dialog), "config-users");
gtk_dialog_set_default_response(GTK_DIALOG(dialog),
- GTK_RESPONSE_ACCEPT);
+ GTK_RESPONSE_ACCEPT);
vbox = GTK_DIALOG(dialog)->vbox;
hbox = gtk_hbox_new(FALSE, 2);
}
if (id != -1) {
retval = configure_network(ifa->ifname, id, mgt, var,
- gtk_entry_get_text(GTK_ENTRY(psk)), TRUE);
+ gtk_entry_get_text(GTK_ENTRY(psk)), TRUE);
}
}
gtk_widget_destroy(dialog);