Exemple #1
0
void LoginDialog::apply()
{
    if (m_client)
        return;
    getContacts()->clearClients();
    int n = cmbProfile->currentItem();
    if ((n < 0) || (n >= cmbProfile->count() - 1)){
		CorePlugin::m_plugin->setSavePasswd(chkSave->isChecked());
	    CorePlugin::m_plugin->setNoShow(chkNoShow->isChecked());
        CorePlugin::m_plugin->setProfile(NULL);
        CorePlugin::m_plugin->destroy();
        return;
    }
    CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str());
    if (m_profile != CorePlugin::m_plugin->getProfile()){
        CorePlugin::m_plugin->changeProfile();
        m_bProfileChanged = true;
    }
    CorePlugin::m_plugin->setSavePasswd(chkSave->isChecked());
    CorePlugin::m_plugin->setNoShow(chkNoShow->isChecked());
    ClientList clients;
    CorePlugin::m_plugin->loadClients(clients);
    clients.addToContacts();
    getContacts()->load();
    for (unsigned i = 0; i < passwords.size(); i++){
        Client *client = getContacts()->getClient(i);
        client->setPassword(passwords[i]->text());
        client->setSavePassword(chkSave->isChecked());
    }
}
/*!
  Sets the client's active state to \a act.

  This function does only change the visual appearance of the client,
  it does not change the focus setting. Use
  Workspace::activateClient() or Workspace::requestFocus() instead.

  If a client receives or looses the focus, it calls setActive() on
  its own.

 */
void Client::setActive(bool act)
{
    if (active == act)
        return;
    active = act;
    const int ruledOpacity = active
                             ? rules()->checkOpacityActive(qRound(opacity() * 100.0))
                             : rules()->checkOpacityInactive(qRound(opacity() * 100.0));
    setOpacity(ruledOpacity / 100.0);
    workspace()->setActiveClient(act ? this : NULL, Allowed);

    if (active)
        Notify::raise(Notify::Activate);

    if (!active)
        cancelAutoRaise();

    if (!active && shade_mode == ShadeActivated)
        setShade(ShadeNormal);

    StackingUpdatesBlocker blocker(workspace());
    workspace()->updateClientLayer(this);   // active windows may get different layer
    ClientList mainclients = mainClients();
    for (ClientList::ConstIterator it = mainclients.constBegin();
            it != mainclients.constEnd();
            ++it)
        if ((*it)->isFullScreen())  // fullscreens go high even if their transient is active
            workspace()->updateClientLayer(*it);
    if (decoration != NULL)
        decoration->activeChange();
    emit activeChanged();
    updateMouseGrab();
    updateUrgency(); // demand attention again if it's still urgent
    workspace()->checkUnredirect();
}
Exemple #3
0
void Workspace::lowerClient( Client* c, bool nogroup )
    {
    if ( !c )
        return;
    if( c->isTopMenu())
        return;

    c->cancelAutoRaise();

    StackingUpdatesBlocker blocker( this );

    unconstrained_stacking_order.removeAll( c );
    unconstrained_stacking_order.prepend( c );
    if( !nogroup && c->isTransient() )
        {
        // lower also all windows in the group, in their reversed stacking order
        ClientList wins = ensureStackingOrder( c->group()->members());
        for( int i = wins.size() - 1;
             i >= 0;
             --i )
            {
            if( wins[ i ] != c )
                lowerClient( wins[ i ], true );
            }
        }

    if ( c == most_recently_raised )
        most_recently_raised = 0;
    }
