Skip to content

Commit f1b182c

Browse files
committed
Show status window while downloading a plugin in Plugin Installer
1 parent 4c59aba commit f1b182c

2 files changed

Lines changed: 106 additions & 94 deletions

File tree

Source/UI/PluginInstaller.cpp

Lines changed: 102 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ void PluginListBoxComponent::returnKeyPressed (int lastRowSelected)
679679

680680
/* ================================== Plugin Information Component ================================== */
681681

682-
PluginInfoComponent::PluginInfoComponent()
682+
PluginInfoComponent::PluginInfoComponent() : ThreadWithProgressWindow("Plugin Installer", false, false)
683683
{
684684
infoFont = Font("FiraSans", 20, Font::plain);
685685
infoFontBold = Font("FiraSans Bold", 20, Font::plain);
@@ -792,118 +792,127 @@ void PluginInfoComponent::buttonClicked(Button* button)
792792
{
793793
if (button == &downloadButton)
794794
{
795-
std::cout << "\nDownloading Plugin: " << pInfo.pluginName << "... " << std::endl;
796-
797-
// If a plugin has depencies outside its zip, download them
798-
for (int i = 0; i < pInfo.dependencies.size(); i++)
799-
{
800-
String depUrl = "https://api.bintray.com/packages/open-ephys-gui-plugins/";
801-
depUrl += pInfo.dependencies[i] + "/" + pInfo.dependencies[i] + "-" ;
802-
depUrl += osType + "/versions/_latest";
803-
804-
String depResponse = URL(depUrl).readEntireTextStream();
805-
var depReply = JSON::parse(depResponse);
806-
String ver = depReply.getProperty("name", "NULL");
807-
808-
int retCode = downloadPlugin(pInfo.dependencies[i], ver, true);
795+
this->runThread();
796+
}
797+
else if (button == &documentationButton)
798+
{
799+
URL url = URL(pInfo.docURL);
800+
url.launchInDefaultBrowser();
801+
}
802+
}
809803

810-
if (retCode == 2)
811-
{
812-
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
813-
"[Plugin Installer] " + pInfo.dependencies[i],
814-
"Could not install dependency: " + pInfo.dependencies[i]
815-
+ ". Please contact the developers.");
816-
817-
std::cout << "Download Failed!!" << std::endl;
818-
return;
819-
}
820-
}
804+
void PluginInfoComponent::run()
805+
{
806+
std::cout << "\nDownloading Plugin: " << pInfo.pluginName << "... " << std::endl;
821807

822-
// download the plugin
823-
int dlReturnCode = downloadPlugin(pInfo.pluginName, pInfo.selectedVersion, false);
808+
// If a plugin has depencies outside its zip, download them
809+
for (int i = 0; i < pInfo.dependencies.size(); i++)
810+
{
811+
String depUrl = "https://api.bintray.com/packages/open-ephys-gui-plugins/";
812+
depUrl += pInfo.dependencies[i] + "/" + pInfo.dependencies[i] + "-" ;
813+
depUrl += osType + "/versions/_latest";
824814

825-
if (dlReturnCode == SUCCESS)
826-
{
827-
AlertWindow::showMessageBoxAsync(AlertWindow::InfoIcon,
828-
"[Plugin Installer] " + pInfo.displayName,
829-
pInfo.displayName + " Installed Successfully");
815+
setStatusMessage("Downloading dependency: " + pInfo.dependencies[i]);
830816

831-
std::cout << "Download Successfull!!" << std::endl;
817+
String depResponse = URL(depUrl).readEntireTextStream();
818+
var depReply = JSON::parse(depResponse);
819+
String ver = depReply.getProperty("name", "NULL");
832820

833-
pInfo.installedVersion = pInfo.selectedVersion;
834-
downloadButton.setEnabled(false);
835-
downloadButton.setButtonText("Installed");
836-
}
837-
else if (dlReturnCode == ZIP_NOTFOUND)
821+
int retCode = downloadPlugin(pInfo.dependencies[i], ver, true);
822+
823+
if (retCode == 2)
838824
{
839825
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
840-
"[Plugin Installer] " + pInfo.displayName,
841-
"Could not find the ZIP file for " + pInfo.displayName
826+
"[Plugin Installer] " + pInfo.dependencies[i],
827+
"Could not install dependency: " + pInfo.dependencies[i]
842828
+ ". Please contact the developers.");
843-
829+
844830
std::cout << "Download Failed!!" << std::endl;
831+
return;
845832
}
846-
else if (dlReturnCode == UNCMP_ERR)
847-
{
848-
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
849-
"[Plugin Installer] " + pInfo.displayName,
850-
"Could not uncompress the ZIP file. Please try again.");
833+
}
834+
835+
setStatusMessage("Downloading " + pInfo.displayName + " ...");
851836

852-
std::cout << "Download Failed!!" << std::endl;
853-
}
854-
else if (dlReturnCode == XML_MISSING)
855-
{
856-
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
857-
"[Plugin Installer] " + pInfo.displayName,
858-
"Unable to locate installedPlugins.xml \n Please restart Plugin Installer and try again.");
837+
// download the plugin
838+
int dlReturnCode = downloadPlugin(pInfo.pluginName, pInfo.selectedVersion, false);
859839

