19
|
1 |
/*
|
25
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Framework Manager. Parses the CFG file
|
|
15 |
*
|
|
16 |
*/
|
19
|
17 |
|
|
18 |
#include <stdio.h>
|
|
19 |
#include <string.h>
|
25
|
20 |
#include "xaframeworkmgr.h"
|
19
|
21 |
|
|
22 |
/* Default line width permitted in the cfg file + 2 to hold "\r\n"*/
|
|
23 |
#define LINEWIDTH 82
|
|
24 |
|
|
25 |
typedef enum
|
25
|
26 |
{
|
19
|
27 |
FWMgrTagNone,
|
|
28 |
FWMgrTagURIScheme,
|
|
29 |
FWMgrTagFileExt
|
25
|
30 |
} FWMgrTagType;
|
19
|
31 |
|
|
32 |
/* Config file location */
|
21
|
33 |
const char configFileLocationZ[] = "z:/openmaxal/openmaxal.cfg";
|
|
34 |
const char configFileLocationC[] = "c:/openmaxal/openmaxal.cfg";
|
19
|
35 |
|
|
36 |
/* Tags used for parsing */
|
|
37 |
const char mediaPlayerBeginTag[] = "<mediaplayer>";
|
|
38 |
const char mediaPlayerEndTag[] = "</mediaplayer>";
|
|
39 |
const char mediaRecorderBeginTag[] = "<mediarecorder>";
|
|
40 |
const char mediaRecorderEndTag[] = "</mediarecorder>";
|
|
41 |
const char mediaFrameworkMmfBeginTag[] = "<mmf>";
|
|
42 |
const char mediaFrameworkMmfEndTag[] = "</mmf>";
|
|
43 |
const char mediaFrameworkGstBeginTag[] = "<gst>";
|
|
44 |
const char uriSchemeBeginTag[] = "<urischeme>";
|
|
45 |
const char uriSchemeEndTag[] = "</urischeme>";
|
|
46 |
const char mediaFrameworkGstEndTag[] = "</gst>";
|
|
47 |
const char fileExtBeginTag[] = "<fileext>";
|
|
48 |
const char fileExtEndTag[] = "</fileext>";
|
|
49 |
|
|
50 |
/* Local function definitions */
|
|
51 |
/* returns FWMgrTrue if processed successfully */
|
25
|
52 |
static FWMgrBool processConfigEntry(const char* buffer,
|
|
53 |
FWMgrMOType *mediaType, FWMgrFwType *frameworkType,
|
|
54 |
FWMgrTagType *tagType, FWMgrBool *newNode, FrameworkMap **node);
|
|
55 |
|
|
56 |
/* returns FWMgrTrue if processed successfully */
|
|
57 |
static FWMgrBool processTagType(const char* buffer,
|
|
58 |
FWMgrFwType *frameworkType, FWMgrTagType *tagType,
|
19
|
59 |
FrameworkMap **node);
|
|
60 |
|
|
61 |
/* returns FWMgrTrue if processed successfully */
|
25
|
62 |
static FWMgrBool tokenizeTag(FWMgrTagType tagType, const char* buffer,
|
19
|
63 |
FrameworkMap **node);
|
|
64 |
|
|
65 |
/* Crates a default rules config file */
|
|
66 |
static int createDefaultRules(const char * filename);
|
|
67 |
|
|
68 |
/* Global functions from header file */
|
|
69 |
|
|
70 |
/* FrameworkMap* XAFrameworkMgr_CreateFrameworkMap
|
|
71 |
* Description: Creates a list of framework and use-case map.
|
|
72 |
*/
|
|
73 |
FrameworkMap* XAFrameworkMgr_CreateFrameworkMap()
|
25
|
74 |
{
|
19
|
75 |
char buffer[LINEWIDTH];
|
|
76 |
int readSize;
|
|
77 |
int lineNumber = 0;
|
|
78 |
FWMgrBool processedEntry = FWMgrTrue;
|
|
79 |
FWMgrMOType currentMediaType = FWMgrMOUnknown;
|
|
80 |
FWMgrFwType currentFrameworkType = FWMgrFWUknown;
|
|
81 |
FWMgrTagType currentTagType = FWMgrTagNone;
|
|
82 |
FrameworkMap *curNode = NULL;
|
|
83 |
FWMgrBool newNode;
|
|
84 |
FrameworkMap *frameworkMap = NULL;
|
21
|
85 |
FILE* fp = fopen(configFileLocationZ, "r");
|
25
|
86 |
|
19
|
87 |
if (fp == NULL)
|
|
88 |
{
|
21
|
89 |
createDefaultRules(configFileLocationC);
|
20
|
90 |
|
21
|
91 |
fp = fopen(configFileLocationC, "r");
|
19
|
92 |
}
|
|
93 |
|
|
94 |
if (fp != NULL)
|
|
95 |
{
|
25
|
96 |
while ((fgets(buffer, LINEWIDTH, fp) != NULL) && processedEntry)
|
|
97 |
{
|
19
|
98 |
/* keep looping until NULL pointer OR error... */
|
|
99 |
lineNumber++;
|
|
100 |
readSize = strlen(buffer);
|
|
101 |
/* Ignore comments line */
|
|
102 |
if (buffer[0] == '#')
|
|
103 |
continue;
|
|
104 |
|
|
105 |
/* Ignore replace "\r\n" with '\0' */
|
25
|
106 |
if ((readSize >= 2) && (buffer[readSize - 2] == '\r')
|
|
107 |
&& (buffer[readSize - 1] == '\n'))
|
|
108 |
buffer[readSize - 2] = '\0';
|
19
|
109 |
|
|
110 |
/* Ignore new line... */
|
|
111 |
if (readSize == 2)
|
|
112 |
continue;
|
|
113 |
|
25
|
114 |
processedEntry = processConfigEntry(buffer, ¤tMediaType,
|
|
115 |
¤tFrameworkType, ¤tTagType, &newNode,
|
|
116 |
&curNode);
|
19
|
117 |
if (newNode)
|
25
|
118 |
{
|
19
|
119 |
/*Just link to the last element in the chain*/
|
|
120 |
if (!frameworkMap)
|
25
|
121 |
{
|
19
|
122 |
frameworkMap = curNode;
|
25
|
123 |
}
|
19
|
124 |
else
|
25
|
125 |
{
|
19
|
126 |
FrameworkMap *lastNode = frameworkMap;
|
|
127 |
while (lastNode->next)
|
25
|
128 |
{
|
19
|
129 |
lastNode = lastNode->next;
|
25
|
130 |
}
|
|
131 |
lastNode->next = curNode;
|
19
|
132 |
}
|
|
133 |
}
|
|
134 |
}
|
25
|
135 |
fclose(fp);
|
19
|
136 |
}
|
|
137 |
else
|
25
|
138 |
{
|
19
|
139 |
printf("unable to open config file!\n");
|
25
|
140 |
}
|
|
141 |
return frameworkMap;
|
19
|
142 |
}
|
|
143 |
|
|
144 |
#ifdef _DEBUG
|
|
145 |
/* void XAFrameworkMgr_DumpFrameworkMap
|
|
146 |
* Description: Prints map to std console.
|
|
147 |
*/
|
|
148 |
void XAFrameworkMgr_DumpFrameworkMap(FrameworkMap *map)
|
25
|
149 |
{
|
19
|
150 |
FrameworkMap *node = map;
|
|
151 |
int i;
|
|
152 |
int loopIndex = 0;
|
|
153 |
while (node)
|
25
|
154 |
{
|
19
|
155 |
loopIndex++;
|
|
156 |
printf("%d>", loopIndex);
|
|
157 |
if (node->moType == FWMgrMOPlayer)
|
|
158 |
printf("MediaPlayer-");
|
|
159 |
else if (node->moType == FWMgrMORecorder)
|
|
160 |
printf("MediaRecrdr-");
|
|
161 |
else
|
|
162 |
printf("UKNOWN-");
|
|
163 |
if (node->fwType == FWMgrFWMMF)
|
|
164 |
printf("MMF-");
|
|
165 |
else if (node->fwType == FWMgrFWGST)
|
|
166 |
printf("GST-");
|
|
167 |
else
|
|
168 |
printf("UKNOWN-");
|
|
169 |
printf("Scheme[");
|
25
|
170 |
for (i = 0; i < node->uriSchemeCount; i++)
|
19
|
171 |
printf(" %s", node->uriSchemes[i]);
|
|
172 |
printf("]FileExt[");
|
25
|
173 |
for (i = 0; i < node->fileExtCount; i++)
|
19
|
174 |
printf(" %s", node->fileExts[i]);
|
|
175 |
printf("]\n");
|
|
176 |
node = node->next;
|
25
|
177 |
}
|
19
|
178 |
}
|
|
179 |
#endif
|
|
180 |
|
|
181 |
/* void XAFrameworkMgr_DeleteFrameworkMap
|
|
182 |
* Description: Deletes the list of framework and use-case map.
|
|
183 |
*/
|
|
184 |
void XAFrameworkMgr_DeleteFrameworkMap(FrameworkMap **map)
|
25
|
185 |
{
|
19
|
186 |
FrameworkMap *node = *map;
|
|
187 |
FrameworkMap *nextNode = NULL;
|
|
188 |
int i;
|
|
189 |
while (node)
|
25
|
190 |
{
|
|
191 |
for (i = 0; i < node->uriSchemeCount; i++)
|
|
192 |
free(node->uriSchemes[i]);
|
|
193 |
free(node->uriSchemes);
|
19
|
194 |
|
25
|
195 |
for (i = 0; i < node->fileExtCount; i++)
|
|
196 |
free(node->fileExts[i]);
|
|
197 |
free(node->fileExts);
|
19
|
198 |
|
|
199 |
nextNode = node->next;
|
25
|
200 |
free(node);
|
19
|
201 |
node = nextNode;
|
25
|
202 |
}
|
|
203 |
*map = NULL;
|
19
|
204 |
}
|
|
205 |
|
|
206 |
/* FWMgrFwType XAFrameworkMgr_GetFramework
|
|
207 |
* Description: Returns the framework enum that handles uri.
|
|
208 |
*/
|
25
|
209 |
FWMgrFwType XAFrameworkMgr_GetFramework(FrameworkMap *map, const char *uri,
|
|
210 |
FWMgrMOType mediaObject)
|
|
211 |
{
|
19
|
212 |
FWMgrFwType retVal = FWMgrFWUknown;
|
|
213 |
char fileScheme[] = "file";
|
|
214 |
char *uriScheme = NULL;
|
|
215 |
char *fileExt = NULL;
|
|
216 |
FrameworkMap *node = map;
|
|
217 |
FWMgrBool uriMatchFound = FWMgrFalse;
|
|
218 |
FWMgrBool fileExtMatchFound = FWMgrFalse;
|
|
219 |
int i = 0;
|
|
220 |
int copyLen = 0;
|
|
221 |
|
|
222 |
if (!map || !uri)
|
25
|
223 |
{
|
19
|
224 |
/* TODO Log invalid uri */
|
|
225 |
return retVal;
|
25
|
226 |
}
|
19
|
227 |
|
|
228 |
/* Get uri scheme */
|
|
229 |
uriScheme = strchr(uri, ':');
|
25
|
230 |
if (uriScheme == NULL)
|
|
231 |
{
|
19
|
232 |
/* TODO Log invalid uri */
|
|
233 |
return retVal;
|
25
|
234 |
}
|
19
|
235 |
|
|
236 |
copyLen = (uriScheme - uri);
|
25
|
237 |
uriScheme = (char*) calloc(copyLen + 1, sizeof(char));
|
19
|
238 |
strncpy(uriScheme, uri, copyLen);
|
|
239 |
uriScheme[copyLen] = '\0'; /*Null terminate it*/
|
|
240 |
|
|
241 |
if (strcasecmp(uriScheme, fileScheme) == 0)
|
25
|
242 |
{
|
19
|
243 |
/* Get uri extension */
|
|
244 |
char* dotLoc = strrchr(uri, '.');
|
25
|
245 |
if (dotLoc == NULL)
|
|
246 |
{
|
19
|
247 |
/* TODO Log invalid uri */
|
|
248 |
free(uriScheme);
|
|
249 |
return retVal;
|
25
|
250 |
}
|
19
|
251 |
/* We need to add 1 to exclude '.'*/
|
|
252 |
copyLen = strlen(uri) - (dotLoc + 1 - uri);
|
25
|
253 |
fileExt = (char*) calloc(copyLen + 1, sizeof(char));
|
19
|
254 |
strncpy(fileExt, dotLoc + 1, copyLen);
|
|
255 |
fileExt[copyLen] = '\0'; /*Null terminate it*/
|
25
|
256 |
}
|
19
|
257 |
|
|
258 |
while (node)
|
25
|
259 |
{
|
19
|
260 |
if (mediaObject == node->moType)
|
|
261 |
{
|
|
262 |
uriMatchFound = FWMgrFalse;
|
|
263 |
fileExtMatchFound = FWMgrFalse;
|
|
264 |
/* Match for uri*/
|
25
|
265 |
for (i = 0; i < node->uriSchemeCount; i++)
|
|
266 |
{
|
19
|
267 |
if (strcasecmp(uriScheme, node->uriSchemes[i]) == 0)
|
|
268 |
{
|
25
|
269 |
uriMatchFound = FWMgrTrue;
|
|
270 |
break;
|
19
|
271 |
}
|
25
|
272 |
}
|
19
|
273 |
/* if uri scheme is not file, we only need to check for uri */
|
|
274 |
if (!fileExt)
|
25
|
275 |
{
|
19
|
276 |
fileExtMatchFound = FWMgrTrue;
|
25
|
277 |
}
|
19
|
278 |
else
|
|
279 |
{
|
25
|
280 |
for (i = 0; i < node->fileExtCount; i++)
|
|
281 |
{
|
19
|
282 |
if (strcasecmp(fileExt, node->fileExts[i]) == 0)
|
25
|
283 |
{
|
19
|
284 |
fileExtMatchFound = FWMgrTrue;
|
|
285 |
break;
|
25
|
286 |
}
|
19
|
287 |
}
|
|
288 |
}
|
|
289 |
|
25
|
290 |
if ((uriMatchFound == FWMgrTrue) && (fileExtMatchFound
|
|
291 |
== FWMgrTrue))
|
19
|
292 |
{
|
25
|
293 |
retVal = node->fwType;
|
|
294 |
break;
|
19
|
295 |
}
|
|
296 |
}
|
|
297 |
node = node->next;
|
25
|
298 |
}
|
19
|
299 |
free(uriScheme);
|
|
300 |
free(fileExt);
|
|
301 |
return retVal;
|
25
|
302 |
}
|
19
|
303 |
|
|
304 |
/* Local functions */
|
|
305 |
|
|
306 |
/* FWMgrBool processConfigEntry
|
|
307 |
* Description: Processes a single line entry from the config file.
|
|
308 |
*/
|
25
|
309 |
FWMgrBool processConfigEntry(const char* buffer, FWMgrMOType *mediaType,
|
|
310 |
FWMgrFwType *frameworkType, FWMgrTagType *tagType,
|
|
311 |
FWMgrBool *newNode, FrameworkMap **node)
|
|
312 |
{
|
19
|
313 |
FWMgrBool processedSuccessfully = FWMgrTrue;
|
25
|
314 |
|
|
315 |
if (!buffer || !mediaType || !frameworkType || !tagType || !newNode)
|
|
316 |
{
|
|
317 |
processedSuccessfully = FWMgrFalse;
|
|
318 |
return processedSuccessfully;
|
|
319 |
}
|
|
320 |
|
|
321 |
*newNode = FWMgrFalse;
|
19
|
322 |
switch (*mediaType)
|
25
|
323 |
{
|
19
|
324 |
case FWMgrMOUnknown:
|
25
|
325 |
{
|
19
|
326 |
if (strcmp(buffer, mediaPlayerBeginTag) == 0)
|
25
|
327 |
{
|
19
|
328 |
*mediaType = FWMgrMOPlayer;
|
|
329 |
*frameworkType = FWMgrFWUknown;
|
|
330 |
*tagType = FWMgrTagNone;
|
|
331 |
*node = NULL;
|
25
|
332 |
}
|
19
|
333 |
else if (strcmp(buffer, mediaRecorderBeginTag) == 0)
|
25
|
334 |
{
|
19
|
335 |
*mediaType = FWMgrMORecorder;
|
|
336 |
*frameworkType = FWMgrFWUknown;
|
|
337 |
*tagType = FWMgrTagNone;
|
|
338 |
*node = NULL;
|
25
|
339 |
}
|
19
|
340 |
}
|
|
341 |
break;
|
|
342 |
case FWMgrMOPlayer:
|
|
343 |
case FWMgrMORecorder:
|
25
|
344 |
{
|
19
|
345 |
switch (*frameworkType)
|
|
346 |
{
|
25
|
347 |
case FWMgrFWUknown:
|
|
348 |
{
|
|
349 |
if ((*mediaType == FWMgrMOPlayer) && (strcmp(buffer,
|
|
350 |
mediaPlayerEndTag) == 0))
|
19
|
351 |
*mediaType = FWMgrMOUnknown;
|
25
|
352 |
else if ((*mediaType == FWMgrMORecorder) && (strcmp(
|
|
353 |
buffer, mediaRecorderEndTag) == 0))
|
|
354 |
*mediaType = FWMgrMOUnknown;
|
|
355 |
else if ((strcmp(buffer, mediaFrameworkMmfBeginTag) == 0)
|
|
356 |
|| (strcmp(buffer, mediaFrameworkGstBeginTag)
|
|
357 |
== 0))
|
|
358 |
{
|
|
359 |
|
19
|
360 |
*frameworkType = FWMgrFWMMF;
|
|
361 |
if (strcmp(buffer, mediaFrameworkGstBeginTag) == 0)
|
|
362 |
*frameworkType = FWMgrFWGST;
|
|
363 |
if (*node)
|
25
|
364 |
{
|
|
365 |
printf(
|
|
366 |
"Fatal error error. Entry already exists and creating another one!!!");
|
|
367 |
processedSuccessfully = FWMgrFalse;
|
|
368 |
}
|
|
369 |
else
|
|
370 |
{
|
|
371 |
*node = (FrameworkMap*) calloc(1,
|
|
372 |
sizeof(FrameworkMap));
|
|
373 |
if (!(*node))
|
|
374 |
{
|
|
375 |
printf(
|
|
376 |
"Fatal error. No memory to create an Entry!!!");
|
|
377 |
processedSuccessfully = FWMgrFalse;
|
|
378 |
}
|
|
379 |
else
|
|
380 |
{
|
|
381 |
*newNode = FWMgrTrue;
|
|
382 |
(*node)->moType = *mediaType;
|
|
383 |
(*node)->fwType = *frameworkType;
|
|
384 |
}
|
|
385 |
}
|
19
|
386 |
}
|
|
387 |
}
|
|
388 |
break;
|
|
389 |
case FWMgrFWMMF:
|
25
|
390 |
{
|
|
391 |
processedSuccessfully = processTagType(buffer,
|
|
392 |
frameworkType, tagType, node);
|
|
393 |
}
|
19
|
394 |
break;
|
|
395 |
case FWMgrFWGST:
|
25
|
396 |
{
|
|
397 |
processedSuccessfully = processTagType(buffer,
|
|
398 |
frameworkType, tagType, node);
|
|
399 |
}
|
19
|
400 |
break;
|
|
401 |
default:
|
|
402 |
processedSuccessfully = FWMgrFalse;
|
|
403 |
break;
|
25
|
404 |
};
|
|
405 |
}
|
19
|
406 |
break;
|
|
407 |
default:
|
|
408 |
processedSuccessfully = FWMgrFalse;
|
|
409 |
break;
|
25
|
410 |
};
|
19
|
411 |
return processedSuccessfully;
|
25
|
412 |
}
|
19
|
413 |
|
|
414 |
/* FWMgrBool processTagType
|
25
|
415 |
* Description: Processes a framework type, uri, file tags entry from
|
|
416 |
* the config file.
|
19
|
417 |
*/
|
25
|
418 |
FWMgrBool processTagType(const char* buffer, FWMgrFwType *frameworkType,
|
|
419 |
FWMgrTagType *tagType, FrameworkMap **node)
|
|
420 |
{
|
19
|
421 |
FWMgrBool processedSuccessfully = FWMgrTrue;
|
25
|
422 |
|
|
423 |
if (!buffer || !frameworkType || !tagType || (*node == NULL))
|
19
|
424 |
{
|
25
|
425 |
processedSuccessfully = FWMgrFalse;
|
|
426 |
return processedSuccessfully;
|
|
427 |
}
|
|
428 |
|
|
429 |
switch (*tagType)
|
|
430 |
{
|
|
431 |
case FWMgrTagNone:
|
19
|
432 |
{
|
25
|
433 |
if (((*frameworkType == FWMgrFWMMF) && (strcmp(buffer,
|
|
434 |
mediaFrameworkMmfEndTag) == 0)) || ((*frameworkType
|
|
435 |
== FWMgrFWGST)
|
|
436 |
&& (strcmp(buffer, mediaFrameworkGstEndTag) == 0)))
|
|
437 |
{
|
19
|
438 |
*node = NULL;
|
|
439 |
*frameworkType = FWMgrFWUknown;
|
25
|
440 |
}
|
19
|
441 |
else if (strcmp(buffer, uriSchemeBeginTag) == 0)
|
|
442 |
*tagType = FWMgrTagURIScheme;
|
|
443 |
else if (strcmp(buffer, fileExtBeginTag) == 0)
|
|
444 |
*tagType = FWMgrTagFileExt;
|
25
|
445 |
}
|
19
|
446 |
break;
|
|
447 |
case FWMgrTagURIScheme:
|
25
|
448 |
{
|
19
|
449 |
if (strcmp(buffer, uriSchemeEndTag) == 0)
|
|
450 |
*tagType = FWMgrTagNone;
|
|
451 |
else
|
25
|
452 |
{
|
19
|
453 |
processedSuccessfully = FWMgrFalse;
|
|
454 |
if (*node)
|
25
|
455 |
processedSuccessfully = tokenizeTag(FWMgrTagURIScheme,
|
|
456 |
buffer, node);
|
|
457 |
}
|
19
|
458 |
}
|
|
459 |
break;
|
|
460 |
case FWMgrTagFileExt:
|
25
|
461 |
{
|
19
|
462 |
if (strcmp(buffer, fileExtEndTag) == 0)
|
|
463 |
*tagType = FWMgrTagNone;
|
|
464 |
else
|
25
|
465 |
{
|
19
|
466 |
processedSuccessfully = FWMgrFalse;
|
|
467 |
if (*node)
|
25
|
468 |
processedSuccessfully = tokenizeTag(FWMgrTagFileExt,
|
|
469 |
buffer, node);
|
|
470 |
}
|
19
|
471 |
}
|
|
472 |
break;
|
|
473 |
default:
|
25
|
474 |
processedSuccessfully = FWMgrFalse;
|
19
|
475 |
break;
|
25
|
476 |
};
|
19
|
477 |
return processedSuccessfully;
|
25
|
478 |
}
|
19
|
479 |
|
|
480 |
/* FWMgrBool processTagType
|
25
|
481 |
* Description: Processes a framework type, uri, file tags entry from
|
|
482 |
* the config file.
|
19
|
483 |
*/
|
25
|
484 |
FWMgrBool tokenizeTag(FWMgrTagType tagType, const char* buffer,
|
|
485 |
FrameworkMap **node)
|
|
486 |
{
|
|
487 |
char* tempStartPtr;
|
|
488 |
char* tempEndPtr;
|
19
|
489 |
int index = 0;
|
|
490 |
int strLen = 0;
|
|
491 |
|
25
|
492 |
if (!buffer || (*node == NULL))
|
|
493 |
{
|
|
494 |
return FWMgrFalse;
|
|
495 |
}
|
|
496 |
|
|
497 |
tempStartPtr = /*const_cast<char*>*/(char*) (buffer);
|
|
498 |
tempEndPtr = /*const_cast<char*>*/(char*) (buffer);
|
|
499 |
|
19
|
500 |
if (tagType == FWMgrTagURIScheme)
|
25
|
501 |
{
|
19
|
502 |
(*node)->uriSchemeCount = atoi(buffer);
|
25
|
503 |
(*node)->uriSchemes = (char**) calloc((*node)->uriSchemeCount,
|
|
504 |
sizeof(*((*node)->uriSchemes)));
|
19
|
505 |
if (!(*node)->uriSchemes)
|
25
|
506 |
{
|
19
|
507 |
printf("Fatal error. No memory to create an Entry!!!");
|
|
508 |
return FWMgrFalse;
|
25
|
509 |
}
|
19
|
510 |
}
|
|
511 |
else if (tagType == FWMgrTagFileExt)
|
25
|
512 |
{
|
19
|
513 |
(*node)->fileExtCount = atoi(buffer);
|
25
|
514 |
(*node)->fileExts = (char**) calloc((*node)->fileExtCount,
|
|
515 |
sizeof(*((*node)->fileExts)));
|
19
|
516 |
if (!(*node)->fileExts)
|
25
|
517 |
{
|
19
|
518 |
printf("Fatal error. No memory to create an Entry!!!");
|
|
519 |
return FWMgrFalse;
|
25
|
520 |
}
|
19
|
521 |
}
|
|
522 |
else
|
|
523 |
return FWMgrFalse;
|
|
524 |
|
|
525 |
/*Find the index of :*/
|
|
526 |
tempStartPtr = strchr(tempStartPtr, ',');
|
|
527 |
index = 0;
|
|
528 |
while (tempStartPtr && (strlen(tempStartPtr) > 1))
|
25
|
529 |
{
|
19
|
530 |
tempStartPtr++; /* Ignore separator ','*/
|
|
531 |
tempEndPtr = strchr(tempStartPtr, ',');
|
|
532 |
strLen = (tempEndPtr - tempStartPtr) + 1; /* To hold null terminator */
|
|
533 |
if (strLen > 0)
|
25
|
534 |
{
|
19
|
535 |
if (tagType == FWMgrTagURIScheme)
|
25
|
536 |
{
|
|
537 |
(*node)->uriSchemes[index] = (char*) calloc(strLen,
|
|
538 |
sizeof(char));
|
19
|
539 |
strncpy((*node)->uriSchemes[index], tempStartPtr, strLen);
|
25
|
540 |
(*node)->uriSchemes[index][strLen - 1] = '\0'; /*Null terminate it*/
|
19
|
541 |
index++;
|
25
|
542 |
}
|
19
|
543 |
else if (tagType == FWMgrTagFileExt)
|
25
|
544 |
{
|
|
545 |
(*node)->fileExts[index] = (char*) calloc(strLen,
|
|
546 |
sizeof(char));
|
19
|
547 |
strncpy((*node)->fileExts[index], tempStartPtr, strLen);
|
25
|
548 |
(*node)->fileExts[index][strLen - 1] = '\0'; /*Null terminate it*/
|
19
|
549 |
index++;
|
25
|
550 |
}
|
19
|
551 |
}
|
25
|
552 |
tempStartPtr = tempEndPtr;
|
19
|
553 |
}
|
25
|
554 |
return FWMgrTrue;
|
19
|
555 |
}
|
|
556 |
|
|
557 |
int createDefaultRules(const char * filename)
|
25
|
558 |
{
|
19
|
559 |
FILE* fp = fopen(filename, "w");
|
|
560 |
if (fp == NULL)
|
|
561 |
return /*KErrAccessDenied*/-21;
|
|
562 |
fputs("#/*\r\n", fp);
|
25
|
563 |
fputs(
|
|
564 |
"#* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\r\n",
|
|
565 |
fp);
|
19
|
566 |
fputs("#* All rights reserved.\r\n", fp);
|
25
|
567 |
fputs(
|
|
568 |
"#* This component and the accompanying materials are made available\r\n",
|
|
569 |
fp);
|
19
|
570 |
fputs("#* under the terms of \"Eclipse Public License v1.0\"\r\n", fp);
|
|
571 |
fputs("#* which accompanies this distribution, and is available\r\n", fp);
|
25
|
572 |
fputs("#* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\r\n",
|
|
573 |
fp);
|
19
|
574 |
fputs("#*\r\n", fp);
|
|
575 |
fputs("#* Initial Contributors:\r\n", fp);
|
|
576 |
fputs("#* Nokia Corporation - initial contribution.\r\n", fp);
|
|
577 |
fputs("#*\r\n", fp);
|
|
578 |
fputs("#* Contributors:\r\n", fp);
|
|
579 |
fputs("#*\r\n", fp);
|
25
|
580 |
fputs("#* Description:\r\n", fp);
|
19
|
581 |
fputs("#*\r\n", fp);
|
|
582 |
fputs("#*/\r\n", fp);
|
25
|
583 |
fputs(
|
|
584 |
"#============================================================================>|\r\n",
|
|
585 |
fp);
|
|
586 |
fputs(
|
|
587 |
"# Must not exceed 80 chars each line=========================================>|\r\n",
|
|
588 |
fp);
|
|
589 |
fputs(
|
|
590 |
"#============================================================================>|\r\n",
|
|
591 |
fp);
|
19
|
592 |
fputs("<mediaplayer>\r\n", fp);
|
|
593 |
fputs("<mmf>\r\n", fp);
|
|
594 |
fputs("<urischeme>\r\n", fp);
|
25
|
595 |
fputs(
|
|
596 |
"# Num of entries followed by actual entries all ending with a comma\r\n",
|
|
597 |
fp);
|
21
|
598 |
fputs("6,file,http,rtsp,rtspu,rtspt,mms,\r\n", fp);
|
19
|
599 |
fputs("</urischeme>\r\n", fp);
|
|
600 |
fputs("<fileext>\r\n", fp);
|
25
|
601 |
fputs(
|
|
602 |
"15,3gp,wma,wmv,wav,amr,mp3,mp4,rm,ra,avi,mkv,aac,mid,awb,3g2,\r\n",
|
|
603 |
fp);
|
19
|
604 |
fputs("</fileext>\r\n", fp);
|
|
605 |
fputs("</mmf>\r\n", fp);
|
|
606 |
fputs("</mediaplayer>\r\n", fp);
|
|
607 |
fputs("<mediarecorder>\r\n", fp);
|
|
608 |
fputs("<gst>\r\n", fp);
|
|
609 |
fputs("<urischeme>\r\n", fp);
|
25
|
610 |
fputs(
|
|
611 |
"# Num of entries followed by actual entries all ending with a comma\r\n",
|
|
612 |
fp);
|
19
|
613 |
fputs("1,file,\r\n", fp);
|
|
614 |
fputs("</urischeme>\r\n", fp);
|
|
615 |
fputs("<fileext>\r\n", fp);
|
|
616 |
fputs("3,wav,amr,mp4,\r\n", fp);
|
|
617 |
fputs("</fileext>\r\n", fp);
|
|
618 |
fputs("</gst>\r\n", fp);
|
|
619 |
fputs("</mediarecorder>\r\n", fp);
|
|
620 |
fclose(fp);
|
|
621 |
return 0;
|
25
|
622 |
}
|