Embed default widget on homescreen 18/213918/5 submit/tizen/20190919.023441
authorprachi kumar <prachi.kumar@samsung.com>
Mon, 16 Sep 2019 19:56:57 +0000 (01:26 +0530)
committerprachi kumar <prachi.kumar@samsung.com>
Wed, 18 Sep 2019 17:36:22 +0000 (23:06 +0530)
Change-Id: I5794233129199bea0ea11f155b275061603dad6b

res/default-widget.conf [new file with mode: 0644]
src/cluster_data.c

diff --git a/res/default-widget.conf b/res/default-widget.conf
new file mode 100644 (file)
index 0000000..0fc80af
--- /dev/null
@@ -0,0 +1 @@
+org.tizen.calendar.widget
\ No newline at end of file
index ef86789..e761ebd 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 #include <app_preference.h>
+#include <app_manager.h>
 
 #include "cluster_data.h"
 #include "cluster_db.h"
@@ -25,6 +26,7 @@
 #include "conf.h"
 
 #define CLUSTER_DATA_PAGE_COUNT "cluster_page_count"
+#define MAX_SIZE 100
 
 static struct {
        Eina_List *data_list;
@@ -39,7 +41,7 @@ void cluster_data_init(void)
 {
        if (cluster_db_create()) {
                /* Do not show default calendar widget for common profile */
-               //__cluster_data_insert_default_data();
+               __cluster_data_insert_default_data();
                cluster_data_set_page_count(1);
        }
        cluster_db_get_list(&cluster_data_s.data_list);
@@ -119,12 +121,45 @@ static void __cluster_data_insert_default_data(void)
         * org.tizen.music-player.widget
         * org.tizen.contacts-widget
        */
+       char default_widget[MAX_SIZE] = {0};
+       char path[MAX_SIZE];
+       app_info_h appHandle = NULL;
+
+       char *path1 = app_get_resource_path();
+       if(!path1) {
+               __E("Resource Path not found");
+               return;
+       }
+       snprintf(path,MAX_SIZE,"%s%s",path1,"default-widget.conf");
+       __D("Conf file path : [%s]", path);
+       free(path1);
+       FILE *fp = fopen(path,"r");
+
+       if (!fp) {
+               __E("Conf file default-widget.conf doesn't exist at path : [%s]", path);
+               return;
+       }
+
+       fscanf(fp,"%s",default_widget);
+       fclose(fp);
+
+       __D("Default Widget : [%s]", default_widget);
+
+       int nRet = app_info_create(default_widget, &appHandle);
+       if (nRet != APP_MANAGER_ERROR_NONE) {
+               __E("Default Widget not installed in the device : [%s]", default_widget);
+               return;
+       }
+       __D("Default Widget installed in the device : [%s]", default_widget);
+       app_info_destroy(appHandle);
+
+
        widget_data_t *new_item = (widget_data_t *)malloc(sizeof(widget_data_t));
        memset(new_item, 0, sizeof(widget_data_t));
        new_item->page_idx = 0;
        new_item->pos_y = 0;
        new_item->pos_x = 0;
-       new_item->pkg_name = strdup("org.tizen.calendar.widget");
+       new_item->pkg_name = strdup(default_widget);
        new_item->widget_label = strdup(add_widget_data_get_widget_label(new_item->pkg_name));
 
        new_item->content_info = NULL;