EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Voucher.cpp
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Allan
24 */
25 
26 #include "eve-server.h"
27 
28 #include "PyServiceCD.h"
29 #include "inventory/Voucher.h"
30 #include "system/BookmarkDB.h"
31 
33 
35 : PyService(mgr, "voucher"),
36  m_dispatch(new Dispatcher(this))
37 {
38  _SetCallDispatcher(m_dispatch);
39 
41 }
42 
44  delete m_dispatch;
45 }
46 
47 PyResult VoucherService::Handle_GetObject( PyCallArgs& call ) {
55  //call.Dump(BOOKMARK__CALL_DUMP);
56  // return none for now, to allow client to use default name of 'bookmark'
57  //return PyStatic.NewNone();
58 
59  PyDict* dict = new PyDict();
60  Call_SingleIntegerArg arg;
61  if (!arg.Decode(&call.tuple)) {
62  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
63  return dict;
64  }
65  InventoryItemRef iRef = sItemFactory.GetItem(arg.arg);
66  if (iRef.get() == nullptr) {
67  codelog(ITEM__ERROR, "%s: Failed to retrieve bookmark voucher for bmID %u", call.client->GetName(), arg.arg);
68  return dict;
69  }
70 
71  // this is how i return objects for method chaining
72  //we just bind up a new voucher object for item requested and give it back to them.
73  VoucherBound *vb = new VoucherBound(m_manager, iRef);
74  return m_manager->BindObject(call.client, vb );
75 }
76 
77 
79 
81 : PyBoundObject(mgr),
82 m_dispatch(new Dispatcher(this))
83 {
84  _SetCallDispatcher(m_dispatch);
85 
86  m_strBoundObjectName = "VoucherBound";
87 
88  m_itemRef = itemRef;
89 
90  PyCallable_REG_CALL(VoucherBound, GetDescription);
91 }
92 
94 {
95  delete m_dispatch;
96 }
97 
98 PyResult VoucherBound::Handle_GetDescription(PyCallArgs &call) {
99  // name = voucher.GetDescription()
100 
101  // get bookmark name (memo) as stored in db. item.customInfo is bookmarkID this item is copied from
102  return new PyString(BookmarkDB::GetBookmarkName(atoi(m_itemRef->customInfo().c_str())));
103 }
Dispatcher *const m_dispatch
virtual ~VoucherBound()
Definition: Voucher.cpp:93
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
const std::string & customInfo() const
virtual ~VoucherService()
Definition: Voucher.cpp:43
const char * GetName() const
Definition: PyService.h:54
Dispatcher *const m_dispatch
Definition: Voucher.h:39
static const char * GetBookmarkName(uint32 bookmarkID)
Definition: BookmarkDB.cpp:165
#define codelog(type, fmt,...)
Definition: logsys.h:128
InventoryItemRef m_itemRef
Definition: Voucher.h:69
PyCallable_Make_InnerDispatcher(VoucherService) VoucherService
Definition: Voucher.cpp:32
PyServiceMgr *const m_manager
Definition: PyService.h:91
X * get() const
Definition: RefPtr.h:213
const char * GetName() const
Definition: Client.h:94
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
PySubStruct * BindObject(Client *pClient, PyBoundObject *pObj, PyDict *dict=nullptr, PyDict *oid=nullptr)
Dispatcher *const m_dispatch
Definition: Voucher.h:64
#define sItemFactory
Definition: ItemFactory.h:165
PyTuple * tuple
Definition: PyCallable.h:50