コード例 #1
0
        public override bool TryGetSimPosition(out Vector3 pos, OutputDelegate Debug)
        {
            bool gotPos = base.TryGetSimPosition(out pos, Debug);

            if (IsControllable)
            {
                pos = Client0.Self.SimPosition;
                return(true);
            }
            var theAvatar = _Prim0;

            if (theAvatar != null)
            {
                if (pos != theAvatar.Position)
                {
                    if (!IsSitting && Vector3.Distance(pos, theAvatar.Position) > 3)
                    {
                        if (Debug != null)
                        {
                            Debug("wrong pos");
                        }
                        return(false);
                    }
                }
            }
            if (gotPos)
            {
                return(true);
            }
            return(false);
        }
コード例 #2
0
 public Command(BotClient bc)
 {
     _mClient          = bc;
     WriteLineDelegate = StaticWriteLine;
     Name = GetType().Name.Replace("Command", "");
     if (!(this is BotCommand))
     {
         DLRConsole.DebugWriteLine("" + this + " is not a BotCommand?!");
     }
     if (this is BotPersonalCommand)
     {
         //Parameters = CreateParams();
         Category = CommandCategory.Other;
     }
     if (this is BotSystemCommand)
     {
         //Parameters = CreateParams();
         Category = CommandCategory.Simulator;
     }
     if (this is RegionMasterCommand)
     {
         // Parameters = new[] { new NamedParam(typeof(Simulator), null) };
         Category = CommandCategory.Simulator;
     }
     if (this is SystemApplicationCommand)
     {
         // Parameters = CreateParams();
         Category = CommandCategory.BotClient;
     }
     if (this.GetType().Namespace.ToString() == "Cogbot.Actions.Movement")
     {
         Category = CommandCategory.Movement;
     }
 } // constructor
コード例 #3
0
 public void UpateLogging(string sa, OutputDelegate od)
 {
     od = CheckOutput(od);
     sa = sa.Trim().ToLower();
     while (sa != null && sa.Trim().Length > 0)
     {
         sa = sa.Trim();
         if (sa.StartsWith("clear"))
         {
             ExceptFor.Clear();
             AnyOf.Clear();
             od("Clearing all");
             sa = sa.Substring(5);
             continue;
         }
         if (sa.StartsWith("reset"))
         {
             sa = sa.Substring(5);
             if (addMode)
             {
                 od("Clearing AnyOf");
                 AnyOf.Clear();
             }
             if (remMode)
             {
                 od("Clearing ExceptFor");
                 ExceptFor.Clear();
             }
             continue;
         }
         if (sa.StartsWith("+"))
         {
             addMode = true;
             remMode = false;
             sa      = sa.Substring(1);
             continue;
         }
         if (sa.StartsWith("-"))
         {
             remMode = true;
             addMode = false;
             sa      = sa.Substring(1);
             continue;
         }
         int    f = (sa + "\n").IndexOfAny(new char[] { '+', '-', '\n' });
         string w = sa.Substring(0, f).ToUpper().Trim();
         if (addMode)
         {
             AnyOf.Add(w);
             ExceptFor.Remove(w);
         }
         if (remMode)
         {
             ExceptFor.Add(w);
             AnyOf.Remove(w);
         }
         sa = sa.Substring(f);
     }
     od(ToString());
 }
コード例 #4
0
            public bool LoadTaskOSD(OutputDelegate WriteLine)
            {
                failed    = 0;
                succeeded = 0;
                string taskFile  = ExportCommand.dumpDir + OldID + ".task";
                string taskDataS = File.ReadAllText(taskFile);

                if (string.IsNullOrEmpty(taskDataS) || taskDataS.Length < 30)
                {
                    TaskInvComplete = true;
                    return(true);
                }
                var taskData = OSDParser.DeserializeLLSDXml(taskDataS) as OSDArray;

                if (taskData == null)
                {
                    WriteLine("ERROR: Cant read taskData: " + taskDataS);
                    return(false);
                }

                lock (TaskItemsToCreate) if (taskData.Count == TaskItemsToCreate.Count && taskData.Count > 0)
                    {
                        succeeded = taskData.Count;
                        return(true);
                    }
                // scan for existing source nodes
                lock (TaskItemsToCreate)
                {
                    foreach (OSDMap item in taskData)
                    {
                        if (item["AssetType"].Type == OSDType.Unknown)
                        {
                            continue;
                        }
                        var itemID            = item["UUID"].AsUUID();
                        TaskItemToCreate titc = null;

                        foreach (TaskItemToCreate itemToCreate in TaskItemsToCreate)
                        {
                            if (itemToCreate.OldItemID == itemID)
                            {
                                titc = itemToCreate;
                                break;
                            }
                        }
                        if (titc == null)
                        {
                            titc = new TaskItemToCreate(this, item);
                            TaskItemsToCreate.Add(titc);
                        }
                        else
                        {
                            titc.TaskItemOSD = item;
                        }
                        AssignObjectNums();
                        succeeded++;
                    }
                }
                return(failed == 0);
            }
コード例 #5
0
        public string callDbQuery0(string searchTerm1, OutputDelegate dbgLog, Func <Unifiable> OnFalure, XmlNode templateNode, float threshold, bool expandWithWordNet, bool expandOnNoHits, out float reliablity)
        {
            checkDbLock();
            bool tf;

            if (StaticXMLUtils.TryParseBool(templateNode, "wordnet,synonyms", out tf))
            {
                expandWithWordNet = tf;
            }
            WordExpander wordNetExpander = expandWithWordNet ? (WordExpander)WordNetExpand : NoWordNetExpander;
            string       userFilter      = "";
            // Do we only want responses with the current user name in it ?
            // As in "what is my favorite color?"
            string onlyUserStr = StaticXMLUtils.GetAttribValue(templateNode, "onlyUser", "false").ToLower();

            if (onlyUserStr.Equals("true"))
            {
                userFilter = TripleStoreProxy.Entify(TheBot.BotUserID);
            }
            string res = callDbQueryStatic(SearchSources, searchTerm1, dbgLog, templateNode, threshold, out reliablity,
                                           userFilter, wordNetExpander);

            if (OnFalure != null && string.IsNullOrEmpty(res))
            {
                return(OnFalure());
            }
            return(res);
        }
コード例 #6
0
        public CmdResult ExecuteTask(string scripttype, TextReader reader, OutputDelegate WriteLine)
        {
            var    si = ScriptManager.LoadScriptInterpreter(scripttype, this, _LispTaskInterperter);
            object o  = si.Read(scripttype, reader, WriteLine);

            if (o is CmdResult)
            {
                return((CmdResult)o);
            }
            string verb = "ExecuteTask " + scripttype;

            if (o == null)
            {
                return(ACmdResult.Complete(verb, "void", true));
            }
            if (si.Eof(o))
            {
                return(ACmdResult.Complete(verb, "EOF " + o, true));
            }
            o = si.Eval(o);
            if (o is CmdResult)
            {
                return((CmdResult)o);
            }
            verb = "ExecuteTask " + o;
            if (o == null)
            {
                return(ACmdResult.Complete(verb, "void", true));
            }
            if (si.Eof(o))
            {
                return(ACmdResult.Complete(verb, "EOF " + o, true));
            }
            return(ACmdResult.Complete(verb, "" + o, true));
        }
コード例 #7
0
 public DBShell(IDBConnection connection, int capacity, OutputDelegate outputMsg)
 {
     db            = connection;
     queue         = new Queue <IQuery> (capacity);
     adapters      = new Dictionary <string, IStorageAdapter> ();
     OutputMessage = outputMsg;
 }
