Esempio n. 1
0
static PyObject *Session_user_is_loaded(Session *self) {
    sp_user *user;

    user = sp_session_user(self->_session);
    if(user == NULL)
        return NULL;
    bool loaded = sp_user_is_loaded(user);
    return Py_BuildValue("i", loaded);
};
Esempio n. 2
0
static PyObject *
Session_user_is_loaded(PyObject *self)
{
    sp_user *user = sp_session_user(Session_SP_SESSION(self));
    if (user == NULL) {
        PyErr_SetString(SpotifyError, "Not logged in");
        return NULL;
    }
    return PyBool_FromLong(sp_user_is_loaded(user));
};
Esempio n. 3
0
static PyObject *
Session_user_is_loaded(Session * self)
{
    sp_user *user;

    user = sp_session_user(self->_session);
    if (user == NULL) {
        PyErr_SetString(SpotifyError, "Not logged in");
        return NULL;
    }
    bool loaded = sp_user_is_loaded(user);

    return Py_BuildValue("i", loaded);
};
Esempio n. 4
0
static void
spotify_cb_logged_in (sp_session *spotify_session, sp_error error)
{
  if (SP_ERROR_OK != error) {
    GST_CAT_ERROR_OBJECT (gst_spot_src_debug_cb, ugly_spot, "Failed to log in to Spotify: %s", sp_error_message (error));
    return;
  }

  sp_user *me = sp_session_user (spotify_session);
  const char *my_name = (sp_user_is_loaded (me) ?
                         sp_user_display_name (me) :
                         sp_user_canonical_name (me));
  GST_CAT_DEBUG_OBJECT (gst_spot_src_debug_cb, ugly_spot, "Logged_in callback, user=%s", my_name);
  /* set default bitrate to audiofility */
  sp_session_preferred_bitrate(spotify_session, SP_BITRATE_320k);
  GST_SPOT_SRC_LOGGED_IN (ugly_spot) = TRUE;
}
Esempio n. 5
0
/**
 * This callback is called when an attempt to login has succeeded or failed.
 *
 * @sa sp_session_callbacks#logged_in
 */
static void logged_in(sp_session *session, sp_error error)
{
  sp_user *me;
  const char *my_name;

  if (SP_ERROR_OK != error) {
    fprintf(stderr, "failed to log in to Spotify: %s\n",
                    sp_error_message(error));
    sp_session_release(session);
    exit(4);
  }

  // Let us print the nice message...
  me = sp_session_user(session);
  my_name = (sp_user_is_loaded(me) ? sp_user_display_name(me) : sp_user_canonical_name(me));

  fprintf(stderr, "Logged in to Spotify as user %s\n", my_name);
}
Esempio n. 6
0
void SpotifyUser::updateData()
{
    bool updated = false;

    QString canonicalName = QString::fromUtf8(sp_user_canonical_name(m_spUser));
    QString displayName = QString::fromUtf8(sp_user_display_name(m_spUser));
    bool loaded = sp_user_is_loaded(m_spUser);

    if(exchange(canonicalName, m_canonicalName)) {
        updated = true;
    }

    if(exchange(displayName, m_displayName)) {
        updated = true;
    }

    if(exchange(m_loaded, loaded)) {
        updated = true;
    }
}
Esempio n. 7
0
/**
 * This callback is called when an attempt to login has succeeded or failed.
 *
 * @sa sp_session_callbacks#logged_in
 */
