Add logic to find port when port_type and port_name are same 02/318702/3 accepted/tizen/unified/20241008.173936 accepted/tizen/unified/x/20241009.055411
authorurmain <wn.jang@samsung.com>
Mon, 7 Oct 2024 07:36:31 +0000 (16:36 +0900)
committerurmain <wn.jang@samsung.com>
Mon, 7 Oct 2024 11:17:59 +0000 (20:17 +0900)
Change-Id: I63eb8fb8a76e6b9c6d6a76c95bc34fc36a673aa9

src/mmi/mmi-node.cpp

index 53ed0a1eb17db62154aaaeba52d7726796b1ef8a..d757100f5d2c77a3dee57c9016e10c61d709970c 100644 (file)
@@ -19,6 +19,7 @@
 #include "mmi.h"
 #include "mmi-node.h"
 #include "mmi-node-internal.h"
+#include "mmi-port-internal.h"
 #include "mmi-plugin-storage.h"
 
 #include "mmi-log.h"
@@ -98,7 +99,22 @@ int mmi_node_find_port(mmi_node_h node, mmi_port_type_e port_type, const char *p
         LOGE("[ERROR] parameter is null");
         return MMI_ERROR_INVALID_PARAMETER;
     }
-    return MMI_ERROR_NONE;
+
+    mmi_node_s *node_ptr = static_cast<mmi_node_s*>(node);
+
+    mmi_port_h *ports = node_ptr->ports;
+    size_t port_count = node_ptr->port_count;
+
+    for (size_t i = 0; i < port_count; ++i) {
+        mmi_port_s *current_port = static_cast<mmi_port_s*>(ports[i]);
+
+        if (current_port->type == port_type && strncmp(current_port->name, port_name, MMI_NAME_MAX_LENGTH) == 0) {
+            *port = ports[i];
+            return MMI_ERROR_NONE;
+        }
+    }
+    LOGE("[ERROR] Port not found");
+    return MMI_ERROR_INVALID_PARAMETER;
 }
 
 int mmi_node_link(mmi_node_h from_node, mmi_node_h to_node) {