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

#include "PyPacket.h"

Collaboration diagram for EVENotificationStream:

Public Member Functions

 EVENotificationStream ()
 
 ~EVENotificationStream ()
 
void Dump (LogType type, PyVisitor &dumper)
 
bool Decode (const std::string &pkt_type, const std::string &notify_type, PyTuple *&payload)
 
PyTupleEncode ()
 
EVENotificationStreamClone () const
 

Public Attributes

std::string notifyType
 
uint32 remoteObject
 
std::string remoteObjectStr
 
PyTupleargs
 

Detailed Description

Definition at line 162 of file PyPacket.h.

Constructor & Destructor Documentation

EVENotificationStream::EVENotificationStream ( )

Definition at line 794 of file PyPacket.cpp.

Referenced by Clone().

795 : notifyType("NO TYPE SET"),
796  remoteObject(0),
797  args(nullptr)
798 {
799 }
std::string notifyType
Definition: PyPacket.h:172

Here is the caller graph for this function:

EVENotificationStream::~EVENotificationStream ( )

Definition at line 801 of file PyPacket.cpp.

References args, and PySafeDecRef.

801  {
803 }
#define PySafeDecRef(op)
Definition: PyRep.h:61

Member Function Documentation

EVENotificationStream * EVENotificationStream::Clone ( ) const

Definition at line 805 of file PyPacket.cpp.

References args, PyRep::AsTuple(), PyTuple::Clone(), and EVENotificationStream().

805  {
807  res->args = args->Clone()->AsTuple();
808  return res;
809 }
PyTuple * AsTuple()
Definition: PyRep.h:138
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:548

Here is the call graph for this function:

bool EVENotificationStream::Decode ( const std::string &  pkt_type,
const std::string &  notify_type,
PyTuple *&  payload 
)

Definition at line 823 of file PyPacket.cpp.

References _log, args, PyRep::AsTuple(), codelog, PyRep::Dump(), PyRep::IntegerValue(), PyTuple::items, notifyType, PyDecRef, PySafeDecRef, remoteObject, remoteObjectStr, and PyRep::StringContent().

823  {
824  PyTuple *payload = in_payload; //copy
825  in_payload = nullptr; //consume
826 
828  args = nullptr;
829 
830  if (payload == nullptr) {
831  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - payload is null.");
832  return false;
833  }
834 
835  if (pkt_type != "macho.Notification") {
836  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - notification payload has unknown string type %s", pkt_type.c_str());
837  PyDecRef(payload);
838  return false;
839  }
840 
841  //decode payload tuple
842  if (payload->items.size() != 2) {
843  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - invalid tuple length %lu", payload->items.size());
844  PyDecRef(payload);
845  return false;
846  }
847  if (!payload->items[0]->IsTuple()) {
848  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - non-tuple payload[0]");
849  PyDecRef(payload);
850  return false;
851  }
852  PyTuple *payload2 = payload->items[0]->AsTuple();
853  if (payload2 == nullptr) {
854  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - payload2 is null.");
855  PyDecRef(payload);
856  return false;
857  }
858 
859  if (payload2->items.size() != 2) {
860  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - invalid tuple2 length %lu", payload2->items.size());
861  PyDecRef(payload);
862  PyDecRef(payload2);
863  return false;
864  }
865 
866  //decode inner payload tuple
867  //ignore tuple 0, it should be an int, dont know what it is
868  if (!payload2->items[1]->IsSubStream()) {
869  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - non-substream type");
870  PyDecRef(payload);
871  PyDecRef(payload2);
872  return false;
873  }
874 
875  PySubStream *ss(payload2->items[1]->AsSubStream());
876  if (ss == nullptr) {
877  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - ss is null.");
878  PyDecRef(payload);
879  PyDecRef(payload2);
880  return false;
881  }
882  ss->DecodeData();
883  if (ss->decoded() == nullptr) {
884  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - Unable to decode call stream");
885  PyDecRef(ss);
886  PyDecRef(payload);
887  PyDecRef(payload2);
888  return false;
889  }
890 
891  if (!ss->decoded()->IsTuple()) {
892  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - packet body does not contain a tuple");
893  PyDecRef(ss);
894  PyDecRef(payload);
895  PyDecRef(payload2);
896  return false;
897  }
898 
899  PyTuple *robjt = ss->decoded()->AsTuple();
900  if (robjt == nullptr) {
901  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - robjt is null.");
902  PyDecRef(ss);
903  PyDecRef(payload);
904  PyDecRef(payload2);
905  return false;
906  }
907  if (robjt->items.size() != 2) {
908  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - packet body has %lu elements, expected %d", robjt->items.size(), 2);
909  PyDecRef(ss);
910  PyDecRef(payload);
911  PyDecRef(payload2);
912  PySafeDecRef(robjt);
913  return false;
914  }
915 
916  //parse first tuple element, remote object
917  if (robjt->items[0]->IsInt()) {
919  remoteObjectStr = "";
920  } else if (robjt->items[0]->IsString()) {
921  remoteObject = 0;
923  } else {
924  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - main tuple[0] has invalid type %s", robjt->items[0]->TypeString());
925  _log(NET__PACKET_ERROR, " in:");
926  payload->Dump( NET__PACKET_ERROR, "" );
927  PyDecRef(ss);
928  PyDecRef(payload);
929  PyDecRef(payload2);
930  PySafeDecRef(robjt);
931  return false;
932  }
933 
934  if (!robjt->items[1]->IsTuple()) {
935  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - main tuple[1] has non-tuple type %s", robjt->items[0]->TypeString());
936  _log(NET__PACKET_ERROR, " it is:");
937  payload->Dump( NET__PACKET_ERROR, "" );
938  PyDecRef(ss);
939  PyDecRef(payload);
940  PyDecRef(payload2);
941  PySafeDecRef(robjt);
942  return false;
943  }
944 
945  PyTuple *subt(robjt->items[1]->AsTuple());
946  if (subt == nullptr) {
947  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - subt is null.");
948  PyDecRef(ss);
949  PyDecRef(payload);
950  PyDecRef(payload2);
951  PySafeDecRef(robjt);
952  return false;
953  }
954  if (subt->items.size() != 2) {
955  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - packet body has %lu elements, expected %d", subt->items.size(), 2);
956  PyDecRef(ss);
957  PyDecRef(payload);
958  PyDecRef(payload2);
959  PySafeDecRef(subt);
960  PySafeDecRef(robjt);
961  return false;
962  }
963 
964  //parse first tuple element, remote object
965  if (subt->items[0]->IsInt()) {
966  //PyInt *tuple0 = (PyInt *) maint->items[0];
967  //no idea what this is.
968  } else {
969  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - sub tuple[0] has invalid type %s", subt->items[0]->TypeString());
970  _log(NET__PACKET_ERROR, " in:");
971  payload->Dump( NET__PACKET_ERROR, "" );
972  PyDecRef(ss);
973  PyDecRef(payload);
974  PyDecRef(payload2);
975  PySafeDecRef(subt);
976  PySafeDecRef(robjt);
977  return false;
978  }
979 
980  if (!subt->items[1]->IsTuple()) {
981  codelog(NET__PACKET_ERROR, "EVENotificationStream::Decode() - subt tuple[1] has non-tuple type %s", robjt->items[0]->TypeString());
982  _log(NET__PACKET_ERROR, " it is:");
983  payload->Dump( NET__PACKET_ERROR, "" );
984  PyDecRef(ss);
985  PyDecRef(payload);
986  PyDecRef(payload2);
987  PySafeDecRef(subt);
988  PySafeDecRef(robjt);
989  return false;
990  }
991 
992  args = subt->items[1]->AsTuple();
993  notifyType = notify_type;
994 
995  PyDecRef(ss);
996  PyDecRef(payload);
997  PyDecRef(payload2);
998  PySafeDecRef(subt);
999  PySafeDecRef(robjt);
1000  return true;
1001 }
PyTuple * AsTuple()
Definition: PyRep.h:138
static std::string StringContent(PyRep *pRep)
Definition: PyRep.cpp:103
#define _log(type, fmt,...)
Definition: logsys.h:124
Python tuple.
Definition: PyRep.h:567
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
std::string notifyType
Definition: PyPacket.h:172
#define codelog(type, fmt,...)
Definition: logsys.h:128
#define PyDecRef(op)
Definition: PyRep.h:57
#define PySafeDecRef(op)
Definition: PyRep.h:61
storage_type items
Definition: PyRep.h:628
static int64 IntegerValue(PyRep *pRep)
Definition: PyRep.cpp:118
std::string remoteObjectStr
Definition: PyPacket.h:175

