private async Task <bool> ExistingSettingLogin(IChannelSettings setting)
        {
            bool result = await ChannelSession.ConnectUser(setting);

            if (result)
            {
                if (!await ChannelSession.ConnectBot(setting))
                {
                    await MessageBoxHelper.ShowMessageDialog("Bot Account failed to authenticate, please re-connect it from the Services section.");
                }
            }
            else
            {
                await MessageBoxHelper.ShowMessageDialog("Unable to authenticate with Mixer, please try again");
            }
            return(result);
        }
        private async void StreamerLoginButton_Click(object sender, RoutedEventArgs e)
        {
            bool result = false;

            await this.RunAsyncOperation(async() =>
            {
                if (this.ExistingStreamerComboBox.Visibility == Visibility.Visible)
                {
                    if (this.ExistingStreamerComboBox.SelectedIndex >= 0)
                    {
                        IChannelSettings setting = (IChannelSettings)this.ExistingStreamerComboBox.SelectedItem;
                        if (setting.Channel.id == 0)
                        {
                            result = await this.NewStreamerLogin();
                        }
                        else
                        {
                            if (await this.ExistingSettingLogin(setting))
                            {
                                LoadingWindowBase newWindow = null;
                                if (ChannelSession.Settings.ReRunWizard)
                                {
                                    newWindow = new NewUserWizardWindow();
                                }
                                else
                                {
                                    newWindow = new MainWindow();
                                }
                                ShowMainWindow(newWindow);
                                this.Hide();
                                this.Close();
                                return;
                            }
                        }
                    }
                    else
                    {
                        await MessageBoxHelper.ShowMessageDialog("You must select a Streamer account to log in to");
                    }
                }
                else
                {
                    result = await this.NewStreamerLogin();
                }
            });
        }
Ejemplo n.º 3
0
        private async void ModeratorLoginButton_Click(object sender, RoutedEventArgs e)
        {
            await this.RunAsyncOperation(async() =>
            {
                if (string.IsNullOrEmpty(this.ModeratorChannelComboBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("A channel name must be entered");
                    return;
                }

                bool authenticationSuccessful = false;
                if (this.ModeratorChannelComboBox.SelectedIndex >= 0)
                {
                    IChannelSettings setting = (IChannelSettings)this.ModeratorChannelComboBox.SelectedItem;
                    authenticationSuccessful = await this.ExistingSettingLogin(setting);
                }
                else
                {
                    if (await this.ShowLicenseAgreement())
                    {
                        authenticationSuccessful = await this.EstablishConnection(ChannelSession.ModeratorScopes, this.ModeratorChannelComboBox.Text);
                    }
                }

                if (authenticationSuccessful)
                {
                    IEnumerable <UserWithGroupsModel> users = await ChannelSession.Connection.GetUsersWithRoles(ChannelSession.Channel, MixerRoleEnum.Mod);
                    if (users.Any(uwg => uwg.id.Equals(ChannelSession.User.id)) || Logger.IsDebug)
                    {
                        ShowMainWindow(new MainWindow());
                        this.Hide();
                        this.Close();
                    }
                    else
                    {
                        await MessageBoxHelper.ShowMessageDialog("You are not a moderator for this channel.");
                    }
                }
                else
                {
                    await MessageBoxHelper.ShowMessageDialog("Unable to authenticate with Mixer, please try again");
                }
            });
        }
Ejemplo n.º 4
0
        public void InitServerQueue(IChannelSettings settings, bool autoStart = false)
        {
            if (_ChannelService != null)
            {
                return;
            }

            ChannelInfo = settings.RawHostAddress;

            switch (settings.Protocol)
            {
            case NetProtocol.Http:
                _ChannelService = new HttpServerQueue((HttpSettings)settings, this);
                break;

            case NetProtocol.Pipe:
                _ChannelService = new PipeServerQueue((PipeSettings)settings, this);
                break;

            case NetProtocol.Tcp:
                _ChannelService = new TcpServerQueue((TcpSettings)settings, this);
                break;

            default:
                throw new InvalidOperationException("Protocol not supported");
            }
            if (_Logger == null)
            {
                _Logger = new LoggerConsole(true);
            }

            if (_Logger != null)
            {
                _ChannelService.Log = _Logger;
                _Logger.Info("TopicSbscriberListener Initilaized protocol:" + settings.Protocol.ToString());
                _Logger.Info("QueueHost Info - " + HostInfo);
                _Logger.Info("Channel Info: " + ChannelInfo);
            }

            if (autoStart)
            {
                Start();
            }
        }
Ejemplo n.º 5
0
        public async Task SavePackagedBackup(IChannelSettings settings, string filePath)
        {
            await this.Save(ChannelSession.Settings);

            string settingsFilePath = this.GetFilePath(settings);
            DesktopChannelSettings desktopSettings = (DesktopChannelSettings)settings;

            if (Directory.Exists(Path.GetDirectoryName(filePath)))
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }

                using (ZipArchive zipFile = ZipFile.Open(filePath, ZipArchiveMode.Create))
                {
                    zipFile.CreateEntryFromFile(settingsFilePath, Path.GetFileName(settingsFilePath));
                    zipFile.CreateEntryFromFile(desktopSettings.DatabasePath, Path.GetFileName(desktopSettings.DatabasePath));
                }
            }
        }
