예제 #1
0
파일: OpCore.cs 프로젝트: nandub/DeOps
        public bool NewsWorthy(ulong id, uint project, bool localRegionOnly)
        {
            //crit - if in buddy list, if non-local self
            //should really be done per compontnt (board only cares about local, mail doesnt care at all, neither does chat)

            // if not self, higher, adjacent or lower direct then true
            if (id == UserID || Trust.LocalTrust == null)
            {
                return(false);
            }

            if (!localRegionOnly && Trust.IsHigher(id, project))
            {
                return(true);
            }

            if (localRegionOnly && Trust.IsHigherDirect(id, project))
            {
                return(true);
            }

            if (Trust.IsAdjacent(id, project))
            {
                return(true);
            }

            if (Trust.IsLowerDirect(id, project))
            {
                return(true);
            }

            return(false);
        }
예제 #2
0
        private void ReceiveMessage(ChatText message, RudpSession session)
        {
            if (Core.Buddies.IgnoreList.SafeContainsKey(session.UserID))
            {
                return;
            }

            // remote's command low, is my command high
            // do here otherwise have to send custom roomID packets to selfs/lowers/highers

            if (Trust != null && session.UserID != Core.UserID)
            {
                // if check fails then it is loop node sending data, keep it unchanged
                if (message.Kind == RoomKind.Command_High && Trust.IsLowerDirect(session.UserID, message.ProjectID))
                {
                    message.Kind = RoomKind.Command_Low;
                }

                else if (message.Kind == RoomKind.Command_Low && Trust.IsHigher(session.UserID, message.ProjectID))
                {
                    message.Kind = RoomKind.Command_High;
                }

                else if (message.Kind == RoomKind.Live_High)
                {
                    message.Kind = RoomKind.Live_Low;
                }

                else if (message.Kind == RoomKind.Live_Low)
                {
                    message.Kind = RoomKind.Live_High;
                }
            }

            ulong id = IsCommandRoom(message.Kind) ? GetRoomID(message.ProjectID, message.Kind) : message.RoomID;

            ChatRoom room = null;

            // if not in room let remote user know
            if (!RoomMap.TryGetValue(id, out room) ||
                !room.Active)
            {
                SendStatus(session);
                return;
            }

            // if sender not in room
            if (!room.Members.SafeContains(session.UserID))
            {
                return;
            }

            if (!ChatNewsUpdate)
            {
                ChatNewsUpdate = true;
                Core.MakeNews(ServiceIDs.Chat, Core.GetName(session.UserID) + " is chatting", session.UserID, 0, false);
            }

            ProcessMessage(room, new ChatMessage(Core, session, message));
        }
예제 #3
0
        private void Cache_FileAquired(OpVersionedFile file)
        {
            // get profile
            OpProfile prevProfile = GetProfile(file.UserID);

            OpProfile newProfile = new OpProfile(file);

            ProfileMap.SafeAdd(file.UserID, newProfile);


            if (file.UserID == Core.UserID)
            {
                LocalProfile = newProfile;
            }

            if ((newProfile == LocalProfile) || (prevProfile != null && prevProfile.Loaded))
            {
                LoadProfile(newProfile.UserID);
            }


            // update subs
            if (Network.Established)
            {
                List <LocationData> locations = new List <LocationData>();

                Trust.ProjectRoots.LockReading(delegate()
                {
                    foreach (uint project in Trust.ProjectRoots.Keys)
                    {
                        if (newProfile.UserID == Core.UserID || Trust.IsHigher(newProfile.UserID, project))
                        {
                            Trust.GetLocsBelow(Core.UserID, project, locations);
                        }
                    }
                });

                Store.PublishDirect(locations, newProfile.UserID, ServiceID, 0, file.SignedHeader);
            }

            if (ProfileUpdate != null)
            {
                Core.RunInGuiThread(ProfileUpdate, newProfile);
            }

            if (Core.NewsWorthy(newProfile.UserID, 0, false))
            {
                Core.MakeNews(ServiceIDs.Profile, "Profile updated by " + Core.GetName(newProfile.UserID), newProfile.UserID, 0, true);
            }
        }
예제 #4
0
파일: GoalPanel.cs 프로젝트: nandub/DeOps
        bool CheckGoal(ulong higher, PlanGoal goal)
        {
            // if only branch
            if (MineOnly.Checked && View.UserID != goal.Person)
            {
                if (!Trust.IsHigher(View.UserID, goal.Person, View.ProjectID) && // show only if person is higher than self
                    !Trust.IsLower(View.UserID, goal.Person, View.ProjectID))    // or is lower than self
                {
                    return(false);
                }
            }

            // only subordinates can have goals assigned
            if (!Trust.IsLower(higher, goal.Person, View.ProjectID))
            {
                return(false);
            }

            return(true);
        }