コード例 #8
0
        public virtual Object EvalForObject(Object lispCode, OutputDelegate output)
        {
            if (lispCode == null)
            {
                return(null);
            }
            TextReader stringCodeReader;

            if (lispCode is String)
            {
                stringCodeReader = new StringReader(lispCode.ToString());
            }
            else if (lispCode is TextReader)
            {
                stringCodeReader = lispCode as TextReader;
            }
            else
            {
                stringCodeReader = null;
            }

            if (stringCodeReader != null)
            {
                lispCode = Read("" + this, stringCodeReader, output);
            }
            output("Eval> " + lispCode);
            if (Eof(lispCode))
            {
                return(lispCode.ToString());
            }
            return(Eval(lispCode));
        }
コード例 #9
0
        public CmdResult ExecuteCommand(string text, CMDFLAGS needResult)
        {
            // done inside the callee InvokeJoin("ExecuteCommand " + text);
            OutputDelegate WriteLine = DisplayNotificationInChat;

            return(ExecuteCommand(text, this, WriteLine, needResult));
        }
コード例 #10
0
        /// <summary>
        /// 总的函数调用接口
        /// </summary>
        /// <param name="Paths">所有接收机的所有路径</param>
        /// <param name="Rxname">接收机名字</param>
        /// <param name="groupnum">接收机的类型号</param>
        /// <param name="filePath">存放路径</param>
        /// <param name="ProjName">工程名</param>
        public static void p2mfileoutput(List <CalculateModelClasses.Path> Paths, string filePath, string ProjName, int TxIndex, int txTotol, int index, ReceiveBall rxball, Point txPosition, int Frequence, int minFrequence, int maxFrequence)
        {
            lock (typeof(P2mFileOutput))
            {
                if (index == 0)
                {
                    if (!Directory.Exists(filePath))
                    {
                        //DeleteDir(filePath);
                        //Directory.Delete(filePath);
                        Directory.CreateDirectory(filePath);
                    }
                    //Directory.CreateDirectory(filePath);
                }

                OutputDelegate output = PowerOutput.OutPath;
                output += PathOutput.OutPath;
                output += PlOutput.OutPath;
                output += PgOutput.OutPath;
                output += SpreadOutput.OutPath;
                //output += ErmOutput.OutPath;
                output += ExmagOutput.OutPath;
                output += ExphsOutput.OutPath;
                output += EymagOutput.OutPath;
                output += EyphsOutput.OutPath;
                output += EzmagOutput.OutPath;
                output += EzphsOutput.OutPath;
                output(Paths, filePath, ProjName, TxIndex, txTotol, rxball, txPosition, Frequence, minFrequence, maxFrequence);
            }
        }
コード例 #11
0
 public SanGuoCapture(OutputDelegate o)
     : base(o)
 {
     ShowHex         = true;
     ShowChar        = true;
     IsShowInspector = false;
 }
コード例 #12
0
        delegate void OutputDelegate(string s);//(ref int a, ref int b);

        public static void testClass(string dllPath)
        {
            var DLL     = Assembly.LoadFile(dllPath);
            var theType = DLL.GetType("dll_test.Class1"); // 네임스페이스. 클래스 명

            if (theType == null)
            {
                // not found calss
            }

            // 1. 메서드 직접 호출이 아닌 type에서 GetMethod로 함수를 찾고 실행시키는 방법
            var c      = Activator.CreateInstance(theType);
            var method = theType.GetMethod("Output");

            method.Invoke(c, new object[] { @"Hello" });

            // 2. 델리게이트를 이용한 방식
            MethodInfo     minfo   = theType.GetMethod("Output");
            OutputDelegate _Output = (OutputDelegate)Delegate.CreateDelegate(typeof(OutputDelegate), null, minfo);

            _Output(@"Hello_2");


            //Console.ReadLine(); // 사용자 입력대기
        }
コード例 #13
0
 protected Node(InputDelegate userInput, OutputDelegate userOutput)
 {
     input  = userInput;
     output = userOutput;
     numberIncomingConnections = 0;
     Ip = GetIpAdress();
 }
コード例 #14
0
        public static void PrintResult(Result result, OutputDelegate console, PrintOptions printOptions)
        {
            console("-----------------------------------------------------------------");
            console("Result: " + result.Graph + " Request: " + result.request);
            foreach (Unifiable s in result.InputSentences)
            {
                console("input: \"" + s + "\"");
            }
            PrintTemplates(result.ResultTemplates, console, printOptions, TimeSpan.Zero);
            foreach (SubQuery s in result.SubQueries)
            {
                console("\n" + s);
            }
            console("-");
            var OutputSentences = result.OutputSentences;

            lock (OutputSentences)
            {
                foreach (string s in OutputSentences)
                {
                    console("outputsentence: " + s);
                }
            }
            console("-----------------------------------------------------------------");
        }
コード例 #15
0
        public CmdResult ExecuteXmlCommand(string cmd, object session, OutputDelegate outputDelegate)
        {
            outputDelegate = outputDelegate ?? WriteLine;
            CmdResult res = null;

            outputDelegate("<xml>");
            outputDelegate("<cmdtext>" + cmd + "</cmdtext>"); //strinbg
            outputDelegate("<output>");                       //string
            try
            {
                res = BotClient.ExecuteCommand(cmd, session, outputDelegate, CMDFLAGS.Foregrounded);
            }
            finally
            {
                string verb = GetType().Name;
                res = res ?? ACmdResult.Complete(verb, "cannot process " + cmd, false);
                outputDelegate("\n</output>");
                outputDelegate("<message>" + res.Message + "</message>");             //string
                outputDelegate("<success>" + res.Success + "</success>");             //True/False
                outputDelegate("<invalidArgs>" + res.InvalidArgs + "</invalidArgs>"); //True/False
                outputDelegate("<completedSynchronously>" + res.CompletedSynchronously + "</completedSynchronously>");
                //True/False
                outputDelegate("<isCompleted>" + res.IsCompleted + "</isCompleted>"); //True/False
                outputDelegate("</xml>");
            }
            return(res);
        }
コード例 #16
0
        private R UserOper <R>(string operationType, Func <R> action, OutputDelegate output)
        {
            OutputDelegate prev = userTraceRedir;
            //lock (OnBotCreatedHooks)
            Action needsExit = LockInfo.MonitorTryEnter("UserOper " + operationType, BotUsers, MaxWaitTryEnter);

            try
            {
                userTraceRedir = output;
                try
                {
                    return(action());
                }
                catch (ChatSignal ex)
                {
                    throw;
                }
                catch (Exception e)
                {
                    writeToLog(e);
                    if (!ChatOptions.AllowRuntimeErrors)
                    {
                        return(default(R));
                    }
                    throw;
                }
            }
            finally
            {
                userTraceRedir = prev;
                needsExit();
            }
        }
コード例 #17
0
            public bool SyncToObject(OutputDelegate WriteLine, bool createObjects)
            {
                failed = 0;
                bool invComplete = true;

                lock (TaskItemsToCreate) foreach (var itemTask in TaskItemsToCreate)
                    {
                        if (!itemTask.FindAgentItem())
                        {
                            WriteLine("FAILED FindAgentItem: " + itemTask);
                            failed++;
                            invComplete = false;
                            continue;
                        }
                        if (!itemTask.CreateTaskItem(WriteLine, createObjects))
                        {
                            WriteLine("FAILED CreateTaskItem: " + itemTask);
                            invComplete = false;
                            failed++;
                            continue;
                        }
                        succeeded++;
                    }
                if (invComplete)
                {
                    TaskInvComplete = true;
                }
                return(failed == 0);
            }
コード例 #18
0
        private void SaveRelatedAssets(string pathStem, SimObject exportPrim, OutputDelegate Failure)
        {
            string exportFile = pathStem + ".deps";

            if (Incremental || showsMissingOnly)
            {
                lock (fileWriterLock) if (File.Exists(exportFile))
                    {
                        return;
                    }
            }
            needFiles++;
            if (showsMissingOnly)
            {
                Failure("NEED DEPS for " + named(exportPrim));
                return;
            }
            if (PrimDepsAssets.Count == 0)
            {
                lock (fileWriterLock) File.WriteAllText(exportFile, "");
                return;
            }
            string content = "";

            foreach (UUID assetID in PrimDepsAssets)
            {
                content += assetTypeOf(assetID) + "," + assetID + "\n";
            }
            lock (fileWriterLock) File.WriteAllText(exportFile, content);
        }
