예제 #1
0
static void
import_items(ICalImporterData *icidata)
{
	ESource *source;
	g_return_if_fail (icidata != NULL);

	source = e_source_selector_peek_primary_selection ((ESourceSelector *)icidata->selector);
	g_return_if_fail ( source != NULL);

	icidata->client = auth_new_cal_from_source (source, icidata->source_type);
	e_cal_open (icidata->client, FALSE, NULL);

	switch (icidata->source_type) {
	case E_CAL_SOURCE_TYPE_EVENT:
		prepare_events (icidata->icalcomp, NULL);
		if (!update_objects (icidata->client, icidata->icalcomp))
			/* FIXME: e_error ... */;
		break;
	case E_CAL_SOURCE_TYPE_TODO:
		prepare_tasks (icidata->icalcomp, NULL);
		if (!update_objects (icidata->client, icidata->icalcomp))
			/* FIXME: e_error ... */;
		break;
	default:
		g_assert_not_reached ();
	}
	ical_import_done (icidata);
}
예제 #2
0
static gboolean
ivcal_import_items (gpointer d)
{
	ICalImporter *ici = d;

	switch (ici->source_type) {
	case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
		prepare_events (ici->icalcomp, NULL);
		update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici);
		break;
	case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
		prepare_tasks (ici->icalcomp, NULL);
		update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici);
		break;
	default:
		g_warn_if_reached ();

		ici->idle_id = 0;
		ivcal_import_done (ici);
		return FALSE;
	}

	ici->idle_id = 0;

	return FALSE;
}
int main(int argc, char* argv[]) {
	SharedVariable v;

	int runningTimeInSec = 10;
	if (argc == 2) {
		runningTimeInSec = atoi(argv[1]);
	}

	if (wiringPiSetup() == -1) {
		printf("Failed to setup wiringPi.");
		return 1; 
	}

	printf("start");
	// Initialize for the interfaces provided
	signal(SIGINT, signal_handler);
	init_deferred_buffer(1024*1024); // 1MB
	init_userspace_governor();
	init_workload();
	printf("stop");

	// Initializers that you need to implement
	init_shared_variable(&v);
	init_sensors(&v);
	learn_workloads(&v);

	printf("Init scheduler start");
	// Init scheduler
	int aliveTasks[NUM_TASKS];
	init_scheduler(runningTimeInSec);
	set_by_max_freq(); // reset to the max freq

	printf("Init scheduler stop");
	printDBG("Start Scheduling with %d threads\n", NUM_TASKS);
	TaskSelection sel;
	long long idleTime;
	while (v.bProgramExit != 1) {
		// 1. Prepare tasks
		idleTime = prepare_tasks(aliveTasks, &v);
		if (idleTime < 0)
			break;

		// 2. Select a process: You need to implement.
		sel = select_task(&v, aliveTasks, idleTime); 
		if (sel.task < 0)
			break;

		// 3. Run the selected task
		execute_task(sel);
	}

	finish_workload();
	release_buffer(fileno(stdout));
	printf("Scheduler program finished.\n");

	return 0;
}
예제 #4
0
static void
gnome_calendar_import (EImport *ei,
                       EImportTarget *target,
                       EImportImporter *im)
{
	icalcomponent *icalcomp = NULL;
	gchar *filename;
	gint do_calendar, do_tasks;
	ICalIntelligentImporter *ici;

	/* This is pretty shitty, everything runs in the gui thread and can block
	 * for quite some time */

	do_calendar = GPOINTER_TO_INT (g_datalist_get_data (&target->data, "gnomecal-do-cal"));
	do_tasks = GPOINTER_TO_INT (g_datalist_get_data (&target->data, "gnomecal-do-tasks"));

	/* If neither is selected, just return. */
	if (!do_calendar && !do_tasks)
		return;

	/* Load the Gnome Calendar file and convert to iCalendar. */
	filename = g_build_filename (g_get_home_dir (), "user-cal.vcf", NULL);
	icalcomp = load_vcalendar_file (filename);
	g_free (filename);

	/* If we couldn't load the file, just return. FIXME: Error message? */
	if (icalcomp) {
		ici = g_malloc0 (sizeof (*ici));
		ici->ei = ei;
		ici->target = target;
		ici->cancellable = g_cancellable_new ();
		ici->icalcomp = icalcomp;

		g_datalist_set_data_full (&target->data, "gnomecal-data", ici, free_ici);

		prepare_events (ici->icalcomp, &ici->tasks);
		if (do_calendar) {
			open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, gc_import_events);
			return;
		}

		prepare_tasks (ici->icalcomp, ici->tasks);
		if (do_tasks) {
			open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks);
			return;
		}
	}

	e_import_complete (ei, target);
}
예제 #5
0
static void
gc_import_tasks (ECalClient *cal_client,
                 const GError *error,
                 ICalIntelligentImporter *ici)
{
	g_return_if_fail (ici != NULL);

	if (error != NULL) {
		g_warning (
			"%s: Failed to open tasks: %s",
			G_STRFUNC, error->message);
		e_import_complete (ici->ei, ici->target);
		return;
	}

	e_import_status (ici->ei, ici->target, _("Importing..."), 0);

	prepare_tasks (ici->icalcomp, ici->tasks);

	update_objects (
		cal_client, ici->icalcomp,
		ici->cancellable, continue_done_cb, ici);
}