1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 18:47:19 +03:00

During init, load all packages in CARD_ROOT/*/apps

This commit is contained in:
Paul Cercueil 2012-10-07 21:51:25 +02:00
parent 61d22e26e6
commit cd4809343b
2 changed files with 58 additions and 0 deletions

View File

@ -48,6 +48,21 @@ Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
sort(sections.begin(),sections.end(),case_less());
setSectionIndex(0);
readLinks();
#ifdef HAVE_LIBOPK
{
struct dirent *dptr;
DIR *dirp = opendir(CARD_ROOT);
if (dirp) {
while ((dptr = readdir(dirp))) {
if (dptr->d_type != DT_DIR)
continue;
readPackages((string) CARD_ROOT + dptr->d_name + "/apps");
}
closedir(dirp);
}
}
#endif
}
Menu::~Menu() {
@ -418,6 +433,44 @@ void Menu::setLinkIndex(int i) {
iLink = i;
}
#ifdef HAVE_LIBOPK
void Menu::readPackages(std::string parentDir)
{
DIR *dirp;
struct dirent *dptr;
vector<string> linkfiles;
dirp = opendir(parentDir.c_str());
if (!dirp)
return;
while ((dptr = readdir(dirp))) {
char *c;
LinkApp *link;
std::string path;
if (dptr->d_type != DT_REG)
continue;
c = strrchr(dptr->d_name, '.');
if (!c) /* File without extension */
continue;
if (strcasecmp(c + 1, "opk"))
continue;
path = parentDir + '/' + dptr->d_name;
link = new LinkApp(gmenu2x, ts, gmenu2x->input, path.c_str(), true);
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
/* TODO: Read the category from the OPK. */
links[0].push_back(link);
}
closedir(dirp);
}
#endif
void Menu::readLinksOfSection(std::string path, std::vector<std::string> &linkfiles)
{
DIR *dirp;

View File

@ -49,6 +49,11 @@ private:
// Load all the sections of the given "sections" directory.
void readSections(std::string parentDir);
#ifdef HAVE_LIBOPK
// Load all the .opk packages of the given directory
void readPackages(std::string parentDir);
#endif
// Load all the links on the given section directory.
void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles);