void on_logged_in(list<int> int_params, list<string> string_params, sp_session *session, sp_track *track) { sp_error error = (sp_error)int_params.front(); bool success = (SP_ERROR_OK == error) ? true : false; JNIEnv *env; jclass class_libspotify = find_class_from_native_thread(&env); jmethodID methodId = env->GetStaticMethodID(class_libspotify, "onLogin", "(ZLjava/lang/String;Ljava/lang/String;)V"); log("on_logged_in: success:%s, error %s, sp_error_message(error) %s, session %s, sp_session_user_name(session) %s", success?"true":"false", error==0?"null":"not null", sp_error_message(error)==0?"null":"not null", session==0?"null":"not null", sp_session_user_name(session)==0?"null":"not null"); env->CallStaticVoidMethod(class_libspotify, methodId, success, env->NewStringUTF(sp_error_message(error)), env->NewStringUTF(sp_session_user_name(session))); if (env->ExceptionCheck()) { env->ExceptionDescribe(); env->ExceptionClear(); } env->DeleteLocalRef(class_libspotify); }
/** credentialsBlobUpdated callback from login when we get the blob, used instead of plain password will send blob to application to storage @note its up the the application to store it @note2: it will be fired more than once, always store latest blob @note3: if user have no cache, it will fire once, if cache it will (maybe) update current blob **/ void SpotifySession::credentialsBlobUpdated(sp_session *session, const char *blob) { SpotifySession* _session = reinterpret_cast<SpotifySession*>(sp_session_userdata(session)); #if SPOTIFY_API_VERSION >= 12 const char* username = sp_session_user_name( session ); #else const char* username = sp_user_canonical_name( sp_session_user( session ) ); #endif _session->m_blob = QByteArray(blob); qDebug() << " ==== Got blob update for " << QString::fromUtf8(username, strlen(username) ) << " ==== "; emit _session->blobUpdated( username, QByteArray(blob).constData() ); }
static void sess_callback_credentials_blob_updated(sp_session *session, const char *token) { syslog(LOG_INFO, "AUTH: credentials blob updated for %s: %s", sp_session_user_name(session), token); update_auth_blob(token); }