예제 #5
0
        void Cache_FileAquired(OpVersionedFile file)
        {
            // unload old file
            OpStorage prevStorage = GetStorage(file.UserID);

            if (prevStorage != null)
            {
                string oldPath = GetFilePath(prevStorage);

                UnloadHeaderFile(oldPath, prevStorage.File.Header.FileKey);
            }

            OpStorage newStorage = new OpStorage(file);

            StorageMap.SafeAdd(file.UserID, newStorage);


            LoadHeaderFile(GetFilePath(newStorage), newStorage, false, false);

            // record changes of higher nodes for auto-integration purposes
            Trust.ProjectRoots.LockReading(delegate()
            {
                foreach (uint project in Trust.ProjectRoots.Keys)
                {
                    List <ulong> inheritIDs = Trust.GetAutoInheritIDs(Core.UserID, project);

                    if (Core.UserID == newStorage.UserID || inheritIDs.Contains(newStorage.UserID))
                    {
                        // doesnt get called on startup because working not initialized before headers are loaded
                        if (Working.ContainsKey(project))
                        {
                            bool doSave = Working[project].RefreshHigherChanges(newStorage.UserID);

                            if (!Loading && !SavingLocal)
                            {
                                Working[project].AutoIntegrate(doSave);
                            }
                        }
                    }
                }
            });

            // update subs - this ensures file not propagated lower until we have it (prevents flood to original poster)
            if (Network.Established)
            {
                List <LocationData> locations = new List <LocationData>();

                Trust.ProjectRoots.LockReading(delegate()
                {
                    foreach (uint project in Trust.ProjectRoots.Keys)
                    {
                        if (newStorage.UserID == Core.UserID || Trust.IsHigher(newStorage.UserID, project))
                        {
                            Trust.GetLocsBelow(Core.UserID, project, locations);
                        }
                    }
                });

                Store.PublishDirect(locations, newStorage.UserID, ServiceID, FileTypeCache, file.SignedHeader);
            }

            if (StorageUpdate != null)
            {
                Core.RunInGuiThread(StorageUpdate, newStorage);
            }

            if (Core.NewsWorthy(newStorage.UserID, 0, false))
            {
                Core.MakeNews(ServiceIDs.Storage, "File System updated by " + Core.GetName(newStorage.UserID), newStorage.UserID, 0, false);
            }
        }
예제 #6
0
파일: PlanService.cs 프로젝트: nandub/DeOps
        private void Cache_FileAquired(OpVersionedFile file)
        {
            OpPlan prevPlan = GetPlan(file.UserID, false);

            OpPlan newPlan = new OpPlan(file);

            PlanMap.SafeAdd(newPlan.UserID, newPlan);

            if (file.UserID == Core.UserID)
            {
                LocalPlan = newPlan;
            }

            if ((newPlan == LocalPlan) || (prevPlan != null && prevPlan.Loaded)) // if loaded, reload
            {
                LoadPlan(newPlan.UserID);
            }


            // update subs
            if (Network.Established)
            {
                List <LocationData> locations = new List <LocationData>();

                Trust.ProjectRoots.LockReading(delegate()
                {
                    foreach (uint project in Trust.ProjectRoots.Keys)
                    {
                        if (newPlan.UserID == Core.UserID || Trust.IsHigher(newPlan.UserID, project))
                        {
                            Trust.GetLocsBelow(Core.UserID, project, locations);
                        }
                    }
                });

                Store.PublishDirect(locations, newPlan.UserID, ServiceID, DataTypeFile, newPlan.File.SignedHeader);
            }


            // see if we need to update our own goal estimates
            if (newPlan.UserID != Core.UserID && LocalPlan != null)
            {
                Trust.ProjectRoots.LockReading(delegate()
                {
                    foreach (uint project in Trust.ProjectRoots.Keys)
                    {
                        if (Trust.IsLower(Core.UserID, newPlan.UserID, project)) // updated plan must be lower than us to have an effect
                        {
                            foreach (int ident in LocalPlan.GoalMap.Keys)
                            {
                                if (!newPlan.Loaded)
                                {
                                    LoadPlan(newPlan.UserID);
                                }

                                // if updated plan part of the same goal ident, re-estimate our own goals, incorporating update's changes
                                if (newPlan.GoalMap.ContainsKey(ident) || newPlan.ItemMap.ContainsKey(ident))
                                {
                                    foreach (PlanGoal goal in LocalPlan.GoalMap[ident])
                                    {
                                        int completed = 0, total = 0;

                                        GetEstimate(goal, ref completed, ref total);

                                        if (completed != goal.EstCompleted || total != goal.EstTotal)
                                        {
                                            goal.EstCompleted = completed;
                                            goal.EstTotal     = total;

                                            if (RunSaveLocal == 0) // if countdown not started, start
                                            {
                                                RunSaveLocal = SaveInterval;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                });
            }


            Core.RunInGuiThread(PlanUpdate, newPlan);

            if (Core.NewsWorthy(newPlan.UserID, 0, false))
            {
                Core.MakeNews(ServiceIDs.Plan, "Plan updated by " + Core.GetName(newPlan.UserID), newPlan.UserID, 0, false);
            }
        }