summaryrefslogtreecommitdiff
path: root/src/festival-wallpaper.c
blob: 6d42440b22eda681ff0cb4782417789704d448dd (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/*
 *  starter
 *
 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
 *
 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
 *
 * 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 <Elementary.h>
#include <Ecore_X.h>
#include <vconf.h>
#include <vconf-keys.h>
#include <efl_assist.h>
#include <feedback.h>
#include <app_alarm.h>
#include <system_settings.h>
#include <sys/time.h>
#include <time.h>

#include <calendar.h>

#include "wallpaper-ui-service-debug.h"
#include "festival-wallpaper.h"


//#define ICON_DIR                  "/usr/ug/res/images/ug-lockscreen-options-efl"
//efine   ICON_DIR            "/usr/apps/org.tizen.wallpaper-ui-service/res/images/"
#define VCONF_LOCKSCREEN_FESTIVAL_INDEX "db/lockscreen/pre_wallpaper_type"	// int : save festival wallpaper idx
#define VCONF_LOCKSCREEN_FESTIVAL_BGSET "db/lockscreen/pre_bgset"	// string : save festival wallpaper location
#define LOCKSCREEN_FESTIVAL_DISMISS "__DISMISS__"
#define LOCKSCREEN_FESTIVAL_NONE "__NONE__"

#define VCONFKEY_FESTIVAL_EVENTS_LIST "db/lockscreen/festival_wallpaper_enable_string"


#define MAX_FESTIVAL 17

typedef struct {
	char* name;
	int b_on;

	int duration;
	time_t from_time;
	time_t to_time;
} festival_day_info;

festival_day_info day_info[MAX_FESTIVAL] =
{
	{"Milad-un-Nabi",				1,		1, 0, 0},
	{"Republic Day",				1,		1, 0, 0},
	{"Holi",						1,		1, 0, 0},
	{"Ram Navami",				1,		1, 0, 0},
	{"Mahavir Jayanti",			1,		1, 0, 0},
	{"Good Friday",				1,		1, 0, 0},
	{"Buddha Purnima",			1,		1, 0, 0},
	{"Idul Fitr",					1,		1, 0, 0},
	{"Independence Day",			1,		1, 0, 0},
	{"Janmashtami",				1,		1, 0, 0},
	{"Idul Juha",					1,		1, 0, 0},
	{"Mahatma Gandhi Birthday",	1,		1, 0, 0},
	{"Dussehra",					1,		1, 0, 0},
	{"Muharram (10th Day)",		1,		1, 0, 0},
	{"Deewali",					1,		5, 0, 0},
	{"Guru Nanak's Birthday",	1,		1, 0, 0},
	{"Christmas Day",				1,		5, 0, 0},
};

static const char *icon_path[] = {
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/01_Milad-un-Nabi.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/02_Republic_Day.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/03_Holi.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/04_Ram-Navami.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/16_Mahavir_Jayanti.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/05_Good_Friday.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/06_Buddha.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/07_Id-Ul-Fitr.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/08_IndependenceDay.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/10_Janmashtami.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/09_Id-ul-Juha.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/12_Mahatma_Gandhi_Jayanti.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/11_Dussehra.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/14_Muharram.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/13_Diwali.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/17_Guru_Nanak.jpg",
	"/opt/usr/apps/org.tizen.wallpaper-ui-service-lite/data/wallpaper/festival/15_Christmas.jpg",
};

static void set_festival_as_value(void* data, int festival_value)
{
#if 0
	int wallpaper_type = 0;
	char* value = NULL;

	vconf_get_int(VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE,&wallpaper_type);

	if(wallpaper_type!=LOCKSCREEN_WALLPAPER_TYPE_FESTIVAL)
	{
		vconf_set_int(VCONF_LOCKSCREEN_FESTIVAL_INDEX,wallpaper_type);
	}
	else
	{
		WALLPAPERUI_ERR("set pre type failed =%d", wallpaper_type);
	}

	WALLPAPERUI_DBG("festival_wallpaper_handle pre(%d) current(%d)",wallpaper_type,LOCKSCREEN_WALLPAPER_TYPE_FESTIVAL);
	if(system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value) == SYSTEM_SETTINGS_ERROR_NONE) {
		WALLPAPERUI_ERR("SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN:get value=%s", value);
	}

	if(wallpaper_type!=LOCKSCREEN_WALLPAPER_TYPE_FESTIVAL)
	{
		vconf_set_str(VCONF_LOCKSCREEN_FESTIVAL_BGSET,value);
	}
	else
	{
		WALLPAPERUI_ERR("set pre bgset failed =%d", value);
	}

	//backup
	//set
	vconf_set_int(VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE, LOCKSCREEN_WALLPAPER_TYPE_FESTIVAL);
	if(system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN,icon_path[festival_value]) == SYSTEM_SETTINGS_ERROR_NONE) {
		WALLPAPERUI_ERR("SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN:set value=%s", icon_path[festival_value]);
	}
	//notification_status_message_post(_("IDS_ST_POP_LOCK_SCREEN_WALLPAPER_CHANGED_ABB"));
#endif

	int idx = 0;
	char *festival_wallpaper = NULL;
	festival_wallpaper = vconf_get_str(VCONF_LOCKSCREEN_FESTIVAL_BGSET);
	vconf_get_int(VCONF_LOCKSCREEN_FESTIVAL_BGSET, &idx);
	if(festival_wallpaper && strcmp(festival_wallpaper, LOCKSCREEN_FESTIVAL_DISMISS) == 0 && idx == festival_value) {
		WALLPAPERUI_ERR("%d is dismissed", idx);
	} else {
		vconf_set_str(VCONF_LOCKSCREEN_FESTIVAL_BGSET, icon_path[festival_value]);
		vconf_set_int(VCONF_LOCKSCREEN_FESTIVAL_INDEX, festival_value);
	}
	if(festival_wallpaper!=NULL)
	{
		FREE(festival_wallpaper);
	}
}

static void reset_as_previous(void* data)
{
	wallpaper_ui_service_appdata *ad = (wallpaper_ui_service_appdata *)data;
	vconf_set_str(VCONF_LOCKSCREEN_FESTIVAL_BGSET, LOCKSCREEN_FESTIVAL_NONE);
	vconf_set_int(VCONF_LOCKSCREEN_FESTIVAL_INDEX, -1);

}
void get_holiday_date(void* data)
{
	int i = 0;
	char *checkinfo = NULL;
	checkinfo = vconf_get_str(VCONFKEY_FESTIVAL_EVENTS_LIST);
	WALLPAPERUI_DBG("checkinfo %s",checkinfo);
	if(checkinfo!=NULL)
	{
		char* temp = NULL;
		for(i=0;i<MAX_FESTIVAL;i++)
		{
			if(*(checkinfo+i) == '1')
				day_info[i].b_on = 1;
			else
				day_info[i].b_on = 0;
		}
	}
	if(checkinfo!=NULL)
	{
		FREE(checkinfo);
	}

	//get data from calendar svc
}

int check_today_is_holiday(void* data, int prev)
{
	int i = 0;
	struct tm date;
	time_t now;
	time(&now);
	localtime_r(&now, &date);
	for(i=0;i<MAX_FESTIVAL;i++)
	{
//		struct tm date;
//		WALLPAPERUI_ERR("NEXT %d, %d, %d, %d, %d, %d,index %d b_on %d",date.tm_year,date.tm_mon,date.tm_mday,date.tm_hour,date.tm_min,date.tm_sec,i,b_on);
//		WALLPAPERUI_ERR("day_info[%d] $d %d, %d, %d",i,day_info[i].from_month,day_info[i].to_month,day_info[i].from_day,day_info[i].to_day,date.tm_min);
		if(i!=prev)//check for previous holiday
		{
			if(day_info[i].from_time >= now && now < day_info[i].to_time) {
				WALLPAPERUI_ERR("!!!today is holiday %d %s", i, day_info[i].name);
				set_festival_as_value(data, i);
				break;
			}
		}
	}

}

void set_alarm_by_date(struct tm* date,int index,int day)
{
	WALLPAPERUI_ERR("NEXT %d, mon %d, day %d, hour %d, min %d, sec %d,index %d,day %d,name %s",date->tm_year,date->tm_mon,date->tm_mday,date->tm_hour,date->tm_min,date->tm_sec,index,day,day_info[day].name);
	int tid;

	app_control_h service;
	app_control_create(&service);
	app_control_set_app_id(service, "org.tizen.wallpaper-ui-service");
	app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT);
	app_control_add_extra_data(service, "popup_type", "festival");
	app_control_add_extra_data(service, EXTRA_KEY_FESTIVAL_TYPE, EXTRA_DATA_FESTIVAL_TRIGGER);

	if(index==0)//off
	{
		app_control_add_extra_data(service, EXTRA_KEY_FESTIVAL_TRIGGER, EXTRA_DATA_FESTIVAL_TRIGGER_OFF);
	}
	else
	{
		app_control_add_extra_data(service, EXTRA_KEY_FESTIVAL_TRIGGER, EXTRA_DATA_FESTIVAL_TRIGGER_ON);
	}

	char val[10] = {0,};
	snprintf(val,sizeof(val),"%d",day);
	app_control_add_extra_data(service, EXTRA_KEY_FESTIVAL_TRIGGER_VAL, val);
	int ret = alarm_schedule_at_date(service, date, 0, &tid);
	if(ret == ALARM_ERROR_NONE)
	{
//		WALLPAPERUI_ERR("NO ERROR");
	}
	else
	{
		WALLPAPERUI_ERR("ERROR(%d)", ret);
	}
	//	app_control_send_launch_request(service,NULL,NULL);
	app_control_destroy(service);

}
void set_next_year_alarm(void)
{
	struct tm date;
	int b_on = 1;
	time_t now;
	time(&now);
	localtime_r(&now, &date);

	int tid;

	app_control_h service;
	app_control_create(&service);
	app_control_set_app_id(service, "org.tizen.wallpaper-ui-service");
	app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT);
	app_control_add_extra_data(service, "popup_type", "festival");
	app_control_add_extra_data(service, EXTRA_KEY_FESTIVAL_TYPE, EXTRA_DATA_FESTIVAL_CREATE);

	date.tm_year = date.tm_year+1;
	date.tm_mon = 0;
	date.tm_mday = 1;
	date.tm_hour = 0;
	date.tm_min = 0;
	date.tm_sec = 0;

	WALLPAPERUI_ERR("NEXT year %d, mon %d, day %d, hour %d, min %d, sec %d",date.tm_year,date.tm_mon,date.tm_mday,date.tm_hour,date.tm_min,date.tm_sec);

	int ret = alarm_schedule_at_date(service, &date, 0, &tid);
	if(ret == ALARM_ERROR_NONE)
	{
//		WALLPAPERUI_ERR("NO ERROR");
	}
	else
	{
		WALLPAPERUI_ERR("ERROR(%d)", ret);
	}

	app_control_destroy(service);

}
int set_alarm_all(void* data)
{
	int i = 0;
//	int b_plus_year = 0;
	get_holiday_date(data);

	int b_plus_year = 0;
	struct tm date;
	time_t now;
	time(&now);
	localtime_r(&now, &date);

	Eina_Bool is_today_festival = EINA_FALSE;

	WALLPAPERUI_ERR("today %d, %d, %d, %d, %d, %d,index %d b_on %d",date.tm_year,date.tm_mon,date.tm_mday,date.tm_hour,date.tm_min,date.tm_sec);

	int b_on_list[MAX_FESTIVAL];

	for(i=0;i<MAX_FESTIVAL;i++)
	{
		b_on_list[i] = 1;

		if(day_info[i].b_on==0)
		{
			WALLPAPERUI_DBG("SKIP unchecked event(%s) idx(%d)", day_info[i].name, i);
			b_on_list[i] = 0;
			continue;
		}

		if(day_info[i].from_time <= now && now < day_info[i].to_time) {
			WALLPAPERUI_ERR("!!!today is holiday %d %s", i, day_info[i].name);
			set_festival_as_value(data, i);
			b_on_list[i] = 0;

			/* end alarm */
			struct tm to_time;
			localtime_r(&day_info[i].to_time, &to_time);
			set_alarm_by_date(&to_time, b_on_list[i], i);
			is_today_festival = EINA_TRUE;
		} else if (day_info[i].from_time <= now) {
			WALLPAPERUI_DBG("SKIP previous event(%s) idx(%d) from(%d) now(%d) to(%d)", day_info[i].name, i, day_info[i].from_time, now, day_info[i].to_time);
			b_on_list[i] = 0;
			continue;
		}
	}

	if(!is_today_festival)
	{
		reset_as_previous(data);
	}

	/* set alarms */
	for(i=0;i<MAX_FESTIVAL;i++)
	{
		if(b_on_list[i] == 1)//on
		{
			int index = 0;
			for(index=0; index<2 ;index++)
			{
				if(index==0)
				{
					// to
					localtime_r(&day_info[i].to_time, &date);
				}
				else
				{
					// from
					localtime_r(&day_info[i].from_time, &date);
				}
				set_alarm_by_date(&date, index, i);
			}
		}
	}

	set_next_year_alarm();

	return 0;
}