Ejemplo n.º 6
0
        public async Task <IEnumerable <IChannelSettings> > GetAllSettings()
        {
            if (!Directory.Exists(SettingsDirectoryName))
            {
                Directory.CreateDirectory(SettingsDirectoryName);
            }

            List <IChannelSettings> settings = new List <IChannelSettings>();

            foreach (string filePath in Directory.GetFiles(SettingsDirectoryName))
            {
                if (filePath.EndsWith(".xml"))
                {
                    IChannelSettings setting = null;
                    try
                    {
                        setting = await this.LoadSettings(filePath);

                        if (setting != null)
                        {
                            settings.Add(setting);
                            continue;
                        }
                    }
                    catch (Exception ex) { Logger.Log(ex); }

                    string backupFilePath = filePath + DesktopSettingsService.BackupFileExtension;

                    setting = await this.LoadSettings(backupFilePath);

                    if (setting != null)
                    {
                        settings.Add(setting);

                        GlobalEvents.ShowMessageBox("We were unable to load your settings file due to file corruption and will instead load your backup. This means that your most recent changes from the last time you ran Mix It Up will not be present." + Environment.NewLine + Environment.NewLine + "We apologize for this inconvenience and have already recorded this issue to help prevent this from happening in the future.");
                    }
                }
            }
            return(settings);
        }
Ejemplo n.º 7
0
        public async Task <IEnumerable <IChannelSettings> > GetAllSettings()
        {
            if (!Directory.Exists(SettingsDirectoryName))
            {
                Directory.CreateDirectory(SettingsDirectoryName);
            }

            List <IChannelSettings> settings = new List <IChannelSettings>();

            foreach (string filePath in Directory.GetFiles(SettingsDirectoryName))
            {
                if (filePath.EndsWith(".xml"))
                {
                    IChannelSettings setting = await this.LoadSettings(filePath);

                    if (setting != null)
                    {
                        settings.Add(setting);
                    }
                }
            }
            return(settings);
        }
        private static IEnumerable <CommandBase> GetAllCommands(IChannelSettings settings)
        {
            List <CommandBase> commands = new List <CommandBase>();

            commands.AddRange(settings.ChatCommands);
            commands.AddRange(settings.EventCommands);
            commands.AddRange(settings.InteractiveCommands);
            commands.AddRange(settings.TimerCommands);
            commands.AddRange(settings.ActionGroupCommands);
            commands.AddRange(settings.GameCommands);

            foreach (UserDataViewModel userData in settings.UserData.Values)
            {
                commands.AddRange(userData.CustomCommands);
                if (userData.EntranceCommand != null)
                {
                    commands.Add(userData.EntranceCommand);
                }
            }

            foreach (GameCommandBase gameCommand in settings.GameCommands)
            {
                commands.AddRange(gameCommand.GetAllInnerCommands());
            }

            foreach (UserCurrencyViewModel currency in settings.Currencies.Values)
            {
                if (currency.RankChangedCommand != null)
                {
                    commands.Add(currency.RankChangedCommand);
                }
            }

            foreach (UserInventoryViewModel inventory in settings.Inventories.Values)
            {
                commands.Add(inventory.ItemsBoughtCommand);
                commands.Add(inventory.ItemsSoldCommand);
            }

            foreach (OverlayWidget widget in settings.OverlayWidgets)
            {
                if (widget.Item is OverlayStreamBoss)
                {
                    OverlayStreamBoss item = ((OverlayStreamBoss)widget.Item);
                    if (item.NewStreamBossCommand != null)
                    {
                        commands.Add(item.NewStreamBossCommand);
                    }
                }
                else if (widget.Item is OverlayProgressBar)
                {
                    OverlayProgressBar item = ((OverlayProgressBar)widget.Item);
                    if (item.GoalReachedCommand != null)
                    {
                        commands.Add(item.GoalReachedCommand);
                    }
                }
                else if (widget.Item is OverlayTimer)
                {
                    OverlayTimer item = ((OverlayTimer)widget.Item);
                    if (item.TimerCompleteCommand != null)
                    {
                        commands.Add(item.TimerCompleteCommand);
                    }
                }
            }

            return(commands);
        }
