Пример #1
0
void EffectManager::scaleEffect(int t)
{
    if(prev_img.bitmap) {
        if(start_pos > -1) {
            int w_sz = 0;
            int h_sz = 0;

            int xpos = 0;
            int ypos = 0;

            switch(t)
            {
            case 0:
                w_sz = rect().w()-start_pos;
                h_sz = rect().h() - (rect().h() *(start_pos*100/rect().w()) /100);
                xpos = start_pos/2;
                ypos = ((rect().h() *(start_pos*100/rect().w()) /100))/2;
                break;

            case 1:
                w_sz = rect().w()-start_pos;
                h_sz = prev_img.h;
                xpos = 0;
                ypos = 0;
                break;

            case 2:
                w_sz = rect().w()-start_pos;
                h_sz = prev_img.h;
                xpos = start_pos;
                ypos = 0;
                break;
            }

            //drawImage(0, 0, &prev_img);
            ScaleAndPaint(glActiveContext(), (unsigned short*)prev_img.bitmap, rect().w(), rect().h(),
                          xpos, ypos, w_sz, h_sz, 255);
        }
    }

    if(start_pos > (prev_img.w)) {
        stop();
        eventManager()->updateAfterEvent();
        eventManager()->refresh();
    } else {
        eventManager()->refresh();
    }

    start_pos += speed;
    speed += speed * 10 / 100+1;
}
Пример #2
0
void EffectManager::timerEvent()
{
    if(timer.period() != 40) {
        timer.resetPeriod(40);
    }
    eventManager()->updateAfterEvent();
}
Пример #3
0
int     main(int ac, char **av)
{

    WINDOW      *my_wins[3];
    PANEL       *my_panels[3];


    setlocale(LC_ALL, "");
    Explorer    exp((ac < 2) ? "/" : av[1]);
    exp.sort();
    MenuLeft        menu_left(&exp);
    MenuRight       menu_right(&exp);
    initCurses();
    initColor();
    init_wins(my_wins, 3);
    menu_left.setup(my_wins[0]);
    menu_right.setup(my_wins[1]);
    traceExplorateur();
    refresh();
    setUpPanel(my_panels, my_wins);
    eventManager(&menu_left, &menu_right, my_wins[2], my_panels);
    endwin();
    std::cout << exp << std::endl;
    return 0;
}
Пример #4
0
void TechBot::welcome()
{
    eventManager("welcome**");
    chooseOutput();
    Savelog();
    Savelog("TechTron");
    //speak(TB_Response);
    print_response();
}
Пример #5
0
void EffectManager::alphaEffect(int t)
{
    if(prev_img.bitmap) {
        if(start_pos > -1) {
            int alpha = 0;

            switch(t)
            {
            case 0:
                alpha = 0xff - (0xff * (start_pos*100/rect().w()) / 100);
                if(!next_img.bitmap) {
                    next_img.bitmap = malloc(rect().w()*rect().h()*2);
                }
                memcpy(next_img.bitmap, Graphics_GetScreenBuffer(), rect().w()*rect().h()*2);

                glDrawBitmap(0, 0, prev_img.w, prev_img.h, prev_img.bit, prev_img.bitmap);

                glDrawAlphaBitmap(0, 0, alpha, prev_img.w, prev_img.h, prev_img.bit, next_img.bitmap);
                break;

            case 1:
                alpha = (0xff * (start_pos*100/rect().w()) / 100);
                glDrawAlphaBitmap(0, 0, alpha, prev_img.w, prev_img.h, prev_img.bit, prev_img.bitmap);
                break;
            }
        }
    }

    if(start_pos > (prev_img.w)-speed) {
        stop();
        eventManager()->updateAfterEvent();

    } else {
        eventManager()->refresh();
    }

    start_pos += speed;
    speed += speed * 8 / 100+1;
}
Пример #6
0
bool MyMainWindow::eventFilter(unsigned long event, unsigned long p1, unsigned long )
{
    // Пока так, нужно для работы таймеров
    switch(event)
    {
        case MSG_TIMER:
        {
            __timer_notifier(p1);
            eventManager()->update();
            break;
        }
    }

    return true; // true - продолжить, false - пропустить
}
Пример #7
0
void EffectManager::start(int effect, int delay)
{
    reset();

    m_effect = effect;
    start_pos = 0;
    end_pos = prev_img.w;
    speed = 20;

    //printf("Show delay %d\n", delay);
    show();

    timer.start(delay);
    m_isActive = true;

    eventManager()->updateAfterEvent();
}
void
TL_Central::start()
{
	// TO DO - take info from configuration

	// create the pool server
	TL_EPollServer server(100, 1000);
		
	TL_SocketEventManager eventManager(1);

	TL_EventBuffer::Instance().setBufferSize(1000);

	try
	{
		// start event manager before server to be ready to accept events
		eventManager.start();
		
		server.listen("*", "3333", TL_EventBuffer::addEvents, TL_EventBuffer::addNewConnections);
	
		server.start();

		TL_SignalManager::Instance().addSignalReceiver(this, SIGHUP);
		// loop waiting for signals
		for(;;)
		{
			TL_Timespec theWait(TL_Timespec::NOW);
			theWait.add(1, 0); // 1 sec
			TL_SignalManager::Instance().process(theWait);
		}
	}
	catch (std::exception& e)
	{
		TL_ExceptionComply eC(e);

		LOG(this, "TL_Central::start" , TL_Log::NORMAL,
			eC.what() << " " << eC.who() );
	}

	TL_Timespec theWait(TL_Timespec::NOW);
	theWait.add(10,0);
	TL_ThreadManager::Instance().cancelAllThreads(theWait);
	server.destroy();
	eventManager.destroy();
}
Пример #9
0
void MyMainWindow::paintEvent()
{
    Rect rc = realRect();

    glSetPen(0xFF1d1b1b);
    glDrawFilledRectange(rc.x(), rc.y(), rc.x2(), rc.y2());

    glSetPen(0xFFFFFFFF);
    glDrawHLine(rc.x(), rc.x2(), rc.y()+25);

    //glDrawString(filename, rect().x()+3, rect().y(), rect().x2(), rect().y()+25, 18, FT_TEXT_H_CENTER, 0, 128);
    m_headText.paintEvent();


    int mx, my;

    mx = rc.w() / 2 - m_musicImage.width()/2;
    my = m_mediaList.rect().h() / 2 - m_musicImage.height()/2;

    drawImage(rc.x()+mx, m_mediaList.rect().y()+my, &m_musicImage);

    if(!m_player->isPlaying()) {
        m_playPos.setPosition(0);
        m_playPos.setLength(0);

    } else {
        m_playPos.setPosition(m_player->position());
        m_playPos.setLength(m_player->length());


        if(m_player->isHaveAlbymImage())
            drawImage(rc.x(), m_playButton.realRect().y2(), &m_player->albymImage());
    }


    MainWindow::paintEvent();

    eventManager()->update();
}
Пример #10
0
HRESULT
nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
    FUNCDESC *pFuncDesc = NULL;
    HRESULT hr = S_OK;
    CComBSTR bstrName;

    // Must search and compare each member to the dispid...
    if (m_spEventSinkTypeInfo)
    {
	    HRESULT hr = S_OK;
	    TYPEATTR* pAttr;
	    hr = m_spEventSinkTypeInfo->GetTypeAttr(&pAttr);
        if (pAttr)
        {
	        int i;
	        for (i = 0; i < pAttr->cFuncs;i++)
	        {
		        hr = m_spEventSinkTypeInfo->GetFuncDesc(i, &pFuncDesc);
		        if (FAILED(hr))
			        return hr;
		        if (pFuncDesc->memid == dispIdMember)
                {
                    UINT cNames = 0;
                    m_spEventSinkTypeInfo->GetNames(dispIdMember, &bstrName, 1, &cNames);
			        break;
                }
                
		        m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc);
		        pFuncDesc = NULL;
	        }
	        m_spEventSinkTypeInfo->ReleaseTypeAttr(pAttr);
        }
    }
    if (!pFuncDesc)
    {
        // Return
        return S_OK;
    }

