Logo Search packages:      
Sourcecode: q4wine version File versions  Download package

bool corelib::runWineBinary ( const ExecObject  execObj,
const QString  prefix_name,
bool  detach = true 
)

Prepare icon data for run wine.

Parameters:
ExecObject An icon data struct.
prefix_name Prefix name.
Returns:
Return true on success.

Definition at line 806 of file q4wine-lib.cpp.

References ExecObject::cmdargs, ExecObject::desktop, ExecObject::display, ExecObject::execcmd, ExecObject::nice, ExecObject::override, ExecObject::useconsole, ExecObject::winedebug, and ExecObject::wrkdir.

Referenced by runIcon().

                                                                                             {
            QString binary = QString("%1/bin/q4wine-helper").arg(APP_PREF);
            QStringList args;

            args.append("--prefix");
            args.append(prefix_name);

            if (execObj.nice>0){
                args.append("--nice");
                args.append(execObj.nice);
            }

            if (!execObj.desktop.isEmpty()){
                args.append("--desktop");
                args.append(execObj.desktop);
            }

            if (!execObj.override.isEmpty()){
                args.append("--override");
                args.append(execObj.override);
            }

            if (execObj.useconsole == "1"){
                args.append("--console");
                args.append(execObj.useconsole);
            }

            if (!execObj.winedebug.isEmpty()){
                args.append("--wine-debug");
                args.append(execObj.winedebug);
            }

            if (!execObj.display.isEmpty()){
                args.append("--display");
                args.append(execObj.display);
            }

            if (!execObj.cmdargs.isEmpty()){
                args.append("--program-args");
                args.append(execObj.cmdargs);
            }

            if (!execObj.execcmd.isEmpty()){
                args.append("--program-bin");
                args.append(execObj.execcmd);
            }

            QString wrkdir = execObj.wrkdir;

            if (wrkdir.isEmpty())
                wrkdir = QDir::homePath();

            args.append("--wrkdir");
            args.append(execObj.wrkdir);

#ifdef DEBUG
            qDebug()<<"[ii] corelib::runWineBinary: "<<binary<<args<<" at: "<<wrkdir;
#endif

            if (detach){
                QProcess proc(0);
                return proc.startDetached(binary, args, wrkdir);
            } else {
                Process proc(args, binary, wrkdir, QObject::tr("Running binary: \"%1\"").arg(execObj.execcmd), QObject::tr("Running binary..."), false);
                return proc.exec();
            }

            //--prefix %1").arg(prefix_name)

            //proc.se

            /*
            if (!checkFileExists(execObj.execcmd))
                return false;

            QStringList prefixList;
                  // 0   1     2             3            4            5          6            7
                  // id, path, wine_dllpath, wine_loader, wine_server, wine_exec, cdrom_mount, cdrom_drive
                  prefixList = db_prefix.getFieldsByPrefixId(execObj.prefixid);

                  QString exec;
                  QStringList args;
                  QString envargs;

                  if (execObj.useconsole == "1"){
                        // If we gona use console output, so exec program is program specificed at CONSOLE global variable
                        exec = this->getSetting("console", "bin").toString();

                        if (!this->getSetting("console", "args", false).toString().isEmpty()){
                              // If we have any conslope parametres, we gona preccess them one by one
                              QStringList cons_args = this->getSetting("console", "args", false).toString().split(" ");
                              for (int i=0; i<cons_args.count(); i++){
                                    if (!cons_args.at(i).isEmpty())
                                          args.append(cons_args.at(i));
                              }
                        }

                        args.append(this->getSetting("system", "sh").toString());

                  } else {
                        exec = this->getSetting("system", "sh").toString();
                  }

                  args.append("-c");


                  if ((execObj.useconsole == "1") && (!execObj.wrkdir.isNull())){
                        envargs.append(" cd '");
                        envargs.append(execObj.wrkdir);
                        envargs.append("' && ");
                  }

                  if (!prefixList.at(1).isEmpty()){
                        //If icon has prefix -- add to args
                        envargs.append(QString(" WINEPREFIX=\"%1\" ").arg(prefixList.at(1)));
                  } else {
                        //Else use default prefix
                        envargs.append(QString(" WINEPREFIX=\"%1/.wine\" ").arg(QDir::homePath()));
                  }

                  if (!prefixList.at(2).isEmpty()){
                        envargs.append(QString(" WINEDLLPATH=\"%1\" ").arg(prefixList.at(2)));
                  } else {
                        envargs.append(QString(" WINEDLLPATH=\"%1\" ").arg(this->getSetting("wine", "WineLibs").toString()));
                  }

                  if (!prefixList.at(3).isEmpty()){
                        envargs.append(QString(" WINELOADER=\"%1\" ").arg(prefixList.at(3)));
                  } else {
                        envargs.append(QString(" WINELOADER=\"%1\" ").arg(this->getSetting("wine", "LoaderBin").toString()));
                  }

                  if (!prefixList.at(4).isEmpty()){
                        envargs.append(QString(" WINESERVER=\"%1\" ").arg(prefixList.at(4)));
                  } else {
                        envargs.append(QString(" WINESERVER=\"%1\" ").arg(this->getSetting("wine", "ServerBin").toString()));
                  }

                  if (!execObj.override.isEmpty()){
                        envargs.append(QString(" WINEDLLOVERRIDES=\"%1\" ").arg(execObj.override));
                  }

                  if (!execObj.winedebug.isEmpty() && execObj.useconsole == "1"){
                        envargs.append(QString(" WINEDEBUG=\"%1\" ").arg(execObj.winedebug));
                  }

                  if (!execObj.display.isEmpty()){
                        envargs.append(QString(" DISPLAY=\"%1\" ").arg(execObj.display));
                  }

                  QString exec_string = "";

                  exec_string.append(envargs);
                  if(!execObj.nice.isEmpty()){
                        exec_string.append(this->getSetting("system", "nice").toString());
                        exec_string.append(" -n ");
                        exec_string.append(execObj.nice);
                  }

                  exec_string.append(" ");

                  if (!prefixList.at(5).isEmpty()){
                        exec_string.append(prefixList.at(5));
                  } else {
                        exec_string.append(this->getSetting("wine", "WineBin").toString());
                  }

                  exec_string.append(" ");

                  if (!execObj.desktop.isEmpty()){
                        exec_string.append(" explorer.exe /desktop=");
                        QString repl = execObj.name;
                        exec_string.append(repl.replace(" ", ""));
                        exec_string.append(",");
                        exec_string.append(execObj.desktop);
                  }

                  exec_string.append(" \"");
                  exec_string.append(execObj.execcmd);
                  exec_string.append("\" ");
            exec_string.append(this->getEscapeString(execObj.cmdargs, false));
                  if (execObj.useconsole != "1")
                        exec_string.append(" > /dev/null 2>&1");

                  args.append(exec_string);

#ifdef DEBUG
                  qDebug()<<"[ii] corelib::runWineBinary via ExecObj args: "<<exec<<args<<execObj.wrkdir;
#endif

                  QProcess proc;
                  return proc.startDetached( exec, args, execObj.wrkdir );
            */
            return false;
            }


Generated by  Doxygen 1.6.0   Back to index