diff options
Diffstat (limited to 'main/src/control/ivug-filter.c')
-rwxr-xr-x | main/src/control/ivug-filter.c | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/main/src/control/ivug-filter.c b/main/src/control/ivug-filter.c new file mode 100755 index 0000000..56e08f7 --- /dev/null +++ b/main/src/control/ivug-filter.c @@ -0,0 +1,161 @@ +/*
+ * 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-datatypes.h" +#include "ivug-filter.h" + +#include <Eina.h> + +#include "ivug-debug.h" +#include "ivug-uuid.h" +#include "ivug-util.h" +#include "ivug-context.h" + +Filter_struct *ivug_data_filter_create(const ivug_parameter *param) +{ + IV_ASSERT(param != NULL); + + Filter_struct *filter_str = calloc(1, sizeof(Filter_struct)); + IV_ASSERT(filter_str != NULL); + + filter_str->type = FILTER_DB; + + filter_str->view_by = param->view_by; + filter_str->media_type = param->media_type; + filter_str->sort_type = param->sort_type; + filter_str->index = param->start_index; + + DB_Filter *filter = calloc(1, sizeof(DB_Filter)); + + IV_ASSERT(filter != NULL); + + 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; + + } + + filter_str->db_filter = filter; + + return filter_str; + +} + +void ivug_data_filter_delete(Filter_struct *filter_str) +{ + IV_ASSERT(filter_str != NULL); + + MSG_SDATA_HIGH("Removing filter struct. Type=%d", filter_str->type); + + if(filter_str->type == FILTER_DB) + { + DB_Filter *filter = filter_str->db_filter; + switch(filter_str->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_str->view_by); + break; + } + free(filter); + } + free(filter_str); +} + + +Filter_struct *ivug_data_filter_copy(const Filter_struct *filter_str) +{ + IV_ASSERT(filter_str != NULL); + Filter_struct *cFilter_str = malloc(sizeof(Filter_struct)); + IV_ASSERT(cFilter_str != NULL); + + memcpy(cFilter_str, filter_str, sizeof(Filter_struct)); + + if(filter_str->type == FILTER_DB) + { + DB_Filter *filter = filter_str->db_filter; + DB_Filter *cFilter = malloc(sizeof(DB_Filter)); + memcpy(cFilter, filter, sizeof(DB_Filter)); + + switch(filter_str->view_by) + { + case IVUG_VIEW_BY_PLACES: + break; + + case IVUG_VIEW_BY_FILE: + cFilter->file_path = strdup( filter->file_path ); + + if ( filter->file_path ) + { + free(filter->file_path); + } + break; + + case IVUG_VIEW_BY_ALL: + cFilter->album_id = uuid_assign( filter->album_id ); + break; + + case IVUG_VIEW_BY_FOLDER: + cFilter->album_id = uuid_assign( filter->album_id ); + break; + + case IVUG_VIEW_BY_INVAILD: + default: + MSG_SDATA_WARN("Invalid ViewBy : %d", filter_str->view_by); + break; + } + + cFilter_str->db_filter = cFilter; + } + return cFilter_str; +} + |