1 /* 2 * Copyright (C) 2007 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 #ifndef _ROMANAGER_H 17 #define _ROMANAGER_H 18 19 #include <Drm2CommonTypes.h> 20 #include <ustring.h> 21 #include <rights/Ro.h> 22 23 using namespace ustl; 24 25 class RoManager { 26 27 public: 28 /** 29 * Singleton instance function. 30 * @return the singleton pointer. 31 */ 32 static RoManager* Instance(); 33 34 /** 35 * Destructor for ExpatWrapper. 36 */ 37 ~RoManager(); 38 39 /** 40 * Install Ro from stream. 41 * @param roStream the input ro stream. 42 * @return the status of installaltion. 43 */ 44 Ro::ERRCODE installRo(istringstream *roStream); 45 46 /** 47 * Check whether Ro in cache or not. 48 * @param roID the specific roID. 49 * @return true/false to indicate result. 50 */ 51 bool checkRoInCache(const string& roID); 52 53 /** 54 * Get the ro. 55 * @param roID the specific id of ro. 56 * @return NULL if not found otherwise return ro. 57 */ 58 Ro* getRo(const string& roID); 59 60 /** 61 * Get all the Ro. 62 * @return ro list. 63 */ 64 vector<Ro*> getAllRo(); 65 66 /** 67 * Get ro which contained rights of specific content. 68 * @param contentID the specific id of content. 69 * @return NULL if not fount otherwise the related ro. 70 */ 71 Ro* getRoByContentID(const string& contentID); 72 73 /** 74 * Delete Ro by its id. 75 * @param roID the specific roID. 76 * @return true/false to indicate the result. 77 */ 78 bool deleteRo(const string& roID); 79 80 81 PRIVATE: 82 /** 83 * Constructor for RoManager. 84 */ 85 RoManager(); 86 87 PRIVATE: 88 static RoManager* msInstance; /**< singleton instance pointer. */ 89 vector<Ro*> mRoList; /**< the ro list. */ 90 }; 91 92 #endif 93