Ejemplo n.º 9
0
 public string GetDatabaseFilePath(IChannelSettings settings)
 {
     return(Path.Combine(SettingsDirectoryName, string.Format("{0}.{1}.sqlite", settings.Channel.id.ToString(), (settings.IsStreamer) ? "Streamer" : "Moderator")));
 }
Ejemplo n.º 10
0
 public async Task ClearAllUserData(IChannelSettings settings)
 {
     DesktopChannelSettings desktopSettings = (DesktopChannelSettings)settings;
     await desktopSettings.DatabaseWrapper.RunWriteCommand("DELETE FROM Users");
 }
Ejemplo n.º 11
0
 public async Task Save(IChannelSettings settings, string fileName)
 {
     await this.SaveSettings(settings, fileName);
 }
Ejemplo n.º 12
0
 public async Task Save(IChannelSettings settings)
 {
     await this.SaveSettings(settings, this.GetFilePath(settings));
 }
Ejemplo n.º 13
0
        protected override async Task OnLoaded()
        {
            GlobalEvents.OnShowMessageBox += GlobalEvents_OnShowMessageBox;

            this.Title += " - v" + Assembly.GetEntryAssembly().GetName().Version.ToString();

            this.ExistingStreamerComboBox.ItemsSource = streamerSettings;
            this.ModeratorChannelComboBox.ItemsSource = moderatorSettings;

            if (Environment.OSVersion.Version < minimumOSVersion)
            {
                await MessageBoxHelper.ShowMessageDialog("Thank you for using Mix It Up, but unfortunately we only support Windows 8 & higher. If you are running Windows 8 or higher and see this message, please contact Mix It Up support for assistance.");

                this.Close();
                return;
            }

            if (!App.AppSettings.InstallerFolderUpgradeAsked)
            {
                App.AppSettings.InstallerFolderUpgradeAsked = true;
                App.AppSettings.Save();

                string currentInstallDirectory = ChannelSession.Services.FileService.GetApplicationDirectory();
                if (!Logger.IsDebug && !currentInstallDirectory.Equals(InstallerHelpers.InstallDirectory))
                {
                    if (await MessageBoxHelper.ShowConfirmationDialog("We noticed you are not running Mix It Up from the default installation folder." +
                                                                      " We now have a full installer that puts Mix It Up into your Local App Data folder and creates a Start Menu shortcut for you to easily launch it." +
                                                                      Environment.NewLine + Environment.NewLine +
                                                                      "We can install the latest version of Mix It Up with the Start Menu shortcut, copy over your current settings over there for you, and keep this version of Mix It Up as is for backup purposes." +
                                                                      Environment.NewLine + Environment.NewLine +
                                                                      "The process should take no more than a miunute; would you like us to do this for you?"))
                    {
                        bool installationSuccessful = await Task.Run(() =>
                        {
                            try
                            {
                                return(InstallerHelpers.DownloadMixItUp() && InstallerHelpers.InstallMixItUp() && InstallerHelpers.CreateMixItUpShortcut());
                            }
                            catch (Exception ex) { Logger.Log(ex); }
                            return(false);
                        });

                        if (installationSuccessful)
                        {
                            await ChannelSession.Services.FileService.CopyDirectory(Path.Combine(currentInstallDirectory, "Settings"),
                                                                                    Path.Combine(InstallerHelpers.InstallDirectory, "Settings"));

                            await ChannelSession.Services.FileService.CopyDirectory(Path.Combine(currentInstallDirectory, "Counters"),
                                                                                    Path.Combine(InstallerHelpers.InstallDirectory, "Counters"));

                            await MessageBoxHelper.ShowMessageDialog("Mix It Up was successfully installed to your Local App Data folder and a shortcut was created on the Start Menu." +
                                                                     " We will now close this version of Mix It Up and launch your newly installed version.");

                            Process.Start(Path.Combine(InstallerHelpers.StartMenuDirectory, InstallerHelpers.ShortcutFileName));
                            this.Close();
                            return;
                        }
                        else
                        {
                            await MessageBoxHelper.ShowMessageDialog("The installation failed for an unknown reason");
                        }
                    }
                }
            }

            await this.CheckForUpdates();

            foreach (IChannelSettings setting in (await ChannelSession.Services.Settings.GetAllSettings()).OrderBy(s => s.Channel.user.username))
            {
                if (setting.IsStreamer)
                {
                    this.streamerSettings.Add(setting);
                }
                else
                {
                    this.moderatorSettings.Add(setting);
                }
            }

            if (this.streamerSettings.Count > 0)
            {
                this.ExistingStreamerComboBox.Visibility = Visibility.Visible;
                this.streamerSettings.Add(new DesktopChannelSettings()
                {
                    Channel = new ExpandedChannelModel()
                    {
                        id = 0, user = new UserModel()
                        {
                            username = "******"
                        }
                    }
                });
                if (this.streamerSettings.Count() == 2)
                {
                    this.ExistingStreamerComboBox.SelectedIndex = 0;
                }
            }

            if (this.moderatorSettings.Count == 1)
            {
                this.ModeratorChannelComboBox.SelectedIndex = 0;
            }

            if (App.AppSettings.AutoLogInAccount > 0)
            {
                var allSettings = this.streamerSettings.ToList();
                allSettings.AddRange(this.moderatorSettings);

                IChannelSettings autoLogInSettings = allSettings.FirstOrDefault(s => s.Channel.user.id == App.AppSettings.AutoLogInAccount);
                if (autoLogInSettings != null && autoLogInSettings.LicenseAccepted)
                {
                    await Task.Delay(5000);

                    if (!updateFound)
                    {
                        if (await this.ExistingSettingLogin(autoLogInSettings))
                        {
                            LoadingWindowBase newWindow = null;
                            if (ChannelSession.Settings.ReRunWizard)
                            {
                                newWindow = new NewUserWizardWindow();
                            }
                            else
                            {
                                newWindow = new MainWindow();
                            }
                            ShowMainWindow(newWindow);
                            this.Hide();
                            this.Close();
                            return;
                        }
                    }
                }
            }

            await base.OnLoaded();
        }
