summaryrefslogtreecommitdiff
path: root/main/src/data/ivug-data-shuffle.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/data/ivug-data-shuffle.c')
-rwxr-xr-xmain/src/data/ivug-data-shuffle.c238
1 files changed, 0 insertions, 238 deletions
diff --git a/main/src/data/ivug-data-shuffle.c b/main/src/data/ivug-data-shuffle.c
deleted file mode 100755
index fa4d07d..0000000
--- a/main/src/data/ivug-data-shuffle.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * 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.h"
-#include "ivug-data-priv.h"
-#include "ivug-data-shuffle.h"
-
-static void _swap_eina_list(Eina_List* list, int i, int j)
-{
- Eina_List *first;
- Eina_List *second;
- int temp;
-
- if ( i == j ) return ;
-
- first = eina_list_nth_list(list, i);
- second = eina_list_nth_list(list, j);
-
- temp = (int)(first->data);
- first->data = second->data;
- second->data = (void *)temp;
-}
-
-void _shuffle_eina_list(Eina_List *list, int count)
-{
- int i;
- int r;
-
- IV_ASSERT(list != NULL);
-
- srand((unsigned)time(NULL));
-
- for(i=0; i<count; i++)
- {
- r = rand()%count;
- //MSG_UTIL_HIGH("rand = %d", r);
- _swap_eina_list(list, i, r);
- }
-}
-
-static Eina_List *_create_eina_list(int count)
-{
- int i;
-
- Eina_List *list = NULL;
-
- for(i=1; i <= count; i++) /* 1 ~ total count */
- {
- list = eina_list_append(list, (void *)i);
- }
-
- _shuffle_eina_list(list, count);
-
- return list;
-}
-
-
-bool ivug_data_init_shuffle_slide_show(Media_List *mList, slide_show_mode ss_mode, int cur_index, int total_count)
-{
- IV_ASSERT(mList != NULL);
-
- Eina_List *item = NULL;
- _Media_List *_mList = (_Media_List *)mList;
-
- if(total_count == 1 && !(ss_mode & SLIDE_SHOW_MODE_REPEAT))
- {
- return false;
- }
-
- item = eina_list_data_find_list(_mList->ss_shuffle_header, (void * )cur_index);
- if(item == NULL)
- {
- MSG_SDATA_ERROR("Can't find cur index item %d", cur_index);
- item = _mList->ss_shuffle_header;
- }
- _mList->ss_shuffle_end = item;
- _mList->ss_shuffle_current = eina_list_next(item);
-
- if( _mList->ss_shuffle_current == NULL)
- {
- _mList->ss_shuffle_current = _mList->ss_shuffle_header; /* back to first */
- }
-
- return true;
-}
-
-void ivug_data_deinit_shuffle_slide_show(Media_List *mList, int total_count)
-{
- IV_ASSERT(mList != NULL);
-
- _Media_List *_mList = (_Media_List *)mList;
-
- _mList->ss_shuffle_end = NULL;
- _mList->ss_shuffle_current = NULL;
-
- _shuffle_eina_list(_mList->ss_shuffle_header, total_count);
-}
-
-void ivug_data_create_shuffled_list(Media_List *mList, int total_count)
-{
- _Media_List *_mList = (_Media_List *)mList;
-
- _mList->ss_shuffle_header = _create_eina_list(total_count);
- _shuffle_eina_list(_mList->ss_shuffle_header, total_count); // Shuffle
-
-}
-
-int ivug_data_get_next_slide_show_index(Media_List *mList, slide_show_mode ss_mode, int next_index, int total_count, bool increase_flag)
-{
- IV_ASSERT(mList != NULL);
- _Media_List *_mList = (_Media_List *)mList;
- int index = -1;
- Eina_List *item = NULL;
- Eina_List *list = NULL;
-
- if(ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
- {
- item = _mList->ss_shuffle_current;
-
- list = eina_list_next(item);
- if ( list == NULL)
- {
- list = _mList->ss_shuffle_header; /* back to start */
- }
- if(list == _mList->ss_shuffle_end && !(ss_mode & SLIDE_SHOW_MODE_REPEAT))
- {
- if(increase_flag == true)
- {
- _mList->ss_shuffle_current = NULL;
- }
- return -1;
- }
- if(increase_flag == true)
- {
- _mList->ss_shuffle_current = list;
- }
- index = (int)eina_list_data_get(list);
- }
- else
- {
- index = next_index + 1;
- if(index > total_count && (ss_mode & SLIDE_SHOW_MODE_REPEAT) )
- {
- index = 1; /* back to start */
- }
- }
- return index;
-}
-
-Media_Item * ivug_data_get_current_slide_show_item(Media_List *mList, slide_show_mode ss_mode, int cur_index, int *next_index, int total_count)
-{
- IV_ASSERT(mList != NULL);
-
- Eina_List *item = NULL;
- int index;
- Media_Item *slide_show_item = NULL;
- _Media_List *_mList = (_Media_List *)mList;
-
- if(ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
- {
- item = _mList->ss_shuffle_current;
-
- index = (int)eina_list_data_get(item);
- }
- else
- {
- index = cur_index + 1;
- if(index > total_count && (ss_mode & SLIDE_SHOW_MODE_REPEAT) )
- {
- index = 1; /* back to start */
- }
- }
- MSG_SDATA_HIGH("*******current shuffle index is %d", index);
-
- slide_show_item = _ivug_data_create_window_size_list(mList, index, total_count);
- if(slide_show_item == NULL)
- {
- MSG_SDATA_HIGH("*******current shuffle item is NULL");
- return NULL;
- }
- *next_index = index;
-
- return slide_show_item;
-}
-
-Media_Item * ivug_data_set_next_slide_show_item(Media_List *mList, slide_show_mode ss_mode, int *next_index, int total_count)
-{
- IV_ASSERT(mList != NULL);
-
- int index;
- Media_Item *slide_show_item = NULL;
-
- index = ivug_data_get_next_slide_show_index(mList, ss_mode, *next_index, total_count, false);
- if(index < 0)
- {
- MSG_SDATA_HIGH("*******Next slide show item is NULL");
- return NULL;
- }
-
- MSG_SDATA_HIGH("*******Next slide show index is %d", index);
-
- slide_show_item = _ivug_data_create_window_size_list(mList, index, total_count);
- if(slide_show_item == NULL)
- {
- MSG_SDATA_HIGH("*******Next slide show item is NULL");
- return NULL;
- }
- ivug_data_append_media_item(mList, slide_show_item);
-
- return slide_show_item;
-}
-
-
-Media_Item *
-ivug_data_get_next_shuffle_item(Media_List *mList)
-{
- IV_ASSERT(mList != NULL);
-
- _Media_List *_mList = (_Media_List *)mList;
-
- return _mList->ss_shuffle_current; // current is set at next slide
-}
-