2 #include <notification.h>
6 #include <dbus/dbus-glib.h>
7 #include <dbus/dbus-glib-lowlevel.h>
10 #include <libwlmessage.h>
17 BT_CORE_AGENT_TIMEOUT,
18 } bt_agent_accept_type_t;
21 typedef void (*bt_notification)(DBusGProxy *proxy);
24 __bluetooth_create_agent_proxy(DBusGConnection *sys_conn, const char *path)
26 return dbus_g_proxy_new_for_name (sys_conn,
33 __bluetooth_create_obex_proxy(DBusGConnection *sys_conn)
35 return dbus_g_proxy_new_for_name(sys_conn,
36 "org.bluez.frwk_agent",
37 "/org/obex/ops_agent",
38 "org.openobex.Agent");
42 __notify_passkey_confirm_request_accept_cb( DBusGProxy* agent_proxy)
44 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyConfirmation",
45 G_TYPE_UINT, BT_AGENT_ACCEPT,
46 G_TYPE_INVALID, G_TYPE_INVALID);
51 __notify_passkey_confirm_request_cancel_cb(DBusGProxy* agent_proxy)
54 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyConfirmation",
55 G_TYPE_UINT, BT_AGENT_CANCEL,
56 G_TYPE_INVALID, G_TYPE_INVALID);
61 __notify_push_authorize_request_accept_cb(DBusGProxy* obex_proxy)
64 dbus_g_proxy_call_no_reply( obex_proxy, "ReplyAuthorize",
65 G_TYPE_UINT, BT_AGENT_ACCEPT,
66 G_TYPE_INVALID, G_TYPE_INVALID);
71 __notify_push_authorize_request_cancel_cb(DBusGProxy* obex_proxy)
74 dbus_g_proxy_call_no_reply( obex_proxy, "ReplyAuthorize",
75 G_TYPE_UINT, BT_AGENT_CANCEL,
76 G_TYPE_INVALID, G_TYPE_INVALID);
81 __notify_authorize_request_accept_cb(DBusGProxy* agent_proxy)
84 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyAuthorize",
85 G_TYPE_UINT, BT_AGENT_ACCEPT,
86 G_TYPE_INVALID, G_TYPE_INVALID);
90 __notify_authorize_request_cancel_cb(DBusGProxy* agent_proxy)
93 dbus_g_proxy_call_no_reply( agent_proxy, "ReplyAuthorize",
94 G_TYPE_UINT, BT_AGENT_CANCEL,
95 G_TYPE_INVALID, G_TYPE_INVALID);
100 __display_notification(bt_notification cb_1, bt_notification cb_2, DBusGProxy *proxy)
103 notification_error_e err = NOTIFICATION_ERROR_NONE;
109 struct wlmessage *wlmessage = wlmessage_create();
110 wlmessage_set_message(wlmessage, "Do you confirm ?");
111 wlmessage_add_button(wlmessage, 1, "Yes");
112 wlmessage_add_button(wlmessage, 0, "No");
113 wlmessage_set_default_button(wlmessage, 1);
114 bt_yesno = wlmessage_show(wlmessage, NULL);
115 wlmessage_destroy(wlmessage);
119 else if (bt_yesno == 0)
122 fprintf(stdout, "Do you confirm yes or no ? ");
123 while ( bt_yesno != 0){
124 if (!fgets(line, sizeof(line), stdin))
126 if ( strcmp(line,"yes") == 0){
129 } else if ( strcmp(line,"no") == 0){
133 fprintf(stdout," yes or no :");
137 err = notification_delete_all_by_type("bluetooth-frwk-bt-service", NOTIFICATION_TYPE_NOTI);
138 if (err != NOTIFICATION_ERROR_NONE) {
139 fprintf(stdout, "Unable to remove notifications");
144 static void __noti_changed_cb(void *data, notification_type_e type)
146 notification_h noti = NULL;
147 notification_list_h notification_list = NULL;
148 notification_list_h get_list = NULL;
149 int count = 0, group_id = 0, priv_id = 0, show_noti = 0, num = 1;
150 char *pkgname = NULL;
152 char *str_count = NULL;
154 bundle *user_data = NULL;
155 DBusGConnection *sys_conn;
156 DBusGProxy *agent_proxy;
157 DBusGProxy *obex_proxy;
160 const char *device_name = NULL;
161 const char *passkey = NULL;
162 const char *file = NULL;
163 const char *agent_path;
164 const char *event_type = NULL;
166 notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬ification_list);
167 if (notification_list) {
168 get_list = notification_list_get_head(notification_list);
169 noti = notification_list_get_data(get_list);
170 notification_get_id(noti, &group_id, &priv_id);
171 notification_get_pkgname(noti, &pkgname);
173 notification_get_application(noti, &pkgname);
176 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &str_count);
180 count = atoi(str_count);
182 notification_get_title(noti, &title, NULL);
183 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT , &content);
184 notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,NULL, &user_data);
186 fprintf(stdout, "NOTIFICATION: %s - %s - %s - %i - %i \n", pkgname, title, content, count, num);
188 event_type = bundle_get_val(user_data, "event-type");
190 if(!strcasecmp(event_type, "pin-request")) {
191 /* Not implemented */
192 fprintf(stdout," Not implemented\n");
194 } else if (!strcasecmp(event_type, "passkey-confirm-request")){
195 device_name = (gchar*) bundle_get_val(user_data, "device-name");
196 passkey = (gchar*) bundle_get_val(user_data, "passkey");
197 agent_path = bundle_get_val(user_data, "agent-path");
199 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
200 if (sys_conn == NULL) {
201 fprintf(stdout,"ERROR: Can't get on system bus");
205 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
207 fprintf(stdout,"create new agent_proxy failed\n");
211 __display_notification(__notify_passkey_confirm_request_accept_cb, __notify_passkey_confirm_request_cancel_cb,agent_proxy);
212 } else if (!strcasecmp(event_type, "passkey-request")) {
213 /* Not implemented */
214 fprintf(stdout," Not implemented\n");
216 } else if (!strcasecmp(event_type, "passkey-display-request")) {
217 /* Not implemented */
218 fprintf(stdout," Not implemented\n");
220 } else if (!strcasecmp(event_type, "authorize-request")) {
221 device_name = (gchar*) bundle_get_val(user_data, "device-name");
222 agent_path = bundle_get_val(user_data, "agent-path");
224 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
225 if (sys_conn == NULL) {
226 fprintf(stdout,"ERROR: Can't get on system bus");
230 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
232 fprintf(stdout,"create new agent_proxy failed\n");
236 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
237 } else if (!strcasecmp(event_type, "app-confirm-request")) {
238 /* Not implemented */
239 fprintf(stdout," Not implemented\n");
241 } else if (!strcasecmp(event_type, "push-authorize-request")) {
242 file = (gchar*) bundle_get_val(user_data, "file");
243 device_name = (gchar*) bundle_get_val(user_data, "device-name");
245 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
246 if (sys_conn == NULL) {
247 fprintf(stdout,"ERROR: Can't get on system bus");
251 obex_proxy = __bluetooth_create_obex_proxy(sys_conn);
253 fprintf(stdout,"create new obex_proxy failed\n");
257 __display_notification( __notify_push_authorize_request_accept_cb, __notify_push_authorize_request_cancel_cb,obex_proxy);
258 } else if (!strcasecmp(event_type, "confirm-overwrite-request")) {
259 /* Not implemented */
260 fprintf(stdout," Not implemented\n");
262 } else if (!strcasecmp(event_type, "keyboard-passkey-request")) {
263 /* Not implemented */
264 fprintf(stdout," Not implemented\n");
266 } else if (!strcasecmp(event_type, "bt-information")) {
267 /* Not implemented */
268 fprintf(stdout," Not implemented\n");
270 } else if (!strcasecmp(event_type, "exchange-request")) {
271 device_name = (gchar*) bundle_get_val(user_data, "device-name");
272 agent_path = bundle_get_val(user_data, "agent-path");
274 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
275 if (sys_conn == NULL) {
276 fprintf(stdout,"ERROR: Can't get on system bus");
280 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
282 fprintf(stdout,"create new agent_proxy failed\n");
286 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
287 } else if (!strcasecmp(event_type, "phonebook-request")) {
288 device_name = bundle_get_val(user_data, "device-name");
289 agent_path = bundle_get_val(user_data, "agent-path");
291 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
292 if (sys_conn == NULL) {
293 fprintf(stdout,"ERROR: Can't get on system bus");
297 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
299 fprintf(stdout,"create new agent_proxy failed\n");
303 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
304 } else if (!strcasecmp(event_type, "message-request")) {
305 device_name = bundle_get_val(user_data, "device-name");
306 agent_path = bundle_get_val(user_data, "agent-path");
308 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
309 if (sys_conn == NULL) {
310 fprintf(stdout,"ERROR: Can't get on system bus");
314 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
316 fprintf(stdout,"create new agent_proxy failed\n");
320 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
323 if (notification_list != NULL) {
324 notification_free_list(notification_list);
325 notification_list = NULL;
332 main(int argc, char **argv)
335 fprintf(stderr, "ERROR: Cannot init Ecore!\n");
339 notification_resister_changed_cb(__noti_changed_cb, NULL);
340 ecore_main_loop_begin();