public void InvokeAsync(UPnPService S, string Action, byte[] InArgs, string Caller, int Handle)
        {
            UPnPAction A     = S.GetAction(Action);
            ArrayList  AList = new ArrayList();

            foreach (UPnPArgument arg in A.ArgumentList)
            {
                if (arg.IsReturnValue == false && arg.Direction == "out")
                {
                    UPnPArgument _arg = (UPnPArgument)arg.Clone();
                    _arg.DataValue = UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(), null);
                    AList.Add(_arg);
                }
            }

            UPnPArgument[] Temp = ParseArguments(InArgs);
            foreach (UPnPArgument _arg in Temp)
            {
                _arg.DataType  = A.GetArg(_arg.Name).RelatedStateVar.ValueType;
                _arg.Direction = "in";
                AList.Add(_arg);
            }

            UPnPArgument[] Arguments = (UPnPArgument[])AList.ToArray(typeof(UPnPArgument));

            (new UPnPDebugObject(S)).SetProperty("ValidationMode", false);
            S.InvokeAsync(Action, Arguments, new Object[2] {
                Caller, Handle
            }, A_ICB, A_IECB);
        }
        private ArrayList BasicControlTest_BuildActionArgs(UPnPAction A)
        {
            ArrayList ArgList = new ArrayList();

            foreach (UPnPArgument arg in A.ArgumentList)
            {
                if (arg.IsReturnValue == false)
                {
                    UPnPArgument NArg;
//					if(arg.RelatedStateVar.GetNetType().FullName=="System.String")
//					{
//						NArg = new UPnPArgument(arg.Name,"Sample String");
//					}
//					else
//					{
                    NArg = new UPnPArgument(arg.Name, UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(), null));
//					}
                    if (arg.RelatedStateVar.AllowedStringValues != null)
                    {
                        NArg.DataValue = arg.RelatedStateVar.AllowedStringValues[0];
                    }
                    if (arg.RelatedStateVar.Minimum != null)
                    {
                        NArg.DataValue = arg.RelatedStateVar.Minimum;
                    }
                    if (arg.RelatedStateVar.Maximum != null)
                    {
                        NArg.DataValue = arg.RelatedStateVar.Maximum;
                    }
                    ArgList.Add(NArg);
                }
            }
            return(ArgList);
        }
 private void Error_Sink_GetCurrentConnectionIDs(UPnPService sender, string MethodName, UPnPArgument[] Args, UPnPInvokeException e, object _Tag)
 {
     object[] StateInfo = (object[])_Tag;
     if (StateInfo[1] != null)
     {
         ((Delegate_OnResult_GetCurrentConnectionIDs)StateInfo[1])(this, (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), e, StateInfo[0]);
     }
     else
     {
         OnResult_GetCurrentConnectionIDs_Event.Fire(this, (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), e, StateInfo[0]);
     }
 }
        private void TestAction(UPnPAction A)
        {
            ArrayList    ArgList  = new ArrayList();
            Hashtable    RelTable = new Hashtable();
            UPnPArgument G;

            foreach (UPnPArgument arg in A.Arguments)
            {
                if (arg.IsReturnValue == false)
                {
                    G           = new UPnPArgument(arg.Name, UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(), null));
                    RelTable[G] = arg.RelatedStateVar;
                    ArgList.Add(G);
                }
            }
        }
