|
|
@ -56,7 +56,7 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_events.OnAddInOperationError(new AddInExceptionEventArgs(ex)); |
|
|
|
_events.OnAddInOperationError(new AddInOperationErrorEventArgs(ex)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -71,8 +71,9 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
if (addInEntry != null) |
|
|
|
if (addInEntry != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_events.OnAddInOperationError( |
|
|
|
_events.OnAddInOperationError( |
|
|
|
new AddInExceptionEventArgs( |
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
new AddInLoadException("The package may only contain one .addin file."))); |
|
|
|
SD.ResourceService.GetString("AddInManager2.InvalidPackage"))); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
addInEntry = entry; |
|
|
|
addInEntry = entry; |
|
|
|
} |
|
|
|
} |
|
|
@ -80,8 +81,9 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
if (addInEntry == null) |
|
|
|
if (addInEntry == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_events.OnAddInOperationError( |
|
|
|
_events.OnAddInOperationError( |
|
|
|
new AddInExceptionEventArgs( |
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
new AddInLoadException("The package must contain one .addin file."))); |
|
|
|
SD.ResourceService.GetString("AddInManager2.InvalidPackage"))); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
using (Stream s = file.GetInputStream(addInEntry)) |
|
|
|
using (Stream s = file.GetInputStream(addInEntry)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -100,22 +102,28 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
{ |
|
|
|
{ |
|
|
|
AddIn addIn = null; |
|
|
|
AddIn addIn = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool installAsExternal = false; |
|
|
|
|
|
|
|
|
|
|
|
switch (Path.GetExtension(fileName).ToLowerInvariant()) |
|
|
|
switch (Path.GetExtension(fileName).ToLowerInvariant()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case ".addin": |
|
|
|
case ".addin": |
|
|
|
if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, fileName)) |
|
|
|
if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, fileName)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO Send around the error message
|
|
|
|
// Don't allow to install AddIns from application root path
|
|
|
|
// MessageService.ShowMessage("${res:AddInManager.CannotInstallIntoApplicationDirectory}");
|
|
|
|
_events.OnAddInOperationError( |
|
|
|
|
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
|
|
|
|
SD.ResourceService.GetString("AddInManager.CannotInstallIntoApplicationDirectory"))); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Load directly from location
|
|
|
|
// Load directly from location
|
|
|
|
addIn = _sdAddInManagement.Load(fileName); |
|
|
|
addIn = _sdAddInManagement.Load(fileName); |
|
|
|
|
|
|
|
installAsExternal = true; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ".sdaddin": |
|
|
|
case ".sdaddin": |
|
|
|
|
|
|
|
case ".zip": |
|
|
|
// Try to load the *.sdaddin file as ZIP archive
|
|
|
|
// Try to load the *.sdaddin file as ZIP archive
|
|
|
|
ZipFile zipFile = null; |
|
|
|
ZipFile zipFile = null; |
|
|
|
try |
|
|
|
try |
|
|
@ -123,10 +131,12 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
zipFile = new ZipFile(fileName); |
|
|
|
zipFile = new ZipFile(fileName); |
|
|
|
addIn = LoadAddInFromZip(zipFile); |
|
|
|
addIn = LoadAddInFromZip(zipFile); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Report the exception
|
|
|
|
// ZIP file seems not to be valid
|
|
|
|
_events.OnAddInOperationError(new AddInExceptionEventArgs(ex)); |
|
|
|
_events.OnAddInOperationError( |
|
|
|
|
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
|
|
|
|
SD.ResourceService.GetString("AddInManager2.InvalidPackage"))); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
finally |
|
|
|
finally |
|
|
@ -139,8 +149,10 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
// TODO Send around the error message
|
|
|
|
// Unknown format of file
|
|
|
|
// MessageService.ShowMessage("${res:AddInManager.UnknownFileFormat} " + Path.GetExtension(file));
|
|
|
|
_events.OnAddInOperationError( |
|
|
|
|
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
|
|
|
|
SD.ResourceService.GetString("AddInManager.UnknownFileFormat") + " " + Path.GetExtension(fileName))); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -149,7 +161,7 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
if ((addIn.Manifest == null) || (addIn.Manifest.PrimaryIdentity == null)) |
|
|
|
if ((addIn.Manifest == null) || (addIn.Manifest.PrimaryIdentity == null)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_events.OnAddInOperationError( |
|
|
|
_events.OnAddInOperationError( |
|
|
|
new AddInExceptionEventArgs( |
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity")))); |
|
|
|
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity")))); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -172,6 +184,8 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
_sdAddInManagement.AbortRemoveUserAddInOnNextStart(installedIdentity); |
|
|
|
_sdAddInManagement.AbortRemoveUserAddInOnNextStart(installedIdentity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!installAsExternal) |
|
|
|
|
|
|
|
{ |
|
|
|
// Create target directory for AddIn in user profile & copy package contents there
|
|
|
|
// Create target directory for AddIn in user profile & copy package contents there
|
|
|
|
CopyAddInFromZip(addIn, fileName); |
|
|
|
CopyAddInFromZip(addIn, fileName); |
|
|
|
|
|
|
|
|
|
|
@ -185,6 +199,12 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
addIn.Action = AddInAction.Install; |
|
|
|
addIn.Action = AddInAction.Install; |
|
|
|
_sdAddInManagement.AddToTree(addIn); |
|
|
|
_sdAddInManagement.AddToTree(addIn); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Only add a reference to an external manifest
|
|
|
|
|
|
|
|
_sdAddInManagement.AddExternalAddIns(new AddIn[] { addIn }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Mark this AddIn
|
|
|
|
// Mark this AddIn
|
|
|
|
ManagedAddIn markedAddIn = new ManagedAddIn(addIn) |
|
|
|
ManagedAddIn markedAddIn = new ManagedAddIn(addIn) |
|
|
@ -202,13 +222,9 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
|
|
|
|
|
|
|
|
return addIn; |
|
|
|
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; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -222,7 +238,7 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
if (addIn.Manifest.PrimaryIdentity == null) |
|
|
|
if (addIn.Manifest.PrimaryIdentity == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_events.OnAddInOperationError( |
|
|
|
_events.OnAddInOperationError( |
|
|
|
new AddInExceptionEventArgs( |
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity")))); |
|
|
|
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity")))); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -278,7 +294,9 @@ namespace ICSharpCode.AddInManager2.Model |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// This is not a valid SharpDevelop AddIn package!
|
|
|
|
// This is not a valid SharpDevelop AddIn package!
|
|
|
|
// TODO Throw something.
|
|
|
|
_events.OnAddInOperationError( |
|
|
|
|
|
|
|
new AddInOperationErrorEventArgs( |
|
|
|
|
|
|
|
SD.ResourceService.GetString("AddInManager2.InvalidPackage"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|