// -----------------------------------------------------------------------------
// CMediatorServerObjectHandler::RemoveCategoryIfEmptyL
//  
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//      
TBool CMediatorServerObjectHandler::RemoveCategoryIfEmptyL( TUid aDomain, TUid aCategory)
    {
    TBool removed = EFalse;
    // Check if category is empty
    if ( IsCategoryEmptyL( aDomain, aCategory ))
        {
        CDomain* domainPtr = FindDomain( aDomain );
        if ( domainPtr )
            {
            domainPtr->RemoveCategory( aCategory );
            removed = ETrue;
            domainPtr = NULL; // Not owned
            }
        }
    return removed;
    }
// -----------------------------------------------------------------------------
// CMediatorServerObjectHandler::GetCategoriesL
//  
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CMediatorServerObjectHandler::GetCategoriesL( TMediatorCategory aCategory, 
                                                   RCategoryList& aCategories )
    {
    // Check that domain exists 
    CDomain* domain = FindDomain( aCategory.iDomain );
    if ( !domain )
        {
        ERROR_TRACE(Print(_L("[Mediator] CMediatorServerObjectHandler::GetCategoriesL: domain %d not found\n"), aCategory.iDomain ) );
        User::Leave( KErrMediatorDomainNotFound );
        }
    else
        {
        // Ok, get categories from domain.
        domain->GetCategoriesL( aCategories );
        }
    }
// -----------------------------------------------------------------------------
// CMediatorServerObjectHandler::CategoryL
// Returns pointer to found category
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//     
CCategory* CMediatorServerObjectHandler::CategoryL( TMediatorCategory aCategory )
    {
    // Check that domain exists 
    CDomain* domain = FindDomain( aCategory.iDomain );
    if ( !domain )
        {
        ERROR_TRACE(Print(_L("[Mediator] CMediatorServerObjectHandler::CategoryL: domain %d not found\n"), aCategory.iDomain ) );
        User::Leave( KErrMediatorDomainNotFound );
        }
    // Check that category exists
    TInt index = 0; // not used
    CCategory* category = domain->FindCategory( aCategory.iCategory, index );
    if ( !category )
        {
        ERROR_TRACE(Print(_L("[Mediator] CMediatorServerObjectHandler::CategoryL: category %d not found\n"), aCategory.iCategory ) );
        User::Leave( KErrMediatorCategoryNotFound );
        }
    return category;
    }
Esempio n. 4
0
void
UpdateUserModes(struct Luser *user, char *modes)

