revise exported headers and cleanup headers
[platform/core/connectivity/smartcard-service.git] / server / ServerGDBus.cpp
index b74ed8e..050b8db 100644 (file)
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#ifdef USE_GDBUS
-/* standard library header */
 #include <unistd.h>
 #include <glib.h>
 #include <gio/gio.h>
 #include <string>
 #include <sys/socket.h>
 
-/* SLP library header */
 #ifdef USER_SPACE_SMACK
 #include "security-server.h"
 #endif
 
-/* local header */
 #include "smartcard-types.h"
 #include "Debug.h"
 #include "ByteArray.h"
@@ -133,6 +129,11 @@ namespace smartcard_service_api
                const gchar *name, const gchar *old_owner,
                const gchar *new_owner, void *user_data)
        {
+               if (name == NULL || old_owner == NULL || new_owner == NULL) {
+                       _ERR("invalid parameter");
+                       return;
+               }
+
                if (strlen(new_owner) == 0) {
                        ClientInstance *client;
 
@@ -153,16 +154,15 @@ namespace smartcard_service_api
                const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data)
        {
-               GVariantIter *iter;
                gchar *name;
                gchar *old_owner;
                gchar *new_owner;
 
-               iter = g_variant_iter_new(parameters);
-
-               g_variant_iter_next(iter, "s", &name);
-               g_variant_iter_next(iter, "s", &old_owner);
-               g_variant_iter_next(iter, "s", &new_owner);
+               g_variant_get(parameters,
+                       "(sss)",
+                       &name,
+                       &old_owner,
+                       &new_owner);
 
                name_owner_changed((GDBusProxy *)connection,
                        name, old_owner, new_owner, user_data);
@@ -236,10 +236,10 @@ namespace smartcard_service_api
 
        void ServerGDBus::deinit()
        {
-               deinitSEService();
-               deinitReader();
-               deinitSession();
                deinitChannel();
+               deinitSession();
+               deinitReader();
+               deinitSEService();
 
                _deinit();
 
@@ -363,9 +363,12 @@ namespace smartcard_service_api
                                resource.createClient(name, pid);
 
                                instance = resource.getClient(name);
-
-                               /* generate certification hashes */
-                               instance->generateCertificationHashes();
+                               if (instance != NULL) {
+                                       /* generate certification hashes */
+                                       instance->generateCertificationHashes();
+                               } else {
+                                       _ERR("createClient failed");
+                               }
                        }
 
                        if (instance != NULL) {
@@ -1368,4 +1371,3 @@ namespace smartcard_service_api
                }
        }
 } /* namespace smartcard_service_api */
-#endif