Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
98d2036a
Commit
98d2036a
authored
Oct 18, 2010
by
Srikanth Raju
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Media library CRUD operations
parent
db662f04
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2276 additions
and
0 deletions
+2276
-0
modules/media_library/sql_add.c
modules/media_library/sql_add.c
+303
-0
modules/media_library/sql_delete.c
modules/media_library/sql_delete.c
+125
-0
modules/media_library/sql_search.c
modules/media_library/sql_search.c
+1109
-0
modules/media_library/sql_update.c
modules/media_library/sql_update.c
+739
-0
No files found.
modules/media_library/sql_add.c
0 → 100644
View file @
98d2036a
This diff is collapsed.
Click to expand it.
modules/media_library/sql_delete.c
0 → 100644
View file @
98d2036a
/*****************************************************************************
* sql_delete.c: SQL-based media library: all database delete functions
*****************************************************************************
* Copyright (C) 2008-2010 The VideoLAN Team and AUTHORS
* $Id$
*
* Authors: Antoine Lejeune <phytos@videolan.org>
* Jean-Philippe André <jpeg@videolan.org>
* Rémi Duraffort <ivoire@videolan.org>
* Adrien Maglo <magsoft@videolan.org>
* Srikanth Raju <srikiraju at gmail dot com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "sql_media_library.h"
/**
* @brief Generic DELETE function for many medias
* Delete a media and all its referencies which don't point
* an anything else.
*
* @param p_ml This media_library_t object
* @param p_array list of ids to delete
* @return VLC_SUCCESS or VLC_EGENERIC
* TODO: Expand to delete media/artist/album given any params
*/
int
Delete
(
media_library_t
*
p_ml
,
vlc_array_t
*
p_array
)
{
char
*
psz_idlist
=
NULL
,
*
psz_tmp
=
NULL
;
int
i_return
=
VLC_ENOMEM
;
int
i_rows
=
0
,
i_cols
=
0
;
char
**
pp_results
=
NULL
;
if
(
vlc_array_count
(
p_array
)
<=
0
)
{
i_return
=
VLC_SUCCESS
;
goto
quit_delete_final
;
}
for
(
int
i
=
0
;
i
<
vlc_array_count
(
p_array
);
i
++
)
{
ml_element_t
*
find
=
(
ml_element_t
*
)
vlc_array_item_at_index
(
p_array
,
i
);
assert
(
find
->
criteria
==
ML_ID
);
if
(
!
psz_idlist
)
{
if
(
asprintf
(
&
psz_tmp
,
"( %d"
,
find
->
value
.
i
)
==
-
1
)
{
goto
quit_delete_final
;
}
}
else
{
if
(
asprintf
(
&
psz_tmp
,
"%s, %d"
,
psz_idlist
,
find
->
value
.
i
)
==
-
1
)
{
goto
quit_delete_final
;
}
}
free
(
psz_idlist
);
psz_idlist
=
psz_tmp
;
psz_tmp
=
NULL
;
}
free
(
psz_tmp
);
if
(
asprintf
(
&
psz_tmp
,
"%s )"
,
psz_idlist
?
psz_idlist
:
"("
)
==
-
1
)
{
goto
quit_delete_final
;
}
psz_idlist
=
psz_tmp
;
psz_tmp
=
NULL
;
msg_Dbg
(
p_ml
,
"Multi Delete id list: %s"
,
psz_idlist
);
/**
* Below ensures you are emitting media-deleted only
* for existant media
*/
Begin
(
p_ml
);
i_return
=
Query
(
p_ml
,
&
pp_results
,
&
i_rows
,
&
i_cols
,
"SELECT id FROM media WHERE id IN %s"
,
psz_idlist
);
if
(
i_return
!=
VLC_SUCCESS
)
goto
quit
;
i_return
=
QuerySimple
(
p_ml
,
"DELETE FROM media WHERE media.id IN %s"
,
psz_idlist
);
if
(
i_return
!=
VLC_SUCCESS
)
goto
quit
;
i_return
=
QuerySimple
(
p_ml
,
"DELETE FROM extra WHERE extra.id IN %s"
,
psz_idlist
);
if
(
i_return
!=
VLC_SUCCESS
)
goto
quit
;
quit:
if
(
i_return
==
VLC_SUCCESS
)
{
Commit
(
p_ml
);
/* Emit delete on var media-deleted */
for
(
int
i
=
1
;
i
<=
i_rows
;
i
++
)
{
var_SetInteger
(
p_ml
,
"media-deleted"
,
atoi
(
pp_results
[
i
*
i_cols
]
)
);
}
}
else
Rollback
(
p_ml
);
quit_delete_final:
FreeSQLResult
(
p_ml
,
pp_results
);
free
(
psz_tmp
);
free
(
psz_idlist
);
return
i_return
;
}
modules/media_library/sql_search.c
0 → 100644
View file @
98d2036a
This diff is collapsed.
Click to expand it.
modules/media_library/sql_update.c
0 → 100644
View file @
98d2036a
This diff is collapsed.
Click to expand it.
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