summaryrefslogtreecommitdiff
path: root/src/agent/service-engine/se_notification.c
blob: 1fdf1c5b39d4fd2af4d4bbc3aab61cfbb60b0751 (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
/*
 * oma-ds-agent
 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
 *
 * 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.
 */

/**
 *   @SE_Notification.c
 *   @version									0.1
 *   @brief										This file is the source file of implementation of notify to ui
 */

#include <aul.h>

#include <sync_agent.h>

#include "service-engine/se_notification.h"
#include "service-engine/se_sync.h"

#ifndef OMADS_AGENT_LOG
#undef LOG_TAG
#define LOG_TAG "OMA_DS_SE"
#endif

#define NOTI_KEY	"OMADS"
#define OMA_DS_UI_PKG "ug-setting-synchronise-efl"

se_error_type_e send_noti_session_process(char *profile, char *sync_type, char *progress, char *error)
{
	_EXTERN_FUNC_ENTER;

	se_error_type_e err = SE_INTERNAL_OK;

	int notiType = 1;
	sync_agent_event_data_s *noti = NULL;

	if (profile == NULL) {
		_DEBUG_ERROR("Not Defined profile");
		err = SE_INTERNAL_NOT_DEFINED;
		goto error;
	}

	noti = sync_agent_create_noti(notiType);
	if (noti == NULL) {
		_DEBUG_ERROR("failed to sync_agent_create_noti");
		err = SE_INTERNAL_NO_MEMORY;
		goto error;
	}

	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_type);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)progress);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)error);

	sync_agent_event_error_e event_err;
	sync_agent_send_noti(NOTI_KEY, noti, NULL, NULL, &event_err);
	if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
		if (aul_app_is_running(OMA_DS_UI_PKG)) {
			_DEBUG_ERROR("failed to sync_agent_send_noti");
			err = SE_INTERNAL_EVENT_ERROR;
			goto error;
		}
	}

 error:

	sync_agent_free_noti(noti);

	_EXTERN_FUNC_EXIT;
	return err;
}

se_error_type_e send_noti_process_update(char *profile_dir_name, char *sync_type, char *uri, char *progress_status, char *operation_type, int is_from_server, int total_per_operation, int synced_per_operation, int total_per_db, int synced_per_db)
{
	_EXTERN_FUNC_ENTER;

	se_error_type_e err = SE_INTERNAL_OK;

	int notiType = 2;
	sync_agent_event_data_s *noti = NULL;

	if (profile_dir_name == NULL) {
		_DEBUG_ERROR("Not Defined profileDirName");
		err = SE_INTERNAL_NOT_DEFINED;
		goto error;
	}

	noti = sync_agent_create_noti(notiType);
	if (noti == NULL) {
		_DEBUG_ERROR("failed to sync_agent_create_noti");
		err = SE_INTERNAL_NO_MEMORY;
		goto error;
	}

	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_dir_name);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_type);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)uri);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)progress_status);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)operation_type);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &is_from_server);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &total_per_operation);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &synced_per_operation);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &total_per_db);
	sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &synced_per_db);

	sync_agent_event_error_e event_err;
	sync_agent_send_noti(NOTI_KEY, noti, NULL, NULL, &event_err);
	if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
		if (aul_app_is_running(OMA_DS_UI_PKG)) {
			_DEBUG_ERROR("failed to sync_agent_send_noti");
			err = SE_INTERNAL_EVENT_ERROR;
			goto error;
		}
	}

 error:

	sync_agent_free_noti(noti);

	_EXTERN_FUNC_EXIT;
	return err;
}