Ejemplo n.º 14
0
        protected override async Task OnLoaded()
        {
            GlobalEvents.OnShowMessageBox += GlobalEvents_OnShowMessageBox;

            this.Title += " - v" + Assembly.GetEntryAssembly().GetName().Version.ToString();

            this.ExistingStreamerComboBox.ItemsSource = streamerSettings;
            this.ModeratorChannelComboBox.ItemsSource = moderatorSettings;

            await this.CheckForUpdates();

            foreach (IChannelSettings setting in (await ChannelSession.Services.Settings.GetAllSettings()).OrderBy(s => s.Channel.token))
            {
                if (setting.IsStreamer)
                {
                    this.streamerSettings.Add(setting);
                }
                else
                {
                    this.moderatorSettings.Add(setting);
                }
            }

            if (this.streamerSettings.Count > 0)
            {
                this.ExistingStreamerComboBox.Visibility = Visibility.Visible;
                this.streamerSettings.Add(new DesktopChannelSettings()
                {
                    Channel = new ExpandedChannelModel()
                    {
                        id = 0, user = new UserModel()
                        {
                            username = "******"
                        }, token = "NEW STREAMER"
                    }
                });
                if (this.streamerSettings.Count() == 2)
                {
                    this.ExistingStreamerComboBox.SelectedIndex = 0;
                }
            }

            if (this.moderatorSettings.Count == 1)
            {
                this.ModeratorChannelComboBox.SelectedIndex = 0;
            }

            if (App.AppSettings.AutoLogInAccount > 0)
            {
                var allSettings = this.streamerSettings.ToList();
                allSettings.AddRange(this.moderatorSettings);

                IChannelSettings autoLogInSettings = allSettings.FirstOrDefault(s => s.Channel.user.id == App.AppSettings.AutoLogInAccount);
                if (autoLogInSettings != null && autoLogInSettings.LicenseAccepted)
                {
                    await Task.Delay(5000);

                    if (!updateFound)
                    {
                        if (await this.ExistingSettingLogin(autoLogInSettings))
                        {
                            LoadingWindowBase newWindow = null;
                            if (ChannelSession.Settings.ReRunWizard)
                            {
                                newWindow = new NewUserWizardWindow();
                            }
                            else
                            {
                                newWindow = new MainWindow();
                            }
                            ShowMainWindow(newWindow);
                            this.Hide();
                            this.Close();
                            return;
                        }
                    }
                }
            }

            await base.OnLoaded();
        }
Ejemplo n.º 15
0
        private static IEnumerable <CommandBase> GetAllCommands(IChannelSettings settings)
        {
            List <CommandBase> commands = new List <CommandBase>();

            commands.AddRange(settings.ChatCommands);
            commands.AddRange(settings.EventCommands);
            commands.AddRange(settings.InteractiveCommands);
            commands.AddRange(settings.TimerCommands);
            commands.AddRange(settings.ActionGroupCommands);
            commands.AddRange(settings.GameCommands);

            foreach (UserDataViewModel userData in settings.UserData.Values)
            {
                commands.AddRange(userData.CustomCommands);
                if (userData.EntranceCommand != null)
                {
                    commands.Add(userData.EntranceCommand);
                }
            }

            foreach (GameCommandBase gameCommand in settings.GameCommands)
            {
                commands.AddRange(gameCommand.GetAllInnerCommands());
            }

            foreach (UserCurrencyViewModel currency in settings.Currencies.Values)
            {
                if (currency.RankChangedCommand != null)
                {
                    commands.Add(currency.RankChangedCommand);
                }
            }

            foreach (UserInventoryViewModel inventory in settings.Inventories.Values)
            {
                commands.Add(inventory.ItemsBoughtCommand);
                commands.Add(inventory.ItemsSoldCommand);
            }

#pragma warning disable CS0612 // Type or member is obsolete
            foreach (OverlayWidget widget in settings.overlayWidgetsInternal)
            {
                if (widget.Item is OverlayStreamBoss)
                {
                    OverlayStreamBoss item = ((OverlayStreamBoss)widget.Item);
                    if (item.NewStreamBossCommand != null)
                    {
                        commands.Add(item.NewStreamBossCommand);
                    }
                }
                else if (widget.Item is OverlayProgressBar)
                {
                    OverlayProgressBar item = ((OverlayProgressBar)widget.Item);
                    if (item.GoalReachedCommand != null)
                    {
                        commands.Add(item.GoalReachedCommand);
                    }
                }
                else if (widget.Item is OverlayTimer)
                {
                    OverlayTimer item = ((OverlayTimer)widget.Item);
                    if (item.TimerCompleteCommand != null)
                    {
                        commands.Add(item.TimerCompleteCommand);
                    }
                }
            }
#pragma warning restore CS0612 // Type or member is obsolete

            foreach (OverlayWidgetModel widget in settings.OverlayWidgets)
            {
                if (widget.Item is OverlayStreamBossItemModel)
                {
                    OverlayStreamBossItemModel item = ((OverlayStreamBossItemModel)widget.Item);
                    if (item.NewStreamBossCommand != null)
                    {
                        commands.Add(item.NewStreamBossCommand);
                    }
                }
                else if (widget.Item is OverlayProgressBarItemModel)
                {
                    OverlayProgressBarItemModel item = ((OverlayProgressBarItemModel)widget.Item);
                    if (item.GoalReachedCommand != null)
                    {
                        commands.Add(item.GoalReachedCommand);
                    }
                }
                else if (widget.Item is OverlayTimerItemModel)
                {
                    OverlayTimerItemModel item = ((OverlayTimerItemModel)widget.Item);
                    if (item.TimerCompleteCommand != null)
                    {
                        commands.Add(item.TimerCompleteCommand);
                    }
                }
            }

            commands.Add(settings.GameQueueUserJoinedCommand);
            commands.Add(settings.GameQueueUserSelectedCommand);
            commands.Add(settings.GiveawayStartedReminderCommand);
            commands.Add(settings.GiveawayUserJoinedCommand);
            commands.Add(settings.GiveawayWinnerSelectedCommand);
            commands.Add(settings.ModerationStrike1Command);
            commands.Add(settings.ModerationStrike2Command);
            commands.Add(settings.ModerationStrike3Command);
            commands.Add(settings.SongAddedCommand);
            commands.Add(settings.SongRemovedCommand);
            commands.Add(settings.SongPlayedCommand);

            return(commands.Where(c => c != null));
        }
Ejemplo n.º 16
0
 public StreamerLoginItem(IChannelSettings setting)
 {
     this.Setting = setting;
 }