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

13 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 [new file with mode: 0644]
src/common/protocol/askuser-notification.pc.in [deleted file]
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 538b952e2d20c12f71dd4d34d564cad8e5c1ce9c..305d0d862d372fd613821339dc062b6ceb846196 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 ffcf031887470a1fbf02b1fc512024d70c45099d..8932ceb3cce1b14444c88140558fc5726b7d9240 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 e1530d4011acdf9b65e9975f91b9eaced88dc525..aef453c47e1223aa224c28437e9f869615ba9e03 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 6010ffbfb4b7457922a628b89232fb0ace730c4b..6e892166eace1af313add4b0c5c5ef0a0065f1fe 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 f9aa1881a0118f5b1fd9ec137dcf089dd439063a..90b11ca038344bbbead0fab4c64d94077da961e6 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 a7ab80d3eec153168acd98b5e6dc64ead482cc18..19f9364d35afa056f2fdf5c0c25a03a139c300c2 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;
 }
 
diff --git a/src/common/protocol/askuser-notification-ipc.pc.in b/src/common/protocol/askuser-notification-ipc.pc.in
new file mode 100644 (file)
index 0000000..88bbbed
--- /dev/null
@@ -0,0 +1,12 @@
+# Package Information for pkg-config
+
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+
+Name: askuser-notification
+Description: askuser-notification library
+Version: @ASKUSER_NOTIFICATION_VERSION@
+Libs: -L${libdir} -laskuser-notification-ipc
+Cflags: -I${includedir}/askuser-notification
diff --git a/src/common/protocol/askuser-notification.pc.in b/src/common/protocol/askuser-notification.pc.in
deleted file mode 100644 (file)
index dca3398..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Package Information for pkg-config
-
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=@CMAKE_INSTALL_PREFIX@
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@
-
-Name: askuser-notification
-Description: askuser-notification library
-Version: @ASKUSER_NOTIFICATION_VERSION@
-Libs: -L${libdir} -laskuser-notification
-Cflags: -I${includedir}/askuser-notification
index d320e38ad7a59fedb5a65509de1e0ed40018fa91..fd22201b8ddc0cd897ab29c2992828cd100da9b6 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 3eee6fc2535591ed8723c4832c994c02c09f346b..5d2f31f2858e457db03ebeff0844f12b5259f4d6 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 2f724335aeae4fef1784f6da2fbf049848d0eda4..850c85324b055ce6064f83793534e7be768ad7c1 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 a74690854fb30e9fbb353ec426293aa8f477d58c..6aff31bce596ff4e42d8a5d58c77458749391296 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 65cd23db3de24fc3ba3ee5e4e3f8588b587881db..5f4d4143aae067c632d3e880ff07e616dd489fba 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