void UIShader::checkShaderFile(){
	int currTime = ofGetElapsedTimeMillis();
	if( ((currTime - lastTimeCheckMillis) > millisBetweenFileCheck) ){
        if( fragFile.exists() ){
            std::time_t fragmentShaderFileLastChangeTime = getLastModified( fragFile );
            if( fragmentShaderFileLastChangeTime != fragChangedTimes ){
                fragChangedTimes = fragmentShaderFileLastChangeTime;
                reloadShader(fragFilename,vertFilename,geomFilename);
            } else if (bVertex){
                if( vertFile.exists() ){
                    std::time_t vertexShaderFileLastChangeTime = getLastModified( vertFile );
                    if( vertexShaderFileLastChangeTime != vertChangedTimes ){
                        vertChangedTimes = vertexShaderFileLastChangeTime;
                        reloadShader(fragFilename,vertFilename,geomFilename);
                    }
                }
                
                if( geomFile.exists() ){
                    std::time_t geometryShaderFileLastChangeTime = getLastModified( geomFile );
                    if( geometryShaderFileLastChangeTime != geomChangedTimes ){
                        vertChangedTimes = geometryShaderFileLastChangeTime;
                        reloadShader(fragFilename,vertFilename,geomFilename);
                    }
                }
            }
        }
        
		lastTimeCheckMillis = currTime;
	}
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
bool ofxAutoReloadedShader::load(string vertName, string fragName, string geomName)
{
	unload();
	
    ofShader::setGeometryOutputCount(geometryOutputCount);
    ofShader::setGeometryInputType(geometryInputType);
    ofShader::setGeometryOutputType(geometryOutputType);

    
	// hackety hack, clear errors or shader will fail to compile
	GLuint err = glGetError();
	
	lastTimeCheckMillis = ofGetElapsedTimeMillis();
	setMillisBetweenFileCheck( 2 * 1000 );
	enableWatchFiles();
	
	loadShaderNextFrame = false;
	
	vertexShaderFilename = vertName;
	fragmentShaderFilename = fragName;
	geometryShaderFilename = geomName;
	
	vertexShaderFile.clear();
	fragmentShaderFile.clear();
	geometryShaderFile.clear();
	
	vertexShaderFile   = ofFile( ofToDataPath( vertexShaderFilename ) );
	fragmentShaderFile = ofFile( ofToDataPath( fragmentShaderFilename ) );
	geometryShaderFile = ofFile( ofToDataPath( geometryShaderFilename ) );
	
	ofBuffer vertexShaderBuffer = ofBufferFromFile( ofToDataPath( vertexShaderFilename ) );
	ofBuffer fragmentShaderBuffer = ofBufferFromFile( ofToDataPath( fragmentShaderFilename ) );
	ofBuffer geometryShaderBuffer = ofBufferFromFile( ofToDataPath( geometryShaderFilename ) );
	
	fileChangedTimes.clear();
	fileChangedTimes.push_back( getLastModified( vertexShaderFile ) );
	fileChangedTimes.push_back( getLastModified( fragmentShaderFile ) );
	fileChangedTimes.push_back( getLastModified( geometryShaderFile ) );
	
	if( vertexShaderBuffer.size() > 0 )
	{
		setupShaderFromSource(GL_VERTEX_SHADER, vertexShaderBuffer.getText() );
	}

	if( fragmentShaderBuffer.size() > 0 )
	{
		setupShaderFromSource(GL_FRAGMENT_SHADER, fragmentShaderBuffer.getText());
	}

	#ifndef TARGET_OPENGLES
	if( geometryShaderBuffer.size() > 0 )
	{
		setupShaderFromSource(GL_GEOMETRY_SHADER_EXT, geometryShaderBuffer.getText());
	}
	#endif

	bindDefaults();
	
	return linkProgram();
}
bool UIShader::reloadShader(string _fragPath, string _vertPath, string _geomPath){
    ofShader::unload();
	
	// hackety hack, clear errors or shader will fail to compile
	GLuint err = glGetError();
	
    fragFile.clear();
    fragFilename = ofToDataPath( _fragPath );
    fragFile = ofFile( fragFilename );
    fragChangedTimes = getLastModified( fragFile );
    ofBuffer fragBuffer = ofBufferFromFile( fragFilename );
    if( fragBuffer.size() > 0 ){
        setupShaderFromSource(GL_FRAGMENT_SHADER, fragBuffer.getText());
    }
    
    
    if (_vertPath != ""){
        vertFile.clear();
        vertFilename = ofToDataPath(_vertPath);
        vertFile = ofFile( vertFilename );
        vertChangedTimes = getLastModified( vertFile );
        ofBuffer vertBuffer = ofBufferFromFile( vertFilename );
        
        if( vertBuffer.size() > 0 ){
            setupShaderFromSource(GL_VERTEX_SHADER, vertBuffer.getText());
        }
        
        bVertex = true;
    }
    
    if (_geomPath != ""){
        geomFile.clear();
        geomFilename = ofToDataPath(_geomPath);
        geomFile = ofFile( geomFilename );
        geomChangedTimes = getLastModified( geomFile );
        ofBuffer geomBuffer = ofBufferFromFile( geomFilename );
        
        if( geomBuffer.size() > 0 ){
            setupShaderFromSource(GL_GEOMETRY_SHADER, geomBuffer.getText());
        }
        
        setGeometryInputType(geomInType);
        setGeometryOutputType(geomOutType);
        setGeometryOutputCount(geomOutCount);
        
        bGeometry = true;
    }
    
	lastTimeCheckMillis = ofGetElapsedTimeMillis();
    
    if (linkProgram()){
        extractUniforms(fragBuffer.getText());
        return true;
    } else {
        return false;
    }
}
QImage ImageCache::image(QString path, int width, int height, int &origWidth, int &origHeight)
{
    if (m_cacheDir.isEmpty())
        return scaledImage(Helper::instance()->getImage(path), width, height);

    QString md5 = QCryptographicHash::hash(path.toUtf8(), QCryptographicHash::Md5).toHex();
    QString baseName = QString("%1_%2_%3_").arg(md5).arg(width).arg(height);

    bool update = true;
    QDir dir(m_cacheDir);
    QStringList files = dir.entryList(QStringList() << baseName + "*");
    if (!files.isEmpty()) {
        QString fileName = files.first();
        QStringList parts = fileName.split("_");
        if (parts.count() > 6) {
            origWidth = parts.at(3).toInt();
            origHeight = parts.at(4).toInt();
            if (m_forceCache || parts.at(5).toInt() == getLastModified(path))
                update = false;
        }
    }

    if (update) {
        QImage origImg = Helper::instance()->getImage(path);
        origWidth = origImg.width();
        origHeight = origImg.height();
        QImage img = scaledImage(origImg, width, height);
        img.save(m_cacheDir + "/" + QString("%1_%2_%3_%4_%5_%6_.png").arg(md5).arg(width).arg(height).arg(origWidth).arg(origHeight).arg(getLastModified(path)), "png", -1);
        return img;
    }

    return Helper::instance()->getImage(m_cacheDir + "/" + files.first());
}
Exemple #5
0
 void
 StdOutputRedirector::removeoldArchives() {
     vector<std::string> myFiles = getDirectoryEntries(getDirectoryPart(_myOutputFilename));
     // search the newest
     int myNewestIndex = -1;
     time_t myHighestTimeStamp = 0;
     vector<int> myFilesToDelete;
     for (vector<std::string>::size_type myFileIndex = 0; myFileIndex != myFiles.size(); myFileIndex++) {
         string myFilename = myFiles[myFileIndex];//getDirectoryPart(_myOutputFilename) + myFiles[myFileIndex];
         string mySearchString(removeExtension(_myOutputFilename) + "logarchive_" );
         size_t myPos = myFilename.rfind(mySearchString.c_str() ,0, mySearchString.size());
         if (myPos != string::npos) {
             time_t myTimeStamp = getLastModified(myFilename);
             if (myTimeStamp > myHighestTimeStamp) {
                 myHighestTimeStamp = myTimeStamp;
                 myNewestIndex = myFileIndex;
             }
             myFilesToDelete.push_back(myFileIndex);
         }
     }
     for (vector<std::string>::size_type myFileIndex = 0; myFileIndex != myFilesToDelete.size(); myFileIndex++) {
         if (myFilesToDelete[myFileIndex] != myNewestIndex ) {
             deleteFile(getDirectoryPart(_myOutputFilename) + myFiles[myFilesToDelete[myFileIndex]]);
         } else {
             _myOldArchiveFilename = myFiles[myNewestIndex];
         }
     }
 }
Exemple #6
0
void testApp::checkShaderFile(){
	int currTime = ofGetElapsedTimeMillis();
	if( ((currTime - lastTimeCheckMillis) > millisBetweenFileCheck) ){
        if( shaderFile.exists() ){
            std::time_t fragmentShaderFileLastChangeTime = getLastModified( shaderFile );
            if( fragmentShaderFileLastChangeTime != shaderChangedTimes ){
                shaderChangedTimes = fragmentShaderFileLastChangeTime;
                reloadShader();
            }
        }
    
		lastTimeCheckMillis = currTime;
	}
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
bool ofxAutoReloadedShader::filesChanged()
{
	bool fileChanged = false;
	
	if( vertexShaderFile.exists() )
	{
		std::time_t vertexShaderFileLastChangeTime = getLastModified( vertexShaderFile );
		if( vertexShaderFileLastChangeTime != fileChangedTimes.at(0) )
		{
			fileChangedTimes.at(0) = vertexShaderFileLastChangeTime;
			fileChanged = true;
		}
	}
	
	if( fragmentShaderFile.exists() )
	{
		std::time_t fragmentShaderFileLastChangeTime = getLastModified( fragmentShaderFile );
		if( fragmentShaderFileLastChangeTime != fileChangedTimes.at(1) )
		{
			fileChangedTimes.at(1) = fragmentShaderFileLastChangeTime;
			fileChanged = true;
		}
	}
	
	
	if( geometryShaderFile.exists() )
	{
		std::time_t geometryShaderFileLastChangeTime = getLastModified( geometryShaderFile );
		if( geometryShaderFileLastChangeTime != fileChangedTimes.at(2) )
		{
			fileChangedTimes.at(2) = geometryShaderFileLastChangeTime;
			fileChanged = true;
		}
	}
	
	return fileChanged;
}
QSize ImageCache::imageSize(QString path)
{
    if (m_cacheDir.isEmpty())
        return Helper::instance()->getImage(path).size();

    QString md5 = QCryptographicHash::hash(path.toUtf8(), QCryptographicHash::Md5).toHex();
    QString baseName = QString("%1_").arg(md5);
    QDir dir(m_cacheDir);
    QStringList files = dir.entryList(QStringList() << baseName + "*");
    if (files.isEmpty() || files.first().split("_").count() < 7)
        return Helper::instance()->getImage(path).size();

    QStringList parts = files.first().split("_");
    if (!m_forceCache && getLastModified(path) != parts.at(5).toInt())
        return Helper::instance()->getImage(path).size();

    return QSize(parts.at(3).toInt(), parts.at(4).toInt());
}
Exemple #9
0
void Track::writeData( QByteArray& data) const {
    QBuffer buffer( data);
    buffer.open(IO_WriteOnly);
    QDataStream stream( &buffer);
    stream.setByteOrder( QDataStream::LittleEndian);

    /** Write the track header **/
    stream << (Q_UINT32) 0x7469686D;        // 0x00 mhit
    stream << (Q_UINT32) 0xf4;              // 0x04 headerlen
    stream << (Q_UINT32) 0x0;               // 0x08 length - set later
    stream << (Q_UINT32) 0x0;               // 0x0C number of mhods
    stream << (Q_UINT32) getID();           // 0x10
    stream << (Q_UINT32) 1;                 // 0x14
    //stream << (Q_UINT32) 0;                 // 0x18
    stream << (Q_UINT32) 0x4d503320;        // ipod shiffle wants a "MP3 " here
    stream << vbr;                          // 0x1C
    stream << type;                         // 0x1D
    stream << compilation;                  // 0x1E
    stream << rating;                       // 0x1F
    stream << (Q_UINT32) getLastModified()+ MAC_EPOCH_DELTA; // 0x20
    stream << (Q_UINT32) getFileSize();     // 0x24
    stream << (Q_UINT32) getTrackLength();  // 0x28
    stream << (Q_UINT32) getTrackNumber();  // 0x2C
    stream << (Q_UINT32) getTrackCount();   // 0x30
    stream << (Q_UINT32) getYear();         // 0x34
    stream << (Q_UINT32) getBitrate();      // 0x38
    stream << (Q_UINT32) getSamplerate();   // 0x3C
    stream << (Q_UINT32) getVolumeAdjust(); // 0x40
    stream << (Q_UINT32) 0;                 // 0x44 empty space
    //stream << (Q_UINT32) getTrackLength();  // 0x48 empty space
    stream << (Q_UINT32) 0;  // 0x48 empty space
    stream << (Q_UINT32) 0;                 // 0x4C empty space
    stream << (Q_UINT32) getPlayCount();    // 0x50
    stream << (Q_UINT32) getPlayCount();    // 0x54
    stream << (Q_UINT32) getLastPlayed();   // 0x58
    stream << (Q_UINT32) getCdNumber();     // 0x5C
    stream << (Q_UINT32) getCdCount();      // 0x60
    stream << (Q_UINT32) 0;                 // 0x64 empty space //userid from apple store
    stream << (Q_UINT32) date_added;        // 0x68
    stream << (Q_UINT32) 0;                 // boockmarktime
    stream << (Q_UINT64) dbid;              // unique bit (64 bit)
    stream << (Q_UINT8) 0;                 // checked in iTZnes
    stream << (Q_UINT8) 0;                 // application rating
    stream << (Q_UINT16) 0;                 // BPM
    stream << (Q_UINT16) 0;                 // artworkcount
    stream << (Q_UINT16) 0xffff;            // unkown
    stream << (Q_UINT32) 0;                 // artwork size
    stream << (Q_UINT32) 0;                 // unkown
    stream << (float) -getSamplerate();      // samplerate as floating point "-"?!?
    stream << (Q_UINT32) 0;                 // date/time added
    stream << (Q_UINT32) file_format_code;  // unkown, but 0x0000000c for MP3 ?
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0;                 // unkown
    stream << (Q_UINT32) 0x02;              // unknown
    stream << (Q_UINT64) dbid; // same unique id as above
    for( int i= 0; i< 17; i++)
        stream << (Q_UINT32) 0;
    
    /** Write Track contents **/
    Q_UINT32 num_mhods = 0;
    for( PropertyMap::const_iterator element= properties.begin(); element!= properties.end(); ++element) {
        if( (*element).isEmpty())
            continue;

        const char *data= (const char *)(*element).ucs2();
        if( data == NULL)
            continue;

        int datalen= 2* (*element).length();

        stream << (Q_UINT32) 0x646F686D;    // mhod
        stream << (Q_UINT32) 0x18;    // headerlen
        stream << (Q_UINT32) 40+ datalen;
        stream << (Q_UINT32) element.key();
        stream << (Q_UINT32) 0;
        stream << (Q_UINT32) 0;
        stream << (Q_UINT32) 1;    // dummy - would refer to the trackID if used in playlist
        stream << (Q_UINT32) datalen;
        stream << (Q_UINT32) 0;
        stream << (Q_UINT32) 0;
        stream.writeRawBytes( data, datalen);
        num_mhods++;
    }
    buffer.at( 8);
    stream << (Q_UINT32)data.size();	// set content length
    stream << (Q_UINT32)num_mhods;	// set real mhod count
    buffer.close();
}
Exemple #10
0
void
OfferFrame::storeUpdateHelper(LedgerDelta& delta, Database& db, bool insert)
{
    touch(delta);

    if (!isValid())
    {
        throw std::runtime_error("Invalid asset");
    }

    std::string actIDStrKey = PubKeyUtils::toStrKey(mOffer.sellerID);

    unsigned int sellingType = mOffer.selling.type();
    unsigned int buyingType = mOffer.buying.type();
    std::string sellingIssuerStrKey, buyingIssuerStrKey;
    std::string sellingAssetCode, buyingAssetCode;
    soci::indicator selling_ind = soci::i_null, buying_ind = soci::i_null;

    if (sellingType == ASSET_TYPE_CREDIT_ALPHANUM4)
    {
        sellingIssuerStrKey =
            PubKeyUtils::toStrKey(mOffer.selling.alphaNum4().issuer);
        assetCodeToStr(mOffer.selling.alphaNum4().assetCode, sellingAssetCode);
        selling_ind = soci::i_ok;
    }
    else if (sellingType == ASSET_TYPE_CREDIT_ALPHANUM12)
    {
        sellingIssuerStrKey =
            PubKeyUtils::toStrKey(mOffer.selling.alphaNum12().issuer);
        assetCodeToStr(mOffer.selling.alphaNum12().assetCode, sellingAssetCode);
        selling_ind = soci::i_ok;
    }

    if (buyingType == ASSET_TYPE_CREDIT_ALPHANUM4)
    {
        buyingIssuerStrKey =
            PubKeyUtils::toStrKey(mOffer.buying.alphaNum4().issuer);
        assetCodeToStr(mOffer.buying.alphaNum4().assetCode, buyingAssetCode);
        buying_ind = soci::i_ok;
    }
    else if (buyingType == ASSET_TYPE_CREDIT_ALPHANUM12)
    {
        buyingIssuerStrKey =
            PubKeyUtils::toStrKey(mOffer.buying.alphaNum12().issuer);
        assetCodeToStr(mOffer.buying.alphaNum12().assetCode, buyingAssetCode);
        buying_ind = soci::i_ok;
    }

    string sql;

    if (insert)
    {
        sql = "INSERT INTO offers (sellerid,offerid,"
              "sellingassettype,sellingassetcode,sellingissuer,"
              "buyingassettype,buyingassetcode,buyingissuer,"
              "amount,pricen,priced,price,flags,lastmodified) VALUES "
              "(:sid,:oid,:sat,:sac,:si,:bat,:bac,:bi,:a,:pn,:pd,:p,:f,:l)";
    }
    else
    {
        sql = "UPDATE offers SET sellingassettype=:sat "
              ",sellingassetcode=:sac,sellingissuer=:si,"
              "buyingassettype=:bat,buyingassetcode=:bac,buyingissuer=:bi,"
              "amount=:a,pricen=:pn,priced=:pd,price=:p,flags=:f,"
              "lastmodified=:l WHERE offerid=:oid";
    }

    auto prep = db.getPreparedStatement(sql);
    auto& st = prep.statement();

    if (insert)
    {
        st.exchange(use(actIDStrKey, "sid"));
    }
    st.exchange(use(mOffer.offerID, "oid"));
    st.exchange(use(sellingType, "sat"));
    st.exchange(use(sellingAssetCode, selling_ind, "sac"));
    st.exchange(use(sellingIssuerStrKey, selling_ind, "si"));
    st.exchange(use(buyingType, "bat"));
    st.exchange(use(buyingAssetCode, buying_ind, "bac"));
    st.exchange(use(buyingIssuerStrKey, buying_ind, "bi"));
    st.exchange(use(mOffer.amount, "a"));
    st.exchange(use(mOffer.price.n, "pn"));
    st.exchange(use(mOffer.price.d, "pd"));
    auto price = computePrice();
    st.exchange(use(price, "p"));
    st.exchange(use(mOffer.flags, "f"));
    st.exchange(use(getLastModified(), "l"));
    st.define_and_bind();

    auto timer =
        insert ? db.getInsertTimer("offer") : db.getUpdateTimer("offer");
    st.execute(true);

    if (st.get_affected_rows() != 1)
    {
        throw std::runtime_error("could not update SQL");
    }

    if (insert)
    {
        delta.addEntry(*this);
    }
    else
    {
        delta.modEntry(*this);
    }
}
void intervalWork(VersionUpdateConfig *config) {

	if(debug) {
		fprintf(stdout, "start intervalWork\n");
	}
	//clean old responsefile
	remove(config->reponseFilePath->ptr);

	buffer *lastModifiedTime = NULL;

	int paramLen = config->URLDomain->used + config->tmpVersionFilePath->used + config->reponseFilePath->used;
	buffer *param = buffer_init_size(20 + paramLen);
	stringAppend(param, " ", 1);
	stringAppend(param, config->URLDomain->ptr, config->URLDomain->used);
	stringAppend(param, " -O ", 4);
	stringAppend(param, config->tmpVersionFilePath->ptr, config->tmpVersionFilePath->used);
	stringAppend(param, " > ", 3);
	stringAppend(param, config->reponseFilePath->ptr, config->reponseFilePath->used);
	stringAppend(param, " 2>&1 ", 6);

	while(1) {
		char *responseCnt = readResponse(config->reponseFilePath->ptr);
		int httpStatus = getHttpStatus(responseCnt);
		if(debug) {
			fprintf(stdout, "httpStatus:%d\n", httpStatus);
		}
		// ignore the lock checke for the first version file request
		if(0 != httpStatus && 404 != httpStatus) {
			int bLocked = checkLockStatus(config->lockRequestURL->ptr);
			if(bLocked){
				sleep(config->intervalSecond);
				continue;
			}
		}
		if(304 != httpStatus) {
			getLastModified(responseCnt, &lastModifiedTime);
		}
		debug_buffer(lastModifiedTime, "lastModifiedTime");
		
		//thread interval exec
		buffer *cmdBuf = buffer_init_size(LAST_MODIFIED_LEN + WGET_CMD_LEN + HEADER_LEN + param->used);
		stringAppend(cmdBuf, WGET_CMD, WGET_CMD_LEN);
		if(NULL != lastModifiedTime) {
			stringAppend(cmdBuf, HEADER, HEADER_LEN);
			stringAppend(cmdBuf, lastModifiedTime->ptr, lastModifiedTime->used);
			stringAppend(cmdBuf, "\"", 1);
		}
		stringAppend(cmdBuf, param->ptr, param->used);
		debug_buffer(cmdBuf, "cmdBuf");

		if(-1 == system(cmdBuf->ptr)) {
			fprintf(stderr, "system (wget...) error:%s\n", cmdBuf->ptr);
			exit(4);
		}

		free(responseCnt);
		buffer_free(cmdBuf);

		checkAndGzip(config->tmpVersionFilePath, config->versionFilePath,
					config->expectVersionFilePath, config->reponseFilePath);

		sleep(config->intervalSecond);
	}
}
Exemple #12
0
bool testApp::reloadShader(string _filePath){
    shader.unload();
	
	// hackety hack, clear errors or shader will fail to compile
	GLuint err = glGetError();
	
    if (_filePath != "none"){
        shaderFilename = ofToDataPath( _filePath );
	}
    
	shaderFile.clear();
	shaderFile = ofFile( shaderFilename );
	shaderChangedTimes = getLastModified( shaderFile );
    lastTimeCheckMillis = ofGetElapsedTimeMillis();
    
	ofBuffer shaderBuffer = ofBufferFromFile( shaderFilename);
	
	if( shaderBuffer.size() > 0 ){
        shader.setupShaderFromSource(GL_FRAGMENT_SHADER, shaderBuffer.getText());
	}
	
    if (shader.linkProgram()){
        
        //  Prepear the uniform to be checked
        //
        for (int i = 0; i < uniforms.size(); i++) {
            uniforms[i]->bUpdated = false;
        }
        
        //  Read the shder and check what needs to be added;
        //
        string fragmentShaderText = shaderBuffer.getText();
        vector<string> lines = ofSplitString(shaderBuffer.getText(), "\n");

        for(int i = 0; i<lines.size(); i++){
            vector<string> words = ofSplitString( lines[i], " ");
            
            for(int j = 0; j < words.size(); j++){
                if (words[j] == "uniform"){
                    jumpNextWord(j,words);
                    
                    if (words[j] == "sampler2DRect"){
                        jumpNextWord(j,words);
                        eraseSemiColon(words[j]);
                        addUniform(UNIFORM_SAMPLE2DRECT,words[j]);
                    } else if (words[j] == "vec2"){
                        jumpNextWord(j,words);
                        eraseSemiColon(words[j]);
                        addUniform(UNIFORM_VEC2,words[j]);
                    } else if (words[j] == "float"){
                        jumpNextWord(j,words);
                        eraseSemiColon(words[j]);
                        addUniform(UNIFORM_FLOAT,words[j]);
                    } 
                }
                else {
                    break;
                }
            }
        }
        
        //  Get rid of extra uniforms
        //
        for (int i = uniforms.size()-1; i >= 0; i--) {
            if (!uniforms[i]->bUpdated){
                ofRemoveListener(uniforms[i]->textChanged, this, &testApp::reloadUniforms);
                delete uniforms[i];
                uniforms.erase(uniforms.begin()+i);
            }
        }
        
        //  How many SyphonClients we need?
        //
        int needSyphonClients = 0;
        for(int i = 0; i < uniforms.size(); i++){
            if (uniforms[i]->type == UNIFORM_SAMPLE2DRECT) {
                needSyphonClients++;
            }
            uniforms[i]->y = 5+(BOX_HEIGHT+5)*i;
        }
        
        //  Add SyphonClients
        //
        while ( sTextures.size() < needSyphonClients) {
            SyphonTexture *newSyphonTexture = new SyphonTexture();
            newSyphonTexture->setup();
            sTextures.push_back(newSyphonTexture);
        }
    
        string nothing = "nothing";
        reloadUniforms(nothing);
        
        return true;
    } else {
        return false;
    }
}
string CTodo::toString()
{
    CAlarm *pAlarm;
    CRecurrence *cRec;
    string szRet;
    string szTemp;
    time_t temp = 0;
    std::stringstream ss;
    ss << "ID=";
    if (getId().c_str()){
	szTemp= getId().substr(0,100);
	ss << szTemp;
	szTemp.clear();
    }
    else
	ss << NULL_STRING;

    ss << ",CalendarId=";
    ss << getCalendarId();

    ss << ",summary=";
    if (getSummary().c_str()){
	szTemp= getSummary().substr(0,100);
	ss << szTemp;
	szTemp.clear();
    }

    else
	ss << NULL_STRING;
    ss << ",description=";
    if (getDescription().c_str()){
	szTemp= getDescription().substr(0,100);
	ss << szTemp;
	szTemp.clear();
    }

    else
	ss << NULL_STRING;
    ss << ",location=";
    if (getLocation().c_str()){
	szTemp= getLocation().substr(0,100);
	ss << szTemp;
	szTemp.clear();
    }

    else
	ss << NULL_STRING;
    ss << ",UId=";
    if (getGUid().c_str()){
	szTemp= getGUid().substr(0,100);
	ss << szTemp;
	szTemp.clear();
    }
    else
	ss << NULL_STRING;

    ss << ",TimeZone=";
    if (getTzid().c_str()){
	szTemp= getTzid().substr(0,100);
	ss << szTemp;
	szTemp.clear();
    }
    else
	ss << NULL_STRING;
    ss << ",Type=";
    ss << getType() ;
    ss << ",Flags=";
    switch (getFlags()){
	case HAS_ATTENDEE:
	    ss << "Has Attendee";
	    break;
	case HAS_ORGANIZER:
	    ss << "Has Organizer";
	    break;
	case HAS_RECURRENCE:
	    ss << "Has Recurrence";
	    break;
	case HAS_ALARM:
	    ss << "Has Alarm";
	    break;
	case HAS_RECURRENCE_ALARM :
	    ss << "Has Recurrent Alarm";
	    break;
	case HAS_PARTICIPANT :
	    ss << "Has Participant";
	    break;
	case HAS_CATEGORIES :
	    ss << "Has Categories";
	    break;
	case HAS_COMMENT:
	    ss << "Has Comment ";
	    break;
	case HAS_EXTRA:
	    ss << "Has Extra ";
	    break;
	default:
	    break;
    }

    ss << ",Status=";
    ss << getStatus();
    ss << ",Start date=";
    temp = getDateStart();
    ss << ctime(&temp);
    ss << ",End date=";
    temp = getDateEnd();
    ss << ctime(&temp);
    ss << ",Last modified=";
    temp = getLastModified();
    ss << ctime(&temp);
    ss << ",created=";
    temp = getCreatedTime();
    ss << ctime(&temp);
    ss << ",until=";
    temp = getUntil();
    ss << ctime(&temp);

    ss << ",All day=";
    ss << getAllDay();
    ss << ",Geo=";
    if (szGeo.c_str()){
	szTemp= szGeo.substr(0,100);
	ss << szTemp;
	szTemp.clear();
    }
    else
	ss << NULL_STRING;

    ss << ",TodoDue=";
    ss << iDue;
    ss << ",Completed=";
    ss << iCompleted;
    ss << ",Percent";
    ss << iPercentComplete;
    ss << ",Priority";
    ss << iPriority;
    pAlarm=getAlarm();
    if(pAlarm)
	ss << pAlarm->toString();
    else
	ss << ",Alarm=NULL";
    cRec=getRecurrence();
    if(cRec)
	ss << cRec->toString();
    else
	ss << ",Rec=NULL";

    szRet.append(ss.str());
    return szRet;
}