diff --git a/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj b/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj
index 90eeb233d2..bdcbd9ba89 100644
--- a/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj
+++ b/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj
@@ -77,6 +77,7 @@
+
@@ -110,7 +111,7 @@
-
+
diff --git a/src/AddIns/Misc/AddInManager2/Project/Resources/StringResources.resx b/src/AddIns/Misc/AddInManager2/Project/Resources/StringResources.resx
index fa78b641fc..b0d2f7ecb2 100644
--- a/src/AddIns/Misc/AddInManager2/Project/Resources/StringResources.resx
+++ b/src/AddIns/Misc/AddInManager2/Project/Resources/StringResources.resx
@@ -236,7 +236,7 @@ If you do not agree to the license terms click "I Decline".
License Agreements
- SharpDevelop AddIns|*.sdaddin|All files|*.*
+ SharpDevelop AddIns|*.sdaddin;*.addin|All files|*.*
Package "{0}" needs at least one additional package:
@@ -254,4 +254,7 @@ The application will try to download and install them, as well. Do you want to c
File name:
+
+ Selected package doesn't contain a valid SharpDevelop AddIn.
+
\ No newline at end of file
diff --git a/src/AddIns/Misc/AddInManager2/Project/Resources/external_addin_small.png b/src/AddIns/Misc/AddInManager2/Project/Resources/external_addin_small.png
new file mode 100644
index 0000000000..ac945975af
Binary files /dev/null and b/src/AddIns/Misc/AddInManager2/Project/Resources/external_addin_small.png differ
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInExceptionEventArgs.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInExceptionEventArgs.cs
deleted file mode 100644
index 9cc0a54d2b..0000000000
--- a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInExceptionEventArgs.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-
-namespace ICSharpCode.AddInManager2.Model
-{
- ///
- /// Data for events indicating an exception during package-related operations.
- ///
- public class AddInExceptionEventArgs : EventArgs
- {
- public AddInExceptionEventArgs(Exception exception)
- {
- Exception = exception;
- }
-
- public Exception Exception
- {
- get;
- private set;
- }
- }
-}
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInManagerEvents.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInManagerEvents.cs
index 7bf7cddff2..c77bf3bab3 100644
--- a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInManagerEvents.cs
+++ b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInManagerEvents.cs
@@ -13,6 +13,14 @@ namespace ICSharpCode.AddInManager2.Model
{
public event EventHandler OperationStarted;
+ public void OnOperationStarted()
+ {
+ if (OperationStarted != null)
+ {
+ OperationStarted(this, new EventArgs());
+ }
+ }
+
public void OnOperationStarted(EventArgs e)
{
if (OperationStarted != null)
@@ -41,9 +49,9 @@ namespace ICSharpCode.AddInManager2.Model
}
}
- public event EventHandler AddInOperationError;
+ public event EventHandler AddInOperationError;
- public void OnAddInOperationError(AddInExceptionEventArgs e)
+ public void OnAddInOperationError(AddInOperationErrorEventArgs e)
{
if (AddInOperationError != null)
{
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInOperationErrorEventArgs.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInOperationErrorEventArgs.cs
new file mode 100644
index 0000000000..a65310f4b7
--- /dev/null
+++ b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInOperationErrorEventArgs.cs
@@ -0,0 +1,49 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.AddInManager2.Model
+{
+ ///
+ /// Data for events indicating an exception or other errors during package-related operations.
+ ///
+ public class AddInOperationErrorEventArgs : EventArgs
+ {
+ private string _message = null;
+
+ public AddInOperationErrorEventArgs(Exception exception)
+ {
+ Exception = exception;
+ }
+
+ public AddInOperationErrorEventArgs(string message)
+ {
+ Exception = null;
+ _message = message;
+ }
+
+ public Exception Exception
+ {
+ get;
+ private set;
+ }
+
+ public string Message
+ {
+ get
+ {
+ if (_message != null)
+ {
+ return _message;
+ }
+ if (Exception != null)
+ {
+ return Exception.Message;
+ }
+
+ return null;
+ }
+ }
+ }
+}
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs
index af7b03b298..6476c0b050 100644
--- a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs
+++ b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs
@@ -56,7 +56,7 @@ namespace ICSharpCode.AddInManager2.Model
}
catch (Exception ex)
{
- _events.OnAddInOperationError(new AddInExceptionEventArgs(ex));
+ _events.OnAddInOperationError(new AddInOperationErrorEventArgs(ex));
}
}
@@ -71,8 +71,9 @@ namespace ICSharpCode.AddInManager2.Model
if (addInEntry != null)
{
_events.OnAddInOperationError(
- new AddInExceptionEventArgs(
- new AddInLoadException("The package may only contain one .addin file.")));
+ new AddInOperationErrorEventArgs(
+ SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
+ return null;
}
addInEntry = entry;
}
@@ -80,8 +81,9 @@ namespace ICSharpCode.AddInManager2.Model
if (addInEntry == null)
{
_events.OnAddInOperationError(
- new AddInExceptionEventArgs(
- new AddInLoadException("The package must contain one .addin file.")));
+ new AddInOperationErrorEventArgs(
+ SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
+ return null;
}
using (Stream s = file.GetInputStream(addInEntry))
{
@@ -100,22 +102,28 @@ namespace ICSharpCode.AddInManager2.Model
{
AddIn addIn = null;
+ bool installAsExternal = false;
+
switch (Path.GetExtension(fileName).ToLowerInvariant())
{
case ".addin":
if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, fileName))
{
- // TODO Send around the error message
-// MessageService.ShowMessage("${res:AddInManager.CannotInstallIntoApplicationDirectory}");
+ // Don't allow to install AddIns from application root path
+ _events.OnAddInOperationError(
+ new AddInOperationErrorEventArgs(
+ SD.ResourceService.GetString("AddInManager.CannotInstallIntoApplicationDirectory")));
return null;
}
// Load directly from location
addIn = _sdAddInManagement.Load(fileName);
+ installAsExternal = true;
break;
case ".sdaddin":
+ case ".zip":
// Try to load the *.sdaddin file as ZIP archive
ZipFile zipFile = null;
try
@@ -123,10 +131,12 @@ namespace ICSharpCode.AddInManager2.Model
zipFile = new ZipFile(fileName);
addIn = LoadAddInFromZip(zipFile);
}
- catch (Exception ex)
+ catch (Exception)
{
- // Report the exception
- _events.OnAddInOperationError(new AddInExceptionEventArgs(ex));
+ // ZIP file seems not to be valid
+ _events.OnAddInOperationError(
+ new AddInOperationErrorEventArgs(
+ SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
return null;
}
finally
@@ -139,8 +149,10 @@ namespace ICSharpCode.AddInManager2.Model
break;
default:
- // TODO Send around the error message
-// MessageService.ShowMessage("${res:AddInManager.UnknownFileFormat} " + Path.GetExtension(file));
+ // Unknown format of file
+ _events.OnAddInOperationError(
+ new AddInOperationErrorEventArgs(
+ SD.ResourceService.GetString("AddInManager.UnknownFileFormat") + " " + Path.GetExtension(fileName)));
return null;
}
@@ -149,7 +161,7 @@ namespace ICSharpCode.AddInManager2.Model
if ((addIn.Manifest == null) || (addIn.Manifest.PrimaryIdentity == null))
{
_events.OnAddInOperationError(
- new AddInExceptionEventArgs(
+ new AddInOperationErrorEventArgs(
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity"))));
return null;
}
@@ -172,18 +184,26 @@ namespace ICSharpCode.AddInManager2.Model
_sdAddInManagement.AbortRemoveUserAddInOnNextStart(installedIdentity);
}
- // Create target directory for AddIn in user profile & copy package contents there
- CopyAddInFromZip(addIn, fileName);
-
- // Install the AddIn using manifest
- if (foundAddIn != null)
+ if (!installAsExternal)
{
- addIn.Action = AddInAction.Update;
+ // Create target directory for AddIn in user profile & copy package contents there
+ CopyAddInFromZip(addIn, fileName);
+
+ // Install the AddIn using manifest
+ if (foundAddIn != null)
+ {
+ addIn.Action = AddInAction.Update;
+ }
+ else
+ {
+ addIn.Action = AddInAction.Install;
+ _sdAddInManagement.AddToTree(addIn);
+ }
}
else
{
- addIn.Action = AddInAction.Install;
- _sdAddInManagement.AddToTree(addIn);
+ // Only add a reference to an external manifest
+ _sdAddInManagement.AddExternalAddIns(new AddIn[] { addIn });
}
// Mark this AddIn
@@ -202,13 +222,9 @@ namespace ICSharpCode.AddInManager2.Model
return addIn;
}
- else
- {
- // This is not a valid SharpDevelop AddIn package!
- // TODO Show a message to user!
- }
}
+ // In successful cases we should have exited somewhere else, in error cases the error event was already fired.
return null;
}
@@ -222,7 +238,7 @@ namespace ICSharpCode.AddInManager2.Model
if (addIn.Manifest.PrimaryIdentity == null)
{
_events.OnAddInOperationError(
- new AddInExceptionEventArgs(
+ new AddInOperationErrorEventArgs(
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity"))));
return null;
}
@@ -278,7 +294,9 @@ namespace ICSharpCode.AddInManager2.Model
else
{
// This is not a valid SharpDevelop AddIn package!
- // TODO Throw something.
+ _events.OnAddInOperationError(
+ new AddInOperationErrorEventArgs(
+ SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
}
return null;
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/IAddInManagerEvents.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/IAddInManagerEvents.cs
index 30a7de7441..d774903567 100644
--- a/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/IAddInManagerEvents.cs
+++ b/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/IAddInManagerEvents.cs
@@ -13,6 +13,7 @@ namespace ICSharpCode.AddInManager2.Model
{
event EventHandler OperationStarted;
void OnOperationStarted(EventArgs e);
+ void OnOperationStarted();
event EventHandler AddInInstalled;
void OnAddInInstalled(AddInInstallationEventArgs e);
@@ -20,8 +21,8 @@ namespace ICSharpCode.AddInManager2.Model
event EventHandler AddInUninstalled;
void OnAddInUninstalled(AddInInstallationEventArgs e);
- event EventHandler AddInOperationError;
- void OnAddInOperationError(AddInExceptionEventArgs e);
+ event EventHandler AddInOperationError;
+ void OnAddInOperationError(AddInOperationErrorEventArgs e);
event EventHandler AddInPackageDownloaded;
void OnAddInPackageDownloaded(PackageOperationEventArgs e);
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/ISDAddInManagement.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/ISDAddInManagement.cs
index ea814a7371..a56af15da4 100644
--- a/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/ISDAddInManagement.cs
+++ b/src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/ISDAddInManagement.cs
@@ -35,5 +35,6 @@ namespace ICSharpCode.AddInManager2.Model
void RemoveUserAddInOnNextStart(string identity);
AddIn Load(TextReader textReader);
AddIn Load(string fileName);
+ void AddExternalAddIns(IList addIns);
}
}
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/SDAddInManagement.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/SDAddInManagement.cs
index 0bde903869..d716c79c39 100644
--- a/src/AddIns/Misc/AddInManager2/Project/Src/Model/SDAddInManagement.cs
+++ b/src/AddIns/Misc/AddInManager2/Project/Src/Model/SDAddInManagement.cs
@@ -84,5 +84,10 @@ namespace ICSharpCode.AddInManager2.Model
{
return AddIn.Load(SD.AddInTree, fileName);
}
+
+ public void AddExternalAddIns(IList addIns)
+ {
+ ICSharpCode.Core.AddInManager.AddExternalAddIns(addIns);
+ }
}
}
diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml b/src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml
index db56187271..45f416a5bb 100644
--- a/src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml
+++ b/src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml
@@ -20,6 +20,25 @@
+
+
+
+