EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BillMgr.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 "eve-server.h"
28 
29 #include "PyServiceCD.h"
30 #include "StaticDataMgr.h"
31 #include "cache/ObjCacheService.h"
32 #include "corporation/BillMgr.h"
33 
35 
37 : PyService(mgr, "billMgr"),
38  m_dispatch(new Dispatcher(this)) {
39  _SetCallDispatcher(m_dispatch);
40 
41  PyCallable_REG_CALL(BillMgr, CharPayBill);
42  PyCallable_REG_CALL(BillMgr, CharGetBills);
43  PyCallable_REG_CALL(BillMgr, CharGetBillsReceivable);
44  PyCallable_REG_CALL(BillMgr, GetBillTypes);
45  PyCallable_REG_CALL(BillMgr, PayCorporationBill);
46  PyCallable_REG_CALL(BillMgr, GetCorporationBills);
47  PyCallable_REG_CALL(BillMgr, GetCorporationBillsReceivable);
48  PyCallable_REG_CALL(BillMgr, GetAutomaticPaySettings);
49  PyCallable_REG_CALL(BillMgr, SendAutomaticPaySettings);
50 }
51 
53  delete m_dispatch;
54 }
55 
56 PyResult BillMgr::Handle_GetBillTypes(PyCallArgs& call) {
57  return sDataMgr.GetBillTypes();
58 }
59 
60 PyResult BillMgr::Handle_GetCorporationBills(PyCallArgs &call) {
61  return m_db.GetCorporationBills(call.client->GetCorporationID(), true);
62 }
63 
64 PyResult BillMgr::Handle_GetCorporationBillsReceivable(PyCallArgs &call) {
65  return m_db.GetCorporationBills(call.client->GetCorporationID(), false);
66 }
67 
68 
69 PyResult BillMgr::Handle_CharPayBill(PyCallArgs &call) {
70  // sm.RemoteSvc('billMgr').CharPayBill(bill.billID)
71  sLog.Warning("BillMgr", "Handle_CharPayBill() size=%u", call.tuple->size() );
72  call.Dump(CORP__CALL_DUMP);
73 
74  // returns nothing
75  return nullptr;
76 }
77 
78 PyResult BillMgr::Handle_CharGetBills(PyCallArgs &call) {
79  // return sm.RemoteSvc('billMgr').CharGetBills()
80  sLog.Warning("BillMgr", "Handle_CharGetBills() size=%u", call.tuple->size() );
81  call.Dump(CORP__CALL_DUMP);
82 
83  // returns nothing
84  return nullptr;
85 }
86 
87 PyResult BillMgr::Handle_CharGetBillsReceivable(PyCallArgs &call) {
88  // bills = sm.RemoteSvc('billMgr').CharGetBillsReceivable()
89  sLog.Warning("BillMgr", "Handle_CharGetBillsReceivable() size=%u", call.tuple->size() );
90  call.Dump(CORP__CALL_DUMP);
91 
92  // returns nothing
93  return nullptr;
94 }
95 
96 PyResult BillMgr::Handle_PayCorporationBill(PyCallArgs &call) {
97  // sm.RemoteSvc('billMgr').PayCorporationBill(bill.billID, fromAccountKey=eve.session.corpAccountKey)
98  sLog.Warning("BillMgr", "Handle_PayCorporationBill() size=%u", call.tuple->size() );
99  call.Dump(CORP__CALL_DUMP);
100 
101  // returns nothing
102  return nullptr;
103 }
104 
105 
106 PyResult BillMgr::Handle_SendAutomaticPaySettings(PyCallArgs &call) {
107  // sm.RemoteSvc('billMgr').SendAutomaticPaySettings(self.automaticPaymentSettings)
108 
109  // if corp in alliance, get settings for all 6, else ignore AllianceMaintainanceBill (5)
110 
111  /*
112  * 19:07:55 [CorpCallDump] Call Arguments:
113  * 19:07:55 [CorpCallDump] Tuple: 1 elements
114  * 19:07:55 [CorpCallDump] [ 0] Dictionary: 1 entries
115  * 19:07:55 [CorpCallDump] [ 0] [ 0] Key: Integer: 98000001
116  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: Dictionary: 6 entries
117  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 0] Key: Integer: 6
118  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 0] Value: Boolean: false
119  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 1] Key: Integer: 4
120  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 1] Value: Boolean: true
121  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 2] Key: String: 'divisionID' << wallet to use
122  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 2] Value: Integer: 1003
123  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 3] Key: Integer: 3
124  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 3] Value: Boolean: true
125  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 4] Key: Integer: 2
126  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 4] Value: Boolean: true
127  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 5] Key: Integer: 1
128  * 19:07:55 [CorpCallDump] [ 0] [ 0] Value: [ 5] Value: Boolean: false
129  */
130 
131  // returns nothing
132  return nullptr;
133 }
134 
135 PyResult BillMgr::Handle_GetAutomaticPaySettings(PyCallArgs &call) {
136  // ambSettings = sm.RemoteSvc('billMgr').GetAutomaticPaySettings()
137  // returns t/f for bill types
138  DBQueryResult res;
139  m_db.GetAutoPay(call.client->GetCorporationID(), res);
140 
141  DBResultRow row;
142  PyDict* sets = new PyDict();
143  if (res.GetRow(row)) {
144  sets->SetItem(new PyInt(Corp::BillType::MarketFine), new PyBool(row.GetBool(0)));
145  sets->SetItem(new PyInt(Corp::BillType::RentalBill), new PyBool(row.GetBool(1)));
146  sets->SetItem(new PyInt(Corp::BillType::BrokerBill), new PyBool(row.GetBool(2)));
147  sets->SetItem(new PyInt(Corp::BillType::WarBill), new PyBool(row.GetBool(3)));
148  if (call.client->GetAllianceID())
151  }
152 
153  PyDict* dict = new PyDict();
154  dict->SetItem(new PyInt(call.client->GetCorporationID()), sets);
155 
156  if (is_log_enabled(CORP__RSP_DUMP))
157  dict->Dump(CORP__RSP_DUMP, "");
158 
159  return dict;
160 }
161 
162 
163 /*
164  * [PyString "OnNotificationReceived"]
165  * [PyList 0 items]
166  * [PyString "clientID"]
167  * [PyInt 5654387]
168  * [PyTuple 1 items]
169  * [PyTuple 2 items]
170  * [PyInt 0]
171  * [PySubStream 168 bytes]
172  * [PyTuple 2 items]
173  * [PyInt 0]
174  * [PyTuple 2 items]
175  * [PyInt 1]
176  * [PyTuple 5 items]
177  * [PyInt 342402174]
178  * [PyInt 10] << Notify::Types::CorpAllBill
179  * [PyInt 1000167]
180  * [PyIntegerVar 129492968400000000]
181  * [PyDict 8 kvp]
182  * [PyString "debtorID"]
183  * [PyInt 98038978]
184  * [PyString "creditorID"]
185  * [PyInt 1000167]
186  * [PyString "billTypeID"]
187  * [PyInt 2]
188  * [PyString "amount"]
189  * [PyInt 981907]
190  * [PyString "externalID2"]
191  * [PyInt 60014683]
192  * [PyString "externalID"]
193  * [PyInt 27]
194  * [PyString "currentDate"]
195  * [PyIntegerVar 129492968683459696]
196  * [PyString "dueDate"]
197  * [PyIntegerVar 129518888683422295]
198  * [PyDict 1 kvp]
199  * [PyString "sn"]
200  * [PyIntegerVar 4]
201  */
202 
203 /*
204 // OnBillReceived, an essentially empty tuple, just to tell the client that there is something,
205 // maybe for blinking purpose?
206 OnBillReceived N_obr; // this is in Wallet.xmlp
207 PyTuple * res5 = N_obr.Encode();
208 //call.client->SendNotification("OnBillReceived", "*corpid&corprole", &res5, false);
209 // Why do we create a bill, when the office is already paid? Maybe that's why it's empty...
210 
211 
212 // OnMessage notification, the LSC packet NotifyOnMessage can be used, along with the StoreNewEVEMail
213 // Who to send notification? corpRoleJuniorAccountant and equiv? atm it's enough to send it to the renter
214 // TODO: get the correct evemail content from somewhere
215 // TODO: send it to every corp member who's affected by it. corpRoleAccountant, corpRoleJuniorAccountant or equiv
216 m_manager->lsc_service->SendMail(
217  m_db.GetStationCorporationCEO(oInfo.stationID),
218  call.client->GetCharacterID(),
219  "Bill issued",
220  "Bill issued for renting an office");
221 
222 */
Dispatcher *const m_dispatch
Python's dictionary.
Definition: PyRep.h:719
size_t size() const
Definition: PyRep.h:591
PyCallable_Make_InnerDispatcher(BillMgr) BillMgr
Definition: BillMgr.cpp:34
int32 GetCorporationID() const
Definition: Client.h:123
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
int32 GetAllianceID() const
Definition: Client.h:125
Dispatcher *const m_dispatch
Definition: BillMgr.h:41
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
Python boolean.
Definition: PyRep.h:323
#define is_log_enabled(type)
Definition: logsys.h:78
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
PyObject * GetCorporationBills(uint32 corpID, bool payable)
Python integer.
Definition: PyRep.h:231
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
virtual ~BillMgr()
Definition: BillMgr.cpp:52
void GetAutoPay(uint32 corpID, DBQueryResult &res)
CorporationDB m_db
Definition: BillMgr.h:44
void Dump(LogType type) const
Definition: PyCallable.cpp:81
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
PyTuple * tuple
Definition: PyCallable.h:50
#define sDataMgr