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
0d8e44a0
Commit
0d8e44a0
authored
Feb 07, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/DatabaseError: rename enum db_error and make strictly-typed
parent
f097952b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
22 deletions
+30
-22
Instance.cxx
src/Instance.cxx
+2
-1
CommandError.cxx
src/command/CommandError.cxx
+4
-4
DatabaseError.hxx
src/db/DatabaseError.hxx
+4
-4
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+2
-1
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+8
-7
UpnpDatabasePlugin.cxx
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+10
-5
No files found.
src/Instance.cxx
View file @
0d8e44a0
...
...
@@ -37,7 +37,8 @@ Database *
Instance
::
GetDatabase
(
Error
&
error
)
{
if
(
database
==
nullptr
)
error
.
Set
(
db_domain
,
DB_DISABLED
,
"No database"
);
error
.
Set
(
db_domain
,
int
(
DatabaseErrorCode
::
DISABLED
),
"No database"
);
return
database
;
}
...
...
src/command/CommandError.cxx
View file @
0d8e44a0
...
...
@@ -129,12 +129,12 @@ ToAck(const Error &error)
return
(
enum
ack
)
error
.
GetCode
();
#ifdef ENABLE_DATABASE
}
else
if
(
error
.
IsDomain
(
db_domain
))
{
switch
((
enum
db_error
)
error
.
GetCode
())
{
case
D
B_
DISABLED
:
case
D
B_
NOT_FOUND
:
switch
((
DatabaseErrorCode
)
error
.
GetCode
())
{
case
D
atabaseErrorCode
:
:
DISABLED
:
case
D
atabaseErrorCode
:
:
NOT_FOUND
:
return
ACK_ERROR_NO_EXIST
;
case
D
B_
CONFLICT
:
case
D
atabaseErrorCode
:
:
CONFLICT
:
return
ACK_ERROR_ARG
;
}
#endif
...
...
src/db/DatabaseError.hxx
View file @
0d8e44a0
...
...
@@ -22,16 +22,16 @@
class
Domain
;
enum
db_error
{
enum
class
DatabaseErrorCode
{
/**
* The database is disabled, i.e. none is configured in this
* MPD instance.
*/
D
B_D
ISABLED
,
DISABLED
,
DB_
NOT_FOUND
,
NOT_FOUND
,
DB_
CONFLICT
,
CONFLICT
,
};
extern
const
Domain
db_domain
;
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
0d8e44a0
...
...
@@ -518,7 +518,8 @@ ProxyDatabase::GetSong(const char *uri, Error &error) const
}
if
(
song
==
nullptr
)
{
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
"No such song: %s"
,
uri
);
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No such song: %s"
,
uri
);
return
nullptr
;
}
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
0d8e44a0
...
...
@@ -263,14 +263,14 @@ SimpleDatabase::GetSong(const char *uri, Error &error) const
if
(
r
.
uri
==
nullptr
)
{
/* it's a directory */
error
.
Format
(
db_domain
,
DB_
NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No such song: %s"
,
uri
);
return
nullptr
;
}
if
(
strchr
(
r
.
uri
,
'/'
)
!=
nullptr
)
{
/* refers to a URI "below" the actual song */
error
.
Format
(
db_domain
,
DB_
NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No such song: %s"
,
uri
);
return
nullptr
;
}
...
...
@@ -278,7 +278,7 @@ SimpleDatabase::GetSong(const char *uri, Error &error) const
const
Song
*
song
=
r
.
directory
->
FindSong
(
r
.
uri
);
protect
.
unlock
();
if
(
song
==
nullptr
)
{
error
.
Format
(
db_domain
,
DB_
NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No such song: %s"
,
uri
);
return
nullptr
;
}
...
...
@@ -343,7 +343,8 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
}
}
error
.
Set
(
db_domain
,
DB_NOT_FOUND
,
"No such directory"
);
error
.
Set
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No such directory"
);
return
false
;
}
...
...
@@ -426,13 +427,13 @@ SimpleDatabase::Mount(const char *uri, Database *db, Error &error)
auto
r
=
root
->
LookupDirectory
(
uri
);
if
(
r
.
uri
==
nullptr
)
{
error
.
Format
(
db_domain
,
DB_
CONFLICT
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
CONFLICT
,
"Already exists: %s"
,
uri
);
return
false
;
}
if
(
strchr
(
r
.
uri
,
'/'
)
!=
nullptr
)
{
error
.
Format
(
db_domain
,
DB_
NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"Parent not found: %s"
,
uri
);
return
false
;
}
...
...
@@ -459,7 +460,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri,
Error
&
error
)
{
if
(
cache_path
.
IsNull
())
{
error
.
Format
(
db_domain
,
DB_
NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No 'cache_directory' configured"
);
return
false
;
}
...
...
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
View file @
0d8e44a0
...
...
@@ -217,7 +217,8 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const
{
auto
vpath
=
stringToTokens
(
uri
,
"/"
,
true
);
if
(
vpath
.
size
()
<
2
)
{
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
"No such song: %s"
,
uri
);
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No such song: %s"
,
uri
);
return
nullptr
;
}
...
...
@@ -495,7 +496,8 @@ UpnpDatabase::Namei(const ContentDirectoryService &server,
// Look for the name in the sub-container list
UPnPDirObject
*
child
=
dirbuf
.
FindObject
(
i
->
c_str
());
if
(
child
==
nullptr
)
{
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"No such object"
);
return
false
;
}
...
...
@@ -506,7 +508,8 @@ UpnpDatabase::Namei(const ContentDirectoryService &server,
}
if
(
child
->
type
!=
UPnPDirObject
::
Type
::
CONTAINER
)
{
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"Not a container"
);
return
false
;
}
...
...
@@ -604,7 +607,8 @@ UpnpDatabase::VisitServer(const ContentDirectoryService &server,
break
;
default
:
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"Not found"
);
return
false
;
}
...
...
@@ -617,7 +621,8 @@ UpnpDatabase::VisitServer(const ContentDirectoryService &server,
if
(
dirent
.
type
!=
UPnPDirObject
::
Type
::
ITEM
||
dirent
.
item_class
!=
UPnPDirObject
::
ItemClass
::
MUSIC
)
{
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
error
.
Format
(
db_domain
,
(
int
)
DatabaseErrorCode
::
NOT_FOUND
,
"Not found"
);
return
false
;
}
...
...
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