DhcpcdQt::DhcpcdQt()
{

	createActions();
	createTrayIcon();

	onLine = carrier = false;
	lastStatus = NULL;
	aniTimer = new QTimer(this);
	connect(aniTimer, SIGNAL(timeout()), this, SLOT(animate()));
	notifier = NULL;
	retryOpenTimer = NULL;

	about = NULL;
	preferences = NULL;

	wis = new QList<DhcpcdWi *>();
	ssidMenu = NULL;

	qDebug("%s", "Connecting ...");
	con = dhcpcd_new();
	if (con == NULL) {
		qCritical("libdhcpcd: %s", strerror(errno));
		exit(EXIT_FAILURE);
		return;
	}
	dhcpcd_set_progname(con, "dhcpcd-qt");
	dhcpcd_set_status_callback(con, dhcpcd_status_cb, this);
	dhcpcd_set_if_callback(con, dhcpcd_if_cb, this);
	dhcpcd_wpa_set_scan_callback(con, dhcpcd_wpa_scan_cb, this);
	dhcpcd_wpa_set_status_callback(con, dhcpcd_wpa_status_cb, this);
	tryOpen();
}
Exemple #2
0
int
main(int argc, char *argv[])
{
	DHCPCD_CONNECTION *con;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, NULL);
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain(PACKAGE);

	gtk_init(&argc, &argv);
	g_set_application_name("Network Configurator");
	gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
	    ICONDIR);
	status_icon = gtk_status_icon_new_from_icon_name("network-offline");

	gtk_status_icon_set_tooltip_text(status_icon,
	    _("Connecting to dhcpcd ..."));
	gtk_status_icon_set_visible(status_icon, true);
	online = false;
#ifdef NOTIFY
	notify_init(PACKAGE);
#endif

	g_message(_("Connecting ..."));
	con = dhcpcd_new();
	if (con ==  NULL) {
		g_critical("libdhcpcd: %s", strerror(errno));
		exit(EXIT_FAILURE);
	}
	dhcpcd_set_progname(con, "dhcpcd-gtk");
	dhcpcd_set_status_callback(con, dhcpcd_status_cb, NULL);
	dhcpcd_set_if_callback(con, dhcpcd_if_cb, NULL);
	dhcpcd_wpa_set_scan_callback(con, dhcpcd_wpa_scan_cb, NULL);
	//dhcpcd_wpa_set_status_callback(con, dhcpcd_wpa_status_cb, NULL);
	if (dhcpcd_try_open(con))
		g_timeout_add(DHCPCD_RETRYOPEN, dhcpcd_try_open, con);

	menu_init(status_icon, con);

	gtk_main();
	dhcpcd_close(con);
	dhcpcd_free(con);
	return 0;
}