void CPositionUsersDlg::PositionButton(CUserButton* pBtn, int nUserID) { ASSERT(pBtn); if(pBtn) { CRect rect; CRect client; m_wndRoom.GetWindowRect(&client); ScreenToClient(&client); User user; if(TT_GetUser(ttInst, nUserID, &user)) { CPoint center(client.left + client.Width()/2, client.top + client.Height()/2); CRect btnRect; pBtn->GetWindowRect(btnRect); int nWidth = btnRect.Width(); int nHeight = btnRect.Height(); btnRect.left = center.x + (user.soundPositionVoice[0]*100.0f) - nWidth/2; btnRect.right = btnRect.left + nWidth; btnRect.top = center.y + (user.soundPositionVoice[1]*100.0f*(-1)) - nHeight/2; btnRect.bottom = btnRect.top + nHeight; pBtn->MoveWindow(btnRect.left, btnRect.top, btnRect.Width(), btnRect.Height()); } else { pBtn->EnableWindow(FALSE); } } }
void UserVideoWidget::slotUpdateVideoTextBox() { m_showvidtext = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_SHOW, false).toBool(); if(m_showvidtext) m_nickname.clear(); else { User user; if(TT_GetUser(ttInst, m_userid & VIDEOTYPE_USERMASK, &user)) m_nickname = getDisplayName(user); } m_vidtext = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT, SETTINGS_DISPLAY_VIDEOTEXT_DEFAULT).toUInt(); m_vidtext_w_pct = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_WIDTH, SETTINGS_DISPLAY_VIDEOTEXT_WIDTH_DEFAULT).toInt(); m_vidtext_h_pct = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_HEIGHT, SETTINGS_DISPLAY_VIDEOTEXT_HEIGHT_DEFAULT).toInt(); m_vidtext_bg = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_BGCOLOR, SETTINGS_DISPLAY_VIDEOTEXT_BGCOLOR_DEFAULT) .value<QColor>(); m_vidtext_fg = ttSettings->value(SETTINGS_DISPLAY_VIDEOTEXT_FGCOLOR, SETTINGS_DISPLAY_VIDEOTEXT_FGCOLOR_DEFAULT) .value<QColor>(); update(); }
UserVolumeDlg::UserVolumeDlg(int userid, QWidget * parent/* = 0*/) : QDialog(parent, QT_DEFAULT_DIALOG_HINTS) , m_userid(userid) { ui.setupUi(this); setWindowIcon(QIcon(APPICON)); ui.voicevolSlider->setRange(0, 100); ui.mfvolSlider->setRange(0, 100); connect(ui.voicevolSlider, SIGNAL(valueChanged(int)), SLOT(slotVolumeChanged(int))); connect(ui.voiceleftChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel())); connect(ui.voicerightChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel())); connect(ui.mfvolSlider, SIGNAL(valueChanged(int)), SLOT(slotVolumeChanged(int))); connect(ui.mfleftChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel())); connect(ui.mfrightChkBox, SIGNAL(clicked()), SLOT(slotMuteChannel())); connect(ui.defaultsButton, SIGNAL(clicked()), SLOT(slotDefaults())); User user; if(TT_GetUser(ttInst, m_userid, &user)) setWindowTitle(windowTitle() + QString(" - ") + _Q(user.szNickname)); ui.voicevolSlider->setValue(refVolumeToPercent(user.nVolumeVoice)); ui.mfvolSlider->setValue(refVolumeToPercent(user.nVolumeMediaFile)); ui.voiceleftChkBox->setChecked(!user.stereoPlaybackVoice[0]); ui.voicerightChkBox->setChecked(!user.stereoPlaybackVoice[1]); ui.mfleftChkBox->setChecked(!user.stereoPlaybackMediaFile[0]); ui.mfrightChkBox->setChecked(!user.stereoPlaybackMediaFile[1]); }
void UserVideoWidget::completePaint(const QRect& r, QPainter& painter) { if(m_showvidtext && m_vidtext != VIDEOTEXT_NONE) { User user; if(TT_GetUser(ttInst, m_userid & VIDEOTYPE_USERMASK, &user)) { QString text = QString("User #%1").arg(m_userid & VIDEOTYPE_USERMASK); switch(m_vidtext & VIDTEXT_SHOW_MASK) { case VIDTEXT_SHOW_NICKNAME : text = _Q(user.szNickname); break; case VIDTEXT_SHOW_USERNAME : text = _Q(user.szUsername); break; case VIDTEXT_SHOW_STATUSTEXT : text = _Q(user.szStatusMsg); break; } setVideoTextBox(r, m_vidtext_bg, m_vidtext_fg, text, m_vidtext, m_vidtext_w_pct, m_vidtext_h_pct, painter); } } }
ChangeStatusDlg::ChangeStatusDlg(QWidget* parent/* = 0*/) : QDialog(parent, QT_DEFAULT_DIALOG_HINTS) { ui.setupUi(this); setWindowIcon(QIcon(APPICON)); connect(this, SIGNAL(accepted()), SLOT(slotAccepted())); if(TT_GetUser(ttInst, TT_GetMyUserID(ttInst), &m_user)) { switch(m_user.nStatusMode & STATUSMODE_MODE) { case STATUSMODE_AVAILABLE: ui.availBtn->setFocus(); ui.availBtn->setChecked(true); break; case STATUSMODE_AWAY: ui.awayBtn->setFocus(); ui.awayBtn->setChecked(true); break; case STATUSMODE_QUESTION : ui.questionBtn->setFocus(); ui.questionBtn->setChecked(true); break; } ui.msgEdit->setText(_Q(m_user.szStatusMsg)); } }
void OnlineUsersModel::addUser(int userid) { this->beginResetModel(); User user; if(TT_GetUser(ttInst, userid, &user)) { m_users.insert(user.nUserID, user); } this->endResetModel(); }
QString ChatTextEdit::addTextMessage(const TextMessage& msg) { User user; if(!TT_GetUser(ttInst, msg.nFromUserID, &user)) return QString(); QString dt = getTimeStamp(); QString line = dt; switch(msg.nMsgType) { case MSGTYPE_USER : line += QString("<%1> %2").arg(getDisplayName(user)).arg(_Q(msg.szMessage)); break; case MSGTYPE_CHANNEL : if(msg.nChannelID != TT_GetMyChannelID(ttInst)) { TTCHAR chpath[TT_STRLEN] = {}; TT_GetChannelPath(ttInst, msg.nChannelID, chpath); line += QString("<%1->%2> %3").arg(getDisplayName(user)) .arg(_Q(chpath)).arg(_Q(msg.szMessage)); } else line += QString("<%1> %2").arg(getDisplayName(user)) .arg(_Q(msg.szMessage)); break; case MSGTYPE_BROADCAST : line += QString("<%1->BROADCAST> %2").arg(getDisplayName(user)) .arg(_Q(msg.szMessage)); break; case MSGTYPE_CUSTOM : break; } if(TT_GetMyUserID(ttInst) == msg.nFromUserID) { QTextCharFormat format = textCursor().charFormat(); QTextCharFormat original = format; format.setForeground(QBrush(Qt::darkGray)); QTextCursor cursor = textCursor(); cursor.setCharFormat(format); setTextCursor(cursor); appendPlainText(line); cursor.setCharFormat(original); setTextCursor(cursor); } else appendPlainText(line); limitText(); return line; }
void TextMessageDlg::newMsg(const TextMessage& msg, bool store) { switch(msg.nMsgType) { case MSGTYPE_USER : { QString line = ui.historyTextEdit->addTextMessage(msg); ui.newmsgLabel->setText(tr("New message")); QString folder = ttSettings->value(SETTINGS_MEDIASTORAGE_USERLOGFOLDER).toString(); if(store && folder.size()) { User user; if(TT_GetUser(ttInst, m_userid, &user)) { if(!m_logFile.isOpen()) openLogFile(m_logFile, folder, _Q(user.szNickname)); } writeLogEntry(m_logFile, line); } } break; case MSGTYPE_CUSTOM : { QStringList cmd_msg = getCustomCommand(msg); if(cmd_msg.size() >= 2 && cmd_msg[0] == TT_INTCMD_TYPING_TEXT) { if(cmd_msg[1] == "1") { ui.newmsgLabel->setText(tr("New message - remote user typing.")); if(m_remote_typing_id) killTimer(m_remote_typing_id); m_remote_typing_id = startTimer(REMOTE_TYPING_DELAY); } else { if(m_remote_typing_id) killTimer(m_remote_typing_id); m_remote_typing_id = 0; ui.newmsgLabel->setText(tr("New message")); } } break; } default : break; } }
void CUserDesktopDlg::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { User user; if(!TT_GetUser(ttInst, m_nUserID, &user) || (user.uPeerSubscriptions & SUBSCRIBE_DESKTOPINPUT)) return; CMenu menu; menu.LoadMenu(IDR_MENU_DESKTOPINPUT); TRANSLATE(menu); CMenu* pop = menu.GetSubMenu(0); if(!pop) return; UINT uCmd = pop->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this, NULL ); MenuCommand(uCmd); }
void CUserDesktopDlg::OnTimer(UINT_PTR nIDEvent) { CDialog::OnTimer(nIDEvent); switch(nIDEvent) { case TIMERID_GET_DESKTOPWINDOW : { DesktopWindow* wnd = TT_AcquireUserDesktopWindow(ttInst, m_nUserID); if(wnd) TT_ReleaseUserDesktopWindow(ttInst, m_desktopwnd); m_desktopwnd = wnd; if(m_desktopwnd) { CRect rect; GetClientRect(rect); if(rect.Width() != m_desktopwnd->nWidth || rect.Height() != m_desktopwnd->nHeight) ResizeToDesktopWindow(); } else AfxGetMainWnd()->PostMessage(WM_USERDESKTOPDLG_ENDED, m_nUserID); Invalidate(); break; } case TIMERID_SEND_DESKTOPINPUT : { User user; if(!TT_GetUser(ttInst, m_nUserID, &user) || (user.uPeerSubscriptions & SUBSCRIBE_DESKTOPINPUT) == 0) break; while(m_SendInputQueue.size()) { int n_send = min(m_SendInputQueue.size(), TT_DESKTOPINPUT_MAX); if(TT_SendDesktopInput(ttInst, m_nUserID, &m_SendInputQueue[0], n_send)) m_SendInputQueue.erase(m_SendInputQueue.begin(), m_SendInputQueue.begin()+n_send); else break; } } break; } }
void ChannelsModel::slotAddUser(int userid, int channelid) { User user = {0}; if(!TT_GetUser(ttInst, userid, &user)) return; users_t::iterator c_ite = m_users.find(channelid); Q_ASSERT(c_ite != m_users.end()); chanusers_t& users = c_ite.value(); chanusers_t::iterator ite = users.begin(); while(ite != users.end()) { if(wcscmp(user.szNickname, ite->szNickname)<0) break; ite++; } users.insert(ite, user); m_userparent.insert(userid, channelid); reset(); }
BOOL CUserDesktopDlg::OnInitDialog() { CDialog::OnInitDialog(); TRANSLATE(*this, IDD); if(m_nUserID == 0) SetWindowText(_T("Local Desktop")); else { User user = {0}; TT_GetUser(ttInst, m_nUserID, &user); SetWindowText(CString(_T("Desktop - ")) + GetDisplayName(user)); } ResizeToDesktopWindow(); SetTimer(TIMERID_GET_DESKTOPWINDOW, 100, NULL); SetTimer(TIMERID_SEND_DESKTOPINPUT, 50, NULL); return TRUE; }
void ChannelsModel::slotUpdateUser(int userid, int channelid) { User user = {0}; if(!TT_GetUser(ttInst, userid, &user) || channelid == 0) return; users_t::iterator c_ite = m_users.find(channelid); Q_ASSERT(c_ite != m_users.end()); chanusers_t& users = c_ite.value(); chanusers_t::iterator u_ite = users.begin(); while(u_ite != users.end()) { if(u_ite->nUserID == userid) { u_ite = users.erase(u_ite); users.insert(u_ite, user); break; } u_ite++; } reset(); }
UserVideoWidget::UserVideoWidget(QWidget * parent, int userid, int border_width) : UserImageWidget(parent, userid, true, border_width) , m_novideo_count(0) , m_showvidtext(false) { Q_ASSERT(userid & VIDEOTYPE_MASK); slotUpdateVideoTextBox(); startTimer(1000); User user; TT_GetUser(ttInst, m_userid & VIDEOTYPE_USERMASK, &user); if(userid & VIDEOTYPE_CAPTURE) { if((userid & VIDEOTYPE_USERMASK) == 0) m_textmsg = tr("Waiting for local video"); else m_textmsg = tr("Waiting for video from %1").arg(getDisplayName(user)); } if(userid & VIDEOTYPE_MEDIAFILE) m_textmsg = tr("Waiting for media file from %1").arg(getDisplayName(user)); m_video_frame = acquireVideo(); #if !defined(USE_TT_PAINT) && !USE_VIDEO_SHAREDMEM_ZEROCOPY if(m_video_frame) { m_image = QImage(m_video_frame->nWidth, m_video_frame->nHeight, QImage::Format_RGB32); if(m_mirrored) m_image = m_image.mirrored(true, true); } #endif }
void UserDesktopWidget::setUserID(int userid) { UserImageWidget::setUserID(userid); TT_GetUser(ttInst, userid, &m_user); m_nickname = getDisplayName(m_user); }
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(); } } } }
void OnlineUsersModel::updateUser(int userid) { User user; if(TT_GetUser(ttInst, userid, &user)) m_users.insert(user.nUserID, user); }