void sess_connect() { assert(g_session.username && g_session.password); sess_disconnect(); if (!(g_session.dsfy = despotify_init_client(sess_callback, NULL, true, true))) panic("despotify_init_client(...) failed"); play_state = PAUSE; pthread_create(&thread, NULL, &thread_loop, g_session.dsfy); // Login with credentials set by sess_username/sess_password. if (!despotify_authenticate(g_session.dsfy, g_session.username, g_session.password)) { g_session.state = SESS_ERROR; log_append(despotify_get_error(g_session.dsfy)); despotify_exit(g_session.dsfy); // Switch to log view. ui_show(UI_SET_LOG); } else { g_session.state = SESS_ONLINE; log_append("Logged in as %s@%s:%d (%s)", g_session.dsfy->user_info->username, g_session.dsfy->user_info->server_host, g_session.dsfy->user_info->server_port, g_session.dsfy->user_info->country); // Switch to browser view. ui_show(UI_SET_BROWSER); } // Redraw status info. ui_dirty(UI_FOOTER); }
static VALUE rb_ds_session_authenticate (VALUE self, VALUE username, VALUE password) { rb_ds_session *session; VALUE2SESSION(self, session); if (!despotify_authenticate(session->real, StringValuePtr(username), StringValuePtr(password))) rb_ds_session_error(self); else session->connected = true; return self; }
int main(int argc, char** argv) { setlocale(LC_ALL, ""); if (argc < 3) { wprintf(L"Usage: %s <username> <password>\n", argv[0]); return 1; } if (!despotify_init()) { wprintf(L"despotify_init() failed\n"); return 1; } struct despotify_session* ds = despotify_init_client(callback); if (!ds) { wprintf(L"despotify_init_client() failed\n"); return 1; } if (!despotify_authenticate(ds, argv[1], argv[2])) { printf( "Authentication failed: %s\n", despotify_get_error(ds)); despotify_exit(ds); return 1; } print_info(ds); command_loop(ds); despotify_exit(ds); if (!despotify_cleanup()) { wprintf(L"despotify_cleanup() failed\n"); return 1; } return 0; }
struct despotify_session *get_session(const char *user, const char *passwd) { struct despotify_session *session; if (!despotify_init()) { fprintf(stderr, "Can't initialize despotify\n"); return NULL; } session = despotify_init_client(NULL, NULL, true, true); if (!session) { fprintf(stderr, "Can't initialize despotify client\n"); return NULL; } if (!despotify_authenticate(session, user, passwd)) { fprintf(stderr, "Can't authenticate despotify session\n"); despotify_exit(session); return NULL; } return session; }
int main(int argc, char** argv) { setlocale(LC_ALL, ""); if (argc < 4) { printf("Usage: %s <username> <password> <out directory>\n", argv[0]); return 1; } if (!despotify_init()) { wrapper_printf("despotify_init() failed"); return 1; } struct despotify_session* ds = despotify_init_client(callback, NULL, true, true); if (!ds) { wrapper_printf("despotify_init_client() failed"); return 1; } /* listen ? */ if (!despotify_authenticate(ds, argv[1], argv[2])) { printf("Authentication failed: %s\n", despotify_get_error(ds)); despotify_exit(ds); return 1; } (void)print_playlists(ds, argv[3]); clean_and_exit(ds, EXIT_SUCCESS); return 0; }
int main(int argc, char** argv) { setlocale(LC_ALL, ""); if (argc < 3) { wrapper_wprintf(L"Usage: %s <username> <password> [remote control port]\n", argv[0]); return 1; } DSFYDEBUG("$Id$\n"); if (!despotify_init()) { wrapper_wprintf(L"despotify_init() failed\n"); return 1; } struct despotify_session* ds = despotify_init_client(callback, NULL, true, true); if (!ds) { wrapper_wprintf(L"despotify_init_client() failed\n"); return 1; } pthread_create(&thread, NULL, &thread_loop, ds); if(argc == 4 && wrapper_listen(atoi(argv[3]))) { wrapper_wprintf(L"wrapper_listen() failed to listen on local port %s\n", argv[3]); return 1; } if (!despotify_authenticate(ds, argv[1], argv[2])) { printf( "Authentication failed: %s\n", despotify_get_error(ds)); despotify_exit(ds); return 1; } audio_device = audio_init(); #if 0 { struct ds_track* t = despotify_get_track(ds, "d1b264bb6bcd46be852ceba8ac5e6582"); despotify_play(ds, t, false); thread_play(); while(1) { sleep(1); } } #else print_info(ds); command_loop(ds); #endif thread_exit(); audio_exit(audio_device); despotify_exit(ds); if (!despotify_cleanup()) { wrapper_wprintf(L"despotify_cleanup() failed\n"); return 1; } return 0; }
int main(int argc, char *argv[]) { if (argc < 3) { printf("Usage: %s <username> <password>\n", argv[0]); return 1; } GtkWidget *vbox; GtkWidget *swin; GtkTreeSelection *selection; /* Create needed variables - not anymore, use appdata instead HildonProgram *program; HildonWindow *window; */ /* Create AppData */ AppData *appdata=g_malloc( sizeof( *appdata ) ); /* Initialize the GTK. */ gtk_init(&argc, &argv); /* Create the Hildon program and setup the title */ g_set_application_name("Maemify"); #ifdef MAEMO4 appdata->program = HILDON_PROGRAM(hildon_program_get_instance()); /* Create HildonWindow and set it to HildonProgram */ appdata->window = HILDON_WINDOW(hildon_window_new()); hildon_program_add_window(appdata->program, appdata->window); #else appdata->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (appdata->window), "Maemify"); gtk_widget_set_usize( GTK_WIDGET ( appdata->window ) , 600 , 300 ); /* create our table */ appdata->table = gtk_table_new(3, 3, FALSE); //three rows, three columns, not homogenous gtk_container_add(GTK_CONTAINER(appdata->window),appdata->table); #endif /* Create find toolbar, but keep it hidden */ create_find_toolbar(appdata); #ifdef MAEMO4 gtk_widget_show_all(GTK_WIDGET(appdata->find_toolbar)); /* Create menu for the Window */ create_menu(appdata->window); #else gtk_table_attach_defaults(GTK_TABLE(appdata->table), GTK_WIDGET(appdata->entry), 1, 2, 2, 3); gtk_widget_show_all(GTK_WIDGET(appdata->table)); #endif /* Begin the main application */ gtk_widget_show_all(GTK_WIDGET(appdata->window)); /* Connect signal to X in the upper corner */ g_signal_connect(G_OBJECT(appdata->window), "delete_event", G_CALLBACK(gtk_main_quit), NULL); if (!despotify_init()) { printf("despotify_init() failed\n"); return 1; } appdata->ds = despotify_init_client(callback, NULL, false); if (!appdata->ds) { printf("despotify_init_client() failed\n"); return 1; } if (!despotify_authenticate(appdata->ds, argv[1], argv[2])) { printf( "Authentication failed: %s\n", despotify_get_error(appdata->ds)); despotify_exit(appdata->ds); return 1; } /* Create a tree view and place it in a scrolled window */ appdata->list = gtk_tree_view_new(); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(appdata->list), TRUE); swin = gtk_scrolled_window_new(NULL, NULL); vbox = gtk_vbox_new(FALSE, 0); /* add labels to the fields */ appdata->label = gtk_label_new("Search hits"); gtk_label_set_justify(GTK_LABEL(appdata->label), GTK_JUSTIFY_CENTER); gtk_box_pack_start(GTK_BOX(vbox), appdata->label, FALSE, FALSE, 5); gtk_container_add(GTK_CONTAINER(swin), appdata->list); #ifdef MAEMO4 gtk_container_add(GTK_CONTAINER(appdata->window), swin); #else gtk_table_attach_defaults(GTK_TABLE(appdata->table), swin, 1, 2, 1, 2); #endif /* initialize a list to hold search hits */ init_list(appdata->list); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->list)); g_signal_connect(selection, "changed", G_CALLBACK(on_changed), appdata); gtk_widget_show_all(GTK_WIDGET(appdata->window)); gtk_main(); despotify_deinit(appdata); /* Exit */ return 0; }