Example #1
0
bool PCloudApp::userLogged(binresult *userinfo, QByteArray &err, bool remember){
    if (isMounted()){
        setUser(userinfo, remember);
        return true;
    }
    else{
#ifdef Q_OS_WIN
        if (find_res(userinfo, "auth")){
            if (!settings->isSet("path") || !settings->get("path").toUtf8()[0]){
                QString path("a:");
                path[0] = getFirstFreeDevice();
                settings->set("path", path);
            }

            QString auth(find_res(userinfo, "auth")->str);
            if (remember){
                settings->set("auth", auth);
                this->authentication = auth;
            }
            else
                settings->set("auth", "");

            if (mountCmd(atol(settings->get("cachesize").toUtf8()),
                         auth.toUtf8(),
                         settings->geti("usessl"),
                         settings->get("path").toUtf8()[0], err)){
                Sleep(5*1000);
                setUser(userinfo, remember);
                return true;
            }
            return false;
        }
        else {
            err = "Invalid E-mail and Password combination.";
            return false;
        }
#else
        QProcess process;
        QStringList params;
#ifdef Q_OS_MAC
        params.append("-o");
        params.append("volname=pCloud");
        // Adding -o local may or may not be a good idea
        params.append("-o");
        params.append("local");
#endif
        params.append("--auth");
        params.append(find_res(userinfo, "auth")->str);
        if (settings->geti("usessl"))
            params.append("--ssl");
        params.append("--cache");
        params.append(settings->get("cachesize"));
        params.append(settings->get("path"));
#ifdef Q_OS_MAC
        process.start("/usr/local/bin/mount.pfs", params);
#else
        process.start("mount.pfs", params);
#endif
        if (!process.waitForFinished()){
            err="Error mounting filesystem.";
            return false;
        }
        if (process.exitCode()==0){
            setUser(userinfo, remember);
            return true;
        }
        else {
            err=process.readAllStandardError();
            return false;
        }
#endif
    }
}
Example #2
0
/* Take the ENML note and transform it into HTML that WebKit will
  not complain about */
