Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
05b8ddac
Commit
05b8ddac
authored
Feb 25, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: add method GetInstance()
parent
668724de
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
21 deletions
+33
-21
Client.cxx
src/client/Client.cxx
+6
-0
Client.hxx
src/client/Client.hxx
+4
-0
MessageCommands.cxx
src/command/MessageCommands.cxx
+2
-3
NeighborCommands.cxx
src/command/NeighborCommands.cxx
+1
-2
OtherCommands.cxx
src/command/OtherCommands.cxx
+4
-4
PartitionCommands.cxx
src/command/PartitionCommands.cxx
+2
-2
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+1
-1
StorageCommands.cxx
src/command/StorageCommands.cxx
+13
-9
No files found.
src/client/Client.cxx
View file @
05b8ddac
...
...
@@ -25,6 +25,12 @@
const
Domain
client_domain
(
"client"
);
Instance
&
Client
::
GetInstance
()
{
return
partition
.
instance
;
}
playlist
&
Client
::
GetPlaylist
()
{
...
...
src/client/Client.hxx
View file @
05b8ddac
...
...
@@ -40,6 +40,7 @@
class
SocketAddress
;
class
EventLoop
;
class
Path
;
struct
Instance
;
struct
Partition
;
struct
PlayerControl
;
struct
playlist
;
...
...
@@ -188,6 +189,9 @@ public:
void
AllowFile
(
Path
path_fs
)
const
;
gcc_pure
Instance
&
GetInstance
();
gcc_pure
playlist
&
GetPlaylist
();
gcc_pure
...
...
src/command/MessageCommands.cxx
View file @
05b8ddac
...
...
@@ -24,7 +24,6 @@
#include "client/ClientList.hxx"
#include "client/Response.hxx"
#include "Instance.hxx"
#include "Partition.hxx"
#include "util/ConstBuffer.hxx"
#include <set>
...
...
@@ -80,7 +79,7 @@ handle_channels(Client &client, gcc_unused Request args, Response &r)
assert
(
args
.
IsEmpty
());
std
::
set
<
std
::
string
>
channels
;
for
(
const
auto
&
c
:
*
client
.
partition
.
instance
.
client_list
)
for
(
const
auto
&
c
:
*
client
.
GetInstance
()
.
client_list
)
channels
.
insert
(
c
.
subscriptions
.
begin
(),
c
.
subscriptions
.
end
());
...
...
@@ -122,7 +121,7 @@ handle_send_message(Client &client, Request args, Response &r)
bool
sent
=
false
;
const
ClientMessage
msg
(
channel_name
,
message_text
);
for
(
auto
&
c
:
*
client
.
partition
.
instance
.
client_list
)
for
(
auto
&
c
:
*
client
.
GetInstance
()
.
client_list
)
if
(
c
.
PushMessage
(
msg
))
sent
=
true
;
...
...
src/command/NeighborCommands.cxx
View file @
05b8ddac
...
...
@@ -23,7 +23,6 @@
#include "client/Client.hxx"
#include "client/Response.hxx"
#include "Instance.hxx"
#include "Partition.hxx"
#include "neighbor/Glue.hxx"
#include "neighbor/Info.hxx"
...
...
@@ -39,7 +38,7 @@ CommandResult
handle_listneighbors
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
const
NeighborGlue
*
const
neighbors
=
client
.
partition
.
instance
.
neighbors
;
client
.
GetInstance
()
.
neighbors
;
if
(
neighbors
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_UNKNOWN
,
"No neighbor plugin configured"
);
return
CommandResult
::
ERROR
;
...
...
src/command/OtherCommands.cxx
View file @
05b8ddac
...
...
@@ -126,11 +126,11 @@ handle_listfiles(Client &client, Request args, Response &r)
case
LocatedUri
:
:
Type
::
RELATIVE
:
#ifdef ENABLE_DATABASE
if
(
client
.
partition
.
instance
.
storage
!=
nullptr
)
if
(
client
.
GetInstance
()
.
storage
!=
nullptr
)
/* if we have a storage instance, obtain a list of
files from it */
return
handle_listfiles_storage
(
r
,
*
client
.
partition
.
instance
.
storage
,
*
client
.
GetInstance
()
.
storage
,
uri
);
/* fall back to entries from database if we have no storage */
...
...
@@ -295,11 +295,11 @@ handle_update(Client &client, Request args, Response &r, bool discard)
}
}
UpdateService
*
update
=
client
.
partition
.
instance
.
update
;
UpdateService
*
update
=
client
.
GetInstance
()
.
update
;
if
(
update
!=
nullptr
)
return
handle_update
(
r
,
*
update
,
path
,
discard
);
Database
*
db
=
client
.
partition
.
instance
.
database
;
Database
*
db
=
client
.
GetInstance
()
.
database
;
if
(
db
!=
nullptr
)
return
handle_update
(
r
,
*
db
,
path
,
discard
);
#else
...
...
src/command/PartitionCommands.cxx
View file @
05b8ddac
...
...
@@ -31,7 +31,7 @@
CommandResult
handle_listpartitions
(
Client
&
client
,
Request
,
Response
&
r
)
{
for
(
const
auto
&
partition
:
client
.
partition
.
instance
.
partitions
)
{
for
(
const
auto
&
partition
:
client
.
GetInstance
()
.
partitions
)
{
r
.
Format
(
"partition: %s
\n
"
,
partition
.
name
.
c_str
());
}
...
...
@@ -76,7 +76,7 @@ handle_newpartition(Client &client, Request request, Response &response)
return
CommandResult
::
ERROR
;
}
auto
&
instance
=
client
.
partition
.
instance
;
auto
&
instance
=
client
.
GetInstance
()
;
if
(
HasPartitionNamed
(
instance
,
name
))
{
response
.
Error
(
ACK_ERROR_EXIST
,
"name already exists"
);
return
CommandResult
::
ERROR
;
...
...
src/command/PlayerCommands.cxx
View file @
05b8ddac
...
...
@@ -182,7 +182,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
}
#ifdef ENABLE_DATABASE
const
UpdateService
*
update_service
=
client
.
partition
.
instance
.
update
;
const
UpdateService
*
update_service
=
client
.
GetInstance
()
.
update
;
unsigned
updateJobId
=
update_service
!=
nullptr
?
update_service
->
GetId
()
:
0
;
...
...
src/command/StorageCommands.cxx
View file @
05b8ddac
...
...
@@ -109,7 +109,7 @@ handle_listfiles_storage(Response &r, Storage &storage, const char *uri)
CommandResult
handle_listfiles_storage
(
Client
&
client
,
Response
&
r
,
const
char
*
uri
)
{
auto
&
event_loop
=
client
.
partition
.
instance
.
io_thread
.
GetEventLoop
();
auto
&
event_loop
=
client
.
GetInstance
()
.
io_thread
.
GetEventLoop
();
std
::
unique_ptr
<
Storage
>
storage
(
CreateStorageURI
(
event_loop
,
uri
));
if
(
storage
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
...
...
@@ -148,7 +148,7 @@ print_storage_uri(Client &client, Response &r, const Storage &storage)
CommandResult
handle_listmounts
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
Storage
*
_composite
=
client
.
partition
.
instance
.
storage
;
Storage
*
_composite
=
client
.
GetInstance
()
.
storage
;
if
(
_composite
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
return
CommandResult
::
ERROR
;
...
...
@@ -170,7 +170,9 @@ handle_listmounts(Client &client, gcc_unused Request args, Response &r)
CommandResult
handle_mount
(
Client
&
client
,
Request
args
,
Response
&
r
)
{
Storage
*
_composite
=
client
.
partition
.
instance
.
storage
;
auto
&
instance
=
client
.
GetInstance
();
Storage
*
_composite
=
instance
.
storage
;
if
(
_composite
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
return
CommandResult
::
ERROR
;
...
...
@@ -196,7 +198,7 @@ handle_mount(Client &client, Request args, Response &r)
return
CommandResult
::
ERROR
;
}
auto
&
event_loop
=
client
.
partition
.
instance
.
io_thread
.
GetEventLoop
();
auto
&
event_loop
=
instance
.
io_thread
.
GetEventLoop
();
Storage
*
storage
=
CreateStorageURI
(
event_loop
,
remote_uri
);
if
(
storage
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
...
...
@@ -207,7 +209,7 @@ handle_mount(Client &client, Request args, Response &r)
client
.
partition
.
EmitIdle
(
IDLE_MOUNT
);
#ifdef ENABLE_DATABASE
Database
*
_db
=
client
.
partition
.
instance
.
database
;
Database
*
_db
=
instance
.
database
;
if
(
_db
!=
nullptr
&&
_db
->
IsPlugin
(
simple_db_plugin
))
{
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
_db
;
...
...
@@ -230,7 +232,9 @@ handle_mount(Client &client, Request args, Response &r)
CommandResult
handle_unmount
(
Client
&
client
,
Request
args
,
Response
&
r
)
{
Storage
*
_composite
=
client
.
partition
.
instance
.
storage
;
auto
&
instance
=
client
.
GetInstance
();
Storage
*
_composite
=
instance
.
storage
;
if
(
_composite
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
return
CommandResult
::
ERROR
;
...
...
@@ -246,13 +250,13 @@ handle_unmount(Client &client, Request args, Response &r)
}
#ifdef ENABLE_DATABASE
if
(
client
.
partition
.
instance
.
update
!=
nullptr
)
if
(
instance
.
update
!=
nullptr
)
/* ensure that no database update will attempt to work
with the database/storage instances we're about to
destroy here */
client
.
partition
.
instance
.
update
->
CancelMount
(
local_uri
);
instance
.
update
->
CancelMount
(
local_uri
);
Database
*
_db
=
client
.
partition
.
instance
.
database
;
Database
*
_db
=
instance
.
database
;
if
(
_db
!=
nullptr
&&
_db
->
IsPlugin
(
simple_db_plugin
))
{
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
_db
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment