aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/InventoryServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/InventoryServer/Main.cs')
-rw-r--r--OpenSim/Grid/InventoryServer/Main.cs113
1 files changed, 97 insertions, 16 deletions
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 97addb0..392c741 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -31,49 +31,130 @@ using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.IO; 32using System.IO;
33using System.Text; 33using System.Text;
34using System.Xml;
35
34using libsecondlife; 36using libsecondlife;
35using OpenSim.Framework.User;
36using OpenSim.Framework.Sims;
37using OpenSim.Framework.Inventory;
38using OpenSim.Framework.Interfaces; 37using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
40using OpenSim.Servers;
41using OpenSim.Framework.Utilities; 39using OpenSim.Framework.Utilities;
40using OpenSim.Framework.Configuration;
41using OpenSim.Framework.Data;
42using InventoryCategory = OpenSim.Framework.Data.InventoryCategory;
42 43
43namespace OpenGridServices.InventoryServer 44namespace OpenSim.Grid.InventoryServer
44{ 45{
45 public class OpenInventory_Main : BaseServer, conscmd_callback 46
47 public class OpenInventory_Main : conscmd_callback
46 { 48 {
47 ConsoleBase m_console;
48 InventoryManager m_inventoryManager;
49 49
50 public const string MainLogName = "INVENTORY";
51
52 private InventoryConfig m_config;
53 LogBase m_console;
54 InventoryManager m_inventoryManager; ///connection the database backend
55 InventoryService m_inventoryService; ///Remoting interface, where messages arrive
56 [STAThread]
50 public static void Main(string[] args) 57 public static void Main(string[] args)
51 { 58 {
59 Console.WriteLine("Launching InventoryServer...");
60
61 OpenInventory_Main inventoryServer = new OpenInventory_Main();
62
63 inventoryServer.Startup();
64
65// inventoryServer.RunCmd("load", new string[] { "library", "inventory_library.xml" });
66// inventoryServer.RunCmd("load", new string[] { "default", "inventory_default.xml" });
67
68 inventoryServer.Work();
52 } 69 }
53 70
54 public OpenInventory_Main() 71 public OpenInventory_Main()
55 { 72 {
56 m_console = new ConsoleBase("opengrid-inventory-console.log", "OpenInventory", this, false); 73
57 MainConsole.Instance = m_console; 74 if (!Directory.Exists(Util.logDir()))
75 {
76 Directory.CreateDirectory(Util.logDir());
77 }
78
79 m_console = new LogBase(Path.Combine(Util.logDir(), "opensim-inventory-console.log"), "OpenInventory", this, false);
80 MainLog.Instance = m_console;
81 }
82
83 private void Work()
84 {
85 m_console.Notice(OpenInventory_Main.MainLogName, "Enter help for a list of commands\n");
86
87 while (true)
88 {
89 m_console.MainLogPrompt();
90 }
58 } 91 }
59 92
60 public void Startup() 93 public void Startup()
61 { 94 {
62 MainConsole.Instance.Notice("Initialising inventory manager..."); 95 MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Initialising inventory manager...");
96
97 m_config = new InventoryConfig(OpenInventory_Main.MainLogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
98
99 // instantiate the manager, responsible for doing the actual storage
63 m_inventoryManager = new InventoryManager(); 100 m_inventoryManager = new InventoryManager();
101 m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider);
102
103 m_inventoryService = new InventoryService(m_inventoryManager, m_config);
64 104
65 MainConsole.Instance.Notice("Starting HTTP server"); 105 // Dig out the embedded version number of this assembly
66 BaseHttpServer httpServer = new BaseHttpServer(8004); 106 Assembly assembly = Assembly.GetExecutingAssembly();
107 string serverExeName = assembly.ManifestModule.Name;
108 Version serverExeVersion = AssemblyName.GetAssemblyName(serverExeName).Version;
67 109
68 httpServer.AddXmlRPCHandler("rootfolders", m_inventoryManager.XmlRpcInventoryRequest); 110 m_console.Status(OpenInventory_Main.MainLogName, "Inventoryserver {0}.{1}.{2}.{3} - Startup complete", serverExeVersion.Major, serverExeVersion.Minor, serverExeVersion.Revision, serverExeVersion.Build);
69 //httpServer.AddRestHandler("GET","/rootfolders/",Rest
70 } 111 }
71 112
72 public void RunCmd(string cmd, string[] cmdparams) 113
114 public void Load(string[] cmdparams)
73 { 115 {
116 string cmd = cmdparams[0];
117 string fileName = cmdparams[1];
118
119 if (cmdparams.Length != 2)
120 {
121 cmd = "help";
122 }
123
74 switch (cmd) 124 switch (cmd)
75 { 125 {
126 case "library":
127 InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Library, fileName);
128 break;
129 case "default":
130 InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Default, fileName);
131 break;
132 case "user":
133 InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.User, fileName);
134 break;
135 case "help":
136 m_console.Notice("load library <filename>, load library inventory, shared between all users");
137 m_console.Notice("load default <filename>, load template inventory, used when creating a new user inventory");
138 m_console.Notice("load user <first> <last>, load inventory for a specific users, warning this will reset the contents of the inventory");
139 break;
140 }
141 }
142
143 public void RunCmd(string cmd, string[] cmdparams)
144 {
145 switch (cmd)
146 {
147 case "help":
148 m_console.Notice("load - load verious inventories, use \"load help\", to see a list of commands");
149 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
150 m_console.Notice("quit - shutdown the grid (USE CAUTION!)");
151 break;
152 case "load":
153 Load(cmdparams);
154 break;
155 case "quit":
76 case "shutdown": 156 case "shutdown":
157 MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Shutting down inventory server");
77 m_console.Close(); 158 m_console.Close();
78 Environment.Exit(0); 159 Environment.Exit(0);
79 break; 160 break;