{
QMap<QString, EmuFrontObject*> list;
QSqlQuery q;
- q.prepare("SELECT file.id, file.name, file.checksum, file.size "
+ q.prepare("SELECT file.id, file.name, file.size, file.checksum "
"FROM file INNER JOIN mediaimagecontainer_mediaimage "
"ON mediaimagecontainer_mediaimage.mediaimageid = file.id "
"WHERE mediaimagecontainer_mediaimage.mediaimagecontainerid = :micid ");
}
selectedImages << efo;
MediaImage *mi = dynamic_cast<MediaImage*>(efo);
- mediaImages.remove(mi->getCheckSum());
+ QString key = mi->getCheckSum();
+ mediaImages.remove(key);
}
- if (list.count() == mediaImages.count() && mediaImages.count() == 1) {
- // there should be only one media image left in mediaImages map
+ if (mediaImages.count() == 1) {
+ // there should be at least one media image left in mediaImages map
selectedImages << mediaImages.values().first();
}
}
if (selectedImages.count() < 1)
throw EmuFrontException(tr("No media images selected"));
- emuHelper->launch(exe, mediaImageContainers, selectedImages);
+ emuHelper->launch(exe, mediaImageContainers, selectedImages, list.count());
} catch (EmuFrontException efe) {
delete exe;
qDeleteAll(mediaImageContainers);
}
void EmuHelper::launch(const Executable * ex, QList<MediaImageContainer *> micList,
- QList<EmuFrontObject *> miList)
+ QList<EmuFrontObject *> miList, int mediaCount)
{
if (miList.count() < 1) {
throw EmuFrontException(tr("No media images available!"));
if (micList.count() < 1) {
throw EmuFrontException(tr("No media image containers available!"));
}
+
// extract the media image container to tmp folder
// (TODO: tmp folder configuration)
-
foreach(MediaImageContainer *mic, micList) {
QString fp;
fp.append(mic->getFilePath()->getName());
int ret = unzipHelper->extractAll(fp, "/tmp/");
if (ret) {
qDebug() << "Failed unzipping " << fp << ".";
- //throw EmuFrontException(tr("Unzip failed with %1.").arg(ret));
}
}
- // TODO: launch the 1st media image in the media image list of ex
- // or if emulator command options has a place for more than one
- // media image assign the media images in the list order
- // to emulator command line.
-
+ // fill in the media image slots in the command line options ($1, $2, ...)
QString opts = ex->getOptions();
- QString tmpfp = " \"/tmp/";
- // if only one media image placeholder -> TODO: if more placeholders e.g. $1 $2 ...
- tmpfp.append(miList.first()->getName()).append("\"");
- opts.replace("$1", tmpfp);
+ for(int i = 0; i < mediaCount && i < miList.size(); i++) {
+ QString tmpfp = " \"/tmp/";
+ tmpfp.append (miList.at(i)->getName());
+ tmpfp.append("\"");
+ opts.replace(QString("$%1").arg(i+1), tmpfp);
+ }
+
QString cmdWithParams;
cmdWithParams.append(ex->getExecutable());
cmdWithParams.append(" ").append(opts);
- // TODO: tmp will be set dynamically
- // TODO: assigning multiple media images
+
qDebug() << "Command with params " << cmdWithParams;
// Executable and MediaImageContainer / MediaImage objects are no more needed:
delete ex;
Q_OBJECT
public:
explicit EmuHelper(QObject *parent = 0);
- void launch(const Executable * ex, QList<MediaImageContainer *> micList, QList<EmuFrontObject*> miList);
+ void launch(const Executable * ex, QList<MediaImageContainer *> micList, QList<EmuFrontObject*> miList, int mediaCount = 1);
private slots:
void processError(QProcess::ProcessError);
void processFinished(int);