From 35ded165ba1c21cd526191a47101da56c101d1a9 Mon Sep 17 00:00:00 2001 From: sje Date: Fri, 2 Feb 2007 13:06:20 +0000 Subject: added user id to status bar tips git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@104 4f64403b-2f21-0410-a795-97e2b3489a10 --- tipper/subst.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'tipper/subst.cpp') diff --git a/tipper/subst.cpp b/tipper/subst.cpp index aac9e8f..c67e207 100644 --- a/tipper/subst.cpp +++ b/tipper/subst.cpp @@ -73,11 +73,12 @@ void format_timestamp(DWORD ts, char *format, TCHAR *buff, int bufflen) { } } -bool uid(HANDLE hContact, TCHAR *buff, int bufflen) { +bool uid(HANDLE hContact, char *proto, TCHAR *buff, int bufflen) { CONTACTINFO ci; ci.cbSize = sizeof(CONTACTINFO); ci.hContact = hContact; - ci.szProto = 0;//(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); + // pass in proto so we can get uid when hContact == 0 (i.e. our own uid for a given proto) + ci.szProto = proto;//(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); ci.dwFlag = CNF_UNIQUEID | (unicode_system ? CNF_UNICODE : 0); if(!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch(ci.type) { @@ -106,6 +107,17 @@ bool uid(HANDLE hContact, TCHAR *buff, int bufflen) { return false; } +bool uid_name(char *szProto, TCHAR *buff, int bufflen) { + if (szProto){ + char *szUniqueId = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); + if(szUniqueId) { + a2t(szUniqueId, buff, bufflen); + return true; + } + } + return false; +} + TCHAR *GetLastMessageText(HANDLE hContact) { DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(dbei); @@ -167,7 +179,7 @@ TCHAR *GetStatusMessageText(HANDLE hContact) { bool GetSysSubstText(HANDLE hContact, TCHAR *raw_spec, TCHAR *buff, int bufflen) { if (!_tcscmp(raw_spec, _T("uid"))) { - return uid(hContact, buff, bufflen); + 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){ @@ -176,13 +188,7 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *raw_spec, TCHAR *buff, int bufflen) } } else if (!_tcscmp(raw_spec, _T("uidname"))) { char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto){ - char *szUniqueId = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); - if(szUniqueId) { - a2t(szUniqueId, buff, bufflen); - return true; - } - } + return uid_name(szProto, buff, bufflen); } else if (!_tcscmp(raw_spec, _T("status_msg"))) { TCHAR *msg = GetStatusMessageText(hContact); if(msg) { @@ -208,7 +214,7 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *raw_spec, TCHAR *buff, int bufflen) } else if (!_tcscmp(raw_spec, _T("meta_subuid"))){ HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); if(!hSubContact) return false; - return uid(hSubContact, buff, bufflen); + 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); -- cgit v1.2.3