Commit 358c843bb192495044f5005c1f47ab6a1fa94c25
1 parent
218d29cf
Added IP address to dali-demo version popup
Change-Id: I247a7660c6fa8b4a5115980654e038f4417c77f7
Showing
1 changed file
with
52 additions
and
6 deletions
shared/dali-table-view.cpp
| ... | ... | @@ -35,6 +35,16 @@ |
| 35 | 35 | #include "shared/utility.h" |
| 36 | 36 | #include "shared/view.h" |
| 37 | 37 | |
| 38 | + | |
| 39 | +#include <ifaddrs.h> | |
| 40 | +#include <net/if.h> | |
| 41 | +#include <netdb.h> | |
| 42 | +#include <sys/ioctl.h> | |
| 43 | +#include <sys/types.h> | |
| 44 | +#include <cstdio> | |
| 45 | +#include <cstring> | |
| 46 | + | |
| 47 | + | |
| 38 | 48 | using namespace Dali; |
| 39 | 49 | using namespace Dali::Toolkit; |
| 40 | 50 | |
| ... | ... | @@ -114,12 +124,8 @@ private: |
| 114 | 124 | float mTileXOffset; |
| 115 | 125 | }; |
| 116 | 126 | |
| 117 | -/** | |
| 118 | - * Creates a popup that shows the version information of the DALi libraries and demo | |
| 119 | - */ | |
| 120 | -Dali::Toolkit::Popup CreateVersionPopup(Application& application, ConnectionTrackerInterface& connectionTracker) | |
| 127 | +void AppendVersionString(std::ostringstream& stream) | |
| 121 | 128 | { |
| 122 | - std::ostringstream stream; | |
| 123 | 129 | stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl |
| 124 | 130 | << "(" << CORE_BUILD_DATE << ")\n"; |
| 125 | 131 | 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 |
| 127 | 133 | stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl |
| 128 | 134 | << "(" << TOOLKIT_BUILD_DATE << ")\n"; |
| 129 | 135 | stream << "DALi Demo:" |
| 130 | - << "\n(" << DEMO_BUILD_DATE << ")\n"; | |
| 136 | + << "\n(" << DEMO_BUILD_DATE << ")\n\n"; | |
| 137 | +} | |
| 138 | + | |
| 139 | +void AppendIpAddress(std::ostringstream& stream) | |
| 140 | +{ | |
| 141 | + // Append IP addresses | |
| 142 | + struct ifaddrs *interfaceAddresses, *head; | |
| 143 | + if(!getifaddrs(&interfaceAddresses)) | |
| 144 | + { | |
| 145 | + head = interfaceAddresses; | |
| 146 | + | |
| 147 | + char host[NI_MAXHOST]; | |
| 148 | + int n = 0; | |
| 149 | + while(interfaceAddresses) | |
| 150 | + { | |
| 151 | + if(strcmp(interfaceAddresses->ifa_name, "lo")) | |
| 152 | + { | |
| 153 | + struct sockaddr* address = interfaceAddresses->ifa_addr; | |
| 154 | + if(address != nullptr && address->sa_family == AF_INET) | |
| 155 | + { | |
| 156 | + if(getnameinfo(address, sizeof(struct sockaddr_in), host, NI_MAXHOST, nullptr, 0, NI_NUMERICHOST) == 0) | |
| 157 | + { | |
| 158 | + stream<<interfaceAddresses->ifa_name<<": "<<host<<std::endl; | |
| 159 | + ++n; | |
| 160 | + } | |
| 161 | + } | |
| 162 | + } | |
| 163 | + interfaceAddresses = interfaceAddresses->ifa_next; | |
| 164 | + } | |
| 165 | + freeifaddrs(head); | |
| 166 | + } | |
| 167 | +} | |
| 168 | + | |
| 169 | +/** | |
| 170 | + * Creates a popup that shows the version information of the DALi libraries and demo | |
| 171 | + */ | |
| 172 | +Dali::Toolkit::Popup CreateVersionPopup(Application& application, ConnectionTrackerInterface& connectionTracker) | |
| 173 | +{ | |
| 174 | + std::ostringstream stream; | |
| 175 | + AppendVersionString(stream); | |
| 176 | + AppendIpAddress(stream); | |
| 131 | 177 | |
| 132 | 178 | Dali::Toolkit::Popup popup = Dali::Toolkit::Popup::New(); |
| 133 | 179 | ... | ... |