From 2754b2fba973e2b613ec5ecce1b549450d67acc9 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Mon, 6 Sep 2010 13:38:41 +0000 Subject: Added support for accounts git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@529 4f64403b-2f21-0410-a795-97e2b3489a10 --- tipper/subst.cpp | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'tipper/subst.cpp') 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); -- cgit v1.2.3