{
	int PLUS = 1;
	int umode;
	unsigned int ii;

	if (!modes || !user)
		return;

	for (ii = 0; ii < strlen(modes); ii++)
	{
		if (modes[ii] == '+')
		{
			PLUS = 1;
			continue;
		}
		if (modes[ii] == '-')
		{
			PLUS = 0;
			continue;
		}
		umode = 0;
		if (modes[ii] == 'i')
			umode = UMODE_I;
		if (modes[ii] == 's')
			umode = UMODE_S;
		if (modes[ii] == 'w')
			umode = UMODE_W;
		if (modes[ii] == 'o')
			umode = UMODE_O;
#ifdef DANCER

		if (modes[ii] == 'e')
			if (PLUS)
			{
				struct NickInfo* realptr = FindNick(user->nick);
				if (realptr)
				{
					realptr->flags |= NS_IDENTIFIED;
					RecordCommand("User %s has +e umode, marking as identified",user->nick);
					umode = UMODE_E;
				}
				else
				{
					/* Blech, who is screwing with us? */
					toserv(":%s MODE %s -e\r\n", Me.name, user->nick);
					RecordCommand("User %s has +e umode but is not known to me, setting -e",
					              user->nick);
					umode = 0;
				}
			}
#endif /* DANCER */

		if (!umode)
			continue;

		if (PLUS)
		{
			if ((umode == UMODE_O) && (!IsOperator(user)))
			{
#ifdef STATSERVICES
				char *hostname, *domain;
				struct HostHash *hosth, *domainh;
				time_t currtime = current_ts;
#endif

#ifdef NICKSERVICES

				CheckOper(user);
#endif

				Network->TotalOperators++;

				if (SafeConnect)
					SendUmode(OPERUMODE_O,
					          "*** New Operator: %s (%s@%s) [%s]",
					          user->nick,
					          user->username,
					          user->hostname,
					          user->server ? user->server->name : "*unknown*");

#ifdef STATSERVICES

				if (Network->TotalOperators > Network->MaxOperators)
				{
					Network->MaxOperators = Network->TotalOperators;
					Network->MaxOperators_ts = current_ts;

					if ((Network->MaxOperators % 5) == 0)
					{
						/* inform +y people of new max oper count */
						SendUmode(OPERUMODE_Y,
						          "*** New Max Operator Count: %ld",
						          Network->MaxOperators);
						putlog(LOG2, "New Max Operator Count: %ld",
								Network->MaxOperators);
					}
				}
				if (Network->TotalOperators > Network->MaxOperatorsT)
				{
					Network->MaxOperatorsT = Network->TotalOperators;
					Network->MaxOperatorsT_ts = current_ts;
				}
#endif

				if (user->server)
				{
					user->server->numopers++;

#ifdef STATSERVICES

					if (user->server->numopers > user->server->maxopers)
					{
						user->server->maxopers = user->server->numopers;
						user->server->maxopers_ts = current_ts;
					}
#endif

				}

#ifdef STATSERVICES
				hostname = user->hostname;

				if ((hosth = FindHost(hostname)))
				{
					hosth->curropers++;
					if (hosth->curropers > hosth->maxopers)
					{
						hosth->maxopers = hosth->curropers;
						hosth->maxopers_ts = currtime;
					}
				}

				if ((domain = GetDomain(hostname)))
				{
					if ((domainh = FindDomain(domain)))
					{
						domainh->curropers++;
						if (domainh->curropers > domainh->maxopers)
						{
							domainh->maxopers = domainh->curropers;
							domainh->maxopers_ts = currtime;
						}
					}
				}
#endif /* STATSERVICES */

			}
			user->umodes |= umode;
		}
		else
		{
			if ((umode == UMODE_O) && (IsOperator(user)))
			{
#ifdef STATSERVICES
				char *hostname, *domain;
				struct HostHash *hosth, *domainh;
#endif

				Network->TotalOperators--;
				if (user->server)
					user->server->numopers--;

#ifdef STATSERVICES

				hostname = user->hostname;

				if ((hosth = FindHost(hostname)))
					hosth->curropers--;

				if ((domain = GetDomain(hostname)))
					if ((domainh = FindDomain(domain)))
						domainh->curropers--;
#endif

			}
			user->umodes &= ~umode;
		}
	}
} /* UpdateUserModes() */
Esempio n. 5
0
static void
ss_domain(struct Luser *lptr, int ac, char **av)

{
	struct HostHash *hosth;
	char *domain;
	char str[MAXLINE + 1];

	if (ac < 2)
	{
		notice(n_StatServ, lptr->nick,
		       "Syntax: DOMAIN <domain>");
		notice(n_StatServ, lptr->nick,
		       ERR_MORE_INFO,
		       n_StatServ,
		       "DOMAIN");
		return;
	}

	domain = GetDomain(av[1]);

	RecordCommand("%s: %s!%s@%s DOMAIN [%s]",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname,
	              domain ? domain : av[1]);

	if (!(hosth = FindDomain(domain)))
	{
		notice(n_StatServ, lptr->nick,
		       "No domains matching [\002%s\002] found",
		       domain ? domain : av[1]);
		return;
	}

	notice(n_StatServ, lptr->nick,
	       "Statistics for domain: \002%s\002",
	       domain);
	notice(n_StatServ, lptr->nick,
	       "Current Clients:  %ld (%ld unique)",
	       hosth->currclients,
	       hosth->currunique);
	notice(n_StatServ, lptr->nick,
	       "Current Opers:    %ld",
	       hosth->curropers);

	strlcpy(str, ctime(&hosth->maxclients_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Clients:      %ld on %s",
	       hosth->maxclients,
	       str);

	strlcpy(str, ctime(&hosth->maxunique_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Unique:       %ld on %s",
	       hosth->maxunique,
	       str);

	if (hosth->maxopers_ts)
	{
		strlcpy(str, "on ", sizeof(str));
		strlcat(str, ctime(&hosth->maxopers_ts), sizeof(str));
		str[strlen(str) - 1] = '\0';
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Operators:    %ld %s",
	       hosth->maxopers,
	       str);

	notice(n_StatServ, lptr->nick,
	       "Identd Users:     %ld",
	       hosth->curridentd);
	notice(n_StatServ, lptr->nick,
	       "Non-Identd Users: %ld",
	       hosth->currclients - hosth->curridentd);
} /* ss_domain() */