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
a9cb12b7
Commit
a9cb12b7
authored
Apr 03, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: make almost all attributes `private`
parent
380f73c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
13 deletions
+28
-13
Client.hxx
src/client/Client.hxx
+16
-1
ClientNew.cxx
src/client/ClientNew.cxx
+4
-3
MessageCommands.cxx
src/command/MessageCommands.cxx
+8
-9
No files found.
src/client/Client.hxx
View file @
a9cb12b7
...
...
@@ -56,7 +56,6 @@ class Client final
Partition
*
partition
;
public
:
unsigned
permission
;
/** the uid of the client process, or -1 if unknown */
...
...
@@ -76,11 +75,14 @@ public:
/** idle flags that the client wants to receive */
unsigned
idle_subscriptions
;
public
:
// TODO: make this attribute "private"
/**
* The tags this client is interested in.
*/
TagMask
tag_mask
=
TagMask
::
All
();
private
:
/**
* A list of channel names this client is subscribed to.
*/
...
...
@@ -97,6 +99,7 @@ public:
*/
std
::
list
<
ClientMessage
>
messages
;
public
:
Client
(
EventLoop
&
loop
,
Partition
&
partition
,
UniqueSocketDescriptor
fd
,
int
uid
,
unsigned
_permission
,
...
...
@@ -175,11 +178,23 @@ public:
return
subscriptions
.
find
(
channel_name
)
!=
subscriptions
.
end
();
}
const
auto
&
GetSubscriptions
()
const
noexcept
{
return
subscriptions
;
}
SubscribeResult
Subscribe
(
const
char
*
channel
)
noexcept
;
bool
Unsubscribe
(
const
char
*
channel
)
noexcept
;
void
UnsubscribeAll
()
noexcept
;
bool
PushMessage
(
const
ClientMessage
&
msg
)
noexcept
;
template
<
typename
F
>
void
ConsumeMessages
(
F
&&
f
)
{
while
(
!
messages
.
empty
())
{
f
(
messages
.
front
());
messages
.
pop_front
();
}
}
/**
* Is this client allowed to use the specified local file?
*
...
...
src/client/ClientNew.cxx
View file @
a9cb12b7
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -70,14 +70,15 @@ client_new(EventLoop &loop, Partition &partition,
(
void
)
fd
.
Write
(
GREETING
,
sizeof
(
GREETING
)
-
1
);
const
unsigned
num
=
next_client_num
++
;
Client
*
client
=
new
Client
(
loop
,
partition
,
std
::
move
(
fd
),
uid
,
permission
,
n
ext_client_num
++
);
n
um
);
client_list
.
Add
(
*
client
);
FormatInfo
(
client_domain
,
"[%u] opened from %s"
,
client
->
num
,
remote
.
c_str
());
num
,
remote
.
c_str
());
}
void
...
...
src/command/MessageCommands.cxx
View file @
a9cb12b7
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -78,9 +78,11 @@ handle_channels(Client &client, gcc_unused Request args, Response &r)
assert
(
args
.
empty
());
std
::
set
<
std
::
string
>
channels
;
for
(
const
auto
&
c
:
*
client
.
GetInstance
().
client_list
)
channels
.
insert
(
c
.
subscriptions
.
begin
(),
c
.
subscriptions
.
end
());
for
(
const
auto
&
c
:
*
client
.
GetInstance
().
client_list
)
{
const
auto
&
subscriptions
=
c
.
GetSubscriptions
();
channels
.
insert
(
subscriptions
.
begin
(),
subscriptions
.
end
());
}
for
(
const
auto
&
channel
:
channels
)
r
.
Format
(
"channel: %s
\n
"
,
channel
.
c_str
());
...
...
@@ -94,13 +96,10 @@ handle_read_messages(Client &client,
{
assert
(
args
.
empty
());
while
(
!
client
.
messages
.
empty
())
{
const
ClientMessage
&
msg
=
client
.
messages
.
front
();
client
.
ConsumeMessages
([
&
r
](
const
auto
&
msg
){
r
.
Format
(
"channel: %s
\n
message: %s
\n
"
,
msg
.
GetChannel
(),
msg
.
GetMessage
());
client
.
messages
.
pop_front
();
}
});
return
CommandResult
::
OK
;
}
...
...
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