X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcontrib%2Flibqxt-2007-10-24%2Fsrc%2Fweb%2Fqxtwebcontroller.cpp;fp=src%2Fcontrib%2Flibqxt-2007-10-24%2Fsrc%2Fweb%2Fqxtwebcontroller.cpp;h=dcfb8dd01fed6fd6c1e68ca58bdc3a33ca8a5a20;hp=0000000000000000000000000000000000000000;hb=a634acadbcf6017474f68a3eaf7cb632660e9e49;hpb=cd122ca8e0d2c0ffc5397e0a813c75d791a7e6e3 diff --git a/src/contrib/libqxt-2007-10-24/src/web/qxtwebcontroller.cpp b/src/contrib/libqxt-2007-10-24/src/web/qxtwebcontroller.cpp new file mode 100644 index 00000000..dcfb8dd0 --- /dev/null +++ b/src/contrib/libqxt-2007-10-24/src/web/qxtwebcontroller.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) Qxt Foundation. Some rights reserved. +** +** This file is part of the QxtWeb module of the Qt eXTension library +** +** This library is free software; you can redistribute it and/or modify it +** under the terms of th Common Public License, version 1.0, as published by +** IBM. +** +** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY +** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR +** FITNESS FOR A PARTICULAR PURPOSE. +** +** You should have received a copy of the CPL along with this file. +** See the LICENSE file and the cpl1.0.txt file included with the source +** distribution for more information. If you did not receive a copy of the +** license, contact the Qxt Foundation. +** +** +** +****************************************************************************/ +#include "qxtwebcontroller.h" +#include "qxtwebcore.h" +#include +#include +#include +#include +static QTextStream nullstream; + +QString QxtWebController::WebRoot() +{ + + return QCoreApplication::applicationDirPath()+"/../"; +} + + +QxtWebController::QxtWebController(QString name):QObject(QCoreApplication::instance()) +{ + stream_m=0; + setObjectName(name); +} + + +QTextStream & QxtWebController::echo() +{ + if (!stream_m) + { + qDebug("QxtWebController::echo() no stream open"); + return nullstream; + } + return *stream_m; +} + + +QString QxtWebController::self() +{ + return "/"+objectName(); +} + + +int QxtWebController::invoke(server_t & SERVER_i) +{ + SERVER=SERVER_i; + QList args_d = SERVER["REQUEST_URI"].split('/'); + + ///--------------find action ------------------ + QByteArray action="index"; + if (args_d.count()>2) + { + action=args_d.at(2); + if (action.trimmed().isEmpty())action="index"; + } + else if (args_d.count()>1) + action="index"; + + + if (args_d.count()>3) + { + args_d.removeFirst(); + args_d.removeFirst(); + args_d.removeFirst(); + } + else + args_d.clear(); + + QStringList args; + foreach(QByteArray arg,args_d) + args<8) + { + if (!QMetaObject::invokeMethod(this, action,Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)),Q_ARG(QString, args.at(2)),Q_ARG(QString, args.at(3)) + ,Q_ARG(QString, args.at(4)),Q_ARG(QString, args.at(5)),Q_ARG(QString, args.at(6)),Q_ARG(QString, args.at(8)))) + { + retVal=4042; ///FIXME: the return value of the invoke has a meaning, handle it! + } + } + else if (args.count()>7) + { + if (!QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)),Q_ARG(QString, args.at(2)),Q_ARG(QString, args.at(3)) + ,Q_ARG(QString, args.at(4)),Q_ARG(QString, args.at(5)),Q_ARG(QString, args.at(6)),Q_ARG(QString, args.at(7)) + )) + { + retVal=4042; + } + + } + else if (args.count()>6) + { + if ( !QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)),Q_ARG(QString, args.at(2)),Q_ARG(QString, args.at(3)) + ,Q_ARG(QString, args.at(4)),Q_ARG(QString, args.at(5)),Q_ARG(QString, args.at(6)) + )) + { + retVal=4042; + } + } + else if (args.count()>5) + { + if (!QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)),Q_ARG(QString, args.at(2)),Q_ARG(QString, args.at(3)) + ,Q_ARG(QString, args.at(4)),Q_ARG(QString, args.at(5)) + )) + { + retVal=4042; + } + } + else if ( args.count()>4) + { + if ( !QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)),Q_ARG(QString, args.at(2)),Q_ARG(QString, args.at(3)) + ,Q_ARG(QString, args.at(4)) + )) + { + retVal=4042; + } + } + else if (args.count()>3) + { + if ( !QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)),Q_ARG(QString, args.at(2)),Q_ARG(QString, args.at(3)) + )) + { + retVal=4042; + } + } + else if (args.count()>2) + { + if ( !QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)),Q_ARG(QString, args.at(2)) + )) + retVal=4042; + } + else if (args.count()>1) + { + if ( !QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) , + Q_ARG(QString, args.at(0)),Q_ARG(QString, args.at(1)) + )) + retVal=4042; + } + else if (args.count()>0) + { + if ( !QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) ,Q_ARG(QString, args.at(0)))) + retVal=4042; + } + else + { + if ( !QMetaObject::invokeMethod(this, (action),Q_RETURN_ARG(int, retVal) )) + { + retVal=4042; + } + } + + stream_m->flush (); + stream_m=0; + if(buffer.size()) + QxtWebCore::send(buffer); + return retVal; +}; + + + + +