Exemple #1
0
void psi::decoding(QFile &path) {
    QDomDocument doc;
    doc.setContent(&path);
    QDomElement root = doc.documentElement();
    QDomNode node = root.firstChild();
    while (!node.isNull()) {
        if (node.toElement().tagName() == "accounts") {
            QDomNode yyy = node.toElement().firstChild();
            while (!yyy.isNull()) {
                QDomNode nn = yyy.firstChild();
                QString hash, jid, host;
                while(!nn.isNull()) {
                    if (nn.toElement().tagName() == "password")
                        hash = nn.firstChild().toText().data();
                    if (nn.toElement().tagName() == "jid")
                        jid = nn.firstChild().toText().data();
                    if (nn.toElement().tagName() == "host")
                        host = nn.firstChild().toText().data();
                    nn = nn.nextSibling();
                }
                createXML(jid, decodePassword(hash, jid), host);
                yyy = yyy.nextSibling();
            }
        }
        node = node.nextSibling();
    }
}
Exemple #2
0
void saje::decoding(QFile &file) {
        QDomDocument tempDoc;
        tempDoc.setContent(&file);
        QDomNode nRoot = tempDoc.documentElement();
        for (int i = 0;i < nRoot.childNodes().count();i++) {
                if (nRoot.childNodes().at(i).toElement().tagName() == "account-data") {
                    QString login = nRoot.childNodes().at(i).toElement().attribute("username");
                    QString server = nRoot.childNodes().at(i).toElement().attribute("host");
                    QString proto = nRoot.childNodes().at(i).toElement().attribute("protocol-name");
                    QString key = login + server;
                    QString tmp = nRoot.childNodes().at(i).toElement().attribute("password");
                    QString pass = decodePassword(QByteArray::fromBase64(tmp.toUtf8()), key);

                    createXML(login, pass, server, proto);
                }
            }

}
Exemple #3
0
bool XMLMetadata::createXMLDoc()
{
	if (doc)
		xmlFreeDoc(doc);

        doc = xmlNewDoc((xmlChar *)"1.0");

        if (!doc)
                return false;

        xmlNodePtr xn = xmlNewNode(NULL, (xmlChar *)name.c_str());
        
        if (!createXML(xn))
                goto out_err;

        xmlDocSetRootElement(doc, xn);

        return true;
out_err:
        xmlFreeDoc(doc);
        doc = NULL;
	return false;
}
Exemple #4
0
int main(int argc, char *argv[])
{
    QString title;
    title = title + "****************************************************************** \n";
    title = title + " * DictToXML 1.0                                                  * \n";
    title = title + " * This tool generates an XML structure of a CSPro dictionary     * \n";
    title = title + " * file. The XML has the same data as the DCF file but using      * \n";
    title = title + " * XML tags. The purpose of an XML structure is to easily read    * \n";
    title = title + " * dictionary information or to quickly alter value lists.        * \n";
    title = title + " * The XMLToDict do the oposite.                                  * \n";
    title = title + " * This tool is part of CSPro Tools (c) ILRI, 2012                * \n";
    title = title + " ****************************************************************** \n";

    TCLAP::CmdLine cmd(title.toLatin1().constData(), ' ', "1.0 (Beta 1)");
    //Required arguments
    TCLAP::ValueArg<std::string> inputArg("i","input","Input CSPro DCF File",true,"","string");
    TCLAP::ValueArg<std::string> outputArg("o","output","Output XML file. Default ./output.xml",false,"./output.xml","string");

    cmd.add(inputArg);
    cmd.add(outputArg);
    //Parsing the command lines
    cmd.parse( argc, argv );

    //Getting the variables from the command

    QString input = QString::fromUtf8(inputArg.getValue().c_str());
    QString output = QString::fromUtf8(outputArg.getValue().c_str());

    QFile file(input);

    if (!file.exists())
    {
        printLog("The input DCF file does not exits");
        return 1;
    }

    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        printLog("Cannot open DCF file");
        return 1;
    }

    doc = QDomDocument("CSProXMLFile");

    root = doc.createElement("CSProXML");
    root.setAttribute("version", "1.0");
    doc.appendChild(root);

    QTextStream in(&file);
    int pos;
    pos = 1;
    while (!in.atEnd())
    {
        QString line = in.readLine();
        if (!line.isEmpty())
            addToXML(line); //Parse the line
        pos++;
    }

    if (createXML(output) != 0)
    {
        printLog("Error saving XML file");
        return 1;
    }

    printLog("Done");
    return 0;
}
Exemple #5
0
int Processor::start(int argc, char **argv) {

    //get the path of exe dir
    path = argv[0];
    int pos = path.find_last_of("/")+1;
    if (pos > 0 ){
        path = path.substr(0, pos);
    }else{
        path = "";
    }

    fileName = argv[1];         //ONI file
    bool isDisplay = false;     //display or not the depth scene
    if(argc>2)
        isDisplay=true;

    //get the name of file without path
    pos = fileName.find_last_of("/") +1;
    if (pos < 0 ) pos = 0;
    fileName = fileName.substr(pos);
    dateStart = fileName.substr(0,fileName.find("."));

    //Get the config
    std::string tmp =  path + "config.xml";
    const char *filename = tmp.c_str();
    TiXmlDocument config(filename);
    if (!config.LoadFile()) {
        printf("Error while loading config!\n");
        return 1;
    }
    TiXmlElement *root, *video, *faceDetection;
    root = config.FirstChildElement( "config" );
    int fps = 24;
    bool active = false;
    const char* cascadeFile;

    if (root) {
        video = root->FirstChildElement("video");
        fps = atoi(video->Attribute("fps2d"));
        faceDetection = root->FirstChildElement("faceDetection");
        active = faceDetection->Attribute("active");
        cascadeFile = faceDetection->Attribute("cascadeFile");
        tmp =  path + cascadeFile;
        cascadeFile = tmp.c_str();
    }
    MovingObject::init(active, cascadeFile);



    //create directory for media
    instance->dir = "movieData/"+fileName.substr(0,fileName.find_last_of("."));
    mkdir("movieData", 0777);
    mkdir((dir).c_str(), 0777);
    mkdir((dir+"/2D").c_str(), 0777);
    mkdir((dir+"/3D").c_str(), 0777);


    XnStatus rc = XN_STATUS_OK;
    xn::DepthGenerator g_DepthGenerator;
    xn::UserGenerator  g_UserGenerator;
    xn::ImageGenerator g_image;

    //Init context and all Node/Generator
    rc = context.Init();
    CHECK_RC(rc, "Init");

    context.SetGlobalMirror(true); //mirror image

    rc = context.OpenFileRecording(argv[1]);
    CHECK_RC(rc, "InitFromONI");

    rc = context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
    CHECK_RC(rc, "Find depth generator");

    rc = context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
    if(rc!=XN_STATUS_OK){
      rc = g_UserGenerator.Create(context);
      CHECK_RC(rc, "UserGenerator");
    }

    rc = context.FindExistingNode(XN_NODE_TYPE_IMAGE, g_image);
    CHECK_RC(rc, "Find image generator");

    initGenerator(g_UserGenerator, g_DepthGenerator);

    if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON) ||
            !g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION)) {
        printf("User generator doesn't support either skeleton or pose detection.\n");
        return XN_STATUS_ERROR;
    }

    XnBool isSupported = g_DepthGenerator.IsCapabilitySupported("AlternativeViewPoint");
    if(TRUE == isSupported) {
      XnStatus res = g_DepthGenerator.GetAlternativeViewPointCap().SetViewPoint(g_image);
      if(XN_STATUS_OK != res) {
        printf("Getting and setting AlternativeViewPoint failed: %s\n", xnGetStatusString(res));
      }
    } else {
        printf("AlternativeViewPoint not supported\n");
    }

    g_UserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);

    //Init Player
    xn::Player player;
    xn::NodeInfoList list;
    rc = context.EnumerateExistingNodes(list);
    if (rc == XN_STATUS_OK) {
        for (xn::NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it) {
                switch ((*it).GetDescription().Type) {
                    case XN_NODE_TYPE_PLAYER:
                        (*it).GetInstance(player);
                }
        }
    }else{
        printf("Player error: %s\n", xnGetStatusString(rc));
    }

    //Create a Generators contains all generators
    gen = new Generators(g_UserGenerator, g_DepthGenerator, g_image, player);

    strNodeName = g_image.GetName();

    createXML();    //Create a XMLDocument

    //Start the Nodes/Generators
    rc = context.StartGeneratingAll();
    CHECK_RC(rc, "StartGenerating");

    //Set callbacks functions : NewUser & LostUser
    XnCallbackHandle hUserCBs;
    g_UserGenerator.RegisterUserCallbacks(Processor::NewUser, Processor::LostUser, NULL, hUserCBs);


    XnUInt32 nFrame, nFrameTot;
    instance->gen->player.GetNumFrames(instance->strNodeName, nFrameTot);


    //Loop each frames with windows output or not
    if (!isDisplay){
        while(nFrame != nFrameTot -2){
            //update current frame id
            instance->gen->player.TellFrame(instance->strNodeName,nFrame);
            // Read next available data
            instance->context.WaitAndUpdateAll();
            //Update sequence if there is someone in the scene
            if (instance->hasUserInSight)
                instance->sequence->update();
        }
        CleanupExit();
    }else{
        //Start the GL to display Depth image
        glInit(&argc, argv);
        glutMainLoop();
    }
}