diff options
Diffstat (limited to 'OpenSim/Services/UserAccountService')
-rw-r--r-- | OpenSim/Services/UserAccountService/GridUserService.cs | 95 | ||||
-rw-r--r-- | OpenSim/Services/UserAccountService/UserAccountService.cs | 10 |
2 files changed, 94 insertions, 11 deletions
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index c6e33bb..697ba63 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using OpenSim.Data; | 32 | using OpenSim.Data; |
33 | using OpenSim.Services.Interfaces; | 33 | using OpenSim.Services.Interfaces; |
34 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 36 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
36 | 37 | ||
@@ -50,27 +51,109 @@ namespace OpenSim.Services.UserAccountService | |||
50 | 51 | ||
51 | public GridUserInfo GetGridUserInfo(string userID) | 52 | public GridUserInfo GetGridUserInfo(string userID) |
52 | { | 53 | { |
53 | GridUserData d = m_Database.GetGridUserData(userID); | 54 | GridUserData d = m_Database.Get(userID); |
54 | 55 | ||
56 | if (d == null) | ||
57 | return null; | ||
58 | |||
55 | GridUserInfo info = new GridUserInfo(); | 59 | GridUserInfo info = new GridUserInfo(); |
56 | info.UserID = d.UserID; | 60 | info.UserID = d.UserID; |
57 | info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); | 61 | info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); |
58 | info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); | 62 | info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); |
59 | info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); | 63 | info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); |
60 | 64 | ||
65 | info.LastRegionID = new UUID(d.Data["LastRegionID"]); | ||
66 | info.LastPosition = Vector3.Parse(d.Data["LastPosition"]); | ||
67 | info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]); | ||
68 | |||
69 | info.Online = bool.Parse(d.Data["Online"]); | ||
70 | info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); | ||
71 | info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); | ||
72 | |||
61 | return info; | 73 | return info; |
62 | } | 74 | } |
63 | 75 | ||
64 | public bool StoreGridUserInfo(GridUserInfo info) | 76 | public GridUserInfo LoggedIn(string userID) |
77 | { | ||
78 | m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID); | ||
79 | GridUserData d = m_Database.Get(userID); | ||
80 | |||
81 | if (d == null) | ||
82 | { | ||
83 | d = new GridUserData(); | ||
84 | d.UserID = userID; | ||
85 | } | ||
86 | |||
87 | d.Data["Online"] = true.ToString(); | ||
88 | d.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); | ||
89 | |||
90 | m_Database.Store(d); | ||
91 | |||
92 | return GetGridUserInfo(userID); | ||
93 | } | ||
94 | |||
95 | public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) | ||
96 | { | ||
97 | m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID); | ||
98 | GridUserData d = m_Database.Get(userID); | ||
99 | |||
100 | if (d == null) | ||
101 | { | ||
102 | d = new GridUserData(); | ||
103 | d.UserID = userID; | ||
104 | } | ||
105 | |||
106 | d.Data["Online"] = false.ToString(); | ||
107 | d.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); | ||
108 | d.Data["LastRegionID"] = regionID.ToString(); | ||
109 | d.Data["LastPosition"] = lastPosition.ToString(); | ||
110 | d.Data["LastLookAt"] = lastLookAt.ToString(); | ||
111 | |||
112 | return m_Database.Store(d); | ||
113 | } | ||
114 | |||
115 | protected bool StoreGridUserInfo(GridUserInfo info) | ||
65 | { | 116 | { |
66 | GridUserData d = new GridUserData(); | 117 | GridUserData d = new GridUserData(); |
67 | 118 | ||
68 | d.Data["UserID"] = info.UserID; | ||
69 | d.Data["HomeRegionID"] = info.HomeRegionID.ToString(); | 119 | d.Data["HomeRegionID"] = info.HomeRegionID.ToString(); |
70 | d.Data["HomePosition"] = info.HomePosition.ToString(); | 120 | d.Data["HomePosition"] = info.HomePosition.ToString(); |
71 | d.Data["HomeLookAt"] = info.HomeLookAt.ToString(); | 121 | d.Data["HomeLookAt"] = info.HomeLookAt.ToString(); |
72 | 122 | ||
73 | return m_Database.StoreGridUserData(d); | 123 | return m_Database.Store(d); |
124 | } | ||
125 | |||
126 | public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt) | ||
127 | { | ||
128 | GridUserData d = m_Database.Get(userID); | ||
129 | if (d == null) | ||
130 | { | ||
131 | d = new GridUserData(); | ||
132 | d.UserID = userID; | ||
133 | } | ||
134 | |||
135 | d.Data["HomeRegionID"] = homeID.ToString(); | ||
136 | d.Data["HomePosition"] = homePosition.ToString(); | ||
137 | d.Data["HomeLookAt"] = homeLookAt.ToString(); | ||
138 | |||
139 | return m_Database.Store(d); | ||
140 | } | ||
141 | |||
142 | public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) | ||
143 | { | ||
144 | //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); | ||
145 | GridUserData d = m_Database.Get(userID); | ||
146 | if (d == null) | ||
147 | { | ||
148 | d = new GridUserData(); | ||
149 | d.UserID = userID; | ||
150 | } | ||
151 | |||
152 | d.Data["LastRegionID"] = regionID.ToString(); | ||
153 | d.Data["LastPosition"] = lastPosition.ToString(); | ||
154 | d.Data["LastLookAt"] = lastLookAt.ToString(); | ||
155 | |||
156 | return m_Database.Store(d); | ||
74 | } | 157 | } |
75 | } | 158 | } |
76 | } \ No newline at end of file | 159 | } \ No newline at end of file |
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 35e2826..6923293 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Services.UserAccountService | |||
46 | 46 | ||
47 | protected IGridService m_GridService; | 47 | protected IGridService m_GridService; |
48 | protected IAuthenticationService m_AuthenticationService; | 48 | protected IAuthenticationService m_AuthenticationService; |
49 | protected IPresenceService m_PresenceService; | 49 | protected IGridUserService m_GridUserService; |
50 | protected IInventoryService m_InventoryService; | 50 | protected IInventoryService m_InventoryService; |
51 | 51 | ||
52 | public UserAccountService(IConfigSource config) | 52 | public UserAccountService(IConfigSource config) |
@@ -69,9 +69,9 @@ namespace OpenSim.Services.UserAccountService | |||
69 | if (authServiceDll != string.Empty) | 69 | if (authServiceDll != string.Empty) |
70 | m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config }); | 70 | m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config }); |
71 | 71 | ||
72 | string presenceServiceDll = userConfig.GetString("PresenceService", string.Empty); | 72 | string presenceServiceDll = userConfig.GetString("GridUserService", string.Empty); |
73 | if (presenceServiceDll != string.Empty) | 73 | if (presenceServiceDll != string.Empty) |
74 | m_PresenceService = LoadPlugin<IPresenceService>(presenceServiceDll, new Object[] { config }); | 74 | m_GridUserService = LoadPlugin<IGridUserService>(presenceServiceDll, new Object[] { config }); |
75 | 75 | ||
76 | string invServiceDll = userConfig.GetString("InventoryService", string.Empty); | 76 | string invServiceDll = userConfig.GetString("InventoryService", string.Empty); |
77 | if (invServiceDll != string.Empty) | 77 | if (invServiceDll != string.Empty) |
@@ -333,8 +333,8 @@ namespace OpenSim.Services.UserAccountService | |||
333 | if (defaultRegions != null && defaultRegions.Count >= 1) | 333 | if (defaultRegions != null && defaultRegions.Count >= 1) |
334 | home = defaultRegions[0]; | 334 | home = defaultRegions[0]; |
335 | 335 | ||
336 | if (m_PresenceService != null && home != null) | 336 | if (m_GridUserService != null && home != null) |
337 | m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | 337 | m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); |
338 | else | 338 | else |
339 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", | 339 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", |
340 | firstName, lastName); | 340 | firstName, lastName); |