示例#1
0
// !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;
}
示例#2
0
//----------------------------------------------------------------------
// 
// GMServerInfoHander::execute()
// 
// 게임 서버가 로그인 서버로부터 GMServerInfo 패킷을 받게 되면,
// ReconnectLoginInfo를 새로 추가하게 된다.
// 
//----------------------------------------------------------------------
void GMServerInfoHandler::execute (GMServerInfo * pPacket )
	 throw(ProtocolException , Error )
{
	__BEGIN_TRY __BEGIN_DEBUG_EX
	__BEGIN_DEBUG

#ifdef __LOGIN_SERVER__

	ZONEUSERDATA rData;
	WorldID_t WorldID = pPacket->getWorldID();
	ServerGroupID_t ServerGroupID = pPacket->getServerID();
	BYTE MaxCount = pPacket->getZoneUserCount();

	UserInfo * pUserInfo = g_pUserInfoManager->getUserInfo(ServerGroupID, WorldID);

	pUserInfo->setUserNum(0);
	Assert(pUserInfo != NULL);
	for(int count = 0; count < MaxCount; count++ ) {
		pPacket->popZoneUserData(rData);
		pUserInfo->setUserNum(pUserInfo->getUserNum() + rData.UserNum);
	}

#endif

	__END_DEBUG
	__END_DEBUG_EX __END_CATCH
}
示例#3
0
//! \brief
void IncomingUdp::onExecute()
{
    char buffer[ max_packet_size ];     // TODO: Member variable? Allow max_packet_size to be defined by configuration

    // Memory allocation comes from round-robin memory buffer(s) to remove
    // the necessity for new/delete blocks

    while ( isActive() )
    {
        const int dataLength = m_socket.recv( buffer, max_packet_size );
        if ( dataLength < 0 )
        {
            if ( isActive() )
            {
                processSocketError( dataLength );
            }
        }
        else if ( dataLength > 0 )  // TODO: Simpler if the message queue handles this?
        {
            m_queue->push( buffer, dataLength );
            
            // TODO: Should validate packet then pass it into message queue, we shouldn't know about UserInfo at this level.
            // TODO: Decrypt packet content
            UserInfo *user = findUser( packetInfo.publicKey );
            if ( user && user->ipAddress == packetInfo.ipAddress )
            {
                user->queueMessage( buffer, dataLength );
            }
            else
            {
                m_log->Error( kModuleName, "Received unexpected UDP packet.\n" );
            }
        }
    }
}
示例#4
0
int main ()
{
	try {
		Connection connection("hostname", 22, true);
//		connection.setCredentials("", "");
//		connection.setKeyPath("");

		UserInfo ui = connection.getUserInfo();

		cout 	<< "User infos:\n"
				<< "   login: "******"    home: " << ui.getHomeDir() << endl
				<< "   shell: " << ui.getUserShell() << endl;

		connection.mkConnection();

		if (connection.isSessionValid())
			cout << "Connection OK" << endl;

		connection 	>> "whoami"
					>> "id"
					>> "echo 'test' > msg"
					>> "cat msg";

		string received_out = connection.getLastOutput();
		cout << "Received output: " << endl << received_out << endl;

	} catch (Exception & e) {
		cout << "Exception caught: " << e.what() << endl;
	}

	return 0;
}
示例#5
0
文件: NsAdapter.cpp 项目: ic-hep/emi3
void NsAdapterCatalog::updateUser(const UserInfo& user) throw (DmException)
{
  // uid may not be initialized
  UserInfo u = this->getUser(user.name);
  wrapCall(dpns_modifyusrmap(u.getUnsigned("uid"),
                             (char*)user.name.c_str(),
                             user.getLong("banned")));
}
示例#6
0
//----------------------------------------------------------------------
// load data from database
//----------------------------------------------------------------------
void UserInfoManager::load ()
	throw(Error )
{
	__BEGIN_TRY

	Statement * pStmt;

	BEGIN_DB
	{
		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();
		Result* pResult = pStmt->executeQuery(
			"SELECT MAX(WorldID) FROM GameServerGroupInfo"
		);

		if (pResult->getRowCount() == 0)
		{
			throw Error("GameServerGroupInfo TABLE does not exist!");
		}

		pResult->next();
		m_MaxWorldID = pResult->getInt(1) + 2;

		SAFE_DELETE(pStmt);
	}
	END_DB(pStmt)

	m_UserInfos= new HashMapUserInfo[m_MaxWorldID];


	try {

		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();
		Result * pResult = pStmt->executeQuery(
			"SELECT WorldID, GroupID FROM GameServerGroupInfo"
		);

		while (pResult->next() ) {
			UserInfo * pUserInfo = new UserInfo();
			WorldID_t WorldID = pResult->getInt(1);
			pUserInfo->setWorldID(WorldID);
			pUserInfo->setServerGroupID(pResult->getInt(2));
			pUserInfo->setUserNum(0);
			addUserInfo(pUserInfo);
		}

	} catch (SQLQueryException & sqe ) {

		// 필살 삭제!
		delete pStmt;

		throw Error(sqe.toString());
	}

	// 필살 삭제!
	delete pStmt;

	__END_CATCH
}
示例#7
0
void TestUserInfo::isTalkingTo()
{
    UserInfo u(m_ipbxid, "1234");
    u.setPhoneIdList(QStringList() << "asterisk/p1");
    UserInfo *other = new UserInfo("asterisk", "u2");
    other->setPhoneIdList(QStringList() << "asterisk/p2");

    QCOMPARE(u.isTalkingTo("asterisk/u2"), false);
    b_engine->setUser("asterisk/u2", other);
    QCOMPARE(u.isTalkingTo("asterisk/u2"), true);
}
/*! \brief display the context Menu
 */
