Exemplo n.º 1
0
void _m_numeric351( char *origin, char **argv, int argc, int srv )
{
	Client *s;

	if( ircd_srv.protocol & PROTOCOL_B64SERVER )
		s = FindServer( base64_to_server( origin ) );
	else
		s = FindServer( origin );
	if( s )
		strlcpy( s->version, argv[1], MAXHOST );
}
Exemplo n.º 2
0
void es_add(char *nick, char *user, char *host, char *msg, time_t time,
            int type)
{
    int ac;
    char userhost[USERLEN + HOSTLEN + 2], **av, *mymsg;
    aSeen *seen = MyMalloc(sizeof(aSeen));

#ifdef NOSQUITSEEN
    if (type == 1)
    {
        mymsg = MyStrdup(msg);
        ac = SplitBuf(mymsg, &av);
        if (ac == 2)
        {
            if (FindServer(av[0]) && FindServer(av[1]))
            {
                MyFree(mymsg);
                MyFree(av);
                return ;
            }
        }
        MyFree(mymsg);
        MyFree(av);
    }
#endif
    if (++seenc > SeenMaxRecs)
    {
        aSeen *sp = seenb;
        MyFree(seenb->userhost);
        MyFree(seenb->msg);
        if (seenb->next)
            seenb->next->prev = NULL;
        seenb = seenb->next;
        MyFree(sp);
        seenc--;
    }
    memset(userhost, 0, sizeof(userhost));
    memset(seen, 0, sizeof(aSeen));
    strncpy(seen->nick, nick, NICKLEN);
    strncpy(userhost, user, USERLEN);
    strcat(userhost, "@");
    strncat(userhost, host, HOSTLEN);
    seen->userhost = MyStrdup(userhost);
    seen->msg = (type == 1) ? MyStrdup(msg) : NULL;
    seen->time = time;
    seen->type = type;
    seen->prev = seenp;
    seen->next = NULL;
    if (seenp)
        seenp->next = seen;
    seenp = seen;
    if (!seenb)
        seenb = seen;
}
Exemplo n.º 3
0
/*----------------------------------------------------------------------
|   PLT_MediaBrowser::Search
+---------------------------------------------------------------------*/
NPT_Result 
PLT_MediaBrowser::Search(PLT_DeviceDataReference& device, 
                         const char*              container_id,
						 const char*              search_criteria,
                         NPT_UInt32               start_index,
                         NPT_UInt32               count,
                         const char*              filter,
                         void*                    userdata)
{
    // verify device still in our list
    PLT_DeviceDataReference device_data;
    NPT_CHECK_WARNING(FindServer(device->GetUUID(), device_data));

    // create action
    PLT_ActionReference action;
    NPT_CHECK_SEVERE(m_CtrlPoint->CreateAction(
        device, 
        "urn:schemas-upnp-org:service:ContentDirectory:1",
        "Search",
        action));

    // Set the container id
    PLT_Arguments args;
    if (NPT_FAILED(action->SetArgumentValue("ContainerID", container_id))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the Search Criteria
    if (NPT_FAILED(action->SetArgumentValue("SearchCriteria", search_criteria))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

 
    // set the Filter
    if (NPT_FAILED(action->SetArgumentValue("Filter", filter))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the Starting Index
    if (NPT_FAILED(action->SetArgumentValue("StartingIndex", NPT_String::FromInteger(start_index)))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the Requested Count
    if (NPT_FAILED(action->SetArgumentValue("RequestedCount", NPT_String::FromInteger(count)))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the Requested Count
    if (NPT_FAILED(action->SetArgumentValue("SortCriteria", ""))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // invoke the action
    if (NPT_FAILED(m_CtrlPoint->InvokeAction(action, userdata))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    return NPT_SUCCESS;
}
Exemplo n.º 4
0
/*----------------------------------------------------------------------
|   PLT_MediaBrowser::Browse
+---------------------------------------------------------------------*/
NPT_Result 
PLT_MediaBrowser::Browse(PLT_DeviceDataReference& device, 
                         const char*              obj_id,
                         NPT_UInt32               start_index,
                         NPT_UInt32               count,
                         bool                     browse_metadata,
                         const char*              filter,
                         const char*              sort_criteria,
                         void*                    userdata)
{
    // verify device still in our list
    PLT_DeviceDataReference device_data;
    NPT_CHECK_WARNING(FindServer(device->GetUUID(), device_data));

    // create action
    PLT_ActionReference action;
    NPT_CHECK_SEVERE(m_CtrlPoint->CreateAction(
        device, 
        "urn:schemas-upnp-org:service:ContentDirectory:1",
        "Browse",
        action));

    // Set the object id
    PLT_Arguments args;
    if (NPT_FAILED(action->SetArgumentValue("ObjectID", obj_id))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the browse_flag
    if (NPT_FAILED(action->SetArgumentValue("BrowseFlag", browse_metadata?"BrowseMetadata":"BrowseDirectChildren"))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }
 
    // set the Filter
    if (NPT_FAILED(action->SetArgumentValue("Filter", filter))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the Starting Index
    if (NPT_FAILED(action->SetArgumentValue("StartingIndex", NPT_String::FromInteger(start_index)))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the Requested Count
    if (NPT_FAILED(action->SetArgumentValue("RequestedCount", NPT_String::FromInteger(count)))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // set the Requested Count
    if (NPT_FAILED(action->SetArgumentValue("SortCriteria", sort_criteria))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    // invoke the action
    if (NPT_FAILED(m_CtrlPoint->InvokeAction(action, userdata))) {
        return NPT_ERROR_INVALID_PARAMETERS;
    }

    return NPT_SUCCESS;
}
Exemplo n.º 5
0
Arquivo: UPnP.cpp Projeto: MrMC/mrmc
    bool InvokeUpdateObject(const char* id, const char* curr_value, const char* new_value)
    {
        CURL url(id);
        PLT_DeviceDataReference device;
        PLT_Service* cds;
        PLT_ActionReference action;

        CLog::Log(LOGDEBUG, "UPNP: attempting to invoke UpdateObject for %s", id);

        // check this server supports UpdateObject action
        NPT_CHECK_LABEL(FindServer(url.GetHostName().c_str(), device),failed);
        NPT_CHECK_LABEL(device->FindServiceById("urn:upnp-org:serviceId:ContentDirectory", cds),failed);

        NPT_CHECK_LABEL(m_CtrlPoint->CreateAction(
            device,
            "urn:schemas-upnp-org:service:ContentDirectory:1",
            "UpdateObject",
            action), failed);

        NPT_CHECK_LABEL(action->SetArgumentValue("ObjectID", url.GetFileName().c_str()), failed);
        NPT_CHECK_LABEL(action->SetArgumentValue("CurrentTagValue", curr_value), failed);
        NPT_CHECK_LABEL(action->SetArgumentValue("NewTagValue", new_value), failed);

        NPT_CHECK_LABEL(m_CtrlPoint->InvokeAction(action, NULL),failed);

        CLog::Log(LOGDEBUG, "UPNP: invoked UpdateObject successfully");
        return true;

    failed:
        CLog::Log(LOGINFO, "UPNP: invoking UpdateObject failed");
        return false;
    }
Exemplo n.º 6
0
void dlgMain::OnRefreshServer(wxCommandEvent &event)
{   
    // prevent reentrancy
    static wxRecursionGuardFlag s_rgf;
    wxRecursionGuard recursion_guard(s_rgf);
    
    if (recursion_guard.IsInside())
        return;	
    
    if (!m_LstCtrlServers->GetItemCount() || !m_LstCtrlServers->GetSelectedItemCount())
        return;
        
    m_LstCtrlPlayers->DeleteAllItems();
        
    wxInt32 listindex = m_LstCtrlServers->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        
    wxListItem item;
    item.SetId(listindex);
    item.SetColumn(7);
    item.SetMask(wxLIST_MASK_TEXT);
        
    m_LstCtrlServers->GetItem(item);
        
    wxInt32 arrayindex = FindServer(item.GetText()); 
        
    if (arrayindex == -1)
        return;
                
    TotalPlayers -= QServer[arrayindex].info.numplayers;
    
    mtcs_Request.Signal = mtcs_getsingleserver;
    mtcs_Request.ServerListIndex = listindex;
    mtcs_Request.Index = arrayindex; 
}
Exemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: Handles a server info message, which is a reply from a RequestInfo msg
// Input  : *msg - 
//-----------------------------------------------------------------------------
void CServerList::ReceivedMsg_MonitorInfo(IReceiveMessage *msg)
{
	server_t &server = FindServer(msg->NetAddress());

	// parse out information about server
	msg->ReadInt("users", server.users);
	msg->ReadInt("maxusers", server.maxUsers);
	msg->ReadInt("state", server.state);
	msg->ReadInt("fps", server.fps);
	msg->ReadInt("netbufs", server.networkBuffers);
	msg->ReadInt("peaknetbufs", server.peakNetworkBuffers);
	msg->ReadInt("dboutbufs", server.dbOutBufs);
	msg->ReadInt("dbinbufs", server.dbInBufs);
	msg->ReadInt("primary", server.primary);
	msg->ReadInt("rbps", server.bytesReceivedPerSecond);
	msg->ReadInt("sbps", server.bytesSentPerSecond);

	// calculate some info
	if ((server.fps > 0 && server.fps < 500) || server.dbInBufs > 100 || server.dbOutBufs > 100 || server.networkBuffers > 100)
	{
		server.underHeavyLoad = true;
	}
	else
	{
		server.underHeavyLoad = false;
	}

	// if we don't have the sqldb info yet, ask for it
	if (!m_bHasDBInfo)
	{
		g_pTrackerNET->SendMessage(g_pTrackerNET->CreateReply(TSV_REQSRVINFO, msg), NET_RELIABLE);
	}
}
Exemplo n.º 8
0
void _m_numeric242( char *origin, char **argv, int argc, int srv )
{
	Client *s;

	if( ircd_srv.protocol & PROTOCOL_B64SERVER )
		s = FindServer( base64_to_server( origin ) );
	else
		s = FindServer( origin );
	if( s ) {
		/* Convert "Server Up d days, hh:mm:ss" to seconds*/
		char *ptr;
		time_t secs;

		/* current string: "Server Up d days, hh:mm:ss" */
		strtok( argv[argc-1], " " );
		/* current string: "Up d days, hh:mm:ss" */
		strtok( NULL, " " );
		/* current string: "d days, hh:mm:ss" */
		ptr = strtok( NULL, " " );
		if( ptr == NULL )
			return;
		secs = atoi( ptr ) * TS_ONE_DAY;
		/* current string: "days, hh:mm:ss" */
		strtok( NULL, " " );
		/* current string: ", hh:mm:ss" */
		ptr = strtok( NULL, "" );
		/* current string: "hh:mm:ss" */
		ptr = strtok( ptr , ":" );
		if( ptr == NULL )
			return;
		secs += atoi( ptr ) * TS_ONE_HOUR;
		/* current string: "mm:ss" */
		ptr = strtok( NULL, ":" );
		if( ptr == NULL )
			return;
		secs += atoi( ptr )*60;
		/* current string: "ss" */
		ptr = strtok( NULL, "" );
		if( ptr == NULL )
			return;
		secs += atoi( ptr );

		s->server->uptime = secs;
	}
}
Exemplo n.º 9
0
//-----------------------------------------------------------------------------
bool TAdministradora :: CrearCuenta(TCuenta* pCuenta, AnsiString pServer)
{
  bool create = false;
  TServidor* server = FindServer(pServer);
  if(server)
  {
    server->Cuentas()->Insert(pCuenta);
    create = true;
  }
  return create;
}
Exemplo n.º 10
0
MCResult 
MemCacheClient::IncDec(
    const char *    aType, 
    unsigned        aService,
    const char *    aKey, 
    uint64_t *      aNewValue,
    uint64_t        aDiff,
    bool            aWantReply
    )
{
    string_t key(aKey);
    Server * pServer = FindServer(key, aService);
    if (!pServer) return MCERR_NOSERVER;

    char szBuf[50];
    string_t sRequest(aType);
    sRequest += ' ';
    sRequest += aKey;
    snprintf(szBuf, sizeof(szBuf), " %" PRIu64, aDiff);
    sRequest += szBuf;
    if (!aWantReply) {
        sRequest += " noreply";
    }
    sRequest += "\r\n";

    try {
        pServer->SendBytes(sRequest.data(), sRequest.length());

        if (!aWantReply) {
            return MCERR_NOREPLY;
        }

        string_t sValue;
        sValue = pServer->GetByte();
        while (sValue[sValue.length()-1] != '\n') {
            sValue += pServer->GetByte();
        }

        if (sValue == "NOT_FOUND\r\n") {
            return MCERR_NOTFOUND;
        }

        if (aNewValue) {
            *aNewValue = strtoull(sValue.data(), NULL, 10);
        }
        return MCERR_OK;
    }
    catch (const Socket::Exception & e) {
        mTrace.Trace(CLINFO, "IncDec: error '%s' at %s, marking request as NOSERVER",
            e.mDetail, pServer->GetAddress());
        pServer->Disconnect();
        return MCERR_NOSERVER;
    }
}
Exemplo n.º 11
0
/** Returns the locally connected server we must route a
 * message through to reach server 'ServerName'. This
 * only applies to one-to-one and not one-to-many routing.
 * See the comments for the constructor of TreeServer
 * for more details.
 */
TreeServer* SpanningTreeUtilities::BestRouteTo(const std::string &ServerName)
{
	TreeServer* Found = FindServer(ServerName);
	if (Found)
	{
		return Found->GetRoute();
	}
	else
	{
		// Cheat a bit. This allows for (better) working versions of routing commands with nick based prefixes, without hassle
		User *u = ServerInstance->FindNick(ServerName);
		if (u)
		{
			Found = FindServer(u->server);
			if (Found)
				return Found->GetRoute();
		}

		return NULL;
	}
}
Exemplo n.º 12
0
//-----------------------------------------------------------------------------
//::::::::::::::::::::::::::::::::::FICHERO DBF::::::::::::::::::::::::::::::::::
//-----------------------------------------------------------------------------
void TAdministradora :: CrearFileDBF(AnsiString pServerName,AnsiString pFileName)
{    //buscar el server
  TServidor* server = FindServer(pServerName);
  if(server)
  {
    TDBF* FileDBF = new TDBF(pFileName);
    char *Buff= new char[36];
    FileDBF->FillDescriptor();
    FileDBF->Open();
    int length = server->Cuentas()->Length();

    for(int i = 0; i < length; i++)
    {
      TCuenta* cuenta = (TCuenta*)server->Cuentas()->ItemInfo(i);

      char  User[10];
      char Pass[6];
      char Add[20];
      strcpy(User,cuenta->Usuario().c_str());
      strcpy(Pass, cuenta->Password().c_str());
      strcpy(Add,cuenta->Address().c_str());


       for(int i = 0; i < 10; i++)
       {
        if(i<cuenta->Usuario().Length())
         {Buff[i]=User[i];}
         else
         {Buff[i]=' ';}
       }
      for(int i = 10; i < 16; i++)
       {
        if(i-10<cuenta->Password().Length())
         {Buff[i]=Pass[i-10];}
         else
         {Buff[i]=' ';}
       }
      for(int i = 16; i < 36; i++)
       {
        if(i-16<cuenta->Address().Length())
         {Buff[i]=Add[i-16];}
         else
         {Buff[i]=' ';}
       }

    FileDBF->AppendRec(Buff);
    }

    FileDBF->Close();
    delete FileDBF;
  }
}
Exemplo n.º 13
0
//-----------------------------------------------------------------------------
TServidor*  TAdministradora :: ModificarServerNacional(AnsiString Domain,AnsiString pModifyDomain,int pModifyTope,int ModifyMax)
{
  TServidor* Server= NULL;
  Server = FindServer(Domain);
  if(Server)   //si lo encontro
  {
    Server->NameDomain(pModifyDomain);
    Server->Tope(pModifyTope);
    Server->Max(ModifyMax);
    //FiltrarServerNacional();
  }
  return Server;
}
Exemplo n.º 14
0
void Client::Logic()
{
  clock_t time = clock();
  clock_t actime = time;

  SOCKET bsock;

  SocketBase bcomm;
  sockaddr_in &bsin = bcomm.Connect( PORT_BROADCAST );
  bsock = bcomm.CreateSocket();
  bcomm.Bind();
  bcomm.SetBroadcast( true );

  int keysize = int( key.size() + 1 );
  int portsize = sizeof port;

  char *message = new char[ keysize + portsize ];

  //memcpy( message, this.key.c_str(), keysize );
  //memcpy( message + keysize, &this.port, portsize );

  while ( running )
  {
    LONGLONG flowend = Clock() - flowstart;
    if ( flowend >  1000000LL )
    {
      flowstart = Clock();
      currentdatasent = 0;
      float l = GetRTT();
      if ( l < 0.0001f )
        BandWidth += 512;
      else if ( l > 0.001f )
        BandWidth -= 512;
    }

    if ( !ServerFound )
    {
      FindServer( bsock, message, portsize, keysize );
    }

    SendPackets();

    ReceivePackets();

    HandlePackets();

    UpdateRTT();

    Sleep( 10 );
  }
}
Exemplo n.º 15
0
/*
 * ms_ping - server message handler
 */
int ms_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  struct Client* acptr;
  char*          origin;
  char*          destination;

  assert(0 != cptr);
  assert(0 != sptr);
  assert(IsServer(cptr));

  if (parc < 2 || EmptyString(parv[1])) {
    /*
     * don't bother sending the error back
     */
    return 0;
  }
  origin      = parv[1];
  destination = parv[2];        /* Will get NULL or pointer (parc >= 2!!) */

  if (parc > 3)
  {
    /* AsLL ping, send reply back */
    int diff = atoi(militime_float(parv[3]));
    sendcmdto_one(&me, CMD_PONG, sptr, "%C %s %s %i %s", &me, origin,
                  parv[3], diff, militime_float(NULL));
    return 0;
  }
  if (!EmptyString(destination) && 0 != ircd_strcmp(destination, cli_name(&me))) {
    if ((acptr = FindServer(destination))) {
      /*
       * Servers can just forward the origin
       */
      sendcmdto_one(sptr, CMD_PING, acptr, "%s :%s", origin, destination);
    }
    else {
      /*
       * this can happen if server split before the ping got here
       */
      send_reply(sptr, ERR_NOSUCHSERVER, destination);
    }
  }
  else {
    /*
     * send pong back
     * NOTE:  sptr is never local so if pong handles numerics everywhere we
     * could send a numeric here.
     */
    sendcmdto_one(&me, CMD_PONG, sptr, "%C :%s", &me, origin);
  }
  return 0;
}
Exemplo n.º 16
0
//-----------------------------------------------------------------------------
//::::::::::::::::::::::::::::BUSCADORES DE CUENTAS:::::::::::::::::::::::::::::::::::::
//-----------------------------------------------------------------------------
TCuenta* TAdministradora :: FindCuenta(AnsiString pServidor,AnsiString pUserName)
{
  TServidor* Server = FindServer(pServidor);
  if(Server)
  {
    TCuenta* cuenta = (TCuenta*)Server->Cuentas()->FirstThat(Daemon::FindCuenta,&pUserName);
    if(cuenta)
      return cuenta;
    else
      return NULL;
  }
  else
    return NULL;
}
Exemplo n.º 17
0
MCResult 
MemCacheClient::IncDec(
    const char *    a_pszType, 
    const char *    a_pszKey, 
    uint64_t *      a_pnNewValue,
    uint64_t        a_nDiff,
    bool            a_bWantReply
    )
{
    Server * pServer = FindServer(a_pszKey);
    if (!pServer) return MCERR_NOSERVER;

    char szBuf[50];
    string_t sRequest(a_pszType);
    sRequest += ' ';
    sRequest += a_pszKey;
    snprintf(szBuf, sizeof(szBuf), " " SPRINTF_UINT64, a_nDiff);
    sRequest += szBuf;
    if (!a_bWantReply) {
        sRequest += " noreply";
    }
    sRequest += "\r\n";

    try {
        pServer->SendBytes(sRequest.data(), sRequest.length());

        if (!a_bWantReply) {
            return MCERR_NOREPLY;
        }

        string_t sValue;
        sValue = pServer->GetByte();
        while (sValue[sValue.length()-1] != '\n') {
            sValue += pServer->GetByte();
        }

        if (sValue == "NOT_FOUND\r\n") {
            return MCERR_NOTFOUND;
        }

        if (a_pnNewValue) {
            *a_pnNewValue = STRTOUL64(sValue.data(), NULL, 10);
        }
        return MCERR_OK;
    }
    catch (const ServerSocket::Exception &) {
        pServer->Disconnect();
        return MCERR_NOSERVER;
    }
}
void CGameQueryListener::ConnectToServer(const char* server)
{
	//first check the version of the server ...
	char myVersion[32];
	GetISystem()->GetProductVersion().ToShortString(myVersion);
	string version(myVersion);

	SGameServer* targetServer = FindServer(server);
	if(!targetServer)
	{
		CryWarning(VALIDATOR_MODULE_NETWORK, VALIDATOR_WARNING, "Selected server not found in list!");
		return;
	}

	if(version.compare(targetServer->GetServerGameVersion()) != 0)
	{
		CryWarning(VALIDATOR_MODULE_NETWORK, VALIDATOR_WARNING, "Game versions differ - not connecting!");
		return;
	}

	string addr(server);
	string port;
	int pos = addr.find(":");
	if(pos != string::npos)	//space for port
	{
		port = addr.substr(pos+1, addr.size()-pos);
		addr.erase(pos, addr.size()-pos);
	}

	IConsole* pConsole = gEnv->pConsole;

	pConsole->GetCVar("cl_serveraddr")->Set(addr.c_str());
	if(port.size() > 0)
		pConsole->GetCVar("cl_serverport")->Set(port.c_str());

	string tempHost = pConsole->GetCVar("cl_serveraddr")->GetString();

	SGameStartParams params;	//this would connect to a server
	params.flags = eGSF_Client;
	params.hostname = tempHost.c_str();
	params.pContextParams = NULL;
	params.port = pConsole->GetCVar("cl_serverport")->GetIVal();

	CCryAction *action = (CCryAction*) (gEnv->pGame->GetIGameFramework());
	if(action)
	{
		gEnv->pConsole->ExecuteString("net_lanbrowser 0");
		action->StartGameContext(&params);
	}
}
bool MMG_TrackableServer::AuthServer(SvClient *aClient, uint aKeySequence, ushort aProtocolVersion)
{
	// Sanity check: Server should not be registered
	assert(FindServer(aClient) == nullptr);

	//
	// Protocol and key validation (similar to the client)
	//
	//if (aProtocolVersion != MassgateProtocolVersion)
	//	return false;

	//
	// Insert into master server list
	//
	Server masterEntry(aClient->GetIPAddress(), aClient->GetPort());
	{
		if (aKeySequence != 0)
		{
			// TODO: Query database
			uint id = 0;
			MySQLDatabase::ourInstance->VerifyServerKey(aKeySequence, &id);

			if (id > 0)
				masterEntry.m_KeyAuthenticated = true;

			// TODO: Generate quiz answer
			masterEntry.m_KeySequence	= aKeySequence;
			masterEntry.m_QuizAnswer	= 0;
		}

		this->m_ServerList.push_back(masterEntry);
	}

	// Sanity check: Server should be registered
	assert(FindServer(aClient) != nullptr);
	return true;
}
Exemplo n.º 20
0
void CSbmfcsampleDlg::AddServer(SBServer server, BOOL checkForReplace)
{
	// set the progress
	if(ServerBrowserCount(m_serverBrowser) > 0)
		m_progress.SetPos((ServerBrowserCount(m_serverBrowser) - ServerBrowserPendingQueryCount(m_serverBrowser)) * 100 / ServerBrowserCount(m_serverBrowser));

	// check for the server in the list
	int index = FindServer(server);
	bool replace = (index != -1);

	// if we didn't find a server to replace, append
	if(!replace)
		index = m_serverList.GetItemCount();

	// set or insert the hostname
	const char * hostname = SBServerGetStringValue(server, "hostname","(NO NAME)");
	if(replace)
	{
		m_serverList.SetItem(index, COL_SERVERNAME, LVIF_TEXT, hostname, -1, 0, 0, NULL);
	}
	else
	{
		m_serverList.InsertItem(index, hostname);
		m_serverList.SetItem(index, COL_SERVERNAME, LVIF_PARAM, NULL, -1, 0, 0, (LPARAM)server);
	}

	// set the rest of the columns
	int numplayers = SBServerGetIntValue(server, "numplayers", 0);
	CString ping, players;
	if (SBServerHasValidPing(server))
		ping.Format("%d%s", SBServerGetPing(server), SBServerDirectConnect(server) ? "" : "i");
	else
		ping = "Unknown";
	players.Format("%d/%d", numplayers,  SBServerGetIntValue(server, "maxplayers", 0));
	m_serverList.SetItem(index, COL_PING, LVIF_TEXT, ping, -1, 0, 0, 0);
	m_serverList.SetItem(index, COL_PLAYERS, LVIF_TEXT, players, -1, 0, 0, 0);
	m_serverList.SetItem(index, COL_MAPNAME, LVIF_TEXT, SBServerGetStringValue(server, "mapname", "(NO MAP)"), -1, 0, 0, 0);
	m_serverList.SetItem(index, COL_GAMETYPE, LVIF_TEXT, SBServerGetStringValue(server, "gametype", ""), -1, 0, 0, 0);

	// update server count
	if(!replace)
	{
		CString str;
		str.Format("%d", ++m_serverCount);
		m_servers.SetWindowText(str);
	}

	GSI_UNUSED(checkForReplace);
}
Exemplo n.º 21
0
void dlgMain::OnRefreshServer(wxCommandEvent &event)
{   
    // prevent reentrancy
    static wxRecursionGuardFlag s_rgf;
    wxRecursionGuard recursion_guard(s_rgf);
    
    if (recursion_guard.IsInside())
        return;	

    if (GetThread() && GetThread()->IsRunning())
        return;

    if (!m_LstCtrlServers->GetItemCount() || !m_LstCtrlServers->GetSelectedItemCount())
        return;
        
    m_LstCtrlPlayers->DeleteAllItems();
        
    wxInt32 listindex = m_LstCtrlServers->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        
    wxListItem item;
    item.SetId(listindex);
    item.SetColumn(7);
    item.SetMask(wxLIST_MASK_TEXT);
        
    m_LstCtrlServers->GetItem(item);
        
    wxInt32 arrayindex = FindServer(item.GetText()); 
        
    if (arrayindex == -1)
        return;
                
    TotalPlayers -= QServer[arrayindex].info.numplayers;
    
    mtcs_Request.Signal = mtcs_getsingleserver;
    mtcs_Request.ServerListIndex = listindex;
    mtcs_Request.Index = arrayindex;

    // Create monitor thread and run it
    if (this->wxThreadHelper::Create() != wxTHREAD_NO_ERROR)
    {
        wxMessageBox(_T("Could not create monitor thread!"), 
                     _T("Error"), 
                     wxOK | wxICON_ERROR);
                     
        wxExit();
    }

    GetThread()->Run();   
}
Exemplo n.º 22
0
/*----------------------------------------------------------------------
|   PLT_MediaBrowser::OnEventNotify
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaBrowser::OnEventNotify(PLT_Service* service, NPT_List<PLT_StateVariable*>* vars)
{
    if (!service->GetDevice()->GetType().StartsWith("urn:schemas-upnp-org:device:MediaServer"))
        return NPT_FAILURE;

    if (!m_Delegate) return NPT_SUCCESS;

    /* make sure device associated to service is still around */
    PLT_DeviceDataReference data;
    NPT_CHECK_WARNING(FindServer(service->GetDevice()->GetUUID(), data));

    if (m_Delegate) m_Delegate->OnMSStateVariablesChanged(service, vars);
    return NPT_SUCCESS;
}
Exemplo n.º 23
0
//-----------------------------------------------------------------------------
TGLinkedList* TAdministradora :: BuzonLleno(AnsiString pServidor) //inciso f)
{
  TGLinkedList* llenos = new TGLinkedList();
  TServidor* server = FindServer(pServidor);
  if(server)
  {
    for(int i = 0; i < server->Cuentas()->Length(); i++)
    {
      TCuenta* cuenta = (TCuenta*)server->Cuentas()->ItemInfo(i);
      if(cuenta->Cuota() == server->Tope())
        llenos->Insert(cuenta->Person());
    }
  }
  return llenos;
}
Exemplo n.º 24
0
void CSbmfcsampleDlg::RemoveServer(SBServer server)
{
	// find the server
	int index = FindServer(server);
	ASSERT(index != -1);
	if(index == -1)
		return;

	// remove it
	m_serverList.DeleteItem(index);

	// update server count
	CString str;
	str.Format("%d", --m_serverCount);
	m_servers.SetWindowText(str);
}
Exemplo n.º 25
0
/** Apply a jupe.
 * @param[in] cptr Local client that sent us the jupe.
 * @param[in] sptr Originator of the jupe.
 * @param[in] jupe Jupe to check.
 */
static int
do_jupe(struct Client *cptr, struct Client *sptr, struct Jupe *jupe)
{
  struct Client *acptr;

  if (!JupeIsActive(jupe)) /* no action to be taken on inactive jupes */
    return 0;

  acptr = FindServer(jupe->ju_server);

  /* server isn't online or isn't local or is me */
  if (!acptr || !MyConnect(acptr) || IsMe(acptr))
    return 0;

  return exit_client_msg(cptr, acptr, &me, "Juped: %s", jupe->ju_reason);
}
Exemplo n.º 26
0
//-----------------------------------------------------------------------------
TGLinkedList* TAdministradora :: ShowPerson(AnsiString pServidor) //inciso c)
{
  TGLinkedList* Consalidas = new TGLinkedList();

  TServidor* server = FindServer(pServidor);
  if(server)
  {
    for(int i=0; i < server->Cuentas()->Length(); i++)
    {
      TCuenta* cuneta = (TCuenta*)server->Cuentas()->ItemInfo(i);
      if(cuneta->Salida() == true)
        Consalidas->Insert(((TCuenta*)server->Cuentas()->ItemInfo(i))->Person());
    }
  }
  return Consalidas;
}
Exemplo n.º 27
0
void relay_directed_notice(struct Client* sptr, char* name, char* server, const char* text)
{
  struct Client* acptr;
  char*          host;

  assert(0 != sptr);
  assert(0 != name);
  assert(0 != text);
  assert(0 != server);

  if (0 == (acptr = FindServer(server + 1)))
    return;
  /*
   * NICK[%host]@server addressed? See if <server> is me first
   */
  if (!IsMe(acptr)) {
    sendcmdto_one(sptr, CMD_NOTICE, acptr, "%s :%s", name, text);
    return;
  }
  /*
   * Look for an user whose NICK is equal to <name> and then
   * check if it's hostname matches <host> and if it's a local
   * user.
   */
  *server = '\0';
  if ((host = strchr(name, '%')))
    *host++ = '\0';

  if (!(acptr = FindUser(name)) || !MyUser(acptr) ||
      (!EmptyString(host) && 0 != match(host, cli_user(acptr)->realhost)))
    return;

  *server = '@';
  if (host)
    *--host = '%';

  if (!IsChannelService(sptr) && is_silenced(sptr, acptr))
  {
    send_reply(sptr, ERR_SILENCED, cli_name(acptr));
    return;
  }

  if (IsOnlyreg(acptr) && !IsRegnick(sptr))
    send_reply(sptr, RPL_MSGONLYREG, cli_name(acptr));
  else
    sendcmdto_one(sptr, CMD_NOTICE, acptr, "%s :%s", name, text);
}
Exemplo n.º 28
0
/*
 * m_pseudo - generic service message handler
 *
 * parv[0] = sender prefix
 * parv[1] = service mapping (s_map * disguised as char *)
 * parv[2] = message
 */
int m_pseudo(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  char *text, buffer[BUFSIZE];
  struct s_map *map;
  struct nick_host *nh;

  assert(0 != cptr);
  assert(cptr == sptr);
  assert(0 != cli_user(sptr));

  /* By default, relay the message straight through. */
  text = parv[parc - 1];

  /* HACK! HACK! HACK! HACK! Yes. It's icky, but
   * it's the only way. */
  map = (struct s_map *)parv[1];
  assert(0 != map);

  if (parc < 3 || EmptyString(text)) {
    if (map->defaulttext)
      text = map->defaulttext;
    else
      return send_reply(sptr, ERR_NOTEXTTOSEND);
  }

  if (map->prepend) {
    ircd_snprintf(0, buffer, sizeof(buffer) - 1, "%s%s", map->prepend, text);
    buffer[sizeof(buffer) - 1] = 0;
    text = buffer;
  }

  for (nh = map->services; nh; nh = nh->next) {
    struct Client *target, *server;

    if (NULL == (server = FindServer(nh->nick + nh->nicklen + 1)))
      continue;
    nh->nick[nh->nicklen] = '\0';
    if ((NULL == (target = FindUser(nh->nick)))
        || (server != cli_user(target)->server))
      continue;
    nh->nick[nh->nicklen] = '@';
    relay_directed_message(sptr, nh->nick, nh->nick + nh->nicklen, text);
    return 0;
  }

  return send_reply(sptr, ERR_SERVICESDOWN, map->name);
}
Exemplo n.º 29
0
// Retrieves the currently selected server in array index form
wxInt32 dlgMain::GetSelectedServerArrayIndex()
{
    wxListItem item;
    wxInt32 i;

    i = GetSelectedServerListIndex();

    item.SetId(i);
    item.SetColumn(7);
    item.SetMask(wxLIST_MASK_TEXT);
        
    m_LstCtrlServers->GetItem(item);
        
    i = FindServer(item.GetText()); 
    
    return i;
}
Exemplo n.º 30
0
//-----------------------------------------------------------------------------
//::::::::::::::::::::::::::::ELIMINAR UNA CUENTA:::::::::::::::::::::::::::::::::::::
//-----------------------------------------------------------------------------
//Elimina Cuenta
TCuenta* TAdministradora :: EliminarCuenta(AnsiString pServer,AnsiString pCuenta)
{
  TSPosName posname;
  posname.name = pCuenta;
  posname.pos = -1;
  TServidor* server = FindServer(pServer);
  if(server)
  {
    TCuenta* cuenta = (TCuenta*)server->Cuentas()->FirstThat(Daemon::FindPosCuenta,&posname);
    if(cuenta)
    {
      void* info = server->Cuentas()->Delete(posname.pos);
      return (TCuenta*)info;
    }
  }
  return NULL;
}