calendar_query_h _create_range_list_query()
{
	const char* uri = _calendar_instance_localtime_calendar_book_extended._uri ;
	const unsigned int startProperty = _calendar_instance_localtime_calendar_book_extended.start_time;

	calendar_query_h query = NULL;
	calendar_query_create(uri, &query);

	calendar_filter_h filter = NULL;
	calendar_filter_create(uri, &filter);

	struct tm tm_start;
	time_t now = time(NULL);
	localtime_r(&now, &tm_start);

	// time filter
	calendar_time_s fromTime;
	fromTime.type = CALENDAR_TIME_LOCALTIME;
	fromTime.time.date.year = tm_start.tm_year+1900;
	fromTime.time.date.month = 1;
	fromTime.time.date.mday = 1;
	fromTime.time.date.hour = 0;
	fromTime.time.date.minute = 0;
	fromTime.time.date.second = 0;
	fromTime.time.date.is_leap_month = false;

	calendar_time_s toTime;
	toTime.type = CALENDAR_TIME_LOCALTIME;
	toTime.time.date.year = tm_start.tm_year+1900+1;
	toTime.time.date.month = 1;
	toTime.time.date.mday = 1;
	toTime.time.date.hour = 0;
	toTime.time.date.minute = 0;
	toTime.time.date.second = 0;
	toTime.time.date.is_leap_month = false;

	calendar_filter_add_caltime(filter, startProperty, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, fromTime);
	calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
	calendar_filter_add_caltime(filter, startProperty, CALENDAR_MATCH_LESS_THAN, toTime);

	// string filter
	calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
	calendar_filter_add_str(filter,_calendar_instance_localtime_calendar_book_extended.sync_data2,CALENDAR_MATCH_FULLSTRING, "FESTIVAL");

	calendar_query_set_filter(query, filter);
	calendar_filter_destroy(filter);

	calendar_query_set_sort(query, startProperty, true);

	return query;
}

