tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.080247 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:15:08 +0000 (22:15 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:15:08 +0000 (22:15 +0900)
.gitignore [new file with mode: 0755]
CMakeLists.txt
SLP_Heynoti_PG.h
heynoti.c
heynoti.manifest [new file with mode: 0644]
image/SLP_heynoti_PG_images_logical_view.png [new file with mode: 0644]
include/heynoti-log.h
packaging/heynoti.spec
test/tst_publish.c

diff --git a/.gitignore b/.gitignore
new file mode 100755 (executable)
index 0000000..6c53821
--- /dev/null
@@ -0,0 +1,12 @@
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*.ipk
+*~
index db58bb8..fa443c4 100755 (executable)
@@ -49,7 +49,8 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
 
 ADD_EXECUTABLE(heynotitool heynotitool.c)
-TARGET_LINK_LIBRARIES(heynotitool ${pkgs_LDFLAGS} ${glib_pkg_LDFLAGS} ${PROJECT_NAME})
+SET_TARGET_PROPERTIES(heynotitool PROPERTIES COMPILE_FLAGS "-fPIE")
+TARGET_LINK_LIBRARIES(heynotitool ${pkgs_LDFLAGS} ${glib_pkg_LDFLAGS} ${PROJECT_NAME} "-pie")
 INSTALL(TARGETS heynotitool DESTINATION bin)
 
 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
@@ -63,5 +64,5 @@ FOREACH(hfile ${HEADERS})
 ENDFOREACH(hfile)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/SLP_Heynoti_PG.h DESTINATION include/${PROJECT_NAME})
 
-ADD_SUBDIRECTORY(test)
+#ADD_SUBDIRECTORY(test)
 
index f1bc1b6..a82a1d0 100644 (file)
 
 /**
  *
- * @ingroup   SLP_PG 
+ * @ingroup   SLP_PG
  * @defgroup   HEYNOTI_PG HEY(ligHt Easy speedY) Notification
 @{
 <h1 class="pg">Introduction</h1>
 
-Heynoti is notification system which uses the Linux kernel inotify subsystem. <br>
-It is ligHt, Easy, speedY, so that is named 'Heynoti'. <br>
-But it doesn't support data delivery, is just sent event notification. <br>
-If developers want to send event with data like integer, string, they have to use DBus for IPC. <br>
-Heynoti is based on inotify in Linux Sytem. So for more information about inotify, refer to manpage(inotify(7)).
+<p>Heynoti is notification system which uses the Linux kernel inotify subsystem. </p>
+<p> It is ligHt, Easy, speedY, so that is named 'Heynoti'. </p>
+<p> But it doesn't support data delivery, is just sent event notification. </p>
+<p> If developers want to send event with data like integer, string, they have to use DBus for IPC. </p>>
+<p> Heynoti is based on inotify in Linux Sytem. So for more information about inotify, refer to manpage(inotify(7)).</p>
 
-@image html SLP_Heynoti_PG_image01.png
+<h1 class="pg">Features</h1>
+<ul>
+       <li>HEYNOTI provides a mechanism to define/undefine a notification </li>
+       <li>It provides a mechanism to subscribe for a notification </li>
+       <li>It supports unsubscription from subscription</li>
+       <li>It provides a mechanism to publish a notification</li>
+</ul>
 
 <h2 class="pg">Properties</h2>
-- HEY(ligHt Easy speedY) Notification
-- Convenient API
-- Header File : heynoti.h
+       <ul>
+               <li> light weight Notification system. </li>
+               <li> Very fast Notifcation delivery </li>
+               <li> Convenient API's to use </li>
+               <li> It does not send event data </li>
+       </ul>
+
+<h1 class="pg"> Heynoti Logical view diagram </h1>
+\image html SLP_heynoti_PG_images_logical_view.png "Picture 1. Logical view"
+
+
+<h1 class="pg"> Heynoti Functional diagram </h1>
+\image html SLP_Heynoti_PG_image01.png "Picture 2. Functional  view"
+
 
 <h1 class="pg">Programming Guide</h1>
-For receiving notification, we can use heynoti_attach_handler() or heynoti_poll_event().
+<h2 class="pg"> Header file </h2>
+<p> header file name :<strong> heynoti.h </strong> </p>
+
+<p>For receiving notification, we can use heynoti_attach_handler() or heynoti_poll_event().
 heynoti_attach_handler() use g_main_loop of default context.
-For g_main_loop, refer to glib manual.
+For g_main_loop, refer to glib manual.</p>
 
 @code
 #include <stdio.h>
@@ -88,7 +108,7 @@ int main(int argc, const char *argv[])
 }
 @endcode
 
-And heynoti_poll_event() use polling mechanism. Therefore the process block until notification is received.
+<p> And heynoti_poll_event() use polling mechanism. Therefore the process block until notification is received.</p>
 
 @code
 #include <stdio.h>
@@ -116,14 +136,14 @@ int main(int argc, const char *argv[])
 
        if(!heynoti_poll_event(fd))
                fprintf(stderr, "heynoti_poll_event FAIL\n");
-       
+
        heynoti_unsubscribe(fd, "test_testnoti", callback);
 
        return 0;
 }
 @endcode
 
-If developer want to send notification message to the other process that watch the event, call heynoti_publish() API.
+<p> If developer want to send notification message to the other process that watch the event, call heynoti_publish() API. </p>
 
 @code
 #include <stdio.h>
@@ -139,12 +159,12 @@ int main(int argc, char** argv)
                fprintf(stderr, "heynoti_publish() FAIL\n");
                return -1;
        }
-               
+
        return 0;
 }
 @endcode
 
-Also, heynoti can do the monitoring of file. This is a basic faculty of inotify.
+<p> Also, heynoti can do the monitoring of file. This is a basic faculty of inotify. </p>
 
 @code
 #include <stdio.h>
index 6956eb6..bf1f437 100755 (executable)
--- a/heynoti.c
+++ b/heynoti.c
@@ -60,7 +60,6 @@ static int __make_noti_root(const char *p);
 static int __make_noti_file(const char *p);
 static inline int __make_noti_path(char *path, int size, const char *name);
 static int __read_proc(const char *path, char *buf, int size);
-static int __get_kern_ver();
 static void __clear_nslot_list(GList *g_ns);
 static struct noti_cont *__get_noti_cont(int fd);
 static int __handle_callback(struct noti_cont *nc, int wd, uint32_t mask);
@@ -128,7 +127,7 @@ static int __make_noti_file(const char *p)
 
        if ((fd = open(p, O_RDONLY)) == -1)
                return -1;
-               
+
        close(fd);
 
        return 0;
@@ -160,10 +159,9 @@ static int __read_proc(const char *path, char *buf, int size)
        return ret;
 }
 
-static int kern_ver;           /* Kernel version */
 #define PROC_VERSION "/proc/version"
 
