summaryrefslogtreecommitdiff
path: root/wpd/WpdServiceSampleDriver/FakeContent.h
blob: 3f1f71035faee07ed5d1d4a35425d32e7b838c62 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once

class FakeContent
{
public:
    FakeContent() :
        CanDelete(false), 
        RequiredScope(FULL_DEVICE_ACCESS),
        MarkedForDeletion(false)
    {
        Format = WPD_OBJECT_FORMAT_UNSPECIFIED;
        ContentType = WPD_CONTENT_TYPE_UNSPECIFIED;
    }

    FakeContent(const FakeContent& src) :
        CanDelete(false)
    {
        *this = src;
    }

    virtual ~FakeContent()
    {
        for(size_t index = 0; index < m_Children.GetCount(); index++)
        {
            if (m_Children[index])
            {
                delete(m_Children[index]);
                m_Children[index] = NULL;
            }
        }
        m_Children.RemoveAll();
    }

    virtual FakeContent& operator= (const FakeContent& src)
    {
        ObjectID                    = src.ObjectID;
        PersistentUniqueID          = src.PersistentUniqueID;
        ParentID                    = src.ParentID;
        Name                        = src.Name;
        ContentType                 = src.ContentType;
        Format                      = src.Format;
        CanDelete                   = src.CanDelete;
        RequiredScope               = src.RequiredScope;
        ParentPersistentUniqueID    = src.ParentPersistentUniqueID;
        ContainerFunctionalObjectID = src.ContainerFunctionalObjectID;

        return *this;
    }

    virtual HRESULT InitializeContent(
        _Inout_ DWORD *pdwLastObjectID);
        
    virtual HRESULT InitializeEnumerationContext(
                ACCESS_SCOPE                Scope,
        _In_    WpdObjectEnumeratorContext* pEnumeratorContext);

    virtual HRESULT GetSupportedProperties(
        _In_    IPortableDeviceKeyCollection *pKeys);

    virtual HRESULT GetPropertyAttributes(
        _In_    REFPROPERTYKEY         Key,
        _In_    IPortableDeviceValues* pAttributes);

    virtual HRESULT GetValue(
        _In_    REFPROPERTYKEY         Key,
        _In_    IPortableDeviceValues* pStore);
        
    virtual HRESULT WriteValue(
        _In_    REFPROPERTYKEY         Key,
        _In_    REFPROPVARIANT         Value);

    virtual HRESULT CreatePropertiesOnlyObject(
        _In_                          IPortableDeviceValues* pObjectProperties,
        _Out_                         DWORD*                 pdwLastObjectID,
        _Outptr_result_nullonfailure_ FakeContent**          ppNewObject);

    virtual HRESULT GetSupportedResources(
        _In_    IPortableDeviceKeyCollection* pResources);

    virtual HRESULT GetResourceAttributes(
        _In_    REFPROPERTYKEY         Resource,
        _In_    IPortableDeviceValues* pAttributes);
    
    virtual HRESULT OpenResource(
        _In_    REFPROPERTYKEY            Resource,
                const DWORD               dwMode,
        _In_    WpdObjectResourceContext* pResourceContext); 

    virtual HRESULT ReadResourceData(
        _In_                            WpdObjectResourceContext*   pResourceContext,
        _Out_writes_to_(dwNumBytesToRead, *pdwNumBytesRead)   BYTE* pBuffer,
                                        const DWORD                 dwNumBytesToRead,
        _Out_                           DWORD*                      pdwNumBytesRead);

    virtual HRESULT WriteValues(
        _In_    IPortableDeviceValues* pValues,
        _In_    IPortableDeviceValues* pResults,
        _Out_   bool*                  pbObjectChanged); 

public:
    bool CanAccess(
                ACCESS_SCOPE Scope);

    HRESULT GetAllValues(
        _In_    IPortableDeviceValues* pStore);

    _Success_(return)
    bool FindNext(
                            ACCESS_SCOPE  Scope,
                            const DWORD   dwIndex,
        _Outptr_result_nullonfailure_     FakeContent** ppChild);

    HRESULT GetContent(
                            ACCESS_SCOPE  Scope,
        _In_                LPCWSTR       wszObjectID,
        _Outptr_result_nullonfailure_     FakeContent**  ppContent);

    HRESULT GetObjectIDsByFormat(
                ACCESS_SCOPE                          Scope,
        _In_    REFGUID                               Format,
                const DWORD                           dwDepth,
        _In_    IPortableDevicePropVariantCollection* pObjectIDs);

    HRESULT GetObjectIDByPersistentID(
                ACCESS_SCOPE                          Scope,
        _In_    LPCWSTR                               wszPersistentID,
        _In_    IPortableDevicePropVariantCollection* pObjectIDs);

    HRESULT MarkForDelete(
                const DWORD dwOptions);

    HRESULT RemoveObjectsMarkedForDeletion(
                ACCESS_SCOPE Scope);

public:
    CAtlStringW     ObjectID;
    CAtlStringW     PersistentUniqueID;
    CAtlStringW     ParentID;
    CAtlStringW     Name;
    CAtlStringW     ParentPersistentUniqueID;
    CAtlStringW     ContainerFunctionalObjectID;
    GUID            ContentType;
    GUID            Format;
    bool            CanDelete;
    bool            MarkedForDeletion;
    
    // A bitmask of all the required scopes in order to access this object
    ACCESS_SCOPE    RequiredScope;

    CAtlArray<FakeContent*> m_Children;
};