private void GetForm(XmppClient Client, XmlElement Element, IqType IqType, string From, string To, string Id)
        {
            string LanguageCode = XmlUtilities.GetAttribute(Element, "xml:lang", string.Empty);

            if (this.provisioning == null)
            {
                this.RequestRejected(From, Id, "Control rejected. No provisioning server found.", "cancel", "forbidden", "urn:ietf:params:xml:ns:xmpp-stanzas", string.Empty);
            }
            else
            {
                string ServiceToken = XmlUtilities.GetAttribute(Element, "serviceToken", string.Empty);
                string DeviceToken  = XmlUtilities.GetAttribute(Element, "deviceToken", string.Empty);
                string UserToken    = XmlUtilities.GetAttribute(Element, "userToken", string.Empty);

                List <NodeReference> Nodes;
                List <string>        Parameters;

                ReadoutRequest.ParseNodesAndFieldNames(Element, out Nodes, out Parameters);

                Parameters = new List <string> ();
                Parameters.AddRange(this.parameterByName.Keys);

                this.provisioning.CanControl(From, this.CanControlGetFormResponse, new object[] { LanguageCode, From, Id }, ServiceToken, DeviceToken, UserToken,
                                             Parameters.ToArray(), Nodes == null ? (NodeReference[])null : Nodes.ToArray());
            }
        }
        private void Set(XmppClient Client, XmlElement Element, string From, string To)
        {
            string LanguageCode = XmlUtilities.GetAttribute(Element, "xml:lang", string.Empty);

            if (this.provisioning != null)
            {
                string ServiceToken = XmlUtilities.GetAttribute(Element, "serviceToken", string.Empty);
                string DeviceToken  = XmlUtilities.GetAttribute(Element, "deviceToken", string.Empty);
                string UserToken    = XmlUtilities.GetAttribute(Element, "userToken", string.Empty);

                List <NodeReference> Nodes;
                List <string>        Parameters;

                ReadoutRequest.ParseNodesAndFieldNames(Element, out Nodes, out Parameters);

                this.provisioning.CanControl(From, this.CanControlResponse, new object[] { LanguageCode, From, null, Element }, ServiceToken, DeviceToken, UserToken,
                                             Parameters == null ? (string[])null : Parameters.ToArray(), Nodes == null ? (NodeReference[])null : Nodes.ToArray());
            }
        }
        private void CanControlResponse(XmppClient Client, string Type, XmlNodeList Response, ref StanzaError Error, object State)
        {
            object[]           P        = (object[])State;
            CanControlCallback Callback = (CanControlCallback)P [0];
            object             State2   = (object)P [1];
            string             Hash     = (string)P [2];

            string[]        Parameters     = (string[])P [3];
            NodeReference[] NodeReferences = (NodeReference[])P [4];
            bool            CanControl     = false;
            string          Jid            = string.Empty;
            XmlElement      E;

            if (Error != null)
            {
                Error = null;
            }
            else if (Response != null)
            {
                if (Hash != null)
                {
                    this.AddToCache(Hash, Response);
                }

                foreach (XmlNode N in Response)
                {
                    if (N.LocalName == "canControlResponse" && (E = N as XmlElement) != null)
                    {
                        CanControl = XmlUtilities.GetAttribute(E, "result", false);

                        List <NodeReference> Nodes;
                        List <string>        ParameterNames;

                        ReadoutRequest.ParseNodesAndFieldNames(E, out Nodes, out ParameterNames);

                        if (Nodes == null)
                        {
                            NodeReferences = null;
                        }
                        else
                        {
                            NodeReferences = Nodes.ToArray();
                        }

                        if (ParameterNames == null)
                        {
                            Parameters = null;
                        }
                        else
                        {
                            Parameters = ParameterNames.ToArray();
                        }
                        break;
                    }
                }
            }

            CanControlEventArgs e = new CanControlEventArgs(Jid, CanControl, Parameters, NodeReferences, State2);

            if (Callback != null)
            {
                try
                {
                    Callback(e);
                } catch (Exception ex)
                {
                    Log.Exception(ex);
                }
            }
        }