int _festival_date_find(const char *name)
{
	int i = 0;

	for(i = 0; i < MAX_FESTIVAL; i++) {
		if(strstr(name, day_info[i].name) != NULL) {
			return i;
		}
	}
	return -1;
}

void festival_date_get_from_calendar(void)
{
	calendar_connect();

	calendar_query_h query = _create_range_list_query();
	if (query == NULL) {
		WALLPAPERUI_ERR("_create_range_list_query() failed");
		return;
	}

	calendar_list_h list = NULL;
	int error = calendar_db_get_records_with_query(query, 0, 0, &list);
	if (error != CALENDAR_ERROR_NONE) {
		WALLPAPERUI_ERR("calendar_db_get_records_with_query() failed");
		return;
	}

	if (list != NULL) {
		int count = 0;
		int i = 0;
		calendar_list_first(list);
		error = calendar_list_get_count(list, &count);
		if (error != CALENDAR_ERROR_NONE) {
			WALLPAPERUI_ERR("calendar_list_get_count() failed");
			return;
		}

		for (i = 0; i < count; i++)
		{
			calendar_record_h record2 = NULL;

			error = calendar_list_get_current_record_p(list, &record2);
			if (error != CALENDAR_ERROR_NONE) {
				WALLPAPERUI_ERR("calendar_list_get_current_record_p() failed");
			}

			if (record2) {
				char * tmp = NULL;
				calendar_record_get_str_p(record2, _calendar_instance_localtime_calendar_book_extended.summary ,&tmp);
				if (tmp) {

					/* TODO : tmp can be changed for multi languages */
					int index = _festival_date_find(tmp);
					if(index != -1) {
						calendar_time_s start;
						calendar_record_get_caltime(record2, _calendar_instance_localtime_calendar_book_extended.start_time, &start);
						if(start.type == CALENDAR_TIME_LOCALTIME) {

							struct tm temp_tm;
							temp_tm.tm_year = start.time.date.year-1900;
							temp_tm.tm_mon = start.time.date.month-1;
							temp_tm.tm_mday = start.time.date.mday;
							temp_tm.tm_hour = 0;
							temp_tm.tm_min = 0;
							temp_tm.tm_sec = 0;

							WALLPAPERUI_DBG("name(%s) y(%d) m(%d) d(%d)", tmp, start.time.date.year, start.time.date.month, start.time.date.mday);

							day_info[index].from_time = mktime(&temp_tm);

							//temp_tm.tm_mday += day_info[index].duration-1;
							temp_tm.tm_mday += day_info[index].duration;

							day_info[index].to_time = mktime(&temp_tm);

							//WALLPAPERUI_DBG("from(%d) to(%d)", day_info[index].from_time, day_info[index].to_time);
						}
					} else {
						WALLPAPERUI_ERR("There is no date(%s)", tmp);
					}
				}
			}

			calendar_list_next(list);
		}
		calendar_list_destroy(list,true);
	}

	calendar_disconnect();
}

