// !SMT!-S LRESULT UsersFrame::onIgnorePrivate(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { int i = -1; while ((i = ctrlUsers.GetNextItem(i, LVNI_SELECTED)) != -1) { UserInfo *ui = ctrlUsers.getItemData(i); FavoriteManager::getInstance()->setNormalPM(ui->getUser()); ui->columns[COLUMN_IGNORE].clear(); switch (wID) { case IDC_PM_IGNORED: ui->columns[COLUMN_IGNORE] = TSTRING(IGNORE_S); FavoriteManager::getInstance()->setIgnorePM(ui->getUser(), true); break; case IDC_PM_FREE: ui->columns[COLUMN_IGNORE] = TSTRING(FREE_PM_ACCESS); FavoriteManager::getInstance()->setFreePM(ui->getUser(), true); break; }; updateUser(ui->getUser()); ctrlUsers.updateItem(i); } return 0; }
LRESULT UsersFrame::handleSpeaker(WPARAM wParam, LPARAM lParam) { if(wParam == USER_UPDATED) { boost::scoped_ptr<UserInfoBase> uib(reinterpret_cast<UserInfoBase*>(lParam)); updateUser(uib->user); } return 0; }
void lmcChatRoomWindow::settingsChanged(void) { showSmiley = pSettings->value(IDS_EMOTICON, IDS_EMOTICON_VAL).toBool(); pMessageLog->showSmiley = showSmiley; pMessageLog->fontSizeVal = pSettings->value(IDS_FONTSIZE, IDS_FONTSIZE_VAL).toInt(); pMessageLog->autoFile = pSettings->value(IDS_AUTOFILE, IDS_AUTOFILE_VAL).toBool(); sendKeyMod = pSettings->value(IDS_SENDKEYMOD, IDS_SENDKEYMOD_VAL).toBool(); pSoundPlayer->settingsChanged(); if(localName.compare(pLocalUser->name) != 0) { localName = pLocalUser->name; updateUser(pLocalUser); pMessageLog->updateUserName(&localId, &localName); } bool msgTime = pSettings->value(IDS_MESSAGETIME, IDS_MESSAGETIME_VAL).toBool(); bool msgDate = pSettings->value(IDS_MESSAGEDATE, IDS_MESSAGEDATE_VAL).toBool(); bool allowLinks = pSettings->value(IDS_ALLOWLINKS, IDS_ALLOWLINKS_VAL).toBool(); bool pathToLink = pSettings->value(IDS_PATHTOLINK, IDS_PATHTOLINK_VAL).toBool(); bool trim = pSettings->value(IDS_TRIMMESSAGE, IDS_TRIMMESSAGE_VAL).toBool(); QString theme = pSettings->value(IDS_THEME, IDS_THEME_VAL).toString(); if(msgTime != pMessageLog->messageTime || msgDate != pMessageLog->messageDate || allowLinks != pMessageLog->allowLinks || pathToLink != pMessageLog->pathToLink || trim != pMessageLog->trimMessage || theme.compare(pMessageLog->themePath) != 0) { pMessageLog->messageTime = msgTime; pMessageLog->messageDate = msgDate; pMessageLog->allowLinks = allowLinks; pMessageLog->pathToLink = pathToLink; pMessageLog->trimMessage = trim; pMessageLog->themePath = theme; pMessageLog->reloadMessageLog(); } int viewType = pSettings->value(IDS_USERLISTVIEW, IDS_USERLISTVIEW_VAL).toInt(); ui.tvUserList->setView((UserListView)viewType); }
LRESULT UsersFrame::onSpeaker(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { if(wParam == USER_UPDATED) { UserInfoBase* uib = (UserInfoBase*)lParam; updateUser(uib->user); delete uib; } return 0; }
LRESULT UsersFrame::onSpeaker(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { if (wParam == USER_UPDATED) { UserPtr* user = (UserPtr*)lParam; updateUser(*user); delete user; } return 0; }
void ComputerManager::startComputerControlInterface( Computer& computer ) { computer.controlInterface().start( computerScreenSize(), &m_builtinFeatures.userSessionControl() ); connect( &computer.controlInterface(), &ComputerControlInterface::featureMessageReceived, &m_featureManager, &FeatureManager::handleMasterFeatureMessage ); connect( &computer.controlInterface(), &ComputerControlInterface::userChanged, [&] () { updateUser( computer ); } ); }
void UsersFrame::addUser(const FavoriteUser& user) { dcassert(!ClientManager::isShutdown()); if (!ClientManager::isShutdown()) { auto ui = new UserInfo(user); // [+] IRainman fix. int i = ctrlUsers.insertItem(ui, 0); bool b = user.isSet(FavoriteUser::FLAG_GRANT_SLOT); ctrlUsers.SetCheckState(i, b); updateUser(i, ui, user); // [!] IRainman fix. } }
void IrcUserModelPrivate::setUserMode(IrcUser* user) { Q_Q(IrcUserModel); if (updateUser(user) && sortMethod == Irc::SortByTitle) { const bool notify = false; removeUser(user, notify); insertUser(0, user, notify); if (updateTitles()) emit q->titlesChanged(titles); emit q->usersChanged(userList); } }
AddUserResult AuthRepositoryServer::updateUserWithRole ( const std::string &licenseStaticId, const std::string &login, const std::string &password, const std::string &fullName, const std::string &email, const std::string &phone, bool enabled, const std::string& roleStaticId, const std::vector<std::string> & groupStaticIdList, const std::string &userStaticId ) { AddUserResult result; try { authrepo::DBDataSource src; authrepo::CommitNode myHead ( &m_dbStructure, src.getTaggedCommit ( "head" ) ); myHead.load ( &src ); myHead.setUserPermissions ( m_userStaticId ); validateUpdateUserParams ( myHead, licenseStaticId, login, password, fullName, email, phone, enabled, userStaticId ); updateUser ( myHead, licenseStaticId, login, password, fullName, email, phone, enabled, roleStaticId, groupStaticIdList, userStaticId ); //write DBSession s = DBSessionFactory::getSession(); s.BeginTransaction(); authrepo::DBDataCollector coll ( s ); myHead.storeUpdates ( &coll ); coll.writeTag ( "head", myHead.getId() ); if (!password.empty()) { std::string newSalt = authtools::generateRandomSalt(); std::string pwdHash = authtools::calculatePwdHash ( password, newSalt ); std::string computeridToken = authtools::calculatePwdHash ( licenseStaticId, authtools::generateRandomSalt() ); s.execUpdate ( "DELETE FROM repo.user_credentials WHERE userstaticid = %s", userStaticId.c_str() ); s.execUpdate ( "INSERT INTO repo.user_credentials(userstaticid, pwdhash, pwdsalt) VALUES (%s, %s, %s)", userStaticId.c_str(), pwdHash.c_str(), newSalt.c_str() ); } s.CommitTransaction(); result.set_successful ( true ); } catch ( ValidationException &re ) { result.set_successful ( false ); result.set_errorMessage ( re.what() ); } catch ( authrepo::util::permissions_check_error& e ) { result.set_successful ( false ); result.set_errorMessage ( "insufficient permissions" ); } return result; }
// A message is to be sent void lmcMessaging::sendMessage(MessageType type, QString* lpszUserId, XmlMessage* pMessage) { QString data = QString::null; XmlMessage message; switch(type) { case MT_Group: data = pMessage->data(XN_GROUP); updateUser(type, *lpszUserId, data); break; case MT_Status: case MT_UserName: case MT_Note: case MT_PublicMessage: for(int index = 0; index < userList.count(); index++) prepareMessage(type, msgId, false, &userList[index].id, pMessage); msgId++; break; case MT_GroupMessage: if(lpszUserId) prepareMessage(type, msgId, false, lpszUserId, pMessage); else { for(int index = 0; index < userList.count(); index++) prepareMessage(type, msgId, false, &userList[index].id, pMessage); } msgId++; break; case MT_Avatar: // if user id is specified send to that user alone, else send to all if(lpszUserId) { if(pMessage->data(XN_FILEOP) == FileOpNames[FO_Request]) pMessage->addData(XN_FILEID, getUuid() ); prepareMessage(type, msgId, false, lpszUserId, pMessage); } else { for(int index = 0; index < userList.count(); index++) { message = pMessage->clone(); message.addData( XN_FILEID, getUuid() ); prepareMessage(type, msgId, false, &userList[index].id, &message); } } msgId++; break; case MT_Version: sendWebMessage(type, pMessage); break; default: prepareMessage(type, msgId, false, lpszUserId, pMessage); msgId++; break; } }
Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); bool connFlag = this->connDb(); if(connFlag) { this->userList(); } QObject::connect(ui->addButton,SIGNAL(clicked()),this,SLOT(addUser())); QObject::connect(ui->delButton,SIGNAL(clicked()),this,SLOT(delUser())); QObject::connect(ui->updateButton,SIGNAL(clicked()),this,SLOT(updateUser())); QObject::connect(ui->userListWidget,SIGNAL(itemSelectionChanged()),this,SLOT(changeEditContent())); }
void IrcUserModelPrivate::renameUser(IrcUser* user) { Q_Q(IrcUserModel); if (updateUser(user) && sortMethod != Irc::SortByHand) { QList<IrcUser*> users = userList; const bool notify = false; removeUser(user, notify); insertUser(-1, user, notify); if (updateTitles()) emit q->titlesChanged(titles); if (users != userList) emit q->usersChanged(userList); } }
// A message is to be sent void lmcMessaging::sendMessage(MessageType type, QString* lpszUserId, XmlMessage* pMessage) { QString data = QString::null; XmlMessage message; switch(type) { case MT_Group: data = pMessage->data(XN_GROUP); updateUser(type, *lpszUserId, data); break; case MT_Status: case MT_UserName: case MT_Note: case MT_PublicMessage: for(int index = 0; index < userList.count(); index++) prepareMessage(type, msgId, false, &userList[index].id, pMessage); msgId++; break; case MT_GroupMessage: if(lpszUserId) prepareMessage(type, msgId, false, lpszUserId, pMessage); else { for(int index = 0; index < userList.count(); index++) prepareMessage(type, msgId, false, &userList[index].id, pMessage); } msgId++; break; case MT_Avatar: // if user id is specified send to that user alone, else send to all if(lpszUserId) { prepareMessage(type, msgId, false, lpszUserId, pMessage); } else { message = pMessage->clone(); emit messageReceived(MT_Avatar, &localUser->id, &message); for(int index = 0; index < userList.count(); index++) { message = pMessage->clone(); prepareMessage(type, msgId, false, &userList[index].id, &message); } } msgId++; break; case MT_Version: sendWebMessage(type, pMessage); break; default: prepareMessage(type, msgId, false, lpszUserId, pMessage); msgId++; break; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimFileWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { RimWellPath::defineUiOrdering(uiConfigName, uiOrdering); caf::PdmUiGroup* fileInfoGroup = uiOrdering.createGroupBeforeGroup("Simulation Well", "File"); fileInfoGroup->add(&m_filepath); fileInfoGroup->add(&m_wellPathIndexInFile); if ( !id().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &id); if ( !sourceSystem().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &sourceSystem); if ( !utmZone().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &utmZone); if ( !updateDate().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &updateDate); if ( !updateUser().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &updateUser); if ( !m_surveyType().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &m_surveyType); }
void MainWindow::loadSettings() { QSettings s(Config::COMPANY, Config::SOFTWARE); m_masterDelay = s.value("masterDelay", m_defaultMasterDelay).toInt(); m_loginDelay = s.value("delay", m_defaultLoginDelay).toInt(); m_autoCopy = s.value("autoCopy", false).toBool(); m_autoClear = s.value("autoClear", false).toBool(); m_alwaysOnTop = s.value("alwaysOnTop", true).toBool(); const int defaultLength = s.value("length", m_defaultLength).toInt(); m_settingsDlg->setSettings(m_masterDelay, m_loginDelay, m_autoCopy, m_autoClear, m_alwaysOnTop); m_timeLine->setDuration(m_loginDelay * 1000); m_masterTimer->setInterval(m_masterDelay * 60 * 1000); // Read login data m_urlCombo->clear(); m_loginHash.clear(); // Loop through saved logins const int size = s.beginReadArray("logins"); for (int i = 0; i < size; i++) { s.setArrayIndex(i); // Read the url const QString url = s.value("url").toString(); // Add url to the combo box m_urlCombo->addItem(url); // Add url to the login data hash m_loginHash[url] = LoginData(url, s.value("user").toString(), s.value("length", defaultLength).toInt()); } s.endArray(); // Sort the combo box m_urlCombo->model()->sort(0); // Set the current index to zero // and update related fields. m_urlCombo->setCurrentIndex(0); updateUser(m_urlCombo->currentText()); }
// !SMT!-S LRESULT UsersFrame::onSetUserLimit(WORD /* wNotifyCode */, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { MENUINFO menuInfo = {0}; menuInfo.cbSize = sizeof(MENUINFO); menuInfo.fMask = MIM_MENUDATA; speedMenu.GetMenuInfo(&menuInfo); const int iLimit = menuInfo.dwMenuData; const int lim = getSpeedLimitByCtrlId(wID, iLimit); int i = -1; while ((i = ctrlUsers.GetNextItem(i, LVNI_SELECTED)) != -1) { UserInfo *ui = ctrlUsers.getItemData(i); FavoriteManager::getInstance()->setUploadLimit(ui->getUser(), lim); ui->columns[COLUMN_SPEED_LIMIT] = Text::toT(FavoriteUser::getSpeedLimitText(lim)); updateUser(ui->getUser()); ctrlUsers.updateItem(i); } return 0; }
/** * @param tokens message tokens */ bool SessionState::handleMessage(const QStringList& tokens) { if(tokens[0] == "SAY") { int userid = tokens.at(1).toInt(); if(hasUser(userid)) emit chatMessage(user(userid).name(), tokens.at(2)); else qWarning() << "Got chat message from unknown user:"******"USER") { updateUser(tokens); } else if(tokens[0] == "PART") { partUser(tokens); } else if(tokens[0] == "SLOCK") { emit syncWait(); } else if(tokens[0] == "SUNLOCK") { emit syncDone(); } else if(tokens[0] == "BOARD") { update(Session(tokens)); } else if(tokens[0] == "RASTER") { releaseRaster(); expectRaster_ = tokens.at(1).toInt(); if(expectRaster_ == 0) emit rasterReceived(100); } else if(tokens[0] == "GIVERASTER") { emit syncRequest(); } else if(tokens[0] == "MORE") { if(isUploading()) sendRasterChunk(); else qWarning() << "Got request for more raster data, but we're not uploading anything!"; } else if(tokens[0] == "ANNOTATE") { protocol::Annotation a(tokens); if(!a.isValid()) qWarning() << "Received an invalid annotation"; else emit annotation(a); } else if(tokens[0] == "RMANNOTATION") { emit rmAnnotation(tokens.at(1).toInt()); } else return false; return true; }
void Game::playGame() { resizeConsole(x_max+1,y_max+1);//game size screen.clear(); drawBoundary(); while(!dead) { displayScore(); if(!paused) { snake.clear(screen); snake.move(); snake.draw(screen); food.draw(screen); Sleep(100-speed); if(snake.hit(x_min,x_max,y_min,y_max)) { dead = true; } else if(snake.getHead().equals(food)) { snake.grow(); generateFood(); harder(); } } if(kbhit()) { getKeys(); } } //endgame(); updateUser(); }
void UsersFrame::updateUser(const UserPtr& user) { dcassert(!ClientManager::isShutdown()); if (!ClientManager::isShutdown()) { const int l_cnt = ctrlUsers.GetItemCount(); for (int i = 0; i < l_cnt; ++i) { dcassert(l_cnt == ctrlUsers.GetItemCount()); UserInfo *ui = ctrlUsers.getItemData(i); if (ui->getUser() == user) { FavoriteUser currentFavUser; if (FavoriteManager::getFavoriteUser(user, currentFavUser)) { updateUser(i, ui, currentFavUser); } } } } }
bool DB::addOrUpdateUser(User & user, const QString & password) { TRANSACTION(ta); QSqlQuery query(ta.db); UserId userId = DB::getUserId(user.getLogin()); if (!userId.isValid()) { if (!addUser(user, password)) return false; userId = DB::getUserId(user.getLogin()); user.setId(userId); } else { if (!updateUser(user, password)) return false; } if (!userId.isValid()) { qInfo() << "Some error occured during changing the user with the login:" << user.getLogin(); return false; } if (!updatePermissions(userId, user.getPermissions())) return false; return ta.commit(); }
//////////////////////////////////////////////////////////////////////////////// // Plays a complete game, until the death of the main character // u16 game(u16 hiscore) { u8 alive = 1; // Main character still alive? TCharacter* c; // Pointer to main character // Initialize game initializeGameScreen(hiscore); // Set up Game Screen initializeEntities(); // Set up initial entities c = getCharacter(); // Get the main character ///// // Main Game Loop (while character is alive) ///// while(alive) { updateUser(c); // Update user status (depending on keypresses) scrollWorld(); // Update world scrolling alive = updateCharacter(c); // Update character status cpct_waitVSYNC(); // Wait for VSYNC and... drawAll(); // ..draw everything } // Return final score, at the end of the game return getScore(); }
void ClientManager::on(UsersUpdated, Client*, const OnlineUserList& l) noexcept { for(auto& i: l) { updateUser(*i); } }
/****************************************************************************** * Main scheduler callback for rendering the anchored spring force. *****************************************************************************/ HDCallbackCode HDCALLBACK AnchoredSpringForceCallback(void *pUserData) { static hduVector3Dd anchor; static HDboolean bRenderForce = (1==2); HDErrorInfo error; HDint nCurrentButtons, nLastButtons; hduVector3Dd position; hduVector3Dd force; force[0] = 0; force[1] = 0; force[2] = 0; hdBeginFrame(hdGetCurrentDevice()); hdGetDoublev(HD_CURRENT_POSITION, position); hdGetIntegerv(HD_CURRENT_BUTTONS, &nCurrentButtons); hdGetIntegerv(HD_LAST_BUTTONS, &nLastButtons); if ((nCurrentButtons & HD_DEVICE_BUTTON_1) != 0 && (nLastButtons & HD_DEVICE_BUTTON_1) == 0) { /* Detected button down */ memcpy(anchor, position, sizeof(hduVector3Dd)); bRenderForce = (1==1); } else if ((nCurrentButtons & HD_DEVICE_BUTTON_1) == 0 && (nLastButtons & HD_DEVICE_BUTTON_1) != 0) { /* Detected button up */ bRenderForce = (1==2); /* Send zero force to the device, or else it will just continue rendering the last force sent */ hdSetDoublev(HD_CURRENT_FORCE, force); } if (bRenderForce) { /* Compute spring force as F = k * (anchor - pos), which will attract the device position towards the anchor position */ hduVecSubtract(force, anchor, position); hduVecScaleInPlace(force, gSpringStiffness); hdSetDoublev(HD_CURRENT_FORCE, force); } ////////////////////////////////////////////// //More stuff oliver has added: call to update position and force display// if (count>MAX_COUNT) { updateUser(position, force); count -= MAX_COUNT; } ////////////////////////////////////////////// ////////////////////////////////////////////// hdEndFrame(hdGetCurrentDevice()); /* Check if an error occurred while attempting to render the force */ if (HD_DEVICE_ERROR(error = hdGetError())) { if (hduIsForceError(&error)) { bRenderForce = (1==2); } else if (hduIsSchedulerError(&error)) { return HD_CALLBACK_DONE; } } count++; return HD_CALLBACK_CONTINUE; }
void UserManager::addUser(const Owner &owner, QTreeWidgetItem* groupItem) { updateUser(owner, groupItem); }
LRESULT UsersFrame::onSpeaker(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { if(wParam == USER_UPDATED) { updateUser(((Identity*)lParam)->getUser()); } return 0; }
void UsersFrame::addUser(const FavoriteUser& aUser) { int i = ctrlUsers.insertItem(new UserInfo(aUser), 0); bool b = aUser.isSet(FavoriteUser::FLAG_GRANTSLOT); ctrlUsers.SetCheckState(i, b); updateUser(aUser.getUser()); }
/*! * This function takes an element of the interprocess buffer passed to it, and * handles populating the respective user and contact tables with its contained * data. */ static void executeInterprocessBufferCmd(interprocessBuffer_t *currentBuffer) { int delContactIndex; aorToIndexStruct_t *currentUser; if (currentBuffer->callbackType == UL_CONTACT_INSERT) { /* Add the user if the user doesn't exist, or increment its * contact index otherwise. */ updateUser(currentBuffer->stringName); } else if (currentBuffer->callbackType != UL_CONTACT_EXPIRE) { /* Currently we only support UL_CONTACT_INSERT and * UL_CONTACT_EXPIRE. If we receive another callback type, this * is a bug. */ LM_ERR("found a command on the interprocess buffer that" " was not an INSERT or EXPIRE"); return; } currentUser = findHashRecord(hashTable, currentBuffer->stringName, HASH_SIZE); /* This should never happen. This is more of a sanity check. */ if (currentUser == NULL) { LM_ERR("Received a request for contact: %s for user: %s who doesn't " "exists\n", currentBuffer->stringName, currentBuffer->stringContact); return; } /* This buffer element specified that we need to add a contact. So lets * add them */ if (currentBuffer->callbackType == UL_CONTACT_INSERT) { /* Increment the contact index, which will be used to generate * our new row. */ currentUser->contactIndex++; /* We should do this after we create the row in the snmptable. * Its easier to delete the SNMP Row than the contact record. */ if(!insertContactRecord(&(currentUser->contactList), currentUser->contactIndex, currentBuffer->stringContact)) { LM_ERR("openserSIPRegUserTable was unable to allocate memory for " "adding contact: %s to user %s.\n", currentBuffer->stringName, currentBuffer->stringContact); /* We didn't use the index, so decrement it so we can * use it next time around. */ currentUser->contactIndex--; return; } if (!createContactRow(currentUser->userIndex, currentUser->contactIndex, currentBuffer->stringContact, currentBuffer->contactInfo)) { deleteContactRecord(&(currentUser->contactList), currentBuffer->stringContact); } } else { delContactIndex = deleteContactRecord(&(currentUser->contactList), currentBuffer->stringContact); /* This should never happen. But its probably wise to check and * to print out debug messages in case there is a hidden bug. */ if(delContactIndex == 0) { LM_ERR("Received a request to delete contact: %s for user: %s" " who doesn't exist\n", currentBuffer->stringName, currentBuffer->stringContact); return; } deleteContactRow(currentUser->userIndex, delContactIndex); deleteUser(hashTable, currentBuffer->stringName, HASH_SIZE); } }
void lmcMessaging::processMessage(MessageHeader* pHeader, XmlMessage* pMessage) { QString msgId; QString data = QString::null; XmlMessage reply; lmcTrace::write("Processing message type " + QString::number(pHeader->type) + " from user " + pHeader->userId); switch(pHeader->type) { case MT_UserData: if(pMessage->data(XN_QUERYOP) == QueryOpNames[QO_Get]) sendUserData(pHeader->type, QO_Result, &pHeader->userId, &pHeader->address); // add the user only after sending back user data, this way both parties will have added each other addUser(pMessage->data(XN_USERID), pMessage->data(XN_VERSION), pMessage->data(XN_ADDRESS), pMessage->data(XN_NAME), pMessage->data(XN_STATUS), QString::null, pMessage->data(XN_NOTE), pMessage->data(XN_USERCAPS)); break; case MT_Broadcast: emit messageReceived(pHeader->type, &pHeader->userId, pMessage); break; case MT_Status: data = pMessage->data(XN_STATUS); updateUser(pHeader->type, pHeader->userId, data); break; case MT_UserName: data = pMessage->data(XN_NAME); updateUser(pHeader->type, pHeader->userId, data); break; case MT_Note: data = pMessage->data(XN_NOTE); updateUser(pHeader->type, pHeader->userId, data); break; case MT_Message: // add message to received message list if(addReceivedMsg(pHeader->id, pHeader->userId)) { emit messageReceived(pHeader->type, &pHeader->userId, pMessage); } // send an acknowledgement msgId = QString::number(pHeader->id); reply.addData(XN_MESSAGEID, msgId); sendMessage(MT_Acknowledge, &pHeader->userId, &reply); break; case MT_GroupMessage: emit messageReceived(pHeader->type, &pHeader->userId, pMessage); break; case MT_PublicMessage: emit messageReceived(pHeader->type, &pHeader->userId, pMessage); break; case MT_Ping: // send an acknowledgement msgId = QString::number(pHeader->id); reply.addData(XN_MESSAGEID, msgId); sendMessage(MT_Acknowledge, &pHeader->userId, &reply); break; case MT_Query: // send a reply cum acknowledgement if its a 'get' query if(pMessage->data(XN_QUERYOP) == QueryOpNames[QO_Get]) { msgId = QString::number(pHeader->id); reply.addData(XN_MESSAGEID, msgId); reply.addData(XN_QUERYOP, QueryOpNames[QO_Result]); sendMessage(pHeader->type, &pHeader->userId, &reply); } else if(pMessage->data(XN_QUERYOP) == QueryOpNames[QO_Result]) { msgId = pMessage->data(XN_MESSAGEID); removePendingMsg(msgId.toLongLong()); // Add the path to the user's avatar image stored locally data = "avt_" + pHeader->userId + ".png"; data = QDir(StdLocation::cacheDir()).absoluteFilePath(data); pMessage->addData(XN_AVATAR, data); emit messageReceived(pHeader->type, &pHeader->userId, pMessage); } break; case MT_ChatState: emit messageReceived(pHeader->type, &pHeader->userId, pMessage); break; case MT_Acknowledge: // remove message from pending list msgId = pMessage->data(XN_MESSAGEID); removePendingMsg(msgId.toLongLong()); break; case MT_File: case MT_Avatar: processFile(pHeader, pMessage); break; case MT_Folder: processFolder(pHeader, pMessage); break; default: break; } lmcTrace::write("Message processing done"); }
void ClientManager::on(UserUpdated, Client*, const OnlineUser& user) noexcept { updateUser(user); }