summaryrefslogtreecommitdiff
path: root/protocols/Omegle/src
diff options
context:
space:
mode:
authorGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:03:31 +0100
committerGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:07:33 +0100
commita7c24ca48995cf2bf436156302f96b91bf135409 (patch)
tree953835509ff1b778833e78fd7b74b05e05e77c84 /protocols/Omegle/src
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'protocols/Omegle/src')
-rw-r--r--protocols/Omegle/src/chat.cpp44
-rw-r--r--protocols/Omegle/src/communication.cpp42
-rw-r--r--protocols/Omegle/src/connection.cpp22
-rw-r--r--protocols/Omegle/src/messages.cpp4
-rw-r--r--protocols/Omegle/src/proto.cpp14
-rw-r--r--protocols/Omegle/src/theme.cpp2
6 files changed, 64 insertions, 64 deletions
diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp
index 2914daeb59..6281d90e11 100644
--- a/protocols/Omegle/src/chat.cpp
+++ b/protocols/Omegle/src/chat.cpp
@@ -28,10 +28,10 @@ void OmegleProto::UpdateChat(const wchar_t *name, const wchar_t *message, bool a
utils::text::treplace_all(&smessage, L"%", L"%%");
GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
- gce.time = ::time(NULL);
+ gce.time = ::time(nullptr);
gce.ptszText = smessage.c_str();
- if (name == NULL) {
+ if (name == nullptr) {
gce.iType = GC_EVENT_INFORMATION;
name = TranslateT("Server");
gce.bIsMe = false;
@@ -85,12 +85,12 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
facy.spy_mode_ = false;
facy.question_.clear();
- ForkThread(&OmegleProto::NewChatWorker, NULL);
+ ForkThread(&OmegleProto::NewChatWorker, nullptr);
break;
}
else if (!mir_strcmpi(command.c_str(), "quit"))
{
- ForkThread(&OmegleProto::StopChatWorker, NULL);
+ ForkThread(&OmegleProto::StopChatWorker, nullptr);
break;
}
else if (!mir_strcmpi(command.c_str(), "spy"))
@@ -98,7 +98,7 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
facy.spy_mode_ = true;
facy.question_.clear();
- ForkThread(&OmegleProto::NewChatWorker, NULL);
+ ForkThread(&OmegleProto::NewChatWorker, nullptr);
break;
}
else if (!mir_strcmpi(command.c_str(), "ask"))
@@ -112,7 +112,7 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
}
if (params.empty()) {
- UpdateChat(NULL, TranslateT("Last question is empty."), false);
+ UpdateChat(nullptr, TranslateT("Last question is empty."), false);
break;
}
}
@@ -126,13 +126,13 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
if (params.length() < OMEGLE_QUESTION_MIN_LENGTH)
{
- UpdateChat(NULL, TranslateT("Your question is too short."), false);
+ UpdateChat(nullptr, TranslateT("Your question is too short."), false);
break;
}
facy.spy_mode_ = true;
facy.question_ = params;
- ForkThread(&OmegleProto::NewChatWorker, NULL);
+ ForkThread(&OmegleProto::NewChatWorker, nullptr);
break;
}
else if (!mir_strcmpi(command.c_str(), "asl"))
@@ -145,13 +145,13 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
SendChatMessage(text);
}
else {
- UpdateChat(NULL, TranslateT("Your '/asl' setting is empty."), false);
+ UpdateChat(nullptr, TranslateT("Your '/asl' setting is empty."), false);
break;
}
}
else if (!mir_strcmpi(command.c_str(), "help"))
{
- UpdateChat(NULL, TranslateT("There are three different modes of chatting:\
+ UpdateChat(nullptr, TranslateT("There are three different modes of chatting:\
\n1) Standard mode\t - You chat with random stranger privately\
\n2) Question mode\t - You ask two strangers a question and see how they discuss it (you can't join their conversation, only watch)\
\n3) Spy mode\t - You and stranger got a question to discuss from third stranger (he can't join your conversation, only watch)\
@@ -159,7 +159,7 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
}
else if (!mir_strcmpi(command.c_str(), "commands"))
{
- UpdateChat(NULL, TranslateT("You can use different commands:\
+ UpdateChat(nullptr, TranslateT("You can use different commands:\
\n/help\t - show info about chat modes\
\n/new\t - start standard mode\
\n/ask <question> - start question mode with your question\
@@ -172,7 +172,7 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
}
else
{
- UpdateChat(NULL, TranslateT("Unknown command. Send '/commands' for list."), false);
+ UpdateChat(nullptr, TranslateT("Unknown command. Send '/commands' for list."), false);
break;
}
@@ -187,8 +187,8 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam)
case GC_USER_LEAVE:
case GC_SESSION_TERMINATE:
- facy.nick_ = NULL;
- ForkThread(&OmegleProto::StopChatWorker, NULL);
+ facy.nick_ = nullptr;
+ ForkThread(&OmegleProto::StopChatWorker, nullptr);
break;
}
@@ -204,11 +204,11 @@ void OmegleProto::SendChatMessage(std::string text)
break;
case STATE_INACTIVE:
- UpdateChat(NULL, TranslateT("You aren't connected to any stranger. Send '/help' or '/commands' for help."), false);
+ UpdateChat(nullptr, TranslateT("You aren't connected to any stranger. Send '/help' or '/commands' for help."), false);
break;
case STATE_SPY:
- UpdateChat(NULL, TranslateT("You can't send messages in question mode."), false);
+ UpdateChat(nullptr, TranslateT("You can't send messages in question mode."), false);
break;
//case STATE_WAITING:
@@ -227,12 +227,12 @@ Chat_Event(WINDOW_CLEARLOG,&gce);
void OmegleProto::AddChatContact(const wchar_t *name)
{
GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN };
- gce.time = DWORD(time(0));
+ gce.time = DWORD(time(nullptr));
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = name;
gce.ptszUID = gce.ptszNick;
- if (name == NULL)
+ if (name == nullptr)
gce.bIsMe = false;
else
gce.bIsMe = mir_wstrcmp(name, this->facy.nick_);
@@ -251,8 +251,8 @@ void OmegleProto::DeleteChatContact(const wchar_t *name)
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = name;
gce.ptszUID = gce.ptszNick;
- gce.time = DWORD(time(0));
- if (name == NULL)
+ gce.time = DWORD(time(nullptr));
+ if (name == nullptr)
gce.bIsMe = false;
else
gce.bIsMe = mir_wstrcmp(name, this->facy.nick_);
@@ -284,9 +284,9 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM, LPARAM suppress)
void OmegleProto::SetTopic(const wchar_t *topic)
{
GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC };
- gce.time = ::time(NULL);
+ gce.time = ::time(nullptr);
- if (topic == NULL)
+ if (topic == nullptr)
gce.ptszText = TranslateT("Omegle is a great way of meeting new friends!");
else
gce.ptszText = topic;
diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp
index 8e8f69e2cf..42664f2a97 100644
--- a/protocols/Omegle/src/communication.cpp
+++ b/protocols/Omegle/src/communication.cpp
@@ -36,7 +36,7 @@ http::response Omegle_client::flap(const int request_type, std::string *post_dat
nlhr.timeout = 1000 * ((request_type == OMEGLE_REQUEST_EVENTS) ? 65 : 20);
// Set request type (GET/POST) and eventually also POST data
- if (post_data != NULL) {
+ if (post_data != nullptr) {
nlhr.requestType = REQUEST_POST;
nlhr.pData = (char*)(*post_data).c_str();
nlhr.dataLength = (int)post_data->length();
@@ -61,7 +61,7 @@ http::response Omegle_client::flap(const int request_type, std::string *post_dat
switch (request_type)
{
case OMEGLE_REQUEST_HOME:
- nlhr.nlc = NULL;
+ nlhr.nlc = nullptr;
break;
case OMEGLE_REQUEST_EVENTS:
@@ -90,17 +90,17 @@ http::response Omegle_client::flap(const int request_type, std::string *post_dat
break;
case OMEGLE_REQUEST_EVENTS:
- hEventsConnection = pnlhr ? pnlhr->nlc : NULL;
+ hEventsConnection = pnlhr ? pnlhr->nlc : nullptr;
break;
default:
ReleaseMutex(connection_lock_);
- hConnection = pnlhr ? pnlhr->nlc : NULL;
+ hConnection = pnlhr ? pnlhr->nlc : nullptr;
break;
}
// Check and copy response data
- if (pnlhr != NULL)
+ if (pnlhr != nullptr)
{
parent->debugLogA("@@@@@ Got response with code %d", pnlhr->resultCode);
store_headers(&resp, pnlhr->headers, pnlhr->headersCount);
@@ -154,7 +154,7 @@ bool Omegle_client::handle_error(const std::string &method, bool force_disconnec
if (result == false)
{
reset_error();
- parent->UpdateChat(NULL, TranslateT("Connection error."));
+ parent->UpdateChat(nullptr, TranslateT("Connection error."));
parent->StopChat(false);
}
@@ -172,7 +172,7 @@ std::string Omegle_client::get_server(bool not_last)
server = 0;
if (server == 0) {
- srand(::time(NULL));
+ srand(::time(nullptr));
server = (rand() % (_countof(servers) - 1 - q)) + 1;
}
@@ -218,7 +218,7 @@ std::string Omegle_client::choose_action(int request_type, std::string* get_data
{
std::string action = "/start?rcs=1&spid=&lang=";
action += get_language();
- if (get_data != NULL)
+ if (get_data != nullptr)
action += (*get_data);
return action;
@@ -371,7 +371,7 @@ bool Omegle_client::start()
mir_snprintf(str, Translate("Connected to server %s. There are %s users online now."), server_.c_str(), count.c_str());
wchar_t *msg = mir_a2u(str);
- parent->UpdateChat(NULL, msg);
+ parent->UpdateChat(nullptr, msg);
mir_free(msg);
}
}
@@ -380,12 +380,12 @@ bool Omegle_client::start()
mir_snprintf(str, Translate("Connected to server %s."), server_.c_str());
wchar_t *msg = mir_a2u(str);
- parent->UpdateChat(NULL, msg);
+ parent->UpdateChat(nullptr, msg);
mir_free(msg);
}
// Send validation
- http::response resp = flap(OMEGLE_REQUEST_START, NULL, &data);
+ http::response resp = flap(OMEGLE_REQUEST_START, nullptr, &data);
switch (resp.code)
{
@@ -429,11 +429,11 @@ bool Omegle_client::stop()
if (hConnection)
Netlib_CloseHandle(hConnection);
- hConnection = NULL;
+ hConnection = nullptr;
if (hEventsConnection)
Netlib_CloseHandle(hEventsConnection);
- hEventsConnection = NULL;
+ hEventsConnection = nullptr;
if (resp.data == "win") {
return HANDLE_SUCCESS;
@@ -477,7 +477,7 @@ bool Omegle_client::events()
}
JSONROOT root(resp.data.c_str());
- if (root == NULL)
+ if (root == nullptr)
return HANDLE_ERROR(false);
bool newStranger = false;
@@ -485,7 +485,7 @@ bool Omegle_client::events()
for (size_t i = 0; i < json_size(root); i++) {
JSONNode *item = json_at(root, i);
- if (item == NULL)
+ if (item == nullptr)
continue;
std::string name = _T2A(json_as_string(json_at(item, 0)));
@@ -514,11 +514,11 @@ bool Omegle_client::events()
wchar_t strT[255];
mir_snwprintf(strT, TranslateT("On whole Omegle are %s strangers online now."), count);
- parent->UpdateChat(NULL, strT);
+ parent->UpdateChat(nullptr, strT);
}
else if (name == "serverMessage") {
ptrW message(json_as_string(json_at(item, 1)));
- parent->UpdateChat(NULL, TranslateW(message));
+ parent->UpdateChat(nullptr, TranslateW(message));
}
else if (name == "connected") {
// Stranger connected
@@ -613,7 +613,7 @@ bool Omegle_client::events()
wchar_t strT[255];
mir_snwprintf(strT, TranslateT("%s disconnected."), TranslateW(stranger));
- parent->UpdateChat(NULL, strT);
+ parent->UpdateChat(nullptr, strT);
// Stranger disconnected
if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0))
@@ -626,7 +626,7 @@ bool Omegle_client::events()
}
else if (name == "recaptchaRequired") {
// Nothing to do with recaptcha
- parent->UpdateChat(NULL, TranslateT("Recaptcha is required.\nOpen http://omegle.com , solve Recaptcha and try again."));
+ parent->UpdateChat(nullptr, TranslateT("Recaptcha is required.\nOpen http://omegle.com , solve Recaptcha and try again."));
parent->StopChat(false);
}
else if (name == "recaptchaRejected") {
@@ -638,7 +638,7 @@ bool Omegle_client::events()
wchar_t strT[255];
mir_snwprintf(strT, TranslateT("Error: %s"), TranslateW(error));
- parent->UpdateChat(NULL, strT);
+ parent->UpdateChat(nullptr, strT);
}
}
@@ -663,7 +663,7 @@ bool Omegle_client::events()
if (waiting) {
// If we are only waiting in this event...
- parent->UpdateChat(NULL, TranslateT("We are still waiting..."));
+ parent->UpdateChat(nullptr, TranslateT("We are still waiting..."));
}
return HANDLE_SUCCESS;
diff --git a/protocols/Omegle/src/connection.cpp b/protocols/Omegle/src/connection.cpp
index 361820f2b5..db7d5f4403 100644
--- a/protocols/Omegle/src/connection.cpp
+++ b/protocols/Omegle/src/connection.cpp
@@ -34,7 +34,7 @@ void OmegleProto::SignOn(void*)
m_iStatus = m_iDesiredStatus;
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
- setDword("LogonTS", (DWORD)time(NULL));
+ setDword("LogonTS", (DWORD)time(nullptr));
ClearChat();
OnJoinChat(0, false);
@@ -64,13 +64,13 @@ void OmegleProto::SignOff(void*)
if (facy.hEventsConnection)
Netlib_CloseHandle(facy.hEventsConnection);
- facy.hEventsConnection = NULL;
+ facy.hEventsConnection = nullptr;
}
void OmegleProto::StopChat(bool disconnect)
{
if (facy.state_ == STATE_WAITING) {
- UpdateChat(NULL, TranslateT("Connecting canceled."), false);
+ UpdateChat(nullptr, TranslateT("Connecting canceled."), false);
}
else if (facy.state_ == STATE_ACTIVE || facy.state_ == STATE_SPY) {
bool spy = facy.state_ == STATE_SPY;
@@ -78,7 +78,7 @@ void OmegleProto::StopChat(bool disconnect)
if (disconnect)
{
facy.state_ = STATE_DISCONNECTING;
- UpdateChat(NULL, TranslateT("Disconnecting..."), true);
+ UpdateChat(nullptr, TranslateT("Disconnecting..."), true);
if (facy.stop())
debugLogA("***** Disconnected from stranger %s", facy.chat_id_.c_str());
@@ -111,12 +111,12 @@ void OmegleProto::NewChat()
{
if (facy.state_ == STATE_WAITING)
{
- UpdateChat(NULL, TranslateT("We are already waiting for new stranger..."), false);
+ UpdateChat(nullptr, TranslateT("We are already waiting for new stranger..."), false);
return;
}
else if (facy.state_ == STATE_ACTIVE || facy.state_ == STATE_SPY)
{
- UpdateChat(NULL, TranslateT("Disconnecting..."), true);
+ UpdateChat(nullptr, TranslateT("Disconnecting..."), true);
if (facy.stop())
debugLogA("***** Disconnected from stranger %s", facy.chat_id_.c_str());
@@ -135,13 +135,13 @@ void OmegleProto::NewChat()
ClearChat();
- UpdateChat(NULL, TranslateT("Connecting..."), true);
+ UpdateChat(nullptr, TranslateT("Connecting..."), true);
facy.state_ = STATE_WAITING;
if (facy.start())
{
- UpdateChat(NULL, TranslateT("Waiting for Stranger..."), true);
+ UpdateChat(nullptr, TranslateT("Waiting for Stranger..."), true);
debugLogA("***** Waiting for stranger %s", facy.chat_id_.c_str());
}
}
@@ -153,13 +153,13 @@ void OmegleProto::NewChat()
else
{
ClearChat();
- UpdateChat(NULL, TranslateT("Connecting..."), true);
+ UpdateChat(nullptr, TranslateT("Connecting..."), true);
facy.state_ = STATE_WAITING;
if (facy.start())
{
- UpdateChat(NULL, TranslateT("Waiting for Stranger..."), true);
+ UpdateChat(nullptr, TranslateT("Waiting for Stranger..."), true);
debugLogA("***** Waiting for stranger %s", facy.chat_id_.c_str());
ForkThread(&OmegleProto::EventsLoop, this);
@@ -172,7 +172,7 @@ void OmegleProto::EventsLoop(void *)
{
ScopedLock s(events_loop_lock_);
- time_t tim = ::time(NULL);
+ time_t tim = ::time(nullptr);
debugLogA(">>>>> Entering Omegle::EventsLoop[%d]", tim);
while (facy.events())
diff --git a/protocols/Omegle/src/messages.cpp b/protocols/Omegle/src/messages.cpp
index 8544b0464f..d1021c3597 100644
--- a/protocols/Omegle/src/messages.cpp
+++ b/protocols/Omegle/src/messages.cpp
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void OmegleProto::SendMsgWorker(void *p)
{
- if (p == NULL)
+ if (p == nullptr)
return;
std::string data = *(std::string*)p;
@@ -42,7 +42,7 @@ void OmegleProto::SendMsgWorker(void *p)
void OmegleProto::SendTypingWorker(void *p)
{
- if (p == NULL)
+ if (p == nullptr)
return;
// Save typing info
diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp
index aa46bbc601..3f98ad8845 100644
--- a/protocols/Omegle/src/proto.cpp
+++ b/protocols/Omegle/src/proto.cpp
@@ -27,10 +27,10 @@ PROTO<OmegleProto>(proto_name, username)
{
this->facy.parent = this;
- this->signon_lock_ = CreateMutex(NULL, FALSE, NULL);
- this->log_lock_ = CreateMutex(NULL, FALSE, NULL);
- this->facy.connection_lock_ = CreateMutex(NULL, FALSE, NULL);
- this->events_loop_lock_ = CreateMutex(NULL, FALSE, NULL);
+ this->signon_lock_ = CreateMutex(nullptr, FALSE, nullptr);
+ this->log_lock_ = CreateMutex(nullptr, FALSE, nullptr);
+ this->facy.connection_lock_ = CreateMutex(nullptr, FALSE, nullptr);
+ this->events_loop_lock_ = CreateMutex(nullptr, FALSE, nullptr);
// Group chats
CreateProtoService(PS_JOINCHAT, &OmegleProto::OnJoinChat);
@@ -49,10 +49,10 @@ PROTO<OmegleProto>(proto_name, username)
mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName);
nlu.szDescriptiveName.w = descr;
m_hNetlibUser = Netlib_RegisterUser(&nlu);
- if (m_hNetlibUser == NULL) {
+ if (m_hNetlibUser == nullptr) {
wchar_t error[200];
mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName);
- MessageBox(NULL, error, L"Miranda NG", MB_OK | MB_ICONERROR);
+ MessageBox(nullptr, error, L"Miranda NG", MB_OK | MB_ICONERROR);
}
facy.set_handle(m_hNetlibUser);
@@ -171,7 +171,7 @@ int OmegleProto::OnModulesLoaded(WPARAM, LPARAM)
gcr.ptszDispName = m_tszUserName;
gcr.iMaxText = OMEGLE_MESSAGE_LIMIT;
gcr.nColors = 0;
- gcr.pColors = NULL;
+ gcr.pColors = nullptr;
Chat_Register(&gcr);
return 0;
diff --git a/protocols/Omegle/src/theme.cpp b/protocols/Omegle/src/theme.cpp
index a787f5e42c..7fd634c9a7 100644
--- a/protocols/Omegle/src/theme.cpp
+++ b/protocols/Omegle/src/theme.cpp
@@ -42,5 +42,5 @@ HANDLE GetIconHandle(const char* name)
if (mir_strcmp(icons[i].szName, name) == 0)
return icons[i].hIcolib;
- return 0;
+ return nullptr;
}