    001    /**
    002     * Copyright (C) 2010, Skype Limited
    003     *
    004     * All intellectual property rights, including but not limited to copyrights,
    005     * trademarks and patents, as well as know how and trade secrets contained in,
    006     * relating to, or arising from the internet telephony software of
    007     * Skype Limited (including its affiliates, "Skype"), including without
    008     * limitation this source code, Skype API and related material of such
    009     * software proprietary to Skype and/or its licensors ("IP Rights") are and
    010     * shall remain the exclusive property of Skype and/or its licensors.
    011     * The recipient hereby acknowledges and agrees that any unauthorized use of
    012     * the IP Rights is a violation of intellectual property laws.
    013     *
    014     * Skype reserves all rights and may take legal action against infringers of
    015     * IP Rights.
    016     *
    017     * The recipient agrees not to remove, obscure, make illegible or alter any
    018     * notices or indications of the IP Rights and/or Skype's rights and
    019     * ownership thereof.
    020     */
    021
    022    package com.skype.ipc;
    023
    024    import java.io.IOException;
    025
    026    import com.skype.util.Log;
    027
    028    public class Event extends AbstractTaggedInputMessage {
    029            private static final String TAG="Event";
    030            private int module_id;
    031            private int event_id;
    032
    033            Event(Transport in) throws IOException
    034            {
    035                    super(in);
    036
    037                    module_id = decodeVaruint();
    038                event_id  = decodeVaruint();
    039                    Log.d(TAG,"Event decoding started. module_id="+module_id+", event_id="+event_id+".");
    040                    // Decode parms
    041                    try {
    042                            while(decodeNextParm()==true) {};
    043                    } catch (IOException e) {
    044                            Log.e(TAG,"IOException while decoding " + e.getMessage());
    045                            invalid=true;
    046                            //e.printStackTrace();
    047                    }
    048                    Log.d(TAG,"Event decoded. module_id="+module_id+", event_id="+event_id+", validity="+(!invalid));
    049            }
    050
    051            public int getEventId()
    052            {
    053                    return event_id;
    054            }
    055            public int getModuleId()
    056            {
    057                    return module_id;
    058            }
    059
    060            private boolean decodeNextParm() throws IOException
    061            {
    062                    int kind=ioTransport.read();
    063                    while(kind==']')
    064                    {
    065                            kind=ioTransport.read();
    066                    }
    067                    if(kind=='z')
    068                    {
    069                            return false;
    070                    }
    071                    int tag=ioTransport.read();
    072                    addParm(tag, decodeOneOfKind(kind));
    073                    Log.d(TAG,"Decoded one parm of event_id="+event_id+", tag="+tag+", kind='"+(char)(kind&0xff)+"'.");
    074                    return true;
    075            }
    076
    077    }