EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MailingListMgrService.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: Luck, caytchen
24 */
25 
26 #include "eve-server.h"
27 
28 #include "PyServiceCD.h"
30 
32 
34 : PyService(mgr, "mailingListsMgr"),
35  m_dispatch(new Dispatcher(this))
36 {
37  _SetCallDispatcher(m_dispatch);
38 
47  PyCallable_REG_CALL(MailingListMgrService, ClearEntityAccess);
49  PyCallable_REG_CALL(MailingListMgrService, SetMembersOperator);
51  PyCallable_REG_CALL(MailingListMgrService, SetDefaultAccess);
57  PyCallable_REG_CALL(MailingListMgrService, ClearWelcomeMail);
58 }
59 
61 {
62  delete m_dispatch;
63 }
64 
65 PyResult MailingListMgrService::Handle_GetJoinedLists(PyCallArgs& call)
66 {
67  // @TODO: Test
68  // no args
69  sLog.Debug("MailingListMgrService", "Called GetJoinedLists stub" );
70 
72 }
73 
74 PyResult MailingListMgrService::Handle_Create(PyCallArgs& call)
75 {
76  // @TODO: Test
77  sLog.Debug("MailingListMgrService", "Called Create stub" );
78  Call_CreateMailingList args;
79  if (!args.Decode(&call.tuple)) {
80  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
81  return nullptr;
82  }
83 
84  uint32 r = m_db.CreateMailingList(call.client->GetCharacterID(), args.name, args.defaultAccess,
85  args.defaultMemberAccess, args.mailCost);
86  if (r >= 0) {
87  return new PyInt(r);
88  }
89  return nullptr;
90 }
91 
92 PyResult MailingListMgrService::Handle_Join(PyCallArgs& call)
93 {
94  // @TODO: Stub
95  sLog.Debug("MailingListMgrService", "Called Join stub" );
96  Call_SingleStringArg args;
97  if (!args.Decode(&call.tuple)) {
98  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
99  return nullptr;
100  }
101 
102  std::string listName = args.arg;
103  // returns mailing list object
104  return nullptr;
105 }
106 
107 PyResult MailingListMgrService::Handle_Leave(PyCallArgs& call)
108 {
109  // @TODO: Stub
110  sLog.Debug("MailingListMgrService", "Called Leave stub" );
111  Call_SingleIntegerArg args;
112  if (!args.Decode(&call.tuple)) {
113  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
114  return nullptr;
115  }
116 
117  int listID = args.arg;
118  // no return values
119  return nullptr;
120 }
121 
122 PyResult MailingListMgrService::Handle_Delete(PyCallArgs& call)
123 {
124  // @TODO: Stub
125  sLog.Debug("MailingListMgrService", "Called Delete stub" );
126  Call_SingleIntegerArg args;
127  if (!args.Decode(&call.tuple)) {
128  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
129  return nullptr;
130  }
131 
132  int listID = args.arg;
133  // no return values
134  return nullptr;
135 }
136 
137 PyResult MailingListMgrService::Handle_KickMembers(PyCallArgs& call)
138 {
139  // @TODO: Stub
140  sLog.Debug("MailingListMgrService", "Called KickMembers stub" );
141  Call_MemberList args;
142  if (!args.Decode(&call.tuple)) {
143  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
144  return nullptr;
145  }
146 
147  for (int i = 0; i < args.memberIDs->size(); i++) {
148  PyRep *member = args.memberIDs->GetItem(i);
149  member->Dump(SERVICE__ERROR, "member item");
150  }
151 
152  // no return values
153  return nullptr;
154 }
155 
156 PyResult MailingListMgrService::Handle_GetMembers(PyCallArgs& call)
157 {
158  // @TODO: Stub
159  sLog.Debug("MailingListMgrService", "Called GetMembers stub" );
160  Call_SingleIntegerArg args;
161  if (!args.Decode(&call.tuple)) {
162  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
163  return nullptr;
164  }
165 
166  int listID = args.arg;
167  return m_db.GetMailingListMembers(listID);
168 }
169 
170 PyResult MailingListMgrService::Handle_SetEntityAccess(PyCallArgs& call)
171 {
172  // @TODO: Stub
173  sLog.Debug("MailingListMgrService", "Called SetEntityAccess stub" );
174  Call_SetEntityAccess args;
175  if (!args.Decode(&call.tuple)) {
176  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
177  return nullptr;
178  }
179 
180  // no return values
181  return nullptr;
182 }
183 
184 PyResult MailingListMgrService::Handle_ClearEntityAccess(PyCallArgs& call)
185 {
186  // @TODO: Stub
187  sLog.Debug("MailingListMgrService", "Called ClearEntityAccess stub" );
188  Call_ClearEntityAccess args;
189  if (!args.Decode(&call.tuple)) {
190  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
191  return nullptr;
192  }
193 
194  // no return values
195  return nullptr;
196 }
197 
198 PyResult MailingListMgrService::Handle_SetMembersMuted(PyCallArgs& call)
199 {
200  // @TODO: Stub
201  sLog.Debug("MailingListMgrService", "Called SetMembersMuted stub" );
202  Call_MemberList args;
203  if (!args.Decode(&call.tuple)) {
204  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
205  return nullptr;
206  }
207 
208  return nullptr;
209 }
210 
211 PyResult MailingListMgrService::Handle_SetMembersOperator(PyCallArgs& call)
212 {
213  // @TODO: Stub
214  sLog.Debug("MailingListMgrService", "Called SetMembersOperator stub" );
215  Call_MemberList args;
216  if (!args.Decode(&call.tuple)) {
217  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
218  return nullptr;
219  }
220 
221  return nullptr;
222 }
223 
224 PyResult MailingListMgrService::Handle_SetMembersClear(PyCallArgs& call)
225 {
226  // @TODO: Stub
227  sLog.Debug("MailingListMgrService", "Called SetMembersClear stub" );
228  Call_MemberList args;
229  if (!args.Decode(&call.tuple)) {
230  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
231  return nullptr;
232  }
233 
234  return nullptr;
235 }
236 
237 PyResult MailingListMgrService::Handle_SetDefaultAccess(PyCallArgs& call)
238 {
239  // @TODO: Stub
240  sLog.Debug("MailingListMgrService", "Called SetDefaultAccess stub" );
241  Call_SetDefaultAccess args;
242  if (!args.Decode(&call.tuple)) {
243  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
244  return nullptr;
245  }
246 
247  m_db.SetMailingListDefaultAccess(args.listID, args.defaultAccess,
248  args.defaultMemberAccess, args.mailCost);
249 
250  return nullptr;
251 }
252 
253 PyResult MailingListMgrService::Handle_GetInfo(PyCallArgs& call)
254 {
255  // @TODO: Stub
256  sLog.Debug("MailingListMgrService", "Called GetInfo stub" );
257  Call_SingleIntegerArg args;
258  if (!args.Decode(&call.tuple)) {
259  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
260  return nullptr;
261  }
262 
263  int listID = args.arg;
264  if (listID == 0) {
265  PyDict *ret = new PyDict();
266  ret->SetItem("displayName", new PyString("Test"));
267  return new PyObject("util.KeyVal", ret);
268  }
269  return nullptr;
270 }
271 
272 PyResult MailingListMgrService::Handle_GetSettings(PyCallArgs& call)
273 {
274  // @TODO: Test
275  sLog.Debug("MailingListMgrService", "Called GetSettings stub" );
276  Call_SingleIntegerArg args;
277  if (!args.Decode(&call.tuple)) {
278  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
279  return nullptr;
280  }
281 
282  // return:
283  // .access: list (ownerID, accessLevel)
284  // .defaultAccess
285  // .defaultMemberAccess
286 
287  int listID = args.arg;
288  return m_db.MailingListGetSettings(listID);
289 }
290 
291 PyResult MailingListMgrService::Handle_GetWelcomeMail(PyCallArgs& call)
292 {
293  // @TODO: Stub
294  sLog.Debug("MailingListMgrService", "Called GetWelcomeMail stub" );
295  Call_SingleIntegerArg args;
296  if (!args.Decode(&call.tuple)) {
297  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
298  return nullptr;
299  }
300 
301  int listID = args.arg;
302  return nullptr;
303 }
304 
305 PyResult MailingListMgrService::Handle_SaveWelcomeMail(PyCallArgs& call)
306 {
307  // @TODO: Stub
308  sLog.Debug("MailingListMgrService", "Called SaveWelcomeMail stub" );
309  Call_SaveWelcomeMail args;
310  if (!args.Decode(&call.tuple)) {
311  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
312  return nullptr;
313  }
314 
315  return nullptr;
316 }
317 
318 PyResult MailingListMgrService::Handle_SendWelcomeMail(PyCallArgs& call)
319 {
320  // @TODO: Stub
321  sLog.Debug("MailingListMgrService", "Called SendWelcomeMail stub" );
322  Call_SaveWelcomeMail args;
323  if (!args.Decode(&call.tuple)) {
324  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
325  return nullptr;
326  }
327 
328  return nullptr;
329 }
330 
331 PyResult MailingListMgrService::Handle_ClearWelcomeMail(PyCallArgs& call)
332 {
333  // @TODO: Stub
334  sLog.Debug("MailingListMgrService", "Called ClearWelcomeMail stub" );
335  Call_SingleIntegerArg args;
336  if (!args.Decode(&call.tuple)) {
337  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
338  return nullptr;
339  }
340 
341  int listID = args.arg;
342  // no return value
343  return nullptr;
344 }
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
void SetMailingListDefaultAccess(int32 listID, int32 defaultAccess, int32 defaultMemberAccess, int32 cost)
Definition: MailDB.cpp:759
PyDict * GetJoinedMailingLists(uint32 characterID)
Definition: MailDB.cpp:607
int32 GetCharacterID() const
Definition: Client.h:113
const char * GetName() const
Definition: PyService.h:54
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
* args
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
Python object.
Definition: PyRep.h:826
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyDict * GetMailingListMembers(int32 listID)
Definition: MailDB.cpp:688
Python integer.
Definition: PyRep.h:231
uint32 CreateMailingList(uint32 creator, std::string name, int32 defaultAccess, int32 defaultMemberAccess, int32 cost)
Definition: MailDB.cpp:659
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
unsigned __int32 uint32
Definition: eve-compat.h:50
PyObject * MailingListGetSettings(int32 listID)
Definition: MailDB.cpp:710
Dispatcher *const m_dispatch
PyCallable_Make_InnerDispatcher(MailingListMgrService) MailingListMgrService
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
PyTuple * tuple
Definition: PyCallable.h:50