src/linkapp.cpp |
57 | 57 | static const char *tokens[] = { "%f", "%F", "%u", "%U", }; |
58 | 58 | |
59 | 59 | #ifdef HAVE_LIBOPK |
60 | | LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile, struct OPK *opk) |
| 60 | LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile, |
| 61 | struct OPK *opk, const char *metadata_) |
61 | 62 | #else |
62 | 63 | LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile) |
63 | 64 | #endif |
... | ... | |
80 | 81 | |
81 | 82 | #ifdef HAVE_LIBOPK |
82 | 83 | isOPK = !!opk; |
| 84 | |
83 | 85 | if (isOPK) { |
84 | 86 | string::size_type pos; |
85 | 87 | const char *key, *val; |
86 | 88 | size_t lkey, lval; |
87 | 89 | int ret; |
88 | 90 | |
| 91 | metadata.assign(metadata_); |
89 | 92 | opkFile = file; |
90 | 93 | pos = file.rfind('/'); |
91 | 94 | opkMount = file.substr(pos+1); |
... | ... | |
553 | 556 | |
554 | 557 | if (isOpk()) { |
555 | 558 | #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; |
577 | 560 | #endif |
578 | 561 | } else { |
579 | 562 | //Set correct working directory |
... | ... | |
604 | 587 | INFO("Executing '%s' (%s %s)\n", title.c_str(), exec.c_str(), params.c_str()); |
605 | 588 | |
606 | 589 | //check if we have to quit |
607 | | string command = cmdclean(exec); |
| 590 | string command = exec; |
608 | 591 | |
609 | 592 | if (!params.empty()) command += " " + params; |
610 | 593 | #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) |
... | ... | |
614 | 597 | if (gmenu2x->confInt["outputLogs"]) |
615 | 598 | command += " &> " LOG_FILE; |
616 | 599 | #endif |
617 | | #ifdef HAVE_LIBOPK |
618 | | if (isOPK) |
619 | | command += " ; umount -l " + opkMount; |
620 | | #endif |
621 | 600 | |
622 | 601 | gmenu2x->saveSelection(); |
623 | 602 | |
src/linkapp.h |
45 | 45 | bool dontleave; |
46 | 46 | #ifdef HAVE_LIBOPK |
47 | 47 | bool isOPK; |
48 | | std::string opkMount, opkFile, category; |
| 48 | std::string opkMount, opkFile, category, metadata; |
49 | 49 | #endif |
50 | 50 | |
51 | 51 | void start(); |
... | ... | |
59 | 59 | bool isOpk() { return isOPK; } |
60 | 60 | const std::string &getOpkFile() { return opkFile; } |
61 | 61 | |
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); |
63 | 64 | #else |
64 | 65 | LinkApp(GMenu2X *gmenu2x, const char* linkfile); |
65 | 66 | bool isOpk() { return false; } |
src/menu.cpp |
26 | 26 | #include <math.h> |
27 | 27 | #include <fstream> |
28 | 28 | #include <unistd.h> |
| 29 | #include <ini.h> |
29 | 30 | |
30 | 31 | #ifdef HAVE_LIBOPK |
31 | 32 | #include <opk.h> |
... | ... | |
674 | 675 | for (;;) { |
675 | 676 | unsigned int i; |
676 | 677 | bool has_metadata = false; |
| 678 | const char *name; |
677 | 679 | LinkApp *link; |
678 | 680 | |
679 | 681 | for (;;) { |
680 | 682 | string::size_type pos; |
681 | | const char *name; |
682 | 683 | int ret = opk_open_metadata(opk, &name); |
683 | 684 | if (ret < 0) { |
684 | 685 | ERROR("Error while loading meta-data\n"); |
... | ... | |
704 | 705 | if (!has_metadata) |
705 | 706 | break; |
706 | 707 | |
707 | | link = new LinkApp(gmenu2x, path.c_str(), opk); |
| 708 | link = new LinkApp(gmenu2x, path.c_str(), opk, name); |
708 | 709 | link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]); |
709 | 710 | |
710 | 711 | addSection(link->getCategory()); |