/*static*/ void ChatDialog::chatFriend(const std::string &peerId, const bool forceFocus) { if (peerId.empty()){ return; } std::string distant_chat_pgp_id ; uint32_t distant_peer_status ; if(rsMsgs->getDistantChatStatus(peerId,distant_peer_status,distant_chat_pgp_id)) { getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN ); // use own flags return ; } ChatLobbyId lid; if (rsMsgs->isLobbyId(peerId, lid)) { getChat(peerId, (forceFocus ? (RS_CHAT_OPEN | RS_CHAT_FOCUS) : RS_CHAT_OPEN)); } RsPeerDetails detail; if (!rsPeers->getPeerDetails(peerId, detail)) return; if (detail.isOnlyGPGdetail) { std::list<std::string> onlineIds; //let's get the ssl child details std::list<std::string> sslIds; rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds); if (sslIds.size() == 1) { // chat with the one ssl id (online or offline) getChat(sslIds.front(), forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN); return; } // more than one ssl ids available, check for online for (std::list<std::string>::iterator it = sslIds.begin(); it != sslIds.end(); ++it) { if (rsPeers->isOnline(*it)) { onlineIds.push_back(*it); } } if (onlineIds.size() == 1) { // chat with the online ssl id getChat(onlineIds.front(), forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN); return; } // more than one ssl ids online or all offline QMessageBox mb(QMessageBox::Warning, "RetroShare", tr("Your friend has more than one locations.\nPlease choose one of it to chat with."), QMessageBox::Ok); mb.setWindowIcon(QIcon(":/images/rstray3.png")); mb.exec(); } else { getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN); } }
// Connected with SIGNAL(state(const QStringList&)) // properties.at(0): Login // properties.at(1): Id // properties.at(2): Ip // properties.at(3): Promo // properties.at(4): State // properties.at(5): Location // properties.at(6): Comment void QNetsoul::changeStatus(const QStringList& properties) { bool ok; Chat* chat = NULL; int id = properties.at(1).toInt(&ok); if (ok) chat = getChat(id); else qFatal("[QNetSoul::changeStatus] " "properties.at(1) must be a number. " "current value == %s", properties.at(1).toStdString().c_str()); if (chat == NULL) chat = createWindowChat(id, properties.at(0), properties.at(5)); for (int i = 0; (states[i].state); ++i) if (properties.at(4) == states[i].state) { chat->statusLabel->setPixmap(QPixmap(states[i].pixmap)); if ("login" == properties.at(4)) // get comment field this->_network->refreshContact(properties.at(0)); else if ("logout" == properties.at(4)) { disableChat(chat); } if (this->_trayIcon && this->_options->chatWidget->notifyState()) this->_trayIcon->showMessage (this->tree->getAliasByLogin(properties.at(0)), tr("is now ") + states[i].displayState); break; } this->tree->updateConnectionPoint(properties); }
/*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); } } }
// properties.at(0): Login // properties.at(1): Id // properties.at(2): Ip // properties.at(3): Promo // properties.at(4): State // properties.at(5): Location // properties.at(6): Comment void QNetsoul::showConversation(const QStringList& properties, const QString& message) { bool ok; const int id = properties.at(1).toInt(&ok); if (ok == false) qFatal("[QNetsoul::showConversation] Invalid id (%d)", id); Chat* window = getChat(id); const bool userEvent = message.isEmpty(); if (NULL == window) { // DEBUG focus //qDebug() << "CASE 1"; window = createWindowChat(id, properties.at(0), properties.at(5)); window->show(); } if (false == window->isVisible()) { // DEBUG focus //qDebug() << "CASE 2"; //window->outputTextBrowser->clear(); //window->inputTextEdit->clear(); if (userEvent) { window->show(); window->activateWindow(); QApplication::setActiveWindow(window); window->inputTextEdit->setFocus(); } else window->showMinimized(); } else { // DEBUG focus //qDebug() << "CASE 3"; if (userEvent) { window->showNormal(); window->activateWindow(); QApplication::setActiveWindow(window); window->inputTextEdit->setFocus(); } } if (message.isEmpty() == false) { if (window) { window->insertMessage(properties.at(0), message, QColor(204, 0, 0)); window->autoReply(statusComboBox->currentIndex()); QApplication::alert(window); } if (this->_trayIcon && this->_options->chatWidget->notifyMsg()) this->_trayIcon->showMessage(properties.at(0), tr(" is talking to you.")); } }
api_return PrivateChatApi::handleDeleteChat(ApiRequest& aRequest) { auto chat = getSubModule(aRequest.getStringParam(0)); if (!chat) { aRequest.setResponseErrorStr("Chat session not found"); return websocketpp::http::status_code::not_found; } MessageManager::getInstance()->removeChat(chat->getChat()->getUser()); return websocketpp::http::status_code::ok; }
PrivateChatPtr MessageManager::addChat(const HintedUser& user, bool aReceivedMessage) noexcept { if (getChat(user.user)) { return nullptr; } PrivateChatPtr chat; { WLock l(cs); chat = make_shared<PrivateChat>(user, getPMConn(user.user)); chats.emplace(user.user, chat); } fire(MessageManagerListener::ChatCreated(), chat, aReceivedMessage); return chat; }
// Connected with SIGNAL(who(const QStringList&)) // properties.at(0): Login // properties.at(1): Id // properties.at(2): Ip // properties.at(3): Promo // properties.at(4): State // properties.at(5): Location // properties.at(6): Comment void QNetsoul::updateContact(const QStringList& properties) { bool ok; Chat* chat = NULL; int id = properties.at(1).toInt(&ok); if (ok) chat = getChat(id); else qFatal("[QNetSoul::updateContact]" "properties.at(1) a.k.a id must be a number." "current value == %s", properties.at(1).toStdString().c_str()); if (chat == NULL) chat = createWindowChat(id, properties.at(0), properties.at(5)); for (int i = 0; (states[i].state); ++i) if (properties.at(4) == states[i].state) chat->statusLabel->setPixmap(QPixmap(states[i].pixmap)); this->tree->updateConnectionPoint(properties); }
void OnetAuth::authorize(QString _strNick, QString _strPass) { if (_strNick.isEmpty()) return; // empty nick if (Settings::instance()->getBool("logged")) return; // already logged if (Settings::instance()->getBool("authorizing")) return; // already authorizing Settings::instance()->setBool("authorizing", true); emit authStateChanged(); strFullNick = _strNick.left(32); strNick = (_strNick.at(0) == '~' ? _strNick.remove(0,1).left(31) : _strNick.left(32)); strPass = _strPass; strNickLen = QString::number(strNick.length()); bRegisteredNick = strFullNick.at(0) != '~'; bOverride = Settings::instance()->getBool("override"); if (Settings::instance()->getBool("debug")) { qDebug() << "Override: " << bOverride; qDebug() << "Logged: " << Settings::instance()->get("logged"); qDebug() << "Authorizing: " << Settings::instance()->get("authorizing"); } // update nick emit updateNick(strFullNick); // remove cookies removeCookies(); getChat(); }
void QNetsoul::notifyTypingStatus(const int id, const bool typing) { Chat* chat = getChat(id); if (chat) chat->notifyTypingStatus(typing); }