#ifdef DEBUG
    {
        // Dump out some info to look at
        ATLTRACE(_T("Invoke(%d)\n"), (int) dispIdMember);

        ATLTRACE(_T("  "));

        /* Return code */
        switch (pFuncDesc->elemdescFunc.tdesc.vt)
        {
        case VT_HRESULT:     ATLTRACE(_T("HRESULT")); break;
        case VT_VOID:        ATLTRACE(_T("void")); break;
        default:             ATLTRACE(_T("void /* vt = %d */"), pFuncDesc->elemdescFunc.tdesc.vt); break;
        }

        /* Function name */
        ATLTRACE(_T(" %S("), SUCCEEDED(hr) ? bstrName.m_str : L"?unknown?");

        /* Parameters */
        for (int i = 0; i < pFuncDesc->cParams; i++)
        {
            USHORT  paramFlags = pFuncDesc->lprgelemdescParam[i].paramdesc.wParamFlags;
            ATLTRACE("[");
            BOOL addComma = FALSE;
            if (paramFlags & PARAMFLAG_FIN)
            {
                ATLTRACE(_T("in")); addComma = TRUE;
            }
            if (paramFlags & PARAMFLAG_FOUT)
            {
                ATLTRACE(addComma ? _T(",out") : _T("out")); addComma = TRUE;
            }
            if (paramFlags & PARAMFLAG_FRETVAL)
            {
                ATLTRACE(addComma ? _T(",retval") : _T("retval")); addComma = TRUE;
            }
            ATLTRACE("] ");

            VARTYPE vt = pFuncDesc->lprgelemdescParam[i].tdesc.vt;
            switch (vt)
            {
            case VT_HRESULT:     ATLTRACE(_T("HRESULT")); break;
            case VT_VARIANT:     ATLTRACE(_T("VARIANT")); break;
            case VT_I2:          ATLTRACE(_T("short")); break;
            case VT_I4:          ATLTRACE(_T("long")); break;
            case VT_R8:          ATLTRACE(_T("double")); break;
            case VT_BOOL:        ATLTRACE(_T("VARIANT_BOOL")); break;
            case VT_BSTR:        ATLTRACE(_T("BSTR")); break;
            case VT_DISPATCH:    ATLTRACE(_T("IDispatch *")); break;
            case VT_UNKNOWN:     ATLTRACE(_T("IUnknown *")); break;
            case VT_USERDEFINED: ATLTRACE(_T("/* Userdefined */")); break;
            case VT_PTR:         ATLTRACE(_T("void *")); break;
            case VT_VOID:        ATLTRACE(_T("void")); break;
            // More could be added...
            default:             ATLTRACE(_T("/* vt = %d */"), vt); break;
            }
            if (i + 1 < pFuncDesc->cParams)
            {
                ATLTRACE(_T(", "));
            }
        }
        ATLTRACE(_T(");\n"));
    }
