예제 #1
0
파일: Updater.cs 프로젝트: razluta/jazz2
        public static void CheckUpdates(CheckUpdatesCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            ThreadPool.UnsafeQueueUserWorkItem(delegate {
                try {
                    WebClient client = new WebClient();
                    client.Encoding  = Encoding.UTF8;
                    string content   = client.DownloadString(new Uri("http://deat.tk/downloads/other/jazz2/updates"));

                    if (content == null || !content.StartsWith("Death™ Updates :: ", StringComparison.InvariantCulture))
                    {
                        callback(false, null);
                        return;
                    }

                    int i = content.IndexOf(' ', 19);
                    if (i == -1)
                    {
                        callback(false, null);
                        return;
                    }

                    string version = content.Substring(18, i - 18);
                    bool isNewer   = IsVersionNewer(App.AssemblyVersion, version);
                    callback(isNewer, version);
                } catch {
                    // Nothing to do...
                    callback(false, null);
                }
            }, null);
        }
예제 #2
0
        public static void CheckUpdates(CheckUpdatesCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            ThreadPool.UnsafeQueueUserWorkItem(delegate {
                string deviceId;
#if __ANDROID__
                try {
                    deviceId = global::Android.Provider.Settings.Secure.GetString(Android.MainActivity.Current.ContentResolver, global::Android.Provider.Settings.Secure.AndroidId);
                    if (deviceId == null)
                    {
                        deviceId = "";
                    }
                } catch {
                    deviceId = "";
                }

                deviceId += "|Android " + global::Android.OS.Build.VERSION.Release;
#else
                try {
                    deviceId = System.Environment.MachineName;
                    if (deviceId == null)
                    {
                        deviceId = "";
                    }
                } catch {
                    deviceId = "";
                }

                deviceId += "|" + System.Environment.OSVersion.ToString();
#endif

                deviceId = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(deviceId))
                           .Replace('+', '-').Replace('/', '_').TrimEnd('=');

                try {
                    string currentVersion = App.AssemblyVersion;

                    WebClient client             = new WebClient();
                    client.Encoding              = Encoding.UTF8;
                    client.Headers["User-Agent"] = App.AssemblyTitle;

                    string content = client.DownloadString(Url + "?v=" + currentVersion + "&d=" + deviceId);
                    if (content == null)
                    {
                        callback(false, null);
                        return;
                    }

                    bool isNewer = IsVersionNewer(currentVersion, content);
                    callback(isNewer, content);
                } catch {
                    // Nothing to do...
                    callback(false, null);
                }
            }, null);
        }
예제 #3
0
        public static void CheckUpdates(CheckUpdatesCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            ThreadPool.UnsafeQueueUserWorkItem(delegate {
                try {
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                    WebClient client             = new WebClient();
                    client.Encoding              = Encoding.UTF8;
                    client.Headers["User-Agent"] = App.AssemblyTitle;

                    string content = client.DownloadString(Url);
                    if (content == null)
                    {
                        callback(false, null);
                        return;
                    }

                    Release release = new JsonParser().Parse <Release>(content);
                    if (release == null || release.tag_name == null)
                    {
                        callback(false, null);
                        return;
                    }

                    bool isNewer = IsVersionNewer(App.AssemblyVersion, release.tag_name);
                    callback(isNewer, release);
                } catch {
                    // Nothing to do...
                    callback(false, null);
                }
            }, null);
        }
예제 #4
0
파일: Updater.cs 프로젝트: iidioter/jazz2
        public static void CheckUpdates(CheckUpdatesCallback callback)
        {
#if !PLATFORM_WASM
            if (callback == null)
            {
                return;
            }

            ThreadPool.UnsafeQueueUserWorkItem(delegate {
                string deviceId;
#if PLATFORM_ANDROID
                try {
                    deviceId = global::Android.Provider.Settings.Secure.GetString(Android.MainActivity.Current.ContentResolver, global::Android.Provider.Settings.Secure.AndroidId);
                    if (deviceId == null)
                    {
                        deviceId = "";
                    }
                } catch {
                    deviceId = "";
                }

                deviceId += "|Android " + global::Android.OS.Build.VERSION.Release + "|";

                try {
                    string device = (string.IsNullOrEmpty(global::Android.OS.Build.Model) ? global::Android.OS.Build.Manufacturer : (global::Android.OS.Build.Model.StartsWith(global::Android.OS.Build.Manufacturer) ? global::Android.OS.Build.Model : global::Android.OS.Build.Manufacturer + " " + global::Android.OS.Build.Model));

                    if (device == null)
                    {
                        device = "";
                    }
                    else if (device.Length > 1)
                    {
                        device = char.ToUpper(device[0]) + device.Substring(1);
                    }

                    deviceId += device;
                } catch {
                }
#else
                try {
                    deviceId = System.Environment.MachineName;
                    if (deviceId == null)
                    {
                        deviceId = "";
                    }
                } catch {
                    deviceId = "";
                }

                deviceId += "|" + System.Environment.OSVersion.ToString() + "|";
#endif

                deviceId = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(deviceId))
                           .Replace('+', '-').Replace('/', '_').TrimEnd('=');

                try {
                    string currentVersion = App.AssemblyVersion;

                    WebClient client             = new WebClient();
                    client.Encoding              = Encoding.UTF8;
                    client.Headers["User-Agent"] = App.AssemblyTitle;

                    string content = client.DownloadString(Url + "?v=" + currentVersion + "&d=" + deviceId);
                    if (content == null)
                    {
                        callback(false, null);
                        return;
                    }

                    bool isNewer = IsVersionNewer(currentVersion, content);
                    callback(isNewer, content);
                } catch {
                    // Nothing to do...
                    callback(false, null);
                }
            }, null);
#endif
        }