Esempio n. 1
0
 public UpdateResult(List <Update> updates, UpdateLevel level, string errorMessage, Exception errorDetail)
 {
     this.Updates      = updates;
     this.Level        = level;
     this.ErrorMessage = errorMessage;
     this.ErrorDetail  = errorDetail;
 }
Esempio n. 2
0
		public UpdateResult (List<Update> updates, UpdateLevel level, string errorMessage, Exception errorDetail)
		{
			this.Updates = updates;
			this.Level = level;
			this.ErrorMessage = errorMessage;
			this.ErrorDetail = errorDetail;
		}
Esempio n. 3
0
 public static void BroadcastUpdate(UpdateLevel level, float frameTime)
 {
     foreach (var entrypoint in _mods.SelectMany(m => m.EntryPoints))
     {
         entrypoint.Update(level, frameTime);
     }
 }
        public void RequestLogin(REQ_Login loginInfo)
        {
            _currentUserID = loginInfo.UserID;

            Log.Info("客户请求登录,来自IP:{0},用户ID:{1}", tcpSession.RemoteIPEndPoint, _currentUserID);

            UpdateLevel updateLevel = VersionManager.CheckVersion(loginInfo.ClientVersion);

            if (updateLevel == UpdateLevel.Necessary)
            {
                SendAutoUpdaterConfig(SocketConfig.UpdateXmlUrl_complete);
                return;
            }
            else if (updateLevel == UpdateLevel.Optional)
            {
                SendAutoUpdaterConfig(SocketConfig.UpdateXmlUrl_patch);
                return;// 临时的
            }

            if (loginInfo.LoginType == LoginType.First)
            {
                FirstLogin(loginInfo);
            }
            else if (loginInfo.LoginType == LoginType.Reconnect)
            {
                Reconnect(loginInfo);
            }
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public static string GetUpdateLevel(UpdateLevel level)
        {
            string processed = Vars.CurrentLang.Message_SysStatus_UpdateLevel_Template;

            return(level switch
            {
                UpdateLevel.Optional => processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Optional),
                UpdateLevel.Recommended => processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Recommended),
                UpdateLevel.Important => processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Important),
                UpdateLevel.Urgent => processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Urgent),
                _ => processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Unknown),
            });
Esempio n. 7
0
		public void RegisterMainRepository (UpdateLevel level, bool enable)
		{
			string url = GetMainRepositoryUrl (level);
			if (!Repositories.ContainsRepository (url)) {
				var rep = Repositories.RegisterRepository (null, url, false);
				rep.Name = "MonoDevelop Add-in Repository";
				if (level != UpdateLevel.Stable)
					rep.Name += " (" + level + " channel)";
				if (!enable)
					Repositories.SetRepositoryEnabled (url, false);
			}
		}
Esempio n. 8
0
		public string GetMainRepositoryUrl (UpdateLevel level)
		{
			string platform;
			if (Platform.IsWindows)
				platform = "Win32";
			else if (Platform.IsMac)
				platform = "Mac";
			else
				platform = "Linux";
			
			return "http://addins.monodevelop.com/" + level + "/" + platform + "/" + AddinManager.CurrentAddin.Version + "/main.mrep";
		}
Esempio n. 9
0
        public void RegisterMainRepository(UpdateLevel level, bool enable)
        {
            string url = GetMainRepositoryUrl(level);

            if (!Repositories.ContainsRepository(url))
            {
                var rep = Repositories.RegisterRepository(null, url, false);
                rep.Name = BrandingService.BrandApplicationName("MonoDevelop Extension Repository");
                if (level != UpdateLevel.Stable)
                {
                    rep.Name += " (" + level + " channel)";
                }
                if (!enable)
                {
                    Repositories.SetRepositoryEnabled(url, false);
                }
            }
        }
Esempio n. 10
0
        public static UpdateChannel FromUpdateLevel(UpdateLevel level)
        {
            switch (level)
            {
            case UpdateLevel.Stable:
                return(UpdateChannel.Stable);

            case UpdateLevel.Beta:
                return(UpdateChannel.Beta);

            case UpdateLevel.Alpha:
            case UpdateLevel.Test:
                return(UpdateChannel.Alpha);

            default:
                return(UpdateChannel.Alpha);
            }
        }
        public void RegisterMainRepository(UpdateLevel level, bool enable)
        {
            string url = GetMainRepositoryUrl(level);

            if (!Repositories.ContainsRepository(url))
            {
                var rep = Repositories.RegisterRepository(null, url, false);
                rep.Name = "MonoDevelop Add-in Repository";
                if (level != UpdateLevel.Stable)
                {
                    rep.Name += " (" + level + " channel)";
                }
                if (!enable)
                {
                    Repositories.SetRepositoryEnabled(url, false);
                }
            }
        }
Esempio n. 12
0
        public static void QueryAddinUpdates(UpdateLevel level, Action <UpdateResult> callback)
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                List <Update> updates = new List <Update> ();
                string error          = null;
                Exception errorDetail = null;

                try {
                    CheckAddinUpdates(updates, level);
                } catch (Exception ex) {
                    LoggingService.LogError("Could not retrieve update information", ex);
                    error       = GettextCatalog.GetString("Error retrieving update information");
                    errorDetail = ex;
                }

                callback(new UpdateResult(updates, level, error, errorDetail));
            });
        }
        public string GetMainRepositoryUrl(UpdateLevel level)
        {
            string platform;

            if (Platform.IsWindows)
            {
                platform = "Win32";
            }
            else if (Platform.IsMac)
            {
                platform = "Mac";
            }
            else
            {
                platform = "Linux";
            }

            return("http://addins.monodevelop.com/" + level + "/" + platform + "/" + AddinManager.CurrentAddin.Version + "/main.mrep");
        }
Esempio n. 14
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("http://go-mono.com/macupdate/update?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());
            }

            if (Directory.Exists("/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk"))
            {
                query.Append("&env=iphsdk4.0");
            }

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

            //FIXME: use IfModifiedSince
            //request.IfModifiedSince = somevalue;

            request.BeginGetResponse(delegate(IAsyncResult ar) {
                ReceivedResponse(request, ar, level, callback);
            }, null);
        }
Esempio n. 15
0
        static void ReceivedResponse(HttpWebRequest request, IAsyncResult ar, UpdateLevel level, Action <UpdateResult> callback)
        {
            List <Update> updates     = null;
            string        error       = null;
            Exception     errorDetail = null;

            try {
                using (var response = (HttpWebResponse)request.EndGetResponse(ar)) {
                    var encoding = !string.IsNullOrEmpty(response.CharacterSet) ? Encoding.GetEncoding(response.CharacterSet) : Encoding.UTF8;
                    using (var reader = new StreamReader(response.GetResponseStream(), encoding)) {
                        var doc = System.Xml.Linq.XDocument.Load(reader);
                        updates = (from x in doc.Root.Elements("Application")
                                   let first = x.Elements("Update").First()
                                               select new Update()
                        {
                            Name = x.Attribute("name").Value,
                            Url = first.Attribute("url").Value,
                            Version = first.Attribute("version").Value,
                            Level = first.Attribute("level") != null
                                                                        ? (UpdateLevel)Enum.Parse(typeof(UpdateLevel), (string)first.Attribute("level"))
                                                                        : UpdateLevel.Stable,
                            Date = DateTime.Parse(first.Attribute("date").Value),
                            Releases = x.Elements("Update").Select(y => new Release()
                            {
                                Version = y.Attribute("version").Value,
                                Date = DateTime.Parse(y.Attribute("date").Value),
                                Notes = y.Value
                            }).ToList()
                        }).ToList();
                    }
                }

                CheckAddinUpdates(updates, level);
            } catch (Exception ex) {
                LoggingService.LogError("Could not retrieve update information", ex);
                error       = GettextCatalog.GetString("Error retrieving update information");
                errorDetail = ex;
            }

            callback(new UpdateResult(updates, level, error, errorDetail));
        }