예제 #5
0
 private void Error_Sink_GetCurrentConnectionIDs(UPnPService sender, string MethodName, UPnPArgument[] Args, UPnPInvokeException e, int Handle)
 {
     if (OnResult_GetCurrentConnectionIDs != null)
     {
         OnResult_GetCurrentConnectionIDs((System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), e, Handle);
     }
     WeakReference[] w = (WeakReference[])WeakList_GetCurrentConnectionIDs.ToArray(typeof(WeakReference));
     foreach (WeakReference wr in w)
     {
         if (wr.IsAlive == true)
         {
             ((Delegate_OnResult_GetCurrentConnectionIDs)wr.Target)((System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), e, Handle);
         }
         else
         {
             WeakList_GetCurrentConnectionIDs.Remove(wr);
         }
     }
 }
        protected void LastChangeSink(CpRenderingControl sender, string LC)
        {
            if (LC == "")
            {
                return;
            }
            if (LC.Substring(0, 1) != "<")
            {
                LC = UPnPStringFormatter.UnEscapeString(LC);
            }
            if (LC.Substring(0, 1) != "<")
            {
                LC = UPnPStringFormatter.UnEscapeString(LC);
            }


            /*
             * if(LC.StartsWith("<?")==true)
             * {
             *      int dx = LC.IndexOf(">");
             *      LC = LC.Substring(0,dx+1) + "<MYROOT>" + LC.Substring(dx+1) + "</MYROOT>";
             * }
             * else
             * {
             *      LC = "<MYROOT>" + LC + "</MYROOT>";
             * }*/

            StringReader  MyString = new StringReader(LC);
            XmlTextReader XMLDoc   = new XmlTextReader(MyString);

            Hashtable T = new Hashtable();

            int    ID        = -1;
            string VarName   = "";
            string VarValue  = "";
            string AttrName  = "";
            string AttrValue = "";

            XMLDoc.Read();
            XMLDoc.MoveToContent();

            XMLDoc.Read();
            XMLDoc.MoveToContent();

            while ((XMLDoc.LocalName != "Event") && (XMLDoc.EOF == false))
            {
                // At Start, should be InstanceID
                if (XMLDoc.LocalName == "InstanceID")
                {
                    XMLDoc.MoveToAttribute("val");
                    ID = int.Parse(XMLDoc.GetAttribute("val"));
                    if (T.ContainsKey(ID) == false)
                    {
                        T[ID] = new Hashtable();
                    }
                    XMLDoc.MoveToContent();

                    XMLDoc.Read();
                    XMLDoc.MoveToContent();

                    while (XMLDoc.LocalName != "InstanceID")
                    {
                        VarName   = XMLDoc.LocalName;
                        VarValue  = "";
                        AttrName  = "";
                        AttrValue = "";

                        for (int a_idx = 0; a_idx < XMLDoc.AttributeCount; ++a_idx)
                        {
                            XMLDoc.MoveToAttribute(a_idx);
                            if (XMLDoc.LocalName == "val")
                            {
                                VarValue = XMLDoc.GetAttribute(a_idx);
                            }
                            else
                            {
                                AttrName  = XMLDoc.LocalName;
                                AttrValue = XMLDoc.GetAttribute(a_idx);
                            }
                        }

                        XMLDoc.MoveToContent();

                        if (AttrName == "")
                        {
                            ((Hashtable)T[ID])[VarName] = VarValue;
                        }
                        else
                        {
                            if (((Hashtable)T[ID]).ContainsKey(VarName) == false)
                            {
                                ((Hashtable)T[ID])[VarName] = new Hashtable();
                            }
                            if (((Hashtable)((Hashtable)T[ID])[VarName]).ContainsKey(AttrName) == false)
                            {
                                ((Hashtable)((Hashtable)T[ID])[VarName])[AttrName] = new Hashtable();
                            }
                            ((Hashtable)((Hashtable)((Hashtable)T[ID])[VarName])[AttrName])[AttrValue] = VarValue;
                        }
                        XMLDoc.Read();
                        XMLDoc.MoveToContent();
                    }
                }
                else
                {
                    XMLDoc.Skip();
                }
                XMLDoc.Read();
                XMLDoc.MoveToContent();
            }

            XMLDoc.Close();


            IDictionaryEnumerator inEn = T.GetEnumerator();
            IDictionaryEnumerator EvEn;
            Hashtable             TT;

            while (inEn.MoveNext())
            {
                if ((int)inEn.Key == InstanceID)
                {
                    TT   = (Hashtable)inEn.Value;
                    EvEn = TT.GetEnumerator();
                    while (EvEn.MoveNext())
                    {
                        switch ((string)EvEn.Key)
                        {
                        case "Mute":
                            if (EvEn.Value.GetType().FullName == "System.String")
                            {
                                MuteByChannel["MASTER"] = (bool)UPnPService.CreateObjectInstance(typeof(bool), (string)EvEn.Value);
                            }
                            else
                            {
                                IDictionaryEnumerator E2 = ((Hashtable)EvEn.Value).GetEnumerator();
                                while (E2.MoveNext())
                                {
                                    IDictionaryEnumerator E3 = ((Hashtable)((Hashtable)E2.Value)).GetEnumerator();
                                    while (E3.MoveNext())
                                    {
                                        MuteByChannel[E3.Key.ToString()] = (bool)UPnPService.CreateObjectInstance(typeof(bool), E3.Value.ToString());
                                    }
                                }
                            }

                            if (OnMuteChanged != null)
                            {
                                OnMuteChanged(this);
                            }
                            break;

                        case "Volume":
                            if (EvEn.Value.GetType().FullName == "System.String")
                            {
                                VolumeByChannel["MASTER"] = UInt16.Parse((string)EvEn.Value);
                            }
                            else
                            {
                                IDictionaryEnumerator E2 = ((Hashtable)EvEn.Value).GetEnumerator();
                                while (E2.MoveNext())
                                {
                                    IDictionaryEnumerator E3 = ((Hashtable)((Hashtable)E2.Value)).GetEnumerator();
                                    while (E3.MoveNext())
                                    {
                                        VolumeByChannel[E3.Key.ToString()] = UInt16.Parse(E3.Value.ToString());
                                    }
                                }
                            }
                            //_Volume = UInt16.Parse((string)EvEn.Value);
                            if (OnVolumeChanged != null)
                            {
                                OnVolumeChanged(this);
                            }
                            break;
                        }
                    }
                }
            }
        }
        public void Invoke(UPnPService S, string Action, byte[] InArgs, out byte[] OutArgs)
        {
            UPnPAction A     = S.GetAction(Action);
            ArrayList  AList = new ArrayList();

            foreach (UPnPArgument arg in A.ArgumentList)
            {
                if (arg.IsReturnValue == false && arg.Direction == "out")
                {
                    UPnPArgument _arg = (UPnPArgument)arg.Clone();
                    _arg.DataValue = UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(), null);
                    AList.Add(_arg);
                }
            }

            UPnPArgument[] Temp = ParseArguments(InArgs);
            foreach (UPnPArgument _arg in Temp)
            {
                _arg.DataType  = A.GetArg(_arg.Name).RelatedStateVar.ValueType;
                _arg.Direction = "in";
                AList.Add(_arg);
            }

            UPnPArgument[] Arguments = (UPnPArgument[])AList.ToArray(typeof(UPnPArgument));

            (new UPnPDebugObject(S)).SetProperty("ValidationMode", false);
            object RetVal = null;

            try
            {
                RetVal = S.InvokeSync(Action, Arguments);
            }
            catch (UPnPInvokeException ie)
            {
                if (ie.UPNP != null)
                {
                    throw(ie.UPNP);
                }
                else
                {
                    throw(ie);
                }
            }

            ArrayList RetList = new ArrayList();

            if (A.HasReturnValue == true)
            {
                UPnPArgument RA = (UPnPArgument)A.GetRetArg().Clone();
                RA.DataValue = RetVal;
                RetList.Add(RA);
            }

            foreach (UPnPArgument OA in Arguments)
            {
                if (OA.Direction == "out")
                {
                    RetList.Add(OA);
                }
            }

            OutArgs = BuildArguments((UPnPArgument[])RetList.ToArray(typeof(UPnPArgument)));
        }
        private void Error_Sink_PrepareForConnection(UPnPService sender, string MethodName, UPnPArgument[] Args, UPnPInvokeException e, object _Tag)
        {
            for (int i = 0; i < Args.Length; ++i)
            {
                switch (Args[i].Name)
                {
                case "Direction":
                    switch ((string)Args[i].DataValue)
                    {
                    case "Input":
                        Args[i].DataValue = Enum_A_ARG_TYPE_Direction.INPUT;
                        break;

                    case "Output":
                        Args[i].DataValue = Enum_A_ARG_TYPE_Direction.OUTPUT;
                        break;
                    }
                    break;
                }
            }
            object[] StateInfo = (object[])_Tag;
            if (StateInfo[1] != null)
            {
                ((Delegate_OnResult_PrepareForConnection)StateInfo[1])(this, (System.String)Args[0].DataValue, (System.String)Args[1].DataValue, (System.Int32)Args[2].DataValue, (Enum_A_ARG_TYPE_Direction )Args[3].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), e, StateInfo[0]);
            }
            else
            {
                OnResult_PrepareForConnection_Event.Fire(this, (System.String)Args[0].DataValue, (System.String)Args[1].DataValue, (System.Int32)Args[2].DataValue, (Enum_A_ARG_TYPE_Direction )Args[3].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), e, StateInfo[0]);
            }
        }
 private void Error_Sink_GetCurrentConnectionInfo(UPnPService sender, string MethodName, UPnPArgument[] Args, UPnPInvokeException e, object _Tag)
 {
     object[] StateInfo = (object[])_Tag;
     if (StateInfo[1] != null)
     {
         ((Delegate_OnResult_GetCurrentConnectionInfo)StateInfo[1])(this, (System.Int32)Args[0].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (Enum_A_ARG_TYPE_Direction)0, (Enum_A_ARG_TYPE_ConnectionStatus)0, e, StateInfo[0]);
     }
     else
     {
         OnResult_GetCurrentConnectionInfo_Event.Fire(this, (System.Int32)Args[0].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (Enum_A_ARG_TYPE_Direction)0, (Enum_A_ARG_TYPE_ConnectionStatus)0, e, StateInfo[0]);
     }
 }
