void DirEntity::UnpackACLs(BaseMessage& theMsgR) { WTRACE("DirEntity::UnpackACLs"); unsigned short anACLCt = theMsgR.ReadShort(); WDBG_LL("DirEntity::UnpackACLs Unpacking ACLs, size=" << anACLCt); mACLs.clear(); for (int i=0; i < anACLCt; i++) { DirACL anACL; anACL.mType = static_cast<WONMsg::DirG2ACLType>(theMsgR.ReadByte()); unsigned short aPermCt = theMsgR.ReadShort(); for (int j=0; j < aPermCt; j++) { Permission aPerm; aPerm.mUserId = theMsgR.ReadLong(); aPerm.mCommunityId = theMsgR.ReadLong(); aPerm.mTrustLevel = theMsgR.ReadShort(); anACL.mACL.insert(aPerm); } mACLs.push_back(anACL); } }
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); }