コード例 #19
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            //   base.acceptInput(verb, args);

            BotClient      Client  = TheBotClient;
            string         subject = String.Join(" ", args);
            OutputDelegate wtoList = (f, a) => AppendResults("events", string.Format(f, a));

            if (subject.Length == 0)
            {
                return(Success(DebugInfo(TheSimAvatar, wtoList)));
            }

            float range;
            int   blanks    = 0;
            int   nonblanks = 0;

            if (float.TryParse(subject, out range))
            {
                SimAvatar simAva = WorldSystem.TheSimAvatar;
                if (simAva != null)
                {
                    List <SimObject> objs = ((SimObjectImpl)simAva).GetNearByObjects((double)range, false);
                    if (objs.Count > 0)
                    {
                        foreach (SimObject o in objs)
                        {
                            if (o.ActionEventQueue == null || o.ActionEventQueue.Count == 0)
                            {
                                blanks++;
                                if (!(o is SimAvatar))
                                {
                                    continue;
                                }
                            }
                            string s = DebugInfo(o, wtoList);
                            WriteLine(s);
                            nonblanks++;
                        }
                    }
                }
            }
            else
            {
                int argsUsed = 0;
                var PS       = WorldSystem.GetPrimitives(Parser.SplitOff(args, argsUsed), out argsUsed);
                foreach (SimObject o in PS)
                {
                    string s = DebugInfo(o, wtoList);
                    WriteLine(s);
                    if (o.ActionEventQueue == null || o.ActionEventQueue.Count == 0)
                    {
                        blanks++;
                        continue;
                    }
                    nonblanks++;
                }
            }
            return(Success("simEventComplete blanks=" + blanks + " nonblanks=" + nonblanks));
        }
コード例 #20
0
        /// <summary>
        ///  Inspects the database for
        /// searchTerm1
        ///     max  = 1,
        ///     failprefix = "",
        ///     wordnet = true,
        ///     threshold = 0.0f
        /// </summary>
        /// <param name="searchTerm1"></param>
        /// <param name="dbgLog"></param>
        /// <param name="OnFalure"></param>
        /// <param name="templateNode"></param>
        /// <param name="threshold"> &lt;dbquery&gt; uses 0.0f by default</param>
        /// <param name="expandOnNoHits"></param>
        /// <returns></returns>
        private string callDbQuery(string searchTerm1, OutputDelegate dbgLog, Func <Unifiable> OnFalure,
                                   XmlNode templateNode, float threshold, bool expandOnNoHits, out float reliablity)
        {
            // if synonyms is overriden?? the defualt is true
            bool expandWithWordNet = true;

            return(AskQuery(searchTerm1, dbgLog, OnFalure, templateNode, threshold, expandWithWordNet, expandOnNoHits, out reliablity));
        }
コード例 #21
0
ファイル: Client.cs プロジェクト: Potashev/ClientServer
 public Client(InputDelegate userInput, OutputDelegate userOutput, int checkLostTime) : base(userInput, userOutput)
 {
     timeCheckingLost          = checkLostTime;
     sendingAvailable          = true;
     sendingInProcess          = false;
     checkingInProcess         = false;
     eventPacketSequenceAdded += TrySendNewPackets;
 }
コード例 #22
0
 /// <summary>
 /// 
 /// 
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 public override bool LoadFile(string filename, OutputDelegate WriteLine)
 {
     if (!File.Exists(filename)) return false;
     System.IO.FileStream f = System.IO.File.OpenRead(filename);
     StreamReader r = new StreamReader(f);
     r.BaseStream.Seek(0, SeekOrigin.Begin);
     return Read(filename, new StringReader(r.ReadToEnd()), WriteLine) != null;
 }
コード例 #23
0
        private bool IsExcludedSRV(string subject, string relation, string value, string factoidSRV,
                                   OutputDelegate writeToLog, string fmtString, params object[] fmtArgs)
        {
            bool ExcludedFactPattern = false;
            bool debug = (writeToLog != null);

            fmtString = TextPatternUtils.SafeFormat(fmtString, fmtArgs);
            if (factoidSRV == "false")
            {
                if (!debug)
                {
                    return(true);
                }
                writeToLog("ExcludedSRV: '{0}' Format '{1}'", fmtString, relation);
                ExcludedFactPattern = true;
            }
            fmtString += " " + factoidSRV;
            if (IsExcludedRelation(relation))
            {
                if (!debug)
                {
                    return(true);
                }
                writeToLog("ExcludedSRV: '{0}' Relation '{1}'", fmtString, relation);
                if (!ExtremeDebug)
                {
                    return(true);
                }
                ExcludedFactPattern = true;
            }
            if (IsExcludedSubject(subject))
            {
                if (!debug)
                {
                    return(true);
                }
                writeToLog("ExcludedSRV: '{0}' Subject '{1}'", fmtString, subject);
                if (!ExtremeDebug)
                {
                    return(true);
                }
                ExcludedFactPattern = true;
            }
            if (IsExcludedValue(value))
            {
                if (!debug)
                {
                    return(true);
                }
                writeToLog("ExcludedSRV: '{0}' Value '{1}'", fmtString, value);
                ExcludedFactPattern = true;
            }
            if (debug)
            {
                writeToLog(factoidSRV + " " + fmtString, fmtArgs);
            }
            return(ExcludedFactPattern);
        }
コード例 #24
0
 public CourseSystem(string id, string password, OutputDelegate logDelegate, OutputDelegate stateDelegate)
 {
     _httpHelper    = new HTTPHelper(10000);
     _jpgreader     = new Readjpg();
     UserId         = id;
     _userPassword  = password;
     _logDelegate   = logDelegate;
     _stateDelegate = stateDelegate;
 }
コード例 #25
0
        private void Error(OutputDelegate Failure, string s, params object[] ps)
        {
            string msg = DLRConsole.SafeFormat(s, ps);

            Client.DisplayNotificationInChat(msg);
            Failure(msg);
            return;

            throw new NotImplementedException(msg);
        }
コード例 #26
0
        static public CmdResult DoCmdAct(Command command, string verb, string args,
                                         object callerSession, OutputDelegate del, CMDFLAGS needResult)
        {
            string cmdStr = "ExecuteActBotCommand " + verb + " " + args;

            callerSession = SessionToCallerId(callerSession);
            var cmdr = new CmdRequest(verb, args, callerSession, del, command.GetCmdInfo());

            return(DoCmdAct(command, () => command.ExecuteRequestSyn(cmdr), cmdr, cmdStr, needResult) ?? cmdr);
        }
コード例 #27
0
        public static TextFilter filter = DLRConsole.TheGlobalLogFilter;// //new TextFilter() { "+*" };
        static public void FilteredWriteLine(string str, params object[] args)
        {
            OutputDelegate del = new OutputDelegate(ClientManager.Real ?? DLRConsole.DebugWriteLine);

            if (ClientManager.Filter == null)
            {
                ClientManager.Filter = new OutputDelegate(del);
            }
            filter.writeDebugLine(del, str, args);
        }
コード例 #28
0
ファイル: TranslatorForm.cs プロジェクト: Jeroen93/JMSChat
 private void Output(string text)
 {
     if (tbTranslator.InvokeRequired)
     {
         var od = new OutputDelegate(Output);
         Invoke(od, text);
         return;
     }
     tbTranslator.AppendLine(text);
 }
