Example #1
0
 public static void UpdateClickStats(string vmName)
 {
     if (!CloudAnnouncement.sUploadStats)
     {
         return;
     }
     new Thread((ThreadStart)(() =>
     {
         try
         {
             if (BstHttpClient.Get(string.Format("{0}/updateAnnouncementStats", (object)RegistryManager.Instance.Host), new Dictionary <string, string>()
             {
                 {
                     "x_last_msg_id",
                     Convert.ToString(CloudAnnouncement.sMsgId)
                 }
             }, false, vmName, 0, 1, 0, false, "bgp") != null)
             {
                 return;
             }
             Logger.Info("Could not send click stats.");
         }
         catch (Exception ex)
         {
             Logger.Error("Failed to send click stats: " + ex.ToString());
         }
     }))
     {
         IsBackground = true
     }.Start();
 }
 private static void GetGrmFromCloud(IEnumerable <string> listOfPackages = null)
 {
     try
     {
         if (listOfPackages != null && listOfPackages.Any <string>())
         {
             List <string> first = new List <string>();
             foreach (string vm in RegistryManager.Instance.VmList)
             {
                 first = first.Union <string>((IEnumerable <string>)JsonParser.GetInstalledAppsList(vm)).ToList <string>();
             }
             if (!listOfPackages.Intersect <string>((IEnumerable <string>)first).Any <string>())
             {
                 return;
             }
         }
         JObject jobject = JObject.Parse(HTTPUtils.SendRequestToCloud("grm/files", (Dictionary <string, string>)null, "Android", 0, (Dictionary <string, string>)null, false, 1, 0, false));
         if ((int)jobject["code"] != 200 || !jobject["data"].Value <bool>((object)"success"))
         {
             return;
         }
         string url                  = jobject["data"][(object)"files"].Value <string>((object)"translations_file");
         string fullJson             = BstHttpClient.Get(jobject["data"][(object)"files"].Value <string>((object)"config_file"), (Dictionary <string, string>)null, false, BlueStacks.Common.Strings.CurrentDefaultVmName, 0, 1, 0, false, "bgp");
         string currentDefaultVmName = BlueStacks.Common.Strings.CurrentDefaultVmName;
         string translationJson      = BstHttpClient.Get(url, (Dictionary <string, string>)null, false, currentDefaultVmName, 0, 1, 0, false, "bgp");
         AppRequirementsParser.Instance.UpdateOverwriteRequirements(fullJson, translationJson);
     }
     catch (Exception ex)
     {
         Logger.Info("Error Getting Grm json " + ex.ToString());
     }
 }
Example #3
0
 private void GetSearchTextFromCloud()
 {
     new Thread((ThreadStart)(() =>
     {
         try
         {
             this.defaultSearchBoxText = LocaleStrings.GetLocalizedString("STRING_SEARCH", "");
             string urlWithParams = WebHelper.GetUrlWithParams(WebHelper.GetServerHost() + "/app_center_searchdefaultquery", (string)null, (string)null, (string)null);
             Logger.Debug("url for search api :" + urlWithParams);
             string json = BstHttpClient.Get(urlWithParams, (Dictionary <string, string>)null, false, string.Empty, 0, 1, 0, false, "bgp");
             Logger.Debug("result for app_center_searchdefaultquery : " + json);
             JObject jobject = JObject.Parse(json);
             if ((bool)jobject["success"])
             {
                 string str = jobject["result"].ToString().Trim();
                 if (!string.IsNullOrEmpty(str))
                 {
                     this.defaultSearchBoxText = str;
                 }
                 Logger.Debug("response from search text cloud api :" + str);
             }
         }
         catch (Exception ex)
         {
             Logger.Warning("Failed to fetch text from cloud... Err : " + ex.ToString());
         }
         this.Dispatcher.Invoke((Delegate)(() => this.mSearchTextBox.Text = this.defaultSearchBoxText));
     }))
     {
         IsBackground = true
     }.Start();
 }
Example #4
0
 public static bool ShowAnnouncement(string vmName)
 {
     if (!Features.IsFeatureEnabled(1UL))
     {
         Logger.Debug("Broadcast message feature disabled. Ignoring...");
         return(false);
     }
     Logger.Info("Checking for announcement");
     try
     {
         if (Directory.Exists(CloudAnnouncement.Dir))
         {
             string[] files = Directory.GetFiles(CloudAnnouncement.Dir);
             for (int index = 0; index < files.Length; ++index)
             {
                 try
                 {
                     if (System.IO.File.Exists(files[index]))
                     {
                         System.IO.File.Delete(files[index]);
                     }
                 }
                 catch (Exception ex)
                 {
                     Logger.Error("Failed to delete file. err: " + ex.Message);
                 }
             }
         }
         else
         {
             Directory.CreateDirectory(CloudAnnouncement.Dir);
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Failed to delete/create announcement dir. err: " + ex.Message);
         if (!Directory.Exists(CloudAnnouncement.Dir))
         {
             Directory.CreateDirectory(CloudAnnouncement.Dir);
         }
     }
     return(CloudAnnouncement.ShowAnnouncementResponse(BstHttpClient.Get(string.Format("{0}/getAnnouncement", (object)RegistryManager.Instance.Host), new Dictionary <string, string>()
     {
         {
             "x_locale",
             CultureInfo.CurrentCulture.Name.ToLower()
         }
     }, false, vmName, 0, 1, 0, false, "bgp"), vmName));
 }
        internal JToken GetPostBootData()
        {
            JToken jtoken = (JToken)null;

            try
            {
                string json = BstHttpClient.Get(this.Url, (Dictionary <string, string>)null, false, "Android", 0, 1, 0, false, "bgp");
                Logger.Debug("Postboot data Url: " + this.Url);
                jtoken = JToken.Parse(json);
            }
            catch (Exception ex)
            {
                Logger.Error("Error Getting Post Boot Data err: " + ex.ToString());
            }
            return(jtoken);
        }