aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local/LocalInventoryService.cs
blob: af58d332863aa7ba559371ed2cbe144014cd291f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Data;
using OpenSim.Framework.Types;
using OpenSim.Framework.UserManagement;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.InventoryServiceBase;
using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder;

namespace OpenSim.Region.Communications.Local
{
    public class LocalInventoryService : InventoryServiceBase , IInventoryServices
    {

        public LocalInventoryService()
        {

        }

        public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack)
        {
            List<InventoryFolderBase> folders = this.RequestFirstLevelFolders(userID);
            InventoryFolder rootFolder = null;

            //need to make sure we send root folder first
            foreach (InventoryFolderBase folder in folders)
            {
                if (folder.parentID == libsecondlife.LLUUID.Zero)
                {
                    InventoryFolder newfolder = new InventoryFolder(folder);
                    rootFolder = newfolder;
                    folderCallBack(userID, newfolder);
                }
            }

            if (rootFolder != null)
            {
                foreach (InventoryFolderBase folder in folders)
                {
                    if (folder.folderID != rootFolder.folderID)
                    {
                        InventoryFolder newfolder = new InventoryFolder(folder);
                        folderCallBack(userID, newfolder);

                        List<InventoryItemBase> items = this.RequestFolderItems(newfolder.folderID);
                        foreach (InventoryItemBase item in items)
                        {
                            itemCallBack(userID, item);
                        }
                    }
                }
            }
        }

        public void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder)
        {
            this.AddFolder(folder);
        }

        public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
        {
            this.AddItem(item);
        }

        public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
        {
            this.deleteItem(item);
        }
    }
}