Example #1
0
        /// <summary>
        /// Performs an authentication command.  These commands are defined by the native
        /// code update provider.  This method is intented to enable handshaking during
        /// authentication.  For our samples, this method is only used to determine what
        /// validation is supported on the device.
        /// </summary>
        /// <param name="command">The command ID for the authentication call.</param>
        /// <param name="args">The argument object that corresponds to the command ID.</param>
        /// <param name="response">The response object for the command.</param>
        /// <returns>Returns true if the command succeeded, false otherwise.</returns>
        public bool AuthenticationCommand(int command, object args, ref object response)
        {
            byte[] resp = response == null ? null : MFNativeUpdate.SerializeParameter(response);

            bool fRet = MFNativeUpdate.AuthCommand(m_updateHandle, command, MFNativeUpdate.SerializeParameter(args), ref resp);

            if (fRet && resp != null)
            {
                response = MFNativeUpdate.DeserializeParameter(resp, response);
            }

            return(fRet);
        }
Example #2
0
        /// <summary>
        /// Gets the update property given the property name.
        /// </summary>
        /// <param name="propName">The name of the property.</param>
        /// <param name="propValue">The returned property object.</param>
        /// <returns>Returns false if the property was not set or is not supported.  Returns true otherwise.</returns>
        public bool GetUpdateProperty(string propName, ref object propValue)
        {
            if (m_updateHandle == -1)
            {
                throw new InvalidOperationException();
            }

            byte[] ser = MFNativeUpdate.SerializeParameter(propValue);

            if (MFNativeUpdate.GetUpdateProperty(m_updateHandle, propName, ref ser))
            {
                return(MFNativeUpdate.DeserializeParameter(ser, propValue));
            }

            return(false);
        }
Example #3
0
        /// <summary>
        /// Sets the update property for the given property name.
        /// </summary>
        /// <param name="propName">The name of the property to be set.</param>
        /// <param name="propValue">The value of property to be set.</param>
        /// <returns>Returns true if the property was set, false otherwise.</returns>
        public bool SetUpdateProperty(string propName, object propValue)
        {
            byte[] data = MFNativeUpdate.SerializeParameter(propValue);

            return(MFNativeUpdate.SetUpdateProperty(m_updateHandle, propName, data));
        }
Example #4
0
        /// <summary>
        /// Authenticates the update and opens the update storage file.  This method must be called prior to adding packets.
        /// If authentication is not required by the underlying native update component null can be passed for the
        /// authenticationData parameter.
        /// </summary>
        /// <param name="authenticationData">The authentication data for starting the update (can be null).</param>
        /// <returns></returns>
        public bool Open(object authenticationData)
        {
            m_authenticated = MFNativeUpdate.Authenticate(m_updateHandle, authenticationData != null ? MFNativeUpdate.SerializeParameter(authenticationData) : null);

            if (m_authenticated)
            {
                if (MFNativeUpdate.Open(m_updateHandle))
                {
                    MFNativeUpdate.GetMissingPackets(m_updateHandle, m_pktBitChk);
                }
                else
                {
                    if (!MFNativeUpdate.Create(m_updateHandle))
                    {
                        throw new OutOfMemoryException();
                    }
                }
            }

            return(m_authenticated);
        }