2 #include <notification.h>
6 #include <dbus/dbus-glib.h>
7 #include <dbus/dbus-glib-lowlevel.h>
14 BT_CORE_AGENT_TIMEOUT,
15 } bt_agent_accept_type_t;
18 typedef void (*bt_notification)(DBusGProxy *proxy);
21 __bluetooth_create_agent_proxy(DBusGConnection *sys_conn, const char *path)
23 return dbus_g_proxy_new_for_name (sys_conn,
30 __bluetooth_create_obex_proxy(DBusGConnection *sys_conn)
32 return dbus_g_proxy_new_for_name(sys_conn,
33 "org.bluez.frwk_agent",
34 "/org/obex/ops_agent",
35 "org.openobex.Agent");
39 __notify_passkey_confirm_request_accept_cb( DBusGProxy* agent_proxy)
41 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyConfirmation",
42 G_TYPE_UINT, BT_AGENT_ACCEPT,
43 G_TYPE_INVALID, G_TYPE_INVALID);
48 __notify_passkey_confirm_request_cancel_cb(DBusGProxy* agent_proxy)
51 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyConfirmation",
52 G_TYPE_UINT, BT_AGENT_CANCEL,
53 G_TYPE_INVALID, G_TYPE_INVALID);
58 __notify_push_authorize_request_accept_cb(DBusGProxy* obex_proxy)
61 dbus_g_proxy_call_no_reply( obex_proxy, "ReplyAuthorize",
62 G_TYPE_UINT, BT_AGENT_ACCEPT,
63 G_TYPE_INVALID, G_TYPE_INVALID);
68 __notify_push_authorize_request_cancel_cb(DBusGProxy* obex_proxy)
71 dbus_g_proxy_call_no_reply( obex_proxy, "ReplyAuthorize",
72 G_TYPE_UINT, BT_AGENT_CANCEL,
73 G_TYPE_INVALID, G_TYPE_INVALID);
78 __notify_authorize_request_accept_cb(DBusGProxy* agent_proxy)
81 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyAuthorize",
82 G_TYPE_UINT, BT_AGENT_ACCEPT,
83 G_TYPE_INVALID, G_TYPE_INVALID);
87 __notify_authorize_request_cancel_cb(DBusGProxy* agent_proxy)
90 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyAuthorize",
91 G_TYPE_UINT, BT_AGENT_CANCEL,
92 G_TYPE_INVALID, G_TYPE_INVALID);
97 __display_notification(bt_notification cb_1, bt_notification cb_2, DBusGProxy *proxy)
100 notification_error_e err = NOTIFICATION_ERROR_NONE;
105 fprintf(stdout, "Do you confirm yes or no ? ");
106 while ( bt_yesno != 0){
108 if ( strcmp(line,"yes") == 0){
111 } else if ( strcmp(line,"no") == 0){
115 fprintf(stdout," yes or no :");
118 err = notification_delete_all_by_type("bluetooth-frwk-bt-service", NOTIFICATION_TYPE_NOTI);
119 if (err != NOTIFICATION_ERROR_NONE) {
120 fprintf(stdout, "Unable to remove notifications");
125 static int __noti_changed_cb(void *data, notification_type_e type)
127 notification_h noti = NULL;
128 notification_list_h notification_list = NULL;
129 notification_list_h get_list = NULL;
130 int count = 0, group_id = 0, priv_id = 0, show_noti = 0, num = 1;
131 char *pkgname = NULL;
133 char *str_count = NULL;
135 bundle *user_data = NULL;
136 DBusGConnection *sys_conn;
137 DBusGProxy *agent_proxy;
138 DBusGProxy *obex_proxy;
141 const char *device_name = NULL;
142 const char *passkey = NULL;
143 const char *file = NULL;
144 const char *agent_path;
145 const char *event_type = NULL;
147 notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬ification_list);
148 if (notification_list) {
149 get_list = notification_list_get_head(notification_list);
150 noti = notification_list_get_data(get_list);
151 notification_get_id(noti, &group_id, &priv_id);
152 notification_get_pkgname(noti, &pkgname);
154 notification_get_application(noti, &pkgname);
157 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &str_count);
161 count = atoi(str_count);
163 notification_get_title(noti, &title, NULL);
164 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT , &content);
165 notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,NULL, &user_data);
167 fprintf(stdout, "NOTIFICATION: %s - %s - %s - %i - %i \n", pkgname, title, content, count, num);
169 event_type = bundle_get_val(user_data, "event-type");
171 if(!strcasecmp(event_type, "pin-request")) {
172 /* Not implemented */
173 fprintf(stdout," Not implemented\n");
175 } else if (!strcasecmp(event_type, "passkey-confirm-request")){
176 device_name = (gchar*) bundle_get_val(user_data, "device-name");
177 passkey = (gchar*) bundle_get_val(user_data, "passkey");
178 agent_path = bundle_get_val(user_data, "agent-path");
180 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
181 if (sys_conn == NULL) {
182 fprintf(stdout,"ERROR: Can't get on system bus");
186 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
188 fprintf(stdout,"create new agent_proxy failed\n");
192 __display_notification(__notify_passkey_confirm_request_accept_cb, __notify_passkey_confirm_request_cancel_cb,agent_proxy);
193 } else if (!strcasecmp(event_type, "passkey-request")) {
194 /* Not implemented */
195 fprintf(stdout," Not implemented\n");
197 } else if (!strcasecmp(event_type, "passkey-display-request")) {
198 /* Not implemented */
199 fprintf(stdout," Not implemented\n");
201 } else if (!strcasecmp(event_type, "authorize-request")) {
202 device_name = (gchar*) bundle_get_val(user_data, "device-name");
203 agent_path = bundle_get_val(user_data, "agent-path");
205 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
206 if (sys_conn == NULL) {
207 fprintf(stdout,"ERROR: Can't get on system bus");
211 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
213 fprintf(stdout,"create new agent_proxy failed\n");
217 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
218 } else if (!strcasecmp(event_type, "app-confirm-request")) {
219 /* Not implemented */
220 fprintf(stdout," Not implemented\n");
222 } else if (!strcasecmp(event_type, "push-authorize-request")) {
223 file = (gchar*) bundle_get_val(user_data, "file");
224 device_name = (gchar*) bundle_get_val(user_data, "device-name");
226 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
227 if (sys_conn == NULL) {
228 fprintf(stdout,"ERROR: Can't get on system bus");
232 obex_proxy = __bluetooth_create_obex_proxy(sys_conn);
234 fprintf(stdout,"create new obex_proxy failed\n");
238 __display_notification( __notify_push_authorize_request_accept_cb, __notify_push_authorize_request_cancel_cb,obex_proxy);
239 } else if (!strcasecmp(event_type, "confirm-overwrite-request")) {
240 /* Not implemented */
241 fprintf(stdout," Not implemented\n");
243 } else if (!strcasecmp(event_type, "keyboard-passkey-request")) {
244 /* Not implemented */
245 fprintf(stdout," Not implemented\n");
247 } else if (!strcasecmp(event_type, "bt-information")) {
248 /* Not implemented */
249 fprintf(stdout," Not implemented\n");
251 } else if (!strcasecmp(event_type, "exchange-request")) {
252 device_name = (gchar*) bundle_get_val(user_data, "device-name");
253 agent_path = bundle_get_val(user_data, "agent-path");
255 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
256 if (sys_conn == NULL) {
257 fprintf(stdout,"ERROR: Can't get on system bus");
261 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
263 fprintf(stdout,"create new agent_proxy failed\n");
267 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
268 } else if (!strcasecmp(event_type, "phonebook-request")) {
269 device_name = bundle_get_val(user_data, "device-name");
270 agent_path = bundle_get_val(user_data, "agent-path");
272 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
273 if (sys_conn == NULL) {
274 fprintf(stdout,"ERROR: Can't get on system bus");
278 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
280 fprintf(stdout,"create new agent_proxy failed\n");
284 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
285 } else if (!strcasecmp(event_type, "message-request")) {
286 device_name = bundle_get_val(user_data, "device-name");
287 agent_path = bundle_get_val(user_data, "agent-path");
289 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
290 if (sys_conn == NULL) {
291 fprintf(stdout,"ERROR: Can't get on system bus");
295 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
297 fprintf(stdout,"create new agent_proxy failed\n");
301 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
304 if (notification_list != NULL) {
305 notification_free_list(notification_list);
306 notification_list = NULL;
313 main(int argc, char **argv)
316 fprintf(stderr, "ERROR: Cannot init Ecore!\n");
320 notification_resister_changed_cb(__noti_changed_cb, NULL);
321 ecore_main_loop_begin();