Fix errors in askuser-notification library 89/122489/13
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Sun, 2 Apr 2017 12:15:47 +0000 (14:15 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Mon, 3 Apr 2017 17:13:21 +0000 (19:13 +0200)
* Fix name conflict between askuser-notification service and
  askuser-notification library
* The datagram socket was marked as stream socket.
* The stream socket was marked as datagram socket.
* Change order of calls: updateFd and erase descriptor.
* Add stream socket and datagram socket to askuser-notification.service.

Change-Id: I05d097ba15f038a4f7e88c323ae8790fe7d3eb14

12 files changed:
CMakeLists.txt
packaging/askuser-notification.spec
packaging/askuser.spec
src/agent/notification-daemon/CMakeLists.txt
src/common/protocol/CMakeLists.txt
src/common/protocol/ask-user-config.cpp
src/common/protocol/askuser-notification-ipc.pc.in [moved from src/common/protocol/askuser-notification.pc.in with 87% similarity]
src/common/protocol/channel.cpp
src/common/protocol/main.cpp
src/common/protocol/sock.cpp
src/common/protocol/sock.h
systemd/askuser-notification.service

index 538b952..305d0d8 100644 (file)
@@ -90,7 +90,7 @@ SET(ASKUSER_PATH ${PROJECT_SOURCE_DIR}/src)
 IF (BUILD_ASKUSER)
     SET(TARGET_ASKUSER "askuser")
     SET(TARGET_ASKUSER_COMMON "askuser-common")
-    SET(TARGET_ASKUSER_NOTIFICATION_LIB "askuser-notification")
+    SET(TARGET_ASKUSER_NOTIFICATION_LIB "askuser-notification-ipc")
     SET(TARGET_PLUGIN_SERVICE "askuser-plugin-service")
     SET(TARGET_PLUGIN_CLIENT "askuser-plugin-client")
     SET(TARGET_PRIVACYDENIED_PLUGIN_CLIENT "privacy-denied-plugin-client")
index ffcf031..8932ceb 100644 (file)
@@ -22,6 +22,7 @@ BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(capi-ui-efl-util)
 BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(askuser-notification-ipc)
 BuildRequires: coregl
 BuildRequires: edje-bin
 
index e1530d4..aef453c 100644 (file)
@@ -166,12 +166,12 @@ systemctl restart cynara.service
 %files -n libaskuser-notification
 %manifest libaskuser-notification.manifest
 %license LICENSE
-%{_libdir}/libaskuser-notification.so.*
+%{_libdir}/libaskuser-notification-ipc.so.*
 
 %files -n libaskuser-notification-devel
-%{_libdir}/libaskuser-notification.so
+%{_libdir}/libaskuser-notification-ipc.so
 %{_includedir}/askuser-notification
-%{_libdir}/pkgconfig/askuser-notification.pc
+%{_libdir}/pkgconfig/askuser-notification-ipc.pc
 
 %files -n askuser-plugins
 %manifest askuser-plugins.manifest
index 6010ffb..6e89216 100644 (file)
@@ -13,6 +13,7 @@ PKG_CHECK_MODULES(ASKUSER_NOTIFICATION_DEP
     capi-ui-efl-util
     capi-system-info
     security-privilege-manager
+    askuser-notification-ipc
 )
 
 INCLUDE_DIRECTORIES(SYSTEM
index f9aa188..90b11ca 100644 (file)
@@ -21,7 +21,7 @@ SET(PROTOCOL_PATH ${ASKUSER_PATH}/common/protocol)
 SET(ASKUSER_NOTIFICATION_VERSION_MAJOR 0)
 SET(ASKUSER_NOTIFICATION_VERSION ${ASKUSER_NOTIFICATION_VERSION_MAJOR}.1.0)
 
-SET(PC_FILE "askuser-notification.pc")
+SET(PC_FILE "askuser-notification-ipc.pc")
 
 PKG_CHECK_MODULES(ASKUSER_NOTIFICATION_DEP
     REQUIRED
@@ -30,6 +30,7 @@ PKG_CHECK_MODULES(ASKUSER_NOTIFICATION_DEP
 
 INCLUDE_DIRECTORIES(
     ${PROTOCOL_PATH}
+    SYSTEM
     ${ASKUSER_NOTIFICATION_DEP_INCLUDE_DIRS}
   )
 
@@ -55,6 +56,8 @@ SET_TARGET_PROPERTIES(${TARGET_ASKUSER_NOTIFICATION_LIB}
         VERSION ${ASKUSER_NOTIFICATION_VERSION}
     )
 
+LINK_DIRECTORIES(${ASKUSER_NOTIFICATION_DEP_LIBRARY_DIRS})
+
 TARGET_LINK_LIBRARIES(${TARGET_ASKUSER_NOTIFICATION_LIB} ${ASKUSER_NOTIFICATION_DEP_LIBRARIES})
 TARGET_LINK_LIBRARIES(${TARGET_ASKUSER_NOTIFICATION_TEST} ${TARGET_ASKUSER_NOTIFICATION_LIB})
 
index a7ab80d..19f9364 100644 (file)
@@ -27,10 +27,10 @@ const std::string SOCKET_DGRAM_NAME("/askuser-notification-datagram.socket");
 } // namespace anonymous
 
 std::string getDatagramSocketPath(uid_t uid) {
-    return USER_EXT_PATH + std::to_string(uid) + SOCKET_STREAM_NAME;
+    return USER_EXT_PATH + std::to_string(uid) + SOCKET_DGRAM_NAME;
 }
 
 std::string getStreamSocketPath(uid_t uid) {
-    return USER_EXT_PATH + std::to_string(uid) + SOCKET_DGRAM_NAME;
+    return USER_EXT_PATH + std::to_string(uid) + SOCKET_STREAM_NAME;
 }
 
@@ -8,5 +8,5 @@ includedir=@INCLUDE_INSTALL_DIR@
 Name: askuser-notification
 Description: askuser-notification library
 Version: @ASKUSER_NOTIFICATION_VERSION@
-Libs: -L${libdir} -laskuser-notification
+Libs: -L${libdir} -laskuser-notification-ipc
 Cflags: -I${includedir}/askuser-notification
index d320e38..fd22201 100644 (file)
@@ -54,8 +54,8 @@ void Channel::process(int fd, int mask) {
             return;
 
         if (0 == mask) {
-            m_socket.erase(it);
             m_callbacks->updateFd(fd, 0);
+            m_socket.erase(it);
             return;
         }
 
@@ -75,8 +75,8 @@ void Channel::process(int fd, int mask) {
             int ret = desc.sock.recv(desc.input);
 
             if (ret <= 0) {
-                m_socket.erase(fd);
                 m_callbacks->updateFd(fd, 0);
+                m_socket.erase(fd);
                 return;
             }
 
@@ -121,8 +121,8 @@ void Channel::process(int fd, int mask) {
             int size = static_cast<int>(desc.output.size());
             int result = desc.sock.send(desc.output);
             if (result < 0) {
-                m_socket.erase(fd);
                 m_callbacks->updateFd(fd, 0);
+                m_socket.erase(fd);
                 return;
             }
 
index 3eee6fc..5d2f31f 100644 (file)
@@ -95,25 +95,25 @@ void server(void) {
 }
 
 void stream() {
-    PrivilegeVector vect = {"one", "two"};
+    PrivilegeVector vect = {"http://tizen.org/privilege/camera", "http://tizen.org/privilege/contacts"};
     int result;
-    UNUSED int ret = popup_launch("spkg", "sapp", getuid(), vect, result);
+    UNUSED int ret = popup_launch("org.tizen.memo", "org.tizen.memo", getuid(), vect, result);
     printf("Sended stream. Result: %x\n", result);
 }
 
 void toust1() {
-    toast_deny("tpkg1", "sapp1", getuid(), "some_priv");
+    toast_deny("org.tizen.memo", "org.tizen.memo", getuid(), "http://tizen.org/privilege/camera");
     printf("sended\n");
 }
 
 void toust2() {
-    toast_fail_launch("tpkg2", "sapp2", getuid());
+    toast_fail_launch("org.tizen.memo", "org.tizen.memo", getuid());
     printf("sended\n");
 }
 
 int main(){
     int com;
-    printf("0 - server, 1 - send stream, 2 - send toust1, 3 - send toust2\n>");
+    printf("0 - server, 1 - send popup, 2 - send toust1, 3 - send toust2\n>");
     UNUSED int ret = scanf("%d", &com);
 
     switch(com) {
index 2f72433..850c853 100644 (file)
@@ -77,7 +77,7 @@ int Sock::getUnixSockType() const {
     return 0;
 }
 
-int Sock::getSocketFromSystemD() {
+int Sock::getSocketFromSystemD() const {
 #ifdef BUILD_WITH_SYSTEMD_DAEMON
     int n = sd_listen_fds(0);
 
index a746908..6aff31b 100644 (file)
@@ -62,7 +62,7 @@ public:
     int send(const RawBuffer &buffer);
 
 private:
-    int getSocketFromSystemD();
+    int getSocketFromSystemD() const;
 
     Type m_type;
     int m_fd;
index 65cd23d..5f4d414 100644 (file)
@@ -4,7 +4,8 @@ Description=Ask user notification
 [Service]
 ExecStart=/usr/bin/askuser-notification
 Type=notify
-Sockets=askuser-notification.socket
+Sockets=askuser-notification-datagram.socket
+Sockets=askuser-notification-stream.socket
 TimeoutStopSec=10
 TimeoutStartSec=10