mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-13 18:17:49 -04:00
CWE Directory Reorganization
Rearrange directory structure of CWE to be loosely equivalent to the H'uru Plasma repository. Part 1: Movement of directories and files.
This commit is contained in:
503
Sources/Plasma/PythonLib/pyVault/pyVNodeMgr.cpp
Normal file
503
Sources/Plasma/PythonLib/pyVault/pyVNodeMgr.cpp
Normal file
@ -0,0 +1,503 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyVNodeMgr.h"
|
||||
#include "../plVault/plVaultCallback.h"
|
||||
#include "../plVault/plVaultInitTasks.h"
|
||||
#include "../pfPython/pyVaultNode.h"
|
||||
#include "../pfPython/pyVaultFolderNode.h"
|
||||
#include "../pyNetClientComm/pyNetClientComm.h"
|
||||
#include "../plNetMessage/plNetMessage.h"
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class pyVaultOperationCallback : public plVaultOperationCallback
|
||||
{
|
||||
public:
|
||||
PyObject * fPyObject;
|
||||
pyVaultOperationCallback( PyObject * pyObject )
|
||||
: fPyObject( pyObject )
|
||||
{
|
||||
Py_XINCREF( fPyObject );
|
||||
}
|
||||
~pyVaultOperationCallback()
|
||||
{
|
||||
Py_XDECREF( fPyObject );
|
||||
}
|
||||
void VaultOperationStarted( UInt32 context )
|
||||
{
|
||||
if ( fPyObject )
|
||||
{
|
||||
// Do callback
|
||||
PyObject* func = PyObject_GetAttrString( fPyObject, "operationStarted" );
|
||||
if ( func )
|
||||
{
|
||||
if ( PyCallable_Check(func)>0 )
|
||||
{
|
||||
PyObject* retVal = PyObject_CallMethod(fPyObject, "operationStarted", "l", context);
|
||||
Py_XDECREF(retVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void VaultOperationComplete( UInt32 context, int resultCode )
|
||||
{
|
||||
if ( fPyObject )
|
||||
{
|
||||
// Pass args.
|
||||
// PyObject* pyArgs = PyObject_GetAttrString( fPyObject, "fCbArgs" );
|
||||
// if ( pyArgs )
|
||||
// {
|
||||
// dict pyDict = dict();
|
||||
// std::map<UInt16,plCreatable*> args;
|
||||
// fCbArgs.GetItems( args );
|
||||
// for ( std::map<UInt16,plCreatable*>::iterator ii=args.begin(); ii!=args.end(); ++ii )
|
||||
// {
|
||||
// UInt16 key = ii->first;
|
||||
// plCreatable* arg = ii->second;
|
||||
// plCreatableGenericValue * genValue = plCreatableGenericValue::ConvertNoRef( arg );
|
||||
// if ( genValue )
|
||||
// {
|
||||
// plGenericType & value = genValue->Value();
|
||||
// switch ( value.GetType() )
|
||||
// {
|
||||
// case plGenericType::kInt:
|
||||
// pyDict[key] = (int)value;
|
||||
// break;
|
||||
// case plGenericType::kUInt:
|
||||
// pyDict[key] = (unsigned int)value;
|
||||
// break;
|
||||
// case plGenericType::kFloat:
|
||||
// pyDict[key] = (float)value;
|
||||
// break;
|
||||
// case plGenericType::kDouble:
|
||||
// pyDict[key] = (double)value;
|
||||
// break;
|
||||
// case plGenericType::kBool:
|
||||
// pyDict[key] = (bool)value;
|
||||
// break;
|
||||
// case plGenericType::kChar:
|
||||
// pyDict[key] = (char)value;
|
||||
// break;
|
||||
// case plGenericType::kString:
|
||||
// pyDict[key] = (const char *)value;
|
||||
// break;
|
||||
// case plGenericType::kAny:
|
||||
// break;
|
||||
// case plGenericType::kNone:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// PyObject_SetAttrString( fPyObject, "fCbArgs", pyDict.ptr() );
|
||||
// }
|
||||
// Do callback
|
||||
PyObject* func = PyObject_GetAttrString( fPyObject, "operationComplete" );
|
||||
if ( func )
|
||||
{
|
||||
if ( PyCallable_Check(func)>0 )
|
||||
{
|
||||
PyObject* retVal = PyObject_CallMethod(fPyObject, "operationComplete", "li", context, resultCode);
|
||||
Py_XDECREF(retVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class pyVaultCallback : public plVaultStubbedCallback
|
||||
{
|
||||
public:
|
||||
PyObject * fPyObject;
|
||||
pyVaultCallback( PyObject * pyObject )
|
||||
: fPyObject( pyObject )
|
||||
{
|
||||
Py_XINCREF( fPyObject );
|
||||
}
|
||||
~pyVaultCallback()
|
||||
{
|
||||
Py_XDECREF( fPyObject );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
int pyVNodeMgr::VaultMsgHandler::HandleMessage( plNetMessage* msg )
|
||||
{
|
||||
plNetMsgVault * vaultMsg = plNetMsgVault::ConvertNoRef( msg );
|
||||
|
||||
if ( vaultMsg )
|
||||
{
|
||||
plNetCoreMessage * ncmsg = (plNetCoreMessage*)msg->GetNetCoreMsg();
|
||||
msg->PeekBuffer( ncmsg->GetData(), ncmsg->GetLen() );
|
||||
fMyVNodeMgr->GetStatusLog()->AddLineF( "\t%s", msg->AsStdString().c_str() );
|
||||
plVault::ProcessMsg( vaultMsg );
|
||||
return plNetClientComm::kOK_MsgConsumed;
|
||||
}
|
||||
|
||||
return hsFail;
|
||||
}
|
||||
|
||||
|
||||
// pyVNodeMgr ----------------------------------------------
|
||||
pyVNodeMgr::pyVNodeMgr( PyObject* thaComm )
|
||||
{
|
||||
if (!pyNetClientComm::Check(thaComm))
|
||||
{
|
||||
fMyCommObj = NULL;
|
||||
return; // screwed!
|
||||
}
|
||||
|
||||
fMsgHandler.setMgr(this);
|
||||
|
||||
fMyCommObj = thaComm;
|
||||
Py_INCREF(fMyCommObj);
|
||||
fMyComm = pyNetClientComm::ConvertFrom(fMyCommObj);
|
||||
fMyComm->GetNetClientComm()->AddMsgHandlerForType( plNetMsgVault::Index(), &fMsgHandler );
|
||||
plVNodeMgr::SetStatusLog( fMyComm->GetNetClientComm()->GetLog(), false );
|
||||
}
|
||||
|
||||
// ~pyVNodeMgr ----------------------------------------------
|
||||
pyVNodeMgr::~pyVNodeMgr()
|
||||
{
|
||||
fMyComm->GetNetClientComm()->RemoveMsgHandler( &fMsgHandler );
|
||||
Py_DECREF(fMyCommObj);
|
||||
}
|
||||
|
||||
void pyVNodeMgr::setMyComm(PyObject* thaComm)
|
||||
{
|
||||
if (fMyComm)
|
||||
{
|
||||
fMyComm->GetNetClientComm()->RemoveMsgHandler(&fMsgHandler);
|
||||
Py_DECREF(fMyCommObj);
|
||||
fMyCommObj = NULL;
|
||||
fMyComm = NULL;
|
||||
}
|
||||
if (!pyNetClientComm::Check(thaComm))
|
||||
return; // screwed!
|
||||
|
||||
fMyCommObj = thaComm;
|
||||
Py_INCREF(fMyCommObj);
|
||||
fMyComm = pyNetClientComm::ConvertFrom(fMyCommObj);
|
||||
fMyComm->GetNetClientComm()->AddMsgHandlerForType(plNetMsgVault::Index(), &fMsgHandler);
|
||||
plVNodeMgr::SetStatusLog(fMyComm->GetNetClientComm()->GetLog(), false);
|
||||
}
|
||||
|
||||
// IAmOnline ----------------------------------------------
|
||||
bool pyVNodeMgr::IAmOnline() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// IIsThisMe ----------------------------------------------
|
||||
bool pyVNodeMgr::IIsThisMe( plVaultPlayerInfoNode* node ) const
|
||||
{
|
||||
return ( fMyComm->GetNetClientComm()->GetPlayerID()==node->GetPlayerID() );
|
||||
}
|
||||
|
||||
// IIsThisMe ----------------------------------------------
|
||||
bool pyVNodeMgr::IIsThisMe( plVaultPlayerNode * node ) const
|
||||
{
|
||||
return ( fMyComm->GetNetClientComm()->GetPlayerID()==node->GetID() );
|
||||
}
|
||||
|
||||
// ISendNetMsg ----------------------------------------------
|
||||
int pyVNodeMgr::ISendNetMsg( plNetMsgVault* msg, UInt32 sendFlags/*=0 */)
|
||||
{
|
||||
return fMyComm->GetNetClientComm()->SendMsg( msg, sendFlags );
|
||||
}
|
||||
|
||||
// IGetPlayerID ----------------------------------------------
|
||||
UInt32 pyVNodeMgr::IGetPlayerID() const
|
||||
{
|
||||
return fMyComm->GetNetClientComm()->GetPlayerID();
|
||||
}
|
||||
|
||||
// Update ----------------------------------------------
|
||||
int pyVNodeMgr::Update( double secs )
|
||||
{
|
||||
return plVNodeMgr::Update( secs );
|
||||
}
|
||||
|
||||
// Startup ----------------------------------------------
|
||||
void pyVNodeMgr::Startup()
|
||||
{
|
||||
plVNodeMgr::Startup();
|
||||
}
|
||||
|
||||
// Shutdown ----------------------------------------------
|
||||
void pyVNodeMgr::Shutdown()
|
||||
{
|
||||
plVNodeMgr::Shutdown();
|
||||
}
|
||||
|
||||
|
||||
// IsConnected ----------------------------------------------
|
||||
bool pyVNodeMgr::IsConnected()
|
||||
{
|
||||
return plVNodeMgr::IsConnected();
|
||||
}
|
||||
|
||||
// Disconnect ----------------------------------------------
|
||||
void pyVNodeMgr::Disconnect( PyObject* cb/*=nil*/, UInt32 cbContext/*=0 */)
|
||||
{
|
||||
// disconnect from allplayers and globalsdl folders
|
||||
plVaultNodeRef * out;
|
||||
plVaultNode * root = plVNodeMgr::GetRootNode();
|
||||
if ( root )
|
||||
{
|
||||
plVaultFolderNode tmpGlobalSDL;
|
||||
tmpGlobalSDL.SetFolderType( plVault::kAllAgeGlobalSDLNodesFolder );
|
||||
if ( root->FindNode( &tmpGlobalSDL, out ) )
|
||||
root->RemoveNode( out->GetChildID() );
|
||||
plVaultFolderNode tmpAllPlayers;
|
||||
tmpAllPlayers.SetFolderType( plVault::kAllPlayersFolder );
|
||||
if ( root->FindNode( &tmpAllPlayers, out ) )
|
||||
root->RemoveNode( out->GetChildID() );
|
||||
}
|
||||
plVNodeMgr::Disconnect( new pyVaultOperationCallback( cb ), cbContext );
|
||||
}
|
||||
|
||||
// Connect ----------------------------------------------
|
||||
void pyVNodeMgr::Connect( int childFetchLevel/*=plVault::kFetchAllChildren*/, PyObject* cb/*=nil*/, UInt32 cbContext/*=0 */)
|
||||
{
|
||||
plVNodeMgr::Connect( childFetchLevel, new pyVaultOperationCallback( cb ), cbContext );
|
||||
}
|
||||
|
||||
// FetchNode ----------------------------------------------
|
||||
bool pyVNodeMgr::FetchNode( UInt32 nodeID,
|
||||
int childFetchLevel/*=plVault::kFetchAllChildren*/,
|
||||
PyObject* cb/*=nil*/,
|
||||
UInt32 cbContext/*=0 */)
|
||||
{
|
||||
return plVNodeMgr::FetchNode( nodeID, childFetchLevel, new pyVaultOperationCallback( cb ), cbContext );
|
||||
}
|
||||
|
||||
// GetRootNode ----------------------------------------------
|
||||
PyObject* pyVNodeMgr::GetRootNode() const
|
||||
{
|
||||
return pyVaultNode::New( plVNodeMgr::GetRootNode() );
|
||||
}
|
||||
|
||||
// GetClientID ----------------------------------------------
|
||||
UInt32 pyVNodeMgr::GetClientID() const
|
||||
{
|
||||
return plVNodeMgr::GetClientID();
|
||||
}
|
||||
|
||||
// GetNode ----------------------------------------------
|
||||
PyObject* pyVNodeMgr::GetNode( UInt32 id ) const
|
||||
{
|
||||
plVaultNode * tmp;
|
||||
if ( plVNodeMgr::GetNode( id, tmp ) )
|
||||
return pyVaultNode::New( tmp );
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
// FindNode ----------------------------------------------
|
||||
PyObject* pyVNodeMgr::FindNode( pyVaultNode* templateNode ) const
|
||||
{
|
||||
plVaultNode * node;
|
||||
if ( plVNodeMgr::FindNode( templateNode->GetNode(), node ) )
|
||||
return pyVaultNode::New( node );
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
// EnableCallbacks ----------------------------------------------
|
||||
bool pyVNodeMgr::EnableCallbacks( bool b )
|
||||
{
|
||||
return plVNodeMgr::EnableCallbacks( b );
|
||||
}
|
||||
|
||||
// AddCallback ----------------------------------------------
|
||||
void pyVNodeMgr::AddCallback( PyObject* cb )
|
||||
{
|
||||
pyVaultCallback * pycb = new pyVaultCallback( cb );
|
||||
fPyCallbacks.push_back( pycb );
|
||||
plVNodeMgr::AddCallback( pycb );
|
||||
}
|
||||
|
||||
// RemoveCallback ----------------------------------------------
|
||||
void pyVNodeMgr::RemoveCallback( PyObject* cb )
|
||||
{
|
||||
PyCallbackVec tmp;
|
||||
for ( int i=0; i<fPyCallbacks.size(); i++ )
|
||||
{
|
||||
if ( fPyCallbacks[i]->fPyObject==cb )
|
||||
tmp.push_back( fPyCallbacks[i] );
|
||||
}
|
||||
for ( int i=0; i<tmp.size(); i++ )
|
||||
{
|
||||
PyCallbackVec::iterator it = std::find( fPyCallbacks.begin(), fPyCallbacks.end(), tmp[i] );
|
||||
if ( it!=fPyCallbacks.end() )
|
||||
fPyCallbacks.erase( it );
|
||||
plVNodeMgr::RemoveCallback( tmp[i] );
|
||||
delete tmp[i];
|
||||
}
|
||||
}
|
||||
|
||||
// CreateNode ----------------------------------------------
|
||||
PyObject* pyVNodeMgr::CreateNode( int nodeType, bool persistent )
|
||||
{
|
||||
plVaultNode * node = plVNodeMgr::CreateNode( nodeType, persistent?kNewPersistentNodeOptions( this ):kNilNodeOptions() );
|
||||
if ( node )
|
||||
return pyVaultNode::New( node );
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
// Dump ----------------------------------------------
|
||||
void pyVNodeMgr::Dump() const
|
||||
{
|
||||
plVNodeMgr::Dump();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyPlayerVNodeMgr::pyPlayerVNodeMgr( PyObject* thaComm )
|
||||
: pyVNodeMgr( thaComm )
|
||||
{}
|
||||
|
||||
// IAmSuperUser ----------------------------------------------
|
||||
bool pyPlayerVNodeMgr::IAmSuperUser( void ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// IFillOutConnectFields ----------------------------------------------
|
||||
void pyPlayerVNodeMgr::IFillOutConnectFields( plNetMsgVault* msg ) const
|
||||
{
|
||||
msg->GetArgs()->AddInt( plVault::kArg_NodeMgrType, plVault::kNodeType_VNodeMgrPlayer );
|
||||
msg->GetArgs()->AddInt( plVault::kArg_NodeMgrID, fMyComm->GetNetClientComm()->GetPlayerID() );
|
||||
}
|
||||
|
||||
// IGetNodeInitializationTask ----------------------------------------------
|
||||
plVNodeInitTask * pyPlayerVNodeMgr::IGetNodeInitializationTask( plVaultNode * node )
|
||||
{
|
||||
if ( plVaultPlayerNode::ConvertNoRef( node ) )
|
||||
return new plVaultPlayerInitializationTask( this, node, true );
|
||||
return nil;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyAgeVNodeMgr::pyAgeVNodeMgr( PyObject* thaComm )
|
||||
: pyVNodeMgr( thaComm )
|
||||
{}
|
||||
|
||||
// IAmSuperUser ----------------------------------------------
|
||||
bool pyAgeVNodeMgr::IAmSuperUser( void ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// IFillOutConnectFields ----------------------------------------------
|
||||
void pyAgeVNodeMgr::IFillOutConnectFields( plNetMsgVault* msg ) const
|
||||
{
|
||||
msg->GetArgs()->AddInt( plVault::kArg_NodeMgrType, plVault::kNodeType_VNodeMgrAge );
|
||||
msg->GetArgs()->AddString( plVault::kArg_NodeMgrAgeInstanceName, fAgeFilename.c_str() );
|
||||
msg->GetArgs()->AddItem( plVault::kArg_NodeMgrAgeGuid, &fAgeInstanceGuid );
|
||||
}
|
||||
|
||||
// IGetNodeInitializationTask ----------------------------------------------
|
||||
plVNodeInitTask * pyAgeVNodeMgr::IGetNodeInitializationTask( plVaultNode * node )
|
||||
{
|
||||
if ( plVaultAgeNode::ConvertNoRef( node ) )
|
||||
return new plVaultAgeInitializationTask( this, node, nil, true );
|
||||
if ( plVaultAgeInfoNode::ConvertNoRef( node ) )
|
||||
return new plVaultAgeInfoInitializationTask( this, node );
|
||||
return nil;
|
||||
}
|
||||
|
||||
// SetAgeInfo ----------------------------------------------
|
||||
void pyAgeVNodeMgr::SetAgeInfo( const char * ageFilename, const char * ageInstanceGuid )
|
||||
{
|
||||
fAgeFilename = ageFilename;
|
||||
fAgeInstanceGuid.FromString( ageInstanceGuid );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyAdminVNodeMgr::pyAdminVNodeMgr( PyObject* thaComm )
|
||||
: pyVNodeMgr( thaComm )
|
||||
, fWantGlobalSDL( true )
|
||||
, fWantAllPlayers( false )
|
||||
{}
|
||||
|
||||
// IAmSuperUser ----------------------------------------------
|
||||
bool pyAdminVNodeMgr::IAmSuperUser( void ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// IFillOutConnectFields ----------------------------------------------
|
||||
void pyAdminVNodeMgr::IFillOutConnectFields( plNetMsgVault* msg ) const
|
||||
{
|
||||
msg->GetArgs()->AddInt( plVault::kArg_NodeMgrType, plVault::kNodeType_VNodeMgrAdmin );
|
||||
msg->GetArgs()->AddInt( plVault::kArg_NodeMgrID, fMyComm->GetNetClientComm()->GetPlayerID() );
|
||||
}
|
||||
|
||||
// IGetNodeInitializationTask ----------------------------------------------
|
||||
plVNodeInitTask * pyAdminVNodeMgr::IGetNodeInitializationTask( plVaultNode * node )
|
||||
{
|
||||
if ( plVaultAdminNode::ConvertNoRef( node ) )
|
||||
return new plVaultAdminInitializationTask( this, node, fWantGlobalSDL, fWantAllPlayers );
|
||||
return nil;
|
||||
}
|
||||
|
||||
// GetGlobalInbox ----------------------------------------------
|
||||
PyObject * pyAdminVNodeMgr::GetGlobalInbox() const
|
||||
{
|
||||
plVaultFolderNode tmp;
|
||||
tmp.SetFolderType( plVault::kGlobalInboxFolder );
|
||||
plVaultNode * node;
|
||||
if ( plVNodeMgr::FindNode( &tmp, node ) )
|
||||
{
|
||||
return pyVaultFolderNode::New( plVaultFolderNode::ConvertNoRef( node ) );
|
||||
}
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// End.
|
247
Sources/Plasma/PythonLib/pyVault/pyVNodeMgr.h
Normal file
247
Sources/Plasma/PythonLib/pyVault/pyVNodeMgr.h
Normal file
@ -0,0 +1,247 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// pyVNodeMgr - python wrapper for plVNodeMgr class.
|
||||
|
||||
#ifndef pyVNodeMgr_h_inc
|
||||
#define pyVNodeMgr_h_inc
|
||||
|
||||
#include "../plVault/plVaultClient.h"
|
||||
#include "../plNetClientComm/plNetClientComm.h"
|
||||
|
||||
#include "../FeatureLib/pfPython/pyGlueHelpers.h"
|
||||
#include <python.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class pyVaultNode;
|
||||
class pyVaultCallback;
|
||||
class pyStatusLog;
|
||||
class pyNetClientComm;
|
||||
class pyVaultFolderNode;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class pyVNodeMgr : public plVNodeMgr
|
||||
{
|
||||
private:
|
||||
typedef std::vector<pyVaultCallback*> PyCallbackVec;
|
||||
PyCallbackVec fPyCallbacks;
|
||||
|
||||
class VaultMsgHandler : public plNetClientComm::MsgHandler
|
||||
{
|
||||
private:
|
||||
pyVNodeMgr * fMyVNodeMgr;
|
||||
int HandleMessage( plNetMessage* msg );
|
||||
public:
|
||||
VaultMsgHandler(): fMyVNodeMgr(nil) {}
|
||||
void setMgr(pyVNodeMgr * thaNodeMgr) {fMyVNodeMgr = thaNodeMgr;}
|
||||
};
|
||||
friend class VaultMsgHandler;
|
||||
VaultMsgHandler fMsgHandler;
|
||||
|
||||
protected:
|
||||
PyObject* fMyCommObj;
|
||||
pyNetClientComm* fMyComm; // pointer to object stored in fMyCommObj
|
||||
|
||||
bool IAmOnline() const;
|
||||
bool IIsThisMe( plVaultPlayerInfoNode* node ) const;
|
||||
bool IIsThisMe( plVaultPlayerNode * node ) const;
|
||||
int ISendNetMsg( plNetMsgVault* msg, UInt32 sendFlags=0 );
|
||||
UInt32 IGetPlayerID() const;
|
||||
|
||||
pyVNodeMgr(): fMyComm(nil) {fMsgHandler.setMgr(this);} // for python glue only, do NOT call
|
||||
pyVNodeMgr( PyObject* thaComm );
|
||||
|
||||
public:
|
||||
~pyVNodeMgr();
|
||||
|
||||
void setMyComm(PyObject* thaComm); // for python glue only, do NOT call
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE;
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVNodeMgr);
|
||||
static PyObject* New(PyObject* thaComm);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVNodeMgr object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVNodeMgr); // converts a PyObject to a pyVNodeMgr (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject *m);
|
||||
|
||||
PyObject * GetNetClient() const { Py_INCREF(fMyCommObj); return fMyCommObj; } // returns pyNetClientComm
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Vault Client API
|
||||
|
||||
int Update( double secs );
|
||||
|
||||
void Startup();
|
||||
void Shutdown();
|
||||
|
||||
// connect/disconnect
|
||||
bool IsConnected();
|
||||
void Disconnect(
|
||||
PyObject* cb=nil,
|
||||
UInt32 cbContext=0 );
|
||||
void Connect(
|
||||
int childFetchLevel=plVault::kFetchAllChildren,
|
||||
PyObject* cb=nil,
|
||||
UInt32 cbContext=0 );
|
||||
// TODO: Glue this.
|
||||
// Fetch matching node from server and hold onto it.
|
||||
// Note: You won't receive notifications about the fetched node or
|
||||
// it's children until it has been added to your root node or any
|
||||
// of it's children.
|
||||
// bool FetchNode(
|
||||
// pyVaultNode* templateNode,
|
||||
// int childFetchLevel=plVault::kFetchAllChildren,
|
||||
// bool allowCreate = false,
|
||||
// PyObject* cb=nil,
|
||||
// UInt32 cbContext=0 );
|
||||
bool FetchNode( UInt32 nodeID,
|
||||
int childFetchLevel=plVault::kFetchAllChildren,
|
||||
PyObject* cb=nil,
|
||||
UInt32 cbContext=0 );
|
||||
|
||||
// get our root node
|
||||
PyObject* GetRootNode() const; // returns pyVaultNode
|
||||
// get the client node ID returned to us by the server ( if we didn't
|
||||
// fetch when we connected then we have to use this to identify ourselves ).
|
||||
UInt32 GetClientID() const;
|
||||
// search all nodes in client locally
|
||||
PyObject* GetNode( UInt32 id ) const; // returns pyVaultNode
|
||||
// TODO: Glue these.
|
||||
PyObject* FindNode( pyVaultNode* templateNode ) const; // returns pyVaultNode
|
||||
// bool FindNodes( const pyVaultNode* templateNode, PyObject * out ) const;
|
||||
// callback management
|
||||
bool EnableCallbacks( bool b ); // returns previous enabled setting.
|
||||
void AddCallback( PyObject* cb );
|
||||
void RemoveCallback( PyObject* cb );
|
||||
|
||||
// create a node of the given type.
|
||||
PyObject* CreateNode( int nodeType, bool persistent ); // returns pyVaultNode
|
||||
|
||||
// dump contents to log
|
||||
void Dump() const;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class pyPlayerVNodeMgr : public pyVNodeMgr
|
||||
{
|
||||
protected:
|
||||
bool IAmSuperUser( void ) const;
|
||||
void IFillOutConnectFields( plNetMsgVault* msg ) const;
|
||||
plVNodeInitTask * IGetNodeInitializationTask( plVaultNode * node );
|
||||
|
||||
pyPlayerVNodeMgr(): pyVNodeMgr() {} // for python glue only, do NOT call
|
||||
pyPlayerVNodeMgr( PyObject* thaComm );
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptPlayerVNodeMgr);
|
||||
static PyObject* New(PyObject* thaComm);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyPlayerVNodeMgr object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyPlayerVNodeMgr); // converts a PyObject to a pyPlayerVNodeMgr (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject *m);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class pyAgeVNodeMgr : public pyVNodeMgr
|
||||
{
|
||||
std::string fAgeFilename;
|
||||
plServerGuid fAgeInstanceGuid;
|
||||
|
||||
protected:
|
||||
bool IAmSuperUser( void ) const;
|
||||
void IFillOutConnectFields( plNetMsgVault* msg ) const;
|
||||
plVNodeInitTask * IGetNodeInitializationTask( plVaultNode * node );
|
||||
|
||||
pyAgeVNodeMgr(): pyVNodeMgr() {} // for python glue only, do NOT call
|
||||
pyAgeVNodeMgr( PyObject* thaComm );
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptAgeVNodeMgr);
|
||||
static PyObject* New(PyObject* thaComm);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeVNodeMgr object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeVNodeMgr); // converts a PyObject to a pyAgeVNodeMgr (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject *m);
|
||||
|
||||
void SetAgeInfo( const char * ageFilename, const char * ageInstanceGuid );
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class pyAdminVNodeMgr : public pyVNodeMgr
|
||||
{
|
||||
private:
|
||||
bool fWantGlobalSDL;
|
||||
bool fWantAllPlayers;
|
||||
|
||||
protected:
|
||||
bool IAmSuperUser( void ) const;
|
||||
void IFillOutConnectFields( plNetMsgVault* msg ) const;
|
||||
plVNodeInitTask * IGetNodeInitializationTask( plVaultNode * node );
|
||||
|
||||
pyAdminVNodeMgr(): pyVNodeMgr(), fWantGlobalSDL(true), fWantAllPlayers(false) {} // for python glue only, do NOT call
|
||||
pyAdminVNodeMgr( PyObject* thaComm );
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptAdminVNodeMgr);
|
||||
static PyObject* New(PyObject* thaComm);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAdminVNodeMgr object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAdminVNodeMgr); // converts a PyObject to a pyAdminVNodeMgr (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject *m);
|
||||
|
||||
void SetWantGlobalSDL( bool v ) { fWantGlobalSDL=v; }
|
||||
void SetWantAllPlayers( bool v ) { fWantAllPlayers=v; }
|
||||
|
||||
PyObject * GetGlobalInbox() const; // returns pyVaultFolderNode
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#endif // pyVNodeMgr_h_inc
|
477
Sources/Plasma/PythonLib/pyVault/pyVNodeMgrGlue.cpp
Normal file
477
Sources/Plasma/PythonLib/pyVault/pyVNodeMgrGlue.cpp
Normal file
@ -0,0 +1,477 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyVNodeMgr.h"
|
||||
#include "../FeatureLib/pfPython/pyVaultNode.h"
|
||||
#include "../pyNetClientComm/pyNetClientComm.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
// glue functions
|
||||
PYTHON_CLASS_DEFINITION(ptVNodeMgr, pyVNodeMgr);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVNodeMgr, pyVNodeMgr)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVNodeMgr)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVNodeMgr)
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, update, args)
|
||||
{
|
||||
double secs;
|
||||
if (!PyArg_ParseTuple(args, "d", &secs))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "update expects a double");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
return PyInt_FromLong(self->fThis->Update(secs));
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptVNodeMgr, startup, Startup)
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptVNodeMgr, shutdown, Shutdown)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVNodeMgr, isConnected)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->IsConnected());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, disconnect, args)
|
||||
{
|
||||
PyObject* cb = NULL;
|
||||
unsigned long context = 0;
|
||||
if (!PyArg_ParseTuple(args, "|Ol", &cb, &context))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "disconnect expects an optional object, and an optional unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->Disconnect(cb, context);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, connect, args)
|
||||
{
|
||||
int childFetchLevel = -1;
|
||||
PyObject* cb = NULL;
|
||||
unsigned long context = 0;
|
||||
if (!PyArg_ParseTuple(args, "|iOl", &childFetchLevel, &cb, &context))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "connect expects an optional int, an optional object, and an optional unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->Connect(childFetchLevel, cb, context);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, fetchNode, args)
|
||||
{
|
||||
unsigned long nodeID;
|
||||
int childFetchLevel = -1;
|
||||
PyObject* cb = NULL;
|
||||
unsigned long context = 0;
|
||||
if (!PyArg_ParseTuple(args, "l|iOl", &nodeID, &childFetchLevel, &cb, &context))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "fetchNode expects an unsigned long, an optional int, an optional object, and an optional unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
PYTHON_RETURN_BOOL(self->fThis->FetchNode(nodeID, childFetchLevel, cb, context));
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVNodeMgr, getRootNode)
|
||||
{
|
||||
return self->fThis->GetRootNode();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVNodeMgr, getClientID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->GetClientID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, getNode, args)
|
||||
{
|
||||
unsigned long nodeID;
|
||||
if (!PyArg_ParseTuple(args, "l", &nodeID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "getNode expects an unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
return self->fThis->GetNode(nodeID);
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, findNode, args)
|
||||
{
|
||||
PyObject* templateObj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &templateObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "findNode expects a ptVaultNode");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyVaultNode::Check(templateObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "findNode expects a ptVaultNode");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyVaultNode* templateNode = pyVaultNode::ConvertFrom(templateObj);
|
||||
return self->fThis->FindNode(templateNode);
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, enableCallbacks, args)
|
||||
{
|
||||
char enable;
|
||||
if (!PyArg_ParseTuple(args, "b", &enable))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "enableCallbacks expects a boolean");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
PYTHON_RETURN_BOOL(self->fThis->EnableCallbacks(enable != 0));
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, addCallback, args)
|
||||
{
|
||||
PyObject* cb = NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &cb))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "addCallback expects an object");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->AddCallback(cb);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, removeCallback, args)
|
||||
{
|
||||
PyObject* cb = NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &cb))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "removeCallback expects an object");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->RemoveCallback(cb);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVNodeMgr, createNode, args)
|
||||
{
|
||||
int nodeType;
|
||||
bool persistent;
|
||||
if (!PyArg_ParseTuple(args, "ib", &nodeType, &persistent))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "createNode expects an int and a boolean");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
return self->fThis->CreateNode(nodeType, persistent != 0);
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVNodeMgr, getNetClient)
|
||||
{
|
||||
return self->fThis->GetNetClient();
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptVNodeMgr, dump, Dump)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVNodeMgr)
|
||||
PYTHON_METHOD(ptVNodeMgr, update, "Params: secs\nUNKNOWN"),
|
||||
PYTHON_BASIC_METHOD(ptVNodeMgr, startup, "UNKNOWN"),
|
||||
PYTHON_BASIC_METHOD(ptVNodeMgr, shutdown, "UNKNOWN"),
|
||||
PYTHON_METHOD_NOARGS(ptVNodeMgr, isConnected, "Are we connected to the vault?"),
|
||||
PYTHON_METHOD(ptVNodeMgr, disconnect, "Params: callback=None,cbContext=0\nDisconnects us from the vault"),
|
||||
PYTHON_METHOD(ptVNodeMgr, connect, "Params: childFetchLevel=-1,callback=None,cbContext=0\nConnects us ti the vault"),
|
||||
PYTHON_METHOD(ptVNodeMgr, fetchNode, "Params: nodeID,childFetchLevel=-1,callback=None,cbContext=0\nFetchs the specified node"),
|
||||
PYTHON_METHOD_NOARGS(ptVNodeMgr, getRootNode, "Returns the root node"),
|
||||
PYTHON_METHOD_NOARGS(ptVNodeMgr, getClientID, "Returns the client ID number"),
|
||||
PYTHON_METHOD(ptVNodeMgr, getNode, "Params: nodeID\nReturns the specified node"),
|
||||
PYTHON_METHOD(ptVNodeMgr, findNode, "Params: templateNode\nLocates a node matching the template"),
|
||||
PYTHON_METHOD(ptVNodeMgr, enableCallbacks, "Params: enable\nEnable/disable callbacks"),
|
||||
PYTHON_METHOD(ptVNodeMgr, addCallback, "Params: callback\nUNKNOWN"),
|
||||
PYTHON_METHOD(ptVNodeMgr, removeCallback, "Params: callback\nUNKNOWN"),
|
||||
PYTHON_METHOD(ptVNodeMgr, createNode, "Params: nodeType,persistent\nCreates a new node"),
|
||||
PYTHON_METHOD(ptVNodeMgr, getNetClient, "Returns our internal ptNetClientComm"),
|
||||
PYTHON_BASIC_METHOD(ptVNodeMgr, dump, "Dump contents to our log"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE(ptVNodeMgr, "UNKNOWN");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptVNodeMgr, pyVNodeMgr);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject *pyVNodeMgr::New(PyObject* thaComm)
|
||||
{
|
||||
ptVNodeMgr *newObj = (ptVNodeMgr*)ptVNodeMgr_type.tp_new(&ptVNodeMgr_type, NULL, NULL);
|
||||
if (!pyNetClientComm::Check(thaComm))
|
||||
{
|
||||
Py_DECREF(newObj);
|
||||
return NULL; // bad parameter
|
||||
}
|
||||
newObj->fThis->setMyComm(thaComm);
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVNodeMgr, pyVNodeMgr)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVNodeMgr, pyVNodeMgr)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AddPlasmaClasses - the python module definitions
|
||||
//
|
||||
void pyVNodeMgr::AddPlasmaClasses(PyObject *m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVNodeMgr);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// glue functions
|
||||
PYTHON_CLASS_DEFINITION(ptPlayerVNodeMgr, pyPlayerVNodeMgr);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptPlayerVNodeMgr, pyPlayerVNodeMgr)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptPlayerVNodeMgr)
|
||||
|
||||
PYTHON_INIT_DEFINITION(ptPlayerVNodeMgr, args, keywords)
|
||||
{
|
||||
PyObject* netClientComm = NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &netClientComm))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__init__ expects a ptNetClientComm");
|
||||
PYTHON_RETURN_INIT_ERROR;
|
||||
}
|
||||
if (!pyNetClientComm::Check(netClientComm))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__init__ expects a ptNetClientComm");
|
||||
PYTHON_RETURN_INIT_ERROR;
|
||||
}
|
||||
self->fThis->setMyComm(netClientComm);
|
||||
PYTHON_RETURN_INIT_OK;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptPlayerVNodeMgr)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptPlayerVNodeMgr, pyVNodeMgr, "UNKNOWN");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject *pyPlayerVNodeMgr::New(PyObject* thaComm)
|
||||
{
|
||||
ptPlayerVNodeMgr *newObj = (ptPlayerVNodeMgr*)ptPlayerVNodeMgr_type.tp_new(&ptPlayerVNodeMgr_type, NULL, NULL);
|
||||
if (!pyNetClientComm::Check(thaComm))
|
||||
{
|
||||
Py_DECREF(newObj);
|
||||
return NULL; // bad parameter
|
||||
}
|
||||
newObj->fThis->setMyComm(thaComm);
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptPlayerVNodeMgr, pyPlayerVNodeMgr)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptPlayerVNodeMgr, pyPlayerVNodeMgr)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AddPlasmaClasses - the python module definitions
|
||||
//
|
||||
void pyPlayerVNodeMgr::AddPlasmaClasses(PyObject *m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptPlayerVNodeMgr);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// glue functions
|
||||
PYTHON_CLASS_DEFINITION(ptAgeVNodeMgr, pyAgeVNodeMgr);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeVNodeMgr, pyAgeVNodeMgr)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeVNodeMgr)
|
||||
|
||||
PYTHON_INIT_DEFINITION(ptAgeVNodeMgr, args, keywords)
|
||||
{
|
||||
PyObject* netClientComm = NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &netClientComm))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__init__ expects a ptNetClientComm");
|
||||
PYTHON_RETURN_INIT_ERROR;
|
||||
}
|
||||
if (!pyNetClientComm::Check(netClientComm))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__init__ expects a ptNetClientComm");
|
||||
PYTHON_RETURN_INIT_ERROR;
|
||||
}
|
||||
self->fThis->setMyComm(netClientComm);
|
||||
PYTHON_RETURN_INIT_OK;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptAgeVNodeMgr, setAgeInfo, args)
|
||||
{
|
||||
char* filename;
|
||||
char* guid;
|
||||
if (!PyArg_ParseTuple(args, "ss", &filename, &guid))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->SetAgeInfo(filename, guid);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptAgeVNodeMgr)
|
||||
PYTHON_METHOD(ptAgeVNodeMgr, setAgeInfo, "Params: filename,guid\nUNKNOWN"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptAgeVNodeMgr, pyVNodeMgr, "UNKNOWN");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject *pyAgeVNodeMgr::New(PyObject* thaComm)
|
||||
{
|
||||
ptAgeVNodeMgr *newObj = (ptAgeVNodeMgr*)ptAgeVNodeMgr_type.tp_new(&ptAgeVNodeMgr_type, NULL, NULL);
|
||||
if (!pyNetClientComm::Check(thaComm))
|
||||
{
|
||||
Py_DECREF(newObj);
|
||||
return NULL; // bad parameter
|
||||
}
|
||||
newObj->fThis->setMyComm(thaComm);
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptAgeVNodeMgr, pyAgeVNodeMgr)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeVNodeMgr, pyAgeVNodeMgr)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AddPlasmaClasses - the python module definitions
|
||||
//
|
||||
void pyAgeVNodeMgr::AddPlasmaClasses(PyObject *m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptAgeVNodeMgr);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// glue functions
|
||||
PYTHON_CLASS_DEFINITION(ptAdminVNodeMgr, pyAdminVNodeMgr);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptAdminVNodeMgr, pyAdminVNodeMgr)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAdminVNodeMgr)
|
||||
|
||||
PYTHON_INIT_DEFINITION(ptAdminVNodeMgr, args, keywords)
|
||||
{
|
||||
PyObject* netClientComm = NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &netClientComm))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__init__ expects a ptNetClientComm");
|
||||
PYTHON_RETURN_INIT_ERROR;
|
||||
}
|
||||
if (!pyNetClientComm::Check(netClientComm))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__init__ expects a ptNetClientComm");
|
||||
PYTHON_RETURN_INIT_ERROR;
|
||||
}
|
||||
self->fThis->setMyComm(netClientComm);
|
||||
PYTHON_RETURN_INIT_OK;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptAdminVNodeMgr, setWantGlobalSDL, args)
|
||||
{
|
||||
bool flag;
|
||||
if (!PyArg_ParseTuple(args, "b", &flag))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setWantGlobalSDL expects a boolean");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->SetWantGlobalSDL(flag != 0);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptAdminVNodeMgr, setWantAllPlayers, args)
|
||||
{
|
||||
bool flag;
|
||||
if (!PyArg_ParseTuple(args, "b", &flag))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setWantAllPlayers expects a boolean");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->SetWantAllPlayers(flag != 0);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptAdminVNodeMgr, getGlobalInbox)
|
||||
{
|
||||
return self->fThis->GetGlobalInbox();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptAdminVNodeMgr)
|
||||
PYTHON_METHOD(ptAdminVNodeMgr, setWantGlobalSDL, "Params: flag\nUNKNOWN"),
|
||||
PYTHON_METHOD(ptAdminVNodeMgr, setWantAllPlayers, "Params: flag\nUNKNOWN"),
|
||||
PYTHON_METHOD_NOARGS(ptAdminVNodeMgr, getGlobalInbox, "UNKNOWN"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptAdminVNodeMgr, pyVNodeMgr, "UNKNOWN");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject *pyAdminVNodeMgr::New(PyObject* thaComm)
|
||||
{
|
||||
ptAdminVNodeMgr *newObj = (ptAdminVNodeMgr*)ptAdminVNodeMgr_type.tp_new(&ptAdminVNodeMgr_type, NULL, NULL);
|
||||
if (!pyNetClientComm::Check(thaComm))
|
||||
{
|
||||
Py_DECREF(newObj);
|
||||
return NULL; // bad parameter
|
||||
}
|
||||
newObj->fThis->setMyComm(thaComm);
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptAdminVNodeMgr, pyAdminVNodeMgr)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAdminVNodeMgr, pyAdminVNodeMgr)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AddPlasmaClasses - the python module definitions
|
||||
//
|
||||
void pyAdminVNodeMgr::AddPlasmaClasses(PyObject *m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptAdminVNodeMgr);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
Reference in New Issue
Block a user