/** * obtain the UIN. This is only maintained for open message windows * it also run when the subcontact for a MC changes. */ bool CContactCache::updateUIN() { bool fChanged = false; if(m_Valid) { CONTACTINFO ci = {0}; ci.hContact = getActiveContact(); ci.szProto = const_cast<char *>(getActiveProto()); ci.cbSize = sizeof(ci); ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR; if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) { switch (ci.type) { case CNFT_ASCIIZ: mir_sntprintf(m_szUIN, safe_sizeof(m_szUIN), _T("%s"), reinterpret_cast<TCHAR *>(ci.pszVal)); mir_free((void *)ci.pszVal); break; case CNFT_DWORD: mir_sntprintf(m_szUIN, safe_sizeof(m_szUIN), _T("%u"), ci.dVal); break; default: m_szUIN[0] = 0; break; } } else m_szUIN[0] = 0; } else m_szUIN[0] = 0; return(fChanged); }
int CContactCache::getMaxMessageLength() { HANDLE hContact; const char* szProto; hContact = getActiveContact(); szProto = getActiveProto(); if (szProto) { m_nMax = CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, reinterpret_cast<LPARAM>(hContact)); if (m_nMax) { if (M->GetByte("autosplit", 0)) { if(m_hwnd) ::SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_EXLIMITTEXT, 0, 20000); } else { if(m_hwnd) ::SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_EXLIMITTEXT, 0, (LPARAM)m_nMax); } } else { if(m_hwnd) ::SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_EXLIMITTEXT, 0, 20000); m_nMax = 20000; } } return(m_nMax); }
/** * update all or only the given status message information from the database * * @param szKey: char* database key name or 0 to reload all messages */ void CContactCache::updateStatusMsg(const char *szKey) { if (!m_Valid) return; MCONTACT hContact = getActiveContact(); if (szKey == 0 || (szKey && !mir_strcmp("StatusMsg", szKey))) { if (m_szStatusMsg) mir_free(m_szStatusMsg); m_szStatusMsg = 0; ptrT szStatus(db_get_tsa(hContact, "CList", "StatusMsg")); if (szStatus != 0) m_szStatusMsg = (mir_tstrlen(szStatus) > 0 ? getNormalizedStatusMsg(szStatus) : 0); } if (szKey == 0 || (szKey && !mir_strcmp("ListeningTo", szKey))) { if (m_ListeningInfo) mir_free(m_ListeningInfo); m_ListeningInfo = 0; ptrT szListeningTo(db_get_tsa(hContact, cc->szProto, "ListeningTo")); if (szListeningTo != 0 && *szListeningTo) m_ListeningInfo = szListeningTo.detach(); } if (szKey == 0 || (szKey && !mir_strcmp("XStatusMsg", szKey))) { if (m_xStatusMsg) mir_free(m_xStatusMsg); m_xStatusMsg = 0; ptrT szXStatusMsg(db_get_tsa(hContact, cc->szProto, "XStatusMsg")); if (szXStatusMsg != 0 && *szXStatusMsg) m_xStatusMsg = szXStatusMsg.detach(); } m_xStatus = db_get_b(hContact, cc->szProto, "XStatusId", 0); }
/** * update status mode * @return bool: true if status mode has changed, false if not. */ bool CContactCache::updateStatus() { if (!m_Valid) return false; m_wOldStatus = m_wStatus; m_wStatus = (WORD)db_get_w(getActiveContact(), getActiveProto(), "Status", ID_STATUS_OFFLINE); return m_wOldStatus != m_wStatus; }
/** * update private copy of the nick name. Use contact list name cache * * @return bool: true if nick has changed. */ bool CContactCache::updateNick() { bool fChanged = false; if (m_Valid) { TCHAR *tszNick = pcli->pfnGetContactDisplayName(getActiveContact(), 0); if (tszNick) fChanged = (mir_tstrcmp(m_szNick, tszNick) ? true : false); _tcsncpy_s(m_szNick, (tszNick ? tszNick : _T("<undef>")), _TRUNCATE); } return fChanged; }
int CContactCache::getMaxMessageLength() { MCONTACT hContact = getActiveContact(); LPCSTR szProto = getActiveProto(); if (szProto) { m_nMax = CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, hContact); if (m_nMax) { if (M.GetByte("autosplit", 0)) { if (m_hwnd) ::SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_EXLIMITTEXT, 0, 20000); } else { if (m_hwnd) ::SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_EXLIMITTEXT, 0, (LPARAM)m_nMax); } } else { if (m_hwnd) ::SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_EXLIMITTEXT, 0, 20000); m_nMax = 20000; } } return m_nMax; }
/** * obtain the UIN. This is only maintained for open message windows * it also run when the subcontact for a MC changes. */ bool CContactCache::updateUIN() { m_szUIN[0] = 0; if (m_Valid) { CONTACTINFO ci = { sizeof(ci) }; ci.hContact = getActiveContact(); ci.szProto = const_cast<char *>(getActiveProto()); ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR; if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch (ci.type) { case CNFT_ASCIIZ: _tcsncpy_s(m_szUIN, ci.pszVal, _TRUNCATE); mir_free(ci.pszVal); break; case CNFT_DWORD: mir_sntprintf(m_szUIN, _countof(m_szUIN), _T("%u"), ci.dVal); break; } } } return false; }