コード例 #1
0
ファイル: BoardService.cs プロジェクト: RoelofSol/DeOps
        public BoardService(OpCore core )
        {
            Core       = core;
            Network = Core.Network;
            Protocol = Network.Protocol;
            Store    = Network.Store;
            Trust = Core.Trust;

            Core.SecondTimerEvent += Core_SecondTimer;
            Core.MinuteTimerEvent += Core_MinuteTimer;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            Store.StoreEvent[ServiceID, 0] += new StoreHandler(Store_Local);
            Store.ReplicateEvent[ServiceID, 0] += new ReplicateHandler(Store_Replicate);
            Store.PatchEvent[ServiceID, 0] += new PatchHandler(Store_Patch);

            Network.Searches.SearchEvent[ServiceID, 0] += new SearchRequestHandler(Search_Local);

            Core.Transfers.FileSearch[ServiceID, 0] += new FileSearchHandler(Transfers_FileSearch);
            Core.Transfers.FileRequest[ServiceID, 0] += new FileRequestHandler(Transfers_FileRequest);

            if (Core.Sim != null)
                PruneSize = 16;

            LocalFileKey = Core.User.Settings.FileKey;

            BoardPath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + ServiceID.ToString();

            if (!Directory.Exists(BoardPath))
                Directory.CreateDirectory(BoardPath);

            // get available board header targets
            string[] directories = Directory.GetDirectories(BoardPath);

            SortedDictionary<ulong, ulong> targets = new SortedDictionary<ulong, ulong>(); // key distance to self, value target

            foreach (string path in directories)
            {
                string dir = Path.GetFileName(path); // gets dir name

                ulong id = BitConverter.ToUInt64(Utilities.FromBase64String(dir), 0);

                targets[Core.UserID ^ id] = id;
            }

            // load closest targets
            int loaded = 0;
            foreach (ulong id in targets.Values)
            {
                LoadHeader(id);

                loaded++;
                if (loaded == PruneSize)
                    break;
            }

            Loading = false;
        }
コード例 #2
0
ファイル: LinkTree.cs プロジェクト: RoelofSol/DeOps
        public LinkNode(OpLink link, LinkTree parent)
        {
            Link = link;
            ParentView = parent;
            Trust = parent.Trust;
            Locations = parent.Core.Locations;

            UpdateStatus();
        }
コード例 #3
0
ファイル: ProfileView.cs プロジェクト: RoelofSol/DeOps
        public ProfileView(ProfileService profile, ulong id, uint project)
        {
            InitializeComponent();

            Profiles = profile;
            Core = profile.Core;
            Trust = Core.Trust;

            UserID = id;
            ProjectID = project;
        }
