From c5b3cdf74666a1fb86c40e09daab2ad5141f9c22 Mon Sep 17 00:00:00 2001 From: KyungwooNoh Date: Fri, 27 Sep 2013 13:53:39 +0900 Subject: [PATCH] merge tizen 2.2 Change-Id: Ic900a0d89d903f510d5e803ccd40dff63a801ca0 Signed-off-by: KyungwooNoh --- include/app_service.h | 18 ++++ include/app_service_private.h | 2 - packaging/capi-appfw-application.spec | 8 +- src/alarm.c | 158 +++++++--------------------------- src/service.c | 22 +++++ 5 files changed, 78 insertions(+), 130 deletions(-) diff --git a/include/app_service.h b/include/app_service.h index 21e2fd6..fc8bab3 100755 --- a/include/app_service.h +++ b/include/app_service.h @@ -31,6 +31,9 @@ extern "C" { */ +typedef struct _bundle_t bundle; + + /** * @brief Service handle. */ @@ -153,6 +156,10 @@ typedef enum */ #define SERVICE_OPERATION_PRINT "http://tizen.org/appcontrol/operation/print" +/** + * @brief Service operation : compose. + */ +#define SERVICE_OPERATION_COMPOSE "http://tizen.org/appcontrol/operation/compose" /** * @brief Service optional data : the subject of a message. @@ -274,6 +281,17 @@ int service_destroy(service_h service); /** + * @brief Converts the service handle to bundle data. + * + * @param [in] service The service handle + * @param [out] data a bundle data on success + * @return 0 on success, otherwise a negative error value. + * @retval #SERVICE_ERROR_NONE Successful + * @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter + */ +int service_to_bundle(service_h service, bundle **data); + +/** * @brief Sets the operation to be performed. * * @details The @a operation is the mandatory information for the launch request. diff --git a/include/app_service_private.h b/include/app_service_private.h index 6f71533..f5a4963 100755 --- a/include/app_service_private.h +++ b/include/app_service_private.h @@ -28,8 +28,6 @@ int service_create_request(bundle *data, service_h *service); int service_create_event(bundle *data, service_h *service); -int service_to_bundle(service_h service, bundle **data); - #ifdef __cplusplus } #endif diff --git a/packaging/capi-appfw-application.spec b/packaging/capi-appfw-application.spec index 67aa65b..7162d71 100755 --- a/packaging/capi-appfw-application.spec +++ b/packaging/capi-appfw-application.spec @@ -1,7 +1,7 @@ Name: capi-appfw-application Summary: An Application library in SLP C API -Version: 0.1.0 -Release: 52 +Version: 0.1.1 +Release: 55 Group: API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -48,6 +48,9 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -57,6 +60,7 @@ rm -rf %{buildroot} %manifest %{name}.manifest %{_libdir}/libcapi-appfw-application.so.* %manifest capi-appfw-application.manifest +/usr/share/license/%{name} %files devel %manifest %{name}.manifest diff --git a/src/alarm.c b/src/alarm.c index 5b787af..6d68d03 100755 --- a/src/alarm.c +++ b/src/alarm.c @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -41,50 +41,6 @@ typedef struct { bool* foreach_break; } alarm_foreach_item_cb_context; -static void alarm_get_interval(alarm_entry_t *alarm_info, int day_week, int *repeat_interval) -{ - time_t due_time = 0; - time_t current_time = 0; - struct tm duetime_tm; - int wday; - int interval = 0; - - time(¤t_time); - localtime_r(¤t_time, &duetime_tm); - wday = duetime_tm.tm_wday; - - due_time = mktime(&duetime_tm); - wday = duetime_tm.tm_wday; - - if (due_time > current_time && day_week == 0) - return; - - if (!(day_week & 1 << wday)) { - int day = wday + 1; - int next_week = 0; - interval = 1; - /*this week */ - - if (day == 7) { - day = 0; - next_week = 1; - } - - while (!(day_week & 1 << day) - && interval < 8) { - day += 1; - interval += 1; - - if (day == 7) { - day = 0; - next_week = 1; - } - - } - *repeat_interval = interval; - } -} - static int alarm_registered_alarm_cb_broker(int alarm_id, void *user_data) { alarm_foreach_item_cb_context* foreach_cb_context = NULL; @@ -131,7 +87,7 @@ static int convert_error_code_to_alarm(const char* function, alarm_error_t alarm LOGE("[%s] INVALID_DATE(0x%08x)", function, ALARM_ERROR_INVALID_DATE); return ALARM_ERROR_INVALID_DATE; break; - + case ERR_ALARM_NO_SERVICE_NAME: LOGE("[%s] INVALID_PARAMETER(0x%08x)", function, ALARM_ERROR_INVALID_PARAMETER); return ALARM_ERROR_INVALID_PARAMETER; @@ -145,11 +101,11 @@ static int convert_error_code_to_alarm(const char* function, alarm_error_t alarm case ALARMMGR_RESULT_SUCCESS: return ALARM_ERROR_NONE; break; - + default: - return ALARM_ERROR_INVALID_PARAMETER; + return ALARM_ERROR_INVALID_PARAMETER; } - + } static int _remove_alarm_cb(alarm_id_t alarm_id, void* user_param) @@ -160,11 +116,7 @@ static int _remove_alarm_cb(alarm_id_t alarm_id, void* user_param) int alarm_get_scheduled_date(int alarm_id, struct tm* date) { alarm_error_t result; - alarm_entry_t *entry = NULL; - alarm_date_t adate; - alarm_repeat_mode_t repeat=0; - int week_day=0; - int repeat_interval=0; + time_t due_time = 0; if (date == NULL) { @@ -172,59 +124,13 @@ int alarm_get_scheduled_date(int alarm_id, struct tm* date) return ALARM_ERROR_INVALID_PARAMETER; } - entry = alarmmgr_create_alarm(); - - result = alarmmgr_get_info(alarm_id, entry); + result = alarmmgr_get_next_duetime(alarm_id, &due_time); if (result != ALARMMGR_RESULT_SUCCESS) { - if (entry != NULL) { - alarmmgr_free_alarm(entry); - } - return convert_error_code_to_alarm(__FUNCTION__, result); - } - - result = alarmmgr_get_time(entry, &adate); - if (result != ALARMMGR_RESULT_SUCCESS) - { - if (entry != NULL) - { - alarmmgr_free_alarm(entry); - } return convert_error_code_to_alarm(__FUNCTION__, result); } - result = alarmmgr_get_repeat_mode(entry, &repeat, &week_day); - - if (result != ALARMMGR_RESULT_SUCCESS) - { - if (entry != NULL) - { - alarmmgr_free_alarm(entry); - } - return convert_error_code_to_alarm(__FUNCTION__, result); - } - - if ( repeat == ALARM_REPEAT_MODE_WEEKLY) - alarm_get_interval(entry, week_day, &repeat_interval); - else - repeat_interval=0; - - alarm_get_current_time(date); - - date->tm_year = adate.year - 1900; - date->tm_mon = adate.month - 1; - date->tm_mday = adate.day + repeat_interval; - date->tm_hour = adate.hour; - date->tm_min = adate.min; - date->tm_sec = adate.sec; - - mktime(date); - - result = alarmmgr_free_alarm(entry); - if (result != ALARMMGR_RESULT_SUCCESS) - { - return convert_error_code_to_alarm(__FUNCTION__, result); - } + localtime_r(&due_time, date); return ALARM_ERROR_NONE; @@ -242,7 +148,7 @@ int alarm_get_scheduled_period(int alarm_id, int* period) LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER); return ALARM_ERROR_INVALID_PARAMETER; } - + entry = alarmmgr_create_alarm(); result = alarmmgr_get_info(alarm_id, entry); @@ -251,17 +157,17 @@ int alarm_get_scheduled_period(int alarm_id, int* period) if (entry != NULL) { alarmmgr_free_alarm(entry); - } + } return convert_error_code_to_alarm(__FUNCTION__, result); } - + result = alarmmgr_get_repeat_mode(entry, &mode, &value); if (result != ALARMMGR_RESULT_SUCCESS) { if (entry != NULL) { alarmmgr_free_alarm(entry); - } + } return convert_error_code_to_alarm(__FUNCTION__, result); } @@ -271,10 +177,10 @@ int alarm_get_scheduled_period(int alarm_id, int* period) if (entry != NULL) { alarmmgr_free_alarm(entry); - } + } return convert_error_code_to_alarm(__FUNCTION__, result); } - + (*period) = value; return ALARM_ERROR_NONE; @@ -299,7 +205,7 @@ int alarm_schedule_after_delay(service_h service, int delay, int period, int *al } result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, delay, period, bundle_data, alarm_id); - + return convert_error_code_to_alarm(__FUNCTION__, result); } @@ -321,7 +227,7 @@ int alarm_schedule_at_date(service_h service, struct tm *date, int period_in_sec LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER); return ALARM_ERROR_INVALID_PARAMETER; } - + alarm_info = alarmmgr_create_alarm(); internal_time.year = date->tm_year + 1900; @@ -339,7 +245,7 @@ int alarm_schedule_at_date(service_h service, struct tm *date, int period_in_sec alarmmgr_free_alarm(alarm_info); return convert_error_code_to_alarm(__FUNCTION__, result); } - + if (period_in_second > 0) { @@ -355,9 +261,9 @@ int alarm_schedule_at_date(service_h service, struct tm *date, int period_in_sec alarmmgr_free_alarm(alarm_info); return convert_error_code_to_alarm(__FUNCTION__, result); } - + result = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT); - + if (result < 0) { alarmmgr_free_alarm(alarm_info); @@ -370,7 +276,7 @@ int alarm_schedule_at_date(service_h service, struct tm *date, int period_in_sec { alarmmgr_free_alarm(alarm_info); return convert_error_code_to_alarm(__FUNCTION__, result); - } + } alarmmgr_free_alarm(alarm_info); return ALARM_ERROR_NONE; @@ -413,7 +319,7 @@ int alarm_foreach_registered_alarm(alarm_registered_alarm_cb callback, void* use }; result = alarmmgr_enum_alarm_ids(alarm_registered_alarm_cb_broker, &foreach_cb_context); - + return convert_error_code_to_alarm(__FUNCTION__, result); } @@ -474,15 +380,15 @@ int alarm_schedule_with_recurrence_week_flag(service_h service, struct tm *date, { result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_WEEKLY, week_flag); } - + if (result < 0) { alarmmgr_free_alarm(alarm_info); return convert_error_code_to_alarm(__FUNCTION__, result); } - + result = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT); - + if (result < 0) { alarmmgr_free_alarm(alarm_info); @@ -501,7 +407,7 @@ int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag) alarm_entry_t *entry = NULL; alarm_repeat_mode_t mode; int value; - + if(week_flag == NULL) { LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER); @@ -516,10 +422,10 @@ int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag) if (entry != NULL) { alarmmgr_free_alarm(entry); - } + } return convert_error_code_to_alarm(__FUNCTION__, result); } - + result = alarmmgr_get_repeat_mode(entry, &mode, &value); if(mode != ALARM_REPEAT_MODE_WEEKLY) @@ -530,7 +436,7 @@ int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag) } return ALARM_ERROR_INVALID_PARAMETER; } - + if(result != ALARMMGR_RESULT_SUCCESS) { if (entry != NULL) @@ -546,12 +452,12 @@ int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag) if (entry != NULL) { alarmmgr_free_alarm(entry); - } + } return convert_error_code_to_alarm(__FUNCTION__, result); } - + (*week_flag) = value; - + return ALARM_ERROR_NONE; } @@ -571,7 +477,7 @@ int alarm_get_service(int alarm_id, service_h *service) { return ALARM_ERROR_INVALID_PARAMETER; } - + error_code = service_create_request(b, service); if(error_code != SERVICE_ERROR_NONE) diff --git a/src/service.c b/src/service.c index e01f86a..7c88313 100755 --- a/src/service.c +++ b/src/service.c @@ -60,6 +60,7 @@ struct service_s { int id; service_type_e type; bundle *data; + int launch_pid; }; typedef struct service_request_context_s { @@ -265,6 +266,7 @@ int service_create_request(bundle *data, service_h *service) } service_request->id = service_new_id(); + service_request->launch_pid = -1; *service = service_request; @@ -754,6 +756,26 @@ int service_send_launch_request(service_h service, service_reply_cb callback, vo } } + service->launch_pid = launch_pid; + + return SERVICE_ERROR_NONE; +} + + +int service_send_terminate_request(service_h service) +{ + if (service_valiate_service(service)) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + if(service->type != SERVICE_TYPE_REQUEST || service->launch_pid < 0) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + appsvc_subapp_terminate_request_pid(service->launch_pid); + return SERVICE_ERROR_NONE; } -- 2.7.4