Variant Propertized::convertStringTo( const Variant& str, Variant::types t ) {
	if ( str.type() != Variant::t_string ) {
		nError() << "convertStringTo require a string-type Variant; "
				 << "passed type " << str.typeName();
		return Variant();
	}
	QString qstr( str.getString() );
	char ch;
    switch( t ) {
    case Variant::t_null: 
		return Variant();
		break;
    case Variant::t_real:
#ifdef NNFW_DOUBLE_PRECISION
		return Variant( qstr.toDouble() );
#else
		return Variant( qstr.toFloat() );
#endif
		break;
    case Variant::t_int:
		return Variant( qstr.toInt() );
		break;
    case Variant::t_uint: 
		return Variant( qstr.toUInt() );
		break;
    case Variant::t_char:
		ch = qstr[0].toAscii();
		return Variant( ch );
		break;
    case Variant::t_uchar:
		ch = qstr[0].toAscii();
		return Variant( (unsigned char)(ch) );
		break;
    case Variant::t_bool:
		if ( qstr == "true" ) {
			return Variant( true );
		} else {
			return Variant( false );
		}
		break;
    case Variant::t_string:
    case Variant::t_realvec:
    case Variant::t_realmat:
    case Variant::t_outfunction:
    case Variant::t_cluster:
    case Variant::t_linker:
    case Variant::t_propertized:
    case Variant::t_dataptr:
		nError() << "Unsupported convertion type: " << Variant::typeName(t);
		break;
    }
	return Variant();
}
Example #2
0
Nuria::Internal::TcpServer::TcpServer (bool useSsl, QObject *parent)
	: QTcpServer (parent), m_ssl (useSsl)
{
	
#ifndef NURIA_NO_SSL_HTTP
	if (useSsl) {
		nError() << "Trying to create unsupported SSL server - Was disabled at compile-time.";
		nError() << "Connections will fail.";
	}
#endif
	
}
void Variant::checkType( types t ) const {
    if ( t != dtype ) {
        nError() << "Attempt to access a " << typen[t] << " type instead of the right type " << typen[dtype]
				 << " unpredictable result";
    }
    return;
}
void Nuria::ObjectWrapperResourcePrivate::connectToSignal (QMetaMethod method) {
	// Connect objects' signal to our homegrown qt_metacall().
	int index = method.methodIndex ();
	if (!QMetaObject::connect (this->object, index, this, index, Qt::DirectConnection)) {
		nError() << "connect() failed on" << this->object << "for signal" << method.methodSignature ();
	}
	
}
Example #5
0
int main (int argc, char *argv[]) {
	QCoreApplication a (argc, argv);
	Nuria::HttpServer server;

	server.root ()->connectSlot ("index", mySlot);

	if (!server.listen (QHostAddress::Any, 3000)) {
		nError() << "Failed to listen on port 3000.";
		return 1;
	}

	nLog() << "Listening on all interfaces on port 3000.";
	return a.exec ();
}
Example #6
0
void nFrameBuffer::setUnmodified() {
    bool valid = depthTexture && depthTexture->getSize().mul() > 0;
    for(int i = 0; i != nGL::getState()->getHWInt(nGLState::MaxFboAttachements) && !valid; i++) {
        if(attachments[i]) {
            valid = attachments[i]->getSize().mul() > 0;
        }
    }
    if(valid && glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
        int error = glCheckFramebufferStatus(GL_FRAMEBUFFER);
        nError("Unable to modify frame-buffer-object, error = " + (error == GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT ? nString("MISSING ATTACHMENT") :
                (error == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT ? nString("INCOMPLETE ATTACHMENT") :
                 (error == GL_FRAMEBUFFER_UNSUPPORTED ? nString("UNSUPPORTED") : nString::fromNumber(error)))));
    }
    modified = false;
}
Example #7
0
void Nuria::RestfulHttpNode::registerAnnotatedHandlers () {
	this->d_ptr->loaded = true;
	
	if (!this->d_ptr->metaObject) {
		this->d_ptr->metaObject = MetaObject::byName (metaObject ()->className ());
		if (!this->d_ptr->metaObject) {
			nError() << "Failed to auto-find meta object of class" << metaObject ()->className ();
			return;
		}
		
	}
	
	// 
	MetaObject *meta = this->d_ptr->metaObject;
	for (int i = 0; i < meta->methodCount (); i++) {
		MetaMethod method = meta->method (i);
		registerMetaMethod (method);
	}
	
}
void Nuria::ObjectWrapperResource::exclude (const char *signalOrSlot) {
	Q_ASSERT(signalOrSlot);
	
	// Find method
	int index = 0;
	if (signalOrSlot[0] == '1') { // Slot
		index = this->d_ptr->meta->indexOfSlot (signalOrSlot + 1);
	} else { // Signal
		index = this->d_ptr->meta->indexOfSignal (signalOrSlot + 1);
	}
	
	// Sanity check
	if (index < 0) {
		nError() << "Failed to find signal or slot" << signalOrSlot
		         << "in class" << this->d_ptr->meta->className ();
		return;
	}
	
	// Remove entry
	Method descriptor = this->d_ptr->methods.take (index);
	this->d_ptr->removeMethodFromPropertyList (descriptor.propertyIndex);
	
}
Example #9
0
uint nTexture::TextureInternal::getGLHandle() const {
	if(!makeValid(true)) {
		nError("Unable to get texture handle");
	}
	return *handle;
}
Example #10
0
void Nuria::RestfulHttpNode::conversionFailure (const QVariant &variant, Nuria::HttpClient *client) {
	nError() << "Failed to convert type" << variant.typeName ()
		 << "for URL" << client->path ().toString ();
	
	client->killConnection (500);
}
Example #11
0
Linker* Linker::clone() const {
	nError() << "The clone() method has to implemented by subclasses";
	return 0;
}
Example #12
0
void Player::playIndex(int index, int listIndex)
{
        qDebug() << "PlayIndex,index: " << index << "listIndex: " << listIndex;
    if(listIndex > -1) {
        if(currentListIndex != listIndex || !listSync) {
            setList(parser->sources[listIndex]);
            currentListIndex = listIndex;
        }
    }

    if(index > playList.size() - 1)
        index = 0;

    prevIndex = curIndex;
    curIndex = index;

    mediaObject->stop();
    setState(Player::STOPED);

    buffer->close();
    buffer->setData("");
    buffer = new QBuffer(mediaObject);


    QFile file;
    QDir::setCurrent(savePath);
    QString fileName = playList[curIndex]["artist"]+" - "+playList[curIndex]["title"]+"__"+playList[curIndex]["opt4"]+".mp3";
    fileName.replace(QRegExp("[?*/\"<>]"), "_");
    file.setFileName(fileName);
    if(file.open(QIODevice::ReadOnly)) {
        emit bufferProgress(1, 1);
        //buffer->setData(file.readAll());
        //buffer->open(QBuffer::ReadWrite);
        if(obCreated) {
            nReply->reset();
            if(nReply->isRunning())
                nReply->abort();
        }
        mediaObject->stop();
        mediaObject->setCurrentSource(Phonon::MediaSource(fileName));
        mediaObject->play();
        setState(Player::PLAY);
        ob2Created = true;
    } else {
        if(bufferOff)
        {
            emit bufferProgress(-1, -1);
            mediaObject->stop();
            mediaObject->setCurrentSource(Phonon::MediaSource(playList[curIndex]["link"]));
            mediaObject->play();
            setState(Player::PLAY);
        } else {
            blockNum = 0;

            QNetworkRequest req;
            req.setUrl(QUrl(playList[curIndex]["link"]));

            if(obCreated) {
                if(nReply->isRunning())
                    nReply->abort();
            }
            canPlay = false;
            nReply = nManager.get(req);
            connect(nReply, SIGNAL(readyRead()), this, SLOT(readData()));
            connect(nReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(dProgress(qint64,qint64)));
            connect(nReply, SIGNAL(finished()), this, SLOT(rFinished()));
            connect(nReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(nError(QNetworkReply::NetworkError)));
            obCreated = true;
        }

    }
    file.close();

    emit curSong(playList[curIndex], curIndex, autoNext);
    autoNext = false;

    QRegExp rx("(.*):(.*)"); // Сиськиии!)
    rx.indexIn(playList[curIndex]["duration"]);
    QString c1 = rx.capturedTexts()[1];
    QString c2 = rx.capturedTexts()[2];
    int dur1 = c1.toInt();
    int dur2 = c2.toInt();
    duration = dur1 * 60;
    duration += dur2;

}