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
41e0eb73
Commit
41e0eb73
authored
Feb 20, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/dbus/udisks2: parse the MountPoints property
parent
6adf964c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
UDisks2.cxx
src/lib/dbus/UDisks2.cxx
+58
-0
UDisks2.hxx
src/lib/dbus/UDisks2.hxx
+7
-0
No files found.
src/lib/dbus/UDisks2.cxx
View file @
41e0eb73
...
...
@@ -22,6 +22,7 @@
#include "ReadIter.hxx"
#include "ObjectManager.hxx"
#include "util/StringAPI.hxx"
#include "util/StringView.hxx"
#include "util/Compiler.h"
#include <functional>
...
...
@@ -39,6 +40,40 @@ CheckString(I &&i) noexcept
return
i
.
GetString
();
}
template
<
typename
I
>
gcc_pure
static
StringView
CheckRecursedByteArrayToString
(
I
&&
i
)
noexcept
{
if
(
i
.
GetArgType
()
!=
DBUS_TYPE_BYTE
)
return
nullptr
;
auto
value
=
i
.
template
GetFixedArray
<
char
>
();
return
{
value
.
data
,
value
.
size
};
}
template
<
typename
I
>
gcc_pure
static
StringView
CheckByteArrayToString
(
I
&&
i
)
noexcept
{
if
(
i
.
GetArgType
()
!=
DBUS_TYPE_ARRAY
)
return
nullptr
;
return
CheckRecursedByteArrayToString
(
i
.
Recurse
());
}
template
<
typename
I
>
gcc_pure
static
StringView
CheckByteArrayArrayFrontToString
(
I
&&
i
)
noexcept
{
if
(
i
.
GetArgType
()
!=
DBUS_TYPE_ARRAY
)
return
nullptr
;
return
CheckByteArrayToString
(
i
.
Recurse
());
}
static
void
ParseDriveDictEntry
(
Object
&
o
,
const
char
*
name
,
ODBus
::
ReadMessageIter
&&
value_i
)
noexcept
...
...
@@ -62,6 +97,25 @@ ParseBlockDictEntry(Object &o, const char *name,
}
static
void
ParseFileesystemDictEntry
(
Object
&
o
,
const
char
*
name
,
ODBus
::
ReadMessageIter
&&
value_i
)
noexcept
{
if
(
StringIsEqual
(
name
,
"MountPoints"
))
{
if
(
!
o
.
mount_point
.
empty
())
/* we already know one mount point, and we're
not interested in more */
return
;
/* get the first string in the array */
auto
value
=
CheckByteArrayArrayFrontToString
(
value_i
);
if
(
value
!=
nullptr
)
o
.
mount_point
=
{
value
.
data
,
value
.
size
};
// TODO: check whether the string is a valid filesystem path
}
}
static
void
ParseInterface
(
Object
&
o
,
const
char
*
interface
,
ODBus
::
ReadMessageIter
&&
i
)
noexcept
{
...
...
@@ -74,6 +128,10 @@ ParseInterface(Object &o, const char *interface,
std
::
ref
(
o
),
_1
,
_2
));
}
else
if
(
StringIsEqual
(
interface
,
"org.freedesktop.UDisks2.Filesystem"
))
{
o
.
is_filesystem
=
true
;
i
.
ForEachProperty
(
std
::
bind
(
ParseFileesystemDictEntry
,
std
::
ref
(
o
),
_1
,
_2
));
}
}
...
...
src/lib/dbus/UDisks2.hxx
View file @
41e0eb73
...
...
@@ -39,6 +39,13 @@ struct Object {
std
::
string
drive_id
,
block_id
;
/**
* The first element of the "MountPoints" array of the
* "Filesystem" interface. Empty if no "MountPoints" property
* exists.
*/
std
::
string
mount_point
;
bool
is_filesystem
=
false
;
explicit
Object
(
const
char
*
_path
)
noexcept
...
...
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