コード例 #29
0
 public CmdRequest(string verb, string args, object callerIDORZero, OutputDelegate writeLine, ParseInfo command)
     : base(args)
 {
     CmdFlags     = CMDFLAGS.Inherit;
     CmdName      = verb;
     CallerAgent  = callerIDORZero;
     Output       = writeLine;
     IsFFI        = false;
     KeysRequired = false;
     SetCmdInfo(command);
 }
コード例 #30
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context_name"></param>
 /// <param name="stringCodeReader"></param>
 /// <returns></returns>
 public override object Read(string context_name, System.IO.TextReader stringCodeReader, OutputDelegate WriteLine)
 {
     string res = null;
     int line = 0;
     while (stringCodeReader.Peek() != -1)
     {
         line++;
         res += stringCodeReader.ReadToEnd();
     }
     return res;
 } // method: Read
コード例 #31
0
        /// <summary>
        ///
        ///
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public virtual bool LoadFile(string filename, OutputDelegate WriteLine)
        {
            if (!File.Exists(filename))
            {
                return(false);
            }
            System.IO.FileStream f = System.IO.File.OpenRead(filename);
            StreamReader         r = new StreamReader(f);

            r.BaseStream.Seek(0, SeekOrigin.Begin);
            return(Read(filename, new StringReader(r.ReadToEnd()), WriteLine) != null);
        }
コード例 #32
0
 public static OutputDelegate OnlyWith(OutputDelegate writeLine, Predicate <string> msgTest)
 {
     return((f, a) =>
     {
         string msg = DLRConsole.SafeFormat(f, a);
         if (!msgTest(msg))
         {
             return;
         }
         writeLine(f, a);
     });
 }
コード例 #33
0
ファイル: SysVarCommand.cs プロジェクト: drzo/opensim4opencog
 public void SysVarHtml(OutputDelegate writeIt, bool noReadOnly)
 {
     writeIt("<table><tr><th>Variable Name</th><th>current value</th><th>Description</th></tr>");
     foreach (var sv in GetSysVars())
     {
         IKeyValuePair<string, object> svv = sv;
         var t = (svv.Value ?? svv.Key).GetType().Name;
         if (noReadOnly && svv.IsReadOnly) continue;
         writeIt(string.Format("<tr name=\"{0}\" id='{0}'><td>{0}</td><td>{1}</td><td>{2}</td></tr>",
                                     Htmlize.NoEnts(svv.Key), Htmlize.NoEnts("" + svv.Value),
                                     Htmlize.NoEnts(svv.Comments)));
     }
     writeIt("</table>");
 }
コード例 #34
0
 /// <summary>
 /// 
 /// 
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 public override bool LoadFile(string filename, OutputDelegate WriteLine)
 {
     if (!filename.EndsWith(".lisp"))
     {
         filename = filename + ".lisp";
     }
     System.IO.FileInfo fi = new System.IO.FileInfo(filename);
     if (fi.Exists)
     {
         dotLispInterpreter.LoadFile(filename);
         return true;
     }      
     return false;
 } // method: LoadFile
コード例 #35
0
        private void PrintFolder(InventoryFolder f, OutputDelegate result, int indent)
        {
            List<InventoryBase> contents = Manager.FolderContents(f.UUID, Client.Self.AgentID,
                                                                  true, true, InventorySortOrder.ByName, 10000);

            if (contents != null)
            {
                foreach (InventoryBase i in contents)
                {
                    result("{0}{1} ({2})\n", new String(' ', indent*2), i.Name, i.UUID);
                    if (i is InventoryFolder)
                    {
                        InventoryFolder folder = (InventoryFolder) i;
                        PrintFolder(folder, result, indent + 1);
                    }
                }
            }
        }
コード例 #36
0
 private void SaveRelatedAssets(string pathStem, SimObject exportPrim, OutputDelegate Failure)
 {
     string exportFile = pathStem + ".deps";
     if (Incremental || showsMissingOnly) lock (fileWriterLock) if (File.Exists(exportFile)) return;
     needFiles++;
     if (showsMissingOnly)
     {
         Failure("NEED DEPS for " + named(exportPrim));
         return;
     }
     if (PrimDepsAssets.Count == 0)
     {
         lock (fileWriterLock) File.WriteAllText(exportFile, "");
         return;
     }
     string content = "";
     foreach (UUID assetID in PrimDepsAssets)
     {
         content += assetTypeOf(assetID) + "," + assetID + "\n";
     }
     lock (fileWriterLock) File.WriteAllText(exportFile, content);
 }
コード例 #37
0
        public void ExecuteCommand(ConsoleWriteLine WriteLine, object session, string cmdline)
        {
            while (cmdline.StartsWith("/"))
            {
                cmdline = cmdline.Substring(1);
            }
            OutputDelegate newOutputDelegate = new OutputDelegate(WriteLine);
            CmdResult result;
            var botClient = BotClient;
            CMDFLAGS needResult = CMDFLAGS.Inherit | CMDFLAGS.IsConsole;
            try
            {
                if (botClient == null)
                {
                    result = clientManager.ExecuteCommand(cmdline, session, newOutputDelegate, needResult);
                }
                else
                {
                    result = botClient.ExecuteCommand(cmdline, session, newOutputDelegate, needResult);
                }

                if (result != null)
                {
                    WriteLine(result.ToString());
                }
                else
                {
                    WriteLine("No result returned: {0}", cmdline);
                }
            }
            catch (NoSuchCommand nsc)
            {
                WriteLine("NoSuchCommand: {0} => {1}", cmdline, nsc);
            }
            catch (Exception nsc)
            {
                WriteLine("Exception: {0} => {1}", cmdline, nsc);
            }
        }
コード例 #38
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
 public string CreateTask(string id, ThreadStart task, string debugName0, bool createFresh, bool kill, EventWaitHandle mre, OutputDelegate WriteLine)
 {
     BotClient TheBotClient = this;
     string[] debugName = new[] { debugName0 };
     ThreadStart thread =
         () =>
         {
             try
             {
                 try
                 {
                     task();
                 }
                 catch (ThreadAbortException e)
                 {
                     WriteLine("Aborting " + debugName[0]);
                 }
                 catch (Exception e)
                 {
                     WriteLine("Problem with {0} {1}", debugName[0], e);
                 }
             }
             finally
             {
                 try
                 {
                     if (mre != null) mre.Set();
                     if (createFresh)
                     {
                         TheBotClient.RemoveThread(Thread.CurrentThread);
                     }
                 }
                 catch (OutOfMemoryException)
                 {
                 }
                 catch (StackOverflowException)
                 {
                 }
                 catch (Exception)
                 {
                 }
                 WriteLine("done with " + debugName[0]);
             }
         };
     String threadName = id;
     if (createFresh)
     {
         TheBotClient.InvokeThread(threadName, thread);
     }
     else
     {
         Abortable tq = TheBotClient.GetTaskQueueHandler(id, true);
         if (kill)
         {
             tq.Abort();
             tq.Resume();
         }
         if (task != null) tq.Enqueue(thread);
         debugName[0] += tq;
     }
     return debugName[0];
 }
コード例 #39
0
            public bool SyncToObject(OutputDelegate WriteLine, bool createObjects)
            {
                failed = 0;
                bool invComplete = true;

                lock (TaskItemsToCreate) foreach (var itemTask in TaskItemsToCreate)
                {
                    if (!itemTask.FindAgentItem())
                    {
                        WriteLine("FAILED FindAgentItem: " + itemTask);
                        failed++;
                        invComplete = false;
                        continue;
                    }
                    if (!itemTask.CreateTaskItem(WriteLine, createObjects))
                    {
                        WriteLine("FAILED CreateTaskItem: " + itemTask);
                        invComplete = false;
                        failed++;
                        continue;
                    }
                    succeeded++;
                }
                if (invComplete) TaskInvComplete = true;
                return failed == 0;
            }