Here is the call graph for this function:

void EVENotificationStream::Dump ( LogType  type,
PyVisitor dumper 
)

Definition at line 811 of file PyPacket.cpp.

References _log, args, notifyType, remoteObject, remoteObjectStr, and PyTuple::visit().

Referenced by EVECollectDispatcher::Handle_Notify().

812 {
813  _log(type, "Notification: %s", notifyType.c_str());
814  if (remoteObject == 0)
815  _log(type, " Remote Object: %s", remoteObjectStr.c_str());
816  else
817  _log(type, " Remote Object: %u", remoteObject);
818 
819  _log(type, " Arguments:");
820  args->visit( dumper );
821 }
#define _log(type, fmt,...)
Definition: logsys.h:124
std::string notifyType
Definition: PyPacket.h:172
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:553
std::string remoteObjectStr
Definition: PyPacket.h:175

Here is the call graph for this function:

Here is the caller graph for this function:

PyTuple * EVENotificationStream::Encode ( )

Definition at line 1003 of file PyPacket.cpp.

References args, PyStatic, and PyTuple::SetItem().

Referenced by Client::SendNotification().

1003  {
1004  PyTuple *t4 = new PyTuple(2);
1005  t4->SetItem(0, PyStatic.NewOne());
1006  t4->SetItem(1, args); // no need to clone here. set actual rep in item, and it will be cleaned up by d'tor later
1007  PyTuple *t3 = new PyTuple(2);
1008  t3->SetItem(0, new PyInt(0));
1009  t3->SetItem(1, t4);
1010  PyTuple *t2 = new PyTuple(2);
1011  t2->SetItem(0, new PyInt(0));
1012  t2->SetItem(1, new PySubStream(t3));
1013  PyTuple *t1 = new PyTuple(1);
1014  t1->SetItem(0, t2);
1015  return t1;
1016 }
Python tuple.
Definition: PyRep.h:567
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
Python integer.
Definition: PyRep.h:231
#define PyStatic
Definition: PyRep.h:1209

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::string EVENotificationStream::notifyType

Definition at line 172 of file PyPacket.h.

Referenced by Decode(), Dump(), and Client::SendNotification().

uint32 EVENotificationStream::remoteObject

Definition at line 174 of file PyPacket.h.

Referenced by EntityList::Broadcast(), Decode(), Dump(), and Client::SendNotification().

std::string EVENotificationStream::remoteObjectStr

Definition at line 175 of file PyPacket.h.

Referenced by Decode(), and Dump().


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