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
22dd3c80
Commit
22dd3c80
authored
Jan 18, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp/Device: move code to method Parse()
Forward the Error to the caller.
parent
04b7648e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
27 deletions
+35
-27
Device.cxx
src/db/upnp/Device.cxx
+9
-10
Device.hxx
src/db/upnp/Device.hxx
+7
-8
Discovery.cxx
src/db/upnp/Discovery.cxx
+9
-3
Discovery.hxx
src/db/upnp/Discovery.hxx
+10
-6
No files found.
src/db/upnp/Device.cxx
View file @
22dd3c80
...
...
@@ -21,7 +21,6 @@
#include "Device.hxx"
#include "Util.hxx"
#include "Expat.hxx"
#include "Log.hxx"
#include "util/Error.hxx"
#include <stdlib.h>
...
...
@@ -99,16 +98,15 @@ protected:
}
};
UPnPDevice
::
UPnPDevice
(
const
std
::
string
&
url
,
const
char
*
description
)
:
ok
(
false
)
bool
UPnPDevice
::
Parse
(
const
std
::
string
&
url
,
const
char
*
description
,
Error
&
error
)
{
{
UPnPDeviceParser
mparser
(
*
this
);
Error
error
;
if
(
!
mparser
.
Parse
(
description
,
strlen
(
description
),
true
,
error
))
{
// TODO: pass Error to caller
LogError
(
error
);
return
;
if
(
!
mparser
.
Parse
(
description
,
strlen
(
description
),
true
,
error
))
return
false
;
}
if
(
URLBase
.
empty
())
{
...
...
@@ -129,5 +127,6 @@ UPnPDevice::UPnPDevice(const std::string &url, const char *description)
}
}
}
ok
=
true
;
return
true
;
}
src/db/upnp/Device.hxx
View file @
22dd3c80
...
...
@@ -61,7 +61,6 @@ struct UPnPService {
*/
class
UPnPDevice
{
public
:
bool
ok
;
// e.g. urn:schemas-upnp-org:device:MediaServer:1
std
::
string
deviceType
;
// e.g. MediaTomb
...
...
@@ -78,17 +77,17 @@ public:
// Services provided by this device.
std
::
vector
<
UPnPService
>
services
;
UPnPDevice
()
=
default
;
UPnPDevice
(
const
UPnPDevice
&
)
=
delete
;
UPnPDevice
(
UPnPDevice
&&
)
=
default
;
UPnPDevice
&
operator
=
(
UPnPDevice
&&
)
=
default
;
/** Build device from xml description downloaded from discovery
* @param url where the description came from
* @param description the xml device description
*/
UPnPDevice
(
const
std
::
string
&
url
,
const
char
*
description
);
UPnPDevice
()
:
ok
(
false
)
{}
UPnPDevice
(
const
UPnPDevice
&
)
=
delete
;
UPnPDevice
(
UPnPDevice
&&
)
=
default
;
UPnPDevice
&
operator
=
(
UPnPDevice
&&
)
=
default
;
bool
Parse
(
const
std
::
string
&
url
,
const
char
*
description
,
Error
&
error
);
};
#endif
/* _UPNPDEV_HXX_INCLUDED_ */
src/db/upnp/Discovery.cxx
View file @
22dd3c80
...
...
@@ -22,6 +22,7 @@
#include "Domain.hxx"
#include "ContentDirectoryService.hxx"
#include "upnpplib.hxx"
#include "Log.hxx"
#include <upnp/upnptools.h>
...
...
@@ -73,13 +74,18 @@ UPnPDeviceDirectory::discoExplorer()
}
// Update or insert the device
ContentDirectoryDescriptor
d
(
tsk
->
url
,
buf
,
time
(
0
),
tsk
->
expires
);
ContentDirectoryDescriptor
d
(
time
(
0
),
tsk
->
expires
);
{
Error
error2
;
bool
success
=
d
.
Parse
(
tsk
->
url
,
buf
,
error2
);
free
(
buf
);
if
(
!
d
.
device
.
ok
)
{
if
(
!
success
)
{
delete
tsk
;
LogError
(
error2
);
continue
;
}
}
const
ScopeLock
protect
(
mutex
);
directories
[
std
::
move
(
tsk
->
deviceId
)]
=
std
::
move
(
d
);
...
...
src/db/upnp/Discovery.hxx
View file @
22dd3c80
...
...
@@ -65,15 +65,19 @@ class UPnPDeviceDirectory {
*/
class
ContentDirectoryDescriptor
{
public
:
ContentDirectoryDescriptor
()
=
default
;
ContentDirectoryDescriptor
(
const
std
::
string
&
url
,
const
char
*
description
,
time_t
last
,
int
exp
)
:
device
(
url
,
description
),
last_seen
(
last
),
expires
(
exp
+
20
)
{}
UPnPDevice
device
;
time_t
last_seen
;
int
expires
;
// seconds valid
ContentDirectoryDescriptor
()
=
default
;
ContentDirectoryDescriptor
(
time_t
last
,
int
exp
)
:
last_seen
(
last
),
expires
(
exp
+
20
)
{}
bool
Parse
(
const
std
::
string
&
url
,
const
char
*
description
,
Error
&
_error
)
{
return
device
.
Parse
(
url
,
description
,
_error
);
}
};
LibUPnP
*
const
lib
;
...
...
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