コード例 #40
0
        public void SaveLLSD(BotClient Client, string pathStem, SimObject exportPrim, OutputDelegate Failure, ImportSettings settings)
        {
            if (exportPrim != null)
            {
                string exportFile = pathStem + ".llsd";
                if (Incremental || showsMissingOnly) lock (fileWriterLock) if (File.Exists(exportFile)) return;
                needFiles++;
                if (showsMissingOnly)
                {
                    Failure("NEED LLSD for " + named(exportPrim));
                    AddMoveTo(exportPrim.SimPosition);
                    return;
                }

                try
                {
                    List<string> skipTag = new List<string>() { "Tag" };
                    Primitive prim = exportPrim.Prim;

                    Vector3 pp = prim.Position;
                    Quaternion pr = prim.Rotation;
                    //prim = prim.Clone(); 
                    OSDMap primOSD = (OSDMap) prim.GetOSD();
                    if (prim.ParentID != 0)
                    {
                        var parent = WorldSystem.GetLibOMVHostedPrim(prim.ParentID, settings.CurSim, false);
                        if (parent == null)
                        {
                            pp += new Vector3(128, 128, Client.Self.SimPosition.Z + 20);
                            Failure("YET FAILED: Cant GET parent of " + prim);
                            return;
                        }
                        else
                        {
                            pp = prim.Position * Matrix4.CreateFromQuaternion(parent.Rotation) + parent.Position;
                            pr = parent.Rotation * pr;
                            primOSD["ParentUUID"] = parent.ID;
                        }
                    }
                    primOSD["RegionPosition"] = pp;
                    primOSD["RegionRotation"] = pr;
                    if (exportPrim.PathFinding.MadeNonPhysical)
                    {
                        primOSD["physical"] = true;
                        primOSD["use_physics"] = true;
                    }
                    if (exportPrim.PathFinding.MadeNonTemp)
                    {
                        primOSD["temporary"] = true;
                    }
                    AddExportUser(primOSD["CreatorID"]);
                    AddExportGroup(primOSD["GroupID"]);
                    AddExportUser(primOSD["OwnerID"]);
                    AddExportUser(primOSD["LastOwnerID"]);
                    string output = OSDParser.SerializeLLSDXmlString(primOSD);
                    {
                        lock (fileWriterLock) File.WriteAllText(exportFile, output);
                    }
                    var ptc = Importing.APrimToCreate(prim);
                    ptc.Rezed = exportPrim;
                   
                    if (forced && !verbosely) return;
                    return;
                    Primitive prim2 = FromFile(exportFile, ExportCommand.UseBinarySerialization) as Primitive;
                    string memberwiseCompare = MemberwiseCompare(prim, prim2, skipTag);
                    if (!string.IsNullOrEmpty(memberwiseCompare))
                    {
                        string failre = "Error in LLSD: " + memberwiseCompare;
                        Failure(failre);
                        if (!forced)
                        {
                            File.Delete(exportFile);
                            return;
                            Error(failre);
                        }
                    }
                }
                catch (Exception e)
                {
                    File.Delete(exportFile);
                    Failure("Writing file " + exportFile + " caused " + e);
                }
            }
        }
コード例 #41
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
 public void InvokeAssembly(Assembly assembly, string args, OutputDelegate output)
 {
     LoadListeners(assembly);
     InvokeNext("", () =>
                        {
                            foreach (Listener item in LoadListeners(assembly))
                            {
                                item.InvokeCommand(args, output);
                                RegisterListener(item);
                            }
                        });
 }
コード例 #42
0
        private void Self_OnMessage(string FromAgentName, UUID FromAgentID, UUID ToAgentID,
            string Message, UUID IMSessionID, bool GroupIM,
            UUID RegionID, Vector3 Position,
            InstantMessageDialog Dialog, ChatType Type, EventArgs origin)
        {
            if (Dialog == InstantMessageDialog.GroupNotice)
            {
                GroupIM = true;
            }

            BotPermissions perms = GetSecurityLevel(FromAgentID, FromAgentName);

            // Received an IM from someone that is authenticated
            if (Type == ChatType.OwnerSay)
            {
                perms |= BotPermissions.Owner;
            }

            bool displayedMessage = false;
            if (origin is ChatEventArgs && Message.Length > 0 && Dialog == InstantMessageDialog.MessageFromAgent)
            {
                WriteLine(String.Format("{0} says, \"{1}\".", FromAgentName, Message));
                PosterBoard["/posterboard/onchat"] = Message;
                if (FromAgentName == Self.Name)
                {
                    PosterBoard["/posterboard/onchat-said"] = Message;
                }
                else
                {
                    PosterBoard["/posterboard/onchat-heard"] = Message;
                }
            }

            bool groupIM = GroupIM && GroupMembers != null && GroupMembers.ContainsKey(FromAgentID) ? true : false;


            switch (Dialog)
            {
                case InstantMessageDialog.MessageBox:
                    break;
                case InstantMessageDialog.GroupInvitation:
                    if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                    {
                        string groupName = Message;
                        int found = groupName.IndexOf("Group:");
                        if (found > 0) groupName = groupName.Substring(found + 6);
                        Self.InstantMessage(Self.Name, FromAgentID, string.Empty, IMSessionID,
                                            InstantMessageDialog.GroupInvitationAccept, InstantMessageOnline.Offline,
                                            Self.SimPosition,
                                            UUID.Zero, new byte[0]);
                        found = groupName.IndexOf(":");
                        if (found > 0)
                        {
                            groupName = groupName.Substring(0, found).Trim();
                            ExecuteCommand("joingroup " + groupName, CMDFLAGS.NoResult);
                        }
                    }
                    break;
                case InstantMessageDialog.InventoryOffered:
                    break;
                case InstantMessageDialog.InventoryAccepted:
                    break;
                case InstantMessageDialog.InventoryDeclined:
                    break;
                case InstantMessageDialog.GroupVote:
                    break;
                case InstantMessageDialog.TaskInventoryOffered:
                    break;
                case InstantMessageDialog.TaskInventoryAccepted:
                    break;
                case InstantMessageDialog.TaskInventoryDeclined:
                    break;
                case InstantMessageDialog.NewUserDefault:
                    break;
                case InstantMessageDialog.SessionAdd:
                    break;
                case InstantMessageDialog.SessionOfflineAdd:
                    break;
                case InstantMessageDialog.SessionGroupStart:
                    break;
                case InstantMessageDialog.SessionCardlessStart:
                    break;
                case InstantMessageDialog.SessionSend:
                    break;
                case InstantMessageDialog.SessionDrop:
                    break;
                case InstantMessageDialog.BusyAutoResponse:
                    break;
                case InstantMessageDialog.ConsoleAndChatHistory:
                    break;
                case InstantMessageDialog.Lure911:
                case InstantMessageDialog.RequestTeleport:
                    if ((perms & BotPermissions.AcceptTeleport) != 0)
                    {
                        TheSimAvatar.StopMoving();
                        if (RegionID != UUID.Zero)
                        {
                            if (!displayedMessage)
                            {
                                DisplayNotificationInChat("TP to Lure from " + FromAgentName);
                                displayedMessage = true;
                            }
                            SimRegion R = SimRegion.GetRegion(RegionID, gridClient);
                            if (R != null)
                            {
                                Self.Teleport(R.RegionHandle, Position);
                                return;
                            }
                        }
                        DisplayNotificationInChat("Accepting TP Lure from " + FromAgentName);
                        displayedMessage = true;
                        Self.TeleportLureRespond(FromAgentID, IMSessionID, true);
                    }
                    break;
                case InstantMessageDialog.AcceptTeleport:
                    break;
                case InstantMessageDialog.DenyTeleport:
                    break;
                case InstantMessageDialog.GodLikeRequestTeleport:
                    break;
              //  case InstantMessageDialog.CurrentlyUnused:
                //    break;
                case InstantMessageDialog.GotoUrl:
                    break;
                case InstantMessageDialog.Session911Start:
                    break;
                case InstantMessageDialog.FromTaskAsAlert:
                    break;
                case InstantMessageDialog.GroupNotice:
                    break;
                case InstantMessageDialog.GroupNoticeInventoryAccepted:
                    break;
                case InstantMessageDialog.GroupNoticeInventoryDeclined:
                    break;
                case InstantMessageDialog.GroupInvitationAccept:
                    break;
                case InstantMessageDialog.GroupInvitationDecline:
                    break;
                case InstantMessageDialog.GroupNoticeRequested:
                    break;
                case InstantMessageDialog.FriendshipOffered:
                    if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                    {
                        DisplayNotificationInChat("Accepting Friendship from " + FromAgentName);
                        Friends.AcceptFriendship(FromAgentID, IMSessionID);
                        displayedMessage = true;
                    }
                    break;
                case InstantMessageDialog.FriendshipAccepted:
                    break;
                case InstantMessageDialog.FriendshipDeclined:
                    break;
                case InstantMessageDialog.StartTyping:
                    break;
                case InstantMessageDialog.StopTyping:
                    break;
                case InstantMessageDialog.MessageFromObject:
                case InstantMessageDialog.MessageFromAgent:
                    // message from self
                    if (FromAgentName == GetName()) return;
                    // message from system
                    if (FromAgentName == "System") return;
                    // message from others
                    CommandInstance ci;
                    if (Commands.TryGetValue("im", out ci))
                    {
                        var whisper = ci.WithBotClient as Cogbot.Actions.Communication.ImCommand;
                        if (whisper != null)
                        {
                            whisper.currentAvatar = FromAgentID;
                            whisper.currentSession = IMSessionID;
                        }
                    }
                    var cea = origin as ChatEventArgs;
                    if ((perms & BotPermissions.ExecuteCommands) != 0)
                    {
                        OutputDelegate WriteLine;
                        if (origin is InstantMessageEventArgs)
                        {
                            WriteLine = new OutputDelegate(
                                (string text, object[] ps) =>
                                    {
                                        string reply0 = DLRConsole.SafeFormat(text, ps);
                                        InstantMessage(FromAgentID, reply0, IMSessionID);
                                    });
                        }
                        else
                        {
                            WriteLine = new OutputDelegate(
                                (string text, object[] ps) =>
                                    {
                                        string reply0 = DLRConsole.SafeFormat(text, ps);
                                        Talk(reply0, 0, Type);
                                    });
                        }
                        string cmd = Message;
                        CMDFLAGS needResult = CMDFLAGS.Console;
                        if (cmd.StartsWith("cmcmd "))
                        {
                            cmd = cmd.Substring(6);
                            WriteLine("");
                            WriteLine(string.Format("invokecm='{0}'", cmd));
                            ClientManager.DoCommandAll(cmd, FromAgentID, WriteLine);
                        }
                        else if (cmd.StartsWith("cmd "))
                        {
                            cmd = cmd.Substring(4);
                            WriteLine(string.Format("invoke='{0}'", cmd));
                            var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                            WriteLine("iresult='" + res + "'");
                        }
                        else if (cmd.StartsWith("/") || cmd.StartsWith("@"))
                        {
                            cmd = cmd.Substring(1);
                            WriteLine("");
                            WriteLine(string.Format("invoke='{0}'", cmd));
                            var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                            WriteLine("iresult='" + res + "'");
                        }
                    }
                    if (cea != null && cea.AudibleLevel == ChatAudibleLevel.Barely) return;
                    break;
                default:
                    break;
            }
            //if (Dialog != InstantMessageDialog.MessageFromAgent && Dialog != InstantMessageDialog.MessageFromObject)
            {
                string debug = String.Format("{0} {1} {2} {3} {4} {5}: {6}",
                                             groupIM ? "GroupIM" : "IM", Dialog, Type, perms, FromAgentID, FromAgentName,
                                             Helpers.StructToString(origin));
                if (!displayedMessage)
                {
                    DisplayNotificationInChat(debug);
                    displayedMessage = true;
                }
            }
        }
