Пример #1
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);
		}
Пример #2
0
		public static void RunCheckDialog (UpdateInfo[] updateInfos, bool automatic)
		{
			if (!CanUpdate || (automatic && !CheckAutomatically))
				return;
			
			if (!automatic) {
				ShowUpdateDialog ();
				QueryUpdateServer (updateInfos, UpdateLevel, delegate (UpdateResult result) {
					ShowUpdateResult (result);
				});
			} else {
				QueryUpdateServer (updateInfos, UpdateLevel, delegate (UpdateResult result) {
					if (result.HasError || !result.HasUpdates)
						return;
					ShowUpdateDialog ();
					ShowUpdateResult (result);
				});
			}
		}