aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs
blob: b95219c58bab514ff8587855a81f4052d1292a7a (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.Text;
using OpenGrid.Framework.Data;
using libsecondlife;

namespace OpenGrid.Framework.Data.DB4o
{
    public class DB4oUserData : IUserData
    {
        DB4oUserManager manager;

        public void Initialise()
        {
            manager = new DB4oUserManager("userprofiles.yap");
        }

        public UserProfileData getUserByUUID(LLUUID uuid)
        {
            if(manager.userProfiles.ContainsKey(uuid))
                return manager.userProfiles[uuid];
            return null;
        }

        public UserProfileData getUserByName(string name)
        {
            return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
        }

        public UserProfileData getUserByName(string fname, string lname)
        {
            foreach (UserProfileData profile in manager.userProfiles.Values)
            {
                if (profile.username == fname && profile.surname == lname)
                    return profile;
            }
            return null;
        }

        public UserAgentData getAgentByUUID(LLUUID uuid)
        {   
            try
            {
                return getUserByUUID(uuid).currentAgent;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        public UserAgentData getAgentByName(string name)
        {
            return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
        }

        public UserAgentData getAgentByName(string fname, string lname)
        {
            try
            {
                return getUserByName(fname,lname).currentAgent;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        public void addNewUserProfile(UserProfileData user)
        {
            manager.AddRow(user);
        }

        public void addNewUserAgent(UserAgentData agent)
        {
            // Do nothing. yet.
        }

        public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
        {
            return true;
        }

        public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
        {
            return true;
        }


        public string getName()
        {
            return "DB4o Userdata";
        }

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