コード例 #43
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
 static public CmdResult DoCmdAct(Command command, string verb, string args, 
     object callerSession, OutputDelegate del, CMDFLAGS needResult)
 {
     
     string cmdStr = "ExecuteActBotCommand " + verb + " " + args;
     callerSession = SessionToCallerId(callerSession);
     var cmdr = new CmdRequest(verb, args, callerSession, del, command.GetCmdInfo());
     return DoCmdAct(command, () => command.ExecuteRequestSyn(cmdr), cmdr, cmdStr, needResult) ?? cmdr;
 }
コード例 #44
0
 internal bool ExportPrim0(BotClient Client, SimObject exportPrim, OutputDelegate Failure, ImportSettings settings)
 {
     if (IsSkipped(exportPrim, settings)) return false;
     Simulator CurSim = exportPrim.GetSimulator();
     //settings.CurSim = CurSim;
     WorldObjects.EnsureSelected(exportPrim.LocalID, CurSim);
     string pathStem = Path.Combine(dumpDir, exportPrim.ID.ToString());
     if (settings.Contains("task") || showsMissingOnly)
     {
         exportPrim.StartGetTaskInventory();
     }
     if (settings.Contains("wait"))
     {
         var waitUntil = DateTime.Now.AddSeconds(10);
         bool needsLoop = true;
         while (needsLoop && waitUntil > DateTime.Now)
         {
             needsLoop = false;
             if (exportPrim.Properties == null || CogbotHelpers.IsNullOrZero(exportPrim.Properties.OwnerID))
             {
                 needsLoop = true;
             }
             if (settings.Contains("task"))
             {
                 var ti = exportPrim.TaskInventory;
                 if (ti == null)
                 {
                     needsLoop = true;
                 }
             }
         }
         if (needsLoop)
         {
             Success("needs loop " + named(exportPrim));
             string bissues = exportPrim.MissingData;
             if (!string.IsNullOrEmpty(bissues) && !settings.Allows(bissues ,exportPrim))
             {
                 Failure("Cant wait out the Issues " + bissues + ": " + named(exportPrim));
                 if (LocalFailures == 0) LocalFailures++;
               //  return;
             }
         }
     }
     string issues = exportPrim.MissingData;           
     if (!string.IsNullOrEmpty(issues) && !settings.Allows(issues, exportPrim))
     {
         Failure("Issues " + issues + " " + named(exportPrim));
         if (LocalFailures == 0) LocalFailures++;
         //return false;
     }
     //ImportCommand.PrimToCreate ptc = ImportCommand.Running.APrimToCreate(exportPrim.ID);
     //ptc._prim = exportPrim.Prim;
     bool passedOK = true;
     if (settings.Contains("llsd"))
     {
         SaveLLSD(Client, pathStem, exportPrim, Failure, settings);
     }
     if (exportPrim.IsRoot && (true || exportPrim.Children.Count > 0))
     {
         if (settings.Contains("link")) SaveLinksetInfo(Client, pathStem, exportPrim, Failure, settings);
         string exportFile = pathStem + ".link";
         //lock (fileWriterLock) if (File.Exists(exportFile))
         {
             foreach (var c in exportPrim.Children)
             {
                 var ch = ExportPrim(Client, c, Failure, settings);
                 if (!ch) passedOK = false;
             }
         }
     }
     if (settings.Contains("task"))
     {
         if (!SaveTaskInv(settings, Client, pathStem, exportPrim, Failure)) passedOK = false;
         // ImportCommand.PrimToCreate ptc = ImportCommand.Running.APrimToCreate(exportPrim.ID);
         //  if (!ptc.EnsureTaskInv()) return false;
     }
     if (!settings.Contains("dep")) return passedOK;
     AddRelatedTextures(exportPrim);
     SaveRelatedAssets(pathStem, exportPrim, Failure);
     return passedOK;
 }