static void logged_in(sp_session *session, sp_error error)
{
	sp_user *me;
	const char *my_name;

	if (SP_ERROR_OK != error) {
		fprintf(stderr, "failed to log in to Spotify: %s\n",
		                sp_error_message(error));
		sp_session_release(session);
		exit(4);
	}

	// Let us print the nice message...
	me = sp_session_user(session);
	my_name = (sp_user_is_loaded(me) ? sp_user_display_name(me) : sp_user_canonical_name(me));

	fprintf(stderr, "Logged in to Spotify as user %s\n", my_name);
    sp_playlist *pl = sp_playlist_create(session, sp_link_create_from_string("spotify:user:devnevyn:playlist:44ZXlJstDZrwuQvWPOo7KX"));
    empty_callbacks.playlist_state_changed = foo;
    sp_playlist_add_callbacks(pl, &empty_callbacks, NULL);
}
Esempio n. 8
0
/**
 * This callback is called when an attempt to login has succeeded or failed.
 *
 * @sa sp_session_callbacks#logged_in
 */
static void logged_in(sp_session *session, sp_error error)
{
	sp_user *me;
	const char *my_name;

	if (SP_ERROR_OK != error) {
		fprintf(stderr, "failed to log in to Spotify: %s\n",
		                sp_error_message(error));
		exit(4);
	}

	// Let us print the nice message...
	me = sp_session_user(session);
	my_name = (sp_user_is_loaded(me) ? sp_user_display_name(me) : sp_user_canonical_name(me));

	fprintf(stderr, "Logged in to Spotify as user %s\n", my_name);


	// Below are parts related to the playlist manager
	// error == OK is true by now.
	logged_in_playlist(session);

	start_prompt();
}
Esempio n. 9
0
static PyObject *
User_is_loaded(User * self)
{
    return PyBool_FromLong(sp_user_is_loaded(self->_user));
}
Esempio n. 10
0
bool SpotifyUser::loaded() const
{
    return sp_user_is_loaded(m_spUser);
}
Esempio n. 11
0
JNIEXPORT jobject JNICALL Java_jahspotify_impl_JahSpotifyImpl_retrieveUser (JNIEnv *env, jobject obj)
{
    sp_user *user = sp_session_user(g_sess);
    const char *value = NULL;
    int country = 0;

    while (!sp_user_is_loaded(user))
    {
        fprintf ( stderr, "jahspotify::Java_jahspotify_impl_JahSpotifyImpl_retrieveUser: waiting for user to load\n" );
        sleep(1);
    }

    jclass jClass = (*env)->FindClass(env, "jahspotify/media/User");
    if (jClass == NULL)
    {
        fprintf(stderr,"jahspotify::Java_jahspotify_impl_JahSpotifyImpl_retrieveUser: could not load jahnotify.media.User\n");
        return NULL;
    }

    jobject userInstance = (*env)->AllocObject(env,jClass);
    if (!userInstance)
    {
        fprintf(stderr,"jahspotify::Java_jahspotify_impl_JahSpotifyImpl_retrieveUser: could not create instance of jahspotify.media.User\n");
        return NULL;
    }

    while (!sp_user_is_loaded(user))
    {
        sleep(1);
    }

    if (sp_user_is_loaded(user))
    {
        fprintf ( stderr, "jahspotify::Java_jahspotify_impl_JahSpotifyImpl_retrieveUser: user is loaded\n" );
        value = sp_user_full_name(user);
        if (value)
        {
            setObjectStringField(env,userInstance,"fullName",value);
        }
        value = sp_user_canonical_name(user);
        if (value)
        {
            setObjectStringField(env,userInstance,"userName",value);
        }
        value = sp_user_display_name(user);
        if (value)
        {
            setObjectStringField(env,userInstance,"displayName",value);
        }
        value = sp_user_picture(user);
        if (value)
        {
            setObjectStringField(env,userInstance,"imageURL",value);
        }

        // Country encoded in an integer 'SE' = 'S' << 8 | 'E'
        country = sp_session_user_country(g_sess);
        char countryStr[] = "  ";
        countryStr[0] = (byte)(country >> 8);
        countryStr[1] = (byte)country;
        setObjectStringField(env,userInstance,"country",countryStr);

        return userInstance;
    }

    return NULL;

}
Esempio n. 12
0
bool QSpotifyUser::isLoaded()
{
    return sp_user_is_loaded(m_sp_user);
}