-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcomponent_client.cpp
More file actions
132 lines (110 loc) · 3.09 KB
/
component_client.cpp
File metadata and controls
132 lines (110 loc) · 3.09 KB
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
// Include the SDK's component client implementation
// This provides core_api functions and the foobar2000_get_interface entry point
// Adjust include paths for our project structure
#include "../columns_ui/foobar2000/SDK/foobar2000.h"
#include "../columns_ui/foobar2000/SDK/component.h"
#include "../columns_ui/foobar2000/SDK/cfg_var_legacy.h"
#ifdef _WIN32
static HINSTANCE g_hIns;
#endif
static pfc::string_simple g_name,g_full_path;
static bool g_services_available = false, g_initialized = false;
namespace core_api
{
#ifdef _WIN32
HINSTANCE get_my_instance()
{
return g_hIns;
}
#endif
fb2k::hwnd_t get_main_window()
{
PFC_ASSERT( g_foobar2000_api != NULL );
return g_foobar2000_api->get_main_window();
}
const char* get_my_file_name()
{
return g_name;
}
const char* get_my_full_path()
{
return g_full_path;
}
bool are_services_available()
{
return g_services_available;
}
bool assert_main_thread()
{
return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->assert_main_thread() : true;
}
void ensure_main_thread() {
if (!is_main_thread()) FB2K_BugCheck();
}
bool is_main_thread()
{
return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->is_main_thread() : true;
}
const char* get_profile_path()
{
PFC_ASSERT( g_foobar2000_api != NULL );
return g_foobar2000_api->get_profile_path();
}
bool is_shutting_down()
{
return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->is_shutting_down() : g_initialized;
}
bool is_initializing()
{
return (g_services_available && g_foobar2000_api) ? g_foobar2000_api->is_initializing() : !g_initialized;
}
bool is_portable_mode_enabled() {
PFC_ASSERT( g_foobar2000_api != NULL );
return g_foobar2000_api->is_portable_mode_enabled();
}
bool is_quiet_mode_enabled() {
PFC_ASSERT( g_foobar2000_api != NULL );
return g_foobar2000_api->is_quiet_mode_enabled();
}
}
namespace {
class foobar2000_client_impl : public foobar2000_client, private foobar2000_component_globals
{
public:
t_uint32 get_version() override {return FOOBAR2000_CLIENT_VERSION;}
pservice_factory_base get_service_list() override {return service_factory_base::__internal__list;}
void get_config(stream_writer * p_stream,abort_callback & p_abort) override {
#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY
cfg_var_legacy::cfg_var::config_write_file(p_stream,p_abort);
#endif
}
void set_config(stream_reader * p_stream,abort_callback & p_abort) override {
#ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY
cfg_var_legacy::cfg_var::config_read_file(p_stream,p_abort);
#endif
}
void set_library_path(const char * path,const char * name) override {
g_full_path = path;
g_name = name;
}
void services_init(bool val) override {
if (val) g_initialized = true;
g_services_available = val;
}
bool is_debug() override {
return PFC_DEBUG != 0;
}
};
}
static foobar2000_client_impl g_client;
#ifdef _WIN32
extern "C"
{
__declspec(dllexport) foobar2000_client * _cdecl foobar2000_get_interface(foobar2000_api * p_api,HINSTANCE hIns)
{
g_hIns = hIns;
g_foobar2000_api = p_api;
return &g_client;
}
}
#endif