Exemplo n.º 1
0
int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue)
{
    play_tree_iter_t *my_pt_iter = NULL;
    int result = 0;

    if(!mygui) guiInit();

    if((my_pt_iter = pt_iter_create(&my_playtree, config)))
    {
        while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
        {
            if (parse_filename(filename, my_playtree, config, 0))
                result = 1;
            else if (import_file_into_gui(filename, 0)) /* Add it to end of list */
                result = 1;
        }
    }
    uiGotoTheNext = 1;

    if (result)
    {
        mygui->playlist->current = 0;
        uiSetFileName(NULL, mygui->playlist->tracks[0]->filename, STREAMTYPE_FILE);
    }

    if (enqueue) filename = NULL;

    return result;
}
Exemplo n.º 2
0
int guiPlaylist (int what, play_tree_t *playtree, m_config_t *config, int enqueue)
{
    play_tree_iter_t *pt_iter = NULL;
    char *file;
    int added = FALSE;

    switch (what)
    {
        /*  This function imports the initial playtree (based on cmd-line files) into the gui playlist
            by either:
            - overwriting gui pl (enqueue=0) */
        case GUI_PLAYLIST_INIT:

            if(!mygui) guiInit();

            if((pt_iter = pt_iter_create(&playtree, config)))
            {
                while ((file = pt_iter_get_next_file(pt_iter)) != NULL)
                {
                    if (parse_filename(file, playtree, config, 0))
                        added = TRUE;
                    else if (import_file_into_gui(file, 0)) /* Add it to end of list */
                        added = TRUE;
                }
            }
            guiInfo.PlaylistNext = TRUE;

            if (added)
            {
                mygui->playlist->current = 0;
                uiSetFile(NULL, mygui->playlist->tracks[0]->filename, STREAMTYPE_FILE);
            }

            if (enqueue) filename = NULL;

            break;

        /* This function imports and inserts an playtree, that is created "on the fly", for example by
           parsing some MOV-Reference-File; or by loading an playlist with "File Open"
           The file which contained the playlist is thereby replaced with it's contents. */
        case GUI_PLAYLIST_ADD:

            if((pt_iter = pt_iter_create(&playtree, config)))
            {
                while ((file = pt_iter_get_next_file(pt_iter)) != NULL)
                    if (import_file_into_gui(file, 1)) /* insert it into the list and set plCurrent = new item */
                        added = TRUE;
                pt_iter_destroy(&pt_iter);
            }

            break;
    }

    return added;
}
Exemplo n.º 3
0
void engineInit() {
	int err;
	err = SDL_Init(SDL_INIT_VIDEO);
	assert(!err);
	
	err = TTF_Init();
	assert(!err);
	
	engine.window = SDL_CreateWindow("bored", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1024, 768, 0);
	assert(engine.window);
	
	mapInit();
	mapSeed(rand());
	gfxInit();
	guiInit();
}
Exemplo n.º 4
0
/**===========================================
 * @brief main thread, starting up the client and the other threads
 * @param argc:int argv**char
 * ==========================================*/
int main(int argc, char **argv)
{
	char *name   = "Guest";
	char *server = "localhost";
	char *port   = "54321";
	int thread;
	int ret, c, conn=0;
	
	while(optind < argc) {
		int option_index = 0;
		static struct option long_options[] = {
			{"name",    required_argument, 0, 'n'},
			{"port",    optional_argument, 0, 'p'},
			{"help",    no_argument,       0, 'h'},
			{0,0,0,0}
		};
		c = getopt_long(argc, argv, "hp:n:", long_options, &option_index);
		if(c == -1) break;
		
		switch(c) {
			case '?': /* unknown parameter */
			case ':': /* missing argument */
				print_help(argv[0]);
				break;
			case 'n':
				name = strdup(optarg);
				if(!name) return -1;
				break;
			case 'p':
				port = strdup(optarg);
				break;
			case 'h':
				print_help(argv[0]);
				break;
			default:
				break;
		}
	}
	while(optind < argc) {
		server = argv[optind++];
	}
	
	GCI.name = name;
	
	printf("Benutzername: %s\n", GCI.name);
	printf("server: %s", server);
	struct addrinfo *addr_info, *p;
	
	ret = getaddrinfo(server, port, NULL, &addr_info);
	if(ret) {
		printf("getaddrinfo: %s\n", gai_strerror(ret));
		exit(-1);
	}
	
	p = addr_info;
	
	while (p)
	{
		if(p->ai_socktype != SOCK_STREAM)/* we only care about TCP */
		{
			p = p->ai_next;
			continue;
		}
		int sock = socket(p->ai_family, p->ai_socktype, 0);
		if(sock == -1)
		{
			perror("socket");
			exit(-1);
		}
		
		if(connect(sock, p->ai_addr, p->ai_addrlen) == 0)
		{
			signal(SIGINT, sigint_handler);
			// move to better positioon
			sem_V(keymng_local(KEY_GCI_SEM));
			
			
			printf("Socket OK");
			GCI.sock = sock;
			send_login(GCI.name);
			int state = wait_loginOK();
			
			if(state !=0)
			{
				printf("Keine antwort erhalten \n");
				return 0;
			}
			
			printf("juhu ich bin eingeloggt \n");
			GCI.status = preparation;
			conn =1;
			
			guiInit(&argc, &argv);
			printf("GUI init \n");
			
			setClientMode();
			preparation_showWindow();
			guiShowMessageDialog("Willkommen bei You Dont Know Rainer",0);
			
			// start the threads
			thread = pthread_create(&listener_thread_id, NULL, &listener_thread, NULL);
			
			if(thread)
			{
				printf("Failed to start Listener Thread\n");
				exit(0);
			}
			
			thread = pthread_create(&fragen_thread_id, NULL, &fragen_thread, NULL);
			
			if(thread)
			{
				printf("Failed to start Fragewechsel Thread\n");
				exit(0);
			}
			//katalog request
			sendCR();
			
			guiMain();
			guiDestroy();
		}
		
		close(sock);
		p = p->ai_next;
	}
	if(conn==0)
		printf("Could not connect to server :/\n");
	
	freeaddrinfo(addr_info);
	exit(0);
}