Exemplo n.º 1
0
/**
 * 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 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)
{
	DBVARIANT 	dbv = {0};
	BYTE 		bStatusMsgValid = 0;
	INT_PTR		res = 0;

	if(!m_Valid)
		return;

	if(szKey == 0 || (szKey && !strcmp("StatusMsg", szKey))) {
		if(m_szStatusMsg)
			mir_free(m_szStatusMsg);
		m_szStatusMsg = 0;
		res = M->GetTString(m_hContact, "CList", "StatusMsg", &dbv);
		if(res == 0) {
			m_szStatusMsg = (lstrlen(dbv.ptszVal) > 0 ? getNormalizedStatusMsg(dbv.ptszVal) : 0);
			DBFreeVariant(&dbv);
		}
	}
	if(szKey == 0 || (szKey && !strcmp("ListeningTo", szKey))) {
		if(m_ListeningInfo)
			mir_free(m_ListeningInfo);
		m_ListeningInfo = 0;
		res = M->GetTString(m_hContact, m_szProto, "ListeningTo", &dbv);
		if(res == 0) {
			m_ListeningInfo = (lstrlen(dbv.ptszVal) > 0 ? mir_tstrdup(dbv.ptszVal) : 0);
			DBFreeVariant(&dbv);
		}
	}
	if(szKey == 0 || (szKey && !strcmp("XStatusMsg", szKey))) {
		if(m_xStatusMsg)
			mir_free(m_xStatusMsg);
		m_xStatusMsg = 0;
		res = M->GetTString(m_hContact, m_szProto, "XStatusMsg", &dbv);
		if(res == 0) {
			m_xStatusMsg = (lstrlen(dbv.ptszVal) > 0 ? mir_tstrdup(dbv.ptszVal) : 0);
			DBFreeVariant(&dbv);
		}
	}
	m_xStatus = M->GetByte(m_hContact, m_szProto, "XStatusId", 0);
}