#endif
    m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc);
    pFuncDesc = NULL;

    nsCOMPtr<nsIDOMElement> element;
    NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMElement, 
        static_cast<nsIDOMElement **>(getter_AddRefs(element)));
    if (!element)
    {
        NS_ERROR("can't get the object element");
        return S_OK;
    }
    nsAutoString id;
    if (NS_FAILED(element->GetAttribute(NS_LITERAL_STRING("id"), id)) ||
        id.IsEmpty())
    {
        // Object has no name so it can't fire events
        return S_OK;
    }

    nsDependentString eventName(bstrName.m_str);

    // Fire the script event handler...
    nsCOMPtr<nsIDOMWindow> window;
    NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMWindow, 
        static_cast<nsIDOMWindow **>(getter_AddRefs(window)));
    
    nsCOMPtr<nsIScriptEventManager> eventManager(do_GetInterface(window));
    if (!eventManager) return S_OK;

    nsCOMPtr<nsISupports> handler;

    eventManager->FindEventHandler(id, eventName, pDispParams->cArgs, getter_AddRefs(handler));
    if (!handler)
    {
        return S_OK;
    }

    // Create a list of arguments to pass along
    //
    // This array is created on the stack if the number of arguments
    // less than kMaxArgsOnStack.  Otherwise, the array is heap
    // allocated.
    //
    const int kMaxArgsOnStack = 10;

    PRUint32 argc = pDispParams->cArgs;
    jsval *args = nsnull;
    jsval stackArgs[kMaxArgsOnStack];

    // Heap allocate the jsval array if it is too big to fit on
    // the stack (ie. more than kMaxArgsOnStack arguments)
    if (argc > kMaxArgsOnStack)
    {
        args = new jsval[argc];
        if (!args) return S_OK;
    }
    else if (argc)
    {
        // Use the jsval array on the stack...
        args = stackArgs;
    }

    if (argc)
    {
        nsCOMPtr<nsIDispatchSupport> disp(do_GetService("@mozilla.org/nsdispatchsupport;1"));
        for (UINT i = 0; i < argc; i++)
        {
            // Arguments are listed backwards, intentionally, in rgvarg
            disp->COMVariant2JSVal(&pDispParams->rgvarg[argc - 1 - i], &args[i]);
        }
    }

    // Fire the Event.
    eventManager->InvokeEventHandler(handler, element, args, argc);

    // Free the jsvals if they were heap allocated...
    if (args != stackArgs)
    {
        delete [] args;
    }

    // TODO Turn js objects for out params back into VARIANTS

    // TODO Turn js return code into VARIANT

    // TODO handle js exception and fill in exception info (do we care?)

    if (pExcepInfo)
    {
        pExcepInfo->wCode = 0;
    }

    return S_OK;
}
Пример #11
0
void MyMainWindow::touchEvent(int action, int x, int y)
{
    MainWindow::touchEvent(action, x, y);
    eventManager()->update();
}
Пример #12
0
MyMainWindow::MyMainWindow(EventManager *event_manager, MediaPlayer *p) :
    MainWindow(0, Rect(0, 0, GRSYS_WIDTH, GRSYS_HEIGHT), event_manager),
    m_headText(event_manager, Rect(rect().x(), rect().y(), rect().w(), 24)),
    m_playPos(Rect(), this),
    m_lastTouchedButton(0),
    m_functionalTab(Rect(0, rect().h()-48, rect().w(), 48), this, TabBox::Horizontal),
    m_stopButton(Rect(), this, ""),
    m_prevButton(Rect(), this, ""),
    m_playButton(Rect(), this, ""),
    m_nextButton(Rect(), this, ""),
    m_mediaList(Rect(4, 0, rect().w()-8, 0), this),
    m_musicImage(resource_manager->image("music")),
    setup_handle(-1),
    m_player(p),
    m_currentPlayedItem(0)
{
    setup_handle = SetUP_GetHandle();

    m_playImg  = &resource_manager->image("play");
    m_stopImg  = &resource_manager->image("stop");
    m_pauseImg = &resource_manager->image("pause");
    m_prevImg  = &resource_manager->image("prev");
    m_nextImg  = &resource_manager->image("next");

    m_headText.setText( path2name(m_player->file()) );
    m_headText.start(200);
    m_headText.setTextSize(18);
    m_headText.setTextAttrs(FT_TEXT_H_CENTER);

    m_playPos.setSize( Rect(9, rect().h()-78, rect().w()-18, 16) );
    m_playPos.show();

    m_playPos.positionSelected().connect( [this](int pos) {
        //printf("Percent: %d\n", pos);

        unsigned int ms = m_player->length()*pos / 100;
        m_player->seek(ms);
    });

    //m_timer.start(1000);
    m_timer.timerEventSignal().connect( [this](Timer *) {
        eventManager()->updateAfterEvent();
    });


    m_functionalTab.show();
    m_functionalTab.addTab("List");
    m_functionalTab.addTab("Play");
    m_functionalTab.addTab("Info");
    m_functionalTab.addTab("Exit");

    m_functionalTab.setFocusTab(1);

    m_functionalTab.onTabChanged().connect( this, &MyMainWindow::tabBoxChanged,
                                            std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);

    setupMediaButtons();


    ListMenuStyle menu_style = m_mediaList.style();

    menu_style.setShadow( Brush() );
    menu_style.setBackground( Brush() );

    m_mediaList.setStyle(menu_style);

    Rect rc =  m_mediaList.rect();
    rc.setY(m_headText.size().h() + m_prevButton.rect().h()+10);
    rc.setH( rect().h() - (m_mediaList.rect().y() + (rect().h() - m_playPos.rect().y()) + 90 ));

    m_mediaList.setSize(rc);


    m_mediaList.resizeEvent();

    scanFolder();

    m_player->endAction().connect( [this](MediaPlayer *){
        playNext();
    });
}
Пример #13
0
void MyMainWindow::keyEvent(int type, int key)
{
    if(type == KEY_DOWN) {
        switch (key)
        {
            case KEY_CAMERA:
            {
                image_t img;

                img.bitmap = Graphics_GetScreenBuffer();
                img.w = GRSYS_WIDTH;
                img.h = GRSYS_HEIGHT;
                img.bit = 16;

                save_png_to_file (&img, "/usr/Zbin/shoot.png");
                break;
            }

            case KEY_SEND:
                break;

            case KEY_MULTI:
                TaskMngr_Show();
                break;

            case KEY_END:
                TaskMngr_AppExit(0, 0, 0);
                break;

            case BNS_VOLUP_K:
                m_player->incrementVolume();

                volumeTimer.timerEventSignal().clear();
                volumeTimer.timerEventSignal().connect( [this](Timer*) {

                    volumeTimer.stop();
                    eventManager()->notifyAfterEvent( [this]() {
                        volumeTimer.start(100);
                        volumeTimer.timerEventSignal().clear();
                        volumeTimer.timerEventSignal().connect( [this](Timer*) {
                            m_player->incrementVolume();
                        });
                    });
                });

                volumeTimer.start(800);
                break;

            case BNS_VOLDOWN_K:
                m_player->decrementVolume();

                volumeTimer.timerEventSignal().clear();
                volumeTimer.timerEventSignal().connect( [this](Timer*) {

                    volumeTimer.stop();

                    eventManager()->notifyAfterEvent( [this]() {
                        volumeTimer.start(100);
                        volumeTimer.timerEventSignal().clear();

                        volumeTimer.timerEventSignal().connect( [this](Timer*) {
                            m_player->decrementVolume();
                        });
                    });

                });

                volumeTimer.start(800);
                break;

        }
    }


    if(type == KEY_UP)
    {
        switch (key)
        {
            case BNS_VOLUP_K: case BNS_VOLDOWN_K:
                volumeTimer.stop();
                break;
        }
    }

    eventManager()->update();
}
Пример #14
0
void MyMainWindow::scanFolder() {

    const std::string &m_file = m_player->file();
    const char *f = strrchr(m_file.c_str(), '/');

    if(!f)
        return;

    ++f;

    m_playFile = m_file;

    char folder[128];
    memcpy(folder, m_file.c_str(), f-m_file.c_str());
    folder[f-m_file.c_str()] = 0;

    m_workFolder = folder;

    int h = fs_opendir(folder);

    printf("open %s - %d\n", folder, h);

    std::string fname = path2name(m_playFile);

    if(h > 0) {
        FS_INFO info;
        while(!fs_readdir(h, &info)) {

            if(!(info.attr & FS_ATTR_FOLDER)) {

                ListMenuItem *mi = 0;
                m_mediaList.scrollArea().addItem(
                           (mi = new ListMenuItem(&m_mediaList, m_mediaList.rect().w(), 40, info.name)) );

                if(info.name == fname) {
                    mi->setIcon( &resource_manager->image("played") );
                    m_currentPlayedItem = mi;

                } else
                    mi->setIcon( &resource_manager->image("music_small") );

                mi->onReleasedSignal().connect( [this](ListMenuItem *i) {
                    m_playFile = m_workFolder + i->text();
                    m_player->play(m_playFile);
                    m_headText.setText(i->text());
                    m_headText.start(200);

                    m_currentPlayedItem->setIcon( &resource_manager->image("music_small") );
                    i->setIcon( &resource_manager->image("played") );

                    m_currentPlayedItem = i;
                    eventManager()->updateAfterEvent();
                });
            }
        }

        fs_closedir(h);
    }



    m_mediaList.scrollArea().setLinesCount(m_mediaList.scrollArea().items().size());
}
Пример #15
0
/* used to be handleServerMsg()                                  */
void IrcParser::processNetworkIncoming(NetworkDataEvent *e)
{
    CoreNetwork *net = qobject_cast<CoreNetwork *>(e->network());
    if (!net) {
        qWarning() << "Received network event without valid network pointer!";
        return;
    }

    // note that the IRC server is still alive
    net->resetPingTimeout();

    QByteArray msg = e->data();
    if (msg.isEmpty()) {
        qWarning() << "Received empty string from server!";
        return;
    }

    // Now we split the raw message into its various parts...
    QString prefix;
    QByteArray trailing;
    QString cmd, target;

    // First, check for a trailing parameter introduced by " :", since this might screw up splitting the msg
    // NOTE: This assumes that this is true in raw encoding, but well, hopefully there are no servers running in japanese on protocol level...
    int idx = msg.indexOf(" :");
    if (idx >= 0) {
        if (msg.length() > idx + 2)
            trailing = msg.mid(idx + 2);
        msg = msg.left(idx);
    }
    // OK, now it is safe to split...
    QList<QByteArray> params = msg.split(' ');

    // This could still contain empty elements due to (faulty?) ircds sending multiple spaces in a row
    // Also, QByteArray is not nearly as convenient to work with as QString for such things :)
    QList<QByteArray>::iterator iter = params.begin();
    while (iter != params.end()) {
        if (iter->isEmpty())
            iter = params.erase(iter);
        else
            ++iter;
    }

    if (!trailing.isEmpty())
        params << trailing;
    if (params.count() < 1) {
        qWarning() << "Received invalid string from server!";
        return;
    }

    QString foo = net->serverDecode(params.takeFirst());

    // a colon as the first chars indicates the existence of a prefix
    if (foo[0] == ':') {
        foo.remove(0, 1);
        prefix = foo;
        if (params.count() < 1) {
            qWarning() << "Received invalid string from server!";
            return;
        }
        foo = net->serverDecode(params.takeFirst());
    }

    // next string without a whitespace is the command
    cmd = foo.trimmed();

    QList<Event *> events;
    EventManager::EventType type = EventManager::Invalid;

    uint num = cmd.toUInt();
    if (num > 0) {
        // numeric reply
        if (params.count() == 0) {
            qWarning() << "Message received from server violates RFC and is ignored!" << msg;
            return;
        }
        // numeric replies have the target as first param (RFC 2812 - 2.4). this is usually our own nick. Remove this!
        target = net->serverDecode(params.takeFirst());
        type = EventManager::IrcEventNumeric;
    }
    else {
        // any other irc command
        QString typeName = QLatin1String("IrcEvent") + cmd.at(0).toUpper() + cmd.mid(1).toLower();
        type = eventManager()->eventTypeByName(typeName);
        if (type == EventManager::Invalid) {
            type = eventManager()->eventTypeByName("IrcEventUnknown");
            Q_ASSERT(type != EventManager::Invalid);
        }
        target = QString();
    }

    // Almost always, all params are server-encoded. There's a few exceptions, let's catch them here!
    // Possibly not the best option, we might want something more generic? Maybe yet another layer of
    // unencoded events with event handlers for the exceptions...
    // Also, PRIVMSG and NOTICE need some special handling, we put this in here as well, so we get out
    // nice pre-parsed events that the CTCP handler can consume.

    QStringList decParams;
    bool defaultHandling = true; // whether to automatically copy the remaining params and send the event

    switch (type) {
    case EventManager::IrcEventPrivmsg:
        defaultHandling = false; // this might create a list of events

        if (checkParamCount(cmd, params, 1)) {
            QString senderNick = nickFromMask(prefix);
            QByteArray msg = params.count() < 2 ? QByteArray() : params.at(1);

            QStringList targets = net->serverDecode(params.at(0)).split(',', QString::SkipEmptyParts);
            QStringList::const_iterator targetIter;
            for (targetIter = targets.constBegin(); targetIter != targets.constEnd(); ++targetIter) {
                QString target = net->isChannelName(*targetIter) ? *targetIter : senderNick;

                msg = decrypt(net, target, msg);

                events << new IrcEventRawMessage(EventManager::IrcEventRawPrivmsg, net, msg, prefix, target, e->timestamp());
            }
        }
        break;

    case EventManager::IrcEventNotice:
        defaultHandling = false;

        if (checkParamCount(cmd, params, 2)) {
            QStringList targets = net->serverDecode(params.at(0)).split(',', QString::SkipEmptyParts);
            QStringList::const_iterator targetIter;
            for (targetIter = targets.constBegin(); targetIter != targets.constEnd(); ++targetIter) {
                QString target = *targetIter;

                // special treatment for welcome messages like:
                // :ChanServ!ChanServ@services. NOTICE egst :[#apache] Welcome, this is #apache. Please read the in-channel topic message. This channel is being logged by IRSeekBot. If you have any question please see http://blog.freenode.net/?p=68
                if (!net->isChannelName(target)) {
                    QString decMsg = net->serverDecode(params.at(1));
                    QRegExp welcomeRegExp("^\\[([^\\]]+)\\] ");
                    if (welcomeRegExp.indexIn(decMsg) != -1) {
                        QString channelname = welcomeRegExp.cap(1);
                        decMsg = decMsg.mid(welcomeRegExp.matchedLength());
                        CoreIrcChannel *chan = static_cast<CoreIrcChannel *>(net->ircChannel(channelname)); // we only have CoreIrcChannels in the core, so this cast is safe
                        if (chan && !chan->receivedWelcomeMsg()) {
                            chan->setReceivedWelcomeMsg();
                            events << new MessageEvent(Message::Notice, net, decMsg, prefix, channelname, Message::None, e->timestamp());
                            continue;
                        }
                    }
                }

                if (prefix.isEmpty() || target == "AUTH") {
                    target = QString();
                }
                else {
                    if (!target.isEmpty() && net->prefixes().contains(target.at(0)))
                        target = target.mid(1);
                    if (!net->isChannelName(target))
                        target = nickFromMask(prefix);
                }

#ifdef HAVE_QCA2
                // Handle DH1080 key exchange
                if (params[1].startsWith("DH1080_INIT") && !net->isChannelName(target)) {
                    events << new KeyEvent(EventManager::KeyEvent, net, prefix, target, KeyEvent::Init, params[1].mid(12));
                } else if (params[1].startsWith("DH1080_FINISH") && !net->isChannelName(target)) {
                    events << new KeyEvent(EventManager::KeyEvent, net, prefix, target, KeyEvent::Finish, params[1].mid(14));
                } else
#endif
                    events << new IrcEventRawMessage(EventManager::IrcEventRawNotice, net, params[1], prefix, target, e->timestamp());
            }
        }
        break;

    // the following events need only special casing for param decoding
    case EventManager::IrcEventKick:
        if (params.count() >= 3) { // we have a reason
            decParams << net->serverDecode(params.at(0)) << net->serverDecode(params.at(1));
            decParams << net->channelDecode(decParams.first(), params.at(2)); // kick reason
        }
        break;

    case EventManager::IrcEventPart:
        if (params.count() >= 2) {
            QString channel = net->serverDecode(params.at(0));
            decParams << channel;
            decParams << net->userDecode(nickFromMask(prefix), params.at(1));
        }
        break;

    case EventManager::IrcEventQuit:
        if (params.count() >= 1) {
            decParams << net->userDecode(nickFromMask(prefix), params.at(0));
        }
        break;

    case EventManager::IrcEventTopic:
        if (params.count() >= 1) {
            QString channel = net->serverDecode(params.at(0));
            decParams << channel;
            decParams << (params.count() >= 2 ? net->channelDecode(channel, decrypt(net, channel, params.at(1), true)) : QString());
        }
        break;

    case EventManager::IrcEventNumeric:
        switch (num) {
        case 301: /* RPL_AWAY */
            if (params.count() >= 2) {
                QString nick = net->serverDecode(params.at(0));
                decParams << nick;
                decParams << net->userDecode(nick, params.at(1));
            }
            break;

        case 332: /* RPL_TOPIC */
            if (params.count() >= 2) {
                QString channel = net->serverDecode(params.at(0));
                decParams << channel;
                decParams << net->channelDecode(channel, decrypt(net, channel, params.at(1), true));
            }
            break;

        case 333: /* Topic set by... */
            if (params.count() >= 3) {
                QString channel = net->serverDecode(params.at(0));
                decParams << channel << net->serverDecode(params.at(1));
                decParams << net->channelDecode(channel, params.at(2));
            }
            break;
        }

    default:
        break;
    }

    if (defaultHandling && type != EventManager::Invalid) {
        for (int i = decParams.count(); i < params.count(); i++)
            decParams << net->serverDecode(params.at(i));

        // We want to trim the last param just in case, except for PRIVMSG and NOTICE
        // ... but those happen to be the only ones not using defaultHandling anyway
        if (!decParams.isEmpty() && decParams.last().endsWith(' '))
            decParams.append(decParams.takeLast().trimmed());

        IrcEvent *event;
        if (type == EventManager::IrcEventNumeric)
            event = new IrcEventNumeric(num, net, prefix, target);
        else
            event = new IrcEvent(type, net, prefix);
        event->setParams(decParams);
        event->setTimestamp(e->timestamp());
        events << event;
    }

    foreach(Event *event, events) {
        emit newEvent(event);
    }