コード例 #4
0
ファイル: EditProfile.cs プロジェクト: RoelofSol/DeOps
        public EditProfile(ProfileService control, ProfileView view)
        {
            InitializeComponent();

            Core     = control.Core;
            Links    = Core.Trust;
            Profiles = control;
            MainView = view;

            TextFields = new Dictionary<string, string>(view.TextFields);
            FileFields = new Dictionary<string, string>(view.FileFields);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: RoelofSol/DeOps
        public MainForm(CoreUI ui, bool sideMode)
            : base(ui.Core)
        {
            InitializeComponent();

            UI = ui;
            Core = ui.Core;
            Trust = Core.Trust;

            UI.ShowView += ShowView;

            Core.NewsUpdate += new NewsUpdateHandler(Core_NewsUpdate);
            Core.KeepDataGui += new KeepDataHandler(Core_KeepData);
            Trust.GuiUpdate  += new LinkGuiUpdateHandler(Trust_Update);

            CommandTree.SelectedLink = Core.UserID;
            CommandTree.SearchOnline = true;

            GuiUtils.SetupToolstrip(TopToolStrip, new OpusColorTable());
            GuiUtils.SetupToolstrip(NavStrip, new NavColorTable());
            GuiUtils.SetupToolstrip(SideToolStrip, new OpusColorTable());
            GuiUtils.SetupToolstrip(SideNavStrip, new NavColorTable());

            GuiUtils.FixMonoDropDownOpening(SideViewsButton, SideViewsButton_DropDownOpening);
            GuiUtils.FixMonoDropDownOpening(SideNewsButton, SideNewsButton_DropDownOpening);
            GuiUtils.FixMonoDropDownOpening(NewsButton, NewsButton_DropDownOpening);
            GuiUtils.FixMonoDropDownOpening(ProjectsButton, ProjectsButton_DropDownOpening);

            if (GuiUtils.IsRunningOnMono())
            {
                foreach (ToolStripItem item in SideToolStrip.Items)
                {
                    //item.DisplayStyle = ToolStripItemDisplayStyle.Text;
                    //item.TextDirection = ToolStripTextDirection.Horizontal;
                    //item.Alignment = ToolStripItemAlignment.Left;
                }

                NetworkButton.Text = "Network";
                SideButton.Text = "Sidebar";
                LockButton.Text = "Lockdown";

                NewsButton.ForeColor = Color.White;
                PopoutButton.ForeColor = Color.White;

                SideViewsButton.ForeColor = Color.White;
                SideNewsButton.ForeColor = Color.White;
                SideHelpButton.ForeColor = Color.White;
            }

            SideNavStrip.Visible = sideMode;
            SideMode = sideMode;
        }
コード例 #6
0
ファイル: EditLink.cs プロジェクト: RoelofSol/DeOps
        public EditLink(OpCore core, uint id)
            : base(core)
        {
            InitializeComponent();

            Core = core;
            Trust = core.Trust;

            ProjectID = id;

            AwayCheckBox.Checked = Core.Locations.LocalAway;
            AwayMessage.Enabled = Core.Locations.LocalAway;
            AwayMessage.Text = Core.User.Settings.AwayMessage;
        }
コード例 #7
0
ファイル: DetailsForm.cs プロジェクト: RoelofSol/DeOps
        public DetailsForm(StorageView view, FolderNode folder)
        {
            InitializeComponent();

            View = view;
            Trust = View.Trust;
            TargetFolder = folder;

            EnableControls(View.Working != null);

            NameBox.Text = folder.Text;

            SizeLabel.Text = "Contains " + Utilities.CommaIze(CalculateFolderSize(folder, 0)) + " Bytes";

            LoadVis(folder.Details.Scope);
        }
コード例 #8
0
ファイル: DetailsForm.cs プロジェクト: RoelofSol/DeOps
        public DetailsForm(StorageView view, FolderNode folder, FileItem file)
        {
            InitializeComponent();

            View = view;
            Core = View.Core;
            Trust = View.Trust;

            TargetFolder = folder;
            TargetFile = file;

            EnableControls(View.Working != null);

            NameBox.Text = file.Text;

            SizeLabel.Text = Utilities.CommaIze(((StorageFile)file.Details).InternalSize) + " Bytes";

            LoadVis(file.Details.Scope);
        }
コード例 #9
0
ファイル: MailView.cs プロジェクト: RoelofSol/DeOps
        public MailView(MailUI ui)
        {
            InitializeComponent();

            UI = ui;
            Mail = ui.Mail;
            Core  = ui.Core;
            Trust = Core.Trust;

            MessageView.SmallImageList = new List<Image>();
            MessageView.SmallImageList.Add(MailRes.recvmail);
            MessageView.SmallImageList.Add(MailRes.sentmail);

            MessageHeader.DocumentText = HeaderPage.ToString();

            GuiUtils.SetupToolstrip(toolStrip1, new OpusColorTable());

            MessageBody.Core = Core;
        }
コード例 #10
0
ファイル: ScheduleView.cs プロジェクト: RoelofSol/DeOps
        public ScheduleView(CoreUI ui, PlanService plans, ulong id, uint project)
        {
            InitializeComponent();

            UI = ui;
            Core = ui.Core;
            Plans = plans;
            Trust = Core.Trust;

            UserID = id;
            ProjectID = project;

            StartTime = Core.TimeNow;
            EndTime   = Core.TimeNow.AddMonths(3);

            GuiUtils.SetupToolstrip(TopStrip, new OpusColorTable());

            MainSplit.Panel2Collapsed = true;

            Core.KeepDataGui += new KeepDataHandler(Core_KeepData);

            PlanStructure.NodeExpanding += new EventHandler(PlanStructure_NodeExpanding);
            PlanStructure.NodeCollapsed += new EventHandler(PlanStructure_NodeCollapsed);

            // set last block so that setdetails shows correctly
            LastBlock = new PlanBlock();
            SetDetails(null);
        }
コード例 #11
0
ファイル: StorageView.cs プロジェクト: RoelofSol/DeOps
        public StorageView(CoreUI ui, StorageService storages, ulong id, uint project)
        {
            InitializeComponent();

            UI = ui;
            Core = ui.Core;
            Storages = storages;
            Trust = Core.Trust;

            UserID = id;
            ProjectID = project;

            splitContainer1.Height = Height - toolStrip1.Height;

            if (UserID == Core.UserID)
                if (Storages.Working.ContainsKey(ProjectID))
                {
                    Working = Storages.Working[ProjectID];
                    IsLocal = true;
                }

            MenuAdd = new ToolStripMenuItem("Add to Files", StorageRes.Add, FileView_Add);
            MenuLock = new ToolStripMenuItem("Lock", StorageRes.Locked, FileView_Lock);
            MenuUnlock = new ToolStripMenuItem("Unlock", StorageRes.Unlocked, FileView_Unlock);
            MenuRestore = new ToolStripMenuItem("Restore", null, FileView_Restore);
            MenuDelete = new ToolStripMenuItem("Delete", StorageRes.Reject, FileView_Delete);
            MenuDetails = new ToolStripMenuItem("Details", StorageRes.details, FileView_Details);

            GuiUtils.SetupToolstrip(toolStrip1, new OpusColorTable());

            RescanLabel.Text = "";
            StatusLabel.Text = "";
        }
コード例 #12
0
ファイル: GoalPanel.cs プロジェクト: RoelofSol/DeOps
        public void Init(GoalsView view)
        {
            View = view;
            Core = View.Core;
            Plans = view.Plans;
            Trust = Core.Trust;

            GoalTree.NodeExpanding += new EventHandler(GoalTree_NodeExpanding);
            GoalTree.NodeCollapsed += new EventHandler(GoalTree_NodeCollapsed);

            GoalTree.ControlPadding = 3;

            GoalTree.SmallImageList = new List<Image>();
            GoalTree.SmallImageList.Add(new Bitmap(16, 16));
            GoalTree.SmallImageList.Add(PlanRes.star);
            GoalTree.SmallImageList.Add(PlanRes.high_goal);
            GoalTree.SmallImageList.Add(PlanRes.low_goal);

            DelegateLink.Hide();
            AddItemLink.Hide();
        }
コード例 #13
0
ファイル: StorageService.cs プロジェクト: RoelofSol/DeOps
        public StorageService(OpCore core)
        {
            Core = core;
            Network = core.Network;
            Protocol = Network.Protocol;
            Store = Network.Store;
            Trust = Core.Trust;

            Core.SecondTimerEvent += Core_SecondTimer;
            Core.MinuteTimerEvent += Core_MinuteTimer;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            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);

            LocalFileKey = Core.User.Settings.FileKey;
            FileCrypt.Key = LocalFileKey;
            FileCrypt.IV = new byte[FileCrypt.IV.Length];

            string rootpath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + ServiceID.ToString() + Path.DirectorySeparatorChar;
            DataPath = rootpath + FileTypeData.ToString();
            WorkingPath = rootpath + FileTypeWorking.ToString();
            ResourcePath = rootpath + FileTypeResource.ToString();

            Directory.CreateDirectory(DataPath);
            Directory.CreateDirectory(WorkingPath);

            // clear resource files so that updates of these files work
            if (Directory.Exists(ResourcePath))
                Directory.Delete(ResourcePath, true);

            Cache = new VersionedCache(Network, ServiceID, FileTypeCache, false);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            // load working headers
            OpStorage local = GetStorage(Core.UserID);

            foreach (uint project in Trust.LocalTrust.Links.Keys)
            {
                if (local != null)
                    LoadHeaderFile(GetWorkingPath(project), local, false, true);

                Working[project] = new WorkingStorage(this, project);

                bool doSave = false;
                foreach (ulong higher in Trust.GetAutoInheritIDs(Core.UserID, project))
                    if (Working[project].RefreshHigherChanges(higher))
                        doSave = true;

                Working[project].AutoIntegrate(doSave);
            }

            foreach (string testPath in Directory.GetFiles(DataPath))
                if (!ReferencedPaths.Contains(testPath))
                    try { File.Delete(testPath); }
                    catch { }

            ReferencedPaths.Clear();
            Loading = false;
        }
