aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AvatarService/AvatarService.cs
diff options
context:
space:
mode:
authorMelanie2010-01-04 02:52:43 +0000
committerMelanie2010-01-04 02:52:43 +0000
commit6e8d94685d4e5784398ff656fdab169310dc219a (patch)
tree41afa2c07f493c013a9535e4ea81a7866f5620f2 /OpenSim/Services/AvatarService/AvatarService.cs
parentSome work on avatar service. Retrieval and storage done (diff)
downloadopensim-SC_OLD-6e8d94685d4e5784398ff656fdab169310dc219a.zip
opensim-SC_OLD-6e8d94685d4e5784398ff656fdab169310dc219a.tar.gz
opensim-SC_OLD-6e8d94685d4e5784398ff656fdab169310dc219a.tar.bz2
opensim-SC_OLD-6e8d94685d4e5784398ff656fdab169310dc219a.tar.xz
AvatarStore. Untested, but complete
Diffstat (limited to 'OpenSim/Services/AvatarService/AvatarService.cs')
-rw-r--r--OpenSim/Services/AvatarService/AvatarService.cs63
1 files changed, 52 insertions, 11 deletions
diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs
index ffcdcc5..0b351a2 100644
--- a/OpenSim/Services/AvatarService/AvatarService.cs
+++ b/OpenSim/Services/AvatarService/AvatarService.cs
@@ -53,45 +53,86 @@ namespace OpenSim.Services.AvatarService
53 53
54 public AvatarData GetAvatar(UUID principalID) 54 public AvatarData GetAvatar(UUID principalID)
55 { 55 {
56
57 AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString()); 56 AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString());
58 if (av.Length == 0) 57 if (av.Length == 0)
59 return null; 58 return null;
60 59
61 AvatarData ret = new AvatarData(); 60 AvatarData ret = new AvatarData();
62 ret.AvatarType = Convert.ToInt32(av[0].Data["AvatarType"]); 61 ret.Data = new Dictionary<string,string>();
63 62
64 av[0].Data.Remove("AvatarType"); 63 foreach (AvatarBaseData b in av)
65 64 {
66 ret.Data = av[0].Data; 65 if (b.Data["Name"] == "AvatarType")
66 ret.AvatarType = Convert.ToInt32(b.Data["Value"]);
67 else
68 ret.Data[b.Data["Name"]] = b.Data["Value"];
69 }
67 70
68 return ret; 71 return ret;
69 } 72 }
70 73
71 public bool SetAvatar(UUID principalID, AvatarData avatar) 74 public bool SetAvatar(UUID principalID, AvatarData avatar)
72 { 75 {
76 m_Database.Delete("PrincipalID", principalID.ToString());
77
73 AvatarBaseData av = new AvatarBaseData(); 78 AvatarBaseData av = new AvatarBaseData();
79 av.Data = new Dictionary<string,string>();
74 80
75 av.PrincipalID = principalID; 81 av.PrincipalID = principalID;
76 av.Data = avatar.Data; 82 av.Data["Name"] = "AvatarType";
77 av.Data["AvatarType"] = avatar.AvatarType.ToString(); 83 av.Data["Value"] = avatar.AvatarType.ToString();
84
85 if (!m_Database.Store(av))
86 return false;
78 87
79 return m_Database.Store(av); 88 foreach (KeyValuePair<string,string> kvp in avatar.Data)
89 {
90 av.Data["Name"] = kvp.Key;
91 av.Data["Value"] = kvp.Value;
92
93 if (!m_Database.Store(av))
94 {
95 m_Database.Delete("PrincipalID", principalID.ToString());
96 return false;
97 }
98 }
99
100 return true;
80 } 101 }
81 102
82 public bool ResetAvatar(UUID principalID) 103 public bool ResetAvatar(UUID principalID)
83 { 104 {
84 return false; 105 return m_Database.Delete("PrincipalID", principalID.ToString());
85 } 106 }
86 107
87 public bool SetItems(UUID principalID, string[] names, string[] values) 108 public bool SetItems(UUID principalID, string[] names, string[] values)
88 { 109 {
89 return false; 110 AvatarBaseData av = new AvatarBaseData();
111 av.Data = new Dictionary<string,string>();
112 av.PrincipalID = principalID;
113
114 if (names.Length != values.Length)
115 return false;
116
117 for (int i = 0 ; i < names.Length ; i++)
118 {
119 av.Data["Name"] = names[i];
120 av.Data["Value"] = values[i];
121
122 if (!m_Database.Store(av))
123 return false;
124 }
125
126 return true;
90 } 127 }
91 128
92 public bool RemoveItems(UUID principalID, string[] names) 129 public bool RemoveItems(UUID principalID, string[] names)
93 { 130 {
94 return false; 131 foreach (string name in names)
132 {
133 m_Database.Delete(principalID, name);
134 }
135 return true;
95 } 136 }
96 } 137 }
97} 138}