void festival_wallpaper_handle(app_control_h service, void * data)
{
	WALLPAPERUI_DBG("festival_wallpaper_handle begin");
	wallpaper_ui_service_appdata *ad = (wallpaper_ui_service_appdata *)data;
	if(ad->festival_data.festival_type == WALLPAPER_FESTIVAL_TYPE_CREATE)
	{
		int i = 0;
		alarm_cancel_all();
		festival_date_get_from_calendar();
		set_alarm_all(data);
	}
	else if(ad->festival_data.festival_type == WALLPAPER_FESTIVAL_TYPE_DELETE)
	{
		alarm_cancel_all();
		reset_as_previous(data);
	}
	else if(ad->festival_data.festival_type == WALLPAPER_FESTIVAL_TYPE_TRIGGER)
	{
		char* trigger_type = NULL;
		char* trigger_val = NULL;
		
		int type = 0;
		int val = 0;
		app_control_get_extra_data(service, EXTRA_KEY_FESTIVAL_TRIGGER, &trigger_type);
		if(trigger_type!=NULL)
		{
			WALLPAPERUI_ERR("EXTRA_KEY_FESTIVAL_TRIGGER %s",trigger_type);
			if(strcmp(trigger_type, EXTRA_DATA_FESTIVAL_TRIGGER_ON)==0)
			{
				type = 1;
			}
			else if(strcmp(trigger_type, EXTRA_DATA_FESTIVAL_TRIGGER_OFF)==0)
			{
				type = 0;
			}
			free(trigger_type);
		}
		else
		{
			type = 0;
		}
		
		app_control_get_extra_data(service, EXTRA_KEY_FESTIVAL_TRIGGER_VAL, &trigger_val);
		if(trigger_val!=NULL)
			val = atoi(trigger_val);
		
		WALLPAPERUI_DBG("festival_wallpaper_handle %d %d",type,val);
		if(val<0 || val>MAX_FESTIVAL)
		{
			val = 0;
		}
		
		if(type==1)
		{
			set_festival_as_value(data,val);
//			set_alarm_nearest_date_index(data,val);
		}
		else
		{
			reset_as_previous(data);
			check_today_is_holiday(data,val);
//			set_alarm_nearest_date_index(data,0);
		}

	}

	WALLPAPERUI_DBG("festival_wallpaper_handle end");
}