Example #1
0
int Logger::basicLog(std::string message){
	//XXX build the logfile location from the polaris folder, not app folder
	std::string appdata(getenv("APPDATA"));
	std::string logpath = appdata  + "\\hp\\polaris\\log.txt";
    FILE* logger = fopen(logpath.c_str(), "a+");
	int errorcode = fprintf(logger, "%s\n",message.c_str());
	if (errorcode >0 ) {errorcode =0;};
	fclose(logger);
	return errorcode;
}
void RetrieveAssemblyHierarchyInformation (
    const ProSolid					  p_solid_handle,
    bool							  in_IncludeTheEntireHierarchy_NotJustImmediateDependents,
    CreoModelAssemblyAttributes        &out_AssemblyHierarchy  )
throw (isis::application_exception)
{
    if ( p_solid_handle == NULL )
    {
        std::stringstream errorString;
        errorString << "BuildAssemblyHierarchy was passed a NULL pointer for p_solid_handle.";
        throw isis::application_exception(errorString);
    }

    UserAppdata appdata(out_AssemblyHierarchy);

    ProMdldata mdldata;
    isis::isis_ProMdlDataGet(p_solid_handle, &mdldata);

    char name[PRO_NAME_SIZE];
    char type[PRO_TYPE_SIZE];

    ProWstringToString(name,mdldata.name);
    ProWstringToString(type,mdldata.type);

    if ( in_IncludeTheEntireHierarchy_NotJustImmediateDependents)
        appdata.assemblyHierarchy.includeTheEntireHierarchy = true;
    else
        appdata.assemblyHierarchy.includeTheEntireHierarchy = false;

    if ( strncmp(type,"ASM",3) == 0 )
    {
        appdata.assemblyHierarchy.modelType = PRO_MDL_ASSEMBLY;
        appdata.assemblyHierarchy.proAsmcomp.type = PRO_TYPE_UNUSED;
        appdata.assemblyHierarchy.proAsmcomp.id = 0;
        appdata.assemblyHierarchy.proAsmcomp.owner = 0;
    }
    else
    {
        // This would be a PRO_MDL_PART
        std::stringstream errorString;
        errorString << "BuildAssemblyHierarchy was passed a p_solid_handle that pointed to a model " << type  << " type.  The only allowed model type is ASM.";
        throw isis::application_exception(errorString);
    }

    appdata.assemblyHierarchy.modelname = mdldata.name;
    appdata.assemblyHierarchy.p_solid_handle = p_solid_handle;

    isis::isis_ProSolidFeatVisit(p_solid_handle, user_action, UserAsmCompFilter, &appdata);
}
void Installer::installpkg() {
    QString url = sender()->property("url").toString();
    uint bsize = sender()->property("bsize").toUInt();

    wait = new QProgressDialog(this);
    wait->setModal(true);
    wait->setMaximum(bsize+1);
    wait->setLabelText(QString("Downloading ") + url + " ...");
    wait->show();

    reply = qnam.get(QNetworkRequest(QUrl(url)));
    reply->setReadBufferSize(bsize*2);
    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(dlProgress(qint64,qint64)));
    loop.exec();

    QString appdata_path = DATALOCATION;
    QDir().mkpath(appdata_path);
    QDir appdata(appdata_path);
    appdata.remove("data.tmp");
    appdata.remove("data.tar");
    appdata.remove("data.tar.xz");
    appdata.remove("debian-binary");
    appdata.remove("control.tar.gz");

    QFile file(appdata.filePath("data.tmp"));
    file.open(QIODevice::WriteOnly);
    file.write(reply->readAll());
    file.close();

    QDir exep(QCoreApplication::applicationDirPath());
    wait->setLabelText("Unpacking ...");
    QProcess *up = new QProcess(this);
    up->setWorkingDirectory(appdata_path);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
    up->start(exep.absoluteFilePath("7z"), QStringList() << "x" << "-y" << "data.tmp");
#else
    up->start("ar", QStringList() << "x" << "data.tmp");
#endif
    up->waitForStarted();
    up->waitForFinished();
    up->deleteLater();

    if (appdata.exists("data.tar")) {
        QProcess *up = new QProcess(this);
        up->setWorkingDirectory(appdata_path);
        up->start(exep.absoluteFilePath("7z"), QStringList() << "x" << "-y" << "data.tar");
        up->waitForStarted();
        up->waitForFinished();
        up->deleteLater();
    }

    if (appdata.exists("data.tar.xz")) {
        QProcess *up = new QProcess(this);
        up->setWorkingDirectory(appdata_path);
        up->start("tar", QStringList() << "-Jxf" << "data.tar.xz");
        up->waitForStarted();
        up->waitForFinished();
        up->deleteLater();
    }

    wait->close();
    wait->deleteLater();
    appdata.remove("data.tmp");
    appdata.remove("data.tar");
    appdata.remove("data.tar.xz");
    appdata.remove("debian-binary");
    appdata.remove("control.tar.gz");

    QSettings conf;
    conf.setValue(sender()->property("name").toString(), sender()->property("lm").toString());
}