EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LSCDB Class Reference

#include "LSCDB.h"

Inheritance diagram for LSCDB:
Collaboration diagram for LSCDB:

Public Member Functions

uint32 StoreMail (uint32 senderID, uint32 recipID, const char *subject, const char *message, int64 sentTime)
 
PyObjectGetMailHeaders (uint32 recID)
 
PyRepGetMailDetails (uint32 messageID, uint32 readerID)
 
bool MarkMessageRead (uint32 messageID)
 
bool DeleteMessage (uint32 messageID, uint32 readerID)
 
void GetChannelNames (uint32 charID, std::vector< std::string > &names)
 
int32 GetNextAvailableChannelID ()
 
bool IsChannelNameAvailable (std::string name)
 
bool IsChannelIDAvailable (int32 channel_ID)
 
bool IsChannelSubscribedByThisChar (uint32 char_ID, int32 channel_ID)
 
std::string GetRegionName (uint32 id)
 
std::string GetConstellationName (uint32 id)
 
std::string GetSolarSystemName (uint32 id)
 
std::string GetCorporationName (uint32 id)
 
std::string GetAllianceName (uint32 id)
 
std::string GetCharacterName (uint32 id)
 
int32 GetChannelID (std::string &name)
 
void GetChannelInformation (int32 channelID, std::string &name, std::string &motd, uint32 &ownerid, std::string &compkey, bool &memberless, std::string &password, bool &maillist, uint32 &cspa)
 
void GetChannelSubscriptions (uint32 charID, std::vector< long > &ids, std::vector< std::string > &names, std::vector< std::string > &MOTDs, std::vector< unsigned long > &ownerids, std::vector< std::string > &compkeys, std::vector< int > &memberless, std::vector< std::string > &passwords, std::vector< int > &maillists, std::vector< int > &cspas, int &channelCount)
 
bool GetChannelInfo (int32 channelID, std::string &name, std::string &motd)
 
int32 GetChannelIDFromComparisonKey (std::string compkey)
 
void UpdateChannelInfo (LSCChannel *channel)
 
void UpdateSubscription (int32 channelID, Client *pClient)
 
void DeleteChannel (int32 channelID)
 
void DeleteSubscription (int32 channelID, uint32 charID)
 
- Public Member Functions inherited from ServiceDB
uint32 GetStationOwner (uint32 stationID)
 

Protected Member Functions

std::string GetChannelName (uint32 id, const char *table, const char *column, const char *key)
 