Exemple #4
0
int DoConnect (char *host, int port) {
  char buff[2];
  Client *c;
  
  /**/
  printf("Connect request from %hhu.%hhu.%hhu.%hhu:%u\n", 
	 host[0],host[1],host[2],host[3], port);
  printf("Assigning clientId: %d\n", clientID);
  /**/
  
  clientID++;

  buff[0]=0;
  buff[1]=(char)clientID;
  
  c = new Client;
  c->id = clientID;
  c->address = strndup(host, 4);
  c->port = port;
  c->it = (clients.size()==0);

  teleport(c);
  
  clients.push_back(c);

  return send(host, port, buff, 2);
}
void LoginDialog::profileChanged(int)
{
	if (m_client)
		return;
    int n = cmbProfile->currentIndex();
	if (n < 0)
    {
		clearInputs();
		buttonOk->setEnabled(false);
		btnDelete->setEnabled(false);
		btnRename->hide();
		return;
	}
	buttonOk->setEnabled(true);
	if (n >= (int)cmbProfile->count() - 1)
	{
        groupBoxPasswords->hide();
        clearInputs();
		buttonOk->setEnabled(true);
		btnDelete->setEnabled(false);
		btnRename->hide();
        labelNew->show();
        e_newName->show();
        newNameChanged(e_newName->text());
    }
	else
	{
		btnRename->show();
        labelNew->hide();
        e_newName->hide();
        clearInputs();
		ProfileManager::instance()->selectProfile(cmbProfile->currentText());
		ClientList clients;
		loadClients(cmbProfile->currentText(), clients);
		unsigned nClients = 0;
		unsigned i;
		for (i = 0; i < clients.size(); i++)
		{
			if (clients[i]->protocol()->description()->flags & PROTOCOL_NO_AUTH)
				continue;
			nClients++;
		}
        groupBoxPasswords->show();

		unsigned row = 2;
		for (unsigned i = 0; i < clients.size(); i++)
        {
			if (clients[i]->protocol()->description()->flags & PROTOCOL_NO_AUTH)
				continue;
			makeInputs(row, clients[i]);
		}
		btnDelete->setEnabled(m_loginProfile == cmbProfile->currentText());
		buttonOk->setEnabled(false);
		pswdChanged("");
		// is pressed otherwise sim will overwrite wrong config file on
		// exit.
	}
	QTimer::singleShot(0, this, SLOT(adjust()));
}
Exemple #6
0
// deactivates 'c' and activates next client
bool Workspace::activateNextClient( Client* c )
    {
    // if 'c' is not the active or the to-become active one, do nothing
    if( !( c == active_client
            || ( should_get_focus.count() > 0 && c == should_get_focus.last())))
        return false;
    closeActivePopup();
    if( c != NULL )
        {
        if( c == active_client )
            setActiveClient( NULL, Allowed );
        should_get_focus.removeAll( c );
        }
    if( focusChangeEnabled())
        {
        if ( options->focusPolicyIsReasonable())
            { // search the focus_chain for a client to transfer focus to,
              // first try to transfer focus to the first suitable window in the group
            Client* get_focus = NULL;
            const ClientList windows = ( c != NULL ? c->group()->members() : ClientList());
	    for ( int i = focus_chain[ currentDesktop() ].size() - 1;
                  i >= 0;
                  --i )
                {
                Client* ci = focus_chain[ currentDesktop() ].at( i );
                if( c == ci || !ci->isShown( false )
                    || !ci->isOnCurrentDesktop())
                    continue;
                if( options->separateScreenFocus )
                    {
                    if( c != NULL && !ci->isOnScreen( c->screen()))
                        continue;
                    if( c == NULL && !ci->isOnScreen( activeScreen()))
                        continue;
                    }
                if( windows.contains( ci ))
                    {
                    get_focus = ci;
                    break;
                    }
                if( get_focus == NULL )
                    get_focus = ci;
                }
            if( get_focus == NULL )
                get_focus = findDesktop( true, currentDesktop());
            if( get_focus != NULL )
                requestFocus( get_focus );
            else
                focusToNull();
            }
            else
                return false;
        }
    else
        // if blocking focus, move focus to the desktop later if needed
        // in order to avoid flickering
        focusToNull();
    return true;
    }
