summaryrefslogtreecommitdiff
path: root/main/src/data/ivug-data-filter.c
blob: 754a72371e3253452a086356e0f687f9b52f8941 (plain)
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
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
 *
 * 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.
 */


#include "ivug-common.h"
#include "ivug-data-filter.h"

List_Filter *ivug_data_filter_create(const ivug_parameter *param)
{
	IV_ASSERT(param != NULL);

	List_Filter *filter = calloc(1, sizeof(List_Filter));

	IV_ASSERT(filter != NULL);

	filter->view_by = param->view_by;
	filter->media_type = param->media_type;
	filter->sort_type = param->sort_type;

	MSG_SDATA_HIGH("param->view_by is %d", param->view_by);
	switch(param->view_by)
	{
	case IVUG_VIEW_BY_PLACES:
		filter->place.max_longitude = param->max_longitude;
		filter->place.min_longitude = param->min_longitude;
		filter->place.max_latitude = param->max_latitude;
		filter->place.min_latitude = param->min_latitude;
		break;
	case IVUG_VIEW_BY_FILE:
		filter->file_path = strdup(param->filepath);
		break;
	case IVUG_VIEW_BY_ALL:
		filter->album_id = uuid_assign(param->album_id);
		break;

	case IVUG_VIEW_BY_FOLDER:
		filter->album_id = uuid_assign(param->album_id);
		break;

	case IVUG_VIEW_BY_INVAILD:
	default:
		MSG_SDATA_WARN("Invalid ViewBy : %d", param->view_by);
		break;

	}

	return filter;

}

void ivug_data_filter_delete(List_Filter *filter)
{
	IV_ASSERT(filter != NULL);

	MSG_SDATA_HIGH("Removing filter. ViewBy=%d", filter->view_by);

	switch(filter->view_by)
	{
	case IVUG_VIEW_BY_PLACES:
		break;

	case IVUG_VIEW_BY_FILE:
		if ( filter->file_path )
		{
			free(filter->file_path);
		}
		break;
	case IVUG_VIEW_BY_ALL:
		uuid_free(filter->album_id);
		break;

	case IVUG_VIEW_BY_FOLDER:
		uuid_free(filter->album_id);

		break;

	case IVUG_VIEW_BY_INVAILD:
	default:
		MSG_SDATA_WARN("Invalid ViewBy : %d", filter->view_by);
		break;
	}


	free(filter);
}