예제 #1
0
        public frmControllerBrowser()
        {
            DataContext            = this;
            State                  = ASYNC_STATE.NOTREFRESHED;
            allControllers         = new ObservableCollection <ControllerInfo>();
            purchasedControllers   = new ObservableCollection <ControllerInfo>();
            downloadingControllers = new ObservableCollection <ControllerInfo>();

            InitializeComponent();

            lstAllControllers.ItemsSource       = allControllers;
            lstPurchasedControllers.ItemsSource = purchasedControllers;
            lstDownloading.ItemsSource          = downloadingControllers;

            downloadingControllers.CollectionChanged += downloadingControllers_CollectionChanged;

            refreshControllers(null, null);
        }
예제 #2
0
        public void refreshPurchased()
        {
            string hostname = "secure144.inmotionhosting.com";
            var    request  = new HttpRequest("/~r4msof5/releases/MobiController/controllers/listpurchased.php");

            try
            {
                var thisConnection = App.MainWin.Browser.openSecureConnection(hostname, HttpBrowserEntitiy.PORTS.SSL, hostname);
                request.cookies = App.MainWin.Browser.SessionCookies;
                thisConnection.sendRequestAsync(request, (response) =>
                {
                    string[] cs = response.Body.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    if (!response.Body.Contains("You have not purchased any controllers"))
                    {
                        for (int i = 1; i < cs.Length; i++) // i=1 accounts for apache's weird header
                        {
                            var newConnection         = App.MainWin.Browser.openConnection(frmMain.WEB_ROOT, HttpBrowserEntitiy.PORTS.HTTP);
                            HttpResponse htmlresponse = newConnection.sendRequest(new HttpRequest("/controllers/" + cs[i] + "/index.php"));
                            Dispatcher.Invoke(() =>
                            {
                                var thisController = new ControllerInfo(false)
                                {
                                    Description = "sample description", ImageSource = "http://mobicontroller.com/controllers/" + cs[i] + "/1.png", Lastupdated = "never", FileName = cs[i]
                                };
                                thisController.Description = HelperClass.stripHtmlParagraph(HelperClass.getIsolatedString("<section>", "</section>", htmlresponse.Body));
                                thisController.Lastupdated = HelperClass.getIsolatedString("<b> Last Updated: ", "</b>", htmlresponse.Body);
                                purchasedControllers.Add(thisController);
                                State = ASYNC_STATE.REFRESHED;
                            });
                        }
                    }
                });
            }
            catch (SocketException)
            {
                State = ASYNC_STATE.NOTREFRESHED;
            }
        }
예제 #3
0
        private void refreshControllers(object sender, RoutedEventArgs e)
        {
            //HelperClass helper = new HelperClass();
            State = ASYNC_STATE.REFRESHING;
            allControllers.Clear();
            purchasedControllers.Clear();

            try
            {
                var thisConnection = App.MainWin.Browser.openConnection(frmMain.WEB_ROOT, 80);
                {
                    thisConnection.sendRequestAsync(new HttpRequest("/releases/MobiController/controllers/listpaid.php"), (response) =>
                    {
                        string[] cs = response.Body.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 1; i < cs.Length; i++) // i=1 accounts for apache's weird header
                        {
                            var newConnection  = App.MainWin.Browser.openConnection(frmMain.WEB_ROOT, 80);
                            var thisController = new ControllerInfo(false)
                            {
                                Description = "sample description", ImageSource = "http://mobicontroller.com/controllers/" + cs[i] + "/1.png", Lastupdated = "never", FileName = cs[i]
                            };
                            newConnection.sendRequestAsync(new HttpRequest("/controllers/" + cs[i] + "/index.php"), (htmlresponse) =>
                            {
                                Dispatcher.Invoke(() =>
                                {
                                    thisController.Description = HelperClass.stripHtmlParagraph(HelperClass.getIsolatedString("<section>", "</section>", htmlresponse.Body));
                                    thisController.Lastupdated = HelperClass.getIsolatedString("<b> Last Updated: ", "</b>", htmlresponse.Body);
                                    allControllers.Insert(0, thisController);
                                });
                            });
                        }
                    });
                }

                thisConnection = App.MainWin.Browser.openConnection(frmMain.WEB_ROOT, 80); // just in case the other thread is slow
                thisConnection.sendRequestAsync(new HttpRequest("/releases/MobiController/controllers/listfree.php"), (response) =>
                {
                    string[] cs = response.Body.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 1; i < cs.Length; i++) // i=1 accounts for apache's weird header
                    {
                        var newConnection         = App.MainWin.Browser.openConnection(frmMain.WEB_ROOT, 80);
                        HttpResponse htmlresponse = newConnection.sendRequest(new HttpRequest("/controllers/" + cs[i] + "/index.php"));
                        var thisController        = new ControllerInfo(true)
                        {
                            Description = "sample description", ImageSource = "http://mobicontroller.com/controllers/" + cs[i] + "/1.png", Lastupdated = "never", FileName = cs[i]
                        };
                        Dispatcher.Invoke(() =>
                        {
                            //Features</h2><div style='text-align:left'> <div style=\"text-align:center;\">
                            thisController.Description = HelperClass.stripHtmlParagraph(HelperClass.getIsolatedString("<section>", "</section>", htmlresponse.Body));
                            thisController.Lastupdated = HelperClass.getIsolatedString("<b> Last Updated: ", "</b>", htmlresponse.Body);
                            allControllers.Add(thisController);
                        });
                    }
                });
                if (App.MainWin.Browser.SessionCookies.ContainsKey(frmMain.PHP_COOKIE))
                {
                    refreshPurchased();
                }
                else
                {
                    State = ASYNC_STATE.REFRESHED;
                }
            }
            catch (SocketException)
            {
                State = ASYNC_STATE.NOTREFRESHED;
                new MessageBox("Error connecting. Please check your connection.").Show();
            }
        }