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
23using namespace ustl;
24
25class RoManager {
26
27public:
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 the private key of the device.
68     * @return the private key.
69     */
70    const string& getDevicePrivateKey() const;
71
72    /**
73     * Get ro which contained rights of specific content.
74     * @param contentID the specific id of content.
75     * @return NULL if not fount otherwise the related ro.
76     */
77    Ro* getRoByContentID(const string& contentID);
78
79    /**
80     * Delete Ro by its id.
81     * @param roID the specific roID.
82     * @return true/false to indicate the result.
83     */
84    bool deleteRo(const string& roID);
85
86
87PRIVATE:
88    /**
89     * Constructor for RoManager.
90     */
91    RoManager();
92
93PRIVATE:
94    static RoManager* msInstance; /**< singleton instance pointer. */
95    vector<Ro*> mRoList; /**< the ro list. */
96};
97
98#endif
99