EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CorpMgrService.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: Zhur
24  Rewrite: Allan
25 */
26 
27 #include <string>
28 #include "eve-server.h"
29 
30 #include "PyServiceCD.h"
32 
34 
36 : PyService(mgr, "corpmgr"),
37  m_dispatch(new Dispatcher(this))
38 {
39  _SetCallDispatcher(m_dispatch);
40 
41  PyCallable_REG_CALL(CorpMgrService, GetPublicInfo);
42  PyCallable_REG_CALL(CorpMgrService, GetCorporations);
43  PyCallable_REG_CALL(CorpMgrService, GetAssetInventory);
44  PyCallable_REG_CALL(CorpMgrService, GetCorporationStations);
45  PyCallable_REG_CALL(CorpMgrService, GetCorporationIDForCharacter);
46  PyCallable_REG_CALL(CorpMgrService, GetAssetInventoryForLocation);
47  PyCallable_REG_CALL(CorpMgrService, SearchAssets);
48  PyCallable_REG_CALL(CorpMgrService, AuditMember);
49 }
50 
52  delete m_dispatch;
53 }
54 
55 
56 /*
57  * CORP__ERROR
58  * CORP__WARNING
59  * CORP__INFO
60  * CORP__MESSAGE
61  * CORP__TRACE
62  * CORP__CALL
63  * CORP__CALL_DUMP
64  * CORP__RSP_DUMP
65  * CORP__DB_ERROR
66  * CORP__DB_WARNING
67  * CORP__DB_INFO
68  * CORP__DB_MESSAGE
69  */
70 
71 
72 PyResult CorpMgrService::Handle_GetPublicInfo(PyCallArgs &call) {
73  Call_SingleIntegerArg arg;
74  if (!arg.Decode(&call.tuple)) {
75  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
76  return nullptr;
77  }
78 
79  return m_db.GetCorpInfo(arg.arg);
80 }
81 
82 PyResult CorpMgrService::Handle_GetCorporations(PyCallArgs &call) {
83  // called by non-member
84  Call_SingleIntegerArg arg;
85  if (!arg.Decode(&call.tuple)) {
86  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
87  return nullptr;
88  }
89 
90  return m_db.GetCorporations(arg.arg);
91 }
92 
93 PyResult CorpMgrService::Handle_GetCorporationIDForCharacter(PyCallArgs &call) {
94  Call_SingleIntegerArg arg;
95  if (!arg.Decode(&call.tuple)) {
96  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
97  return nullptr;
98  }
99 
100  return new PyInt(m_db.GetCorpIDforChar(arg.arg));
101 }
102 
103 PyResult CorpMgrService::Handle_AuditMember(PyCallArgs &call) {
104  // logItemEventRows, crpRoleHistroyRows = sm.RemoteSvc('corpmgr').AuditMember(memberID, fromDate, toDate, rowsPerPage)
105 
106  _log(CORP__CALL, "CorpMgrService::Handle_AuditMember()");
107  call.Dump(CORP__CALL_DUMP);
108 
109  Call_AuditMember args;
110  if (!args.Decode(&call.tuple)) {
111  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
112  return nullptr;
113  }
114 
115  PyTuple* tuple = new PyTuple(2);
116  tuple->SetItem(0, m_db.GetItemEvents(call.client->GetCorporationID(), args.charID, args.fromDate, args.toDate, args.rowsPerPage));
117  tuple->SetItem(1, m_db.GetRoleHistroy(call.client->GetCorporationID(), args.charID, args.fromDate, args.toDate, args.rowsPerPage));
118 
119  if (is_log_enabled(CORP__RSP_DUMP))
120  tuple->Dump(CORP__RSP_DUMP, " ");
121 
122  return tuple;
123 }
124 
125 PyResult CorpMgrService::Handle_GetAssetInventory(PyCallArgs &call) {
126  // rows = sm.RemoteSvc('corpmgr').GetAssetInventory(eve.session.corpid, which)
127  // this is called from corp asset screen. wants a return of locationIDs of stations where corp hangers have items
128  _log(CORP__CALL, "CorpMgrService::Handle_GetAssetInventory()");
129  call.Dump(CORP__CALL_DUMP);
130 
131  Call_GetAssetInventory args;
132  if (!args.Decode(&call.tuple)) {
133  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
134  return nullptr;
135  }
136 
137  EVEItemFlags locFlag = flagNone;
138  std::ostringstream flags;
139  flags << "(";
140  if (args.flag.compare("offices") == 0) {
141  locFlag = flagOffice;
142  flags << flagHangar << "," << flagCorpHangar2 << "," << flagCorpHangar3 << "," << flagCorpHangar4 << "," << flagCorpHangar5;
143  flags << "," << flagCorpHangar6 << "," << flagCorpHangar7;
144  } else if (args.flag.compare("junk") == 0) { // this is 'impounded' tab for all locations
145  locFlag = flagImpounded;
146  flags << flagImpounded;
147  } else if (args.flag.compare("property") == 0) { // this is 'inSpace' tab...LSC, ALSC, POS, etc
148  locFlag = flagProperty;
149  flags << flagHangar << "," << flagCorpHangar2 << "," << flagCorpHangar3 << "," << flagCorpHangar4 << "," << flagCorpHangar5;
150  flags << "," << flagCorpHangar6 << "," << flagCorpHangar7;
151  } else if (args.flag.compare("deliveries") == 0) {
152  locFlag = flagCorpMarket;
153  flags << flagCorpMarket;
154  } else {
155  _log(CORP__ERROR, "CorpMgrService::Handle_GetAssetInventory: flag is %s", args.flag.c_str());
156  return nullptr;
157  }
158 
159  flags << ")";
160 
161  PyRep* rsp = m_db.GetAssetInventory(args.corpID, locFlag, flags.str().c_str());
162  if (is_log_enabled(CORP__RSP_DUMP))
163  rsp->Dump(CORP__RSP_DUMP, " ");
164 
165  // returns a CRowSet
166  return rsp;
167 }
168 
169 PyResult CorpMgrService::Handle_GetAssetInventoryForLocation(PyCallArgs &call) {
170  // items = sm.RemoteSvc('corpmgr').GetAssetInventoryForLocation(eve.session.corpid, stationID, which)
171  _log(CORP__CALL, "CorpMgrService::Handle_GetAssetInventoryForLocation()");
172  call.Dump(CORP__CALL_DUMP);
173 
174  Call_GetAssetInventoryForLocation args;
175  if (!args.Decode(&call.tuple)) {
176  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
177  return nullptr;
178  }
179 
180  EVEItemFlags locFlag = flagNone;
181  std::ostringstream flags;
182  flags << "(";
183  if (args.flag.compare("offices") == 0) {
184  locFlag = flagOffice;
185  flags << flagHangar << "," << flagCorpHangar2 << "," << flagCorpHangar3 << "," << flagCorpHangar4 << "," << flagCorpHangar5;
186  flags << "," << flagCorpHangar6 << "," << flagCorpHangar7;
187  } else if (args.flag.compare("junk") == 0) {
188  locFlag = flagImpounded;
189  flags << flagImpounded;
190  } else if (args.flag.compare("property") == 0) { // this is 'inSpace' tab...LSC, POS, etc
191  locFlag = flagProperty;
192  flags << flagHangar << "," << flagCorpHangar2 << "," << flagCorpHangar3 << "," << flagCorpHangar4 << "," << flagCorpHangar5;
193  flags << "," << flagCorpHangar6 << "," << flagCorpHangar7;
194  } else if (args.flag.compare("deliveries") == 0) {
195  locFlag = flagCorpMarket;
196  flags << flagCorpMarket;
197  } else {
198  _log(CORP__ERROR, "CorpMgrService::Handle_GetAssetInventory: flag is %s", args.flag.c_str());
199  return nullptr;
200  }
201 
202  flags << ")";
203  // returns a CRowSet
204  // this can be called on system/station/office that isnt loaded, so must hit db for info.
205  return m_db.GetAssetInventoryForLocation(args.corpID, args.locationID, flags.str().c_str());
206 }
207 
208 // this is called for corp trade
209 PyResult CorpMgrService::Handle_GetCorporationStations(PyCallArgs &call) {
218  _log(CORP__CALL, "CorpMgrService::Handle_GetCorporationStations()");
219  call.Dump(CORP__CALL_DUMP);
220 
221  if (IsPlayerCorp(call.client->GetCorporationID()))
222  return m_db.Fetch(call.client->GetCorporationID(), 0, 50); // arbitrary values
223 
224  _log(CORP__WARNING, "CorpMgrService::Handle_GetCorporationStations() calling for NPC Corp");
225  return nullptr;
226 }
227 
228 
229 PyResult CorpMgrService::Handle_SearchAssets(PyCallArgs &call) {
230  // rows = sm.RemoteSvc('corpmgr').SearchAssets(which, itemCategoryID, itemGroupID, itemTypeID, qty)
231  // 'which' is a filter type or None
232  _log(CORP__CALL, "CorpMgrService::Handle_SearchAssets()");
233  call.Dump(CORP__CALL_DUMP);
234 
235  return nullptr;
236 }
PyRep * Fetch(uint32 corpID, uint32 from, uint32 count)
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
CorporationDB m_db
PyRep * GetCorporations(uint32 corpID)
PyRep * GetCorpInfo(uint32 corpID)
#define _log(type, fmt,...)
Definition: logsys.h:124
EVEItemFlags
Definition: EVE_Flags.h:13
int32 GetCorporationID() const
Definition: Client.h:123
Python tuple.
Definition: PyRep.h:567
const char * GetName() const
Definition: PyService.h:54
int32 GetCorpIDforChar(int32 charID)
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
* args
#define is_log_enabled(type)
Definition: logsys.h:78
PyRep * GetAssetInventoryForLocation(uint32 corpID, uint32 locationID, const char *flags)
#define codelog(type, fmt,...)
Definition: logsys.h:128
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
Python integer.
Definition: PyRep.h:231
PyRep * GetRoleHistroy(uint32 corpID, uint32 charID, int64 fromDate, int64 toDate, uint8 rowsPerPage)
#define IsPlayerCorp(itemID)
Definition: EVE_Defines.h:241
virtual ~CorpMgrService()
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
PyRep * GetAssetInventory(uint32 corpID, EVEItemFlags locFlag, const char *flags)
PyRep * GetItemEvents(uint32 corpID, uint32 charID, int64 fromDate, int64 toDate, uint8 rowsPerPage)
void Dump(LogType type) const
Definition: PyCallable.cpp:81
PyCallable_Make_InnerDispatcher(CorpMgrService) CorpMgrService
Dispatcher *const m_dispatch
PyTuple * tuple
Definition: PyCallable.h:50