aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
blob: 546713e6ffaf999160176ab252aebc2f34187916 (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
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Text;
using OpenGrid.Framework.Data;
using libsecondlife;


namespace OpenGrid.Framework.Data.DB4o
{
    class DB4oGridData : IGridData
    {
        DB4oGridManager manager;

        public void Initialise() {
             manager = new DB4oGridManager("gridserver.yap");
        }

        public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
        {
            return null;
        }

        public SimProfileData GetProfileByHandle(ulong handle) {
            lock (manager.simProfiles)
            {
                foreach (LLUUID UUID in manager.simProfiles.Keys)
                {
                    if (manager.simProfiles[UUID].regionHandle == handle)
                    {
                        return manager.simProfiles[UUID];
                    }
                }
            }
            throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
        }

        public SimProfileData GetProfileByLLUUID(LLUUID uuid)
        {
            lock (manager.simProfiles)
            {
                if (manager.simProfiles.ContainsKey(uuid))
                    return manager.simProfiles[uuid];
            }
            throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
        }

        public DataResponse AddProfile(SimProfileData profile)
        {
            lock (manager.simProfiles)
            {
                if (manager.AddRow(profile))
                {
                    return DataResponse.RESPONSE_OK;
                }
                else
                {
                    return DataResponse.RESPONSE_ERROR;
                }
            }
        }

        public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
            if (manager.simProfiles[uuid].regionRecvKey == key)
                return true;
            return false;
        }

        public void Close()
        {
            manager = null;
        }

        public string getName()
        {
            return "DB4o Grid Provider";
        }

        public string getVersion()
        {
            return "0.1";
        }
    }
}