Exemple #1
0
 public BrowseItem(ushort browseid, ISharedFile file)
 {
     BrowseId = browseid;
     Type     = file.Type;
     Size     = file.Size;
     Content  = file.Content;
 }
Exemple #2
0
 public SearchHit(ushort searchid, IClient user, ISharedFile file)
 {
     SearchId   = searchid;
     Type       = file.Type;
     Size       = file.Size;
     Content    = file.Content;
     Username   = user.Name;
     ExternalIp = user.ExternalIp;
     DCPort     = user.ListenPort;
     NodeIp     = user.NodeIp;
     NodePort   = user.NodePort;
     LocalIp    = user.LocalIp;
 }
Exemple #3
0
        public void Setup()
        {
            this.storage = new List <IAlarm>();

            this.serializeArgs = null;
            this.serializer    = Substitute.For <IRepositorySerializer>();
            this.serializer.Deserialize(null).ReturnsForAnyArgs(this.storage);
            this.serializer.WhenForAnyArgs(x => x.Serialize(null, null)).Do(x => this.serializeArgs = (IEnumerable <IAlarm>)x.Args()[0]);

            this.stream            = new MemoryStream();
            this.watcher           = Substitute.For <IFileWatcher>();
            this.sharedFileFactory = Substitute.For <ISharedFileFactory>();
            this.sharedFile        = Substitute.For <ISharedFile>();
            this.sharedFileFactory.Write(TEST_PATH).Returns(this.sharedFile);
            this.sharedFileFactory.Read(TEST_PATH).Returns(this.sharedFile);
            this.sharedFile.Stream.Returns(this.stream);
        }
Exemple #4
0
        public bool OnFileReceived(IClient client, ISharedFile file)
        {
            bool ret = true;

            foreach (var plugin in this)
            {
                try {
                    if (plugin.Enabled && !plugin.Plugin.OnFileReceived(client, file))
                    {
                        ret = false;
                    }
                }
                catch (Exception ex) {
                    OnError(plugin, nameof(OnFileReceived), ex);
                }
            }

            return(ret);
        }
Exemple #5
0
        //This plugin function has been disabled from being passed to scripts.
        //It can be pretty resource intensive and not recommended for performance reasons.
        public override bool OnFileReceived(IClient client, ISharedFile file)
        {
            bool ret = true;

            /*
             * lock (scripts) {
             *  foreach (var s in scripts) {
             *
             *      User user = s.Room.Users.Items.Find((x) => x.Client == client);
             *      if (user == null) continue;
             *
             *      try {
             *          bool b = s.Engine.CallGlobalFunction<bool>("onFileReceived", user, ifile);
             *          if (!b) ret = false;
             *      }
             *      catch (JavaScriptException jex) {
             *      }
             *  }
             * }
             */
            return(ret);
        }
Exemple #6
0
 public bool OnFileReceived(IClient client, ISharedFile file)
 {
     return(true);
 }
            public static async void Release(ISharedFile file, int delay)
            {
                await Task.Delay(delay);

                file.Dispose();
            }
        public void Setup()
        {
            this.storage = new List<IAlarm>();

            this.serializeArgs = null;
            this.serializer = Substitute.For<IRepositorySerializer>();
            this.serializer.Deserialize(null).ReturnsForAnyArgs(this.storage);
            this.serializer.WhenForAnyArgs(x => x.Serialize(null, null)).Do(x => this.serializeArgs = (IEnumerable<IAlarm>)x.Args()[0]);

            this.stream = new MemoryStream();
            this.watcher = Substitute.For<IFileWatcher>();
            this.sharedFileFactory = Substitute.For<ISharedFileFactory>();
            this.sharedFile = Substitute.For<ISharedFile>();
            this.sharedFileFactory.Write(TEST_PATH).Returns(this.sharedFile);
            this.sharedFileFactory.Read(TEST_PATH).Returns(this.sharedFile);
            this.sharedFile.Stream.Returns(this.stream);
        }