1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
|
/*
* Media Server
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* This file defines api utilities of contents manager engines.
*
* @file media-server-db-svc.c
* @author Yong Yeon Kim(yy9875.kim@samsung.com)
* @version 1.0
* @brief This file implements main database operation.
*/
#include <dlfcn.h>
#include "media-util.h"
#include "media-common-utils.h"
#include "media-scanner-dbg.h"
#include "media-scanner-db-svc.h"
#define CONFIG_PATH "/usr/etc/media-server-plugin"
#define EXT ".so"
#define EXT_LEN 3
#define MSC_REGISTER_COUNT 100 /*For bundle commit*/
#define MSC_VALID_COUNT 100 /*For bundle commit*/
GMutex * db_mutex;
GArray *so_array;
void ***func_array;
int lib_num;
void **scan_func_handle = NULL; /*dlopen handel*/
extern int insert_count;
enum func_list {
eCONNECT,
eDISCONNECT,
eEXIST,
eINSERT_BEGIN,
eINSERT_END,
eINSERT_BATCH,
eINSERT_ITEM_IMMEDIATELY,
eSET_ALL_VALIDITY,
eSET_VALIDITY_BEGIN,
eSET_VALIDITY_END,
eSET_VALIDITY,
eDELETE_ALL,
eDELETE_INVALID_ITEMS,
eUPDATE_BEGIN,
eUPDATE_END,
eSET_FOLDER_VALIDITY,
eDELETE_FOLDER,
eINSERT_BURST,
eSEND_DIR_UPDATE_NOTI,
eCOUNT_DELETE_ITEMS_IN_FOLDER,
eDELETE_ITEM,
eGET_FOLDER_LIST,
eUPDATE_FOLDER_TIME,
eUPDATE_ITEM_META,
eUPDATE_ITEM_BEGIN,
eUPDATE_ITEM_END,
eFUNC_MAX
};
static int
_msc_token_data(char *buf, char **name)
{
int len;
char* pos = NULL;
pos = strstr(buf, EXT);
if (pos == NULL) {
MSC_DBG_ERR("This is not shared object library.");
name = NULL;
return -1;
} else {
len = pos - buf + EXT_LEN;
*name = strndup(buf, len);
}
return 0;
}
static bool
_msc_load_config()
{
int ret;
FILE *fp;
char *so_name = NULL;
char buf[256] = {0};
fp = fopen(CONFIG_PATH, "rt");
if (fp == NULL) {
MSC_DBG_ERR("fp is NULL");
return MS_MEDIA_ERR_FILE_OPEN_FAIL;
}
while(1) {
if (fgets(buf, 256, fp) == NULL)
break;
ret = _msc_token_data(buf, &so_name);
if (ret == 0) {
/*add to array*/
g_array_append_val(so_array, so_name);
so_name = NULL;
}
}
fclose(fp);
return MS_MEDIA_ERR_NONE;
}
int
msc_load_functions(void)
{
int lib_index = 0, func_index;
char func_list[eFUNC_MAX][40] = {
"connect_db",
"disconnect_db",
"check_item_exist",
"insert_item_begin",
"insert_item_end",
"insert_item",
"insert_item_immediately",
"set_all_storage_items_validity",
"set_item_validity_begin",
"set_item_validity_end",
"set_item_validity",
"delete_all_items_in_storage",
"delete_all_invalid_items_in_storage",
"update_begin",
"update_end",
"set_folder_item_validity",
"delete_all_invalid_items_in_folder",
"insert_burst_item",
"send_dir_update_noti",
"count_delete_items_in_folder",
"delete_item",
"get_folder_list",
"update_folder_time",
"update_item_meta",
"update_item_begin",
"update_item_end",
};
/*init array for adding name of so*/
so_array = g_array_new(FALSE, FALSE, sizeof(char*));
/*load information of so*/
_msc_load_config();
if(so_array->len == 0) {
MSC_DBG_ERR("There is no information for functions");
return MS_MEDIA_ERR_DYNAMIC_LINK;
}
/*the number of functions*/
lib_num = so_array->len;
MSC_DBG_SLOG("The number of information of so : %d", lib_num);
MS_MALLOC(scan_func_handle, sizeof(void*) * lib_num);
if (scan_func_handle == NULL) {
MSC_DBG_ERR("malloc failed");
return MS_MEDIA_ERR_ALLOCATE_MEMORY_FAIL;
}
while(lib_index < lib_num) {
/*get handle*/
MSC_DBG_SLOG("[name of so : %s]", g_array_index(so_array, char*, lib_index));
scan_func_handle[lib_index] = dlopen(g_array_index(so_array, char*, lib_index), RTLD_LAZY);
if (!scan_func_handle[lib_index]) {
MSC_DBG_ERR("%s", dlerror());
MS_SAFE_FREE(scan_func_handle);
return MS_MEDIA_ERR_DYNAMIC_LINK;
}
lib_index++;
}
dlerror(); /* Clear any existing error */
/*allocate for array of functions*/
MS_MALLOC(func_array, sizeof(void**) * lib_num);
if (func_array == NULL) {
MSC_DBG_ERR("malloc failed");
MS_SAFE_FREE(scan_func_handle);
return MS_MEDIA_ERR_ALLOCATE_MEMORY_FAIL;
}
for(lib_index = 0 ; lib_index < lib_num; lib_index ++) {
MS_MALLOC(func_array[lib_index], sizeof(void*) * eFUNC_MAX);
if (func_array[lib_index] == NULL) {
int index;
for (index = 0; index < lib_index; index ++) {
MS_SAFE_FREE(func_array[index]);
}
MS_SAFE_FREE(func_array);
MS_SAFE_FREE(scan_func_handle);
MSC_DBG_ERR("malloc failed");
return MS_MEDIA_ERR_ALLOCATE_MEMORY_FAIL;
}
}
/*add functions to array */
for (lib_index = 0; lib_index < lib_num; lib_index++) {
for (func_index = 0; func_index < eFUNC_MAX ; func_index++) {
func_array[lib_index][func_index] = dlsym(scan_func_handle[lib_index], func_list[func_index]);
if (func_array[lib_index][func_index] == NULL) {
int index;
for (index = 0; index < lib_index; index ++) {
MS_SAFE_FREE(func_array[index]);
}
MS_SAFE_FREE(func_array);
MS_SAFE_FREE(scan_func_handle);
MSC_DBG_ERR("dlsym failed [%s]", func_list[func_index]);
return MS_MEDIA_ERR_DYNAMIC_LINK;
}
}
}
return MS_MEDIA_ERR_NONE;
}
void
msc_unload_functions(void)
{
int lib_index;
for (lib_index = 0; lib_index < lib_num; lib_index ++)
dlclose(scan_func_handle[lib_index]);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
if (func_array[lib_index]) {
MS_SAFE_FREE(func_array[lib_index]);
}
}
MS_SAFE_FREE (func_array);
MS_SAFE_FREE (scan_func_handle);
if (so_array) g_array_free(so_array, TRUE);
}
int
msc_connect_db(void ***handle)
{
int lib_index;
int ret;
char * err_msg = NULL;
/*Lock mutex for openning db*/
g_mutex_lock(db_mutex);
MS_MALLOC(*handle, sizeof (void*) * lib_num);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((CONNECT)func_array[lib_index][eCONNECT])(&((*handle)[lib_index]), &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
g_mutex_unlock(db_mutex);
return MS_MEDIA_ERR_DB_CONNECT_FAIL;
}
}
MSC_DBG_INFO("connect Media DB");
g_mutex_unlock(db_mutex);
return MS_MEDIA_ERR_NONE;
}
int
msc_disconnect_db(void ***handle)
{
int lib_index;
int ret;
char * err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((DISCONNECT)func_array[lib_index][eDISCONNECT])((*handle)[lib_index], &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return MS_MEDIA_ERR_DB_DISCONNECT_FAIL;
}
}
MS_SAFE_FREE(*handle);
MSC_DBG_INFO("Disconnect Media DB");
return MS_MEDIA_ERR_NONE;
}
int
msc_validate_item(void **handle, const char *path)
{
int lib_index;
int res = MS_MEDIA_ERR_NONE;
int ret;
char *err_msg = NULL;
bool modified = FALSE;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
/*check exist in Media DB, If file is not exist, insert data in DB. */
ret = ((CHECK_ITEM_EXIST)func_array[lib_index][eEXIST])(handle[lib_index], path, &modified, &err_msg); /*dlopen*/
if (ret != 0) {
MS_SAFE_FREE(err_msg);
ret = msc_insert_item_batch(handle, path);
if (ret != 0) {
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
} else {
insert_count++;
}
} else {
if (modified == FALSE) {
/*if meta data of file exist, change valid field to "1" */
ret = ((SET_ITEM_VALIDITY)func_array[lib_index][eSET_VALIDITY])(handle[lib_index], path, true, true, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_UPDATE_FAIL;
}
} else {
/* the file has same name but it is changed, so we have to update DB */
MSC_DBG_WAN("DELETE ITEM [%s]", path);
ret = ((DELETE_ITEM)func_array[lib_index][eDELETE_ITEM])(handle[lib_index], path, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_DELETE_FAIL;
} else {
ret = msc_insert_item_batch(handle, path);
if (ret != 0) {
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
} else {
insert_count++;
}
}
}
}
}
return res;
}
int
msc_validaty_change_all_items(void **handle, ms_storage_type_t store_type, bool validity)
{
int lib_index;
int res = MS_MEDIA_ERR_NONE;
int ret;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((SET_ALL_STORAGE_ITEMS_VALIDITY)func_array[lib_index][eSET_ALL_VALIDITY])(handle[lib_index], store_type, validity, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_UPDATE_FAIL;
}
}
return res;
}
int
msc_insert_item_batch(void **handle, const char *path)
{
int lib_index;
int res = MS_MEDIA_ERR_NONE;
int ret;
char *err_msg = NULL;
ms_storage_type_t storage_type;
storage_type = ms_get_storage_type_by_full(path);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((INSERT_ITEM)func_array[lib_index][eINSERT_BATCH])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
}
}
return res;
}
int
msc_insert_item_immediately(void **handle, const char *path)
{
int lib_index;
int res = MS_MEDIA_ERR_NONE;
int ret;
char *err_msg = NULL;
ms_storage_type_t storage_type;
storage_type = ms_get_storage_type_by_full(path);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((INSERT_ITEM_IMMEDIATELY)func_array[lib_index][eINSERT_ITEM_IMMEDIATELY])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
}
}
return res;
}
int
msc_insert_burst_item(void **handle, const char *path)
{
int lib_index;
int res = MS_MEDIA_ERR_NONE;
int ret;
char *err_msg = NULL;
ms_storage_type_t storage_type;
storage_type = ms_get_storage_type_by_full(path);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((INSERT_BURST_ITEM)func_array[lib_index][eINSERT_BURST])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
}
}
return res;
}
bool
msc_delete_all_items(void **handle, ms_storage_type_t store_type)
{
int lib_index;
int ret = 0;
char *err_msg = NULL;
/* To reset media db when differnet mmc is inserted. */
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((DELETE_ALL_ITEMS_IN_STORAGE)func_array[lib_index][eDELETE_ALL])(handle[lib_index], store_type, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return false;
}
}
return true;
}
bool
msc_delete_invalid_items(void **handle, ms_storage_type_t store_type)
{
int lib_index;
int ret;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((DELETE_ALL_INVALID_ITMES_IN_STORAGE)func_array[lib_index][eDELETE_INVALID_ITEMS])(handle[lib_index], store_type, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return false;
}
}
return true;
}
int
msc_set_folder_validity(void **handle, const char *path, int validity, int recursive)
{
int lib_index;
int ret;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((SET_FOLDER_ITEM_VALIDITY)func_array[lib_index][eSET_FOLDER_VALIDITY])(handle[lib_index], path, validity, recursive,&err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return MS_MEDIA_ERR_DB_UPDATE_FAIL;
}
}
return MS_MEDIA_ERR_NONE;
}
int
msc_delete_invalid_items_in_folder(void **handle, const char*path)
{
int lib_index;
int ret;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((DELETE_ALL_INVALID_ITEMS_IN_FOLDER)func_array[lib_index][eDELETE_FOLDER])(handle[lib_index], path, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return MS_MEDIA_ERR_DB_UPDATE_FAIL;
}
}
return MS_MEDIA_ERR_NONE;
}
int
msc_send_dir_update_noti(void **handle, const char*path)
{
int lib_index;
int ret;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((SEND_DIR_UPDATE_NOTI)func_array[lib_index][eSEND_DIR_UPDATE_NOTI])(handle[lib_index], path, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return MS_MEDIA_ERR_SEND_NOTI_FAIL;
}
}
return MS_MEDIA_ERR_NONE;
}
int
msc_count_delete_items_in_folder(void **handle, const char*path, int *count)
{
int lib_index;
int ret;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((COUNT_DELETE_ITEMS_IN_FOLDER)func_array[lib_index][eCOUNT_DELETE_ITEMS_IN_FOLDER])(handle[lib_index], path, count, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return MS_MEDIA_ERR_INTERNAL;
}
}
return MS_MEDIA_ERR_NONE;
}
int
msc_get_folder_list(void **handle, char* start_path, GArray **dir_array)
{
int lib_index;
int ret;
char *err_msg = NULL;
char **folder_list = NULL;
int *modified_time_list = NULL;
int *item_num_list = NULL;
int count = 0;
int i = 0;
msc_dir_info_s* dir_info = NULL;
MSC_DBG_ERR("start path: %s", start_path);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((GET_FOLDER_LIST)func_array[lib_index][eGET_FOLDER_LIST])(handle[lib_index], start_path, &folder_list, &modified_time_list, &item_num_list, &count, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return MS_MEDIA_ERR_INTERNAL;
}
}
MSC_DBG_ERR("OK");
*dir_array = g_array_new(FALSE, FALSE, sizeof(msc_dir_info_s*));
if (count != 0) {
for(i = 0; i < count; i ++) {
dir_info = malloc(sizeof(msc_dir_info_s));
dir_info->dir_path = strdup(folder_list[i]);
dir_info->modified_time = modified_time_list[i];
dir_info->item_num = item_num_list[i];
g_array_append_val(*dir_array, dir_info);
MS_SAFE_FREE(folder_list[i]);
// MSC_DBG("%d get path : %s, %d", i, dir_info->dir_path, dir_info->modified_time);
}
}
MS_SAFE_FREE(folder_list);
MS_SAFE_FREE(modified_time_list);
return MS_MEDIA_ERR_NONE;
}
int
msc_update_folder_time(void **handle, char *folder_path)
{
int lib_index;
int ret;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((UPDATE_FOLDER_TIME)func_array[lib_index][eUPDATE_FOLDER_TIME])(handle[lib_index], folder_path, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
return MS_MEDIA_ERR_INTERNAL;
}
}
return MS_MEDIA_ERR_NONE;
}
int
msc_update_meta_batch(void **handle, const char *path)
{
int lib_index;
int res = MS_MEDIA_ERR_NONE;
int ret;
char *err_msg = NULL;
ms_storage_type_t storage_type;
storage_type = ms_get_storage_type_by_full(path);
MSC_DBG_ERR("");
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((UPDATE_ITEM_META)func_array[lib_index][eUPDATE_ITEM_META])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
}
}
return res;
}
/****************************************************************************************************
FOR BULK COMMIT
*****************************************************************************************************/
void
msc_register_start(void **handle, ms_noti_status_e noti_status, int pid)
{
int lib_index;
int ret = 0;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((INSERT_ITEM_BEGIN)func_array[lib_index][eINSERT_BEGIN])(handle[lib_index], MSC_REGISTER_COUNT, noti_status, pid, &err_msg);/*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
}
}
}
void
msc_register_end(void **handle)
{
int lib_index;
int ret = 0;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((INSERT_ITEM_END)func_array[lib_index][eINSERT_END])(handle[lib_index], &err_msg);/*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
}
}
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((UPDATE_END)func_array[lib_index][eUPDATE_END])();/*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
}
}
}
void
msc_validate_start(void **handle)
{
int lib_index;
int ret = 0;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((SET_ITEM_VALIDITY_BEGIN)func_array[lib_index][eSET_VALIDITY_BEGIN])(handle[lib_index], MSC_VALID_COUNT, &err_msg);/*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
}
}
}
void
msc_validate_end(void **handle)
{
int lib_index;
int ret = 0;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((SET_ITEM_VALIDITY_END)func_array[lib_index][eSET_VALIDITY_END])(handle[lib_index], &err_msg);/*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
}
}
}
void
msc_update_start(void **handle)
{
int lib_index;
int ret = 0;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((UPDATE_ITEM_BEGIN)func_array[lib_index][eUPDATE_ITEM_BEGIN])(handle[lib_index], MSC_VALID_COUNT, &err_msg);/*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
}
}
}
void
msc_update_end(void **handle)
{
int lib_index;
int ret = 0;
char *err_msg = NULL;
for (lib_index = 0; lib_index < lib_num; lib_index++) {
ret = ((UPDATE_ITEM_END)func_array[lib_index][eUPDATE_ITEM_END])(handle[lib_index], &err_msg);/*dlopen*/
if (ret != 0) {
MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
}
}
}
|