/// <summary>
        /// Parses a VWRAP Launch Document file
        /// </summary>
        /// <param name="path">Filename of the launch document to parse</param>
        /// <returns>The parsed document, or null on failure</returns>
        public static LaunchDocument FromFile(string path)
        {
            try
            {
                using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    OSDMap launchMap = OSDParser.Deserialize(stream) as OSDMap;

                    if (launchMap != null)
                    {
                        LaunchDocument document = new LaunchDocument();

                        document.LoginUrl    = launchMap["loginurl"].AsString();
                        document.WelcomeUrl  = launchMap["welcomeurl"].AsString(); // --loginpage
                        document.EconomyUrl  = launchMap["economyurl"].AsString(); // --helperuri
                        document.AboutUrl    = launchMap["abouturl"].AsString();
                        document.RegisterUrl = launchMap["registerurl"].AsString();
                        document.HelpUrl     = launchMap["helpurl"].AsString();
                        document.PasswordUrl = launchMap["passwordurl"].AsString();

                        // Not a valid launch doc without a loginurl
                        if (String.IsNullOrEmpty(document.LoginUrl))
                        {
                            return(null);
                        }

                        document.Region = launchMap["region"].AsString();

                        OSDMap authenticatorMap = launchMap["authenticator"] as OSDMap;
                        if (authenticatorMap != null)
                        {
                            document.IsLoginUrlCapability = (authenticatorMap["type"].AsString() == "capability");
                        }

                        OSDMap identifierMap = launchMap["identifier"] as OSDMap;
                        if (identifierMap != null)
                        {
                            document.AccountName = identifierMap["account_name"].AsString();
                            document.Name        = identifierMap["name"].AsString();

                            // Legacy support
                            if (String.IsNullOrEmpty(document.Name))
                            {
                                string first = identifierMap["first_name"].AsString();
                                string last  = identifierMap["last_name"].AsString();

                                document.Name = (first + " " + last).Trim();
                            }
                        }

                        return(document);
                    }
                }
            }
            catch
            {
            }

            return(null);
        }
示例#2
0
        private void frmVWRAPLauncher_Load(object sender, EventArgs e)
        {
            string path, arguments;

            cboStartLocation.Items.Add(START_HOME);
            cboStartLocation.Items.Add(START_LAST);
            cboStartLocation.Items.Add(START_TYPE);
            cboStartLocation.SelectedIndex = 1;

            panel.VerticalScroll.Enabled = true;
            panel.Click += HighlightItem;

            PopulateList();

            if (!String.IsNullOrEmpty(LaunchDocumentPath))
            {
                m_launchDocument = LaunchDocument.FromFile(LaunchDocumentPath);
                if (m_launchDocument == null)
                {
                    MessageBox.Show("Failed to load a VWRAP launch document from \"" + LaunchDocumentPath + "\"",
                                    "VWRAP Launcher", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            if (m_launchDocument != null)
            {
                // If a viewer preference was saved we can go straight to launching
                if (LoadViewerPreference(out path, out arguments))
                {
                    chkRemember.Checked = true;
                    LaunchViewer(path, arguments);
                }
            }
            else
            {
                // Clear the remember preference
                chkRemember_CheckedChanged(chkRemember, null);

                MessageBox.Show("The VWRAP Launcher will automatically handle VWRAP documents in a web browser. " +
                                "You do not need to run this application directly.", "VWRAP Launcher",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#3
0
        /// <summary>
        /// Parses a VWRAP Launch Document file
        /// </summary>
        /// <param name="path">Filename of the launch document to parse</param>
        /// <returns>The parsed document, or null on failure</returns>
        public static LaunchDocument FromFile(string path)
        {
            try
            {
                using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    OSDMap launchMap = OSDParser.Deserialize(stream) as OSDMap;

                    if (launchMap != null)
                    {
                        LaunchDocument document = new LaunchDocument();

                        document.LoginUrl = launchMap["loginurl"].AsString();
                        document.WelcomeUrl = launchMap["welcomeurl"].AsString(); // --loginpage
                        document.EconomyUrl = launchMap["economyurl"].AsString(); // --helperuri
                        document.AboutUrl = launchMap["abouturl"].AsString();
                        document.RegisterUrl = launchMap["registerurl"].AsString();
                        document.HelpUrl = launchMap["helpurl"].AsString();
                        document.PasswordUrl = launchMap["passwordurl"].AsString();

                        // Not a valid launch doc without a loginurl
                        if (String.IsNullOrEmpty(document.LoginUrl))
                            return null;

                        document.Region = launchMap["region"].AsString();

                        OSDMap authenticatorMap = launchMap["authenticator"] as OSDMap;
                        if (authenticatorMap != null)
                        {
                            document.IsLoginUrlCapability = (authenticatorMap["type"].AsString() == "capability");
                        }

                        OSDMap identifierMap = launchMap["identifier"] as OSDMap;
                        if (identifierMap != null)
                        {
                            document.AccountName = launchMap["account_name"].AsString();
                            document.Name = launchMap["name"].AsString();

                            // Legacy support
                            if (String.IsNullOrEmpty(document.Name))
                            {
                                string first = launchMap["first_name"].AsString();
                                string last = launchMap["last_name"].AsString();

                                document.Name = (first + " " + last).Trim();
                            }
                        }

                        return document;
                    }
                }
            }
            catch
            {
            }

            return null;
        }