860-
std::cout << "XML File Missing!!" << std::endl;
861-
}
862-
else if (dlReturnCode == VER_EXISTS_ERR)
863-
{
864-
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
865-
"[Plugin Installer] " + pInfo.displayName,
866-
pInfo.displayName + " v" + pInfo.selectedVersion
867-
+ " already exists. Please download another version.");
840+
if (dlReturnCode == SUCCESS)
841+
{
842+
AlertWindow::showMessageBoxAsync(AlertWindow::InfoIcon,
843+
"[Plugin Installer] " + pInfo.displayName,
844+
pInfo.displayName + " Installed Successfully");
868845

869-
std::cout << "Download Failed!!" << std::endl;
870-
}
871-
else if (dlReturnCode == XML_WRITE_ERR)
872-
{
873-
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
874-
"[Plugin Installer] " + pInfo.displayName,
875-
"Unable to write to installedPlugins.xml \n Please try again.");
876-
877-
std::cout << "Writing to XML Failed!!" << std::endl;
878-
}
879-
else if (dlReturnCode == LOAD_ERR)
880-
{
881-
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
882-
"[Plugin Installer] " + pInfo.displayName,
883-
"Unable to load " + pInfo.displayName
884-
+ " in the Processor List.\nLook at console output for more details.");
846+
std::cout << "Download Successfull!!" << std::endl;
885847

886-
std::cout << "Loading Plugin Failed!!" << std::endl;
848+
pInfo.installedVersion = pInfo.selectedVersion;
849+
downloadButton.setEnabled(false);
850+
downloadButton.setButtonText("Installed");
851+
}
852+
else if (dlReturnCode == ZIP_NOTFOUND)
853+
{
854+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
855+
"[Plugin Installer] " + pInfo.displayName,
856+
"Could not find the ZIP file for " + pInfo.displayName
857+
+ ". Please contact the developers.");
887858

888-
pInfo.installedVersion = pInfo.selectedVersion;
889-
downloadButton.setEnabled(false);
890-
downloadButton.setButtonText("Installed");
891-
}
892-
else if (dlReturnCode == PROC_IN_USE)
893-
{
894-
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
895-
"[Plugin Installer] " + pInfo.displayName,
896-
"Plugin already in use. Please remove it from the signal chain and try again.");
859+
std::cout << "Download Failed!!" << std::endl;
860+
}
861+
else if (dlReturnCode == UNCMP_ERR)
862+
{
863+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
864+
"[Plugin Installer] " + pInfo.displayName,
865+
"Could not uncompress the ZIP file. Please try again.");
897866

898-
std::cout << "Error.. Plugin already in use. Please remove it from the signal chain and try again." << std::endl;
899-
}
867+
std::cout << "Download Failed!!" << std::endl;
868+
}
869+
else if (dlReturnCode == XML_MISSING)
870+
{
871+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
872+
"[Plugin Installer] " + pInfo.displayName,
873+
"Unable to locate installedPlugins.xml \n Please restart Plugin Installer and try again.");
900874

875+
std::cout << "XML File Missing!!" << std::endl;
901876
}
902-
else if (button == &documentationButton)
877+
else if (dlReturnCode == VER_EXISTS_ERR)
903878
{
904-
URL url = URL(pInfo.docURL);
905-
url.launchInDefaultBrowser();
879+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
880+
"[Plugin Installer] " + pInfo.displayName,
881+
pInfo.displayName + " v" + pInfo.selectedVersion
882+
+ " already exists. Please download another version.");
883+
884+
std::cout << "Download Failed!!" << std::endl;
906885
}
886+
else if (dlReturnCode == XML_WRITE_ERR)
887+
{
888+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
889+
"[Plugin Installer] " + pInfo.displayName,
890+
"Unable to write to installedPlugins.xml \n Please try again.");
891+
892+
std::cout << "Writing to XML Failed!!" << std::endl;
893+
}
894+
else if (dlReturnCode == LOAD_ERR)
895+
{
896+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
897+
"[Plugin Installer] " + pInfo.displayName,
898+
"Unable to load " + pInfo.displayName
899+
+ " in the Processor List.\nLook at console output for more details.");
900+
901+
std::cout << "Loading Plugin Failed!!" << std::endl;
902+
903+
pInfo.installedVersion = pInfo.selectedVersion;
904+
downloadButton.setEnabled(false);
905+
downloadButton.setButtonText("Installed");
906+
}
907+
else if (dlReturnCode == PROC_IN_USE)
908+
{
909+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
910+
"[Plugin Installer] " + pInfo.displayName,
911+
"Plugin already in use. Please remove it from the signal chain and try again.");
912+
913+
std::cout << "Error.. Plugin already in use. Please remove it from the signal chain and try again." << std::endl;
914+
}
915+
907916
}
908917

909918
int PluginInfoComponent::versionCompare(const String& v1, const String& v2)

Source/UI/PluginInstaller.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ struct SelectedPluginInfo
6868
*/
6969
class PluginInfoComponent : public Component,
7070
public Button::Listener,
71-
public ComboBox::Listener
71+
public ComboBox::Listener,
72+
public ThreadWithProgressWindow
7273
{
7374
public:
7475
PluginInfoComponent();
@@ -123,6 +124,8 @@ class PluginInfoComponent : public Component,
123124

124125
enum RetunCode {ZIP_NOTFOUND, SUCCESS, UNCMP_ERR, XML_MISSING, VER_EXISTS_ERR, XML_WRITE_ERR, LOAD_ERR, PROC_IN_USE};
125126

127+
void run() override;
128+
126129
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginInfoComponent);
127130

128131
};

0 commit comments

Comments
 (0)