本文整理汇总了C++中ChatDialog类的典型用法代码示例。如果您正苦于以下问题:C++ ChatDialog类的具体用法?C++ ChatDialog怎么用?C++ ChatDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChatDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getChat
/*static*/ void ChatDialog::chatChanged(int list, int type)
{
if (list == NOTIFY_LIST_PRIVATE_INCOMING_CHAT && type == NOTIFY_TYPE_ADD) {
// play sound when recv a message
soundManager->play(SOUND_NEW_CHAT_MESSAGE);
std::list<std::string> ids;
if (rsMsgs->getPrivateChatQueueIds(true, ids)) {
uint chatflags = Settings->getChatFlags();
std::list<std::string>::iterator id;
for (id = ids.begin(); id != ids.end(); id++) {
ChatDialog *cd = getChat(*id, chatflags);
if (cd) {
cd->insertChatMsgs();
}
}
}
}
/* now notify all open priavate chat windows */
std::map<std::string, ChatDialog *>::iterator it;
for (it = chatDialogs.begin (); it != chatDialogs.end(); it++) {
if (it->second) {
it->second->onChatChanged(list, type);
}
}
}
示例2: ReceivedVoipData
void PluginGUIHandler::ReceivedVoipData(const QString& peer_id)
{
std::cerr << "****** Plugin GUI handler: received VoipData!" << std::endl;
std::vector<RsVoipDataChunk> chunks ;
if(!rsVoip->getIncomingData(peer_id.toStdString(),chunks))
{
std::cerr << "PluginGUIHandler::ReceivedVoipData(): No data chunks to get. Weird!" << std::endl;
return ;
}
ChatDialog *di = ChatDialog::getExistingChat(peer_id.toStdString()) ;
if (di) {
ChatWidget *cw = di->getChatWidget();
if (cw) {
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList) {
AudioChatWidgetHolder *acwh = dynamic_cast<AudioChatWidgetHolder*>(chatWidgetHolder) ;
if (acwh) {
for (unsigned int i = 0; i < chunks.size(); ++i) {
for (unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
acwh->addAudioData(peer_id,&qb);
}
}
break;
}
}
}
} else {
示例3: getCurrentDialog
void PopupChatWindow::setStyle()
{
ChatDialog *cd = getCurrentDialog();
if (cd && cd->setStyle()) {
calculateStyle(cd);
}
}
示例4: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QNetworkConfigurationManager manager;
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
settings.beginGroup(QLatin1String("QtNetwork"));
const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
settings.endGroup();
// If the saved network configuration is not currently discovered use the system default
QNetworkConfiguration config = manager.configurationFromIdentifier(id);
if ((config.state() & QNetworkConfiguration::Discovered) !=
QNetworkConfiguration::Discovered) {
config = manager.defaultConfiguration();
}
QNetworkSession *networkSession = new QNetworkSession(config, &app);
networkSession->open();
networkSession->waitForOpened();
if (networkSession->isOpen()) {
// Save the used configuration
QNetworkConfiguration config = networkSession->configuration();
QString id;
if (config.type() == QNetworkConfiguration::UserChoice) {
id = networkSession->sessionProperty(
QLatin1String("UserChoiceConfiguration")).toString();
} else {
id = config.identifier();
}
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
settings.beginGroup(QLatin1String("QtNetwork"));
settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
settings.endGroup();
}
}
ChatDialog dialog;
#ifdef Q_OS_SYMBIAN
// Make application better looking and more usable on small screen
dialog.showMaximized();
#else
dialog.show();
#endif
return app.exec();
}
示例5: undockTab
void PopupChatWindow::undockTab()
{
ChatDialog *cd = dynamic_cast<ChatDialog*>(ui.tabWidget->currentWidget());
if (cd) {
PopupChatWindow *pcw = getWindow(true);
if (pcw) {
removeDialog(cd);
pcw->addDialog(cd);
cd->show();
pcw->show();
pcw->calculateTitle(cd);
}
}
}
示例6: PersonLoginInfo
void sharefile::on_download_clicked()
{
PersonLoginInfo *info = new PersonLoginInfo(checkedFile.HostName,checkedFile.HostIP);
ChatDialog *ServerDialog = new ChatDialog(info);
ServerDialog->fileName = checkedFile.filePath;
ServerDialog->show();
//ServerDialog->startServer();
downSend = new UdpConnection();
checkedFile.ServerIP = SystemInformation().getHostIP();
checkedFile.ServerName = SystemInformation().getHostName();
downSend->sendMessage(5,checkedFile,QHostAddress(checkedFile.HostIP),6666);
}
示例7: _stprintf_s
void MainFrame::OnItemActivate(TNotifyUI& msg)
{
CTabLayoutUI* pTabControl = static_cast<CTabLayoutUI*>(m_PaintManager.FindControl(kMainTabControlName));
if (pTabControl != NULL)
{
if (pTabControl->GetCurSel() == 0)
{
CFriendsUI* pFriendsList = static_cast<CFriendsUI*>(m_PaintManager.FindControl(kFriendsListControlName));
if ((pFriendsList != NULL) && pFriendsList->GetItemIndex(msg.pSender) != -1)
{
if (_tcsicmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0)
{
Node* node = (Node*)msg.pSender->GetTag();
CControlUI* background = m_PaintManager.FindControl(kBackgroundControlName);
if (!pFriendsList->CanExpand(node) && (background != NULL))
{
FriendListItemInfo friend_info;
for (std::vector<FriendListItemInfo>::const_iterator citer = friends_.begin(); citer != friends_.end(); ++citer)
{
if (_tcsicmp(citer->id, node->data().value) == 0)
{
friend_info = *citer;
break;
}
}
TCHAR szBuf[MAX_PATH] = { 0 };
if (_tcslen(background->GetBkImage()) > 0)
{
_stprintf_s(szBuf, MAX_PATH - 1, _T("bg%d.png"), bk_image_index_);
}
ChatDialog* pChatDialog = new ChatDialog(szBuf, background->GetBkColor(), myself_info_, friend_info);
if (pChatDialog == NULL)
return;
pChatDialog->Create(NULL, _T("ChatDialog"), UI_WNDSTYLE_FRAME | WS_POPUP, NULL, 0, 0, 0, 0);
skin_changed_observer_.AddReceiver(pChatDialog);
pChatDialog->CenterWindow();
::ShowWindow(*pChatDialog, SW_SHOW);
}
}
}
}
}
}
示例8: GetPaintMgr
void CRichEditWnd::OnItemActive(TNotifyUI& msg)
{
CAnimationTabLayoutUI* pTabControl = static_cast<CAnimationTabLayoutUI*>(GetPaintMgr()->FindControl(_T("TAB_MAIN")));
if (pTabControl != NULL)
{
if (pTabControl->GetCurSel() == 1)
{
CFriendsUI* pFriendsList = static_cast<CFriendsUI*>(GetPaintMgr()->FindControl(_T("LIST_FRIEND")));
if ((pFriendsList != NULL) && pFriendsList->GetItemIndex(msg.pSender) != -1)
{
if (_tcsicmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0)
{
Node* node = (Node*)msg.pSender->GetTag();
CControlUI* background = GetPaintMgr()->FindControl(_T("bg"));
if (!pFriendsList->CanExpand(node) && (background != NULL))
{
FriendListItemInfo friend_info;
for (std::vector<FriendListItemInfo>::const_iterator citer = friends_.begin(); citer != friends_.end(); ++citer)
{
if (_tcsicmp(citer->id, node->data().value) == 0)
{
friend_info = *citer;
break;
}
}
ChatDialog* pChatDialog = new ChatDialog(background->GetBkImage(), background->GetBkColor(), myself_info_, friend_info);
if (pChatDialog == NULL)
return;
#if defined(WIN32) && !defined(UNDER_CE)
pChatDialog->Create(NULL, _T("ChatDialog"), UI_WNDSTYLE_FRAME | WS_POPUP, NULL, 0, 0, 0, 0);
#else
pChatDialog->Create(NULL, _T("ChatDialog"), UI_WNDSTYLE_FRAME | WS_POPUP, NULL, 0, 0, 0, 0);
#endif
pChatDialog->CenterWindow();
::ShowWindow(*pChatDialog, SW_SHOW);
}
}
}
}
}
}
示例9: ReceivedInvitation
void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &peer_id, int flags)
{
#ifdef VOIPGUIHANDLER_DEBUG
std::cerr << "****** VOIPGUIHandler: received Invitation from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
#endif
ChatDialog *di = ChatDialog::getChat(ChatId(peer_id), Settings->getChatFlags());
if (di) {
ChatWidget *cw = di->getChatWidget();
if(cw) {
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
{
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
if (acwh)
acwh->ReceivedInvitation(peer_id, flags);
}
}
} else {
示例10: closeEvent
void PopupChatWindow::closeEvent(QCloseEvent *event)
{
if (tabbedWindow) {
for (int index = ui.tabWidget->count() - 1; index >= 0; --index) {
ChatDialog *dialog = dynamic_cast<ChatDialog*>(ui.tabWidget->widget(0));
if (dialog == NULL) {
continue;
}
if (!dialog->close()) {
event->ignore();
break;
}
}
} else {
if (chatDialog && !chatDialog->close()) {
event->ignore();
}
}
}
示例11: ReceivedVoipData
void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
{
std::vector<RsVOIPDataChunk> chunks ;
if(!rsVOIP->getIncomingData(peer_id,chunks))
{
std::cerr << "VOIPGUIHandler::ReceivedVoipData(): No data chunks to get. Weird!" << std::endl;
return ;
}
ChatDialog *di = ChatDialog::getChat(ChatId(peer_id), Settings->getChatFlags());
if (di) {
ChatWidget *cw = di->getChatWidget();
if (cw) {
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
{
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
if (acwh) {
for (unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++)
{
QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_AUDIO)
acwh->addAudioData(peer_id, &qb);
else if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO)
acwh->addVideoData(peer_id, &qb);
else
std::cerr << "VOIPGUIHandler: Unknown data type received. type=" << chunks[chunkIndex].type << std::endl;
}
break;
}
}
}
} else {
示例12: getExistingChat
/*static*/ ChatDialog *ChatDialog::getChat(const std::string &peerId, uint chatflags)
{
/* see if it already exists */
ChatDialog *cd = getExistingChat(peerId);
if (cd == NULL) {
ChatLobbyId lobby_id = 0;
if (rsMsgs->isLobbyId(peerId, lobby_id)) {
// chatflags = RS_CHAT_OPEN | RS_CHAT_FOCUS; // use own flags
}
uint32_t distant_peer_status ;
std::string distant_chat_pgp_id ;
if(rsMsgs->getDistantChatStatus(peerId,distant_peer_status,distant_chat_pgp_id))
chatflags = RS_CHAT_OPEN | RS_CHAT_FOCUS; // use own flags
if (chatflags & RS_CHAT_OPEN) {
if (lobby_id) {
std::list<ChatLobbyInfo> linfos;
rsMsgs->getChatLobbyList(linfos);
for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) {
if ((*it).lobby_id == lobby_id) {
cd = new ChatLobbyDialog(lobby_id);
chatDialogs[peerId] = cd;
cd->init(peerId, QString::fromUtf8((*it).lobby_name.c_str()));
}
}
} else if(distant_peer_status > 0) {
cd = new PopupDistantChatDialog();
chatDialogs[peerId] = cd;
std::string peer_name = rsPeers->getGPGName(distant_chat_pgp_id) ;
cd->init(peerId, tr("Talking to ")+QString::fromStdString(peer_name)+" (PGP id="+QString::fromStdString(distant_chat_pgp_id)+")") ;
} else {
RsPeerDetails sslDetails;
if (rsPeers->getPeerDetails(peerId, sslDetails)) {
cd = new PopupChatDialog();
chatDialogs[peerId] = cd;
cd->init(peerId, PeerDefs::nameWithLocation(sslDetails));
}
}
}
}
if (cd == NULL) {
return NULL;
}
cd->insertChatMsgs();
cd->showDialog(chatflags);
return cd;
}
示例13: calculateTitle
void PopupChatWindow::calculateTitle(ChatDialog *dialog)
{
bool hasNewMessages = false;
ChatDialog *cd;
/* is typing */
bool isTyping = false;
if (ui.tabWidget->isVisible()) {
ui.tabWidget->getInfo(isTyping, hasNewMessages, NULL);
} else {
if (dialog) {
isTyping = dialog->isTyping();
hasNewMessages = dialog->hasNewMessages();
}
}
if (ui.tabWidget->isVisible()) {
cd = dynamic_cast<ChatDialog*>(ui.tabWidget->currentWidget());
} else {
cd = dialog;
}
QIcon icon;
if (isTyping) {
mBlinkIcon = QIcon();
icon = QIcon(IMAGE_TYPING);
} else if (hasNewMessages) {
icon = QIcon(IMAGE_CHAT);
if (Settings->getChatFlags() & RS_CHAT_BLINK) {
mBlinkIcon = icon;
} else {
mBlinkIcon = QIcon();
}
} else {
mBlinkIcon = QIcon();
if (cd && cd->hasPeerStatus()) {
icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus()));
} else {
icon = qApp->windowIcon();
}
}
setWindowIcon(icon);
if (cd) {
QString title = cd->getTitle();
if (cd->hasPeerStatus()) {
title += " (" + StatusDefs::name(cd->getPeerStatus()) + ")";
}
setWindowTitle(title);
} else {
setWindowTitle("RetroShare");
}
}
示例14: OnPrepare
//.........这里部分代码省略.........
UpdateMicroBlogList();
}
}
}
else if (_tcsicmp(msg.sType, _T("itemactivate")) == 0)
{
CTabLayoutUI* pTabControl = static_cast<CTabLayoutUI*>(paint_manager_.FindControl(kTabControlName));
if (pTabControl != NULL)
{
if (pTabControl->GetCurSel() == 0)
{
CFriendsUI* pFriendsList = static_cast<CFriendsUI*>(paint_manager_.FindControl(kFriendsListControlName));
if ((pFriendsList != NULL) && pFriendsList->GetItemIndex(msg.pSender) != -1)
{
if (_tcsicmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0)
{
Node* node = (Node*)msg.pSender->GetTag();
CControlUI* background = paint_manager_.FindControl(kBackgroundControlName);
if (!pFriendsList->CanExpand(node) && (background != NULL))
{
FriendListItemInfo friend_info;
for (std::vector<FriendListItemInfo>::const_iterator citer = friends_.begin(); citer != friends_.end(); ++citer)
{
if (_tcsicmp(citer->id.c_str(), node->data().value.c_str()) == 0)
{
friend_info = *citer;
break;
}
}
TCHAR szBuf[MAX_PATH] = {0};
if (_tcslen(background->GetBkImage()) > 0)
{
#if defined(UNDER_WINCE)
_stprintf(szBuf, _T("bg%d.png"), bk_image_index_);
#else
_stprintf_s(szBuf, MAX_PATH - 1, _T("bg%d.png"), bk_image_index_);
#endif
}
ChatDialog* pChatDialog = new ChatDialog(szBuf, background->GetBkColor(), myself_info_, friend_info);
if( pChatDialog == NULL )
return;
#if defined(WIN32) && !defined(UNDER_CE)
pChatDialog->Create(NULL, _T("ChatDialog"), UI_WNDSTYLE_FRAME | WS_POPUP, NULL, 0, 0, 0, 0);
#else
pChatDialog->Create(NULL, _T("ChatDialog"), UI_WNDSTYLE_FRAME | WS_POPUP, NULL, 0, 0, 0, 0);
#endif
skin_changed_observer_.AddReceiver(pChatDialog);
pChatDialog->CenterWindow();
::ShowWindow(*pChatDialog, SW_SHOW);
}
}
}
}
}
}
else if (_tcsicmp(msg.sType, _T("itemclick")) == 0)
{
CTabLayoutUI* pTabControl = static_cast<CTabLayoutUI*>(paint_manager_.FindControl(kTabControlName));
if (pTabControl != NULL)
{
if (pTabControl->GetCurSel() == 0)
{
CFriendsUI* pFriendsList = static_cast<CFriendsUI*>(paint_manager_.FindControl(kFriendsListControlName));
if ((pFriendsList != NULL) && pFriendsList->GetItemIndex(msg.pSender) != -1)
{
if (_tcsicmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0)
{
Node* node = (Node*)msg.pSender->GetTag();
if (pFriendsList->CanExpand(node))
{
pFriendsList->SetChildVisible(node, !node->data().child_visible_);
}
}
}
}
else if (pTabControl->GetCurSel() == 1)
{
CGroupsUI* pGroupsList = static_cast<CGroupsUI*>(paint_manager_.FindControl(kGroupsListControlName));
if ((pGroupsList != NULL) && pGroupsList->GetItemIndex(msg.pSender) != -1)
{
if (_tcsicmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0)
{
Node* node = (Node*)msg.pSender->GetTag();
if (pGroupsList->CanExpand(node))
{
pGroupsList->SetChildVisible(node, !node->data().child_visible_);
}
}
}
}
}
}
}
示例15: m
void NotifyQt::UpdateGUI()
{
if(RsAutoUpdatePage::eventsLocked())
return ;
{
QMutexLocker m(&_mutex) ;
if(!_enabled)
return ;
}
static bool already_updated = false ; // these only update once at start because they may already have been set before
// the gui is running, then they get updated by callbacks.
if(!already_updated)
{
emit messagesChanged() ;
emit neighboursChanged();
emit configChanged();
already_updated = true ;
}
/* Finally Check for PopupMessages / System Error Messages */
if (rsNotify)
{
uint32_t sysid;
uint32_t type;
std::string title, id, msg;
/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
ToasterItem *toaster = NULL;
if (rsNotify->NotifyPopupMessage(type, id, title, msg))
{
uint popupflags = Settings->getNotifyFlags();
switch(type)
{
case RS_POPUP_ENCRYPTED_MSG:
SoundManager::play(SOUND_MESSAGE_ARRIVED);
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
{
toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
}
break;
case RS_POPUP_MSG:
SoundManager::play(SOUND_MESSAGE_ARRIVED);
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
{
toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CONNECT:
SoundManager::play(SOUND_USER_ONLINE);
if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster)
{
toaster = new ToasterItem(new OnlineToaster(RsPeerId(id)));
}
break;
case RS_POPUP_DOWNLOAD:
SoundManager::play(SOUND_DOWNLOAD_COMPLETE);
if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
{
/* id = file hash */
toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
}
break;
case RS_POPUP_CHAT:
if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster)
{
// TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT
ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id)));
ChatWidget *chatWidget;
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
// do not show when active
break;
}
toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_GROUPCHAT:
if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster)
{
MainWindow *mainWindow = MainWindow::getInstance();
if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) {
if (MainWindow::getActivatePage() == MainWindow::Friends) {
if (FriendsDialog::isGroupChatActive()) {
// do not show when active
break;
}
}
}
toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CHATLOBBY:
//.........这里部分代码省略.........