platform/shared/common/RhodesApp.cpp in rhodes-1.4.1 vs platform/shared/common/RhodesApp.cpp in rhodes-1.4.2

- old
+ new

@@ -339,76 +339,82 @@ #endif } const char* CRhodesApp::getFreeListeningPort() { -#ifdef OS_MACOSX - return "8080"; -#else - if ( m_strListeningPorts.length() > 0 ) - return m_strListeningPorts.c_str(); + if ( m_strListeningPorts.length() > 0 ) + return m_strListeningPorts.c_str(); + + int noerrors = 1; + LOG(INFO) + "Trying to get free listening port."; + + //get free port + int sockfd = -1; + struct sockaddr_in serv_addr = {0}; + //struct hostent *server = {0}; + //int result = -1; + + if ( noerrors ) + { + sockfd = socket(AF_INET, SOCK_STREAM, 0); + if ( sockfd < 0 ) + { + LOG(WARNING) + ("Unable to open socket"); + noerrors = 0; + } + + if ( noerrors ) + { + //server = gethostbyname( "localhost" ); + + memset((void *) &serv_addr, 0, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); + serv_addr.sin_port = htons(8080); - int noerrors = 1; - LOG(INFO) + "Trying to get free listening port."; - - //get free port - int sockfd = -1; - struct sockaddr_in serv_addr = {0}; - //struct hostent *server = {0}; - //int result = -1; - - if ( noerrors ) - { - sockfd = socket(AF_INET, SOCK_STREAM, 0); - if ( sockfd < 0 ) - { - LOG(WARNING) + ("Unable to open socket"); - noerrors = 0; - } - - if ( noerrors ) - { - //server = gethostbyname( "localhost" ); - - memset((void *) &serv_addr, 0, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); - serv_addr.sin_port = htons(0); - - if ( bind( sockfd, (struct sockaddr *) &serv_addr, sizeof( serv_addr ) ) ) + if ( bind( sockfd, (struct sockaddr *) &serv_addr, sizeof( serv_addr ) ) ) { - LOG(WARNING) + "Unable to bind"; - noerrors = 0; + serv_addr.sin_port = htons(0); + if ( bind( sockfd, (struct sockaddr *) &serv_addr, sizeof( serv_addr ) ) ) + { + LOG(WARNING) + "Unable to bind"; + noerrors = 0; + } } - else - { - char buf[10] = {0}; - /*socklen_t*/int length = sizeof( serv_addr ); - getsockname( sockfd, (struct sockaddr *)&serv_addr, &length ); - - sprintf(buf,"%d",ntohs(serv_addr.sin_port)); - - m_strListeningPorts = buf; - } - //Clean up + if ( noerrors ) + { + char buf[10] = {0}; +#ifdef OS_MACOSX + socklen_t +#else + int +#endif + length = sizeof( serv_addr ); + + getsockname( sockfd, (struct sockaddr *)&serv_addr, &length ); + + sprintf(buf,"%d",ntohs(serv_addr.sin_port)); + + m_strListeningPorts = buf; + } + //Clean up #if defined(OS_ANDROID) - close(sockfd); + close(sockfd); #else - closesocket(sockfd); + closesocket(sockfd); #endif - } - - } - - if ( !noerrors ) - m_strListeningPorts = "8080"; - - LOG(INFO) + "Free listening port: " + m_strListeningPorts; - - return m_strListeningPorts.c_str(); -#endif + } + + } + + if ( !noerrors ) + m_strListeningPorts = "8080"; + + LOG(INFO) + "Free listening port: " + m_strListeningPorts; + + return m_strListeningPorts.c_str(); } void CRhodesApp::initAppUrls() { m_currentTabIndex = 0; @@ -444,10 +450,15 @@ { m_strStartUrl = canonicalizeRhoUrl( RHOCONF().getString("start_path") ); return m_strStartUrl; } +const char* rho_rhodesapp_gethomeurl() +{ + return RHODESAPP().getHomeUrl().c_str(); +} + const String& CRhodesApp::getOptionsUrl() { m_strOptionsUrl = canonicalizeRhoUrl( RHOCONF().getString("options_path") ); return m_strOptionsUrl; } @@ -744,9 +755,14 @@ const char* rho_rhodesapp_getstarturl() { return RHODESAPP().getStartUrl().c_str(); } +const char* rho_rhodesapp_gethomeurl() +{ + return RHODESAPP().getHomeUrl().c_str(); +} + const char* rho_rhodesapp_getoptionsurl() { return RHODESAPP().getOptionsUrl().c_str(); }