示例#1
0
            private void CheckLocalGoogleDrive()
            {
                new Thread(() => {
                    Thread.CurrentThread.IsBackground = true;
                    stopCheck = false;

                    MainProgram.DoDebug("Starting loop to check for Google Drive folder locally");
                    while (backgroundCheckerServiceName == "googledrive" && CloudServiceFunctions.GetGoogleDriveFolder() == String.Empty && !stopCheck)
                    {
                        Thread.Sleep(1000);
                    }
                    if (stopCheck)
                    {
                        stopCheck = false;
                        return;
                    }

                    if (backgroundCheckerServiceName == "googledrive")
                    {
                        //Cloud service has been installed since we last checked!
                        MainProgram.DoDebug("Google Drive has been added to local PC. Proceed.");
                        theWebBrowser.Invoke(new Action(() => {
                            theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[2] {
                                true, false
                            });
                        }));
                    }
                    else
                    {
                        MainProgram.DoDebug("Service has since been changed. Stopping the search for Google Drive.");
                    }
                }).Start();
            }
示例#2
0
            private bool CheckSetPath(string chosenService)
            {
                if (customSetPath != String.Empty)
                {
                    if (Directory.Exists(customSetPath))
                    {
                        if (!customSetPath.Contains("AssistantComputerControl") && !customSetPath.Contains("assistantcomputercontrol"))
                        {
                            customSetPath = Path.Combine(customSetPath, "AssistantComputerControl");
                            MainProgram.DoDebug("Changed path to include 'AssistantComputerControl': " + customSetPath);

                            if (!Directory.Exists(customSetPath))
                            {
                                Directory.CreateDirectory(customSetPath);
                            }
                        }

                        Properties.Settings.Default.ActionFilePath = customSetPath;
                        Properties.Settings.Default.Save();

                        MainProgram.SetupListener();
                        return(true);
                    }
                }
                else
                {
                    string checkPath = CloudServiceFunctions.GetCloudServicePath(chosenService);
                    MainProgram.DoDebug("Checking: " + checkPath);
                    if (!String.IsNullOrEmpty(checkPath))
                    {
                        if (Directory.Exists(checkPath))
                        {
                            if (!checkPath.Contains("AssistantComputerControl") && !checkPath.Contains("assistantcomputercontrol"))
                            {
                                checkPath = Path.Combine(checkPath, "AssistantComputerControl");
                                MainProgram.DoDebug("Changed path to include 'AssistantComputerControl': " + checkPath);

                                if (!Directory.Exists(checkPath))
                                {
                                    Directory.CreateDirectory(checkPath);
                                }
                            }

                            Properties.Settings.Default.ActionFilePath = checkPath;
                            Properties.Settings.Default.Save();

                            MainProgram.SetupListener();
                            return(true);
                        }
                    }
                }
                return(false);
            }
示例#3
0
            public void CloudServiceChosen(string service = "")
            {
                switch (service)
                {
                case "dropbox":
                case "onedrive":
                case "googledrive":
                    backgroundCheckerServiceName = service;
                    break;

                default:
                    return;
                }

                if (CloudServiceFunctions.GetCloudServicePath(backgroundCheckerServiceName) != "")
                {
                    //Cloud service found
                    MainProgram.DoDebug("Cloud service " + backgroundCheckerServiceName + " is installed");
                    bool partial = false;

                    if (backgroundCheckerServiceName == "googledrive")
                    {
                        partial = CloudServiceFunctions.GetGoogleDriveFolder() != String.Empty;
                    }

                    if (theWebBrowser != null)
                    {
                        IntPtr theHandle = IntPtr.Zero;
                        try {
                            theHandle = theWebBrowser.Handle;
                        } catch {
                            MainProgram.DoDebug("Failed to get web browser handle.");
                            MessageBox.Show(Translator.__("cloud_setup_failed", "general"), MainProgram.messageBoxTitle);
                        }

                        if (theHandle != IntPtr.Zero)
                        {
                            if (theWebBrowser.Handle != null)
                            {
                                theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[2] {
                                    true, partial
                                });
                            }
                        }
                    }

                    if (partial)
                    {
                        CheckLocalGoogleDrive();
                    }
                }
                else
                {
                    //Not found
                    new Thread(() => {
                        Thread.CurrentThread.IsBackground = true;
                        string checkValue = "";
                        stopCheck         = false;

                        MainProgram.DoDebug("Could not find cloud service. Running loop to check");
                        while (checkValue == "" && !stopCheck)
                        {
                            checkValue = CloudServiceFunctions.GetCloudServicePath(backgroundCheckerServiceName);
                            Thread.Sleep(1000);
                        }
                        if (stopCheck)
                        {
                            stopCheck = false;
                            return;
                        }

                        //Cloud service has been installed since we last checked!
                        MainProgram.DoDebug("Cloud service has been installed since last check. Proceed.");

                        if (theWebBrowser != null)
                        {
                            if (theWebBrowser.Handle != null)
                            {
                                theWebBrowser.Invoke(new Action(() => {
                                    if (backgroundCheckerServiceName == "googledrive")
                                    {
                                        bool partial = CloudServiceFunctions.GetGoogleDriveFolder() != String.Empty;
                                        theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[2] {
                                            true, partial
                                        });
                                        if (partial)
                                        {
                                            CheckLocalGoogleDrive();
                                        }
                                    }
                                    else
                                    {
                                        theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[1] {
                                            true
                                        });
                                    }
                                }));
                            }
                        }
                    }).Start();
                }
            }