Example #1
0
/* add a custom mirror to the list */
void add_mirror(GtkWidget *button, gpointer data)
{
	GtkTreeIter iter;
	GtkTreeView *treeview = (GtkTreeView *)data;
	GtkTreeModel *model = gtk_tree_view_get_model (treeview);
	char* sName = NULL;

	sName = fwife_entry(_("Add a custom server"),
						_("You may specify a custom mirror (eg. LAN) so you can download packages faster.\nEnter server's address below :")
						, NULL);
	if(sName && strcmp(sName, "")) {
		gtk_list_store_append (GTK_LIST_STORE (model), &iter);
		gtk_list_store_set (GTK_LIST_STORE (model), &iter,
							COLUMN_USE, TRUE, COLUMN_NAME, sName, COLUMN_FROM, "CUSTOM", -1);
	}
	return;
}
Example #2
0
int run(GList **config)
{
	int i, ret;	
	fwnet_profile_t *newprofile=NULL;

	if((newprofile = (fwnet_profile_t*)malloc(sizeof(fwnet_profile_t))) == NULL)
		return(1);
	memset(newprofile, 0, sizeof(fwnet_profile_t));
	
	sprintf(newprofile->name, "default");
	for(i = 1; i<g_list_length(interfaceslist); i+=2)
	{
		newprofile->interfaces = g_list_append(newprofile->interfaces, (fwnet_interface_t *) g_list_nth_data(interfaceslist, i));
	}
	switch(fwife_question(_("Do you want to configure a DSL connexion now?")))
	{
		case GTK_RESPONSE_YES:
			dsl_config(newprofile);
		break;
		case GTK_RESPONSE_NO:
		break;
	}
	char *host = fwife_entry(_("Hostname"), _("We'll need the name you'd like to give your host.\nThe full hostname is needed, such as:\n\nfrugalware.example.net\n\nEnter full hostname:"), "frugalware.example.net");

	pid_t pid = fork();

	if(pid == -1)
		LOG("Error when forking process in grubconf plugin.");
	else if(pid == 0)
	{
		chroot(TARGETDIR);
		fwnet_writeconfig(newprofile, host);
		exit(0);
	}
	else
	{
		wait(&ret);
	}
	
	FREE(host);
	return 0;
}
Example #3
0
int add_interface(GtkWidget *button, gpointer data)
{
	fwnet_interface_t *newinterface = NULL;
	GtkWidget *cellview;
	GdkPixbuf *connectimg;
	char *ptr=NULL;
	char *nettype=NULL;
	char *iface=NULL;

	GtkTreeIter iter;
	GtkTreeModel *model;
	gtk_combo_box_get_active_iter(GTK_COMBO_BOX(intercombo), &iter);
	model = gtk_combo_box_get_model(GTK_COMBO_BOX(intercombo));
	gtk_tree_model_get (model, &iter, 0, &iface, -1);

	int i;
	for(i=0;i<g_list_length(interfaceslist); i+=2)
	{
		if(!strcmp((char*)g_list_nth_data(interfaceslist, i), iface))
		{
			fwife_error("This interface has been already configured!");
			return -1;
		}
	}
	
	if((newinterface = (fwnet_interface_t*)malloc(sizeof(fwnet_interface_t))) == NULL)
		return(-1);
	memset(newinterface, 0, sizeof(fwnet_interface_t));
	
	snprintf(newinterface->name, IF_NAMESIZE, iface);
	
	nettype = ask_nettype();
	if(nettype == NULL)
		return -1;

	if(strcmp(nettype, "lo"))
	{
		interfaceslist = g_list_append(interfaceslist, strdup(iface));
		interfaceslist = g_list_append(interfaceslist, newinterface);

		GtkTreeView *treeview = (GtkTreeView *)data;
  		model = gtk_tree_view_get_model (treeview);

		cellview = gtk_cell_view_new ();
	    	connectimg = gtk_widget_render_icon (cellview, GTK_STOCK_NETWORK,
					GTK_ICON_SIZE_BUTTON, NULL);
	   	gtk_widget_destroy (cellview);

		gtk_list_store_append (GTK_LIST_STORE (model), &iter);
		gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IMAGE, connectimg, COLUMN_NET_NAME, iface, -1);		
	}

	if(strcmp(nettype, "lo") && fwnet_is_wireless_device(iface))
	{
		switch(fwife_question(_("It seems that this network card has a wireless extension.\n\nConfigure your wireless now?")))
					{
						case GTK_RESPONSE_YES:
							configure_wireless(newinterface);
							break;
						case GTK_RESPONSE_NO:
							break;
					}
	}
	
	if(!strcmp(nettype, "dhcp"))
	{
		ptr = fwife_entry(_("Set DHCP hostname"), _("Some network providers require that the DHCP hostname be\n"
			"set in order to connect.\n If so, they'll have assigned a hostname to your machine.\n If you were"
			"assigned a DHCP hostname, please enter it below.\n If you do not have a DHCP hostname, just"
			"hit enter."), NULL);
		if(strlen(ptr))
			snprintf(newinterface->dhcp_opts, PATH_MAX, "-t 10 -h %s\n", ptr);
		else
			newinterface->dhcp_opts[0]='\0';
		newinterface->options = g_list_append(newinterface->options, strdup("dhcp"));
		gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IP, "dhcp", COLUMN_NET_NAMESERV, ptr, -1);
		FREE(ptr);
	}
	else if(!strcmp(nettype, "static"))
	{
		configure_static(newinterface, iter);
	}

	return 0;
}