Esempio n. 16
0
        public static string GetUpdateLevel(UpdateLevel Level)
        {
            string Processed = Vars.CurrentLang.Message_SysStatus_UpdateLevel_Template;

            switch (Level)
            {
            case UpdateLevel.Optional:
                return(Processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Optional));

            case UpdateLevel.Recommended:
                return(Processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Recommended));

            case UpdateLevel.Important:
                return(Processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Important));

            case UpdateLevel.Urgent:
                return(Processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Urgent));

            default:
                return(Processed.Replace("$1", Vars.CurrentLang.Message_SysStatus_UpdateLevel_Unknown));
            }
        }
Esempio n. 17
0
        static IEnumerable <Update> GetAddinUpdates(UpdateLevel level)
        {
            List <Update> res = new List <Update> ();
            string        url = Runtime.AddinSetupService.GetMainRepositoryUrl(level);
            List <AddinRepositoryEntry> list = new List <AddinRepositoryEntry> ();

            list.AddRange(Runtime.AddinSetupService.Repositories.GetAvailableUpdates(url));
            FilterOldVersions(list);
            foreach (var ventry in list)
            {
                var    entry  = ventry;
                string notify = entry.Addin.Properties.GetPropertyValue("NotifyUpdate").ToLower();
                if (notify != "yes" && notify != "true")
                {
                    continue;
                }
                string   sdate = entry.Addin.Properties.GetPropertyValue("ReleaseDate");
                DateTime date;
                if (!string.IsNullOrEmpty(sdate))
                {
                    date = DateTime.Parse(sdate, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
                }
                else
                {
                    date = DateTime.Now;
                }
                res.Add(new Update()
                {
                    Name          = entry.Addin.Name,
                    InstallAction = (m) => InstallAddin(m, entry),
                    Version       = entry.Addin.Version,
                    Level         = level,
                    Date          = date,
                    Releases      = ParseReleases(entry.Addin.Id, entry).ToList()
                });
            }
            return(res);
        }
Esempio n. 18
0
        static void CheckAddinUpdates(List <Update> updates, UpdateLevel level)
        {
            for (UpdateLevel n = UpdateLevel.Stable; n <= level; n++)
            {
                Runtime.AddinSetupService.RegisterMainRepository((UpdateLevel)n, true);
            }

            AddinUpdateHandler.QueryAddinUpdates();

            updates.AddRange(GetAddinUpdates(UpdateLevel.Stable));
            if (level >= UpdateLevel.Beta)
            {
                updates.AddRange(GetAddinUpdates(UpdateLevel.Beta));
            }
            if (level >= UpdateLevel.Alpha)
            {
                updates.AddRange(GetAddinUpdates(UpdateLevel.Alpha));
            }
            if (level == UpdateLevel.Test)
            {
                updates.AddRange(GetAddinUpdates(UpdateLevel.Test));
            }
        }
Esempio n. 19
0
		static void CheckAddinUpdates (List<Update> updates, UpdateLevel level)
		{
			for (UpdateLevel n=UpdateLevel.Stable; n<=level; n++)
				Runtime.AddinSetupService.RegisterMainRepository ((UpdateLevel)n, true);
			
			AddinUpdateHandler.QueryAddinUpdates ();
			
			updates.AddRange (GetAddinUpdates (UpdateLevel.Stable));
			if (level >= UpdateLevel.Beta)
				updates.AddRange (GetAddinUpdates (UpdateLevel.Beta));
			if (level >= UpdateLevel.Alpha)
				updates.AddRange (GetAddinUpdates (UpdateLevel.Alpha));
			if (level == UpdateLevel.Test)
				updates.AddRange (GetAddinUpdates (UpdateLevel.Test));
		}
Esempio n. 20
0
        /// <summary>
        /// Method for setting asset parameter to default-test values
        /// </summary>
        public void setTestEnvironment23(string xi, string minonecompetence, string maxonelevel)
        {
            //create DomainModel
            DomainModel dm = new DomainModel();
            //Competences
            Elements       elements = new Elements();
            CompetenceList cl       = new CompetenceList();
            CompetenceDesc cd1      = new CompetenceDesc("C1");
            CompetenceDesc cd2      = new CompetenceDesc("C2");
            CompetenceDesc cd3      = new CompetenceDesc("C3");
            CompetenceDesc cd4      = new CompetenceDesc("C4");

            CompetenceDesc[]      cdArray = { cd1, cd2, cd3, cd4 };
            List <CompetenceDesc> cdList  = new List <CompetenceDesc>(cdArray);

            cl.competenceList    = cdList;
            elements.competences = cl;
            dm.elements          = elements;
            //Competences prerequisites
            Relations relations             = new Relations();
            CompetenceprerequisitesList cpl = new CompetenceprerequisitesList();
            CompetenceP cp1 = new CompetenceP("C2", new String[] { "C1" });
            CompetenceP cp2 = new CompetenceP("C3", new String[] { "C2" });
            CompetenceP cp3 = new CompetenceP("C4", new String[] { "C3" });

            CompetenceP[]      cpArray = { cp1, cp2, cp3 };
            List <CompetenceP> cpList  = new List <CompetenceP>(cpArray);

            cpl.competences = cpList;
            relations.competenceprerequisites = cpl;
            dm.relations = relations;
            //Update Levels
            UpdateLevel ul1 = new UpdateLevel();

            ul1.direction        = "up";
            ul1.power            = "low";
            ul1.xi               = xi;
            ul1.minonecompetence = minonecompetence;
            ul1.maxonelevel      = maxonelevel;
            UpdateLevel ul2 = new UpdateLevel();

            ul2.direction        = "up";
            ul2.power            = "medium";
            ul2.xi               = xi;
            ul2.minonecompetence = minonecompetence;
            ul2.maxonelevel      = maxonelevel;
            UpdateLevel ul3 = new UpdateLevel();

            ul3.direction        = "up";
            ul3.power            = "high";
            ul3.xi               = xi;
            ul3.minonecompetence = minonecompetence;
            ul3.maxonelevel      = maxonelevel;
            UpdateLevel ul4 = new UpdateLevel();

            ul4.direction        = "down";
            ul4.power            = "low";
            ul4.xi               = xi;
            ul4.minonecompetence = minonecompetence;
            ul4.maxonelevel      = maxonelevel;
            UpdateLevel ul5 = new UpdateLevel();

            ul5.direction        = "down";
            ul5.power            = "medium";
            ul5.xi               = xi;
            ul5.minonecompetence = minonecompetence;
            ul5.maxonelevel      = maxonelevel;
            UpdateLevel ul6 = new UpdateLevel();

            ul6.direction        = "down";
            ul6.power            = "high";
            ul6.xi               = xi;
            ul6.minonecompetence = minonecompetence;
            ul6.maxonelevel      = maxonelevel;
            UpdateLevel[] ulArray = { ul1, ul2, ul3, ul4, ul5, ul6 };
            dm.updateLevels = new UpdateLevels();
            dm.updateLevels.updateLevelList = new List <UpdateLevel>(ulArray);


            //set needed structures for asset functionality
            setDomainModel(dm);
        }
        public bool IsMainRepositoryRegistered(UpdateLevel level)
        {
            string url = GetMainRepositoryUrl(level);

            return(Repositories.ContainsRepository(url));
        }
Esempio n. 22
0
        /// <summary>
        /// Method creating an example domain model
        /// </summary>
        /// <returns></returns>
        public DomainModel createExampleDomainModel()
        {
            DomainModel dm = new DomainModel();


            //Competences
            Elements       elements = new Elements();
            CompetenceList cl       = new CompetenceList();
            CompetenceDesc cd1      = new CompetenceDesc("C1");
            CompetenceDesc cd2      = new CompetenceDesc("C2");
            CompetenceDesc cd3      = new CompetenceDesc("C3");
            CompetenceDesc cd4      = new CompetenceDesc("C4");
            CompetenceDesc cd5      = new CompetenceDesc("C5");
            CompetenceDesc cd6      = new CompetenceDesc("C6");
            CompetenceDesc cd7      = new CompetenceDesc("C7");
            CompetenceDesc cd8      = new CompetenceDesc("C8");
            CompetenceDesc cd9      = new CompetenceDesc("C9");
            CompetenceDesc cd10     = new CompetenceDesc("C10");

            CompetenceDesc[]      cdArray = { cd1, cd2, cd3, cd4, cd5, cd6, cd7, cd8, cd9, cd10 };
            List <CompetenceDesc> cdList  = new List <CompetenceDesc>(cdArray);

            cl.competenceList    = cdList;
            elements.competences = cl;

            //Game situations
            SituationsList sl  = new SituationsList();
            Situation      s1  = new Situation("gs1");
            Situation      s2  = new Situation("gs2");
            Situation      s3  = new Situation("gs3");
            Situation      s4  = new Situation("gs4");
            Situation      s5  = new Situation("gs5");
            Situation      s6  = new Situation("gs6");
            Situation      s7  = new Situation("gs7");
            Situation      s8  = new Situation("gs8");
            Situation      s9  = new Situation("gs9");
            Situation      s10 = new Situation("gs10");

            Situation[]      sArray = { s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 };
            List <Situation> loList = new List <Situation>(sArray);

            sl.situationList    = loList;
            elements.situations = sl;

            //Competences prerequisites
            Relations relations             = new Relations();
            CompetenceprerequisitesList cpl = new CompetenceprerequisitesList();
            CompetenceP cp1 = new CompetenceP("C5", new String[] { "C1", "C2" });
            CompetenceP cp3 = new CompetenceP("C6", new String[] { "C4" });
            CompetenceP cp4 = new CompetenceP("C7", new String[] { "C4" });
            CompetenceP cp5 = new CompetenceP("C8", new String[] { "C3", "C6" });
            CompetenceP cp7 = new CompetenceP("C9", new String[] { "C5", "C8" });
            CompetenceP cp8 = new CompetenceP("C10", new String[] { "C9", "C7" });

            CompetenceP[]      cpArray = { cp1, cp3, cp4, cp5, cp7, cp8 };
            List <CompetenceP> cpList  = new List <CompetenceP>(cpArray);

            cpl.competences = cpList;
            relations.competenceprerequisites = cpl;

            //assignmend of competences to game situations (=learning objects)
            SituationRelationList lorl  = new SituationRelationList();
            SituationRelation     lor1  = new SituationRelation("gs1", new String[] { "C1" });
            SituationRelation     lor2  = new SituationRelation("gs2", new String[] { "C2" });
            SituationRelation     lor3  = new SituationRelation("gs3", new String[] { "C3" });
            SituationRelation     lor4  = new SituationRelation("gs4", new String[] { "C4" });
            SituationRelation     lor5  = new SituationRelation("gs5", new String[] { "C5", "C1", "C2" });
            SituationRelation     lor8  = new SituationRelation("gs6", new String[] { "C6", "C4" });
            SituationRelation     lor10 = new SituationRelation("gs7", new String[] { "C4", "C7" });
            SituationRelation     lor12 = new SituationRelation("gs8", new String[] { "C8", "C6", "C3" });
            SituationRelation     lor15 = new SituationRelation("gs9", new String[] { "C9", "C5", "C8" });
            SituationRelation     lor18 = new SituationRelation("gs10", new String[] { "C10", "C9", "C7" });

            SituationRelation[]      lorArray = { lor1, lor2, lor3, lor4, lor5, lor8, lor10, lor12, lor15, lor18 };
            List <SituationRelation> lorList  = new List <SituationRelation>(lorArray);

            lorl.situations      = lorList;
            relations.situations = lorl;

            dm.elements  = elements;
            dm.relations = relations;

            //Update Levels
            UpdateLevel ul1 = new UpdateLevel();

            ul1.direction        = "up";
            ul1.power            = "low";
            ul1.xi               = "1.2";
            ul1.minonecompetence = "false";
            ul1.maxonelevel      = "true";
            UpdateLevel ul2 = new UpdateLevel();

            ul2.direction        = "up";
            ul2.power            = "medium";
            ul2.xi               = "2";
            ul2.minonecompetence = "false";
            ul2.maxonelevel      = "true";
            UpdateLevel ul3 = new UpdateLevel();

            ul3.direction        = "up";
            ul3.power            = "high";
            ul3.xi               = "4";
            ul3.minonecompetence = "true";
            ul3.maxonelevel      = "false";
            UpdateLevel ul4 = new UpdateLevel();

            ul4.direction        = "down";
            ul4.power            = "low";
            ul4.xi               = "1.2";
            ul4.minonecompetence = "false";
            ul4.maxonelevel      = "true";
            UpdateLevel ul5 = new UpdateLevel();

            ul5.direction        = "down";
            ul5.power            = "medium";
            ul5.xi               = "2";
            ul5.minonecompetence = "false";
            ul5.maxonelevel      = "true";
            UpdateLevel ul6 = new UpdateLevel();

            ul6.direction        = "down";
            ul6.power            = "high";
            ul6.xi               = "4";
            ul6.minonecompetence = "true";
            ul6.maxonelevel      = "false";
            UpdateLevel[] ulArray = { ul1, ul2, ul3, ul4, ul5, ul6 };
            dm.updateLevels = new UpdateLevels();
            dm.updateLevels.updateLevelList = new List <UpdateLevel>(ulArray);

            return(dm);
        }
Esempio n. 23
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 ("http://go-mono.com/macupdate/update?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 ());
			}
			
			if (Directory.Exists ("/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk")) {
				query.Append ("&env=iphsdk4.0");
			}
			
			var request = (HttpWebRequest) WebRequest.Create (query.ToString ());
			
			//FIXME: use IfModifiedSince
			//request.IfModifiedSince = somevalue;
			
			request.BeginGetResponse (delegate (IAsyncResult ar) {
				ReceivedResponse (request, ar, level, callback);
			}, null);
		}
        /// <summary>
        /// The ToString implementation.
        /// </summary>
        /// <param name="format">The format specifier to use, e.g. <b>Console.WriteLine(workspace.ToString("L"));</b></param>
        /// <param name="provider">Allow clients to format output for their own types using [ICustomFormatter](https://msdn.microsoft.com/en-us/library/system.icustomformatter.aspx).</param>
        /// <returns>The formatted string.</returns>
        /// <exception cref="FormatException">thrown if an invalid format string is specified.</exception>
        /// \par Format specifiers:
        /// \arg \c G Name of the workspace, e.g. MARS_DEV3_barnyrd. Default when not using a format specifier.
        /// \arg \c LV Long version (verbose).
        /// \arg \c I Workspace ID number.
        /// \arg \c L Workspace [location](@ref AcUtils#AcWorkspace#Location).
        /// \arg \c S Location on the host ([storage](@ref AcUtils#AcWorkspace#Storage)) where the elements physically reside.
        /// \arg \c M Machine name ([host](@ref AcUtils#AcWorkspace#Host)) where the elements physically reside.
        /// \arg \c H \e True if the workspace is hidden, \e False otherwise.
        /// \arg \c D Depot name.
        /// \arg \c TL [Target level](@ref AcUtils#AcWorkspace#TargetLevel): how up-to-date the workspace should be.
        /// \arg \c UL [Update level](@ref AcUtils#AcWorkspace#UpdateLevel): how up-to-date the workspace actually is.
        /// \arg \c U Time of the oldest non-member file in the workspace with (\e modified) status, otherwise the time the \c update command was issued.
        /// \arg \c T [Workspace type](@ref AcUtils#WsType): standard, exclusive-file locking, anchor-required, or reference tree.
        /// \arg \c E [End-of-line character](@ref AcUtils#WsEOL) in use by the workspace: platform-appropriate, Unix/Linux style, or Windows style.
        /// \arg \c PI Workspace owner's principal ID number.
        /// \arg \c PN Workspace owner's principal name.
        public string ToString(string format, IFormatProvider provider)
        {
            if (provider != null)
            {
                ICustomFormatter fmt = provider.GetFormat(this.GetType()) as ICustomFormatter;
                if (fmt != null)
                {
                    return(fmt.Format(format, this, provider));
                }
            }

            if (String.IsNullOrEmpty(format))
            {
                format = "G";
            }

            switch (format.ToUpperInvariant())
            {
            case "G":         // name of the workspace, e.g. MARS_DEV3_barnyrd
                return(Name); // general format should be short since it can be called by anything

            case "LV":        // long version (verbose)
                return($"{Name} ({ID}) {{{Type}}}{Environment.NewLine}" +
                       $@"Location: ""{Location}"", Storage: ""{Storage}""{Environment.NewLine}" +
                       $"Host: {Host}, ULevel-Target [{UpdateLevel}:{TargetLevel}]{((TargetLevel != UpdateLevel) ? " (incomplete)" : String.Empty)}{Environment.NewLine}" +
                       $"Depot: {Depot}, EOL: {EOL}, Hidden: {Hidden}{Environment.NewLine}");

            case "I":     // workspace ID number
                return(ID.ToString());

            case "L":     // workspace location
                return(Location);

            case "S":     // location on the host (storage) where the elements physically reside
                return(Storage);

            case "M":     // machine name (host) where the elements physically reside
                return(Host);

            case "H":     // True if workspace is hidden, False otherwise
                return(Hidden.ToString());

            case "D":     // depot name
                return(Depot.ToString());

            case "TL":     // how up-to-date the workspace should be
                return(TargetLevel.ToString());

            case "UL":     // how up-to-date the workspace actually is
                return(UpdateLevel.ToString());

            case "U":     // time of the oldest non-member file in the workspace with modified status, otherwise time the update command was issued
                return(FileModTime.ToString());

            case "T":     // type of workspace: standard, exclusive-file locking, anchor-required, or reference tree
                return(Type.ToString());

            case "E":     // end-of-line character in use by the workspace: platform-appropriate, Unix/Linux style, or Windows style
                return(EOL.ToString());

            case "PI":     // ID number of the AccuRev principal who owns the workspace
                return(Principal.ID.ToString());

            case "PN":     // principal name of the workspace owner
                return(Principal.Name);

            default:
                throw new FormatException($"The {format} format string is not supported.");
            }
        }
