diff options
author | UbitUmarov | 2015-09-01 14:54:35 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-01 14:54:35 +0100 |
commit | 371c9dd2af01a2e7422ec901ee1f80757284a78c (patch) | |
tree | 058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/CoreModules/Avatar/UserProfiles | |
parent | remove lixo (diff) | |
parent | dont change camera on crossings (diff) | |
download | opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2 opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz |
bad merge?
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/UserProfiles')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | 187 |
1 files changed, 183 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index c20369c..bea2834 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -288,10 +288,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
288 | // Notes | 288 | // Notes |
289 | client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest); | 289 | client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest); |
290 | client.OnAvatarNotesUpdate += NotesUpdate; | 290 | client.OnAvatarNotesUpdate += NotesUpdate; |
291 | |||
292 | // Preferences | ||
293 | client.OnUserInfoRequest += UserPreferencesRequest; | ||
294 | client.OnUpdateUserInfo += UpdateUserPreferences; | ||
295 | } | 291 | } |
296 | #endregion Region Event Handlers | 292 | #endregion Region Event Handlers |
297 | 293 | ||
@@ -873,6 +869,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
873 | } | 869 | } |
874 | #endregion Notes | 870 | #endregion Notes |
875 | 871 | ||
872 | <<<<<<< HEAD | ||
876 | #region User Preferences | 873 | #region User Preferences |
877 | /// <summary> | 874 | /// <summary> |
878 | /// Updates the user preferences. | 875 | /// Updates the user preferences. |
@@ -936,6 +933,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
936 | } | 933 | } |
937 | #endregion User Preferences | 934 | #endregion User Preferences |
938 | 935 | ||
936 | ======= | ||
937 | >>>>>>> avn/ubitvar | ||
939 | #region Avatar Properties | 938 | #region Avatar Properties |
940 | /// <summary> | 939 | /// <summary> |
941 | /// Update the avatars interests . | 940 | /// Update the avatars interests . |
@@ -1402,5 +1401,185 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1402 | return null; | 1401 | return null; |
1403 | } | 1402 | } |
1404 | #endregion Util | 1403 | #endregion Util |
1404 | <<<<<<< HEAD | ||
1405 | ======= | ||
1406 | |||
1407 | #region Web Util | ||
1408 | /// <summary> | ||
1409 | /// Sends json-rpc request with a serializable type. | ||
1410 | /// </summary> | ||
1411 | /// <returns> | ||
1412 | /// OSD Map. | ||
1413 | /// </returns> | ||
1414 | /// <param name='parameters'> | ||
1415 | /// Serializable type . | ||
1416 | /// </param> | ||
1417 | /// <param name='method'> | ||
1418 | /// Json-rpc method to call. | ||
1419 | /// </param> | ||
1420 | /// <param name='uri'> | ||
1421 | /// URI of json-rpc service. | ||
1422 | /// </param> | ||
1423 | /// <param name='jsonId'> | ||
1424 | /// Id for our call. | ||
1425 | /// </param> | ||
1426 | bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId) | ||
1427 | { | ||
1428 | if (jsonId == null) | ||
1429 | throw new ArgumentNullException ("jsonId"); | ||
1430 | if (uri == null) | ||
1431 | throw new ArgumentNullException ("uri"); | ||
1432 | if (method == null) | ||
1433 | throw new ArgumentNullException ("method"); | ||
1434 | if (parameters == null) | ||
1435 | throw new ArgumentNullException ("parameters"); | ||
1436 | |||
1437 | // Prep our payload | ||
1438 | OSDMap json = new OSDMap(); | ||
1439 | |||
1440 | json.Add("jsonrpc", OSD.FromString("2.0")); | ||
1441 | json.Add("id", OSD.FromString(jsonId)); | ||
1442 | json.Add("method", OSD.FromString(method)); | ||
1443 | |||
1444 | json.Add("params", OSD.SerializeMembers(parameters)); | ||
1445 | |||
1446 | string jsonRequestData = OSDParser.SerializeJsonString(json); | ||
1447 | byte[] content = Encoding.UTF8.GetBytes(jsonRequestData); | ||
1448 | |||
1449 | HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
1450 | |||
1451 | webRequest.ContentType = "application/json-rpc"; | ||
1452 | webRequest.Method = "POST"; | ||
1453 | |||
1454 | Stream dataStream = webRequest.GetRequestStream(); | ||
1455 | dataStream.Write(content, 0, content.Length); | ||
1456 | dataStream.Close(); | ||
1457 | |||
1458 | WebResponse webResponse = null; | ||
1459 | try | ||
1460 | { | ||
1461 | webResponse = webRequest.GetResponse(); | ||
1462 | } | ||
1463 | catch (WebException e) | ||
1464 | { | ||
1465 | Console.WriteLine("Web Error" + e.Message); | ||
1466 | Console.WriteLine ("Please check input"); | ||
1467 | return false; | ||
1468 | } | ||
1469 | |||
1470 | OSDMap mret = new OSDMap(); | ||
1471 | |||
1472 | using (Stream rstream = webResponse.GetResponseStream()) | ||
1473 | { | ||
1474 | try | ||
1475 | { | ||
1476 | mret = (OSDMap)OSDParser.DeserializeJson(rstream); | ||
1477 | } | ||
1478 | catch (Exception e) | ||
1479 | { | ||
1480 | m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); | ||
1481 | if (webResponse != null) | ||
1482 | webResponse.Close(); | ||
1483 | return false; | ||
1484 | } | ||
1485 | } | ||
1486 | |||
1487 | if (webResponse != null) | ||
1488 | webResponse.Close(); | ||
1489 | |||
1490 | if (mret.ContainsKey("error")) | ||
1491 | return false; | ||
1492 | |||
1493 | // get params... | ||
1494 | OSD.DeserializeMembers(ref parameters, (OSDMap) mret["result"]); | ||
1495 | return true; | ||
1496 | } | ||
1497 | |||
1498 | /// <summary> | ||
1499 | /// Sends json-rpc request with OSD parameter. | ||
1500 | /// </summary> | ||
1501 | /// <returns> | ||
1502 | /// The rpc request. | ||
1503 | /// </returns> | ||
1504 | /// <param name='data'> | ||
1505 | /// data - incoming as parameters, outgong as result/error | ||
1506 | /// </param> | ||
1507 | /// <param name='method'> | ||
1508 | /// Json-rpc method to call. | ||
1509 | /// </param> | ||
1510 | /// <param name='uri'> | ||
1511 | /// URI of json-rpc service. | ||
1512 | /// </param> | ||
1513 | /// <param name='jsonId'> | ||
1514 | /// If set to <c>true</c> json identifier. | ||
1515 | /// </param> | ||
1516 | bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonId) | ||
1517 | { | ||
1518 | OSDMap map = new OSDMap(); | ||
1519 | |||
1520 | map["jsonrpc"] = "2.0"; | ||
1521 | if(string.IsNullOrEmpty(jsonId)) | ||
1522 | map["id"] = UUID.Random().ToString(); | ||
1523 | else | ||
1524 | map["id"] = jsonId; | ||
1525 | |||
1526 | map["method"] = method; | ||
1527 | map["params"] = data; | ||
1528 | |||
1529 | string jsonRequestData = OSDParser.SerializeJsonString(map); | ||
1530 | byte[] content = Encoding.UTF8.GetBytes(jsonRequestData); | ||
1531 | |||
1532 | HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
1533 | webRequest.ContentType = "application/json-rpc"; | ||
1534 | webRequest.Method = "POST"; | ||
1535 | |||
1536 | Stream dataStream = webRequest.GetRequestStream(); | ||
1537 | dataStream.Write(content, 0, content.Length); | ||
1538 | dataStream.Close(); | ||
1539 | |||
1540 | WebResponse webResponse = null; | ||
1541 | try | ||
1542 | { | ||
1543 | webResponse = webRequest.GetResponse(); | ||
1544 | } | ||
1545 | catch (WebException e) | ||
1546 | { | ||
1547 | Console.WriteLine("Web Error" + e.Message); | ||
1548 | Console.WriteLine ("Please check input"); | ||
1549 | return false; | ||
1550 | } | ||
1551 | |||
1552 | OSDMap response = new OSDMap(); | ||
1553 | |||
1554 | using (Stream rstream = webResponse.GetResponseStream()) | ||
1555 | { | ||
1556 | try | ||
1557 | { | ||
1558 | response = (OSDMap)OSDParser.DeserializeJson(rstream); | ||
1559 | } | ||
1560 | catch (Exception e) | ||
1561 | { | ||
1562 | m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); | ||
1563 | if (webResponse != null) | ||
1564 | webResponse.Close(); | ||
1565 | return false; | ||
1566 | } | ||
1567 | } | ||
1568 | |||
1569 | if (webResponse != null) | ||
1570 | webResponse.Close(); | ||
1571 | |||
1572 | if(response.ContainsKey("error")) | ||
1573 | { | ||
1574 | data = response["error"]; | ||
1575 | return false; | ||
1576 | } | ||
1577 | |||
1578 | data = response; | ||
1579 | |||
1580 | return true; | ||
1581 | } | ||
1582 | #endregion Web Util | ||
1583 | >>>>>>> avn/ubitvar | ||
1405 | } | 1584 | } |
1406 | } | 1585 | } |