summaryrefslogtreecommitdiff
path: root/tipper/subst.cpp
diff options
context:
space:
mode:
author(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2010-09-06 13:38:41 +0000
committer(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2010-09-06 13:38:41 +0000
commit2754b2fba973e2b613ec5ecce1b549450d67acc9 (patch)
treea68b881569ba5de6fc6b25d8d091eec7bfdf2ecc /tipper/subst.cpp
parent254c4ff94589346623a9617eee1ae02505b3423f (diff)
Added support for accounts
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@529 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'tipper/subst.cpp')
-rw-r--r--tipper/subst.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/tipper/subst.cpp b/tipper/subst.cpp
index efd71b4..f766116 100644
--- a/tipper/subst.cpp
+++ b/tipper/subst.cpp
@@ -192,10 +192,18 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *raw_spec, TCHAR *buff, int bufflen)
if (!_tcscmp(raw_spec, _T("uid"))) {
return uid(hContact, 0, buff, bufflen);
} else if (!_tcscmp(raw_spec, _T("proto"))) {
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (szProto){
- a2t(szProto, buff, bufflen);
- return true;
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)hContact, 0);
+ if ((INT_PTR)szProto == CALLSERVICE_NOTFOUND) {
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto) {
+ a2t(szProto, buff, bufflen);
+ return true;
+ }
+ }
+ else if (szProto) {
+ PROTOACCOUNT *pa = ProtoGetAccount(szProto);
+ _tcsncpy(buff, pa->tszAccountName, bufflen);
+ return true;
}
} else if (!_tcscmp(raw_spec, _T("uidname"))) {
char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
@@ -217,24 +225,32 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *raw_spec, TCHAR *buff, int bufflen)
} else if (!_tcscmp(raw_spec, _T("meta_subname"))) {
// get contact list name of active subcontact
HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
- if(!hSubContact) return false;
+ if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false;
TCHAR *stzCDN = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hSubContact, GCDNF_TCHAR);
if(stzCDN) _tcsncpy(buff, stzCDN, bufflen);
return true;
} else if (!_tcscmp(raw_spec, _T("meta_subuid"))){
HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
- if(!hSubContact) return false;
+ if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false;
return uid(hSubContact, 0, buff, bufflen);
} else if (!_tcscmp(raw_spec, _T("meta_subproto"))) {
// get protocol of active subcontact
HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
- if(!hSubContact) return false;
-
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubContact, 0);
- if (szProto){
- a2t(szProto, buff, bufflen);
- return true;
+ if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false;
+
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)hContact, 0);
+ if ((INT_PTR)szProto == CALLSERVICE_NOTFOUND) {
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto) {
+ a2t(szProto, buff, bufflen);
+ return true;
+ }
+ }
+ else if (szProto) {
+ PROTOACCOUNT *pa = ProtoGetAccount(szProto);
+ _tcsncpy(buff, pa->tszAccountName, bufflen);
+ return true;
}
} else if (!_tcscmp(raw_spec, _T("last_msg_time"))) {
DWORD ts = last_message_timestamp(hContact);