示例#1
0
int main(int argc, char *argv[]) {
	pthread_t 		thread;

	/* init threads */
    g_thread_init (NULL);
    gdk_threads_init ();
    gdk_threads_enter ();

    gtk_init(&argc, &argv);

    initApp();

    appdata->program = HILDON_PROGRAM(hildon_program_get_instance());
    g_set_application_name("Webview");

    appdata->window = HILDON_WINDOW(hildon_window_new());
    hildon_program_add_window(appdata->program, appdata->window);


    create_menu(appdata->window);
    build_interface(appdata->window);

    /* Connect signal to X in the upper corner */
    g_signal_connect(G_OBJECT(appdata->window), "delete_event", G_CALLBACK(destroy), NULL);

	update_image();
	load_settings();

	gtk_widget_show_all(GTK_WIDGET(appdata->window));

	if(! start_camera(appdata->window))
	{
		g_warning("Unable to start camera\n");

		GtkWidget *failDialog = gtk_message_dialog_new(NULL,
	     		GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
	     		GTK_BUTTONS_OK,
	     		"Unable to start camera\n");
		gtk_dialog_run (GTK_DIALOG (failDialog));
		gtk_widget_destroy (failDialog);
	}

	if(! start_webserver())
	{
		GtkWidget *failDialog = gtk_message_dialog_new(NULL,
	     		GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
	     		GTK_BUTTONS_OK,
	     		"Unable to start web server.\nCheck server port is not already in use.\n");
		gtk_dialog_run (GTK_DIALOG (failDialog));
		gtk_widget_destroy (failDialog);
	}
	sleep(1);

	pthread_create(&thread, NULL, count_down_thread, NULL);

	gtk_main();

	gdk_threads_leave ();
	return( 0 );
}
示例#2
0
文件: gdmenu.c 项目: haobug/gdmenu
int main(int argc, char *argv[])
{
	gtk_init(&argc, &argv);
	parse_options(&argc, &argv);
	build_interface();
	read_input();
	gtk_main();
	return 0;
}
示例#3
0
static QStatus setup_busattachment(alljoyn_busattachment bus)
{
    QStatus status;
    status = alljoyn_busattachment_start(bus);
    QCC_ASSERT(ER_OK == status);
    status = alljoyn_busattachment_connect(bus, NULL);
    QCC_ASSERT(ER_OK == status);

    status = build_interface(bus);
    QCC_ASSERT(ER_OK == status);

    return status;
}
static inline int build_config( JNIEnv *env, jclass JavaxUsb, int fd, jobject device, unsigned char bus, unsigned char dev )
{
	int result = -1;
	struct jusb_config_descriptor *cfg_desc = NULL;
	unsigned char *desc = NULL;
	unsigned short wTotalLength;
	unsigned int pos;
	jobject config = NULL, interface = NULL;
	jmethodID createUsbConfigImp;
	jboolean isActive = JNI_FALSE;

	if (!(cfg_desc = get_descriptor( fd ))) {
		dbg( MSG_ERROR, "nativeTopologyUpdater.build_config : Short read on config desriptor\n" );
		goto BUILD_CONFIG_EXIT;
	}

	createUsbConfigImp = (*env)->GetStaticMethodID( env, JavaxUsb, "createUsbConfigImp", "(Lcom/ibm/jusb/UsbDeviceImp;BBSBBBBBZ)Lcom/ibm/jusb/UsbConfigImp;" );

	dbg( MSG_DEBUG3, "nativeTopologyUpdater.build_config : Building config %d\n", cfg_desc->bConfigurationValue );

	wTotalLength = cfg_desc->wTotalLength;
	pos = cfg_desc->bLength;

	isActive = isConfigActive( fd, bus, dev, cfg_desc->bConfigurationValue );
	config = (*env)->CallStaticObjectMethod( env, JavaxUsb, createUsbConfigImp, device,
		cfg_desc->bLength, cfg_desc->bDescriptorType, wTotalLength,
		cfg_desc->bNumInterfaces, cfg_desc->bConfigurationValue, cfg_desc->iConfiguration,
		cfg_desc->bmAttributes, cfg_desc->bMaxPower, isActive );

	while (pos < wTotalLength) {
		desc = get_descriptor( fd );
		if ((!desc) || (2 > desc[0])) {
			dbg( MSG_ERROR, "nativeTopologyUpdater.build_config : Short read on descriptor\n" );
			goto BUILD_CONFIG_EXIT;
		}
		pos += desc[0];
		switch( desc[1] ) {
			case USB_DT_DEVICE:
				dbg( MSG_ERROR, "nativeTopologyUpdater.build_config : Got device descriptor inside of config descriptor\n" );
				goto BUILD_CONFIG_EXIT;

			case USB_DT_CONFIG:
				dbg( MSG_ERROR, "nativeTopologyUpdater.build_config : Got config descriptor inside of config descriptor\n" );
				goto BUILD_CONFIG_EXIT;

			case USB_DT_INTERFACE:
				if (interface) (*env)->DeleteLocalRef( env, interface );
				interface = build_interface( env, JavaxUsb, fd, config, (struct jusb_interface_descriptor*)desc );
				break;

			case USB_DT_ENDPOINT:
				build_endpoint( env, JavaxUsb, interface, (struct jusb_endpoint_descriptor*)desc );
				break;

			default:
				/* Ignore proprietary descriptor */
				break;
		}
		free(desc);
		desc = NULL;
	}

	result = 0;

BUILD_CONFIG_EXIT:
	if (config) (*env)->DeleteLocalRef( env, config );
	if (interface) (*env)->DeleteLocalRef( env, interface );
	if (cfg_desc) free(cfg_desc);
	if (desc) free(desc);

	return result;
}