summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-04-09 17:39:42 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-04-09 17:39:42 +0000
commit00f9b2759777ab68b7f7c731a03e85f8d92b004a (patch)
tree5edd4813daaff41761dda34addb02c69266c5ff6
parent9a1095f99f6a5355fc329faa46ff975a1d76fb1c (diff)
MirFox:
- memory leaks fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@12711 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/MirFox/src/MirandaOptions.cpp11
-rw-r--r--plugins/MirFox/src/MirandaUtils.cpp85
2 files changed, 22 insertions, 74 deletions
diff --git a/plugins/MirFox/src/MirandaOptions.cpp b/plugins/MirFox/src/MirandaOptions.cpp
index 30595f53ea..f810f1a5b1 100644
--- a/plugins/MirFox/src/MirandaOptions.cpp
+++ b/plugins/MirFox/src/MirandaOptions.cpp
@@ -90,10 +90,10 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
}
- if (LOWORD(wParam) == IDC1_BUTTON_INVALIDATE && HIWORD(wParam) == BN_CLICKED){
+ //if (LOWORD(wParam) == IDC1_BUTTON_INVALIDATE && HIWORD(wParam) == BN_CLICKED){
//TODO invalidate button clicked - refresh MSM's (now this button has visable=false at .rc file)
- break;
- }
+ //break;
+ //}
break;
}
@@ -131,7 +131,7 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
wchar_t * opt2Buffer = new WCHAR[opt2Len+1];
UINT opt2NumCharCopy = GetDlgItemText(hwndDlg, IDC1_EDIT1, opt2Buffer, opt2Len+1);
mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->assign(opt2Buffer);
- delete opt2Buffer;
+ delete[] opt2Buffer;
mirfoxMiranda.getMirfoxData().normalizeClientsProfilesFilterString(SMUCONST_CSM_RECORD_VISABLETO_SIZEC_DEF);
SetDlgItemText(hwndDlg, IDC1_EDIT1, mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str());
@@ -294,7 +294,6 @@ static void setAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int
}
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
-
}
@@ -673,7 +672,7 @@ INT_PTR CALLBACK DlgProcOpts_Tab3(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
*
* called from: options.cpp.InitOptions()
*/
-int OptInit(WPARAM wParam, LPARAM lParam) {
+int OptInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = -790000000;
diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp
index 944e21c371..79a897b098 100644
--- a/plugins/MirFox/src/MirandaUtils.cpp
+++ b/plugins/MirFox/src/MirandaUtils.cpp
@@ -14,14 +14,11 @@ MirandaUtils::MirandaUtils()
}
-
-/* static */ void
-MirandaUtils::netlibLog(const wchar_t* szText){
+void MirandaUtils::netlibLog(const wchar_t* szText){
MirandaUtils::getInstance()->netlibLog_int(szText);
}
-void
-MirandaUtils::netlibLog_int(const wchar_t* szText){
+void MirandaUtils::netlibLog_int(const wchar_t* szText){
if (netlibHandle) {
CallService(MS_NETLIB_LOGW, (WPARAM)netlibHandle, (LPARAM)szText);
}
@@ -39,14 +36,11 @@ void MirandaUtils::netlibRegister(){
nlu.ptszDescriptiveName = TranslateT("MirFox log");
netlibHandle = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
-
}
void MirandaUtils::netlibUnregister(){
-
Netlib_CloseHandle(netlibHandle);
netlibHandle = NULL;
-
}
@@ -81,7 +75,6 @@ std::wstring& MirandaUtils::getDisplayName()
displayName.append(L")");
return displayName;
-
}
@@ -113,11 +106,9 @@ void MirandaUtils::userActionThread(void* threadArg)
delete actionThreadArgPtr->userActionSelection;
actionThreadArgPtr->mirfoxDataPtr->workerThreadsCount--;
- delete threadArg;
+ delete actionThreadArgPtr;
Thread_Pop();
- return;
-
}
void MirandaUtils::sendMessageToContact(ActionThreadArgStruct* args)
@@ -140,7 +131,6 @@ void MirandaUtils::sendMessageToContact(ActionThreadArgStruct* args)
void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE mode)
{
-
logger->log_p(L"MirandaUtils::sendMessage: mode = [%d] to = [" SCNuPTR L"] msg = [%s]", mode, args->targetHandle, args->userActionSelection );
if (mode == MFENUM_SMM_ONLY_SEND || mode == MFENUM_SMM_SEND_AND_SHOW_MW){
@@ -153,7 +143,7 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
// targetHandleSzProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hSubContact, 0);
// }
- char* targetHandleSzProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)args->targetHandle, 0); //targetHandleSzProto doesnt need mir_free or delete
+ char *targetHandleSzProto = GetContactProto((MCONTACT)args->targetHandle); //targetHandleSzProto doesnt need mir_free or delete
if (targetHandleSzProto == NULL){
logger->log(L"MirandaUtils::sendMessageToContact: ERROR targetHandleSzProto == NULL");
return;
@@ -165,19 +155,15 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
std::size_t bufSize = 0;
if (mirandaSendModeFlag == PREF_UTF){
-
msgBuffer = mir_utf8encodeW(args->userActionSelection);
bufSize = strlen(msgBuffer) + 1;
-
} else if (mirandaSendModeFlag == PREF_UNICODE){
-
msgBuffer = mir_t2a(args->userActionSelection);
bufSize = strlen(msgBuffer) + 1;
size_t bufSizeT = (wcslen(args->userActionSelection) + 1) * sizeof(wchar_t);
msgBuffer = (char*)mir_realloc(msgBuffer, bufSizeT + bufSize);
memcpy((wchar_t*)&msgBuffer[bufSize], args->userActionSelection, bufSizeT);
bufSize += bufSizeT;
-
}
logger->log_p(L"SMTC: mirandaSendModeFlag = [%d] bufSize = [%d]", mirandaSendModeFlag, bufSize);
@@ -210,7 +196,6 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
} while (myMfAck == NULL && counter <= MAX_ACK_WAIT_COUNTER); //TODO or Plugin_Terminated or Miranda_Terminated()
logger->log_p(L"SMTC: ACK found counter = [%d] myMfAck = [" SCNuPTR L"]", counter, myMfAck);
-
}
MirandaContact* mirandaContact = args->mirfoxDataPtr->getMirandaContactPtrByHandle((MCONTACT)args->targetHandle);
@@ -223,19 +208,15 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
tszAccountName = mirandaAccount->tszAccountName;
}
}
-
if(myMfAck != NULL && myMfAck->result == ACKRESULT_SUCCESS){
-
addMessageToDB((MCONTACT)args->targetHandle, mirandaSendModeFlag, msgBuffer, bufSize, targetHandleSzProto);
-
if (mode == MFENUM_SMM_ONLY_SEND){
-
//show notyfication popup (only in SMM_ONLY_SEND mode)
wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)];
if (contactNameW != NULL && tszAccountName != NULL){
mir_sntprintf(buffer, 1024, TranslateT("Message sent to %s (%s)"), contactNameW, tszAccountName);
} else {
- buffer = mir_wstrdup(TranslateT("Message sent"));
+ mir_sntprintf(buffer, 1024, TranslateT("Message sent"));
}
if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
@@ -244,28 +225,19 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
PUShowMessageT(buffer, SM_NOTIFY);
}
- delete buffer;
-
+ delete[] buffer;
} else if (mode == MFENUM_SMM_SEND_AND_SHOW_MW){
-
//notify hook to open window
if (args->mirfoxDataPtr != NULL && args->mirfoxDataPtr->hhook_EventOpenMW != NULL){
-
OnHookOpenMvStruct* onHookOpenMv = new(OnHookOpenMvStruct);
onHookOpenMv->targetHandle = args->targetHandle;
onHookOpenMv->msgBuffer = NULL;
- NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, (LPARAM)NULL);
-
+ NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, 0);
} else {
-
logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
-
}
-
}
-
} else {
-
//error - show error popup
wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)];
if (myMfAck != NULL){
@@ -280,16 +252,15 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
if (contactNameW != NULL && tszAccountName != NULL){
mir_sntprintf(buffer, 1024, TranslateT("Cannot send message to %s (%s)"), contactNameW, tszAccountName);
} else {
- buffer = mir_wstrdup(TranslateT("Cannot send message - %S"));
+ mir_sntprintf(buffer, 1024, TranslateT("Cannot send message"));
}
}
-
} else {
logger->log(L"SMTC: ERROR - Cannot send message 2");
if (contactNameW != NULL && tszAccountName != NULL){
mir_sntprintf(buffer, 1024, TranslateT("Cannot send message to %s (%s)"), contactNameW, tszAccountName);
} else {
- buffer = mir_wstrdup(TranslateT("Cannot send message"));
+ mir_sntprintf(buffer, 1024, TranslateT("Cannot send message"));
}
}
@@ -299,8 +270,7 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
PUShowMessageT(buffer, SM_WARNING);
}
- delete buffer;
-
+ delete[] buffer;
}
if (myMfAck != NULL){ //when we found ack, not when we exceed MAX_ACK_WAIT_COUNTER
@@ -313,9 +283,7 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
LeaveCriticalSection(&ackMapCs);
mir_free(msgBuffer);
-
} else if (mode == MFENUM_SMM_ONLY_SHOW_MW){
-
//notify hook to open window
if (args->mirfoxDataPtr != NULL && args->mirfoxDataPtr->hhook_EventOpenMW != NULL){
@@ -326,14 +294,11 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
msgBuffer->append(args->userActionSelection);
msgBuffer->append(L"\r\n");
onHookOpenMv->msgBuffer = msgBuffer;
- NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, (LPARAM)NULL);
-
+ NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, 0);
} else {
logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
-
}
-
}
int MirandaUtils::getMirandaSendModeFlag(char* targetHandleSzProto)
@@ -343,7 +308,6 @@ int MirandaUtils::getMirandaSendModeFlag(char* targetHandleSzProto)
} else {
return PREF_UNICODE;
}
-
}
HANDLE MirandaUtils::sendMessageMiranda(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer)
@@ -427,12 +391,11 @@ int MirandaUtils::on_hook_OpenMW(WPARAM wParam, LPARAM lParam)
void MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args)
{
-
logger->log(L"MirandaUtils::setStatusOnAccount: start");
int status = CallProtoService(args->accountSzModuleName, PS_GETSTATUS, 0, 0);
logger->log_p(L"SSOA: on account: [%S] targetHandle = [" SCNuPTR L"] at status = [%d]", args->accountSzModuleName, args->targetHandle, status);
- int result = -1;
+ INT_PTR result = -1;
if (!(CallProtoService(args->accountSzModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_INDIVMODEMSG)){
result = CallProtoService(args->accountSzModuleName, PS_SETAWAYMSGW, (WPARAM)status, (LPARAM)args->userActionSelection);
@@ -451,13 +414,12 @@ void MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args)
wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)];
if(result == 0){
-
if (tszAccountName != NULL){
logger->log_p(L"SSOA: Status message set on [%s]", tszAccountName);
mir_sntprintf(buffer, 1024, TranslateT("Status message set on %s"), tszAccountName);
} else {
logger->log(L"SSOA: Status message set");
- buffer = mir_wstrdup(TranslateT("Status message set"));
+ mir_sntprintf(buffer, 1024, TranslateT("Status message set"));
}
if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
@@ -465,15 +427,13 @@ void MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args)
} else {
PUShowMessageT(buffer, SM_NOTIFY);
}
-
} else {
-
if (tszAccountName != NULL){
logger->log_p(L"SSOA: ERROR - Cannot set status message 2 on [%s] - result = [%d] ", tszAccountName, result);
mir_sntprintf(buffer, 1024, TranslateT("Cannot set status message on %s"), tszAccountName);
} else {
logger->log_p(L"SSOA: ERROR - Cannot set status message 2 - result = [%d] ", result);
- buffer = mir_wstrdup(TranslateT("Cannot set status message"));
+ mir_sntprintf(buffer, 1024, TranslateT("Cannot set status message"));
}
if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
@@ -481,13 +441,11 @@ void MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args)
} else {
PUShowMessageT(buffer, SM_WARNING);
}
-
}
- delete buffer;
-
+ delete[] buffer;
}
-int MirandaUtils::onProtoAck(WPARAM wParam, LPARAM lParam)
+int MirandaUtils::onProtoAck(WPARAM, LPARAM lParam)
{
MirandaUtils* mirandaUtils = MirandaUtils::getInstance();
mirandaUtils->onProtoAckOnInstance((ACKDATA*)lParam);
@@ -525,7 +483,6 @@ void MirandaUtils::onProtoAckOnInstance(ACKDATA* ack)
ackMap[ack->hProcess] = myMfAck;
}
LeaveCriticalSection(&ackMapCs);
-
}
#define OLD_PLUGIN_DB_ID "MirfoxMiranda"
@@ -537,13 +494,10 @@ void MirandaUtils::translateOldDBNames() {
//settings "clientsProfilesFilterCheckbox", "clientsProfilesFilterString"
int opt1KeyValue = db_get_b(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 0);
if (opt1KeyValue != 0){
-
db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", opt1KeyValue);
db_unset(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterCheckbox");
logger->log(L"TranslateOldDBNames: 'clientsProfilesFilterCheckbox' db entry found and moved");
-
} else {
-
logger->log(L"TranslateOldDBNames: no old settings found. returning.");
return;
}
@@ -551,14 +505,12 @@ void MirandaUtils::translateOldDBNames() {
DBVARIANT opt2Dbv = {0};
INT_PTR opt2Result = db_get_s(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterString", &opt2Dbv, DBVT_TCHAR);
if (opt2Result == 0){ //success
-
std::wstring clientsProfilesFilterString = opt2Dbv.pwszVal;
db_set_ts(0, PLUGIN_DB_ID, "clientsProfilesFilterString", clientsProfilesFilterString.c_str());
db_unset(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterString");
logger->log(L"TranslateOldDBNames: 'clientsProfilesFilterString' db entry found and moved");
-
+ db_free(&opt2Dbv);
}
- db_free(&opt2Dbv);
//account's settings "ACCOUNTSTATE_"
int accountsTmpCount = 0;
@@ -576,12 +528,10 @@ void MirandaUtils::translateOldDBNames() {
db_unset(0, OLD_PLUGIN_DB_ID, mirandaAccountDBKey.c_str());
logger->log(L"TranslateOldDBNames: ACCOUNT db entry found and moved");
}
-
}
//contacts "state"
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)){
-
logger->log_p(L"TranslateOldDBNames: found CONTACT: [" SCNuPTR L"]", hContact);
int keyValue = db_get_b(hContact, OLD_PLUGIN_DB_ID, "state", 0);
@@ -590,7 +540,6 @@ void MirandaUtils::translateOldDBNames() {
db_unset(hContact, OLD_PLUGIN_DB_ID, "state");
logger->log(L"TranslateOldDBNames: CONTACT db entry found and moved");
}
-
}
//delete db module