Esempio n. 25
0
		public static void QueryUpdateServer (UpdateInfo[] updateInfos, UpdateLevel level, Action<UpdateResult> callback)
		{
			if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("MONODEVELOP_UPDATER_TEST")))
				level = UpdateLevel.Test;
			
			if (updateInfos == null || updateInfos.Length == 0) {
				QueryAddinUpdates (level, callback);
				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 (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);
		}
Esempio n. 26
0
		static void ReceivedResponse (HttpWebRequest request, IAsyncResult ar, UpdateLevel level, Action<UpdateResult> callback)
		{
			List<Update> updates = null;
			string error = null;
			Exception errorDetail = null;
			
			try {
				using (var response = (HttpWebResponse) request.EndGetResponse (ar)) {
					var encoding = Encoding.GetEncoding (response.CharacterSet);
					using (var reader = new StreamReader (response.GetResponseStream(), encoding)) {
						var doc = System.Xml.Linq.XDocument.Load (reader);
						updates = (from x in doc.Root.Elements ("Application")
							let first = x.Elements ("Update").First ()
							select new Update () {
								Name = x.Attribute ("name").Value,
								Url = first.Attribute ("url").Value,
								Version = first.Attribute ("version").Value,
								Level = first.Attribute ("level") != null
									? (UpdateLevel)Enum.Parse (typeof(UpdateLevel), (string)first.Attribute ("level"))
									: UpdateLevel.Stable,
								Date = DateTime.Parse (first.Attribute ("date").Value),
								Releases = x.Elements ("Update").Select (y => new Release () {
									Version = y.Attribute ("version").Value,
									Date = DateTime.Parse (y.Attribute ("date").Value),
									Notes = y.Value
								}).ToList ()
							}).ToList ();
					}
				}
			} catch (Exception ex) {
				error = GettextCatalog.GetString ("Error retrieving update information");
				errorDetail = ex;
			}
			callback (new UpdateResult (updates, level, error, errorDetail));
		}