コード例 #14
0
ファイル: PlanService.cs プロジェクト: RoelofSol/DeOps
        int SaveInterval = 60*10; // 10 min stagger, prevent cascade up

        #endregion Fields

        #region Constructors

        public PlanService(OpCore core)
        {
            Core = core;
            Network = core.Network;
            Protocol = Network.Protocol;
            Store = Network.Store;
            Trust = Core.Trust;

            if (Core.Sim != null)
                SaveInterval = 30;

            Core.SecondTimerEvent += Core_SecondTimer;

            Cache = new VersionedCache(Network, ServiceID, DataTypeFile, false);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            if (!PlanMap.SafeContainsKey(Core.UserID))
            {
                LocalPlan = new OpPlan(new OpVersionedFile(Core.User.Settings.KeyPublic));
                LocalPlan.Init();
                LocalPlan.Loaded = true;
                PlanMap.SafeAdd(Core.UserID, LocalPlan);
            }
        }
コード例 #15
0
ファイル: LinkTree.cs プロジェクト: RoelofSol/DeOps
        public void Init(TrustService trust)
        {
            Trust = trust;
            Core = trust.Core;

            Core.Locations.GuiUpdate += new LocationGuiUpdateHandler(Locations_Update);
            Trust.GuiUpdate += new LinkGuiUpdateHandler(Trust_Update);
            Core.KeepDataGui += new KeepDataHandler(Core_KeepData);

            SelectedLink = Core.UserID;

            SelectedItemChanged += new EventHandler(LinkTree_SelectedItemChanged);
            NodeExpanding += new EventHandler(LinkTree_NodeExpanding);
            NodeCollapsed += new EventHandler(LinkTree_NodeCollapsed);
        }