diff options
author | Alex <b0ris@b0ris-satellite.localdomain> | 2011-11-03 16:21:29 +0200 |
---|---|---|
committer | Alex <b0ris@b0ris-satellite.localdomain> | 2011-11-03 16:21:29 +0200 |
commit | da3277b21e4a947691df84eb35f675c6f06a4369 (patch) | |
tree | 4ff43488cc88247ba07e9114b63305469b822188 | |
parent | c0c86b6cab64186e97285e1b5b1ef13062926d87 (diff) |
Fix compiler warnings
-rw-r--r-- | client/Config.cpp | 6 | ||||
-rw-r--r-- | client/Config.h | 2 | ||||
-rw-r--r-- | client/Dialog.cpp | 5 | ||||
-rw-r--r-- | client/Logger.cpp | 65 | ||||
-rw-r--r-- | client/Logger.h | 30 | ||||
-rw-r--r-- | client/Proxy.h | 4 | ||||
-rw-r--r-- | client/SslClient.cpp | 2 | ||||
-rw-r--r-- | client/SslClient.h | 4 |
8 files changed, 61 insertions, 57 deletions
diff --git a/client/Config.cpp b/client/Config.cpp index 4fcaea9..b3c66a4 100644 --- a/client/Config.cpp +++ b/client/Config.cpp @@ -17,7 +17,7 @@ Config *Config::CurrentConfig() return self; } -Config::Config(): configValid(0), StaticProxySpeedLow(50) +Config::Config(): StaticProxySpeedLow(50), configValid(0) { } @@ -119,7 +119,7 @@ vector<string> Config::GetProxies(string &country, string &state, string &city) return proxies; } -vector<ProxyEntryStatic> Config::GetStaticProxyGuiLine(int line) +vector<ProxyEntryStatic> Config::GetStaticProxyGuiLine(unsigned line) { vector<ProxyEntryStatic> staticProxyLine; for (unsigned i = 0; i < staticProxy.size(); i++) @@ -144,7 +144,7 @@ vector<ProxyEntryStatic> Config::GetStaticProxyGuiLine(int line) unsigned Config::GetStaticProxyGuiLines() { - int maxLine = 0; + unsigned maxLine = 0; for (unsigned i = 0; i < staticProxy.size(); i++) { if (staticProxy[i].position > maxLine) diff --git a/client/Config.h b/client/Config.h index 1c67604..f9e797e 100644 --- a/client/Config.h +++ b/client/Config.h @@ -92,7 +92,7 @@ public: * @param line number of GUI line proxy list associated with * @return List of static proxy entries sorted by speed in descending order */ - std::vector<ProxyEntryStatic> GetStaticProxyGuiLine(int line); + std::vector<ProxyEntryStatic> GetStaticProxyGuiLine(unsigned line); /** * @brief Get number of static proxy GUI lines diff --git a/client/Dialog.cpp b/client/Dialog.cpp index 86fecdf..9703821 100644 --- a/client/Dialog.cpp +++ b/client/Dialog.cpp @@ -2,13 +2,12 @@ #include <QtGui> #include <iostream> #include <sstream> -#include <typeinfo> #include "client.h" #include "Config.h" #include "Dialog.h" #include "Proxy.h" -using namespace std; + using namespace std; ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent) { @@ -17,7 +16,7 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent) cfg->AcquireConfig(); if (! cfg->IsConfigValid()) { - Logger::Fatal("No valid configuration found! Can't proceed."); + Logger::Fatal((std::string)"No valid configuration found! Can't proceed."); return ; } diff --git a/client/Logger.cpp b/client/Logger.cpp index 4cbb8aa..67c4907 100644 --- a/client/Logger.cpp +++ b/client/Logger.cpp @@ -1,97 +1,98 @@ #include <stdio.h> #include <stdarg.h> -#include <string.h> +#include <string> #include <time.h> #include "Logger.h" +using std::string; LogLevelType Logger::LogLevel = TraceLevel; #ifdef DEBUG -void Logger::Trace(char* msgfmt, ...) +void Logger::Trace(string msg, ...) { va_list args; - va_start(args, msgfmt); - Logger::Log(TraceLevel, msgfmt, args); + va_start(args, msg); + Logger::Log(TraceLevel, msg, args); } -void Logger::Debug(char* msgfmt, ...) +void Logger::Debug(string msg, ...) { va_list args; - va_start(args, msgfmt); - Logger::Log(DebugLevel, msgfmt, args); + va_start(args, msg); + Logger::Log(DebugLevel, msg, args); } -void Logger::Info(char* msgfmt, ...) +void Logger::Info(string msg, ...) { va_list args; - va_start(args, msgfmt); - Logger::Log(InfoLevel, msgfmt, args); + va_start(args, msg); + Logger::Log(InfoLevel, msg, args); } -void Logger::Warn(char* msgfmt, ...) +void Logger::Warn(string msg, ...) { va_list args; - va_start(args, msgfmt); - Logger::Log(WarnLevel, msgfmt, args); + va_start(args, msg); + Logger::Log(WarnLevel, msg, args); } -void Logger::Error(char* msgfmt, ...) +void Logger::Error(string msg, ...) { va_list args; - va_start(args, msgfmt); - Logger::Log(ErrorLevel, msgfmt, args); + va_start(args, msg); + Logger::Log(ErrorLevel, msg, args); } -void Logger::Fatal(char* msgfmt, ...) +void Logger::Fatal(string msg, ...) { va_list args; - va_start(args, msgfmt); - Logger::Log(FatalLevel, msgfmt, args); + va_start(args, msg); + Logger::Log(FatalLevel, msg, args); } -void Logger::Log(LogLevelType logLevel, char* msgfmt, ...) +void Logger::Log(LogLevelType logLevel, string msg, ...) { va_list args; - va_start(args, msgfmt); - Logger::Log(logLevel, msgfmt, args); + va_start(args, msg); + Logger::Log(logLevel, msg, args); } -void Logger::Log(LogLevelType logLevel, char* msgfmt, va_list args) +void Logger::Log(LogLevelType logLevel, string msg, va_list args) { time_t rawtime = time(NULL); struct tm *lctime = localtime(&rawtime); char time_str[10] = {0}; strftime(time_str, 10, "%H:%M:%S", lctime); - char log_level_str[6] = {0}; + string log_level_str; switch (logLevel) { default: case TraceLevel: - strcpy(log_level_str, "Trace"); + log_level_str = "Trace"; break; case DebugLevel: - strcpy(log_level_str, "Debug"); + log_level_str = "Debug"; break; case InfoLevel: - strcpy(log_level_str, "Info"); + log_level_str = "Info"; break; case WarnLevel: - strcpy(log_level_str, "Warn"); + log_level_str = "Warn"; break; case ErrorLevel: - strcpy(log_level_str, "Error"); + log_level_str = "Error"; break; case FatalLevel: - strcpy(log_level_str, "Fatal"); + log_level_str = "Fatal"; break; } - char *newfmt = new char[strlen(msgfmt) + 24]; - sprintf(newfmt, "[%s] %-6s: %s", time_str, log_level_str, msgfmt); + char *newfmt = new char[msg.size() + 24]; + sprintf(newfmt, "[%s] %-6s: %s", time_str, log_level_str.c_str(), msg.c_str()); vfprintf(stderr, newfmt, args); } diff --git a/client/Logger.h b/client/Logger.h index c5cf70f..cecd454 100644 --- a/client/Logger.h +++ b/client/Logger.h @@ -23,15 +23,15 @@ class Logger public: static LogLevelType LogLevel; - static void Trace(char* msgfmt, ...); - static void Debug(char* msgfmt, ...); - static void Info(char* msgfmt, ...); - static void Warn(char* msgfmt, ...); - static void Error(char* msgfmt, ...); - static void Fatal(char* msgfmt, ...); - static void Log(LogLevelType logLevel, char* msgfmt, ...); + static void Trace(std::string msg, ...); + static void Debug(std::string msg, ...); + static void Info(std::string msg, ...); + static void Warn(std::string msg, ...); + static void Error(std::string msg, ...); + static void Fatal(std::string msg, ...); + static void Log(LogLevelType logLevel, std::string msg, ...); private: - static void Log(LogLevelType logLevel, char* msgfmt, va_list arsg); + static void Log(LogLevelType logLevel, std::string msg, va_list arsg); }; #else @@ -41,13 +41,13 @@ class Logger public: static LogLevelType LogLevel; - static void Trace(char* msgfmt, ...) {} - static void Debug(char* msgfmt, ...) {} - static void Info(char* msgfmt, ...) {} - static void Warn(char* msgfmt, ...) {} - static void Error(char* msgfmt, ...) {} - static void Fatal(char* msgfmt, ...) {} - static void Log(LogLevelType logLevel, char* msgfmt, ...) {} + static void Trace(std::string msg, ...) {} + static void Debug(std::string msg, ...) {} + static void Info(std::string msg, ...) {} + static void Warn(std::string msg, ...) {} + static void Error(std::string msg, ...) {} + static void Fatal(std::string msg, ...) {} + static void Log(LogLevelType logLevel, std::string msg, ...) {} }; #endif diff --git a/client/Proxy.h b/client/Proxy.h index 0194db4..368f2b8 100644 --- a/client/Proxy.h +++ b/client/Proxy.h @@ -33,8 +33,8 @@ class ProxyEntryStatic: public Proxy { public: std::string name; - int position; - int speed; //kb per second + unsigned position; + unsigned speed; //kb per second ProxyEntryStatic(): Proxy(), position(0), speed(0) {} virtual void Parse(std::string entry); diff --git a/client/SslClient.cpp b/client/SslClient.cpp index 25a3839..d54523c 100644 --- a/client/SslClient.cpp +++ b/client/SslClient.cpp @@ -6,7 +6,7 @@ SslClient::SslClient(): port(13666) { - SslClient("127.0.0.1"); + SslClient((char*)"127.0.0.1"); } SslClient::SslClient(char* addr): port(13666) diff --git a/client/SslClient.h b/client/SslClient.h index 77c3ff3..c8126f6 100644 --- a/client/SslClient.h +++ b/client/SslClient.h @@ -17,6 +17,10 @@ class QString; * - Request format: [0x13 0x13 code 0x14 0x14] * - Reply format: [0x13 0x13 code [data] 0x14 0x14] * - Request codes: + * -# 0x01 - request client config + * -# 0x02 - request generic proxy list + * -# 0x04 - request static proxy list + * -# 0x08 - request firewall host list */ class SslClient: QObject { |