summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-05-18 17:21:08 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-05-18 17:21:08 +0000
commita1d6cb7bdc354be0968c6ba5ac4615e14a90eead (patch)
treea1ed17002c33644b3362e6c1e6572f3fa7ef17d7 /src/core
parentfef6b799309b5b9d7cbb2845fa27b777477e2a61 (diff)
these tons of code aren't needed anymore...
git-svn-id: http://svn.miranda-ng.org/main/trunk@16850 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stdauth/src/auth.cpp23
-rw-r--r--src/core/stdfile/src/file.cpp20
-rw-r--r--src/core/stdfile/src/filerecvdlg.cpp30
-rw-r--r--src/core/stdfile/src/filesenddlg.cpp30
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp49
-rw-r--r--src/core/stdmsg/src/msglog.cpp32
6 files changed, 24 insertions, 160 deletions
diff --git a/src/core/stdauth/src/auth.cpp b/src/core/stdauth/src/auth.cpp
index adb4577ab3..da81b55068 100644
--- a/src/core/stdauth/src/auth.cpp
+++ b/src/core/stdauth/src/auth.cpp
@@ -44,7 +44,6 @@ INT_PTR ShowAddedWindow(WPARAM, LPARAM lParam)
static int AuthEventAdded(WPARAM, LPARAM lParam)
{
- TCHAR szUid[128] = _T("");
TCHAR szTooltip[256];
MEVENT hDbEvent = (MEVENT)lParam;
@@ -66,27 +65,11 @@ static int AuthEventAdded(WPARAM, LPARAM lParam)
cli.lParam = lParam;
cli.hDbEvent = hDbEvent;
- CONTACTINFO ci = {};
- ci.cbSize = sizeof(ci);
- ci.hContact = hContact;
- ci.szProto = GetContactProto(hContact);
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- _tcsncpy_s(szUid, ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
-
- case CNFT_DWORD:
- mir_sntprintf(szUid, _T("%u"), ci.dVal);
- break;
- }
- }
+ ptrT szUid(Contact_GetInfo(CNF_UNIQUEID, hContact));
if (dbei.eventType == EVENTTYPE_AUTHREQUEST) {
SkinPlaySound("AuthRequest");
- if (szUid[0])
+ if (szUid)
mir_sntprintf(szTooltip, TranslateT("%s requests authorization"), szUid);
else
mir_sntprintf(szTooltip, TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob);
@@ -97,7 +80,7 @@ static int AuthEventAdded(WPARAM, LPARAM lParam)
}
else if (dbei.eventType == EVENTTYPE_ADDED) {
SkinPlaySound("AddedEvent");
- if (szUid[0])
+ if (szUid)
mir_sntprintf(szTooltip, TranslateT("%s added you to their contact list"), szUid);
else
mir_sntprintf(szTooltip, TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob);
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp
index 33d6a5df66..2e6409bbfd 100644
--- a/src/core/stdfile/src/file.cpp
+++ b/src/core/stdfile/src/file.cpp
@@ -35,25 +35,11 @@ static HGENMENU hSRFileMenuItem;
TCHAR* GetContactID(MCONTACT hContact)
{
char *szProto = GetContactProto(hContact);
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1) {
+ if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1)
if (TCHAR *theValue = db_get_tsa(hContact, szProto, "ChatRoomID"))
return theValue;
- }
- else {
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = hContact;
- ci.szProto = szProto;
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- return (TCHAR*)ci.pszVal;
- case CNFT_DWORD:
- return _itot(ci.dVal, (TCHAR*)mir_alloc(sizeof(TCHAR)*32), 10);
- }
- }
- }
- return NULL;
+
+ return Contact_GetInfo(CNF_UNIQUEID, hContact, szProto);
}
static INT_PTR SendFileCommand(WPARAM hContact, LPARAM)
diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp
index df3d46f881..47254f5499 100644
--- a/src/core/stdfile/src/filerecvdlg.cpp
+++ b/src/core/stdfile/src/filerecvdlg.cpp
@@ -247,34 +247,8 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, _countof(datetimestr), 0);
SetDlgItemText(hwndDlg, IDC_DATE, datetimestr);
- char* szProto = GetContactProto(dat->hContact);
- if (szProto) {
- int hasName = 0;
- char buf[128];
-
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.hContact = dat->hContact;
- ci.szProto = szProto;
- ci.dwFlag = CNF_UNIQUEID;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- hasName = 1;
- strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- hasName = 1;
- mir_snprintf(buf, "%u", ci.dVal);
- break;
- }
- }
- if (hasName)
- SetDlgItemTextA(hwndDlg, IDC_NAME, buf);
- else
- SetDlgItemText(hwndDlg, IDC_NAME, contactName);
- }
+ ptrT info(Contact_GetInfo(CNF_UNIQUEID, dat->hContact));
+ SetDlgItemText(hwndDlg, IDC_NAME, (info) ? info : contactName);
if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) {
RECT rcBtn1, rcBtn2, rcDateCtrl;
diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp
index a2aa180770..2a5d28c7ef 100644
--- a/src/core/stdfile/src/filesenddlg.cpp
+++ b/src/core/stdfile/src/filesenddlg.cpp
@@ -238,34 +238,8 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
SetDlgItemText(hwndDlg, IDC_TO, contactName);
- char *szProto = GetContactProto(dat->hContact);
- if (szProto) {
- int hasName = 0;
- char buf[128];
-
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = dat->hContact;
- ci.szProto = szProto;
- ci.dwFlag = CNF_UNIQUEID;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- hasName = 1;
- strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- hasName = 1;
- mir_snprintf(buf, "%u", ci.dVal);
- break;
- }
- }
-
- if (hasName)
- SetDlgItemTextA(hwndDlg, IDC_NAME, buf);
- else
- SetDlgItemText(hwndDlg, IDC_NAME, contactName);
- }
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact));
+ SetDlgItemText(hwndDlg, IDC_NAME, (id) ? id : contactName);
if (fsd->ppFiles == NULL) {
EnableWindow(hwndDlg, FALSE);
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index cd941d301c..22bf436713 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -920,27 +920,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case DM_USERNAMETOCLIP:
if (dat->hContact) {
- TCHAR buf[128] = _T("");
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = dat->hContact;
- ci.szProto = dat->szProto;
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
-
- case CNFT_DWORD:
- mir_sntprintf(buf, _T("%u"), ci.dVal);
- break;
- }
- }
- if (buf[0] && OpenClipboard(hwndDlg)) {
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact, dat->szProto));
+ if (id != NULL && OpenClipboard(hwndDlg)) {
EmptyClipboard();
- HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_tstrlen(buf) * sizeof(TCHAR)+1);
- mir_tstrcpy((TCHAR*)GlobalLock(hData), buf);
+ HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_tstrlen(id) * sizeof(TCHAR)+1);
+ mir_tstrcpy((TCHAR*)GlobalLock(hData), id);
GlobalUnlock(hData);
SetClipboardData(CF_UNICODETEXT, hData);
CloseClipboard();
@@ -1025,29 +1009,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
- TCHAR buf[128] = _T("");
- if (mir_strcmp(dat->szProto, META_PROTO)) {
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.hContact = dat->hContact;
- ci.szProto = dat->szProto;
- ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- mir_sntprintf(buf, _T("%u"), ci.dVal);
- break;
- }
- }
- }
- if (buf[0])
- SetDlgItemText(hwndDlg, IDC_NAME, buf);
- else
- SetDlgItemText(hwndDlg, IDC_NAME, contactName);
+ ptrT id(Contact_GetInfo(CNF_DISPLAYUID, dat->hContact, dat->szProto));
+ SetDlgItemText(hwndDlg, IDC_NAME, (id) ? id : contactName);
TCHAR *szStatus = pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE), 0);
if (statusIcon)
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp
index 29ab6af1f9..38e583c2ca 100644
--- a/src/core/stdmsg/src/msglog.cpp
+++ b/src/core/stdmsg/src/msglog.cpp
@@ -271,27 +271,18 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT
if (!(g_dat.flags & SMF_HIDENAMES) && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE) {
TCHAR *szName;
- CONTACTINFO ci = { 0 };
if (dbei.flags & DBEF_SENT) {
- ci.cbSize = sizeof(ci);
- ci.szProto = dbei.szModule;
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- // CNF_DISPLAY always returns a string type
- szName = ci.pszVal;
- }
+ if (TCHAR *p = Contact_GetInfo(CNF_DISPLAY, NULL, dbei.szModule))
+ szName = NEWTSTR_ALLOCA(p);
else
- // Shouldn't happen?
- szName = mir_tstrdup(TranslateT("Me"));
+ szName = TranslateT("Me");
}
else szName = pcli->pfnGetContactDisplayName(hContact, 0);
buffer.AppendFormat(" %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
AppendToBufferWithRTF(buffer, szName);
showColon = 1;
- if (ci.pszVal)
- mir_free(ci.pszVal);
}
if (showColon)
@@ -302,18 +293,11 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT
case EVENTTYPE_JABBER_CHATSTATES:
case EVENTTYPE_JABBER_PRESENCE:
if (dbei.flags & DBEF_SENT) {
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = NULL;
- ci.szProto = dbei.szModule;
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
-
- // CNF_DISPLAY always returns a string type
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci))
- szName = NEWTSTR_ALLOCA(ci.pszVal);
- else
- szName = _T("");
-
- mir_free(ci.pszVal);
+ if (TCHAR *p = Contact_GetInfo(CNF_DISPLAY, NULL, dbei.szModule)) {
+ szName = NEWTSTR_ALLOCA(p);
+ mir_free(p);
+ }
+ else szName = _T("");
}
else szName = pcli->pfnGetContactDisplayName(hContact, 0);