Example #1
0
 private async void signInButton_Click(object sender, EventArgs e)
 {
     if (!authenticatable.IsAuthenticated)
     {
         var authenticatableAsync = service.AsAuthenticatableAsync();
         if (authenticatableAsync == null)
         {
             var dlg = new CredentialsForm(service);
             dlg.ShowDialog();
             servicePlugin.SettingsFile.Save();
         }
         else
         {
             await authenticatableAsync.AuthenticateAsync();
         }
         signInStatusLabel.Text = String.Format(sspSignInStatus.Get(authenticatable.IsAuthenticated),
                                                LocalisableAccountNameFormat.GetFormattedName(authenticatable.Account));
         sspSignInButton.Update(authenticatable.IsAuthenticated);
     }
     else
     {
         authenticatable.Reset();
         sspSignInStatus.Update(false);
         sspSignInButton.Update(false);
     }
 }
Example #2
0
        private void urlValidStateLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var svc = (MusicService)e.Link.LinkData;

            using (var cf = new CredentialsForm(svc))
            {
                var res = cf.ShowDialog(this);
                if (res != DialogResult.OK)
                {
                    return;
                }
                ValidateEnteredUrl();
            }
        }
Example #3
0
        private async void signInButton_Click(object sender, EventArgs e)
        {
            if (!authenticatable.IsAuthenticated)
            {
                if (!am.CanAuthenticate(service))
                {
                    TaskDialogHelper.ShowMessage(caption: "Cannot authenticate this service right now.",
                                                 message: "The service is already being authenticated in the background. Please try again in a moment.",
                                                 icon: TaskDialogStandardIcon.Error, buttons: TaskDialogStandardButtons.Ok, owner: Handle);
                    return;
                }
                var authenticatableAsync = service.AsAuthenticatableAsync();
                if (authenticatableAsync == null)
                {
                    var dlg = new CredentialsForm(service);
                    dlg.ShowDialog();
                }
                else
                {
                    var result = await am.Authenticate(service);

                    if (result.Result)
                    {
                        return;
                    }
                    if (result.Exception != null)
                    {
                        Log.WriteException(Level.Error, Lag, result.Exception, "AM custom auth");
                        TaskDialogHelper.ShowExceptionDialog(result.Exception,
                                                             "An error occurred while attempting to sign in.",
                                                             "Make sure you have entered the correct credentials and your device has an active internet connection.\n\n" +
                                                             "The information below may be useful to the plugin's author.", Handle);
                    }
                    else
                    {
                        TaskDialogHelper.ShowMessage("An error occurred while attempting to sign in.",
                                                     "Make sure you have entered the correct credentials and your device has an active internet connection.",
                                                     TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, Handle);
                    }
                }
            }
            else
            {
                authenticatable.Reset();
            }
            UpdateViews();
            servicePlugin.SettingsFile.Save();
        }
 private void signInButton_Click(object sender, EventArgs e)
 {
     if (!service.IsAuthenticated)
     {
         var dlg    = new CredentialsForm(service);
         var result = dlg.ShowDialog();
         if (result != DialogResult.OK)
         {
             return;
         }
         signInStatusLabel.Text = String.Format(sspSignInStatus.Get(true), dlg.Result.UserName);
         sspSignInButton.Update(true);
     }
     else
     {
         service.ClearSession();
         sspSignInStatus.Update(false);
         sspSignInButton.Update(false);
     }
 }
Example #5
0
 private async void signInButton_Click(object sender, EventArgs e)
 {
     if (!authenticatable.IsAuthenticated)
     {
         var authenticatableAsync = service.AsAuthenticatableAsync();
         if (authenticatableAsync == null)
         {
             var dlg = new CredentialsForm(service);
             dlg.ShowDialog();
         }
         else
         {
             await authenticatableAsync.AuthenticateAsync();
         }
     }
     else
     {
         authenticatable.Reset();
     }
     UpdateLabels();
     servicePlugin.SettingsFile.Save();
 }
Example #6
0
        public async Task <bool> Authenticate(MusicService service)
        {
            if (!am.CanAuthenticate(service))
            {
                TaskDialogHelper.ShowMessage(caption: "Cannot authenticate this service right now.",
                                             message: "The service is already being authenticated in the background. Please try again in a moment.",
                                             icon: TaskDialogStandardIcon.Error, buttons: TaskDialogStandardButtons.Ok, owner: parent.Handle);
                return(false);
            }
            var authenticatableAsync = service.AsAuthenticatableAsync();

            if (authenticatableAsync == null)
            {
                var dlg = new CredentialsForm(service);
                return(dlg.ShowDialog() == DialogResult.OK);
            }
            var result = await am.Authenticate(service);

            if (result.Result)
            {
                return(true);
            }
            if (result.Exception != null)
            {
                Log.WriteException(Level.Error, Tag, result.Exception, "AM custom auth");
                TaskDialogHelper.ShowExceptionDialog(result.Exception,
                                                     "An error occurred while attempting to sign in.",
                                                     "Make sure you have entered the correct credentials and your device has an active internet connection.\n\n" +
                                                     "The information below may be useful to the plugin's author.", parent.Handle);
            }
            else
            {
                TaskDialogHelper.ShowMessage("An error occurred while attempting to sign in.",
                                             "Make sure you have entered the correct credentials and your device has an active internet connection.",
                                             TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, parent.Handle);
            }
            return(false);
        }