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
7eee79c1
Commit
7eee79c1
authored
Jun 04, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neighbor/udisks: move code to class UDisks2::ParseObjects(ODBus::Message)
parent
96265234
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
19 deletions
+36
-19
UDisks2.cxx
src/lib/dbus/UDisks2.cxx
+16
-0
UDisks2.hxx
src/lib/dbus/UDisks2.hxx
+14
-1
UdisksNeighborPlugin.cxx
src/neighbor/plugins/UdisksNeighborPlugin.cxx
+6
-18
No files found.
src/lib/dbus/UDisks2.cxx
View file @
7eee79c1
...
...
@@ -18,6 +18,7 @@
*/
#include "UDisks2.hxx"
#include "Message.hxx"
#include "ReadIter.hxx"
#include "ObjectManager.hxx"
#include "util/StringAPI.hxx"
...
...
@@ -113,4 +114,19 @@ ParseObjects(ODBus::ReadMessageIter &&i,
});
}
void
ParseObjects
(
ODBus
::
Message
&
reply
,
std
::
function
<
void
(
Object
&&
o
)
>
callback
)
{
using
namespace
ODBus
;
reply
.
CheckThrowError
();
ReadMessageIter
i
(
*
reply
.
Get
());
if
(
i
.
GetArgType
()
!=
DBUS_TYPE_ARRAY
)
throw
std
::
runtime_error
(
"Malformed response"
);
ParseObjects
(
i
.
Recurse
(),
std
::
move
(
callback
));
}
}
// namespace UDisks2
src/lib/dbus/UDisks2.hxx
View file @
7eee79c1
...
...
@@ -26,7 +26,10 @@
#define UDISKS2_PATH "/org/freedesktop/UDisks2"
#define UDISKS2_INTERFACE "org.freedesktop.UDisks2"
namespace
ODBus
{
class
ReadMessageIter
;
}
namespace
ODBus
{
class
Message
;
class
ReadMessageIter
;
}
namespace
UDisks2
{
...
...
@@ -66,6 +69,16 @@ void
ParseObjects
(
ODBus
::
ReadMessageIter
&&
i
,
std
::
function
<
void
(
Object
&&
o
)
>
callback
);
/**
* Parse objects from a GetManagedObjects reply and invoke the
* callback for each.
*
* Throws on error.
*/
void
ParseObjects
(
ODBus
::
Message
&
reply
,
std
::
function
<
void
(
Object
&&
o
)
>
callback
);
}
// namespace UDisks2
#endif
src/neighbor/plugins/UdisksNeighborPlugin.cxx
View file @
7eee79c1
...
...
@@ -34,7 +34,6 @@
#include "event/Call.hxx"
#include "thread/Mutex.hxx"
#include "thread/SafeSingleton.hxx"
#include "util/Domain.hxx"
#include "util/Manual.hxx"
#include "Log.hxx"
...
...
@@ -43,8 +42,6 @@
#include <list>
#include <map>
static
constexpr
Domain
udisks_domain
(
"udisks"
);
static
NeighborInfo
ToNeighborInfo
(
const
UDisks2
::
Object
&
o
)
noexcept
{
...
...
@@ -216,24 +213,15 @@ UdisksNeighborExplorer::Remove(const std::string &path) noexcept
inline
void
UdisksNeighborExplorer
::
OnListNotify
(
ODBus
::
Message
reply
)
noexcept
{
using
namespace
ODBus
;
try
{
reply
.
CheckThrowError
(
);
try
{
ParseObjects
(
reply
,
std
::
bind
(
&
UdisksNeighborExplorer
::
Insert
,
this
,
std
::
placeholders
::
_1
)
);
}
catch
(...)
{
LogError
(
std
::
current_exception
());
LogError
(
std
::
current_exception
(),
"Failed to parse GetManagedObjects reply"
);
return
;
}
ReadMessageIter
i
(
*
reply
.
Get
());
if
(
i
.
GetArgType
()
!=
DBUS_TYPE_ARRAY
)
{
LogError
(
udisks_domain
,
"Malformed response"
);
return
;
}
ParseObjects
(
i
.
Recurse
(),
std
::
bind
(
&
UdisksNeighborExplorer
::
Insert
,
this
,
std
::
placeholders
::
_1
));
}
inline
DBusHandlerResult
...
...
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