QByteArray NoteFormatter::rebuildNoteHTML() {

    QLOG_DEBUG() << "Rebuilding Note: " << QString::fromStdString(note.guid) << " : " <<
                    QString::fromStdString(note.title);

    formatError = false;
    readOnly = false;

    // First try to read the document.  If it fails we need to clean it up
    content.append(QString::fromStdString(note.content));
    QDomDocument doc;
    QString emsg;
    bool goodReturn = doc.setContent(content, &emsg);

    if (!goodReturn) {
        QLOG_DEBUG() << "Error with initial document: " << emsg << " running through tidy";
        // Run it through "tidy".  It is a program which will fix any invalid XML
        // and give us the results back through stdout.  In a perfect world this
        // wouldn't be needed, but I've seen times where the ENML is bad for some reason.
        QProcess tidyProcess;
        tidyProcess.start("tidy -xml -raw -q -e", QIODevice::ReadWrite|QIODevice::Unbuffered);
        QLOG_DEBUG() << "Starting tidy " << tidyProcess.waitForStarted();
        QByteArray b;
        b.append(QString::fromStdString(note.content));
        tidyProcess.write(b);
        tidyProcess.closeWriteChannel();
        QLOG_DEBUG() << "Stopping tidy " << tidyProcess.waitForFinished() << " Return Code: " << tidyProcess.state();
        QLOG_DEBUG() << "Tidy Errors:" << tidyProcess.readAllStandardError();
        content = tidyProcess.readAllStandardOutput();

        // If the content is null, then we had a problem.  Just risk going forward without tidy cleanup
        if (content.size() == 0)
            content = b;
        doc.setContent(content);
    }
    QLOG_DEBUG() << doc.toString();
    // Remove all the temporary file names
    tempFiles.clear();
    modifyTags(doc);

    // If we have search criteria, then do the highlighting
    if (enableHighlight)
        doc = addHighlight(doc);

    // Finish up and return the HTML to the user
    QDomElement docElem = doc.documentElement();
    docElem.setTagName("body");
    content = doc.toByteArray(3);
        qint32 index = content.indexOf("<body");
    content.remove(0,index);
    content.prepend("<style type=\"text/css\">.en-crypt-temp { border-collapse:collapse; border-style:solid; border-color:blue; padding:0.0mm 0.0mm 0.0mm 0.0mm; }</style>");
    content.prepend("<style type=\"text/css\">en-hilight { background-color: rgb(255,255,0) }</style>");
    content.prepend("<style> img { height:auto; width:auto; max-height:auto; max-width:100%; }</style>");
    content.prepend("<head><meta http-equiv=\"content-type\" content=\"text-html; charset=utf-8\"></head>");
    content.prepend("<html>");
    content.append("</html>");

    if (!formatError && !readOnly) {
        NotebookTable ntable;
        qint32 notebookLid = ntable.getLid(note.notebookGuid);
        if (ntable.isReadOnly(notebookLid))
            readOnly = true;
    }
    if (note.__isset.active && !note.active)
        readOnly = true;
    return content;
}
Example #3
0
int ctkDICOMApplicationTest1(int argc, char * argv []) {
  
  QApplication app(argc, argv);
  QTextStream out(stdout);

  if ( argc < 10 )
  {
    out << "ERROR: invalid arguments.  Should be:\n";
    out << " ctkDICOMApplicationTest1 <dcmqrscp> <configfile> <dicomData1> <dcmData2> <storescu> <ctkDICOMQuery> <ctkDICOMRetrieve> <retrieveDirectory>\n";
    return EXIT_FAILURE;
  }

  QString dcmqrscp_exe  (argv[1]);
  QString dcmqrscp_cfg  (argv[2]);
  QString dicomData1  (argv[3]);
  QString dicomData2  (argv[4]);
  QString storescu_exe  (argv[5]);
  QString ctkDICOMQuery_exe  (argv[6]);
  QString ctkDICOMQuery_db_file  (argv[7]);
  QString ctkDICOMRetrieve_exe  (argv[8]);
  QString ctkDICOMRetrieve_directory  (argv[9]);

  //
  // first, start the server process
  //

  QProcess *dcmqrscp = new QProcess(0);
  QStringList dcmqrscp_args;
  dcmqrscp_args << "--config" << dcmqrscp_cfg;
  dcmqrscp_args << "--debug" << "--verbose";
  dcmqrscp_args << "11112";

  try
  {
    out << "starting server" << dcmqrscp_exe << "\n";
    out << "with args " << dcmqrscp_args.join(" ") << "\n";
    dcmqrscp->start(dcmqrscp_exe, dcmqrscp_args);
    dcmqrscp->waitForStarted();
  }
  catch (std::exception e)
  {
    out << "ERROR: could not start server" << e.what();
    return EXIT_FAILURE;
  }


  //
  // now push some dicom data in using storescp
  //

  QProcess *storescu = new QProcess(0);
  QStringList storescu_args;
  storescu_args << "-aec" << "CTK_AE";
  storescu_args << "-aet" << "CTK_AE";
  storescu_args << "localhost" << "11112";
  storescu_args << dicomData1;
  storescu_args << dicomData2;

  try
  {
    out << "running client" << storescu_exe << "\n";
    out << "with args" << storescu_args.join(" ") << "\n";
    storescu->start(storescu_exe, storescu_args);
    storescu->waitForFinished();
    out << "storescu Finished.\n";
    out << "Standard Output:\n";
    out << storescu->readAllStandardOutput();
    out << "Standard Error:\n";
    out << storescu->readAllStandardError();
  }
  catch (std::exception e)
  {
    out << "ERROR: could not start client" << e.what();
    return EXIT_FAILURE;
  }

  //
  // now query the server to see if the data arrived okay
  // - our database file will be updated with metadata from the query
  //

  QProcess *ctkDICOMQuery = new QProcess(0);
  QStringList ctkDICOMQuery_args;
  ctkDICOMQuery_args << ctkDICOMQuery_db_file;
  ctkDICOMQuery_args << "CTK_AE" << "CTK_AE";
  ctkDICOMQuery_args << "localhost" << "11112";

  try
  {
    out << "running client" << ctkDICOMQuery_exe << "\n";
    out << "with args" << ctkDICOMQuery_args.join(" ") << "\n";
    ctkDICOMQuery->start(ctkDICOMQuery_exe, ctkDICOMQuery_args);
    ctkDICOMQuery->waitForFinished();
    out << "ctkDICOMQuery Finished.\n";
    out << "Standard Output:\n";
    out << ctkDICOMQuery->readAllStandardOutput();
    out << "Standard Error:\n";
    out << ctkDICOMQuery->readAllStandardError();
  }
  catch (std::exception e)
  {
    out << "ERROR: could not start client" << e.what();
    return EXIT_FAILURE;
  }


  //
  // now do a retrieve into our download directory
  //

  // this is the study id of the dicom files we load from CTKData
  QString studyUID("1.2.840.113619.2.135.3596.6358736.5118.1115807980.182");

  QProcess *ctkDICOMRetrieve = new QProcess(0);
  QStringList ctkDICOMRetrieve_args;
  ctkDICOMRetrieve_args << studyUID;
  ctkDICOMRetrieve_args << ctkDICOMRetrieve_directory;
  ctkDICOMRetrieve_args << "CTK_AE" << "11113";
  ctkDICOMRetrieve_args << "CTK_AE";
  ctkDICOMRetrieve_args << "localhost" << "11112" << "CTK_CLIENT_AE";

  try
  {
    out << "running client" << ctkDICOMRetrieve_exe << "\n";
    out << "with args" << ctkDICOMRetrieve_args.join(" ") << "\n";
    ctkDICOMRetrieve->start(ctkDICOMRetrieve_exe, ctkDICOMRetrieve_args);
    ctkDICOMRetrieve->waitForFinished();
    out << "ctkDICOMRetrieve Finished.\n";
    out << "Standard Output:\n";
    out << ctkDICOMRetrieve->readAllStandardOutput();
    out << "Standard Error:\n";
    out << ctkDICOMRetrieve->readAllStandardError();
  }
  catch (std::exception e)
  {
    out << "ERROR: could not start client" << e.what();
    return EXIT_FAILURE;
  }


  //
  // clients are finished, not kill server and print output
  //
  try
  {
    dcmqrscp->kill();
    dcmqrscp->waitForFinished();
    out << "dcmqrscp Finished.\n";
    out << "Standard Output:\n";
    out << dcmqrscp->readAllStandardOutput();
    out << "Standard Error:\n";
    out << dcmqrscp->readAllStandardError();
  }
  catch (std::exception e)
  {
    out << "ERROR: could not start client" << e.what();
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}
Example #4
0
void KeyCreator::accept()
{
    // Validate data:

    if (editStorePass1->text().length() < 6) {
        emit warning(NULL, tr("Password must be at least 6 characters."));
        editStorePass1->setFocus();
        editStorePass1->selectAll();
        return;
    }

    if (editStorePass1->text() != editStorePass2->text()) {
        emit warning(NULL, tr("Passwords do not match."));
        editStorePass2->setFocus();
        editStorePass2->selectAll();
        return;
    }

    if (editAlias->text().isEmpty()) {
        emit warning(NULL, tr("Enter alias name."));
        editAlias->setFocus();
        editAlias->selectAll();
        return;
    }

    if (editAliasPass1->text() != editAliasPass2->text()) {
        emit warning(NULL, tr("Passwords do not match."));
        editAliasPass2->setFocus();
        editAliasPass2->selectAll();
        return;
    }

    if (editAliasPass1->text().length() < 6) {
        emit warning(NULL, tr("Password must be at least 6 characters."));
        editAliasPass1->setFocus();
        editAliasPass1->selectAll();
        return;
    }

    // Create KeyStore and Alias:

    const QString FILENAME = QFileDialog::getSaveFileName(this, NULL, NULL, "KeyStore (*.keystore)");
    if (FILENAME.isEmpty()) {
        return;
    }
    qDebug() << "Creating KeyStore...";
    const QString ENV_PATH = qgetenv("PATH");
    const QString JAVA_HOME = qgetenv("JAVA_HOME");
    const QString KEYTOOL_CMD =
            QString("keytool -genkeypair -v -keystore \"%1\" -storepass \"%10\""
                    " -alias \"%2\" -keyalg RSA -keysize 2048"
                    " -dname \"CN=%3, OU=%4, O=%5, L=%6, S=%7, C=%8\""
                    " -validity %9 -keypass \"%11\"")
                        .arg(FILENAME)
                        .arg(editAlias->text())
                        .arg(editName->text())
                        .arg(editUnit->text())
                        .arg(editOrgan->text())
                        .arg(editCity->text())
                        .arg(editState->text())
                        .arg(editCountry->text())
                        .arg(editYears->text().toInt() * 365);
    qputenv("PATH", ENV_PATH.toStdString().c_str());
    qputenv("PATH", QString("%1;%2/bin").arg(ENV_PATH, JAVA_HOME).toStdString().c_str());
    qDebug() << qPrintable(KEYTOOL_CMD.arg("*****", "*****"));
    QProcess p;
    p.start(KEYTOOL_CMD.arg(editStorePass1->text(), editAliasPass1->text()));
    qputenv("PATH", ENV_PATH.toStdString().c_str());

    if (p.waitForStarted(-1)) {
        p.waitForFinished(10000);
        if (p.exitCode() != 0) {
            QString error_text = p.readAllStandardError().trimmed();
            if (error_text.isEmpty()) error_text = p.readAllStandardOutput().trimmed();
            qDebug() << qPrintable(QString("Keytool exit code: %1").arg(p.exitCode()));
            qDebug() << error_text;
            emit warning("Keytool", tr("%1: invalid parameters").arg("Keytool"));
            return;
        }
    }
    else {
        const QString ERROR_TEXT = tr("Error starting %1.\n"
                                      "Check your JDK installation and "
                                      "PATH environment variable.").arg("Keytool");
        emit error("Keytool", ERROR_TEXT);
        return;
    }
    qDebug() << "Done.\n";
    emit success("Keytool", tr("KeyStore successfully created/updated!"));
    emit created(FILENAME);
    clear();
    QDialog::accept();
}
QString CQuazaaSysInfo::osVersionToString()
{
	QString operatingSystemString = "";

#if defined(Q_OS_WIN)
	QString sVersion;
	QString sEdition;
	QString sServicePack;
	QString sMachine;

	switch(GetWindowsVersion())
	{
	case WindowsVersion::Windows:
		sVersion = "Windows";
		break;
	case WindowsVersion::Windows32s:
		sVersion = "Windows 32s";
		break;
	case WindowsVersion::Windows95:
		sVersion = "Windows 95";
		break;
	case WindowsVersion::Windows95OSR2:
		sVersion = "Windows 95 SR2";
		break;
	case WindowsVersion::Windows98:
		sVersion = "Windows 98";
		break;
	case WindowsVersion::Windows98SE:
		sVersion = "Windows 98 SE";
		break;
	case WindowsVersion::WindowsMillennium:
		sVersion = "Windows Me";
		break;
	case WindowsVersion::WindowsNT351:
		sVersion = "Windows NT 3.51";
		break;
	case WindowsVersion::WindowsNT40:
		sVersion = "Windows NT 4.0";
		break;
	case WindowsVersion::WindowsNT40Server:
		sVersion = "Windows NT 4.0 Server";
		break;
	case WindowsVersion::Windows2000:
		sVersion = "Windows 2000";
		break;
	case WindowsVersion::WindowsXP:
		sVersion = "Windows XP";
		break;
	case WindowsVersion::WindowsXPProfessionalx64:
		sVersion = "Windows XP Professional x64";
		break;
	case WindowsVersion::WindowsHomeServer:
		sVersion = "Windows Home Server";
		break;
	case WindowsVersion::WindowsServer2003:
		sVersion = "Windows Server 2003";
		break;
	case WindowsVersion::WindowsServer2003R2:
		sVersion = "Windows Server 2003 R2";
		break;
	case WindowsVersion::WindowsVista:
		sVersion = "Windows Vista";
		break;
	case WindowsVersion::WindowsServer2008:
		sVersion = "Windows Server 2008";
		break;
	case WindowsVersion::WindowsServer2008R2:
		sVersion = "Windows Server 2008 R2";
		break;
	case WindowsVersion::Windows7:
		sVersion = "Windows 7";
		break;
	case WindowsVersion::WindowsServer2012:
		sVersion = "Windows Server 2012";
		break;
	case WindowsVersion::Windows8:
		sVersion = "Windows 8";
		break;
	default:
		sVersion = "Unknown Windows Version";
		break;
	}

	switch(GetWindowsEdition())
	{
	case WindowsEdition::EditionUnknown:
		sEdition = "Unknown Edition";
		break;
	case WindowsEdition::Workstation:
		sEdition = "Workstation";
		break;
	case WindowsEdition::Server:
		sEdition = "Server";
		break;
	case WindowsEdition::AdvancedServer:
		sEdition = "Advanced Server";
		break;
	case WindowsEdition::Home:
		sEdition = "Home";
		break;
	case WindowsEdition::Ultimate:
		sEdition = "Ultimate";
		break;
	case WindowsEdition::HomeBasic:
		sEdition = "Home Basic";
		break;
	case WindowsEdition::HomePremium:
		sEdition = "Home Premium";
		break;
	case WindowsEdition::Enterprise:
		sEdition = "Enterprise";
		break;
	case WindowsEdition::HomeBasicN:
		sEdition = "Home Basic N";
		break;
	case WindowsEdition::Business:
		sEdition = "Business";
		break;
	case WindowsEdition::StandardServer:
		sEdition = "Server Standard";
		break;
	case WindowsEdition::DatacenterServer:
		sEdition = "Server Datacenter (full installation)";
		break;
	case WindowsEdition::SmallBusinessServer:
		sEdition = "Small Business Server";
		break;
	case WindowsEdition::EnterpriseServer:
		sEdition = "Server Enterprise (full installation)";
		break;
	case WindowsEdition::Starter:
		sEdition = "Starter";
		break;
	case WindowsEdition::DatacenterServerCore:
		sEdition = "Server Datacenter (core installation)";
		break;
	case WindowsEdition::StandardServerCore:
		sEdition = "Server Standard (core installation)";
		break;
	case WindowsEdition::EnterpriseServerCore:
		sEdition = "Server Enterprise (core installation)";
		break;
	case WindowsEdition::EnterpriseServerIA64:
		sEdition = "Server Enterprise for Itanium-based Systems";
		break;
	case WindowsEdition::BusinessN:
		sEdition = "Business N";
		break;
	case WindowsEdition::WebServer:
		sEdition = "Web Server (full installation)";
		break;
	case WindowsEdition::ClusterServer:
		sEdition = "High Performance Computing Edition";
		break;
	case WindowsEdition::HomeServer:
		sEdition = "Storage Server 2008 R2 Essentials";
		break;
	case WindowsEdition::StorageExpressServer:
		sEdition = "Storage Server Express";
		break;
	case WindowsEdition::StorageStandardServer:
		sEdition = "Storage Server Standard";
		break;
	case WindowsEdition::StorageWorkgroupServer:
		sEdition = "Storage Server Workgroup";
		break;
	case WindowsEdition::StorageEnterpriseServer:
		sEdition = "Storage Server Enterprise";
		break;
	case WindowsEdition::ServerForSmallBusiness:
		sEdition = "for Windows Essential Server Solutions";
		break;
	case WindowsEdition::SmallBusinessServerPremium:
		sEdition = "Small Business Server Premium";
		break;
	case WindowsEdition::HomePremiumN:
		sEdition = "Home Premium N";
		break;
	case WindowsEdition::EnterpriseN:
		sEdition = "Enterprise N";
		break;
	case WindowsEdition::UltimateN:
		sEdition = "Ultimate N";
		break;
	case WindowsEdition::WebServerCore:
		sEdition = "Web Server (core installation)";
		break;
	case WindowsEdition::MediumBusinessServerManagement:
		sEdition = "Essential Business Server Management Server";
		break;
	case WindowsEdition::MediumBusinessServerSecurity:
		sEdition = "Essential Business Server Security Server";
		break;
	case WindowsEdition::MediumBusinessServerMessaging:
		sEdition = "Essential Business Server Messaging Server";
		break;
	case WindowsEdition::ServerFoundation:
		sEdition = "Server Foundation";
		break;
	case WindowsEdition::HomePremiumServer:
		sEdition = "Home Server 2011";
		break;
	case WindowsEdition::ServerForSmallBusinessV:
		sEdition = "without Hyper-V for Windows Essential Server Solutions";
		break;
	case WindowsEdition::StandardServerV:
		sEdition = "Server Standard without Hyper-V";
		break;
	case WindowsEdition::DatacenterServerV:
		sEdition = "Server Datacenter without Hyper-V (full installation)";
		break;
	case WindowsEdition::EnterpriseServerV:
		sEdition = "Server Enterprise without Hyper-V (full installation)";
		break;
	case WindowsEdition::DatacenterServerCoreV:
		sEdition = "Server Datacenter without Hyper-V (core installation)";
		break;
	case WindowsEdition::StandardServerCoreV:
		sEdition = "Server Standard without Hyper-V (core installation)";
		break;
	case WindowsEdition::EnterpriseServerCoreV:
		sEdition = "Server Enterprise without Hyper-V (core installation) ";
		break;
	case WindowsEdition::HyperV:
		sEdition = "Hyper-V Server";
		break;
	case WindowsEdition::StorageExpressServerCore:
		sEdition = "Storage Express Server Core";
		break;
	case WindowsEdition::StorageStandardServerCore:
		sEdition = "Storage Standard Server Core";
		break;
	case WindowsEdition::StorageWorkgroupServerCore:
		sEdition = "Storage Workgroup Server Core";
		break;
	case WindowsEdition::StorageEnterpriseServerCore:
		sEdition = "Storage Enterprise Server Core";
		break;
	case WindowsEdition::StarterN:
		sEdition = "Starter N";
		break;
	case WindowsEdition::Professional:
		sEdition = "Professional";
		break;
	case WindowsEdition::ProfessionalN:
		sEdition = "Professional N";
		break;
	case WindowsEdition::SBSolutionServer:
		sEdition = "Windows Small Business Server 2011 Essentials";
		break;
	case WindowsEdition::ServerForSBSolutions:
		sEdition = "Server For Small Business Solutions";
		break;
	case WindowsEdition::StandardServerSolutions:
		sEdition = "Server Solutions Premium";
		break;
	case WindowsEdition::StandardServerSolutionsCore:
		sEdition = "Server Solutions Premium (core installation)";
		break;
	case WindowsEdition::SBSolutionServerEM:
		sEdition = "Server For Small Business Solutions EM";
		break;
	case WindowsEdition::ServerForSBSolutionsEM:
		sEdition = "Server For Small Business Solutions EM";
		break;
	case WindowsEdition::SolutionEmbeddedServer:
		sEdition = "MultiPoint Server";
		break;
	case WindowsEdition::SolutionEmbeddedServerCore:
		sEdition = "MultiPoint Server (core installation)";
		break;
	case WindowsEdition::EssentialBusinessServerMGMT:
		sEdition = "Essential Server Solution Management";
		break;
	case WindowsEdition::EssentialBusinessServerADDL:
		sEdition = "Essential Server Solution Additional";
		break;
	case WindowsEdition::EssentialBusinessServerMGMTSVC:
		sEdition = "Essential Server Solution Management Service";
		break;
	case WindowsEdition::EssentialBusinessServerADDLSVC:
		sEdition = "Essential Server Solution Additional Service";
		break;
	case WindowsEdition::SmallBusinessServerPremiumCore:
		sEdition = "Small Business Server Premium (core installation)";
		break;
	case WindowsEdition::ClusterServerV:
		sEdition = "Server Hyper Core V";
		break;
	case WindowsEdition::Embedded:
		sEdition = "Embedded Standard";
		break;
	case WindowsEdition::StarterE:
		sEdition = "Starter E";
		break;
	case WindowsEdition::HomeBasicE:
		sEdition = "Home Basic E";
		break;
	case WindowsEdition::HomePremiumE:
		sEdition = "Home Premium E";
		break;
	case WindowsEdition::ProfessionalE:
		sEdition = "Professional E";
		break;
	case WindowsEdition::EnterpriseE:
		sEdition = "Enterprise E";
		break;
	case WindowsEdition::UltimateE:
		sEdition = "Ultimate E";
		break;
	case WindowsEdition::EnterpriseEvaluation:
		sEdition = "Server Enterprise (evaluation installation)";
		break;
	case WindowsEdition::MultipointStandardServer:
		sEdition = "MultiPoint Server Standard (full installation)";
		break;
	case WindowsEdition::MultipointPremiumServer:
		sEdition = "MultiPoint Server Premium (full installation)";
		break;
	case WindowsEdition::StandardEvaluationServer:
		sEdition = "Server Standard (evaluation installation)";
		break;
	case WindowsEdition::DatacenterEvaluationServer:
		sEdition = "Server Datacenter (evaluation installation)";
		break;
	case WindowsEdition::EnterpriseNEvaluation:
		sEdition = "Enterprise N (evaluation installation)";
		break;
	case WindowsEdition::StorageWorkgroupEvaluationServer:
		sEdition = "Storage Server Workgroup (evaluation installation)";
		break;
	case WindowsEdition::StorageStandardEvaluationServer:
		sEdition = "Storage Server Standard (evaluation installation)";
		break;
	case WindowsEdition::CoreN:
		sEdition = "Core N";
		break;
	case WindowsEdition::CoreCountrySpecific:
		sEdition = "Core China";
		break;
	case WindowsEdition::CoreSingleLanguage:
		sEdition = "Core Single Language";
		break;
	case WindowsEdition::Core:
		sEdition = "Core";
		break;
	case WindowsEdition::ProfessionalWindowsMediaCenter:
		sEdition = "Professional Windows Media Center";
		break;
	default:
		sEdition = "Unknown Edition";
	}

	sServicePack = GetServicePackInfo();

	if(Is64bitPlatform())
		sMachine = "64-bit";
	else
		sMachine = "32-bit";

	operatingSystemString = QString(sVersion + " ");
	if(!sEdition.isEmpty())
		operatingSystemString.append(sEdition + " ");
	if(!sServicePack.isEmpty())
		operatingSystemString.append(tr("with %1 ").arg(sServicePack));
	operatingSystemString.append(sMachine);

#elif defined(Q_OS_MAC)
	switch ( QSysInfo::MacintoshVersion ) {
		case QSysInfo::MV_9 :
			operatingSystemString = "Mac OS 9 (unsupported)";
			break;
		case QSysInfo::MV_10_0 :
			operatingSystemString = "Mac OS X 10.0 Cheetah (unsupported)";
			break;
		case QSysInfo::MV_10_1 :
			operatingSystemString = "Mac OS X 10.1 Puma (unsupported)";
			break;
		case QSysInfo::MV_10_2 :
			operatingSystemString = "Mac OS X 10.2 Jaguar (unsupported)";
			break;
		case QSysInfo::MV_10_3 :
			operatingSystemString = "Mac OS X 10.3 Panther";
			break;
		case QSysInfo::MV_10_4 :
			operatingSystemString = "Mac OS X 10.4 Tiger";
			break;
		case QSysInfo::MV_10_5 :
			operatingSystemString = "Mac OS X 10.5 Leopard";
			break;
		case QSysInfo::MV_10_6 :
			operatingSystemString = "Mac OS X 10.6 Snow Leopard";
			break;
		case QSysInfo::MV_10_7 :
			operatingSystemString = "Mac OS X 10.7 Lion";
			break;
		case QSysInfo::MV_10_8 :
			operatingSystemString = "Mac OS X 10.8 Mountain Lion";
			break;
		case QSysInfo::MV_10_9 :
			operatingSystemString = "Mac OS X 10.9 Mavericks";
			break;
		case QSysInfo::MV_Unknown :
			operatingSystemString = "An unknown and currently unsupported Mac platform";
			break;
		default :
			operatingSystemString = "Unknown Mac operating system.";
			break;
	}
#else
	//TODO: Detect Unix, Linux etc. distro as described on http://www.novell.com/coolsolutions/feature/11251.html
	operatingSystemString = "Linux";
	QProcess process;
	process.start("uname -s");
	bool result = process.waitForFinished(1000);
	QString os = process.readAllStandardOutput().trimmed();

	process.start("uname -r");
	result = process.waitForFinished(1000);
	QString rev = process.readAllStandardOutput().trimmed();

	process.start("uname -m");
	result = process.waitForFinished(1000);
	QString mach = process.readAllStandardOutput().trimmed();

	if ( os == "SunOS" ) {
		os = "Solaris";

		process.start("uname -p");
		result = process.waitForFinished(1000);
		QString arch = process.readAllStandardOutput().trimmed();

		process.start("uname -v");
		result = process.waitForFinished(1000);
		QString timestamp = process.readAllStandardOutput().trimmed();

		operatingSystemString = os + " " + rev + " (" + arch + " " + timestamp + ")";
	}
	else if ( os == "AIX" ) {
		process.start("oslevel -r");
		result = process.waitForFinished(1000);
		QString oslevel = process.readAllStandardOutput().trimmed();

		operatingSystemString = os + "oslevel " + oslevel;
	}
	else if ( os == "Linux" ) {
		QString dist;
		QString pseudoname;
		QString kernel = rev;

		if ( QFile::exists("/etc/SUSE-release") ) {
			process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' '| sed s/VERSION.*//\"");
			result = process.waitForFinished(1000);
			dist = process.readAllStandardOutput().trimmed();

			process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' ' | sed s/.*=\\ //\"");
			result = process.waitForFinished(1000);
			rev = process.readAllStandardOutput().trimmed();
		}
		else if ( QFile::exists("/etc/mandrake-release") ) {
			dist = "Mandrake";

			process.start("sh -c \"cat /etc/mandrake-release | sed s/.*\\(// | sed s/\\)//\"");
			result = process.waitForFinished(1000);
			pseudoname = process.readAllStandardOutput().trimmed();

			process.start("sh -c \"cat /etc/mandrake-release | sed s/.*release\\ // | sed s/\\ .*//\"");
			result = process.waitForFinished(1000);
			rev = process.readAllStandardOutput().trimmed();
		}
		else if ( QFile::exists("/etc/lsb-release") ) {
			dist = "Ubuntu";

			QString processCall = "sh -c \"cat /etc/lsb-release | grep --max-count=1 DISTRIB_RELEASE=\"";
			process.start( processCall );
			result = process.waitForFinished(1000);
			rev = process.readAllStandardOutput().trimmed();
			qDebug() << "revision:" << rev;
			if(!rev.isEmpty())
			{
				rev.remove("DISTRIB_RELEASE=");
				rev.remove("\"");
			}
			QString errorStr = process.readAllStandardError();

			process.start("sh -c \"cat /etc/lsb-release | grep --max-count=1 DISTRIB_CODENAME=\"");
			result = process.waitForFinished(1000);
			pseudoname = process.readAllStandardOutput().trimmed();
			qDebug() << "pseudoname:" << pseudoname;
			if(!pseudoname.isEmpty())
			{
				pseudoname.remove("DISTRIB_CODENAME=");
				pseudoname.remove("\"");
			}
	   }
			else if ( QFile::exists("/etc/debian_version") ) {
			dist = "Debian";

			process.start("cat /etc/debian_version");
			result = process.waitForFinished(1000);
			dist += process.readAllStandardOutput().trimmed();

			rev = "";
		}

		if ( QFile::exists("/etc/UnitedLinux-release") ) {
			process.start("sh -c \"cat /etc/UnitedLinux-release | grep --max-count=1 \"VERSION = \"\"");
			result = process.waitForFinished(1000);
			dist += process.readAllStandardOutput().trimmed();
			if(!dist.isEmpty())
			{
				dist.remove("VERSION = ");
				dist.remove("\"");
			}
		}


		if ( QFile::exists("/etc/os-release") ) { //This file makes distribution identification much easier.
			process.start("sh -c \"cat /etc/os-release | grep --max-count=1 PRETTY_NAME=\"");
			result = process.waitForFinished(1000);
			QString distname = process.readAllStandardOutput().trimmed();
			if(!distname.isEmpty())
			{
				distname.remove("PRETTY_NAME=");
				distname.remove("\"");

				dist = distname;
				pseudoname = "";
			}
		}

		operatingSystemString = os;
		if(!dist.isEmpty())
			operatingSystemString.append(" " + dist);
		if(!rev.isEmpty())
			operatingSystemString.append(" " + rev);
		operatingSystemString.append(" (");
		if(!pseudoname.isEmpty())
			operatingSystemString.append(pseudoname + " ");
		if(!kernel.isEmpty())
			operatingSystemString.append(kernel + " ");
		operatingSystemString.append(mach + ")");
	}
#endif

	return operatingSystemString;
}
Example #6
0
void QgsGPSPlugin::uploadToGPS( QgsVectorLayer* gpxLayer, const QString& device,
                                const QString& port )
{
  const QString& source( gpxLayer->dataProvider()->dataSourceUri() );

  // what kind of data does the user want to upload?
  QString typeArg, features;
  if ( source.right( 8 ) == "waypoint" )
  {
    typeArg = "-w";
    features = "waypoints";
  }
  else if ( source.right( 5 ) == "route" )
  {
    typeArg = "-r";
    features = "routes";
  }
  else if ( source.right( 5 ) == "track" )
  {
    typeArg = "-t";
    features = "tracks";
  }
  else
  {
    QgsDebugMsg( source.right( 8 ) );
    assert( false );
  }

  // try to start the gpsbabel process
  QStringList babelArgs =
    mDevices[device]->exportCommand( mBabelPath, typeArg,
                                     source.left( source.lastIndexOf( '?' ) ), port );
  if ( babelArgs.isEmpty() )
  {
    QMessageBox::warning( nullptr, tr( "Not supported" ),
                          tr( "This device does not support uploading of %1." )
                          .arg( features ) );
    return;
  }

  QgsDebugMsg( QString( "Upload command: " ) + babelArgs.join( "|" ) );

  QProcess babelProcess;
  babelProcess.start( babelArgs.join( " " ) );
  if ( !babelProcess.waitForStarted() )
  {
    QMessageBox::warning( nullptr, tr( "Could not start process" ),
                          tr( "Could not start GPSBabel!" ) );
    return;
  }

  // wait for gpsbabel to finish (or the user to cancel)
  QProgressDialog progressDialog( tr( "Uploading data..." ), tr( "Cancel" ), 0, 0 );
  progressDialog.setWindowModality( Qt::WindowModal );
  for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
  {
    progressDialog.setValue( i / 64 );
    if ( progressDialog.wasCanceled() )
      return;
  }

  // did we get an error?
  if ( babelProcess.exitStatus() != 0 )
  {
    QString babelError( babelProcess.readAllStandardError() );
    QString errorMsg( tr( "Error while uploading data to GPS!\n\n" ) );
    errorMsg += babelError;
    QMessageBox::warning( nullptr, tr( "Error uploading data" ), errorMsg );
    return;
  }

  // everything was OK, remember this device for next time
  QSettings settings;
  settings.setValue( "/Plugin-GPS/lastuldevice", device );
  settings.setValue( "/Plugin-GPS/lastulport", port );

  emit closeGui();
}
Example #7
0
void QgsGPSPlugin::downloadFromGPS( const QString& device, const QString& port,
                                    bool downloadWaypoints, bool downloadRoutes,
                                    bool downloadTracks, const QString& outputFileName,
                                    const QString& layerName )
{
  // what does the user want to download?
  QString typeArg, features;
  if ( downloadWaypoints )
  {
    typeArg = "-w";
    features = "waypoints";
  }
  else if ( downloadRoutes )
  {
    typeArg = "-r";
    features = "routes";
  }
  else if ( downloadTracks )
  {
    typeArg = "-t";
    features = "tracks";
  }

  // try to start the gpsbabel process
  QStringList babelArgs =
    mDevices[device]->importCommand( mBabelPath, typeArg,
                                     port, outputFileName );
  if ( babelArgs.isEmpty() )
  {
    QMessageBox::warning( nullptr, tr( "Not supported" ),
                          tr( "This device does not support downloading of %1." )
                          .arg( features ) );
    return;
  }

  QgsDebugMsg( QString( "Download command: " ) + babelArgs.join( "|" ) );

  QProcess babelProcess;
  babelProcess.start( babelArgs.join( " " ) );
  if ( !babelProcess.waitForStarted() )
  {
    QMessageBox::warning( nullptr, tr( "Could not start process" ),
                          tr( "Could not start GPSBabel!" ) );
    return;
  }

  // wait for gpsbabel to finish (or the user to cancel)
  QProgressDialog progressDialog( tr( "Downloading data..." ), tr( "Cancel" ), 0, 0 );
  progressDialog.setWindowModality( Qt::WindowModal );
  for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
  {
    progressDialog.setValue( i / 64 );
    if ( progressDialog.wasCanceled() )
      return;
  }

  // did we get any data?
  if ( babelProcess.exitStatus() != 0 )
  {
    QString babelError( babelProcess.readAllStandardError() );
    QString errorMsg( tr( "Could not download data from GPS!\n\n" ) );
    errorMsg += babelError;
    QMessageBox::warning( nullptr, tr( "Error downloading data" ), errorMsg );
    return;
  }

  // add the layer
  if ( downloadWaypoints )
    emit drawVectorLayer( outputFileName + "?type=waypoint",
                          layerName, "gpx" );
  if ( downloadRoutes )
    emit drawVectorLayer( outputFileName + "?type=route",
                          layerName, "gpx" );
  if ( downloadTracks )
    emit drawVectorLayer( outputFileName + "?type=track",
                          layerName, "gpx" );

  // everything was OK, remember the device and port for next time
  QSettings settings;
  settings.setValue( "/Plugin-GPS/lastdldevice", device );
  settings.setValue( "/Plugin-GPS/lastdlport", port );

  emit closeGui();
}
Example #8
0
void QgsGPSPlugin::convertGPSFile( const QString& inputFileName,
                                   int convertType,
                                   const QString& outputFileName,
                                   const QString& layerName )
{
  // what features does the user want to import?
  QStringList convertStrings;

  switch ( convertType )
  {
    case 0:
      convertStrings << "-x" << "transform,wpt=rte,del";
      break;
    case 1:
      convertStrings << "-x" << "transform,rte=wpt,del";
      break;
    case 2:
      convertStrings << "-x" << "transform,trk=wpt,del";
      break;
    case 3:
      convertStrings << "-x" << "transform,wpt=trk,del";
      break;
    default:
      QgsDebugMsg( "Illegal conversion index!" );
      return;
  }

  // try to start the gpsbabel process
  QStringList babelArgs;
  babelArgs << mBabelPath << "-i" << "gpx" << "-f" << QString( "\"%1\"" ).arg( inputFileName )
  << convertStrings << "-o" << "gpx" << "-F" << QString( "\"%1\"" ).arg( outputFileName );
  QgsDebugMsg( QString( "Conversion command: " ) + babelArgs.join( "|" ) );

  QProcess babelProcess;
  babelProcess.start( babelArgs.join( " " ) );
  if ( !babelProcess.waitForStarted() )
  {
    QMessageBox::warning( nullptr, tr( "Could not start process" ),
                          tr( "Could not start GPSBabel!" ) );
    return;
  }

  // wait for gpsbabel to finish (or the user to cancel)
  QProgressDialog progressDialog( tr( "Importing data..." ), tr( "Cancel" ), 0, 0 );
  progressDialog.setWindowModality( Qt::WindowModal );
  for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
  {
    progressDialog.setValue( i / 64 );
    if ( progressDialog.wasCanceled() )
      return;
  }

  // did we get any data?
  if ( babelProcess.exitStatus() != 0 )
  {
    QString babelError( babelProcess.readAllStandardError() );
    QString errorMsg( tr( "Could not convert data from %1!\n\n" )
                      .arg( inputFileName ) );
    errorMsg += babelError;
    QMessageBox::warning( nullptr, tr( "Error converting data" ), errorMsg );
    return;
  }

  // add the layer
  switch ( convertType )
  {
    case 0:
    case 3:
      emit drawVectorLayer( outputFileName + "?type=waypoint",
                            layerName, "gpx" );
      break;
    case 1:
      emit drawVectorLayer( outputFileName + "?type=route",
                            layerName, "gpx" );
      break;
    case 2:
      emit drawVectorLayer( outputFileName + "?type=track",
                            layerName, "gpx" );
      break;
    default:
      QgsDebugMsg( "Illegal conversion index!" );
      return;
  }

  emit closeGui();
}
Example #9
0
void QgsGPSPlugin::importGPSFile( const QString& inputFileName, QgsBabelFormat* importer,
                                  bool importWaypoints, bool importRoutes,
                                  bool importTracks, const QString& outputFileName,
                                  const QString& layerName )
{
  // what features does the user want to import?
  QString typeArg;
  if ( importWaypoints )
    typeArg = "-w";
  else if ( importRoutes )
    typeArg = "-r";
  else if ( importTracks )
    typeArg = "-t";

  // try to start the gpsbabel process
  QStringList babelArgs =
    importer->importCommand( mBabelPath, typeArg,
                             inputFileName, outputFileName );

  QgsDebugMsg( QString( "Import command: " ) + babelArgs.join( "|" ) );

  QProcess babelProcess;
  babelProcess.start( babelArgs.join( " " ) );
  if ( !babelProcess.waitForStarted() )
  {
    QMessageBox::warning( nullptr, tr( "Could not start process" ),
                          tr( "Could not start GPSBabel!" ) );
    return;
  }

  // wait for gpsbabel to finish (or the user to cancel)
  QProgressDialog progressDialog( tr( "Importing data..." ), tr( "Cancel" ), 0, 0 );
  progressDialog.setWindowModality( Qt::WindowModal );
  for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
  {
    progressDialog.setValue( i / 64 );
    if ( progressDialog.wasCanceled() )
      return;
  }

  babelProcess.waitForFinished();

  // did we get any data?
  if ( babelProcess.exitCode() != 0 )
  {
    QString babelError( babelProcess.readAllStandardError() );
    QString errorMsg( tr( "Could not import data from %1!\n\n" )
                      .arg( inputFileName ) );
    errorMsg += babelError;
    QMessageBox::warning( nullptr, tr( "Error importing data" ), errorMsg );
    return;
  }

  // add the layer
  if ( importTracks )
    emit drawVectorLayer( outputFileName + "?type=track",
                          layerName, "gpx" );
  if ( importRoutes )
    emit drawVectorLayer( outputFileName + "?type=route",
                          layerName, "gpx" );
  if ( importWaypoints )
    emit drawVectorLayer( outputFileName + "?type=waypoint",
                          layerName, "gpx" );

  emit closeGui();
}
Example #10
0
void MarketSrcPackage::process()
{
  if (!m_Initialized)
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                              "package "+m_PackageFilename+" not initialized");

  if (!m_Downloaded)
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                              "package "+m_PackageFilename+" cannot be processed before download");

  if (!openfluid::utils::CMakeProxy::isAvailable())
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"CMake command not defined");


  std::string BuildConfigOptions = composeFullBuildOptions(getPackageType(), m_BuildConfigOptions);

  std::string BuildDir = m_TempBuildsDir + "/" + m_ID;
  std::string SrcInstallDir = getInstallPath() + "/" + m_ID;

  // creating installation dir
  if (openfluid::tools::Filesystem::isDirectory(SrcInstallDir))
    openfluid::tools::Filesystem::removeDirectory(SrcInstallDir);

  if (!openfluid::tools::Filesystem::makeDirectory(SrcInstallDir))
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                              "unable to create source directory for "+m_ID+" package");

  // creating build dir
  if (openfluid::tools::Filesystem::isDirectory(BuildDir))
    openfluid::tools::Filesystem::removeDirectory(BuildDir);

  if (!openfluid::tools::Filesystem::makeDirectory(BuildDir))
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                              "unable to create build directory for "+m_ID+" package");


  // == Building commands ==

  QString UntarCommand = openfluid::utils::CMakeProxy::getTarUncompressCommand(QString::fromStdString(SrcInstallDir),
                                                                               QString::fromStdString(m_PackageDest),
                                                                               "z");

  QString BuildConfigCommand =
      openfluid::utils::CMakeProxy::getConfigureCommand(QString::fromStdString(BuildDir),
                                                        QString::fromStdString(SrcInstallDir),
                                                        {},"",
                                                        {QString::fromStdString(BuildConfigOptions)});


  QString BuildCommand = openfluid::utils::CMakeProxy::getBuildCommand(QString::fromStdString(BuildDir));


  // uncompressing package
  {
    QProcess Untar;

    Untar.start(UntarCommand);
    Untar.waitForFinished(-1);
    Untar.waitForReadyRead(-1);

    appendToLogFile(QString(Untar.readAllStandardOutput()).toStdString());

    int RetValue = Untar.exitCode();

    if (RetValue != 0)
    {
      appendToLogFile(QString(Untar.readAllStandardError()).toStdString());
      throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                                "Error uncompressing sources package using CMake");
    }
  }

  // configuring the build
  {
    QProcess Config;

    Config.start(BuildConfigCommand);
    Config.waitForFinished(-1);
    Config.waitForReadyRead(-1);

    appendToLogFile(QString(Config.readAllStandardOutput()).toStdString());

    int RetValue = Config.exitCode();

    if (RetValue != 0)
    {
      appendToLogFile(QString(Config.readAllStandardError()).toStdString());
      throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                                "Error configuring package build using CMake");
    }
  }

  // building
  {
    QProcess Build;

    Build.start(BuildCommand);
    Build.waitForFinished(-1);
    Build.waitForReadyRead(-1);

    appendToLogFile(QString(Build.readAllStandardOutput()).toStdString());

    int RetValue = Build.exitCode();

    if (RetValue != 0)
    {
      appendToLogFile(QString(Build.readAllStandardError()).toStdString());
      throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"Error building package using CMake");
    }
  }


  // TODO add management of plugins suffixes for builder-extensions
  std::string PackagesPluginsSuffixes= "";
  if (getPackageType() == PackageInfo::SIM)
    PackagesPluginsSuffixes = openfluid::config::SIMULATORS_PLUGINS_SUFFIX;
  else if (getPackageType() == PackageInfo::OBS)
    PackagesPluginsSuffixes = openfluid::config::OBSERVERS_PLUGINS_SUFFIX;


  if (!openfluid::tools::Filesystem::isFile(BuildDir+"/"+m_ID+PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT))
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"Error finding built package");

  std::string BinInstallDir = getInstallPath() + "/../" + m_MarketBagBinSubDir;
  if (openfluid::tools::Filesystem::isFile(BinInstallDir+"/"+m_ID+
                                           PackagesPluginsSuffixes +openfluid::config::PLUGINS_EXT))
    openfluid::tools::Filesystem::removeFile(BinInstallDir+"/"+m_ID+
                                             PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT);

  openfluid::tools::Filesystem::copyFile(BuildDir+"/"+m_ID+PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT,
                                         BinInstallDir+"/"+m_ID+PackagesPluginsSuffixes+openfluid::config::PLUGINS_EXT);

  if (!m_KeepSources)
    openfluid::tools::Filesystem::removeDirectory(SrcInstallDir);

}