void CDirectoryTreeCtrl::CheckChanged(HTREEITEM hItem, bool bChecked) { CString strDir = GetFullPath(hItem); if (bChecked) AddShare(strDir); else DelShare(strDir); UpdateParentItems(hItem); GetParent()->SendMessage(WM_COMMAND, USRMSG_ITEMSTATECHANGED, (long)m_hWnd); }
// Unflatten status_t ServerInfo::Unflatten(RequestUnflattener* unflattener) { unflattener->ReadString(fServerName); unflattener->ReadString(fConnectionMethod); int32 count; if (unflattener->ReadInt32(count) != B_OK) return unflattener->GetStatus(); for (int32 i = 0; i < count; i++) { ShareInfo info; unflattener->Visit(this, info); if (info.IsValid()) AddShare(info.GetShareName()); } return unflattener->GetStatus(); }
// constructor SecurityContext::SecurityContext(BMessage* archive) : BArchivable(archive), fUsers(new(std::nothrow) UserMap), fShares(new(std::nothrow) ShareMap), fPermissions(new(std::nothrow) PermissionMap), fNode2Path(new(std::nothrow) NodePathMap), fPath2Node(new(std::nothrow) PathNodeMap) { if (InitCheck() != B_OK) return; status_t error = B_OK; // users BMessage userArchive; for (int32 i = 0; archive->FindMessage("users", i, &userArchive) == B_OK; i++) { User tmpUser; error = tmpUser.Unarchive(&userArchive); if (error != B_OK) return; error = AddUser(tmpUser.GetName(), tmpUser.GetPassword()); if (error != B_OK) return; } // shares BMessage shareArchive; for (int32 i = 0; archive->FindMessage("shares", i, &shareArchive) == B_OK; i++) { Share tmpShare; error = tmpShare.Unarchive(&shareArchive); if (error != B_OK) return; error = AddShare(tmpShare.GetName(), tmpShare.GetPath()); if (error != B_OK) return; } // permissions BMessage permissionsArchive; if (archive->FindMessage("permissions", &permissionsArchive) != B_OK) return; #ifdef ANTARES_TARGET_PLATFORM_DANO const char* userName; #else char* userName; #endif type_code type; for (int32 userIndex = 0; permissionsArchive.GetInfo(B_MESSAGE_TYPE, userIndex, &userName, &type) == B_OK; userIndex++) { User* user = FindUser(userName); if (!user) return; Reference<User> userReference(user, true); error = permissionsArchive.FindMessage(userName, &userArchive); if (error != B_OK) return; // got a user: iterate through its permissions #ifdef ANTARES_TARGET_PLATFORM_DANO const char* path; #else char* path; #endif for (int32 i = 0; userArchive.GetInfo(B_INT32_TYPE, i, &path, &type) == B_OK; i++) { uint32 permissions; error = userArchive.FindInt32(path, (int32*)&permissions); if (error == B_OK) error = SetNodePermissions(path, user, permissions); } } }