Esempio n. 27
0
		static IEnumerable<Update> GetAddinUpdates (UpdateLevel level)
		{
			List<Update> res = new List<Update> ();
			string url = Runtime.AddinSetupService.GetMainRepositoryUrl (level);
			List<AddinRepositoryEntry> list = new List<AddinRepositoryEntry> ();
			list.AddRange (Runtime.AddinSetupService.Repositories.GetAvailableUpdates (url));
			FilterOldVersions (list);
			foreach (var ventry in list) {
				var entry = ventry;
				string notify = entry.Addin.Properties.GetPropertyValue ("NotifyUpdate").ToLower ();
				if (notify != "yes" && notify != "true")
					continue;
				string sdate = entry.Addin.Properties.GetPropertyValue ("ReleaseDate");
				DateTime date;
				if (!string.IsNullOrEmpty (sdate))
					date = DateTime.Parse (sdate, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
				else
					date = DateTime.Now;
				res.Add (new Update () {
					Name = entry.Addin.Name,
					InstallAction = (m) => InstallAddin (m, entry),
					Version = entry.Addin.Version,
					Level = level,
					Date = date,
					Releases = ParseReleases (entry.Addin.Id, entry).ToList ()
				});
			}
			return res;
		}
Esempio n. 28
0
		public static void QueryAddinUpdates (UpdateLevel level, Action<UpdateResult> callback)
		{
			System.Threading.ThreadPool.QueueUserWorkItem (delegate {
				List<Update> updates = new List<Update> ();
				string error = null;
				Exception errorDetail = null;
				
				try {
					CheckAddinUpdates (updates, level);
					
				} catch (Exception ex) {
					LoggingService.LogError ("Could not retrieve update information", ex);
					error = GettextCatalog.GetString ("Error retrieving update information");
					errorDetail = ex;
				}
				
				callback (new UpdateResult (updates, level, error, errorDetail));
			});
		}
Esempio n. 29
0
        /// <summary>
        /// Tell all the prims which have had updates scheduled
        /// </summary>
        public void SendScheduledUpdates(UpdateLevel level, PrimUpdateFlags updateFlags)
        {
            switch (level)
            {
                case UpdateLevel.Terse:
                    AddTerseUpdateToAllAvatars();
                    break;

                /*case UpdateLevel.Compressed:
                    AddCompressedUpdateToAllAvatars();
                    break;*/

                case UpdateLevel.Full:
                    AddFullUpdateToAllAvatars(updateFlags);
                    break;
            }
        }
Esempio n. 30
0
		public bool IsMainRepositoryRegistered (UpdateLevel level)
		{
			string url = GetMainRepositoryUrl (level);
			return Repositories.ContainsRepository (url);
		}