コード例 #45
0
        } // method: LoadFile


        /// <summary>
        /// 
        /// </summary>
        /// <param name="context_name"></param>
        /// <param name="stringCodeReader"></param>
        /// <returns></returns>
        public override object Read(string context_name, System.IO.TextReader stringCodeReader, OutputDelegate WriteLine)
        {
            return dotLispInterpreter.Read(context_name, stringCodeReader);
        } // method: Read
コード例 #46
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
 internal void DoCommandAll(string line, UUID uUID, OutputDelegate outputDelegate)
 {
     ClientManager.DoCommandAll(line, uUID, outputDelegate);
 }
コード例 #47
0
 public bool ExportPrim(BotClient Client, SimObject exportPrim, OutputDelegate Failure, ImportSettings settings)
 {
     uint localID = exportPrim.LocalID;
     WorldObjects.EnsureRequested(localID + 1, settings.CurSim);
     try
     {
         Client.Objects.SelectObject(settings.CurSim, localID);
         WorldObjects.EnsureRequested(localID, settings.CurSim);
         return ExportPrim0(Client, exportPrim, Failure, settings);
     }
     finally
     {
         Client.Objects.DeselectObject(settings.CurSim, localID);                
     }
 }
コード例 #48
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
 public CmdResult ExecuteCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult)
 {
     text = ClientManager.GetCommandText(text);
     try
     {
         return ExecuteBotCommand(text, session, WriteLine, needResult);
     }
     catch (NoSuchCommand)
     {
     }
     try
     {
         return ClientManager.ExecuteSystemCommand(text, session, WriteLine, needResult);
     }
     catch (NoSuchCommand)
     {
     }
     string verb = Parser.ParseArguments(text)[0];
     Command act = GetCommand(verb, false);
     if (act != null)
     {
         if (act is GridMasterCommand)
         {
             if (!WorldSystem.IsGridMaster)
             {
                 throw new NoSuchCommand("I am not gridMaster " + text + ".");
                 return null;
             }
         }
         if (act is RegionMasterCommand)
         {
             if (!IsRegionMaster)
             {
                 WriteLine("I am not regionMaster " + text + ".");
             }
         }
         string pargs = (text.Length > verb.Length) ? text.Substring(verb.Length + 1) : "";
         return BotClient.DoCmdAct(act, verb, pargs, BotClient.SessionToCallerId(session),
                                   WriteLine, needResult);
     }
     throw new NoSuchCommand("I don't understand the ExecuteCommand " + text + ".");
 }
コード例 #49
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
        public CmdResult ExecuteXmlCommand(string cmd, object session, OutputDelegate line)
        {
            return XmlInterp.ExecuteXmlCommand(cmd, session, line);

        }
コード例 #50
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
 public CmdResult ExecuteTask(string scripttype, TextReader reader, OutputDelegate WriteLine)
 {
     var si = ScriptManager.LoadScriptInterpreter(scripttype, this, _LispTaskInterperter);
     object o = si.Read(scripttype, reader, WriteLine);
     if (o is CmdResult) return (CmdResult) o;
     string verb = "ExecuteTask " + scripttype;
     if (o == null) return ACmdResult.Complete(verb, "void", true);
     if (si.Eof(o)) return ACmdResult.Complete(verb, "EOF " + o, true);
     o = si.Eval(o);
     if (o is CmdResult) return (CmdResult) o;
     verb = "ExecuteTask " + o;
     if (o == null) return ACmdResult.Complete(verb, "void", true);
     if (si.Eof(o)) return ACmdResult.Complete(verb, "EOF " + o, true);
     return ACmdResult.Complete(verb, "" + o, true);
 }
コード例 #51
0
 public bool SyncToAgentFolder(OutputDelegate WriteLine, bool createObjects)
 {
     failed = 0;
     succeeded = 0;
     // create missing source nodes
     lock (TaskItemsToCreate) foreach (var itemTask in TaskItemsToCreate)
     {
         if (!itemTask.CreateAgentItem(WriteLine, createObjects))
         {
             failed++;
             TaskInvComplete = false;
         }
         else
         {
             succeeded++;
         }
     }
     return failed == 0;
 }
コード例 #52
0
 void SaveLinksetInfo(BotClient Client, string pathStem, SimObject exportPrim, OutputDelegate Failure, ImportSettings settings)
 {
     string exportFile = pathStem + ".link";
     if (Incremental || true) lock (fileWriterLock) if (File.Exists(exportFile)) return;
     if (false && exportPrim.Children.Count == 0)
     {
         // so we dont do it again
         if (Incremental) lock (fileWriterLock) File.WriteAllText(exportFile, "");
         return;
     }
     if (Incremental || showsMissingOnly) lock (fileWriterLock) if (File.Exists(exportFile)) return;
     needFiles++;
     if (showsMissingOnly)
     {
         Failure("NEED LINK for " + named(exportPrim));
         return;
     }
     SlowlyDo(() => RequestLinksetInfo(Client, pathStem, exportPrim, Failure, settings));
 }
コード例 #53
0
ファイル: ConsoleApp.cs プロジェクト: drzo/opensim4opencog
        public static TextFilter filter = DLRConsole.TheGlobalLogFilter;// //new TextFilter() { "+*" };
        static public void FilteredWriteLine(string str, params object[] args)
        {

            OutputDelegate del = new OutputDelegate(ClientManager.Real ?? DLRConsole.DebugWriteLine);
            if (ClientManager.Filter == null)
            {
                ClientManager.Filter = new OutputDelegate(del);
            }
            filter.writeDebugLine(del, str, args);
        }
コード例 #54
0
 public void RequestLinksetInfo(BotClient Client, string pathStem, SimObject exportPrim, OutputDelegate Failure, ImportSettings settings)
 {
     string exportFile = pathStem + ".link";
     lock (fileWriterLock) if (File.Exists(exportFile)) return;
     bool canScript = checkPerms(Client, exportPrim, SilientFailure, true);
     InventoryItem found = GetInvItem(Client, "LinksetSpeaker");
     if (!canScript || found == null)
     {
         ScanForLinksets(exportPrim);
         return;
     }
     lock (PrimWaitingLinkset)
     {
         if (PrimWaitingLinkset.ContainsKey(exportPrim.ID)) return;
         PrimWaitingLinkset.Add(exportPrim.ID, new LinkSetBuffer {S = "", O = exportPrim, F = pathStem});
     }
     PutItemToTaskInv(Client,exportPrim.LocalID, exportPrim, "LinksetSpeaker");
 }
コード例 #55
0
 public SimEventTextSubscriber(OutputDelegate _text, BotClient from)
 {
     From = from;
     textForm = _text;
     EventsEnabled = true;
 }
