Ejemplo n.º 1
0
        public void Write()
        {
            FileVar ivFile = new FileVar(FileNamePath);

            ivFile["ChunkCount"] = Chunks.Count.ToString();
            Int32 iChunck = 1;

            foreach (string sChunck in Chunks)
            {
                ivFile["x" + iChunck.ToString()] = sChunck;
                iChunck++;
            }
        }
Ejemplo n.º 2
0
        private async void button1_ClickAsync(object sender, EventArgs e)
        {
            var github = new GitHubClient(new ProductHeaderValue("SyncDrop"));

            #region Credit
            MMCredentialStore mc = new MMCredentialStore("");
            if (mc["github"] != "")
            {
                string sCredits = mc["github"];
                string sUser    = sCredits.ParseString(" ", 0);
                string sPwd     = sCredits.ParseString(" ", 1);
                github.Credentials = new Credentials(sUser, sPwd);
            }
            #endregion

            var sRepUser  = "******";
            var sRepName  = "MMDataStore";
            var sFileName = "EFJGJNATBKTTHHQYGL.txt";
            var branch    = "master";

            //  var rMMDataStore = await github.Repository.Get("mmeents", "MMDataStore");
            //  var sName = rMMDataStore.Name;
            //  var sLogin = rMMDataStore.Owner.Login;

            var RepContent = await github.Repository.Content.GetAllContents(sRepUser, sRepName, "path");

            foreach (RepositoryContent rc in RepContent)
            {
                if (rc.Name == sFileName)
                {
                    setMessage(rc.Name + " found in Encoded");
                    String sTempName = Path.GetTempFileName();
                    rc.DownloadUrl.SaveAs(sTempName);
                    FileVar fv        = new FileVar(sTempName);
                    string  sUserHash = mc.rTool.GetPublicCert().toHashSHA512();
                    string  sUserCert = mc.rTool.GetPublicCert();
                    if (fv["Usr" + sUserHash] != sUserCert)
                    {
                        fv["Usr" + sUserHash] = mc.rTool.GetPublicCert();
                        string sSha            = rc.Sha;
                        string sContents       = File.ReadAllText(sTempName);
                        var    updateChangeSet = await github.Repository.Content.UpdateFile(sRepUser, sRepName, "path/" + sFileName,
                                                                                            new UpdateFileRequest("RegisterUserX", sContents, sSha, branch));
                    }
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public static void VA_Invoke1(String context, ref Dictionary <string, object> state, ref Dictionary <string, Int16?> shortIntValues, ref Dictionary <string, string> textValues, ref Dictionary <string, int?> intValues, ref Dictionary <string, decimal?> decimalValues, ref Dictionary <string, bool?> booleanValues, ref Dictionary <string, object> extendedValues)
        {
            try
            {
                Elite.MessageBus messageBus = (Elite.MessageBus)state["VAEDmessageBus"];
                messageBus.loggedinState = (string)state["VAEDloggedIn"];
                if (state.ContainsKey("VAEDcookieContainer"))
                {
                    messageBus.cookies = (CookieContainer)state["VAEDcookieContainer"];
                }
                Debug.Write("COMMAND:  " + context);
                switch (context.ToLower())
                {
                case "check for upgrade":
                    if (Upgrade.needUpgradeWithCooldown(ref state))
                    {
                        booleanValues["VAEDupgradeAvailable"] = true;
                        state["VAEDupgradeAvailable"]         = true;
                    }
                    else
                    {
                        booleanValues["VAEDupgradeAvailable"] = false;
                        state["VAEDupgradeAvailable"]         = false;
                    }
                    break;

                case "distance from here":
                    string currentSystem = messageBus.currentSystem;
                    if (currentSystem == null)     // If we don't have it from netlog then go get it from the profile
                    {
                        Dictionary <string, dynamic> companion = Companion.getProfile((messageBus));
                        if (companion.ContainsKey("lastSystem") && companion["lastSystem"].ContainsKey("name"))
                        {
                            currentSystem            = currentSystem = companion["lastSystem"]["name"];
                            messageBus.currentSystem = currentSystem;
                            // We didn't have current system from netlog, so erase out x,y,z

                            messageBus.haveSystemCoords = false;
                        }
                    }

                    decimalValues["VAEDdecimalDistance"] = null;
                    decimalValues["VAEDintDistance"]     = null;
                    if (currentSystem != null)
                    {
                        int distance = Atlas.calcDistanceFromHere(messageBus, textValues["VAEDtargetSystem"]);
                        if (distance < 0)
                        {
                            //Cound not find destination system
                            Debug.Write("Error:  Could not determine distance to target system");
                            booleanValues["VAEDerrorTargetSystem"] = true;
                            break;
                        }
                        // Found the system - return distance
                        intValues["VAEDintDistance"]           = distance;
                        booleanValues["VAEDerrorTargetSystem"] = false;
                        booleanValues["VAEDerrorSourceSystem"] = false;
                        break;
                    }
                    //Can't find the System
                    Debug.Write("Error:  Could not determine current location for command 'distance from here'");
                    booleanValues["VAEDerrorSourceSystem"]      = true;
                    booleanValues["VAEDerrorDestinationSystem"] = false;
                    break;

                case "dictate system":
                    booleanValues["VAEDrecognitionNotLoaded"] = false;
                    if (messageBus.grammarLoaded)
                    {
                        SpeechRecognitionEngine recognitionEngine = messageBus.recognitionEngine;

                        Tuple <string, string> tSystemNames = EliteGrammar.dictateSystem(recognitionEngine, (List <String>)state["VAEDtrackedSystems"]);
                        textValues["VAEDdictateSystem"]         = tSystemNames.Item1;
                        textValues["VAEDdictateSystemPhonetic"] = tSystemNames.Item2;
                        break;
                    }
                    else
                    {
                        booleanValues["VAEDrecognitionNotLoaded"] = true;
                        Debug.Write("Error:  Speech Engine not yet Initialized.  (Possibly still loading)");
                    }
                    textValues["VAEDdictateSystem"]         = null;
                    textValues["VAEDdictateSystemPhonetic"] = null;
                    break;

                case "press key bind":
                    // If the Binds file changes then reload the binds.

                    string[]   parts      = textValues["VAEDkeyBinding"].Split(new char[] { ':' }, 2);
                    EliteBinds eliteBinds = EliteBinds.getBinds(ref state, ref textValues, ref booleanValues, messageBus);
                    if (eliteBinds != null)
                    {
                        string keyboardLanguage;
                        if (state.ContainsKey("VAEDbindsLanguage"))
                        {
                            keyboardLanguage = (string)state["VAEDbindsLanguage"];
                        }
                        else
                        {
                            keyboardLanguage = "en-US";
                        }
                        List <uint> scanCodeExs = KeyMouse.MapVkToScanCodeExs(eliteBinds.GetCodes(parts[1], keyboardLanguage));
                        if (scanCodeExs.Count == 0)
                        {
                            Debug.Write("Warning: No key binding found for: " + textValues["VAEDkeyBinding"]);
                            booleanValues["VAEDkeyBindingError"] = true;
                            break;
                        }



                        switch (parts[0])
                        {
                        // For now we only "best effort" focus the game before keypressing.  Igorning the setFocus return code.
                        case "KEYPRESS":
                            Debug.Write("Key Press " + parts[1]);
                            User32.setFocus(eliteWindowTitle);
                            KeyMouse.KeyPress(scanCodeExs);
                            booleanValues["VAEDkeyBindingError"] = false;
                            break;

                        case "KEYUP":
                            Debug.Write("Key up " + parts[1]);
                            User32.setFocus(eliteWindowTitle);
                            KeyMouse.KeyUp(scanCodeExs);
                            booleanValues["VAEDkeyBindingError"] = false;
                            break;

                        case "KEYDOWN":
                            Debug.Write("Key down " + parts[1]);
                            User32.setFocus(eliteWindowTitle);
                            KeyMouse.KeyDown(scanCodeExs);
                            booleanValues["VAEDkeyBindingError"] = false;
                            break;

                        default:
                            booleanValues["VAEDkeyBindingError"] = true;
                            break;
                        }
                    }
                    else
                    {
                        Debug.Write("Error:  Binds not loaded, unable to perform keypress");
                    }
                    break;

                case "clear debug":
                    Debug.Clear();
                    break;

                case "get debug":
                    string tempDebug = Debug.Path();
                    textValues["VAEDdebugFile"] = tempDebug;
                    break;

                case "export for ed shipyard":
                    Companion.updateProfile(messageBus, ref state, ref shortIntValues, ref textValues, ref intValues, ref decimalValues, ref booleanValues);

                    if (state.ContainsKey("VAEDshipObj"))
                    {
                        Ship.Components shipObj = (Ship.Components)state["VAEDshipObj"];
                        StringBuilder   export  = EDShipyard.export(shipObj);
                        if (export != null)
                        {
                            booleanValues["VAEDexportEDShipyardError"] = false;
                            Clipboard.SetText(export.ToString());
                            break;
                        }
                    }
                    Debug.Write("Error:  Unable to form ED Shipyard.com Export");
                    Clipboard.Clear();
                    booleanValues["VAEDexportEDShipyuardError"] = true;
                    break;

                case "export for coriolis":
                    Companion.updateProfile(messageBus, ref state, ref shortIntValues, ref textValues, ref intValues, ref decimalValues, ref booleanValues);
                    if (state.ContainsKey("VAEDshipObj"))
                    {
                        Ship.Components shipObj = (Ship.Components)state["VAEDshipObj"];
                        string          json    = Coriolis.export(shipObj);
                        if (json != null)
                        {
                            booleanValues["VAEDexportCoriolisError"] = false;
                            Clipboard.SetText(json);
                            break;
                        }
                    }
                    Debug.Write("Error:  Unable to form Coriolis.io JSON");
                    Clipboard.Clear();
                    booleanValues["VAEDexportCoriolisError"] = true;
                    break;

                case "edit web variable sources":
                    bool foundWindow = false;
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType().Name == "EditWebVars")
                        {
                            Debug.Write("Edit Web Variable Sources window is already open");
                            foundWindow = true;
                        }
                    }
                    if (!foundWindow)
                    {
                        var webVarsForm = new WebVars.EditWebVars();
                        webVarsForm.ShowDialog();
                    }
                    break;

                case "get web variables":
                    GetWebVars.readWebVars(ref state, ref textValues, ref intValues, ref booleanValues);
                    break;

                case "get file variables":
                    FileVar.readFileVars(ref state, ref textValues, ref intValues, ref booleanValues);
                    break;

                case "get clipboard":
                    if (Clipboard.ContainsText(TextDataFormat.Text))
                    {
                        textValues.Add("VAEDclipboard", Clipboard.GetText());
                    }
                    break;

                case "get frontier credentials":
                    var configureForm = new ConfigureForm.Configuration((string)state["VAEDloggedIn"]);
                    configureForm.ShowDialog();
                    CookieContainer loginCookies = configureForm.Cookie;
                    state["VAEDcookieContainer"] = loginCookies;
                    string loginResponse = configureForm.LoginResponse;
                    Debug.Write("Frontier Login Response: " + loginResponse);
                    textValues["VAEDloggedIn"] = loginResponse;
                    break;

                case "get frontier verification":
                    CookieContainer verifyCookies = new CookieContainer();
                    if (state.ContainsKey("VAEDcookieContainer"))
                    {
                        verifyCookies = (CookieContainer)state["VAEDcookieContainer"];
                    }
                    var verificationForm = new VerificationCode.Validate();
                    verificationForm.Cookie = verifyCookies;
                    verificationForm.ShowDialog();
                    verifyCookies = verificationForm.Cookie;
                    string verifyResponse = verificationForm.VerifyResponse;
                    state["VAEDloggedIn"]        = verifyResponse;
                    state["VAEDcookieContainer"] = verifyCookies;
                    textValues["VAEDloggedIn"]   = verifyResponse;
                    if (verifyResponse == "ok")
                    {
                        Web.WriteCookiesToDisk(Config.CookiePath(), verifyCookies);
                    }
                    break;

                case "update profile and eddn":
                    if (state["VAEDloggedIn"].ToString() == "ok" && state.ContainsKey("VAEDcookieContainer"))
                    {
                        Companion.updateProfile(messageBus, ref state, ref shortIntValues, ref textValues, ref intValues, ref decimalValues, ref booleanValues);
                    }
                    else     // Not logged in
                    {
                        textValues["VAEDprofileStatus"] = "credentials";
                    }
                    break;

                default:
                    Debug.Write("ERROR: unknown command");
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
            }
        }