예제 #1
0
/* 
 * Log in and wait for rootlist to be loaded
 */
void launch(void)
{   
    printf("Welcome to spotify_terminal\n");
    printf("Using libspotify %s\n", sp_build_id());
    init();
    
    get_user_info();
    printf("Logging in user: '******'... \n", username);
    usleep(500000);
    log_in();
    while(is_logged_in != TRUE) {
        sp_session_process_events(g_session, &next_timeout);
    }
    printf("Loading playlists... \n");
    usleep(500000);
    sp_session_process_events(g_session, &next_timeout);
    while(playlist_loaded != TRUE) {
        sp_session_process_events(g_session, &next_timeout);
    }
    printf("ready!\n");
    printf("> ");
    fflush(stdout);
}
예제 #2
0
int __cdecl main(int argc, char **argv)
{
	const char *username = argc > 1 ? argv[1] : NULL;
	const char *blob = argc > 2 ? argv[2] : NULL;
	const char *password = NULL;
	int selftest = argc > 3 ? !strcmp(argv[3], "selftest") : 0;
	char username_buf[256];
	char password_buf[256];
	int r;
	int next_timeout = 0;
	DWORD ev;
	DWORD mode;

	events[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
	events[1] = GetStdHandle(STD_INPUT_HANDLE);

	printf("Using libspotify %s\n", sp_build_id());

	if (username == NULL) {
		printf("Username: (just press enter to login with stored credentials): ");
		fflush(stdout);
		fgets(username_buf, sizeof(username_buf), stdin);
		trim(username_buf);
		if(username_buf[0] == 0) {
			username = NULL;
		} else {
			username = username_buf;
		}
	}

	// If a username was supplied but no blob, prompt for password
	if (username != NULL && blob == NULL) {
		printf("Password: "******"Unable to set console mode err=%d\n", GetLastError());
			exit(1);
		}

		fgets(password_buf, sizeof(password_buf), stdin);
		trim(password_buf);
		password = password_buf;
		printf("\r\n");
	}

	if ((r = spshell_init(username, password, blob, selftest)) != 0)
		exit(r);

	if (!SetConsoleMode(events[1], ENABLE_PROCESSED_INPUT)) {
		printf("Unable to set console mode err=%d\n", GetLastError());
		exit(1);
	}

	while(!is_logged_out) {
		ev = WaitForMultipleObjects(1 + enable_console, events, FALSE, next_timeout > 0 ? next_timeout : INFINITE);
		switch (ev) {
		case WAIT_OBJECT_0 + 0:
		case WAIT_TIMEOUT:
			do {
				sp_session_process_events(g_session, &next_timeout);
			} while (next_timeout == 0);

			if(g_selftest)
				test_process();
			break;

		case WAIT_OBJECT_0 + 1:
			console_input();
			break;
		}
	}
	printf("Logged out\n");
	sp_session_release(g_session);
	printf("Exiting...\n");
	return 0;
}
예제 #3
0
int main(int argc, char **argv)
{
	const char *username = argc > 1 ? argv[1] : NULL;
	const char *password = argc > 2 ? argv[2] : NULL;
	int selftest = argc > 3 ? !strcmp(argv[3], "selftest") : 0;
	char username_buf[256];
	int r;
	int next_timeout = 0;

	printf("Using libspotify %s\n", sp_build_id());

	if (username == NULL) {
		printf("Username (just press enter to login with stored credentials): ");
		fflush(stdout);
		fgets(username_buf, sizeof(username_buf), stdin);
		trim(username_buf);
		if(username_buf[0] == 0) {
			username = NULL;
		} else {
			username = username_buf;
		}
	}

	if (username != NULL && password == NULL)
		password = getpass("Password: "******"Logged out\n");
	sp_session_release(g_session);
	printf("Exiting...\n");
	return 0;
}