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){
107 if (!fgets(line, sizeof(line), stdin))
109 if ( strcmp(line,"yes") == 0){
112 } else if ( strcmp(line,"no") == 0){
116 fprintf(stdout," yes or no :");
119 err = notification_delete_all_by_type("bluetooth-frwk-bt-service", NOTIFICATION_TYPE_NOTI);
120 if (err != NOTIFICATION_ERROR_NONE) {
121 fprintf(stdout, "Unable to remove notifications");
126 static void __noti_changed_cb(void *data, notification_type_e type)
128 notification_h noti = NULL;
129 notification_list_h notification_list = NULL;
130 notification_list_h get_list = NULL;
131 int count = 0, group_id = 0, priv_id = 0, show_noti = 0, num = 1;
132 char *pkgname = NULL;
134 char *str_count = NULL;
136 bundle *user_data = NULL;
137 DBusGConnection *sys_conn;
138 DBusGProxy *agent_proxy;
139 DBusGProxy *obex_proxy;
142 const char *device_name = NULL;
143 const char *passkey = NULL;
144 const char *file = NULL;
145 const char *agent_path;
146 const char *event_type = NULL;
148 notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬ification_list);
149 if (notification_list) {
150 get_list = notification_list_get_head(notification_list);
151 noti = notification_list_get_data(get_list);
152 notification_get_id(noti, &group_id, &priv_id);
153 notification_get_pkgname(noti, &pkgname);
155 notification_get_application(noti, &pkgname);
158 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &str_count);
162 count = atoi(str_count);
164 notification_get_title(noti, &title, NULL);
165 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT , &content);
166 notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,NULL, &user_data);
168 fprintf(stdout, "NOTIFICATION: %s - %s - %s - %i - %i \n", pkgname, title, content, count, num);
170 event_type = bundle_get_val(user_data, "event-type");
172 if(!strcasecmp(event_type, "pin-request")) {
173 /* Not implemented */
174 fprintf(stdout," Not implemented\n");
176 } else if (!strcasecmp(event_type, "passkey-confirm-request")){
177 device_name = (gchar*) bundle_get_val(user_data, "device-name");
178 passkey = (gchar*) bundle_get_val(user_data, "passkey");
179 agent_path = bundle_get_val(user_data, "agent-path");
181 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
182 if (sys_conn == NULL) {
183 fprintf(stdout,"ERROR: Can't get on system bus");
187 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
189 fprintf(stdout,"create new agent_proxy failed\n");
193 __display_notification(__notify_passkey_confirm_request_accept_cb, __notify_passkey_confirm_request_cancel_cb,agent_proxy);
194 } else if (!strcasecmp(event_type, "passkey-request")) {
195 /* Not implemented */
196 fprintf(stdout," Not implemented\n");
198 } else if (!strcasecmp(event_type, "passkey-display-request")) {
199 /* Not implemented */
200 fprintf(stdout," Not implemented\n");
202 } else if (!strcasecmp(event_type, "authorize-request")) {
203 device_name = (gchar*) bundle_get_val(user_data, "device-name");
204 agent_path = bundle_get_val(user_data, "agent-path");
206 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
207 if (sys_conn == NULL) {
208 fprintf(stdout,"ERROR: Can't get on system bus");
212 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
214 fprintf(stdout,"create new agent_proxy failed\n");
218 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
219 } else if (!strcasecmp(event_type, "app-confirm-request")) {
220 /* Not implemented */
221 fprintf(stdout," Not implemented\n");
223 } else if (!strcasecmp(event_type, "push-authorize-request")) {
224 file = (gchar*) bundle_get_val(user_data, "file");
225 device_name = (gchar*) bundle_get_val(user_data, "device-name");
227 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
228 if (sys_conn == NULL) {
229 fprintf(stdout,"ERROR: Can't get on system bus");
233 obex_proxy = __bluetooth_create_obex_proxy(sys_conn);
235 fprintf(stdout,"create new obex_proxy failed\n");
239 __display_notification( __notify_push_authorize_request_accept_cb, __notify_push_authorize_request_cancel_cb,obex_proxy);
240 } else if (!strcasecmp(event_type, "confirm-overwrite-request")) {
241 /* Not implemented */
242 fprintf(stdout," Not implemented\n");
244 } else if (!strcasecmp(event_type, "keyboard-passkey-request")) {
245 /* Not implemented */
246 fprintf(stdout," Not implemented\n");
248 } else if (!strcasecmp(event_type, "bt-information")) {
249 /* Not implemented */
250 fprintf(stdout," Not implemented\n");
252 } else if (!strcasecmp(event_type, "exchange-request")) {
253 device_name = (gchar*) bundle_get_val(user_data, "device-name");
254 agent_path = bundle_get_val(user_data, "agent-path");
256 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
257 if (sys_conn == NULL) {
258 fprintf(stdout,"ERROR: Can't get on system bus");
262 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
264 fprintf(stdout,"create new agent_proxy failed\n");
268 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
269 } else if (!strcasecmp(event_type, "phonebook-request")) {
270 device_name = bundle_get_val(user_data, "device-name");
271 agent_path = bundle_get_val(user_data, "agent-path");
273 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
274 if (sys_conn == NULL) {
275 fprintf(stdout,"ERROR: Can't get on system bus");
279 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
281 fprintf(stdout,"create new agent_proxy failed\n");
285 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
286 } else if (!strcasecmp(event_type, "message-request")) {
287 device_name = bundle_get_val(user_data, "device-name");
288 agent_path = bundle_get_val(user_data, "agent-path");
290 sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
291 if (sys_conn == NULL) {
292 fprintf(stdout,"ERROR: Can't get on system bus");
296 agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
298 fprintf(stdout,"create new agent_proxy failed\n");
302 __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy);
305 if (notification_list != NULL) {
306 notification_free_list(notification_list);
307 notification_list = NULL;
314 main(int argc, char **argv)
317 fprintf(stderr, "ERROR: Cannot init Ecore!\n");
321 notification_resister_changed_cb(__noti_changed_cb, NULL);
322 ecore_main_loop_begin();