summaryrefslogtreecommitdiff
path: root/src/modules/metacontacts
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2014-04-18 10:10:25 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2014-04-18 10:10:25 +0000
commit3bf31e0a0f3332fe8c150c24cd79da6d8acca722 (patch)
tree527758e5d1bad946017f9774163a3aa779953a77 /src/modules/metacontacts
parent9488fce53a0784c99c744d6652fc7a8da6749aeb (diff)
metacontacts:
-fixed a rare crash -some ressource fixes -code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@9000 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/metacontacts')
-rw-r--r--src/modules/metacontacts/meta_addto.cpp2
-rw-r--r--src/modules/metacontacts/meta_edit.cpp49
-rw-r--r--src/modules/metacontacts/meta_menu.cpp25
-rw-r--r--src/modules/metacontacts/meta_options.cpp84
-rw-r--r--src/modules/metacontacts/meta_services.cpp43
-rw-r--r--src/modules/metacontacts/meta_utils.cpp42
6 files changed, 108 insertions, 137 deletions
diff --git a/src/modules/metacontacts/meta_addto.cpp b/src/modules/metacontacts/meta_addto.cpp
index 98d1a310e8..696b375237 100644
--- a/src/modules/metacontacts/meta_addto.cpp
+++ b/src/modules/metacontacts/meta_addto.cpp
@@ -170,7 +170,7 @@ static INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wPa
switch (LOWORD(wParam)) {
case IDOK:
{
- int item = SendMessage(GetDlgItem(hwndDlg, IDC_METALIST), LB_GETCURSEL, 0, 0); // Get the index of the selected metacontact
+ int item = SendDlgItemMessage(hwndDlg, IDC_METALIST, LB_GETCURSEL, 0, 0); // Get the index of the selected metacontact
if (item == -1)
return IDOK == MessageBox(hwndDlg, TranslateT("Please select a MetaContact"), TranslateT("No MetaContact selected"), MB_ICONHAND);
diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp
index b0ce85dfce..d5496b7dd4 100644
--- a/src/modules/metacontacts/meta_edit.cpp
+++ b/src/modules/metacontacts/meta_edit.cpp
@@ -208,9 +208,6 @@ LRESULT ProcessCustomDraw(LPARAM lParam)
static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- HWND hwnd;
- int sel, i;
-
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -225,7 +222,7 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
// Disable the 'Apply' button.
EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), FALSE);
- hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
ListView_SetExtendedListViewStyle(hwnd, LVS_EX_FULLROWSELECT);
// Create list columns
@@ -268,7 +265,7 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
g_data.num_deleted = 0;
g_data.hDefaultContact = Meta_GetContactHandle(g_data.cc, cc->nDefault);
g_data.hOfflineContact = Meta_GetContactHandle(g_data.cc, offline_contact_number);
- for (i = 0; i < cc->nSubs; i++)
+ for (int i = 0; i < cc->nSubs; i++)
g_data.hContact[i] = Meta_GetContactHandle(g_data.cc, i);
SendMessage(hwndDlg, WMU_SETTITLE, 0, lParam);
@@ -283,7 +280,7 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
if (ptszCDN == NULL)
ptszCDN = TranslateT("(Unknown Contact)");
- SetWindowText(GetDlgItem(hwndDlg, IDC_ED_NAME), ptszCDN);
+ SetDlgItemText(hwndDlg, IDC_ED_NAME, ptszCDN);
}
return TRUE;
@@ -291,7 +288,7 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
switch (LOWORD(wParam)) { // hit control
case IDC_LST_CONTACTS: // did we hit our ListView contorl?
if (((LPNMHDR)lParam)->code == NM_CLICK) {
- sel = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LST_CONTACTS), -1, LVNI_FOCUSED | LVNI_SELECTED); // return item selected
+ int sel = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LST_CONTACTS), -1, LVNI_FOCUSED | LVNI_SELECTED); // return item selected
// enable buttons
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REM), sel != -1);
@@ -339,9 +336,9 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
EndDialog(hwndDlg, IDCANCEL);
return TRUE;
- case IDC_BTN_SETDEFAULT:
- hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
- sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
+ case IDC_BTN_SETDEFAULT: {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
+ int sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
InvalidateRect(hwnd, 0, TRUE);
g_data.hDefaultContact = g_data.hContact[sel];
SendMessage(hwndDlg, WMU_SETTITLE, 0, (LPARAM)g_data.hContact[sel]);
@@ -351,10 +348,10 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
return TRUE;
-
- case IDC_BTN_SETOFFLINE:
- hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
- sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
+ }
+ case IDC_BTN_SETOFFLINE: {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
+ int sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
InvalidateRect(hwnd, 0, TRUE);
g_data.hOfflineContact = g_data.hContact[sel];
@@ -363,10 +360,10 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
return TRUE;
-
- case IDC_BTN_REM:
- hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
- sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
+ }
+ case IDC_BTN_REM: {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
+ int sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
g_data.num_contacts--;
g_data.hDeletedContacts[g_data.num_deleted++] = g_data.hContact[sel];
if (g_data.hDefaultContact == g_data.hContact[sel]) {
@@ -380,7 +377,7 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
}
}
- for (i = sel; i < g_data.num_contacts; i++)
+ for (int i = sel; i < g_data.num_contacts; i++)
g_data.hContact[i] = g_data.hContact[i + 1];
FillContactList(hwndDlg);
@@ -394,10 +391,10 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
// Enable the 'Apply' button.
EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
return TRUE;
-
- case IDC_BTN_UP:
- hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
- sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
+ }
+ case IDC_BTN_UP: {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
+ int sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
{
MCONTACT temp = g_data.hContact[sel];
g_data.hContact[sel] = g_data.hContact[sel - 1];
@@ -411,10 +408,10 @@ static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wPara
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel < g_data.num_contacts - 1));
EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
return TRUE;
-
+ }
case IDC_BTN_DOWN:
- hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
- sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
+ int sel = ListView_GetNextItem(hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
{
MCONTACT temp = g_data.hContact[sel];
g_data.hContact[sel] = g_data.hContact[sel + 1];
diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp
index 4e8cd40187..755ba5084a 100644
--- a/src/modules/metacontacts/meta_menu.cpp
+++ b/src/modules/metacontacts/meta_menu.cpp
@@ -106,24 +106,24 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateI
Meta_SwapContacts(ccMeta, i, i - 1);
// remove the last one
- char buffer[512], idStr[20];
- _itoa(ccMeta->nSubs - 1, idStr, 10);
- strcpy(buffer, "Protocol"); strcat(buffer, idStr);
+ int id = ccMeta->nSubs - 1;
+ char buffer[512];
+ mir_snprintf(buffer, SIZEOF(buffer), "Protocol%d", id);
db_unset(ccMeta->contactID, META_PROTO, buffer);
- strcpy(buffer, "Status"); strcat(buffer, idStr);
+ mir_snprintf(buffer, SIZEOF(buffer), "Status%d", id);
db_unset(ccMeta->contactID, META_PROTO, buffer);
- strcpy(buffer, "StatusString"); strcat(buffer, idStr);
+ mir_snprintf(buffer, SIZEOF(buffer), "StatusString%d", id);
db_unset(ccMeta->contactID, META_PROTO, buffer);
- strcpy(buffer, "Login"); strcat(buffer, idStr);
+ mir_snprintf(buffer, SIZEOF(buffer), "Login%d", id);
db_unset(ccMeta->contactID, META_PROTO, buffer);
- strcpy(buffer, "Nick"); strcat(buffer, idStr);
+ mir_snprintf(buffer, SIZEOF(buffer), "Nick%d", id);
db_unset(ccMeta->contactID, META_PROTO, buffer);
- strcpy(buffer, "CListName"); strcat(buffer, idStr);
+ mir_snprintf(buffer, SIZEOF(buffer), "CListName%d", id);
db_unset(ccMeta->contactID, META_PROTO, buffer);
ccSub->parentID = 0;
@@ -157,7 +157,7 @@ void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateI
AI.format = PA_FORMAT_UNKNOWN;
_tcscpy(AI.filename, _T("X"));
- if ((int)CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS)
+ if (CallProtoService(META_PROTO, PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS)
db_set_ts(ccMeta->contactID, "ContactPhoto", "File", AI.filename);
}
}
@@ -320,7 +320,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam)
}
PROTOACCOUNT *pa = Proto_GetAccount(cc->szProto);
- if (!db_mc_isEnabled() || pa->bIsVirtual) {
+ if (!db_mc_isEnabled() || !pa || pa->bIsVirtual) {
// groups disabled - all meta menu options hidden
Menu_ShowItem(hMenuDefault, false);
Menu_ShowItem(hMenuDelete, false);
@@ -428,7 +428,6 @@ void InitMenus()
mi.pszName = LPGEN("Subcontacts");
hMenuRoot = Menu_AddContactMenuItem(&mi);
- char buffer[512], buffer2[512];
mi.flags = CMIF_HIDDEN | CMIF_CHILDPOPUP;
mi.hParentMenu = hMenuRoot;
@@ -436,8 +435,8 @@ void InitMenus()
mi.position--;
mi.pszName = "";
- strcpy(buffer, "MetaContacts/MenuFunc");
- strcat(buffer, _itoa(i, buffer2, 10));
+ char buffer[512];
+ mir_snprintf(buffer, SIZEOF(buffer),"MetaContacts/MenuFunc%d", i);
mi.pszService = buffer;
hMenuContact[i] = Menu_AddContactMenuItem(&mi);
diff --git a/src/modules/metacontacts/meta_options.cpp b/src/modules/metacontacts/meta_options.cpp
index 1346f0b049..e7772fa96f 100644
--- a/src/modules/metacontacts/meta_options.cpp
+++ b/src/modules/metacontacts/meta_options.cpp
@@ -29,9 +29,6 @@ MetaOptions options_changes;
INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- HWND hw;
- TCHAR buff[40];
-
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
@@ -49,10 +46,11 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
CheckDlgButton(hwndDlg, IDC_RAD_NICK, options_changes.clist_contact_name == CNNT_NICK);
CheckDlgButton(hwndDlg, IDC_RAD_NAME, options_changes.clist_contact_name == CNNT_DISPLAYNAME);
CheckDlgButton(hwndDlg, IDC_CHK_LOCKHANDLE, options_changes.bLockHandle);
-
- hw = GetDlgItem(hwndDlg, IDC_ED_DAYS);
- _itot(options_changes.days_history, buff, 10);
- SetWindowText(hw, buff);
+ {
+ TCHAR buff[40];
+ _itot(options_changes.days_history, buff, SIZEOF(buff));
+ SetDlgItemText(hwndDlg, IDC_ED_DAYS, buff);
+ }
return TRUE;
case WM_COMMAND:
@@ -128,8 +126,8 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
- hw = GetDlgItem(hwndDlg, IDC_ED_DAYS);
- GetWindowText(hw, buff, SIZEOF(buff));
+ TCHAR buff[40];
+ GetDlgItemText(hwndDlg, IDC_ED_DAYS, buff, SIZEOF(buff));
if (buff[0] != 0)
options_changes.days_history = _ttoi(buff);
@@ -318,9 +316,6 @@ void ResetPriorities()
INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- HWND hw;
- int sel;
-
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -331,29 +326,28 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP
PROTOACCOUNT **pppDesc;
ProtoEnumAccounts(&num_protocols, &pppDesc);
- hw = GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL);
- int index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)TranslateT("<default>"));
- SendMessage(hw, CB_SETITEMDATA, index, -1);
+ int index = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_INSERTSTRING, -1, (LPARAM)TranslateT("<default>"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_SETITEMDATA, index, -1);
for (int i = 0; i < num_protocols; i++) {
if (strcmp(pppDesc[i]->szModuleName, META_PROTO) != 0) {
- index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)pppDesc[i]->tszAccountName);
- SendMessage(hw, CB_SETITEMDATA, index, i);
+ index = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_INSERTSTRING, -1, (LPARAM)pppDesc[i]->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_SETITEMDATA, index, i);
}
}
- SendMessage(hw, CB_SETCURSEL, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_SETCURSEL, 0, 0);
SendMessage(hwndDlg, WMU_FILLSTATUSCMB, 0, 0);
SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0);
}
return FALSE;
- case WMU_FILLPRIODATA:
- sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ case WMU_FILLPRIODATA: {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETCURSEL, 0, 0);
if (sel != -1) {
- int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0);
- sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0);
+ int index = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETITEMDATA, sel, 0);
+ sel = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_GETCURSEL, 0, 0);
if (sel != -1) {
- int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, sel, 0);
+ int status = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_GETITEMDATA, sel, 0);
SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE);
if (index == -1) {
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), TRUE);
@@ -378,17 +372,16 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
}
return TRUE;
-
- case WMU_FILLSTATUSCMB:
- sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ }
+ case WMU_FILLSTATUSCMB:{
+ int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETCURSEL, 0, 0);
if (sel != -1) {
- int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0);
- HWND hw = GetDlgItem(hwndDlg, IDC_CMB_STATUS);
- SendMessage(hw, CB_RESETCONTENT, 0, 0);
+ int index = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETITEMDATA, sel, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_RESETCONTENT, 0, 0);
if (index == -1) {
for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
- index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0));
- SendMessage(hw, CB_SETITEMDATA, index, i);
+ index = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_INSERTSTRING, -1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_SETITEMDATA, index, i);
}
}
else {
@@ -400,27 +393,28 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP
for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
if (caps & Proto_Status2Flag(i)) {
- index = SendMessage(hw, CB_INSERTSTRING, -1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0));
- SendMessage(hw, CB_SETITEMDATA, index, i);
+ index = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_INSERTSTRING, -1, (LPARAM)cli.pfnGetStatusModeDescription(i, 0));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_SETITEMDATA, index, i);
}
}
}
- SendMessage(hw, CB_SETCURSEL, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_SETCURSEL, 0, 0);
SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0);
}
return TRUE;
+ }
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED) {
switch (LOWORD(wParam)) {
- case IDC_CHK_DEFAULT:
- sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ case IDC_CHK_DEFAULT: {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETCURSEL, 0, 0);
if (sel != -1) {
- int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0);
- sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0);
+ int index = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETITEMDATA, sel, 0);
+ sel = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_GETCURSEL, 0, 0);
if (sel != -1) {
BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHK_DEFAULT);
- int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, sel, 0);
+ int status = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_GETITEMDATA, sel, 0);
if (checked) {
SetPriority(index, status, TRUE, 0);
SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE);
@@ -433,7 +427,7 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
}
break;
-
+ }
case IDC_BTN_RESET:
ResetPriorities();
SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_SETCURSEL, 0, 0);
@@ -445,12 +439,12 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
if (HIWORD(wParam) == EN_CHANGE && LOWORD(wParam) == IDC_ED_PRIORITY && (HWND)lParam == GetFocus()) {
- sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETCURSEL, 0, 0);
if (sel != -1) {
- int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, sel, 0);
- sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0);
+ int index = SendDlgItemMessage(hwndDlg, IDC_CMB_PROTOCOL, CB_GETITEMDATA, sel, 0);
+ sel = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_GETCURSEL, 0, 0);
if (sel != -1) {
- int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, sel, 0);
+ int status = SendDlgItemMessage(hwndDlg, IDC_CMB_STATUS, CB_GETITEMDATA, sel, 0);
int prio = GetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, 0, FALSE);
SetPriority(index, status, FALSE, prio);
if (prio != GetPriority(index, status))
@@ -488,7 +482,7 @@ INT_PTR CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LP
/////////////////////////////////////////////////////////////////////////////////////////
-int Meta_OptInit(WPARAM wParam, LPARAM lParam)
+int Meta_OptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = -790000000;
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp
index 7a1fb8ad6e..30c7d6ae0e 100644
--- a/src/modules/metacontacts/meta_services.cpp
+++ b/src/modules/metacontacts/meta_services.cpp
@@ -312,7 +312,7 @@ int Meta_HandleACK(WPARAM, LPARAM lParam)
int Meta_SettingChanged(WPARAM hContact, LPARAM lParam)
{
DBCONTACTWRITESETTING *dcws = (DBCONTACTWRITESETTING *)lParam;
- char buffer[512], szId[40];
+ char buffer[512];
// the only global options we're interested in
if (hContact == 0)
@@ -361,14 +361,12 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam)
}
else if (!strcmp(dcws->szSetting, "Nick") && !dcws->value.type == DBVT_DELETED) {
// subcontact nick has changed - update metacontact
- strcpy(buffer, "Nick");
- strcat(buffer, _itoa(contact_number, szId, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "Nick%d", contact_number);
db_set(ccMeta->contactID, META_PROTO, buffer, &dcws->value);
DBVARIANT dbv;
if (db_get_s(hContact, "CList", "MyHandle", &dbv, 0)) {
- strcpy(buffer, "CListName");
- strcat(buffer, _itoa(contact_number, szId, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "CListName%d", contact_number);
db_set(ccMeta->contactID, META_PROTO, buffer, &dcws->value);
}
else db_free(&dbv);
@@ -394,8 +392,7 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam)
else if (!strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "MyHandle")) {
if (dcws->value.type == DBVT_DELETED) {
char *proto = GetContactProto(hContact);
- strcpy(buffer, "CListName");
- strcat(buffer, _itoa(contact_number, szId, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "CListName%d", contact_number);
DBVARIANT dbv;
if (proto && !db_get_ts(hContact, proto, "Nick", &dbv)) {
@@ -406,8 +403,7 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam)
}
else {
// subcontact clist displayname has changed - update metacontact
- strcpy(buffer, "CListName");
- strcat(buffer, _itoa(contact_number, szId, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "CListName%d", contact_number);
db_set(ccMeta->contactID, META_PROTO, buffer, &dcws->value);
}
@@ -420,12 +416,10 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam)
// subcontact changing status
// update subcontact status setting
- strcpy(buffer, "Status");
- strcat(buffer, _itoa(contact_number, szId, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "Status%d", contact_number);
db_set_w(ccMeta->contactID, META_PROTO, buffer, dcws->value.wVal);
-
- strcpy(buffer, "StatusString");
- strcat(buffer, _itoa(contact_number, szId, 10));
+
+ mir_snprintf(buffer, SIZEOF(buffer), "StatusString%d", contact_number);
db_set_ts(ccMeta->contactID, META_PROTO, buffer, cli.pfnGetStatusModeDescription(dcws->value.wVal, 0));
// set status to that of most online contact
@@ -636,6 +630,9 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu);
HookEvent(ME_CLIST_DOUBLECLICKED, Meta_ClistDoubleClicked);
+ // hook srmm window close/open events
+ HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent);
+ HookEvent(ME_MSG_ICONPRESSED, Meta_SrmmIconClicked);
////////////////////////////////////////////////////////////////////////////
InitMenus();
@@ -646,10 +643,6 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam)
sid.hIcon = LoadSkinnedProtoIcon(META_PROTO, ID_STATUS_ONLINE);
Srmm_AddIcon(&sid);
- // hook srmm window close/open events
- HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent);
- HookEvent(ME_MSG_ICONPRESSED, Meta_SrmmIconClicked);
-
// hook protocol nudge events to forward to subcontacts
int numberOfProtocols;
PROTOACCOUNT ** ppProtocolDescriptors;
@@ -690,15 +683,11 @@ INT_PTR Meta_ContactMenuFunc(WPARAM hMeta, LPARAM lParam)
// open message window if protocol supports message sending or chat, else simulate double click
char *proto = GetContactProto(hContact);
if (proto) {
- char buffer[512];
- strcpy(buffer, proto);
- strcat(buffer, PS_GETCAPS);
-
- int caps = CallService(buffer, PFLAGNUM_1, 0);
- if ((caps & PF1_IMSEND) || (caps & PF1_CHAT) || (proto && strcmp(proto, "IRC") == 0)) {
+ INT_PTR caps = CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0);
+ if ((caps & PF1_IMSEND) || (caps & PF1_CHAT)) {
// set default contact for sending/status and open message window
db_mc_setDefaultNum(hMeta, lParam);
- CallService(MS_MSG_SENDMESSAGE, hMeta, 0);
+ CallService(MS_MSG_SENDMESSAGET, hMeta, 0);
}
else // protocol does not support messaging - simulate double click
CallService(MS_CLIST_CONTACTDOUBLECLICKED, hContact, 0);
@@ -731,7 +720,7 @@ INT_PTR Meta_FileSend(WPARAM wParam, LPARAM lParam)
char *proto = GetContactProto(most_online);
if (proto)
- return (int)(CallContactService(most_online, PSS_FILE, ccs->wParam, ccs->lParam));
+ return CallContactService(most_online, PSS_FILE, ccs->wParam, ccs->lParam);
return 0; // fail
}
@@ -752,7 +741,7 @@ INT_PTR Meta_GetAwayMsg(WPARAM wParam, LPARAM lParam)
return 0;
ccs->hContact = most_online;
- return (int)(CallContactService(ccs->hContact, PSS_GETAWAYMSG, ccs->wParam, ccs->lParam));
+ return CallContactService(ccs->hContact, PSS_GETAWAYMSG, ccs->wParam, ccs->lParam);
}
INT_PTR Meta_GetAvatarInfo(WPARAM wParam, LPARAM lParam)
diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp
index 6f3b67bd78..32986361e8 100644
--- a/src/modules/metacontacts/meta_utils.cpp
+++ b/src/modules/metacontacts/meta_utils.cpp
@@ -108,8 +108,6 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
return FALSE;
}
- char szId[40];
- _itoa(ccDest->nSubs++, szId, 10);
if (ccDest->nSubs >= MAX_CONTACTS) {
MessageBox(0, TranslateT("MetaContact is full"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
db_free(&dbv);
@@ -117,8 +115,9 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
}
// write the contact's protocol
+ int id = ccDest->nSubs++;
char buffer[512];
- strcpy(buffer, "Protocol"); strcat(buffer, szId);
+ mir_snprintf(buffer, SIZEOF(buffer),"Protocol%d",id);
if (db_set_s(hMeta, META_PROTO, buffer, szProto)) {
MessageBox(0, TranslateT("Could not write contact protocol to MetaContact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
db_free(&dbv);
@@ -126,7 +125,7 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
}
// write the login
- strcpy(buffer, "Login"); strcat(buffer, szId);
+ mir_snprintf(buffer, SIZEOF(buffer),"Login%d",id);
if (db_set(hMeta, META_PROTO, buffer, &dbv)) {
MessageBox(0, TranslateT("Could not write unique ID of contact to MetaContact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
db_free(&dbv);
@@ -138,10 +137,10 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
// If we can get the nickname of the subcontact...
if (!db_get(hSub, szProto, "Nick", &dbv)) {
// write the nickname
- strcpy(buffer, "Nick");
- strcat(buffer, szId);
+ mir_snprintf(buffer, SIZEOF(buffer),"Nick%d",id);
if (db_set(hMeta, META_PROTO, buffer, &dbv)) {
MessageBox(0, TranslateT("Could not write nickname of contact to MetaContact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
+ db_free(&dbv);
return FALSE;
}
@@ -149,23 +148,22 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
}
// write the display name
- strcpy(buffer, "CListName");
- strcat(buffer, szId);
+ mir_snprintf(buffer, SIZEOF(buffer),"CListName%d",id);
db_set_ts(hMeta, META_PROTO, buffer, cli.pfnGetContactDisplayName(hSub, 0));
// Get the status
WORD status = (!szProto) ? ID_STATUS_OFFLINE : db_get_w(hSub, szProto, "Status", ID_STATUS_OFFLINE);
// write the status
- strcpy(buffer, "Status"); strcat(buffer, szId);
+ mir_snprintf(buffer, SIZEOF(buffer),"Status%d",id);
db_set_w(hMeta, META_PROTO, buffer, status);
// write the handle
- strcpy(buffer, "Handle"); strcat(buffer, szId);
+ mir_snprintf(buffer, SIZEOF(buffer),"Handle%d",id);
db_set_dw(hMeta, META_PROTO, buffer, hSub);
// write status string
- strcpy(buffer, "StatusString"); strcat(buffer, szId);
+ mir_snprintf(buffer, SIZEOF(buffer),"StatusString%d",id);
TCHAR *szStatus = cli.pfnGetStatusModeDescription(status, 0);
db_set_ts(hMeta, META_PROTO, buffer, szStatus);
@@ -331,7 +329,7 @@ MCONTACT Meta_GetContactHandle(DBCachedContact *cc, int contact_number)
int Meta_HideLinkedContacts(void)
{
DBVARIANT dbv, dbv2;
- char buffer[512], buffer2[512];
+ char buffer[512];
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
@@ -345,28 +343,25 @@ int Meta_HideLinkedContacts(void)
// get contact number
int contact_number = Meta_GetContactNumber(cc, hContact);
- // prepare to update metacontact record of subcontat status
- char *szProto = GetContactProto(hContact);
-
// find metacontact
if (contact_number < 0 || contact_number >= ccMeta->nSubs)
continue;
// update metacontact's record of status for this contact
- strcpy(buffer, "Status");
- strcat(buffer, _itoa(contact_number, buffer2, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "Status%d",contact_number);
+
+ // prepare to update metacontact record of subcontat status
+ char *szProto = GetContactProto(hContact);
WORD status = (!szProto) ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
db_set_w(ccMeta->contactID, META_PROTO, buffer, status);
// update metacontact's record of nick for this contact
if (szProto && !db_get(hContact, szProto, "Nick", &dbv)) {
- strcpy(buffer, "Nick");
- strcat(buffer, _itoa(contact_number, buffer2, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "Nick%d",contact_number);
db_set(ccMeta->contactID, META_PROTO, buffer, &dbv);
- strcpy(buffer, "CListName");
- strcat(buffer, _itoa(contact_number, buffer2, 10));
+ mir_snprintf(buffer, SIZEOF(buffer), "CListName%d",contact_number);
if (db_get(hContact, "CList", "MyHandle", &dbv2))
db_set(ccMeta->contactID, META_PROTO, buffer, &dbv);
else {
@@ -378,8 +373,7 @@ int Meta_HideLinkedContacts(void)
}
else {
if (!db_get(hContact, "CList", "MyHandle", &dbv)) {
- strcpy(buffer, "CListName");
- strcat(buffer, _itoa(contact_number, buffer2, 10));
+ mir_snprintf(buffer, SIZEOF(buffer),"CListName%d",contact_number);
db_set(ccMeta->contactID, META_PROTO, buffer, &dbv);
db_free(&dbv);
}
@@ -509,8 +503,6 @@ static void SwapValues(MCONTACT hContact, LPCSTR szSetting, int n1, int n2)
int Meta_SwapContacts(DBCachedContact *cc, int n1, int n2)
{
- MCONTACT hContact1 = Meta_GetContactHandle(cc, n1), hContact2 = Meta_GetContactHandle(cc, n2);
-
SwapValues(cc->contactID, "Protocol", n1, n2);
SwapValues(cc->contactID, "Status", n1, n2);
SwapValues(cc->contactID, "StatusString", n1, n2);