Exemple #7
0
void CReportCtrl::InsertGroupsClient( int nIndex , ClientList& list )
{
	ClientList::iterator it = list.begin();
	for ( ; it != list.end(); it ++)
	{
		AddClientInfo(&it->second);
	}
}
Exemple #8
0
int DoDisconnect (int client) {
  printf("Disconnect from %d\n", client);

  ClientList::iterator it = clients.begin();
  while (it != clients.end() && (*it)->id != client)
    it++;
  if (it != clients.end()) {
    clients.erase(it);
  }
}
void LoginDialog::profileChanged(int)
{
    if (m_client)
        return;
    int n = cmbProfile->currentItem();
    if (n < 0){
        clearInputs();
        buttonOk->setEnabled(false);
        btnDelete->setEnabled(false);
        return;
    }
    buttonOk->setEnabled(true);
    if (n >= (int)cmbProfile->count() - 1){
        lblPasswd->hide();
        clearInputs();
        btnDelete->setEnabled(false);
    }else{
        clearInputs();
        CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str());
        ClientList clients;
        CorePlugin::m_plugin->loadClients(clients);
        unsigned nClients = 0;
        unsigned i;
        for (i = 0; i < clients.size(); i++){
            if (clients[i]->protocol()->description()->flags & PROTOCOL_NO_AUTH)
                continue;
            nClients++;
        }
        if (nClients > 1){
            lblPasswd->show();
        }else{
            lblPasswd->hide();
        }
        unsigned row = 2;
        if (nClients == 1){
            makeInputs(row, clients[0], true);
        }else{
            for (unsigned i = 0; i < clients.size(); i++){
                if (clients[i]->protocol()->description()->flags & PROTOCOL_NO_AUTH)
                    continue;
                makeInputs(row, clients[i], false);
            }
        }
        if (passwords.size())
            passwords[0]->setFocus();
        btnDelete->setEnabled(m_loginProfile == CorePlugin::m_plugin->m_profiles[n].c_str());
        buttonOk->setEnabled(false);
        pswdChanged("");
    }
    QTimer::singleShot(0, this, SLOT(adjust()));
}
ClientList ClientRepository::select(const string& where)
{
	soci::rowset<row> rs = 	dataBase.prepare << "SELECT  client.client_id as Client_client_id, client.sys_userid as Client_sys_userid, client.sys_groupid as Client_sys_groupid, client.sys_perm_user as Client_sys_perm_user, client.sys_perm_group as Client_sys_perm_group, client.sys_perm_other as Client_sys_perm_other, client.company_name as Client_company_name, client.company_id as Client_company_id, client.gender as Client_gender, client.contact_name as Client_contact_name, client.customer_no as Client_customer_no, client.vat_id as Client_vat_id, client.street as Client_street, client.zip as Client_zip, client.city as Client_city, client.state as Client_state, client.country as Client_country, client.telephone as Client_telephone, client.mobile as Client_mobile, client.fax as Client_fax, client.email as Client_email, client.internet as Client_internet, client.icq as Client_icq, client.notes as Client_notes, client.bank_account_owner as Client_bank_account_owner, client.bank_account_number as Client_bank_account_number, client.bank_code as Client_bank_code, client.bank_name as Client_bank_name, client.bank_account_iban as Client_bank_account_iban, client.bank_account_swift as Client_bank_account_swift, client.paypal_email as Client_paypal_email, client.default_mailserver as Client_default_mailserver, client.mail_servers as Client_mail_servers, client.limit_maildomain as Client_limit_maildomain, client.limit_mailbox as Client_limit_mailbox, client.limit_mailalias as Client_limit_mailalias, client.limit_mailaliasdomain as Client_limit_mailaliasdomain, client.limit_mailforward as Client_limit_mailforward, client.limit_mailcatchall as Client_limit_mailcatchall, client.limit_mailrouting as Client_limit_mailrouting, client.limit_mailfilter as Client_limit_mailfilter, client.limit_fetchmail as Client_limit_fetchmail, client.limit_mailquota as Client_limit_mailquota, client.limit_spamfilter_wblist as Client_limit_spamfilter_wblist, client.limit_spamfilter_user as Client_limit_spamfilter_user, client.limit_spamfilter_policy as Client_limit_spamfilter_policy, client.default_webserver as Client_default_webserver, client.web_servers as Client_web_servers, client.limit_web_ip as Client_limit_web_ip, client.limit_web_domain as Client_limit_web_domain, client.limit_web_quota as Client_limit_web_quota, client.web_php_options as Client_web_php_options, client.limit_cgi as Client_limit_cgi, client.limit_ssi as Client_limit_ssi, client.limit_perl as Client_limit_perl, client.limit_ruby as Client_limit_ruby, client.limit_python as Client_limit_python, client.force_suexec as Client_force_suexec, client.limit_hterror as Client_limit_hterror, client.limit_wildcard as Client_limit_wildcard, client.limit_ssl as Client_limit_ssl, client.limit_web_subdomain as Client_limit_web_subdomain, client.limit_web_aliasdomain as Client_limit_web_aliasdomain, client.limit_ftp_user as Client_limit_ftp_user, client.limit_shell_user as Client_limit_shell_user, client.ssh_chroot as Client_ssh_chroot, client.limit_webdav_user as Client_limit_webdav_user, client.limit_backup as Client_limit_backup, client.limit_aps as Client_limit_aps, client.default_dnsserver as Client_default_dnsserver, client.db_servers as Client_db_servers, client.limit_dns_zone as Client_limit_dns_zone, client.default_slave_dnsserver as Client_default_slave_dnsserver, client.limit_dns_slave_zone as Client_limit_dns_slave_zone, client.limit_dns_record as Client_limit_dns_record, client.default_dbserver as Client_default_dbserver, client.dns_servers as Client_dns_servers, client.limit_database as Client_limit_database, client.limit_database_quota as Client_limit_database_quota, client.limit_cron as Client_limit_cron, client.limit_cron_type as Client_limit_cron_type, client.limit_cron_frequency as Client_limit_cron_frequency, client.limit_traffic_quota as Client_limit_traffic_quota, client.limit_client as Client_limit_client, client.limit_domainmodule as Client_limit_domainmodule, client.limit_mailmailinglist as Client_limit_mailmailinglist, client.limit_openvz_vm as Client_limit_openvz_vm, client.limit_openvz_vm_template_id as Client_limit_openvz_vm_template_id, client.parent_client_id as Client_parent_client_id, client.username as Client_username, client.password as Client_password, client.language as Client_language, client.usertheme as Client_usertheme, client.template_master as Client_template_master, client.template_additional as Client_template_additional, client.created_at as Client_created_at, client.locked as Client_locked, client.canceled as Client_canceled, client.can_use_api as Client_can_use_api, client.tmp_data as Client_tmp_data, client.id_rsa as Client_id_rsa, client.ssh_rsa as Client_ssh_rsa, client.customer_no_template as Client_customer_no_template, client.customer_no_start as Client_customer_no_start, client.customer_no_counter as Client_customer_no_counter, client.added_date as Client_added_date, client.added_by as Client_added_by "
	" FROM client" 
	<< (where.size()?" WHERE "+where:"");
	ClientList clientList;
	for(row& r: rs)
	{
		ClientPtr client(new Client);
		type_conversion<Client>::from_base(r, i_ok, *client);
		clientList.push_back(client);
	}
	return clientList;
}
Exemple #11
0
/// \brief Expire any clients in the delete list
void LogForwardThread::expireClients(void)
{
#ifndef NOLOGSERVER
    QMutexLocker lock(&logClientMapMutex);
    QMutexLocker lock2(&logRevClientMapMutex);
    QMutexLocker lock3(&logClientToDelMutex);

    while (!logClientToDel.isEmpty())
    {
        QString clientId = logClientToDel.takeFirst();
        logClientCount.deref();
        LOG(VB_GENERAL, LOG_INFO, QString("Expiring client %1 (#%2)")
            .arg(clientId).arg(logClientCount.fetchAndAddOrdered(0)));
        LoggerListItem *item = logClientMap.take(clientId);
        if (!item)
            continue;
        LoggerList *list = item->list;
        delete item;

        while (!list->isEmpty())
        {
            LoggerBase *logger = list->takeFirst();
            ClientList *clientList = logRevClientMap.value(logger, NULL);
            if (!clientList || clientList->size() == 1)
            {
                if (clientList)
                {
                    logRevClientMap.remove(logger);
                    delete clientList;
                }
                delete logger;
                continue;
            }

            clientList->removeAll(clientId);
        }
        delete list;
    }

    // TODO FIXME: This is not thread-safe!
    // just this daemon left
    if (logClientCount.fetchAndAddOrdered(0) == 1 &&
        m_shutdownTimer && !m_shutdownTimer->isActive())
    {
        LOG(VB_GENERAL, LOG_INFO, "Starting 5min shutdown timer");
        m_shutdownTimer->start(5*60*1000);
    }
#endif
}
Exemple #12
0
void CHostList::InsertGroupsClient( int nIndex , ClientList& list )
{
	ClientList::iterator it = list.begin();
	for ( ; it != list.end(); it ++)
	{
		int i = AddClientInfo(it->second);

		if (IsAlive(it->second->clientid))
			SetItemColor((int)it->second,RGB(255,0,0));
		else
			SetItemColor((int)it->second,RGB(96,96,96));

		Update(i);
	}
}
Exemple #13
0
void NetConnection::ListenNewClients()
{

	uchar		buffer[1024];

	int			status;
	unsigned short	port;

	struct sockaddr_in	from;
	struct in_addr	in;
	unsigned int	fromlen;

	from.sin_family = AF_INET;
	fromlen = sizeof(from);

#ifdef WIN32
	status = recvfrom(listening_socket, (char *) &buffer, sizeof(buffer), 0,(struct sockaddr*) &from, (int *) &fromlen);
#else
	status = recvfrom(listening_socket, &buffer, sizeof(buffer), 0,(struct sockaddr*) &from, &fromlen);
#endif


	if (status > 1)
	{
		Client* client = 0;

		port = from.sin_port;
		in.s_addr = from.sin_addr.s_addr;

		//cout << Timer::GetCurrentTime() << " Data from ip: " << inet_ntoa(in) << " port:" << ntohs(port) << " length: " << status << endl;
		if (!client_list.RecvData(in.s_addr, from.sin_port, buffer, status)) {
			// If it is a new client make sure it has the starting flag set. Ignore otherwise
			if (buffer[0] & 0x20)
			{
				EQC::Common::PrintF(CP_CLIENT, "New client from %s:%i\n", inet_ntoa(in), ntohs(port));
				client = new Client(in.s_addr, port, listening_socket);
				client->ReceiveData(buffer, status);
				entity_list.AddClient(client);
				client_list.Add(client);
				numclients++;
			}
			else
			{
				return;
			}
		}
	}
}
Exemple #14
0
ClientListEntry::~ClientListEntry() {
	if (RunLoops) {
		Camp(); // updates zoneserver's numplayers
		client_list.RemoveCLEReferances(this);
	}
	tell_queue.clear();
}
Exemple #15
0
void CHostList::DeleteGroupsClient( int nIndex , ClientList& list )
{
	for (UINT i = 0 ; i < list.size() ; i ++)
	{
		DeleteItem(nIndex+1);
	}
}
Exemple #16
0
map<string,string> EQW::GetPlayerDetails(Const_char *char_name) {
	map<string,string> res;
	
	ClientListEntry *cle = client_list.FindCharacter(char_name);
	if(cle == NULL) {
		res["error"] = "1";
		return(res);
	}
	
	res["character"] = cle->name();
	res["account"] = cle->AccountName();
	res["account_id"] = itoa(cle->AccountID());
	res["location_short"] = cle->zone()?database.GetZoneName(cle->zone()):"No Zone";
	res["location_long"] = res["location_short"];
	res["location_id"] = itoa(cle->zone());
	res["ip"] = long2ip(cle->GetIP());
	res["level"] = itoa(cle->level());
	res["race"] = GetRaceName(cle->race());
	res["race_id"] = itoa(cle->race());
	res["class"] = GetEQClassName(cle->class_());
	res["class_id"] = itoa(cle->class_());
	res["guild_id"] = itoa(cle->GuildID());
	res["guild"] = guild_mgr.GetGuildName(cle->GuildID());
	res["status"] = itoa(cle->Admin());
//	res["patch"] = cle->DescribePatch();
	
	return(res);
}
Exemple #17
0
/// \brief  Handles heartbeat checking once a second.  If a client is not heard
///         from for at least 1 second, send it a heartbeat message which it
///         should send back.  If we haven't heard from it in 5s, shut down its
///         logging.
void LogServerThread::checkHeartBeats(void)
{
#ifndef NOLOGSERVER
    qlonglong epoch;

    // cout << "pre-lock 1" << endl;
    QMutexLocker lock(&logClientMapMutex);
    // cout << "pre-lock 2" << endl;
    QMutexLocker lock2(&logClientToDelMutex);
    loggingGetTimeStamp(&epoch, NULL);

    // cout << "msgcount " << msgsSinceHeartbeat << endl;
    msgsSinceHeartbeat = 0;

    ClientMap::iterator it = logClientMap.begin();
    for( ; it != logClientMap.end(); ++it )
    {
        QString clientId        = it.key();
        LoggerListItem *logItem = it.value();
        qlonglong age = epoch - logItem->epoch;

        if (age > 5)
        {
            logClientToDel.append(clientId);
        }
        else
        {
            // cout << "age " << age << " " << clientId.toLocal8Bit().constData() << endl;
            pingClient(clientId);
        }
    }
#endif
}
Exemple #18
0
void CReportCtrl::DeleteGroupsClient( int nIndex , ClientList& list )
{
	for (UINT i = 0 ; i < list.size() ; i ++)
	{
		delete (void*)GetItemData(nIndex+1);
		DeleteItem(nIndex+1);
	}
}
Exemple #19
0
int GetClients (std::vector<Client *> *client_out) {
  pthread_mutex_lock(&client_lock);
  for (int i=0;i<clients.size();i++)
    client_out->push_back(clients[i]);
  pthread_mutex_unlock(&client_lock);

  return 0;
}
Exemple #20
0
bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
	BootingUp = false;
	
	const char* zn = MakeLowerString(database.GetZoneName(iZoneID));
	char*	longname;

	if (iZoneID)
		zlog(WORLD__ZONE,"Setting to '%s' (%d:%d)%s",(zn) ? zn : "",iZoneID, iInstanceID, 
			iStaticZone ? " (Static)" : "");

	zoneID = iZoneID;
	instanceID = iInstanceID;
	if(iZoneID!=0)
		oldZoneID = iZoneID;
	if (zoneID == 0) {
		client_list.CLERemoveZSRef(this);
		pNumPlayers = 0;
		LSSleepUpdate(GetPrevZoneID());
	}

	staticzone = iStaticZone;

	if (zn)
	{
		strn0cpy(zone_name, zn, sizeof(zone_name));
		if( database.GetZoneLongName( (char*)zone_name, &longname, NULL, NULL, NULL, NULL, NULL, NULL ) )
		{
			strn0cpy(long_name, longname, sizeof(long_name));
			safe_delete_array( longname );
		}
		else
			strcpy(long_name, "");
	}
	else
	{
		strcpy(zone_name, "");
		strcpy(long_name, "");
	}	

	client_list.ZoneBootup(this);
	ls_zboot.Start();

	return true;
}
// find the less loaded provider in the list of provider
ClientConnectionPtr ConnectionManager::findLessLoadedProvider( const ClientList& providers ) const
{
   // get the first provider
   ClientList::iterator itProvider = providers.begin();
   ClientConnectionPtr lessLoadedProvider = *itProvider;

   // and found the less loaded
   while( itProvider != providers.end() )
   {
      if ( (*itProvider)->getLoad() < lessLoadedProvider->getLoad() )
      {
         lessLoadedProvider = *itProvider;
      }
      itProvider++;
   }

   // return it
   return lessLoadedProvider;
}
void DatabaseLogger::receivedMessage(const QList<QByteArray> &msg)
{
    // Filter on the clientId
    QByteArray clientBa = msg.first();
    QString clientId = QString(clientBa.toHex());

    {
        QMutexLocker locker(&logRevClientMapMutex);

        ClientList *clients = logRevClientMap.value(this, NULL);
        if (!clients || !clients->contains(clientId))
            return;
    }

    QByteArray json     = msg.at(1);
    LoggingItem *item = LoggingItem::create(json);
    if (!logmsg(item))
        item->DecrRef();
}
Exemple #23
0
void LoginDialog::profileChanged(int)
{
    if (m_client)
        return;
    int n = cmbProfile->currentItem();
    if (n < 0){
        clearInputs();
        buttonOk->setEnabled(false);
        btnDelete->setEnabled(false);
        return;
    }
    buttonOk->setEnabled(true);
    if (n >= (int)cmbProfile->count() - 1){
        lblPasswd->hide();
        clearInputs();
        btnDelete->setEnabled(false);
    }else{
        clearInputs();
        CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str());
        ClientList clients;
        CorePlugin::m_plugin->loadClients(clients);
        if (clients.size() > 1){
            lblPasswd->show();
        }else{
            lblPasswd->hide();
        }
        if (clients.size() == 1){
            QLabel *txt = new QLabel(this);
            txt->setText(i18n("Password:"));
            txt->setAlignment(AlignRight);
            QLineEdit *edt = new QLineEdit(this);
            edt->setText(clients[0]->getPassword());
            edt->setEchoMode(QLineEdit::Password);
            connect(edt, SIGNAL(textChanged(const QString&)), this, SLOT(pswdChanged(const QString&)));
            passwords.push_back(edt);
            texts.push_back(txt);
            PLayout->addWidget(txt, 2, 1);
            PLayout->addWidget(edt, 2, 2);
            edt->show();
            txt->show();
        }else{
            for (unsigned i = 0; i < clients.size(); i++){
Exemple #24
0
inline Client *getClient(int id) {
  Client *c = NULL;
  pthread_mutex_lock(&client_lock);
  for(int i=0;i<clients.size();i++)
    if (clients[i]->id == id) {
      c = clients[i];
      break;
    }
  pthread_mutex_unlock(&client_lock);
  return c;
}
Exemple #25
0
void Command::process_login_command(char* buf, SOCKET socket)
{
	ClientList* clientList = ClientList::GetInstance();
	player p;
	uint8_t msg[65536],msgH[65536];
	ee122_login_request login;
	ee122_hdr *header = (struct ee122_hdr*)msgH;
	memset(header, 0, sizeof(ee122_hdr));
	memset(&login, 0, sizeof(ee122_login_request));
	ee122_login_reply *login_reply = (struct ee122_login_reply*)msg;
	memset(login_reply, 0, sizeof(ee122_login_reply));
	memcpy(&login, buf+sizeof(ee122_hdr), sizeof(ee122_login_request));
	//包头的处理
	header->version_ = EE122_VALID_VERSION;
	header->type_ = messages::LOGIN_REPLY;
	header->length_ = sizeof(ee122_hdr) + sizeof(ee122_login_reply);

	p.name_ = login.player_name_;
	p.hp_ = 100;
	p.exp_ = 0;
	p.x_ = Random();
	p.y_ = Random();

	if (clientList->AddPlayerInfo(p))
	{
		clientList->AddSocket(socket,(char*) p.name_);
		//包内容的处理
		login_reply->error_code_ = LOGIN_REPLY_ERROR_NONE;
		login_reply->hp_ = 100;
		login_reply->exp_ = 0;
		login_reply->x_ = p.x_;
		login_reply->y_ = p.y_;
	}
	else
	{
		login_reply->error_code_ = LOGIN_REPLY_ERROR_EXISTING;
	}
	memset(buff, 0, 1024);
	memcpy(buff, header, sizeof(ee122_hdr));
	memcpy(buff + sizeof(ee122_hdr), login_reply, sizeof(ee122_login_reply));
}
Exemple #26
0
int UpdateBoard () {
  if (clients.size() > 0) {
    Client *it = NULL;
    for (int i=0;i<clients.size();i++) {
      if (clients[i]->it) {
	it = clients[i];
	break;
      }
    }
    assert(it);
    for (int i=0;i<clients.size();i++) {
      if (clients[i] != it && closeEnough(clients[i], it)) {
	clients[i]->it = true;
	it->it = false;
	teleport(clients[i]);
	return 0;
      }
    }
  }
  return 0;
}
Exemple #27
0
void LoginDialog::profileChanged(int)
{
    if (m_client)
        return;
    int n = cmbProfile->currentItem();
    if (n < 0){
        clearInputs();
        buttonOk->setEnabled(false);
        btnDelete->setEnabled(false);
        return;
    }
    buttonOk->setEnabled(true);
    if (n >= (int)cmbProfile->count() - 1){
        lblPasswd->hide();
        clearInputs();
        btnDelete->setEnabled(false);
    }else{
        clearInputs();
        CorePlugin::m_plugin->setProfile(CorePlugin::m_plugin->m_profiles[n].c_str());
        ClientList clients;
        CorePlugin::m_plugin->loadClients(clients);
        if (clients.size() > 1){
            lblPasswd->show();
        }else{
            lblPasswd->hide();
        }
        unsigned row = 2;
        if (clients.size() == 1){
            makeInputs(row, clients[0], true);
        }else{
            for (unsigned i = 0; i < clients.size(); i++)
                makeInputs(row, clients[i], false);
        }
        if (passwords.size())
            passwords[0]->setFocus();
        btnDelete->setEnabled(m_loginProfile == CorePlugin::m_plugin->m_profiles[n].c_str());
        buttonOk->setEnabled(false);
        pswdChanged("");
    }
}
Exemple #28
0
void Command::process_move_command(char* buf,SOCKET socket)
{
	ClientList* clientList = ClientList::GetInstance();
	
	uint8_t msg[65536],msgH[65536];
	ee122_hdr *header = (struct ee122_hdr*)msg;
	memset(header, 0, sizeof(ee122_hdr));
	header->version_ = EE122_VALID_VERSION;
	header->type_ = messages::MOVE_REPLY;
	header->length_ = sizeof(ee122_hdr) + sizeof(ee122_login_reply);
	
	if (clientList->findScoket(socket))
	{
		string name = clientList->getName(socket);
		
		ee122_move move;
		memset(&move, 0, sizeof(ee122_move));
		memcpy(&move, buf + sizeof(ee122_hdr), sizeof(ee122_move));
		int direction = move.direction_;

		clientList->changePosition(name, direction);

		ee122_move_reply *moveReply = (struct ee122_move_reply*)msgH;
		moveReply->error_code_ = MOVE_REPLY_ERROR_NONE;
		moveReply->direction_ = direction;
		memset(buff, 0, 1024);
		memcpy(buff, header, sizeof(ee122_hdr));
		memcpy(buff + sizeof(header), moveReply, sizeof(ee122_move_reply));
	}
	else
	{
		ee122_move_reply *moveReply = (struct ee122_move_reply*)msgH;
		moveReply->error_code_ = MOVE_REPLY_ERROR_EXITING;
		moveReply->direction_ = 0;
		memset(buff, 0, 1024);
		memcpy(buff, header, sizeof(ee122_hdr));
		memcpy(buff + sizeof(header), moveReply, sizeof(ee122_move_reply));
	}
}
Exemple #29
0
//returns an array of character names in the zone (empty=all zones)
vector<string> EQW::ListPlayers(Const_char *zone_name) {
	vector<string> res;
	
	vector<ClientListEntry *> list;
	client_list.GetClients(zone_name, list);
	
	vector<ClientListEntry *>::iterator cur, end;
	cur = list.begin();
	end = list.end();
	for(; cur != end; cur++) {
		res.push_back((*cur)->name());
	}
	return(res);
}
Exemple #30
0
void LoginDialog::fill()
{
    if (m_client){
        lblPasswd->hide();
        unsigned row = 2;
        makeInputs(row, m_client, true);
        return;
    }
    cmbProfile->clear();
    int newCur = -1;
    string save_profile = CorePlugin::m_plugin->getProfile();
    CorePlugin::m_plugin->m_profiles.clear();
    CorePlugin::m_plugin->loadDir();
    for (unsigned i = 0; i < CorePlugin::m_plugin->m_profiles.size(); i++){
        string curProfile = CorePlugin::m_plugin->m_profiles[i];
        if (!strcmp(curProfile.c_str(), save_profile.c_str()))
            newCur = i;
        CorePlugin::m_plugin->setProfile(curProfile.c_str());
        ClientList clients;
        CorePlugin::m_plugin->loadClients(clients);
        if (clients.size()){
            Client *client = clients[0];
            cmbProfile->insertItem(
                Pict(client->protocol()->description()->icon),
                QString::fromLocal8Bit(client->name().c_str()));
        }
    }
    cmbProfile->insertItem(i18n("New profile"));
    if (newCur != - 1){
        cmbProfile->setCurrentItem(newCur);
        CorePlugin::m_plugin->setProfile(save_profile.c_str());
    }else{
        cmbProfile->setCurrentItem(cmbProfile->count() - 1);
        CorePlugin::m_plugin->setProfile(NULL);
    }
}