/*==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 . 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==*/ ////////////////////////////////////////////////////////////////////// // // pyAgeVault - a wrapper class to provide interface to the plVaultAgeNode // ////////////////////////////////////////////////////////////////////// #include #include "pnNetCommon/plNetApp.h" #pragma hdrstop #include "pyAgeVault.h" #include "pyVault.h" #include "pyVaultNodeRef.h" #include "pyVaultFolderNode.h" #include "pyVaultPlayerInfoListNode.h" #include "pyVaultPlayerInfoNode.h" #include "pyVaultAgeInfoNode.h" #include "pyVaultAgeLinkNode.h" #include "pyVaultChronicleNode.h" #include "pyVaultTextNoteNode.h" #include "pyNetLinkingMgr.h" #include "pyAgeInfoStruct.h" #include "pySDL.h" #include "plVault/plVault.h" #include "plNetClient/plNetClientMgr.h" #include "plNetClient/plNetLinkingMgr.h" #include "plNetTransport/plNetTransport.h" #include "plNetTransport/plNetTransportMember.h" #include "plSDL/plSDL.h" pyAgeVault::pyAgeVault() { } pyAgeVault::~pyAgeVault() { } ////////////////////////////////////////////////// PyObject* pyAgeVault::GetAgeInfo() { hsRef rvn = VaultGetAgeInfoNode(); if (rvn) return pyVaultAgeInfoNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } PyObject* pyAgeVault::GetAgeDevicesFolder( void ) { hsRef rvn = VaultGetAgeDevicesFolder(); if (rvn) return pyVaultFolderNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } PyObject* pyAgeVault::GetSubAgesFolder( void ) { hsRef rvn = VaultGetAgeSubAgesFolder(); if (rvn) return pyVaultFolderNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } PyObject* pyAgeVault::GetChronicleFolder( void ) { hsRef rvn = VaultGetAgeChronicleFolder(); if (rvn) return pyVaultFolderNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } PyObject* pyAgeVault::GetBookshelfFolder ( void ) { hsRef rvn = VaultAgeGetBookshelfFolder(); if (rvn) return pyVaultFolderNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } PyObject* pyAgeVault::GetPeopleIKnowAboutFolder( void ) { hsRef rvn = VaultGetAgePeopleIKnowAboutFolder(); if (rvn) return pyVaultFolderNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } PyObject* pyAgeVault::GetPublicAgesFolder(void) { hsRef rvn = VaultGetAgePublicAgesFolder(); if (rvn) return pyVaultFolderNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } PyObject* pyAgeVault::GetSubAgeLink( const pyAgeInfoStruct & info ) { hsRef rvn = VaultFindAgeSubAgeLink(info.GetAgeInfo()); if (rvn) return pyVaultAgeLinkNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } plUUID pyAgeVault::GetAgeGuid( void ) { hsRef rvn = VaultGetAgeInfoNode(); if (rvn) { VaultAgeInfoNode ageInfo(rvn); return ageInfo.GetAgeInstanceGuid(); } return kNilUuid; } /////////////// // Chronicle PyObject* pyAgeVault::FindChronicleEntry( const plString& entryName ) { if (hsRef rvn = VaultFindAgeChronicleEntry(entryName)) return pyVaultChronicleNode::New(rvn); // just return a None object PYTHON_RETURN_NONE; } void pyAgeVault::AddChronicleEntry( const plString& name, uint32_t type, const plString& value ) { VaultAddAgeChronicleEntry(name, type, value); } // AGE DEVICES. AKA IMAGERS, WHATEVER. // Add a new device. void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, uint32_t cbContext ) { pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); cb->VaultOperationStarted( cbContext ); if (hsRef rvn = VaultAgeAddDeviceAndWait(deviceName)) cb->SetNode(rvn); cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here. } // Remove a device. void pyAgeVault::RemoveDevice( const char * deviceName ) { VaultAgeRemoveDevice(deviceName); } // True if device exists in age. bool pyAgeVault::HasDevice( const char * deviceName ) { return VaultAgeHasDevice(deviceName); } PyObject * pyAgeVault::GetDevice( const char * deviceName ) { if (hsRef rvn = VaultAgeGetDevice(deviceName)) return pyVaultTextNoteNode::New(rvn); PYTHON_RETURN_NONE; } // Sets the inbox associated with a device. void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName, PyObject * cbObject, uint32_t cbContext ) { pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); cb->VaultOperationStarted( cbContext ); if (hsRef rvn = VaultAgeSetDeviceInboxAndWait(deviceName, inboxName)) cb->SetNode(rvn); cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here. } PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName ) { if (hsRef rvn = VaultAgeGetDeviceInbox(deviceName)) return pyVaultTextNoteNode::New(rvn); PYTHON_RETURN_NONE; } PyObject * pyAgeVault::GetAgeSDL() const { plStateDataRecord * rec = new plStateDataRecord; if (!VaultAgeGetAgeSDL(rec)) { delete rec; PYTHON_RETURN_NONE; } else { return pySDLStateDataRecord::New( rec ); } } void pyAgeVault::UpdateAgeSDL( pySDLStateDataRecord & pyrec ) { plStateDataRecord * rec = pyrec.GetRec(); if ( !rec ) return; VaultAgeUpdateAgeSDL(rec); } PyObject* pyAgeVault::FindNode( pyVaultNode* templateNode ) const { if (hsRef rvn = VaultGetAgeNode()) { hsRef find = rvn->GetChildNode(templateNode->fNode, 1); if (find) return pyVaultNode::New(find); } PYTHON_RETURN_NONE; }