void DirEntity::UnpackDataObjects(BaseMessage& theMsgR, DataObjectTypeSet& theSetR, unsigned long theFlags) { WTRACE("DirEntity::UnpackDataObjects"); unsigned short aCt = theMsgR.ReadShort(); WDBG_LL("DirEntity::UnpackDataObjects Unpacking data objects, size=" << aCt); theSetR.clear(); bool unpackType = ((theFlags & WONMsg::GF_ADDDOTYPE) != 0); bool unpackData = ((theFlags & WONMsg::GF_ADDDODATA) != 0); for (int i=0; i < aCt; i++) { DataObject anObj; if (unpackType) { unsigned char aLen = theMsgR.ReadByte(); anObj.GetDataType().assign(reinterpret_cast<const unsigned char*>(theMsgR.ReadBytes(aLen)), aLen); } else anObj.GetDataType().assign(reinterpret_cast<const unsigned char*>(&i), sizeof(i)); if (unpackData) { unsigned short aLen = theMsgR.ReadShort(); anObj.GetData().assign(reinterpret_cast<const unsigned char*>(theMsgR.ReadBytes(aLen)), aLen); } theSetR.insert(anObj); } }
void DirEntity::Unpack(BaseMessage& theMsgR, unsigned long theGetFlags) { WTRACE("DirEntity::Unpack"); WDBG_LL("DirEntity::Unpack Unpacking entity"); // Read type if needed if (theGetFlags & WONMsg::GF_ADDTYPE) mType = theMsgR.ReadByte(); // Entity specific fields switch (mType) { case ET_DIRECTORY: // Read dir path if needed if (theGetFlags & WONMsg::GF_DIRADDPATH) theMsgR.ReadWString(mPath); //Read dir name if needed if (theGetFlags & WONMsg::GF_DIRADDNAME) theMsgR.ReadWString(mName); // Read dir visibility if needed if (theGetFlags & WONMsg::GF_DIRADDVISIBLE) mVisible = theMsgR.ReadByte(); break; case ET_SERVICE: // Read serv path if needed if (theGetFlags & WONMsg::GF_SERVADDPATH) theMsgR.ReadWString(mPath); // Read serv name if needed if (theGetFlags & WONMsg::GF_SERVADDNAME) theMsgR.ReadWString(mName); // Read serv netaddress if needed if (theGetFlags & WONMsg::GF_SERVADDNETADDR) { unsigned char aCt = theMsgR.ReadByte(); mNetAddress.assign(reinterpret_cast<const unsigned char*>(theMsgR.ReadBytes(aCt)), aCt); } break; } // Read displayName if needed if (theGetFlags & WONMsg::GF_ADDDISPLAYNAME) theMsgR.ReadWString(mDisplayName); // Read lifespan if needed if (theGetFlags & WONMsg::GF_ADDLIFESPAN) mLifespan = theMsgR.ReadLong(); // Read create date if needed if (theGetFlags & WONMsg::GF_ADDCREATED) mCreated = theMsgR.ReadLong(); // Read touched date if needed if (theGetFlags & WONMsg::GF_ADDTOUCHED) mTouched = theMsgR.ReadLong(); // Read CRC if needed if (theGetFlags & WONMsg::GF_ADDCRC) mCRC = theMsgR.ReadLong(); // Add UserIds if needed if (theGetFlags & WONMsg::GF_ADDUIDS) { mCreateId = theMsgR.ReadLong(); mTouchId = theMsgR.ReadLong(); } // Read Data Objects if needed if (theGetFlags & WONMsg::GF_ADDDATAOBJECTS) UnpackDataObjects(theMsgR, mDataObjects, theGetFlags); // Read ACLs if needed (deferred) if (theGetFlags & WONMsg::GF_ADDACLS) UnpackACLs(theMsgR); }