refactoring: getNames() -> prepareNames() 00/203200/4
authorAdrian Szyndela <adrian.s@samsung.com>
Wed, 10 Apr 2019 12:37:33 +0000 (14:37 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Thu, 11 Apr 2019 15:16:45 +0000 (17:16 +0200)
prepareNames() is more proper name for the function as it
prepares an array of names in the KdbusConnectionInfo object,
it does not return them.

Change-Id: I9f86ae80c138a2371456c86543757e962d23e25a

src/libdbuspolicy1.cpp

index 94dfdfa..6fe1722 100644 (file)
@@ -286,7 +286,13 @@ DBUSPOLICY1_EXPORT void dbuspolicy1_free(void* configuration)
        delete KCONN(configuration);
 }
 
-static int getNames(const char *name, KdbusConnectionInfo &info,
+/*
+ * This function prepares contents of info.names() for initialization of MatchItems.
+ * First, it tries to get names from kdbus connection.
+ * If it fails, names are added from the 'name' parameter, which is treaten
+ * as a string containing names separated by single space.
+ */
+static int prepareNames(const char *name, KdbusConnectionInfo &info,
                KdbusConnection::conn_info_type info_type) {
        if (name && *name) {
                int r = info.get(name, info_type);
@@ -329,7 +335,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration,
        int r;
        /* check can send */
        /* if broadcasting, then pass - null destination */
-       r = getNames(destination, destinationInfo, KdbusConnection::POLICY_CONN_INFO_ALL);
+       r = prepareNames(destination, destinationInfo, KdbusConnection::POLICY_CONN_INFO_ALL);
        if (r < 0)
                return r;
 
@@ -344,7 +350,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration,
        KdbusConnectionInfo senderInfo(kconn->conn);
        /* check can recv */
        /* get sender information from kdbus */
-       r = getNames(sender, senderInfo, KdbusConnection::POLICY_CONN_INFO_NAME);
+       r = prepareNames(sender, senderInfo, KdbusConnection::POLICY_CONN_INFO_NAME);
        if (r < 0)
                return r;
 
@@ -373,7 +379,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_in(void* configuration,
        auto kconn = KCONN(configuration);
        KdbusConnectionInfo info(kconn->conn);
        int r;
-       r = getNames(destination, info, KdbusConnection::POLICY_CONN_INFO_NAME);
+       r = prepareNames(destination, info, KdbusConnection::POLICY_CONN_INFO_NAME);
        if (r < 0)
                return r;