Home | History | Annotate | Download | only in common
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include <drm/DrmInfoRequest.h>
     18 
     19 using namespace android;
     20 
     21 const String8 DrmInfoRequest::ACCOUNT_ID("account_id");
     22 const String8 DrmInfoRequest::SUBSCRIPTION_ID("subscription_id");
     23 
     24 DrmInfoRequest::DrmInfoRequest(int infoType, const String8& mimeType) :
     25     mInfoType(infoType), mMimeType(mimeType) {
     26 
     27 }
     28 
     29 String8 DrmInfoRequest::getMimeType(void) const {
     30     return mMimeType;
     31 }
     32 
     33 int DrmInfoRequest::getInfoType(void) const {
     34     return mInfoType;
     35 }
     36 
     37 int DrmInfoRequest::getCount(void) const {
     38     return mRequestInformationMap.size();
     39 }
     40 
     41 status_t DrmInfoRequest::put(const String8& key, const String8& value) {
     42     mRequestInformationMap.add(key, value);
     43     return DRM_NO_ERROR;
     44 }
     45 
     46 String8 DrmInfoRequest::get(const String8& key) const {
     47     if (NAME_NOT_FOUND != mRequestInformationMap.indexOfKey(key)) {
     48         return mRequestInformationMap.valueFor(key);
     49     }
     50     return String8("");
     51 }
     52 
     53 DrmInfoRequest::KeyIterator DrmInfoRequest::keyIterator() const {
     54     return KeyIterator(this);
     55 }
     56 
     57 DrmInfoRequest::Iterator DrmInfoRequest::iterator() const {
     58     return Iterator(this);
     59 }
     60 
     61 // KeyIterator implementation
     62 DrmInfoRequest::KeyIterator::KeyIterator(const DrmInfoRequest::KeyIterator& keyIterator)
     63     : mDrmInfoRequest(keyIterator.mDrmInfoRequest),
     64       mIndex(keyIterator.mIndex) {
     65 
     66 }
     67 
     68 bool DrmInfoRequest::KeyIterator::hasNext() {
     69     return (mIndex < mDrmInfoRequest->mRequestInformationMap.size());
     70 }
     71 
     72 const String8& DrmInfoRequest::KeyIterator::next() {
     73     const String8& key = mDrmInfoRequest->mRequestInformationMap.keyAt(mIndex);
     74     mIndex++;
     75     return key;
     76 }
     77 
     78 DrmInfoRequest::KeyIterator& DrmInfoRequest::KeyIterator::operator=(
     79     const DrmInfoRequest::KeyIterator& keyIterator) {
     80     mDrmInfoRequest = keyIterator.mDrmInfoRequest;
     81     mIndex = keyIterator.mIndex;
     82     return *this;
     83 }
     84 
     85 // Iterator implementation
     86 DrmInfoRequest::Iterator::Iterator(const DrmInfoRequest::Iterator& iterator) :
     87     mDrmInfoRequest(iterator.mDrmInfoRequest), mIndex(iterator.mIndex) {
     88 }
     89 
     90 DrmInfoRequest::Iterator& DrmInfoRequest::Iterator::operator=(
     91     const DrmInfoRequest::Iterator& iterator) {
     92     mDrmInfoRequest = iterator.mDrmInfoRequest;
     93     mIndex = iterator.mIndex;
     94     return *this;
     95 }
     96 
     97 bool DrmInfoRequest::Iterator::hasNext() {
     98     return mIndex < mDrmInfoRequest->mRequestInformationMap.size();
     99 }
    100 
    101 String8& DrmInfoRequest::Iterator::next() {
    102     String8& value = mDrmInfoRequest->mRequestInformationMap.editValueAt(mIndex);
    103     mIndex++;
    104     return value;
    105 }
    106 
    107