/// <summary> /// Gets any outstanding error messages for a given user /// </summary> /// <param name="userid"></param> /// <returns></returns> public static async Task <VOption <IList <SpotifyError> > > GetSpotifyErrorMessages(string userid) { List <SpotifyError> errors = new List <SpotifyError>(); using (SqliteConnection conn = new SqliteConnection(AppConstants.ConnectionString)) { await conn.OpenAsync(); try { using (SqliteCommand comm = conn.CreateCommand()) { comm.CommandText = "SELECT ErrorMessage, ErrorCode FROM SpotifyErrors WHERE SpotifyUserId=@sid"; comm.Parameters.Add("@sid", SqliteType.Text).Value = userid; DbDataReader reader = await comm.ExecuteReaderAsync(); while (await reader.ReadAsync()) { string erm = reader.GetString(0); int erc = reader.GetInt32(1); SpotifyError serr = new SpotifyError(userid, erc, erm); errors.Add(serr); } return(new VOption <IList <SpotifyError> >(errors)); } } catch (Exception e) { logger.Error(e, "Critical - failed to get Spotify errors for user"); return(new VOption <IList <SpotifyError> >(ErrorCodes.DatabaseWriteError, "Failed to query database to retrieve Spotify errors for user")); } } }
public override async void LoggedIn(SpotifySession session, SpotifyError error) { base.LoggedIn(session, error); await WaitForBool(session.User().IsLoaded); session.PreferredBitrate(BitRate._320k); }
public static void CheckError(SpotifyError aError) { if (aError == SpotifyError.Ok) { return; } string message = Utf8ToString(NativeMethods.sp_error_message(aError)); throw new SpotifyException(aError, message); }
public override async void LoggedIn(SpotifySession session, SpotifyError error) { if (error == SpotifyError.Ok) { await SpotifyObject.WaitForInitialization(session.User().IsLoaded); _Session.PreferredBitrate(BitRate._320k); } _LoggedInCallback(error); }
public void LoggedIn(ISpotifySession session, SpotifyError error) { Log.Debug("LoggedIn"); if (error != SpotifyError.Ok) { _bus.PublishAsync(new LoginFailedEvent()); return; } _bus.PublishAsync(new LoggedInEvent()); }
private void HandleSpotifyError(SpotifyError error) { switch (error) { case SpotifyError.BadUsernameOrPassword: // ErrorManager.GetInstance().AddError(new SAMIUserException("Spotify's credentials were not correct. Please check Spotify's configuration and relaunch Sammie.")); _isValid = false; break; case SpotifyError.ApiInitializationFailed: case SpotifyError.ApplicationBanned: case SpotifyError.BadApiVersion: case SpotifyError.BadApplicationKey: case SpotifyError.BadUserAgent: case SpotifyError.CantOpenTraceFile: case SpotifyError.ClientTooOld: case SpotifyError.InboxIsFull: case SpotifyError.IndexOutOfRange: case SpotifyError.InvalidArgument: case SpotifyError.InvalidDeviceId: case SpotifyError.InvalidIndata: case SpotifyError.IsLoading: case SpotifyError.LastfmAuthError: case SpotifyError.MissingCallback: case SpotifyError.NetworkDisabled: case SpotifyError.NoCache: case SpotifyError.NoCredentials: case SpotifyError.NoStreamAvailable: case SpotifyError.NoSuchUser: case SpotifyError.OfflineDiskCache: case SpotifyError.OfflineExpired: case SpotifyError.OfflineLicenseError: case SpotifyError.OfflineLicenseLost: case SpotifyError.OfflineNotAllowed: case SpotifyError.OfflineTooManyTracks: case SpotifyError.OtherPermanent: case SpotifyError.OtherTransient: case SpotifyError.PermissionDenied: case SpotifyError.SystemFailure: case SpotifyError.TrackNotPlayable: case SpotifyError.UnableToContactServer: case SpotifyError.UserBanned: case SpotifyError.UserNeedsPremium: _isValid = false; break; case SpotifyError.Ok: default: break; } }
public override void LoggedIn(SpotifySession session, SpotifyError error) { if (error != SpotifyError.Ok) { IsFinished = true; Console.WriteLine("Failed to log in to Spotify: {0}", Spotify.ErrorMessage(error)); } var me = session.User(); string displayName = me.IsLoaded() ? me.DisplayName() : me.CanonicalName(); string username = session.UserName(); var cc = session.UserCountry(); Console.Error.WriteLine("Logged in to Spotify as user {0} [{1}] (registered in country: {2})", username, displayName, Spotify.CountryString(cc)); iReader.RequestInput("> "); // TODO: self test }
public override async void LoggedIn(SpotifySession session, SpotifyError error) { if (error != SpotifyError.Ok) { if (OnLoginResult != null) { OnLoginResult(false); } return; } base.LoggedIn(session, error); await WaitForBool(session.User().IsLoaded); session.PreferredBitrate(BitRate._320k); }
public override async void LoggedIn(SpotifySession session, SpotifyError error) { if (error != SpotifyError.Ok) { if (OnLoginResult != null) { OnLoginResult(false); } return; } // Autenticate _spotifyWeb _spotifyWeb = new SpotifyWeb(GUI.frmMain.configuration.GetConfiguration("clientId"), GUI.frmMain.configuration.GetConfiguration("clientSecret")); _spotifyWeb.Auth(); // SpotifySharp log in base.LoggedIn(session, error); await WaitForBool(session.User().IsLoaded); session.PreferredBitrate(BitRate._320k); }
public virtual void StreamingError(SpotifySession @session, SpotifyError @error) { }
public virtual void ScrobbleError(SpotifySession @session, SpotifyError @error) { }
static void connection_error(IntPtr @session, SpotifyError @error) { var context = GetListener(session); context.Listener.ConnectionError(context.Session,error); }
public SpotifyException(SpotifyError error, string message) : base(message) { Error = error; }
public static string ErrorMessage(SpotifyError error) { return(SpotifyMarshalling.Utf8ToString(NativeMethods.sp_error_message(error))); }
public SpotifyException(SpotifyError error) { Error = error; }
public virtual void ConnectionError(SpotifySession @session, SpotifyError @error) { }
/// <summary> /// Writes a Spotify Error for the given user /// </summary> /// <param name="aspnetuserid"></param> /// <param name="tracks"></param> /// <returns></returns> public static async Task <VOption <bool> > WriteSpotifyErrorForUser(string aspnetuserid, string spotifyid, SpotifyError serr) { using (SqliteConnection conn = new SqliteConnection(AppConstants.ConnectionString)) { await conn.OpenAsync(); using (SqliteTransaction t = conn.BeginTransaction()) { try { using (SqliteCommand comm = conn.CreateCommand()) { comm.CommandText = "INSERT OR REPLACE INTO SpotifyErrors (AspNetUserId, SpotifyUserId, ErrorMessage, ErrorCode) VALUES (@auid, @sid, @erm, @erc)"; comm.Parameters.Add("@auid", SqliteType.Text).Value = aspnetuserid; comm.Parameters.Add("@sid", SqliteType.Text).Value = spotifyid; comm.Parameters.Add("@erm", SqliteType.Text).Value = serr.ErrorMessage; comm.Parameters.Add("@erc", SqliteType.Integer).Value = serr.ErrorCode; await comm.ExecuteNonQueryAsync(); } t.Commit(); logger.Info("Successfully wrote user spotify error"); return(new VOption <bool>()); } catch (Exception e) { logger.Error(e, "Failed to write a users spotify error"); t.Rollback(); return(new VOption <bool>(ErrorCodes.DatabaseWriteError, "Failed to write a users spotify error")); } } } }
public void ConnectionError(ISpotifySession session, SpotifyError error) { Log.Debug("ConnectionError"); }
static void StreamingError(IntPtr @session, SpotifyError @error) { var context = GetListener(session); context.Listener.StreamingError(context.Session,error); }
static void OfflineError(IntPtr @session, SpotifyError @error) { var context = GetListener(session); context.Listener.OfflineError(context.Session,error); }
static void logged_in(IntPtr @session, SpotifyError @error) { var context = GetListener(session); context.Listener.LoggedIn(context.Session, error); }
public virtual void LoggedIn(SpotifySession @session, SpotifyError @error) { }
public override void ConnectionError(SpotifySession session, SpotifyError error) { Console.Error.WriteLine("Connection to Spotify failed: {0}", Spotify.ErrorMessage(error)); }
public void ScrobbleError(ISpotifySession session, SpotifyError error) { Log.Debug("ScrobbleError"); }
public override void ScrobbleError(SpotifySession session, SpotifyError error) { Console.Error.WriteLine("Scrobble failure: {0}", Spotify.ErrorMessage(error)); }
public void OfflineError(ISpotifySession session, SpotifyError error) { Log.Debug("OfflineError"); }
public void StreamingError(ISpotifySession session, SpotifyError error) { Log.Debug("StreamingError"); }
static void connection_error(IntPtr @session, SpotifyError @error) { var context = GetListener(session); context.Listener.ConnectionError(context.Session, error); }
public virtual void OfflineError(SpotifySession @session, SpotifyError @error) { }
static void ScrobbleError(IntPtr @session, SpotifyError @error) { var context = GetListener(session); context.Listener.ScrobbleError(context.Session, error); }
public SpotifyException(SpotifyError error) : base(error.Message) { Error = error; }
public override void ConnectionError(SpotifySession session, SpotifyError error) { base.ConnectionError(session, error); }
public override void LoggedIn(SpotifySession session, SpotifyError error) { HandleSpotifyError(error); _loggedInHandle.Set(); }
public override void ScrobbleError(SpotifySession session, SpotifyError error) { base.ScrobbleError(session, error); }
public override void OfflineError(SpotifySession session, SpotifyError error) { base.OfflineError(session, error); }
public override void StreamingError(SpotifySession session, SpotifyError error) { base.StreamingError(session, error); }
public override async void LoggedIn(SpotifySession session, SpotifyError error) { if (error != SpotifyError.Ok) { if (OnLoginResult != null) OnLoginResult(false); return; } base.LoggedIn(session, error); await WaitForBool(session.User().IsLoaded); session.PreferredBitrate(BitRate._320k); }