EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CalendarProxy.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 "system/CalendarDB.h"
30 #include "system/CalendarProxy.h"
31 
33 
35 : PyService(mgr, "calendarProxy"),
36  m_dispatch(new Dispatcher(this))
37 {
38  _SetCallDispatcher(m_dispatch);
39 
40  PyCallable_REG_CALL(CalendarProxy, GetEventList);
41  PyCallable_REG_CALL(CalendarProxy, GetEventDetails);
42 }
43 
45 {
46  delete m_dispatch;
47 }
48 
49 
50 PyResult CalendarProxy::Handle_GetEventList( PyCallArgs& call )
51 {
52  Call_TwoIntegerArgs args; //(month, year)
53  if (!args.Decode(&call.tuple)) {
54  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
55  return nullptr;
56  }
57 
58  PyList *list = new PyList();
59  PyRep* res(nullptr);
60 
61  // get system events
62  res = CalendarDB::GetEventList(ownerSystem, args.arg1, args.arg2);
63  if (res != nullptr)
64  list->AddItem(res);
65 
66  // get personal events
67  res = CalendarDB::GetEventList(call.client->GetCharacterID(), args.arg1, args.arg2);
68  if (res != nullptr)
69  list->AddItem(res);
70 
71  // get corp events
72  res = CalendarDB::GetEventList(call.client->GetCorporationID(), args.arg1, args.arg2);
73  if (res != nullptr)
74  list->AddItem(res);
75 
76  // get alliance events
77  if (IsAlliance(call.client->GetAllianceID())) {
78  res = CalendarDB::GetEventList(call.client->GetAllianceID(), args.arg1, args.arg2);
79  if (res != nullptr)
80  list->AddItem(res);
81  }
82 
83  if (list->empty())
84  list->AddItem(PyStatic.NewNone());
85 
86  return list;
87 }
88 
89 PyResult CalendarProxy::Handle_GetEventDetails( PyCallArgs& call )
90 {
91  // self.eventDetails[eventID] = self.GetCalendarProxy().GetEventDetails(eventID, ownerID)
92  Call_TwoIntegerArgs args; //(eventID, ownerID)
93  if (!args.Decode(&call.tuple)) {
94  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
95  return nullptr;
96  }
97 
98  return CalendarDB::GetEventDetails(args.arg1);
99 }
100 
static PyRep * GetEventDetails(uint32 eventID)
Definition: CalendarDB.cpp:202
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
Dispatcher *const m_dispatch
Definition: CalendarProxy.h:40
virtual ~CalendarProxy()
int32 GetCharacterID() const
Definition: Client.h:113
int32 GetCorporationID() const
Definition: Client.h:123
const char * GetName() const
Definition: PyService.h:54
int32 GetAllianceID() const
Definition: Client.h:125
void AddItem(PyRep *i)
Definition: PyRep.h:701
* args
PyCallable_Make_InnerDispatcher(CalendarProxy) CalendarProxy
#define codelog(type, fmt,...)
Definition: logsys.h:128
#define PyStatic
Definition: PyRep.h:1209
static PyRep * GetEventList(uint32 ownerID, uint32 month, uint32 year)
Definition: CalendarDB.cpp:162
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
#define IsAlliance(itemID)
Definition: EVE_Defines.h:244
bool empty() const
Definition: PyRep.h:664
Python list.
Definition: PyRep.h:639
PyTuple * tuple
Definition: PyCallable.h:50