Permalink
Browse files

added support for trusted publishers, telemetry tracking and initial …

…faux support
  • Loading branch information...
1 parent f00fd52 commit 7c3b8a8457b66db2b577f6b9588803fed7f19c39 Garrett Serack committed May 29, 2012
View
@@ -137,7 +137,32 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Toolkit\Extensions\XmlExtensions.cs" />
+ <Compile Include="Toolkit\Linq\BooleanExpression.cs" />
+ <Compile Include="Toolkit\Linq\BooleanOperation.cs" />
+ <Compile Include="Toolkit\Linq\ExpressionBase.cs" />
+ <Compile Include="Toolkit\Linq\Filter.cs" />
+ <Compile Include="Toolkit\Linq\FilterExpression.cs" />
+ <Compile Include="Toolkit\Linq\FilterOperation.cs" />
+ <Compile Include="Toolkit\Linq\PropertyExpression.cs" />
+ <Compile Include="Toolkit\Linq\QualifierOperation.cs" />
+ <Compile Include="Toolkit\Linq\Query.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Evaluator.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Extn.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\LinqHelper.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Message\ExpressionMessageSerializer.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Query.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Xml\CustomExpressionXmlConverter.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Xml\ExpressionXmlSerializer.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Xml\KnownTypeExpressionXmlConverter.cs" />
+ <Compile Include="Toolkit\Linq\Serialization\Xml\TypeResolver.cs" />
+ <Compile Include="Toolkit\Linq\UnaryExpression.cs" />
+ <Compile Include="Toolkit\Linq\UnaryOperation.cs" />
<Compile Include="Toolkit\Logging\Logger.cs" />
+ <Compile Include="Toolkit\Pipes\AsyncPipeExtensions.cs" />
+ <Compile Include="Toolkit\Pipes\CustomSerializer.cs" />
+ <Compile Include="Toolkit\Pipes\IncomingCallDispatcher.cs" />
+ <Compile Include="Toolkit\Pipes\SerializationExtensions.cs" />
+ <Compile Include="Toolkit\Pipes\UrlEncodedMessage.cs" />
<Compile Include="Toolkit\Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -351,9 +376,7 @@
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
- <ItemGroup>
- <Folder Include="Toolkit\Pipes\" />
- </ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -61,24 +61,27 @@ public class PackageManager {
if( File.Exists(query) ) {
return PackagesFromLocalFile(query.EnsureFileIsLocal(), Path.GetDirectoryName(query.GetFullPath()),pkgFilter,collectionFilter);
}
+
var uri = new Uri(query);
- Task.Factory.StartNew(() => {
- var lp = uri.AbsolutePath.MakeSafeFileName().GenerateTemporaryFilename();
- var remoteFile = new RemoteFile(uri, localPath, itemUri => {
- Event<DownloadCompleted>.Raise(uri.AbsolutePath, lp); // got the file!
- localPath = lp;
- },
- itemUri => {
- localPath = null; // failed
+ if (uri.IsWebUri()) {
+ Task.Factory.StartNew(() => {
+ var lp = uri.AbsolutePath.MakeSafeFileName().GenerateTemporaryFilename();
+ var remoteFile = new RemoteFile(uri, lp, itemUri => {
+ Event<DownloadCompleted>.Raise(uri.AbsolutePath, lp); // got the file!
+ localPath = lp;
},
- (itemUri, percent) => Event<DownloadProgress>.Raise(uri.AbsolutePath, localPath, percent));
- remoteFile.Get();
-
- if (localPath != null) {
- return PackagesFromLocalFile(localPath, null,pkgFilter ,collectionFilter).Result;
- }
- return Enumerable.Empty<Package>();
- });
+ itemUri => {
+ localPath = null; // failed
+ },
+ (itemUri, percent) => Event<DownloadProgress>.Raise(uri.AbsolutePath, localPath, percent));
+ remoteFile.Get();
+
+ if (localPath != null) {
+ return PackagesFromLocalFile(localPath, null, pkgFilter, collectionFilter).Result;
+ }
+ return Enumerable.Empty<Package>();
+ });
+ }
}
catch {
// ignore what can't be fixed
@@ -639,18 +642,18 @@ public class PackageManager {
}
}
- public Task<IEnumerable<Publisher>> TrustedPublishers {
+ public Task<IEnumerable<string>> TrustedPublishers {
get {
- return null;
+ return (Remote.GetTrustedPublishers() as Task<PackageManagerResponseImpl>).Continue(response => response.Publishers);
}
}
- public Task<Publisher> AddTrustedPublisher(string publisherName, string publicKeyToken) {
- return null;
+ public Task AddTrustedPublisher(string publicKeyToken) {
+ return Remote.AddTrustedPublisher(publicKeyToken);
}
- public Task RemoveTrustedPublisher(string publisherName, string publicKeyToken) {
- return null;
+ public Task RemoveTrustedPublisher(string publicKeyToken) {
+ return Remote.RemoveTrustedPublisher(publicKeyToken);
}
// GS01: TrustedPublishers Coming Soon.
@@ -15,9 +15,7 @@ namespace CoApp.Packaging.Client {
using System.Collections.Generic;
using System.IO;
using System.Linq;
- using System.ServiceModel.Syndication;
using System.Threading.Tasks;
- using System.Xml;
using Common;
using Common.Exceptions;
using Common.Model;
@@ -48,6 +46,13 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
internal bool NoPackages;
internal bool IsSignatureValid;
internal bool OptedIn;
+ internal IEnumerable<string> _publishers = Enumerable.Empty<string>();
+
+ internal IEnumerable<string> Publishers {
+ get {
+ return _publishers;
+ }
+ }
internal IEnumerable<Package> Packages {
get {
@@ -153,23 +158,43 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
}
public void InstallingPackageProgress(CanonicalName canonicalName, int percentComplete, int overallProgress) {
- Event<PackageInstallProgress>.Raise(canonicalName, percentComplete, overallProgress);
+ try {
+ Event<PackageInstallProgress>.Raise(canonicalName, percentComplete, overallProgress);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: PackageInstallProgress event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
}
public void RemovingPackageProgress(CanonicalName canonicalName, int percentComplete) {
- Event<PackageRemoveProgress>.Raise(canonicalName, percentComplete);
+ try {
+ Event<PackageRemoveProgress>.Raise(canonicalName, percentComplete);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: PackageRemoveProgress event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
}
public void InstalledPackage(CanonicalName canonicalName) {
_packages.Value.Add(Package.GetPackage(canonicalName));
Package.GetPackage(canonicalName).IsInstalled = true;
- Event<PackageInstalled>.Raise(canonicalName);
+ try {
+ Event<PackageInstalled>.Raise(canonicalName);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: PackageInstalled event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
}
public void RemovedPackage(CanonicalName canonicalName) {
_packages.Value.Add(Package.GetPackage(canonicalName));
Package.GetPackage(canonicalName).IsInstalled = false;
- Event<PackageRemoved>.Raise(canonicalName);
+ try {
+ Event<PackageRemoved>.Raise(canonicalName);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: PackageRemoved event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
}
public void FailedPackageInstall(CanonicalName canonicalName, string filename, string reason) {
@@ -189,8 +214,12 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
// wait for this guy to respond (which should give us what we need)
CurrentDownloads[requestReference].Continue(() => {
if (File.Exists(targetFilename)) {
- Event<DownloadCompleted>.Raise(requestReference, targetFilename);
-
+ try {
+ Event<DownloadCompleted>.Raise(requestReference, targetFilename);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: DownloadCompleted event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
Remote.RecognizeFile(requestReference, targetFilename, (remoteLocations.FirstOrDefault() ?? new Uri("http://nowhere")).AbsoluteUri);
}
});
@@ -219,7 +248,12 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
var rf = new RemoteFile(uri, targetFilename,
itemUri => {
Remote.RecognizeFile(requestReference, targetFilename, uri.AbsoluteUri);
- Event<DownloadCompleted>.Raise(requestReference, targetFilename);
+ try {
+ Event<DownloadCompleted>.Raise(requestReference, targetFilename);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: DownloadCompleted event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
// remove it from the list of current downloads
CurrentDownloads.Remove(requestReference);
success = true;
@@ -235,8 +269,12 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
progressTask = null;
});
}
-
- Event<DownloadProgress>.Raise(requestReference, targetFilename, percent);
+ try {
+ Event<DownloadProgress>.Raise(requestReference, targetFilename, percent);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: DownloadCompleted event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
});
rf.Get();
@@ -255,7 +293,12 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
// was there a file there from before?
if (File.Exists(targetFilename)) {
- Event<DownloadCompleted>.Raise(requestReference, targetFilename);
+ try {
+ Event<DownloadCompleted>.Raise(requestReference, targetFilename);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: DownloadCompleted event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
Remote.RecognizeFile(requestReference, targetFilename, (remoteLocations.FirstOrDefault() ?? new Uri("http://nowhere")).AbsoluteUri);
}
@@ -372,7 +415,12 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
}
public void UnableToDownloadPackage(CanonicalName packageCanonicalName) {
- Event<UnableToDownloadPackage>.Raise(packageCanonicalName);
+ try {
+ Event<UnableToDownloadPackage>.Raise(packageCanonicalName);
+ }
+ catch (Exception e) {
+ Logger.Error("CRITICAL: UnableToDownloadPackage event delegate thru an exception of type '{0}' -- {1}".format(e.GetType(), e.StackTrace));
+ }
}
public void UnableToInstallPackage(CanonicalName packageCanonicalName) {
@@ -403,5 +451,9 @@ public class PackageManagerResponseImpl : IPackageManagerResponse {
public void AtomFeedText(string atomText) {
_feed = AtomFeed.Load(atomText);
}
+
+ public void TrustedPublishers( IEnumerable<string> trustedPublishers) {
+ _publishers = trustedPublishers;
+ }
}
}
@@ -80,27 +80,6 @@ public class Installer : MarshalByRefObject, INotifyPropertyChanged {
.UnionSingleItem(_packageManager.GetPackageDetails(pkg).Continue(() => { PrimaryPackage = pkg; }))
.ToArray()));
});
-
- /*
- _packageManager.AddSessionFeed(Path.GetDirectoryName(Path.GetFullPath(MsiFilename))).Continue(() => {
- _packageManager.GetPackageFromFile(Path.GetFullPath(MsiFilename)).Continue(pkg => {
-
- // gets the package data for the likely suspects.
-
- var tsks = new[] { pkg.InstalledNewest, pkg.AvailableNewestUpdate, pkg.AvailableNewestUpgrade }
- .Select(each =>
- each == null ?
- null :
- _packageManager.GetPackage(each.CanonicalName, true).Continue(pg => {
- if (pg != null) {
- _packageManager.GetPackageDetails(pg.CanonicalName);
- }
- })).Where( each => each != null).ToArray();
-
- _packageManager.GetPackageDetails(pkg).Continue(() => {PrimaryPackage = pkg;}).Wait();
- Task.WaitAll(tsks);
- });
- });*/
});
tsk.ContinueOnFail(error => {
@@ -384,8 +363,6 @@ public class Installer : MarshalByRefObject, INotifyPropertyChanged {
}
}
-
-
public bool CancelRequested {
get {
return _cancel;
@@ -432,7 +409,6 @@ public class Installer : MarshalByRefObject, INotifyPropertyChanged {
}
}
-
internal bool Ping {
get {
return _ping.WaitOne(0);
@@ -118,9 +118,8 @@
<TextBlock Name="StatusText" HorizontalAlignment="Center" Margin="0,6,0,0" Grid.Row="1" Foreground="#FF015329" FontSize="16" FontStyle="Italic" Text=""/>
<ProgressBar Height="30" Name="InstallationProgress" Width="450" Visibility="Collapsed" Grid.Row="1" Foreground="#FF01D329" />
- <ComboBox Margin="0,0,0,0" Name="WhichVersionToInstall" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="2" Foreground="Black" Background="#80000000" Width="450" FontSize="16" BorderThickness="1" />
+ <ComboBox Margin="0,0,0,0" Name="WhichVersionToInstall" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="2" Width="450" FontSize="16" BorderThickness="1" />
<CheckBox Name="CloseOption" HorizontalAlignment="Center" Margin="0,8,0,0" Visibility="Collapsed" Grid.Row="2" Foreground="#FF000000" Checked="CloseOption_Checked" Unchecked="CloseOption_Unchecked" >Close installation window automatically when complete</CheckBox>
-
<Grid Margin="10,10,10,10" Grid.Row="3" Height="40">
<Grid.ColumnDefinitions>
@@ -58,8 +58,8 @@ public interface IPackageManager {
Task RemoveScheduledTask(string taskName);
Task GetScheduledTasks(string taskName);
- Task AddTrustedPublisher();
- Task RemoveTrustedPublisher();
+ Task AddTrustedPublisher(string publisherKeyToken);
+ Task RemoveTrustedPublisher(string publisherKeyToken);
Task GetTrustedPublishers();
Task GetTelemetry();
@@ -69,5 +69,6 @@ public interface IPackageManagerResponse {
void GeneralPackageSetting(int priority, CanonicalName canonicalName, string key, string value);
void AtomFeedText(string atomText);
+ void TrustedPublishers(IEnumerable<string> trustedPublishers);
}
}
@@ -28,6 +28,9 @@ public class Composition {
public List<WebApplication> WebApplications { get; set; }
[XmlArray(IsNullable = false)]
+ public List<FauxApplication> FauxApplications { get; set; }
+
+ [XmlArray(IsNullable = false)]
public List<Service> Services { get; set; }
[XmlArray(IsNullable = false)]
@@ -19,6 +19,21 @@ namespace CoApp.Packaging.Common.Model {
public enum CompositionAction {
/// <summary>
+ /// TrustedAction: Downloads a file
+ /// </summary>
+ DownloadFile,
+
+ /// <summary>
+ /// TrustedAction: Allows arbitrary code to execute at install
+ /// </summary>
+ InstallCommand,
+
+ /// <summary>
+ /// TrustedAction: Allows arbitrary code to execute at remove
+ /// </summary>
+ RemoveCommand,
+
+ /// <summary>
/// Create a symlink to a folder
/// </summary>
SymlinkFolder,
@@ -53,19 +68,6 @@ public enum CompositionAction {
/// </summary>
Registry,
- /// <summary>
- /// TrustedAction: Downloads a file
- /// </summary>
- DownloadFile,
-
- /// <summary>
- /// TrustedAction: Allows arbitrary code to execute at install
- /// </summary>
- InstallScript,
-
- /// <summary>
- /// TrustedAction: Allows arbitrary code to execute at remove
- /// </summary>
- RemoveScript,
+
}
}
Oops, something went wrong.

0 comments on commit 7c3b8a8

Please sign in to comment.