Ejemplo n.º 1
0
/*
	\method account.authorized
	\param group The ACL group that should be checked for.
	\param action The action in the given ACL group that should be checked.
	\return True if the account may perform the given action. False otherwise.
	\description Checks if the account may perform a given action based on its ACL.
*/
static PyObject* wpAccount_authorized( wpAccount* self, PyObject* args )
{
	if ( !checkArgStr( 0 ) || !checkArgStr( 1 ) )
	{
		PyErr_BadArgument();
		return 0;
	}

	QCString group = getArgStr( 0 ).latin1();
	QCString action = getArgStr( 1 ).latin1();

	if ( self->account->authorized( group, action ) )
		Py_RETURN_TRUE;
	else
		Py_RETURN_FALSE;
}
Ejemplo n.º 2
0
/*
	\method socket.hastag
	\description Check if the socket has a certain custom tag attached to it.
	\return True if the tag is present. False otherwise.
	\param name The name of the tag.
*/
static PyObject* wpSocket_hastag( wpSocket* self, PyObject* args )
{
	if ( !self->pSock )
		return PyFalse();

	if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) )
	{
		PyErr_BadArgument();
		return NULL;
	}

	QString key = getArgStr( 0 );

	return self->pSock->tags().has( key ) ? PyTrue() : PyFalse();
}
Ejemplo n.º 3
0
/*
	\method socket.sendweblink
	\description Send an url to the client and open it in the players webbrowser.
	\param url The url that should be sent.
*/
static PyObject* wpSocket_sendweblink( wpSocket* self, PyObject* args )
{
	if ( !self->pSock )
		return PyFalse();

	if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) )
	{
		PyErr_BadArgument();
		return NULL;
	}

	QString url = getArgStr( 0 );
	self->pSock->sendWeblink( url );

	Py_RETURN_NONE;
}
Ejemplo n.º 4
0
/*
	\method socket.deltag
	\description Deletes a tag attached to the socket.
	\param name The name of the tag.
*/
static PyObject* wpSocket_deltag( wpSocket* self, PyObject* args )
{
	if ( !self->pSock )
		return PyFalse();

	if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) )
	{
		PyErr_BadArgument();
		return NULL;
	}

	QString key = getArgStr( 0 );
	self->pSock->tags().remove( key );

	Py_RETURN_NONE;
}
Ejemplo n.º 5
0
/*
	\method ai.onSpeechInput
	\param from A <object id="char">char</object> object for the character the text is coming from.
	\param text A string with the text that should be processed.
	\description This method sends a text with a given source to the ai engine to proces it. This
	could be used to force the banker engine to open the bankbox for instance.
*/
static PyObject* wpAI_onSpeechInput( wpAI* self, PyObject* args )
{
	if ( !checkArgChar( 0 ) )
		return 0;
	if ( !checkArgStr( 1 ) )
		return 0;
	P_CHAR pc = getArgChar( 0 );

	P_PLAYER player = dynamic_cast<P_PLAYER>( pc );
	if ( !player )
		Py_RETURN_FALSE;

	QString str = getArgStr( 1 );
	self->pAI->onSpeechInput( player, str.upper() );

	Py_RETURN_TRUE;
}
Ejemplo n.º 6
0
void
getInfo(InfoType type,
        virt_ptr<void> buffer,
        uint32_t size)
{
   switch (type) {
   case InfoType::Type0:
      getType0Info(virt_cast<Info0 *>(buffer), size);
      break;
   case InfoType::Type6:
      getType6Info(virt_cast<Info6 *>(buffer), size);
      break;
   case InfoType::ArgStr:
      getArgStr(virt_cast<char *>(buffer), size);
      break;
   default:
      decaf_abort(fmt::format("Unexpected kernel info type {}",
                              static_cast<unsigned>(type)));
   }
}
Ejemplo n.º 7
0
/*
 * Adds a temp effect to this multi.
 */
static PyObject* wpMulti_addtimer( wpMulti* self, PyObject* args )
{
	if( (PyTuple_Size( args ) < 3 && PyTuple_Size( args ) > 4) || !checkArgInt( 0 ) || !checkArgStr( 1 ) || !PyList_Check( PyTuple_GetItem( args, 2 ) ) )
	{
		PyErr_BadArgument();
		return NULL;
	}
	UINT32 expiretime = getArgInt( 0 );
	QString function = getArgStr( 1 );
	PyObject *py_args = PyList_AsTuple( PyTuple_GetItem( args, 2 ) );
	cPythonEffect *effect = new cPythonEffect( function, py_args );
	if( checkArgInt( 3 ) && getArgInt( 3 ) != 0 )
		effect->setSerializable( true );
	else
		effect->setSerializable( false );
	effect->setDest( self->pMulti->serial() );
	effect->setExpiretime_ms( expiretime );
	TempEffects::instance()->insert( effect );
	return PyTrue;
}
Ejemplo n.º 8
0
/*!
	Sets a custom tag
*/
static PyObject* wpMulti_settag( wpMulti* self, PyObject* args )
{
	if( !self->pMulti || self->pMulti->free )
		return PyFalse;

	if( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) || ( !checkArgStr( 1 ) && !checkArgInt( 1 )  ) )
	{
		PyErr_BadArgument();
		return NULL;
	}

	QString key = PyString_AsString( PyTuple_GetItem( args, 0 ) );

	self->pMulti->removeTag( key );

	if( checkArgStr( 1 ) )
		self->pMulti->setTag( key, cVariant( QString( getArgStr( 1 ) ) ) );
	else if( checkArgInt( 1 ) )
		self->pMulti->setTag( key, cVariant( (int)getArgInt( 1 ) ) );

	return PyTrue;
}