void ExtendedTableWidget::contextMenuEvent(QContextMenuEvent * event)
{
    qDebug() << Q_FUNC_INFO << event;
    qDebug() << "   " << event->pos();
    QTableWidgetItem *item = itemAt(event->pos());
    QAction *action;
    if (item) {
        event->accept();
        QMenu contextMenu( this );
        if (m_editable) {
            action = contextMenu.addAction(tr("&Remove"), this, SLOT(remove()));
            action->setProperty("row", row(item));
        }
        if (m_re_number.exactMatch(item->text())) {
            action = contextMenu.addAction(tr("&Dial"), this, SLOT(dialNumber()));
            action->setProperty("number", item->text());

            QMenu *transferMenu = new QMenu(tr("Direct &Transfer"), &contextMenu);
            QMenu *indirectTransferMenu = new QMenu(tr("&Indirect Transfer"), &contextMenu);
            UserInfo *ui = b_engine->getXivoClientUser();
            if (ui) {
                foreach (const QString phone, ui->phonelist()) {
                    const PhoneInfo * pi = ui->getPhoneInfo( phone );
                    if (pi) {
                        QMapIterator<QString, QVariant> it( pi->comms() );
                        while(it.hasNext()) {
                            it.next();
                            QMap<QString, QVariant> call = it.value().toMap();
                            // Add the transfer entry with the callerid name and num
                            QString text;
                            if (call.contains("calleridname")) {
                                text.append( call["calleridname"].toString() );
                                text.append(" : ");
                            }
                            text.append(call["calleridnum"].toString() );

                            action = transferMenu->addAction(text, this, SLOT(dtransfer()));
                            action->setProperty("chan", call["peerchannel"]);
                            action->setProperty("number", item->text());

                            action = indirectTransferMenu->addAction(text, this, SLOT(itransfer()));
                            action->setProperty("chan", call["thischannel"]);
                            action->setProperty("number", item->text());
                        }
                    }
                }
            }
            if (!transferMenu->isEmpty()) {
                contextMenu.addMenu(transferMenu);
            }
            if (!indirectTransferMenu->isEmpty()) {
                contextMenu.addMenu(indirectTransferMenu);
            }
        } else if(item->text().contains("@")) { // this is an email address
示例#9
0
void UsersFrame::handleDescription() {
	if(users->countSelected() == 1) {
		int i = users->getSelected();
		UserInfo* ui = users->getData(i);
		ParamDlg dlg(this, ui->columns[COLUMN_NICK], T_("Description"), ui->columns[COLUMN_DESCRIPTION]);

		if(dlg.run() == IDOK) {
			FavoriteManager::getInstance()->setUserDescription(ui->getUser(), Text::fromT(dlg.getValue()));
			ui->columns[COLUMN_DESCRIPTION] = dlg.getValue();
		}
	}
}
ContainerStatus ContainerManagement::getContainerStatus(Container &container,
		Token &nmToken) {
	//1. setup Connection to NodeManager
	string host = container.getNodeId().getHost();
	ostringstream oss;
	oss << container.getNodeId().getPort();
	string port(oss.str());

	LOG(INFO,
			"ContainerManagement, is going to connect to NM [%s:%s] to getContainerStatus container",
			host.c_str(), port.c_str());

	UserInfo user = UserInfo::LocalUser();
	Yarn::Token anotherToken;
	anotherToken.setIdentifier(nmToken.getIdentifier());
	anotherToken.setKind(nmToken.getKind());
	anotherToken.setPassword(nmToken.getPassword());
	anotherToken.setService(nmToken.getService());
	user.addToken(anotherToken);

	RpcAuth rpcAuth(user, AuthMethod::TOKEN);
	Yarn::Config config;
	SessionConfig sessionConfig(config);

#ifdef MOCKTEST
	 ContainerManagementProtocol *nmClient = stub->getContainerManagementProtocol();
#else
	 ContainerManagementProtocol *nmClient = new ContainerManagementProtocol(
			host, port, anotherToken.getService(), sessionConfig, rpcAuth);
#endif

	ContainerId cid = container.getId();
	list<ContainerId> cids;
	cids.push_back(cid);

	GetContainerStatusesRequest request;
	request.setContainerIds(cids);

	GetContainerStatusesResponse response = nmClient->getContainerStatuses(request);

	//3. free
	delete nmClient;
	list<ContainerStatus> statusList = response.getContainerStatuses();
	if (statusList.size() > 0){
		list<ContainerStatus>::iterator statusHead = statusList.begin();
		return (*statusHead);
	}else{
		ContainerStatus status;
		return status;
	}

}
示例#11
0
int	UserInfoMng::removeIdleUsers(void)
{
	WriteMutex<PasMutex> writeMutex(lockUserInfo);

	map<intMDN_t, UserInfo*>::const_iterator mdnpos = MDNs.begin();

	vector<intMDN_t> idleMdnList;
	vector<intIP_t> idleIpList;

	time_t now = time(NULL);
	for( ; mdnpos != MDNs.end(); mdnpos++)
	{
		// 상용에서는 20분 
		UserInfo *userInfo = mdnpos->second;
		
		if (userInfo && userInfo->isIdle(now, maxIdleSec))
		{
			idleMdnList.push_back(mdnpos->first);
			idleIpList.push_back(mdnpos->second->getIntIpAddr());
		}
	}

	if (idleMdnList.size()==0)
		return 0;
		
	//PAS_INFO1("UserInfoMng:: found %d IDLE users", idleMdnList.size() );

	
	int	delCount = 0;
	for (unsigned int i=0; i<idleMdnList.size(); i++)
	{
		char stripaddr[32];
		Util::int2ipaddr(idleIpList[i], stripaddr, sizeof(stripaddr)-1);
		PAS_TRACE2("UserInfoMng:: Idle user{MDN[0%d] IP[%s]}", idleMdnList[i], stripaddr);

		map<intMDN_t, UserInfo*>::const_iterator mdnfound = MDNs.find(idleMdnList[i]);
		if(mdnfound != MDNs.end())
		{
			delete mdnfound->second;

			MDNs.erase(idleMdnList[i]);
			IPs.erase(idleIpList[i]);
			delCount++;
		}
	}

	PAS_INFO3("UserInfoMng:: %d idle, %d deleted, %d left", 
		idleMdnList.size(), delCount, MDNs.size());
		
	userCount = MDNs.size();
	return delCount;
}
示例#12
0
UserInfo* UserInfo::getUserMap(QString iniFile, QStringList keys, QString passphrase)
{
  FUNC_DEBUG;
  INIHelper iniHelper(iniFile);
  UserInfo* info = new UserInfo();
  for (int i = 0; i < keys.size(); i++) {
    iniHelper.readValue("User",keys.at(i));
    info->addUser(keys.at(i)
                 ,iniHelper.readValue("User",keys.at(i))
                 ,Crypt::decrypt(passphrase,iniHelper.readValue("Password",keys.at(i))));
  }
  return info;
}
StartContainerResponse ContainerManagement::startContainer(Container &container,
		StartContainerRequest &request, Token &nmToken) {
	//1. setup Connection to NodeManager
	string host = container.getNodeId().getHost();
	ostringstream oss;
	oss << container.getNodeId().getPort();
	string port(oss.str());

	LOG(INFO,
			"ContainerManagement::startContainer, is going to connect to NM [%s:%s] to start container",
			host.c_str(), port.c_str());

	UserInfo user = UserInfo::LocalUser();
	Yarn::Token anotherToken;
	anotherToken.setIdentifier(nmToken.getIdentifier());
	anotherToken.setKind(nmToken.getKind());
	anotherToken.setPassword(nmToken.getPassword());
	anotherToken.setService(nmToken.getService());
	user.addToken(anotherToken);

	RpcAuth rpcAuth(user, AuthMethod::TOKEN);
	Yarn::Config config;
	SessionConfig sessionConfig(config);

#ifdef MOCKTEST
	 ContainerManagementProtocol *nmClient = stub->getContainerManagementProtocol();
#else
	 ContainerManagementProtocol *nmClient = new ContainerManagementProtocol(
			host, port, anotherToken.getService(), sessionConfig, rpcAuth);
#endif

	//2. startContainers
	StartContainersRequest scsRequest;
	list<StartContainerRequest> requests;
	requests.push_back(request);
	scsRequest.setStartContainerRequests(requests);

	StartContainersResponse scsResponse = nmClient->startContainers(scsRequest);

	StartContainerResponse scResponse;
	scResponse.setServicesMetaData(scsResponse.getServicesMetaData());

	LOG(INFO,
			"ContainerManagement::startContainer, after start a container, id:%d on NM [%s:%s]",
			container.getId().getId(), host.c_str(), port.c_str());

	//3. free
	delete nmClient;

	return scResponse;
}
示例#14
0
void ClientManager::userUpdated(sid_type sid, UserInfo const& ui) throw()
{
	LocalUsers::iterator i = localUsers.find(sid);
	if(i == localUsers.end())
		assert(0); // maybe use this for remote later, but now...

	const string& oldNick = i->second->getUserInfo()->getNick();
	const string& newNick = ui.getNick();
	if(ui.has("NI")) {
		nicks.erase(oldNick);
		nicks.insert(newNick);
	}
	// CID can't change, nothing else to do
}
示例#15
0
文件: Home.cpp 项目: ekersale/Babel
void		Home::setSurname(void *cmdptr, void *idptr)
{
	std::vector<const char *> *value = (std::vector<const char *> *)cmdptr;
	std::vector<int> *id = (std::vector<int> *)idptr;
	std::map<int, UserInfo *>::iterator it;
	static int tmp = 0;

	if ((it = _musers.find(id[0][0])) == _musers.end()) {
		UserInfo *info = new UserInfo;
		if (tmp == 0)
			_myid = id[0][0];
		tmp++;
		info->set_id(id[0][0]);
		std::cout << info->get_id() << std::endl;
		info->set_surname((*value)[0]);
		_musers[id[0][0]] = info;
		addContact(_musers[id[0][0]]);
	}
	else {
		UserInfo *tmp = _musers[id[0][0]];
		std::string stmp;
		tmp->set_surname((*value)[0]);
		stmp = tmp->get_name() + " " + tmp->get_surname();
		std::map<int, t_contact *>::iterator it;
		if ((it = _bcontact.find(id[0][0])) == _bcontact.end())
			return;
		_bcontact[id[0][0]]->item->setText(stmp.c_str());
	}
}
示例#16
0
void ClientManager::addRemoteClient(sid_type sid, UserInfo const& ui) throw()
{
	assert(!hasClient(sid) || remoteUsers.count(sid));
	if(!remoteUsers.count(sid))
		remoteUsers[sid] = new UserInfo(Command('B', Command::INF, sid));
	if(ui.has("ID") && remoteUsers[sid]->has("ID")) {
		cids.erase(remoteUsers[sid]->getCID());
		cids.insert(ui.getCID());
	}
	if(ui.has("NI") && remoteUsers[sid]->has("NI")) {
		nicks.erase(remoteUsers[sid]->getNick());
		nicks.insert(ui.getNick());
	}
	remoteUsers[sid]->update(ui);
}
示例#17
0
文件: Authn.cpp 项目: ic-hep/emi3
std::vector<UserInfo> BuiltInAuthn::getUsers(void) throw (DmException)
{
  std::vector<UserInfo> users;
  UserInfo user;
  struct passwd* ent;
  
  while ((ent = getpwent()) != NULL) {
    user.clear();
    user.name = ent->pw_name;
    user["uid"] = ent->pw_uid;
    users.push_back(user);
  }
  
  return users;
}
示例#18
0
LRESULT UsersFrame::onConnect(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	const int l_cnt = ctrlUsers.GetItemCount();
	for (int i = 0; i < l_cnt; ++i)
	{
		dcassert(l_cnt == ctrlUsers.GetItemCount());
		UserInfo *ui = ctrlUsers.getItemData(i);
		const string& l_url = FavoriteManager::getUserUrl(ui->getUser());
		if (!l_url.empty())
		{
			HubFrame::openWindow(false, l_url);
		}
	}
	return 0;
}
示例#19
0
UserInfo *UserInfoMng::searchByMdn(char *MDN, char*ipAddr)
{
	ReadMutex<PasMutex> readMutex(lockUserInfo);

	UserInfo user;
	user.set(MDN, ipAddr);
	
	map<intMDN_t,  UserInfo*>::const_iterator mdnpos;
	mdnpos = MDNs.find(user.getIntPhoneNumber());
	if (mdnpos != MDNs.end()) //
	{
		return mdnpos->second;
	}
	return NULL;
}
示例#20
0
UserInfo *UserInfoMng::searchByAddr(char *MDN, char*ipAddr)
{
	ReadMutex<PasMutex> readMutex(lockUserInfo);
	
	UserInfo user;
	user.set(MDN, ipAddr);
	
	map<intMDN_t,  UserInfo*>::const_iterator ippos;
	ippos = IPs.find(user.getIntIpAddr());
	if (ippos != IPs.end()) // NOT found
	{
		return ippos->second;
	}

	return NULL;
}
void AuthorizationDialog::request(const UserInfo &userInfo)
{
	this->userInfo = userInfo;

	topLabel->setText(tr(REQUEST_TOP_LABEL).arg(userInfo.getDisplayName()));

	messageEdit->setPlainText(tr(REQUEST_DEFAULT_TEXT));
	messageEdit->setReadOnly(false);
	messageEdit->setFocus();
	messageEdit->selectAll();
	
	connect(messageEdit, SIGNAL(textChanged()), this, SLOT(checkMessages()));
	loadMessages();

	okButton->setText(tr(REQUEST_OK_BUTTON));
	rejectButton->hide();
	cancelButton->setText(tr(REQUEST_CANCEL_BUTTON));

	// Set widget info about yourself
	UserAccount currentUser = INFOMANAGER->getUserAccount();
	authUserNameLabel->setText(currentUser.getDisplayName());
	
	contactAvatarToolButton->setThumbnailMode(false);
	contactAvatarToolButton->setContactId(currentUser.getId());

	mode = Request;
	
	show();
}
示例#22
0
bool UsersFrame::matches(const UserInfo &ui) {
	if(!filter.empty() && !filter.match(filter.prepare(), [this, &ui](int column) { return Text::fromT(ui.getText(column)); })) {
		return false;
	}

	return show(ui.getUser(), false);
}
示例#23
0
文件: Home.cpp 项目: ekersale/Babel
void		Home::setStatus(void *cmdptr, void *idptr)
{
	std::vector<const char *> *value = (std::vector<const char *> *)cmdptr;
	std::vector<int> *id = (std::vector<int> *)idptr;
	std::map<int, UserInfo *>::iterator it;
	static int tmp = 0;

	if ((it = _musers.find(id[0][0])) == _musers.end()) {
		UserInfo *info = new UserInfo;
		if (tmp == 0)
			_myid = id[0][0];
		tmp++;
		info->set_id(id[0][0]);
		info->set_status((*value)[0][0]);
		_musers[id[0][0]] = info;
		addContact(_musers[id[0][0]]);
	}
	else {
		UserInfo *tmp = _musers[id[0][0]];
		QPixmap			*pixmap = NULL;
		QPalette		palette;

		tmp->set_status((*value)[0][0]);
		int itmp = (*value)[0][0];
		switch (itmp)
		{
		case 2:
			pixmap = new QPixmap("./Images/BabelHD_0001s_0005s_0002_status.png");
			break;
		case 3:
			pixmap = new QPixmap("./Images/BabelHD_0001s_0003s_0000_status.png");
			break;
		case 4:
			pixmap = new QPixmap("./Images/BabelHD_0001s_0000s_0000_status.png");
			break;
		case 1:
			pixmap = new QPixmap("./Images/BabelHD_0001s_0002s_0000_status.png");
			break;
		default:
			break;
		}
		if (pixmap != NULL)
			palette.setBrush(_bcontact[id[0][0]]->but->backgroundRole(), QBrush(*pixmap));
		_bcontact[id[0][0]]->but->setPalette(palette);
	}
}
示例#24
0
文件: user.cpp 项目: codepr/linqedin
int BusinessUser::similarity(const SmartPtr<User>& user) const {
    UserInfo* uf = dynamic_cast<UserInfo*> (this->account()->info());
    UserInfo* host = dynamic_cast<UserInfo*> (user->account()->info());
    int i_w = 2, s_w = 6, l_w = 2;
    double counter = 0;
    // interests
    vector<string> interests = uf->interests();
    vector<string> h_interests = host->interests();
    if(interests.size() <= h_interests.size()) {
        vector<string>::const_iterator it = interests.begin();
        for(; it < interests.end(); ++it)
            if(std::find(h_interests.begin(), h_interests.end(), (*it)) != h_interests.end()) counter++;
        counter = (counter / h_interests.size()) * 100;
    }
    else {
        vector<string>::const_iterator ith = h_interests.begin();
        for(; ith < h_interests.end(); ++ith)
            if(std::find(interests.begin(), interests.end(), (*ith)) != interests.end()) counter++;
        counter = (counter / interests.size()) * 100;
    }
    double countsk = 0;
    // skills
    vector<string> skills = uf->skills();
    vector<string> h_skills = host->skills();
    if(skills.size() <= h_skills.size()) {
        vector<string>::const_iterator it = skills.begin();
        for(; it < skills.end(); ++it)
            if(std::find(h_skills.begin(), h_skills.end(), (*it)) != h_skills.end()) countsk++;
        countsk = (countsk / h_skills.size()) * 100;
    }
    else {
        vector<string>::const_iterator ith = h_skills.begin();
        for(; ith < h_skills.end(); ++ith)
            if(std::find(skills.begin(), skills.end(), (*ith)) != skills.end()) countsk++;
        countsk = (countsk / skills.size()) * 100;
    }
    double countl = 0;
    // language
    vector<string> languages = uf->languages();
    vector<string> h_languages = host->languages();
    if(languages.size() <= h_languages.size()) {
        vector<string>::const_iterator it = languages.begin();
        for(; it < languages.end(); ++it)
            if(std::find(h_languages.begin(), h_languages.end(), (*it)) != h_languages.end()) countl++;
        countl = (countl / h_languages.size()) * 100;
    }
    else {
        vector<string>::const_iterator ith = h_languages.begin();
        for(; ith < h_languages.end(); ++ith)
            if(std::find(languages.begin(), languages.end(), (*ith)) != languages.end()) countl++;
        countl = (countl / languages.size()) * 100;
    }
    double res;
    res = ((counter * i_w) + (countsk * s_w) + (countl * l_w)) / (i_w + s_w + l_w);
    return static_cast<int> (res);
}
示例#25
0
UserInfo *UserInfoMng::add(char *MDN, char*ipAddr)
{
	WriteMutex<PasMutex> writeMutex(lockUserInfo);

	PAS_TRACE3("UserInfoMng::add(): MDN=%s, IP=%s, Count=%d", MDN, ipAddr,  MDNs.size());
	
	UserInfo *user = new UserInfo();
	if (user==0) return NULL;
	
	user->set(MDN, ipAddr);
	MDNs[user->getIntPhoneNumber()] = user;
	IPs[user->getIntIpAddr()] = user;
	userCount = MDNs.size();
	
	PAS_TRACE3("UserInfoMng::add(): MDN=%d, IP=%X, Count=%d", user->getIntPhoneNumber(), user->getIntIpAddr(), userCount);
	return user;
}
示例#26
0
// !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;
}
示例#27
0
int main()
{
	UserInfo uInfo;
	uInfo.age = 2;
	uInfo.height = 100;
	strcpy(uInfo.name.s, "chen");
	uInfo.name.len = strlen(uInfo.name.s);

	Buffer* buff = new Buffer();
	uInfo.pack(buff);

	//printBufferHex(buff->data, buff->next);

	cout << buff->next << endl;

	unsigned char buf[1024] = { 0 }; // = buff->data;
	memcpy(buf, buff->data, buff->next);

	//printBufferHex(buf, buff->next);

	int32_t size = buff->next;

	Buffer psBuf(buf, size);

	//printBufferHex(psBuf.data, psBuf.size);

	printfBuffer(&psBuf);
	printf("-----------\n");

	UserInfo *recvUser = new UserInfo;
	recvUser->unpack(psBuf);
	recvUser->dump();
	printf("%d,%d\n",psBuf.next,psBuf.size);

	UserInfo recvUser1; //= new UserInfo;
	recvUser1.unpack(psBuf);
	//recvUser1->dump();
	printf("%d,%d\n",psBuf.next,psBuf.size);
//	cout << (unsigned int)UserInfo::unpack<<endl;
	printf("func=%d",&UserInfo::unpack);
	return 0;
}
示例#28
0
文件: NsAdapter.cpp 项目: ic-hep/emi3
std::vector<UserInfo> NsAdapterCatalog::getUsers(void) throw (DmException)
{
  std::vector<UserInfo> users;
  struct dpns_userinfo* dpnsUsers;
  UserInfo user;
  int      nUsers;
  
  wrapCall(dpns_getusrmap(&nUsers, &dpnsUsers));
  for (int i = 0; i < nUsers; ++i) {
    user.clear();
    user.name      = dpnsUsers[i].username;
    user["uid"]    = dpnsUsers[i].userid;
    user["banned"] = dpnsUsers[i].banned;
    user["ca"]     = std::string(dpnsUsers[i].user_ca);
    users.push_back(user);
  }
  free(dpnsUsers);
  
  return users;
}
示例#29
0
void UsersFrame::removeUser(const FavoriteUser& aUser)
{
	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() == aUser.getUser())
			{
				ctrlUsers.DeleteItem(i);
				delete ui;
				setCountMessages(ctrlUsers.GetItemCount());
				return;
			}
		}
	}
}
示例#30
0
LRESULT UsersFrame::onOpenUserLog(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	if (ctrlUsers.GetSelectedCount() == 1)
	{
		int i = ctrlUsers.GetNextItem(-1, LVNI_SELECTED);
		UserInfo* ui = ctrlUsers.getItemData(i);
		dcassert(i != -1);
		
		const auto& l_user = ui->getUser(); // [!] PVS V807 Decreased performance. Consider creating a pointer to avoid using the 'ui->getUser()' expression repeatedly. usersframe.cpp 445
		StringMap params;
		params["hubNI"] = Util::toString(ClientManager::getHubNames(l_user->getCID(), Util::emptyString));
		params["hubURL"] = Util::toString(ClientManager::getHubs(l_user->getCID(), Util::emptyString));
		params["userCID"] = l_user->getCID().toBase32();
		params["userNI"] = l_user->getLastNick();
		params["myCID"] = ClientManager::getMyCID().toBase32();
		
		WinUtil::openLog(SETTING(LOG_FILE_PRIVATE_CHAT), params, TSTRING(NO_LOG_FOR_USER));
	}
	return 0;
}