Implement system notification for incoming call 42/10142/2 tizen_ivi_genivi accepted/tizen/20130920.181638 accepted/tizen/20130920.213555 accepted/tizen/ivi/genivi/20140131.070502 accepted/tizen_ivi_stable/20131116.012154 ivi_oct_m2 submit/tizen/20130920.003432 submit/tizen_ivi_generic/20140131.065445 submit/tizen_ivi_genivi/20140131.070624 submit/tizen_ivi_milestone/20131113.054412 submit/tizen_ivi_stable/20131116.010025
authorJimmy Huang <jimmy.huang@intel.com>
Thu, 19 Sep 2013 23:26:51 +0000 (16:26 -0700)
committerJimmy Huang <jimmy.huang@intel.com>
Fri, 20 Sep 2013 00:28:58 +0000 (17:28 -0700)
Change-Id: Ie6883a8fb3d0ddb72b7427227e6c70f6ae756f08
Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
configure.ac
dialer/rc.c
packaging/lemolo.changes
packaging/lemolo.spec

index 348eb8a..2daff61 100644 (file)
@@ -70,6 +70,16 @@ fi
 
 AM_CONDITIONAL([HAVE_TIZEN], [test "$have_tizen" = "yes"])
 
+AC_ARG_ENABLE([notification],
+   AC_HELP_STRING([--enable-notification], [enable Tizen notification. @<:@default=auto@:>@]),
+   [want_notification="${enableval}"], [:])
+
+if test "$have_tizen" = "yes" -a "$want_notification" = "yes"; then
+     AC_DEFINE([HAVE_NOTIFICATION], 1, [Notification support])
+fi
+
+AM_CONDITIONAL([HAVE_NOTIFICATION], [test "$have_tizen" = "yes"])
+
 with_max_log_level="EINA_LOG_LEVEL_DBG"
 AC_ARG_WITH(maximum-log-level,
    [AC_HELP_STRING([--with-maximum-log-level=NUMBER],
index d9898e4..0fed809 100644 (file)
@@ -3,6 +3,11 @@
 #endif
 #include <Elementary.h>
 
+#ifdef HAVE_NOTIFICATION
+#include <appsvc.h>
+#include <notification.h>
+#endif
+
 #include "log.h"
 #include "gui.h"
 #include "ofono.h"
@@ -175,6 +180,80 @@ err_args:
        dbus_message_unref(msg);
 }
 
+#ifdef HAVE_NOTIFICATION
+static void _system_notification_emit(OFono_Call *call)
+{
+       const char *line_id, *type="", *content = "";
+       const char *title = "Incoming call";
+       Contact_Info *c_info;
+       notification_h noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti = notification_new(NOTIFICATION_TYPE_NOTI,
+                               NOTIFICATION_GROUP_ID_NONE,
+                               NOTIFICATION_PRIV_ID_NONE);
+       if (noti == NULL) {
+               ERR("Failed to create notification");
+               return;
+       }
+
+       noti_err = notification_set_pkgname(noti, "org.tizen.dialer");
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               ERR("Failed to set pkgname: %d", noti_err);
+               return;
+       }
+
+       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+                                       title,
+                                       NULL,
+                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               ERR("Failed to set notification title: %d", noti_err);
+               return;
+       }
+
+       line_id = ofono_call_line_id_get(call);
+       c_info = gui_contact_search(line_id, &type);
+
+       if (c_info) {
+               content = contact_info_full_name_get(c_info);
+       } else {
+               content = line_id;
+       }
+
+       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                                       content,
+                                       NULL,
+                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               ERR("Failed to set notification content: %d", noti_err);
+               return;
+       }
+
+       bundle *b = NULL;
+       b = bundle_create();
+       appsvc_set_pkgname(b, "org.tizen.dialer");
+       noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "Launch", NULL, b);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               ERR("Failed to set notification execute option: %d", noti_err);
+               return;
+       }
+
+       noti_err = notification_insert(noti, NULL);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               ERR("Failed to send notification: %d", noti_err);
+               return;
+       }
+       DBG("Sent notification: %s : %s", title, content);
+
+       noti_err = notification_free(noti);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               ERR("Failed to free notification: %d", noti_err);
+               return;
+       }
+}
+#endif
+
 static DBusMessage *_rc_waiting_call_get(E_DBus_Object *obj __UNUSED__,
                                                DBusMessage *msg)
 {
@@ -325,6 +404,9 @@ static void _rc_call_added_cb(void *data __UNUSED__, OFono_Call *call)
        waiting = call;
        _new_call_sig_emit(call);
 
+#ifdef HAVE_NOTIFICATION
+       _system_notification_emit(call);
+#endif
 }
 
 static void _rc_call_removed_cb(void *data __UNUSED__, OFono_Call *call)
index b9aa62e..9baa544 100644 (file)
@@ -1,3 +1,7 @@
+* Thu Sep 19 2013 Jimmy Huang <jimmy.huang@intel.com>
+- Implement system notification for incoming call
+- Fixed compilation warnings
+
 * Wed Aug 21 2013 Jimmy Huang <jimmy.huang@intel.com> submit/tizen/20130628.212219@b452f07
 - Updated version to 0.1.4
 - Init pulseaudio at startup
index d660994..c68e0bb 100644 (file)
@@ -1,3 +1,5 @@
+%bcond_with lemolo_option_notification
+
 Name:       lemolo
 Summary:    Ofono EFL Dialer
 Version:    0.1.4
@@ -33,7 +35,11 @@ handsfree profile over bluetooth.
 
 %build
 
-%autogen --enable-tizen
+%autogen \
+%if %{with lemolo_option_notification}
+--enable-notification \
+%endif
+--enable-tizen
 
 make %{?jobs:-j%jobs}