コード例 #1
0
ファイル: ScheduleView.cs プロジェクト: nandub/DeOps
        public override string GetTitle(bool small)
        {
            if (small)
            {
                return("Schedule");
            }

            string title = "";

            if (UserID == Core.UserID)
            {
                title += "My ";
            }
            else
            {
                title += Core.GetName(UserID) + "'s ";
            }

            if (ProjectID != 0)
            {
                title += Trust.GetProjectName(ProjectID) + " ";
            }

            title += "Schedule";

            return(title);
        }
コード例 #2
0
ファイル: AddUsersDialog.cs プロジェクト: nandub/DeOps
        private void LoadTrustTree()
        {
            TrustService trust = Core.Trust;

            // add projects to combo
            trust.ProjectRoots.LockReading(delegate()
            {
                foreach (uint id in trust.ProjectRoots.Keys)
                {
                    string name = "";

                    if (id == 0)
                    {
                        name = "Main";
                    }
                    else
                    {
                        name = trust.GetProjectName(id);
                    }

                    ProjectCombo.Items.Add(new AddProjectItem(id, name));
                }
            });

            TrustTree.FirstLineBlank = false;
            TrustTree.Init(trust);

            TrustTree.MultiSelect = true;
        }
コード例 #3
0
        public void Dispose()
        {
            if (Disposing != null)
            {
                Disposing();
            }

            HashFiles.Dispose();
            CopyFiles.Dispose();

            // lock down working
            List <LockError> errors = new List <LockError>();

            foreach (WorkingStorage working in Working.Values)
            {
                working.LockAll(errors);

                if (working.Modified)
                {
                    working.SaveWorking();
                }
            }
            Working.Clear();

            // delete completely folders made for other user's storages
            Trust.ProjectRoots.LockReading(delegate()
            {
                foreach (uint project in Trust.ProjectRoots.Keys)
                {
                    string path  = Core.User.RootPath + Path.DirectorySeparatorChar + Trust.GetProjectName(project) + " Storage";
                    string local = Core.GetName(Core.UserID);

                    if (Directory.Exists(path))
                    {
                        foreach (string dir in Directory.GetDirectories(path))
                        {
                            if (Path.GetFileName(dir) != local)
                            {
                                try
                                {
                                    Directory.Delete(dir, true);
                                }
                                catch
                                {
                                    errors.Add(new LockError(dir, "", false, LockErrorType.Blocked));
                                }
                            }
                        }
                    }
                }
            });

            // security warning: could not secure these files
            if (errors.Count > 0)
            {
                string message = "Security Warning: Not able to delete these files, please do it manually\n";

                foreach (LockError error in errors)
                {
                    if (error.Type == LockErrorType.Blocked)
                    {
                        message += error.Path;
                    }
                }

                Core.UserMessage(message);
            }

            // kill events
            Core.SecondTimerEvent -= Core_SecondTimer;
            Core.MinuteTimerEvent -= Core_MinuteTimer;

            Network.CoreStatusChange -= new StatusChange(Network_StatusChange);

            Cache.FileAquired -= new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved -= new FileRemovedHandler(Cache_FileRemoved);
            Cache.Dispose();

            Core.Transfers.FileSearch[ServiceID, FileTypeData]  -= new FileSearchHandler(Transfers_DataFileSearch);
            Core.Transfers.FileRequest[ServiceID, FileTypeData] -= new FileRequestHandler(Transfers_DataFileRequest);

            Core.Trust.LinkUpdate -= new LinkUpdateHandler(Trust_Update);
        }
コード例 #4
0
ファイル: LinkTree.cs プロジェクト: nandub/DeOps
        private void RefreshOperationTree()
        {
            BeginUpdate();

            // save selected
            LinkNode selected = GetSelected();

            // save visible while unloading
            List <ulong> visible = new List <ulong>();

            foreach (TreeListNode node in Nodes)
            {
                if (node.GetType() == typeof(LinkNode))
                {
                    UnloadNode((LinkNode)node, visible);
                }
            }

            NodeMap.Clear();
            Nodes.Clear();

            // white space
            if (FirstLineBlank)
            {
                Nodes.Add(new LabelNode(""));
            }

            if (!Trust.ProjectRoots.SafeContainsKey(Project))
            {
                EndUpdate();
                return;
            }

            string rootname = Core.User.Settings.Operation;

            if (Project != 0)
            {
                rootname = Trust.GetProjectName(Project);
            }

            // operation
            ProjectNode      = new ProjectNode(rootname, Project);
            ProjectNode.Font = TrustedFont;
            Nodes.Add(ProjectNode);

            // white space
            Nodes.Add(new LabelNode(""));

            // unlinked
            UnlinkedNode      = new ProjectNode("Untrusted", 0);
            UnlinkedNode.Font = UntrustedFont;

            Nodes.Add(UnlinkedNode);


            // if forced, load specific node as root
            if (ForceRootID != 0)
            {
                OpLink root = Trust.GetLink(ForceRootID, Project);

                if (root != null)
                {
                    SetupRoot(root);
                }
            }

            // get roots for specific project
            else
            {
                ThreadedList <OpLink> roots = null;
                if (Trust.ProjectRoots.SafeTryGetValue(Project, out roots))
                {
                    roots.LockReading(delegate()
                    {
                        foreach (OpLink root in roots)
                        {
                            SetupRoot(root);
                        }
                    });
                }
            }

            // show unlinked if there's something to show
            if (Nodes.IndexOf(UnlinkedNode) + 1 == Nodes.Count)
            {
                UnlinkedNode.Text = "";
            }
            else
            {
                UnlinkedNode.Text = "Untrusted";
            }

            // restore visible
            foreach (ulong id in visible)
            {
                foreach (TreeListNode node in Nodes)
                {
                    if (node.GetType() == typeof(LinkNode))
                    {
                        List <ulong> uplinks = Trust.GetUnconfirmedUplinkIDs(id, Project);
                        uplinks.Add(id);
                        VisiblePath((LinkNode)node, uplinks);
                    }
                }
            }

            // restore selected
            if (selected != null)
            {
                if (NodeMap.ContainsKey(selected.Link.UserID))
                {
                    Select(NodeMap[selected.Link.UserID]);
                }
            }

            EndUpdate();
        }