aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/XMLRPCModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/XMLRPCModule.cs460
1 files changed, 228 insertions, 232 deletions
diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
index 2a64de9..67ebbf8 100644
--- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
+++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
@@ -1,30 +1,29 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4 *
5* Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15* 15 *
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26 */
27*/
28 27
29using System; 28using System;
30using System.Collections; 29using System.Collections;
@@ -422,260 +421,257 @@ namespace OpenSim.Region.Environment.Modules
422 } 421 }
423 } 422 }
424 } 423 }
425 /**************************************************************
426 *
427 * Class RPCRequestInfo
428 *
429 * Holds details about incoming requests until they are picked
430 * from the queue by LSLLongCmdHandler
431 * ***********************************************************/
432
433 public class RPCRequestInfo
434 {
435 private string m_StrVal;
436 private string m_IntVal;
437 private bool m_processed;
438 private string m_respStr;
439 private int m_respInt;
440 private uint m_localID;
441 private LLUUID m_ItemID;
442 private LLUUID m_MessageID;
443 private LLUUID m_ChannelKey;
444
445 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal)
446 {
447 m_localID = localID;
448 m_StrVal = strVal;
449 m_IntVal = intVal;
450 m_ItemID = itemID;
451 m_ChannelKey = channelKey;
452 m_MessageID = LLUUID.Random();
453 m_processed = false;
454 m_respStr = String.Empty;
455 m_respInt = 0;
456 }
457 424
458 public bool IsProcessed() 425 /**************************************************************
459 { 426 *
460 return m_processed; 427 * Class RPCRequestInfo
461 } 428 *
429 * Holds details about incoming requests until they are picked
430 * from the queue by LSLLongCmdHandler
431 * ***********************************************************/
462 432
463 public LLUUID GetChannelKey() 433 public class RPCRequestInfo
464 { 434 {
465 return m_ChannelKey; 435 private string m_StrVal;
466 } 436 private string m_IntVal;
437 private bool m_processed;
438 private string m_respStr;
439 private int m_respInt;
440 private uint m_localID;
441 private LLUUID m_ItemID;
442 private LLUUID m_MessageID;
443 private LLUUID m_ChannelKey;
444
445 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal)
446 {
447 m_localID = localID;
448 m_StrVal = strVal;
449 m_IntVal = intVal;
450 m_ItemID = itemID;
451 m_ChannelKey = channelKey;
452 m_MessageID = LLUUID.Random();
453 m_processed = false;
454 m_respStr = String.Empty;
455 m_respInt = 0;
456 }
467 457
468 public void SetProcessed(bool processed) 458 public bool IsProcessed()
469 { 459 {
470 m_processed = processed; 460 return m_processed;
471 } 461 }
472 462
473 public void SetStrRetval(string resp) 463 public LLUUID GetChannelKey()
474 { 464 {
475 m_respStr = resp; 465 return m_ChannelKey;
476 } 466 }
477 467
478 public string GetStrRetval() 468 public void SetProcessed(bool processed)
479 { 469 {
480 return m_respStr; 470 m_processed = processed;
481 } 471 }
482 public void SetIntRetval(int resp)
483 {
484 m_respInt = resp;
485 }
486 472
487 public int GetIntRetval() 473 public void SetStrRetval(string resp)
488 { 474 {
489 return m_respInt; 475 m_respStr = resp;
490 } 476 }
491 public uint GetLocalID()
492 {
493 return m_localID;
494 }
495 477
496 public LLUUID GetItemID() 478 public string GetStrRetval()
497 { 479 {
498 return m_ItemID; 480 return m_respStr;
499 } 481 }
482 public void SetIntRetval(int resp)
483 {
484 m_respInt = resp;
485 }
500 486
501 public string GetStrVal() 487 public int GetIntRetval()
502 { 488 {
503 return m_StrVal; 489 return m_respInt;
504 } 490 }
491 public uint GetLocalID()
492 {
493 return m_localID;
494 }
505 495
506 public int GetIntValue() 496 public LLUUID GetItemID()
507 { 497 {
508 return int.Parse(m_IntVal); 498 return m_ItemID;
509 } 499 }
510 500
511 public LLUUID GetMessageID() 501 public string GetStrVal()
512 { 502 {
513 return m_MessageID; 503 return m_StrVal;
514 }
515 } 504 }
516 505
517 public class RPCChannelInfo 506 public int GetIntValue()
518 { 507 {
519 private LLUUID m_itemID; 508 return int.Parse(m_IntVal);
520 private uint m_localID; 509 }
521 private LLUUID m_ChannelKey;
522 510
523 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID) 511 public LLUUID GetMessageID()
524 { 512 {
525 m_ChannelKey = channelID; 513 return m_MessageID;
526 m_localID = localID; 514 }
527 m_itemID = itemID; 515 }
528 }
529 516
530 public LLUUID GetItemID() 517 public class RPCChannelInfo
531 { 518 {
532 return m_itemID; 519 private LLUUID m_itemID;
533 } 520 private uint m_localID;
521 private LLUUID m_ChannelKey;
534 522
535 public LLUUID GetChannelID() 523 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID)
536 { 524 {
537 return m_ChannelKey; 525 m_ChannelKey = channelID;
538 } 526 m_localID = localID;
527 m_itemID = itemID;
528 }
539 529
540 public uint GetLocalID() 530 public LLUUID GetItemID()
541 { 531 {
542 return m_localID; 532 return m_itemID;
543 } 533 }
544 534
535 public LLUUID GetChannelID()
536 {
537 return m_ChannelKey;
545 } 538 }
546 539
547 public class SendRemoteDataRequest 540 public uint GetLocalID()
548 { 541 {
542 return m_localID;
543 }
549 544
550 public LLUUID reqID; 545 }
551 public string destURL;
552 public string channel;
553 public string sdata;
554 public int idata;
555 public bool finished;
556 public string response_sdata;
557 public int response_idata;
558 public XmlRpcRequest request;
559 private Thread httpThread;
560 public LLUUID m_itemID;
561 public uint m_localID;
562 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
563 546
564 public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata) 547 public class SendRemoteDataRequest
565 { 548 {
566 549
567 this.channel = channel; 550 public LLUUID reqID;
568 this.destURL = dest; 551 public string destURL;
569 this.idata = idata; 552 public string channel;
570 this.sdata = sdata; 553 public string sdata;
571 m_itemID = itemID; 554 public int idata;
572 m_localID = localID; 555 public bool finished;
556 public string response_sdata;
557 public int response_idata;
558 public XmlRpcRequest request;
559 private Thread httpThread;
560 public LLUUID m_itemID;
561 public uint m_localID;
562 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
573 563
574 reqID = LLUUID.Random(); 564 public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
565 {
575 566
576 } 567 this.channel = channel;
568 this.destURL = dest;
569 this.idata = idata;
570 this.sdata = sdata;
571 m_itemID = itemID;
572 m_localID = localID;
577 573
578 public LLUUID process() 574 reqID = LLUUID.Random();
579 {
580 httpThread = new Thread(SendRequest);
581 httpThread.Name = "HttpRequestThread";
582 httpThread.Priority = ThreadPriority.BelowNormal;
583 httpThread.IsBackground = true;
584 finished = false;
585 httpThread.Start();
586 OpenSim.Framework.ThreadTracker.Add(httpThread);
587 575
588 return reqID; 576 }
589 577
590 } 578 public LLUUID process()
579 {
580 httpThread = new Thread(SendRequest);
581 httpThread.Name = "HttpRequestThread";
582 httpThread.Priority = ThreadPriority.BelowNormal;
583 httpThread.IsBackground = true;
584 finished = false;
585 httpThread.Start();
586 OpenSim.Framework.ThreadTracker.Add(httpThread);
591 587
592 /* 588 return reqID;
593 * TODO: More work on the response codes. Right now
594 * returning 200 for success or 499 for exception
595 */
596 589
597 public void SendRequest() 590 }
598 {
599 591
600 Hashtable param = new Hashtable(); 592 /*
593 * TODO: More work on the response codes. Right now
594 * returning 200 for success or 499 for exception
595 */
601 596
602 // Check if channel is an LLUUID 597 public void SendRequest()
603 // if not, use as method name 598 {
604 LLUUID parseUID; 599 Hashtable param = new Hashtable();
605 string mName = "llRemoteData"; 600
606 if( (channel != null) && (channel != "") ) 601 // Check if channel is an LLUUID
607 if( !LLUUID.TryParse(channel, out parseUID) ) 602 // if not, use as method name
608 mName = channel; 603 LLUUID parseUID;
609 else 604 string mName = "llRemoteData";
610 param["Channel"] = channel; 605 if( (channel != null) && (channel != "") )
606 if( !LLUUID.TryParse(channel, out parseUID) )
607 mName = channel;
608 else
609 param["Channel"] = channel;
611 610
612 param["StringValue"] = sdata; 611 param["StringValue"] = sdata;
613 param["IntValue"] = Convert.ToString(idata); 612 param["IntValue"] = Convert.ToString(idata);
614 613
615 ArrayList parameters = new ArrayList(); 614 ArrayList parameters = new ArrayList();
616 parameters.Add(param); 615 parameters.Add(param);
617 XmlRpcRequest req = new XmlRpcRequest(mName, parameters); 616 XmlRpcRequest req = new XmlRpcRequest(mName, parameters);
618 try 617 try
618 {
619 XmlRpcResponse resp = req.Send(destURL, 30000);
620 if (resp != null)
619 { 621 {
620 XmlRpcResponse resp = req.Send(destURL, 30000); 622 Hashtable respParms;
621 if (resp != null) 623 if(resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable"))) {
624 respParms = (Hashtable)resp.Value;
625 }
626 else {
627 ArrayList respData = (ArrayList)resp.Value;
628 respParms = (Hashtable)respData[0];
629 }
630 if (respParms != null)
622 { 631 {
623 Hashtable respParms; 632 if (respParms.Contains("StringValue"))
624 if(resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable"))) { 633 {
625 respParms = (Hashtable)resp.Value; 634 sdata = (string)respParms["StringValue"];
635 }
636 if (respParms.Contains("IntValue"))
637 {
638 idata = Convert.ToInt32((string)respParms["IntValue"]);
626 } 639 }
627 else { 640 if (respParms.Contains("faultString"))
628 ArrayList respData = (ArrayList)resp.Value; 641 {
629 respParms = (Hashtable)respData[0]; 642 sdata = (string)respParms["faultString"];
630 } 643 }
631 if (respParms != null) 644 if (respParms.Contains("faultCode"))
632 { 645 {
633 if (respParms.Contains("StringValue")) 646 idata = Convert.ToInt32(respParms["faultCode"]);
634 {
635 sdata = (string)respParms["StringValue"];
636 }
637 if (respParms.Contains("IntValue"))
638 {
639 idata = Convert.ToInt32((string)respParms["IntValue"]);
640 }
641 if (respParms.Contains("faultString"))
642 {
643 sdata = (string)respParms["faultString"];
644 }
645 if (respParms.Contains("faultCode"))
646 {
647 idata = Convert.ToInt32(respParms["faultCode"]);
648 }
649 } 647 }
650 } 648 }
651 } 649 }
652 catch (System.Net.WebException we)
653 {
654 sdata = we.Message;
655 m_log.Warn("[SendRemoteDataRequest]: Request failed");
656 m_log.Warn(we.StackTrace);
657 }
658
659 finished = true;
660
661 } 650 }
662 651 catch (System.Net.WebException we)
663 public void Stop()
664 { 652 {
665 try 653 sdata = we.Message;
666 { 654 m_log.Warn("[SendRemoteDataRequest]: Request failed");
667 httpThread.Abort(); 655 m_log.Warn(we.StackTrace);
668 }
669 catch (Exception)
670 {
671 }
672 } 656 }
673 657
674 public LLUUID GetReqID() 658 finished = true;
659 }
660
661 public void Stop()
662 {
663 try
664 {
665 httpThread.Abort();
666 }
667 catch (Exception)
675 { 668 {
676 return reqID;
677 } 669 }
678
679 } 670 }
680 671
681} \ No newline at end of file 672 public LLUUID GetReqID()
673 {
674 return reqID;
675 }
676 }
677}