void PoslvControl::messageRead(const rosbag::MessageInstance& message) { if (message.isType<poslv::VehicleNavigationSolutionMsg>()) { poslv::VehicleNavigationSolutionMsgPtr vns( message.instantiate<poslv::VehicleNavigationSolutionMsg>()); messageRead(vns); } }
void MainWindow::on_connectButton_clicked() { if(m_connectionState == ConnectionState::Disconnected) { QString host = ui->hostLineEdit->text(); quint16 port = ui->portSpinBox->value(); QString name = ui->nameLineEdit->text(); m_tcpClient.reset(new nc::TcpClient); m_gameState.reset(new GameState(host, port, name, *m_tcpClient.get())); connect(m_tcpClient.get(), SIGNAL(messageRead(QByteArray)), m_gameState.get(), SLOT(onInboundMessage(QByteArray))); connect(m_gameState.get(), SIGNAL(outboundMessage(QByteArray)), m_tcpClient.get(), SLOT(writeMessage(QByteArray))); connect(m_gameState.get(), SIGNAL(chatMessageReceived(QString)), this, SLOT(onChatMessageReceived(QString))); connect(m_gameState.get(), SIGNAL(disconnectedFromServer(QString)), this, SLOT(onDisconnected(QString))); connect(this, SIGNAL(chatMessageSent(QString)), m_gameState.get(), SLOT(onChatMessageSent(QString))); connect(m_tcpClient.get(), SIGNAL(connected()), this, SLOT(onConnected())); connect(m_tcpClient.get(), SIGNAL(disconnected()), this, SLOT(onDisconnected())); connect(m_tcpClient.get(), SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); m_tcpClient->connectToHost(host, port); changeConnectionState(ConnectionState::Connecting); qDebug() << "Connecting."; appendHtml(QString("<b>Connecting to %1:%2.</b><br>").arg(host).arg(port)); } else { m_tcpClient->disconnectFromHost(); } }
ChatWindow *MainWindow::createChatWindow(Contact& contact, bool show) { // Just open one window at a time to avoid duplicates createWindowMutex.lock(); ChatWindow *chat; QString jid = contact.jid; if (contact.type == Contact::TypeGroup) Utilities::logData("Group"); else Utilities::logData("Contact"); if (!chatWindowList.contains(jid)) { Utilities::logData("There's no previous chat window"); if (contact.type == Contact::TypeContact) chat = new ChatWindow(&contact,this); else chat = new GroupWindow((Group *)&contact,this); chatWindowList.insert(jid,chat); if (!lastContactsList.contains(jid)) { // This is a new chat and it is not in the // open chats list // Create the open chats item ChatDisplayItem *item = new ChatDisplayItem(&contact); lastContactsList.insert(jid,item); model->appendRow(item); // This contact now has an open chat contact.hasOpenChat = true; // Set the last line logged in the item FMessage msg = chat->lastMessage(); item->updateData(msg); // Store this chat in the DB ConversationsDBEntry entry; entry.jid = jid; entry.muted = false; entry.muteExpireTimestamp = 0; chatsDB.createChat(entry); if (contact.type == Contact::TypeContact) emit subscribe(jid); } else { // This chat is in the open chats list // Configure mute settings ChatDisplayItem *item = lastContactsList.value(jid); if (item->muted) chat->setMute(item->muteExpireTimestamp); } chat->setAttribute(Qt::WA_DeleteOnClose); if (!show) Utilities::logData("Chat window will not be shown"); if (show) { Utilities::logData("Showing chat window"); qint64 startTime = QDateTime::currentMSecsSinceEpoch(); chat->show(); qint64 endTime = QDateTime::currentMSecsSinceEpoch() - startTime; Utilities::logData("Chat window showed " + QString::number(endTime) + " milliseconds."); } connect(chat,SIGNAL(sendMessage(FMessage)), this,SLOT(sendMessageFromChat(FMessage))); connect(chat,SIGNAL(destroyed(QObject *)), this,SLOT(deleteChat(QObject *))); connect(chat,SIGNAL(mute(QString,bool,qint64)), this,SLOT(mute(QString,bool,qint64))); connect(chat,SIGNAL(blockOrUnblockContact(QString,bool)), this,SLOT(blockOrUnblockContact(QString,bool))); connect(chat,SIGNAL(photoUpdate(QString,QString,bool)), this,SLOT(requestPhotoUpdate(QString,QString,bool))); connect(chat,SIGNAL(requestStatus(QString)), this,SLOT(requestContactStatus(QString))); connect(chat,SIGNAL(voiceNotePlayed(FMessage)), this,SLOT(sendVoiceNotePlayed(FMessage))); connect(chat,SIGNAL(messageRead(FMessage)), this,SLOT(sendMessageRead(FMessage))); connect(chat,SIGNAL(updateLastDir(int,QString)), this,SLOT(requestUpdateLastDir(int,QString))); connect(chat,SIGNAL(forwardMessage(FMessage)), this,SLOT(forwardMessage(FMessage))); if (contact.type == Contact::TypeGroup) { GroupWindow *groupChat = (GroupWindow *) chat; connect(groupChat,SIGNAL(changeSubject(QString,QString)), this,SLOT(sendSetGroupSubjectFromChat(QString,QString))); connect(groupChat,SIGNAL(requestLeaveGroup(QString)), this,SLOT(requestLeaveGroupFromChat(QString))); connect(groupChat,SIGNAL(getParticipants(QString)), this,SLOT(requestGetParticipants(QString))); } else emit queryLastOnline(jid); }