- Protected Member Functions inherited from ServiceDB
void ProcessStringChange (const char *key, const std::string &oldValue, std::string newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessRealChange (const char *key, double oldValue, double newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessIntChange (const char *key, uint32 oldValue, uint32 newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessLongChange (const char *key, int64 oldValue, int64 newValue, PyDict *notif, std::vector< std::string > &dbQ)
 

Additional Inherited Members

- Static Public Member Functions inherited from ServiceDB
static bool GetAccountInformation (CryptoChallengePacket &ccp, AccountData &aData, std::string &failMsg)
 
static bool UpdateAccountHash (const char *username, std::string &hash)
 
static bool IncrementLoginCount (uint32 accountID)
 
static void UpdatePassword (uint32 accountID, const char *pass)
 
static void SaveKillOrLoss (CharKillData &data)
 
static bool GetConstant (const char *name, uint32 &into)
 
static void SetServerOnlineStatus (bool online=false)
 
static void SetCharacterOnlineStatus (uint32 char_id, bool online=false)
 
static void SetAccountOnlineStatus (uint32 accountID, bool online=false)
 
static void SetAccountBanStatus (uint32 accountID, bool banned=false)
 
static void SaveServerStats (double threads, float rss, float vm, float user, float kernel, uint32 items, uint32 bubbles)
 
static uint32 SetClientSeed ()
 
static PyRepLookupChars (const char *match, bool exact=false)
 
static PyRepLookupOwners (const char *match, bool exact=false)
 
static PyRepLookupCorporations (const std::string &)
 
static PyRepLookupFactions (const std::string &)
 
static PyRepLookupCorporationTickers (const std::string &)
 
static PyRepLookupStations (const std::string &)
 
static PyRepLookupKnownLocationsByGroup (const std::string &, uint32)
 
static PyRepPrimeOwners (std::vector< int32 > &itemIDs)
 
static bool ValidateAccountName (CryptoChallengePacket &ccp, std::string &failMsg)
 
static void GetCorpHangarNames (uint32 corpID, std::map< uint8, std::string > &hangarNames)
 
- Static Protected Member Functions inherited from ServiceDB
static uint32 CreateNewAccount (const char *login, const char *pass, const char *passHash, int64 role)
 

Detailed Description

Definition at line 36 of file LSCDB.h.

Member Function Documentation

void LSCDB::DeleteChannel ( int32  channelID)

Definition at line 130 of file LSCDB.cpp.

References sDatabase.

131 {
132  DBerror err;
133  sDatabase.RunQuery(err, "DELETE FROM channels WHERE channelID=%i", channelID);
134 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39
bool LSCDB::DeleteMessage ( uint32  messageID,
uint32  readerID 
)

Definition at line 522 of file LSCDB.cpp.

References _log, DBerror::c_str(), and sDatabase.

522  {
523  DBerror err;
524  bool ret = true;
525 
526  if (!sDatabase.RunQuery(err,
527  " DELETE FROM eveMail "
528  " WHERE messageID=%u AND channelID=%u", messageID, readerID
529  ))
530  {
531  _log(DATABASE__ERROR, "Error in query: %s", err.c_str());
532  ret = false;
533  }
534  if (!sDatabase.RunQuery(err,
535  " DELETE FROM eveMailDetails "
536  " WHERE messageID=%u", messageID
537  ))
538  {
539  _log(DATABASE__ERROR, "Error in query: %s", err.c_str());
540  ret = false;
541  }
542 
543  return ret;
544 
545 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

void LSCDB::DeleteSubscription ( int32  channelID,
uint32  charID 
)

Definition at line 136 of file LSCDB.cpp.

References sDatabase.

137 {
138  DBerror err;
139  sDatabase.RunQuery(err, "DELETE FROM channelChars WHERE channelID=%i AND charID=%u", channelID, charID );
140 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39
std::string LSCDB::GetAllianceName ( uint32  id)
inline

Definition at line 56 of file LSCDB.h.

References GetChannelName().

Referenced by LSCService::CreateSystemChannel().

56 { return GetChannelName(id, "alnAlliance", "shortName", "allianceID"); }
std::string GetChannelName(uint32 id, const char *table, const char *column, const char *key)
Definition: LSCDB.cpp:382

Here is the call graph for this function:

Here is the caller graph for this function:

int32 LSCDB::GetChannelID ( std::string &  name)

Definition at line 222 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), and sDatabase.

222  {
223  DBQueryResult res;
224  if (!sDatabase.RunQuery(res, "SELECT channelID FROM channels WHERE displayName RLIKE '%s'", name.c_str())) {
225  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
226  return 0;
227  }
228 
229  DBResultRow row;
230  if (!res.GetRow(row)) {
231  _log(SERVICE__ERROR, "Channel named '%s' isn't present in the database", name.c_str() );
232  return 0;
233  }
234 
235  return row.GetInt(0);
236 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

int32 LSCDB::GetChannelIDFromComparisonKey ( std::string  compkey)

Definition at line 365 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), and sDatabase.

366 {
367  DBQueryResult res;
368  if(!sDatabase.RunQuery(res, "SELECT channelID FROM channels WHERE comparisonKey RLIKE '%s'", compkey.c_str())) {
369  _log(DATABASE__ERROR, "Error in GetChannelIDFromComparisonKey query: %s", res.error.c_str());
370  return 0;
371  }
372 
373  DBResultRow row;
374  if (!res.GetRow(row)) {
375  _log(SERVICE__ERROR, "Couldn't find %s in table channels", compkey.c_str());
376  return 0;
377  }
378 
379  return row.GetInt(0);
380 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

bool LSCDB::GetChannelInfo ( int32  channelID,
std::string &  name,
std::string &  motd 
)

Definition at line 344 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBQueryResult::GetRow(), DBResultRow::GetText(), and sDatabase.

345 {
346  DBQueryResult res;
347  if (!sDatabase.RunQuery(res, "SELECT displayName, motd FROM channels WHERE channelID = %i ", channelID)) {
348  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
349  return false;
350  }
351 
352  DBResultRow row;
353  if (!res.GetRow(row)) {
354  // _log(SERVICE__ERROR, "Couldn't find %u in table channels", channelID);
355  return false;
356  }
357 
358  name = row.GetText(0);
359  motd = row.GetText(1);
360 
361  return true;
362 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

void LSCDB::GetChannelInformation ( int32  channelID,
std::string &  name,
std::string &  motd,
uint32 ownerid,
std::string &  compkey,
bool &  memberless,
std::string &  password,
bool &  maillist,
uint32 cspa 
)

Definition at line 240 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetBool(), DBQueryResult::GetRow(), DBResultRow::GetText(), DBResultRow::GetUInt(), DBResultRow::IsNull(), and sDatabase.

244 {
245  DBQueryResult res;
246 
247  if (!sDatabase.RunQuery(res,
248  "SELECT"
249  " channelID, "
250  " displayName, "
251  " motd, "
252  " ownerID, "
253  " comparisonKey, "
254  " memberless, "
255  " password, "
256  " mailingList, "
257  " cspa "
258  " FROM channels "
259  " WHERE channelID = %i", channelID))
260  {
261  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
262  return;
263  }
264 
265  DBResultRow row;
266 
267  if (!(res.GetRow(row)))
268  {
269  _log(SERVICE__ERROR, "Channel %i isn't present in the database", channelID );
270  return;
271  }
272 
273  name = (row.IsNull(1) ? "" : row.GetText(1)); // empty displayName field in channels table row returns NULL, so fill this string with "" in that case
274  motd = (row.IsNull(2) ? "" : row.GetText(2)); // empty motd field in channels table row returns NULL, so fill this string with "" in that case
275  ownerid = row.GetUInt(3);
276  compkey = (row.IsNull(4) ? "" : row.GetText(4)); // empty comparisonKey field in channels table row returns NULL, so fill this string with "" in that case
277  memberless = row.GetBool(5);
278  password = (row.IsNull(6) ? "" : row.GetText(6));// empty password field in channels table row returns NULL, so fill this string with "" in that case
279  maillist = row.GetBool(7);
280  cspa = row.GetUInt(8);
281 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
const char * c_str() const
Definition: dbcore.h:48
bool IsNull(uint32 index) const
Definition: dbcore.h:102
DBerror error
Definition: dbcore.h:69
const int cspa
Definition: LSCService.cpp:132

Here is the call graph for this function:

std::string LSCDB::GetChannelName ( uint32  id,
const char *  table,
const char *  column,
const char *  key 
)
protected

Definition at line 382 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBQueryResult::GetRow(), DBResultRow::GetText(), and sDatabase.

Referenced by GetAllianceName(), GetCharacterName(), GetConstellationName(), GetCorporationName(), GetRegionName(), and GetSolarSystemName().

382  {
383  DBQueryResult res;
384  if (!sDatabase.RunQuery(res,"SELECT %s FROM %s WHERE %s = %u ", column, table, key, id)) {
385  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
386  return "";
387  }
388 
389  DBResultRow row;
390  if (!res.GetRow(row)) {
391  _log(SERVICE__ERROR, "Couldn't find %s %u in table %s", key, id, table);
392  return "";
393  }
394 
395  return row.GetText(0);
396 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr

Here is the call graph for this function:

Here is the caller graph for this function:

void LSCDB::GetChannelNames ( uint32  charID,
std::vector< std::string > &  names 
)
Todo:
this entire file needs review

Definition at line 33 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBQueryResult::GetRow(), DBResultRow::GetText(), and sDatabase.

33  {
34  DBQueryResult res;
35 
36  if (!sDatabase.RunQuery(res,
37  "SELECT"
38  " ch.characterName, "
39  " cr.corporationName "
40  " FROM chrCharacters AS ch"
41  " LEFT JOIN crpCorporation AS cr USING (corporationID) "
42  " WHERE ch.characterID = %u ", charID))
43  {
44  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
45  return;
46  }
47 
48  DBResultRow row;
49  if (!res.GetRow(row)) {
50  _log(SERVICE__ERROR, "CharID %u isn't present in the database", charID);
51  return;
52  }
53 
54  names.push_back(row.GetText(0)); // charName
55  names.push_back(row.GetText(1)); // corpName
56 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

void LSCDB::GetChannelSubscriptions ( uint32  charID,
std::vector< long > &  ids,
std::vector< std::string > &  names,
std::vector< std::string > &  MOTDs,
std::vector< unsigned long > &  ownerids,
std::vector< std::string > &  compkeys,
std::vector< int > &  memberless,
std::vector< std::string > &  passwords,
std::vector< int > &  maillists,
std::vector< int > &  cspas,
int &  channelCount 
)

Definition at line 285 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), DBResultRow::GetText(), DBResultRow::GetUInt(), and sDatabase.

289 {
290  DBQueryResult res;
291 
292  // Cross-reference "channelchars" table with "channels" table using the charID
293  // The result is a two column multi-row structure where each row is a channel
294  // that the character (charID) is subscribed to where the channel ID is presented
295  // in the first column and the display name of that channel in the second column
296  if (!sDatabase.RunQuery(res,
297  "SELECT"
298  " channelID, "
299  " displayName, "
300  " motd, "
301  " ownerID, "
302  " comparisonKey, "
303  " memberless, "
304  " password, "
305  " mailingList, "
306  " cspa "
307  " FROM channels "
308  " WHERE channelID = ANY ("
309  " SELECT channelID FROM channelChars WHERE charID = %u )", charID))
310  {
311  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
312  return;
313  }
314 
315  DBResultRow row;
316  int rowCount = 0;
317 
318  // Traverse through all rows in the query result and copy the IDs and displayNames to the
319  // "ids" and "names" vectors for return to the calling function:
320  while(res.GetRow(row))
321  {
322  ++rowCount;
323 
324  ids.push_back(row.GetInt(0));
325  names.push_back((row.GetText(1) == NULL ? "" : row.GetText(1))); // empty displayName field in channels table row returns NULL, so fill this string with "" in that case
326  MOTDs.push_back((row.GetText(2) == NULL ? "" : row.GetText(2))); // empty motd field in channels table row returns NULL, so fill this string with "" in that case
327  ownerids.push_back(row.GetUInt(3));
328  compkeys.push_back((row.GetText(4) == NULL ? "" : row.GetText(4))); // empty comparisonKey field in channels table row returns NULL, so fill this string with "" in that case
329  memberless.push_back(row.GetUInt(5));
330  passwords.push_back((row.GetText(6) == NULL ? "" : row.GetText(6))); // empty password field in channels table row returns NULL, so fill this string with "" in that case
331  maillists.push_back(row.GetUInt(7));
332  cspas.push_back(row.GetUInt(8));
333  }
334 
335  if (rowCount == 0) {
336  //_log(SERVICE__ERROR, "CharID %u isn't present in the database", charID);
337  return;
338  }
339 
340  channelCount = rowCount;
341 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

std::string LSCDB::GetCharacterName ( uint32  id)
inline

Definition at line 57 of file LSCDB.h.

References GetChannelName().

57 { return GetChannelName(id, "chrCharacters", "characterName", "charID"); }
std::string GetChannelName(uint32 id, const char *table, const char *column, const char *key)
Definition: LSCDB.cpp:382

Here is the call graph for this function:

std::string LSCDB::GetConstellationName ( uint32  id)
inline

Definition at line 53 of file LSCDB.h.

References GetChannelName().

Referenced by LSCService::CreateSystemChannel().

53 { return GetChannelName(id, "mapConstellations", "constellationName", "constellationID"); }
std::string GetChannelName(uint32 id, const char *table, const char *column, const char *key)
Definition: LSCDB.cpp:382

Here is the call graph for this function:

Here is the caller graph for this function:

std::string LSCDB::GetCorporationName ( uint32  id)
inline

Definition at line 55 of file LSCDB.h.

References GetChannelName().

Referenced by LSCService::CreateSystemChannel().

55 { return GetChannelName(id, "crpCorporation", "corporationName", "corporationID"); }
std::string GetChannelName(uint32 id, const char *table, const char *column, const char *key)
Definition: LSCDB.cpp:382

Here is the call graph for this function:

Here is the caller graph for this function:

PyRep * LSCDB::GetMailDetails ( uint32  messageID,
uint32  readerID 
)

Definition at line 462 of file LSCDB.cpp.

References _log, DBerror::c_str(), codelog, DBQueryResult::error, DBResultRow::GetInt(), DBResultRow::GetInt64(), DBQueryResult::GetRow(), DBResultRow::GetText(), DBResultRow::GetUInt(), and sDatabase.

462  {
463  DBQueryResult result;
464  DBResultRow row;
465 
466  //we need to query out the primary message here... not sure how to properly
467  //grab the "main message" though... the text/plain clause is pretty hackish.
468  if (!sDatabase.RunQuery(result,
469  " SELECT eveMail.messageID, eveMail.senderID, eveMail.subject, " // need messageID as char*
470  " eveMailDetails.attachment, eveMailDetails.mimeTypeID, "
471  " eveMailMimeType.mimeType, eveMailMimeType.`binary`, "
472  " eveMail.created, eveMail.channelID "
473  " FROM eveMail "
474  " LEFT JOIN eveMailDetails ON eveMailDetails.messageID = eveMail.messageID "
475  " LEFT JOIN eveMailMimeType ON eveMailMimeType.mimeTypeID = eveMailDetails.mimeTypeID "
476  " WHERE eveMail.messageID=%u AND channelID=%u",
477  messageID, readerID
478  ))
479  {
480  _log(DATABASE__ERROR, "Error in query: %s", result.error.c_str());
481  return nullptr;
482  }
483 
484  if (!result.GetRow(row)) {
485  codelog(SERVICE__MESSAGE, "No message with messageID %u", messageID);
486  return nullptr;
487  }
488 
489  Rsp_GetEVEMailDetails details;
490  details.messageID = row.GetUInt(0);
491  details.senderID = row.GetUInt(1);
492  details.subject = row.GetText(2);
493  details.body = row.GetText(3);
494  details.created = row.GetInt64(7);
495  details.channelID = row.GetUInt(8);
496  details.deleted = 0; // If a message's details are sent, then it isn't deleted. If it's deleted, details cannot be sent
497  details.mimeTypeID = row.GetInt(4);
498  details.mimeType = row.GetText(5);
499  details.binary = row.GetInt(6);
500 
501  return details.Encode();
502 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69
int64 GetInt64(uint32 index) const
Definition: dbcore.cpp:670

Here is the call graph for this function:

PyObject * LSCDB::GetMailHeaders ( uint32  recID)

Definition at line 446 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBResultToRowset(), DBQueryResult::error, and sDatabase.

446  {
447  DBQueryResult res;
448 
449  if(!sDatabase.RunQuery(res,
450  "SELECT channelID, messageID, senderID, subject, created, `read` "
451  " FROM eveMail "
452  " WHERE channelID=%u", recID))
453  {
454  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
455  return nullptr;
456  }
457 
458  return DBResultToRowset(res);
459 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

int32 LSCDB::GetNextAvailableChannelID ( )
Todo:
fix this shit

Definition at line 58 of file LSCDB.cpp.

References _log, LSCService::BASE_CHANNEL_ID, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), LSCService::MAX_CHANNEL_ID, and sDatabase.

59 {
61  DBQueryResult res;
62  if( !sDatabase.RunQuery( res,
63  "SELECT"
64  " channelID "
65  " FROM channels "
66  " WHERE channelID >= %i ", LSCService::BASE_CHANNEL_ID ))
67  {
68  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
69  return 0;
70  }
71 
72  int32 currentChannelID = LSCService::BASE_CHANNEL_ID;
73 
74  DBResultRow row;
75  while( res.GetRow(row) )
76  {
77  if ( ++currentChannelID < row.GetInt( 0 ) )
78  return currentChannelID;
79  }
80 
81  // Check to make sure that the next available channelID is not equal to the Maximum channel ID value
82  if( currentChannelID <= LSCService::MAX_CHANNEL_ID )
83  return currentChannelID;
84 
85  return 0; // No free channel IDs found (this should never happen as there are way too many IDs to exhaust)
86 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
signed __int32 int32
Definition: eve-compat.h:49
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69
static const int32 BASE_CHANNEL_ID
Definition: LSCService.h:48
static const uint32 MAX_CHANNEL_ID
Definition: LSCService.h:49

Here is the call graph for this function:

std::string LSCDB::GetRegionName ( uint32  id)
inline

Definition at line 52 of file LSCDB.h.

References GetChannelName().

Referenced by LSCService::CreateSystemChannel().

52 { return GetChannelName(id, "mapRegions", "regionName", "regionID"); }
std::string GetChannelName(uint32 id, const char *table, const char *column, const char *key)
Definition: LSCDB.cpp:382

Here is the call graph for this function:

Here is the caller graph for this function:

std::string LSCDB::GetSolarSystemName ( uint32  id)
inline

Definition at line 54 of file LSCDB.h.

References GetChannelName().

Referenced by LSCService::CreateSystemChannel().

54 { return GetChannelName(id, "mapSolarSystems", "solarSystemName", "solarSystemID"); }
std::string GetChannelName(uint32 id, const char *table, const char *column, const char *key)
Definition: LSCDB.cpp:382

Here is the call graph for this function:

Here is the caller graph for this function:

bool LSCDB::IsChannelIDAvailable ( int32  channel_ID)

Definition at line 172 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBQueryResult::GetRow(), and sDatabase.

173 {
174  DBQueryResult res;
175 
176  if (!sDatabase.RunQuery(res,
177  "SELECT"
178  " channelID "
179  " FROM channels "
180  " WHERE channelID = %i", channelID ))
181  {
182  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
183  return false;
184  }
185 
186  DBResultRow row;
187 
188  // Return true (this channelID not in use) if there are no rows returned by the query:
189  if (!(res.GetRow(row)))
190  return true;
191 
192  return false;
193 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

bool LSCDB::IsChannelNameAvailable ( std::string  name)

Definition at line 145 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBQueryResult::GetRow(), and sDatabase.

146 {
147  DBQueryResult res;
148 
149  // MySQL query channels table for any channel whose displayName matches "name":
150  if (!sDatabase.RunQuery(res,
151  "SELECT"
152  " displayName "
153  " FROM channels "
154  " WHERE displayName = upper('%s')", name.c_str()))
155  {
156  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
157  return false;
158  }
159 
160  DBResultRow row;
161 
162  // Return true (this 'displayName' not in use) if there are no rows returned by the query:
163  if (!res.GetRow(row))
164  return true;
165 
166  return false;
167 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

bool LSCDB::IsChannelSubscribedByThisChar ( uint32  char_ID,
int32  channel_ID 
)

Definition at line 198 of file LSCDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBQueryResult::GetRow(), and sDatabase.

199 {
200  DBQueryResult res;
201 
202  if (!sDatabase.RunQuery(res,
203  "SELECT"
204  " channelID, "
205  " charID "
206  " FROM channelChars "
207  " WHERE channelID = %i AND charID = %u", channelID, charID ))
208  {
209  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
210  return false;
211  }
212 
213  DBResultRow row;
214 
215  // Return false (no subscription exists) if there are no rows returned by the query:
216  if (!(res.GetRow(row)))
217  return false;
218 
219  return true;
220 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

bool LSCDB::MarkMessageRead ( uint32  messageID)

Definition at line 505 of file LSCDB.cpp.

References _log, DBerror::c_str(), and sDatabase.

505  {
506  DBerror err;
507 
508  if (!sDatabase.RunQuery(err,
509  " UPDATE eveMail "
510  " SET `read` = 1 "
511  " WHERE messageID=%u", messageID
512  ))
513  {
514  _log(DATABASE__ERROR, "Error in query: %s", err.c_str());
515  return false;
516  }
517 
518  return true;
519 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

uint32 LSCDB::StoreMail ( uint32  senderID,
uint32  recipID,
const char *  subject,
const char *  message,
int64  sentTime 
)

Definition at line 399 of file LSCDB.cpp.

References _log, DBerror::c_str(), and sDatabase.

Referenced by LSCService::SendMail().

399  {
400  DBQueryResult res;
401  DBerror err;
402  DBResultRow row;
403 
404  std::string escaped;
405  // Escape message header
406  sDatabase.DoEscapeString(escaped, subject);
407 
408  // Store message header
409  uint32 messageID;
410  if (!sDatabase.RunQueryLID(err, messageID,
411  " INSERT INTO eveMail "
412  " (channelID, senderID, subject, created) "
413  " VALUES (%u, %u, '%s', %li) ",
414  recipID, senderID, escaped.c_str(), sentTime ))
415  {
416  _log(DATABASE__ERROR, "Error in query, message header couldn't be saved: %s", err.c_str());
417  return (0);
418  }
419 
420  _log(SERVICE__MESSAGE, "New messageID: %u", messageID);
421 
422  // Escape message content
423  sDatabase.DoEscapeString(escaped, message);
424 
425  // Store message content
426  if (!sDatabase.RunQuery(err,
427  " INSERT INTO eveMailDetails "
428  " (messageID, mimeTypeID, attachment) VALUES (%u, 1, '%s') ",
429  messageID, escaped.c_str()
430  ))
431  {
432  _log(DATABASE__ERROR, "Error in query, message content couldn't be saved: %s", err.c_str());
433  // Delete message header
434  if (!sDatabase.RunQuery(err, "DELETE FROM `eveMail` WHERE `messageID` = %u;", messageID))
435  {
436  _log(DATABASE__ERROR, "Failed to remove invalid header data for messgae id %u: %s", messageID, err.c_str());
437  }
438  return (0);
439  }
440 
441 
442  return (messageID);
443 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
unsigned __int32 uint32
Definition: eve-compat.h:50
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void LSCDB::UpdateChannelInfo ( LSCChannel channel)

Definition at line 88 of file LSCDB.cpp.

References _log, DBerror::c_str(), LSCChannel::GetChannelID(), LSCChannel::GetComparisonKey(), LSCChannel::GetCSPA(), LSCChannel::GetDisplayName(), LSCChannel::GetMailingList(), LSCChannel::GetMemberless(), LSCChannel::GetMOTD(), LSCChannel::GetOwnerID(), LSCChannel::GetPassword(), and sDatabase.

88  {
89  std::string new_password = "NULL";
90  if (channel->GetPassword() != "")
91  new_password = "'" + channel->GetPassword() + "'";
92 
93  DBerror err;
94  if (!sDatabase.RunQuery(err,
95  " INSERT INTO channels"
96  " (channelID, ownerID, displayName, motd, comparisonKey, memberless, password, mailingList, cspa)"
97  " VALUES (%i, %u, '%s', '%s', '%s', %u, '%s', %u, %u)"
98  " ON DUPLICATE KEY UPDATE"
99  " ownerID=VALUES(ownerID),"
100  " displayName=VALUES(displayName),"
101  " motd=VALUES(motd),"
102  " comparisonKey=VALUES(comparisonKey),"
103  " memberless=VALUES(memberless),"
104  " password=VALUES(password),"
105  " mailingList=VALUES(mailingList),"
106  " cspa=VALUES(cspa)",
107  channel->GetChannelID(),
108  channel->GetOwnerID(),
109  channel->GetDisplayName().c_str(),
110  channel->GetMOTD().c_str(),
111  channel->GetComparisonKey().c_str(),
112  (channel->GetMemberless() ? 1 : 0),
113  new_password.c_str(),
114  (channel->GetMailingList() ? 1 : 0),
115  channel->GetCSPA()))
116  {
117  _log(DATABASE__ERROR, "Error in query: %s", err.c_str());
118  }
119 }
#define sDatabase
Definition: dbcore.h:199
uint16 GetCSPA()
Definition: LSCChannel.h:132
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetChannelID()
Definition: LSCChannel.h:134
uint32 GetOwnerID()
Definition: LSCChannel.h:133
bool GetMailingList()
Definition: LSCChannel.h:128
bool GetMemberless()
Definition: LSCChannel.h:127
std::string GetPassword()
Definition: LSCChannel.h:141
const char * c_str() const
Definition: dbcore.h:48
std::string GetDisplayName()
Definition: LSCChannel.h:138
std::string GetMOTD()
Definition: LSCChannel.h:139
std::string GetComparisonKey()
Definition: LSCChannel.h:140
Definition: dbcore.h:39

Here is the call graph for this function:

void LSCDB::UpdateSubscription ( int32  channelID,
Client pClient 
)

Definition at line 121 of file LSCDB.cpp.

References Client::GetAccountRole(), Client::GetAllianceID(), Client::GetCharacterID(), Client::GetCorporationID(), and sDatabase.

121  {
122  DBerror err;
123  sDatabase.RunQuery(err,
124  " INSERT INTO channelChars "
125  " (channelID, corpID, charID, allianceID, role, extra) "
126  " VALUES (%i, %i, %i, %i, %li, 0) ",
127  channelID, pClient->GetCorporationID(), pClient->GetCharacterID(), pClient->GetAllianceID(), pClient->GetAccountRole());
128 }
int64 GetAccountRole() const
Definition: Client.h:118
#define sDatabase
Definition: dbcore.h:199
int32 GetCharacterID() const
Definition: Client.h:113
int32 GetCorporationID() const
Definition: Client.h:123
int32 GetAllianceID() const
Definition: Client.h:125
Definition: dbcore.h:39

Here is the call graph for this function:


The documentation for this class was generated from the following files: