Compare commits
1536 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fc289c039 | ||
|
|
877bdcdce1 | ||
|
|
bdbbeaa494 | ||
|
|
f6913e911e | ||
|
|
f74aafaf63 | ||
|
|
4fed301e65 | ||
|
|
733e067958 | ||
|
|
ffd0da23fb | ||
|
|
f49d513089 | ||
|
|
fc35b45e21 | ||
|
|
bc7fda39b4 | ||
|
|
e10012a7a6 | ||
|
|
3a7c8d1f32 | ||
|
|
c0cc5e0fa4 | ||
|
|
b83a224147 | ||
|
|
4a1c1fc009 | ||
|
|
cf61cdf58c | ||
|
|
1913ab5ad5 | ||
|
|
29c8461631 | ||
|
|
8f372b8ac8 | ||
|
|
342be228c6 | ||
|
|
87abf06956 | ||
|
|
f81841a2c5 | ||
|
|
1b41ec0a85 | ||
|
|
31cba5aa66 | ||
|
|
1aed6567a8 | ||
|
|
f0f852b27f | ||
|
|
1197658233 | ||
|
|
e1d1c27965 | ||
|
|
49c2213a01 | ||
|
|
41b6602a77 | ||
|
|
8c6a0cb44a | ||
|
|
2a4dd34616 | ||
|
|
9c97fb8e12 | ||
|
|
a8e64cd59a | ||
|
|
abb193ec94 | ||
|
|
b2878eb773 | ||
|
|
b8e22f02e7 | ||
|
|
1380b37d71 | ||
|
|
3d62f4369d | ||
|
|
d405254971 | ||
|
|
9db4090c07 | ||
|
|
c9550e473d | ||
|
|
257f9cec40 | ||
|
|
13bb9ea682 | ||
|
|
67ec95bde8 | ||
|
|
c467dfcd81 | ||
|
|
b73baeb4a4 | ||
|
|
b50e5704b8 | ||
|
|
7807b19a89 | ||
|
|
bdab05df0e | ||
|
|
0842e2e15b | ||
|
|
fbf33ef1de | ||
|
|
3f5c6c897f | ||
|
|
1900254e77 | ||
|
|
678c107915 | ||
|
|
dde0e547a7 | ||
|
|
226b5e4d75 | ||
|
|
cfe1bced7d | ||
|
|
2877c7d94d | ||
|
|
0c3493f619 | ||
|
|
d25265ae82 | ||
|
|
1d533b0f01 | ||
|
|
bfb0011cd3 | ||
|
|
e5d59dc696 | ||
|
|
8eec717f5f | ||
|
|
4faf11e001 | ||
|
|
cd35d298fa | ||
|
|
2cf224166f | ||
|
|
f7172095e0 | ||
|
|
8c2b41b01d | ||
|
|
a4017ee1eb | ||
|
|
1b86239f79 | ||
|
|
e2fbc88d98 | ||
|
|
49af6b53e7 | ||
|
|
13a9d5409c | ||
|
|
6831e58616 | ||
|
|
0eda7dd1c7 | ||
|
|
fea8345f56 | ||
|
|
c9b5ba78d9 | ||
|
|
4a9796a506 | ||
|
|
afb2e07111 | ||
|
|
674a3a5639 | ||
|
|
966ab21839 | ||
|
|
a2d5d810e0 | ||
|
|
a859464e91 | ||
|
|
4c362a83f9 | ||
|
|
83626e60e6 | ||
|
|
7bd42fc42f | ||
|
|
af58631f00 | ||
|
|
719810e9d8 | ||
|
|
1cae3664a5 | ||
|
|
5fc871027e | ||
|
|
2cf7478b9a | ||
|
|
2e78e89c36 | ||
|
|
8e72b53edc | ||
|
|
4800303abd | ||
|
|
36d8a24a86 | ||
|
|
95c926b2cd | ||
|
|
28723beb0c | ||
|
|
d1f16c4b4b | ||
|
|
68d83425c6 | ||
|
|
3018b2c5d7 | ||
|
|
ca0336d834 | ||
|
|
e8273fa8ad | ||
|
|
90fa3202c6 | ||
|
|
5e6a47f13f | ||
|
|
6fbfb47b92 | ||
|
|
dd6db72939 | ||
|
|
f127e4b4ee | ||
|
|
4fb3d314b8 | ||
|
|
54a4b9eab4 | ||
|
|
813f0da00b | ||
|
|
08fa0a6a8a | ||
|
|
60de0bc3c2 | ||
|
|
d466446df3 | ||
|
|
e9454d4672 | ||
|
|
50ea2e0d67 | ||
|
|
0cbe5f8424 | ||
|
|
b9453a8f6f | ||
|
|
427ffd3387 | ||
|
|
fc7ccfdafa | ||
|
|
ee8ba1ab9a | ||
|
|
d381da81d6 | ||
|
|
97fbb8ed45 | ||
|
|
12bfce7b9f | ||
|
|
b52b50ee56 | ||
|
|
9fefbcf7fc | ||
|
|
14c72d4a5b | ||
|
|
18e0d2f343 | ||
|
|
39e5785c0f | ||
|
|
4fa843ff19 | ||
|
|
f467121c51 | ||
|
|
3bc669ffc7 | ||
|
|
3ffd90496a | ||
|
|
1a8b56fa87 | ||
|
|
2d9d6fe922 | ||
|
|
46c2791fe2 | ||
|
|
21bc799a17 | ||
|
|
e99a7d879e | ||
|
|
4675a2fb29 | ||
|
|
797684115c | ||
|
|
cc5cffc212 | ||
|
|
1eea6fd452 | ||
|
|
3760d10cd0 | ||
|
|
1cf17a3cf7 | ||
|
|
239b85d7ce | ||
|
|
b5ef585069 | ||
|
|
bc0ff5e7d4 | ||
|
|
66e2e1c9c3 | ||
|
|
70dd4cf152 | ||
|
|
09e800f4b1 | ||
|
|
8c6b9ef865 | ||
|
|
08f2fc63cd | ||
|
|
68cbccb288 | ||
|
|
9050c152b4 | ||
|
|
da47bcae3e | ||
|
|
5e72de1908 | ||
|
|
88f01a4130 | ||
|
|
a94e1e0e08 | ||
|
|
91fd9c4670 | ||
|
|
13f31fdf85 | ||
|
|
32e9c16957 | ||
|
|
0155d42b80 | ||
|
|
38148bd4b6 | ||
|
|
8ff2ff1a36 | ||
|
|
7e32313a49 | ||
|
|
004ecee314 | ||
|
|
d9848943a9 | ||
|
|
dd96fef940 | ||
|
|
fd045d520e | ||
|
|
9984ecf862 | ||
|
|
eab9390e05 | ||
|
|
6869633d76 | ||
|
|
01c0bbf181 | ||
|
|
2d2bea4aa7 | ||
|
|
e5f7c8b6e8 | ||
|
|
b40b57776b | ||
|
|
5c9fa15f30 | ||
|
|
540fa84842 | ||
|
|
2f94165dcc | ||
|
|
f1cd813a29 | ||
|
|
871ac5b16c | ||
|
|
a5e4780547 | ||
|
|
b757ab2586 | ||
|
|
a01862509e | ||
|
|
68773ee7c4 | ||
|
|
e298bf41ff | ||
|
|
a5ca15c428 | ||
|
|
6937eec258 | ||
|
|
141d771a93 | ||
|
|
b03ec6137f | ||
|
|
fe01e7d1cc | ||
|
|
f69e91dc2d | ||
|
|
13a9a4b653 | ||
|
|
00e632ec3a | ||
|
|
51da52f904 | ||
|
|
38d7d46c17 | ||
|
|
957449e62c | ||
|
|
ee163b5751 | ||
|
|
e7a294e739 | ||
|
|
996a6c2eea | ||
|
|
63ccc3dbf5 | ||
|
|
bf826699a5 | ||
|
|
d656ec2a07 | ||
|
|
5ddd818238 | ||
|
|
bcb8c4068e | ||
|
|
d2d4ae541b | ||
|
|
54cc229768 | ||
|
|
11f177d6a8 | ||
|
|
1d605642f7 | ||
|
|
82ebb86d58 | ||
|
|
92aad6f1bb | ||
|
|
5b73b9c4a8 | ||
|
|
3df8990e6f | ||
|
|
97934e00e6 | ||
|
|
0875050161 | ||
|
|
8f221a3077 | ||
|
|
c0380d1bfe | ||
|
|
5047bd7b44 | ||
|
|
4058e5f709 | ||
|
|
aba2a44453 | ||
|
|
1496de7ce9 | ||
|
|
1842388bb4 | ||
|
|
4eb52eb19e | ||
|
|
04f8fc1ce9 | ||
|
|
823a175f07 | ||
|
|
9b76a46df0 | ||
|
|
bb4f4d9480 | ||
|
|
16aaba77d4 | ||
|
|
17b32b764a | ||
|
|
62a2d7836f | ||
|
|
31bacfbb63 | ||
|
|
6cd0d7a62b | ||
|
|
8ebad90800 | ||
|
|
96018afab4 | ||
|
|
4cde02a2a3 | ||
|
|
4bd4f1cd83 | ||
|
|
8b3a4367ea | ||
|
|
5f0e763062 | ||
|
|
84bfde3bdf | ||
|
|
ca079c378a | ||
|
|
868c0c2746 | ||
|
|
f9193e3c51 | ||
|
|
a64377149d | ||
|
|
109136c074 | ||
|
|
7aa00632b9 | ||
|
|
b8dd203378 | ||
|
|
13017034b1 | ||
|
|
73dadef8df | ||
|
|
e52a8d388f | ||
|
|
0785210e29 | ||
|
|
5a9ec0748b | ||
|
|
a3c72dafe6 | ||
|
|
36d146bf27 | ||
|
|
0ad45531a1 | ||
|
|
3193bcaae1 | ||
|
|
60e049ea39 | ||
|
|
1999b218fd | ||
|
|
a68d1fad73 | ||
|
|
eb172be541 | ||
|
|
910f07dffa | ||
|
|
5aa3236ebe | ||
|
|
b9e42aeb6e | ||
|
|
65304260af | ||
|
|
f3f3d390f7 | ||
|
|
8217b52d3a | ||
|
|
78649eb099 | ||
|
|
70e651a8d1 | ||
|
|
bd5c414618 | ||
|
|
ed1029712a | ||
|
|
9bdd3dc7de | ||
|
|
9f4a548a49 | ||
|
|
ff4e7de776 | ||
|
|
c896b4179e | ||
|
|
b44c69807d | ||
|
|
f9984a9685 | ||
|
|
b71952df49 | ||
|
|
9ba5a7e190 | ||
|
|
f94d07f2e2 | ||
|
|
79c1ed8cb9 | ||
|
|
ec4d96acc9 | ||
|
|
edd7e19463 | ||
|
|
62006baaef | ||
|
|
d728c1beb2 | ||
|
|
b58a474105 | ||
|
|
92fbe675b5 | ||
|
|
ecfb78dd16 | ||
|
|
346644016c | ||
|
|
604b39cea9 | ||
|
|
0595974a89 | ||
|
|
f63fd81a68 | ||
|
|
7cab41f422 | ||
|
|
b4932bda2a | ||
|
|
d67236c09d | ||
|
|
8114ae0f8b | ||
|
|
7da10850b0 | ||
|
|
869a23e223 | ||
|
|
d71ebb7ec8 | ||
|
|
4563e7e04a | ||
|
|
0f16612400 | ||
|
|
e2a1fa806d | ||
|
|
c12e68e34d | ||
|
|
7061784cc6 | ||
|
|
beeec1c467 | ||
|
|
a7a837550e | ||
|
|
fd24147afa | ||
|
|
9a9abd37eb | ||
|
|
ea9e96dd50 | ||
|
|
626a050159 | ||
|
|
5cef8bf64e | ||
|
|
3b2721c957 | ||
|
|
52ff860f30 | ||
|
|
f7bd0da026 | ||
|
|
0b4577d5b0 | ||
|
|
709814c194 | ||
|
|
e1ce3907f2 | ||
|
|
cd33972ed1 | ||
|
|
a75ce7423c | ||
|
|
d0854e4ace | ||
|
|
26fd29622d | ||
|
|
417836ac5e | ||
|
|
8e1bf55e7b | ||
|
|
caf2abe311 | ||
|
|
fb23f78928 | ||
|
|
2d315ec207 | ||
|
|
c931b16c1f | ||
|
|
f2810bf03a | ||
|
|
cd1a23fc14 | ||
|
|
ac94dc8a14 | ||
|
|
9bf363e9be | ||
|
|
79b031bd0c | ||
|
|
6df7d4219d | ||
|
|
f66737fe56 | ||
|
|
2b069a3b1e | ||
|
|
92c06a5d0b | ||
|
|
976530569a | ||
|
|
7faf286d00 | ||
|
|
ff5885ab23 | ||
|
|
ce94f990bb | ||
|
|
f4ded3af63 | ||
|
|
db32e5d304 | ||
|
|
c6395240f0 | ||
|
|
cc73ef4eb9 | ||
|
|
cc7065f9ee | ||
|
|
4c4a1cf715 | ||
|
|
50794c9008 | ||
|
|
3d5a7e9b19 | ||
|
|
b7c57294cc | ||
|
|
eb52d346c0 | ||
|
|
0e07fad2e1 | ||
|
|
39777db8ef | ||
|
|
46a4c32e27 | ||
|
|
fdd1c63c3c | ||
|
|
28f36d8db5 | ||
|
|
edaf0a98d6 | ||
|
|
26c2d9e627 | ||
|
|
39de7614ec | ||
|
|
2be0347f50 | ||
|
|
d23ef79f98 | ||
|
|
93d5d66fbd | ||
|
|
5be8f6632b | ||
|
|
df76e52310 | ||
|
|
31989bd51e | ||
|
|
cccdfcb59e | ||
|
|
5d61c4039d | ||
|
|
511122834b | ||
|
|
4830431eb0 | ||
|
|
a7e7bed660 | ||
|
|
84a149ecbf | ||
|
|
571a75f934 | ||
|
|
0094971186 | ||
|
|
1bd89ac287 | ||
|
|
6221356712 | ||
|
|
67ffb64764 | ||
|
|
f83343d302 | ||
|
|
8fdf70b87e | ||
|
|
c581506058 | ||
|
|
8937a2244d | ||
|
|
97bc5263de | ||
|
|
766a31431e | ||
|
|
d0c1780839 | ||
|
|
acfe603a5f | ||
|
|
d82d6bb1ec | ||
|
|
5ca7395e17 | ||
|
|
3e1ca2bd21 | ||
|
|
f106ba87ca | ||
|
|
a27c2432bb | ||
|
|
dbdcf2d995 | ||
|
|
daf44cc65e | ||
|
|
ff8a768258 | ||
|
|
2eade55471 | ||
|
|
8b5e2f2cd2 | ||
|
|
75f63ecfcd | ||
|
|
e7ea053c4a | ||
|
|
1df58d04b1 | ||
|
|
75fdd6054d | ||
|
|
f76cc6036e | ||
|
|
86bf79aa2b | ||
|
|
7416809077 | ||
|
|
25ae59b9eb | ||
|
|
9b150194f6 | ||
|
|
31246ecd04 | ||
|
|
85593d8d25 | ||
|
|
083eb7679b | ||
|
|
44580e2233 | ||
|
|
42bdf44658 | ||
|
|
970249a3c7 | ||
|
|
8c432c7c9b | ||
|
|
8c1d80fdfd | ||
|
|
aea5d3a842 | ||
|
|
fa1c688342 | ||
|
|
139639d25e | ||
|
|
317c04fe17 | ||
|
|
8996ac1a9c | ||
|
|
2cd95fac73 | ||
|
|
b16bc7b01c | ||
|
|
b704de9bf8 | ||
|
|
585d0800dd | ||
|
|
70b51f12cd | ||
|
|
d6d82dbd3c | ||
|
|
fbc9072a5c | ||
|
|
7fa64cce7d | ||
|
|
ab1474b5de | ||
|
|
0765a83a8c | ||
|
|
96abbbb6fb | ||
|
|
e24edada24 | ||
|
|
253f8de8cd | ||
|
|
babfbe8d6d | ||
|
|
4664090b34 | ||
|
|
b22c92368f | ||
|
|
32ddfc2740 | ||
|
|
732554be04 | ||
|
|
f384a6291e | ||
|
|
8de5c29e2c | ||
|
|
7889e7757a | ||
|
|
2dc92e7de1 | ||
|
|
a37c59b43e | ||
|
|
cbdfe96905 | ||
|
|
4c0ec86176 | ||
|
|
e2b3b7a2ae | ||
|
|
8502517d80 | ||
|
|
c01db5fbdd | ||
|
|
c6dea6ee78 | ||
|
|
35a6361b24 | ||
|
|
07d7a5fd76 | ||
|
|
c06a9ffe5c | ||
|
|
f1267730ef | ||
|
|
979b17165b | ||
|
|
b6f10780c2 | ||
|
|
03b2b5b77b | ||
|
|
6bdef1f70b | ||
|
|
3a9a8d2113 | ||
|
|
83c113896e | ||
|
|
997700c4aa | ||
|
|
ac0a527976 | ||
|
|
8999f06025 | ||
|
|
ddcbd4bb7d | ||
|
|
3ce46adb2a | ||
|
|
f4d82a56f4 | ||
|
|
7dbc93c62a | ||
|
|
1d2466889a | ||
|
|
845d2b193a | ||
|
|
69ec85f491 | ||
|
|
2603a2891b | ||
|
|
f99dae03cb | ||
|
|
60cf42cb8d | ||
|
|
3f0fa9f707 | ||
|
|
53de6d94ea | ||
|
|
07d6a0385f | ||
|
|
2d7adcb22f | ||
|
|
3c85afbb43 | ||
|
|
dacc20ee48 | ||
|
|
b29e9d37e7 | ||
|
|
8bcf753127 | ||
|
|
6e39cc316f | ||
|
|
e34385634b | ||
|
|
c5eabb28b4 | ||
|
|
5827b6e1aa | ||
|
|
cf2cdc191d | ||
|
|
7c54630a2d | ||
|
|
30b3657a66 | ||
|
|
67195618d5 | ||
|
|
3dbf4a1002 | ||
|
|
e0b457d3c3 | ||
|
|
d09c35f506 | ||
|
|
995314f91f | ||
|
|
4781297b4e | ||
|
|
6d83f3f021 | ||
|
|
e1120cb74d | ||
|
|
8755aeb348 | ||
|
|
f6fdfd16f5 | ||
|
|
455d36c4c7 | ||
|
|
b2a1348adc | ||
|
|
6aee08ac3c | ||
|
|
dff0fb5690 | ||
|
|
f3cc20050e | ||
|
|
c6a6631efc | ||
|
|
993bcec088 | ||
|
|
0971c7ae77 | ||
|
|
9a7d0e489c | ||
|
|
48ee73bfa7 | ||
|
|
725751fd6c | ||
|
|
663059ac5c | ||
|
|
ec5f17b2ce | ||
|
|
b05cb3b2bf | ||
|
|
a97f6f8668 | ||
|
|
08874d6b9e | ||
|
|
04619a9b13 | ||
|
|
b858be345a | ||
|
|
dc74a50225 | ||
|
|
c7ded0618c | ||
|
|
5f0d54c209 | ||
|
|
b781a23c44 | ||
|
|
9c3c9b7f5f | ||
|
|
76bd2e2d72 | ||
|
|
3dbe7313d1 | ||
|
|
1a2627031d | ||
|
|
9bd6271570 | ||
|
|
01cb8033a4 | ||
|
|
a89c56dcf1 | ||
|
|
9c65207936 | ||
|
|
431156f6c4 | ||
|
|
5f15ee95dc | ||
|
|
fc9f50d940 | ||
|
|
4035badd20 | ||
|
|
9643915093 | ||
|
|
857f24a5e2 | ||
|
|
5ce5ce6edb | ||
|
|
4cbadc3c49 | ||
|
|
56f565b601 | ||
|
|
a8c0e16e47 | ||
|
|
aa521fb385 | ||
|
|
0882cf0fc3 | ||
|
|
0dd9a68eb7 | ||
|
|
1b2830b929 | ||
|
|
60e4ce20b8 | ||
|
|
85824d2cd9 | ||
|
|
ec32c1d4b6 | ||
|
|
f0c0376660 | ||
|
|
5cd7bc2848 | ||
|
|
c7a8afbb8d | ||
|
|
6a24515269 | ||
|
|
c34e6f25b1 | ||
|
|
1a623bb266 | ||
|
|
0fbfef9649 | ||
|
|
050617ae0e | ||
|
|
04f4dd3dc7 | ||
|
|
2be786709b | ||
|
|
61c20bd06a | ||
|
|
065c5839b5 | ||
|
|
a9f9b0da9d | ||
|
|
a0c99a7dcc | ||
|
|
13556cf129 | ||
|
|
70f89ae65b | ||
|
|
51c7fb1969 | ||
|
|
beb9d966f9 | ||
|
|
416bbe9583 | ||
|
|
66a7dc3a0d | ||
|
|
832c35d4d5 | ||
|
|
689cf2d367 | ||
|
|
bcb8605f84 | ||
|
|
3d9b73c47a | ||
|
|
1f39a763a5 | ||
|
|
a6af561660 | ||
|
|
4a81465b91 | ||
|
|
a3e1b278a1 | ||
|
|
43940f6562 | ||
|
|
e384ff604e | ||
|
|
56d1d67a34 | ||
|
|
a3dd7db4a3 | ||
|
|
589b1a2eaf | ||
|
|
ea3f024b8a | ||
|
|
079cd4e94f | ||
|
|
2fa42f24fd | ||
|
|
49b7cbda72 | ||
|
|
ef63abe9b1 | ||
|
|
a90a5f52dd | ||
|
|
3585b0a139 | ||
|
|
85a9cb260a | ||
|
|
d75f00cc2d | ||
|
|
b3052c425e | ||
|
|
f5dbfe99b1 | ||
|
|
d38d5ecbac | ||
|
|
77d418a36d | ||
|
|
217c8deae5 | ||
|
|
1f1736a79f | ||
|
|
14ae89dbe7 | ||
|
|
f5d3145bea | ||
|
|
fbab898f74 | ||
|
|
1624522761 | ||
|
|
7d268912f1 | ||
|
|
7c916ab91c | ||
|
|
3ddb7438d7 | ||
|
|
3f8d79024b | ||
|
|
2231fcf5b4 | ||
|
|
5011c657b5 | ||
|
|
104626d732 | ||
|
|
73e3ca670d | ||
|
|
60cc9e9a3c | ||
|
|
e8b1e91a1d | ||
|
|
7c3b71d294 | ||
|
|
93dffe1777 | ||
|
|
0d5680e971 | ||
|
|
2c67aa0f41 | ||
|
|
225cf0d010 | ||
|
|
fd519748e9 | ||
|
|
97c514daa5 | ||
|
|
3a62f39044 | ||
|
|
2146b20169 | ||
|
|
0feb5da31e | ||
|
|
5933f9448d | ||
|
|
e311f902ff | ||
|
|
a90351cd2c | ||
|
|
4f8c691f8c | ||
|
|
c49ea491a3 | ||
|
|
2c31fe4614 | ||
|
|
377fe63c60 | ||
|
|
f3edc0d8b7 | ||
|
|
de6ad380f6 | ||
|
|
e5b1688913 | ||
|
|
b64d3ecaed | ||
|
|
216f5afe54 | ||
|
|
23ca1f859e | ||
|
|
bfdcdbb2f3 | ||
|
|
aec7019728 | ||
|
|
97bcb59bee | ||
|
|
6fcbf219da | ||
|
|
2cdcf62b48 | ||
|
|
7e01213bf2 | ||
|
|
99bce9d877 | ||
|
|
b1c26a56b3 | ||
|
|
6410a25cef | ||
|
|
9fc97cbbf7 | ||
|
|
d9bd6e6b5b | ||
|
|
c67c55e0fc | ||
|
|
50c163ae6c | ||
|
|
4e86674a3a | ||
|
|
99a4a91488 | ||
|
|
ce1361f2fe | ||
|
|
64216b34a4 | ||
|
|
43da879ea2 | ||
|
|
e4da8d74d8 | ||
|
|
638c3d25b0 | ||
|
|
b10710d4a5 | ||
|
|
a33a1ac958 | ||
|
|
dbd773e89e | ||
|
|
6b9a65972c | ||
|
|
3194ffdab8 | ||
|
|
d6d5d4ebd0 | ||
|
|
4c2f6de8e4 | ||
|
|
ac198068ab | ||
|
|
4581bdd929 | ||
|
|
9bcf072795 | ||
|
|
f9dc5815c4 | ||
|
|
139dcf1246 | ||
|
|
76e778fe2c | ||
|
|
160659f683 | ||
|
|
2d3ac2b1ec | ||
|
|
946b370966 | ||
|
|
24dcf3cf6a | ||
|
|
b8612e005a | ||
|
|
151a8ca0cc | ||
|
|
7f0d9ad644 | ||
|
|
03698121ed | ||
|
|
976514d39a | ||
|
|
76bd3de2fd | ||
|
|
05012bb0df | ||
|
|
5b4b349776 | ||
|
|
09cb2a37dd | ||
|
|
dcfeb95e98 | ||
|
|
b857353fc9 | ||
|
|
847c01f406 | ||
|
|
fdfc951744 | ||
|
|
5198df3aa0 | ||
|
|
4ff3757f86 | ||
|
|
54b1071556 | ||
|
|
5bdfd55ace | ||
|
|
24df15dab7 | ||
|
|
5bcccfc305 | ||
|
|
87ee0c395e | ||
|
|
07e4958b19 | ||
|
|
d4c506e453 | ||
|
|
c9695a0a59 | ||
|
|
7a5d11f8a7 | ||
|
|
68b98a8003 | ||
|
|
7b9a50721d | ||
|
|
216e785ca9 | ||
|
|
0c4c084bed | ||
|
|
932c382737 | ||
|
|
59b461ac0e | ||
|
|
9f05a7ac7b | ||
|
|
1299592405 | ||
|
|
d82126b651 | ||
|
|
48ee440983 | ||
|
|
64f2dc778a | ||
|
|
ac2ad9690d | ||
|
|
87fcff9fc3 | ||
|
|
3c540f0d33 | ||
|
|
e4ecbc2b10 | ||
|
|
fd050fca7c | ||
|
|
590a8b0315 | ||
|
|
2b54199271 | ||
|
|
0d189165a8 | ||
|
|
6ad577d32b | ||
|
|
5a7784a0e6 | ||
|
|
1416c90932 | ||
|
|
8004e6f31c | ||
|
|
8efe4bfc2e | ||
|
|
7eee9eb312 | ||
|
|
1b94de8e58 | ||
|
|
1d4bf06fe7 | ||
|
|
33b54807a1 | ||
|
|
468ddd2373 | ||
|
|
c442ef346e | ||
|
|
698b2135ee | ||
|
|
63f6c8f27c | ||
|
|
7b0b5c9d97 | ||
|
|
6be614ba84 | ||
|
|
170a6f0563 | ||
|
|
8dff05a897 | ||
|
|
9cbbb7eddf | ||
|
|
18eca40af3 | ||
|
|
69975763d2 | ||
|
|
1572e91b5f | ||
|
|
3dac92f345 | ||
|
|
85428c49bb | ||
|
|
428916a64d | ||
|
|
ba9daf849e | ||
|
|
840be97e40 | ||
|
|
c245365484 | ||
|
|
056a6ee765 | ||
|
|
9038a503eb | ||
|
|
d27cc62458 | ||
|
|
ad2ebd2f3d | ||
|
|
a08f01fa83 | ||
|
|
dd2c211e62 | ||
|
|
d5367a219d | ||
|
|
878ce1e6b2 | ||
|
|
4cd03d8c31 | ||
|
|
72ed49af5f | ||
|
|
1fabdcc43c | ||
|
|
20b989e048 | ||
|
|
cac37e298c | ||
|
|
f0320f5652 | ||
|
|
46d017b197 | ||
|
|
4e5c7bdeb3 | ||
|
|
e6a0f6e428 | ||
|
|
14530b2607 | ||
|
|
c0433d5e4c | ||
|
|
879cbb4575 | ||
|
|
261512606d | ||
|
|
d7984ef775 | ||
|
|
aaee63af82 | ||
|
|
3891a8946b | ||
|
|
aae29c0ee2 | ||
|
|
9ab78d412c | ||
|
|
00d4a26eef | ||
|
|
665fb66686 | ||
|
|
e103e34f1d | ||
|
|
d8a6eb5641 | ||
|
|
feef9d64a4 | ||
|
|
fa2653c8e1 | ||
|
|
9a4a513b5e | ||
|
|
516062ae1f | ||
|
|
901bdfed40 | ||
|
|
744276dd50 | ||
|
|
42e52f544d | ||
|
|
7c1eb86c7d | ||
|
|
76e46d0158 | ||
|
|
aec8d1e6be | ||
|
|
f499b328c4 | ||
|
|
75686e0e49 | ||
|
|
b14156aa63 | ||
|
|
aec8852af7 | ||
|
|
401c2e2f2e | ||
|
|
af9deed135 | ||
|
|
90528c23d9 | ||
|
|
a57a472ab8 | ||
|
|
9fb9da1b6c | ||
|
|
60732c96ef | ||
|
|
8396f1bd42 | ||
|
|
bf517899a7 | ||
|
|
e6b6af62dd | ||
|
|
44543ebe63 | ||
|
|
89857378ce | ||
|
|
c45659863d | ||
|
|
5f7b2ea81b | ||
|
|
7b187deb19 | ||
|
|
84d0699761 | ||
|
|
b44f0e1a00 | ||
|
|
d0d654e218 | ||
|
|
acb7b4a09a | ||
|
|
b4c3a791aa | ||
|
|
13a4a80b38 | ||
|
|
803632f8f3 | ||
|
|
df63bfafef | ||
|
|
f81e289a1b | ||
|
|
99a727600b | ||
|
|
8d18ad2f6f | ||
|
|
116a449d89 | ||
|
|
b5ab0698d6 | ||
|
|
032c637c10 | ||
|
|
3919c80505 | ||
|
|
d5a1779465 | ||
|
|
174105ad02 | ||
|
|
18d5d8f5dd | ||
|
|
edafea6ae6 | ||
|
|
3a6acbcc14 | ||
|
|
866de53978 | ||
|
|
61eda1f441 | ||
|
|
e5c677779b | ||
|
|
5a2d4d888c | ||
|
|
66048e1a70 | ||
|
|
3a476bf60c | ||
|
|
98d47ea428 | ||
|
|
63c42d6602 | ||
|
|
9041f4a056 | ||
|
|
c1705236c7 | ||
|
|
1d65b0d802 | ||
|
|
edef7472d1 | ||
|
|
b5062ae7ee | ||
|
|
d9d995914c | ||
|
|
71b1511db5 | ||
|
|
a22a4db5ce | ||
|
|
552b85d33d | ||
|
|
ad198a714c | ||
|
|
9e35b069a4 | ||
|
|
ae997fffee | ||
|
|
6572847518 | ||
|
|
077be8b496 | ||
|
|
6293614074 | ||
|
|
49b3b7ee83 | ||
|
|
fa2370b32e | ||
|
|
f64f07e7c5 | ||
|
|
fda91d93da | ||
|
|
7127891957 | ||
|
|
5495df7443 | ||
|
|
52dc7b2a96 | ||
|
|
519dba9a69 | ||
|
|
5c54eb30ed | ||
|
|
5232ab0496 | ||
|
|
5f95f4d78e | ||
|
|
1d3deda10c | ||
|
|
af792bc7f2 | ||
|
|
f4317dc26d | ||
|
|
0f5b616fb0 | ||
|
|
2b8de2c404 | ||
|
|
e46459ef21 | ||
|
|
2c8bf4aaa6 | ||
|
|
894554faf6 | ||
|
|
9432f3c94d | ||
|
|
5f27aaa6dd | ||
|
|
8bad56cb46 | ||
|
|
d4720bd721 | ||
|
|
9f129938c9 | ||
|
|
9f578cf0c8 | ||
|
|
0419852598 | ||
|
|
a006caabbc | ||
|
|
99a600753e | ||
|
|
3fbd2c54bc | ||
|
|
cbc3576ee2 | ||
|
|
50b8ab60f2 | ||
|
|
21a09ad3ad | ||
|
|
e0f0b88dec | ||
|
|
6da50d34df | ||
|
|
5a01ffa515 | ||
|
|
6dd454240f | ||
|
|
70aa77f520 | ||
|
|
42e2a0d66e | ||
|
|
e8e073aa97 | ||
|
|
eb14e5a175 | ||
|
|
1b7b664c86 | ||
|
|
68fbf7eebb | ||
|
|
687c1a420a | ||
|
|
b060ce96d9 | ||
|
|
864f15ce4d | ||
|
|
fbb01bd280 | ||
|
|
ac73e70293 | ||
|
|
60325f81d8 | ||
|
|
d48946f9ef | ||
|
|
af02231a7b | ||
|
|
b0140383da | ||
|
|
e33ac50388 | ||
|
|
5939529036 | ||
|
|
c8dcb8474d | ||
|
|
98f59ffed5 | ||
|
|
c61ff917ef | ||
|
|
f3b3e21dea | ||
|
|
fcb0349d56 | ||
|
|
e4f741f006 | ||
|
|
a2ee887c6d | ||
|
|
b4f1b9acf6 | ||
|
|
931eb892d9 | ||
|
|
4d93870fe5 | ||
|
|
5a1d6727e1 | ||
|
|
bc405a6a34 | ||
|
|
6825377380 | ||
|
|
3a26e366d2 | ||
|
|
ff4ad60207 | ||
|
|
ccee2959f7 | ||
|
|
a412b1d682 | ||
|
|
cd64a70c79 | ||
|
|
d06c85ea77 | ||
|
|
b4cb644a05 | ||
|
|
3d118fb580 | ||
|
|
fa02f28dbf | ||
|
|
3d700bb42c | ||
|
|
29f6ae199e | ||
|
|
65239b059f | ||
|
|
1909ee70f8 | ||
|
|
83d1680057 | ||
|
|
ba8f9c9d0a | ||
|
|
7c2e4786ce | ||
|
|
e15a15688b | ||
|
|
f57f49eede | ||
|
|
44e9849ed1 | ||
|
|
ee51a9f9c9 | ||
|
|
51d106cff8 | ||
|
|
c4f1ec1fd6 | ||
|
|
ea371a6f54 | ||
|
|
604967b31e | ||
|
|
3b48b6a792 | ||
|
|
0120e858b7 | ||
|
|
9173130fde | ||
|
|
fe5da43d15 | ||
|
|
bdaeb02863 | ||
|
|
864a86983e | ||
|
|
1b265b213b | ||
|
|
59d19f038a | ||
|
|
38e6da5522 | ||
|
|
bb6fb65392 | ||
|
|
cec8e6d0f7 | ||
|
|
095066b1ce | ||
|
|
d0dfb744b2 | ||
|
|
67e500383e | ||
|
|
2c761cef19 | ||
|
|
065f8f56a2 | ||
|
|
33eea62606 | ||
|
|
fad4241e4e | ||
|
|
76b2b20f7e | ||
|
|
5f58b9b552 | ||
|
|
83da14008f | ||
|
|
af9b17c545 | ||
|
|
2025dd25f6 | ||
|
|
047ef9c2a5 | ||
|
|
eccec4f8f6 | ||
|
|
8be59829d1 | ||
|
|
013710168b | ||
|
|
dc54581700 | ||
|
|
b2d4b8b1da | ||
|
|
c3db595944 | ||
|
|
e19defde36 | ||
|
|
a38c2abae4 | ||
|
|
c66a9a08e4 | ||
|
|
1e72e1b258 | ||
|
|
bbb9af363d | ||
|
|
bbc40fab62 | ||
|
|
6026759406 | ||
|
|
70d24a654b | ||
|
|
1286677352 | ||
|
|
803e5498b0 | ||
|
|
71e26555bd | ||
|
|
391633c072 | ||
|
|
1dd3a0bc57 | ||
|
|
9b75d75724 | ||
|
|
93fd5e4036 | ||
|
|
b29a09ab8e | ||
|
|
d838f15d97 | ||
|
|
a65cec3986 | ||
|
|
97698ae311 | ||
|
|
03268d85c4 | ||
|
|
5f97c6f8f0 | ||
|
|
c358d5d168 | ||
|
|
2f6ee8aee2 | ||
|
|
98de67d573 | ||
|
|
ccceb6d6d2 | ||
|
|
55ac8c83c7 | ||
|
|
a44ad01492 | ||
|
|
67407024a2 | ||
|
|
5dbdd5f8b4 | ||
|
|
dd15f95499 | ||
|
|
ca26583e6b | ||
|
|
c4506cf4f3 | ||
|
|
8265a88c4a | ||
|
|
f2f33b7577 | ||
|
|
d80936bbbb | ||
|
|
da3aa44138 | ||
|
|
33ddb6c246 | ||
|
|
c95a23863a | ||
|
|
38a04ff993 | ||
|
|
d997c49e47 | ||
|
|
ca380ec039 | ||
|
|
93ee515d9d | ||
|
|
fdafc2a16c | ||
|
|
bf214122cd | ||
|
|
15d0bc0900 | ||
|
|
ec9ffbb89a | ||
|
|
c61becc62b | ||
|
|
0cc0a2485c | ||
|
|
ae42c93f9a | ||
|
|
98a2fa8e35 | ||
|
|
068a3afad9 | ||
|
|
16f40c1a15 | ||
|
|
5eb78aad96 | ||
|
|
80f4a008eb | ||
|
|
27cdfb7b84 | ||
|
|
25889b2d7e | ||
|
|
119f84fe11 | ||
|
|
06dba1fa62 | ||
|
|
4d24bf75fd | ||
|
|
d01b8e163d | ||
|
|
316e8f9239 | ||
|
|
9725b829d5 | ||
|
|
2c05caec7f | ||
|
|
626940ceb8 | ||
|
|
e984bfb4c6 | ||
|
|
ccca005969 | ||
|
|
635704b7ef | ||
|
|
8eb86c9ec9 | ||
|
|
c24c99f4ba | ||
|
|
9d5ae75950 | ||
|
|
425d2a2a97 | ||
|
|
23516717e4 | ||
|
|
2f4a729d40 | ||
|
|
e377abcc35 | ||
|
|
c738368846 | ||
|
|
1e97972f78 | ||
|
|
d7775d1e11 | ||
|
|
1fc873d09f | ||
|
|
74e7fac13f | ||
|
|
20f2cf8769 | ||
|
|
c462e0a51c | ||
|
|
8fa5d12fcb | ||
|
|
0c97021565 | ||
|
|
ff47cf77ab | ||
|
|
00093a305d | ||
|
|
3a634c56e3 | ||
|
|
371085546d | ||
|
|
eed15703ed | ||
|
|
4406f07a84 | ||
|
|
4cb4c9fb25 | ||
|
|
cbb5122729 | ||
|
|
e26e8b8829 | ||
|
|
dc0455e217 | ||
|
|
f6ce87c96d | ||
|
|
529633d970 | ||
|
|
d47fc48b32 | ||
|
|
c1b8f83dd4 | ||
|
|
149487ea0f | ||
|
|
f7d09b898a | ||
|
|
f78d2ef166 | ||
|
|
ce9b1320d2 | ||
|
|
4b00203fa5 | ||
|
|
936700bda3 | ||
|
|
4bf1afe300 | ||
|
|
edb11a7eca | ||
|
|
6c7e33fe47 | ||
|
|
ca3ce6da73 | ||
|
|
4778d67005 | ||
|
|
74539659f6 | ||
|
|
a5de4f692b | ||
|
|
bbeff4b8ca | ||
|
|
a33b6eed6d | ||
|
|
085a87060a | ||
|
|
05790ba1cf | ||
|
|
5b1a9f84fd | ||
|
|
d97333255d | ||
|
|
3370e19205 | ||
|
|
086fd70a5f | ||
|
|
84af1cab9b | ||
|
|
8a86e29579 | ||
|
|
1a72f62d7b | ||
|
|
3fe5e9057f | ||
|
|
dda44e31e3 | ||
|
|
9501a583cb | ||
|
|
768e8e363b | ||
|
|
0767523834 | ||
|
|
a1e32b8437 | ||
|
|
b7c9dee033 | ||
|
|
c0a00cd7fd | ||
|
|
713a14a6b5 | ||
|
|
b9dac1f8df | ||
|
|
865d46ae1e | ||
|
|
2c9bb0f973 | ||
|
|
0d2fd0d914 | ||
|
|
694c4bcbb6 | ||
|
|
e6cb7b4764 | ||
|
|
42b0c68eab | ||
|
|
9c530d725f | ||
|
|
ecfc6a3f4a | ||
|
|
720806b661 | ||
|
|
da3724a904 | ||
|
|
f074739e33 | ||
|
|
fc89bde044 | ||
|
|
db9d9d83eb | ||
|
|
d412c1b0eb | ||
|
|
d7f3d7efd2 | ||
|
|
b2c8d5eec7 | ||
|
|
b271217084 | ||
|
|
7c00ccb548 | ||
|
|
6b8e94864a | ||
|
|
7759b05dcb | ||
|
|
3357300362 | ||
|
|
824a4b4808 | ||
|
|
ef5be42c86 | ||
|
|
47b6e78790 | ||
|
|
7a17c3720b | ||
|
|
9fec0faade | ||
|
|
3cb65f0d31 | ||
|
|
9f8a8f3719 | ||
|
|
90097de6c3 | ||
|
|
7556a0f699 | ||
|
|
135e10ba09 | ||
|
|
d8da83b4ff | ||
|
|
a0fed03e10 | ||
|
|
b33db917f5 | ||
|
|
26b66c730e | ||
|
|
d47a18fd09 | ||
|
|
ed950e6c74 | ||
|
|
ba84074468 | ||
|
|
9d9b9d4938 | ||
|
|
b242ead6df | ||
|
|
1c7fbb86c2 | ||
|
|
a949556c4e | ||
|
|
7af97f88b7 | ||
|
|
32d1e50565 | ||
|
|
a2f1cd87f8 | ||
|
|
82e3b9a6e0 | ||
|
|
795acaa6aa | ||
|
|
57141e34bf | ||
|
|
7de0912a97 | ||
|
|
e741e5ebce | ||
|
|
4e2e69bd25 | ||
|
|
d00770d56b | ||
|
|
75e4af9d39 | ||
|
|
34d40e46a5 | ||
|
|
1cb1245d84 | ||
|
|
1387224821 | ||
|
|
6aa54a8e16 | ||
|
|
07cc16ff9c | ||
|
|
3a722ef81b | ||
|
|
75631e0267 | ||
|
|
7c0bfca7a0 | ||
|
|
454499ff60 | ||
|
|
346eda27cc | ||
|
|
f2a4d9b99c | ||
|
|
a74e65200c | ||
|
|
045c26f626 | ||
|
|
664c6191ed | ||
|
|
ac9c37f31b | ||
|
|
06012f8675 | ||
|
|
25fa647a74 | ||
|
|
2ebf70d719 | ||
|
|
a3210d1cf8 | ||
|
|
81ad9255b5 | ||
|
|
e1d98c9e4c | ||
|
|
26cd59cd6f | ||
|
|
e53b62304f | ||
|
|
a7dbafb0e3 | ||
|
|
e449950030 | ||
|
|
cd64da8746 | ||
|
|
47ffa12078 | ||
|
|
f41fc4eb25 | ||
|
|
10572b78f8 | ||
|
|
b4f472c4fa | ||
|
|
b5d0ac4c42 | ||
|
|
0c971d148c | ||
|
|
43d804b998 | ||
|
|
07058b044b | ||
|
|
d7fa9f671e | ||
|
|
ba2f13db63 | ||
|
|
217c7d1140 | ||
|
|
921ad8704e | ||
|
|
00c1586ff8 | ||
|
|
bf03523323 | ||
|
|
5b3a443125 | ||
|
|
924a5df25f | ||
|
|
e85c70223a | ||
|
|
4d32ca19bf | ||
|
|
48a175eff7 | ||
|
|
439f11cc3c | ||
|
|
3aa2fb9928 | ||
|
|
46335b103e | ||
|
|
328883700a | ||
|
|
6b88a665d3 | ||
|
|
12a3b85561 | ||
|
|
8f9a726465 | ||
|
|
cc7aa88b26 | ||
|
|
f9ee9efb97 | ||
|
|
4898f18f89 | ||
|
|
233b9ec4d7 | ||
|
|
7e1c7f54c7 | ||
|
|
ae0d6ab28a | ||
|
|
7c3a46ccea | ||
|
|
0c35d28933 | ||
|
|
533bbf033d | ||
|
|
1821372634 | ||
|
|
5f1f5ea5ab | ||
|
|
4979940def | ||
|
|
81a6c39781 | ||
|
|
a087dbed7f | ||
|
|
bb0ea25090 | ||
|
|
681fbda4b6 | ||
|
|
440905ad14 | ||
|
|
21a3a81c7a | ||
|
|
0cdea5c2f3 | ||
|
|
eb2bd9d203 | ||
|
|
02fe05f346 | ||
|
|
e597a7d94e | ||
|
|
9b56f99326 | ||
|
|
d90d8e9999 | ||
|
|
c5549d2730 | ||
|
|
0d5566e879 | ||
|
|
28548ab347 | ||
|
|
0e002e3693 | ||
|
|
29b3b44fab | ||
|
|
5efce21abc | ||
|
|
f490522082 | ||
|
|
ffc9b3dda7 | ||
|
|
61cdf9390d | ||
|
|
7d38f4940c | ||
|
|
6596a1de80 | ||
|
|
10097f13aa | ||
|
|
2fd8819a04 | ||
|
|
9de3979f5b | ||
|
|
ece7b33a96 | ||
|
|
06ab168897 | ||
|
|
ba6a6b2d40 | ||
|
|
434c3cf83b | ||
|
|
5c8d38d6cf | ||
|
|
6edecd5d94 | ||
|
|
c47de9878d | ||
|
|
6ae426c96b | ||
|
|
10e4fb2ce2 | ||
|
|
26904cc5a1 | ||
|
|
e65d1e459e | ||
|
|
477bee6468 | ||
|
|
fa8f5bafb2 | ||
|
|
214bae1479 | ||
|
|
ec818a506b | ||
|
|
61f4ab6674 | ||
|
|
3bc8cf65a4 | ||
|
|
d214e2d0c4 | ||
|
|
bd31821792 | ||
|
|
46eb8465a0 | ||
|
|
71a5cc2041 | ||
|
|
12289c4fd1 | ||
|
|
a4290cdbb3 | ||
|
|
177a53fbcf | ||
|
|
23ebae1828 | ||
|
|
df2a0fec5f | ||
|
|
ce979552fd | ||
|
|
e9847a4dbd | ||
|
|
f8bb90d963 | ||
|
|
91091c3e54 | ||
|
|
03fddb301b | ||
|
|
b135f1d58a | ||
|
|
645da54f25 | ||
|
|
66c328f51b | ||
|
|
f32a21d967 | ||
|
|
c86e828dbf | ||
|
|
15360cbb6b | ||
|
|
45f37e11ad | ||
|
|
4194d935ec | ||
|
|
af1fa95875 | ||
|
|
25fea82049 | ||
|
|
a4431381fa | ||
|
|
ab4d530462 | ||
|
|
48f8b884c3 | ||
|
|
55c9bc15e5 | ||
|
|
81d8deb1a8 | ||
|
|
a42bb799cc | ||
|
|
a1031772eb | ||
|
|
ff0332730d | ||
|
|
292a6037ad | ||
|
|
0e6ad94829 | ||
|
|
9978f36d9f | ||
|
|
b4a6f2195d | ||
|
|
3290cd09d3 | ||
|
|
2cb2f1d7e3 | ||
|
|
2b0b9f3e6c | ||
|
|
641c636790 | ||
|
|
182ea00cb3 | ||
|
|
543d1fe70b | ||
|
|
33aaa40bee | ||
|
|
601aa91163 | ||
|
|
6f5222e863 | ||
|
|
e92c05ebbd | ||
|
|
ac6dcd35fb | ||
|
|
f247ae1a75 | ||
|
|
ddd97cb78e | ||
|
|
84118c5735 | ||
|
|
1c6b8293d7 | ||
|
|
5d5edde429 | ||
|
|
4c83b5e719 | ||
|
|
93e1986d69 | ||
|
|
045aaa838a | ||
|
|
bf31896983 | ||
|
|
f9fb1484aa | ||
|
|
90f03ccd42 | ||
|
|
a81ddf3d70 | ||
|
|
ad00466483 | ||
|
|
1ffa69f691 | ||
|
|
5d25bb3084 | ||
|
|
5d93c99e8c | ||
|
|
7ca42d5711 | ||
|
|
304c5d4a8b | ||
|
|
4042c82a72 | ||
|
|
d9c3947824 | ||
|
|
a9480aed85 | ||
|
|
4cb73192a7 | ||
|
|
ed46b42fea | ||
|
|
0378baed35 | ||
|
|
04f76af22c | ||
|
|
e3d9d5566a | ||
|
|
386d67ec61 | ||
|
|
854dcd1abd | ||
|
|
c6d50cd431 | ||
|
|
b26276c8c4 | ||
|
|
fca4e4ec7c | ||
|
|
81a90e30c6 | ||
|
|
8d3250cee4 | ||
|
|
206fb306a7 | ||
|
|
ac135c649c | ||
|
|
46ae84cfba | ||
|
|
7cdb07b386 | ||
|
|
d322625f90 | ||
|
|
15a3f80e2e | ||
|
|
3ce198165c | ||
|
|
537b243360 | ||
|
|
67789201c3 | ||
|
|
0beccf23c0 | ||
|
|
a7cbb9edc9 | ||
|
|
12054aaa9f | ||
|
|
92ee288d66 | ||
|
|
ad1787770e | ||
|
|
21ec434688 | ||
|
|
f2d408829b | ||
|
|
2da8e60b6d | ||
|
|
e5582939fd | ||
|
|
890cb6a293 | ||
|
|
3ff7391495 | ||
|
|
a517e597f5 | ||
|
|
a49c5291dc | ||
|
|
222f530411 | ||
|
|
90a6891a7d | ||
|
|
f675d465b2 | ||
|
|
12599c34e2 | ||
|
|
cbb3bb62da | ||
|
|
ef08ab68a7 | ||
|
|
2262b13048 | ||
|
|
0e162511cf | ||
|
|
03c9d8ae4f | ||
|
|
5d0a8ff391 | ||
|
|
3bc8017464 | ||
|
|
c10405330d | ||
|
|
0e22021c65 | ||
|
|
ec4f981f1d | ||
|
|
5cd77a460c | ||
|
|
6f3c905744 | ||
|
|
1593d795ea | ||
|
|
1868680848 | ||
|
|
70081a40a4 | ||
|
|
c22a2ab7d2 | ||
|
|
e324f6f3f0 | ||
|
|
522ab85045 | ||
|
|
ed22014646 | ||
|
|
115e0aaf83 | ||
|
|
e1ac683154 | ||
|
|
293a024c14 | ||
|
|
6ddc39a676 | ||
|
|
46e4ecadc8 | ||
|
|
69f07fdb34 | ||
|
|
855c88a9c0 | ||
|
|
f40abc493a | ||
|
|
233f761779 | ||
|
|
258804cc04 | ||
|
|
9ae24cac2f | ||
|
|
06829c4082 | ||
|
|
d5419f0a46 | ||
|
|
7c839f176f | ||
|
|
53122fad40 | ||
|
|
ce043c5141 | ||
|
|
d4fa2c69ed | ||
|
|
c5de9840b0 | ||
|
|
5f2cbfc0fd | ||
|
|
b53713cdda | ||
|
|
9cc41d5118 | ||
|
|
59135c9a31 | ||
|
|
17fd075f39 | ||
|
|
148e46563f | ||
|
|
29e28f4b84 | ||
|
|
e20b0d5695 | ||
|
|
06068444e2 | ||
|
|
659c741ff5 | ||
|
|
8690a08881 | ||
|
|
aab2b032aa | ||
|
|
8e04c752fc | ||
|
|
4d2203ff52 | ||
|
|
f68b963596 | ||
|
|
99f39836a1 | ||
|
|
a7a1b8b7e9 | ||
|
|
fe16dc09da | ||
|
|
c7cd077e55 | ||
|
|
7f070236f7 | ||
|
|
0f008d5f7d | ||
|
|
d2367968e4 | ||
|
|
f064075a85 | ||
|
|
f281a994e8 | ||
|
|
831e4c3850 | ||
|
|
94d44142e3 | ||
|
|
7bf1986e91 | ||
|
|
97f0c9da84 | ||
|
|
c0319daa40 | ||
|
|
3332af4060 | ||
|
|
a3c723ee30 | ||
|
|
68c8633ba1 | ||
|
|
17aef1c883 | ||
|
|
ebc1209fc9 | ||
|
|
2bfe60e2fb | ||
|
|
69bc37acd6 | ||
|
|
0dce496499 | ||
|
|
600087ab49 | ||
|
|
4153cfbf14 | ||
|
|
84eb25da23 | ||
|
|
933ac60746 | ||
|
|
7d50015a74 | ||
|
|
75b8cf428e | ||
|
|
747ece59d2 | ||
|
|
2c581cae2a | ||
|
|
9b83e53b28 | ||
|
|
9fee431cc8 | ||
|
|
f8785b5f47 | ||
|
|
76629289f0 | ||
|
|
cbc9ae898c | ||
|
|
023faa227e | ||
|
|
23ae4c0a4d | ||
|
|
e89bcf4f77 | ||
|
|
4dfffa1df3 | ||
|
|
d87ddf50fc | ||
|
|
285bd3abc8 | ||
|
|
c92654fb43 | ||
|
|
2b142f2f9e | ||
|
|
feffc8081d | ||
|
|
03e421bf3d | ||
|
|
4ad9b27530 | ||
|
|
3b377f16b2 | ||
|
|
e97567e227 | ||
|
|
c2093ccce1 | ||
|
|
6a9630d2bd | ||
|
|
3f9b274180 | ||
|
|
9ca54d00d8 | ||
|
|
afd0d6af07 | ||
|
|
d9c049fd9f | ||
|
|
b05ed4ffa6 | ||
|
|
506d5e41bf | ||
|
|
617637c788 | ||
|
|
b5b01e5bb5 | ||
|
|
876d0d310f | ||
|
|
f32027f3b5 | ||
|
|
cfb20f09a9 | ||
|
|
dd7d7683c9 | ||
|
|
da5dbaf1d0 | ||
|
|
3072f257f5 | ||
|
|
abde0d4efb | ||
|
|
13170ca627 | ||
|
|
3f0f313a76 | ||
|
|
e82fab34d7 | ||
|
|
5f4c4df227 | ||
|
|
285dc554ec | ||
|
|
c96a6f1de6 | ||
|
|
953090fd62 | ||
|
|
f783b9169f | ||
|
|
128c72a234 | ||
|
|
01636ca900 | ||
|
|
93206ef0fa | ||
|
|
c4d9a23f26 | ||
|
|
1f17ef6d3c | ||
|
|
7471bc7775 | ||
|
|
476a7d3eee | ||
|
|
e23a0dcc5d | ||
|
|
46c833810c | ||
|
|
4de530af45 | ||
|
|
b1cd1d917e | ||
|
|
16af5b87f8 | ||
|
|
36651bed71 | ||
|
|
8de933ab07 | ||
|
|
c0ff5635ba | ||
|
|
3cb1c23554 | ||
|
|
9151b9d233 | ||
|
|
90b9121e66 | ||
|
|
3648164219 | ||
|
|
c2e4f8aed5 | ||
|
|
1dd2d432f1 | ||
|
|
8360223fed | ||
|
|
8510f57ad4 | ||
|
|
397379cd3f | ||
|
|
55ab6f015a | ||
|
|
5e1f651e21 | ||
|
|
0635d9d174 | ||
|
|
e4a70b9f9a | ||
|
|
d07943c262 | ||
|
|
fcecfc81bb | ||
|
|
3611d33b00 | ||
|
|
a7a9a8a614 | ||
|
|
46a81b3527 | ||
|
|
464201b41d | ||
|
|
fc84ebb819 | ||
|
|
6e1b3f9951 | ||
|
|
03075359b5 | ||
|
|
7e5d553781 | ||
|
|
35843e8ec8 | ||
|
|
e9f3cd1a60 | ||
|
|
45dee383db | ||
|
|
bd0c1d9b6a | ||
|
|
d05af4bdad | ||
|
|
7fb458b055 | ||
|
|
3a7d9f740e | ||
|
|
8cc3adb585 | ||
|
|
924d6e892a | ||
|
|
032b645e80 | ||
|
|
78b25094dc | ||
|
|
c10c43d6f6 | ||
|
|
d3e76730bd | ||
|
|
cb74186888 | ||
|
|
e25ba116a3 | ||
|
|
081271e1d7 | ||
|
|
12900ea84e | ||
|
|
2fbc08d7dd | ||
|
|
0ea0f8aa83 | ||
|
|
56b333f301 | ||
|
|
55204ccde6 | ||
|
|
f8dab4f93f | ||
|
|
ca99f418d8 | ||
|
|
c1115e4c2e |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -10,6 +10,12 @@
|
||||
*.pidb
|
||||
*.dll.build
|
||||
*.dll
|
||||
|
||||
# Ignore .user and .suo files as these are user preference specific
|
||||
# http://stackoverflow.com/questions/72298/should-i-add-the-visual-studio-suo-and-user-files-to-source-control
|
||||
*.suo
|
||||
*.user
|
||||
|
||||
*.VisualState.xml
|
||||
*/*/obj
|
||||
*/*/*/obj
|
||||
@@ -65,7 +71,6 @@ bin/crashes/
|
||||
Examples/*.dll
|
||||
OpenSim.build
|
||||
OpenSim.sln
|
||||
OpenSim.suo
|
||||
OpenSim.userprefs
|
||||
Prebuild/Prebuild.build
|
||||
Prebuild/Prebuild.sln
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<<<>>>>The following people have contributed to OpenSim (Thank you
|
||||
for your effort!)
|
||||
The following people have contributed to OpenSim (Thank you for your effort!)
|
||||
|
||||
= Current OpenSim Developers (in very rough order of appearance) =
|
||||
These folks represent the current core team for OpenSim, and are the
|
||||
@@ -7,7 +6,7 @@ people that make the day to day of OpenSim happen.
|
||||
|
||||
* justincc (OSVW Consulting, justincc.org)
|
||||
* chi11ken (Genkii)
|
||||
* dahlia
|
||||
* dahlia
|
||||
* Melanie Thielker
|
||||
* Diva (Crista Lopes, University of California, Irvine)
|
||||
* Dan Lake (Intel)
|
||||
@@ -58,13 +57,15 @@ where we are today.
|
||||
|
||||
|
||||
= Additional OpenSim Contributors =
|
||||
These folks have contributed code patches to OpenSim to help make it
|
||||
These folks have contributed code patches or content to OpenSimulator to help make it
|
||||
what it is today.
|
||||
|
||||
* aduffy70
|
||||
* A_Biondi
|
||||
* aduffy70
|
||||
* Ai Austin
|
||||
* alex_carnell
|
||||
* Alan Webb (IBM)
|
||||
* Aleric
|
||||
* Allen Kerensky
|
||||
* BigFootAg
|
||||
* BlueWall Slade
|
||||
@@ -74,17 +75,20 @@ what it is today.
|
||||
* Chris Yeoh (IBM)
|
||||
* controlbreak
|
||||
* coyled
|
||||
* ctrlaltdavid (David Rowe)
|
||||
* Daedius
|
||||
* Dong Jun Lan (IBM)
|
||||
* DoranZemlja
|
||||
* daTwitch
|
||||
* devalnor-#708
|
||||
* dmiles (Daxtron Labs)
|
||||
* Dong Jun Lan (IBM)
|
||||
* DoranZemlja
|
||||
* dr0b3rts
|
||||
* dslake (Intel)
|
||||
* FredoChaplin
|
||||
* Garmin Kawaguichi
|
||||
* Gerhard
|
||||
* Godfrey
|
||||
* Greg C.
|
||||
* Grumly57
|
||||
* GuduleLapointe
|
||||
* Ewe Loon
|
||||
@@ -101,10 +105,12 @@ what it is today.
|
||||
* jhurliman
|
||||
* John R Sohn (XenReborn)
|
||||
* jonc
|
||||
* Jon Cundill
|
||||
* Junta Kohime
|
||||
* Kayne
|
||||
* Kevin Cozens
|
||||
* kinoc (Daxtron Labs)
|
||||
* Kira
|
||||
* Kitto Flora
|
||||
* KittyLiu
|
||||
* Kurt Taylor (IBM)
|
||||
@@ -139,6 +145,7 @@ what it is today.
|
||||
* Richard Alimi (IBM)
|
||||
* Rick Alther (IBM)
|
||||
* Rob Smart (IBM)
|
||||
* Roger Kirkman (zadark)
|
||||
* rtomita
|
||||
* Ruud Lathorp
|
||||
* SachaMagne
|
||||
@@ -155,33 +162,30 @@ what it is today.
|
||||
* tglion
|
||||
* tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud)
|
||||
* tyre
|
||||
* Vegaslon <vegaslon@gmail.com>
|
||||
* VikingErik
|
||||
* Vytek
|
||||
* webmage (IBM)
|
||||
* Xantor
|
||||
* Y. Nitta
|
||||
* YoshikoFazuku
|
||||
* YZh
|
||||
* Zackary Geers aka Kunnis Basiat
|
||||
* Zha Ewry
|
||||
* ziah
|
||||
|
||||
|
||||
= LSL Devs =
|
||||
|
||||
* Alondria
|
||||
* CharlieO
|
||||
* Tedd
|
||||
* Melanie Thielker
|
||||
|
||||
|
||||
= Testers =
|
||||
|
||||
* Ai Austin
|
||||
* CharlieO (LSL)
|
||||
* Ckrinke
|
||||
* openlifegrid.com
|
||||
|
||||
|
||||
This software uses components from the following developers:
|
||||
* Sleepycat Software (Berkeley DB)
|
||||
* Aurora-Sim (http://aurora-sim.org)
|
||||
@@ -212,5 +216,3 @@ In addition, we would like to thank:
|
||||
* The Mono Project
|
||||
* The NANT Developers
|
||||
* Microsoft (.NET, MSSQL-Adapters)
|
||||
*x
|
||||
|
||||
|
||||
@@ -504,6 +504,30 @@ namespace OpenSim.Groups
|
||||
|
||||
return notice;
|
||||
}
|
||||
|
||||
public static Dictionary<string, object> DirGroupsReplyData(DirGroupsReplyData g)
|
||||
{
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
|
||||
dict["GroupID"] = g.groupID;
|
||||
dict["Name"] = g.groupName;
|
||||
dict["NMembers"] = g.members;
|
||||
dict["SearchOrder"] = g.searchOrder;
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
public static DirGroupsReplyData DirGroupsReplyData(Dictionary<string, object> dict)
|
||||
{
|
||||
DirGroupsReplyData g;
|
||||
|
||||
g.groupID = new UUID(dict["GroupID"].ToString());
|
||||
g.groupName = dict["Name"].ToString();
|
||||
Int32.TryParse(dict["NMembers"].ToString(), out g.members);
|
||||
float.TryParse(dict["SearchOrder"].ToString(), out g.searchOrder);
|
||||
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
|
||||
namespace OpenSim.Groups
|
||||
{
|
||||
@@ -51,7 +52,7 @@ namespace OpenSim.Groups
|
||||
private IPresenceService m_presenceService;
|
||||
|
||||
private IMessageTransferModule m_msgTransferModule = null;
|
||||
|
||||
private IUserManagement m_UserManagement = null;
|
||||
private IGroupsServicesConnector m_groupData = null;
|
||||
|
||||
// Config Options
|
||||
@@ -79,6 +80,10 @@ namespace OpenSim.Groups
|
||||
|
||||
private int m_usersOnlineCacheExpirySeconds = 20;
|
||||
|
||||
private Dictionary<UUID, List<string>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<string>>();
|
||||
private Dictionary<UUID, List<string>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<string>>();
|
||||
|
||||
|
||||
#region Region Module interfaceBase Members
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
@@ -124,10 +129,12 @@ namespace OpenSim.Groups
|
||||
m_sceneList.Add(scene);
|
||||
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
|
||||
scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
|
||||
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
||||
scene.EventManager.OnClientLogin += OnClientLogin;
|
||||
}
|
||||
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!m_groupMessagingEnabled)
|
||||
@@ -155,6 +162,17 @@ namespace OpenSim.Groups
|
||||
return;
|
||||
}
|
||||
|
||||
m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
|
||||
|
||||
// No groups module, no groups messaging
|
||||
if (m_UserManagement == null)
|
||||
{
|
||||
m_log.Error("[Groups.Messaging]: Could not get IUserManagement, GroupsMessagingModule is now disabled.");
|
||||
RemoveRegion(scene);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_presenceService == null)
|
||||
m_presenceService = scene.PresenceService;
|
||||
|
||||
@@ -227,87 +245,107 @@ namespace OpenSim.Groups
|
||||
|
||||
public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
|
||||
{
|
||||
List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(new UUID(im.fromAgentID).ToString(), groupID);
|
||||
UUID fromAgentID = new UUID(im.fromAgentID);
|
||||
List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(UUID.Zero.ToString(), groupID);
|
||||
int groupMembersCount = groupMembers.Count;
|
||||
PresenceInfo[] onlineAgents = null;
|
||||
|
||||
if (m_messageOnlineAgentsOnly)
|
||||
// In V2 we always only send to online members.
|
||||
// Sending to offline members is not an option.
|
||||
string[] t1 = groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString()).ToArray();
|
||||
|
||||
// We cache in order not to overwhlem the presence service on large grids with many groups. This does
|
||||
// mean that members coming online will not see all group members until after m_usersOnlineCacheExpirySeconds has elapsed.
|
||||
// (assuming this is the same across all grid simulators).
|
||||
if (!m_usersOnlineCache.TryGetValue(groupID, out onlineAgents))
|
||||
{
|
||||
string[] t1 = groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString()).ToArray();
|
||||
onlineAgents = m_presenceService.GetAgents(t1);
|
||||
m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds);
|
||||
}
|
||||
|
||||
// We cache in order not to overwhlem the presence service on large grids with many groups. This does
|
||||
// mean that members coming online will not see all group members until after m_usersOnlineCacheExpirySeconds has elapsed.
|
||||
// (assuming this is the same across all grid simulators).
|
||||
PresenceInfo[] onlineAgents;
|
||||
if (!m_usersOnlineCache.TryGetValue(groupID, out onlineAgents))
|
||||
{
|
||||
onlineAgents = m_presenceService.GetAgents(t1);
|
||||
m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds);
|
||||
}
|
||||
HashSet<string> onlineAgentsUuidSet = new HashSet<string>();
|
||||
Array.ForEach<PresenceInfo>(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID));
|
||||
|
||||
HashSet<string> onlineAgentsUuidSet = new HashSet<string>();
|
||||
Array.ForEach<PresenceInfo>(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID));
|
||||
groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList();
|
||||
|
||||
groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList();
|
||||
|
||||
// if (m_debugEnabled)
|
||||
// if (m_debugEnabled)
|
||||
// m_log.DebugFormat(
|
||||
// "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members, {2} online",
|
||||
// groupID, groupMembersCount, groupMembers.Count());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat(
|
||||
"[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members",
|
||||
groupID, groupMembers.Count);
|
||||
}
|
||||
|
||||
int requestStartTick = Environment.TickCount;
|
||||
|
||||
im.imSessionID = groupID.Guid;
|
||||
im.fromGroup = true;
|
||||
IClientAPI thisClient = GetActiveClient(fromAgentID);
|
||||
if (thisClient != null)
|
||||
{
|
||||
im.RegionID = thisClient.Scene.RegionInfo.RegionID.Guid;
|
||||
}
|
||||
|
||||
// Send to self first of all
|
||||
im.toAgentID = im.fromAgentID;
|
||||
im.fromGroup = true;
|
||||
ProcessMessageFromGroupSession(im);
|
||||
|
||||
List<UUID> regions = new List<UUID>();
|
||||
List<UUID> clientsAlreadySent = new List<UUID>();
|
||||
|
||||
// Then send to everybody else
|
||||
foreach (GroupMembersData member in groupMembers)
|
||||
{
|
||||
if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID.ToString(), groupID))
|
||||
if (member.AgentID.Guid == im.fromAgentID)
|
||||
continue;
|
||||
|
||||
if (clientsAlreadySent.Contains(member.AgentID))
|
||||
continue;
|
||||
clientsAlreadySent.Add(member.AgentID);
|
||||
|
||||
if (hasAgentDroppedGroupChatSession(member.AgentID.ToString(), groupID))
|
||||
{
|
||||
// Don't deliver messages to people who have dropped this session
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: {0} has dropped session, not delivering to them", member.AgentID);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Copy Message
|
||||
GridInstantMessage msg = new GridInstantMessage();
|
||||
msg.imSessionID = groupID.Guid;
|
||||
msg.fromAgentName = im.fromAgentName;
|
||||
msg.message = im.message;
|
||||
msg.dialog = im.dialog;
|
||||
msg.offline = im.offline;
|
||||
msg.ParentEstateID = im.ParentEstateID;
|
||||
msg.Position = im.Position;
|
||||
msg.RegionID = im.RegionID;
|
||||
msg.binaryBucket = im.binaryBucket;
|
||||
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
|
||||
|
||||
msg.fromAgentID = im.fromAgentID;
|
||||
msg.fromGroup = true;
|
||||
|
||||
msg.toAgentID = member.AgentID.Guid;
|
||||
im.toAgentID = member.AgentID.Guid;
|
||||
|
||||
IClientAPI client = GetActiveClient(member.AgentID);
|
||||
if (client == null)
|
||||
{
|
||||
// If they're not local, forward across the grid
|
||||
// BUT do it only once per region, please! Sim would be even better!
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Delivering to {0} via Grid", member.AgentID);
|
||||
m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
|
||||
|
||||
bool reallySend = true;
|
||||
if (onlineAgents != null)
|
||||
{
|
||||
PresenceInfo presence = onlineAgents.First(p => p.UserID == member.AgentID.ToString());
|
||||
if (regions.Contains(presence.RegionID))
|
||||
reallySend = false;
|
||||
else
|
||||
regions.Add(presence.RegionID);
|
||||
}
|
||||
|
||||
if (reallySend)
|
||||
{
|
||||
// We have to create a new IM structure because the transfer module
|
||||
// uses async send
|
||||
GridInstantMessage msg = new GridInstantMessage(im, true);
|
||||
m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Deliver locally, directly
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
|
||||
ProcessMessageFromGroupSession(msg);
|
||||
|
||||
ProcessMessageFromGroupSession(im);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Temporary for assessing how long it still takes to send messages to large online groups.
|
||||
if (m_messageOnlineAgentsOnly)
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat(
|
||||
"[Groups.Messaging]: SendMessageToGroup for group {0} with {1} visible members, {2} online took {3}ms",
|
||||
groupID, groupMembersCount, groupMembers.Count(), Environment.TickCount - requestStartTick);
|
||||
@@ -324,9 +362,20 @@ namespace OpenSim.Groups
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: OnInstantMessage registered for {0}", client.Name);
|
||||
|
||||
client.OnInstantMessage += OnInstantMessage;
|
||||
ResetAgentGroupChatSessions(client.AgentId.ToString());
|
||||
}
|
||||
|
||||
void OnMakeRootAgent(ScenePresence sp)
|
||||
{
|
||||
sp.ControllingClient.OnInstantMessage += OnInstantMessage;
|
||||
}
|
||||
|
||||
void OnMakeChildAgent(ScenePresence sp)
|
||||
{
|
||||
sp.ControllingClient.OnInstantMessage -= OnInstantMessage;
|
||||
}
|
||||
|
||||
|
||||
private void OnGridInstantMessage(GridInstantMessage msg)
|
||||
{
|
||||
// The instant message module will only deliver messages of dialog types:
|
||||
@@ -335,21 +384,91 @@ namespace OpenSim.Groups
|
||||
// Any other message type will not be delivered to a client by the
|
||||
// Instant Message Module
|
||||
|
||||
|
||||
UUID regionID = new UUID(msg.RegionID);
|
||||
if (m_debugEnabled)
|
||||
{
|
||||
m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
m_log.DebugFormat("[Groups.Messaging]: {0} called, IM from region {1}",
|
||||
System.Reflection.MethodBase.GetCurrentMethod().Name, regionID);
|
||||
|
||||
DebugGridInstantMessage(msg);
|
||||
}
|
||||
|
||||
// Incoming message from a group
|
||||
if ((msg.fromGroup == true) &&
|
||||
((msg.dialog == (byte)InstantMessageDialog.SessionSend)
|
||||
|| (msg.dialog == (byte)InstantMessageDialog.SessionAdd)
|
||||
|| (msg.dialog == (byte)InstantMessageDialog.SessionDrop)))
|
||||
if ((msg.fromGroup == true) && (msg.dialog == (byte)InstantMessageDialog.SessionSend))
|
||||
{
|
||||
ProcessMessageFromGroupSession(msg);
|
||||
// We have to redistribute the message across all members of the group who are here
|
||||
// on this sim
|
||||
|
||||
UUID GroupID = new UUID(msg.imSessionID);
|
||||
|
||||
Scene aScene = m_sceneList[0];
|
||||
GridRegion regionOfOrigin = aScene.GridService.GetRegionByUUID(aScene.RegionInfo.ScopeID, regionID);
|
||||
|
||||
List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(UUID.Zero.ToString(), GroupID);
|
||||
|
||||
//if (m_debugEnabled)
|
||||
// foreach (GroupMembersData m in groupMembers)
|
||||
// m_log.DebugFormat("[Groups.Messaging]: member {0}", m.AgentID);
|
||||
|
||||
foreach (Scene s in m_sceneList)
|
||||
{
|
||||
s.ForEachScenePresence(sp =>
|
||||
{
|
||||
// If we got this via grid messaging, it's because the caller thinks
|
||||
// that the root agent is here. We should only send the IM to root agents.
|
||||
if (sp.IsChildAgent)
|
||||
return;
|
||||
|
||||
GroupMembersData m = groupMembers.Find(gmd =>
|
||||
{
|
||||
return gmd.AgentID == sp.UUID;
|
||||
});
|
||||
if (m.AgentID == UUID.Zero)
|
||||
{
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat("[Groups.Messaging]: skipping agent {0} because he is not a member of the group", sp.UUID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the user has an agent in the region where
|
||||
// the IM came from, and if so, skip it, because the IM
|
||||
// was already sent via that agent
|
||||
if (regionOfOrigin != null)
|
||||
{
|
||||
AgentCircuitData aCircuit = s.AuthenticateHandler.GetAgentCircuitData(sp.UUID);
|
||||
if (aCircuit != null)
|
||||
{
|
||||
if (aCircuit.ChildrenCapSeeds.Keys.Contains(regionOfOrigin.RegionHandle))
|
||||
{
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat("[Groups.Messaging]: skipping agent {0} because he has an agent in region of origin", sp.UUID);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat("[Groups.Messaging]: not skipping agent {0}", sp.UUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UUID AgentID = sp.UUID;
|
||||
msg.toAgentID = AgentID.Guid;
|
||||
|
||||
if (!hasAgentDroppedGroupChatSession(AgentID.ToString(), GroupID))
|
||||
{
|
||||
if (!hasAgentBeenInvitedToGroupChatSession(AgentID.ToString(), GroupID))
|
||||
AddAgentToSession(AgentID, GroupID, msg);
|
||||
else
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", sp.Name);
|
||||
|
||||
ProcessMessageFromGroupSession(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,82 +478,40 @@ namespace OpenSim.Groups
|
||||
|
||||
UUID AgentID = new UUID(msg.fromAgentID);
|
||||
UUID GroupID = new UUID(msg.imSessionID);
|
||||
UUID toAgentID = new UUID(msg.toAgentID);
|
||||
|
||||
switch (msg.dialog)
|
||||
{
|
||||
case (byte)InstantMessageDialog.SessionAdd:
|
||||
m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
break;
|
||||
|
||||
case (byte)InstantMessageDialog.SessionDrop:
|
||||
m_groupData.AgentDroppedFromGroupChatSession(AgentID.ToString(), GroupID);
|
||||
AgentDroppedFromGroupChatSession(AgentID.ToString(), GroupID);
|
||||
break;
|
||||
|
||||
case (byte)InstantMessageDialog.SessionSend:
|
||||
if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID.ToString(), GroupID)
|
||||
&& !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID.ToString(), GroupID)
|
||||
)
|
||||
// User hasn't dropped, so they're in the session,
|
||||
// maybe we should deliver it.
|
||||
IClientAPI client = GetActiveClient(new UUID(msg.toAgentID));
|
||||
if (client != null)
|
||||
{
|
||||
// Agent not in session and hasn't dropped from session
|
||||
// Add them to the session for now, and Invite them
|
||||
m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
// Deliver locally, directly
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Delivering to {0} locally", client.Name);
|
||||
|
||||
UUID toAgentID = new UUID(msg.toAgentID);
|
||||
IClientAPI activeClient = GetActiveClient(toAgentID);
|
||||
if (activeClient != null)
|
||||
if (!hasAgentDroppedGroupChatSession(toAgentID.ToString(), GroupID))
|
||||
{
|
||||
GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), GroupID, null);
|
||||
if (groupInfo != null)
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Sending chatterbox invite instant message");
|
||||
|
||||
// Force? open the group session dialog???
|
||||
// and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
|
||||
IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
|
||||
eq.ChatterboxInvitation(
|
||||
GroupID
|
||||
, groupInfo.GroupName
|
||||
, new UUID(msg.fromAgentID)
|
||||
, msg.message
|
||||
, new UUID(msg.toAgentID)
|
||||
, msg.fromAgentName
|
||||
, msg.dialog
|
||||
, msg.timestamp
|
||||
, msg.offline == 1
|
||||
, (int)msg.ParentEstateID
|
||||
, msg.Position
|
||||
, 1
|
||||
, new UUID(msg.imSessionID)
|
||||
, msg.fromGroup
|
||||
, OpenMetaverse.Utils.StringToBytes(groupInfo.GroupName)
|
||||
);
|
||||
|
||||
eq.ChatterBoxSessionAgentListUpdates(
|
||||
new UUID(GroupID)
|
||||
, new UUID(msg.fromAgentID)
|
||||
, new UUID(msg.toAgentID)
|
||||
, false //canVoiceChat
|
||||
, false //isModerator
|
||||
, false //text mute
|
||||
);
|
||||
}
|
||||
if (!hasAgentBeenInvitedToGroupChatSession(toAgentID.ToString(), GroupID))
|
||||
// This actually sends the message too, so no need to resend it
|
||||
// with client.SendInstantMessage
|
||||
AddAgentToSession(toAgentID, GroupID, msg);
|
||||
else
|
||||
client.SendInstantMessage(msg);
|
||||
}
|
||||
}
|
||||
else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID.ToString(), GroupID))
|
||||
else
|
||||
{
|
||||
// User hasn't dropped, so they're in the session,
|
||||
// maybe we should deliver it.
|
||||
IClientAPI client = GetActiveClient(new UUID(msg.toAgentID));
|
||||
if (client != null)
|
||||
{
|
||||
// Deliver locally, directly
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Delivering to {0} locally", client.Name);
|
||||
client.SendInstantMessage(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[Groups.Messaging]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
|
||||
}
|
||||
m_log.WarnFormat("[Groups.Messaging]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -444,6 +521,53 @@ namespace OpenSim.Groups
|
||||
}
|
||||
}
|
||||
|
||||
private void AddAgentToSession(UUID AgentID, UUID GroupID, GridInstantMessage msg)
|
||||
{
|
||||
// Agent not in session and hasn't dropped from session
|
||||
// Add them to the session for now, and Invite them
|
||||
AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
|
||||
IClientAPI activeClient = GetActiveClient(AgentID);
|
||||
if (activeClient != null)
|
||||
{
|
||||
GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), GroupID, null);
|
||||
if (groupInfo != null)
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Sending chatterbox invite instant message");
|
||||
|
||||
// Force? open the group session dialog???
|
||||
// and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
|
||||
IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
|
||||
eq.ChatterboxInvitation(
|
||||
GroupID
|
||||
, groupInfo.GroupName
|
||||
, new UUID(msg.fromAgentID)
|
||||
, msg.message
|
||||
, AgentID
|
||||
, msg.fromAgentName
|
||||
, msg.dialog
|
||||
, msg.timestamp
|
||||
, msg.offline == 1
|
||||
, (int)msg.ParentEstateID
|
||||
, msg.Position
|
||||
, 1
|
||||
, new UUID(msg.imSessionID)
|
||||
, msg.fromGroup
|
||||
, OpenMetaverse.Utils.StringToBytes(groupInfo.GroupName)
|
||||
);
|
||||
|
||||
eq.ChatterBoxSessionAgentListUpdates(
|
||||
new UUID(GroupID)
|
||||
, AgentID
|
||||
, new UUID(msg.toAgentID)
|
||||
, false //canVoiceChat
|
||||
, false //isModerator
|
||||
, false //text mute
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -469,7 +593,7 @@ namespace OpenSim.Groups
|
||||
|
||||
if (groupInfo != null)
|
||||
{
|
||||
m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
|
||||
ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
|
||||
|
||||
@@ -495,7 +619,7 @@ namespace OpenSim.Groups
|
||||
m_log.DebugFormat("[Groups.Messaging]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
|
||||
|
||||
//If this agent is sending a message, then they want to be in the session
|
||||
m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
|
||||
|
||||
SendMessageToGroup(im, GroupID);
|
||||
}
|
||||
@@ -566,12 +690,12 @@ namespace OpenSim.Groups
|
||||
{
|
||||
if (!sp.IsChildAgent)
|
||||
{
|
||||
if (m_debugEnabled) m_log.WarnFormat("[Groups.Messaging]: Found root agent for client : {0}", sp.ControllingClient.Name);
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Found root agent for client : {0}", sp.ControllingClient.Name);
|
||||
return sp.ControllingClient;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_debugEnabled) m_log.WarnFormat("[Groups.Messaging]: Found child agent for client : {0}", sp.ControllingClient.Name);
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Found child agent for client : {0}", sp.ControllingClient.Name);
|
||||
child = sp.ControllingClient;
|
||||
}
|
||||
}
|
||||
@@ -590,5 +714,71 @@ namespace OpenSim.Groups
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GroupSessionTracking
|
||||
|
||||
public void ResetAgentGroupChatSessions(string agentID)
|
||||
{
|
||||
foreach (List<string> agentList in m_groupsAgentsDroppedFromChatSession.Values)
|
||||
agentList.Remove(agentID);
|
||||
|
||||
foreach (List<string> agentList in m_groupsAgentsInvitedToChatSession.Values)
|
||||
agentList.Remove(agentID);
|
||||
}
|
||||
|
||||
public bool hasAgentBeenInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
// If we're tracking this group, and we can find them in the tracking, then they've been invited
|
||||
return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
|
||||
&& m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
|
||||
}
|
||||
|
||||
public bool hasAgentDroppedGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
// If we're tracking drops for this group,
|
||||
// and we find them, well... then they've dropped
|
||||
return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
|
||||
&& m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
|
||||
}
|
||||
|
||||
public void AgentDroppedFromGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
|
||||
{
|
||||
// If not in dropped list, add
|
||||
if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
|
||||
{
|
||||
m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AgentInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
// Add Session Status if it doesn't exist for this session
|
||||
CreateGroupChatSessionTracking(groupID);
|
||||
|
||||
// If nessesary, remove from dropped list
|
||||
if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
|
||||
{
|
||||
m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
|
||||
}
|
||||
|
||||
// Add to invited
|
||||
if (!m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID))
|
||||
m_groupsAgentsInvitedToChatSession[groupID].Add(agentID);
|
||||
}
|
||||
|
||||
private void CreateGroupChatSessionTracking(UUID groupID)
|
||||
{
|
||||
if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
|
||||
{
|
||||
m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<string>());
|
||||
m_groupsAgentsInvitedToChatSession.Add(groupID, new List<string>());
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,8 @@ namespace OpenSim.Groups
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnMakeRootAgent += OnMakeRoot;
|
||||
scene.EventManager.OnMakeChildAgent += OnMakeChild;
|
||||
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
||||
// The InstantMessageModule itself doesn't do this,
|
||||
// so lets see if things explode if we don't do it
|
||||
@@ -194,6 +196,8 @@ namespace OpenSim.Groups
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
scene.EventManager.OnNewClient -= OnNewClient;
|
||||
scene.EventManager.OnMakeRootAgent -= OnMakeRoot;
|
||||
scene.EventManager.OnMakeChildAgent -= OnMakeChild;
|
||||
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
|
||||
|
||||
lock (m_sceneList)
|
||||
@@ -232,16 +236,29 @@ namespace OpenSim.Groups
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
|
||||
client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
|
||||
client.OnDirFindQuery += OnDirFindQuery;
|
||||
client.OnRequestAvatarProperties += OnRequestAvatarProperties;
|
||||
}
|
||||
|
||||
private void OnMakeRoot(ScenePresence sp)
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
sp.ControllingClient.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
|
||||
// Used for Notices and Group Invites/Accept/Reject
|
||||
client.OnInstantMessage += OnInstantMessage;
|
||||
sp.ControllingClient.OnInstantMessage += OnInstantMessage;
|
||||
|
||||
// Send client their groups information.
|
||||
SendAgentGroupDataUpdate(client, client.AgentId);
|
||||
SendAgentGroupDataUpdate(sp.ControllingClient, sp.UUID);
|
||||
}
|
||||
|
||||
private void OnMakeChild(ScenePresence sp)
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
sp.ControllingClient.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
|
||||
// Used for Notices and Group Invites/Accept/Reject
|
||||
sp.ControllingClient.OnInstantMessage -= OnInstantMessage;
|
||||
}
|
||||
|
||||
private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
|
||||
@@ -287,21 +304,6 @@ namespace OpenSim.Groups
|
||||
}
|
||||
*/
|
||||
|
||||
void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
|
||||
{
|
||||
if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
|
||||
{
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat(
|
||||
"[Groups]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
|
||||
System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
|
||||
|
||||
// TODO: This currently ignores pretty much all the query flags including Mature and sort order
|
||||
remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentIDStr(remoteClient), queryText).ToArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
@@ -347,7 +349,7 @@ namespace OpenSim.Groups
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
m_log.DebugFormat("[Groups]: IM From {0} to {1} msg {2} type {3}", im.fromAgentID, im.toAgentID, im.message, (InstantMessageDialog)im.dialog);
|
||||
//m_log.DebugFormat("[Groups]: IM From {0} to {1} msg {2} type {3}", im.fromAgentID, im.toAgentID, im.message, (InstantMessageDialog)im.dialog);
|
||||
// Group invitations
|
||||
if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
|
||||
{
|
||||
@@ -465,12 +467,12 @@ namespace OpenSim.Groups
|
||||
}
|
||||
|
||||
// Send notice out to everyone that wants notices
|
||||
// Build notice IIM
|
||||
GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice);
|
||||
foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID))
|
||||
{
|
||||
if (member.AcceptNotices)
|
||||
{
|
||||
// Build notice IIM, one of reach, because the sending may be async
|
||||
GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice);
|
||||
msg.toAgentID = member.AgentID.Guid;
|
||||
OutgoingInstantMessage(msg, member.AgentID);
|
||||
}
|
||||
@@ -485,7 +487,7 @@ namespace OpenSim.Groups
|
||||
return;
|
||||
|
||||
//// 16 bytes are the UUID. Maybe.
|
||||
UUID folderID = new UUID(im.binaryBucket, 0);
|
||||
// UUID folderID = new UUID(im.binaryBucket, 0);
|
||||
UUID noticeID = new UUID(im.imSessionID);
|
||||
|
||||
GroupNoticeInfo notice = m_groupData.GetGroupNotice(remoteClient.AgentId.ToString(), noticeID);
|
||||
@@ -766,14 +768,17 @@ namespace OpenSim.Groups
|
||||
remoteClient.SendCreateGroupReply(UUID.Zero, false, "Insufficient funds to create a group.");
|
||||
return UUID.Zero;
|
||||
}
|
||||
money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, "Group Creation");
|
||||
}
|
||||
|
||||
string reason = string.Empty;
|
||||
UUID groupID = m_groupData.CreateGroup(remoteClient.AgentId, name, charter, showInList, insigniaID, membershipFee, openEnrollment,
|
||||
allowPublish, maturePublish, remoteClient.AgentId, out reason);
|
||||
|
||||
if (groupID != UUID.Zero)
|
||||
{
|
||||
if (money != null)
|
||||
money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate);
|
||||
|
||||
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
|
||||
|
||||
// Update the founder with new group information.
|
||||
@@ -904,23 +909,7 @@ namespace OpenSim.Groups
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called for notice {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, groupNoticeID);
|
||||
|
||||
//GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null);
|
||||
|
||||
GridInstantMessage msg = CreateGroupNoticeIM(remoteClient.AgentId, groupNoticeID, (byte)InstantMessageDialog.GroupNoticeRequested);
|
||||
//GridInstantMessage msg = new GridInstantMessage();
|
||||
//msg.imSessionID = UUID.Zero.Guid;
|
||||
//msg.fromAgentID = data.GroupID.Guid;
|
||||
//msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
|
||||
//msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
|
||||
//msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
|
||||
//msg.message = data.noticeData.Subject + "|" + data.Message;
|
||||
//msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNoticeRequested;
|
||||
//msg.fromGroup = true;
|
||||
//msg.offline = (byte)0;
|
||||
//msg.ParentEstateID = 0;
|
||||
//msg.Position = Vector3.Zero;
|
||||
//msg.RegionID = UUID.Zero.Guid;
|
||||
//msg.binaryBucket = data.BinaryBucket;
|
||||
|
||||
OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
|
||||
}
|
||||
@@ -1002,6 +991,10 @@ namespace OpenSim.Groups
|
||||
|
||||
// Should this send updates to everyone in the group?
|
||||
SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
|
||||
|
||||
if (reason != string.Empty)
|
||||
// A warning
|
||||
remoteClient.SendAlertMessage("Warning: " + reason);
|
||||
}
|
||||
else
|
||||
remoteClient.SendJoinGroupReply(groupID, false);
|
||||
@@ -1186,6 +1179,11 @@ namespace OpenSim.Groups
|
||||
}
|
||||
}
|
||||
|
||||
public List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query)
|
||||
{
|
||||
return m_groupData.FindGroups(GetRequestingAgentIDStr(remoteClient), query);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Client/Update Tools
|
||||
@@ -1225,12 +1223,16 @@ namespace OpenSim.Groups
|
||||
{
|
||||
if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
// NPCs currently don't have a CAPs structure or event queues. There is a strong argument for conveying this information
|
||||
// to them anyway since it makes writing server-side bots a lot easier, but for now we don't do anything.
|
||||
if (remoteClient.SceneAgent.PresenceType == PresenceType.Npc)
|
||||
return;
|
||||
|
||||
OSDArray AgentData = new OSDArray(1);
|
||||
OSDMap AgentDataMap = new OSDMap(1);
|
||||
AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID));
|
||||
AgentData.Add(AgentDataMap);
|
||||
|
||||
|
||||
OSDArray GroupData = new OSDArray(data.Length);
|
||||
OSDArray NewGroupData = new OSDArray(data.Length);
|
||||
|
||||
@@ -1276,8 +1278,7 @@ namespace OpenSim.Groups
|
||||
if (queue != null)
|
||||
{
|
||||
queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SendScenePresenceUpdate(UUID AgentID, string Title)
|
||||
@@ -1339,6 +1340,7 @@ namespace OpenSim.Groups
|
||||
|
||||
GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID);
|
||||
SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray);
|
||||
|
||||
//remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray);
|
||||
if (remoteClient.AgentId == dataForAgentID)
|
||||
remoteClient.RefreshGroupMembership();
|
||||
@@ -1399,19 +1401,18 @@ namespace OpenSim.Groups
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
// TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
|
||||
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID);
|
||||
string firstname, lastname;
|
||||
if (account != null)
|
||||
string firstname = "Unknown", lastname = "Unknown";
|
||||
string name = m_UserManagement.GetUserName(dataForAgentID);
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
firstname = account.FirstName;
|
||||
lastname = account.LastName;
|
||||
string[] parts = name.Split(new char[] { ' ' });
|
||||
if (parts.Length >= 2)
|
||||
{
|
||||
firstname = parts[0];
|
||||
lastname = parts[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
firstname = "Unknown";
|
||||
lastname = "Unknown";
|
||||
}
|
||||
|
||||
|
||||
remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname,
|
||||
lastname, activeGroupPowers, activeGroupName,
|
||||
activeGroupTitle);
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenSim.Groups
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
if (GroupID != UUID.Zero)
|
||||
sendData["GroupID"] = GroupID.ToString();
|
||||
if (GroupName != null && GroupName != string.Empty)
|
||||
if (!string.IsNullOrEmpty(GroupName))
|
||||
sendData["Name"] = GroupsDataUtils.Sanitize(GroupName);
|
||||
|
||||
sendData["RequestingAgentID"] = RequestingAgentID;
|
||||
@@ -275,7 +275,7 @@ namespace OpenSim.Groups
|
||||
|
||||
//m_log.DebugFormat("[XXX]: reply was {0}", reply);
|
||||
|
||||
if (reply == string.Empty || reply == null)
|
||||
if (string.IsNullOrEmpty(reply))
|
||||
return null;
|
||||
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
|
||||
|
||||
@@ -186,7 +186,6 @@ namespace OpenSim.Groups
|
||||
public UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
|
||||
bool allowPublish, bool maturePublish, UUID founderID, out string reason)
|
||||
{
|
||||
m_log.DebugFormat("[Groups]: Creating group {0}", name);
|
||||
reason = string.Empty;
|
||||
if (m_UserManagement.IsLocalGridUser(RequestingAgentID))
|
||||
return m_LocalGroupsConnector.CreateGroup(RequestingAgentID, name, charter, showInList, insigniaID,
|
||||
@@ -255,7 +254,10 @@ namespace OpenSim.Groups
|
||||
{
|
||||
string url = string.Empty, gname = string.Empty;
|
||||
if (IsLocal(GroupID, out url, out gname))
|
||||
return m_LocalGroupsConnector.GetGroupMembers(AgentUUI(RequestingAgentID), GroupID);
|
||||
{
|
||||
string agentID = AgentUUI(RequestingAgentID);
|
||||
return m_LocalGroupsConnector.GetGroupMembers(agentID, GroupID);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(RequestingAgentID, RequestingAgentID, GroupID);
|
||||
@@ -397,17 +399,21 @@ namespace OpenSim.Groups
|
||||
|
||||
if (success)
|
||||
{
|
||||
// Here we always return true. The user has been added to the local group,
|
||||
// independent of whether the remote operation succeeds or not
|
||||
url = m_UserManagement.GetUserServerURL(uid, "GroupsServerURI");
|
||||
if (url == string.Empty)
|
||||
{
|
||||
reason = "User doesn't have a groups server";
|
||||
return false;
|
||||
reason = "You don't have an accessible groups server in your home world. You membership to this group in only within this grid.";
|
||||
return true;
|
||||
}
|
||||
|
||||
GroupsServiceHGConnector c = GetConnector(url);
|
||||
if (c != null)
|
||||
return c.CreateProxy(AgentUUI(RequestingAgentID), AgentID, token, GroupID, m_LocalGroupsServiceLocation, name, out reason);
|
||||
c.CreateProxy(AgentUUI(RequestingAgentID), AgentID, token, GroupID, m_LocalGroupsServiceLocation, name, out reason);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (m_UserManagement.IsLocalGridUser(uid)) // local user
|
||||
@@ -544,7 +550,6 @@ namespace OpenSim.Groups
|
||||
List<string> urls = new List<string>();
|
||||
foreach (GroupMembersData m in members)
|
||||
{
|
||||
UUID userID = UUID.Zero;
|
||||
if (!m_UserManagement.IsLocalGridUser(m.AgentID))
|
||||
{
|
||||
string gURL = m_UserManagement.GetUserServerURL(m.AgentID, "GroupsServerURI");
|
||||
@@ -592,28 +597,6 @@ namespace OpenSim.Groups
|
||||
return m_LocalGroupsConnector.GetGroupNotices(AgentUUI(RequestingAgentID), GroupID);
|
||||
}
|
||||
|
||||
public void ResetAgentGroupChatSessions(string agentID)
|
||||
{
|
||||
}
|
||||
|
||||
public bool hasAgentBeenInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool hasAgentDroppedGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AgentDroppedFromGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
}
|
||||
|
||||
public void AgentInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region hypergrid groups
|
||||
@@ -640,10 +623,13 @@ namespace OpenSim.Groups
|
||||
if (agent != null)
|
||||
break;
|
||||
}
|
||||
if (agent == null) // oops
|
||||
return AgentID.ToString();
|
||||
if (agent != null)
|
||||
return Util.ProduceUserUniversalIdentifier(agent);
|
||||
|
||||
// we don't know anything about this foreign user
|
||||
// try asking the user management module, which may know more
|
||||
return m_UserManagement.GetUserUUI(AgentID);
|
||||
|
||||
return Util.ProduceUserUniversalIdentifier(agent);
|
||||
}
|
||||
|
||||
private string AgentUUIForOutside(string AgentIDStr)
|
||||
@@ -685,6 +671,9 @@ namespace OpenSim.Groups
|
||||
{
|
||||
serviceLocation = string.Empty;
|
||||
name = string.Empty;
|
||||
if (groupID.Equals(UUID.Zero))
|
||||
return true;
|
||||
|
||||
ExtendedGroupRecord group = m_LocalGroupsConnector.GetGroupRecord(UUID.Zero.ToString(), groupID, string.Empty);
|
||||
if (group == null)
|
||||
{
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace OpenSim.Groups
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private HGGroupsService m_GroupsService;
|
||||
private string m_HomeURI = string.Empty;
|
||||
private string m_ConfigName = "Groups";
|
||||
|
||||
// Called by Robust shell
|
||||
@@ -113,7 +112,7 @@ namespace OpenSim.Groups
|
||||
m_GroupsService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
@@ -209,7 +208,6 @@ namespace OpenSim.Groups
|
||||
UUID groupID = new UUID(request["GroupID"].ToString());
|
||||
string agentID = request["AgentID"].ToString();
|
||||
string token = request["AccessToken"].ToString();
|
||||
string reason = string.Empty;
|
||||
|
||||
m_GroupsService.RemoveAgentFromGroup(agentID, agentID, groupID, token);
|
||||
}
|
||||
|
||||
@@ -92,12 +92,6 @@ namespace OpenSim.Groups
|
||||
GroupNoticeInfo GetGroupNotice(string RequestingAgentID, UUID noticeID);
|
||||
List<ExtendedGroupNoticeData> GetGroupNotices(string RequestingAgentID, UUID GroupID);
|
||||
|
||||
void ResetAgentGroupChatSessions(string agentID);
|
||||
bool hasAgentBeenInvitedToGroupChatSession(string agentID, UUID groupID);
|
||||
bool hasAgentDroppedGroupChatSession(string agentID, UUID groupID);
|
||||
void AgentDroppedFromGroupChatSession(string agentID, UUID groupID);
|
||||
void AgentInvitedToGroupChatSession(string agentID, UUID groupID);
|
||||
|
||||
}
|
||||
|
||||
public class GroupInviteInfo
|
||||
|
||||
@@ -320,28 +320,6 @@ namespace OpenSim.Groups
|
||||
return m_GroupsService.GetGroupNotices(RequestingAgentID, GroupID);
|
||||
}
|
||||
|
||||
public void ResetAgentGroupChatSessions(string agentID)
|
||||
{
|
||||
}
|
||||
|
||||
public bool hasAgentBeenInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool hasAgentDroppedGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AgentDroppedFromGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
}
|
||||
|
||||
public void AgentInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ using Mono.Addins;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
[assembly: Addin("OpenSim.Groups", "0.1")]
|
||||
[assembly: AddinDependency("OpenSim", "0.5")]
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace OpenSim.Groups
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
if (GroupID != UUID.Zero)
|
||||
sendData["GroupID"] = GroupID.ToString();
|
||||
if (GroupName != null && GroupName != string.Empty)
|
||||
if (!string.IsNullOrEmpty(GroupName))
|
||||
sendData["Name"] = GroupsDataUtils.Sanitize(GroupName);
|
||||
|
||||
sendData["RequestingAgentID"] = RequestingAgentID;
|
||||
@@ -133,6 +133,36 @@ namespace OpenSim.Groups
|
||||
return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
|
||||
}
|
||||
|
||||
public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string query)
|
||||
{
|
||||
List<DirGroupsReplyData> hits = new List<DirGroupsReplyData>();
|
||||
if (string.IsNullOrEmpty(query))
|
||||
return hits;
|
||||
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
sendData["Query"] = query;
|
||||
sendData["RequestingAgentID"] = RequestingAgentID;
|
||||
|
||||
Dictionary<string, object> ret = MakeRequest("FINDGROUPS", sendData);
|
||||
|
||||
if (ret == null)
|
||||
return hits;
|
||||
|
||||
if (!ret.ContainsKey("RESULT"))
|
||||
return hits;
|
||||
|
||||
if (ret["RESULT"].ToString() == "NULL")
|
||||
return hits;
|
||||
|
||||
foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
|
||||
{
|
||||
DirGroupsReplyData m = GroupsDataUtils.DirGroupsReplyData((Dictionary<string, object>)v);
|
||||
hits.Add(m);
|
||||
}
|
||||
|
||||
return hits;
|
||||
}
|
||||
|
||||
public GroupMembershipData AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
@@ -226,6 +256,7 @@ namespace OpenSim.Groups
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
sendData["GroupID"] = GroupID.ToString();
|
||||
sendData["RequestingAgentID"] = RequestingAgentID;
|
||||
|
||||
Dictionary<string, object> ret = MakeRequest("GETGROUPMEMBERS", sendData);
|
||||
|
||||
if (ret == null)
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace OpenSim.Groups
|
||||
public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string search)
|
||||
{
|
||||
// TODO!
|
||||
return new List<DirGroupsReplyData>();
|
||||
return m_GroupsService.FindGroups(RequestingAgentID, search);
|
||||
}
|
||||
|
||||
public bool AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
|
||||
@@ -406,28 +406,6 @@ namespace OpenSim.Groups
|
||||
});
|
||||
}
|
||||
|
||||
public void ResetAgentGroupChatSessions(string agentID)
|
||||
{
|
||||
}
|
||||
|
||||
public bool hasAgentBeenInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool hasAgentDroppedGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AgentDroppedFromGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
}
|
||||
|
||||
public void AgentInvitedToGroupChatSession(string agentID, UUID groupID)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenSim.Groups
|
||||
m_GroupsService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
@@ -133,6 +133,8 @@ namespace OpenSim.Groups
|
||||
return HandleAddNotice(request);
|
||||
case "GETNOTICES":
|
||||
return HandleGetNotices(request);
|
||||
case "FINDGROUPS":
|
||||
return HandleFindGroups(request);
|
||||
}
|
||||
m_log.DebugFormat("[GROUPS HANDLER]: unknown method request: {0}", method);
|
||||
}
|
||||
@@ -170,11 +172,16 @@ namespace OpenSim.Groups
|
||||
|
||||
}
|
||||
|
||||
grec = m_GroupsService.GetGroupRecord(RequestingAgentID, grec.GroupID);
|
||||
if (grec == null)
|
||||
NullResult(result, "Internal Error");
|
||||
if (grec.GroupID != UUID.Zero)
|
||||
{
|
||||
grec = m_GroupsService.GetGroupRecord(RequestingAgentID, grec.GroupID);
|
||||
if (grec == null)
|
||||
NullResult(result, "Internal Error");
|
||||
else
|
||||
result["RESULT"] = GroupsDataUtils.GroupRecord(grec);
|
||||
}
|
||||
else
|
||||
result["RESULT"] = GroupsDataUtils.GroupRecord(grec);
|
||||
NullResult(result, reason);
|
||||
}
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
@@ -264,7 +271,6 @@ namespace OpenSim.Groups
|
||||
UUID groupID = new UUID(request["GroupID"].ToString());
|
||||
string agentID = request["AgentID"].ToString();
|
||||
string requestingAgentID = request["RequestingAgentID"].ToString();
|
||||
string reason = string.Empty;
|
||||
|
||||
m_GroupsService.RemoveAgentFromGroup(requestingAgentID, agentID, groupID);
|
||||
}
|
||||
@@ -495,7 +501,6 @@ namespace OpenSim.Groups
|
||||
else
|
||||
{
|
||||
string op = request["OP"].ToString();
|
||||
string reason = string.Empty;
|
||||
|
||||
bool success = false;
|
||||
if (op == "ADD")
|
||||
@@ -563,7 +568,6 @@ namespace OpenSim.Groups
|
||||
else
|
||||
{
|
||||
string op = request["OP"].ToString();
|
||||
string reason = string.Empty;
|
||||
|
||||
if (op == "GROUP")
|
||||
{
|
||||
@@ -626,7 +630,6 @@ namespace OpenSim.Groups
|
||||
else
|
||||
{
|
||||
string op = request["OP"].ToString();
|
||||
string reason = string.Empty;
|
||||
|
||||
if (op == "ADD" && request.ContainsKey("GroupID") && request.ContainsKey("RoleID") && request.ContainsKey("AgentID"))
|
||||
{
|
||||
@@ -739,6 +742,32 @@ namespace OpenSim.Groups
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] HandleFindGroups(Dictionary<string, object> request)
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
|
||||
if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("Query"))
|
||||
NullResult(result, "Bad network data");
|
||||
|
||||
List<DirGroupsReplyData> hits = m_GroupsService.FindGroups(request["RequestingAgentID"].ToString(), request["Query"].ToString());
|
||||
|
||||
if (hits == null || (hits != null && hits.Count == 0))
|
||||
NullResult(result, "No hits");
|
||||
else
|
||||
{
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
int i = 0;
|
||||
foreach (DirGroupsReplyData n in hits)
|
||||
dict["n-" + i++] = GroupsDataUtils.DirGroupsReplyData(n);
|
||||
|
||||
result["RESULT"] = dict;
|
||||
}
|
||||
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
|
||||
#region Helpers
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenSim.Groups
|
||||
private ForeignImporter m_ForeignImporter;
|
||||
|
||||
private Dictionary<string, bool> m_ActiveRequests = new Dictionary<string, bool>();
|
||||
private const int GROUPS_CACHE_TIMEOUT = 5 * 60; // 5 minutes
|
||||
private const int GROUPS_CACHE_TIMEOUT = 1 * 60; // 1 minutes
|
||||
|
||||
// This all important cache cahces objects of different types:
|
||||
// group-<GroupID> or group-<Name> => ExtendedGroupRecord
|
||||
@@ -209,13 +209,10 @@ namespace OpenSim.Groups
|
||||
public void SetAgentActiveGroup(string AgentID, GroupMembershipDelegate d)
|
||||
{
|
||||
GroupMembershipData activeGroup = d();
|
||||
if (activeGroup != null)
|
||||
{
|
||||
string cacheKey = "active-" + AgentID.ToString();
|
||||
lock (m_Cache)
|
||||
if (m_Cache.Contains(cacheKey))
|
||||
m_Cache.AddOrUpdate(cacheKey, activeGroup, GROUPS_CACHE_TIMEOUT);
|
||||
}
|
||||
string cacheKey = "active-" + AgentID.ToString();
|
||||
lock (m_Cache)
|
||||
if (m_Cache.Contains(cacheKey))
|
||||
m_Cache.AddOrUpdate(cacheKey, activeGroup, GROUPS_CACHE_TIMEOUT);
|
||||
}
|
||||
|
||||
public ExtendedGroupMembershipData GetAgentActiveMembership(string AgentID, GroupMembershipDelegate d)
|
||||
|
||||
@@ -130,6 +130,13 @@ namespace OpenSim.Groups
|
||||
{
|
||||
reason = string.Empty;
|
||||
|
||||
// Check if the group already exists
|
||||
if (m_Database.RetrieveGroup(name) != null)
|
||||
{
|
||||
reason = "A group with that name already exists";
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
// Create the group
|
||||
GroupData data = new GroupData();
|
||||
data.GroupID = UUID.Random();
|
||||
@@ -248,13 +255,20 @@ namespace OpenSim.Groups
|
||||
return members;
|
||||
List<RoleData> rolesList = new List<RoleData>(roles);
|
||||
|
||||
// Is the requester a member of the group?
|
||||
bool isInGroup = false;
|
||||
if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
|
||||
isInGroup = true;
|
||||
// Check visibility?
|
||||
// When we don't want to check visibility, we pass it "all" as the requestingAgentID
|
||||
bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString());
|
||||
|
||||
if (!isInGroup) // reduce the roles to the visible ones
|
||||
rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);
|
||||
if (checkVisibility)
|
||||
{
|
||||
// Is the requester a member of the group?
|
||||
bool isInGroup = false;
|
||||
if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
|
||||
isInGroup = true;
|
||||
|
||||
if (!isInGroup) // reduce the roles to the visible ones
|
||||
rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);
|
||||
}
|
||||
|
||||
MembershipData[] datas = m_Database.RetrieveMembers(GroupID);
|
||||
if (datas == null || (datas != null && datas.Length == 0))
|
||||
@@ -723,12 +737,12 @@ namespace OpenSim.Groups
|
||||
|
||||
#region Actions without permission checks
|
||||
|
||||
private void _AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
|
||||
protected void _AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
|
||||
{
|
||||
_AddAgentToGroup(RequestingAgentID, AgentID, GroupID, RoleID, string.Empty);
|
||||
}
|
||||
|
||||
public void _RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
|
||||
protected void _RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
|
||||
{
|
||||
// 1. Delete membership
|
||||
m_Database.DeleteMember(GroupID, AgentID);
|
||||
@@ -780,7 +794,7 @@ namespace OpenSim.Groups
|
||||
|
||||
}
|
||||
|
||||
private bool _AddOrUpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, bool add)
|
||||
protected bool _AddOrUpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, bool add)
|
||||
{
|
||||
RoleData data = m_Database.RetrieveRole(groupID, roleID);
|
||||
|
||||
@@ -810,12 +824,12 @@ namespace OpenSim.Groups
|
||||
return m_Database.StoreRole(data);
|
||||
}
|
||||
|
||||
private void _RemoveGroupRole(UUID groupID, UUID roleID)
|
||||
protected void _RemoveGroupRole(UUID groupID, UUID roleID)
|
||||
{
|
||||
m_Database.DeleteRole(groupID, roleID);
|
||||
}
|
||||
|
||||
private void _AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
|
||||
protected void _AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
|
||||
{
|
||||
RoleMembershipData data = m_Database.RetrieveRoleMember(GroupID, RoleID, AgentID);
|
||||
if (data != null)
|
||||
@@ -840,7 +854,7 @@ namespace OpenSim.Groups
|
||||
|
||||
}
|
||||
|
||||
private List<GroupRolesData> _GetGroupRoles(UUID groupID)
|
||||
protected List<GroupRolesData> _GetGroupRoles(UUID groupID)
|
||||
{
|
||||
List<GroupRolesData> roles = new List<GroupRolesData>();
|
||||
|
||||
@@ -865,7 +879,7 @@ namespace OpenSim.Groups
|
||||
return roles;
|
||||
}
|
||||
|
||||
private List<ExtendedGroupRoleMembersData> _GetGroupRoleMembers(UUID GroupID, bool isInGroup)
|
||||
protected List<ExtendedGroupRoleMembersData> _GetGroupRoleMembers(UUID GroupID, bool isInGroup)
|
||||
{
|
||||
List<ExtendedGroupRoleMembersData> rmembers = new List<ExtendedGroupRoleMembersData>();
|
||||
|
||||
|
||||
@@ -261,6 +261,11 @@ namespace OpenSim.OfflineIM
|
||||
return m_OfflineIMService.StoreMessage(im, out reason);
|
||||
}
|
||||
|
||||
public void DeleteMessages(UUID userID)
|
||||
{
|
||||
m_OfflineIMService.DeleteMessages(userID);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ using Mono.Addins;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
[assembly: Addin("OpenSim.OfflineIM", "0.1")]
|
||||
[assembly: AddinDependency("OpenSim", "0.5")]
|
||||
|
||||
@@ -117,6 +117,14 @@ namespace OpenSim.OfflineIM
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DeleteMessages(UUID userID)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
sendData["UserID"] = userID;
|
||||
|
||||
MakeRequest("DELETE", sendData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -75,7 +75,7 @@ namespace OpenSim.OfflineIM
|
||||
m_OfflineIMService = service;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream requestData,
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
StreamReader sr = new StreamReader(requestData);
|
||||
@@ -96,13 +96,14 @@ namespace OpenSim.OfflineIM
|
||||
string method = request["METHOD"].ToString();
|
||||
request.Remove("METHOD");
|
||||
|
||||
m_log.DebugFormat("[OfflineIM.V2.Handler]: {0}", method);
|
||||
switch (method)
|
||||
{
|
||||
case "GET":
|
||||
return HandleGet(request);
|
||||
case "STORE":
|
||||
return HandleStore(request);
|
||||
case "DELETE":
|
||||
return HandleDelete(request);
|
||||
}
|
||||
m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method);
|
||||
}
|
||||
@@ -159,6 +160,21 @@ namespace OpenSim.OfflineIM
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] HandleDelete(Dictionary<string, object> request)
|
||||
{
|
||||
if (!request.ContainsKey("UserID"))
|
||||
{
|
||||
return FailureResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
UUID userID = new UUID(request["UserID"].ToString());
|
||||
m_OfflineIMService.DeleteMessages(userID);
|
||||
|
||||
return SuccessResult();
|
||||
}
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
|
||||
private void NullResult(Dictionary<string, object> result, string reason)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -46,7 +46,7 @@ namespace OpenSim.OfflineIM
|
||||
{
|
||||
public class OfflineIMService : OfflineIMServiceBase, IOfflineIMService
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private const int MAX_IM = 25;
|
||||
|
||||
private XmlSerializer m_serializer;
|
||||
@@ -91,7 +91,7 @@ namespace OpenSim.OfflineIM
|
||||
{
|
||||
reason = string.Empty;
|
||||
|
||||
// TODO Check limits
|
||||
// Check limits
|
||||
UUID principalID = new UUID(im.toAgentID);
|
||||
long count = m_Database.GetCount("PrincipalID", principalID.ToString());
|
||||
if (count >= MAX_IM)
|
||||
@@ -100,7 +100,7 @@ namespace OpenSim.OfflineIM
|
||||
return false;
|
||||
}
|
||||
|
||||
string imXml = string.Empty;
|
||||
string imXml;
|
||||
using (MemoryStream mstream = new MemoryStream())
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
@@ -110,22 +110,26 @@ namespace OpenSim.OfflineIM
|
||||
{
|
||||
m_serializer.Serialize(writer, im);
|
||||
writer.Flush();
|
||||
|
||||
mstream.Position = 0;
|
||||
using (StreamReader sreader = new StreamReader(mstream))
|
||||
{
|
||||
imXml = sreader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
imXml = Util.UTF8.GetString(mstream.ToArray());
|
||||
}
|
||||
|
||||
OfflineIMData data = new OfflineIMData();
|
||||
data.PrincipalID = principalID;
|
||||
data.FromID = new UUID(im.fromAgentID);
|
||||
data.Data = new Dictionary<string, string>();
|
||||
data.Data["Message"] = imXml;
|
||||
|
||||
return m_Database.Store(data);
|
||||
|
||||
}
|
||||
|
||||
public void DeleteMessages(UUID userID)
|
||||
{
|
||||
m_Database.Delete("PrincipalID", userID.ToString());
|
||||
m_Database.Delete("FromID", userID.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
List<IScene> createdScenes = new List<IScene>();
|
||||
|
||||
for (int i = 0; i < regionsToLoad.Length; i++)
|
||||
{
|
||||
IScene scene;
|
||||
@@ -123,17 +125,22 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
")");
|
||||
|
||||
bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
|
||||
|
||||
m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
|
||||
createdScenes.Add(scene);
|
||||
|
||||
if (changed)
|
||||
regionsToLoad[i].EstateSettings.Save();
|
||||
|
||||
if (scene != null)
|
||||
regionsToLoad[i].EstateSettings.Save();
|
||||
}
|
||||
|
||||
foreach (IScene scene in createdScenes)
|
||||
{
|
||||
scene.Start();
|
||||
|
||||
m_newRegionCreatedHandler = OnNewRegionCreated;
|
||||
if (m_newRegionCreatedHandler != null)
|
||||
{
|
||||
m_newRegionCreatedHandler = OnNewRegionCreated;
|
||||
if (m_newRegionCreatedHandler != null)
|
||||
{
|
||||
m_newRegionCreatedHandler(scene);
|
||||
}
|
||||
m_newRegionCreatedHandler(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,4 +62,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("0.7.6.*")]
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.0.*")]
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Net;
|
||||
@@ -50,6 +51,8 @@ using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
using PermissionMask = OpenSim.Framework.PermissionMask;
|
||||
using RegionInfo = OpenSim.Framework.RegionInfo;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
{
|
||||
@@ -136,6 +139,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod);
|
||||
|
||||
// Agent management
|
||||
availableMethods["admin_get_agents"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetAgentsMethod);
|
||||
availableMethods["admin_teleport_agent"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcTeleportAgentMethod);
|
||||
|
||||
// User management
|
||||
@@ -143,6 +147,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod);
|
||||
availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod);
|
||||
availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod);
|
||||
availableMethods["admin_authenticate_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAuthenticateUserMethod);
|
||||
|
||||
// Region state management
|
||||
availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod);
|
||||
@@ -155,6 +160,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
availableMethods["admin_acl_add"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListAdd);
|
||||
availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove);
|
||||
availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList);
|
||||
availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload);
|
||||
|
||||
// Either enable full remote functionality or just selected features
|
||||
string enabledMethods = m_config.GetString("enabled_methods", "all");
|
||||
@@ -324,18 +330,26 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
// k, (string)requestData[k], ((string)requestData[k]).Length);
|
||||
// }
|
||||
|
||||
CheckStringParameters(requestData, responseData, new string[] {"filename", "regionid"});
|
||||
CheckStringParameters(requestData, responseData, new string[] { "filename" });
|
||||
CheckRegionParams(requestData, responseData);
|
||||
|
||||
Scene scene = null;
|
||||
GetSceneFromRegionParams(requestData, responseData, out scene);
|
||||
string file = (string)requestData["filename"];
|
||||
|
||||
responseData["accepted"] = true;
|
||||
if (scene != null)
|
||||
{
|
||||
string file = (string)requestData["filename"];
|
||||
|
||||
LoadHeightmap(file, scene.RegionInfo.RegionID);
|
||||
responseData["accepted"] = true;
|
||||
|
||||
responseData["success"] = true;
|
||||
LoadHeightmap(file, scene.RegionInfo.RegionID);
|
||||
|
||||
responseData["success"] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
responseData["success"] = false;
|
||||
}
|
||||
|
||||
m_log.Info("[RADMIN]: Load height maps request complete");
|
||||
}
|
||||
@@ -349,23 +363,30 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
|
||||
// m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString());
|
||||
|
||||
CheckStringParameters(requestData, responseData, new string[] { "filename", "regionid" });
|
||||
CheckStringParameters(requestData, responseData, new string[] { "filename" });
|
||||
CheckRegionParams(requestData, responseData);
|
||||
|
||||
Scene region = null;
|
||||
GetSceneFromRegionParams(requestData, responseData, out region);
|
||||
Scene scene = null;
|
||||
GetSceneFromRegionParams(requestData, responseData, out scene);
|
||||
|
||||
string file = (string)requestData["filename"];
|
||||
m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file);
|
||||
if (scene != null)
|
||||
{
|
||||
string file = (string)requestData["filename"];
|
||||
m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file);
|
||||
|
||||
responseData["accepted"] = true;
|
||||
responseData["accepted"] = true;
|
||||
|
||||
ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
|
||||
if (null == terrainModule) throw new Exception("terrain module not available");
|
||||
ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
|
||||
if (null == terrainModule) throw new Exception("terrain module not available");
|
||||
|
||||
terrainModule.SaveToFile(file);
|
||||
terrainModule.SaveToFile(file);
|
||||
|
||||
responseData["success"] = true;
|
||||
responseData["success"] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
responseData["success"] = false;
|
||||
}
|
||||
|
||||
m_log.Info("[RADMIN]: Save height maps request complete");
|
||||
}
|
||||
@@ -698,6 +719,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
|
||||
IScene newScene;
|
||||
m_application.CreateRegion(region, out newScene);
|
||||
newScene.Start();
|
||||
|
||||
// If an access specification was provided, use it.
|
||||
// Otherwise accept the default.
|
||||
@@ -1000,7 +1022,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
// Set home position
|
||||
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
|
||||
if (null == home)
|
||||
{
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstName, lastName);
|
||||
@@ -1092,7 +1114,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
{
|
||||
GridUserInfo userInfo = m_application.SceneManager.CurrentOrFirstScene.GridUserService.GetGridUserInfo(account.PrincipalID.ToString());
|
||||
if (userInfo != null)
|
||||
responseData["lastlogin"] = userInfo.Login;
|
||||
responseData["lastlogin"] = Util.ToUnixTime(userInfo.Login);
|
||||
else
|
||||
responseData["lastlogin"] = 0;
|
||||
|
||||
@@ -1230,7 +1252,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
if ((null != regionXLocation) && (null != regionYLocation))
|
||||
{
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc((uint)regionXLocation), (int)Util.RegionToWorldLoc((uint)regionYLocation));
|
||||
if (null == home) {
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for updated user account {0} {1}", firstName, lastName);
|
||||
} else {
|
||||
@@ -1261,6 +1283,139 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticate an user.
|
||||
/// <summary>
|
||||
/// <param name="request">incoming XML RPC request</param>
|
||||
/// <remarks>
|
||||
/// XmlRpcAuthenticateUserMethod takes the following XMLRPC
|
||||
/// parameters
|
||||
/// <list type="table">
|
||||
/// <listheader><term>parameter name</term><description>description</description></listheader>
|
||||
/// <item><term>password</term>
|
||||
/// <description>admin password as set in OpenSim.ini</description></item>
|
||||
/// <item><term>user_firstname</term>
|
||||
/// <description>avatar's first name</description></item>
|
||||
/// <item><term>user_lastname</term>
|
||||
/// <description>avatar's last name</description></item>
|
||||
/// <item><term>user_password</term>
|
||||
/// <description>MD5 hash of avatar's password</description></item>
|
||||
/// <item><term>token_lifetime</term>
|
||||
/// <description>the lifetime of the returned token (upper bounded to 30s)</description></item>
|
||||
/// </list>
|
||||
///
|
||||
/// XmlRpcAuthenticateUserMethod returns
|
||||
/// <list type="table">
|
||||
/// <listheader><term>name</term><description>description</description></listheader>
|
||||
/// <item><term>success</term>
|
||||
/// <description>true or false</description></item>
|
||||
/// <item><term>token</term>
|
||||
/// <description>the authentication token sent by OpenSim</description></item>
|
||||
/// <item><term>error</term>
|
||||
/// <description>error message if success is false</description></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
private void XmlRpcAuthenticateUserMethod(XmlRpcRequest request, XmlRpcResponse response,
|
||||
IPEndPoint remoteClient)
|
||||
{
|
||||
m_log.Info("[RADMIN]: AuthenticateUser: new request");
|
||||
|
||||
var responseData = (Hashtable)response.Value;
|
||||
var requestData = (Hashtable)request.Params[0];
|
||||
|
||||
lock (m_requestLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
CheckStringParameters(requestData, responseData, new[]
|
||||
{
|
||||
"user_firstname",
|
||||
"user_lastname",
|
||||
"user_password",
|
||||
"token_lifetime"
|
||||
});
|
||||
|
||||
var firstName = (string)requestData["user_firstname"];
|
||||
var lastName = (string)requestData["user_lastname"];
|
||||
var password = (string)requestData["user_password"];
|
||||
|
||||
var scene = m_application.SceneManager.CurrentOrFirstScene;
|
||||
|
||||
if (scene.Equals(null))
|
||||
{
|
||||
m_log.Debug("scene does not exist");
|
||||
throw new Exception("Scene does not exist.");
|
||||
}
|
||||
|
||||
var scopeID = scene.RegionInfo.ScopeID;
|
||||
var account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
|
||||
|
||||
if (account.Equals(null) || account.PrincipalID.Equals(UUID.Zero))
|
||||
{
|
||||
m_log.DebugFormat("avatar {0} {1} does not exist", firstName, lastName);
|
||||
throw new Exception(String.Format("avatar {0} {1} does not exist", firstName, lastName));
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(password))
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: no password provided for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("no password provided for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
int lifetime;
|
||||
if (int.TryParse((string)requestData["token_lifetime"], NumberStyles.Integer, CultureInfo.InvariantCulture, out lifetime) == false)
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: no token lifetime provided for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("no token lifetime provided for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
// Upper bound on lifetime set to 30s.
|
||||
if (lifetime > 30)
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: token lifetime longer than 30s for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("token lifetime longer than 30s for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
var authModule = scene.RequestModuleInterface<IAuthenticationService>();
|
||||
if (authModule == null)
|
||||
{
|
||||
m_log.Debug("[RADMIN]: AuthenticateUser: no authentication module loded");
|
||||
throw new Exception("no authentication module loaded");
|
||||
}
|
||||
|
||||
var token = authModule.Authenticate(account.PrincipalID, password, lifetime);
|
||||
if (String.IsNullOrEmpty(token))
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: authentication failed for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("authentication failed for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: account for user {0} {1} identified with token {2}",
|
||||
firstName, lastName, token);
|
||||
|
||||
responseData["token"] = token;
|
||||
responseData["success"] = true;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
responseData["success"] = false;
|
||||
responseData["error"] = e.Message;
|
||||
throw e;
|
||||
}
|
||||
|
||||
m_log.Info("[RADMIN]: AuthenticateUser: request complete");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an OAR file into a region..
|
||||
/// <summary>
|
||||
@@ -1329,8 +1484,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
}
|
||||
|
||||
IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
|
||||
Dictionary<string, object> archiveOptions = new Dictionary<string,object>();
|
||||
if (mergeOar) archiveOptions.Add("merge", null);
|
||||
if (skipAssets) archiveOptions.Add("skipAssets", null);
|
||||
if (archiver != null)
|
||||
archiver.DearchiveRegion(filename, mergeOar, skipAssets, Guid.Empty);
|
||||
archiver.DearchiveRegion(filename, Guid.Empty, archiveOptions);
|
||||
else
|
||||
throw new Exception("Archiver module not present for scene");
|
||||
|
||||
@@ -1389,7 +1547,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
/// </remarks>
|
||||
private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
|
||||
{
|
||||
m_log.Info("[RADMIN]: Received Save OAR Administrator Request");
|
||||
m_log.Info("[RADMIN]: Received Save OAR Request");
|
||||
|
||||
Hashtable responseData = (Hashtable)response.Value;
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
@@ -1435,8 +1593,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
|
||||
if (archiver != null)
|
||||
{
|
||||
Guid requestId = Guid.NewGuid();
|
||||
scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
|
||||
archiver.ArchiveRegion(filename, options);
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[RADMIN]: Submitting save OAR request for {0} to file {1}, request ID {2}",
|
||||
scene.Name, filename, requestId);
|
||||
|
||||
archiver.ArchiveRegion(filename, requestId, options);
|
||||
|
||||
lock (m_saveOarLock)
|
||||
Monitor.Wait(m_saveOarLock,5000);
|
||||
@@ -1457,12 +1621,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
throw e;
|
||||
}
|
||||
|
||||
m_log.Info("[RADMIN]: Save OAR Administrator Request complete");
|
||||
m_log.Info("[RADMIN]: Save OAR Request complete");
|
||||
}
|
||||
|
||||
private void RemoteAdminOarSaveCompleted(Guid uuid, string name)
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name);
|
||||
if (name != "")
|
||||
m_log.ErrorFormat("[RADMIN]: Saving of OAR file with request ID {0} failed with message {1}", uuid, name);
|
||||
else
|
||||
m_log.DebugFormat("[RADMIN]: Saved OAR file for request {0}", uuid);
|
||||
|
||||
lock (m_saveOarLock)
|
||||
Monitor.Pulse(m_saveOarLock);
|
||||
}
|
||||
@@ -1759,6 +1927,87 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
m_log.Info("[RADMIN]: Access List List Request complete");
|
||||
}
|
||||
|
||||
private void XmlRpcEstateReload(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
|
||||
{
|
||||
m_log.Info("[RADMIN]: Received Estate Reload Request");
|
||||
|
||||
Hashtable responseData = (Hashtable)response.Value;
|
||||
// Hashtable requestData = (Hashtable)request.Params[0];
|
||||
|
||||
m_application.SceneManager.ForEachScene(s =>
|
||||
s.RegionInfo.EstateSettings = m_application.EstateDataService.LoadEstateSettings(s.RegionInfo.RegionID, false)
|
||||
);
|
||||
|
||||
responseData["success"] = true;
|
||||
|
||||
m_log.Info("[RADMIN]: Estate Reload Request complete");
|
||||
}
|
||||
|
||||
private void XmlRpcGetAgentsMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable responseData = (Hashtable)response.Value;
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
|
||||
bool includeChildren = false;
|
||||
|
||||
if (requestData.Contains("include_children"))
|
||||
bool.TryParse((string)requestData["include_children"], out includeChildren);
|
||||
|
||||
Scene scene;
|
||||
GetSceneFromRegionParams(requestData, responseData, out scene);
|
||||
|
||||
ArrayList xmlRpcRegions = new ArrayList();
|
||||
responseData["regions"] = xmlRpcRegions;
|
||||
|
||||
Hashtable xmlRpcRegion = new Hashtable();
|
||||
xmlRpcRegions.Add(xmlRpcRegion);
|
||||
|
||||
xmlRpcRegion["name"] = scene.Name;
|
||||
xmlRpcRegion["id"] = scene.RegionInfo.RegionID.ToString();
|
||||
|
||||
List<ScenePresence> agents = scene.GetScenePresences();
|
||||
ArrayList xmlrpcAgents = new ArrayList();
|
||||
|
||||
foreach (ScenePresence agent in agents)
|
||||
{
|
||||
if (agent.IsChildAgent && !includeChildren)
|
||||
continue;
|
||||
|
||||
Hashtable xmlRpcAgent = new Hashtable();
|
||||
xmlRpcAgent.Add("name", agent.Name);
|
||||
xmlRpcAgent.Add("id", agent.UUID.ToString());
|
||||
xmlRpcAgent.Add("type", agent.PresenceType.ToString());
|
||||
xmlRpcAgent.Add("current_parcel_id", agent.currentParcelUUID.ToString());
|
||||
|
||||
Vector3 pos = agent.AbsolutePosition;
|
||||
xmlRpcAgent.Add("pos_x", pos.X.ToString());
|
||||
xmlRpcAgent.Add("pos_y", pos.Y.ToString());
|
||||
xmlRpcAgent.Add("pos_z", pos.Z.ToString());
|
||||
|
||||
Vector3 lookAt = agent.Lookat;
|
||||
xmlRpcAgent.Add("lookat_x", lookAt.X.ToString());
|
||||
xmlRpcAgent.Add("lookat_y", lookAt.Y.ToString());
|
||||
xmlRpcAgent.Add("lookat_z", lookAt.Z.ToString());
|
||||
|
||||
Vector3 vel = agent.Velocity;
|
||||
xmlRpcAgent.Add("vel_x", vel.X.ToString());
|
||||
xmlRpcAgent.Add("vel_y", vel.Y.ToString());
|
||||
xmlRpcAgent.Add("vel_z", vel.Z.ToString());
|
||||
|
||||
xmlRpcAgent.Add("is_flying", agent.Flying.ToString());
|
||||
xmlRpcAgent.Add("is_sat_on_ground", agent.SitGround.ToString());
|
||||
xmlRpcAgent.Add("is_sat_on_object", agent.IsSatOnObject.ToString());
|
||||
|
||||
xmlrpcAgents.Add(xmlRpcAgent);
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[REMOTE ADMIN]: XmlRpcGetAgents found {0} agents in {1}", xmlrpcAgents.Count, scene.Name);
|
||||
|
||||
xmlRpcRegion["agents"] = xmlrpcAgents;
|
||||
responseData["success"] = true;
|
||||
}
|
||||
|
||||
private void XmlRpcTeleportAgentMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable responseData = (Hashtable)response.Value;
|
||||
@@ -2517,15 +2766,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
/// </summary>
|
||||
private void ApplyNextOwnerPermissions(InventoryItemBase item)
|
||||
{
|
||||
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
|
||||
if (item.InvType == (int)InventoryType.Object)
|
||||
{
|
||||
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
|
||||
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
|
||||
if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
|
||||
item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
|
||||
if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
|
||||
item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
|
||||
uint perms = item.CurrentPermissions;
|
||||
PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
|
||||
item.CurrentPermissions = perms;
|
||||
}
|
||||
|
||||
item.CurrentPermissions &= item.NextPermissions;
|
||||
item.BasePermissions &= item.NextPermissions;
|
||||
item.EveryOnePermissions &= item.NextPermissions;
|
||||
@@ -2637,7 +2884,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
// Set home position
|
||||
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
|
||||
if (null == home) {
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", names[0], names[1]);
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
<Addin id="OpenSim.ApplicationPlugins.Rest.Inventory" version="0.1">
|
||||
<Runtime>
|
||||
<Import assembly="OpenSim.ApplicationPlugins.Rest.Inventory.dll"/>
|
||||
</Runtime>
|
||||
<Dependencies>
|
||||
<Addin id="OpenSim" version="0.5" />
|
||||
</Dependencies>
|
||||
<Extension path = "/OpenSim/Startup">
|
||||
<Plugin id="RestInventory" type="OpenSim.ApplicationPlugins.Rest.Inventory.RestHandler" />
|
||||
</Extension>
|
||||
</Addin>
|
||||
@@ -1,551 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
public class Rest
|
||||
{
|
||||
internal static readonly ILog Log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
internal static bool DEBUG = Log.IsDebugEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Supported authentication schemes
|
||||
/// </summary>
|
||||
|
||||
public const string AS_BASIC = "Basic"; // simple user/password verification
|
||||
public const string AS_DIGEST = "Digest"; // password safe authentication
|
||||
|
||||
/// Supported Digest algorithms
|
||||
|
||||
public const string Digest_MD5 = "MD5"; // assumed default if omitted
|
||||
public const string Digest_MD5Sess = "MD5-sess"; // session-span - not good for REST?
|
||||
|
||||
public const string Qop_Auth = "auth"; // authentication only
|
||||
public const string Qop_Int = "auth-int"; // TODO
|
||||
|
||||
/// <summary>
|
||||
/// These values have a single value for the whole
|
||||
/// domain and lifetime of the plugin handler. We
|
||||
/// make them static for ease of reference within
|
||||
/// the assembly. These are initialized by the
|
||||
/// RestHandler class during start-up.
|
||||
/// </summary>
|
||||
|
||||
internal static IRestHandler Plugin = null;
|
||||
internal static OpenSimBase main = null;
|
||||
internal static string Prefix = null;
|
||||
internal static IConfig Config = null;
|
||||
internal static string GodKey = null;
|
||||
internal static bool Authenticate = true;
|
||||
internal static bool Secure = true;
|
||||
internal static bool ExtendedEscape = true;
|
||||
internal static bool DumpAsset = false;
|
||||
internal static bool Fill = true;
|
||||
internal static bool FlushEnabled = true;
|
||||
internal static string Realm = "OpenSim REST";
|
||||
internal static string Scheme = AS_BASIC;
|
||||
internal static int DumpLineSize = 32; // Should be a multiple of 16 or (possibly) 4
|
||||
|
||||
/// <summary>
|
||||
/// These are all dependent upon the Comms manager
|
||||
/// being initialized. So they have to be properties
|
||||
/// because the comms manager is now a module and is
|
||||
/// not guaranteed to be there when the rest handler
|
||||
/// initializes.
|
||||
/// </summary>
|
||||
|
||||
internal static IInventoryService InventoryServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.InventoryService; }
|
||||
}
|
||||
|
||||
internal static IUserAccountService UserServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.UserAccountService; }
|
||||
}
|
||||
|
||||
internal static IAuthenticationService AuthServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.AuthenticationService; }
|
||||
}
|
||||
|
||||
internal static IAvatarService AvatarServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.AvatarService; }
|
||||
}
|
||||
|
||||
internal static IAssetService AssetServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.AssetService; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HTTP requires that status information be generated for PUT
|
||||
/// and POST opertaions. This is in support of that. The
|
||||
/// operation verb gets substituted into the first string,
|
||||
/// and the completion code is inserted into the tail. The
|
||||
/// strings are put here to encourage consistency.
|
||||
/// </summary>
|
||||
|
||||
internal static string statusHead = "<html><body><title>{0} status</title><break>";
|
||||
internal static string statusTail = "</body></html>";
|
||||
|
||||
internal static Dictionary<int,string> HttpStatusDesc;
|
||||
|
||||
static Rest()
|
||||
{
|
||||
HttpStatusDesc = new Dictionary<int,string>();
|
||||
if (HttpStatusCodeArray.Length != HttpStatusDescArray.Length)
|
||||
{
|
||||
Log.ErrorFormat("{0} HTTP Status Code and Description arrays do not match");
|
||||
throw new Exception("HTTP Status array discrepancy");
|
||||
}
|
||||
|
||||
// Repackage the data into something more tractable. The sparse
|
||||
// nature of HTTP return codes makes an array a bad choice.
|
||||
|
||||
for (int i=0; i<HttpStatusCodeArray.Length; i++)
|
||||
{
|
||||
HttpStatusDesc.Add(HttpStatusCodeArray[i], HttpStatusDescArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
internal static int CreationDate
|
||||
{
|
||||
get { return (int) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; }
|
||||
}
|
||||
|
||||
internal static string MsgId
|
||||
{
|
||||
get { return Plugin.MsgId; }
|
||||
}
|
||||
|
||||
internal static string RequestId
|
||||
{
|
||||
get { return Plugin.RequestId; }
|
||||
}
|
||||
|
||||
internal static Encoding Encoding = Util.UTF8;
|
||||
|
||||
/// <summary>
|
||||
/// Version control for REST implementation. This
|
||||
/// refers to the overall infrastructure represented
|
||||
/// by the following classes
|
||||
/// RequestData
|
||||
/// RequestInventoryPlugin
|
||||
/// Rest
|
||||
/// It does no describe implementation classes such as
|
||||
/// RestInventoryServices, which may morph much more
|
||||
/// often. Such classes ARE dependent upon this however
|
||||
/// and should check it in their Initialize method.
|
||||
/// </summary>
|
||||
|
||||
public static readonly float Version = 1.0F;
|
||||
public const string Name = "REST 1.0";
|
||||
|
||||
/// <summary>
|
||||
/// Currently defined HTTP methods.
|
||||
/// Only GET and HEAD are required to be
|
||||
/// supported by all servers. See Respond
|
||||
/// to see how these are handled.
|
||||
/// </summary>
|
||||
|
||||
// REST AGENT 1.0 interpretations
|
||||
public const string GET = "get"; // information retrieval - server state unchanged
|
||||
public const string HEAD = "head"; // same as get except only the headers are returned.
|
||||
public const string POST = "post"; // Replace the URI designated resource with the entity.
|
||||
public const string PUT = "put"; // Add the entity to the context represented by the URI
|
||||
public const string DELETE = "delete"; // Remove the URI designated resource from the server.
|
||||
|
||||
public const string OPTIONS = "options"; //
|
||||
public const string TRACE = "trace"; //
|
||||
public const string CONNECT = "connect"; //
|
||||
|
||||
// Define this in one place...
|
||||
|
||||
public const string UrlPathSeparator = "/";
|
||||
public const string UrlMethodSeparator = ":";
|
||||
|
||||
// Redirection qualifications
|
||||
|
||||
public const bool PERMANENT = false;
|
||||
public const bool TEMPORARY = true;
|
||||
|
||||
// Constant arrays used by String.Split
|
||||
|
||||
public static readonly char C_SPACE = ' ';
|
||||
public static readonly char C_SLASH = '/';
|
||||
public static readonly char C_PATHSEP = '/';
|
||||
public static readonly char C_COLON = ':';
|
||||
public static readonly char C_PLUS = '+';
|
||||
public static readonly char C_PERIOD = '.';
|
||||
public static readonly char C_COMMA = ',';
|
||||
public static readonly char C_DQUOTE = '"';
|
||||
|
||||
public static readonly string CS_SPACE = " ";
|
||||
public static readonly string CS_SLASH = "/";
|
||||
public static readonly string CS_PATHSEP = "/";
|
||||
public static readonly string CS_COLON = ":";
|
||||
public static readonly string CS_PLUS = "+";
|
||||
public static readonly string CS_PERIOD = ".";
|
||||
public static readonly string CS_COMMA = ",";
|
||||
public static readonly string CS_DQUOTE = "\"";
|
||||
|
||||
public static readonly char[] CA_SPACE = { C_SPACE };
|
||||
public static readonly char[] CA_SLASH = { C_SLASH };
|
||||
public static readonly char[] CA_PATHSEP = { C_PATHSEP };
|
||||
public static readonly char[] CA_COLON = { C_COLON };
|
||||
public static readonly char[] CA_PERIOD = { C_PERIOD };
|
||||
public static readonly char[] CA_PLUS = { C_PLUS };
|
||||
public static readonly char[] CA_COMMA = { C_COMMA };
|
||||
public static readonly char[] CA_DQUOTE = { C_DQUOTE };
|
||||
|
||||
// HTTP Code Values (in value order)
|
||||
|
||||
public const int HttpStatusCodeContinue = 100;
|
||||
public const int HttpStatusCodeSwitchingProtocols = 101;
|
||||
|
||||
public const int HttpStatusCodeOK = 200;
|
||||
public const int HttpStatusCodeCreated = 201;
|
||||
public const int HttpStatusCodeAccepted = 202;
|
||||
public const int HttpStatusCodeNonAuthoritative = 203;
|
||||
public const int HttpStatusCodeNoContent = 204;
|
||||
public const int HttpStatusCodeResetContent = 205;
|
||||
public const int HttpStatusCodePartialContent = 206;
|
||||
|
||||
public const int HttpStatusCodeMultipleChoices = 300;
|
||||
public const int HttpStatusCodePermanentRedirect = 301;
|
||||
public const int HttpStatusCodeFound = 302;
|
||||
public const int HttpStatusCodeSeeOther = 303;
|
||||
public const int HttpStatusCodeNotModified = 304;
|
||||
public const int HttpStatusCodeUseProxy = 305;
|
||||
public const int HttpStatusCodeReserved306 = 306;
|
||||
public const int HttpStatusCodeTemporaryRedirect = 307;
|
||||
|
||||
public const int HttpStatusCodeBadRequest = 400;
|
||||
public const int HttpStatusCodeNotAuthorized = 401;
|
||||
public const int HttpStatusCodePaymentRequired = 402;
|
||||
public const int HttpStatusCodeForbidden = 403;
|
||||
public const int HttpStatusCodeNotFound = 404;
|
||||
public const int HttpStatusCodeMethodNotAllowed = 405;
|
||||
public const int HttpStatusCodeNotAcceptable = 406;
|
||||
public const int HttpStatusCodeProxyAuthenticate = 407;
|
||||
public const int HttpStatusCodeTimeOut = 408;
|
||||
public const int HttpStatusCodeConflict = 409;
|
||||
public const int HttpStatusCodeGone = 410;
|
||||
public const int HttpStatusCodeLengthRequired = 411;
|
||||
public const int HttpStatusCodePreconditionFailed = 412;
|
||||
public const int HttpStatusCodeEntityTooLarge = 413;
|
||||
public const int HttpStatusCodeUriTooLarge = 414;
|
||||
public const int HttpStatusCodeUnsupportedMedia = 415;
|
||||
public const int HttpStatusCodeRangeNotSatsified = 416;
|
||||
public const int HttpStatusCodeExpectationFailed = 417;
|
||||
|
||||
public const int HttpStatusCodeServerError = 500;
|
||||
public const int HttpStatusCodeNotImplemented = 501;
|
||||
public const int HttpStatusCodeBadGateway = 502;
|
||||
public const int HttpStatusCodeServiceUnavailable = 503;
|
||||
public const int HttpStatusCodeGatewayTimeout = 504;
|
||||
public const int HttpStatusCodeHttpVersionError = 505;
|
||||
|
||||
public static readonly int[] HttpStatusCodeArray = {
|
||||
HttpStatusCodeContinue,
|
||||
HttpStatusCodeSwitchingProtocols,
|
||||
HttpStatusCodeOK,
|
||||
HttpStatusCodeCreated,
|
||||
HttpStatusCodeAccepted,
|
||||
HttpStatusCodeNonAuthoritative,
|
||||
HttpStatusCodeNoContent,
|
||||
HttpStatusCodeResetContent,
|
||||
HttpStatusCodePartialContent,
|
||||
HttpStatusCodeMultipleChoices,
|
||||
HttpStatusCodePermanentRedirect,
|
||||
HttpStatusCodeFound,
|
||||
HttpStatusCodeSeeOther,
|
||||
HttpStatusCodeNotModified,
|
||||
HttpStatusCodeUseProxy,
|
||||
HttpStatusCodeReserved306,
|
||||
HttpStatusCodeTemporaryRedirect,
|
||||
HttpStatusCodeBadRequest,
|
||||
HttpStatusCodeNotAuthorized,
|
||||
HttpStatusCodePaymentRequired,
|
||||
HttpStatusCodeForbidden,
|
||||
HttpStatusCodeNotFound,
|
||||
HttpStatusCodeMethodNotAllowed,
|
||||
HttpStatusCodeNotAcceptable,
|
||||
HttpStatusCodeProxyAuthenticate,
|
||||
HttpStatusCodeTimeOut,
|
||||
HttpStatusCodeConflict,
|
||||
HttpStatusCodeGone,
|
||||
HttpStatusCodeLengthRequired,
|
||||
HttpStatusCodePreconditionFailed,
|
||||
HttpStatusCodeEntityTooLarge,
|
||||
HttpStatusCodeUriTooLarge,
|
||||
HttpStatusCodeUnsupportedMedia,
|
||||
HttpStatusCodeRangeNotSatsified,
|
||||
HttpStatusCodeExpectationFailed,
|
||||
HttpStatusCodeServerError,
|
||||
HttpStatusCodeNotImplemented,
|
||||
HttpStatusCodeBadGateway,
|
||||
HttpStatusCodeServiceUnavailable,
|
||||
HttpStatusCodeGatewayTimeout,
|
||||
HttpStatusCodeHttpVersionError
|
||||
};
|
||||
|
||||
// HTTP Status Descriptions (in status code order)
|
||||
// This array must be kept strictly consistent with respect
|
||||
// to the status code array above.
|
||||
|
||||
public static readonly string[] HttpStatusDescArray = {
|
||||
"Continue Request",
|
||||
"Switching Protocols",
|
||||
"OK",
|
||||
"CREATED",
|
||||
"ACCEPTED",
|
||||
"NON-AUTHORITATIVE INFORMATION",
|
||||
"NO CONTENT",
|
||||
"RESET CONTENT",
|
||||
"PARTIAL CONTENT",
|
||||
"MULTIPLE CHOICES",
|
||||
"PERMANENT REDIRECT",
|
||||
"FOUND",
|
||||
"SEE OTHER",
|
||||
"NOT MODIFIED",
|
||||
"USE PROXY",
|
||||
"RESERVED CODE 306",
|
||||
"TEMPORARY REDIRECT",
|
||||
"BAD REQUEST",
|
||||
"NOT AUTHORIZED",
|
||||
"PAYMENT REQUIRED",
|
||||
"FORBIDDEN",
|
||||
"NOT FOUND",
|
||||
"METHOD NOT ALLOWED",
|
||||
"NOT ACCEPTABLE",
|
||||
"PROXY AUTHENTICATION REQUIRED",
|
||||
"TIMEOUT",
|
||||
"CONFLICT",
|
||||
"GONE",
|
||||
"LENGTH REQUIRED",
|
||||
"PRECONDITION FAILED",
|
||||
"ENTITY TOO LARGE",
|
||||
"URI TOO LARGE",
|
||||
"UNSUPPORTED MEDIA",
|
||||
"RANGE NOT SATISFIED",
|
||||
"EXPECTATION FAILED",
|
||||
"SERVER ERROR",
|
||||
"NOT IMPLEMENTED",
|
||||
"BAD GATEWAY",
|
||||
"SERVICE UNAVAILABLE",
|
||||
"GATEWAY TIMEOUT",
|
||||
"HTTP VERSION NOT SUPPORTED"
|
||||
};
|
||||
|
||||
// HTTP Headers
|
||||
|
||||
public const string HttpHeaderAccept = "Accept";
|
||||
public const string HttpHeaderAcceptCharset = "Accept-Charset";
|
||||
public const string HttpHeaderAcceptEncoding = "Accept-Encoding";
|
||||
public const string HttpHeaderAcceptLanguage = "Accept-Language";
|
||||
public const string HttpHeaderAcceptRanges = "Accept-Ranges";
|
||||
public const string HttpHeaderAge = "Age";
|
||||
public const string HttpHeaderAllow = "Allow";
|
||||
public const string HttpHeaderAuthorization = "Authorization";
|
||||
public const string HttpHeaderCacheControl = "Cache-Control";
|
||||
public const string HttpHeaderConnection = "Connection";
|
||||
public const string HttpHeaderContentEncoding = "Content-Encoding";
|
||||
public const string HttpHeaderContentLanguage = "Content-Language";
|
||||
public const string HttpHeaderContentLength = "Content-Length";
|
||||
public const string HttpHeaderContentLocation = "Content-Location";
|
||||
public const string HttpHeaderContentMD5 = "Content-MD5";
|
||||
public const string HttpHeaderContentRange = "Content-Range";
|
||||
public const string HttpHeaderContentType = "Content-Type";
|
||||
public const string HttpHeaderDate = "Date";
|
||||
public const string HttpHeaderETag = "ETag";
|
||||
public const string HttpHeaderExpect = "Expect";
|
||||
public const string HttpHeaderExpires = "Expires";
|
||||
public const string HttpHeaderFrom = "From";
|
||||
public const string HttpHeaderHost = "Host";
|
||||
public const string HttpHeaderIfMatch = "If-Match";
|
||||
public const string HttpHeaderIfModifiedSince = "If-Modified-Since";
|
||||
public const string HttpHeaderIfNoneMatch = "If-None-Match";
|
||||
public const string HttpHeaderIfRange = "If-Range";
|
||||
public const string HttpHeaderIfUnmodifiedSince = "If-Unmodified-Since";
|
||||
public const string HttpHeaderLastModified = "Last-Modified";
|
||||
public const string HttpHeaderLocation = "Location";
|
||||
public const string HttpHeaderMaxForwards = "Max-Forwards";
|
||||
public const string HttpHeaderPragma = "Pragma";
|
||||
public const string HttpHeaderProxyAuthenticate = "Proxy-Authenticate";
|
||||
public const string HttpHeaderProxyAuthorization = "Proxy-Authorization";
|
||||
public const string HttpHeaderRange = "Range";
|
||||
public const string HttpHeaderReferer = "Referer";
|
||||
public const string HttpHeaderRetryAfter = "Retry-After";
|
||||
public const string HttpHeaderServer = "Server";
|
||||
public const string HttpHeaderTE = "TE";
|
||||
public const string HttpHeaderTrailer = "Trailer";
|
||||
public const string HttpHeaderTransferEncoding = "Transfer-Encoding";
|
||||
public const string HttpHeaderUpgrade = "Upgrade";
|
||||
public const string HttpHeaderUserAgent = "User-Agent";
|
||||
public const string HttpHeaderVary = "Vary";
|
||||
public const string HttpHeaderVia = "Via";
|
||||
public const string HttpHeaderWarning = "Warning";
|
||||
public const string HttpHeaderWWWAuthenticate = "WWW-Authenticate";
|
||||
|
||||
/// Utility routines
|
||||
|
||||
public static string StringToBase64(string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] encData_byte = new byte[str.Length];
|
||||
encData_byte = Util.UTF8.GetBytes(str);
|
||||
return Convert.ToBase64String(encData_byte);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Base64ToString(string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Util.Base64ToString(str);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private const string hvals = "0123456789abcdef";
|
||||
|
||||
public static int Hex2Int(string hex)
|
||||
{
|
||||
int val = 0;
|
||||
int sum = 0;
|
||||
string tmp = null;
|
||||
|
||||
if (hex != null)
|
||||
{
|
||||
tmp = hex.ToLower();
|
||||
for (int i = 0; i < tmp.Length; i++)
|
||||
{
|
||||
val = hvals.IndexOf(tmp[i]);
|
||||
if (val == -1)
|
||||
break;
|
||||
sum *= 16;
|
||||
sum += val;
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
// Nonce management
|
||||
|
||||
public static string NonceGenerator()
|
||||
{
|
||||
return StringToBase64(CreationDate + Guid.NewGuid().ToString());
|
||||
}
|
||||
|
||||
// Dump the specified data stream
|
||||
|
||||
public static void Dump(byte[] data)
|
||||
{
|
||||
char[] buffer = new char[DumpLineSize];
|
||||
int cc = 0;
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (i % DumpLineSize == 0) Console.Write("\n{0}: ",i.ToString("d8"));
|
||||
|
||||
if (i % 4 == 0) Console.Write(" ");
|
||||
|
||||
Console.Write("{0}",data[i].ToString("x2"));
|
||||
|
||||
if (data[i] < 127 && data[i] > 31)
|
||||
buffer[i % DumpLineSize] = (char) data[i];
|
||||
else
|
||||
buffer[i % DumpLineSize] = '.';
|
||||
|
||||
cc++;
|
||||
|
||||
if (i != 0 && (i + 1) % DumpLineSize == 0)
|
||||
{
|
||||
Console.Write(" |"+(new String(buffer))+"|");
|
||||
cc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Finish off any incomplete line
|
||||
|
||||
if (cc != 0)
|
||||
{
|
||||
for (int i = cc ; i < DumpLineSize; i++)
|
||||
{
|
||||
if (i % 4 == 0) Console.Write(" ");
|
||||
Console.Write(" ");
|
||||
buffer[i % DumpLineSize] = ' ';
|
||||
}
|
||||
Console.WriteLine(" |"+(new String(buffer))+"|");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Local exception type
|
||||
|
||||
public class RestException : Exception
|
||||
{
|
||||
internal int statusCode;
|
||||
internal string statusDesc;
|
||||
internal string httpmethod;
|
||||
internal string httppath;
|
||||
|
||||
public RestException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,860 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
|
||||
public class RestAppearanceServices : IRest
|
||||
{
|
||||
// private static readonly int PARM_USERID = 0;
|
||||
|
||||
// private static readonly int PARM_PATH = 1;
|
||||
|
||||
// private bool enabled = false;
|
||||
private string qPrefix = "appearance";
|
||||
|
||||
/// <summary>
|
||||
/// The constructor makes sure that the service prefix is absolute
|
||||
/// and the registers the service handler and the allocator.
|
||||
/// </summary>
|
||||
|
||||
public RestAppearanceServices()
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} User appearance services initializing", MsgId);
|
||||
Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version);
|
||||
|
||||
// If a relative path was specified for the handler's domain,
|
||||
// add the standard prefix to make it absolute, e.g. /admin
|
||||
|
||||
if (!qPrefix.StartsWith(Rest.UrlPathSeparator))
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId);
|
||||
qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
|
||||
qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
|
||||
Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix);
|
||||
}
|
||||
|
||||
// Register interface using the absolute URI.
|
||||
|
||||
Rest.Plugin.AddPathHandler(DoAppearance,qPrefix,Allocate);
|
||||
|
||||
// Activate if everything went OK
|
||||
|
||||
// enabled = true;
|
||||
|
||||
Rest.Log.InfoFormat("{0} User appearance services initialization complete", MsgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post-construction, pre-enabled initialization opportunity
|
||||
/// Not currently exploited.
|
||||
/// </summary>
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the plug-in to halt service processing. Local processing is
|
||||
/// disabled.
|
||||
/// </summary>
|
||||
|
||||
public void Close()
|
||||
{
|
||||
// enabled = false;
|
||||
Rest.Log.InfoFormat("{0} User appearance services closing down", MsgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This property is declared locally because it is used a lot and
|
||||
/// brevity is nice.
|
||||
/// </summary>
|
||||
|
||||
internal string MsgId
|
||||
{
|
||||
get { return Rest.MsgId; }
|
||||
}
|
||||
|
||||
#region Interface
|
||||
|
||||
/// <summary>
|
||||
/// The plugin (RestHandler) calls this method to allocate the request
|
||||
/// state carrier for a new request. It is destroyed when the request
|
||||
/// completes. All request-instance specific state is kept here. This
|
||||
/// is registered when this service provider is registered.
|
||||
/// </summary>
|
||||
/// <param name=request>Inbound HTTP request information</param>
|
||||
/// <param name=response>Outbound HTTP request information</param>
|
||||
/// <param name=qPrefix>REST service domain prefix</param>
|
||||
/// <returns>A RequestData instance suitable for this service</returns>
|
||||
|
||||
private RequestData Allocate(OSHttpRequest request, OSHttpResponse response, string prefix)
|
||||
{
|
||||
return (RequestData) new AppearanceRequestData(request, response, prefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is registered with the handler when this service provider
|
||||
/// is initialized. It is called whenever the plug-in identifies this service
|
||||
/// provider as the best match for a given request.
|
||||
/// It handles all aspects of inventory REST processing, i.e. /admin/inventory
|
||||
/// </summary>
|
||||
/// <param name=hdata>A consolidated HTTP request work area</param>
|
||||
|
||||
private void DoAppearance(RequestData hdata)
|
||||
{
|
||||
// !!! REFACTORIMG PROBLEM. This needs rewriting for 0.7
|
||||
|
||||
//AppearanceRequestData rdata = (AppearanceRequestData) hdata;
|
||||
|
||||
//Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
|
||||
|
||||
//// If we're disabled, do nothing.
|
||||
|
||||
//if (!enabled)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
//// Now that we know this is a serious attempt to
|
||||
//// access inventory data, we should find out who
|
||||
//// is asking, and make sure they are authorized
|
||||
//// to do so. We need to validate the caller's
|
||||
//// identity before revealing anything about the
|
||||
//// status quo. Authenticate throws an exception
|
||||
//// via Fail if no identity information is present.
|
||||
////
|
||||
//// With the present HTTP server we can't use the
|
||||
//// builtin authentication mechanisms because they
|
||||
//// would be enforced for all in-bound requests.
|
||||
//// Instead we look at the headers ourselves and
|
||||
//// handle authentication directly.
|
||||
|
||||
//try
|
||||
//{
|
||||
// if (!rdata.IsAuthenticated)
|
||||
// {
|
||||
// rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
|
||||
// }
|
||||
//}
|
||||
//catch (RestException e)
|
||||
//{
|
||||
// if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
|
||||
// {
|
||||
// Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
|
||||
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
|
||||
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
// }
|
||||
// throw (e);
|
||||
//}
|
||||
|
||||
//Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
|
||||
|
||||
//// We can only get here if we are authorized
|
||||
////
|
||||
//// The requestor may have specified an UUID or
|
||||
//// a conjoined FirstName LastName string. We'll
|
||||
//// try both. If we fail with the first, UUID,
|
||||
//// attempt, we try the other. As an example, the
|
||||
//// URI for a valid inventory request might be:
|
||||
////
|
||||
//// http://<host>:<port>/admin/inventory/Arthur Dent
|
||||
////
|
||||
//// Indicating that this is an inventory request for
|
||||
//// an avatar named Arthur Dent. This is ALL that is
|
||||
//// required to designate a GET for an entire
|
||||
//// inventory.
|
||||
////
|
||||
|
||||
//// Do we have at least a user agent name?
|
||||
|
||||
//if (rdata.Parameters.Length < 1)
|
||||
//{
|
||||
// Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId);
|
||||
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
|
||||
//}
|
||||
|
||||
//// The first parameter MUST be the agent identification, either an UUID
|
||||
//// or a space-separated First-name Last-Name specification. We check for
|
||||
//// an UUID first, if anyone names their character using a valid UUID
|
||||
//// that identifies another existing avatar will cause this a problem...
|
||||
|
||||
//try
|
||||
//{
|
||||
// rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
|
||||
// Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
|
||||
// rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
|
||||
// if (names.Length == 2)
|
||||
// {
|
||||
// Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
|
||||
// rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
|
||||
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
|
||||
// }
|
||||
//}
|
||||
|
||||
//// If the user profile is null then either the server is broken, or the
|
||||
//// user is not known. We always assume the latter case.
|
||||
|
||||
//if (rdata.userProfile != null)
|
||||
//{
|
||||
// Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}",
|
||||
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path);
|
||||
// rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
|
||||
//}
|
||||
|
||||
//// If we get to here, then we have effectively validated the user's
|
||||
|
||||
//switch (rdata.method)
|
||||
//{
|
||||
// case Rest.HEAD : // Do the processing, set the status code, suppress entity
|
||||
// DoGet(rdata);
|
||||
// rdata.buffer = null;
|
||||
// break;
|
||||
|
||||
// case Rest.GET : // Do the processing, set the status code, return entity
|
||||
// DoGet(rdata);
|
||||
// break;
|
||||
|
||||
// case Rest.PUT : // Update named element
|
||||
// DoUpdate(rdata);
|
||||
// break;
|
||||
|
||||
// case Rest.POST : // Add new information to identified context.
|
||||
// DoExtend(rdata);
|
||||
// break;
|
||||
|
||||
// case Rest.DELETE : // Delete information
|
||||
// DoDelete(rdata);
|
||||
// break;
|
||||
|
||||
// default :
|
||||
// Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
|
||||
// MsgId, rdata.method, rdata.path);
|
||||
// rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
|
||||
// String.Format("{0} not supported", rdata.method));
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
#endregion Interface
|
||||
|
||||
#region method-specific processing
|
||||
|
||||
/// <summary>
|
||||
/// This method implements GET processing for user's appearance.
|
||||
/// </summary>
|
||||
/// <param name=rdata>HTTP service request work area</param>
|
||||
|
||||
// private void DoGet(AppearanceRequestData rdata)
|
||||
// {
|
||||
// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
|
||||
//
|
||||
// if (adata == null)
|
||||
// {
|
||||
// rdata.Fail(Rest.HttpStatusCodeNoContent,
|
||||
// String.Format("appearance data not found for user {0} {1}",
|
||||
// rdata.userProfile.FirstName, rdata.userProfile.SurName));
|
||||
// }
|
||||
// rdata.userAppearance = adata.ToAvatarAppearance(rdata.userProfile.ID);
|
||||
//
|
||||
// rdata.initXmlWriter();
|
||||
//
|
||||
// FormatUserAppearance(rdata);
|
||||
//
|
||||
// // Indicate a successful request
|
||||
//
|
||||
// rdata.Complete();
|
||||
//
|
||||
// // Send the response to the user. The body will be implicitly
|
||||
// // constructed from the result of the XML writer.
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} Normal completion", rdata.method));
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// POST adds NEW information to the user profile database.
|
||||
/// This effectively resets the appearance before applying those
|
||||
/// characteristics supplied in the request.
|
||||
/// </summary>
|
||||
|
||||
// private void DoExtend(AppearanceRequestData rdata)
|
||||
// {
|
||||
//
|
||||
// bool created = false;
|
||||
// bool modified = false;
|
||||
// string newnode = String.Empty;
|
||||
//
|
||||
// Rest.Log.DebugFormat("{0} POST ENTRY", MsgId);
|
||||
//
|
||||
// //AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
//
|
||||
// rdata.userAppearance = new AvatarAppearance();
|
||||
//
|
||||
// // Although the following behavior is admitted by HTTP I am becoming
|
||||
// // increasingly doubtful that it is appropriate for REST. If I attempt to
|
||||
// // add a new record, and it already exists, then it seems to me that the
|
||||
// // attempt should fail, rather than update the existing record.
|
||||
// AvatarData adata = null;
|
||||
// if (GetUserAppearance(rdata))
|
||||
// {
|
||||
// modified = rdata.userAppearance != null;
|
||||
// created = !modified;
|
||||
// adata = new AvatarData(rdata.userAppearance);
|
||||
// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
|
||||
// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// created = true;
|
||||
// adata = new AvatarData(rdata.userAppearance);
|
||||
// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
|
||||
// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
// }
|
||||
//
|
||||
// if (created)
|
||||
// {
|
||||
// newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
|
||||
// rdata.userProfile.SurName);
|
||||
// // Must include a location header with a URI that identifies the new resource.
|
||||
//
|
||||
// rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
|
||||
// rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
|
||||
// rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (modified)
|
||||
// {
|
||||
// rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
//
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// This updates the user's appearance. not all aspects need to be provided,
|
||||
/// only those supplied will be changed.
|
||||
/// </summary>
|
||||
|
||||
// private void DoUpdate(AppearanceRequestData rdata)
|
||||
// {
|
||||
//
|
||||
// // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7
|
||||
//
|
||||
// //bool created = false;
|
||||
// //bool modified = false;
|
||||
//
|
||||
//
|
||||
// //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
//
|
||||
// //// If the user exists then this is considered a modification regardless
|
||||
// //// of what may, or may not be, specified in the payload.
|
||||
//
|
||||
// //if (rdata.userAppearance != null)
|
||||
// //{
|
||||
// // modified = true;
|
||||
// // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||
// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
// //}
|
||||
//
|
||||
// //if (created)
|
||||
// //{
|
||||
// // rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // if (modified)
|
||||
// // {
|
||||
// // rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
// // }
|
||||
// //}
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
//
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Delete the specified user's appearance. This actually performs a reset
|
||||
/// to the default avatar appearance, if the info is already there.
|
||||
/// Existing ownership is preserved. All prior updates are lost and can not
|
||||
/// be recovered.
|
||||
/// </summary>
|
||||
// private void DoDelete(AppearanceRequestData rdata)
|
||||
// {
|
||||
// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
|
||||
//
|
||||
// if (adata != null)
|
||||
// {
|
||||
// AvatarAppearance old = adata.ToAvatarAppearance(rdata.userProfile.ID);
|
||||
// rdata.userAppearance = new AvatarAppearance();
|
||||
// rdata.userAppearance.Owner = old.Owner;
|
||||
// adata = new AvatarData(rdata.userAppearance);
|
||||
//
|
||||
// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
|
||||
//
|
||||
// rdata.Complete();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
//
|
||||
// rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
// }
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
// }
|
||||
|
||||
#endregion method-specific processing
|
||||
|
||||
private bool GetUserAppearance(AppearanceRequestData rdata)
|
||||
{
|
||||
|
||||
XmlReader xml;
|
||||
bool indata = false;
|
||||
|
||||
rdata.initXmlReader();
|
||||
xml = rdata.reader;
|
||||
|
||||
while (xml.Read())
|
||||
{
|
||||
switch (xml.NodeType)
|
||||
{
|
||||
case XmlNodeType.Element :
|
||||
switch (xml.Name)
|
||||
{
|
||||
case "Appearance" :
|
||||
if (xml.MoveToAttribute("Height"))
|
||||
{
|
||||
rdata.userAppearance.AvatarHeight = (float) Convert.ToDouble(xml.Value);
|
||||
indata = true;
|
||||
}
|
||||
// if (xml.MoveToAttribute("Owner"))
|
||||
// {
|
||||
// rdata.userAppearance.Owner = (UUID)xml.Value;
|
||||
// indata = true;
|
||||
// }
|
||||
if (xml.MoveToAttribute("Serial"))
|
||||
{
|
||||
rdata.userAppearance.Serial = Convert.ToInt32(xml.Value);
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case "Body" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.BodyItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.BodyAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Skin" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.SkinItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.SkinAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Hair" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.HairItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.HairAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Eyes" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.EyesItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.EyesAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Shirt" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.ShirtItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.ShirtAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Pants" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.PantsItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.PantsAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Shoes" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.ShoesItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.ShoesAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Socks" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.SocksItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.SocksAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Jacket" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.JacketItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.JacketAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Gloves" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.GlovesItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.GlovesAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "UnderShirt" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.UnderShirtItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.UnderShirtAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "UnderPants" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.UnderPantsItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.UnderPantsAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Skirt" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
rdata.userAppearance.SkirtItem = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
rdata.userAppearance.SkirtAsset = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case "Attachment" :
|
||||
{
|
||||
|
||||
int ap;
|
||||
UUID asset;
|
||||
UUID item;
|
||||
|
||||
if (xml.MoveToAttribute("AtPoint"))
|
||||
{
|
||||
ap = Convert.ToInt32(xml.Value);
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
asset = new UUID(xml.Value);
|
||||
if (xml.MoveToAttribute("Asset"))
|
||||
{
|
||||
item = new UUID(xml.Value);
|
||||
rdata.userAppearance.SetAttachment(ap, item, asset);
|
||||
indata = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Texture" :
|
||||
if (xml.MoveToAttribute("Default"))
|
||||
{
|
||||
rdata.userAppearance.Texture = new Primitive.TextureEntry(new UUID(xml.Value));
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
case "Face" :
|
||||
{
|
||||
uint index;
|
||||
if (xml.MoveToAttribute("Index"))
|
||||
{
|
||||
index = Convert.ToUInt32(xml.Value);
|
||||
if (xml.MoveToAttribute("Id"))
|
||||
{
|
||||
rdata.userAppearance.Texture.CreateFace(index).TextureID = new UUID(xml.Value);
|
||||
indata = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "VisualParameters" :
|
||||
{
|
||||
xml.ReadContentAsBase64(rdata.userAppearance.VisualParams,
|
||||
0, rdata.userAppearance.VisualParams.Length);
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return indata;
|
||||
|
||||
}
|
||||
|
||||
private void FormatPart(AppearanceRequestData rdata, string part, UUID item, UUID asset)
|
||||
{
|
||||
if (item != UUID.Zero || asset != UUID.Zero)
|
||||
{
|
||||
rdata.writer.WriteStartElement(part);
|
||||
if (item != UUID.Zero)
|
||||
{
|
||||
rdata.writer.WriteAttributeString("Item",item.ToString());
|
||||
}
|
||||
|
||||
if (asset != UUID.Zero)
|
||||
{
|
||||
rdata.writer.WriteAttributeString("Asset",asset.ToString());
|
||||
}
|
||||
rdata.writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormatUserAppearance(AppearanceRequestData rdata)
|
||||
{
|
||||
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance", MsgId);
|
||||
|
||||
if (rdata.userAppearance != null)
|
||||
{
|
||||
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: appearance object exists", MsgId);
|
||||
rdata.writer.WriteStartElement("Appearance");
|
||||
|
||||
rdata.writer.WriteAttributeString("Height", rdata.userAppearance.AvatarHeight.ToString());
|
||||
// if (rdata.userAppearance.Owner != UUID.Zero)
|
||||
// rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString());
|
||||
rdata.writer.WriteAttributeString("Serial", rdata.userAppearance.Serial.ToString());
|
||||
|
||||
/*
|
||||
FormatPart(rdata, "Body", rdata.userAppearance.BodyItem, rdata.userAppearance.BodyAsset);
|
||||
FormatPart(rdata, "Skin", rdata.userAppearance.SkinItem, rdata.userAppearance.SkinAsset);
|
||||
FormatPart(rdata, "Hair", rdata.userAppearance.HairItem, rdata.userAppearance.HairAsset);
|
||||
FormatPart(rdata, "Eyes", rdata.userAppearance.EyesItem, rdata.userAppearance.EyesAsset);
|
||||
|
||||
FormatPart(rdata, "Shirt", rdata.userAppearance.ShirtItem, rdata.userAppearance.ShirtAsset);
|
||||
FormatPart(rdata, "Pants", rdata.userAppearance.PantsItem, rdata.userAppearance.PantsAsset);
|
||||
FormatPart(rdata, "Skirt", rdata.userAppearance.SkirtItem, rdata.userAppearance.SkirtAsset);
|
||||
FormatPart(rdata, "Shoes", rdata.userAppearance.ShoesItem, rdata.userAppearance.ShoesAsset);
|
||||
FormatPart(rdata, "Socks", rdata.userAppearance.SocksItem, rdata.userAppearance.SocksAsset);
|
||||
|
||||
FormatPart(rdata, "Jacket", rdata.userAppearance.JacketItem, rdata.userAppearance.JacketAsset);
|
||||
FormatPart(rdata, "Gloves", rdata.userAppearance.GlovesItem, rdata.userAppearance.GlovesAsset);
|
||||
|
||||
FormatPart(rdata, "UnderShirt", rdata.userAppearance.UnderShirtItem, rdata.userAppearance.UnderShirtAsset);
|
||||
FormatPart(rdata, "UnderPants", rdata.userAppearance.UnderPantsItem, rdata.userAppearance.UnderPantsAsset);
|
||||
*/
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting attachments", MsgId);
|
||||
|
||||
rdata.writer.WriteStartElement("Attachments");
|
||||
List<AvatarAttachment> attachments = rdata.userAppearance.GetAttachments();
|
||||
foreach (AvatarAttachment attach in attachments)
|
||||
{
|
||||
rdata.writer.WriteStartElement("Attachment");
|
||||
rdata.writer.WriteAttributeString("AtPoint", attach.AttachPoint.ToString());
|
||||
rdata.writer.WriteAttributeString("Item", attach.ItemID.ToString());
|
||||
rdata.writer.WriteAttributeString("Asset", attach.AssetID.ToString());
|
||||
rdata.writer.WriteEndElement();
|
||||
}
|
||||
rdata.writer.WriteEndElement();
|
||||
|
||||
Primitive.TextureEntry texture = rdata.userAppearance.Texture;
|
||||
|
||||
if (texture != null && (texture.DefaultTexture != null || texture.FaceTextures != null))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting textures", MsgId);
|
||||
|
||||
rdata.writer.WriteStartElement("Texture");
|
||||
|
||||
if (texture.DefaultTexture != null)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting default texture", MsgId);
|
||||
rdata.writer.WriteAttributeString("Default",
|
||||
texture.DefaultTexture.TextureID.ToString());
|
||||
}
|
||||
|
||||
if (texture.FaceTextures != null)
|
||||
{
|
||||
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting face textures", MsgId);
|
||||
|
||||
for (int i=0; i<texture.FaceTextures.Length;i++)
|
||||
{
|
||||
if (texture.FaceTextures[i] != null)
|
||||
{
|
||||
rdata.writer.WriteStartElement("Face");
|
||||
rdata.writer.WriteAttributeString("Index", i.ToString());
|
||||
rdata.writer.WriteAttributeString("Id",
|
||||
texture.FaceTextures[i].TextureID.ToString());
|
||||
rdata.writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rdata.writer.WriteEndElement();
|
||||
}
|
||||
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting visual parameters", MsgId);
|
||||
|
||||
rdata.writer.WriteStartElement("VisualParameters");
|
||||
rdata.writer.WriteBase64(rdata.userAppearance.VisualParams,0,
|
||||
rdata.userAppearance.VisualParams.Length);
|
||||
rdata.writer.WriteEndElement();
|
||||
rdata.writer.WriteFullEndElement();
|
||||
}
|
||||
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: completed", MsgId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#region appearance RequestData extension
|
||||
|
||||
internal class AppearanceRequestData : RequestData
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// These are the inventory specific request/response state
|
||||
/// extensions.
|
||||
/// </summary>
|
||||
|
||||
internal UUID uuid = UUID.Zero;
|
||||
internal UserProfileData userProfile = null;
|
||||
internal AvatarAppearance userAppearance = null;
|
||||
|
||||
internal AppearanceRequestData(OSHttpRequest request, OSHttpResponse response, string prefix)
|
||||
: base(request, response, prefix)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion Appearance RequestData extension
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,383 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
public class RestAssetServices : IRest
|
||||
{
|
||||
private bool enabled = false;
|
||||
private string qPrefix = "assets";
|
||||
|
||||
// A simple constructor is used to handle any once-only
|
||||
// initialization of working classes.
|
||||
|
||||
public RestAssetServices()
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Asset services initializing", MsgId);
|
||||
Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version);
|
||||
|
||||
// If the handler specifies a relative path for its domain
|
||||
// then we must add the standard absolute prefix, e.g. /admin
|
||||
|
||||
if (!qPrefix.StartsWith(Rest.UrlPathSeparator))
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Prefixing domain name ({1})", MsgId, qPrefix);
|
||||
qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
|
||||
Rest.Log.InfoFormat("{0} Fully qualified domain name is <{1}>", MsgId, qPrefix);
|
||||
}
|
||||
|
||||
// Register interface using the fully-qualified prefix
|
||||
|
||||
Rest.Plugin.AddPathHandler(DoAsset, qPrefix, Allocate);
|
||||
|
||||
// Activate if all went OK
|
||||
|
||||
enabled = true;
|
||||
|
||||
Rest.Log.InfoFormat("{0} Asset services initialization complete", MsgId);
|
||||
}
|
||||
|
||||
// Post-construction, pre-enabled initialization opportunity
|
||||
// Not currently exploited.
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
// Called by the plug-in to halt REST processing. Local processing is
|
||||
// disabled, and control blocks until all current processing has
|
||||
// completed. No new processing will be started
|
||||
|
||||
public void Close()
|
||||
{
|
||||
enabled = false;
|
||||
Rest.Log.InfoFormat("{0} Asset services ({1}) closing down", MsgId, qPrefix);
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
internal string MsgId
|
||||
{
|
||||
get { return Rest.MsgId; }
|
||||
}
|
||||
|
||||
#region Interface
|
||||
|
||||
private RequestData Allocate(OSHttpRequest request, OSHttpResponse response, string prefix)
|
||||
{
|
||||
return (RequestData) new AssetRequestData(request, response, prefix);
|
||||
}
|
||||
|
||||
// Asset Handler
|
||||
|
||||
private void DoAsset(RequestData rparm)
|
||||
{
|
||||
if (!enabled) return;
|
||||
|
||||
AssetRequestData rdata = (AssetRequestData) rparm;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST Asset handler ({1}) ENTRY", MsgId, qPrefix);
|
||||
|
||||
// Now that we know this is a serious attempt to
|
||||
// access inventory data, we should find out who
|
||||
// is asking, and make sure they are authorized
|
||||
// to do so. We need to validate the caller's
|
||||
// identity before revealing anything about the
|
||||
// status quo. Authenticate throws an exception
|
||||
// via Fail if no identity information is present.
|
||||
//
|
||||
// With the present HTTP server we can't use the
|
||||
// builtin authentication mechanisms because they
|
||||
// would be enforced for all in-bound requests.
|
||||
// Instead we look at the headers ourselves and
|
||||
// handle authentication directly.
|
||||
|
||||
try
|
||||
{
|
||||
if (!rdata.IsAuthenticated)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeNotAuthorized, String.Format("user \"{0}\" could not be authenticated"));
|
||||
}
|
||||
}
|
||||
catch (RestException e)
|
||||
{
|
||||
if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId,
|
||||
rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId,
|
||||
rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
throw (e);
|
||||
}
|
||||
|
||||
// Remove the prefix and what's left are the parameters. If we don't have
|
||||
// the parameters we need, fail the request. Parameters do NOT include
|
||||
// any supplied query values.
|
||||
|
||||
if (rdata.Parameters.Length > 0)
|
||||
{
|
||||
switch (rdata.method)
|
||||
{
|
||||
case "get" :
|
||||
DoGet(rdata);
|
||||
break;
|
||||
case "put" :
|
||||
DoPut(rdata);
|
||||
break;
|
||||
case "post" :
|
||||
DoPost(rdata);
|
||||
break;
|
||||
case "delete" :
|
||||
default :
|
||||
Rest.Log.WarnFormat("{0} Asset: Method not supported: {1}",
|
||||
MsgId, rdata.method);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,String.Format("method <{0}> not supported", rdata.method));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Asset: No agent information provided", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no agent information provided");
|
||||
}
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST Asset handler EXIT", MsgId);
|
||||
}
|
||||
|
||||
#endregion Interface
|
||||
|
||||
/// <summary>
|
||||
/// The only parameter we recognize is a UUID.If an asset with this identification is
|
||||
/// found, it's content, base-64 encoded, is returned to the client.
|
||||
/// </summary>
|
||||
|
||||
private void DoGet(AssetRequestData rdata)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method);
|
||||
|
||||
if (rdata.Parameters.Length == 1)
|
||||
{
|
||||
UUID uuid = new UUID(rdata.Parameters[0]);
|
||||
AssetBase asset = Rest.AssetServices.Get(uuid.ToString());
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Asset located <{1}>", MsgId, rdata.Parameters[0]);
|
||||
|
||||
rdata.initXmlWriter();
|
||||
|
||||
rdata.writer.WriteStartElement(String.Empty,"Asset",String.Empty);
|
||||
|
||||
rdata.writer.WriteAttributeString("id", asset.ID);
|
||||
rdata.writer.WriteAttributeString("name", asset.Name);
|
||||
rdata.writer.WriteAttributeString("desc", asset.Description);
|
||||
rdata.writer.WriteAttributeString("type", asset.Type.ToString());
|
||||
rdata.writer.WriteAttributeString("local", asset.Local.ToString());
|
||||
rdata.writer.WriteAttributeString("temporary", asset.Temporary.ToString());
|
||||
|
||||
rdata.writer.WriteBase64(asset.Data,0,asset.Data.Length);
|
||||
|
||||
rdata.writer.WriteFullEndElement();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, "invalid parameters");
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Complete();
|
||||
rdata.Respond(String.Format("Asset <{0}> : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UPDATE existing item, if it exists. URI identifies the item in question.
|
||||
/// The only parameter we recognize is a UUID. The enclosed asset data (base-64 encoded)
|
||||
/// is decoded and stored in the database, identified by the supplied UUID.
|
||||
/// </summary>
|
||||
private void DoPut(AssetRequestData rdata)
|
||||
{
|
||||
bool modified = false;
|
||||
bool created = false;
|
||||
|
||||
AssetBase asset = null;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method);
|
||||
|
||||
if (rdata.Parameters.Length == 1)
|
||||
{
|
||||
|
||||
rdata.initXmlReader();
|
||||
XmlReader xml = rdata.reader;
|
||||
|
||||
if (!xml.ReadToFollowing("Asset"))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,"invalid request data");
|
||||
}
|
||||
|
||||
UUID uuid = new UUID(rdata.Parameters[0]);
|
||||
asset = Rest.AssetServices.Get(uuid.ToString());
|
||||
|
||||
modified = (asset != null);
|
||||
created = !modified;
|
||||
|
||||
asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type")), UUID.Zero.ToString());
|
||||
asset.Description = xml.GetAttribute("desc");
|
||||
asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0;
|
||||
asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0;
|
||||
asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", ""));
|
||||
|
||||
if (asset.ID != rdata.Parameters[0])
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} URI and payload disagree on UUID U:{1} vs P:{2}",
|
||||
MsgId, rdata.Parameters[0], asset.ID);
|
||||
}
|
||||
|
||||
Rest.AssetServices.Store(asset);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, "invalid parameters");
|
||||
}
|
||||
|
||||
if (created)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Created asset {0}, UUID {1} <p>", asset.Name, asset.FullID));
|
||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modified)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Modified asset {0}, UUID {1} <p>", asset.Name, asset.FullID));
|
||||
rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("Asset {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CREATE new item, replace if it exists. URI identifies the context for the item in question.
|
||||
/// No parameters are required for POST, just thepayload.
|
||||
/// </summary>
|
||||
|
||||
private void DoPost(AssetRequestData rdata)
|
||||
{
|
||||
|
||||
bool modified = false;
|
||||
bool created = false;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method);
|
||||
|
||||
if (rdata.Parameters.Length != 0)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Parameters ignored <{1}>", MsgId, rdata.path);
|
||||
Rest.Log.InfoFormat("{0} POST of an asset has no parameters", MsgId, rdata.path);
|
||||
}
|
||||
|
||||
rdata.initXmlReader();
|
||||
XmlReader xml = rdata.reader;
|
||||
|
||||
if (!xml.ReadToFollowing("Asset"))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,"invalid request data");
|
||||
}
|
||||
|
||||
UUID uuid = new UUID(xml.GetAttribute("id"));
|
||||
AssetBase asset = Rest.AssetServices.Get(uuid.ToString());
|
||||
|
||||
modified = (asset != null);
|
||||
created = !modified;
|
||||
|
||||
asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type")), UUID.Zero.ToString());
|
||||
asset.Description = xml.GetAttribute("desc");
|
||||
asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0;
|
||||
asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0;
|
||||
asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", ""));
|
||||
|
||||
Rest.AssetServices.Store(asset);
|
||||
|
||||
if (created)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Created asset {0}, UUID {1} <p>", asset.Name, asset.FullID));
|
||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modified)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Modified asset {0}, UUID {1} <p>", asset.Name, asset.FullID));
|
||||
rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("Asset {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asset processing has no special data area requirements.
|
||||
/// </summary>
|
||||
|
||||
internal class AssetRequestData : RequestData
|
||||
{
|
||||
internal AssetRequestData(OSHttpRequest request, OSHttpResponse response, string prefix)
|
||||
: base(request, response, prefix)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,448 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
public class RestFileServices : IRest
|
||||
{
|
||||
private bool enabled = false;
|
||||
private string qPrefix = "files";
|
||||
|
||||
// A simple constructor is used to handle any once-only
|
||||
// initialization of working classes.
|
||||
|
||||
public RestFileServices()
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} File services initializing", MsgId);
|
||||
Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version);
|
||||
|
||||
// If the handler specifies a relative path for its domain
|
||||
// then we must add the standard absolute prefix, e.g. /admin
|
||||
|
||||
if (!qPrefix.StartsWith(Rest.UrlPathSeparator))
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Prefixing domain name ({1})", MsgId, qPrefix);
|
||||
qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
|
||||
Rest.Log.InfoFormat("{0} Fully qualified domain name is <{1}>", MsgId, qPrefix);
|
||||
}
|
||||
|
||||
// Register interface using the fully-qualified prefix
|
||||
|
||||
Rest.Plugin.AddPathHandler(DoFile, qPrefix, Allocate);
|
||||
|
||||
// Activate if all went OK
|
||||
|
||||
enabled = true;
|
||||
|
||||
Rest.Log.InfoFormat("{0} File services initialization complete", MsgId);
|
||||
}
|
||||
|
||||
// Post-construction, pre-enabled initialization opportunity
|
||||
// Not currently exploited.
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
// Called by the plug-in to halt REST processing. Local processing is
|
||||
// disabled, and control blocks until all current processing has
|
||||
// completed. No new processing will be started
|
||||
|
||||
public void Close()
|
||||
{
|
||||
enabled = false;
|
||||
Rest.Log.InfoFormat("{0} File services ({1}) closing down", MsgId, qPrefix);
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
internal string MsgId
|
||||
{
|
||||
get { return Rest.MsgId; }
|
||||
}
|
||||
|
||||
#region Interface
|
||||
|
||||
private RequestData Allocate(OSHttpRequest request, OSHttpResponse response, string prefix)
|
||||
{
|
||||
return (RequestData) new FileRequestData(request, response, prefix);
|
||||
}
|
||||
|
||||
// Asset Handler
|
||||
|
||||
private void DoFile(RequestData rparm)
|
||||
{
|
||||
if (!enabled) return;
|
||||
|
||||
FileRequestData rdata = (FileRequestData) rparm;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST File handler ({1}) ENTRY", MsgId, qPrefix);
|
||||
|
||||
// Now that we know this is a serious attempt to
|
||||
// access file data, we should find out who
|
||||
// is asking, and make sure they are authorized
|
||||
// to do so. We need to validate the caller's
|
||||
// identity before revealing anything about the
|
||||
// status quo. Authenticate throws an exception
|
||||
// via Fail if no identity information is present.
|
||||
//
|
||||
// With the present HTTP server we can't use the
|
||||
// builtin authentication mechanisms because they
|
||||
// would be enforced for all in-bound requests.
|
||||
// Instead we look at the headers ourselves and
|
||||
// handle authentication directly.
|
||||
|
||||
try
|
||||
{
|
||||
if (!rdata.IsAuthenticated)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeNotAuthorized, String.Format("user \"{0}\" could not be authenticated"));
|
||||
}
|
||||
}
|
||||
catch (RestException e)
|
||||
{
|
||||
if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId,
|
||||
rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId,
|
||||
rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
throw (e);
|
||||
}
|
||||
|
||||
// Remove the prefix and what's left are the parameters. If we don't have
|
||||
// the parameters we need, fail the request. Parameters do NOT include
|
||||
// any supplied query values.
|
||||
|
||||
if (rdata.Parameters.Length > 0)
|
||||
{
|
||||
switch (rdata.method)
|
||||
{
|
||||
case "get" :
|
||||
DoGet(rdata);
|
||||
break;
|
||||
case "put" :
|
||||
DoPut(rdata);
|
||||
break;
|
||||
case "post" :
|
||||
DoPost(rdata);
|
||||
break;
|
||||
case "delete" :
|
||||
DoDelete(rdata);
|
||||
break;
|
||||
default :
|
||||
Rest.Log.WarnFormat("{0} File: Method not supported: {1}",
|
||||
MsgId, rdata.method);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,String.Format("method <{0}> not supported", rdata.method));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} File: No agent information provided", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no agent information provided");
|
||||
}
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST File handler EXIT", MsgId);
|
||||
|
||||
}
|
||||
|
||||
#endregion Interface
|
||||
|
||||
/// <summary>
|
||||
/// The only parameter we recognize is a UUID.If an asset with this identification is
|
||||
/// found, it's content, base-64 encoded, is returned to the client.
|
||||
/// </summary>
|
||||
|
||||
private void DoGet(FileRequestData rdata)
|
||||
{
|
||||
|
||||
string path = String.Empty;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST File handler, Method = <{1}> ENTRY", MsgId, rdata.method);
|
||||
|
||||
if (rdata.Parameters.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
path = rdata.path.Substring(rdata.Parameters[0].Length+qPrefix.Length+2);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} File located <{1}>", MsgId, path);
|
||||
Byte[] data = File.ReadAllBytes(path);
|
||||
rdata.initXmlWriter();
|
||||
rdata.writer.WriteStartElement(String.Empty,"File",String.Empty);
|
||||
rdata.writer.WriteAttributeString("name", path);
|
||||
rdata.writer.WriteBase64(data,0,data.Length);
|
||||
rdata.writer.WriteFullEndElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, path);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, String.Format("invalid parameters : {0}", path));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, e.Message);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, String.Format("invalid parameters : {0} {1}",
|
||||
path, e.Message));
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Complete();
|
||||
rdata.Respond(String.Format("File <{0}> : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UPDATE existing item, if it exists. URI identifies the item in question.
|
||||
/// The only parameter we recognize is a UUID. The enclosed asset data (base-64 encoded)
|
||||
/// is decoded and stored in the database, identified by the supplied UUID.
|
||||
/// </summary>
|
||||
private void DoPut(FileRequestData rdata)
|
||||
{
|
||||
bool modified = false;
|
||||
bool created = false;
|
||||
string path = String.Empty;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST File handler, Method = <{1}> ENTRY", MsgId, rdata.method);
|
||||
|
||||
if (rdata.Parameters.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
path = rdata.path.Substring(rdata.Parameters[0].Length+qPrefix.Length+2);
|
||||
bool maymod = File.Exists(path);
|
||||
|
||||
rdata.initXmlReader();
|
||||
XmlReader xml = rdata.reader;
|
||||
|
||||
if (!xml.ReadToFollowing("File"))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,"invalid request data");
|
||||
}
|
||||
|
||||
Byte[] data = Convert.FromBase64String(xml.ReadElementContentAsString("File", ""));
|
||||
|
||||
File.WriteAllBytes(path,data);
|
||||
modified = maymod;
|
||||
created = ! maymod;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Exception during file processing : {1}", MsgId,
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, "invalid parameters");
|
||||
}
|
||||
|
||||
if (created)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Created file {0} <p>", path));
|
||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modified)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Modified file {0} <p>", path));
|
||||
rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("File {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CREATE new item, replace if it exists. URI identifies the context for the item in question.
|
||||
/// No parameters are required for POST, just thepayload.
|
||||
/// </summary>
|
||||
|
||||
private void DoPost(FileRequestData rdata)
|
||||
{
|
||||
|
||||
bool modified = false;
|
||||
bool created = false;
|
||||
string path = String.Empty;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST File handler, Method = <{1}> ENTRY", MsgId, rdata.method);
|
||||
|
||||
if (rdata.Parameters.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
path = rdata.path.Substring(rdata.Parameters[0].Length+qPrefix.Length+2);
|
||||
bool maymod = File.Exists(path);
|
||||
|
||||
rdata.initXmlReader();
|
||||
XmlReader xml = rdata.reader;
|
||||
|
||||
if (!xml.ReadToFollowing("File"))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,"invalid request data");
|
||||
}
|
||||
|
||||
Byte[] data = Convert.FromBase64String(xml.ReadElementContentAsString("File", ""));
|
||||
|
||||
File.WriteAllBytes(path,data);
|
||||
modified = maymod;
|
||||
created = ! maymod;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Exception during file processing : {1}", MsgId,
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, "invalid parameters");
|
||||
}
|
||||
|
||||
if (created)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Created file {0} <p>", path));
|
||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modified)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Modified file {0} <p>", path));
|
||||
rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("File {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CREATE new item, replace if it exists. URI identifies the context for the item in question.
|
||||
/// No parameters are required for POST, just thepayload.
|
||||
/// </summary>
|
||||
|
||||
private void DoDelete(FileRequestData rdata)
|
||||
{
|
||||
|
||||
bool modified = false;
|
||||
bool created = false;
|
||||
string path = String.Empty;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST File handler, Method = <{1}> ENTRY", MsgId, rdata.method);
|
||||
|
||||
if (rdata.Parameters.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
path = rdata.path.Substring(rdata.Parameters[0].Length+qPrefix.Length+2);
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Exception during file processing : {1}", MsgId,
|
||||
e.Message);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, String.Format("invalid parameters : {0} {1}",
|
||||
path, e.Message));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, "invalid parameters");
|
||||
}
|
||||
|
||||
if (created)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Created file {0} <p>", path));
|
||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modified)
|
||||
{
|
||||
rdata.appendStatus(String.Format("<p> Modified file {0} <p>", path));
|
||||
rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("File {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File processing has no special data area requirements.
|
||||
/// </summary>
|
||||
|
||||
internal class FileRequestData : RequestData
|
||||
{
|
||||
internal FileRequestData(OSHttpRequest request, OSHttpResponse response, string prefix)
|
||||
: base(request, response, prefix)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,662 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
/// <remarks>
|
||||
/// The class signature reveals the roles that RestHandler plays.
|
||||
///
|
||||
/// [1] It is a sub-class of RestPlugin. It inherits and extends
|
||||
/// the functionality of this class, constraining it to the
|
||||
/// specific needs of this REST implementation. This relates
|
||||
/// to the plug-in mechanism supported by OpenSim, the specifics
|
||||
/// of which are mostly hidden by RestPlugin.
|
||||
/// [2] IRestHandler describes the interface that this class
|
||||
/// exports to service implementations. This is the services
|
||||
/// management interface.
|
||||
/// [3] IHttpAgentHandler describes the interface that is exported
|
||||
/// to the BaseHttpServer in support of this particular HTTP
|
||||
/// processing model. This is the request interface of the
|
||||
/// handler.
|
||||
/// </remarks>
|
||||
|
||||
public class RestHandler : RestPlugin, IRestHandler, IHttpAgentHandler
|
||||
{
|
||||
// Handler tables: both stream and REST are supported. The path handlers and their
|
||||
// respective allocators are stored in separate tables.
|
||||
|
||||
internal Dictionary<string,RestMethodHandler> pathHandlers = new Dictionary<string,RestMethodHandler>();
|
||||
internal Dictionary<string,RestMethodAllocator> pathAllocators = new Dictionary<string,RestMethodAllocator>();
|
||||
internal Dictionary<string,RestStreamHandler> streamHandlers = new Dictionary<string,RestStreamHandler>();
|
||||
|
||||
#region local static state
|
||||
|
||||
private static bool handlersLoaded = false;
|
||||
private static List<Type> classes = new List<Type>();
|
||||
private static List<IRest> handlers = new List<IRest>();
|
||||
private static Type[] parms = new Type[0];
|
||||
private static Object[] args = new Object[0];
|
||||
|
||||
/// <summary>
|
||||
/// This static initializer scans the ASSEMBLY for classes that
|
||||
/// export the IRest interface and builds a list of them. These
|
||||
/// are later activated by the handler. To add a new handler it
|
||||
/// is only necessary to create a new services class that implements
|
||||
/// the IRest interface, and recompile the handler. This gives
|
||||
/// all of the build-time flexibility of a modular approach
|
||||
/// while not introducing yet-another module loader. Note that
|
||||
/// multiple assembles can still be built, each with its own set
|
||||
/// of handlers. Examples of services classes are RestInventoryServices
|
||||
/// and RestSkeleton.
|
||||
/// </summary>
|
||||
|
||||
static RestHandler()
|
||||
{
|
||||
Module[] mods = Assembly.GetExecutingAssembly().GetModules();
|
||||
|
||||
foreach (Module m in mods)
|
||||
{
|
||||
Type[] types = m.GetTypes();
|
||||
foreach (Type t in types)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (t.GetInterface("IRest") != null)
|
||||
{
|
||||
classes.Add(t);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Rest.Log.WarnFormat("[STATIC-HANDLER]: #0 Error scanning {1}", t);
|
||||
Rest.Log.InfoFormat("[STATIC-HANDLER]: #0 {1} is not included", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion local static state
|
||||
|
||||
#region local instance state
|
||||
|
||||
/// <summary>
|
||||
/// This routine loads all of the handlers discovered during
|
||||
/// instance initialization.
|
||||
/// A table of all loaded and successfully constructed handlers
|
||||
/// is built, and this table is then used by the constructor to
|
||||
/// initialize each of the handlers in turn.
|
||||
/// NOTE: The loading process does not automatically imply that
|
||||
/// the handler has registered any kind of an interface, that
|
||||
/// may be (optionally) done by the handler either during
|
||||
/// construction, or during initialization.
|
||||
///
|
||||
/// I was not able to make this code work within a constructor
|
||||
/// so it is isolated within this method.
|
||||
/// </summary>
|
||||
|
||||
private void LoadHandlers()
|
||||
{
|
||||
lock (handlers)
|
||||
{
|
||||
if (!handlersLoaded)
|
||||
{
|
||||
ConstructorInfo ci;
|
||||
Object ht;
|
||||
|
||||
foreach (Type t in classes)
|
||||
{
|
||||
try
|
||||
{
|
||||
ci = t.GetConstructor(parms);
|
||||
ht = ci.Invoke(args);
|
||||
handlers.Add((IRest)ht);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Unable to load {1} : {2}", MsgId, t, e.Message);
|
||||
}
|
||||
}
|
||||
handlersLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion local instance state
|
||||
|
||||
#region overriding properties
|
||||
|
||||
// These properties override definitions
|
||||
// in the base class.
|
||||
|
||||
// Name is used to differentiate the message header.
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "HANDLER"; }
|
||||
}
|
||||
|
||||
// Used to partition the .ini configuration space.
|
||||
|
||||
public override string ConfigName
|
||||
{
|
||||
get { return "RestHandler"; }
|
||||
}
|
||||
|
||||
// We have to rename these because we want
|
||||
// to be able to share the values with other
|
||||
// classes in our assembly and the base
|
||||
// names are protected.
|
||||
|
||||
public string MsgId
|
||||
{
|
||||
get { return base.MsgID; }
|
||||
}
|
||||
|
||||
public string RequestId
|
||||
{
|
||||
get { return base.RequestID; }
|
||||
}
|
||||
|
||||
#endregion overriding properties
|
||||
|
||||
#region overriding methods
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by OpenSimMain immediately after loading the
|
||||
/// plugin and after basic server setup, but before running any server commands.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that entries MUST be added to the active configuration files before
|
||||
/// the plugin can be enabled.
|
||||
/// </remarks>
|
||||
|
||||
public override void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
try
|
||||
{
|
||||
// This plugin will only be enabled if the broader
|
||||
// REST plugin mechanism is enabled.
|
||||
|
||||
//Rest.Log.InfoFormat("{0} Plugin is initializing", MsgId);
|
||||
|
||||
base.Initialise(openSim);
|
||||
|
||||
// IsEnabled is implemented by the base class and
|
||||
// reflects an overall RestPlugin status
|
||||
|
||||
if (!IsEnabled)
|
||||
{
|
||||
//Rest.Log.WarnFormat("{0} Plugins are disabled", MsgId);
|
||||
return;
|
||||
}
|
||||
|
||||
Rest.Log.InfoFormat("{0} Rest <{1}> plugin will be enabled", MsgId, Name);
|
||||
Rest.Log.InfoFormat("{0} Configuration parameters read from <{1}>", MsgId, ConfigName);
|
||||
|
||||
// These are stored in static variables to make
|
||||
// them easy to reach from anywhere in the assembly.
|
||||
|
||||
Rest.main = openSim;
|
||||
if (Rest.main == null)
|
||||
throw new Exception("OpenSim base pointer is null");
|
||||
|
||||
Rest.Plugin = this;
|
||||
Rest.Config = Config;
|
||||
Rest.Prefix = Prefix;
|
||||
Rest.GodKey = GodKey;
|
||||
Rest.Authenticate = Rest.Config.GetBoolean("authenticate", Rest.Authenticate);
|
||||
Rest.Scheme = Rest.Config.GetString("auth-scheme", Rest.Scheme);
|
||||
Rest.Secure = Rest.Config.GetBoolean("secured", Rest.Secure);
|
||||
Rest.ExtendedEscape = Rest.Config.GetBoolean("extended-escape", Rest.ExtendedEscape);
|
||||
Rest.Realm = Rest.Config.GetString("realm", Rest.Realm);
|
||||
Rest.DumpAsset = Rest.Config.GetBoolean("dump-asset", Rest.DumpAsset);
|
||||
Rest.Fill = Rest.Config.GetBoolean("path-fill", Rest.Fill);
|
||||
Rest.DumpLineSize = Rest.Config.GetInt("dump-line-size", Rest.DumpLineSize);
|
||||
Rest.FlushEnabled = Rest.Config.GetBoolean("flush-on-error", Rest.FlushEnabled);
|
||||
|
||||
// Note: Odd spacing is required in the following strings
|
||||
|
||||
Rest.Log.InfoFormat("{0} Authentication is {1}required", MsgId,
|
||||
(Rest.Authenticate ? "" : "not "));
|
||||
|
||||
Rest.Log.InfoFormat("{0} Security is {1}enabled", MsgId,
|
||||
(Rest.Secure ? "" : "not "));
|
||||
|
||||
Rest.Log.InfoFormat("{0} Extended URI escape processing is {1}enabled", MsgId,
|
||||
(Rest.ExtendedEscape ? "" : "not "));
|
||||
|
||||
Rest.Log.InfoFormat("{0} Dumping of asset data is {1}enabled", MsgId,
|
||||
(Rest.DumpAsset ? "" : "not "));
|
||||
|
||||
// The supplied prefix MUST be absolute
|
||||
|
||||
if (Rest.Prefix.Substring(0,1) != Rest.UrlPathSeparator)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Prefix <{1}> is not absolute and must be", MsgId, Rest.Prefix);
|
||||
Rest.Log.InfoFormat("{0} Prefix changed to </{1}>", MsgId, Rest.Prefix);
|
||||
Rest.Prefix = String.Format("{0}{1}", Rest.UrlPathSeparator, Rest.Prefix);
|
||||
}
|
||||
|
||||
// If data dumping is requested, report on the chosen line
|
||||
// length.
|
||||
|
||||
if (Rest.DumpAsset)
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Dump {1} bytes per line", MsgId, Rest.DumpLineSize);
|
||||
}
|
||||
|
||||
// Load all of the handlers present in the
|
||||
// assembly
|
||||
|
||||
// In principle, as we're an application plug-in,
|
||||
// most of what needs to be done could be done using
|
||||
// static resources, however the Open Sim plug-in
|
||||
// model makes this an instance, so that's what we
|
||||
// need to be.
|
||||
// There is only one Communications manager per
|
||||
// server, and by inference, only one each of the
|
||||
// user, asset, and inventory servers. So we can cache
|
||||
// those using a static initializer.
|
||||
// We move all of this processing off to another
|
||||
// services class to minimize overlap between function
|
||||
// and infrastructure.
|
||||
|
||||
LoadHandlers();
|
||||
|
||||
// The intention of a post construction initializer
|
||||
// is to allow for setup that is dependent upon other
|
||||
// activities outside of the agency.
|
||||
|
||||
foreach (IRest handler in handlers)
|
||||
{
|
||||
try
|
||||
{
|
||||
handler.Initialize();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} initialization error: {1}", MsgId, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// Now that everything is setup we can proceed to
|
||||
// add THIS agent to the HTTP server's handler list
|
||||
|
||||
// FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will
|
||||
// have to be handled through the AddHttpHandler interface.
|
||||
// if (!AddAgentHandler(Rest.Name,this))
|
||||
// {
|
||||
// Rest.Log.ErrorFormat("{0} Unable to activate handler interface", MsgId);
|
||||
// foreach (IRest handler in handlers)
|
||||
// {
|
||||
// handler.Close();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} Plugin initialization has failed: {1}", MsgId, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In the interests of efficiency, and because we cannot determine whether
|
||||
/// or not this instance will actually be harvested, we clobber the only
|
||||
/// anchoring reference to the working state for this plug-in. What the
|
||||
/// call to close does is irrelevant to this class beyond knowing that it
|
||||
/// can nullify the reference when it returns.
|
||||
/// To make sure everything is copacetic we make sure the primary interface
|
||||
/// is disabled by deleting the handler from the HTTP server tables.
|
||||
/// </summary>
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Plugin is terminating", MsgId);
|
||||
|
||||
// FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will
|
||||
// have to be handled through the AddHttpHandler interface.
|
||||
// try
|
||||
// {
|
||||
// RemoveAgentHandler(Rest.Name, this);
|
||||
// }
|
||||
// catch (KeyNotFoundException){}
|
||||
|
||||
foreach (IRest handler in handlers)
|
||||
{
|
||||
handler.Close();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion overriding methods
|
||||
|
||||
#region interface methods
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by the HTTP server to match an incoming
|
||||
/// request. It scans all of the strings registered by the
|
||||
/// underlying handlers and looks for the best match. It returns
|
||||
/// true if a match is found.
|
||||
/// The matching process could be made arbitrarily complex.
|
||||
/// Note: The match is case-insensitive.
|
||||
/// </summary>
|
||||
|
||||
public bool Match(OSHttpRequest request, OSHttpResponse response)
|
||||
{
|
||||
|
||||
string path = request.RawUrl.ToLower();
|
||||
|
||||
// Rest.Log.DebugFormat("{0} Match ENTRY", MsgId);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (string key in pathHandlers.Keys)
|
||||
{
|
||||
// Rest.Log.DebugFormat("{0} Match testing {1} against agent prefix <{2}>", MsgId, path, key);
|
||||
|
||||
// Note that Match will not necessarily find the handler that will
|
||||
// actually be used - it does no test for the "closest" fit. It
|
||||
// simply reflects that at least one possible handler exists.
|
||||
|
||||
if (path.StartsWith(key))
|
||||
{
|
||||
// Rest.Log.DebugFormat("{0} Matched prefix <{1}>", MsgId, key);
|
||||
|
||||
// This apparently odd evaluation is needed to prevent a match
|
||||
// on anything other than a URI token boundary. Otherwise we
|
||||
// may match on URL's that were not intended for this handler.
|
||||
|
||||
return (path.Length == key.Length ||
|
||||
path.Substring(key.Length, 1) == Rest.UrlPathSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
path = String.Format("{0}{1}{2}", request.HttpMethod, Rest.UrlMethodSeparator, path);
|
||||
|
||||
foreach (string key in streamHandlers.Keys)
|
||||
{
|
||||
// Rest.Log.DebugFormat("{0} Match testing {1} against stream prefix <{2}>", MsgId, path, key);
|
||||
|
||||
// Note that Match will not necessarily find the handler that will
|
||||
// actually be used - it does no test for the "closest" fit. It
|
||||
// simply reflects that at least one possible handler exists.
|
||||
|
||||
if (path.StartsWith(key))
|
||||
{
|
||||
// Rest.Log.DebugFormat("{0} Matched prefix <{1}>", MsgId, key);
|
||||
|
||||
// This apparently odd evaluation is needed to prevent a match
|
||||
// on anything other than a URI token boundary. Otherwise we
|
||||
// may match on URL's that were not intended for this handler.
|
||||
|
||||
return (path.Length == key.Length ||
|
||||
path.Substring(key.Length, 1) == Rest.UrlPathSeparator);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} matching exception for path <{1}> : {2}", MsgId, path, e.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called by the HTTP server once the handler has indicated
|
||||
/// that it is able to handle the request.
|
||||
/// Preconditions:
|
||||
/// [1] request != null and is a valid request object
|
||||
/// [2] response != null and is a valid response object
|
||||
/// Behavior is undefined if preconditions are not satisfied.
|
||||
/// </summary>
|
||||
|
||||
public bool Handle(OSHttpRequest request, OSHttpResponse response)
|
||||
{
|
||||
bool handled;
|
||||
base.MsgID = base.RequestID;
|
||||
|
||||
// Debug only
|
||||
|
||||
if (Rest.DEBUG)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} ENTRY", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Agent: {1}", MsgId, request.UserAgent);
|
||||
Rest.Log.DebugFormat("{0} Method: {1}", MsgId, request.HttpMethod);
|
||||
|
||||
for (int i = 0; i < request.Headers.Count; i++)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Header [{1}] : <{2}> = <{3}>",
|
||||
MsgId, i, request.Headers.GetKey(i), request.Headers.Get(i));
|
||||
}
|
||||
Rest.Log.DebugFormat("{0} URI: {1}", MsgId, request.RawUrl);
|
||||
}
|
||||
|
||||
// If a path handler worked we're done, otherwise try any
|
||||
// available stream handlers too.
|
||||
|
||||
try
|
||||
{
|
||||
handled = (FindPathHandler(request, response) ||
|
||||
FindStreamHandler(request, response));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// A raw exception indicates that something we weren't expecting has
|
||||
// happened. This should always reflect a shortcoming in the plugin,
|
||||
// or a failure to satisfy the preconditions. It should not reflect
|
||||
// an error in the request itself. Under such circumstances the state
|
||||
// of the request cannot be determined and we are obliged to mark it
|
||||
// as 'handled'.
|
||||
|
||||
Rest.Log.ErrorFormat("{0} Plugin error: {1}", MsgId, e.Message);
|
||||
handled = true;
|
||||
}
|
||||
|
||||
Rest.Log.DebugFormat("{0} EXIT", MsgId);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
#endregion interface methods
|
||||
|
||||
/// <summary>
|
||||
/// If there is a stream handler registered that can handle the
|
||||
/// request, then fine. If the request is not matched, do
|
||||
/// nothing.
|
||||
/// Note: The selection is case-insensitive
|
||||
/// </summary>
|
||||
|
||||
private bool FindStreamHandler(OSHttpRequest request, OSHttpResponse response)
|
||||
{
|
||||
RequestData rdata = new RequestData(request, response, String.Empty);
|
||||
|
||||
string bestMatch = String.Empty;
|
||||
string path = String.Format("{0}:{1}", rdata.method, rdata.path).ToLower();
|
||||
|
||||
Rest.Log.DebugFormat("{0} Checking for stream handler for <{1}>", MsgId, path);
|
||||
|
||||
if (!IsEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (string pattern in streamHandlers.Keys)
|
||||
{
|
||||
if (path.StartsWith(pattern))
|
||||
{
|
||||
if (pattern.Length > bestMatch.Length)
|
||||
{
|
||||
bestMatch = pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle using the best match available
|
||||
|
||||
if (bestMatch.Length > 0)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Stream-based handler matched with <{1}>", MsgId, bestMatch);
|
||||
RestStreamHandler handler = streamHandlers[bestMatch];
|
||||
rdata.buffer = handler.Handle(rdata.path, rdata.request.InputStream, rdata.request, rdata.response);
|
||||
rdata.AddHeader(rdata.response.ContentType,handler.ContentType);
|
||||
rdata.Respond("FindStreamHandler Completion");
|
||||
}
|
||||
|
||||
return rdata.handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a stream handler for the designated HTTP method and path prefix.
|
||||
/// If the handler is not enabled, the request is ignored. If the path
|
||||
/// does not start with the REST prefix, it is added. If method-qualified
|
||||
/// path has not already been registered, the method is added to the active
|
||||
/// handler table.
|
||||
/// </summary>
|
||||
public void AddStreamHandler(string httpMethod, string path, RestMethod method)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!path.StartsWith(Rest.Prefix))
|
||||
{
|
||||
path = String.Format("{0}{1}", Rest.Prefix, path);
|
||||
}
|
||||
|
||||
path = String.Format("{0}{1}{2}", httpMethod, Rest.UrlMethodSeparator, path);
|
||||
|
||||
// Conditionally add to the list
|
||||
|
||||
if (!streamHandlers.ContainsKey(path))
|
||||
{
|
||||
streamHandlers.Add(path, new RestStreamHandler(httpMethod, path, method));
|
||||
Rest.Log.DebugFormat("{0} Added handler for {1}", MsgId, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Ignoring duplicate handler for {1}", MsgId, path);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given the supplied request/response, if the handler is enabled, the inbound
|
||||
/// information is used to match an entry in the active path handler tables, using
|
||||
/// the method-qualified path information. If a match is found, then the handler is
|
||||
/// invoked. The result is the boolean result of the handler, or false if no
|
||||
/// handler was located. The boolean indicates whether or not the request has been
|
||||
/// handled, not whether or not the request was successful - that information is in
|
||||
/// the response.
|
||||
/// Note: The selection process is case-insensitive
|
||||
/// </summary>
|
||||
|
||||
internal bool FindPathHandler(OSHttpRequest request, OSHttpResponse response)
|
||||
{
|
||||
RequestData rdata = null;
|
||||
string bestMatch = null;
|
||||
|
||||
if (!IsEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Conditionally add to the list
|
||||
|
||||
Rest.Log.DebugFormat("{0} Checking for path handler for <{1}>", MsgId, request.RawUrl);
|
||||
|
||||
foreach (string pattern in pathHandlers.Keys)
|
||||
{
|
||||
if (request.RawUrl.ToLower().StartsWith(pattern))
|
||||
{
|
||||
if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length)
|
||||
{
|
||||
bestMatch = pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(bestMatch))
|
||||
{
|
||||
rdata = pathAllocators[bestMatch](request, response, bestMatch);
|
||||
|
||||
Rest.Log.DebugFormat("{0} Path based REST handler matched with <{1}>", MsgId, bestMatch);
|
||||
|
||||
try
|
||||
{
|
||||
pathHandlers[bestMatch](rdata);
|
||||
}
|
||||
|
||||
// A plugin generated error indicates a request-related error
|
||||
// that has been handled by the plugin.
|
||||
|
||||
catch (RestException r)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Request failed: {1}", MsgId, r.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return (rdata == null) ? false : rdata.handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method handler and a request allocator are stored using the designated
|
||||
/// path as a key. If an entry already exists, it is replaced by the new one.
|
||||
/// </summary>
|
||||
|
||||
public void AddPathHandler(RestMethodHandler mh, string path, RestMethodAllocator ra)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (pathHandlers.ContainsKey(path))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Replacing handler for <${1}>", MsgId, path);
|
||||
pathHandlers.Remove(path);
|
||||
}
|
||||
|
||||
if (pathAllocators.ContainsKey(path))
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Replacing allocator for <${1}>", MsgId, path);
|
||||
pathAllocators.Remove(path);
|
||||
}
|
||||
|
||||
Rest.Log.DebugFormat("{0} Adding path handler for {1}", MsgId, path);
|
||||
|
||||
pathHandlers.Add(path, mh);
|
||||
pathAllocators.Add(path, ra);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,246 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
public class RestTestServices : IRest
|
||||
{
|
||||
private bool enabled = false;
|
||||
private string qPrefix = "test";
|
||||
|
||||
// A simple constructor is used to handle any once-only
|
||||
// initialization of working classes.
|
||||
|
||||
public RestTestServices()
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Test services initializing", MsgId);
|
||||
Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version);
|
||||
|
||||
// If a relative path was specified, make it absolute by adding
|
||||
// the standard prefix, e.g. /admin
|
||||
|
||||
if (!qPrefix.StartsWith(Rest.UrlPathSeparator))
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId);
|
||||
qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
|
||||
Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix);
|
||||
}
|
||||
|
||||
// Load test cases
|
||||
|
||||
loadTests();
|
||||
foreach (ITest test in tests)
|
||||
{
|
||||
test.Initialize();
|
||||
}
|
||||
|
||||
// Register interface
|
||||
|
||||
Rest.Plugin.AddPathHandler(DoTests,qPrefix,Allocate);
|
||||
|
||||
// Activate
|
||||
|
||||
enabled = true;
|
||||
|
||||
Rest.Log.InfoFormat("{0} Test services initialization complete", MsgId);
|
||||
}
|
||||
|
||||
// Post-construction, pre-enabled initialization opportunity
|
||||
// Not currently exploited.
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
// Called by the plug-in to halt REST processing. Local processing is
|
||||
// disabled, and control blocks until all current processing has
|
||||
// completed. No new processing will be started
|
||||
|
||||
public void Close()
|
||||
{
|
||||
enabled = false;
|
||||
foreach (ITest test in tests)
|
||||
{
|
||||
test.Close();
|
||||
}
|
||||
Rest.Log.InfoFormat("{0} Test services closing down", MsgId);
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
internal string MsgId
|
||||
{
|
||||
get { return Rest.MsgId; }
|
||||
}
|
||||
|
||||
#region Interface
|
||||
|
||||
private RequestData Allocate(OSHttpRequest request, OSHttpResponse response, string prefix)
|
||||
{
|
||||
return new RequestData(request, response, prefix);
|
||||
}
|
||||
|
||||
// Inventory Handler
|
||||
|
||||
private void DoTests(RequestData rdata)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
// Now that we know this is a serious attempt to
|
||||
// access inventory data, we should find out who
|
||||
// is asking, and make sure they are authorized
|
||||
// to do so. We need to validate the caller's
|
||||
// identity before revealing anything about the
|
||||
// status quo. Authenticate throws an exception
|
||||
// via Fail if no identity information is present.
|
||||
//
|
||||
// With the present HTTP server we can't use the
|
||||
// builtin authentication mechanisms because they
|
||||
// would be enforced for all in-bound requests.
|
||||
// Instead we look at the headers ourselves and
|
||||
// handle authentication directly.
|
||||
|
||||
try
|
||||
{
|
||||
if (!rdata.IsAuthenticated)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeNotAuthorized,
|
||||
String.Format("user \"{0}\" could not be authenticated", rdata.userName));
|
||||
}
|
||||
}
|
||||
catch (RestException e)
|
||||
{
|
||||
if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
throw (e);
|
||||
}
|
||||
|
||||
// Check that a test was specified
|
||||
|
||||
if (rdata.Parameters.Length < 1)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Insufficient parameters", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "not enough parameters");
|
||||
}
|
||||
|
||||
// Select the test
|
||||
|
||||
foreach (ITest test in tests)
|
||||
{
|
||||
if (!rdata.handled)
|
||||
test.Execute(rdata);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Interface
|
||||
|
||||
private static bool testsLoaded = false;
|
||||
private static List<Type> classes = new List<Type>();
|
||||
private static List<ITest> tests = new List<ITest>();
|
||||
private static Type[] parms = new Type[0];
|
||||
private static Object[] args = new Object[0];
|
||||
|
||||
static RestTestServices()
|
||||
{
|
||||
Module[] mods = Assembly.GetExecutingAssembly().GetModules();
|
||||
foreach (Module m in mods)
|
||||
{
|
||||
Type[] types = m.GetTypes();
|
||||
foreach (Type t in types)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (t.GetInterface("ITest") != null)
|
||||
{
|
||||
classes.Add(t);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.WarnFormat("[STATIC-TEST] Unable to include test {0} : {1}", t, e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This routine loads all of the handlers discovered during
|
||||
/// instance initialization. Each handler is responsible for
|
||||
/// registering itself with this handler.
|
||||
/// I was not able to make this code work in a constructor.
|
||||
/// </summary>
|
||||
|
||||
private void loadTests()
|
||||
{
|
||||
lock (tests)
|
||||
{
|
||||
if (!testsLoaded)
|
||||
{
|
||||
|
||||
ConstructorInfo ci;
|
||||
Object ht;
|
||||
|
||||
foreach (Type t in classes)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (t.GetInterface("ITest") != null)
|
||||
{
|
||||
ci = t.GetConstructor(parms);
|
||||
ht = ci.Invoke(args);
|
||||
tests.Add((ITest)ht);
|
||||
Rest.Log.InfoFormat("{0} Test {1} added", MsgId, t);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Unable to load test {1} : {2}", MsgId, t, e.Message);
|
||||
}
|
||||
}
|
||||
testsLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This interface represents the boundary between the general purpose
|
||||
/// REST plugin handling, and the functionally specific handlers. The
|
||||
/// handler knows only to initialzie and terminate all such handlers
|
||||
/// that it finds.
|
||||
/// </summary>
|
||||
|
||||
internal interface ITest
|
||||
{
|
||||
void Initialize();
|
||||
void Execute(RequestData rdata);
|
||||
void Close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
|
||||
{
|
||||
public class Remote : ITest
|
||||
{
|
||||
private static readonly int PARM_TESTID = 0;
|
||||
private static readonly int PARM_COMMAND = 1;
|
||||
|
||||
private static readonly int PARM_MOVE_AVATAR = 2;
|
||||
private static readonly int PARM_MOVE_X = 3;
|
||||
private static readonly int PARM_MOVE_Y = 4;
|
||||
private static readonly int PARM_MOVE_Z = 5;
|
||||
|
||||
private bool enabled = false;
|
||||
|
||||
// No constructor code is required.
|
||||
|
||||
public Remote()
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Remote services constructor", MsgId);
|
||||
}
|
||||
|
||||
// Post-construction, pre-enabled initialization opportunity
|
||||
// Not currently exploited.
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
enabled = true;
|
||||
Rest.Log.InfoFormat("{0} Remote services initialized", MsgId);
|
||||
}
|
||||
|
||||
// Called by the plug-in to halt REST processing. Local processing is
|
||||
// disabled, and control blocks until all current processing has
|
||||
// completed. No new processing will be started
|
||||
|
||||
public void Close()
|
||||
{
|
||||
enabled = false;
|
||||
Rest.Log.InfoFormat("{0} Remote services closing down", MsgId);
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
internal string MsgId
|
||||
{
|
||||
get { return Rest.MsgId; }
|
||||
}
|
||||
|
||||
// Remote Handler
|
||||
// Key information of interest here is the Parameters array, each
|
||||
// entry represents an element of the URI, with element zero being
|
||||
// the
|
||||
|
||||
public void Execute(RequestData rdata)
|
||||
{
|
||||
if (!enabled) return;
|
||||
|
||||
// If we can't relate to what's there, leave it for others.
|
||||
|
||||
if (rdata.Parameters.Length == 0 || rdata.Parameters[PARM_TESTID] != "remote")
|
||||
return;
|
||||
|
||||
Rest.Log.DebugFormat("{0} REST Remote handler ENTRY", MsgId);
|
||||
|
||||
// Remove the prefix and what's left are the parameters. If we don't have
|
||||
// the parameters we need, fail the request. Parameters do NOT include
|
||||
// any supplied query values.
|
||||
|
||||
if (rdata.Parameters.Length > 1)
|
||||
{
|
||||
switch (rdata.Parameters[PARM_COMMAND].ToLower())
|
||||
{
|
||||
case "move" :
|
||||
DoMove(rdata);
|
||||
break;
|
||||
default :
|
||||
DoHelp(rdata);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DoHelp(rdata);
|
||||
}
|
||||
}
|
||||
|
||||
private void DoHelp(RequestData rdata)
|
||||
{
|
||||
rdata.body = Help;
|
||||
rdata.Complete();
|
||||
rdata.Respond("Help");
|
||||
}
|
||||
|
||||
private void DoMove(RequestData rdata)
|
||||
{
|
||||
if (rdata.Parameters.Length < 6)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided");
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE);
|
||||
ScenePresence presence = null;
|
||||
Scene scene = null;
|
||||
|
||||
if (names.Length != 2)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,
|
||||
String.Format("invalid avatar name: <{0}>",rdata.Parameters[PARM_MOVE_AVATAR]));
|
||||
}
|
||||
|
||||
Rest.Log.WarnFormat("{0} '{1}' command received for {2} {3}",
|
||||
MsgId, rdata.Parameters[0], names[0], names[1]);
|
||||
|
||||
// The first parameter should be an avatar name, look for the
|
||||
// avatar in the known regions first.
|
||||
|
||||
Rest.main.SceneManager.ForEachScene(delegate(Scene s)
|
||||
{
|
||||
s.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
{
|
||||
if (sp.Firstname == names[0] && sp.Lastname == names[1])
|
||||
{
|
||||
scene = s;
|
||||
presence = sp;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (presence != null)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}",
|
||||
MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName);
|
||||
|
||||
try
|
||||
{
|
||||
float x = Convert.ToSingle(rdata.Parameters[PARM_MOVE_X]);
|
||||
float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]);
|
||||
float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]);
|
||||
Vector3 vector = new Vector3(x, y, z);
|
||||
presence.MoveToTarget(vector, false, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,
|
||||
String.Format("invalid parameters: {0}", e.Message));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,
|
||||
String.Format("avatar {0} not present", rdata.Parameters[PARM_MOVE_AVATAR]));
|
||||
}
|
||||
|
||||
rdata.Complete();
|
||||
rdata.Respond("OK");
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string Help =
|
||||
"<html>"
|
||||
+ "<head><title>Remote Command Usage</title></head>"
|
||||
+ "<body>"
|
||||
+ "<p>Supported commands are:</p>"
|
||||
+ "<dl>"
|
||||
+ "<dt>move/avatar-name/x/y/z</dt>"
|
||||
+ "<dd>moves the specified avatar to another location</dd>"
|
||||
+ "</dl>"
|
||||
+ "</body>"
|
||||
+ "</html>"
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
public partial class RestRegionPlugin : RestPlugin
|
||||
{
|
||||
#region GET methods
|
||||
public string GetHandler(string request, string path, string param,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// foreach (string h in httpRequest.Headers.AllKeys)
|
||||
// foreach (string v in httpRequest.Headers.GetValues(h))
|
||||
// m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v);
|
||||
|
||||
MsgID = RequestID;
|
||||
m_log.DebugFormat("{0} GET path {1} param {2}", MsgID, path, param);
|
||||
|
||||
try
|
||||
{
|
||||
// param empty: regions list
|
||||
if (String.IsNullOrEmpty(param)) return GetHandlerRegions(httpResponse);
|
||||
|
||||
// param not empty: specific region
|
||||
return GetHandlerRegion(httpResponse, param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "GET", e);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHandlerRegions(IOSHttpResponse httpResponse)
|
||||
{
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
rxw.WriteStartElement(String.Empty, "regions", String.Empty);
|
||||
foreach (Scene s in App.SceneManager.Scenes)
|
||||
{
|
||||
rxw.WriteStartElement(String.Empty, "uuid", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.RegionID.ToString());
|
||||
rxw.WriteEndElement();
|
||||
}
|
||||
rxw.WriteEndElement();
|
||||
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
protected string ShortRegionInfo(string key, string value)
|
||||
{
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
if (String.IsNullOrEmpty(value) ||
|
||||
String.IsNullOrEmpty(key)) return null;
|
||||
|
||||
rxw.WriteStartElement(String.Empty, "region", String.Empty);
|
||||
rxw.WriteStartElement(String.Empty, key, String.Empty);
|
||||
rxw.WriteString(value);
|
||||
rxw.WriteEndDocument();
|
||||
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
public string GetHandlerRegion(IOSHttpResponse httpResponse, string param)
|
||||
{
|
||||
// be resilient and don't get confused by a terminating '/'
|
||||
param = param.TrimEnd(new char[]{'/'});
|
||||
string[] comps = param.Split('/');
|
||||
UUID regionID = (UUID)comps[0];
|
||||
|
||||
m_log.DebugFormat("{0} GET region UUID {1}", MsgID, regionID.ToString());
|
||||
|
||||
if (UUID.Zero == regionID) throw new Exception("missing region ID");
|
||||
|
||||
Scene scene = null;
|
||||
App.SceneManager.TryGetScene(regionID, out scene);
|
||||
if (null == scene) return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound,
|
||||
"GET", "cannot find region {0}", regionID.ToString());
|
||||
|
||||
RegionDetails details = new RegionDetails(scene.RegionInfo);
|
||||
|
||||
// m_log.DebugFormat("{0} GET comps {1}", MsgID, comps.Length);
|
||||
// for (int i = 0; i < comps.Length; i++) m_log.DebugFormat("{0} GET comps[{1}] >{2}<", MsgID, i, comps[i]);
|
||||
|
||||
if (1 == comps.Length)
|
||||
{
|
||||
// complete region details requested
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
XmlSerializer xs = new XmlSerializer(typeof(RegionDetails));
|
||||
xs.Serialize(rxw, details, _xmlNs);
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
if (2 == comps.Length)
|
||||
{
|
||||
string resp = ShortRegionInfo(comps[1], details[comps[1]]);
|
||||
if (null != resp) return resp;
|
||||
|
||||
// m_log.DebugFormat("{0} GET comps advanced: >{1}<", MsgID, comps[1]);
|
||||
|
||||
// check for {terrain,stats,prims}
|
||||
switch (comps[1].ToLower())
|
||||
{
|
||||
case "terrain":
|
||||
return RegionTerrain(httpResponse, scene);
|
||||
|
||||
case "stats":
|
||||
return RegionStats(httpResponse, scene);
|
||||
|
||||
case "prims":
|
||||
return RegionPrims(httpResponse, scene, Vector3.Zero, Vector3.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
if (3 == comps.Length)
|
||||
{
|
||||
switch (comps[1].ToLower())
|
||||
{
|
||||
case "prims":
|
||||
string[] subregion = comps[2].Split(',');
|
||||
if (subregion.Length == 6)
|
||||
{
|
||||
Vector3 min, max;
|
||||
try
|
||||
{
|
||||
min = new Vector3((float)Double.Parse(subregion[0], Culture.NumberFormatInfo), (float)Double.Parse(subregion[1], Culture.NumberFormatInfo), (float)Double.Parse(subregion[2], Culture.NumberFormatInfo));
|
||||
max = new Vector3((float)Double.Parse(subregion[3], Culture.NumberFormatInfo), (float)Double.Parse(subregion[4], Culture.NumberFormatInfo), (float)Double.Parse(subregion[5], Culture.NumberFormatInfo));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest,
|
||||
"GET", "invalid subregion parameter");
|
||||
}
|
||||
return RegionPrims(httpResponse, scene, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest,
|
||||
"GET", "invalid subregion parameter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Failure(httpResponse, OSHttpStatusCode.ClientErrorBadRequest,
|
||||
"GET", "too many parameters {0}", param);
|
||||
}
|
||||
#endregion GET methods
|
||||
|
||||
protected string RegionTerrain(IOSHttpResponse httpResponse, Scene scene)
|
||||
{
|
||||
httpResponse.SendChunked = true;
|
||||
httpResponse.ContentType = "text/xml";
|
||||
|
||||
return scene.Heightmap.SaveToXmlString();
|
||||
//return Failure(httpResponse, OSHttpStatusCode.ServerErrorNotImplemented,
|
||||
// "GET", "terrain not implemented");
|
||||
}
|
||||
|
||||
protected string RegionStats(IOSHttpResponse httpResponse, Scene scene)
|
||||
{
|
||||
int users = scene.GetRootAgentCount();
|
||||
int objects = scene.Entities.Count - users;
|
||||
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
rxw.WriteStartElement(String.Empty, "region", String.Empty);
|
||||
rxw.WriteStartElement(String.Empty, "stats", String.Empty);
|
||||
|
||||
rxw.WriteStartElement(String.Empty, "users", String.Empty);
|
||||
rxw.WriteString(users.ToString());
|
||||
rxw.WriteEndElement();
|
||||
|
||||
rxw.WriteStartElement(String.Empty, "objects", String.Empty);
|
||||
rxw.WriteString(objects.ToString());
|
||||
rxw.WriteEndElement();
|
||||
|
||||
rxw.WriteEndDocument();
|
||||
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
protected string RegionPrims(IOSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max)
|
||||
{
|
||||
httpResponse.SendChunked = true;
|
||||
httpResponse.ContentType = "text/xml";
|
||||
|
||||
IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
|
||||
if (serialiser != null)
|
||||
serialiser.SavePrimsToXml2(scene, new StreamWriter(httpResponse.OutputStream), min, max);
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
public partial class RestRegionPlugin : RestPlugin
|
||||
{
|
||||
#region GET methods
|
||||
public string GetRegionInfoHandler(string request, string path, string param,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// foreach (string h in httpRequest.Headers.AllKeys)
|
||||
// foreach (string v in httpRequest.Headers.GetValues(h))
|
||||
// m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v);
|
||||
|
||||
MsgID = RequestID;
|
||||
m_log.DebugFormat("{0} GET path {1} param {2}", MsgID, path, param);
|
||||
|
||||
try
|
||||
{
|
||||
// param empty: regions list
|
||||
// if (String.IsNullOrEmpty(param))
|
||||
return GetRegionInfoHandlerRegions(httpResponse);
|
||||
|
||||
// // param not empty: specific region
|
||||
// return GetRegionInfoHandlerRegion(httpResponse, param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "GET", e);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetRegionInfoHandlerRegions(IOSHttpResponse httpResponse)
|
||||
{
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
// regions info
|
||||
rxw.WriteStartElement(String.Empty, "regions", String.Empty);
|
||||
{
|
||||
// regions info: number of regions
|
||||
rxw.WriteStartAttribute(String.Empty, "number", String.Empty);
|
||||
rxw.WriteValue(App.SceneManager.Scenes.Count);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
// regions info: max number of regions
|
||||
rxw.WriteStartAttribute(String.Empty, "max", String.Empty);
|
||||
if (App.ConfigSource.Source.Configs["RemoteAdmin"] != null)
|
||||
{
|
||||
rxw.WriteValue(App.ConfigSource.Source.Configs["RemoteAdmin"].GetInt("region_limit", -1));
|
||||
}
|
||||
else
|
||||
{
|
||||
rxw.WriteValue(-1);
|
||||
}
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
// regions info: region
|
||||
foreach (Scene s in App.SceneManager.Scenes)
|
||||
{
|
||||
rxw.WriteStartElement(String.Empty, "region", String.Empty);
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "uuid", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.RegionID.ToString());
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "name", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.RegionName);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "x", String.Empty);
|
||||
rxw.WriteValue(s.RegionInfo.RegionLocX);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "y", String.Empty);
|
||||
rxw.WriteValue(s.RegionInfo.RegionLocY);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "external_hostname", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.ExternalHostName);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "ip", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
int users = s.GetRootAgentCount();
|
||||
rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
|
||||
rxw.WriteValue(users);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "objects", String.Empty);
|
||||
rxw.WriteValue(s.Entities.Count - users);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
return rxw.ToString();
|
||||
}
|
||||
#endregion GET methods
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
public partial class RestRegionPlugin : RestPlugin
|
||||
{
|
||||
#region POST methods
|
||||
|
||||
public string PostHandler(string request, string path, string param,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// foreach (string h in httpRequest.Headers.AllKeys)
|
||||
// foreach (string v in httpRequest.Headers.GetValues(h))
|
||||
// m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v);
|
||||
|
||||
MsgID = RequestID;
|
||||
m_log.DebugFormat("{0} POST path {1} param {2}", MsgID, path, param);
|
||||
|
||||
try
|
||||
{
|
||||
// param empty: new region post
|
||||
if (!IsGod(httpRequest))
|
||||
// XXX: this needs to be turned into a FailureUnauthorized(...)
|
||||
return Failure(httpResponse, OSHttpStatusCode.ClientErrorUnauthorized,
|
||||
"GET", "you are not god");
|
||||
|
||||
if (String.IsNullOrEmpty(param)) return CreateRegion(httpRequest, httpResponse);
|
||||
|
||||
// Parse region ID and other parameters
|
||||
param = param.TrimEnd(new char[] {'/'});
|
||||
string[] comps = param.Split('/');
|
||||
UUID regionID = (UUID) comps[0];
|
||||
|
||||
m_log.DebugFormat("{0} POST region UUID {1}", MsgID, regionID.ToString());
|
||||
if (UUID.Zero == regionID) throw new Exception("missing region ID");
|
||||
|
||||
Scene scene = null;
|
||||
App.SceneManager.TryGetScene(regionID, out scene);
|
||||
if (null == scene)
|
||||
return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound,
|
||||
"POST", "cannot find region {0}", regionID.ToString());
|
||||
|
||||
if (2 == comps.Length)
|
||||
{
|
||||
// check for {prims}
|
||||
switch (comps[1].ToLower())
|
||||
{
|
||||
case "prims":
|
||||
return LoadPrims(request, httpRequest, httpResponse, scene);
|
||||
}
|
||||
}
|
||||
|
||||
return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound,
|
||||
"POST", "url {0} not supported", param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "POST", e);
|
||||
}
|
||||
}
|
||||
|
||||
public string CreateRegion(IOSHttpRequest request, IOSHttpResponse response)
|
||||
{
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
rxw.WriteStartElement(String.Empty, "regions", String.Empty);
|
||||
foreach (Scene s in App.SceneManager.Scenes)
|
||||
{
|
||||
rxw.WriteStartElement(String.Empty, "uuid", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.RegionID.ToString());
|
||||
rxw.WriteEndElement();
|
||||
}
|
||||
rxw.WriteEndElement();
|
||||
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
public string LoadPrims(string requestBody, IOSHttpRequest request, IOSHttpResponse response, Scene scene)
|
||||
{
|
||||
IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
|
||||
if (serialiser != null)
|
||||
serialiser.LoadPrimsFromXml2(scene, new StringReader(requestBody), true);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
#endregion POST methods
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
[XmlRoot(ElementName="region", IsNullable = false)]
|
||||
public class RegionDetails
|
||||
{
|
||||
public string region_name;
|
||||
public string region_id;
|
||||
public uint region_x;
|
||||
public uint region_y;
|
||||
public string region_owner;
|
||||
public string region_owner_id;
|
||||
public uint region_http_port;
|
||||
public uint region_port;
|
||||
public string region_server_uri;
|
||||
public string region_external_hostname;
|
||||
|
||||
public RegionDetails()
|
||||
{
|
||||
}
|
||||
|
||||
public RegionDetails(RegionInfo regInfo)
|
||||
{
|
||||
region_name = regInfo.RegionName;
|
||||
region_id = regInfo.RegionID.ToString();
|
||||
region_x = regInfo.RegionLocX;
|
||||
region_y = regInfo.RegionLocY;
|
||||
region_owner_id = regInfo.EstateSettings.EstateOwner.ToString();
|
||||
region_http_port = regInfo.HttpPort;
|
||||
region_server_uri = regInfo.ServerURI;
|
||||
region_external_hostname = regInfo.ExternalHostName;
|
||||
|
||||
Uri uri = new Uri(region_server_uri);
|
||||
region_port = (uint)uri.Port;
|
||||
}
|
||||
|
||||
public string this[string idx]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (idx.ToLower())
|
||||
{
|
||||
case "name":
|
||||
return region_name;
|
||||
case "id":
|
||||
return region_id;
|
||||
case "location":
|
||||
return String.Format("<x>{0}</x><y>{1}</y>", region_x, region_y);
|
||||
case "owner":
|
||||
return region_owner;
|
||||
case "owner_id":
|
||||
return region_owner_id;
|
||||
case "http_port":
|
||||
return region_http_port.ToString();
|
||||
case "server_uri":
|
||||
return region_server_uri;
|
||||
case "external_hostname":
|
||||
case "hostname":
|
||||
return region_external_hostname;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<Addin id="OpenSim.ApplicationPlugins.Rest.Regions" version="0.1">
|
||||
<Runtime>
|
||||
<Import assembly="OpenSim.ApplicationPlugins.Rest.Regions.dll"/>
|
||||
</Runtime>
|
||||
<Dependencies>
|
||||
<Addin id="OpenSim" version="0.5" />
|
||||
</Dependencies>
|
||||
<Extension path = "/OpenSim/Startup">
|
||||
<Plugin id="RestRegions" type="OpenSim.ApplicationPlugins.Rest.Regions.RestRegionPlugin" />
|
||||
</Extension>
|
||||
</Addin>
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
public partial class RestRegionPlugin : RestPlugin
|
||||
{
|
||||
private static XmlSerializerNamespaces _xmlNs;
|
||||
|
||||
static RestRegionPlugin()
|
||||
{
|
||||
_xmlNs = new XmlSerializerNamespaces();
|
||||
_xmlNs.Add(String.Empty, String.Empty);
|
||||
}
|
||||
|
||||
#region overriding properties
|
||||
public override string Name
|
||||
{
|
||||
get { return "REGION"; }
|
||||
}
|
||||
|
||||
public override string ConfigName
|
||||
{
|
||||
get { return "RestRegionPlugin"; }
|
||||
}
|
||||
#endregion overriding properties
|
||||
|
||||
#region overriding methods
|
||||
/// <summary>
|
||||
/// This method is called by OpenSimMain immediately after loading the
|
||||
/// plugin and after basic server setup, but before running any server commands.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that entries MUST be added to the active configuration files before
|
||||
/// the plugin can be enabled.
|
||||
/// </remarks>
|
||||
public override void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.Initialise(openSim);
|
||||
if (!IsEnabled)
|
||||
{
|
||||
//m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
|
||||
return;
|
||||
}
|
||||
|
||||
m_log.InfoFormat("{0} REST region plugin enabled", MsgID);
|
||||
|
||||
// add REST method handlers
|
||||
AddRestStreamHandler("GET", "/regions/", GetHandler);
|
||||
AddRestStreamHandler("POST", "/regions/", PostHandler);
|
||||
AddRestStreamHandler("GET", "/regioninfo/", GetRegionInfoHandler);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("{0} Initialization failed: {1}", MsgID, e.Message);
|
||||
m_log.DebugFormat("{0} Initialization failed: {1}", MsgID, e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
}
|
||||
#endregion overriding methods
|
||||
}
|
||||
}
|
||||
@@ -1,417 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest
|
||||
{
|
||||
public abstract class RestPlugin : IApplicationPlugin
|
||||
{
|
||||
#region properties
|
||||
|
||||
protected static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IConfig _config; // Configuration source: Rest Plugins
|
||||
private IConfig _pluginConfig; // Configuration source: Plugin specific
|
||||
private OpenSimBase _app; // The 'server'
|
||||
private BaseHttpServer _httpd; // The server's RPC interface
|
||||
private string _prefix; // URL prefix below
|
||||
// which all REST URLs
|
||||
// are living
|
||||
// private StringWriter _sw = null;
|
||||
// private RestXmlWriter _xw = null;
|
||||
|
||||
private string _godkey;
|
||||
private int _reqk;
|
||||
|
||||
[ThreadStatic]
|
||||
private static string _threadRequestID = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Return an ever increasing request ID for logging
|
||||
/// </summary>
|
||||
protected string RequestID
|
||||
{
|
||||
get { return _reqk++.ToString(); }
|
||||
set { _reqk = Convert.ToInt32(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thread-constant message IDs for logging.
|
||||
/// </summary>
|
||||
protected string MsgID
|
||||
{
|
||||
get { return String.Format("[REST-{0}] #{1}", Name, _threadRequestID); }
|
||||
set { _threadRequestID = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if Rest Plugins are enabled.
|
||||
/// </summary>
|
||||
public bool PluginsAreEnabled
|
||||
{
|
||||
get { return null != _config; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if specific Rest Plugin is enabled.
|
||||
/// </summary>
|
||||
public bool IsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (null != _pluginConfig) && _pluginConfig.GetBoolean("enabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OpenSimMain application
|
||||
/// </summary>
|
||||
public OpenSimBase App
|
||||
{
|
||||
get { return _app; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RPC server
|
||||
/// </summary>
|
||||
public BaseHttpServer HttpServer
|
||||
{
|
||||
get { return _httpd; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL prefix to use for all REST handlers
|
||||
/// </summary>
|
||||
public string Prefix
|
||||
{
|
||||
get { return _prefix; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Access to GOD password string
|
||||
/// </summary>
|
||||
protected string GodKey
|
||||
{
|
||||
get { return _godkey; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration of the plugin
|
||||
/// </summary>
|
||||
public IConfig Config
|
||||
{
|
||||
get { return _pluginConfig; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the plugin
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Return the config section name
|
||||
/// </summary>
|
||||
public abstract string ConfigName { get; }
|
||||
|
||||
// public XmlTextWriter XmlWriter
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (null == _xw)
|
||||
// {
|
||||
// _sw = new StringWriter();
|
||||
// _xw = new RestXmlWriter(_sw);
|
||||
// _xw.Formatting = Formatting.Indented;
|
||||
// }
|
||||
// return _xw;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public string XmlWriterResult
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// _xw.Flush();
|
||||
// _xw.Close();
|
||||
// _xw = null;
|
||||
|
||||
// return _sw.ToString();
|
||||
// }
|
||||
// }
|
||||
|
||||
#endregion properties
|
||||
|
||||
#region methods
|
||||
|
||||
// TODO: required by IPlugin, but likely not at all right
|
||||
private string m_version = "0.0";
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return m_version; }
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Info("[RESTPLUGIN]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by OpenSimMain immediately after loading the
|
||||
/// plugin and after basic server setup, but before running any server commands.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that entries MUST be added to the active configuration files before
|
||||
/// the plugin can be enabled.
|
||||
/// </remarks>
|
||||
public virtual void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
RequestID = "0";
|
||||
MsgID = RequestID;
|
||||
|
||||
try
|
||||
{
|
||||
if ((_config = openSim.ConfigSource.Source.Configs["RestPlugins"]) == null)
|
||||
{
|
||||
m_log.WarnFormat("{0} Rest Plugins not configured", MsgID);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_config.GetBoolean("enabled", false))
|
||||
{
|
||||
//m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
|
||||
return;
|
||||
}
|
||||
|
||||
_app = openSim;
|
||||
_httpd = openSim.HttpServer;
|
||||
|
||||
// Retrieve GOD key value, if any.
|
||||
_godkey = _config.GetString("god_key", String.Empty);
|
||||
|
||||
// Retrive prefix if any.
|
||||
_prefix = _config.GetString("prefix", "/admin");
|
||||
|
||||
// Get plugin specific config
|
||||
_pluginConfig = openSim.ConfigSource.Source.Configs[ConfigName];
|
||||
|
||||
m_log.InfoFormat("{0} Rest Plugins Enabled", MsgID);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// we can safely ignore this, as it just means that
|
||||
// the key lookup in Configs failed, which signals to
|
||||
// us that noone is interested in our services...they
|
||||
// don't know what they are missing out on...
|
||||
// NOTE: Under the present OpenSimulator implementation it is
|
||||
// not possible for the openSimulator pointer to be null. However
|
||||
// were the implementation to be changed, this could
|
||||
// result in a silent initialization failure. Harmless
|
||||
// except for lack of function and lack of any
|
||||
// diagnostic indication as to why. The same is true if
|
||||
// the HTTP server reference is bad.
|
||||
// We should at least issue a message...
|
||||
m_log.WarnFormat("{0} Initialization failed: {1}", MsgID, e.Message);
|
||||
m_log.DebugFormat("{0} Initialization failed: {1}", MsgID, e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
private List<RestStreamHandler> _handlers = new List<RestStreamHandler>();
|
||||
private Dictionary<string, IHttpAgentHandler> _agents = new Dictionary<string, IHttpAgentHandler>();
|
||||
|
||||
/// <summary>
|
||||
/// Add a REST stream handler to the underlying HTTP server.
|
||||
/// </summary>
|
||||
/// <param name="httpMethod">GET/PUT/POST/DELETE or
|
||||
/// similar</param>
|
||||
/// <param name="path">URL prefix</param>
|
||||
/// <param name="method">RestMethod handler doing the actual work</param>
|
||||
public virtual void AddRestStreamHandler(string httpMethod, string path, RestMethod method)
|
||||
{
|
||||
if (!IsEnabled) return;
|
||||
|
||||
if (!path.StartsWith(_prefix))
|
||||
{
|
||||
path = String.Format("{0}{1}", _prefix, path);
|
||||
}
|
||||
|
||||
RestStreamHandler h = new RestStreamHandler(httpMethod, path, method);
|
||||
_httpd.AddStreamHandler(h);
|
||||
_handlers.Add(h);
|
||||
|
||||
m_log.DebugFormat("{0} Added REST handler {1} {2}", MsgID, httpMethod, path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a powerful Agent handler to the underlying HTTP
|
||||
/// server.
|
||||
/// </summary>
|
||||
/// <param name="agentName">name of agent handler</param>
|
||||
/// <param name="handler">agent handler method</param>
|
||||
/// <returns>false when the plugin is disabled or the agent
|
||||
/// handler could not be added. Any generated exceptions are
|
||||
/// allowed to drop through to the caller, i.e. ArgumentException.
|
||||
/// </returns>
|
||||
public bool AddAgentHandler(string agentName, IHttpAgentHandler handler)
|
||||
{
|
||||
if (!IsEnabled) return false;
|
||||
_agents.Add(agentName, handler);
|
||||
// return _httpd.AddAgentHandler(agentName, handler);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a powerful Agent handler from the underlying HTTP
|
||||
/// server.
|
||||
/// </summary>
|
||||
/// <param name="agentName">name of agent handler</param>
|
||||
/// <param name="handler">agent handler method</param>
|
||||
/// <returns>false when the plugin is disabled or the agent
|
||||
/// handler could not be removed. Any generated exceptions are
|
||||
/// allowed to drop through to the caller, i.e. KeyNotFound.
|
||||
/// </returns>
|
||||
public bool RemoveAgentHandler(string agentName, IHttpAgentHandler handler)
|
||||
{
|
||||
if (!IsEnabled) return false;
|
||||
if (_agents[agentName] == handler)
|
||||
{
|
||||
_agents.Remove(agentName);
|
||||
// return _httpd.RemoveAgentHandler(agentName, handler);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the HTTP request came from god; that is, is
|
||||
/// the god_key as configured in the config section supplied
|
||||
/// via X-OpenSim-Godkey?
|
||||
/// </summary>
|
||||
/// <param name="request">HTTP request header</param>
|
||||
/// <returns>true when the HTTP request came from god.</returns>
|
||||
protected bool IsGod(IOSHttpRequest request)
|
||||
{
|
||||
string[] keys = request.Headers.GetValues("X-OpenSim-Godkey");
|
||||
if (null == keys) return false;
|
||||
|
||||
// we take the last key supplied
|
||||
return keys[keys.Length - 1] == _godkey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks wether the X-OpenSim-Password value provided in the
|
||||
/// HTTP header is indeed the password on file for the avatar
|
||||
/// specified by the UUID
|
||||
/// </summary>
|
||||
protected bool IsVerifiedUser(IOSHttpRequest request, UUID uuid)
|
||||
{
|
||||
// XXX under construction
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up and remove all handlers that were added earlier.
|
||||
/// </summary>
|
||||
public virtual void Close()
|
||||
{
|
||||
foreach (RestStreamHandler h in _handlers)
|
||||
{
|
||||
_httpd.RemoveStreamHandler(h.HttpMethod, h.Path);
|
||||
}
|
||||
_handlers = null;
|
||||
// foreach (KeyValuePair<string, IHttpAgentHandler> h in _agents)
|
||||
// {
|
||||
// _httpd.RemoveAgentHandler(h.Key, h.Value);
|
||||
// }
|
||||
_agents = null;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a failure message.
|
||||
/// </summary>
|
||||
/// <param name="method">origin of the failure message</param>
|
||||
/// <param name="message">failure message</param>
|
||||
/// <remarks>This should probably set a return code as
|
||||
/// well. (?)</remarks>
|
||||
protected string Failure(IOSHttpResponse response, OSHttpStatusCode status,
|
||||
string method, string format, params string[] msg)
|
||||
{
|
||||
string m = String.Format(format, msg);
|
||||
|
||||
response.StatusCode = (int) status;
|
||||
response.StatusDescription = m;
|
||||
|
||||
m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, m);
|
||||
return String.Format("<error>{0}</error>", m);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a failure message.
|
||||
/// </summary>
|
||||
/// <param name="method">origin of the failure message</param>
|
||||
/// <param name="e">exception causing the failure message</param>
|
||||
/// <remarks>This should probably set a return code as
|
||||
/// well. (?)</remarks>
|
||||
public string Failure(IOSHttpResponse response, OSHttpStatusCode status,
|
||||
string method, Exception e)
|
||||
{
|
||||
string m = String.Format("exception occurred: {0}", e.Message);
|
||||
|
||||
response.StatusCode = (int) status;
|
||||
response.StatusDescription = m;
|
||||
|
||||
m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString());
|
||||
m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, e.Message);
|
||||
|
||||
return String.Format("<error>{0}</error>", e.Message);
|
||||
}
|
||||
|
||||
#endregion methods
|
||||
}
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
|
||||
<xsd:annotation>
|
||||
<xsd:documentation xml:lang="en">
|
||||
Open Simulator Export/Import XML schema
|
||||
August 2008
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<!-- WARNING!!!
|
||||
This is currently a draft, it does not reflect
|
||||
what is exported, nor what will be understood
|
||||
on import. It is included as a working document
|
||||
and this comment will be removed at such time as
|
||||
the schema corresponds to reality.
|
||||
-->
|
||||
|
||||
<!--
|
||||
REST-related information
|
||||
Inventory data is always framed by an
|
||||
inventory element. Consists of zero or
|
||||
more elements representing either folders
|
||||
or items within those folders. The inventory
|
||||
element represents the "real" root folder.
|
||||
-->
|
||||
|
||||
<xsd:element name="inventory" type="inventory_ct" />
|
||||
|
||||
<!--
|
||||
The inventory complex type is just an arbitrary
|
||||
sequence of folders and items. In reality it is
|
||||
typically just folders. Both item and folder
|
||||
have corresponding complex types. It is distinct
|
||||
from folders insofar as it has no other defining
|
||||
attributes.
|
||||
-->
|
||||
|
||||
<xsd:complexType name="inventory_ct">
|
||||
<xsd:element name="folder" type="folder_ct" maxOccurs="unbounded"/>
|
||||
<xsd:element name="item" type="item_ct" maxOccurs="unbounded" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="folder_ct">
|
||||
<xsd:attribute name="UUID" type="uuid_st" />
|
||||
<xsd:attribute name="name" type="name_st" />
|
||||
<xsd:attribute name="type" type="folder_type_st" />
|
||||
<xsd:attribute name="description" type="xsd:string" /> <!-- added -->
|
||||
<xsd:attribute name="version" type="unsignedShort" />
|
||||
<xsd:attribute name="owner" type="uuid_st" />
|
||||
|
||||
<xsd:attribute name="creator" type="uuid_st" /> <!-- added -->
|
||||
<xsd:attribute name="creationdate" type="date_st" /> <!-- added -->
|
||||
|
||||
<xsd:attribute name="parent" type="uuid_st" />
|
||||
|
||||
<xsd:element name="permissions" type="permissions_ct" maxOccurs="unbounded" /> <!-- added -->
|
||||
<xsd:element name="folder" type="folder_ct" maxOccurs="unbounded" />
|
||||
<xsd:element name="item" type="item_ct" maxOccurs="unbounded" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="item_ct">
|
||||
<xsd:attribute name="UUID" type="uuid_st" />
|
||||
<xsd:attribute name="name" type="name_st" />
|
||||
<xsd:attribute name="type" type="inventory_type_st" />
|
||||
<xsd:attribute name="description" type="xsd:string" />
|
||||
<xsd:attribute name="version" type="unsignedShort" /> <!-- added -->
|
||||
<xsd:attribute name="owner" type="uuid_st" />
|
||||
|
||||
<xsd:attribute name="creator" type="uuid_st" />
|
||||
<xsd:attribute name="creationdate" type="date_st" />
|
||||
|
||||
<xsd:attribute name="folder" type="uuid_st" />
|
||||
<xsd:attribute name="groupid" type="uuid_st" />
|
||||
<xsd:attribute name="groupowned" type="xsd:boolean" />
|
||||
<xsd:attribute name="saletype" type="sale_st" />
|
||||
<xsd:attribute name="saleprice" type="xsd:decimal" />
|
||||
|
||||
<xsd:element name="permissions" type="permissions_ct" maxOccurs="unbounded" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="asset_ct">
|
||||
<xsd:attribute name="UUID" type="uuid_st" />
|
||||
<xsd:attribute name="name" type="name_st" />
|
||||
<xsd:attribute name="type" type="asset_type_st" />
|
||||
<xsd:attribute name="description" type="xsd:string" />
|
||||
<xsd:attribute name="version" type="unsignedShort" /> <!-- added -->
|
||||
<xsd:attribute name="owner" type="uuid_st" />
|
||||
|
||||
<xsd:attribute name="creator" type="uuid_st" />
|
||||
<xsd:attribute name="creationdate" type="date_st" />
|
||||
|
||||
<xsd:attribute name="temporary" type="xsd:boolean" />
|
||||
<xsd:attribute name="local" type="xsd:boolean" />
|
||||
<xsd:attribute name="inline" type="xsd:boolean" />
|
||||
</xsd:complexType>
|
||||
|
||||
<!-- Constrained Simple Data types -->
|
||||
|
||||
<!--
|
||||
We need to specify name as a simple type because on
|
||||
some platforms it is constrained by a certain length
|
||||
limitation. For completeness we indicate that whitespace
|
||||
should be preserved exactly as specified.
|
||||
-->
|
||||
|
||||
<xsd:simpleType name="name_st">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<whiteSpace value="preserve" />
|
||||
<minLength value="0" />
|
||||
<maxLength value="64" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<!--
|
||||
Type information in the folder is meant to indicate
|
||||
the preferred asset type for this folder. As such, that
|
||||
currently corresponds to the type values allowed for
|
||||
assets, however that is not mandated, so for
|
||||
now at least I'll represent this as a distinct
|
||||
enumeration.
|
||||
This seems inappropriate; it seems like the folder's
|
||||
content should reflect the InventoryType classifications
|
||||
rather than the asset types.
|
||||
-->
|
||||
|
||||
<xsd:simpleType name="folder_type_st">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="Texture" />
|
||||
<xsd:enumeration value="Sound" />
|
||||
<xsd:enumeration value="CallingCard" />
|
||||
<xsd:enumeration value="Landmark" />
|
||||
<xsd:enumeration value="Script" />
|
||||
<xsd:enumeration value="Clothing" />
|
||||
<xsd:enumeration value="Object" />
|
||||
<xsd:enumeration value="Notecard" />
|
||||
<xsd:enumeration value="LSLText" />
|
||||
<xsd:enumeration value="LSLByteCode" />
|
||||
<xsd:enumeration value="TextureTGA" />
|
||||
<xsd:enumeration value="BodyPart" />
|
||||
<xsd:enumeration value="SoundWAV" />
|
||||
<xsd:enumeration value="ImageTGA" />
|
||||
<xsd:enumeration value="ImageJPEG" />
|
||||
<xsd:enumeration value="Animation" />
|
||||
<xsd:enumeration value="Gesture" />
|
||||
<xsd:enumeration value="Simstate" />
|
||||
<xsd:enumeration value="Unknown" />
|
||||
<xsd:enumeration value="LostAndFoundFolder" />
|
||||
<xsd:enumeration value="SnapshotFolder" />
|
||||
<xsd:enumeration value="TrashFolder" />
|
||||
<xsd:enumeration value="Folder" />
|
||||
<xsd:enumeration value="RootFolder" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<!--
|
||||
Inventory item type designates an asset class, rather
|
||||
than a specific asset type. For example, "SnapShot"
|
||||
might include a number of asset types such as JPEG,
|
||||
TGA, etc.. This is not a consistent interpretation,
|
||||
classifications such as LostAndFound are meta-types
|
||||
relative to asset classes.
|
||||
|
||||
These types should be abstract and not be tied to a
|
||||
specific platform. A world's import facility should be
|
||||
responsible for mapping these to meaningful internal
|
||||
representations.
|
||||
|
||||
These types were based on information in:
|
||||
libsecondlife/InventoryManager.cs
|
||||
-->
|
||||
|
||||
<xsd:simpleType name="inventory_type_st">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="Texture" />
|
||||
<xsd:enumeration value="Sound" />
|
||||
<xsd:enumeration value="CallingCard" />
|
||||
<xsd:enumeration value="Landmark" />
|
||||
<xsd:enumeration value="Script" />
|
||||
<xsd:enumeration value="Clothing" />
|
||||
<xsd:enumeration value="Object" />
|
||||
<xsd:enumeration value="Notecard" />
|
||||
<xsd:enumeration value="LSL" />
|
||||
<xsd:enumeration value="LSLBytecode" />
|
||||
<xsd:enumeration value="TextureTGA" />
|
||||
<xsd:enumeration value="BodyPart" />
|
||||
<xsd:enumeration value="Snapshot" />
|
||||
<xsd:enumeration value="Attachment" />
|
||||
<xsd:enumeration value="Wearable" />
|
||||
<xsd:enumeration value="Animation" />
|
||||
<xsd:enumeration value="Gesture" />
|
||||
<xsd:enumeration value="Folder" />
|
||||
<xsd:enumeration value="Unknown" />
|
||||
<xsd:enumeration value="LostAndFound" />
|
||||
<xsd:enumeration value="Trash" />
|
||||
<xsd:enumeration value="Root" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<!--
|
||||
The asset types seem to be even more disarrayed than
|
||||
the inventory types. It seems to be little more than
|
||||
a reiteration of the inventory type information,
|
||||
which adds little or nothing to the overall data
|
||||
model.
|
||||
|
||||
Of course, given that these are drawn from the
|
||||
libsecondlife definitions, we aren't at liberty to
|
||||
simply redefine them in place. But the XML definitions
|
||||
here could be made more useful.
|
||||
|
||||
These types were based on information in:
|
||||
libsecondlife/AssetManager.cs
|
||||
-->
|
||||
|
||||
<xsd:simpleType name="asset_type_st">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="Texture" />
|
||||
<xsd:enumeration value="Sound" />
|
||||
<xsd:enumeration value="CallingCard" />
|
||||
<xsd:enumeration value="Landmark" />
|
||||
<xsd:enumeration value="Script" />
|
||||
<xsd:enumeration value="Clothing" />
|
||||
<xsd:enumeration value="Object" />
|
||||
<xsd:enumeration value="Notecard" />
|
||||
<xsd:enumeration value="LSLText" />
|
||||
<xsd:enumeration value="LSLByteCode" />
|
||||
<xsd:enumeration value="TextureTGA" />
|
||||
<xsd:enumeration value="BodyPart" />
|
||||
<xsd:enumeration value="SoundWAV" />
|
||||
<xsd:enumeration value="ImageTGA" />
|
||||
<xsd:enumeration value="ImageJPEG" />
|
||||
<xsd:enumeration value="Animation" />
|
||||
<xsd:enumeration value="Gesture" />
|
||||
<xsd:enumeration value="Simstate" />
|
||||
<xsd:enumeration value="Unknown" />
|
||||
<xsd:enumeration value="LostAndFoundFolder" />
|
||||
<xsd:enumeration value="SnapshotFolder" />
|
||||
<xsd:enumeration value="TrashFolder" />
|
||||
<xsd:enumeration value="Folder" />
|
||||
<xsd:enumeration value="RootFolder" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<!-- This is describing the apparent form of a UUID. If
|
||||
we ever want a more metaphysical definition we'll
|
||||
need to add to it.
|
||||
-->
|
||||
|
||||
<xsd:simpleType name="uuid_st">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:pattern value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<!-- This constrains the date representation. Currently
|
||||
it is simply an integer representing the elapsed
|
||||
?? since ??.
|
||||
-->
|
||||
|
||||
<xsd:simpleType name="date_st">
|
||||
<xsd:restriction base="xsd:positiveInteger">
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<!-- This constrains the representation of sale price.
|
||||
Currently it is a simple decimal with no unit
|
||||
specified.
|
||||
Issues: interoperability.
|
||||
-->
|
||||
|
||||
<xsd:simpleType name="sale_st">
|
||||
<xsd:restriction base="xsd:decimal">
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
</xsd:schema>
|
||||
@@ -63,7 +63,11 @@ namespace OpenSim.Framework.Capabilities
|
||||
public string CapsObjectPath { get { return m_capsObjectPath; } }
|
||||
|
||||
private CapsHandlers m_capsHandlers;
|
||||
private Dictionary<string, string> m_externalCapsHandlers;
|
||||
|
||||
private Dictionary<string, PollServiceEventArgs> m_pollServiceHandlers
|
||||
= new Dictionary<string, PollServiceEventArgs>();
|
||||
|
||||
private Dictionary<string, string> m_externalCapsHandlers = new Dictionary<string, string>();
|
||||
|
||||
private IHttpServer m_httpListener;
|
||||
private UUID m_agentID;
|
||||
@@ -132,7 +136,6 @@ namespace OpenSim.Framework.Capabilities
|
||||
|
||||
m_agentID = agent;
|
||||
m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL);
|
||||
m_externalCapsHandlers = new Dictionary<string, string>();
|
||||
m_regionName = regionName;
|
||||
}
|
||||
|
||||
@@ -143,8 +146,29 @@ namespace OpenSim.Framework.Capabilities
|
||||
/// <param name="handler"></param>
|
||||
public void RegisterHandler(string capName, IRequestHandler handler)
|
||||
{
|
||||
m_capsHandlers[capName] = handler;
|
||||
//m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path);
|
||||
m_capsHandlers[capName] = handler;
|
||||
}
|
||||
|
||||
public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler)
|
||||
{
|
||||
m_pollServiceHandlers.Add(capName, pollServiceHandler);
|
||||
|
||||
m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler.Url, pollServiceHandler);
|
||||
|
||||
// uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
|
||||
// string protocol = "http";
|
||||
// string hostName = m_httpListenerHostName;
|
||||
//
|
||||
// if (MainServer.Instance.UseSSL)
|
||||
// {
|
||||
// hostName = MainServer.Instance.SSLCommonName;
|
||||
// port = MainServer.Instance.SSLPort;
|
||||
// protocol = "https";
|
||||
// }
|
||||
|
||||
// RegisterHandler(
|
||||
// capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -163,13 +187,70 @@ namespace OpenSim.Framework.Capabilities
|
||||
/// </summary>
|
||||
public void DeregisterHandlers()
|
||||
{
|
||||
if (m_capsHandlers != null)
|
||||
foreach (string capsName in m_capsHandlers.Caps)
|
||||
{
|
||||
foreach (string capsName in m_capsHandlers.Caps)
|
||||
{
|
||||
m_capsHandlers.Remove(capsName);
|
||||
}
|
||||
m_capsHandlers.Remove(capsName);
|
||||
}
|
||||
|
||||
foreach (PollServiceEventArgs handler in m_pollServiceHandlers.Values)
|
||||
{
|
||||
m_httpListener.RemovePollServiceHTTPHandler("", handler.Url);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetPollHandler(string name, out PollServiceEventArgs pollHandler)
|
||||
{
|
||||
return m_pollServiceHandlers.TryGetValue(name, out pollHandler);
|
||||
}
|
||||
|
||||
public Dictionary<string, PollServiceEventArgs> GetPollHandlers()
|
||||
{
|
||||
return new Dictionary<string, PollServiceEventArgs>(m_pollServiceHandlers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return an LLSD-serializable Hashtable describing the
|
||||
/// capabilities and their handler details.
|
||||
/// </summary>
|
||||
/// <param name="excludeSeed">If true, then exclude the seed cap.</param>
|
||||
public Hashtable GetCapsDetails(bool excludeSeed, List<string> requestedCaps)
|
||||
{
|
||||
Hashtable caps = CapsHandlers.GetCapsDetails(excludeSeed, requestedCaps);
|
||||
|
||||
lock (m_pollServiceHandlers)
|
||||
{
|
||||
foreach (KeyValuePair <string, PollServiceEventArgs> kvp in m_pollServiceHandlers)
|
||||
{
|
||||
if (!requestedCaps.Contains(kvp.Key))
|
||||
continue;
|
||||
|
||||
string hostName = m_httpListenerHostName;
|
||||
uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
|
||||
string protocol = "http";
|
||||
|
||||
if (MainServer.Instance.UseSSL)
|
||||
{
|
||||
hostName = MainServer.Instance.SSLCommonName;
|
||||
port = MainServer.Instance.SSLPort;
|
||||
protocol = "https";
|
||||
}
|
||||
//
|
||||
// caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
|
||||
|
||||
caps[kvp.Key] = string.Format("{0}://{1}:{2}{3}", protocol, hostName, port, kvp.Value.Url);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the external too
|
||||
foreach (KeyValuePair<string, string> kvp in ExternalCapsHandlers)
|
||||
{
|
||||
if (!requestedCaps.Contains(kvp.Key))
|
||||
continue;
|
||||
|
||||
caps[kvp.Key] = kvp.Value;
|
||||
}
|
||||
|
||||
return caps;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Capabilities
|
||||
/// </summary>
|
||||
public class CapsHandlers
|
||||
{
|
||||
private Dictionary <string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
|
||||
private Dictionary<string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
|
||||
private IHttpServer m_httpListener;
|
||||
private string m_httpListenerHostName;
|
||||
private uint m_httpListenerPort;
|
||||
@@ -158,7 +158,7 @@ namespace OpenSim.Framework.Capabilities
|
||||
/// capabilities and their handler details.
|
||||
/// </summary>
|
||||
/// <param name="excludeSeed">If true, then exclude the seed cap.</param>
|
||||
public Hashtable GetCapsDetails(bool excludeSeed)
|
||||
public Hashtable GetCapsDetails(bool excludeSeed, List<string> requestedCaps)
|
||||
{
|
||||
Hashtable caps = new Hashtable();
|
||||
string protocol = "http://";
|
||||
@@ -175,11 +175,26 @@ namespace OpenSim.Framework.Capabilities
|
||||
if (excludeSeed && "SEED" == capsName)
|
||||
continue;
|
||||
|
||||
if (requestedCaps != null && !requestedCaps.Contains(capsName))
|
||||
continue;
|
||||
|
||||
caps[capsName] = baseUrl + m_capsHandlers[capsName].Path;
|
||||
}
|
||||
}
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the dictionary of all the HTTP cap handlers
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The dictionary copy. The key is the capability name, the value is the HTTP handler.
|
||||
/// </returns>
|
||||
public Dictionary<string, IRequestHandler> GetCapsHandlers()
|
||||
{
|
||||
lock (m_capsHandlers)
|
||||
return new Dictionary<string, IRequestHandler>(m_capsHandlers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
//using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class AvatarPickerSearchHandler : BaseStreamHandler
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private IPeople m_PeopleService;
|
||||
|
||||
public AvatarPickerSearchHandler(string path, IPeople peopleService, string name, string description)
|
||||
: base("GET", path, name, description)
|
||||
{
|
||||
m_PeopleService = peopleService;
|
||||
}
|
||||
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Try to parse the texture ID from the request URL
|
||||
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
|
||||
string names = query.GetOne("names");
|
||||
string psize = query.GetOne("page_size");
|
||||
string pnumber = query.GetOne("page");
|
||||
|
||||
if (m_PeopleService == null)
|
||||
return FailureResponse(names, (int)System.Net.HttpStatusCode.InternalServerError, httpResponse);
|
||||
|
||||
if (string.IsNullOrEmpty(names) || names.Length < 3)
|
||||
return FailureResponse(names, (int)System.Net.HttpStatusCode.BadRequest, httpResponse);
|
||||
|
||||
m_log.DebugFormat("[AVATAR PICKER SEARCH]: search for {0}", names);
|
||||
|
||||
int page_size = (string.IsNullOrEmpty(psize) ? 500 : Int32.Parse(psize));
|
||||
int page_number = (string.IsNullOrEmpty(pnumber) ? 1 : Int32.Parse(pnumber));
|
||||
|
||||
// Full content request
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
|
||||
//httpResponse.ContentLength = ??;
|
||||
httpResponse.ContentType = "application/llsd+xml";
|
||||
|
||||
List<UserData> users = m_PeopleService.GetUserData(names, page_size, page_number);
|
||||
|
||||
LLSDAvatarPicker osdReply = new LLSDAvatarPicker();
|
||||
osdReply.next_page_url = httpRequest.RawUrl;
|
||||
foreach (UserData u in users)
|
||||
osdReply.agents.Array.Add(ConvertUserData(u));
|
||||
|
||||
string reply = LLSDHelpers.SerialiseLLSDReply(osdReply);
|
||||
return System.Text.Encoding.UTF8.GetBytes(reply);
|
||||
}
|
||||
|
||||
private LLSDPerson ConvertUserData(UserData user)
|
||||
{
|
||||
LLSDPerson p = new LLSDPerson();
|
||||
p.legacy_first_name = user.FirstName;
|
||||
p.legacy_last_name = user.LastName;
|
||||
p.display_name = user.FirstName + " " + user.LastName;
|
||||
if (user.LastName.StartsWith("@"))
|
||||
p.username = user.FirstName.ToLower() + user.LastName.ToLower();
|
||||
else
|
||||
p.username = user.FirstName.ToLower() + "." + user.LastName.ToLower();
|
||||
p.id = user.Id;
|
||||
p.is_display_name_default = false;
|
||||
return p;
|
||||
}
|
||||
|
||||
private byte[] FailureResponse(string names, int statuscode, IOSHttpResponse httpResponse)
|
||||
{
|
||||
m_log.Error("[AVATAR PICKER SEARCH]: Error searching for " + names);
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
|
||||
return System.Text.Encoding.UTF8.GetBytes(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class FetchInventory2Handler
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IInventoryService m_inventoryService;
|
||||
|
||||
@@ -121,4 +121,4 @@ namespace OpenSim.Capabilities.Handlers
|
||||
return llsdItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
m_assetService = assService;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Try to parse the texture ID from the request URL
|
||||
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
|
||||
@@ -85,7 +85,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
// m_log.DebugFormat("[GETTEXTURE]: Received request for texture id {0}", textureID);
|
||||
|
||||
string[] formats;
|
||||
if (format != null && format != string.Empty)
|
||||
if (!string.IsNullOrEmpty(format))
|
||||
{
|
||||
formats = new string[1] { format.ToLower() };
|
||||
}
|
||||
@@ -189,6 +189,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
|
||||
newTexture.Flags = AssetFlags.Collectable;
|
||||
newTexture.Temporary = true;
|
||||
newTexture.Local = true;
|
||||
m_assetService.Store(newTexture);
|
||||
WriteTextureData(httpRequest, httpResponse, newTexture, format);
|
||||
return true;
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Nini.Config;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class UploadBakedTextureServerConnector : ServiceConnector
|
||||
{
|
||||
private IAssetService m_AssetService;
|
||||
private string m_ConfigName = "CapsService";
|
||||
|
||||
public UploadBakedTextureServerConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string assetService = serverConfig.GetString("AssetService", String.Empty);
|
||||
|
||||
if (assetService == String.Empty)
|
||||
throw new Exception("No AssetService in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_AssetService =
|
||||
ServerUtils.LoadPlugin<IAssetService>(assetService, args);
|
||||
|
||||
if (m_AssetService == null)
|
||||
throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
|
||||
|
||||
// NEED TO FIX THIS
|
||||
OpenSim.Framework.Capabilities.Caps caps = new OpenSim.Framework.Capabilities.Caps(server, "", server.Port, "", UUID.Zero, "");
|
||||
server.AddStreamHandler(new RestStreamHandler(
|
||||
"POST",
|
||||
"/CAPS/UploadBakedTexture/",
|
||||
new UploadBakedTextureHandler(caps, m_AssetService, true).UploadBakedTexture,
|
||||
"UploadBakedTexture",
|
||||
"Upload Baked Texture Capability"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
51
OpenSim/Capabilities/LLSDAvatarPicker.cs
Normal file
51
OpenSim/Capabilities/LLSDAvatarPicker.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Framework.Capabilities
|
||||
{
|
||||
[OSDMap]
|
||||
public class LLSDAvatarPicker
|
||||
{
|
||||
public string next_page_url;
|
||||
// an array of LLSDPerson
|
||||
public OSDArray agents = new OSDArray();
|
||||
}
|
||||
|
||||
[OSDMap]
|
||||
public class LLSDPerson
|
||||
{
|
||||
public string username;
|
||||
public string display_name;
|
||||
//'display_name_next_update':d"1970-01-01T00:00:00Z"
|
||||
public string legacy_first_name;
|
||||
public string legacy_last_name;
|
||||
public UUID id;
|
||||
public bool is_display_name_default;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Capabilities
|
||||
m_method = method;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
protected override byte[] ProcessRequest(string path, Stream request,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
//Encoding encoding = Util.UTF8;
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace OpenSim.Data
|
||||
public interface IGridUserData
|
||||
{
|
||||
GridUserData Get(string userID);
|
||||
GridUserData[] GetAll(string query);
|
||||
bool Store(GridUserData data);
|
||||
}
|
||||
}
|
||||
@@ -25,35 +25,35 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
|
||||
/// <remarks>
|
||||
/// The handler delegates are not noteworthy. The allocator allows
|
||||
/// a given handler to optionally subclass the base RequestData
|
||||
/// structure to carry any locally required per-request state
|
||||
/// needed.
|
||||
/// </remarks>
|
||||
|
||||
public delegate void RestMethodHandler(RequestData rdata);
|
||||
public delegate RequestData RestMethodAllocator(OSHttpRequest request, OSHttpResponse response, string path);
|
||||
|
||||
/// <summary>
|
||||
/// This interface exports the generic plugin-handling services
|
||||
/// available to each loaded REST services module (IRest implementation)
|
||||
/// </summary>
|
||||
|
||||
internal interface IRestHandler
|
||||
// This MUST be a ref type!
|
||||
public class HGTravelingData
|
||||
{
|
||||
public UUID SessionID;
|
||||
public UUID UserID;
|
||||
public Dictionary<string, string> Data;
|
||||
|
||||
string MsgId { get; }
|
||||
string RequestId { get; }
|
||||
|
||||
void AddPathHandler(RestMethodHandler mh, string path, RestMethodAllocator ma);
|
||||
void AddStreamHandler(string httpMethod, string path, RestMethod method);
|
||||
|
||||
public HGTravelingData()
|
||||
{
|
||||
Data = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// An interface for connecting to the user grid datastore
|
||||
/// </summary>
|
||||
public interface IHGTravelingData
|
||||
{
|
||||
HGTravelingData Get(UUID sessionID);
|
||||
HGTravelingData[] GetSessions(UUID userID);
|
||||
bool Store(HGTravelingData data);
|
||||
bool Delete(UUID sessionID);
|
||||
void DeleteOld();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -34,6 +34,7 @@ namespace OpenSim.Data
|
||||
public class OfflineIMData
|
||||
{
|
||||
public UUID PrincipalID;
|
||||
public UUID FromID;
|
||||
public Dictionary<string, string> Data;
|
||||
}
|
||||
|
||||
|
||||
58
OpenSim/Data/IProfilesData.cs
Normal file
58
OpenSim/Data/IProfilesData.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
|
||||
public interface IProfilesData
|
||||
{
|
||||
OSDArray GetClassifiedRecords(UUID creatorId);
|
||||
bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result);
|
||||
bool DeleteClassifiedRecord(UUID recordId);
|
||||
OSDArray GetAvatarPicks(UUID avatarId);
|
||||
UserProfilePick GetPickInfo(UUID avatarId, UUID pickId);
|
||||
bool UpdatePicksRecord(UserProfilePick pick);
|
||||
bool DeletePicksRecord(UUID pickId);
|
||||
bool GetAvatarNotes(ref UserProfileNotes note);
|
||||
bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result);
|
||||
bool GetAvatarProperties(ref UserProfileProperties props, ref string result);
|
||||
bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result);
|
||||
bool UpdateAvatarInterests(UserProfileProperties up, ref string result);
|
||||
bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result);
|
||||
bool UpdateUserPreferences(ref UserPreferences pref, ref string result);
|
||||
bool GetUserPreferences(ref UserPreferences pref, ref string result);
|
||||
bool GetUserAppData(ref UserAppData props, ref string result);
|
||||
bool SetUserAppData(UserAppData props, ref string result);
|
||||
OSDArray GetUserImageAssets(UUID avatarId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ namespace OpenSim.Data
|
||||
/// <summary>
|
||||
/// Return the x-coordinate of this region.
|
||||
/// </summary>
|
||||
public int coordX { get { return posX / (int)Constants.RegionSize; } }
|
||||
public int coordX { get { return (int)Util.WorldToRegionLoc((uint)posX); } }
|
||||
|
||||
/// <summary>
|
||||
/// Return the y-coordinate of this region.
|
||||
/// </summary>
|
||||
public int coordY { get { return posY / (int)Constants.RegionSize; } }
|
||||
public int coordY { get { return (int)Util.WorldToRegionLoc((uint)posY); } }
|
||||
|
||||
public Dictionary<string, object> Data;
|
||||
}
|
||||
@@ -81,6 +81,7 @@ namespace OpenSim.Data
|
||||
bool Delete(UUID regionID);
|
||||
|
||||
List<RegionData> GetDefaultRegions(UUID scopeID);
|
||||
List<RegionData> GetDefaultHypergridRegions(UUID scopeID);
|
||||
List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y);
|
||||
List<RegionData> GetHyperlinks(UUID scopeID);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
}
|
||||
|
||||
public GridUserData Get(string userID)
|
||||
public new GridUserData Get(string userID)
|
||||
{
|
||||
GridUserData[] ret = Get("UserID", userID);
|
||||
|
||||
@@ -60,5 +60,10 @@ namespace OpenSim.Data.MSSQL
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public GridUserData[] GetAll(string userID)
|
||||
{
|
||||
return base.Get(String.Format("UserID LIKE '{0}%'", userID));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +315,11 @@ namespace OpenSim.Data.MSSQL
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace OpenSim.Data.MSSQL
|
||||
|
||||
// private static FileSystemDataStore Instance = new FileSystemDataStore();
|
||||
private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static string LogHeader = "[REGION DB MSSQL]";
|
||||
|
||||
/// <summary>
|
||||
/// The database manager
|
||||
@@ -351,7 +352,7 @@ IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID)
|
||||
ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice,
|
||||
SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem,
|
||||
ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches,
|
||||
LinkNumber = @LinkNumber, MediaURL = @MediaURL, DynAttrs = @DynAttrs,
|
||||
LinkNumber = @LinkNumber, MediaURL = @MediaURL, AttachedPosX = @AttachedPosX, AttachedPosY = @AttachedPosY, AttachedPosZ = @AttachedPosZ, DynAttrs = @DynAttrs,
|
||||
PhysicsShapeType = @PhysicsShapeType, Density = @Density, GravityModifier = @GravityModifier, Friction = @Friction, Restitution = @Restitution
|
||||
WHERE UUID = @UUID
|
||||
END
|
||||
@@ -367,7 +368,7 @@ ELSE
|
||||
PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX,
|
||||
OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ,
|
||||
ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA,
|
||||
ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL, DynAttrs,
|
||||
ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL, AttachedPosX, AttachedPosY, AttachedPosZ, DynAttrs,
|
||||
PhysicsShapeType, Density, GravityModifier, Friction, Restitution
|
||||
) VALUES (
|
||||
@UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask,
|
||||
@@ -378,7 +379,7 @@ ELSE
|
||||
@PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX,
|
||||
@OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ,
|
||||
@ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA,
|
||||
@ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL, @DynAttrs,
|
||||
@ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL, @AttachedPosX, @AttachedPosY, @AttachedPosZ, @DynAttrs,
|
||||
@PhysicsShapeType, @Density, @GravityModifier, @Friction, @Restitution
|
||||
)
|
||||
END";
|
||||
@@ -530,43 +531,53 @@ ELSE
|
||||
/// <returns></returns>
|
||||
public double[,] LoadTerrain(UUID regionID)
|
||||
{
|
||||
double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize];
|
||||
terrain.Initialize();
|
||||
double[,] ret = null;
|
||||
TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
|
||||
if (terrData != null)
|
||||
ret = terrData.GetDoubles();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns 'null' if region not found
|
||||
public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
|
||||
{
|
||||
TerrainData terrData = null;
|
||||
|
||||
string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
// MySqlParameter param = new MySqlParameter();
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
int rev;
|
||||
if (reader.Read())
|
||||
// MySqlParameter param = new MySqlParameter();
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]);
|
||||
BinaryReader br = new BinaryReader(str);
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
int rev;
|
||||
if (reader.Read())
|
||||
{
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
terrain[x, y] = br.ReadDouble();
|
||||
}
|
||||
rev = (int)reader["Revision"];
|
||||
byte[] blob = (byte[])reader["Heightfield"];
|
||||
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
|
||||
}
|
||||
rev = (int)reader["Revision"];
|
||||
else
|
||||
{
|
||||
_Log.Info("[REGION DB]: No terrain found for region");
|
||||
return null;
|
||||
}
|
||||
_Log.Info("[REGION DB]: Loaded terrain revision r" + rev);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Log.Info("[REGION DB]: No terrain found for region");
|
||||
return null;
|
||||
}
|
||||
_Log.Info("[REGION DB]: Loaded terrain revision r" + rev);
|
||||
}
|
||||
}
|
||||
|
||||
return terrain;
|
||||
return terrData;
|
||||
}
|
||||
|
||||
// Legacy entry point for when terrain was always a 256x256 hieghtmap
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
{
|
||||
StoreTerrain(new HeightmapTerrainData(ter), regionID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -574,10 +585,8 @@ ELSE
|
||||
/// </summary>
|
||||
/// <param name="terrain">terrain map data.</param>
|
||||
/// <param name="regionID">regionID.</param>
|
||||
public void StoreTerrain(double[,] terrain, UUID regionID)
|
||||
public void StoreTerrain(TerrainData terrData, UUID regionID)
|
||||
{
|
||||
int revision = Util.UnixTimeSinceEpoch();
|
||||
|
||||
//Delete old terrain map
|
||||
string sql = "delete from terrain where RegionUUID=@RegionUUID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
@@ -590,17 +599,23 @@ ELSE
|
||||
|
||||
sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)";
|
||||
|
||||
int terrainDBRevision;
|
||||
Array terrainDBblob;
|
||||
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain)));
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Revision", terrainDBRevision));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", terrainDBblob));
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
_Log.Info("[REGION DB]: Stored terrain revision r " + revision);
|
||||
_Log.InfoFormat("{0} Stored terrain revision r={1}", LogHeader, terrainDBRevision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1344,30 +1359,6 @@ VALUES
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the terrain data for storage in DB.
|
||||
/// </summary>
|
||||
/// <param name="val">terrain data</param>
|
||||
/// <returns></returns>
|
||||
private static Array serializeTerrain(double[,] val)
|
||||
{
|
||||
MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double));
|
||||
BinaryWriter bw = new BinaryWriter(str);
|
||||
|
||||
// TODO: COMPATIBILITY - Add byte-order conversions
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
double height = val[x, y];
|
||||
if (height == 0.0)
|
||||
height = double.Epsilon;
|
||||
|
||||
bw.Write(height);
|
||||
}
|
||||
|
||||
return str.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores new regionsettings.
|
||||
/// </summary>
|
||||
@@ -1695,6 +1686,12 @@ VALUES
|
||||
if (!(primRow["MediaURL"] is System.DBNull))
|
||||
prim.MediaUrl = (string)primRow["MediaURL"];
|
||||
|
||||
if (!(primRow["AttachedPosX"] is System.DBNull))
|
||||
prim.AttachedPos = new Vector3(
|
||||
Convert.ToSingle(primRow["AttachedPosX"]),
|
||||
Convert.ToSingle(primRow["AttachedPosY"]),
|
||||
Convert.ToSingle(primRow["AttachedPosZ"]));
|
||||
|
||||
if (!(primRow["DynAttrs"] is System.DBNull))
|
||||
prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]);
|
||||
else
|
||||
@@ -2099,8 +2096,11 @@ VALUES
|
||||
parameters.Add(_Database.CreateParameter("PassTouches", 0));
|
||||
parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum));
|
||||
parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl));
|
||||
|
||||
if (prim.DynAttrs.Count > 0)
|
||||
parameters.Add(_Database.CreateParameter("AttachedPosX", prim.AttachedPos.X));
|
||||
parameters.Add(_Database.CreateParameter("AttachedPosY", prim.AttachedPos.Y));
|
||||
parameters.Add(_Database.CreateParameter("AttachedPosZ", prim.AttachedPos.Z));
|
||||
|
||||
if (prim.DynAttrs.CountNamespaces > 0)
|
||||
parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml()));
|
||||
else
|
||||
parameters.Add(_Database.CreateParameter("DynAttrs", null));
|
||||
|
||||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -1153,7 +1153,7 @@ COMMIT
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE prims ADD COLUMN DynAttrs TEXT;
|
||||
ALTER TABLE prims ADD DynAttrs TEXT;
|
||||
|
||||
COMMIT
|
||||
|
||||
@@ -1161,10 +1161,22 @@ COMMIT
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0';
|
||||
ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000';
|
||||
ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1';
|
||||
ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6';
|
||||
ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5';
|
||||
ALTER TABLE prims ADD `PhysicsShapeType` tinyint(4) NOT NULL default '0';
|
||||
ALTER TABLE prims ADD `Density` double NOT NULL default '1000';
|
||||
ALTER TABLE prims ADD `GravityModifier` double NOT NULL default '1';
|
||||
ALTER TABLE prims ADD `Friction` double NOT NULL default '0.6';
|
||||
ALTER TABLE prims ADD `Restitution` double NOT NULL default '0.5';
|
||||
|
||||
COMMIT
|
||||
|
||||
:VERSION 40 #---------------- Save Attachment info
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE prims ADD AttachedPosX float(53) default 0.0;
|
||||
ALTER TABLE prims ADD AttachedPosY float(53) default 0.0;
|
||||
ALTER TABLE prims ADD AttachedPosZ float(53) default 0.0;
|
||||
ALTER TABLE primshapes ADD LastAttachPoint int not null default 0;
|
||||
|
||||
COMMIT
|
||||
|
||||
|
||||
@@ -142,7 +142,8 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message);
|
||||
m_log.Error(
|
||||
string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,8 +210,11 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
|
||||
asset.FullID, asset.Name, e.Message);
|
||||
m_log.Error(
|
||||
string.Format(
|
||||
"[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ",
|
||||
asset.FullID, asset.Name)
|
||||
, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,10 +245,11 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ASSETS DB]: " +
|
||||
"MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
|
||||
+ Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
|
||||
m_log.Error(
|
||||
string.Format(
|
||||
"[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
|
||||
asset.FullID, asset.Name),
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -284,8 +289,8 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid);
|
||||
m_log.Error(
|
||||
string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,7 +349,11 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
|
||||
m_log.Error(
|
||||
string.Format(
|
||||
"[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
|
||||
start, count),
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {}
|
||||
|
||||
public GridUserData Get(string userID)
|
||||
public new GridUserData Get(string userID)
|
||||
{
|
||||
GridUserData[] ret = Get("UserID", userID);
|
||||
|
||||
@@ -56,6 +56,9 @@ namespace OpenSim.Data.MySQL
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
|
||||
public GridUserData[] GetAll(string userID)
|
||||
{
|
||||
return base.Get(String.Format("UserID LIKE '{0}%'", userID));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL
|
||||
if (string.IsNullOrEmpty(pattern))
|
||||
pattern = "1 ORDER BY Name LIMIT 100";
|
||||
else
|
||||
pattern = string.Format("Name LIKE %{0}% ORDER BY Name LIMIT 100", pattern);
|
||||
pattern = string.Format("Name LIKE '%{0}%' ORDER BY Name LIMIT 100", pattern);
|
||||
|
||||
return m_Groups.Get(pattern);
|
||||
}
|
||||
|
||||
80
OpenSim/Data/MySQL/MySQLHGTravelData.cs
Normal file
80
OpenSim/Data/MySQL/MySQLHGTravelData.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace OpenSim.Data.MySQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A MySQL Interface for user grid data
|
||||
/// </summary>
|
||||
public class MySQLHGTravelData : MySQLGenericTableHandler<HGTravelingData>, IHGTravelingData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public MySQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { }
|
||||
|
||||
public HGTravelingData Get(UUID sessionID)
|
||||
{
|
||||
HGTravelingData[] ret = Get("SessionID", sessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public HGTravelingData[] GetSessions(UUID userID)
|
||||
{
|
||||
return base.Get("UserID", userID.ToString());
|
||||
}
|
||||
|
||||
public bool Delete(UUID sessionID)
|
||||
{
|
||||
return Delete("SessionID", sessionID.ToString());
|
||||
}
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 DAY", m_Realm);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,13 +47,10 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
uint now = (uint)Util.UnixTimeSinceEpoch();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm);
|
||||
cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
|
||||
|
||||
cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
|
||||
@@ -310,6 +310,11 @@ namespace OpenSim.Data.MySQL
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
|
||||
@@ -48,11 +48,12 @@ namespace OpenSim.Data.MySQL
|
||||
public class MySQLSimulationData : ISimulationDataStore
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static string LogHeader = "[REGION DB MYSQL]";
|
||||
|
||||
private string m_connectionString;
|
||||
private object m_dbLock = new object();
|
||||
|
||||
protected Assembly Assembly
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
@@ -91,7 +92,7 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message);
|
||||
m_log.ErrorFormat("{0} MySQL error in ExecuteReader: {1}", LogHeader, e);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -173,9 +174,10 @@ namespace OpenSim.Data.MySQL
|
||||
"ParticleSystem, ClickAction, Material, " +
|
||||
"CollisionSound, CollisionSoundVolume, " +
|
||||
"PassTouches, " +
|
||||
"LinkNumber, MediaURL, DynAttrs, " +
|
||||
"LinkNumber, MediaURL, AttachedPosX, " +
|
||||
"AttachedPosY, AttachedPosZ, KeyframeMotion, " +
|
||||
"PhysicsShapeType, Density, GravityModifier, " +
|
||||
"Friction, Restitution " +
|
||||
"Friction, Restitution, DynAttrs " +
|
||||
") values (" + "?UUID, " +
|
||||
"?CreationDate, ?Name, ?Text, " +
|
||||
"?Description, ?SitName, ?TouchName, " +
|
||||
@@ -208,9 +210,10 @@ namespace OpenSim.Data.MySQL
|
||||
"?ColorB, ?ColorA, ?ParticleSystem, " +
|
||||
"?ClickAction, ?Material, ?CollisionSound, " +
|
||||
"?CollisionSoundVolume, ?PassTouches, " +
|
||||
"?LinkNumber, ?MediaURL, ?DynAttrs, " +
|
||||
"?LinkNumber, ?MediaURL, ?AttachedPosX, " +
|
||||
"?AttachedPosY, ?AttachedPosZ, ?KeyframeMotion, " +
|
||||
"?PhysicsShapeType, ?Density, ?GravityModifier, " +
|
||||
"?Friction, ?Restitution)";
|
||||
"?Friction, ?Restitution, ?DynAttrs)";
|
||||
|
||||
FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
|
||||
|
||||
@@ -227,7 +230,7 @@ namespace OpenSim.Data.MySQL
|
||||
"PathTaperX, PathTaperY, PathTwist, " +
|
||||
"PathTwistBegin, ProfileBegin, ProfileEnd, " +
|
||||
"ProfileCurve, ProfileHollow, Texture, " +
|
||||
"ExtraParams, State, Media) " +
|
||||
"ExtraParams, State, LastAttachPoint, Media) " +
|
||||
"values (?UUID, " +
|
||||
"?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " +
|
||||
"?PCode, ?PathBegin, ?PathEnd, " +
|
||||
@@ -239,7 +242,7 @@ namespace OpenSim.Data.MySQL
|
||||
"?PathTwistBegin, ?ProfileBegin, " +
|
||||
"?ProfileEnd, ?ProfileCurve, " +
|
||||
"?ProfileHollow, ?Texture, ?ExtraParams, " +
|
||||
"?State, ?Media)";
|
||||
"?State, ?LastAttachPoint, ?Media)";
|
||||
|
||||
FillShapeCommand(cmd, prim);
|
||||
|
||||
@@ -455,7 +458,9 @@ namespace OpenSim.Data.MySQL
|
||||
foreach (SceneObjectPart prim in prims.Values)
|
||||
{
|
||||
if (prim.ParentUUID == UUID.Zero)
|
||||
{
|
||||
objects[prim.UUID] = new SceneObjectGroup(prim);
|
||||
}
|
||||
}
|
||||
|
||||
// Add all of the children objects to the SOGs
|
||||
@@ -568,10 +573,14 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy entry point for when terrain was always a 256x256 hieghtmap
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
{
|
||||
m_log.Info("[REGION DB]: Storing terrain");
|
||||
StoreTerrain(new HeightmapTerrainData(ter), regionID);
|
||||
}
|
||||
|
||||
public void StoreTerrain(TerrainData terrData, UUID regionID)
|
||||
{
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
@@ -585,11 +594,18 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
|
||||
cmd.CommandText = "insert into terrain (RegionUUID, " +
|
||||
"Revision, Heightfield) values (?RegionUUID, " +
|
||||
"1, ?Heightfield)";
|
||||
|
||||
cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
||||
int terrainDBRevision;
|
||||
Array terrainDBblob;
|
||||
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
|
||||
|
||||
m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}",
|
||||
LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision);
|
||||
|
||||
cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)"
|
||||
+ "values (?RegionUUID, ?Revision, ?Heightfield)";
|
||||
|
||||
cmd.Parameters.AddWithValue("Revision", terrainDBRevision);
|
||||
cmd.Parameters.AddWithValue("Heightfield", terrainDBblob);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
@@ -597,9 +613,20 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy region loading
|
||||
public double[,] LoadTerrain(UUID regionID)
|
||||
{
|
||||
double[,] terrain = null;
|
||||
double[,] ret = null;
|
||||
TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
|
||||
if (terrData != null)
|
||||
ret = terrData.GetDoubles();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns 'null' if region not found
|
||||
public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
|
||||
{
|
||||
TerrainData terrData = null;
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
@@ -619,32 +646,15 @@ namespace OpenSim.Data.MySQL
|
||||
while (reader.Read())
|
||||
{
|
||||
int rev = Convert.ToInt32(reader["Revision"]);
|
||||
|
||||
terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize];
|
||||
terrain.Initialize();
|
||||
|
||||
using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"]))
|
||||
{
|
||||
using (BinaryReader br = new BinaryReader(mstr))
|
||||
{
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
{
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
terrain[x, y] = br.ReadDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev);
|
||||
}
|
||||
byte[] blob = (byte[])reader["Heightfield"];
|
||||
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return terrain;
|
||||
return terrData;
|
||||
}
|
||||
|
||||
public void RemoveLandObject(UUID globalID)
|
||||
@@ -1301,12 +1311,34 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
if (!(row["MediaURL"] is System.DBNull))
|
||||
prim.MediaUrl = (string)row["MediaURL"];
|
||||
|
||||
|
||||
if (!(row["AttachedPosX"] is System.DBNull))
|
||||
{
|
||||
prim.AttachedPos = new Vector3(
|
||||
(float)(double)row["AttachedPosX"],
|
||||
(float)(double)row["AttachedPosY"],
|
||||
(float)(double)row["AttachedPosZ"]
|
||||
);
|
||||
}
|
||||
|
||||
if (!(row["DynAttrs"] is System.DBNull))
|
||||
prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
|
||||
else
|
||||
prim.DynAttrs = new DAMap();
|
||||
|
||||
if (!(row["KeyframeMotion"] is DBNull))
|
||||
{
|
||||
Byte[] data = (byte[])row["KeyframeMotion"];
|
||||
if (data.Length > 0)
|
||||
prim.KeyframeMotion = KeyframeMotion.FromData(null, data);
|
||||
else
|
||||
prim.KeyframeMotion = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
prim.KeyframeMotion = null;
|
||||
}
|
||||
|
||||
prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString());
|
||||
prim.Density = (float)(double)row["Density"];
|
||||
prim.GravityModifier = (float)(double)row["GravityModifier"];
|
||||
@@ -1498,30 +1530,6 @@ namespace OpenSim.Data.MySQL
|
||||
return entry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
/// <returns></returns>
|
||||
private static Array SerializeTerrain(double[,] val)
|
||||
{
|
||||
MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
|
||||
BinaryWriter bw = new BinaryWriter(str);
|
||||
|
||||
// TODO: COMPATIBILITY - Add byte-order conversions
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
double height = val[x, y];
|
||||
if (height == 0.0)
|
||||
height = double.Epsilon;
|
||||
|
||||
bw.Write(height);
|
||||
}
|
||||
|
||||
return str.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill the prim command with prim values
|
||||
/// </summary>
|
||||
@@ -1658,9 +1666,19 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
|
||||
cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
|
||||
if (prim.AttachedPos != null)
|
||||
{
|
||||
cmd.Parameters.AddWithValue("AttachedPosX", (double)prim.AttachedPos.X);
|
||||
cmd.Parameters.AddWithValue("AttachedPosY", (double)prim.AttachedPos.Y);
|
||||
cmd.Parameters.AddWithValue("AttachedPosZ", (double)prim.AttachedPos.Z);
|
||||
}
|
||||
|
||||
if (prim.KeyframeMotion != null)
|
||||
cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize());
|
||||
else
|
||||
cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
|
||||
|
||||
if (prim.DynAttrs.Count > 0)
|
||||
if (prim.DynAttrs.CountNamespaces > 0)
|
||||
cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml());
|
||||
else
|
||||
cmd.Parameters.AddWithValue("DynAttrs", null);
|
||||
@@ -1860,6 +1878,7 @@ namespace OpenSim.Data.MySQL
|
||||
s.ExtraParams = (byte[])row["ExtraParams"];
|
||||
|
||||
s.State = (byte)(int)row["State"];
|
||||
s.LastAttachPoint = (byte)(int)row["LastAttachPoint"];
|
||||
|
||||
if (!(row["Media"] is System.DBNull))
|
||||
s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]);
|
||||
@@ -1906,6 +1925,7 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.Parameters.AddWithValue("Texture", s.TextureEntry);
|
||||
cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams);
|
||||
cmd.Parameters.AddWithValue("State", s.State);
|
||||
cmd.Parameters.AddWithValue("LastAttachPoint", s.LastAttachPoint);
|
||||
cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml());
|
||||
}
|
||||
|
||||
|
||||
1099
OpenSim/Data/MySQL/MySQLUserProfilesData.cs
Normal file
1099
OpenSim/Data/MySQL/MySQLUserProfilesData.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -50,6 +50,11 @@ namespace OpenSim.Data.MySQL
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of days that must pass before we update the access time on an asset when it has been fetched.
|
||||
/// </summary>
|
||||
private const int DaysBetweenAccessTimeUpdates = 30;
|
||||
|
||||
private bool m_enableCompression = false;
|
||||
private string m_connectionString;
|
||||
private object m_dbLock = new object();
|
||||
@@ -133,10 +138,10 @@ namespace OpenSim.Data.MySQL
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(
|
||||
"SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id",
|
||||
"SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID",
|
||||
dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?id", assetID.ToString());
|
||||
cmd.Parameters.AddWithValue("?ID", assetID.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
@@ -144,18 +149,18 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString());
|
||||
asset.Data = (byte[])dbReader["data"];
|
||||
asset.Description = (string)dbReader["description"];
|
||||
asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString());
|
||||
asset.Data = (byte[])dbReader["Data"];
|
||||
asset.Description = (string)dbReader["Description"];
|
||||
|
||||
string local = dbReader["local"].ToString();
|
||||
string local = dbReader["Local"].ToString();
|
||||
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
|
||||
asset.Local = true;
|
||||
else
|
||||
asset.Local = false;
|
||||
|
||||
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
|
||||
asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
|
||||
asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
|
||||
asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
|
||||
|
||||
if (m_enableCompression)
|
||||
{
|
||||
@@ -171,12 +176,14 @@ namespace OpenSim.Data.MySQL
|
||||
// asset.ID, asset.Name, asset.Data.Length, compressedLength);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message);
|
||||
m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,6 +199,8 @@ namespace OpenSim.Data.MySQL
|
||||
/// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
|
||||
public void StoreAsset(AssetBase asset)
|
||||
{
|
||||
// m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID);
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
@@ -242,23 +251,23 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
using (MySqlCommand cmd =
|
||||
new MySqlCommand(
|
||||
"replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" +
|
||||
"VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)",
|
||||
"replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" +
|
||||
"VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)",
|
||||
dbcon))
|
||||
{
|
||||
// create unix epoch time
|
||||
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
||||
cmd.Parameters.AddWithValue("?id", asset.ID);
|
||||
cmd.Parameters.AddWithValue("?hash", hash);
|
||||
cmd.Parameters.AddWithValue("?name", assetName);
|
||||
cmd.Parameters.AddWithValue("?description", assetDescription);
|
||||
cmd.Parameters.AddWithValue("?asset_type", asset.Type);
|
||||
cmd.Parameters.AddWithValue("?local", asset.Local);
|
||||
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
||||
cmd.Parameters.AddWithValue("?create_time", now);
|
||||
cmd.Parameters.AddWithValue("?access_time", now);
|
||||
cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID);
|
||||
cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
|
||||
cmd.Parameters.AddWithValue("?ID", asset.ID);
|
||||
cmd.Parameters.AddWithValue("?Hash", hash);
|
||||
cmd.Parameters.AddWithValue("?Name", assetName);
|
||||
cmd.Parameters.AddWithValue("?Description", assetDescription);
|
||||
cmd.Parameters.AddWithValue("?AssetType", asset.Type);
|
||||
cmd.Parameters.AddWithValue("?Local", asset.Local);
|
||||
cmd.Parameters.AddWithValue("?Temporary", asset.Temporary);
|
||||
cmd.Parameters.AddWithValue("?CreateTime", now);
|
||||
cmd.Parameters.AddWithValue("?AccessTime", now);
|
||||
cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
|
||||
cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@@ -278,11 +287,11 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
using (MySqlCommand cmd =
|
||||
new MySqlCommand(
|
||||
"INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)",
|
||||
"INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)",
|
||||
dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?hash", hash);
|
||||
cmd.Parameters.AddWithValue("?data", asset.Data);
|
||||
cmd.Parameters.AddWithValue("?Hash", hash);
|
||||
cmd.Parameters.AddWithValue("?Data", asset.Data);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@@ -303,41 +312,49 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
// private void UpdateAccessTime(AssetBase asset)
|
||||
// {
|
||||
// lock (m_dbLock)
|
||||
// {
|
||||
// using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
// {
|
||||
// dbcon.Open();
|
||||
// MySqlCommand cmd =
|
||||
// new MySqlCommand("update assets set access_time=?access_time where id=?id",
|
||||
// dbcon);
|
||||
//
|
||||
// // need to ensure we dispose
|
||||
// try
|
||||
// {
|
||||
// using (cmd)
|
||||
// {
|
||||
// // create unix epoch time
|
||||
// int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
||||
// cmd.Parameters.AddWithValue("?id", asset.ID);
|
||||
// cmd.Parameters.AddWithValue("?access_time", now);
|
||||
// cmd.ExecuteNonQuery();
|
||||
// cmd.Dispose();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// m_log.ErrorFormat(
|
||||
// "[ASSETS DB]: " +
|
||||
// "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
|
||||
// + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
/// <summary>
|
||||
/// Updates the access time of the asset if it was accessed above a given threshhold amount of time.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This gives us some insight into assets which haven't ben accessed for a long period. This is only done
|
||||
/// over the threshold time to avoid excessive database writes as assets are fetched.
|
||||
/// </remarks>
|
||||
/// <param name='asset'></param>
|
||||
/// <param name='accessTime'></param>
|
||||
private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime)
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
|
||||
return;
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
MySqlCommand cmd =
|
||||
new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon);
|
||||
|
||||
try
|
||||
{
|
||||
using (cmd)
|
||||
{
|
||||
// create unix epoch time
|
||||
cmd.Parameters.AddWithValue("?ID", assetMetadata.ID);
|
||||
cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
|
||||
assetMetadata.ID, assetMetadata.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We assume we already have the m_dbLock.
|
||||
@@ -353,9 +370,9 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
bool exists = false;
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon))
|
||||
using (MySqlCommand cmd = new MySqlCommand("SELECT Hash FROM XAssetsData WHERE Hash=?Hash", dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?hash", hash);
|
||||
cmd.Parameters.AddWithValue("?Hash", hash);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -395,9 +412,9 @@ namespace OpenSim.Data.MySQL
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon))
|
||||
using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
||||
cmd.Parameters.AddWithValue("?ID", uuid.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
@@ -412,8 +429,7 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid);
|
||||
m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -422,6 +438,7 @@ namespace OpenSim.Data.MySQL
|
||||
return assetExists;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of AssetMetadata objects. The list is a subset of
|
||||
/// the entire data set offset by <paramref name="start" /> containing
|
||||
@@ -439,7 +456,7 @@ namespace OpenSim.Data.MySQL
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon);
|
||||
MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon);
|
||||
cmd.Parameters.AddWithValue("?start", start);
|
||||
cmd.Parameters.AddWithValue("?count", count);
|
||||
|
||||
@@ -450,17 +467,19 @@ namespace OpenSim.Data.MySQL
|
||||
while (dbReader.Read())
|
||||
{
|
||||
AssetMetadata metadata = new AssetMetadata();
|
||||
metadata.Name = (string)dbReader["name"];
|
||||
metadata.Description = (string)dbReader["description"];
|
||||
metadata.Type = (sbyte)dbReader["asset_type"];
|
||||
metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
|
||||
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
|
||||
metadata.FullID = DBGuid.FromDB(dbReader["id"]);
|
||||
metadata.CreatorID = dbReader["creator_id"].ToString();
|
||||
metadata.Name = (string)dbReader["Name"];
|
||||
metadata.Description = (string)dbReader["Description"];
|
||||
metadata.Type = (sbyte)dbReader["AssetType"];
|
||||
metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
|
||||
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
|
||||
metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
|
||||
metadata.CreatorID = dbReader["CreatorID"].ToString();
|
||||
|
||||
// We'll ignore this for now - it appears unused!
|
||||
// metadata.SHA1 = dbReader["hash"]);
|
||||
|
||||
UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
|
||||
|
||||
retList.Add(metadata);
|
||||
}
|
||||
}
|
||||
@@ -485,9 +504,9 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon))
|
||||
using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?id", id);
|
||||
cmd.Parameters.AddWithValue("?ID", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -77,5 +77,11 @@ BEGIN;
|
||||
ALTER TABLE estate_settings AUTO_INCREMENT = 100;
|
||||
COMMIT;
|
||||
|
||||
:VERSION 33 #---------------------
|
||||
|
||||
BEGIN;
|
||||
ALTER TABLE estate_settings ADD COLUMN `AllowLandmark` tinyint(4) NOT NULL default '1';
|
||||
ALTER TABLE estate_settings ADD COLUMN `AllowParcelChanges` tinyint(4) NOT NULL default '1';
|
||||
ALTER TABLE estate_settings ADD COLUMN `AllowSetHome` tinyint(4) NOT NULL default '1';
|
||||
COMMIT;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ CREATE TABLE `Friends` (
|
||||
`Offered` VARCHAR(32) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`PrincipalID`, `Friend`),
|
||||
KEY(`PrincipalID`)
|
||||
);
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
18
OpenSim/Data/MySQL/Resources/HGTravelStore.migrations
Normal file
18
OpenSim/Data/MySQL/Resources/HGTravelStore.migrations
Normal file
@@ -0,0 +1,18 @@
|
||||
:VERSION 1 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE `hg_traveling_data` (
|
||||
`SessionID` VARCHAR(36) NOT NULL,
|
||||
`UserID` VARCHAR(36) NOT NULL,
|
||||
`GridExternalName` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ServiceToken` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '',
|
||||
`MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '',
|
||||
`TMStamp` timestamp NOT NULL,
|
||||
PRIMARY KEY (`SessionID`),
|
||||
KEY (`UserID`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -21,4 +21,14 @@ INSERT INTO `im_offline` SELECT * from `diva_im_offline`;
|
||||
DROP TABLE `diva_im_offline`;
|
||||
DELETE FROM `migrations` WHERE name='diva_im_Store';
|
||||
|
||||
COMMIT;
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE `im_offline`
|
||||
ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`,
|
||||
ADD KEY `FromID` (`FromID`);
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -923,3 +923,20 @@ ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5';
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 48 #---------------- Keyframes
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 49 #--------------------- Save attachment info
|
||||
|
||||
BEGIN;
|
||||
ALTER TABLE prims ADD COLUMN AttachedPosX double default 0;
|
||||
ALTER TABLE prims ADD COLUMN AttachedPosY double default 0;
|
||||
ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0;
|
||||
ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0';
|
||||
COMMIT;
|
||||
|
||||
|
||||
93
OpenSim/Data/MySQL/Resources/UserProfiles.migrations
Normal file
93
OpenSim/Data/MySQL/Resources/UserProfiles.migrations
Normal file
@@ -0,0 +1,93 @@
|
||||
:VERSION 1 # -------------------------------
|
||||
|
||||
begin;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `classifieds` (
|
||||
`classifieduuid` char(36) NOT NULL,
|
||||
`creatoruuid` char(36) NOT NULL,
|
||||
`creationdate` int(20) NOT NULL,
|
||||
`expirationdate` int(20) NOT NULL,
|
||||
`category` varchar(20) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`parceluuid` char(36) NOT NULL,
|
||||
`parentestate` int(11) NOT NULL,
|
||||
`snapshotuuid` char(36) NOT NULL,
|
||||
`simname` varchar(255) NOT NULL,
|
||||
`posglobal` varchar(255) NOT NULL,
|
||||
`parcelname` varchar(255) NOT NULL,
|
||||
`classifiedflags` int(8) NOT NULL,
|
||||
`priceforlisting` int(5) NOT NULL,
|
||||
PRIMARY KEY (`classifieduuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `usernotes` (
|
||||
`useruuid` varchar(36) NOT NULL,
|
||||
`targetuuid` varchar(36) NOT NULL,
|
||||
`notes` text NOT NULL,
|
||||
UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `userpicks` (
|
||||
`pickuuid` varchar(36) NOT NULL,
|
||||
`creatoruuid` varchar(36) NOT NULL,
|
||||
`toppick` enum('true','false') NOT NULL,
|
||||
`parceluuid` varchar(36) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`snapshotuuid` varchar(36) NOT NULL,
|
||||
`user` varchar(255) NOT NULL,
|
||||
`originalname` varchar(255) NOT NULL,
|
||||
`simname` varchar(255) NOT NULL,
|
||||
`posglobal` varchar(255) NOT NULL,
|
||||
`sortorder` int(2) NOT NULL,
|
||||
`enabled` enum('true','false') NOT NULL,
|
||||
PRIMARY KEY (`pickuuid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `userprofile` (
|
||||
`useruuid` varchar(36) NOT NULL,
|
||||
`profilePartner` varchar(36) NOT NULL,
|
||||
`profileAllowPublish` binary(1) NOT NULL,
|
||||
`profileMaturePublish` binary(1) NOT NULL,
|
||||
`profileURL` varchar(255) NOT NULL,
|
||||
`profileWantToMask` int(3) NOT NULL,
|
||||
`profileWantToText` text NOT NULL,
|
||||
`profileSkillsMask` int(3) NOT NULL,
|
||||
`profileSkillsText` text NOT NULL,
|
||||
`profileLanguages` text NOT NULL,
|
||||
`profileImage` varchar(36) NOT NULL,
|
||||
`profileAboutText` text NOT NULL,
|
||||
`profileFirstImage` varchar(36) NOT NULL,
|
||||
`profileFirstText` text NOT NULL,
|
||||
PRIMARY KEY (`useruuid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
commit;
|
||||
|
||||
:VERSION 2 # -------------------------------
|
||||
|
||||
begin;
|
||||
CREATE TABLE IF NOT EXISTS `userdata` (
|
||||
`UserId` char(36) NOT NULL,
|
||||
`TagId` varchar(64) NOT NULL,
|
||||
`DataKey` varchar(255),
|
||||
`DataVal` varchar(255),
|
||||
PRIMARY KEY (`UserId`,`TagId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
commit;
|
||||
|
||||
:VERSION 3 # -------------------------------
|
||||
begin;
|
||||
CREATE TABLE IF NOT EXISTS `usersettings` (
|
||||
`useruuid` varchar(36) NOT NULL,
|
||||
`imviaemail` enum('true','false') NOT NULL,
|
||||
`visible` enum('true','false') NOT NULL,
|
||||
`email` varchar(254) NOT NULL,
|
||||
PRIMARY KEY (`useruuid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
commit;
|
||||
@@ -3,24 +3,24 @@
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE `xassetsmeta` (
|
||||
`id` char(36) NOT NULL,
|
||||
`hash` binary(32) NOT NULL,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`description` varchar(64) NOT NULL,
|
||||
`asset_type` tinyint(4) NOT NULL,
|
||||
`local` tinyint(1) NOT NULL,
|
||||
`temporary` tinyint(1) NOT NULL,
|
||||
`create_time` int(11) NOT NULL,
|
||||
`access_time` int(11) NOT NULL,
|
||||
`asset_flags` int(11) NOT NULL,
|
||||
`creator_id` varchar(128) NOT NULL,
|
||||
CREATE TABLE `XAssetsMeta` (
|
||||
`ID` char(36) NOT NULL,
|
||||
`Hash` binary(32) NOT NULL,
|
||||
`Name` varchar(64) NOT NULL,
|
||||
`Description` varchar(64) NOT NULL,
|
||||
`AssetType` tinyint(4) NOT NULL,
|
||||
`Local` tinyint(1) NOT NULL,
|
||||
`Temporary` tinyint(1) NOT NULL,
|
||||
`CreateTime` int(11) NOT NULL,
|
||||
`AccessTime` int(11) NOT NULL,
|
||||
`AssetFlags` int(11) NOT NULL,
|
||||
`CreatorID` varchar(128) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
|
||||
|
||||
CREATE TABLE `xassetsdata` (
|
||||
`hash` binary(32) NOT NULL,
|
||||
`data` longblob NOT NULL,
|
||||
CREATE TABLE `XAssetsData` (
|
||||
`Hash` binary(32) NOT NULL,
|
||||
`Data` longblob NOT NULL,
|
||||
PRIMARY KEY (`hash`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
|
||||
|
||||
|
||||
@@ -42,6 +42,22 @@ namespace OpenSim.Data.Null
|
||||
|
||||
// private string m_connectionString;
|
||||
|
||||
private Dictionary<uint, EstateSettings> m_knownEstates = new Dictionary<uint, EstateSettings>();
|
||||
private EstateSettings m_estate = null;
|
||||
|
||||
private EstateSettings GetEstate()
|
||||
{
|
||||
if (m_estate == null)
|
||||
{
|
||||
// This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase).
|
||||
// The estate info is pretty empty so don't try banning anyone.
|
||||
m_estate = new EstateSettings();
|
||||
m_estate.EstateID = 1;
|
||||
m_estate.OnSave += StoreEstateSettings;
|
||||
}
|
||||
return m_estate;
|
||||
}
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
@@ -68,21 +84,18 @@ namespace OpenSim.Data.Null
|
||||
|
||||
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
|
||||
{
|
||||
// This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase).
|
||||
// The estate info is pretty empty so don't try banning anyone.
|
||||
EstateSettings oneEstate = new EstateSettings();
|
||||
oneEstate.EstateID = 1;
|
||||
return oneEstate;
|
||||
return GetEstate();
|
||||
}
|
||||
|
||||
public void StoreEstateSettings(EstateSettings es)
|
||||
{
|
||||
m_estate = es;
|
||||
return;
|
||||
}
|
||||
|
||||
public EstateSettings LoadEstateSettings(int estateID)
|
||||
{
|
||||
return new EstateSettings();
|
||||
return GetEstate();
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
@@ -93,13 +106,14 @@ namespace OpenSim.Data.Null
|
||||
public List<EstateSettings> LoadEstateSettingsAll()
|
||||
{
|
||||
List<EstateSettings> allEstateSettings = new List<EstateSettings>();
|
||||
allEstateSettings.Add(new EstateSettings());
|
||||
allEstateSettings.Add(GetEstate());
|
||||
return allEstateSettings;
|
||||
}
|
||||
|
||||
public List<int> GetEstatesAll()
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
result.Add((int)GetEstate().EstateID);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -239,6 +239,11 @@ namespace OpenSim.Data.Null
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
|
||||
@@ -77,20 +77,34 @@ namespace OpenSim.Data.Null
|
||||
}
|
||||
|
||||
#region Environment Settings
|
||||
|
||||
private Dictionary<UUID, string> EnvironmentSettings = new Dictionary<UUID, string>();
|
||||
|
||||
public string LoadRegionEnvironmentSettings(UUID regionUUID)
|
||||
{
|
||||
//This connector doesn't support the Environment module yet
|
||||
lock (EnvironmentSettings)
|
||||
{
|
||||
if (EnvironmentSettings.ContainsKey(regionUUID))
|
||||
return EnvironmentSettings[regionUUID];
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
|
||||
{
|
||||
//This connector doesn't support the Environment module yet
|
||||
lock (EnvironmentSettings)
|
||||
{
|
||||
EnvironmentSettings[regionUUID] = settings;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegionEnvironmentSettings(UUID regionUUID)
|
||||
{
|
||||
//This connector doesn't support the Environment module yet
|
||||
lock (EnvironmentSettings)
|
||||
{
|
||||
if (EnvironmentSettings.ContainsKey(regionUUID))
|
||||
EnvironmentSettings.Remove(regionUUID);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -118,15 +132,33 @@ namespace OpenSim.Data.Null
|
||||
return new List<SceneObjectGroup>();
|
||||
}
|
||||
|
||||
Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>();
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
|
||||
public void StoreTerrain(TerrainData ter, UUID regionID)
|
||||
{
|
||||
if (m_terrains.ContainsKey(regionID))
|
||||
m_terrains.Remove(regionID);
|
||||
m_terrains.Add(regionID, ter);
|
||||
}
|
||||
|
||||
// Legacy. Just don't do this.
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
{
|
||||
TerrainData terrData = new HeightmapTerrainData(ter);
|
||||
StoreTerrain(terrData, regionID);
|
||||
}
|
||||
|
||||
// Legacy. Just don't do this.
|
||||
// Returns 'null' if region not found
|
||||
public double[,] LoadTerrain(UUID regionID)
|
||||
{
|
||||
if (m_terrains.ContainsKey(regionID))
|
||||
{
|
||||
return m_terrains[regionID].GetDoubles();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
|
||||
{
|
||||
if (m_terrains.ContainsKey(regionID))
|
||||
{
|
||||
|
||||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
295
OpenSim/Data/PGSQL/PGSQLAssetData.cs
Normal file
295
OpenSim/Data/PGSQL/PGSQLAssetData.cs
Normal file
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for the Asset server
|
||||
/// </summary>
|
||||
public class PGSQLAssetData : AssetDataBase
|
||||
{
|
||||
private const string _migrationStore = "AssetStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private long m_ticksToEpoch;
|
||||
/// <summary>
|
||||
/// Database manager
|
||||
/// </summary>
|
||||
private PGSQLManager m_database;
|
||||
private string m_connectionString;
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
override public void Dispose() { }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Initialises asset interface</para>
|
||||
/// </summary>
|
||||
// [Obsolete("Cannot be default-initialized!")]
|
||||
override public void Initialise()
|
||||
{
|
||||
m_log.Info("[PGSQLAssetData]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises asset interface
|
||||
/// </summary>
|
||||
/// <para>
|
||||
/// a string instead of file, if someone writes the support
|
||||
/// </para>
|
||||
/// <param name="connectionString">connect string</param>
|
||||
override public void Initialise(string connectionString)
|
||||
{
|
||||
m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
|
||||
|
||||
m_database = new PGSQLManager(connectionString);
|
||||
m_connectionString = connectionString;
|
||||
|
||||
//New migration to check for DB changes
|
||||
m_database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Database provider version.
|
||||
/// </summary>
|
||||
override public string Version
|
||||
{
|
||||
get { return m_database.getVersion(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider.
|
||||
/// </summary>
|
||||
override public string Name
|
||||
{
|
||||
get { return "PGSQL Asset storage engine"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAssetDataPlugin Members
|
||||
|
||||
/// <summary>
|
||||
/// Fetch Asset from m_database
|
||||
/// </summary>
|
||||
/// <param name="assetID">the asset UUID</param>
|
||||
/// <returns></returns>
|
||||
override public AssetBase GetAsset(UUID assetID)
|
||||
{
|
||||
string sql = "SELECT * FROM assets WHERE id = :id";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("id", assetID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
AssetBase asset = new AssetBase(
|
||||
DBGuid.FromDB(reader["id"]),
|
||||
(string)reader["name"],
|
||||
Convert.ToSByte(reader["assetType"]),
|
||||
reader["creatorid"].ToString()
|
||||
);
|
||||
// Region Main
|
||||
asset.Description = (string)reader["description"];
|
||||
asset.Local = Convert.ToBoolean(reader["local"]);
|
||||
asset.Temporary = Convert.ToBoolean(reader["temporary"]);
|
||||
asset.Flags = (AssetFlags)(Convert.ToInt32(reader["asset_flags"]));
|
||||
asset.Data = (byte[])reader["data"];
|
||||
return asset;
|
||||
}
|
||||
return null; // throw new Exception("No rows to return");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create asset in m_database
|
||||
/// </summary>
|
||||
/// <param name="asset">the asset</param>
|
||||
override public void StoreAsset(AssetBase asset)
|
||||
{
|
||||
|
||||
string sql =
|
||||
@"UPDATE assets set name = :name, description = :description, " + "\"assetType\" " + @" = :assetType,
|
||||
local = :local, temporary = :temporary, creatorid = :creatorid, data = :data
|
||||
WHERE id=:id;
|
||||
|
||||
INSERT INTO assets
|
||||
(id, name, description, " + "\"assetType\" " + @", local,
|
||||
temporary, create_time, access_time, creatorid, asset_flags, data)
|
||||
Select :id, :name, :description, :assetType, :local,
|
||||
:temporary, :create_time, :access_time, :creatorid, :asset_flags, :data
|
||||
Where not EXISTS(SELECT * FROM assets WHERE id=:id)
|
||||
";
|
||||
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > 64)
|
||||
{
|
||||
assetName = asset.Name.Substring(0, 64);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
||||
}
|
||||
|
||||
string assetDescription = asset.Description;
|
||||
if (asset.Description.Length > 64)
|
||||
{
|
||||
assetDescription = asset.Description.Substring(0, 64);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
||||
}
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
|
||||
command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
|
||||
command.Parameters.Add(m_database.CreateParameter("name", assetName));
|
||||
command.Parameters.Add(m_database.CreateParameter("description", assetDescription));
|
||||
command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
|
||||
command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
|
||||
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
|
||||
command.Parameters.Add(m_database.CreateParameter("access_time", now));
|
||||
command.Parameters.Add(m_database.CreateParameter("create_time", now));
|
||||
command.Parameters.Add(m_database.CreateParameter("asset_flags", (int)asset.Flags));
|
||||
command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID));
|
||||
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
m_log.Error("[ASSET DB]: Error storing item :" + e.Message + " sql "+sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Commented out since currently unused - this probably should be called in GetAsset()
|
||||
// private void UpdateAccessTime(AssetBase asset)
|
||||
// {
|
||||
// using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = :access_time WHERE id=:id"))
|
||||
// {
|
||||
// int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
|
||||
// cmd.Parameters.AddWithValue(":id", asset.FullID.ToString());
|
||||
// cmd.Parameters.AddWithValue(":access_time", now);
|
||||
// try
|
||||
// {
|
||||
// cmd.ExecuteNonQuery();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// m_log.Error(e.ToString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Check if asset exist in m_database
|
||||
/// </summary>
|
||||
/// <param name="uuid"></param>
|
||||
/// <returns>true if exist.</returns>
|
||||
override public bool ExistsAsset(UUID uuid)
|
||||
{
|
||||
if (GetAsset(uuid) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of AssetMetadata objects. The list is a subset of
|
||||
/// the entire data set offset by <paramref name="start" /> containing
|
||||
/// <paramref name="count" /> elements.
|
||||
/// </summary>
|
||||
/// <param name="start">The number of results to discard from the total data set.</param>
|
||||
/// <param name="count">The number of rows the returned list should contain.</param>
|
||||
/// <returns>A list of AssetMetadata objects.</returns>
|
||||
public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
|
||||
{
|
||||
List<AssetMetadata> retList = new List<AssetMetadata>(count);
|
||||
string sql = @" SELECT id, name, description, " + "\"assetType\"" + @", temporary, creatorid
|
||||
FROM assets
|
||||
order by id
|
||||
limit :stop
|
||||
offset :start;";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("start", start));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
AssetMetadata metadata = new AssetMetadata();
|
||||
metadata.FullID = DBGuid.FromDB(reader["id"]);
|
||||
metadata.Name = (string)reader["name"];
|
||||
metadata.Description = (string)reader["description"];
|
||||
metadata.Type = Convert.ToSByte(reader["assetType"]);
|
||||
metadata.Temporary = Convert.ToBoolean(reader["temporary"]);
|
||||
metadata.CreatorID = (string)reader["creatorid"];
|
||||
retList.Add(metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
254
OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs
Normal file
254
OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLAuthenticationData : IAuthenticationData
|
||||
{
|
||||
private string m_Realm;
|
||||
private List<string> m_ColumnNames = null;
|
||||
private int m_LastExpire = 0;
|
||||
private string m_ConnectionString;
|
||||
private PGSQLManager m_database;
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSQLAuthenticationData(string connectionString, string realm)
|
||||
{
|
||||
m_Realm = realm;
|
||||
m_ConnectionString = connectionString;
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "AuthStore");
|
||||
m_database = new PGSQLManager(m_ConnectionString);
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public AuthenticationData Get(UUID principalID)
|
||||
{
|
||||
AuthenticationData ret = new AuthenticationData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
|
||||
string sql = string.Format("select * from {0} where uuid = :principalID", m_Realm);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader result = cmd.ExecuteReader())
|
||||
{
|
||||
if (result.Read())
|
||||
{
|
||||
ret.PrincipalID = principalID;
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "UUID"||s == "uuid")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Store(AuthenticationData data)
|
||||
{
|
||||
if (data.Data.ContainsKey("UUID"))
|
||||
data.Data.Remove("UUID");
|
||||
if (data.Data.ContainsKey("uuid"))
|
||||
data.Data.Remove("uuid");
|
||||
|
||||
/*
|
||||
Dictionary<string, object> oAuth = new Dictionary<string, object>();
|
||||
|
||||
foreach (KeyValuePair<string, object> oDado in data.Data)
|
||||
{
|
||||
if (oDado.Key != oDado.Key.ToLower())
|
||||
{
|
||||
oAuth.Add(oDado.Key.ToLower(), oDado.Value);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<string, object> oDado in data.Data)
|
||||
{
|
||||
if (!oAuth.ContainsKey(oDado.Key.ToLower())) {
|
||||
oAuth.Add(oDado.Key.ToLower(), oDado.Value);
|
||||
}
|
||||
}
|
||||
*/
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
StringBuilder updateBuilder = new StringBuilder();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
||||
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
{
|
||||
if (!first)
|
||||
updateBuilder.Append(", ");
|
||||
updateBuilder.AppendFormat("\"{0}\" = :{0}",field);
|
||||
|
||||
first = false;
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field]));
|
||||
}
|
||||
|
||||
updateBuilder.Append(" where uuid = :principalID");
|
||||
|
||||
cmd.CommandText = updateBuilder.ToString();
|
||||
cmd.Connection = conn;
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", data.PrincipalID));
|
||||
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
StringBuilder insertBuilder = new StringBuilder();
|
||||
|
||||
insertBuilder.AppendFormat("insert into {0} (uuid, \"", m_Realm);
|
||||
insertBuilder.Append(String.Join("\", \"", fields));
|
||||
insertBuilder.Append("\") values (:principalID, :");
|
||||
insertBuilder.Append(String.Join(", :", fields));
|
||||
insertBuilder.Append(")");
|
||||
|
||||
cmd.CommandText = insertBuilder.ToString();
|
||||
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetDataItem(UUID principalID, string item, string value)
|
||||
{
|
||||
string sql = string.Format("update {0} set {1} = :{1} where uuid = :UUID", m_Realm, item);
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + item, value));
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetToken(UUID principalID, string token, int lifetime)
|
||||
{
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
string sql = "insert into tokens (uuid, token, validity) values (:principalID, :token, :lifetime)";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("token", token));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("lifetime", DateTime.Now.AddMinutes(lifetime)));
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CheckToken(UUID principalID, string token, int lifetime)
|
||||
{
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
DateTime validDate = DateTime.Now.AddMinutes(lifetime);
|
||||
string sql = "update tokens set validity = :validDate where uuid = :principalID and token = :token and validity > (CURRENT_DATE + CURRENT_TIME)";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("token", token));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("validDate", validDate));
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DoExpire()
|
||||
{
|
||||
DateTime currentDateTime = DateTime.Now;
|
||||
string sql = "delete from tokens where validity < :currentDateTime";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
cmd.Parameters.Add(m_database.CreateParameter("currentDateTime", currentDateTime));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
m_LastExpire = System.Environment.TickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
72
OpenSim/Data/PGSQL/PGSQLAvatarData.cs
Normal file
72
OpenSim/Data/PGSQL/PGSQLAvatarData.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for Avatar Storage
|
||||
/// </summary>
|
||||
public class PGSQLAvatarData : PGSQLGenericTableHandler<AvatarBaseData>,
|
||||
IAvatarData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLAvatarData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "Avatar")
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(UUID principalID, string name)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("DELETE FROM {0} where \"PrincipalID\" = :PrincipalID and \"Name\" = :Name", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("Name", name));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
602
OpenSim/Data/PGSQL/PGSQLEstateData.cs
Normal file
602
OpenSim/Data/PGSQL/PGSQLEstateData.cs
Normal file
@@ -0,0 +1,602 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using System.Data;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLEstateStore : IEstateDataStore
|
||||
{
|
||||
private const string _migrationStore = "EstateStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private PGSQLManager _Database;
|
||||
private string m_connectionString;
|
||||
private FieldInfo[] _Fields;
|
||||
private Dictionary<string, FieldInfo> _FieldMap = new Dictionary<string, FieldInfo>();
|
||||
|
||||
#region Public methods
|
||||
|
||||
public PGSQLEstateStore()
|
||||
{
|
||||
}
|
||||
|
||||
public PGSQLEstateStore(string connectionString)
|
||||
{
|
||||
Initialise(connectionString);
|
||||
}
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the estatedata class.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">connectionString.</param>
|
||||
public void Initialise(string connectionString)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
_Database = new PGSQLManager(connectionString);
|
||||
}
|
||||
|
||||
//Migration settings
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "EstateStore");
|
||||
m.Update();
|
||||
}
|
||||
|
||||
//Interesting way to get parameters! Maybe implement that also with other types
|
||||
Type t = typeof(EstateSettings);
|
||||
_Fields = t.GetFields(BindingFlags.NonPublic |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.DeclaredOnly);
|
||||
|
||||
foreach (FieldInfo f in _Fields)
|
||||
{
|
||||
if (f.Name.Substring(0, 2) == "m_")
|
||||
_FieldMap[f.Name.Substring(2)] = f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the estate settings.
|
||||
/// </summary>
|
||||
/// <param name="regionID">region ID.</param>
|
||||
/// <returns></returns>
|
||||
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
|
||||
string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) +
|
||||
"\" from estate_map left join estate_settings on estate_map.\"EstateID\" = estate_settings.\"EstateID\" " +
|
||||
" where estate_settings.\"EstateID\" is not null and \"RegionID\" = :RegionID";
|
||||
|
||||
bool insertEstate = false;
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("RegionID", regionID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
FieldInfo f = _FieldMap[name];
|
||||
object v = reader[name];
|
||||
if (f.FieldType == typeof(bool))
|
||||
{
|
||||
f.SetValue(es, v);
|
||||
}
|
||||
else if (f.FieldType == typeof(UUID))
|
||||
{
|
||||
UUID estUUID = UUID.Zero;
|
||||
|
||||
UUID.TryParse(v.ToString(), out estUUID);
|
||||
|
||||
f.SetValue(es, estUUID);
|
||||
}
|
||||
else if (f.FieldType == typeof(string))
|
||||
{
|
||||
f.SetValue(es, v.ToString());
|
||||
}
|
||||
else if (f.FieldType == typeof(UInt32))
|
||||
{
|
||||
f.SetValue(es, Convert.ToUInt32(v));
|
||||
}
|
||||
else if (f.FieldType == typeof(Single))
|
||||
{
|
||||
f.SetValue(es, Convert.ToSingle(v));
|
||||
}
|
||||
else
|
||||
f.SetValue(es, v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
insertEstate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insertEstate && create)
|
||||
{
|
||||
DoCreate(es);
|
||||
LinkRegion(regionID, (int)es.EstateID);
|
||||
}
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
//Set event
|
||||
es.OnSave += StoreEstateSettings;
|
||||
return es;
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
es.OnSave += StoreEstateSettings;
|
||||
|
||||
DoCreate(es);
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
return es;
|
||||
}
|
||||
|
||||
private void DoCreate(EstateSettings es)
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray()));
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand insertCommand = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
insertCommand.CommandText = sql;
|
||||
|
||||
foreach (string name in names)
|
||||
{
|
||||
insertCommand.Parameters.Add(_Database.CreateParameter("" + name, _FieldMap[name].GetValue(es)));
|
||||
}
|
||||
//NpgsqlParameter idParameter = new NpgsqlParameter("ID", SqlDbType.Int);
|
||||
//idParameter.Direction = ParameterDirection.Output;
|
||||
//insertCommand.Parameters.Add(idParameter);
|
||||
conn.Open();
|
||||
|
||||
es.EstateID = 100;
|
||||
|
||||
if (insertCommand.ExecuteNonQuery() > 0)
|
||||
{
|
||||
insertCommand.CommandText = "Select cast(lastval() as int) as ID ;";
|
||||
|
||||
using (NpgsqlDataReader result = insertCommand.ExecuteReader())
|
||||
{
|
||||
if (result.Read())
|
||||
{
|
||||
es.EstateID = (uint)result.GetInt32(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO check if this is needed??
|
||||
es.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the estate settings.
|
||||
/// </summary>
|
||||
/// <param name="es">estate settings</param>
|
||||
public void StoreEstateSettings(EstateSettings es)
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = string.Format("UPDATE estate_settings SET ");
|
||||
foreach (string name in names)
|
||||
{
|
||||
sql += "\"" + name + "\" = :" + name + ", ";
|
||||
}
|
||||
sql = sql.Remove(sql.LastIndexOf(","));
|
||||
sql += " WHERE \"EstateID\" = :EstateID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
foreach (string name in names)
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("" + name, _FieldMap[name].GetValue(es)));
|
||||
}
|
||||
|
||||
cmd.Parameters.Add(_Database.CreateParameter("EstateID", es.EstateID));
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
SaveBanList(es);
|
||||
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
||||
SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess);
|
||||
SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private string[] FieldList
|
||||
{
|
||||
get { return new List<string>(_FieldMap.Keys).ToArray(); }
|
||||
}
|
||||
|
||||
private void LoadBanList(EstateSettings es)
|
||||
{
|
||||
es.ClearBans();
|
||||
|
||||
string sql = "select \"bannedUUID\" from estateban where \"EstateID\" = :EstateID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
NpgsqlParameter idParameter = new NpgsqlParameter("EstateID", DbType.Int32);
|
||||
idParameter.Value = es.EstateID;
|
||||
cmd.Parameters.Add(idParameter);
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
EstateBan eb = new EstateBan();
|
||||
|
||||
eb.BannedUserID = new UUID((Guid)reader["bannedUUID"]); //uuid;
|
||||
eb.BannedHostAddress = "0.0.0.0";
|
||||
eb.BannedHostIPMask = "0.0.0.0";
|
||||
es.AddBan(eb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UUID[] LoadUUIDList(uint estateID, string table)
|
||||
{
|
||||
List<UUID> uuids = new List<UUID>();
|
||||
|
||||
string sql = string.Format("select uuid from {0} where \"EstateID\" = :EstateID", table);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("EstateID", estateID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
uuids.Add(new UUID((Guid)reader["uuid"])); //uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return uuids.ToArray();
|
||||
}
|
||||
|
||||
private void SaveBanList(EstateSettings es)
|
||||
{
|
||||
//Delete first
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from estateban where \"EstateID\" = :EstateID";
|
||||
cmd.Parameters.AddWithValue("EstateID", (int)es.EstateID);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
//Insert after
|
||||
cmd.CommandText = "insert into estateban (\"EstateID\", \"bannedUUID\",\"bannedIp\", \"bannedIpHostMask\", \"bannedNameMask\") values ( :EstateID, :bannedUUID, '','','' )";
|
||||
cmd.Parameters.AddWithValue("bannedUUID", Guid.Empty);
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
{
|
||||
cmd.Parameters["bannedUUID"].Value = b.BannedUserID.Guid;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveUUIDList(uint estateID, string table, UUID[] data)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateID", (int)estateID);
|
||||
cmd.CommandText = string.Format("delete from {0} where \"EstateID\" = :EstateID", table);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = string.Format("insert into {0} (\"EstateID\", uuid) values ( :EstateID, :uuid )", table);
|
||||
cmd.Parameters.AddWithValue("uuid", Guid.Empty);
|
||||
foreach (UUID uuid in data)
|
||||
{
|
||||
cmd.Parameters["uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EstateSettings LoadEstateSettings(int estateID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) + "\" from estate_settings where \"EstateID\" = :EstateID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateID", (int)estateID);
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
FieldInfo f = _FieldMap[name];
|
||||
object v = reader[name];
|
||||
if (f.FieldType == typeof(bool))
|
||||
{
|
||||
f.SetValue(es, Convert.ToInt32(v) != 0);
|
||||
}
|
||||
else if (f.FieldType == typeof(UUID))
|
||||
{
|
||||
f.SetValue(es, new UUID((Guid)v)); // uuid);
|
||||
}
|
||||
else if (f.FieldType == typeof(string))
|
||||
{
|
||||
f.SetValue(es, v.ToString());
|
||||
}
|
||||
else if (f.FieldType == typeof(UInt32))
|
||||
{
|
||||
f.SetValue(es, Convert.ToUInt32(v));
|
||||
}
|
||||
else if (f.FieldType == typeof(Single))
|
||||
{
|
||||
f.SetValue(es, Convert.ToSingle(v));
|
||||
}
|
||||
else
|
||||
f.SetValue(es, v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
//Set event
|
||||
es.OnSave += StoreEstateSettings;
|
||||
return es;
|
||||
|
||||
}
|
||||
|
||||
public List<EstateSettings> LoadEstateSettingsAll()
|
||||
{
|
||||
List<EstateSettings> allEstateSettings = new List<EstateSettings>();
|
||||
|
||||
List<int> allEstateIds = GetEstatesAll();
|
||||
|
||||
foreach (int estateId in allEstateIds)
|
||||
allEstateSettings.Add(LoadEstateSettings(estateId));
|
||||
|
||||
return allEstateSettings;
|
||||
}
|
||||
|
||||
public List<int> GetEstates(string search)
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select \"EstateID\" from estate_settings where lower(\"EstateName\") = lower(:EstateName)";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateName", search);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<int> GetEstatesAll()
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select \"EstateID\" from estate_settings";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<int> GetEstatesByOwner(UUID ownerID)
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select \"estateID\" from estate_settings where \"EstateOwner\" = :EstateOwner";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateOwner", ownerID);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool LinkRegion(UUID regionID, int estateID)
|
||||
{
|
||||
string deleteSQL = "delete from estate_map where \"RegionID\" = :RegionID";
|
||||
string insertSQL = "insert into estate_map values (:RegionID, :EstateID)";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
NpgsqlTransaction transaction = conn.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(deleteSQL, conn))
|
||||
{
|
||||
cmd.Transaction = transaction;
|
||||
cmd.Parameters.AddWithValue("RegionID", regionID.Guid);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(insertSQL, conn))
|
||||
{
|
||||
cmd.Transaction = transaction;
|
||||
cmd.Parameters.AddWithValue("RegionID", regionID.Guid);
|
||||
cmd.Parameters.AddWithValue("EstateID", estateID);
|
||||
|
||||
int ret = cmd.ExecuteNonQuery();
|
||||
|
||||
if (ret != 0)
|
||||
transaction.Commit();
|
||||
else
|
||||
transaction.Rollback();
|
||||
|
||||
return (ret != 0);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[REGION DB]: LinkRegion failed: " + ex.Message);
|
||||
transaction.Rollback();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<UUID> GetRegions(int estateID)
|
||||
{
|
||||
List<UUID> result = new List<UUID>();
|
||||
string sql = "select \"RegionID\" from estate_map where \"EstateID\" = :EstateID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateID", estateID);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(DBGuid.FromDB(reader["RegionID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool DeleteEstate(int estateID)
|
||||
{
|
||||
// TODO: Implementation!
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
111
OpenSim/Data/PGSQL/PGSQLFramework.cs
Normal file
111
OpenSim/Data/PGSQL/PGSQLFramework.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A database interface class to a user profile storage system
|
||||
/// </summary>
|
||||
public class PGSqlFramework
|
||||
{
|
||||
private static readonly log4net.ILog m_log =
|
||||
log4net.LogManager.GetLogger(
|
||||
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected string m_connectionString;
|
||||
protected object m_dbLock = new object();
|
||||
|
||||
protected PGSqlFramework(string connectionString)
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
InitializeMonoSecurity();
|
||||
}
|
||||
|
||||
public void InitializeMonoSecurity()
|
||||
{
|
||||
if (!Util.IsPlatformMono)
|
||||
{
|
||||
|
||||
if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null)
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true");
|
||||
|
||||
AppDomain currentDomain = AppDomain.CurrentDomain;
|
||||
currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Assembly MyAssembly = null;
|
||||
|
||||
if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security")
|
||||
{
|
||||
MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll");
|
||||
}
|
||||
|
||||
//Return the loaded assembly.
|
||||
return MyAssembly;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// All non queries are funneled through one connection
|
||||
// to increase performance a little
|
||||
//
|
||||
protected int ExecuteNonQuery(NpgsqlCommand cmd)
|
||||
{
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
try
|
||||
{
|
||||
return cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.Message, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
116
OpenSim/Data/PGSQL/PGSQLFriendsData.cs
Normal file
116
OpenSim/Data/PGSQL/PGSQLFriendsData.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLFriendsData : PGSQLGenericTableHandler<FriendsData>, IFriendsData
|
||||
{
|
||||
public PGSQLFriendsData(string connectionString, string realm)
|
||||
: base(connectionString, realm, "FriendsStore")
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "FriendsStore");
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool Delete(string principalID, string friend)
|
||||
{
|
||||
UUID princUUID = UUID.Zero;
|
||||
|
||||
bool ret = UUID.TryParse(principalID, out princUUID);
|
||||
|
||||
if (ret)
|
||||
return Delete(princUUID, friend);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Delete(UUID principalID, string friend)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where \"PrincipalID\" = :PrincipalID and \"Friend\" = :Friend", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("Friend", friend));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(string principalID)
|
||||
{
|
||||
UUID princUUID = UUID.Zero;
|
||||
|
||||
bool ret = UUID.TryParse(principalID, out princUUID);
|
||||
|
||||
if (ret)
|
||||
return GetFriends(princUUID);
|
||||
else
|
||||
return new FriendsData[0];
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(UUID principalID)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("select a.*,case when b.\"Flags\" is null then '-1' else b.\"Flags\" end as \"TheirFlags\" from {0} as a " +
|
||||
" left join {0} as b on a.\"PrincipalID\" = b.\"Friend\" and a.\"Friend\" = b.\"PrincipalID\" " +
|
||||
" where a.\"PrincipalID\" = :PrincipalID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(Guid principalID)
|
||||
{
|
||||
return GetFriends(principalID);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
519
OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
Normal file
519
OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
Normal file
@@ -0,0 +1,519 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using System.Text;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLGenericTableHandler<T> : PGSqlFramework where T : class, new()
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected string m_ConnectionString;
|
||||
protected PGSQLManager m_database; //used for parameter type translation
|
||||
protected Dictionary<string, FieldInfo> m_Fields =
|
||||
new Dictionary<string, FieldInfo>();
|
||||
|
||||
protected Dictionary<string, string> m_FieldTypes = new Dictionary<string, string>();
|
||||
|
||||
protected List<string> m_ColumnNames = null;
|
||||
protected string m_Realm;
|
||||
protected FieldInfo m_DataField = null;
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSQLGenericTableHandler(string connectionString,
|
||||
string realm, string storeName)
|
||||
: base(connectionString)
|
||||
{
|
||||
m_Realm = realm;
|
||||
|
||||
m_ConnectionString = connectionString;
|
||||
|
||||
if (storeName != String.Empty)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, storeName);
|
||||
m.Update();
|
||||
}
|
||||
|
||||
}
|
||||
m_database = new PGSQLManager(m_ConnectionString);
|
||||
|
||||
Type t = typeof(T);
|
||||
FieldInfo[] fields = t.GetFields(BindingFlags.Public |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.DeclaredOnly);
|
||||
|
||||
LoadFieldTypes();
|
||||
|
||||
if (fields.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
if (f.Name != "Data")
|
||||
m_Fields[f.Name] = f;
|
||||
else
|
||||
m_DataField = f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LoadFieldTypes()
|
||||
{
|
||||
m_FieldTypes = new Dictionary<string, string>();
|
||||
|
||||
string query = string.Format(@"select column_name,data_type
|
||||
from INFORMATION_SCHEMA.COLUMNS
|
||||
where table_name = lower('{0}');
|
||||
|
||||
", m_Realm);
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader rdr = cmd.ExecuteReader())
|
||||
{
|
||||
while (rdr.Read())
|
||||
{
|
||||
// query produces 0 to many rows of single column, so always add the first item in each row
|
||||
m_FieldTypes.Add((string)rdr[0], (string)rdr[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckColumnNames(NpgsqlDataReader reader)
|
||||
{
|
||||
if (m_ColumnNames != null)
|
||||
return;
|
||||
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = reader.GetSchemaTable();
|
||||
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
{
|
||||
if (row["ColumnName"] != null &&
|
||||
(!m_Fields.ContainsKey(row["ColumnName"].ToString())))
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// TODO GET CONSTRAINTS FROM POSTGRESQL
|
||||
private List<string> GetConstraints()
|
||||
{
|
||||
List<string> constraints = new List<string>();
|
||||
string query = string.Format(@"SELECT kcu.column_name
|
||||
FROM information_schema.table_constraints tc
|
||||
LEFT JOIN information_schema.key_column_usage kcu
|
||||
ON tc.constraint_catalog = kcu.constraint_catalog
|
||||
AND tc.constraint_schema = kcu.constraint_schema
|
||||
AND tc.constraint_name = kcu.constraint_name
|
||||
|
||||
LEFT JOIN information_schema.referential_constraints rc
|
||||
ON tc.constraint_catalog = rc.constraint_catalog
|
||||
AND tc.constraint_schema = rc.constraint_schema
|
||||
AND tc.constraint_name = rc.constraint_name
|
||||
|
||||
LEFT JOIN information_schema.constraint_column_usage ccu
|
||||
ON rc.unique_constraint_catalog = ccu.constraint_catalog
|
||||
AND rc.unique_constraint_schema = ccu.constraint_schema
|
||||
AND rc.unique_constraint_name = ccu.constraint_name
|
||||
|
||||
where tc.table_name = lower('{0}')
|
||||
and lower(tc.constraint_type) in ('primary key')
|
||||
and kcu.column_name is not null
|
||||
;", m_Realm);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader rdr = cmd.ExecuteReader())
|
||||
{
|
||||
while (rdr.Read())
|
||||
{
|
||||
// query produces 0 to many rows of single column, so always add the first item in each row
|
||||
constraints.Add((string)rdr[0]);
|
||||
}
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] Get(string field, string key)
|
||||
{
|
||||
return Get(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public virtual T[] Get(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return new T[0];
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
if ( m_FieldTypes.ContainsKey(fields[i]) )
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
|
||||
terms.Add(" \"" + fields[i] + "\" = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
protected T[] DoQuery(NpgsqlCommand cmd)
|
||||
{
|
||||
List<T> result = new List<T>();
|
||||
if (cmd.Connection == null)
|
||||
{
|
||||
cmd.Connection = new NpgsqlConnection(m_connectionString);
|
||||
}
|
||||
if (cmd.Connection.State == ConnectionState.Closed)
|
||||
{
|
||||
cmd.Connection.Open();
|
||||
}
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader == null)
|
||||
return new T[0];
|
||||
|
||||
CheckColumnNames(reader);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
T row = new T();
|
||||
|
||||
foreach (string name in m_Fields.Keys)
|
||||
{
|
||||
if (m_Fields[name].GetValue(row) is bool)
|
||||
{
|
||||
int v = Convert.ToInt32(reader[name]);
|
||||
m_Fields[name].SetValue(row, v != 0 ? true : false);
|
||||
}
|
||||
else if (m_Fields[name].GetValue(row) is UUID)
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
|
||||
UUID.TryParse(reader[name].ToString(), out uuid);
|
||||
m_Fields[name].SetValue(row, uuid);
|
||||
}
|
||||
else if (m_Fields[name].GetValue(row) is int)
|
||||
{
|
||||
int v = Convert.ToInt32(reader[name]);
|
||||
m_Fields[name].SetValue(row, v);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Fields[name].SetValue(row, reader[name]);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
new Dictionary<string, string>();
|
||||
|
||||
foreach (string col in m_ColumnNames)
|
||||
{
|
||||
data[col] = reader[col].ToString();
|
||||
|
||||
if (data[col] == null)
|
||||
data[col] = String.Empty;
|
||||
}
|
||||
|
||||
m_DataField.SetValue(row, data);
|
||||
}
|
||||
|
||||
result.Add(row);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] Get(string where)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
||||
m_Realm, where);
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
|
||||
//m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where);
|
||||
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Store(T row)
|
||||
{
|
||||
List<string> constraintFields = GetConstraints();
|
||||
List<KeyValuePair<string, string>> constraints = new List<KeyValuePair<string, string>>();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
StringBuilder query = new StringBuilder();
|
||||
List<String> names = new List<String>();
|
||||
List<String> values = new List<String>();
|
||||
|
||||
foreach (FieldInfo fi in m_Fields.Values)
|
||||
{
|
||||
names.Add(fi.Name);
|
||||
values.Add(":" + fi.Name);
|
||||
// Temporarily return more information about what field is unexpectedly null for
|
||||
// http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the
|
||||
// InventoryTransferModule or we may be required to substitute a DBNull here.
|
||||
if (fi.GetValue(row) == null)
|
||||
throw new NullReferenceException(
|
||||
string.Format(
|
||||
"[PGSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null",
|
||||
fi.Name, row));
|
||||
|
||||
if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name))
|
||||
{
|
||||
constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString() ));
|
||||
}
|
||||
if (m_FieldTypes.ContainsKey(fi.Name))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row), m_FieldTypes[fi.Name]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row)));
|
||||
}
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
(Dictionary<string, string>)m_DataField.GetValue(row);
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp in data)
|
||||
{
|
||||
if (constraintFields.Count > 0 && constraintFields.Contains(kvp.Key))
|
||||
{
|
||||
constraints.Add(new KeyValuePair<string, string>(kvp.Key, kvp.Key));
|
||||
}
|
||||
names.Add(kvp.Key);
|
||||
values.Add(":" + kvp.Key);
|
||||
|
||||
if (m_FieldTypes.ContainsKey(kvp.Key))
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value, m_FieldTypes[kvp.Key]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
query.AppendFormat("UPDATE {0} SET ", m_Realm);
|
||||
int i = 0;
|
||||
for (i = 0; i < names.Count - 1; i++)
|
||||
{
|
||||
query.AppendFormat("\"{0}\" = {1}, ", names[i], values[i]);
|
||||
}
|
||||
query.AppendFormat("\"{0}\" = {1} ", names[i], values[i]);
|
||||
if (constraints.Count > 0)
|
||||
{
|
||||
List<string> terms = new List<string>();
|
||||
for (int j = 0; j < constraints.Count; j++)
|
||||
{
|
||||
terms.Add(String.Format(" \"{0}\" = :{0}", constraints[j].Key));
|
||||
}
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
query.AppendFormat(" WHERE {0} ", where);
|
||||
|
||||
}
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query.ToString();
|
||||
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
//m_log.WarnFormat("[PGSQLGenericTable]: Updating {0}", m_Realm);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// assume record has not yet been inserted
|
||||
|
||||
query = new StringBuilder();
|
||||
query.AppendFormat("INSERT INTO {0} (\"", m_Realm);
|
||||
query.Append(String.Join("\",\"", names.ToArray()));
|
||||
query.Append("\") values (" + String.Join(",", values.ToArray()) + ")");
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query.ToString();
|
||||
|
||||
// m_log.WarnFormat("[PGSQLGenericTable]: Inserting into {0} sql {1}", m_Realm, cmd.CommandText);
|
||||
|
||||
if (conn.State != ConnectionState.Open)
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Delete(string field, string key)
|
||||
{
|
||||
return Delete(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public virtual bool Delete(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return false;
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
if (m_FieldTypes.ContainsKey(fields[i]))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
|
||||
terms.Add(" \"" + fields[i] + "\" = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
|
||||
string query = String.Format("DELETE FROM {0} WHERE {1}", m_Realm, where);
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
//m_log.Warn("[PGSQLGenericTable]: " + deleteCommand);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public long GetCount(string field, string key)
|
||||
{
|
||||
return GetCount(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public long GetCount(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return 0;
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
cmd.Parameters.AddWithValue(fields[i], keys[i]);
|
||||
terms.Add("\"" + fields[i] + "\" = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" and ", terms.ToArray());
|
||||
|
||||
string query = String.Format("select count(*) from {0} where {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
Object result = DoQueryScalar(cmd);
|
||||
|
||||
return Convert.ToInt64(result);
|
||||
}
|
||||
}
|
||||
|
||||
public long GetCount(string where)
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
string query = String.Format("select count(*) from {0} where {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
object result = DoQueryScalar(cmd);
|
||||
|
||||
return Convert.ToInt64(result);
|
||||
}
|
||||
}
|
||||
|
||||
public object DoQueryScalar(NpgsqlCommand cmd)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
return cmd.ExecuteScalar();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
OpenSim/Data/PGSQL/PGSQLGridUserData.cs
Normal file
68
OpenSim/Data/PGSQL/PGSQLGridUserData.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for Avatar Storage
|
||||
/// </summary>
|
||||
public class PGSQLGridUserData : PGSQLGenericTableHandler<GridUserData>,
|
||||
IGridUserData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLGridUserData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "GridUserStore")
|
||||
{
|
||||
}
|
||||
|
||||
public new GridUserData Get(string userID)
|
||||
{
|
||||
GridUserData[] ret = Get("UserID", userID);
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public GridUserData[] GetAll(string userID)
|
||||
{
|
||||
return base.Get(String.Format("\"UserID\" LIKE '{0}%'", userID));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
481
OpenSim/Data/PGSQL/PGSQLGroupsData.cs
Normal file
481
OpenSim/Data/PGSQL/PGSQLGroupsData.cs
Normal file
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLGroupsData : IGroupsData
|
||||
{
|
||||
private PGSqlGroupsGroupsHandler m_Groups;
|
||||
private PGSqlGroupsMembershipHandler m_Membership;
|
||||
private PGSqlGroupsRolesHandler m_Roles;
|
||||
private PGSqlGroupsRoleMembershipHandler m_RoleMembership;
|
||||
private PGSqlGroupsInvitesHandler m_Invites;
|
||||
private PGSqlGroupsNoticesHandler m_Notices;
|
||||
private PGSqlGroupsPrincipalsHandler m_Principals;
|
||||
|
||||
public PGSQLGroupsData(string connectionString, string realm)
|
||||
{
|
||||
m_Groups = new PGSqlGroupsGroupsHandler(connectionString, realm + "_groups", realm + "_Store");
|
||||
m_Membership = new PGSqlGroupsMembershipHandler(connectionString, realm + "_membership");
|
||||
m_Roles = new PGSqlGroupsRolesHandler(connectionString, realm + "_roles");
|
||||
m_RoleMembership = new PGSqlGroupsRoleMembershipHandler(connectionString, realm + "_rolemembership");
|
||||
m_Invites = new PGSqlGroupsInvitesHandler(connectionString, realm + "_invites");
|
||||
m_Notices = new PGSqlGroupsNoticesHandler(connectionString, realm + "_notices");
|
||||
m_Principals = new PGSqlGroupsPrincipalsHandler(connectionString, realm + "_principals");
|
||||
}
|
||||
|
||||
#region groups table
|
||||
public bool StoreGroup(GroupData data)
|
||||
{
|
||||
return m_Groups.Store(data);
|
||||
}
|
||||
|
||||
public GroupData RetrieveGroup(UUID groupID)
|
||||
{
|
||||
GroupData[] groups = m_Groups.Get("GroupID", groupID.ToString());
|
||||
if (groups.Length > 0)
|
||||
return groups[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public GroupData RetrieveGroup(string name)
|
||||
{
|
||||
GroupData[] groups = m_Groups.Get("Name", name);
|
||||
if (groups.Length > 0)
|
||||
return groups[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public GroupData[] RetrieveGroups(string pattern)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pattern)) // True for where clause
|
||||
pattern = " true ORDER BY lower(\"Name\") LIMIT 100";
|
||||
else
|
||||
pattern = string.Format(" lower(\"Name\") LIKE lower('%{0}%') ORDER BY lower(\"Name\") LIMIT 100", pattern);
|
||||
|
||||
return m_Groups.Get(pattern);
|
||||
}
|
||||
|
||||
public bool DeleteGroup(UUID groupID)
|
||||
{
|
||||
return m_Groups.Delete("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
public int GroupsCount()
|
||||
{
|
||||
return (int)m_Groups.GetCount(" \"Location\" = \"\"");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region membership table
|
||||
public MembershipData[] RetrieveMembers(UUID groupID)
|
||||
{
|
||||
return m_Membership.Get("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
public MembershipData RetrieveMember(UUID groupID, string pricipalID)
|
||||
{
|
||||
MembershipData[] m = m_Membership.Get(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), pricipalID });
|
||||
if (m != null && m.Length > 0)
|
||||
return m[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MembershipData[] RetrieveMemberships(string pricipalID)
|
||||
{
|
||||
return m_Membership.Get("PrincipalID", pricipalID.ToString());
|
||||
}
|
||||
|
||||
public bool StoreMember(MembershipData data)
|
||||
{
|
||||
return m_Membership.Store(data);
|
||||
}
|
||||
|
||||
public bool DeleteMember(UUID groupID, string pricipalID)
|
||||
{
|
||||
return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), pricipalID });
|
||||
}
|
||||
|
||||
public int MemberCount(UUID groupID)
|
||||
{
|
||||
return (int)m_Membership.GetCount("GroupID", groupID.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region roles table
|
||||
public bool StoreRole(RoleData data)
|
||||
{
|
||||
return m_Roles.Store(data);
|
||||
}
|
||||
|
||||
public RoleData RetrieveRole(UUID groupID, UUID roleID)
|
||||
{
|
||||
RoleData[] data = m_Roles.Get(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
|
||||
if (data != null && data.Length > 0)
|
||||
return data[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RoleData[] RetrieveRoles(UUID groupID)
|
||||
{
|
||||
//return m_Roles.RetrieveRoles(groupID);
|
||||
return m_Roles.Get("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
public bool DeleteRole(UUID groupID, UUID roleID)
|
||||
{
|
||||
return m_Roles.Delete(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
}
|
||||
|
||||
public int RoleCount(UUID groupID)
|
||||
{
|
||||
return (int)m_Roles.GetCount("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region rolememberhip table
|
||||
public RoleMembershipData[] RetrieveRolesMembers(UUID groupID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get("GroupID", groupID.ToString());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), principalID.ToString() });
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString(), principalID.ToString() });
|
||||
|
||||
if (data != null && data.Length > 0)
|
||||
return data[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int RoleMemberCount(UUID groupID, UUID roleID)
|
||||
{
|
||||
return (int)m_RoleMembership.GetCount(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
}
|
||||
|
||||
public bool StoreRoleMember(RoleMembershipData data)
|
||||
{
|
||||
return m_RoleMembership.Store(data);
|
||||
}
|
||||
|
||||
public bool DeleteRoleMember(RoleMembershipData data)
|
||||
{
|
||||
return m_RoleMembership.Delete(new string[] { "GroupID", "RoleID", "PrincipalID"},
|
||||
new string[] { data.GroupID.ToString(), data.RoleID.ToString(), data.PrincipalID });
|
||||
}
|
||||
|
||||
public bool DeleteMemberAllRoles(UUID groupID, string principalID)
|
||||
{
|
||||
return m_RoleMembership.Delete(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), principalID });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region principals table
|
||||
public bool StorePrincipal(PrincipalData data)
|
||||
{
|
||||
return m_Principals.Store(data);
|
||||
}
|
||||
|
||||
public PrincipalData RetrievePrincipal(string principalID)
|
||||
{
|
||||
PrincipalData[] p = m_Principals.Get("PrincipalID", principalID);
|
||||
if (p != null && p.Length > 0)
|
||||
return p[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool DeletePrincipal(string principalID)
|
||||
{
|
||||
return m_Principals.Delete("PrincipalID", principalID);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region invites table
|
||||
|
||||
public bool StoreInvitation(InvitationData data)
|
||||
{
|
||||
return m_Invites.Store(data);
|
||||
}
|
||||
|
||||
public InvitationData RetrieveInvitation(UUID inviteID)
|
||||
{
|
||||
InvitationData[] invites = m_Invites.Get("InviteID", inviteID.ToString());
|
||||
|
||||
if (invites != null && invites.Length > 0)
|
||||
return invites[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public InvitationData RetrieveInvitation(UUID groupID, string principalID)
|
||||
{
|
||||
InvitationData[] invites = m_Invites.Get(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), principalID });
|
||||
|
||||
if (invites != null && invites.Length > 0)
|
||||
return invites[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool DeleteInvite(UUID inviteID)
|
||||
{
|
||||
return m_Invites.Delete("InviteID", inviteID.ToString());
|
||||
}
|
||||
|
||||
public void DeleteOldInvites()
|
||||
{
|
||||
m_Invites.DeleteOld();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region notices table
|
||||
|
||||
public bool StoreNotice(NoticeData data)
|
||||
{
|
||||
return m_Notices.Store(data);
|
||||
}
|
||||
|
||||
public NoticeData RetrieveNotice(UUID noticeID)
|
||||
{
|
||||
NoticeData[] notices = m_Notices.Get("NoticeID", noticeID.ToString());
|
||||
|
||||
if (notices != null && notices.Length > 0)
|
||||
return notices[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public NoticeData[] RetrieveNotices(UUID groupID)
|
||||
{
|
||||
NoticeData[] notices = m_Notices.Get("GroupID", groupID.ToString());
|
||||
|
||||
return notices;
|
||||
}
|
||||
|
||||
public bool DeleteNotice(UUID noticeID)
|
||||
{
|
||||
return m_Notices.Delete("NoticeID", noticeID.ToString());
|
||||
}
|
||||
|
||||
public void DeleteOldNotices()
|
||||
{
|
||||
m_Notices.DeleteOld();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region combinations
|
||||
public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID)
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
public MembershipData[] RetrievePrincipalGroupMemberships(string principalID)
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class PGSqlGroupsGroupsHandler : PGSQLGenericTableHandler<GroupData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsGroupsHandler(string connectionString, string realm, string store)
|
||||
: base(connectionString, realm, store)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsMembershipHandler : PGSQLGenericTableHandler<MembershipData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsMembershipHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsRolesHandler : PGSQLGenericTableHandler<RoleData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsRolesHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsRoleMembershipHandler : PGSQLGenericTableHandler<RoleMembershipData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsRoleMembershipHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsInvitesHandler : PGSQLGenericTableHandler<InvitationData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsInvitesHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
uint now = (uint)Util.UnixTimeSinceEpoch();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm);
|
||||
cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class PGSqlGroupsNoticesHandler : PGSQLGenericTableHandler<NoticeData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsNoticesHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
uint now = (uint)Util.UnixTimeSinceEpoch();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm);
|
||||
cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class PGSqlGroupsPrincipalsHandler : PGSQLGenericTableHandler<PrincipalData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsPrincipalsHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
80
OpenSim/Data/PGSQL/PGSQLHGTravelData.cs
Normal file
80
OpenSim/Data/PGSQL/PGSQLHGTravelData.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for user grid data
|
||||
/// </summary>
|
||||
public class PGSQLHGTravelData : PGSQLGenericTableHandler<HGTravelingData>, IHGTravelingData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { }
|
||||
|
||||
public HGTravelingData Get(UUID sessionID)
|
||||
{
|
||||
HGTravelingData[] ret = Get("SessionID", sessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public HGTravelingData[] GetSessions(UUID userID)
|
||||
{
|
||||
return base.Get("UserID", userID.ToString());
|
||||
}
|
||||
|
||||
public bool Delete(UUID sessionID)
|
||||
{
|
||||
return Delete("SessionID", sessionID.ToString());
|
||||
}
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format(@"delete from {0} where ""TMStamp"" < CURRENT_DATE - INTERVAL '2 day'", m_Realm);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
831
OpenSim/Data/PGSQL/PGSQLInventoryData.cs
Normal file
831
OpenSim/Data/PGSQL/PGSQLInventoryData.cs
Normal file
@@ -0,0 +1,831 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL interface for the inventory server
|
||||
/// </summary>
|
||||
public class PGSQLInventoryData : IInventoryDataPlugin
|
||||
{
|
||||
private const string _migrationStore = "InventoryStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// The database manager
|
||||
/// </summary>
|
||||
private PGSQLManager database;
|
||||
private string m_connectionString;
|
||||
|
||||
#region IPlugin members
|
||||
|
||||
[Obsolete("Cannot be default-initialized!")]
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Info("[PGSQLInventoryData]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads and initialises the PGSQL inventory storage interface
|
||||
/// </summary>
|
||||
/// <param name="connectionString">connect string</param>
|
||||
/// <remarks>use PGSQL_connection.ini</remarks>
|
||||
public void Initialise(string connectionString)
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
database = new PGSQLManager(connectionString);
|
||||
|
||||
//New migrations check of store
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the name of the DB provider</returns>
|
||||
public string Name
|
||||
{
|
||||
get { return "PGSQL Inventory Data Interface"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes this DB provider
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
database = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the DB provider</returns>
|
||||
public string Version
|
||||
{
|
||||
get { return database.getVersion(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Folder methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of the root folders within a users inventory
|
||||
/// </summary>
|
||||
/// <param name="user">The user whos inventory is to be searched</param>
|
||||
/// <returns>A list of folder objects</returns>
|
||||
public List<InventoryFolderBase> getUserRootFolders(UUID user)
|
||||
{
|
||||
if (user == UUID.Zero)
|
||||
return new List<InventoryFolderBase>();
|
||||
|
||||
return getInventoryFolders(UUID.Zero, user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// see InventoryItemBase.getUserRootFolder
|
||||
/// </summary>
|
||||
/// <param name="user">the User UUID</param>
|
||||
/// <returns></returns>
|
||||
public InventoryFolderBase getUserRootFolder(UUID user)
|
||||
{
|
||||
List<InventoryFolderBase> items = getUserRootFolders(user);
|
||||
|
||||
InventoryFolderBase rootFolder = null;
|
||||
|
||||
// There should only ever be one root folder for a user. However, if there's more
|
||||
// than one we'll simply use the first one rather than failing. It would be even
|
||||
// nicer to print some message to this effect, but this feels like it's too low a
|
||||
// to put such a message out, and it's too minor right now to spare the time to
|
||||
// suitably refactor.
|
||||
if (items.Count > 0)
|
||||
{
|
||||
rootFolder = items[0];
|
||||
}
|
||||
|
||||
return rootFolder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of folders in a users inventory contained within the specified folder
|
||||
/// </summary>
|
||||
/// <param name="parentID">The folder to search</param>
|
||||
/// <returns>A list of inventory folders</returns>
|
||||
public List<InventoryFolderBase> getInventoryFolders(UUID parentID)
|
||||
{
|
||||
return getInventoryFolders(parentID, UUID.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specified inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folderID">The folder to return</param>
|
||||
/// <returns>A folder class</returns>
|
||||
public InventoryFolderBase getInventoryFolder(UUID folderID)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE \"folderID\" = :folderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return readInventoryFolder(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_log.InfoFormat("[INVENTORY DB] : Found no inventory folder with ID : {0}", folderID);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all child folders in the hierarchy from the parent folder and down.
|
||||
/// Does not return the parent folder itself.
|
||||
/// </summary>
|
||||
/// <param name="parentID">The folder to get subfolders for</param>
|
||||
/// <returns>A list of inventory folders</returns>
|
||||
public List<InventoryFolderBase> getFolderHierarchy(UUID parentID)
|
||||
{
|
||||
//Note maybe change this to use a Dataset that loading in all folders of a user and then go throw it that way.
|
||||
//Note this is changed so it opens only one connection to the database and not everytime it wants to get data.
|
||||
|
||||
/* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for
|
||||
* every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL
|
||||
* inventory for a specific user at once.
|
||||
*
|
||||
* Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never
|
||||
* be used, so check for that and return an empty list.
|
||||
*/
|
||||
|
||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||
|
||||
if (parentID == UUID.Zero)
|
||||
return folders;
|
||||
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE \"parentFolderID\" = :parentID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentID", parentID));
|
||||
conn.Open();
|
||||
folders.AddRange(getInventoryFolders(cmd));
|
||||
|
||||
List<InventoryFolderBase> tempFolders = new List<InventoryFolderBase>();
|
||||
|
||||
foreach (InventoryFolderBase folderBase in folders)
|
||||
{
|
||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, cmd));
|
||||
}
|
||||
if (tempFolders.Count > 0)
|
||||
{
|
||||
folders.AddRange(tempFolders);
|
||||
}
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">Folder to create</param>
|
||||
public void addInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = "INSERT INTO inventoryfolders (\"folderID\", \"agentID\", \"parentFolderID\", \"folderName\", type, version) " +
|
||||
" VALUES (:folderID, :agentID, :parentFolderID, :folderName, :type, :version);";
|
||||
|
||||
string folderName = folder.Name;
|
||||
if (folderName.Length > 64)
|
||||
{
|
||||
folderName = folderName.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on add");
|
||||
}
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">Folder to update</param>
|
||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = @"UPDATE inventoryfolders SET ""agentID"" = :agentID,
|
||||
""parentFolderID"" = :parentFolderID,
|
||||
""folderName"" = :folderName,
|
||||
type = :type,
|
||||
version = :version
|
||||
WHERE folderID = :folderID";
|
||||
|
||||
string folderName = folder.Name;
|
||||
if (folderName.Length > 64)
|
||||
{
|
||||
folderName = folderName.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on update");
|
||||
}
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">Folder to update</param>
|
||||
public void moveInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = @"UPDATE inventoryfolders SET ""parentFolderID"" = :parentFolderID WHERE ""folderID"" = :folderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folderID">Id of folder to delete</param>
|
||||
public void deleteInventoryFolder(UUID folderID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryfolders WHERE ""parentFolderID"" = :parentID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
List<InventoryFolderBase> subFolders;
|
||||
cmd.Parameters.Add(database.CreateParameter("parentID", UUID.Zero));
|
||||
conn.Open();
|
||||
subFolders = getFolderHierarchy(folderID, cmd);
|
||||
|
||||
|
||||
//Delete all sub-folders
|
||||
foreach (InventoryFolderBase f in subFolders)
|
||||
{
|
||||
DeleteOneFolder(f.ID, conn);
|
||||
DeleteItemsInFolder(f.ID, conn);
|
||||
}
|
||||
|
||||
//Delete the actual row
|
||||
DeleteOneFolder(folderID, conn);
|
||||
DeleteItemsInFolder(folderID, conn);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Item Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of items in a specified folder
|
||||
/// </summary>
|
||||
/// <param name="folderID">The folder to search</param>
|
||||
/// <returns>A list containing inventory items</returns>
|
||||
public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryitems WHERE ""parentFolderID"" = :parentFolderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folderID));
|
||||
conn.Open();
|
||||
List<InventoryItemBase> items = new List<InventoryItemBase>();
|
||||
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
items.Add(readInventoryItem(reader));
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specified inventory item
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID</param>
|
||||
/// <returns>An inventory item</returns>
|
||||
public InventoryItemBase getInventoryItem(UUID itemID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryitems WHERE ""inventoryID"" = :inventoryID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return readInventoryItem(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[INVENTORY DB]: Found no inventory item with ID : {0}", itemID);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a specified item to the database
|
||||
/// </summary>
|
||||
/// <param name="item">The inventory item</param>
|
||||
public void addInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
if (getInventoryItem(item.ID) != null)
|
||||
{
|
||||
updateInventoryItem(item);
|
||||
return;
|
||||
}
|
||||
|
||||
string sql = @"INSERT INTO inventoryitems
|
||||
(""inventoryID"", ""assetID"", ""assetType"", ""parentFolderID"", ""avatarID"", ""inventoryName"",
|
||||
""inventoryDescription"", ""inventoryNextPermissions"", ""inventoryCurrentPermissions"",
|
||||
""invType"", ""creatorID"", ""inventoryBasePermissions"", ""inventoryEveryOnePermissions"", ""inventoryGroupPermissions"",
|
||||
""salePrice"", ""SaleType"", ""creationDate"", ""groupID"", ""groupOwned"", flags)
|
||||
VALUES
|
||||
(:inventoryID, :assetID, :assetType, :parentFolderID, :avatarID, :inventoryName, :inventoryDescription,
|
||||
:inventoryNextPermissions, :inventoryCurrentPermissions, :invType, :creatorID,
|
||||
:inventoryBasePermissions, :inventoryEveryOnePermissions, :inventoryGroupPermissions, :SalePrice, :SaleType,
|
||||
:creationDate, :groupID, :groupOwned, :flags)";
|
||||
|
||||
string itemName = item.Name;
|
||||
if (item.Name.Length > 64)
|
||||
{
|
||||
itemName = item.Name.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters");
|
||||
}
|
||||
|
||||
string itemDesc = item.Description;
|
||||
if (item.Description.Length > 128)
|
||||
{
|
||||
itemDesc = item.Description.Substring(0, 128);
|
||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters");
|
||||
}
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
||||
command.Parameters.Add(database.CreateParameter("assetType", item.AssetType));
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", item.Folder));
|
||||
command.Parameters.Add(database.CreateParameter("avatarID", item.Owner));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryName", itemName));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryDescription", itemDesc));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
|
||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("SalePrice", item.SalePrice));
|
||||
command.Parameters.Add(database.CreateParameter("SaleType", item.SaleType));
|
||||
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
|
||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error inserting item :" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
sql = @"UPDATE inventoryfolders SET version = version + 1 WHERE ""folderID"" = @folderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", item.Folder.ToString()));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB] Error updating inventory folder for new item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the specified inventory item
|
||||
/// </summary>
|
||||
/// <param name="item">Inventory item to update</param>
|
||||
public void updateInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
string sql = @"UPDATE inventoryitems SET ""assetID"" = :assetID,
|
||||
""assetType"" = :assetType,
|
||||
""parentFolderID"" = :parentFolderID,
|
||||
""avatarID"" = :avatarID,
|
||||
""inventoryName"" = :inventoryName,
|
||||
""inventoryDescription"" = :inventoryDescription,
|
||||
""inventoryNextPermissions"" = :inventoryNextPermissions,
|
||||
""inventoryCurrentPermissions"" = :inventoryCurrentPermissions,
|
||||
""invType"" = :invType,
|
||||
""creatorID"" = :creatorID,
|
||||
""inventoryBasePermissions"" = :inventoryBasePermissions,
|
||||
""inventoryEveryOnePermissions"" = :inventoryEveryOnePermissions,
|
||||
""inventoryGroupPermissions"" = :inventoryGroupPermissions,
|
||||
""salePrice"" = :SalePrice,
|
||||
""saleType"" = :SaleType,
|
||||
""creationDate"" = :creationDate,
|
||||
""groupID"" = :groupID,
|
||||
""groupOwned"" = :groupOwned,
|
||||
flags = :flags
|
||||
WHERE ""inventoryID"" = :inventoryID";
|
||||
|
||||
string itemName = item.Name;
|
||||
if (item.Name.Length > 64)
|
||||
{
|
||||
itemName = item.Name.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters on update");
|
||||
}
|
||||
|
||||
string itemDesc = item.Description;
|
||||
if (item.Description.Length > 128)
|
||||
{
|
||||
itemDesc = item.Description.Substring(0, 128);
|
||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters on update");
|
||||
}
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
||||
command.Parameters.Add(database.CreateParameter("assetType", item.AssetType));
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", item.Folder));
|
||||
command.Parameters.Add(database.CreateParameter("avatarID", item.Owner));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryName", itemName));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryDescription", itemDesc));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
|
||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("SalePrice", item.SalePrice));
|
||||
command.Parameters.Add(database.CreateParameter("SaleType", item.SaleType));
|
||||
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
|
||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error updating item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See IInventoryDataPlugin
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item in inventory database
|
||||
/// </summary>
|
||||
/// <param name="itemID">the item UUID</param>
|
||||
public void deleteInventoryItem(UUID itemID)
|
||||
{
|
||||
string sql = @"DELETE FROM inventoryitems WHERE ""inventoryID""=:inventoryID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error deleting item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InventoryItemBase queryInventoryItem(UUID itemID)
|
||||
{
|
||||
return getInventoryItem(itemID);
|
||||
}
|
||||
|
||||
public InventoryFolderBase queryInventoryFolder(UUID folderID)
|
||||
{
|
||||
return getInventoryFolder(folderID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all activated gesture-items in the inventory of the specified avatar.
|
||||
/// </summary>
|
||||
/// <param name="avatarID">The <see cref="UUID"/> of the avatar</param>
|
||||
/// <returns>
|
||||
/// The list of gestures (<see cref="InventoryItemBase"/>s)
|
||||
/// </returns>
|
||||
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryitems WHERE ""avatarID"" = :uuid AND ""assetType"" = :assetType and flags = 1";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("uuid", avatarID));
|
||||
cmd.Parameters.Add(database.CreateParameter("assetType", (int)AssetType.Gesture));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
List<InventoryItemBase> gestureList = new List<InventoryItemBase>();
|
||||
while (reader.Read())
|
||||
{
|
||||
gestureList.Add(readInventoryItem(reader));
|
||||
}
|
||||
return gestureList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item in inventory database
|
||||
/// </summary>
|
||||
/// <param name="folderID">the item ID</param>
|
||||
/// <param name="connection">connection to the database</param>
|
||||
private void DeleteItemsInFolder(UUID folderID, NpgsqlConnection connection)
|
||||
{
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(@"DELETE FROM inventoryitems WHERE ""folderID""=:folderID", connection))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB] Error deleting item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the folder hierarchy in a loop.
|
||||
/// </summary>
|
||||
/// <param name="parentID">parent ID.</param>
|
||||
/// <param name="command">SQL command/connection to database</param>
|
||||
/// <returns></returns>
|
||||
private static List<InventoryFolderBase> getFolderHierarchy(UUID parentID, NpgsqlCommand command)
|
||||
{
|
||||
command.Parameters["parentID"].Value = parentID.Guid; //.ToString();
|
||||
|
||||
List<InventoryFolderBase> folders = getInventoryFolders(command);
|
||||
|
||||
if (folders.Count > 0)
|
||||
{
|
||||
List<InventoryFolderBase> tempFolders = new List<InventoryFolderBase>();
|
||||
|
||||
foreach (InventoryFolderBase folderBase in folders)
|
||||
{
|
||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, command));
|
||||
}
|
||||
|
||||
if (tempFolders.Count > 0)
|
||||
{
|
||||
folders.AddRange(tempFolders);
|
||||
}
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the inventory folders.
|
||||
/// </summary>
|
||||
/// <param name="parentID">parentID, use UUID.Zero to get root</param>
|
||||
/// <param name="user">user id, use UUID.Zero, if you want all folders from a parentID.</param>
|
||||
/// <returns></returns>
|
||||
private List<InventoryFolderBase> getInventoryFolders(UUID parentID, UUID user)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryfolders WHERE ""parentFolderID"" = :parentID AND ""agentID"" = :uuid";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
if (user == UUID.Zero)
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("uuid", "%"));
|
||||
}
|
||||
else
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("uuid", user));
|
||||
}
|
||||
command.Parameters.Add(database.CreateParameter("parentID", parentID));
|
||||
conn.Open();
|
||||
return getInventoryFolders(command);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the inventory folders.
|
||||
/// </summary>
|
||||
/// <param name="command">SQLcommand.</param>
|
||||
/// <returns></returns>
|
||||
private static List<InventoryFolderBase> getInventoryFolders(NpgsqlCommand command)
|
||||
{
|
||||
using (NpgsqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
while (reader.Read())
|
||||
{
|
||||
items.Add(readInventoryFolder(reader));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a list of inventory folders returned by a query.
|
||||
/// </summary>
|
||||
/// <param name="reader">A PGSQL Data Reader</param>
|
||||
/// <returns>A List containing inventory folders</returns>
|
||||
protected static InventoryFolderBase readInventoryFolder(NpgsqlDataReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
InventoryFolderBase folder = new InventoryFolderBase();
|
||||
folder.Owner = DBGuid.FromDB(reader["agentID"]);
|
||||
folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]);
|
||||
folder.ID = DBGuid.FromDB(reader["folderID"]);
|
||||
folder.Name = (string)reader["folderName"];
|
||||
folder.Type = (short)reader["type"];
|
||||
folder.Version = Convert.ToUInt16(reader["version"]);
|
||||
|
||||
return folder;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB] Error reading inventory folder :" + e.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a one item from an SQL result
|
||||
/// </summary>
|
||||
/// <param name="reader">The SQL Result</param>
|
||||
/// <returns>the item read</returns>
|
||||
private static InventoryItemBase readInventoryItem(IDataRecord reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
|
||||
item.ID = DBGuid.FromDB(reader["inventoryID"]);
|
||||
item.AssetID = DBGuid.FromDB(reader["assetID"]);
|
||||
item.AssetType = Convert.ToInt32(reader["assetType"].ToString());
|
||||
item.Folder = DBGuid.FromDB(reader["parentFolderID"]);
|
||||
item.Owner = DBGuid.FromDB(reader["avatarID"]);
|
||||
item.Name = reader["inventoryName"].ToString();
|
||||
item.Description = reader["inventoryDescription"].ToString();
|
||||
item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]);
|
||||
item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]);
|
||||
item.InvType = Convert.ToInt32(reader["invType"].ToString());
|
||||
item.CreatorId = reader["creatorID"].ToString();
|
||||
item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]);
|
||||
item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]);
|
||||
item.GroupPermissions = Convert.ToUInt32(reader["inventoryGroupPermissions"]);
|
||||
item.SalePrice = Convert.ToInt32(reader["salePrice"]);
|
||||
item.SaleType = Convert.ToByte(reader["saleType"]);
|
||||
item.CreationDate = Convert.ToInt32(reader["creationDate"]);
|
||||
item.GroupID = DBGuid.FromDB(reader["groupID"]);
|
||||
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
|
||||
item.Flags = Convert.ToUInt32(reader["flags"]);
|
||||
|
||||
return item;
|
||||
}
|
||||
catch (NpgsqlException e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error reading inventory item :" + e.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a folder in inventory databasae
|
||||
/// </summary>
|
||||
/// <param name="folderID">the folder UUID</param>
|
||||
/// <param name="connection">connection to database</param>
|
||||
private void DeleteOneFolder(UUID folderID, NpgsqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(@"DELETE FROM inventoryfolders WHERE ""folderID""=:folderID and type=-1", connection))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (NpgsqlException e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error deleting folder :" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
350
OpenSim/Data/PGSQL/PGSQLManager.cs
Normal file
350
OpenSim/Data/PGSQL/PGSQLManager.cs
Normal file
@@ -0,0 +1,350 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A management class for the MS SQL Storage Engine
|
||||
/// </summary>
|
||||
public class PGSQLManager
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Connection string for ADO.net
|
||||
/// </summary>
|
||||
private readonly string connectionString;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the manager and set the connectionstring
|
||||
/// </summary>
|
||||
/// <param name="connection"></param>
|
||||
public PGSQLManager(string connection)
|
||||
{
|
||||
connectionString = connection;
|
||||
InitializeMonoSecurity();
|
||||
}
|
||||
|
||||
public void InitializeMonoSecurity()
|
||||
{
|
||||
if (!Util.IsPlatformMono)
|
||||
{
|
||||
if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null)
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true");
|
||||
|
||||
AppDomain currentDomain = AppDomain.CurrentDomain;
|
||||
currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Assembly MyAssembly = null;
|
||||
|
||||
if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security")
|
||||
{
|
||||
MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll");
|
||||
}
|
||||
|
||||
//Return the loaded assembly.
|
||||
return MyAssembly;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Type conversion to a SQLDbType functions
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlDbType DbtypeFromType(Type type)
|
||||
{
|
||||
if (type == typeof(string))
|
||||
{
|
||||
return NpgsqlDbType.Varchar;
|
||||
}
|
||||
if (type == typeof(double))
|
||||
{
|
||||
return NpgsqlDbType.Double;
|
||||
}
|
||||
if (type == typeof(Single))
|
||||
{
|
||||
return NpgsqlDbType.Double;
|
||||
}
|
||||
if (type == typeof(int))
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (type == typeof(bool))
|
||||
{
|
||||
return NpgsqlDbType.Boolean;
|
||||
}
|
||||
if (type == typeof(UUID))
|
||||
{
|
||||
return NpgsqlDbType.Uuid;
|
||||
}
|
||||
if (type == typeof(byte))
|
||||
{
|
||||
return NpgsqlDbType.Smallint;
|
||||
}
|
||||
if (type == typeof(sbyte))
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (type == typeof(Byte[]))
|
||||
{
|
||||
return NpgsqlDbType.Bytea;
|
||||
}
|
||||
if (type == typeof(uint) || type == typeof(ushort))
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (type == typeof(ulong))
|
||||
{
|
||||
return NpgsqlDbType.Bigint;
|
||||
}
|
||||
if (type == typeof(DateTime))
|
||||
{
|
||||
return NpgsqlDbType.Timestamp;
|
||||
}
|
||||
|
||||
return NpgsqlDbType.Varchar;
|
||||
}
|
||||
|
||||
internal NpgsqlDbType DbtypeFromString(Type type, string PGFieldType)
|
||||
{
|
||||
if (PGFieldType == "")
|
||||
{
|
||||
return DbtypeFromType(type);
|
||||
}
|
||||
|
||||
if (PGFieldType == "character varying")
|
||||
{
|
||||
return NpgsqlDbType.Varchar;
|
||||
}
|
||||
if (PGFieldType == "double precision")
|
||||
{
|
||||
return NpgsqlDbType.Double;
|
||||
}
|
||||
if (PGFieldType == "integer")
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (PGFieldType == "smallint")
|
||||
{
|
||||
return NpgsqlDbType.Smallint;
|
||||
}
|
||||
if (PGFieldType == "boolean")
|
||||
{
|
||||
return NpgsqlDbType.Boolean;
|
||||
}
|
||||
if (PGFieldType == "uuid")
|
||||
{
|
||||
return NpgsqlDbType.Uuid;
|
||||
}
|
||||
if (PGFieldType == "bytea")
|
||||
{
|
||||
return NpgsqlDbType.Bytea;
|
||||
}
|
||||
|
||||
return DbtypeFromType(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates value for parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
private static object CreateParameterValue(object value)
|
||||
{
|
||||
Type valueType = value.GetType();
|
||||
|
||||
if (valueType == typeof(UUID)) //TODO check if this works
|
||||
{
|
||||
return ((UUID) value).Guid;
|
||||
}
|
||||
if (valueType == typeof(UUID))
|
||||
{
|
||||
return ((UUID)value).Guid;
|
||||
}
|
||||
if (valueType == typeof(bool))
|
||||
{
|
||||
return (bool)value;
|
||||
}
|
||||
if (valueType == typeof(Byte[]))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
if (valueType == typeof(int))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create value for parameter based on PGSQL Schema
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="PGFieldType"></param>
|
||||
/// <returns></returns>
|
||||
internal static object CreateParameterValue(object value, string PGFieldType)
|
||||
{
|
||||
if (PGFieldType == "uuid")
|
||||
{
|
||||
UUID uidout;
|
||||
UUID.TryParse(value.ToString(), out uidout);
|
||||
return uidout;
|
||||
}
|
||||
if (PGFieldType == "integer")
|
||||
{
|
||||
int intout;
|
||||
int.TryParse(value.ToString(), out intout);
|
||||
return intout;
|
||||
}
|
||||
if (PGFieldType == "boolean")
|
||||
{
|
||||
return (value.ToString() == "true");
|
||||
}
|
||||
if (PGFieldType == "timestamp with time zone")
|
||||
{
|
||||
return (DateTime)value;
|
||||
}
|
||||
if (PGFieldType == "timestamp without time zone")
|
||||
{
|
||||
return (DateTime)value;
|
||||
}
|
||||
return CreateParameterValue(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a parameter for a command
|
||||
/// </summary>
|
||||
/// <param name="parameterName">Name of the parameter.</param>
|
||||
/// <param name="parameterObject">parameter object.</param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject)
|
||||
{
|
||||
return CreateParameter(parameterName, parameterObject, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the parameter for a command.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">Name of the parameter.</param>
|
||||
/// <param name="parameterObject">parameter object.</param>
|
||||
/// <param name="parameterOut">if set to <c>true</c> parameter is a output parameter</param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject, bool parameterOut)
|
||||
{
|
||||
//Tweak so we dont always have to add : sign
|
||||
if (parameterName.StartsWith(":")) parameterName = parameterName.Replace(":","");
|
||||
|
||||
//HACK if object is null, it is turned into a string, there are no nullable type till now
|
||||
if (parameterObject == null) parameterObject = "";
|
||||
|
||||
NpgsqlParameter parameter = new NpgsqlParameter(parameterName, DbtypeFromType(parameterObject.GetType()));
|
||||
|
||||
if (parameterOut)
|
||||
{
|
||||
parameter.Direction = ParameterDirection.Output;
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter.Direction = ParameterDirection.Input;
|
||||
parameter.Value = CreateParameterValue(parameterObject);
|
||||
}
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a parameter with PGSQL schema type
|
||||
/// </summary>
|
||||
/// <param name="parameterName"></param>
|
||||
/// <param name="parameterObject"></param>
|
||||
/// <param name="PGFieldType"></param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject, string PGFieldType)
|
||||
{
|
||||
//Tweak so we dont always have to add : sign
|
||||
if (parameterName.StartsWith(":")) parameterName = parameterName.Replace(":", "");
|
||||
|
||||
//HACK if object is null, it is turned into a string, there are no nullable type till now
|
||||
if (parameterObject == null) parameterObject = "";
|
||||
|
||||
NpgsqlParameter parameter = new NpgsqlParameter(parameterName, DbtypeFromString(parameterObject.GetType(), PGFieldType));
|
||||
|
||||
parameter.Direction = ParameterDirection.Input;
|
||||
parameter.Value = CreateParameterValue(parameterObject, PGFieldType);
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if we need to do some migrations to the database
|
||||
/// </summary>
|
||||
/// <param name="migrationStore">migrationStore.</param>
|
||||
public void CheckMigration(string migrationStore)
|
||||
{
|
||||
using (NpgsqlConnection connection = new NpgsqlConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
Assembly assem = GetType().Assembly;
|
||||
PGSQLMigration migration = new PGSQLMigration(connection, assem, migrationStore);
|
||||
|
||||
migration.Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the DB provider</returns>
|
||||
public string getVersion()
|
||||
{
|
||||
Module module = GetType().Module;
|
||||
// string dllName = module.Assembly.ManifestModule.Name;
|
||||
Version dllVersion = module.Assembly.GetName().Version;
|
||||
|
||||
return
|
||||
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
|
||||
dllVersion.Revision);
|
||||
}
|
||||
}
|
||||
}
|
||||
102
OpenSim/Data/PGSQL/PGSQLMigration.cs
Normal file
102
OpenSim/Data/PGSQL/PGSQLMigration.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLMigration : Migration
|
||||
{
|
||||
public PGSQLMigration(NpgsqlConnection conn, Assembly assem, string type)
|
||||
: base(conn, assem, type)
|
||||
{
|
||||
}
|
||||
|
||||
public PGSQLMigration(NpgsqlConnection conn, Assembly assem, string subtype, string type)
|
||||
: base(conn, assem, subtype, type)
|
||||
{
|
||||
}
|
||||
|
||||
protected override int FindVersion(DbConnection conn, string type)
|
||||
{
|
||||
int version = 0;
|
||||
NpgsqlConnection lcConn = (NpgsqlConnection)conn;
|
||||
|
||||
using (NpgsqlCommand cmd = lcConn.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = "select version from migrations where name = '" + type + "' " +
|
||||
" order by version desc limit 1"; //Must be
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
version = Convert.ToInt32(reader["version"]);
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Return -1 to indicate table does not exist
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
protected override void ExecuteScript(DbConnection conn, string[] script)
|
||||
{
|
||||
if (!(conn is NpgsqlConnection))
|
||||
{
|
||||
base.ExecuteScript(conn, script);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string sql in script)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, (NpgsqlConnection)conn))
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception(sql);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,48 +25,32 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class RestXmlWriter: XmlTextWriter
|
||||
public class PGSQLOfflineIMData : PGSQLGenericTableHandler<OfflineIMData>, IOfflineIMData
|
||||
{
|
||||
private StringWriter m_sw = null;
|
||||
|
||||
public RestXmlWriter(StringWriter sw) : base(sw)
|
||||
{
|
||||
m_sw = sw;
|
||||
Formatting = Formatting.Indented;
|
||||
}
|
||||
|
||||
public RestXmlWriter(TextWriter textWriter) : base(textWriter)
|
||||
public PGSQLOfflineIMData(string connectionString, string realm)
|
||||
: base(connectionString, realm, "IM_Store")
|
||||
{
|
||||
}
|
||||
|
||||
public RestXmlWriter(Stream stream)
|
||||
: this(stream, Encoding.UTF8)
|
||||
public void DeleteOld()
|
||||
{
|
||||
}
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
public RestXmlWriter(Stream stream, Encoding enc) : base(stream, enc)
|
||||
{
|
||||
}
|
||||
|
||||
public override void WriteStartDocument()
|
||||
{
|
||||
}
|
||||
|
||||
public override void WriteStartDocument(bool standalone)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
Flush();
|
||||
Close();
|
||||
return m_sw.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
115
OpenSim/Data/PGSQL/PGSQLPresenceData.cs
Normal file
115
OpenSim/Data/PGSQL/PGSQLPresenceData.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for the Presence Server
|
||||
/// </summary>
|
||||
public class PGSQLPresenceData : PGSQLGenericTableHandler<PresenceData>,
|
||||
IPresenceData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLPresenceData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "Presence")
|
||||
{
|
||||
}
|
||||
|
||||
public PresenceData Get(UUID sessionID)
|
||||
{
|
||||
PresenceData[] ret = Get("SessionID", sessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public void LogoutRegionAgents(UUID regionID)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format(@"DELETE FROM {0} WHERE ""RegionID""=:RegionID", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReportAgent(UUID sessionID, UUID regionID)
|
||||
{
|
||||
PresenceData[] pd = Get("SessionID", sessionID.ToString());
|
||||
if (pd.Length == 0)
|
||||
return false;
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format(@"UPDATE {0} SET
|
||||
""RegionID"" = :RegionID
|
||||
WHERE ""SessionID"" = :SessionID", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool VerifyAgent(UUID agentId, UUID secureSessionID)
|
||||
{
|
||||
PresenceData[] ret = Get("SecureSessionID", secureSessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return false;
|
||||
|
||||
if(ret[0].UserID != agentId.ToString())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user