-static int __get_kern_ver()
+static int __check_kern_ver()
 {
        struct utsname nm;
        int ret;
@@ -172,8 +170,6 @@ static int __get_kern_ver()
        int v2;
        int v3;
 
-       util_retv_if(kern_ver != 0, kern_ver);
-
        ret = uname(&nm);
        if (ret == 0) {
                strncpy(buf, nm.release, sizeof(buf));
@@ -186,8 +182,11 @@ static int __get_kern_ver()
        }
 
        if (ret == 3) {
-               kern_ver = KERNEL_VERSION(v1, v2, v3);
-               return kern_ver;
+               if(KERNEL_VERSION(v1, v2, v3) < KERNEL_VERSION(2, 6, 13)) {
+                       return -1;
+               } else {
+                       return 0;
+               }
        }
 
        return -1;
@@ -248,7 +247,7 @@ static int __handle_event(int fd)
 {
        int r;
        struct inotify_event ie;
-       char name[FILENAME_MAX];
+       char name[FILENAME_MAX] = {0, };
 
        struct noti_cont *nc;
 
@@ -261,10 +260,16 @@ static int __handle_event(int fd)
                if (nc)
                        __handle_callback(nc, ie.wd, ie.mask);
 
-               if (ie.len > 0)
-                       read(fd, name, ie.len);
+               if(ie.len > SSIZE_MAX)
+                       return -1;
 
-               r = read(fd, &ie, sizeof(ie));
+               if (ie.len > 0u) {
+                       r = read(fd, name, (ie.len > FILENAME_MAX) ? (size_t)FILENAME_MAX : (size_t) ie.len);
+               }
+
+               if(r > 0) {
+                       r = read(fd, &ie, sizeof(ie));
+               }
        }
 
        return 0;
@@ -526,7 +531,7 @@ API int heynoti_init()
 
        struct noti_cont *nc;
 
-       if (__get_kern_ver() < KERNEL_VERSION(2, 6, 13)) {
+       if(__check_kern_ver() < 0) {
                UTIL_ERR("inotify requires kernel version >= 2.6.13 ");
                errno = EPERM;
                return -1;
@@ -535,8 +540,10 @@ API int heynoti_init()
        fd = inotify_init();
        util_retvm_if(fd == -1, -1, "inotify init: %s", strerror(errno));
 
-       fcntl(fd, F_SETFD, FD_CLOEXEC);
-       fcntl(fd, F_SETFL, O_NONBLOCK);
+       r = fcntl(fd, F_SETFD, FD_CLOEXEC);
+       util_retvm_if(r < 0, -1, "fcntl error : %s", strerror(errno));
+       r = fcntl(fd, F_SETFL, O_NONBLOCK);
+       util_retvm_if(r < 0, -1, "fcntl error : %s", strerror(errno));
 
        r = __make_noti_root(noti_root);
        if (r == -1) {
diff --git a/heynoti.manifest b/heynoti.manifest
new file mode 100644 (file)
index 0000000..7b2dd11
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+        <assign>
+                <filesystem path="/usr/bin/heynotitool" exec_label="none" />
+        </assign>
+</manifest>
diff --git a/image/SLP_heynoti_PG_images_logical_view.png b/image/SLP_heynoti_PG_images_logical_view.png
new file mode 100644 (file)
index 0000000..1add2c8
Binary files /dev/null and b/image/SLP_heynoti_PG_images_logical_view.png differ
index 1a5a6a9..769c147 100755 (executable)
@@ -70,9 +70,9 @@
 #include <dlog.h>
 #define UTIL_DLOG(prio, fmt, arg...) \
                do { } while (0)
-#define UTIL_INFO(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
-#define UTIL_ERR(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
-#define _UTIL_DBG(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define UTIL_INFO(fmt, arg...) LOGD(fmt,##arg)
+#define UTIL_ERR(fmt, arg...) LOGE(fmt,##arg)
+#define _UTIL_DBG(fmt, arg...) LOGD(fmt,##arg)
 #else
 #include <syslog.h>
 
index e96f526..b5f196e 100644 (file)
@@ -2,25 +2,21 @@
 Name:       heynoti
 Summary:    HEY (ligHt Easy speedy) notification library
 Version:    0.0.2
-Release:    35
+Release:    45
 Group:      System/Libraries
-License:    Apache License, Version 2.0
+License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
-
 BuildRequires:  cmake
-
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(ecore)
-
+#BuildRequires:  pkgconfig(ecore)
 
 %description
 lightweight notification library, service APIs
 
-
 %package devel
 Summary:    Notification library
 Group:      Development/Libraries
@@ -30,21 +26,20 @@ Requires:   heynoti
 %description devel
 heynoti API (devel)
 
-
 %prep
 %setup -q
 
-
 %build
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_BUILD_TYPE="Debug"
 
-
 make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 %make_install
 
+mkdir -p %{buildroot}/usr/share/license
+install LICENSE %{buildroot}/usr/share/license/%{name}
 
 %post
 /sbin/ldconfig
@@ -53,13 +48,13 @@ chmod 1755 /opt/share/noti
 
 %postun -p /sbin/ldconfig
 
-
 %files
+%manifest heynoti.manifest
 %defattr(-,root,root,-)
 %{_libdir}/libheynoti.so.0
 %{_libdir}/libheynoti.so.0.0.2
 %{_bindir}/heynotitool
-
+/usr/share/license/%{name}
 
 %files devel
 %defattr(-,root,root,-)
index f49667e..63fc162 100755 (executable)
@@ -31,8 +31,10 @@ int main(int argc, char *argv[])
        if (argc > 1) {
                char p[FILENAME_MAX];
 
-               if (!heynoti_get_snoti_name(argv[1], p, sizeof(p))) ;
-               heynoti_publish(p);
+               if (!heynoti_get_snoti_name(argv[1], p, sizeof(p)))
+                       heynoti_publish(p);
+               else
+                       printf("noti name error\n");
        } else {
                printf("usage) %s NOTI_NAME\n", argv[0]);
        }