4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include "cal_internal.h"
25 #include "cal_typedef.h"
26 #include "cal_inotify.h"
28 #include "cal_record.h"
29 #include "cal_handle.h"
31 int cal_client_db_add_changed_cb(calendar_h handle, const char* view_uri, void *callback, void* user_data)
35 cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
37 RETV_IF(NULL == handle, CALENDAR_ERROR_INVALID_PARAMETER);
38 RETV_IF(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER);
39 RETV_IF(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER);
41 type = cal_view_get_type(view_uri);
43 case CAL_RECORD_TYPE_CALENDAR:
44 ret = cal_inotify_subscribe(CAL_NOTI_TYPE_CALENDAR, CAL_NOTI_CALENDAR_CHANGED,
47 case CAL_RECORD_TYPE_EVENT:
48 ret = cal_inotify_subscribe(CAL_NOTI_TYPE_EVENT, CAL_NOTI_EVENT_CHANGED,
51 case CAL_RECORD_TYPE_TODO:
52 ret = cal_inotify_subscribe(CAL_NOTI_TYPE_TODO, CAL_NOTI_TODO_CHANGED,
57 ERR("Invalid view_uri(%s)", view_uri);
58 return CALENDAR_ERROR_INVALID_PARAMETER;
61 if (CALENDAR_ERROR_NONE != ret) {
63 ERR("cal_inotify_subscribe() Fail(%d)", ret);
68 return CALENDAR_ERROR_NONE;
71 int cal_client_db_remove_changed_cb(calendar_h handle, const char* view_uri, calendar_db_changed_cb callback, void* user_data)
75 cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
77 RETV_IF(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER);
78 RETV_IF(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER);
80 type = cal_view_get_type(view_uri);
82 case CAL_RECORD_TYPE_CALENDAR:
83 ret = cal_inotify_unsubscribe(CAL_NOTI_CALENDAR_CHANGED, callback, user_data);
85 case CAL_RECORD_TYPE_EVENT:
86 ret = cal_inotify_unsubscribe(CAL_NOTI_EVENT_CHANGED, callback, user_data);
88 case CAL_RECORD_TYPE_TODO:
89 ret = cal_inotify_unsubscribe(CAL_NOTI_TODO_CHANGED, callback, user_data);
93 ERR("Invalid view_uri(%s)", view_uri);
94 return CALENDAR_ERROR_INVALID_PARAMETER;
97 if (CALENDAR_ERROR_NONE != ret) {
99 ERR("cal_inotify_unsubscribe() Fail(%d)", ret);
104 return CALENDAR_ERROR_NONE;