Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        public LinkNode(OpLink link, LinkTree parent)
        {
            Link = link;
            ParentView = parent;
            Trust = parent.Trust;
            Locations = parent.Core.Locations;

            UpdateStatus();
        }
Exemplo n.º 3
0
        public ProfileView(ProfileService profile, ulong id, uint project)
        {
            InitializeComponent();

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

            UserID = id;
            ProjectID = project;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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 = "";
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        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;
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        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);
        }