Home | History | Annotate | Download | only in adapter
      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.EasSyncService;
     19 
     20 import java.io.IOException;
     21 import java.io.InputStream;
     22 
     23 /**
     24  * Parse the result of a MeetingRequest command.
     25  */
     26 public class MeetingResponseParser extends Parser {
     27     private EasSyncService mService;
     28 
     29     public MeetingResponseParser(InputStream in, EasSyncService service) throws IOException {
     30         super(in);
     31         mService = service;
     32     }
     33 
     34     public 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                     mService.userLog("Error in meeting response: " + status);
     40                 }
     41             } else if (tag == Tags.MREQ_CAL_ID) {
     42                 mService.userLog("Meeting response calendar id: " + 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