상속: IDisposable
예제 #1
0
파일: LocalSync.cs 프로젝트: nandub/DeOps
        public LocalSync(OpCore core)
        {
            Core      = core;
            Network   = core.Network;
            Store     = Network.Store;
            Core.Sync = this;

            GlobalIM = Core.User.Settings.GlobalIM;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            Core.Locations.GetTag[ServiceID, DataTypeSync]      += new GetLocationTagHandler(Locations_GetTag);
            Core.Locations.TagReceived[ServiceID, DataTypeSync] += new LocationTagReceivedHandler(Locations_TagReceived);

            Store.ReplicateEvent[ServiceID, DataTypeSync] += new ReplicateHandler(Store_Replicate);

            Cache              = new VersionedCache(Network, ServiceID, DataTypeSync, true);
            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            // if sync file for ourselves does not exist create
            if (!Cache.FileMap.SafeContainsKey(Core.UserID))
            {
                UpdateLocal();
            }
        }
예제 #2
0
        public LocalSync(OpCore core)
        {
            Core = core;
            Network = core.Network;
            Store = Network.Store;
            Core.Sync = this;

            GlobalIM = Core.User.Settings.GlobalIM;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            Core.Locations.GetTag[ServiceID, DataTypeSync] += new GetLocationTagHandler(Locations_GetTag);
            Core.Locations.TagReceived[ServiceID, DataTypeSync] += new LocationTagReceivedHandler(Locations_TagReceived);

            Store.ReplicateEvent[ServiceID, DataTypeSync] += new ReplicateHandler(Store_Replicate);

            Cache = new VersionedCache(Network, ServiceID, DataTypeSync, true);
            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            // if sync file for ourselves does not exist create
            if (!Cache.FileMap.SafeContainsKey(Core.UserID))
                UpdateLocal();
        }
예제 #3
0
        public BuddyService(OpCore core)
        {
            Core = core;
            Network = Core.Network;
            Core.Buddies = this;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);
            Core.KeepDataCore += new KeepDataHandler(Core_KeepData);
            Core.Locations.KnowOnline += new KnowOnlineHandler(Location_KnowOnline);
            Core.MinuteTimerEvent += Core_MinuteTimer;
            Cache = new VersionedCache(Network, ServiceID, 0, false);

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

            if(!BuddyList.SafeContainsKey(Core.UserID))
                AddBuddy(Core.User.Settings.UserName, Core.User.Settings.KeyPublic);

            BuddyList.SafeTryGetValue(Core.UserID, out LocalBuddy);
        }
예제 #4
0
        public TrustService(OpCore core)
        {
            Core = core;
            Core.Trust = this;

            Store = Core.Network.Store;
            Network = Core.Network;

            Core.SecondTimerEvent += Core_SecondTimer;
            Core.MinuteTimerEvent += Core_MinuteTimer;
            Core.KeepDataCore += new KeepDataHandler(Core_KeepData);

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

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            // piggyback searching for uplink requests on cache file data
            Store.StoreEvent[ServiceID, DataTypeFile] += new StoreHandler(Store_Local);
            Network.Searches.SearchEvent[ServiceID, DataTypeFile] += new SearchRequestHandler(Search_Local);

            Core.Locations.KnowOnline += new KnowOnlineHandler(Location_KnowOnline);

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

            ProjectNames.SafeAdd(0, Core.User.Settings.Operation);

            LinkPath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + ServiceID.ToString();
            Directory.CreateDirectory(LinkPath);

            LocalFileKey = Core.User.Settings.FileKey;

            LoadUplinkReqs();

            LocalTrust = GetTrust(Core.UserID);

            if (LocalTrust == null)
            {
                LocalTrust = new OpTrust(new OpVersionedFile(Core.User.Settings.KeyPublic));
                TrustMap.SafeAdd(Core.UserID, LocalTrust);
            }

            if (!LocalTrust.Loaded)
            {
                LocalTrust.Name = Core.User.Settings.UserName;
                LocalTrust.AddProject(0, true); // operation

                SaveLocal();
            }
        }
예제 #5
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;
        }
예제 #6
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);
            }
        }