Skip to content

Commit

Permalink
[4.4.3] fixed scan old plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Oct 16, 2024
1 parent 9e40024 commit 2f6a8e4
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/framework/extensions/internal/legacy/extpluginsloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ ManifestList ExtPluginsLoader::manifestList(const io::path_t& rootPath) const
io::paths_t paths = qmlsPaths(rootPath);
for (const io::path_t& path : paths) {
Manifest manifest = parseManifest(rootPath, path);
if (!manifest.isValid()) {
continue;
}
resolvePaths(manifest, io::FileInfo(path).dirPath());
manifests.push_back(manifest);
}
Expand All @@ -106,6 +109,7 @@ io::paths_t ExtPluginsLoader::qmlsPaths(const io::path_t& rootPath) const
LOGE() << "failed scan files, err: " << paths.ret.toString()
<< ", path: " << rootPath;
}

return paths.val;
}

Expand All @@ -118,6 +122,30 @@ Manifest ExtPluginsLoader::parseManifest(const io::path_t& rootPath, const io::p
return Manifest();
}

String content = String::fromUtf8(data);

//! NOTE Check is MuseScore plugin
{
size_t bracketPos = 0;
for (size_t i = 0; i < content.size(); ++i) {
if (content.at(i) == Char(u'{')) {
bracketPos = i;
break;
}
}

if (bracketPos == 0) {
LOGD() << "Not MuseScore plugin, path: " << path;
return Manifest();
}

String header = content.left(bracketPos);
if (!content.contains(u"MuseScore")) {
LOGD() << "Not MuseScore plugin, path: " << path;
return Manifest();
}
}

io::FileInfo fi(path);

Manifest m;
Expand Down Expand Up @@ -148,7 +176,6 @@ Manifest ExtPluginsLoader::parseManifest(const io::path_t& rootPath, const io::p
int needProperties = 6; // title, description, pluginType, category, thumbnail, requiresScore
int propertiesFound = 0;
bool insideMuseScoreItem = false;
String content = String::fromUtf8(data);
size_t current, previous = 0;
current = content.indexOf(u"\n");

Expand Down Expand Up @@ -200,7 +227,7 @@ Manifest ExtPluginsLoader::parseManifest(const io::path_t& rootPath, const io::p
++propertiesFound;
} else if (line.startsWith(u"pluginType:")) {
String pluginType = dropQuotes(line.mid(11).trimmed());
if (pluginType == "dialog") {
if (pluginType == "dialog" || pluginType == "dock") {
m.type = Type::Form;
}
++propertiesFound;
Expand All @@ -226,6 +253,10 @@ Manifest ExtPluginsLoader::parseManifest(const io::path_t& rootPath, const io::p
current = content.indexOf(u"\n", previous);
}

if (m.title.isEmpty()) {
m.title = fi.baseName();
}

Action a;
a.code = "main";
a.type = m.type;
Expand Down

0 comments on commit 2f6a8e4

Please sign in to comment.