void SetSRMMIcon(MCONTACT hContact, SRMM_ICON_TYPE type, time_t time)
{
	if (hContact && arMonitoredWindows.getIndex((HANDLE)hContact) != -1)
	{
		StatusIconData sid = { sizeof(sid) };
		sid.szModule = MODULENAME;
		sid.dwId = 1;
		sid.flags = MBF_TCHAR;

		switch (type)
		{
		case ICON_HIDDEN:
			{
				sid.flags |= MBF_HIDDEN;
				break;
			}
		case ICON_READ:
			{
				sid.hIcon = IcoLib_GetIcon("read_icon");
				CMString tooltip;
				if (db_get_dw(hContact, MODULENAME, DBKEY_MESSAGE_READ_TIME_TYPE, -1) == MRD_TYPE_READTIME)
				{
					TCHAR ttime[64];
					_locale_t locale = _create_locale(LC_ALL, "");
					_tcsftime_l(ttime, _countof(ttime), _T("%X %x"), localtime(&time), locale);
					_free_locale(locale);
					tooltip.Format(L"%s %s", TranslateT("Last message read at"), ttime);
				}
				else
				{
					tooltip = TranslateT("Last message read (unknown time)");
				}
				sid.tszTooltip = tooltip.Detach();
				break;
			}
		case ICON_UNREAD:
			{
				sid.hIcon = IcoLib_GetIcon("unread_icon");
				sid.tszTooltip = TranslateT("Last message is not read");
				break;
			}
		case ICON_FAILED:
			{
				sid.hIcon = IcoLib_GetIcon("fail_icon");
				sid.tszTooltip = TranslateT("Last message was not sent.");
				break;
			}
		case ICON_NOSENT:
			{
				sid.hIcon = IcoLib_GetIcon("nosent_icon");
				sid.tszTooltip = TranslateT("Sending...");
				break;
			}
		default:
			return;
		}

		Srmm_ModifyIcon(hContact, &sid);
	}
}