summaryrefslogtreecommitdiff
path: root/plugins/VoiceService/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-08-31 20:55:33 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-08-31 20:55:33 +0300
commitf787825fea601eaece7f20ad11a444c1766bcb2e (patch)
tree4d0017100d6a83ab97647ede9067c87d617b86ae /plugins/VoiceService/src
parenta018488fdc9fd3732e45c4b5f7667d2ed5ae23bf (diff)
code cleaning
Diffstat (limited to 'plugins/VoiceService/src')
-rw-r--r--plugins/VoiceService/src/VoiceCall.cpp12
-rw-r--r--plugins/VoiceService/src/VoiceProvider.cpp8
-rw-r--r--plugins/VoiceService/src/hooks.cpp16
-rw-r--r--plugins/VoiceService/src/popup.cpp6
-rw-r--r--plugins/VoiceService/src/services.cpp6
5 files changed, 23 insertions, 25 deletions
diff --git a/plugins/VoiceService/src/VoiceCall.cpp b/plugins/VoiceService/src/VoiceCall.cpp
index c6f579f2d4..4cf8ef6dda 100644
--- a/plugins/VoiceService/src/VoiceCall.cpp
+++ b/plugins/VoiceService/src/VoiceCall.cpp
@@ -68,7 +68,7 @@ VoiceCall::VoiceCall(VoiceProvider *module, const char *id) :
m_calltimer.OnEvent = Callback(this, &VoiceCall::OnCallTimer);
CreateDisplayName();
- Show(SW_SHOWNOACTIVATE);
+ Show(SW_SHOWNORMAL);
}
VoiceCall::~VoiceCall()
@@ -124,8 +124,8 @@ void VoiceCall::OnCallTimer(CTimer *)
int mins = m_nsec / 60;
int hours = m_nsec / 3600;
if (hours)
- mir_snwprintf(hrs, _countof(hrs), L"%d:", hours);
- mir_snwprintf(text, _countof(text), L"%s%d:%02d", hrs, (mins) % 60, m_nsec % 60);
+ mir_snwprintf(hrs, L"%d:", hours);
+ mir_snwprintf(text, L"%s%d:%02d", hrs, (mins) % 60, m_nsec % 60);
m_lblStatus.SetText(text);
}
@@ -143,12 +143,12 @@ void VoiceCall::AppendCallerID(MCONTACT aHContact, const wchar_t *aName, const w
}
if (!IsEmptyW(aName)) {
- lstrcpyn(name, aName, _countof(name));
+ wcsncpy_s(name, aName, _TRUNCATE);
changed = true;
}
if (!IsEmptyW(aNumber)) {
- lstrcpyn(number, aNumber, _countof(number));
+ wcsncpy_s(number, aNumber, _TRUNCATE);
changed = true;
}
@@ -272,7 +272,7 @@ void VoiceCall::Notify(bool popup, bool sound, bool /*clist*/)
{
if (popup) {
wchar_t text[512];
- mir_snwprintf(text, _countof(text), TranslateW(stateTexts[state]), displayName);
+ mir_snwprintf(text, TranslateW(stateTexts[state]), displayName);
ShowPopup(NULL, TranslateW(popupTitles[state]), text);
}
diff --git a/plugins/VoiceService/src/VoiceProvider.cpp b/plugins/VoiceService/src/VoiceProvider.cpp
index cbfcfa8f77..a5ec34d27c 100644
--- a/plugins/VoiceService/src/VoiceProvider.cpp
+++ b/plugins/VoiceService/src/VoiceProvider.cpp
@@ -77,17 +77,15 @@ static int VoiceState(WPARAM wParam, LPARAM)
VoiceProvider::VoiceProvider(const char *name, const wchar_t *description, int flags, HANDLE pIcon) :
hIcolib(pIcon)
{
- strncpy(this->name, name, _countof(this->name));
- this->name[_countof(this->name) - 1] = 0;
-
- lstrcpyn(this->description, description, _countof(this->description));
+ strncpy_s(this->name, name, _TRUNCATE);
+ wcsncpy_s(this->description, description, _TRUNCATE);
this->flags = flags;
is_protocol = IsProtocol(name);
canHold = (ProtoServiceExists(name, PS_VOICE_HOLDCALL) != 0);
char str[MAXMODULELABELLENGTH];
- mir_snprintf(str, _countof(str), "%s%s", name, PE_VOICE_CALL_STATE);
+ mir_snprintf(str, "%s%s", name, PE_VOICE_CALL_STATE);
state_hook = HookEvent(str, VoiceState);
}
diff --git a/plugins/VoiceService/src/hooks.cpp b/plugins/VoiceService/src/hooks.cpp
index 4eaa3ffcb5..46d9885bf3 100644
--- a/plugins/VoiceService/src/hooks.cpp
+++ b/plugins/VoiceService/src/hooks.cpp
@@ -82,7 +82,7 @@ public:
if (number == NULL)
this->number[0] = 0;
else
- lstrcpyn(this->number, number, _countof(this->number));
+ wcsncpy_s(this->number, number, _TRUNCATE);
}
void Call()
@@ -142,7 +142,7 @@ static void BuildCallingMethodsList(OBJLIST<CallingMethod> *list, MCONTACT hCont
for (int i = 0; ; i++) {
char tmp[128];
- mir_snprintf(tmp, _countof(tmp), "MyPhone%d", i);
+ mir_snprintf(tmp, "MyPhone%d", i);
CMStringW number(db_get_wsm(hContact, "UserInfo", tmp));
if (!number.IsEmpty())
@@ -203,7 +203,7 @@ static int AccListChanged(WPARAM wParam, LPARAM lParam)
case PRAC_CHANGED:
if (provider != NULL)
- lstrcpyn(provider->description, acc->tszAccountName, _countof(provider->description));
+ wcsncpy_s(provider->description, acc->tszAccountName, _TRUNCATE);
break;
case PRAC_CHECKED:
@@ -277,10 +277,10 @@ static int PreBuildContactMenu(WPARAM wParam, LPARAM)
wchar_t name[128];
if (!IsEmptyW(method->number))
- mir_snwprintf(name, _countof(name), TranslateT("Call %s with %s"),
+ mir_snwprintf(name, TranslateT("Call %s with %s"),
method->number, method->provider->description);
else
- mir_snwprintf(name, _countof(name), TranslateT("Call with %s"),
+ mir_snwprintf(name, TranslateT("Call with %s"),
method->provider->description);
Menu_ModifyItem(hCMCall, name);
@@ -297,14 +297,14 @@ static int PreBuildContactMenu(WPARAM wParam, LPARAM)
wchar_t name[128];
if (!IsEmptyW(method->number))
- mir_snwprintf(name, _countof(name), TranslateT("%s with %s"),
+ mir_snwprintf(name, TranslateT("%s with %s"),
method->number, method->provider->description);
else
- mir_snwprintf(name, _countof(name), TranslateT("with %s"),
+ mir_snwprintf(name, TranslateT("with %s"),
method->provider->description);
char service[128];
- mir_snprintf(service, _countof(service), "VoiceService/ContactMenu/Call_%d", i);
+ mir_snprintf(service, "VoiceService/ContactMenu/Call_%d", i);
if (i == hCMCalls.size()) {
CreateServiceFunctionParam(service, Service_CallItem, i);
diff --git a/plugins/VoiceService/src/popup.cpp b/plugins/VoiceService/src/popup.cpp
index a643850295..bac95b09e0 100644
--- a/plugins/VoiceService/src/popup.cpp
+++ b/plugins/VoiceService/src/popup.cpp
@@ -80,12 +80,12 @@ void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *descrip
ppd.lchIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(174), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
if (title != NULL)
- lstrcpyn(ppd.lpwzContactName, title, _countof(ppd.lpwzContactName));
+ wcsncpy_s(ppd.lpwzContactName, title, _TRUNCATE);
else if (hContact != NULL)
- lstrcpyn(ppd.lpwzContactName, Clist_GetContactDisplayName(hContact, 0), _countof(ppd.lpwzContactName));
+ wcsncpy_s(ppd.lpwzContactName, Clist_GetContactDisplayName(hContact, 0), _TRUNCATE);
if (description != NULL)
- lstrcpyn(ppd.lpwzText, description, _countof(ppd.lpwzText));
+ wcsncpy_s(ppd.lpwzText, description, _TRUNCATE);
if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST) {
if (op->popup_use_default_colors) {
diff --git a/plugins/VoiceService/src/services.cpp b/plugins/VoiceService/src/services.cpp
index e068d3dd6f..ad99378728 100644
--- a/plugins/VoiceService/src/services.cpp
+++ b/plugins/VoiceService/src/services.cpp
@@ -36,15 +36,15 @@ static INT_PTR CALLBACK DlgProcNewCall(HWND hwndDlg, UINT msg, WPARAM wParam, LP
VoiceCall *currentCall = GetTalkingCall();
if (currentCall == NULL) {
- mir_snwprintf(text, _countof(text), TranslateT("%s wants to start a voice call with you. What you want to do?"),
+ mir_snwprintf(text, TranslateT("%s wants to start a voice call with you. What you want to do?"),
call->displayName);
}
else if (currentCall->CanHold()) {
- mir_snwprintf(text, _countof(text), TranslateT("%s wants to start a voice call with you. What you want to do?\n\nIf you answer the call, the current call will be put on hold."),
+ mir_snwprintf(text, TranslateT("%s wants to start a voice call with you. What you want to do?\n\nIf you answer the call, the current call will be put on hold."),
call->displayName);
}
else {
- mir_snwprintf(text, _countof(text), TranslateT("%s wants to start a voice call with you. What you want to do?\n\nIf you answer the call, the current call will be dropped."),
+ mir_snwprintf(text, TranslateT("%s wants to start a voice call with you. What you want to do?\n\nIf you answer the call, the current call will be dropped."),
call->displayName);
}