/** When the socket reader receives a property update from runtime, it decodes object ID
         * property ID and the new value of the property. It then calls this method of
         * the target object, to update the new value in property cache. After updating the cache,
         * this method then fires appropriate event in skype.events to notify the UI of what has happened.
         * DispatchPropertyUpdate is executed in the socket reader thread.
         */
        internal override void DispatchPropertyUpdate(uint propId, object value, bool hasValue)
        {
            switch (propId)
            {
            case 190: /* Sms.P_TYPE */
                cache[0] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_type = (SktSms.TYPE)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_TYPE = " + cache_type.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_TYPE - update without value");
                skypeRef.events.FireOnSmsType(this, cache_type);
                break;

            case 1211: /* Sms.P_OUTGOING_REPLY_TYPE */
                cache[1] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_outgoing_reply_type = (SktSms.OUTGOING_REPLY_TYPE)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_OUTGOING_REPLY_TYPE = " + cache_outgoing_reply_type.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_OUTGOING_REPLY_TYPE - update without value");
                skypeRef.events.FireOnSmsOutgoingReplyType(this, cache_outgoing_reply_type);
                break;

            case 191: /* Sms.P_STATUS */
                cache[2] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_status = (SktSms.STATUS)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_STATUS = " + cache_status.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_STATUS - update without value");
                skypeRef.events.FireOnSmsStatus(this, cache_status);
                break;

            case 192: /* Sms.P_FAILUREREASON */
                cache[3] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_failurereason = (SktSms.FAILUREREASON)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_FAILUREREASON = " + cache_failurereason.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_FAILUREREASON - update without value");
                skypeRef.events.FireOnSmsFailurereason(this, cache_failurereason);
                break;

            case 48: /* Sms.P_IS_FAILED_UNSEEN */
                cache[4] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_is_failed_unseen = (Boolean)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_IS_FAILED_UNSEEN = " + cache_is_failed_unseen.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_IS_FAILED_UNSEEN - update without value");
                skypeRef.events.FireOnSmsIsFailedUnseen(this, cache_is_failed_unseen);
                break;

            case 198: /* Sms.P_TIMESTAMP */
                cache[5] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_timestamp = (uint)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_TIMESTAMP = " + cache_timestamp.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_TIMESTAMP - update without value");
                skypeRef.events.FireOnSmsTimestamp(this, skypeRef.UnixTimestampToDateTime(cache_timestamp));
                break;

            case 193: /* Sms.P_PRICE */
                cache[6] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_price = (uint)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_PRICE = " + cache_price.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_PRICE - update without value");
                skypeRef.events.FireOnSmsPrice(this, cache_price);
                break;

            case 49: /* Sms.P_PRICE_PRECISION */
                cache[7] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_price_precision = (uint)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_PRICE_PRECISION = " + cache_price_precision.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_PRICE_PRECISION - update without value");
                skypeRef.events.FireOnSmsPricePrecision(this, cache_price_precision);
                break;

            case 194: /* Sms.P_PRICE_CURRENCY */
                cache[8] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_price_currency = (String)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_PRICE_CURRENCY = " + cache_price_currency.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_PRICE_CURRENCY - update without value");
                skypeRef.events.FireOnSmsPriceCurrency(this, cache_price_currency);
                break;

            case 199: /* Sms.P_REPLY_TO_NUMBER */
                cache[9] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_reply_to_number = (String)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_REPLY_TO_NUMBER = " + cache_reply_to_number.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_REPLY_TO_NUMBER - update without value");
                skypeRef.events.FireOnSmsReplyToNumber(this, cache_reply_to_number);
                break;

            case 195: /* Sms.P_TARGET_NUMBERS */
                cache[10] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_target_numbers = (String)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_TARGET_NUMBERS = " + cache_target_numbers.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_TARGET_NUMBERS - update without value");
                skypeRef.events.FireOnSmsTargetNumbers(this, cache_target_numbers);
                break;

            case 196: /* Sms.P_TARGET_STATUSES */
                cache[11] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_target_statuses = (byte[])value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_TARGET_STATUSES = binary size " + cache_target_statuses.Length.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_TARGET_STATUSES - update without value");
                skypeRef.events.FireOnSmsTargetStatuses(this, cache_target_statuses);
                break;

            case 197: /* Sms.P_BODY */
                cache[12] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_body = (String)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_BODY = " + cache_body.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_BODY - update without value");
                skypeRef.events.FireOnSmsBody(this, cache_body);
                break;

            case 840: /* Sms.P_CHATMSG_ID */
                cache[13] = hasValue; // if no value - invalidate cache
                if (hasValue)
                {
                    cache_chatmsg_id = (SktMessage)value;
                    if (skypeRef.logging) skypeRef.Log("Sms.P_CHATMSG_ID = " + cache_chatmsg_id.ToString());
                }
                else if (skypeRef.logging) skypeRef.Log("Sms.P_CHATMSG_ID - update without value");
                skypeRef.events.FireOnSmsChatmsgId(this, cache_chatmsg_id);
                break;

            default:
                skypeRef.Error(String.Format("Invalid Sms class property ID ({0})received from socket.", propId)); break;
            }
        }
 internal void FetchStatusFromRuntime()
 {
     if (skypeRef.logging) skypeRef.Log("Fetching P_STATUS from runtime");
     skypeRef.transport.SubmitPropertyRequest(12, 191, this.OID);
     if (skypeRef.transport.PropResponseWasOk(191))
     {
     cache_status = (SktSms.STATUS)skypeRef.decoder.DecodeUint();
     cache[2] = true;
     }
     skypeRef.transport.ResumeSocketReaderFromPropRequest();
 }
 public OnSmsStatusArgs(SktSms sender, SktSms.STATUS newValue)
 {
     this.sender = sender;  value = newValue;
 }