void QSpotifySession::logout(bool keepLoginInfo) { qDebug() << "QSpotifySession::logout"; if (!m_isLoggedIn || m_pending_connectionRequest) return; stop(); m_playQueue->clear(); if (!keepLoginInfo) { setOfflineMode(false); sp_session_forget_me(m_sp_session); } m_explicitLogout = true; m_pending_connectionRequest = true; emit pendingConnectionRequestChanged(); emit loggingOut(); if(m_user) { m_user->deleteLater(); m_user = nullptr; } sp_session_logout(m_sp_session); }
void QSpotifySession::setConnectionError(ConnectionError error, const QString &message) { qDebug() << "QSpotifySession::setConnectionError" << error << message; if (error == Ok || m_offlineMode) return; if (m_pending_connectionRequest) { m_pending_connectionRequest = false; emit pendingConnectionRequestChanged(); } if (error == UnableToContactServer && m_ignoreNextConnectionError) { m_ignoreNextConnectionError = false; return; } if (error == UnableToContactServer) { setOfflineMode(true, true); } m_connectionError = error; m_connectionErrorMessage = message; if (error != Ok && m_currentTrack && !m_currentTrack->isAvailableOffline()) pause(); emit connectionErrorChanged(); }
void QSpotifySession::checkNetworkAccess() { // qDebug() << "QSpotifySession::checkNetworkAccess"; if (!m_networkConfManager->isOnline()) { sp_session_set_connection_type(m_sp_session, SP_CONNECTION_TYPE_NONE); setOfflineMode(true, true); } else { bool wifi = false; bool mobile = false; bool roaming = false; QList<QNetworkConfiguration> confs = m_networkConfManager->allConfigurations(QNetworkConfiguration::Active); for (int i = 0; i < confs.count(); ++i) { QNetworkConfiguration::BearerType bearer = confs.at(i).bearerType(); qDebug() << "Network connection type: " << confs.at(i).bearerTypeName(); if (bearer == QNetworkConfiguration::BearerWLAN || bearer == QNetworkConfiguration::BearerEthernet) { wifi = true; break; } else { mobile = true; } if (confs.at(i).isRoamingAvailable()) { roaming = true; } } sp_connection_type type; if (wifi) type = SP_CONNECTION_TYPE_WIFI; else if (roaming) type = SP_CONNECTION_TYPE_MOBILE_ROAMING; else if (mobile) type = SP_CONNECTION_TYPE_MOBILE; else type = SP_CONNECTION_TYPE_UNKNOWN; sp_session_set_connection_type(m_sp_session, type); if (m_forcedOfflineMode) setOfflineMode(false, true); else setConnectionRules(m_offlineMode ? m_connectionRules & ~AllowNetwork : m_connectionRules | AllowNetwork); } }
void QSpotifySession::checkNetworkAccess() { qDebug() << "QSpotifySession::checkNetworkAccess"; if (!isOnline()) { sp_session_set_connection_type(m_sp_session, SP_CONNECTION_TYPE_NONE); setOfflineMode(true, true); } else { bool limited = m_networkingStatus->limitations().contains(ubuntu::connectivity::NetworkingStatus::Limitations::Bandwith); sp_connection_type type; if (!limited) type = SP_CONNECTION_TYPE_WIFI; else type = SP_CONNECTION_TYPE_MOBILE; sp_session_set_connection_type(m_sp_session, type); if (m_forcedOfflineMode) setOfflineMode(false, true); else setConnectionRules(m_offlineMode ? m_connectionRules & ~AllowNetwork : m_connectionRules | AllowNetwork); } }