summaryrefslogtreecommitdiff
path: root/main/src/control/ivug-parameter.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/control/ivug-parameter.c')
-rwxr-xr-xmain/src/control/ivug-parameter.c271
1 files changed, 216 insertions, 55 deletions
diff --git a/main/src/control/ivug-parameter.c b/main/src/control/ivug-parameter.c
index 5717181..5bc94c7 100755
--- a/main/src/control/ivug-parameter.c
+++ b/main/src/control/ivug-parameter.c
@@ -1,26 +1,27 @@
-/*
- * 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 <bundle.h>
+/*
+ * 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 <string.h>
#include "ivug-common.h"
#include "ivug-debug.h"
#include "ivug-parameter.h"
+#include "ivug-file-info.h"
+
+#include "ivug-db.h"
//bundle key
#define IVUG_BUNDLE_KEY_VIEW_MODE "View Mode"
@@ -30,6 +31,7 @@
#define IVUG_BUNDLE_KEY_VIEW_BY "View By"
#define IVUG_BUNDLE_KEY_INDEX "Index"
#define IVUG_BUNDLE_KEY_SORT_BY "Sort By"
+#define IVUG_BUNDLE_KEY_FOOTSTEPS "Footsteps"
#define IVUG_BUNDLE_KEY_MAX_LONGITUDE "LON_MAX"
#define IVUG_BUNDLE_KEY_MIN_LONGITUDE "LON_MIN"
@@ -38,11 +40,28 @@
#define IVUG_BUNDLE_KEY_SETAS_TYPE "Setas type"
+#define IVUG_BUNDLE_KEY_RESOLUTION "Resolution"
+#define IVUG_BUNDLE_KEY_FIXED_RATIO "Fixed ratio"
+
#define IVUG_BUNDLE_KEY_MEDIA_TYPE "Media type"
+#define IVUG_BUNDLE_KEY_MSS_SERVER_ID "MSS_ServerID"
+#define IVUG_BUNDLE_KEY_MSS_SORT_TYPE "MSS_Sort_type"
+
+#define IVUG_BUNDLE_KEY_STANDALONE "Standalone"
+
+#define IVUG_BUNDLE_KEY_CONTACT_ID "Contact id"
+
//default values
#define IVUG_DEFAULT_MODE IVUG_MODE_SINGLE
-#define IVUG_DEFAULT_INDEX (-1)
+#define IVUG_DEFAULT_INDEX (1) // First item
+
+static inline
+void _ivug_free(char **val)
+{
+ free(*val);
+ *val = NULL;
+}
static ivug_mode
_get_view_mode(ivug_parameter* data, const char* val)
@@ -56,6 +75,8 @@ _get_view_mode(ivug_parameter* data, const char* val)
#define IVUG_BUNDLE_VALUE_VIEW_MODE_CAMERA "CAMERA"
#define IVUG_BUNDLE_VALUE_VIEW_MODE_DISPLAY "DISPLAY"
#define IVUG_BUNDLE_VALUE_VIEW_MODE_SETAS "SETAS"
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_SLIDESHOW "SLIDESHOW"
+
int len = strlen(val);
if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_NORMAL, len) == 0
@@ -91,6 +112,14 @@ _get_view_mode(ivug_parameter* data, const char* val)
data->view_by = IVUG_VIEW_BY_FILE;
return IVUG_MODE_SETAS;
}
+ else if(strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_SLIDESHOW, len) == 0)
+ {
+ if(data->view_by != IVUG_VIEW_BY_ALL)
+ {
+ data->view_by = IVUG_VIEW_BY_FOLDER;
+ }
+ return IVUG_MODE_SLIDESHOW;
+ }
MSG_IVUG_ERROR("Invalid mode : %s", val);
return IVUG_MODE_INVAILD;
@@ -102,8 +131,10 @@ _get_view_by(const char* val)
{
//bundle value
#define IVUG_BUNDLE_VALUE_VIEW_BY_ALL "All"
+#define IVUG_BUNDLE_VALUE_VIEW_BY_FAVORITES "Favorites"
#define IVUG_BUNDLE_VALUE_VIEW_BY_FLODER "By Folder"
#define IVUG_BUNDLE_VALUE_VIEW_BY_PLACES "Places"
+#define IVUG_BUNDLE_VALUE_VIEW_BY_CONTACT_ID "Contact id"
IV_ASSERT(val != NULL);
@@ -121,6 +152,10 @@ _get_view_by(const char* val)
{
return IVUG_VIEW_BY_PLACES;
}
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_BY_CONTACT_ID, len) == 0)
+ {
+ return IVUG_VIEW_BY_CONTACT_ID;
+ }
MSG_IVUG_ERROR("Invalid view by : %s", val);
@@ -135,6 +170,10 @@ _get_setas_type(const char* val)
IV_ASSERT(val != NULL);
#define IVUG_BUNDLE_VALUE_SETAS_UG_WALLPAPER "Wallpaper"
+#define IVUG_BUNDLE_VALUE_SETAS_UG_CALLERID "CallerID"
+#define IVUG_BUNDLE_VALUE_SETAS_UG_VIDEO_CALLEID "VideoCallID"
+#define IVUG_BUNDLE_VALUE_SETAS_UG_CROP "Crop"
+#define IVUG_BUNDLE_VALUE_SETAS_UG_WALLPAPER_ONLY "Wallpaper only"
int len = strlen(val);
@@ -142,6 +181,22 @@ _get_setas_type(const char* val)
{
return IVUG_SET_AS_UG_TYPE_WALLPAPER;
}
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_SETAS_UG_WALLPAPER_ONLY, len) == 0 )
+ {
+ return IVUG_SET_AS_UG_TYPE_WALLPAPER_ONLY;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_SETAS_UG_CALLERID, len) == 0)
+ {
+ return IVUG_SET_AS_UG_TYPE_CALLER_ID;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_SETAS_UG_VIDEO_CALLEID, len) == 0)
+ {
+ return IVUG_SET_AS_UG_TYPE_VIDEO_CALL_ID;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_SETAS_UG_CROP, len) == 0)
+ {
+ return IVUG_SET_AS_UG_TYPE_CROP;
+ }
MSG_IVUG_ERROR("Invalid setas ug type : %s", val);
return IVUG_SET_AS_UG_TYPE_INVALID;
@@ -174,38 +229,54 @@ _get_media_type(const char* val)
return IVUG_MEDIA_TYPE_MAX;
}
+static bool _data_print(service_h service, const char *key, void *user_data)
+{
+ char *value;
+
+ service_get_extra_data(service, key, &value);
+ MSG_IVUG_HIGH(" %s : %s", key, value);
-static void
-_bundle_print(const char *key, const char *val, void *data)
+ free(value);
+
+ return true;
+}
+
+static void _print_service_data(service_h service)
{
- MSG_IVUG_HIGH(" %s:%s",key, val);
+ int ret = service_foreach_extra_data(service, _data_print, NULL);
+
+ if(SERVICE_ERROR_NONE != ret)
+ {
+ MSG_IVUG_ERROR("service_foreach_extra_data ERROR");
+ }
}
//parsing bundle
ivug_parameter*
-ivug_param_create_from_bundle(bundle* b)
+ivug_param_create_from_bundle(service_h service)
{
- if (b == NULL)
+ if (service == NULL)
{
MSG_IVUG_WARN("bundle value is NULL");
return NULL;
}
- int nbundle_cnt = bundle_get_count(b);
-
- if ( nbundle_cnt == 0 )
- {
- MSG_IVUG_WARN("bundle count is %d", nbundle_cnt);
- return NULL;
- }
-
//print key and value.
MSG_IVUG_HIGH("**********************************");
- MSG_IVUG_HIGH(" Bundle Count = %d", nbundle_cnt);
- bundle_iterate(b, _bundle_print, NULL);
+ _print_service_data(service);
MSG_IVUG_HIGH("**********************************");
+ char *path = NULL;
+ service_get_uri(service, &path); // app gadget
+ if(path)
+ {
+ MSG_IMAGEVIEW_ERROR("App gadget launched %s", path);
+ service_add_extra_data (service, "Path", path);
+ service_add_extra_data (service, "View Mode", "SINGLE");
+ _ivug_free(&path);
+ }
+
//parsing param
ivug_parameter* data = (ivug_parameter*)calloc(1, sizeof(ivug_parameter));
@@ -215,15 +286,31 @@ ivug_param_create_from_bundle(bundle* b)
return NULL;
}
+// appsvc
+ char* standalone = NULL;
+
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_STANDALONE, &standalone);
+ if (standalone != NULL)
+ {
+ data->bStandalone = true;
+ _ivug_free(&standalone);
+ }
+ else
+ {
+ data->bStandalone = false;
+ }
+
// View By
- const char* szViewBy = NULL;
+ char* szViewBy = NULL;
- szViewBy = bundle_get_val(b, IVUG_BUNDLE_KEY_VIEW_BY);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_VIEW_BY, &szViewBy);
if (szViewBy != NULL)
{
MSG_IVUG_HIGH("View By = %s", szViewBy);
data->view_by = _get_view_by(szViewBy);
+
+ _ivug_free(&szViewBy);
}
else
{
@@ -232,13 +319,14 @@ ivug_param_create_from_bundle(bundle* b)
}
//parse image index at album
- const char* val = NULL;
+ char* val = NULL;
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_INDEX);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_INDEX, &val);
if(val)
{
- data->start_index = atoi(val);
+ data->start_index = ivug_atoi(val);
MSG_IVUG_HIGH("Slide Index = %d", data->start_index);
+ _ivug_free(&val);
}
else
{
@@ -247,14 +335,14 @@ ivug_param_create_from_bundle(bundle* b)
}
//parse mode
- const char* szMode = NULL;
-
- szMode = bundle_get_val(b, IVUG_BUNDLE_KEY_VIEW_MODE);
+ char* szMode = NULL;
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_VIEW_MODE, &szMode);
if (szMode != NULL)
{
data->mode = _get_view_mode(data, szMode);
MSG_IVUG_HIGH("View mode is %s(%d)", szMode, data->mode);
+ _ivug_free(&szMode);
}
else
{
@@ -263,19 +351,25 @@ ivug_param_create_from_bundle(bundle* b)
}
//parse path
- const char* szFilePath = NULL;
-
- szFilePath = bundle_get_val(b, IVUG_BUNDLE_KEY_PATH);
+ char* szFilePath = NULL;
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_PATH, &szFilePath);
if ( szFilePath != NULL )
{
data->filepath = strdup(szFilePath);
MSG_IVUG_HIGH("Current File = %s", data->filepath);
+ _ivug_free(&szFilePath);
}
+ else
+ {
+ MSG_IVUG_ERROR("File path is NULL");
- //parse album id -album id is cluster id of media service
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_ALBUM_IDX);
+ ivug_param_delete(data);
+ return NULL;
+ }
+ //parse album id -album id is cluster id of media service
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_ALBUM_IDX, &val);
if(val && data->view_by != IVUG_VIEW_BY_ALL)
{
data->album_id = uuid_getuuid(val);
@@ -286,6 +380,9 @@ ivug_param_create_from_bundle(bundle* b)
data->album_id = INVALID_UUID;
MSG_IVUG_WARN("Album index is NULL");
}
+ if(val)
+ _ivug_free(&val);
+
if (data->mode == IVUG_MODE_CAMERA)
{
/*
@@ -296,19 +393,28 @@ ivug_param_create_from_bundle(bundle* b)
**********************************
*/
// Get album id from file path.
- UUID cluster_id = ivug_get_album_id_from_filepath(data->filepath);
+ media_handle m_handle = ivug_db_get_folder_handle(ecore_file_dir_get(data->filepath));
+ if(m_handle == NULL)
+ {
+ MSG_IVUG_FATAL("View by Folder. but media handle is NULL" );
+ ivug_param_delete(data);
+ return NULL;
+ }
+
+ data->album_id = ivug_db_get_folder_id(m_handle);
- data->album_id = uuid_assign(cluster_id);
+ ivug_db_destroy_folder_handle(m_handle);
MSG_IVUG_HIGH("Get Album ID(%s) from file %s", uuid_getchar(data->album_id), data->filepath);
}
// TODO : Check parameter integrity
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_MEDIA_TYPE);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_MEDIA_TYPE, &val);
if(val != NULL)
{
data->media_type = _get_media_type(val);
MSG_IVUG_HIGH("Media Type=%s(%d)", val, data->media_type);
+ _ivug_free(&val);
}
else
{
@@ -318,59 +424,114 @@ ivug_param_create_from_bundle(bundle* b)
long long int m = 0;
long int e = 0;
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_MAX_LONGITUDE);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_MAX_LONGITUDE, &val);
if(val != NULL)
{
eina_convert_atod(val, strlen(val), &m, &e);
data->max_longitude = ldexp((double)m, e);
MSG_IVUG_HIGH("Max Longitude =%f", data->max_longitude);
+ _ivug_free(&val);
}
else
{
MSG_IVUG_MED("Max Longitude is not specified.");
}
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_MIN_LONGITUDE);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_MIN_LONGITUDE, &val);
if(val != NULL)
{
eina_convert_atod(val, strlen(val), &m, &e);
data->min_longitude = ldexp((double)m, e);
MSG_IVUG_HIGH("Min Longitude =%f", data->min_longitude);
+ _ivug_free(&val);
}
else
{
MSG_IVUG_MED("Min Longitude is not specified.");
}
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_MAX_LATITUDE);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_MAX_LATITUDE, &val);
if(val != NULL)
{
eina_convert_atod(val, strlen(val), &m, &e);
data->max_latitude = ldexp((double)m, e);
MSG_IVUG_HIGH("Max Latitude =%f", data->max_latitude);
+ _ivug_free(&val);
}
else
{
MSG_IVUG_MED("Max Latitude is not specified.");
}
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_MIN_LATITUDE);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_MIN_LATITUDE, &val);
if(val != NULL)
{
eina_convert_atod(val, strlen(val), &m, &e);
data->min_latitude = ldexp((double)m, e);
MSG_IVUG_HIGH("Min Latitude =%f", data->min_latitude);
+ _ivug_free(&val);
}
else
{
MSG_IVUG_MED("Min Latitude is not specified.");
}
- val = bundle_get_val(b, IVUG_BUNDLE_KEY_SETAS_TYPE);
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_SETAS_TYPE, &val);
if (val)
{
MSG_IVUG_HIGH("SetAs UG Type=%s", val);
data->setas_type = _get_setas_type(val);
+
+ char* resolution = NULL;
+
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_RESOLUTION, &resolution);
+ if(resolution)
+ {
+ sscanf(resolution, "%5dx%5d", &(data->width), &(data->height));
+ MSG_IVUG_HIGH("Rectangle width = %d, height = %d", data->width, data->height);
+ if(data->width == 0 || data->height == 0)
+ {
+ MSG_IVUG_ERROR("Resolution is invalid");
+ _ivug_free(&resolution);
+ _ivug_free(&val);
+ ivug_param_delete(data);
+ return NULL;
+ }
+ }
+ else
+ {
+ /* TODO : remove default value, width & height needed */
+ data->width = 100;
+ data->height = 100;
+ MSG_IVUG_HIGH("Rectangle ratio is not set. Set as default : %dx%d", data->width, data->height);
+ }
+
+ data->bRatioFix = false;
+ char* bRatioFix = NULL;
+
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_FIXED_RATIO, &bRatioFix);
+ if(bRatioFix)
+ {
+ MSG_IVUG_HIGH("Fixed ratio=%s", bRatioFix);
+ if(strcmp(bRatioFix, "TRUE") == 0)
+ {
+ data->bRatioFix = true;
+ }
+ _ivug_free(&bRatioFix);
+ }
+ _ivug_free(&val);
+ }
+
+ data->footsteps = false; /* default */
+ service_get_extra_data (service, IVUG_BUNDLE_KEY_FOOTSTEPS, &val);
+ if (val)
+ {
+ MSG_IVUG_HIGH("Footsteps=%s", val);
+ if(strcmp(val, "TRUE") == 0)
+ {
+ data->footsteps = true;
+ }
+ _ivug_free(&val);
}
return data;