Esempio n. 1
0
void TextMessageDlg::timerEvent(QTimerEvent *event)
{
    if(m_local_typing_id == event->timerId())
    {
        if(m_textchanged)
        {
            ServerProperties srvprop;
            if(TT_GetServerProperties(ttInst, &srvprop))
            {
                TextMessage msg;
                ZERO_STRUCT(msg);
                msg.nFromUserID = TT_GetMyUserID(ttInst);
                msg.nMsgType = MSGTYPE_CUSTOM;
                msg.nToUserID = m_userid;
                QString cmd = makeCustomCommand(TT_INTCMD_TYPING_TEXT,
                                                QString::number((int)!ui.newmsgTextEdit->toPlainText().isEmpty()));
                COPY_TTSTR(msg.szMessage, cmd);
                if(TT_DoTextMessage(ttInst, &msg)>0)
                    emit(newMyselfTextMessage(msg));
            }
            m_textchanged = false;
        }
    }

    if(m_remote_typing_id == event->timerId())
    {
        ui.newmsgLabel->setText(tr("New message"));
        killTimer(m_remote_typing_id);
        m_remote_typing_id = 0;
    }
}
void BannedUsersDlg::slotBanIPAddress()
{
    if(TT_DoBanIPAddress(ttInst, _W(ui.ipaddrEdit->text()))>0)
    {
        BannedUser user;
        ZERO_STRUCT(user);
        COPY_TTSTR(user.szIPAddress, ui.ipaddrEdit->text());
        ui.ipaddrEdit->setText("");
        m_bannedmodel->addBannedUser(user, true);
    }
}
void UserDesktopWidget::slotContextMenu(const QPoint& p)
{
    Q_UNUSED(p);

    //don't show context menu if we're currently using desktop access
    if(m_user.uPeerSubscriptions & SUBSCRIBE_DESKTOPINPUT)
        return;

    QMenu menu(this);
#ifndef USE_TT_PAINT
    QAction* save = menu.addAction(tr("&Save to Image File"));
#endif
    menu.addSeparator();

    QAction* access = NULL;
    if(m_access_requested)
        access = menu.addAction(tr("Retract &Desktop Access"));
    else
        access = menu.addAction(tr("Request &Desktop Access"));
    access->setIcon(QIcon(QString::fromUtf8(":/images/images/chalkstick.png")));
    QAction* result = menu.exec(QCursor::pos());
#ifndef USE_TT_PAINT
    if(result == save)
    {
        QString name = QFileDialog::getSaveFileName(this, tr("Save File"), 
                                                    "", tr("PNG files (*.png)"));
        if(name.size() && !m_image.save(name, "PNG"))
            QMessageBox::critical(this, tr("&Save to Image File"), tr("Failed to save file."));
    }
    else
#endif
    if(result == access)
    {
        TextMessage msg;
        ZERO_STRUCT(msg);
        msg.nFromUserID = TT_GetMyUserID(ttInst);
        msg.nMsgType = MSGTYPE_CUSTOM;
        msg.nToUserID = m_userid;
        m_access_requested = !m_access_requested;
        QString cmd = makeCustomCommand(TT_INTCMD_DESKTOP_ACCESS, 
                                        QString::number(m_access_requested));
        COPY_TTSTR(msg.szMessage, cmd);
        TT_DoTextMessage(ttInst, &msg);
    }
}
Esempio n. 4
0
void TextMessageDlg::slotSendMsg(const QString& txt_msg)
{
    if(txt_msg.isEmpty())
        return;

    TextMessage msg;
    ZERO_STRUCT(msg);
    msg.nFromUserID = TT_GetMyUserID(ttInst);
    msg.nChannelID = 0;
    msg.nMsgType = MSGTYPE_USER;
    msg.nToUserID = m_userid;
    COPY_TTSTR(msg.szMessage, txt_msg);
    if(TT_DoTextMessage(ttInst, &msg)>0)
    {
        ui.newmsgTextEdit->setPlainText("");
        newMsg(msg, true);
        emit(newMyselfTextMessage(msg));
        m_textchanged = false;
    }
}