From: David Steele Date: Mon, 5 Sep 2022 15:14:37 +0000 (+0100) Subject: Added IP address to dali-demo version popup X-Git-Tag: dali_2.1.41~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-demo.git;a=commitdiff_plain;h=358c843bb192495044f5005c1f47ab6a1fa94c25;hp=218d29cfaefc91b901233c373650107d7a595635 Added IP address to dali-demo version popup Change-Id: I247a7660c6fa8b4a5115980654e038f4417c77f7 --- diff --git a/shared/dali-table-view.cpp b/shared/dali-table-view.cpp index a8743ad..261d96f 100644 --- a/shared/dali-table-view.cpp +++ b/shared/dali-table-view.cpp @@ -35,6 +35,16 @@ #include "shared/utility.h" #include "shared/view.h" + +#include +#include +#include +#include +#include +#include +#include + + using namespace Dali; using namespace Dali::Toolkit; @@ -114,12 +124,8 @@ private: float mTileXOffset; }; -/** - * Creates a popup that shows the version information of the DALi libraries and demo - */ -Dali::Toolkit::Popup CreateVersionPopup(Application& application, ConnectionTrackerInterface& connectionTracker) +void AppendVersionString(std::ostringstream& stream) { - std::ostringstream stream; stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")\n"; stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl @@ -127,7 +133,47 @@ Dali::Toolkit::Popup CreateVersionPopup(Application& application, ConnectionTrac stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")\n"; stream << "DALi Demo:" - << "\n(" << DEMO_BUILD_DATE << ")\n"; + << "\n(" << DEMO_BUILD_DATE << ")\n\n"; +} + +void AppendIpAddress(std::ostringstream& stream) +{ + // Append IP addresses + struct ifaddrs *interfaceAddresses, *head; + if(!getifaddrs(&interfaceAddresses)) + { + head = interfaceAddresses; + + char host[NI_MAXHOST]; + int n = 0; + while(interfaceAddresses) + { + if(strcmp(interfaceAddresses->ifa_name, "lo")) + { + struct sockaddr* address = interfaceAddresses->ifa_addr; + if(address != nullptr && address->sa_family == AF_INET) + { + if(getnameinfo(address, sizeof(struct sockaddr_in), host, NI_MAXHOST, nullptr, 0, NI_NUMERICHOST) == 0) + { + stream<ifa_name<<": "<ifa_next; + } + freeifaddrs(head); + } +} + +/** + * Creates a popup that shows the version information of the DALi libraries and demo + */ +Dali::Toolkit::Popup CreateVersionPopup(Application& application, ConnectionTrackerInterface& connectionTracker) +{ + std::ostringstream stream; + AppendVersionString(stream); + AppendIpAddress(stream); Dali::Toolkit::Popup popup = Dali::Toolkit::Popup::New();