1 /* Copyright (C) 2010 The Android Open Source Project. 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 package com.android.exchange.adapter; 17 18 import com.android.exchange.Eas; 19 import com.android.mail.utils.LogUtils; 20 21 import java.io.IOException; 22 import java.io.InputStream; 23 24 /** 25 * Parse the result of a MeetingRequest command. 26 */ 27 public class MeetingResponseParser extends Parser { 28 private static final String TAG = Eas.LOG_TAG; 29 30 public MeetingResponseParser(final InputStream in) throws IOException { 31 super(in); 32 } 33 34 private void parseResult() throws IOException { 35 while (nextTag(Tags.MREQ_RESULT) != END) { 36 if (tag == Tags.MREQ_STATUS) { 37 int status = getValueInt(); 38 if (status != 1) { 39 LogUtils.w(TAG, "Error in meeting response: %d", status); 40 } 41 } else if (tag == Tags.MREQ_CAL_ID) { 42 LogUtils.d(TAG, "Meeting response calender id: %s", getValue()); 43 } else { 44 skipTag(); 45 } 46 } 47 } 48 49 @Override 50 public boolean parse() throws IOException { 51 boolean res = false; 52 if (nextTag(START_DOCUMENT) != Tags.MREQ_MEETING_RESPONSE) { 53 throw new IOException(); 54 } 55 while (nextTag(START_DOCUMENT) != END_DOCUMENT) { 56 if (tag == Tags.MREQ_RESULT) { 57 parseResult(); 58 } else { 59 skipTag(); 60 } 61 } 62 return res; 63 } 64 } 65 66