Update talk to 60923971
Review URL: https://webrtc-codereview.appspot.com/7909004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5475 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
|
||||
#ifndef TALK_BASE_ASYNCSOCKET_H_
|
||||
#define TALK_BASE_ASYNCSOCKET_H_
|
||||
#ifndef __native_client__
|
||||
|
||||
#include "talk/base/common.h"
|
||||
#include "talk/base/sigslot.h"
|
||||
@@ -139,5 +138,4 @@ class AsyncSocketAdapter : public AsyncSocket, public sigslot::has_slots<> {
|
||||
|
||||
} // namespace talk_base
|
||||
|
||||
#endif // __native_client__
|
||||
#endif // TALK_BASE_ASYNCSOCKET_H_
|
||||
|
@@ -33,9 +33,10 @@
|
||||
#ifdef WIN32
|
||||
#include "talk/base/win32.h"
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -463,7 +464,10 @@ const PlatformFile kInvalidPlatformFileValue = INVALID_HANDLE_VALUE;
|
||||
#elif defined(POSIX)
|
||||
typedef int PlatformFile;
|
||||
const PlatformFile kInvalidPlatformFileValue = -1;
|
||||
#else
|
||||
#error Unsupported platform
|
||||
#endif
|
||||
|
||||
FILE* FdopenPlatformFileForWriting(PlatformFile file);
|
||||
bool ClosePlatformFile(PlatformFile file);
|
||||
|
||||
|
@@ -250,6 +250,89 @@ bool ConfigParser::ParseLine(std::string* key, std::string* value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(GOOGLE_CHROME_BUILD) && !defined(CHROMIUM_BUILD)
|
||||
static bool ExpectLineFromStream(FileStream* stream,
|
||||
std::string* out) {
|
||||
StreamResult res = stream->ReadLine(out);
|
||||
if (res != SR_SUCCESS) {
|
||||
if (res != SR_EOS) {
|
||||
LOG(LS_ERROR) << "Error when reading from stream";
|
||||
} else {
|
||||
LOG(LS_ERROR) << "Incorrect number of lines in stream";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ExpectEofFromStream(FileStream* stream) {
|
||||
std::string unused;
|
||||
StreamResult res = stream->ReadLine(&unused);
|
||||
if (res == SR_SUCCESS) {
|
||||
LOG(LS_WARNING) << "Ignoring unexpected extra lines from stream";
|
||||
} else if (res != SR_EOS) {
|
||||
LOG(LS_WARNING) << "Error when checking for extra lines from stream";
|
||||
}
|
||||
}
|
||||
|
||||
// For caching the lsb_release output (reading it invokes a sub-process and
|
||||
// hence is somewhat expensive).
|
||||
static std::string lsb_release_string;
|
||||
static CriticalSection lsb_release_string_critsec;
|
||||
|
||||
std::string ReadLinuxLsbRelease() {
|
||||
CritScope cs(&lsb_release_string_critsec);
|
||||
if (!lsb_release_string.empty()) {
|
||||
// Have cached result from previous call.
|
||||
return lsb_release_string;
|
||||
}
|
||||
// No cached result. Run lsb_release and parse output.
|
||||
POpenStream lsb_release_output;
|
||||
if (!lsb_release_output.Open("lsb_release -idrcs", "r", NULL)) {
|
||||
LOG_ERR(LS_ERROR) << "Can't run lsb_release";
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
// Read in the command's output and build the string.
|
||||
std::ostringstream sstr;
|
||||
std::string line;
|
||||
int wait_status;
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << "DISTRIB_ID=" << line;
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << " DISTRIB_DESCRIPTION=\"" << line << '"';
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << " DISTRIB_RELEASE=" << line;
|
||||
|
||||
if (!ExpectLineFromStream(&lsb_release_output, &line)) {
|
||||
return lsb_release_string; // empty
|
||||
}
|
||||
sstr << " DISTRIB_CODENAME=" << line;
|
||||
|
||||
// Should not be anything left.
|
||||
ExpectEofFromStream(&lsb_release_output);
|
||||
|
||||
lsb_release_output.Close();
|
||||
wait_status = lsb_release_output.GetWaitStatus();
|
||||
if (wait_status == -1 ||
|
||||
!WIFEXITED(wait_status) ||
|
||||
WEXITSTATUS(wait_status) != 0) {
|
||||
LOG(LS_WARNING) << "Unexpected exit status from lsb_release";
|
||||
}
|
||||
|
||||
lsb_release_string = sstr.str();
|
||||
|
||||
return lsb_release_string;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string ReadLinuxUname() {
|
||||
struct utsname buf;
|
||||
|
@@ -121,6 +121,11 @@ class ProcCpuInfo {
|
||||
ConfigParser::MapVector sections_;
|
||||
};
|
||||
|
||||
#if !defined(GOOGLE_CHROME_BUILD) && !defined(CHROMIUM_BUILD)
|
||||
// Builds a string containing the info from lsb_release on a single line.
|
||||
std::string ReadLinuxLsbRelease();
|
||||
#endif
|
||||
|
||||
// Returns the output of "uname".
|
||||
std::string ReadLinuxUname();
|
||||
|
||||
|
@@ -105,6 +105,14 @@ TEST(ConfigParser, ParseConfig) {
|
||||
EXPECT_EQ(true, parser.Parse(&key_val_pairs));
|
||||
}
|
||||
|
||||
#if !defined(GOOGLE_CHROME_BUILD) && !defined(CHROMIUM_BUILD)
|
||||
TEST(ReadLinuxLsbRelease, ReturnsSomething) {
|
||||
std::string str = ReadLinuxLsbRelease();
|
||||
// ChromeOS don't have lsb_release
|
||||
// EXPECT_FALSE(str.empty());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(ReadLinuxUname, ReturnsSomething) {
|
||||
std::string str = ReadLinuxUname();
|
||||
EXPECT_FALSE(str.empty());
|
||||
|
@@ -224,11 +224,11 @@ OpenSSLCertificate* OpenSSLCertificate::FromPEMString(
|
||||
BIO* bio = BIO_new_mem_buf(const_cast<char*>(pem_string.c_str()), -1);
|
||||
if (!bio)
|
||||
return NULL;
|
||||
(void)BIO_set_close(bio, BIO_NOCLOSE);
|
||||
BIO_set_mem_eof_return(bio, 0);
|
||||
X509 *x509 = PEM_read_bio_X509(bio, NULL, NULL,
|
||||
const_cast<char*>("\0"));
|
||||
BIO_free(bio);
|
||||
BIO_free(bio); // Frees the BIO, but not the pointed-to string.
|
||||
|
||||
if (!x509)
|
||||
return NULL;
|
||||
|
||||
@@ -364,11 +364,10 @@ SSLIdentity* OpenSSLIdentity::FromPEMStrings(
|
||||
LOG(LS_ERROR) << "Failed to create a new BIO buffer.";
|
||||
return NULL;
|
||||
}
|
||||
(void)BIO_set_close(bio, BIO_NOCLOSE);
|
||||
BIO_set_mem_eof_return(bio, 0);
|
||||
EVP_PKEY *pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL,
|
||||
const_cast<char*>("\0"));
|
||||
BIO_free(bio);
|
||||
BIO_free(bio); // Frees the BIO, but not the pointed-to string.
|
||||
|
||||
if (!pkey) {
|
||||
LOG(LS_ERROR) << "Failed to create the private key from PEM string.";
|
||||
@@ -392,5 +391,3 @@ bool OpenSSLIdentity::ConfigureIdentity(SSL_CTX* ctx) {
|
||||
} // namespace talk_base
|
||||
|
||||
#endif // HAVE_OPENSSL_SSL_H
|
||||
|
||||
|
||||
|
@@ -2,40 +2,32 @@
|
||||
* libjingle
|
||||
* Copyright 2004--2005, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_BASE_SOCKET_H__
|
||||
#define TALK_BASE_SOCKET_H__
|
||||
|
||||
#if defined(__native_client__)
|
||||
namespace talk_base {
|
||||
// These should never be defined or instantiated.
|
||||
class Socket;
|
||||
class AsyncSocket;
|
||||
} // namespace talk_base
|
||||
#else
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef POSIX
|
||||
@@ -207,5 +199,4 @@ class Socket {
|
||||
|
||||
} // namespace talk_base
|
||||
|
||||
#endif // !__native_client__
|
||||
#endif // TALK_BASE_SOCKET_H__
|
||||
|
@@ -32,6 +32,8 @@
|
||||
|
||||
#ifdef LINUX
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
// X defines a few macros that stomp on types that gunit.h uses.
|
||||
#undef None
|
||||
#undef Bool
|
||||
@@ -601,6 +603,16 @@ inline bool IsScreencastingAvailable() {
|
||||
LOG(LS_WARNING) << "No X Display available.";
|
||||
return false;
|
||||
}
|
||||
int ignored_int, major_version, minor_version;
|
||||
if (!XRRQueryExtension(display, &ignored_int, &ignored_int) ||
|
||||
!XRRQueryVersion(display, &major_version, &minor_version) ||
|
||||
major_version < 1 ||
|
||||
(major_version < 2 && minor_version < 3)) {
|
||||
LOG(LS_WARNING) << "XRandr version: " << major_version << "."
|
||||
<< minor_version;
|
||||
LOG(LS_WARNING) << "XRandr is not supported or is too old (pre 1.3).";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user