-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_fake_feature_library.cc
56 lines (47 loc) · 2.24 KB
/
c_fake_feature_library.cc
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
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "featured/c_fake_feature_library.h"
#include <dbus/bus.h>
#include "featured/c_feature_library.h"
#include "featured/fake_platform_features.h"
extern "C" CFeatureLibrary FakeCFeatureLibraryNew() {
dbus::Bus::Options options;
options.bus_type = dbus::Bus::SYSTEM;
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));
return reinterpret_cast<CFeatureLibrary>(
new feature::FakePlatformFeatures(bus));
}
extern "C" void FakeCFeatureLibraryDelete(CFeatureLibrary handle) {
auto* library = dynamic_cast<feature::FakePlatformFeatures*>(
reinterpret_cast<feature::PlatformFeaturesInterface*>(handle));
library->ShutdownBus();
delete library;
}
extern "C" void FakeCFeatureLibrarySetEnabled(CFeatureLibrary handle,
const char* const feature,
int enabled) {
auto* library = dynamic_cast<feature::FakePlatformFeatures*>(
reinterpret_cast<feature::PlatformFeaturesInterface*>(handle));
library->SetEnabled(feature, enabled);
}
extern "C" void FakeCFeatureLibraryClearEnabled(CFeatureLibrary handle,
const char* const feature) {
auto* library = dynamic_cast<feature::FakePlatformFeatures*>(
reinterpret_cast<feature::PlatformFeaturesInterface*>(handle));
library->ClearEnabled(feature);
}
extern "C" void FakeCFeatureLibrarySetParam(CFeatureLibrary handle,
const char* const feature,
const char* const key,
const char* const value) {
auto* library = dynamic_cast<feature::FakePlatformFeatures*>(
reinterpret_cast<feature::PlatformFeaturesInterface*>(handle));
library->SetParam(feature, key, value);
}
extern "C" void FakeCFeatureLibraryClearParams(CFeatureLibrary handle,
const char* const feature) {
auto* library = dynamic_cast<feature::FakePlatformFeatures*>(
reinterpret_cast<feature::PlatformFeaturesInterface*>(handle));
library->ClearParams(feature);
}