Date:2013-12-05 23:32:15 (10 years 3 months ago)
Author:Paul Cercueil
Commit:7c1af3a03b9c51eafe318ec1116f298105f16b09
Message:Use 'opkrun' to execute OPK files

Files: src/linkapp.cpp (5 diffs)
src/linkapp.h (2 diffs)
src/menu.cpp (3 diffs)

Change Details

src/linkapp.cpp
5757static const char *tokens[] = { "%f", "%F", "%u", "%U", };
5858
5959#ifdef HAVE_LIBOPK
60LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile, struct OPK *opk)
60LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile,
61            struct OPK *opk, const char *metadata_)
6162#else
6263LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile)
6364#endif
...... 
8081
8182#ifdef HAVE_LIBOPK
8283    isOPK = !!opk;
84
8385    if (isOPK) {
8486        string::size_type pos;
8587        const char *key, *val;
8688        size_t lkey, lval;
8789        int ret;
8890
91        metadata.assign(metadata_);
8992        opkFile = file;
9093        pos = file.rfind('/');
9194        opkMount = file.substr(pos+1);
...... 
553556
554557    if (isOpk()) {
555558#ifdef HAVE_LIBOPK
556        int err;
557
558        /* To be sure... */
559        string cmd = "umount " + opkMount;
560        system(cmd.c_str());
561
562        mkdir(opkMount.c_str(), 0700);
563        cmd = "mount -o loop,nosuid,ro " + opkFile + ' ' + opkMount;
564        err = system(cmd.c_str());
565
566        if (err) {
567            ERROR("Unable to mount OPK\n");
568            return;
569        }
570
571        chdir(opkMount.c_str());
572        if (exec[0] != '/') {
573            string tmp = opkMount + exec.substr(0, exec.find(" "));
574            if (fileExists(tmp))
575                exec = opkMount + exec;
576        }
559        exec = "/usr/bin/opkrun -m " + metadata + " " + opkFile;
577560#endif
578561    } else {
579562        //Set correct working directory
...... 
604587    INFO("Executing '%s' (%s %s)\n", title.c_str(), exec.c_str(), params.c_str());
605588
606589    //check if we have to quit
607    string command = cmdclean(exec);
590    string command = exec;
608591
609592    if (!params.empty()) command += " " + params;
610593#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
...... 
614597    if (gmenu2x->confInt["outputLogs"])
615598        command += " &> " LOG_FILE;
616599#endif
617#ifdef HAVE_LIBOPK
618    if (isOPK)
619        command += " ; umount -l " + opkMount;
620#endif
621600
622601    gmenu2x->saveSelection();
623602
src/linkapp.h
4545    bool dontleave;
4646#ifdef HAVE_LIBOPK
4747    bool isOPK;
48    std::string opkMount, opkFile, category;
48    std::string opkMount, opkFile, category, metadata;
4949#endif
5050
5151    void start();
...... 
5959    bool isOpk() { return isOPK; }
6060    const std::string &getOpkFile() { return opkFile; }
6161
62    LinkApp(GMenu2X *gmenu2x, const char* linkfile, struct OPK *opk = NULL);
62    LinkApp(GMenu2X *gmenu2x, const char* linkfile,
63                struct OPK *opk = NULL, const char *metadata = NULL);
6364#else
6465    LinkApp(GMenu2X *gmenu2x, const char* linkfile);
6566    bool isOpk() { return false; }
src/menu.cpp
2626#include <math.h>
2727#include <fstream>
2828#include <unistd.h>
29#include <ini.h>
2930
3031#ifdef HAVE_LIBOPK
3132#include <opk.h>
...... 
674675    for (;;) {
675676        unsigned int i;
676677        bool has_metadata = false;
678        const char *name;
677679        LinkApp *link;
678680
679681        for (;;) {
680682            string::size_type pos;
681            const char *name;
682683            int ret = opk_open_metadata(opk, &name);
683684            if (ret < 0) {
684685                ERROR("Error while loading meta-data\n");
...... 
704705        if (!has_metadata)
705706          break;
706707
707        link = new LinkApp(gmenu2x, path.c_str(), opk);
708        link = new LinkApp(gmenu2x, path.c_str(), opk, name);
708709        link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
709710
710711        addSection(link->getCategory());

Archive Download the corresponding diff file



interactive