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 @@
...
@@ -25,6 +25,12 @@
const
Domain
client_domain
(
"client"
);
const
Domain
client_domain
(
"client"
);
Instance
&
Client
::
GetInstance
()
{
return
partition
.
instance
;
}
playlist
&
playlist
&
Client
::
GetPlaylist
()
Client
::
GetPlaylist
()
{
{
...
...
src/client/Client.hxx
View file @
05b8ddac
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
class
SocketAddress
;
class
SocketAddress
;
class
EventLoop
;
class
EventLoop
;
class
Path
;
class
Path
;
struct
Instance
;
struct
Partition
;
struct
Partition
;
struct
PlayerControl
;
struct
PlayerControl
;
struct
playlist
;
struct
playlist
;
...
@@ -188,6 +189,9 @@ public:
...
@@ -188,6 +189,9 @@ public:
void
AllowFile
(
Path
path_fs
)
const
;
void
AllowFile
(
Path
path_fs
)
const
;
gcc_pure
gcc_pure
Instance
&
GetInstance
();
gcc_pure
playlist
&
GetPlaylist
();
playlist
&
GetPlaylist
();
gcc_pure
gcc_pure
...
...
src/command/MessageCommands.cxx
View file @
05b8ddac
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#include "client/ClientList.hxx"
#include "client/ClientList.hxx"
#include "client/Response.hxx"
#include "client/Response.hxx"
#include "Instance.hxx"
#include "Instance.hxx"
#include "Partition.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include <set>
#include <set>
...
@@ -80,7 +79,7 @@ handle_channels(Client &client, gcc_unused Request args, Response &r)
...
@@ -80,7 +79,7 @@ handle_channels(Client &client, gcc_unused Request args, Response &r)
assert
(
args
.
IsEmpty
());
assert
(
args
.
IsEmpty
());
std
::
set
<
std
::
string
>
channels
;
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
(),
channels
.
insert
(
c
.
subscriptions
.
begin
(),
c
.
subscriptions
.
end
());
c
.
subscriptions
.
end
());
...
@@ -122,7 +121,7 @@ handle_send_message(Client &client, Request args, Response &r)
...
@@ -122,7 +121,7 @@ handle_send_message(Client &client, Request args, Response &r)
bool
sent
=
false
;
bool
sent
=
false
;
const
ClientMessage
msg
(
channel_name
,
message_text
);
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
))
if
(
c
.
PushMessage
(
msg
))
sent
=
true
;
sent
=
true
;
...
...
src/command/NeighborCommands.cxx
View file @
05b8ddac
...
@@ -23,7 +23,6 @@
...
@@ -23,7 +23,6 @@
#include "client/Client.hxx"
#include "client/Client.hxx"
#include "client/Response.hxx"
#include "client/Response.hxx"
#include "Instance.hxx"
#include "Instance.hxx"
#include "Partition.hxx"
#include "neighbor/Glue.hxx"
#include "neighbor/Glue.hxx"
#include "neighbor/Info.hxx"
#include "neighbor/Info.hxx"
...
@@ -39,7 +38,7 @@ CommandResult
...
@@ -39,7 +38,7 @@ CommandResult
handle_listneighbors
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
handle_listneighbors
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
{
const
NeighborGlue
*
const
neighbors
=
const
NeighborGlue
*
const
neighbors
=
client
.
partition
.
instance
.
neighbors
;
client
.
GetInstance
()
.
neighbors
;
if
(
neighbors
==
nullptr
)
{
if
(
neighbors
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_UNKNOWN
,
"No neighbor plugin configured"
);
r
.
Error
(
ACK_ERROR_UNKNOWN
,
"No neighbor plugin configured"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
...
src/command/OtherCommands.cxx
View file @
05b8ddac
...
@@ -126,11 +126,11 @@ handle_listfiles(Client &client, Request args, Response &r)
...
@@ -126,11 +126,11 @@ handle_listfiles(Client &client, Request args, Response &r)
case
LocatedUri
:
:
Type
::
RELATIVE
:
case
LocatedUri
:
:
Type
::
RELATIVE
:
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
if
(
client
.
partition
.
instance
.
storage
!=
nullptr
)
if
(
client
.
GetInstance
()
.
storage
!=
nullptr
)
/* if we have a storage instance, obtain a list of
/* if we have a storage instance, obtain a list of
files from it */
files from it */
return
handle_listfiles_storage
(
r
,
return
handle_listfiles_storage
(
r
,
*
client
.
partition
.
instance
.
storage
,
*
client
.
GetInstance
()
.
storage
,
uri
);
uri
);
/* fall back to entries from database if we have no storage */
/* 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)
...
@@ -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
)
if
(
update
!=
nullptr
)
return
handle_update
(
r
,
*
update
,
path
,
discard
);
return
handle_update
(
r
,
*
update
,
path
,
discard
);
Database
*
db
=
client
.
partition
.
instance
.
database
;
Database
*
db
=
client
.
GetInstance
()
.
database
;
if
(
db
!=
nullptr
)
if
(
db
!=
nullptr
)
return
handle_update
(
r
,
*
db
,
path
,
discard
);
return
handle_update
(
r
,
*
db
,
path
,
discard
);
#else
#else
...
...
src/command/PartitionCommands.cxx
View file @
05b8ddac
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
CommandResult
CommandResult
handle_listpartitions
(
Client
&
client
,
Request
,
Response
&
r
)
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
());
r
.
Format
(
"partition: %s
\n
"
,
partition
.
name
.
c_str
());
}
}
...
@@ -76,7 +76,7 @@ handle_newpartition(Client &client, Request request, Response &response)
...
@@ -76,7 +76,7 @@ handle_newpartition(Client &client, Request request, Response &response)
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
auto
&
instance
=
client
.
partition
.
instance
;
auto
&
instance
=
client
.
GetInstance
()
;
if
(
HasPartitionNamed
(
instance
,
name
))
{
if
(
HasPartitionNamed
(
instance
,
name
))
{
response
.
Error
(
ACK_ERROR_EXIST
,
"name already exists"
);
response
.
Error
(
ACK_ERROR_EXIST
,
"name already exists"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
...
src/command/PlayerCommands.cxx
View file @
05b8ddac
...
@@ -182,7 +182,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
...
@@ -182,7 +182,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
}
}
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
const
UpdateService
*
update_service
=
client
.
partition
.
instance
.
update
;
const
UpdateService
*
update_service
=
client
.
GetInstance
()
.
update
;
unsigned
updateJobId
=
update_service
!=
nullptr
unsigned
updateJobId
=
update_service
!=
nullptr
?
update_service
->
GetId
()
?
update_service
->
GetId
()
:
0
;
:
0
;
...
...
src/command/StorageCommands.cxx
View file @
05b8ddac
...
@@ -109,7 +109,7 @@ handle_listfiles_storage(Response &r, Storage &storage, const char *uri)
...
@@ -109,7 +109,7 @@ handle_listfiles_storage(Response &r, Storage &storage, const char *uri)
CommandResult
CommandResult
handle_listfiles_storage
(
Client
&
client
,
Response
&
r
,
const
char
*
uri
)
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
));
std
::
unique_ptr
<
Storage
>
storage
(
CreateStorageURI
(
event_loop
,
uri
));
if
(
storage
==
nullptr
)
{
if
(
storage
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
...
@@ -148,7 +148,7 @@ print_storage_uri(Client &client, Response &r, const Storage &storage)
...
@@ -148,7 +148,7 @@ print_storage_uri(Client &client, Response &r, const Storage &storage)
CommandResult
CommandResult
handle_listmounts
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
handle_listmounts
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
{
Storage
*
_composite
=
client
.
partition
.
instance
.
storage
;
Storage
*
_composite
=
client
.
GetInstance
()
.
storage
;
if
(
_composite
==
nullptr
)
{
if
(
_composite
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
@@ -170,7 +170,9 @@ handle_listmounts(Client &client, gcc_unused Request args, Response &r)
...
@@ -170,7 +170,9 @@ handle_listmounts(Client &client, gcc_unused Request args, Response &r)
CommandResult
CommandResult
handle_mount
(
Client
&
client
,
Request
args
,
Response
&
r
)
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
)
{
if
(
_composite
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
@@ -196,7 +198,7 @@ handle_mount(Client &client, Request args, Response &r)
...
@@ -196,7 +198,7 @@ handle_mount(Client &client, Request args, Response &r)
return
CommandResult
::
ERROR
;
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
);
Storage
*
storage
=
CreateStorageURI
(
event_loop
,
remote_uri
);
if
(
storage
==
nullptr
)
{
if
(
storage
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
r
.
Error
(
ACK_ERROR_ARG
,
"Unrecognized storage URI"
);
...
@@ -207,7 +209,7 @@ handle_mount(Client &client, Request args, Response &r)
...
@@ -207,7 +209,7 @@ handle_mount(Client &client, Request args, Response &r)
client
.
partition
.
EmitIdle
(
IDLE_MOUNT
);
client
.
partition
.
EmitIdle
(
IDLE_MOUNT
);
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
Database
*
_db
=
client
.
partition
.
instance
.
database
;
Database
*
_db
=
instance
.
database
;
if
(
_db
!=
nullptr
&&
_db
->
IsPlugin
(
simple_db_plugin
))
{
if
(
_db
!=
nullptr
&&
_db
->
IsPlugin
(
simple_db_plugin
))
{
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
_db
;
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
_db
;
...
@@ -230,7 +232,9 @@ handle_mount(Client &client, Request args, Response &r)
...
@@ -230,7 +232,9 @@ handle_mount(Client &client, Request args, Response &r)
CommandResult
CommandResult
handle_unmount
(
Client
&
client
,
Request
args
,
Response
&
r
)
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
)
{
if
(
_composite
==
nullptr
)
{
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
...
@@ -246,13 +250,13 @@ handle_unmount(Client &client, Request args, Response &r)
...
@@ -246,13 +250,13 @@ handle_unmount(Client &client, Request args, Response &r)
}
}
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
if
(
client
.
partition
.
instance
.
update
!=
nullptr
)
if
(
instance
.
update
!=
nullptr
)
/* ensure that no database update will attempt to work
/* ensure that no database update will attempt to work
with the database/storage instances we're about to
with the database/storage instances we're about to
destroy here */
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
))
{
if
(
_db
!=
nullptr
&&
_db
->
IsPlugin
(
simple_db_plugin
))
{
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
_db
;
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