Пример #1
0
        private void RunDirectConnect(bool localLink, ConnectionInfo info, bool diffToken = false)
        {
            var servers = new List <Server>();

            using (var frmDir = new DirectConnect())
            {
                frmDir.ConnectionInfo = info;
                frmDir.DifferentToken = diffToken;
                frmDir.LoadLocalLink  = localLink;

                if (frmDir.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                if (!frmDir.Success)
                {
                    return;
                }

                ObjectProvider.Settings.ConnectionInfo  = frmDir.ConnectionInfo;
                ObjectProvider.User.authenticationToken = frmDir.ConnectionInfo.PlexAccountToken;
                var s = new Server
                {
                    accessToken = ObjectProvider.User.authenticationToken,
                    address     = ObjectProvider.Settings.ConnectionInfo.PlexAddress,
                    port        = ObjectProvider.Settings.ConnectionInfo.PlexPort,
                    name        = "DirectConnect"
                };
                servers.Add(s);
                ObjectProvider.PlexServers = servers;
                SelectedServer             = s;
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Пример #2
0
        private void RunDirectConnect(bool localLink, ConnectionInfo info, bool diffToken = false)
        {
            //new list of servers
            var servers = new List <Server>();

            //construct a new direct connection dialog
            using (var frmDir = new DirectConnect())
            {
                //setup form prerequisities
                frmDir.ConnectionInfo = info;
                frmDir.DifferentToken = diffToken;
                frmDir.LoadLocalLink  = localLink;

                //dialog verification
                if (frmDir.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                if (!frmDir.Success)
                {
                    return;
                }

                //set auth globals
                ObjectProvider.Settings.ConnectionInfo  = frmDir.ConnectionInfo;
                ObjectProvider.User.authenticationToken = frmDir.ConnectionInfo.PlexAccountToken;

                //construct new server obejct from supplied direct connection information
                var s = new Server
                {
                    accessToken = ObjectProvider.User.authenticationToken,
                    address     = ObjectProvider.Settings.ConnectionInfo.PlexAddress,
                    port        = ObjectProvider.Settings.ConnectionInfo.PlexPort,
                    name        = "DirectConnect"
                };

                //apply listing information for auth
                servers.Add(s);
                ObjectProvider.PlexServers = servers;

                //set globals
                SelectedServer = s;
                DialogResult   = DialogResult.OK;

                //close the GUI
                Close();
            }
        }