annotate src/cds.c @ 185:7a0f498af035 default tip

Fix a race condition.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Wed, 14 May 2014 22:43:57 +0900
parents 2659ebefb192
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
125
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
1 /*
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
2 * cds.c : GeeXboX uShare Content Directory Service
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
3 * Originally developped for the GeeXboX project.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
4 * Parts of the code are originated from GMediaServer from Oskar Liljeblad.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
5 * Copyright (C) 2005-2007 Benjamin Zores <ben@geexbox.org>
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
6 *
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
10 * (at your option) any later version.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
11 *
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
15 * GNU Library General Public License for more details.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
16 *
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License along
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
18 * with this program; if not, write to the Free Software Foundation,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
20 */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
21
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
22 #include <stdlib.h>
180
2659ebefb192 fix implicit pointers
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 136
diff changeset
23 #include <string.h>
136
2a9ac5ce2c7e Remove internal libdlna and libupnp.(using OS package by default)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 125
diff changeset
24 #include <upnp.h>
2a9ac5ce2c7e Remove internal libdlna and libupnp.(using OS package by default)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 125
diff changeset
25 #include <upnptools.h>
125
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
26
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
27 #include "ushare.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
28 #include "services.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
29 #include "ushare.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
30 #include "services.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
31 #include "metadata.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
32 #include "mime.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
33 #include "buffer.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
34 #include "minmax.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
35
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
36 /* Represent the CDS GetSearchCapabilities action. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
37 #define SERVICE_CDS_ACTION_SEARCH_CAPS "GetSearchCapabilities"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
38
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
39 /* Represent the CDS GetSortCapabilities action. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
40 #define SERVICE_CDS_ACTION_SORT_CAPS "GetSortCapabilities"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
41
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
42 /* Represent the CDS GetSystemUpdateID action. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
43 #define SERVICE_CDS_ACTION_UPDATE_ID "GetSystemUpdateID"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
44
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
45 /* Represent the CDS Browse action. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
46 #define SERVICE_CDS_ACTION_BROWSE "Browse"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
47
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
48 /* Represent the CDS Search action. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
49 #define SERVICE_CDS_ACTION_SEARCH "Search"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
50
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
51 /* Represent the CDS SearchCaps argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
52 #define SERVICE_CDS_ARG_SEARCH_CAPS "SearchCaps"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
53
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
54 /* Represent the CDS SortCaps argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
55 #define SERVICE_CDS_ARG_SORT_CAPS "SortCaps"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
56
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
57 /* Represent the CDS UpdateId argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
58 #define SERVICE_CDS_ARG_UPDATE_ID "Id"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
59
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
60 /* Represent the CDS StartingIndex argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
61 #define SERVICE_CDS_ARG_START_INDEX "StartingIndex"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
62
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
63 /* Represent the CDS RequestedCount argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
64 #define SERVICE_CDS_ARG_REQUEST_COUNT "RequestedCount"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
65
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
66 /* Represent the CDS ObjectID argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
67 #define SERVICE_CDS_ARG_OBJECT_ID "ObjectID"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
68
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
69 /* Represent the CDS Filter argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
70 #define SERVICE_CDS_ARG_FILTER "Filter"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
71
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
72 /* Represent the CDS BrowseFlag argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
73 #define SERVICE_CDS_ARG_BROWSE_FLAG "BrowseFlag"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
74
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
75 /* Represent the CDS SortCriteria argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
76 #define SERVICE_CDS_ARG_SORT_CRIT "SortCriteria"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
77
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
78 /* Represent the CDS SearchCriteria argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
79 #define SERVICE_CDS_ARG_SEARCH_CRIT "SearchCriteria"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
80
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
81 /* Represent the CDS Root Object ID argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
82 #define SERVICE_CDS_ROOT_OBJECT_ID "0"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
83
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
84 /* Represent the CDS DIDL Message Metadata Browse flag argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
85 #define SERVICE_CDS_BROWSE_METADATA "BrowseMetadata"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
86
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
87 /* Represent the CDS DIDL Message DirectChildren Browse flag argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
88 #define SERVICE_CDS_BROWSE_CHILDREN "BrowseDirectChildren"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
89
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
90 /* Represent the CDS DIDL Message Result argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
91 #define SERVICE_CDS_DIDL_RESULT "Result"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
92
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
93 /* Represent the CDS DIDL Message NumberReturned argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
94 #define SERVICE_CDS_DIDL_NUM_RETURNED "NumberReturned"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
95
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
96 /* Represent the CDS DIDL Message TotalMatches argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
97 #define SERVICE_CDS_DIDL_TOTAL_MATCH "TotalMatches"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
98
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
99 /* Represent the CDS DIDL Message UpdateID argument. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
100 #define SERVICE_CDS_DIDL_UPDATE_ID "UpdateID"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
101
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
102 /* DIDL parameters */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
103 /* Represent the CDS DIDL Message Header Namespace. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
104 #define DIDL_NAMESPACE \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
105 "xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\" " \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
106 "xmlns:dc=\"http://purl.org/dc/elements/1.1/\" " \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
107 "xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\""
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
108
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
109 /* Represent the CDS DIDL Message Header Tag. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
110 #define DIDL_LITE "DIDL-Lite"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
111
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
112 /* Represent the CDS DIDL Message Item value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
113 #define DIDL_ITEM "item"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
114
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
115 /* Represent the CDS DIDL Message Item ID value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
116 #define DIDL_ITEM_ID "id"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
117
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
118 /* Represent the CDS DIDL Message Item Parent ID value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
119 #define DIDL_ITEM_PARENT_ID "parentID"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
120
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
121 /* Represent the CDS DIDL Message Item Restricted value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
122 #define DIDL_ITEM_RESTRICTED "restricted"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
123
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
124 /* Represent the CDS DIDL Message Item UPnP Class value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
125 #define DIDL_ITEM_CLASS "upnp:class"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
126
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
127 /* Represent the CDS DIDL Message Item Title value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
128 #define DIDL_ITEM_TITLE "dc:title"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
129
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
130 /* Represent the CDS DIDL Message Item Resource value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
131 #define DIDL_RES "res"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
132
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
133 /* Represent the CDS DIDL Message Item Protocol Info value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
134 #define DIDL_RES_INFO "protocolInfo"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
135
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
136 /* Represent the CDS DIDL Message Item Resource Size value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
137 #define DIDL_RES_SIZE "size"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
138
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
139 /* Represent the CDS DIDL Message Container value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
140 #define DIDL_CONTAINER "container"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
141
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
142 /* Represent the CDS DIDL Message Container ID value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
143 #define DIDL_CONTAINER_ID "id"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
144
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
145 /* Represent the CDS DIDL Message Container Parent ID value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
146 #define DIDL_CONTAINER_PARENT_ID "parentID"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
147
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
148 /* Represent the CDS DIDL Message Container number of children value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
149 #define DIDL_CONTAINER_CHILDS "childCount"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
150
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
151 /* Represent the CDS DIDL Message Container Restricted value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
152 #define DIDL_CONTAINER_RESTRICTED "restricted"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
153
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
154 /* Represent the CDS DIDL Message Container Searchable value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
155 #define DIDL_CONTAINER_SEARCH "searchable"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
156
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
157 /* Represent the CDS DIDL Message Container UPnP Class value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
158 #define DIDL_CONTAINER_CLASS "upnp:class"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
159
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
160 /* Represent the CDS DIDL Message Container Title value. */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
161 #define DIDL_CONTAINER_TITLE "dc:title"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
162
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
163 /* Represent the "upnp:class" reserved keyword for Search action */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
164 #define SEARCH_CLASS_MATCH_KEYWORD "(upnp:class = \""
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
165
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
166 /* Represent the "upnp:class derived from" reserved keyword */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
167 #define SEARCH_CLASS_DERIVED_KEYWORD "(upnp:class derivedfrom \""
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
168
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
169 /* Represent the "res@protocolInfo contains" reserved keyword */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
170 #define SEARCH_PROTOCOL_CONTAINS_KEYWORD "(res@protocolInfo contains \""
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
171
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
172 /* Represent the Search default keyword */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
173 #define SEARCH_OBJECT_KEYWORD "object"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
174
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
175 /* Represent the Search 'AND' connector keyword */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
176 #define SEARCH_AND ") and ("
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
177
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
178 static bool
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
179 filter_has_val (const char *filter, const char *val)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
180 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
181 char *x = NULL, *token = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
182 char *m_buffer = NULL, *buffer;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
183 int len = strlen (val);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
184 bool ret = false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
185
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
186 if (!strcmp (filter, "*"))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
187 return true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
188
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
189 x = strdup (filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
190 if (x)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
191 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
192 m_buffer = (char*) malloc (strlen (x));
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
193 if (m_buffer)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
194 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
195 buffer = m_buffer;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
196 token = strtok_r (x, ",", &buffer);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
197 while (token)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
198 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
199 if (*val == '@')
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
200 token = strchr (token, '@');
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
201 if (token && !strncmp (token, val, len))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
202 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
203 ret = true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
204 break;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
205 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
206 token = strtok_r (NULL, ",", &buffer);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
207 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
208 free (m_buffer);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
209 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
210 free (x);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
211 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
212 return ret;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
213 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
214
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
215 /* UPnP ContentDirectory Service actions */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
216 static bool
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
217 cds_get_search_capabilities (struct action_event_t *event)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
218 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
219 upnp_add_response (event, SERVICE_CDS_ARG_SEARCH_CAPS, "");
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
220
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
221 return event->status;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
222 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
223
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
224 static bool
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
225 cds_get_sort_capabilities (struct action_event_t *event)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
226 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
227 upnp_add_response (event, SERVICE_CDS_ARG_SORT_CAPS, "");
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
228
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
229 return event->status;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
230 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
231
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
232 static bool
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
233 cds_get_system_update_id (struct action_event_t *event)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
234 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
235 upnp_add_response (event, SERVICE_CDS_ARG_UPDATE_ID,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
236 SERVICE_CDS_ROOT_OBJECT_ID);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
237
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
238 return event->status;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
239 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
240
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
241 static void
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
242 didl_add_header (struct buffer_t *out)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
243 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
244 buffer_appendf (out, "<%s %s>", DIDL_LITE, DIDL_NAMESPACE);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
245 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
246
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
247 static void
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
248 didl_add_footer (struct buffer_t *out)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
249 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
250 buffer_appendf (out, "</%s>", DIDL_LITE);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
251 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
252
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
253 static void
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
254 didl_add_tag (struct buffer_t *out, char *tag, char *value)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
255 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
256 if (value)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
257 buffer_appendf (out, "<%s>%s</%s>", tag, value, tag);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
258 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
259
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
260 static void
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
261 didl_add_param (struct buffer_t *out, char *param, char *value)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
262 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
263 if (value)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
264 buffer_appendf (out, " %s=\"%s\"", param, value);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
265 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
266
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
267 static void
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
268 didl_add_value (struct buffer_t *out, char *param, off_t value)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
269 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
270 buffer_appendf (out, " %s=\"%lld\"", param, value);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
271 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
272
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
273 static void
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
274 didl_add_item (struct buffer_t *out, int item_id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
275 int parent_id, char *restricted, char *class, char *title,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
276 char *protocol_info, off_t size, char *url, char *filter)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
277 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
278 buffer_appendf (out, "<%s", DIDL_ITEM);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
279 didl_add_value (out, DIDL_ITEM_ID, item_id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
280 didl_add_value (out, DIDL_ITEM_PARENT_ID, parent_id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
281 didl_add_param (out, DIDL_ITEM_RESTRICTED, restricted);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
282 buffer_append (out, ">");
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
283
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
284 didl_add_tag (out, DIDL_ITEM_CLASS, class);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
285 didl_add_tag (out, DIDL_ITEM_TITLE, title);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
286
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
287 if (filter_has_val (filter, DIDL_RES))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
288 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
289 buffer_appendf (out, "<%s", DIDL_RES);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
290 // protocolInfo is required :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
291 didl_add_param (out, DIDL_RES_INFO, protocol_info);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
292 if (filter_has_val (filter, "@"DIDL_RES_SIZE))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
293 didl_add_value (out, DIDL_RES_SIZE, size);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
294 buffer_append (out, ">");
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
295 if (url)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
296 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
297 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
298 buffer_appendf (out, "http://%s:%d%s/%s",
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
299 UpnpGetServerIpAddress (), ut->port, VIRTUAL_DIR, url);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
300 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
301 buffer_appendf (out, "</%s>", DIDL_RES);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
302 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
303 buffer_appendf (out, "</%s>", DIDL_ITEM);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
304 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
305
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
306 static void
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
307 didl_add_container (struct buffer_t *out, int id, int parent_id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
308 int child_count, char *restricted, char *searchable,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
309 char *title, char *class)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
310 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
311 buffer_appendf (out, "<%s", DIDL_CONTAINER);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
312
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
313 didl_add_value (out, DIDL_CONTAINER_ID, id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
314 didl_add_value (out, DIDL_CONTAINER_PARENT_ID, parent_id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
315 if (child_count >= 0)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
316 didl_add_value (out, DIDL_CONTAINER_CHILDS, child_count);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
317 didl_add_param (out, DIDL_CONTAINER_RESTRICTED, restricted);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
318 didl_add_param (out, DIDL_CONTAINER_SEARCH, searchable);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
319 buffer_append (out, ">");
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
320
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
321 didl_add_tag (out, DIDL_CONTAINER_CLASS, class);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
322 didl_add_tag (out, DIDL_CONTAINER_TITLE, title);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
323
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
324 buffer_appendf (out, "</%s>", DIDL_CONTAINER);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
325 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
326
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
327 static int
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
328 cds_browse_metadata (struct action_event_t *event, struct buffer_t *out,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
329 int index, int count, struct upnp_entry_t *entry,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
330 char *filter)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
331 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
332 int result_count = 0, c = 0;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
333
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
334 if (!entry)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
335 return -1;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
336
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
337 if (entry->child_count == -1) /* item : file */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
338 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
339 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
340 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
341 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
342
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
343 char *protocol =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
344 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
345 entry->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
346 dlna_write_protocol_info (DLNA_PROTOCOL_INFO_TYPE_HTTP,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
347 DLNA_ORG_PLAY_SPEED_NORMAL,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
348 DLNA_ORG_CONVERSION_NONE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
349 DLNA_ORG_OPERATION_RANGE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
350 ut->dlna_flags, entry->dlna_profile) :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
351 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
352 mime_get_protocol (entry->mime_type);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
353
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
354 didl_add_header (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
355 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
356 entry->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
357 didl_add_item (out, entry->id, entry->parent
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
358 ? entry->parent->id : -1, "false",
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
359 dlna_profile_upnp_object_item (entry->dlna_profile),
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
360 entry->title,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
361 protocol, entry->size,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
362 entry->url, filter) :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
363 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
364 didl_add_item (out, entry->id, entry->parent
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
365 ? entry->parent->id : -1, "false",
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
366 entry->mime_type->mime_class, entry->title,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
367 protocol, entry->size,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
368 entry->url, filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
369
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
370 didl_add_footer (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
371 free (protocol);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
372
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
373 for (c = index; c < MIN (index + count, entry->child_count); c++)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
374 result_count++;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
375 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
376 else /* container : directory */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
377 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
378 didl_add_header (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
379 didl_add_container (out, entry->id, entry->parent
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
380 ? entry->parent->id : -1, entry->child_count,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
381 "true", "true", entry->title,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
382 entry->mime_type->mime_class);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
383 didl_add_footer (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
384
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
385 result_count = 1;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
386 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
387
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
388 upnp_add_response (event, SERVICE_CDS_DIDL_RESULT, out->buf);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
389 upnp_add_response (event, SERVICE_CDS_DIDL_NUM_RETURNED, "1");
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
390 upnp_add_response (event, SERVICE_CDS_DIDL_TOTAL_MATCH, "1");
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
391
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
392 return result_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
393 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
394
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
395 static int
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
396 cds_browse_directchildren (struct action_event_t *event,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
397 struct buffer_t *out, int index,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
398 int count, struct upnp_entry_t *entry, char *filter)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
399 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
400 struct upnp_entry_t **childs;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
401 int s, result_count = 0;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
402 char tmp[32];
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
403
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
404 if (entry->child_count == -1) /* item : file */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
405 return -1;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
406
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
407 didl_add_header (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
408
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
409 /* go to the child pointed out by index */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
410 childs = entry->childs;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
411 for (s = 0; s < index; s++)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
412 if (*childs)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
413 childs++;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
414
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
415 /* UPnP CDS compliance : If starting index = 0 and requested count = 0
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
416 then all children must be returned */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
417 if (index == 0 && count == 0)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
418 count = entry->child_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
419
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
420 for (; *childs; childs++)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
421 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
422 if (count == 0 || result_count < count)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
423 /* only fetch the requested count number or all entries if count = 0 */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
424 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
425 if ((*childs)->child_count >= 0) /* container */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
426 didl_add_container (out, (*childs)->id, (*childs)->parent ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
427 (*childs)->parent->id : -1,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
428 (*childs)->child_count, "true", NULL,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
429 (*childs)->title,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
430 (*childs)->mime_type->mime_class);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
431 else /* item */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
432 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
433 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
434 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
435 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
436
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
437 char *protocol =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
438 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
439 (*childs)->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
440 dlna_write_protocol_info (DLNA_PROTOCOL_INFO_TYPE_HTTP,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
441 DLNA_ORG_PLAY_SPEED_NORMAL,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
442 DLNA_ORG_CONVERSION_NONE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
443 DLNA_ORG_OPERATION_RANGE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
444 ut->dlna_flags, (*childs)->dlna_profile) :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
445 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
446 mime_get_protocol ((*childs)->mime_type);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
447
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
448 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
449 (*childs)->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
450 didl_add_item (out, (*childs)->id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
451 (*childs)->parent ? (*childs)->parent->id : -1,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
452 "true", dlna_profile_upnp_object_item ((*childs)->dlna_profile),
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
453 (*childs)->title, protocol,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
454 (*childs)->size, (*childs)->url, filter) :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
455 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
456 didl_add_item (out, (*childs)->id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
457 (*childs)->parent ? (*childs)->parent->id : -1,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
458 "true", (*childs)->mime_type->mime_class,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
459 (*childs)->title, protocol,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
460 (*childs)->size, (*childs)->url, filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
461
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
462 free (protocol);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
463 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
464 result_count++;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
465 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
466 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
467
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
468 didl_add_footer (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
469
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
470 upnp_add_response (event, SERVICE_CDS_DIDL_RESULT, out->buf);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
471 sprintf (tmp, "%d", result_count);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
472 upnp_add_response (event, SERVICE_CDS_DIDL_NUM_RETURNED, tmp);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
473 sprintf (tmp, "%d", entry->child_count);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
474 upnp_add_response (event, SERVICE_CDS_DIDL_TOTAL_MATCH, tmp);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
475
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
476 return result_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
477 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
478
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
479 static bool
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
480 cds_browse (struct action_event_t *event)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
481 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
482 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
483 struct upnp_entry_t *entry = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
484 int result_count = 0, index, count, id, sort_criteria;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
485 char *flag = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
486 char *filter = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
487 struct buffer_t *out = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
488 bool metadata;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
489
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
490 if (!event)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
491 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
492
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
493 /* Check for status */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
494 if (!event->status)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
495 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
496
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
497 /* check if metadatas have been well inited */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
498 if (!ut->init)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
499 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
500
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
501 /* Retrieve Browse arguments */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
502 index = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_START_INDEX);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
503 count = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_REQUEST_COUNT);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
504 id = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_OBJECT_ID);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
505 flag = upnp_get_string (event->request, SERVICE_CDS_ARG_BROWSE_FLAG);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
506 filter = upnp_get_string (event->request, SERVICE_CDS_ARG_FILTER);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
507 sort_criteria = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_SORT_CRIT);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
508
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
509 if (!flag || !filter)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
510 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
511
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
512 /* Check arguments validity */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
513 if (!strcmp (flag, SERVICE_CDS_BROWSE_METADATA))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
514 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
515 if (index)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
516 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
517 free (flag);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
518 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
519 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
520 metadata = true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
521 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
522 else if (!strcmp (flag, SERVICE_CDS_BROWSE_CHILDREN))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
523 metadata = false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
524 else
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
525 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
526 free (flag);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
527 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
528 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
529 free (flag);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
530
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
531 entry = upnp_get_entry (ut, id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
532 if (!entry && (id < ut->starting_id))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
533 entry = upnp_get_entry (ut, ut->starting_id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
534
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
535 if (!entry)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
536 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
537 free (filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
538 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
539 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
540
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
541 out = buffer_new ();
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
542 if (!out)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
543 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
544 free (filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
545 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
546 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
547
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
548 if (metadata)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
549 result_count =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
550 cds_browse_metadata (event, out, index, count, entry, filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
551 else
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
552 result_count =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
553 cds_browse_directchildren (event, out, index, count, entry, filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
554 free (filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
555
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
556 if (result_count < 0)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
557 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
558 buffer_free (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
559 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
560 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
561
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
562 buffer_free (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
563 upnp_add_response (event, SERVICE_CDS_DIDL_UPDATE_ID,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
564 SERVICE_CDS_ROOT_OBJECT_ID);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
565
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
566 return event->status;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
567 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
568
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
569 static bool
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
570 matches_search (char *search_criteria, struct upnp_entry_t *entry)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
571 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
572 char keyword[256] = SEARCH_OBJECT_KEYWORD;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
573 bool derived_from = false, protocol_contains = false, result = false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
574 char *quote_closed = NULL, *and_clause = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
575 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
576 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
577 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
578 char *protocol =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
579 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
580 entry->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
581 dlna_write_protocol_info (DLNA_PROTOCOL_INFO_TYPE_HTTP,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
582 DLNA_ORG_PLAY_SPEED_NORMAL,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
583 DLNA_ORG_CONVERSION_NONE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
584 DLNA_ORG_OPERATION_RANGE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
585 ut->dlna_flags, entry->dlna_profile) :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
586 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
587 mime_get_protocol (entry->mime_type);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
588
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
589 if (!strncmp (search_criteria, SEARCH_CLASS_MATCH_KEYWORD,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
590 strlen (SEARCH_CLASS_MATCH_KEYWORD)))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
591 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
592 strncpy (keyword, search_criteria
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
593 + strlen (SEARCH_CLASS_MATCH_KEYWORD), sizeof (keyword));
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
594 quote_closed = strchr (keyword, '"');
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
595
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
596 if (quote_closed)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
597 *quote_closed = '\0';
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
598 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
599 else if (!strncmp (search_criteria, SEARCH_CLASS_DERIVED_KEYWORD,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
600 strlen (SEARCH_CLASS_DERIVED_KEYWORD)))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
601 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
602 derived_from = true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
603 strncpy (keyword, search_criteria
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
604 + strlen (SEARCH_CLASS_DERIVED_KEYWORD), sizeof (keyword));
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
605 quote_closed = strchr (keyword, '"');
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
606
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
607 if (quote_closed)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
608 *quote_closed = '\0';
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
609 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
610 else if (!strncmp (search_criteria, SEARCH_PROTOCOL_CONTAINS_KEYWORD,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
611 strlen (SEARCH_PROTOCOL_CONTAINS_KEYWORD)))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
612 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
613 protocol_contains = true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
614 strncpy (keyword, search_criteria
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
615 + strlen (SEARCH_PROTOCOL_CONTAINS_KEYWORD), sizeof (keyword));
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
616 quote_closed = strchr (keyword, '"');
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
617
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
618 if (quote_closed)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
619 *quote_closed = '\0';
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
620 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
621
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
622 if (derived_from && entry->mime_type
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
623 && !strncmp (entry->mime_type->mime_class, keyword, strlen (keyword)))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
624 result = true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
625 else if (protocol_contains && strstr (protocol, keyword))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
626 result = true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
627 else if (entry->mime_type &&
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
628 !strcmp (entry->mime_type->mime_class, keyword))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
629 result = true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
630 free (protocol);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
631
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
632 and_clause = strstr (search_criteria, SEARCH_AND);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
633 if (and_clause)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
634 return (result &&
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
635 matches_search (and_clause + strlen (SEARCH_AND) -1, entry));
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
636
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
637 return true;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
638 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
639
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
640 static int
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
641 cds_search_directchildren_recursive (struct buffer_t *out, int count,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
642 struct upnp_entry_t *entry, char *filter,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
643 char *search_criteria)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
644 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
645 struct upnp_entry_t **childs;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
646 int result_count = 0;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
647
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
648 if (entry->child_count == -1) /* item : file */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
649 return -1;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
650
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
651 /* go to the first child */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
652 childs = entry->childs;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
653
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
654 for (; *childs; childs++)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
655 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
656 if (count == 0 || result_count < count)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
657 /* only fetch the requested count number or all entries if count = 0 */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
658 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
659 if ((*childs)->child_count >= 0) /* container */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
660 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
661 int new_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
662 new_count = cds_search_directchildren_recursive
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
663 (out, (count == 0) ? 0 : (count - result_count),
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
664 (*childs), filter, search_criteria);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
665 result_count += new_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
666 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
667 else /* item */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
668 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
669 if (matches_search (search_criteria, *childs))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
670 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
671 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
672 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
673 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
674 char *protocol =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
675 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
676 (*childs)->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
677 dlna_write_protocol_info(DLNA_PROTOCOL_INFO_TYPE_HTTP,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
678 DLNA_ORG_PLAY_SPEED_NORMAL,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
679 DLNA_ORG_CONVERSION_NONE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
680 DLNA_ORG_OPERATION_RANGE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
681 ut->dlna_flags, (*childs)->dlna_profile):
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
682 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
683 mime_get_protocol ((*childs)->mime_type);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
684
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
685 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
686 (*childs)->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
687 didl_add_item (out, (*childs)->id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
688 (*childs)->parent ? (*childs)->parent->id : -1,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
689 "true", dlna_profile_upnp_object_item ((*childs)->dlna_profile),
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
690 (*childs)->title, protocol,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
691 (*childs)->size, (*childs)->url, filter) :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
692 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
693 didl_add_item (out, (*childs)->id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
694 (*childs)->parent ? (*childs)->parent->id : -1,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
695 "true", (*childs)->mime_type->mime_class,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
696 (*childs)->title, protocol,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
697 (*childs)->size, (*childs)->url, filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
698 free (protocol);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
699 result_count++;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
700 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
701 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
702 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
703 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
704
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
705 return result_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
706 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
707
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
708 static int
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
709 cds_search_directchildren (struct action_event_t *event,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
710 struct buffer_t *out, int index,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
711 int count, struct upnp_entry_t *entry,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
712 char *filter, char *search_criteria)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
713 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
714 struct upnp_entry_t **childs;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
715 int s, result_count = 0;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
716 char tmp[32];
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
717
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
718 index = 0;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
719
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
720 if (entry->child_count == -1) /* item : file */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
721 return -1;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
722
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
723 didl_add_header (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
724
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
725 /* go to the child pointed out by index */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
726 childs = entry->childs;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
727 for (s = 0; s < index; s++)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
728 if (*childs)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
729 childs++;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
730
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
731 /* UPnP CDS compliance : If starting index = 0 and requested count = 0
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
732 then all children must be returned */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
733 if (index == 0 && count == 0)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
734 count = entry->child_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
735
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
736 for (; *childs; childs++)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
737 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
738 if (count == 0 || result_count < count)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
739 /* only fetch the requested count number or all entries if count = 0 */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
740 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
741 if ((*childs)->child_count >= 0) /* container */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
742 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
743 int new_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
744 new_count = cds_search_directchildren_recursive
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
745 (out, (count == 0) ? 0 : (count - result_count),
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
746 (*childs), filter, search_criteria);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
747 result_count += new_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
748 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
749 else /* item */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
750 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
751 if (matches_search (search_criteria, *childs))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
752 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
753 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
754 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
755 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
756 char *protocol =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
757 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
758 (*childs)->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
759 dlna_write_protocol_info(DLNA_PROTOCOL_INFO_TYPE_HTTP,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
760 DLNA_ORG_PLAY_SPEED_NORMAL,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
761 DLNA_ORG_CONVERSION_NONE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
762 DLNA_ORG_OPERATION_RANGE,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
763 ut->dlna_flags, (*childs)->dlna_profile):
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
764 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
765 mime_get_protocol ((*childs)->mime_type);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
766
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
767 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
768 (*childs)->dlna_profile ?
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
769 didl_add_item (out, (*childs)->id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
770 (*childs)->parent ? (*childs)->parent->id : -1,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
771 "true", dlna_profile_upnp_object_item ((*childs)->dlna_profile),
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
772 (*childs)->title, protocol,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
773 (*childs)->size, (*childs)->url, filter) :
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
774 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
775 didl_add_item (out, (*childs)->id,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
776 (*childs)->parent ? (*childs)->parent->id : -1,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
777 "true", (*childs)->mime_type->mime_class,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
778 (*childs)->title, protocol,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
779 (*childs)->size, (*childs)->url, filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
780 free (protocol);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
781 result_count++;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
782 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
783 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
784 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
785 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
786
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
787 didl_add_footer (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
788
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
789 upnp_add_response (event, SERVICE_CDS_DIDL_RESULT, out->buf);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
790
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
791 sprintf (tmp, "%d", result_count);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
792 upnp_add_response (event, SERVICE_CDS_DIDL_NUM_RETURNED, tmp);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
793 sprintf (tmp, "%d", result_count);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
794 upnp_add_response (event, SERVICE_CDS_DIDL_TOTAL_MATCH, tmp);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
795
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
796 return result_count;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
797 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
798
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
799 static bool
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
800 cds_search (struct action_event_t *event)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
801 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
802 extern struct ushare_t *ut;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
803 struct upnp_entry_t *entry = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
804 int result_count = 0, index, count, id, sort_criteria;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
805 char *search_criteria = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
806 char *filter = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
807 struct buffer_t *out = NULL;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
808
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
809 if (!event)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
810 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
811
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
812 /* Check for status */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
813 if (!event->status)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
814 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
815
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
816 /* check if metadatas have been well inited */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
817 if (!ut->init)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
818 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
819
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
820 /* Retrieve Browse arguments */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
821 index = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_START_INDEX);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
822 count = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_REQUEST_COUNT);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
823 id = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_OBJECT_ID);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
824
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
825 search_criteria = upnp_get_string (event->request,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
826 SERVICE_CDS_ARG_SEARCH_CRIT);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
827 filter = upnp_get_string (event->request, SERVICE_CDS_ARG_FILTER);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
828 sort_criteria = upnp_get_ui4 (event->request, SERVICE_CDS_ARG_SORT_CRIT);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
829
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
830 if (!search_criteria || !filter)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
831 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
832
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
833 entry = upnp_get_entry (ut, id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
834
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
835 if (!entry && (id < ut->starting_id))
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
836 entry = upnp_get_entry (ut, ut->starting_id);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
837
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
838 if (!entry)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
839 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
840
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
841 out = buffer_new ();
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
842 if (!out)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
843 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
844
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
845 result_count =
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
846 cds_search_directchildren (event, out, index, count, entry,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
847 filter, search_criteria);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
848
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
849 if (result_count < 0)
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
850 {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
851 buffer_free (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
852 return false;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
853 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
854
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
855 buffer_free (out);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
856 upnp_add_response (event, SERVICE_CDS_DIDL_UPDATE_ID,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
857 SERVICE_CDS_ROOT_OBJECT_ID);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
858
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
859 free (search_criteria);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
860 free (filter);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
861
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
862 return event->status;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
863 }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
864
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
865 /* List of UPnP ContentDirectory Service actions */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
866 struct service_action_t cds_service_actions[] = {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
867 { SERVICE_CDS_ACTION_SEARCH_CAPS, cds_get_search_capabilities },
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
868 { SERVICE_CDS_ACTION_SORT_CAPS, cds_get_sort_capabilities },
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
869 { SERVICE_CDS_ACTION_UPDATE_ID, cds_get_system_update_id },
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
870 { SERVICE_CDS_ACTION_BROWSE, cds_browse },
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
871 { SERVICE_CDS_ACTION_SEARCH, cds_search },
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
872 { NULL, NULL }
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
873 };