/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.bluetooth.mapclient; import android.util.Log; import org.json.JSONException; import org.json.JSONObject; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import java.io.DataInputStream; import java.io.IOException; import java.math.BigInteger; import java.util.HashMap; /** * Object representation of event report received by MNS *
* This object will be received in {@link Client#EVENT_EVENT_REPORT}
* callback message.
*/
public class EventReport {
private static final String TAG = "EventReport";
private final Type mType;
private final String mHandle;
private final String mFolder;
private final String mOldFolder;
private final Bmessage.Type mMsgType;
private EventReport(HashMaptype
application parameter in MAP specification
*/
public Type getType() {
return mType;
}
/**
* @return value corresponding to handle
parameter in MAP
* specification
*/
public String getHandle() {
return mHandle;
}
/**
* @return value corresponding to folder
parameter in MAP
* specification
*/
public String getFolder() {
return mFolder;
}
/**
* @return value corresponding to old_folder
parameter in MAP
* specification
*/
public String getOldFolder() {
return mOldFolder;
}
/**
* @return {@link Bmessage.Type} object corresponding to
* msg_type
application parameter in MAP specification
*/
public Bmessage.Type getMsgType() {
return mMsgType;
}
@Override
public String toString() {
JSONObject json = new JSONObject();
try {
json.put("type", mType);
json.put("handle", mHandle);
json.put("folder", mFolder);
json.put("old_folder", mOldFolder);
json.put("msg_type", mMsgType);
} catch (JSONException e) {
// do nothing
}
return json.toString();
}
public enum Type {
NEW_MESSAGE("NewMessage"),
DELIVERY_SUCCESS("DeliverySuccess"),
SENDING_SUCCESS("SendingSuccess"),
DELIVERY_FAILURE("DeliveryFailure"),
SENDING_FAILURE("SendingFailure"),
MEMORY_FULL("MemoryFull"),
MEMORY_AVAILABLE("MemoryAvailable"),
MESSAGE_DELETED("MessageDeleted"),
MESSAGE_SHIFT("MessageShift"),
READ_STATUS_CHANGED("ReadStatusChanged"),
MESSAGE_REMOVED("MessageRemoved"),
MESSAGE_EXTENDED_DATA_CHANGED("MessageExtendedDataChanged"),
PARTICIPANT_PRESENCE_CHANGED("ParticipantPresenceChanged"),
PARTICIPANT_CHAT_STATE_CHANGED("ParticipantChatStateChanged"),
CONCERSATION_CHANGED("ConversationChanged");
private final String mSpecName;
Type(String specName) {
mSpecName = specName;
}
@Override
public String toString() {
return mSpecName;
}
}
}