Beispiel #1
0
        static UpdateInfo[] LoadUpdateInfos()
        {
            if (string.IsNullOrEmpty(DesktopService.GetUpdaterUrl()))
            {
                return(new UpdateInfo[0]);
            }

            var list = new List <UpdateInfo> ();

            foreach (var node in Mono.Addins.AddinManager.GetExtensionNodes("/MonoDevelop/Ide/Updater"))
            {
                var n = node as UpdateInfoExtensionNode;
                if (n == null)
                {
                    continue;
                }
                string file = n.File;
                if (!File.Exists(file))
                {
                    continue;
                }

                try {
                    list.Add(UpdateInfo.FromFile(file));
                } catch (Exception ex) {
                    LoggingService.LogError("Error reading update info file '" + file + "'", ex);
                }
            }
            return(list.ToArray());
        }
Beispiel #2
0
        public static void QueryUpdateServer(UpdateInfo[] updateInfos, UpdateLevel level, Action <UpdateResult> callback)
        {
            if (updateInfos == null || updateInfos.Length == 0)
            {
                string error = GettextCatalog.GetString("No updatable products detected");
                callback(new UpdateResult(null, level, error, null));
                return;
            }

            var query = new StringBuilder(DesktopService.GetUpdaterUrl());

            query.Append("?v=");
            query.Append(formatVersion);

            foreach (var info in updateInfos)
            {
                query.AppendFormat("&{0}={1}", info.AppId, info.VersionId);
            }

            if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MONODEVELOP_UPDATER_TEST")))
            {
                level = UpdateLevel.Test;
            }

            if (level != UpdateLevel.Stable)
            {
                query.Append("&level=");
                query.Append(level.ToString().ToLower());
            }

            bool hasEnv = false;

            foreach (string flag in DesktopService.GetUpdaterEnvironmentFlags())
            {
                if (!hasEnv)
                {
                    hasEnv = true;
                    query.Append("&env=");
                    query.Append(flag);
                }
                else
                {
                    query.Append(",");
                    query.Append(flag);
                }
            }

            var requestUrl = query.ToString();
            var request    = (HttpWebRequest)WebRequest.Create(requestUrl);

            LoggingService.LogDebug("Checking for updates: {0}", requestUrl);

            //FIXME: use IfModifiedSince, with a cached value
            //request.IfModifiedSince = somevalue;

            request.BeginGetResponse(delegate(IAsyncResult ar) {
                ReceivedResponse(request, ar, level, callback);
            }, null);
        }