void IoHandler::saveUserFile(string userFile, UserList &userList) { ofstream outputFile; outputFile.open(userFile); if (outputFile.fail()) { cout << "파일을 찾을수 없습니다."; return; } for (int i = 0; i < userList.getSize(); ++i) { outputFile << "[" << userList.getUserByIndex(i).getName() << "]" << " "; outputFile << "[" << userList.getUserByIndex(i).getWinCount() << "]" << " "; outputFile << "[" << userList.getUserByIndex(i).getLoseCount() << "]"; if (i != userList.getSize() - 1) { outputFile << endl; } } outputFile.close(); }
bool KaduExtInfo::getSelectedUser(QString &user) { kdebugf(); #if defined(KADU_0_4_x) UserBox *activeUserBox = kadu->userbox()->getActiveUserBox(); #elif defined(KADU_0_5_0) UserBox *activeUserBox = kadu->userbox()->activeUserBox(); #endif if (activeUserBox == NULL)//to siê zdarza... { kdebugf2(); return false; } #if defined(KADU_0_4_x) UserList users = activeUserBox->getSelectedUsers(); #elif defined(KADU_0_5_0) UserListElements users = activeUserBox->selectedUsers(); #endif if (users.count() == 1) { user = (*users.begin()).altNick(); kdebugf2(); return true; } return false; kdebugf2(); }
int GeUser::modify_user(char* system, char* user, char* password, unsigned int priv, char* fullname, char* description, char* email, char* phone, char* sms) { int sts; UserList* ul; SystemName* sn = new SystemName(system); sts = sn->parse(); if (EVEN(sts)) { delete sn; return sts; } SystemList* sl = find_system(sn); delete sn; if (!sl) return USER__NOSUCHSYSTEM; ul = (UserList*)sl->find_user(user); if (!ul) return USER__NOSUCHUSER; ul->modify(password, priv, fullname, description, email, phone, sms); return USER__SUCCESS; }
void Element::setUsers( UserList ul ) { if (!isRecord()) return; UserList toAdd; UserList toRemove; UserList currentUsers = users(); foreach( User emp, ul ) if( !currentUsers.contains( emp ) ) toAdd += emp; foreach( User eu, currentUsers ) if( !ul.contains( eu ) ) toRemove += eu; ElementUserList tul = ElementUser::recordsByElement( *this ); foreach( ElementUser eu, tul ) if( toRemove.contains( eu.user() ) ) eu.remove(); foreach( User emp, toAdd ) { ElementUser tu; tu.setElement( *this ); tu.setUser( emp ); tu.setActive( 1 ); tu.commit(); }
int GeUser::get_user_data(char* system, char* user, char* password, pwr_tMask* priv, pwr_tOix* id, char* fullname, char* description, char* email, char* phone, char* sms) { int sts; UserList* ul; SystemName* sn = new SystemName(system); sts = sn->parse(); if (EVEN(sts)) { delete sn; return sts; } SystemList* sl = find_system(sn); delete sn; if (!sl) return USER__NOSUCHSYSTEM; ul = (UserList*)sl->find_user(user); if (!ul) return USER__NOSUCHUSER; ul->get_data(password, priv, id, fullname, description, email, phone, sms); return USER__SUCCESS; }
LRESULT WaitingUsersFrame::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if (getSelectedUser()) { const UserPtr User = getCurrentdUser(); if (User) { UploadManager::LockInstanceQueue lockedInstance; // [+] IRainman opt. lockedInstance->clearUserFilesL(User); } } else { if (m_ctrlList.getSelectedCount()) { int j = -1; UserList RemoveUsers; while ((j = m_ctrlList.GetNextItem(j, LVNI_SELECTED)) != -1) { // Ok let's cheat here, if you try to remove more users here is not working :( RemoveUsers.push_back((m_ctrlList.getItemData(j))->getUser()); } UploadManager::LockInstanceQueue lockedInstance; // [+] IRainman opt. for (auto i = RemoveUsers.cbegin(); i != RemoveUsers.cend(); ++i) { lockedInstance->clearUserFilesL(*i); } } } m_needsUpdateStatus = true; // [!] IRainman opt. return 0; }
int LuaV6Chat3App::ChatWithText(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { lua_Integer uid = lua_tointeger(luaState, 2); size_t text_len=lua_objlen(luaState, 3); const char *text = lua_tolstring(luaState, 3, &text_len); wstring wtext = V6Util::Utf8ToUnicode(text); string st; UserList *list = UserList::Instance(); list->RecordChatText(uid, wtext, st); Handle<MsgSender> sender; list->GetUserSender(uid, sender); sender->ChatWithTextMsg(wtext, st); lua_pushstring(luaState, st.c_str()); return 1; } lua_pushnil(luaState); return 1; }
STATE StateNetwork::Update() { if(m_pNetworkControler && (m_pNetworkControler->GetNetworkState() == CLIENT)) { m_pNetworkControler->ReceivePacket(); SmartPointer<PacketAddr> pAddr; if((pAddr = m_pNetworkControler->GetPacket()) != NULL) { if( pAddr->m_Packet.Protocolid() == CONNECT_REQ) { UserInfomationPacketMaker pkMaker; pkMaker.SetPacket(&pAddr->m_Packet); UserList lst = pkMaker.OutPutUserInformation(); UserList::iterator iter; for(iter = lst.begin(); iter != lst.end(); iter++) { //여기에다가 이미 존재하는 유져가 있을경우 AddUser를 호출하지 않게 만들어야 함... m_pNetworkControler->AddUser((*iter)); delete (*iter); } lst.clear(); m_pNetworkControler->SetMyUserID(pAddr->m_Packet.ID()); return STATE_WAITINGROOM; } } } if(m_bSelectState) return STATE_WAITINGROOM; else return STATE_NONE; }
//向客户端发送所有的用户信息 void getUserList(sockaddr_in sender) { int len = (int)clientList.size(); sendto(primarySock,(const char *)&len,sizeof(len),0,(SOCKADDR *)&sender,sizeof(sender)); for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator) { sendto(primarySock,(const char *)(*UserIterator),sizeof(stUserListNode),0,(SOCKADDR *)&sender,sizeof(sender)); } }
UserList Element::users( bool recursive ) const { UserList ret = ElementUser::recordsByElement( *this ).users(); if( recursive ) { ElementList kids = children( true ); foreach( Element e, kids ) ret += e.users(); } return ret.unique(); }
User * Query::getUserByName(const string &name) { Metadata *metadata = getFromWebService("user", "", NULL, &UserFilter().name(name)); UserList list = metadata->getUserList(true); delete metadata; if (list.size() > 0) return list[0]; else throw ResponseError("response didn't contain user data"); }
stUserListNode GetUser(char *username) { for(UserList::iterator UserIterator=ClientList.begin(); UserIterator!=ClientList.end(); ++UserIterator) { if( strcmp( ((*UserIterator)->userName), username) == 0 ) return *(*UserIterator); } throw Exception("not find this user"); }
stUserListNode GetUser(char *userName) { for (auto ClientList_iter = ClientList.begin(); ClientList_iter != ClientList.end(); ++ClientList_iter) { if (strcmp((*ClientList_iter)->userName, userName) == 0) return *(*ClientList_iter); } std::cout << "can not find user: " << userName << std::endl; exit(0); }
void UploadQueueFrame::removeSelected() { int i = -1; UserList RemoveUsers; while((i = ctrlList.GetNextItem(i, LVNI_SELECTED)) != -1) { // Ok let's cheat here, if you try to remove more users here is not working :( RemoveUsers.push_back(((UploadQueueItem*)ctrlList.getItemData(i))->getUser()); } for(auto i = RemoveUsers.begin(); i != RemoveUsers.end(); ++i) { UploadManager::getInstance()->clearUserFiles(*i, true); } updateStatus(); }
void TabUserLists::processRemoveFromListEvent(const Event_RemoveFromList &event) { QString list = QString::fromStdString(event.list_name()); QString user = QString::fromStdString(event.user_name()); UserList *userList = 0; if (list == "buddy") userList = buddyList; else if (list == "ignore") userList = ignoreList; if (!userList) return; userList->deleteUser(user); }
int LuaV6Chat3App::DeleteFriend(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { lua_Integer uid = lua_tointeger(luaState, 2); UserList *userlist = UserList::Instance(); userlist->DeleteUser(uid); } return 0; }
void removeUser(char *name) { stUserListNode *removeNode; removeNode = getUser(name); clientList.remove(removeNode); for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator) { stUserListNode *tmpNode = (stUserListNode *)(*UserIterator); u_long ip = htonl(tmpNode->ip); cout << "username :"******" ip:"<<inet_ntoa(*(in_addr *)&ip) <<" port:"<<tmpNode->port <<endl; } }
void rt_pvd_udb::load_systemgroup( SystemList *systemgroup) { procom_obj item; pwr_sClass_SystemGroupReg *body; char sname[120]; char *s; body = (pwr_sClass_SystemGroupReg *) calloc( 1, sizeof(pwr_sClass_SystemGroupReg)); item.body = body; gu->get_system_name( systemgroup, sname); if (( s = strrchr( sname, '.'))) strcpy( item.name, s+1); else strcpy( item.name, sname); gu->get_system_data( sname, &body->Attributes, &item.oix, body->Description); item.oix++; if ( next_oix <= item.oix) next_oix = item.oix + 1; item.cid = pwr_cClass_SystemGroupReg; item.fthoix = menu_stack[menu_cnt - 1]; item.bwsoix = m_list[item.fthoix].lchoix; if ( item.bwsoix) m_list[item.bwsoix].fwsoix = item.oix; if ( m_list[item.fthoix].fchoix == 0) m_list[item.fthoix].fchoix = item.oix; m_list[item.fthoix].lchoix = item.oix; item.body_size = sizeof(pwr_sClass_SystemGroupReg); menu_stack[menu_cnt] = item.oix; menu_cnt++; if ( m_list.size() <= item.oix + 1) m_list.resize( item.oix + 1); m_list[item.oix] = item; UserList *user = systemgroup->first_user(); while ( user) { load_user( user, systemgroup); user = user->next_user(); } SystemList *sg = systemgroup->first_system(); while ( sg) { load_systemgroup( sg); sg = sg->next_system(); } menu_cnt--; }
int LuaV6Chat3App::GetUserInfoByID(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { int id = lua_tointeger(luaState, 2); UserList *list = UserList::Instance(); wstring nick_name, group_name, introduction, location; unsigned short sex = 0; unsigned int age = 0; if(list->GetUser(id, nick_name, group_name, sex, age, introduction, location)) { lua_newtable(luaState); lua_pushstring(luaState, "name"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(nick_name.c_str()).c_str()); lua_settable(luaState,-3); lua_pushstring(luaState, "groupname"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(group_name.c_str()).c_str()); lua_settable(luaState,-3); lua_pushstring(luaState, "sex"); lua_pushnumber(luaState, sex); lua_settable(luaState,-3); lua_pushstring(luaState, "age"); lua_pushnumber(luaState, age); lua_settable(luaState,-3); lua_pushstring(luaState, "introduction"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(introduction.c_str()).c_str()); lua_settable(luaState,-3); lua_pushstring(luaState, "location"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(location.c_str()).c_str()); lua_settable(luaState,-3); wstring headImagePath(USERHEAD_RELATIVE_PATH); wstringstream sid; sid<<id; headImagePath = headImagePath + L"\\" + sid.str(); XL_BITMAP_HANDLE bmp = V6Util::GetUserDataImageHandle(headImagePath.c_str()); if(bmp) { lua_pushstring(luaState, "head"); if(!XLUE_PushBitmap(luaState, bmp)) lua_pushnil(luaState); lua_settable(luaState,-3); //弹出key,value,并设置到subtable里面去 } return 1; } } lua_pushnil(luaState); return 1; }
int GeUser::get_user( const char *gu_system, const char *gu_user, const char *gu_password, unsigned int *priv) { UserList *ul; SystemList *sl; SystemName *sn, *parent; int sts; char system[80]; char password[80]; char user[80]; cdh_ToLower( system, gu_system); cdh_ToLower( user, gu_user); strcpy( password, gu_password); // Find system sn = new SystemName( system); sts = sn->parse(); if ( EVEN(sts)) { delete sn; return USER__NOSUCHSYSTEM; } while( sn) { sl = find_system( sn); if ( sl) { ul = (UserList *) sl->find_user( user); if ( ul) { sts = ul->check_password( password); if ( EVEN(sts)) return sts; *priv = ul->priv; return USER__SUCCESS; } if ( !(sl->attributes & user_mSystemAttr_UserInherit)) break; } parent = sn->parent(); if ( parent) parent->parse(); delete sn; sn = parent; } return USER__NOSUCHUSER; }
int LuaV6Chat3App::GetUserList(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { UserList *list = UserList::Instance(); lua_newtable(luaState); //创建一个表格,放在栈顶 int i=1; map<unsigned int, Handle<UserInfo>>& users = list->GetUsers(); for(UserList::UserIter iter=users.begin(); iter!=users.end(); ++iter, ++i) { lua_pushnumber(luaState, i); lua_newtable(luaState); //压入value,也是一个table(subtable) lua_pushstring(luaState, "groupname"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(iter->second->group_name.c_str()).c_str()); lua_settable(luaState,-3); //弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "id"); lua_pushnumber(luaState, iter->second->uid); lua_settable(luaState,-3); //弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "nickname"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(iter->second->nick_name.c_str()).c_str()); lua_settable(luaState,-3); //弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "location"); wstring location; iter->second->GetLocation(location); lua_pushstring(luaState, V6Util::UnicodeToUtf8(location.c_str()).c_str()); lua_settable(luaState,-3); //弹出key,value,并设置到subtable里面去 wstring headImagePath(USERHEAD_RELATIVE_PATH); wstringstream sid; sid<<iter->second->uid; headImagePath = headImagePath + L"\\" + sid.str(); XL_BITMAP_HANDLE bmp = V6Util::GetUserDataImageHandle(headImagePath.c_str()); if(bmp) { lua_pushstring(luaState, "head"); if(!XLUE_PushBitmap(luaState, bmp)) lua_pushnil(luaState); lua_settable(luaState,-3); //弹出key,value,并设置到subtable里面去 } lua_settable(luaState,-3);//这时候父table的位置还是-3,弹出key,value(subtable),并设置到table里去 } return 1; } lua_pushnil(luaState); return 1; }
stUserListNode* getUser(char *name) { stUserListNode *node = NULL; stUserListNode *removeNode = NULL; for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator) { node = (stUserListNode *)(*UserIterator); if(strcmp(node->stUserName,name) == 0) { removeNode = node; break; } } return removeNode; }
bool XmppStanzaParser::ParseActiveUsersResponseStanza(XmppStanzaPtr stanza, UserList& userList) { bool result = false; if (IsActiveUsersResponseStanza(stanza)) { XmppStanzaPtr query = stanza->GetChildByName(stanza_names::Query); if (!!query) { for (XmppStanzaPtr item = query->GetFirstChild(); !!item; item = item->GetNextChild()) { User user; user.identifier = item->GetAttribute(stanza_attribute_keys::Jid); std::string base64PubKey = item->GetAttribute(stanza_attribute_keys::Key); if (!base64PubKey.empty()) { user.securityPolicy.encryptionAlgo = encryption_algorithm::RSA_1024; // TODO: receive algo from server user.securityPolicy.encryptionPubKey = detail::Base64::Decode(base64PubKey); } userList.push_back(user); } } result = true; } return result; }
void TabUserLists::processAddToListEvent(const Event_AddToList &event) { const ServerInfo_User &info = event.user_info(); bool online = allUsersList->getUsers().contains(QString::fromStdString(info.name())); QString list = QString::fromStdString(event.list_name()); UserList *userList = 0; if (list == "buddy") userList = buddyList; else if (list == "ignore") userList = ignoreList; if (!userList) return; userList->processUserInfo(info, online); userList->sortItems(); }
int LuaV6Chat3App::ChangeFriendGroup(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { lua_Integer uid = lua_tointeger(luaState, 2); size_t group_name_len=lua_objlen(luaState, 3); const char *group_name = lua_tolstring(luaState, 3, &group_name_len); UserList *userlist = UserList::Instance(); userlist->UpdateUser(uid, NULL, &V6Util::Utf8ToUnicode(group_name), 3, 0, NULL, NULL); } return 0; }
void login() { string user; cout << endl; cout << "Please enter your username, then press enter." << endl; cout << "User Entry: "; cin >> user; //get user from database User input = theDatabase.getUser(user); //search for name if (input.getName() == user) { string password; cout << endl; cout << "Please enter your password, then press enter." << endl; cout << "User Entry: "; cin >> password; //password validation User theUser = theDatabase.getUser(user); if (theUser.getPassword() == password) { cout << endl; cout << "Password Correct! Logging in..." << endl; //call logged in menu loggedinmenu(theUser); } else { cout << endl; cout << "Username and/or Password is incorrect." << endl; cout << "Please Try Again" << endl; //call welcomescreen welcomescreen(); } }
void SystemList::save(std::ofstream& fp) { UserList* ul; SystemList* sl; fp << int(user_eData_System) << '\n'; fp << int(user_eData_SystemName) << FSPACE << name << '\n'; fp << int(user_eData_SystemLevel) << FSPACE << level << '\n'; fp << int(user_eData_SystemAttributes) << FSPACE << attributes << '\n'; fp << int(user_eData_SystemId) << FSPACE << id << '\n'; fp << int(user_eData_SystemDescription) << FSPACE << description << '\n'; for (ul = (UserList*)userlist; ul != NULL; ul = ul->next) ul->save(fp); for (sl = childlist; sl; sl = sl->next) sl->save(fp); fp << int(user_eData_End) << '\n'; }
/** 用户登陆时,记录用户信息 并输出所有登陆的用户信息 */ void clientLogin(stMessage *message, sockaddr_in *sender) { cout << "client connected :" << message->message.loginMessage.stUserName <<endl; stUserListNode *node = new stUserListNode; strcpy(node->stUserName,message->message.loginMessage.stUserName); node->ip = ntohl(sender->sin_addr.S_un.S_addr); node->port = ntohs(sender->sin_port); clientList.push_back(node); cout << "total client is " << clientList.size() <<endl; for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator) { stUserListNode *tmpNode = (stUserListNode *)(*UserIterator); u_long ip = htonl(tmpNode->ip); cout << "username :"******" ip:"<<inet_ntoa(*(in_addr *)&ip) <<" port:"<<tmpNode->port <<endl; } }
void MessageManager::closeAll(bool Offline) { UserList toRemove; { RLock l(cs); for (auto i : chats) { if (Offline && i.first->isOnline()) continue; toRemove.push_back(i.first); } } for (const auto& u : toRemove) { removeChat(u); } }
void WaitingUsersFrame::removeSelected() { int j = -1; UserList RemoveUsers; while ((j = m_ctrlList.GetNextItem(j, LVNI_SELECTED)) != -1) { // Ok let's cheat here, if you try to remove more users here is not working :( RemoveUsers.push_back(m_ctrlList.getItemData(j)->getUser()); } { UploadManager::LockInstanceQueue lockedInstance; // [+] IRainman opt. for (auto i = RemoveUsers.cbegin(); i != RemoveUsers.cend(); ++i) { lockedInstance->clearUserFilesL(*i); } } m_needsUpdateStatus = true; // [!] IRainman opt. }