Ejemplo n.º 1
0
void BasicHandler::handle(const QString &member, QGenericArgument val0,
    QGenericArgument val1, QGenericArgument val2,
    QGenericArgument val3, QGenericArgument val4,
    QGenericArgument val5, QGenericArgument val6,
    QGenericArgument val7, QGenericArgument val8)
{
    // Now we try to find a handler for this message. BTW, I do love the Trolltech guys ;-)
    // and now we even have a fast lookup! Thanks thiago!

    QString handler = member.toLower();
    handler[0] = handler[0].toUpper();

    if (!handlerHash().contains(handler)) {
        if (_defaultHandler == -1) {
            qWarning() << QString("No such Handler: %1::%2%3").arg(metaObject()->className(), _methodPrefix, handler);
            return;
        }
        else {
            void *param[] = { 0, Q_ARG(QString, member).data(), val0.data(), val1.data(), val2.data(), val3.data(), val4.data(),
                              val5.data(), val6.data(), val7.data(), val8.data(), val8.data() };
            qt_metacall(QMetaObject::InvokeMetaMethod, _defaultHandler, param);
            return;
        }
    }

    void *param[] = { 0, val0.data(), val1.data(), val2.data(), val3.data(), val4.data(),
                      val5.data(), val6.data(), val7.data(), val8.data(), val8.data(), 0 };
    qt_metacall(QMetaObject::InvokeMetaMethod, handlerHash()[handler], param);
}
Ejemplo n.º 2
0
/**
 * This function does all the dirty qt stuff to call any given signal or slot manually. This function is for internal use only
 * @sa callCallback emitSignal
 * @param sig Signature of the function to be called
 * @param args Arguments list for the function
 * @return Returns the ReturnValue from the function, or an error.
 */
ReturnValue ProxyBase::callMetacall(Signature sig, Arguments args)
{
	// Test to make sure the argument list matches the signature... this is important else the void*'s will contain the wrong types (breaking everything)
	QString test = sig.test(args);
	if (!test.isEmpty())
	{
		return(ReturnValue(2, test));
	}

	// Create the return value
	ReturnValue ret;
	QList<QByteArray> bagarbageCollector;
	QList<QSharedPointer<const char*> > garbageCollector;

	// Create an array of void pointers and place the QVariants into it... I don't know why this works, but it does.
	void *param[] = {(void *)&ret, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};

	for (int i = 0; i < sig.numArgs(); i++)
	{
		if (sig.arg(i) == "char*" || sig.arg(i) == "const char*")
		{
			garbageCollector.append(QSharedPointer<const char*>(new const char*));
			bagarbageCollector.append(args[i].toString().toLocal8Bit());
			*garbageCollector.last().data() = bagarbageCollector.last().constData();
			param[i+1] = garbageCollector.last().data();
		}
		else if (sig.arg(i) != "QVariant" && args.at(i).type() == QVariant::UserType)
		{
			param[i+1] = args[i].data();
		}
		else
		{
			param[i+1] = static_cast<void*>(&args[i]);
		}
	}

	// Check the make sure the signature is a valid string...
	if (sig.name().isEmpty())
		return(ReturnValue(3, "Failed to call " + sig.toString() + ": Sig is not valid (" + sig.name() + ")"));

	// Get the ID number of the function, if it fails normalize the string and try again...
	int id = metaObject()->indexOfMethod(qPrintable(sig.toString()));
	if (id < 0)
		id = metaObject()->indexOfMethod(QMetaObject::normalizedSignature(qPrintable(sig.toString())).constData()); //try again

	if (id < 0) // failed to find the id number of the function
		return(ReturnValue(4, "Failed to call " + sig.toString() + ": Could not find the index of the slot (id=" + QString("%1)").arg(id)));

	// the return from qt_metacall SHOULD be negative if the slot was found...
	int retid = qt_metacall(QMetaObject::InvokeMetaMethod, id, param);
	if (retid > 0) // return error
		return(ReturnValue(5, "Failed to call " + sig.toString() + ": Failed to find it in metacall (" + QString("id=%1 retid= %2 ret=%3)").arg(id).arg(retid).arg(ret.toString())));

	// return the return value. It's data was filled via the *param[] object...
	return(ret);
}
Ejemplo n.º 3
0
/*!
    \overload
    \since 4.6

    If this function is called, the SSL errors given in \a errors
    will be ignored.

    Note that you can set the expected certificate in the SSL error:
    If, for instance, you want to issue a request to a server that uses
    a self-signed certificate, consider the following snippet:

    \snippet doc/src/snippets/code/src_network_access_qnetworkreply.cpp 0

    Multiple calls to this function will replace the list of errors that
    were passed in previous calls.
    You can clear the list of errors you want to ignore by calling this
    function with an empty list.

    \sa sslConfiguration(), sslErrors(), QSslSocket::ignoreSslErrors()
*/
void QNetworkReply::ignoreSslErrors(const QList<QSslError> &errors)
{
    // do this cryptic trick, because we could not add a virtual method to this class later on
    // since that breaks binary compatibility
    int id = metaObject()->indexOfMethod("ignoreSslErrorsImplementation(QList<QSslError>)");
    if (id != -1) {
        QList<QSslError> copy(errors);
        void *arr[] = { 0, &copy };
        qt_metacall(QMetaObject::InvokeMetaMethod, id, arr);
    }
}
Ejemplo n.º 4
0
/*!
    Sets the SSL configuration for the network connection associated
    with this request, if possible, to be that of \a config.
*/
void QNetworkReply::setSslConfiguration(const QSslConfiguration &config)
{
    if (config.isNull())
        return;

    int id = metaObject()->indexOfMethod("setSslConfigurationImplementation(QSslConfiguration)");
    if (id != -1) {
        QSslConfiguration copy(config);
        void *arr[] = { 0, &copy };
        qt_metacall(QMetaObject::InvokeMetaMethod, id, arr);
    }
}