STFavoriteTimeline::STFavoriteTimeline(QString identifier, quint64 targetUserId, QObject *parent) : STTimeline(identifier, parent), m_targetUserId(targetUserId) { QString urlStr="https://api.twitter.com/1.1/favorites/list.json?user_id=%1"; setFetchEndpoint(QUrl(urlStr.arg(targetUserId))); STAccount *account=accountForIdentifier(identifier); if(account->userId()==targetUserId){ m_streamer=account->userStreamer(); connect(m_streamer, SIGNAL(streamingStarted()), this, SLOT(streamStarted())); connect(m_streamer, SIGNAL(streamingStopped(QString)), this, SLOT(streamStopped(QString))); connect(m_streamer, SIGNAL(streamingCouldNotStarted(QString)), this, SLOT(streamFailedToStart(QString))); connect(m_streamer, SIGNAL(statusRemoved(quint64)), this, SLOT(streamRemoved(quint64))); connect(m_streamer, SIGNAL(accountFavoritedStatus(STObjectManager::StatusRef,STObjectManager::UserRef)), this, SLOT(favoritedStatus(STObjectManager::StatusRef))); connect(m_streamer, SIGNAL(accountUnfavoritedStatus(STObjectManager::StatusRef,STObjectManager::UserRef)), this, SLOT(unfavoritedStatus(STObjectManager::StatusRef))); }else{ m_streamer=NULL; } }
bool SpotWorker::start(QString username, QString password) { QByteArray cachePath, settingsPath; cachePath = settings.value("spotify/cache").toString().toLocal8Bit(); settingsPath = settings.value("spotify/settings").toString().toLocal8Bit(); sp_session_config config; config.api_version = SPOTIFY_API_VERSION; config.cache_location = strdup(cachePath.data()); config.settings_location = strdup(settingsPath.data()); config.application_key = g_appkey; config.application_key_size = g_appkey_size; config.user_agent = "libspotify-client"; config.callbacks = &g_callbacks; config.compress_playlists = false; config.dont_save_metadata_for_playlists = false; config.initially_unload_playlists = false; config.device_id = NULL; config.tracefile = NULL; sp_error error = sp_session_create(&config, ¤tSession); if (SP_ERROR_OK != error) { fprintf(stderr, "failed to create session: %s\n", sp_error_message(error)); return false; } // TODO: add callback for error checking to adjust to API changes sp_session_login(currentSession, username.toUtf8().data(), password.toUtf8().data(), true); eventTimer = new QTimer(); connect(eventTimer, SIGNAL(timeout()), SLOT(processEvents())); eventTimer->start(3000); watchDog_ = new QTimer(); connect(watchDog_, SIGNAL(timeout()), SLOT(streamingStopped())); soundSaver_ = new SoundSaver(); alsaWorker_ = new AlsaWorker(); DEBUG printf("Spotworker started with soundSaver and alsaWorker constructed\n"); return true; }
STHomeTimeline::STHomeTimeline(QString identifier, QObject *parent) : STTimeline(identifier, parent) { QStringList lst=identifier.split("."); quint64 uid=lst[0].toULongLong(); this->setFetchEndpoint(QUrl("https://api.twitter.com/1.1/statuses/home_timeline.json?exclude_replies=false&include_my_retweet=1")); STAccount *ac=STAccountsManager::sharedManager()->account(uid); Q_ASSERT(ac); m_streamer=ac->userStreamer(); connect(m_streamer, SIGNAL(streamingStarted()), this, SLOT(streamStarted())); connect(m_streamer, SIGNAL(streamingStopped(QString)), this, SLOT(streamStopped(QString))); connect(m_streamer, SIGNAL(streamingCouldNotStarted(QString)), this, SLOT(streamFailedToStart(QString))); connect(m_streamer, SIGNAL(homeNewStatusReceived(STObjectManager::StatusRef)), this, SLOT(streamReceived(STObjectManager::StatusRef))); connect(m_streamer, SIGNAL(statusRemoved(quint64)), this, SLOT(streamRemoved(quint64))); }