コード例 #56
0
        public static bool checkPerms(BotClient Client, SimObject exportPrim, OutputDelegate Failure, bool mustModify)
        {
            if (exportPrim != null)
            {

                var Properties = exportPrim.Properties;
                if (Properties == null)
                {
                    Client.Objects.RequestObjectPropertiesFamily(exportPrim.GetSimulator(), exportPrim.ID, true);
                    Failure("No props yet for " + named(exportPrim));
                    return false;
                }
                // Check for export permission first
                //GotPermissions = false;
                //
                //if (!GotPermissions)
                // {
                //   Properties = exportPrim.Properties ?? new Primitive.ObjectProperties();
                //}
                //   GotPermissionsEvent.WaitOne(1000 * 10, false);
                if (Properties.OwnerID != Client.Self.AgentID &&
                    Properties.OwnerID != Client.MasterKey &&
                    Properties.GroupID != Client.Self.ActiveGroup)
                {
                    Failure("That object is owned by " + Properties.OwnerID + ", we don't have permission " +
                            "to export " + named(exportPrim));
                }

                SimAvatarClient theAvatar = Client.TheSimAvatar;
                PermissionWho pw = theAvatar.EffectivePermissionWho(exportPrim);
                PermissionMask pm = theAvatar.EffectivePermissionsMask(exportPrim);

                bool modify = Permissions.HasPermissions(pm, PermissionMask.Modify);

                bool cmt = Permissions.HasPermissions(pm, PermissionMask.Copy) ||
                           Permissions.HasPermissions(pm, PermissionMask.Modify) ||
                           Permissions.HasPermissions(pm, PermissionMask.Transfer);

                if (mustModify)
                {
                    if (!modify)
                    {
                        Failure("ObjPerms NOMODIFY " + pm + " for " + pw + " on " + named(exportPrim));
                        return false;
                    }
                }
                if (!cmt)
                {
                    Failure("ObjPerms " + pm + " for " + pw + " on " + named(exportPrim));
                    return false;
                }

                //List<SimObject> family = new List<SimObject>();
                //family.Add(exportPrim);
                //family.AddRange(exportPrim.Children);

                /*bool complete = RequestObjectProperties(family, 250, exportPrim.GetSimulator());
                exportedPrims.AddRange(family);

                if (!complete)
                {
                    Logger.Log("Warning: Unable to retrieve full properties for:", Helpers.LogLevel.Warning, Client);
                    foreach (UUID uuid in PrimsWaiting.Keys)
                        Logger.Log(uuid.ToString(), Helpers.LogLevel.Warning, Client);
                }
                 * return true;*/
            }
            return true;
        }
コード例 #57
0
        private void acceptInput0(string verb, string[] argstokens, OutputDelegate WriteLine)
        {
            //   base.acceptInput(verb, args);

            BotClient Client = TheBotClient;
            if (!Client.IsLoggedInAndReady)
            {
                WriteLine("Not yet logged in");
                return;
            }

            double range;
            if (argstokens.Length > 0 && double.TryParse(argstokens[0], out range))
            {
                SimAvatar simAva = WorldSystem.TheSimAvatar;
                if (simAva != null)
                {
                    List<SimObject> objs = ((SimObjectImpl) simAva).GetNearByObjects(range, false);
                    if (objs.Count > 0)
                    {
                        foreach (SimObject o in objs)
                        {
                            WriteLine(WorldSystem.describePrim(o.Prim, false));
                        }
                        return;
                    }
                    WriteLine("looked at range " + range + " and saw " + objs.Count);
                }
                WriteLine("We have no body yet");
            }
            else
            {
                {
                    {
                        int found = 0;
                        int argsUsed;

                        if (argstokens.Length == 0)
                        {
                            argstokens = Parser.ParseArguments(DefaultLookString);
                        }
                        List<SimObject> PS = WorldSystem.GetPrimitives(argstokens, out argsUsed);
                        bool detailed = true;
                        if (!IsEmpty(PS))
                        {
                            if (PS.Count > 1) detailed = false;
                            foreach (var prim in PS)
                            {
                                found++;
                                if (!prim.HasPrim)
                                {
                                    WriteLine("" + prim);
                                    continue;
                                }
                                if (prim is SimAvatar)
                                    WriteLine(WorldSystem.describeAvatar((Avatar) prim.Prim));
                                else
                                    WriteLine(WorldSystem.describePrim(prim.Prim, detailed));
                                //if (found > 30) break;
                            }
                        }
                        if (found == 0) WriteLine("I don't know about " + Parser.Rejoin(argstokens, 0) + ".");
                        WriteLine("PS.Count==" + PS.Count);
                    }
                }
            }
        }
コード例 #58
0
ファイル: BotScripting.cs プロジェクト: drzo/opensim4opencog
        public CmdResult ExecuteBotCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult)
        {
            text = ClientManager.GetCommandText(text);
            try
            {

                if (text.StartsWith("("))
                {
                    InvokeJoin("ExecuteBotCommand " + text);
                    return ACmdResult.Complete("evalLispString", evalLispString(text).ToString(), true);
                }

                text = text.Replace("\"", "").Replace("  ", " ");
                string verb = text.Split(' ')[0];
                verb = verb.ToLower();

                Command act = GetCommand(verb, false);
                if (act != null)
                {
                    if (act is GridMasterCommand)
                    {
                        if (!WorldSystem.IsGridMaster)
                        {
                            throw new NoSuchCommand("I am not gridMaster " + text + ".");
                            return null;
                        }
                    }
                    if (act is RegionMasterCommand)
                    {
                        if (!IsRegionMaster)
                        {
                            throw new NoSuchCommand("I am not regionMaster " + text + ".");
                            return null;
                        }
                    }
                    try
                    {
                        string args = (text.Length > verb.Length) ? text.Substring(verb.Length + 1) : "";
                        return DoCmdAct(act, verb, args, session, WriteLine, needResult);
                    }
                    catch (Exception e)
                    {
                        if (e is NoSuchCommand) throw e;
                        LogException("ExecuteBotCommand Command " + text, e);
                        return ACmdResult.Complete("ExecuteBotCommand", "ExecuteBotCommand " + text + "cuased " + e, false);
                    }
                }
                else
                {
                    if (WorldSystem == null || WorldSystem.SimAssetSystem == null)
                        return ACmdResult.Complete(verb, "no world yet for gesture", false);
                    UUID assetID = WorldSystem.SimAssetSystem.GetAssetUUID(text, AssetType.Gesture);
                    if (assetID != UUID.Zero) return ExecuteBotCommand("play " + assetID, session, WriteLine, needResult);
                    assetID = WorldSystem.SimAssetSystem.GetAssetUUID(text, AssetType.Unknown);
                    if (assetID != UUID.Zero) return ExecuteBotCommand("play " + assetID, session, WriteLine, needResult);
                    throw new NoSuchCommand(verb);
                }
            }
            catch (Exception e)
            {
                if (e is NoSuchCommand) throw e;
                LogException("ExecuteBotCommand " + text, e);
                return null;
            }
        }
コード例 #59
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 public FetchTimerForm()
 {
     InitializeComponent();
     OutputMethodInstance = OutputResults;
 }
コード例 #60
0
            public bool LoadTaskOSD(OutputDelegate WriteLine)
            {
                failed = 0;
                succeeded = 0;
                string taskFile = ExportCommand.dumpDir + OldID + ".task";
                string taskDataS = File.ReadAllText(taskFile);
                if (string.IsNullOrEmpty(taskDataS) || taskDataS.Length < 30)
                {
                    TaskInvComplete = true;
                    return true;
                }
                var taskData = OSDParser.DeserializeLLSDXml(taskDataS) as OSDArray;
                if (taskData == null)
                {
                    WriteLine("ERROR: Cant read taskData: " + taskDataS);
                    return false;
                }

                lock (TaskItemsToCreate) if (taskData.Count == TaskItemsToCreate.Count && taskData.Count > 0)
                {
                    succeeded = taskData.Count;
                    return true;
                }
                // scan for existing source nodes
                lock (TaskItemsToCreate)
                {
                    foreach (OSDMap item in taskData)
                    {
                        if (item["AssetType"].Type == OSDType.Unknown)
                        {
                            continue;
                        }
                        var itemID = item["UUID"].AsUUID();
                        TaskItemToCreate titc = null;

                        foreach (TaskItemToCreate itemToCreate in TaskItemsToCreate)
                        {
                            if (itemToCreate.OldItemID == itemID)
                            {
                                titc = itemToCreate;
                                break;
                            }
                        }
                        if (titc == null)
                        {
                            titc = new TaskItemToCreate(this, item);
                            TaskItemsToCreate.Add(titc);
                        }
                        else
                        {
                            titc.TaskItemOSD = item;
                        }
                        AssignObjectNums();
                        succeeded++;
                    }
                }
                return failed == 0;
            }