Beispiel #1
0
void ChannelsModel::slotUpdateChannel(int channelid)
{
    Channel chan = {0};
    if(!TT_GetChannel(ttInst, channelid, &chan))
        return;

    mchannels_t::const_iterator p_ite = m_channelparent.find(channelid);
    Q_ASSERT(p_ite != m_channelparent.end());
    channels_t::iterator c_ite = m_channels.find(p_ite.value());
    Q_ASSERT(c_ite != m_channels.end());
    subchannels_t& subs = c_ite.value();
    subchannels_t::iterator ite = subs.begin();
    while(ite != subs.end())
    {
        if(ite->nChannelID == channelid)
        {
            ite = subs.erase(ite);
            subs.insert(ite, chan);
            break;
        }
        ite++;
    }

    reset();
}
Beispiel #2
0
void ChannelsModel::slotAddChannel(int channelid)
{
    Channel chan = {0};
    if(!TT_GetChannel(ttInst, channelid, &chan))
        return;

    if(channelid = TT_GetRootChannelID(ttInst))
    {
        m_rootchannelid = channelid;
        m_channels.insert(0, subchannels_t()); //virtual channel to simulate root
    }

    channels_t::iterator ite = m_channels.find(chan.nParentID);
    if(ite != m_channels.end())
    {
        subchannels_t& subs = ite.value();
        subchannels_t::iterator sub_ite = subs.begin();
        while(sub_ite != subs.end())
        {
            if(wcscmp(chan.szName, sub_ite->szName)<0)
                break;
            sub_ite++;
        }
        subs.insert(sub_ite, chan);
    }

    m_channels.insert(chan.nChannelID, subchannels_t());
    m_channelparent.insert(chan.nChannelID, chan.nParentID);
    m_users.insert(chan.nChannelID, chanusers_t());

    reset();
}
Beispiel #3
0
void ChatTextEdit::joinedChannel(int channelid)
{
    TTCHAR buff[TT_STRLEN];
    Channel chan;
    if(!TT_GetChannel(ttInst, channelid, &chan))
        return;
    if(!TT_GetChannelPath(ttInst, channelid, buff))
        return;

    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Joined new channel");
    setTextCursor(cursor);
    appendPlainText(line);
    //revert bold
    font.setBold(false);
    format.setFont(font);
    
    //show channel name in green
    line = tr("Channel: %1").arg(_Q(buff));
    format.setForeground(QBrush(Qt::darkGreen));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show topic in blue
    line = tr("Topic: %1").arg(_Q(chan.szTopic));
    format.setForeground(QBrush(Qt::darkBlue));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //show disk quota in red
    line = tr("Disk quota: %1 KBytes").arg(chan.nDiskQuota/1024);
    format.setForeground(QBrush(Qt::darkRed));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
Beispiel #4
0
void COnlineUsersDlg::MenuCommand(UINT uCmd)
{
    int nUserID =  0;
    int count = m_wndUsers.GetItemCount();
    for(int i=0;i<count;i++)
    {
        if(m_wndUsers.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED)
            nUserID = m_wndUsers.GetItemData(i);
    }

    User user = {0};
    TT_GetUser(ttInst, nUserID, &user);
    Channel chan = {0};
    TT_GetChannel(ttInst, user.nChannelID, &chan);

    switch(uCmd)
    {
    case ID_POPUP_KICKANDBAN :
        TT_DoBanUser(ttInst, nUserID, 0);
        TT_DoKickUser(ttInst, nUserID, 0);
        break;
    case ID_POPUP_KICK :
        TT_DoKickUser(ttInst, nUserID, user.nChannelID);
        break;
    case ID_POPUP_OP :
        TT_DoChannelOpEx(ttInst, nUserID, user.nChannelID, chan.szOpPassword, 
                         !TT_IsChannelOperator(ttInst, nUserID, user.nChannelID));
        break;
    case ID_POPUP_COPYUSERINFORMATION :
    {
        User user;
        if(TT_GetUser(ttInst, nUserID, &user))
        {
            CString szText;
            CString szUserID;
            szUserID.Format(_T("%d"), user.nUserID);
            TTCHAR szChannel[TT_STRLEN] = _T("");
            TT_GetChannelPath(ttInst, user.nChannelID, szChannel);
            szText = szUserID;
            szText += _T("\t");
            szText += user.szNickname;
            szText += _T("\t");
            szText += user.szStatusMsg;
            szText += _T("\t");
            szText += user.szUsername;
            szText += _T("\t");
            szText += szChannel;
            szText += _T("\t");
            szText += user.szIPAddress;
            szText += _T("\t");
            szText += GetVersion(user);

            OpenClipboard();
            EmptyClipboard();
            HGLOBAL hglbCopy;
            hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
                                   (szText.GetLength() + 1) * sizeof(TCHAR));
            if(hglbCopy)
            {
                LPVOID szStr = GlobalLock(hglbCopy);
                memcpy(szStr, szText.GetBuffer(), (szText.GetLength() + 1) * sizeof(TCHAR));
                GlobalUnlock(hglbCopy);
#if defined(UNICODE) || defined(_UNICODE)
                SetClipboardData(CF_UNICODETEXT, hglbCopy);
#else
                SetClipboardData(CF_TEXT, hglbCopy);
#endif
            }
            CloseClipboard();
        }
    }
    }
}