예제 #10
0
        private void Error_Sink_PrepareForConnection(UPnPService sender, string MethodName, UPnPArgument[] Args, UPnPInvokeException e, int Handle)
        {
            for (int i = 0; i < Args.Length; ++i)
            {
                switch (Args[i].Name)
                {
                case "Direction":
                    switch ((string)Args[i].DataValue)
                    {
                    case "Input":
                        Args[i].DataValue = Enum_A_ARG_TYPE_Direction.INPUT;
                        break;

                    case "Output":
                        Args[i].DataValue = Enum_A_ARG_TYPE_Direction.OUTPUT;
                        break;
                    }
                    break;
                }
            }
            if (OnResult_PrepareForConnection != null)
            {
                OnResult_PrepareForConnection((System.String)Args[0].DataValue, (System.String)Args[1].DataValue, (System.Int32)Args[2].DataValue, (Enum_A_ARG_TYPE_Direction )Args[3].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), e, Handle);
            }
            WeakReference[] w = (WeakReference[])WeakList_PrepareForConnection.ToArray(typeof(WeakReference));
            foreach (WeakReference wr in w)
            {
                if (wr.IsAlive == true)
                {
                    ((Delegate_OnResult_PrepareForConnection)wr.Target)((System.String)Args[0].DataValue, (System.String)Args[1].DataValue, (System.Int32)Args[2].DataValue, (Enum_A_ARG_TYPE_Direction )Args[3].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), e, Handle);
                }
                else
                {
                    WeakList_PrepareForConnection.Remove(wr);
                }
            }
        }
예제 #11
0
 private void Error_Sink_GetCurrentConnectionInfo(UPnPService sender, string MethodName, UPnPArgument[] Args, UPnPInvokeException e, int Handle)
 {
     if (OnResult_GetCurrentConnectionInfo != null)
     {
         OnResult_GetCurrentConnectionInfo((System.Int32)Args[0].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (Enum_A_ARG_TYPE_Direction)0, (Enum_A_ARG_TYPE_ConnectionStatus)0, e, Handle);
     }
     WeakReference[] w = (WeakReference[])WeakList_GetCurrentConnectionInfo.ToArray(typeof(WeakReference));
     foreach (WeakReference wr in w)
     {
         if (wr.IsAlive == true)
         {
             ((Delegate_OnResult_GetCurrentConnectionInfo)wr.Target)((System.Int32)Args[0].DataValue, (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.String)UPnPService.CreateObjectInstance(typeof(System.String), null), (System.Int32)UPnPService.CreateObjectInstance(typeof(System.Int32), null), (Enum_A_ARG_TYPE_Direction)0, (Enum_A_ARG_TYPE_ConnectionStatus)0, e, Handle);
         }
         else
         {
             WeakList_GetCurrentConnectionInfo.Remove(wr);
         }
     }
 }