summaryrefslogtreecommitdiffstats
path: root/media/libdrm/mobile2/src/rights/RoManager.cpp
blob: a115d21f1f33a46abbdf06c44034ad1d53ae45f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <rights/RoManager.h>
#include <rights/Asset.h>

using namespace ustl;

RoManager* RoManager::msInstance = NULL;

/** see RoManager.h */
RoManager* RoManager::Instance()
{
    if (NULL == msInstance)
    {
        msInstance = new RoManager();
    }

    return msInstance;
}

/** see RoManager.h */
RoManager::RoManager()
{
//load the ro list from local system.
}

/** see RoManager.h */
RoManager::~RoManager()
{
    msInstance = NULL;

    for (vector<Ro*>::iterator it = mRoList.begin();
         it != mRoList.end(); it++)
    {
        delete (*it);
    }

    mRoList.clear();
}

/** see RoManager.h */
Ro::ERRCODE RoManager::installRo(istringstream *roStream)
{
    Ro *ro = new Ro();

    Ro::ERRCODE ret = ro->parse(roStream);

    if (Ro::RO_OK == ret)
    {
        ro->save();

        mRoList.push_back(ro);
    }

    return ret;
}

/** see RoManager.h */
Ro* RoManager::getRoByContentID(const string& contentID)
{
    for (vector<Ro*>::iterator it = mRoList.begin();
         it != mRoList.end(); it++)
    {
        for (vector<Asset*>::iterator ita = (*it)->mAssetList.begin();
             ita != (*it)->mAssetList.end(); ita++)
        {
            if (contentID.compare((*ita)->getContentID()) == 0)
            {
                return *it;
            }
        }
    }

    return NULL;
}

/** see RoManager.h */
Ro* RoManager::getRo(const string& roID)
{
    for (vector<Ro*>::iterator it = mRoList.begin();
         it != mRoList.end(); it++)
    {
        if (roID.compare((*it)->getRoID()) == 0)
        {
            return (*it);
        }
    }

    return NULL;
}

/** see RoManager.h */
vector<Ro*> RoManager::getAllRo()
{
    return mRoList;
}

/** see RoManager.h */
bool RoManager::deleteRo(const string& roID)
{
    return true;
}

/** see RoManager.h */
bool RoManager::checkRoInCache(const string& roID)
{
    return true;
}