1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#ifndef _AUTODETECTPROXY_H_
#define _AUTODETECTPROXY_H_
#include "talk/base/sigslot.h"
#include "talk/base/physicalsocketserver.h"
#include "talk/base/proxyinfo.h"
#include "talk/base/signalthread.h"
#include "talk/base/cryptstring.h"
namespace buzz {
class XmppClientSettings;
}
namespace talk_base {
///////////////////////////////////////////////////////////////////////////////
// AutoDetectProxy
///////////////////////////////////////////////////////////////////////////////
class AsyncSocket;
class AutoDetectProxy : public SignalThread, public sigslot::has_slots<> {
public:
AutoDetectProxy(const std::string& user_agent);
const talk_base::ProxyInfo& proxy() const { return proxy_; }
void set_server_url(const std::string& url) {
server_url_ = url;
}
void set_proxy(const SocketAddress& proxy) {
proxy_.type = PROXY_UNKNOWN;
proxy_.address = proxy;
}
void set_auth_info(bool use_auth, const std::string& username,
const CryptString& password) {
if (use_auth) {
proxy_.username = username;
proxy_.password = password;
}
}
protected:
virtual ~AutoDetectProxy();
// SignalThread Interface
virtual void DoWork();
virtual void OnMessage(Message *msg);
void Next();
void Complete(ProxyType type);
void OnConnectEvent(AsyncSocket * socket);
void OnReadEvent(AsyncSocket * socket);
void OnCloseEvent(AsyncSocket * socket, int error);
private:
std::string agent_, server_url_;
ProxyInfo proxy_;
AsyncSocket * socket_;
int next_;
};
///////////////////////////////////////////////////////////////////////////////
} // namespace talk_base
#endif // _AUTODETECTPROXY_H_
|