Esempio n. 1
0
void setSrmmIcon(MCONTACT h)
{
	MCONTACT hContact = metaIsProtoMetaContacts(h) ? metaGetMostOnline(h) : h;
	bool enabled = isContactSecured(hContact);	
	MCONTACT hMC = NULL;
	if(db_mc_isSub(hContact))
		hMC = db_mc_getMeta(hContact);
	else if(metaIsProtoMetaContacts(hContact))
		hMC = db_mc_getMeta(hContact);

	StatusIconData sid = { sizeof(sid) };
	sid.szModule = szGPGModuleName;
	sid.hIcon = IconLibGetIcon("secured");
	sid.dwId = 1;
	sid.flags = enabled ? 0 : MBF_HIDDEN;
	Srmm_ModifyIcon(hContact, &sid);
	if(hMC)
		Srmm_ModifyIcon(hMC, &sid);

	sid.hIcon = IconLibGetIcon("unsecured");
	sid.dwId = 2;
	sid.flags = enabled ? MBF_HIDDEN : 0;
	Srmm_ModifyIcon(hContact, &sid);
	if(hMC)
		Srmm_ModifyIcon(hMC, &sid);
}
Esempio n. 2
0
void setClistIcon(MCONTACT hContact)
{
	bool enabled = isContactSecured(hContact);
	extern HANDLE g_hCLIcon;
	MCONTACT hMC = hContact;
	if(db_mc_isSub(hContact))
		hMC = db_mc_getMeta(hContact);
	else if(metaIsProtoMetaContacts(hContact))
		hMC = db_mc_getMeta(hContact);
	const char *szIconId = (enabled) ? "secured" : NULL;
	ExtraIcon_SetIcon(g_hCLIcon, hContact, szIconId);
	if(hMC)
		ExtraIcon_SetIcon(g_hCLIcon, hMC, szIconId);
}
Esempio n. 3
0
int CMimAPI::ProtoAck(WPARAM wParam, LPARAM lParam)
{
	ACKDATA *pAck = (ACKDATA*)lParam;
	if (lParam == 0)
		return 0;

	HWND hwndDlg = 0;
	int i = 0, iFound = SendQueue::NR_SENDJOBS;
	SendJob *jobs = sendQueue->getJobByIndex(0);

	if (pAck->type == ACKTYPE_MESSAGE) {
		MCONTACT hMeta = db_mc_getMeta(pAck->hContact);
		for (int j = 0; j < SendQueue::NR_SENDJOBS; j++) {
			SendJob &p = jobs[j];
			if (pAck->hProcess == p.hSendId && pAck->hContact == p.hContact) {
				TWindowData *dat = p.hOwnerWnd ? (TWindowData*)GetWindowLongPtr(p.hOwnerWnd, GWLP_USERDATA) : NULL;
				if (dat == NULL) {
					sendQueue->ackMessage(NULL, (WPARAM)MAKELONG(j, i), lParam);
					return 0;
				}
				if (dat->hContact == p.hContact || dat->hContact == hMeta) {
					iFound = j;
					break;
				}
			}
			if (iFound != SendQueue::NR_SENDJOBS)  // no mathing entry found in this queue entry.. continue
				break;
		}
		if (iFound == SendQueue::NR_SENDJOBS)     // no matching send info found in the queue
			sendLater->processAck(pAck);
		else                                      // try to find the process handle in the list of open send later jobs
			SendMessage(jobs[iFound].hOwnerWnd, HM_EVENTSENT, (WPARAM)MAKELONG(iFound, i), lParam);
	}
	return 0;
}
Esempio n. 4
0
// обновляет иконки в clist и в messagew
void ShowStatusIcon(MCONTACT hContact, int mode)
{
	MCONTACT hMC = db_mc_getMeta(hContact);

	// обновить иконки в clist
	if (mode != -1) {
		HANDLE hIcon = mode2clicon(mode, 1);
		ExtraIcon_SetIcon(g_hCLIcon, hContact, hIcon);
		if (hMC)
			ExtraIcon_SetIcon(g_hCLIcon, hMC, hIcon);
	}
	else {
		ExtraIcon_Clear(g_hCLIcon, hContact);
		if (hMC)
			ExtraIcon_Clear(g_hCLIcon, hMC);
	}

	StatusIconData sid = { sizeof(sid) };
	sid.szModule = (char*)MODULENAME;
	for (int i = MODE_NATIVE; i < MODE_CNT; i++) {
		sid.dwId = i;
		sid.flags = (mode & SECURED) ? 0 : MBF_DISABLED;
		if (mode == -1 || (mode & 0x0f) != i || isChatRoom(hContact))
			sid.flags |= MBF_HIDDEN;  // отключаем все ненужные иконки
		Srmm_ModifyIcon(hContact, &sid);
		if (hMC)
			Srmm_ModifyIcon(hMC, &sid);
	}
}
Esempio n. 5
0
void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char* szErr)
{
	MCONTACT hMeta = db_mc_getMeta(hContact);

	mir_cslockfull lck(csMsgQueue);
	for (int i = 0; i < msgQueue.getCount(); i++) {
		TMsgQueue *item = msgQueue[i];
		if ((item->hContact == hContact || item->hContact == hMeta) && item->id == id) {
			msgQueue.remove(i); i--;

			if (!msgQueue.getCount() && timerId) {
				KillTimer(NULL, timerId);
				timerId = 0;
			}
			lck.unlock();

			if (success) {
				mir_free(item->szMsg);
				mir_free(item);
			}
			else MessageFailureProcess(item, szErr);
			break;
		}
	}
}
Esempio n. 6
0
INT_PTR Meta_Default(WPARAM hSub, LPARAM)
{
	DBCachedContact *cc = currDb->m_cache->GetCachedContact(db_mc_getMeta(hSub));
	if (cc && cc->IsMeta())
		db_mc_setDefault(cc->contactID, hSub, true);
	return 0;
}
Esempio n. 7
0
BOOL contactCheckProtocol(char *szProto, MCONTACT hContact, WORD eventType)
{
	if (bMetaProtoEnabled && hContact) {
		MCONTACT hMetaContact = (MCONTACT)db_get_dw(hContact, META_PROTO, "Handle", 0);
		if (hMetaContact && db_mc_getMeta(hContact) == hMetaContact)
			return FALSE;
	}

	return (metaCheckProtocol(szProto, hContact, eventType));
}
Esempio n. 8
0
static INT_PTR SetStatusText(WPARAM hContact, LPARAM lParam)
{
	SESSION_INFO *si = SM_FindSessionByHCONTACT(hContact);
	if (si == NULL) {
		HWND hwnd = M.FindWindow(hContact);
		if (hwnd != NULL)
			SetStatusTextWorker((TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA), (StatusTextData*)lParam);

		if (hContact = db_mc_getMeta(hContact))
			if (hwnd = M.FindWindow(hContact))
				SetStatusTextWorker((TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA), (StatusTextData*)lParam);
	}
	else SetStatusTextWorker(si->dat, (StatusTextData*)lParam);

	return 0;
}
Esempio n. 9
0
//************************************************************************
// returns the contacts group path
//************************************************************************
tstring CContactList::GetContactGroupPath(MCONTACT hContact)
{
	tstring strGroup = _T("");
	if(db_get_b(0, "MetaContacts", "Enabled", 1) && db_mc_isSub(hContact))
	{
		MCONTACT hMetaContact = db_mc_getMeta(hContact);
		if(CConfig::GetBoolSetting(CLIST_USEGROUPS))
			strGroup = CAppletManager::GetContactGroup(hMetaContact);

		tstring strMetaName = CAppletManager::GetContactDisplayname(hMetaContact);
		strGroup += (strGroup.empty()?_T(""):_T("\\"))+ strMetaName;
	}
	else
		strGroup = CAppletManager::GetContactGroup(hContact);
	return strGroup;
}
Esempio n. 10
0
BOOL checkOpenWindow(MCONTACT hContact)
{
	if (bFlashIfMsgOpen && !bFlashIfMsgWinNotTop)
		return TRUE;

	BOOL focus, found = CheckMsgWnd(hContact, &focus);
	if (!found && bMetaProtoEnabled)
		found = CheckMsgWnd(db_mc_getMeta(hContact), &focus);

	if (!found)
		return TRUE;

	if (bFlashIfMsgOpen && !focus)
		return TRUE;

	return FALSE;
}
Esempio n. 11
0
bool MSN_MsgWndExist(MCONTACT hContact)
{
	MessageWindowInputData msgWinInData =
	{ sizeof(MessageWindowInputData), hContact, MSG_WINDOW_UFLAG_MSG_BOTH };
	MessageWindowData msgWinData = {0};
	msgWinData.cbSize = sizeof(MessageWindowData);

	bool res = CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&msgWinInData, (LPARAM)&msgWinData) != 0;
	res = res || msgWinData.hwndWindow;
	if (res) {
		msgWinInData.hContact = db_mc_getMeta(hContact);
		if (msgWinInData.hContact != NULL) {
			res = CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&msgWinInData, (LPARAM)&msgWinData) != 0;
			res |= (msgWinData.hwndWindow == NULL);
		}
	}
	return res;
}
Esempio n. 12
0
//************************************************************************
// returns wether a contact should be listed or not
//************************************************************************
bool CContactList::IsVisible(CContactListEntry *pEntry) {
	if(!pEntry) {
		return false;
	}
	
	if(pEntry->strProto != _T("MetaContacts")) {
		if(pEntry->iStatus == ID_STATUS_OFFLINE && CConfig::GetBoolSetting(CLIST_HIDEOFFLINE)) {
			return false;
		}
	} else {
		if(pEntry->iStatus == ID_STATUS_OFFLINE) {
			int dwNumContacts = db_mc_getSubCount(pEntry->hHandle);
			for(int i = 0; i < dwNumContacts; i++) {
				MCONTACT hSubContact = db_mc_getSub(pEntry->hHandle,i);
				char *szProto = GetContactProto(hSubContact);
				if(db_get_w(hSubContact,szProto,"Status",ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
					return true;
			}
		}
	}

	if(pEntry->iMessages > 0)
		return true;

	if(CConfig::GetBoolSetting(CLIST_USEIGNORE)) {	
		if(db_get_b(pEntry->hHandle,"CList","Hidden",0))
			return false;
		
		if(db_mc_isSub(pEntry->hHandle)) {
			MCONTACT hMetaContact = db_mc_getMeta(pEntry->hHandle);
			if(db_get_b(hMetaContact,"CList","Hidden",0))
				return false;
		}
	}


	if(!CConfig::GetProtocolContactlistFilter(pEntry->strProto))
		return false;

	if(CConfig::GetBoolSetting(CLIST_HIDEOFFLINE) && pEntry->iStatus == ID_STATUS_OFFLINE)
		return false;

	return true;
}
Esempio n. 13
0
BOOL checkOpenWindow(MCONTACT hContact)
{
	if (bFlashIfMsgOpen && !bFlashIfMsgWinNotTop)
		return TRUE;

	BOOL focus, found = CheckMsgWnd(hContact, &focus);
	if (!found && bMetaProtoEnabled) {
		MCONTACT hMetaContact = (MCONTACT)db_get_dw(hContact, META_PROTO, "Handle", 0);
		if (hMetaContact && db_mc_getMeta(hContact) == hMetaContact)
			found = CheckMsgWnd(hMetaContact, &focus);
	}
	if (!found)
		return TRUE;

	if (bFlashIfMsgOpen && !focus)
		return TRUE;

	return FALSE;
}
Esempio n. 14
0
int PopupNotifyBirthday(MCONTACT hContact, int dtb, int age)
{
	if (commonData.bIgnoreSubcontacts) {
		MCONTACT hMetacontact = db_mc_getMeta(hContact);
		if (hMetacontact && hMetacontact != hContact) //not main metacontact
			return 0;
	}

	TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0);

	TCHAR text[1024];
	BuildDTBText(dtb, name, text, SIZEOF(text));
	int gender = GetContactGender(hContact);
	
	POPUPDATAT pd = {0};
	FillPopupData(pd, dtb);
	pd.lchContact = hContact;
	pd.PluginWindowProc = DlgProcPopup;
	pd.lchIcon = GetDTBIcon(dtb);
	
	mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME, TranslateT("Birthday - %s"), name);
	TCHAR *sex;
	switch (toupper(gender)) {
	case _T('M'):
		sex = TranslateT("He");
		break;
	case _T('F'):
		sex = TranslateT("She");
		break;
	default:
		sex = TranslateT("He/She");
		break;
	}
	if (dtb > 0)
		mir_sntprintf(pd.lptzText, MAX_SECONDLINE, TranslateT("%s\n%s will be %d years old."), text, sex, age);
	else
		mir_sntprintf(pd.lptzText, MAX_SECONDLINE, TranslateT("%s\n%s just turned %d."), text, sex, age);

	PUAddPopupT(&pd);

	return 0;
}
Esempio n. 15
0
int __fastcall ApplyFingerprintImage(MCONTACT hContact, LPTSTR szMirVer)
{
	if (hContact == NULL)
		return 0;

	HANDLE hImage = INVALID_HANDLE_VALUE;
	if (szMirVer)
		hImage = GetIconIndexFromFI(szMirVer);

	ExtraIcon_SetIcon(hExtraIcon, hContact, hImage);

	if (arMonitoredWindows.getIndex((HANDLE)hContact) != -1)
		SetSrmmIcon(hContact, szMirVer);

	MCONTACT hMeta = db_mc_getMeta(hContact);
	if (hMeta && db_mc_getMostOnline(hMeta) == hContact)
		db_set_ts(hMeta, META_PROTO, "MirVer", szMirVer);

	return 0;
}
Esempio n. 16
0
TMsgQueue* msgQueue_find(MCONTACT hContact, int id)
{
    MCONTACT hMeta = db_mc_getMeta(hContact);

    mir_cslockfull lck(csMsgQueue);
    for (int i = 0; i < msgQueue.getCount(); i++) {
        TMsgQueue *item = msgQueue[i];
        if ((item->hContact == hContact || item->hContact == hMeta) && item->id == id) {
            msgQueue.remove(i);

            if (!msgQueue.getCount() && timerId) {
                KillTimer(NULL, timerId);
                timerId = 0;
            }

            return item;
        }
    }
    return NULL;
}
Esempio n. 17
0
static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
{
	if (ai->argc != 2)
		return NULL;

	MCONTACT hContact = NULL;

	CONTACTSINFO ci = { sizeof(ci) };
	ci.tszContact = ai->targv[1];
	ci.flags = 0xFFFFFFFF ^ (CI_TCHAR == 0 ? CI_UNICODE : 0);
	int count = getContactFromString(&ci);
	if (count == 1 && ci.hContacts != NULL) {
		hContact = ci.hContacts[0];
		mir_free(ci.hContacts);
	}
	else {
		mir_free(ci.hContacts);
		return NULL;
	}

	hContact = db_mc_getMeta(hContact);
	if (hContact == NULL)
		return NULL;

	ptrT szUniqueID;
	char* szProto = GetContactProto(hContact);
	if (szProto != NULL)
		szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact);

	if (szUniqueID == NULL) {
		szProto = PROTOID_HANDLE;
		TCHAR tszID[40];
		mir_sntprintf(tszID, SIZEOF(tszID), _T("%p"), hContact);
		szUniqueID = mir_tstrdup(tszID);
	}

	if (szUniqueID == NULL)
		return NULL;

	return mir_tstrdup(CMString(FORMAT, _T("<%S:%s>"), szProto, szUniqueID));
}
Esempio n. 18
0
int ContactSettingChanged(WPARAM hContact, LPARAM lParam)
{
	DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
	if (lstrcmpA(cws->szSetting, DB_MIRVER))
		return 0;

	SHOWPOPUP_DATA sd = {0};
	char *szProto = GetContactProto(hContact);
	if (g_PreviewOptPage)
		sd.MirVer = _T("Miranda NG ICQ 0.93.5.3007");
	else {
		if (!hContact) // exit if hContact == NULL and it's not a popup preview
			return 0;

		_ASSERT(szProto);
		if (!strcmp(szProto, META_PROTO)) // workaround for metacontacts
			return 0;

		sd.MirVer = db_get_s(hContact, szProto, DB_MIRVER, _T(""));
		if (sd.MirVer.IsEmpty())
			return 0;
	}
	sd.OldMirVer = db_get_s(hContact, MOD_NAME, DB_OLDMIRVER, _T(""));
	db_set_ts(hContact, MOD_NAME, DB_OLDMIRVER, sd.MirVer); // we have to write it here, because we modify sd.OldMirVer and sd.MirVer to conform our settings later
	if (sd.OldMirVer.IsEmpty())  // looks like it's the right way to do
		return 0;

	COptPage PopupOptPage;
	if (g_PreviewOptPage)
		PopupOptPage = *g_PreviewOptPage;
	else {
		PopupOptPage = g_PopupOptPage;
		PopupOptPage.DBToMem();
	}

	MCONTACT hContactOrMeta = (hContact) ? db_mc_getMeta(hContact) : 0;
	if (!hContactOrMeta)
		hContactOrMeta = hContact;

	if (hContact && db_get_b(hContactOrMeta, "CList", "Hidden", 0))
		return 0;

	int PerContactSetting = hContact ? db_get_b(hContact, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL) : NOTIFY_ALWAYS; // NOTIFY_ALWAYS for preview
	if (PerContactSetting == NOTIFY_USEGLOBAL && hContactOrMeta != hContact) // subcontact setting has a priority over a metacontact setting
		PerContactSetting = db_get_b(hContactOrMeta, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL);

	if (PerContactSetting && (PerContactSetting == NOTIFY_ALMOST_ALWAYS || PerContactSetting == NOTIFY_ALWAYS || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_USESTATUSNOTIFYFLAG) || !(db_get_dw(hContactOrMeta, "Ignore", "Mask1", 0) & 0x8))) { // check if we need to notify at all
		sd.hContact = hContact;
		sd.PopupOptPage = &PopupOptPage;
		if (!PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWVER)) {
			if (bFingerprintExists) {
				LPCTSTR ptszOldClient = Finger_GetClientDescr(sd.OldMirVer); 
				LPCTSTR ptszClient = Finger_GetClientDescr(sd.MirVer);
				if (ptszOldClient && ptszClient) {
					if (PerContactSetting != NOTIFY_ALMOST_ALWAYS && PerContactSetting != NOTIFY_ALWAYS && !PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) && !_tcscmp(ptszClient, ptszOldClient))
						return 0;

					if (!PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWVER)) {
						sd.MirVer = ptszClient;
						sd.OldMirVer = ptszOldClient;
					}
				}
			}
		}
		if (sd.MirVer == (const TCHAR*)sd.OldMirVer) {
			_ASSERT(hContact);
			return 0;
		}
		if (PerContactSetting == NOTIFY_ALWAYS || (PopupOptPage.GetValue(IDC_POPUPOPTDLG_POPUPNOTIFY) && (g_PreviewOptPage || PerContactSetting == NOTIFY_ALMOST_ALWAYS || -1 == PcreCheck(sd.MirVer)))) {
			ShowPopup(&sd);
			SkinPlaySound(CLIENTCHANGED_SOUND);
		}
	}

	if (hContact) {
		TCString ClientName;
		if (PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWPREVCLIENT) && sd.OldMirVer.GetLen()) {
			mir_sntprintf(ClientName.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("%s (was %s)"), (const TCHAR*)sd.MirVer, (const TCHAR*)sd.OldMirVer);
			ClientName.ReleaseBuffer();
		}
		else ClientName = sd.MirVer;
	}
	_ASSERT(sd.MirVer.GetLen()); // save the last known MirVer value even if the new one is empty
	return 0;
}
Esempio n. 19
0
LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	ClcContact *contact;
	ClcGroup *group;
	BOOL frameHasTitlebar = FALSE;

	if (wndFrameCLC)
		frameHasTitlebar = wndFrameCLC->TitleBar.ShowTitleBar;

	ClcData *dat = (struct ClcData *) GetWindowLongPtr(hwnd, 0);
	if (msg >= CLM_FIRST && msg < CLM_LAST)
		return ProcessExternalMessages(hwnd, dat, msg, wParam, lParam);

	switch (msg) {
	case WM_CREATE:
		dat = (struct ClcData *)mir_alloc(sizeof(struct ClcData));
		memset(dat, 0, sizeof(struct ClcData));
		SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat);

		RowHeight::Init(dat);
		dat->forceScroll = 0;
		dat->lastRepaint = 0;
		dat->hwndParent = GetParent(hwnd);
		dat->lastSort = GetTickCount();
		dat->needsResort = FALSE;
		{
			CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
			if (cs->lpCreateParams == (LPVOID)0xff00ff00) {
				dat->bisEmbedded = FALSE;
				dat->bHideSubcontacts = TRUE;
				cfg::clcdat = dat;
				if (cfg::dat.bShowLocalTime)
					SetTimer(hwnd, TIMERID_REFRESH, 65000, NULL);
			}
			else
				dat->bisEmbedded = TRUE;
		}
		break;

	case WM_SIZE:
		pcli->pfnEndRename(hwnd, dat, 1);
		KillTimer(hwnd, TIMERID_INFOTIP);
		KillTimer(hwnd, TIMERID_RENAME);
		pcli->pfnRecalcScrollBar(hwnd, dat);
LBL_Def:
		return DefWindowProc(hwnd, msg, wParam, lParam);

	case WM_NCCALCSIZE:
		return FrameNCCalcSize(hwnd, DefWindowProc, wParam, lParam, frameHasTitlebar);

		/*
		* scroll bar handling
		*/
	case WM_NCPAINT:
		return FrameNCPaint(hwnd, DefWindowProc, wParam, lParam, frameHasTitlebar);

	case INTM_GROUPCHANGED:
	{
		WORD iExtraImage[EXTRA_ICON_COUNT];
		BYTE flags = 0;
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			memset(iExtraImage, 0xFF, sizeof(iExtraImage));
		else {
			memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage));
			flags = contact->flags;
		}
		pcli->pfnDeleteItemFromTree(hwnd, wParam);
		if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(wParam, NULL, dat)) {
			pcli->pfnAddContactToTree(hwnd, dat, wParam, 1, 1);
			if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) {
				memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage));
				if (flags & CONTACTF_CHECKED)
					contact->flags |= CONTACTF_CHECKED;
			}

			NMCLISTCONTROL nm;
			nm.hdr.code = CLN_CONTACTMOVED;
			nm.hdr.hwndFrom = hwnd;
			nm.hdr.idFrom = GetDlgCtrlID(hwnd);
			nm.flags = 0;
			nm.hItem = (HANDLE)wParam;
			SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm);
		}
		dat->needsResort = TRUE;
		PostMessage(hwnd, INTM_SORTCLC, 0, 1);
	}
		goto LBL_Def;

	case INTM_ICONCHANGED:
	{
		int recalcScrollBar = 0;
		MCONTACT hContact = wParam;
		WORD status = ID_STATUS_OFFLINE;
		int  contactRemoved = 0;
		MCONTACT hSelItem = NULL;
		ClcContact *selcontact = NULL;

		char *szProto = GetContactProto(hContact);
		if (szProto == NULL)
			status = ID_STATUS_OFFLINE;
		else
			status = cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE);

		int shouldShow = (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN ||
			!CLVM_GetContactHiddenStatus(hContact, szProto, dat)) && ((cfg::dat.bFilterEffective ? TRUE : !pcli->pfnIsHiddenMode(dat, status)) ||
			pcli->pfnGetContactIcon(hContact) != lParam); // XXX CLVM changed - this means an offline msg is flashing, so the contact should be shown

		if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, &group, NULL)) {
			if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
				if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
					hSelItem = (MCONTACT)pcli->pfnContactToHItem(selcontact);
				pcli->pfnAddContactToTree(hwnd, dat, hContact, 0, 0);
				recalcScrollBar = 1;
				FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL);
				if (contact) {
					contact->iImage = (WORD)lParam;
					pcli->pfnNotifyNewContact(hwnd, hContact);
				}
			}
		}
		else {
			//item in list already
			DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
			if (contact->iImage == (WORD)lParam)
				break;
			if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline || cfg::dat.bFilterEffective)) {        // CLVM changed
				if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
					hSelItem = (MCONTACT)pcli->pfnContactToHItem(selcontact);
				pcli->pfnRemoveItemFromGroup(hwnd, group, contact, 0);
				contactRemoved = TRUE;
				recalcScrollBar = 1;
			}
			else {
				contact->iImage = (WORD)lParam;
				if (!pcli->pfnIsHiddenMode(dat, status))
					contact->flags |= CONTACTF_ONLINE;
				else
					contact->flags &= ~CONTACTF_ONLINE;
			}
		}
		if (hSelItem) {
			ClcGroup *selgroup;
			if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
				dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)& selgroup->cl, selcontact));
			else
				dat->selection = -1;
		}
		dat->needsResort = TRUE;
		PostMessage(hwnd, INTM_SORTCLC, 0, recalcScrollBar);
		PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contactRemoved ? 0 : wParam));
		if (recalcScrollBar)
			pcli->pfnRecalcScrollBar(hwnd, dat);
	}
		goto LBL_Def;

	case INTM_METACHANGED:
		if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
			break;

		if (contact->bIsMeta && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) {
			contact->hSubContact = db_mc_getMostOnline(contact->hContact);
			contact->metaProto = GetContactProto(contact->hSubContact);
			contact->iImage = pcli->pfnGetContactIcon(contact->hSubContact);
			if (contact->pExtra) {
				TExtraCache *pSub = cfg::getCache(contact->hSubContact, contact->metaProto);
				ClcContact *subContact;
				if (!pcli->pfnFindItem(hwnd, dat, contact->hSubContact, &subContact, NULL, NULL))
					break;

				contact->pExtra->proto_status_item = GetProtocolStatusItem(contact->metaProto);
				if (pSub) {
					contact->pExtra->status_item = pSub->status_item;
					memcpy(contact->iExtraImage, subContact->iExtraImage, sizeof(contact->iExtraImage));
				}
			}
		}
		SendMessage(hwnd, INTM_NAMEORDERCHANGED, wParam, lParam);
		goto LBL_Def;

	case INTM_METACHANGEDEVENT:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;
		if (lParam == 0)
			pcli->pfnInitAutoRebuild(hwnd);
		goto LBL_Def;

	case INTM_NAMECHANGED:
		ClcContact *contact;
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;
		lstrcpyn(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText));

		RTL_DetectAndSet(contact, 0);

		dat->needsResort = TRUE;
		PostMessage(hwnd, INTM_SORTCLC, 0, 0);
		goto LBL_Def;

	case INTM_CODEPAGECHANGED:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;
		contact->codePage = cfg::getDword(wParam, "Tab_SRMsg", "ANSIcodepage", cfg::getDword(wParam, "UserInfo", "ANSIcodepage", CP_ACP));
		PostMessage(hwnd, INTM_INVALIDATE, 0, 0);
		goto LBL_Def;

	case INTM_AVATARCHANGED:
	{
		avatarCacheEntry *cEntry = (struct avatarCacheEntry *)lParam;
		contact = NULL;

		if (wParam == 0) {
			//RemoveFromImgCache(0, cEntry);
			cfg::dat.bForceRefetchOnPaint = TRUE;
			RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
			cfg::dat.bForceRefetchOnPaint = FALSE;
			goto LBL_Def;
		}

		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			return 0;
		contact->ace = cEntry;
		if (cEntry == NULL)
			contact->cFlags &= ~ECF_AVATAR;
		else {
			DWORD dwFlags;

			if (contact->pExtra)
				dwFlags = contact->pExtra->dwDFlags;
			else
				dwFlags = cfg::getDword(contact->hContact, "CList", "CLN_Flags", 0);
			if (cfg::dat.dwFlags & CLUI_FRAME_AVATARS)
				contact->cFlags = (dwFlags & ECF_HIDEAVATAR ? contact->cFlags & ~ECF_AVATAR : contact->cFlags | ECF_AVATAR);
			else
				contact->cFlags = (dwFlags & ECF_FORCEAVATAR ? contact->cFlags | ECF_AVATAR : contact->cFlags & ~ECF_AVATAR);
		}
		PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)contact->hContact);
	}
		goto LBL_Def;

	case INTM_STATUSMSGCHANGED:
	{
		TExtraCache *p;
		char *szProto = NULL;

		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			p = cfg::getCache(wParam, NULL);
		else {
			p = contact->pExtra;
			szProto = contact->proto;
		}
		GetCachedStatusMsg(p, szProto);
		PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0));
	}
		goto LBL_Def;

	case INTM_STATUSCHANGED:
		if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) {
			WORD wStatus = cfg::getWord(wParam, contact->proto, "Status", ID_STATUS_OFFLINE);
			if (cfg::dat.bNoOfflineAvatars && wStatus != ID_STATUS_OFFLINE && contact->wStatus == ID_STATUS_OFFLINE) {
				contact->wStatus = wStatus;
				if (cfg::dat.bAvatarServiceAvail && contact->ace == NULL)
					LoadAvatarForContact(contact);
			}
			contact->wStatus = wStatus;
			goto LBL_Def;
		}
		break;

	case INTM_PROTOCHANGED:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;

		contact->proto = GetContactProto(wParam);
		CallService(MS_CLIST_INVALIDATEDISPLAYNAME, wParam, 0);
		lstrcpyn(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText));

		RTL_DetectAndSet(contact, 0);

		dat->needsResort = TRUE;
		PostMessage(hwnd, INTM_SORTCLC, 0, 0);
		goto LBL_Def;

	case INTM_INVALIDATE:
		if (!dat->bNeedPaint) {
			KillTimer(hwnd, TIMERID_PAINT);
			SetTimer(hwnd, TIMERID_PAINT, 100, NULL);
			dat->bNeedPaint = TRUE;
		}
		goto LBL_Def;

	case INTM_INVALIDATECONTACT:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, &group, NULL))
			break;

		if (contact == 0 || group == 0)
			break;
		{
			int iItem = pcli->pfnGetRowsPriorTo(&dat->list, group, List_IndexOf((SortedList*) & group->cl, contact));
			pcli->pfnInvalidateItem(hwnd, dat, iItem);
		}
		goto LBL_Def;

	case INTM_FORCESORT:
		dat->needsResort = TRUE;
		return SendMessage(hwnd, INTM_SORTCLC, wParam, lParam);

	case INTM_SORTCLC:
		if (dat->needsResort) {
			pcli->pfnSortCLC(hwnd, dat, TRUE);
			dat->needsResort = FALSE;
		}
		if (lParam)
			pcli->pfnRecalcScrollBar(hwnd, dat);
		goto LBL_Def;

	case INTM_IDLECHANGED:
		if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) {
			DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
			char *szProto = (char*)cws->szModule;
			if (szProto == NULL)
				break;

			contact->flags &= ~CONTACTF_IDLE;
			if (cfg::getDword(wParam, szProto, "IdleTS", 0)) {
				contact->flags |= CONTACTF_IDLE;
			}
			PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)contact->hContact);
			goto LBL_Def;
		}
		break;

	case INTM_XSTATUSCHANGED:
		{
			DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
			char *szProto = (char *)cws->szModule;
			MCONTACT hContact = wParam;
			TExtraCache *p;

			if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL)) {
				p = cfg::getCache(hContact, szProto);
				if (!dat->bisEmbedded && szProto) {				// may be a subcontact, forward the xstatus
					MCONTACT hMasterContact = db_mc_getMeta(hContact);
					if (hMasterContact && hMasterContact != hContact)				// avoid recursive call of settings handler
						cfg::writeByte(hMasterContact, META_PROTO, "XStatusId", (BYTE)cfg::getByte(hContact, szProto, "XStatusId", 0));
					break;
				}
			}
			else {
				contact->xStatus = cfg::getByte(hContact, szProto, "XStatusId", 0);
				p = contact->pExtra;
			}

			if (szProto == NULL)
				break;

			if (contact) {
				if (ProtoServiceExists(szProto, PS_GETADVANCEDSTATUSICON)) {
					int iconId = ProtoCallService(szProto, PS_GETADVANCEDSTATUSICON, hContact, 0);
					if (iconId != -1)
						contact->xStatusIcon = iconId >> 16;
				}
			}

			GetCachedStatusMsg(p, szProto);
			PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0));
		}
		goto LBL_Def;

	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc = BeginPaint(hwnd, &ps);
			if (IsWindowVisible(hwnd) && !during_sizing && !cfg::shutDown) {
				PaintClc(hwnd, dat, hdc, &ps.rcPaint);
				dat->bNeedPaint = FALSE;
				dat->lastRepaint = GetTickCount();
			}
			EndPaint(hwnd, &ps);
			if (dat->selection != dat->oldSelection && !dat->bisEmbedded && g_ButtonItems != NULL) {
				SetDBButtonStates(0);
				dat->oldSelection = dat->selection;
			}
		}
		goto LBL_Def;

	case WM_MOUSEWHEEL:
		dat->forceScroll = TRUE;
		break;

	case WM_TIMER:
		if (wParam == TIMERID_PAINT) {
			KillTimer(hwnd, TIMERID_PAINT);
			InvalidateRect(hwnd, NULL, FALSE);
			goto LBL_Def;
		}

		if (wParam == TIMERID_REFRESH) {
			InvalidateRect(hwnd, NULL, FALSE);
			goto LBL_Def;
		}
		break;

	case WM_LBUTTONDBLCLK:
		ReleaseCapture();
		dat->iHotTrack = -1;
		pcli->pfnHideInfoTip(hwnd, dat);
		KillTimer(hwnd, TIMERID_RENAME);
		KillTimer(hwnd, TIMERID_INFOTIP);
		dat->szQuickSearch[0] = 0;
		{
			DWORD hitFlags;
			dat->selection = HitTest(hwnd, dat, (short) LOWORD(lParam), (short) HIWORD(lParam), &contact, NULL, &hitFlags);
			if (hitFlags & CLCHT_ONITEMEXTRA)
				break;

			InvalidateRect(hwnd, NULL, FALSE);
			if (dat->selection != -1)
				pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0);
			if (hitFlags & CLCHT_ONAVATAR && cfg::dat.bDblClkAvatars) {
				CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)contact->hContact, 0);
				return TRUE;
			}
			if (hitFlags & (CLCHT_ONITEMICON | CLCHT_ONITEMLABEL | CLCHT_ONITEMSPACE)) {
				UpdateWindow(hwnd);
				pcli->pfnDoSelectionDefaultAction(hwnd, dat);
			}
		}
		return TRUE;

	case WM_CONTEXTMENU:
		{
			HMENU hMenu = NULL;
			POINT pt;
			DWORD hitFlags;

			pcli->pfnEndRename(hwnd, dat, 1);
			pcli->pfnHideInfoTip(hwnd, dat);
			KillTimer(hwnd, TIMERID_RENAME);
			KillTimer(hwnd, TIMERID_INFOTIP);
			if (GetFocus() != hwnd)
				SetFocus(hwnd);
			dat->iHotTrack = -1;
			dat->szQuickSearch[0] = 0;
			pt.x = (short) LOWORD(lParam);
			pt.y = (short) HIWORD(lParam);
			if (pt.x == -1 && pt.y == -1) {
				dat->selection = pcli->pfnGetRowByIndex(dat, dat->selection, &contact, NULL);
				if (dat->selection != -1)
					pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0);
				pt.x = dat->iconXSpace + 15;
				pt.y = RowHeight::getItemTopY(dat, dat->selection) - dat->yScroll + (int)(dat->row_heights[dat->selection] * .7);
				hitFlags = dat->selection == -1 ? CLCHT_NOWHERE : CLCHT_ONITEMLABEL;
			} else {
				ScreenToClient(hwnd, &pt);
				dat->selection = HitTest(hwnd, dat, pt.x, pt.y, &contact, NULL, &hitFlags);
			}
			InvalidateRect(hwnd, NULL, FALSE);
			if (dat->selection != -1)
				pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0);
			UpdateWindow(hwnd);

			if (dat->selection != -1 && hitFlags & (CLCHT_ONITEMICON | CLCHT_ONITEMCHECK | CLCHT_ONITEMLABEL)) {
				if (contact->type == CLCIT_GROUP) {
					hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDSUBGROUP, (WPARAM)contact->group, 0);
					ClientToScreen(hwnd, &pt);
					TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, pcli->hwndContactList, NULL);
					CheckMenuItem(hMenu, POPUP_GROUPHIDEOFFLINE, contact->group->hideOffline ? MF_CHECKED : MF_UNCHECKED);
					DestroyMenu(hMenu);
					return 0;
				} else if (contact->type == CLCIT_CONTACT)
					hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) contact->hContact, 0);
			} else {
				//call parent for new group/hide offline menu
				PostMessage(GetParent(hwnd), WM_CONTEXTMENU, wParam, lParam);
				return 0;
			}
			if (hMenu != NULL) {
				ClientToScreen(hwnd, &pt);
				TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL);
				DestroyMenu(hMenu);
			}
		}
		return 0;

	case WM_COMMAND:
		if (LOWORD(wParam) == POPUP_NEWGROUP)
			SendMessage(GetParent(hwnd), msg, wParam, lParam);
		break;

	case WM_NCHITTEST:
		{
			LRESULT lr = SendMessage(GetParent(hwnd), WM_NCHITTEST, wParam, lParam);
			if (lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT
				|| lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT)
				return HTTRANSPARENT;
		}
		break;

	case WM_DESTROY:
		RowHeight::Free(dat);
		break;
	}

	return saveContactListControlWndProc(hwnd, msg, wParam, lParam);
}
Esempio n. 20
0
//************************************************************************
// adds a contact to the list
//************************************************************************
void CContactList::AddContact(MCONTACT hContact)
{
	CListContainer<CContactListEntry*,CContactListGroup*> *pGroup = NULL;

	tstring strName = CAppletManager::GetContactDisplayname(hContact);
	char *szProto = GetContactProto(hContact);
	
	tstring strGroup = GetContactGroupPath(hContact);
	// ignore contacts without a valid protocoll
	if(szProto == NULL)
		return;

	int iStatus = db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE);
	TCHAR *szStatus = pcli->pfnGetStatusModeDescription(iStatus, 0);

	CContactListEntry *psContact = new CContactListEntry();

	psContact->strName = strName;
	psContact->iMessages = 0;
	psContact->hHandle = hContact;
	
	psContact->iStatus = iStatus;
	
	if(szStatus != NULL)
		psContact->strStatus =toTstring(szStatus);
	psContact->strProto = toTstring(szProto);

	// check wether the contact should be listed
	if(!IsVisible(psContact)) {
		delete psContact;
		return;
	}

	// Don't add metacontacts as contacts
	if(!mir_strcmpi(szProto,"MetaContacts"))
	{
		if(!CConfig::GetBoolSetting(CLIST_USEGROUPS))
			strGroup = _T("");
		strGroup += (strGroup.empty()?_T(""):_T("\\"))+psContact->strName;
		pGroup = GetGroupByString(strGroup);
		if(pGroup == NULL)
			pGroup = AddGroupByString(strGroup);
		pGroup->GetGroupData()->hMetaContact = hContact;
		pGroup->GetGroupData()->pContactListEntry = psContact;

		pGroup = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent();
		if(pGroup->GetType() != ROOT && iStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);

		pGroup->sort(CContactList::CompareEntries);

		// check that all subcontacts exist
		int numContacts = db_mc_getSubCount(hContact);
		MCONTACT hSubContact = NULL;
		for(int i=0;i<numContacts;i++) {
			hSubContact = db_mc_getSub(hContact, i);
			RemoveContact(hSubContact);
			AddContact(hSubContact);
		}
		return;
	}
	else if(db_mc_isSub(hContact)) {
		MCONTACT hMetaContact = db_mc_getMeta(hContact);
		// check that the metacontact exists
		if(!FindContact(hMetaContact))
			AddContact(hMetaContact);
	}

	CListItem<CContactListEntry*,CContactListGroup*> *pItem = NULL;
	if((!db_mc_isSub(hContact) && !CConfig::GetBoolSetting(CLIST_USEGROUPS)) || strGroup.empty())
	{
		pItem = AddItem(psContact);
		((CListContainer<CContactListEntry*,CContactListGroup*>*)this)->sort(CContactList::CompareEntries);
	}
	else
	{
		pGroup = GetGroupByString(strGroup);
		if(pGroup == NULL) {
			pGroup = AddGroupByString(strGroup);
		}
		pItem = pGroup->AddItem(psContact);
	
		if(!db_mc_isSub(hContact) && iStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);

		pGroup->sort(CContactList::CompareEntries);
	}

	UpdateMessageCounter((CListEntry<CContactListEntry*,CContactListGroup*>*)pItem);
}
Esempio n. 21
0
int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode)
{
	int issplit = 1, foundWin = 0, preTyping = 0;
	BOOL fShowOnClist = TRUE;

	HWND hwnd = M.FindWindow(hContact);
	MCONTACT hMeta = db_mc_getMeta(hContact);
	if (hMeta) {
		if (!hwnd)
			hwnd = M.FindWindow(hMeta);
		hContact = hMeta;
	}

	if (hwnd && M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPING, SRMSGDEFSET_SHOWTYPING))
		preTyping = SendMessage(hwnd, DM_TYPING, 0, mode);

	if (hwnd && IsWindowVisible(hwnd))
		foundWin = MessageWindowOpened(0, (LPARAM)hwnd);
	else
		foundWin = 0;

	TContainerData *pContainer = NULL;
	if (hwnd) {
		SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
		if (pContainer == NULL) // should never happen
			return 0;
	}

	if (M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGCLIST, SRMSGDEFSET_SHOWTYPINGCLIST)) {
		if (!hwnd && !M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGNOWINOPEN, 1))
			fShowOnClist = false;
		if (hwnd && !M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGWINOPEN, 1))
			fShowOnClist = false;
	}
	else fShowOnClist = false;

	if ((!foundWin || !(pContainer->dwFlags & CNT_NOSOUND)) && preTyping != (mode != 0))
		SkinPlaySound(mode ? "TNStart" : "TNStop");

	if (M.GetByte(SRMSGMOD, "ShowTypingPopup", 0)) {
		BOOL fShow = false;
		int  iMode = M.GetByte("MTN_PopupMode", 0);

		switch (iMode) {
		case 0:
			fShow = true;
			break;
		case 1:
			if (!foundWin || !(pContainer && pContainer->hwndActive == hwnd && GetForegroundWindow() == pContainer->hwnd))
				fShow = true;
			break;
		case 2:
			if (hwnd == 0)
				fShow = true;
			else {
				if (PluginConfig.m_HideOnClose) {
					TContainerData *pContainer = 0;
					SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
					if (pContainer && pContainer->fHidden)
						fShow = true;
				}
			}
			break;
		}
		if (fShow)
			TN_TypingMessage(hContact, mode);
	}

	if (mode) {
		TCHAR szTip[256];
		mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0));
		if (fShowOnClist && ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && M.GetByte(SRMSGMOD, "ShowTypingBalloon", 0)) {
			MIRANDASYSTRAYNOTIFY tn;
			tn.szProto = NULL;
			tn.cbSize = sizeof(tn);
			tn.tszInfoTitle = TranslateT("Typing Notification");
			tn.tszInfo = szTip;
			tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE;
			tn.uTimeout = 1000 * 4;
			CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn);
		}
		if (fShowOnClist) {
			CLISTEVENT cle = { sizeof(cle) };
			cle.hContact = hContact;
			cle.hDbEvent = (HANDLE)1;
			cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR;
			cle.hIcon = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING];
			cle.pszService = "SRMsg/TypingMessage";
			cle.ptszTooltip = szTip;
			CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1);
			CallServiceSync(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle);
		}
	}
	return 0;
}
Esempio n. 22
0
static int AvatarChanged(WPARAM hContact, LPARAM lParam)
{
	if (hContact == NULL)
		return 0;

	char *proto = GetContactProto(hContact);
	if (proto == NULL)
		return 0;

	if (strcmp(META_PROTO, proto) == 0)
		return 0;

	DBVARIANT dbvOldHash = {0};
	bool ret = (db_get_ts(hContact,MODULE_NAME,"AvatarHash",&dbvOldHash) == 0);

	CONTACTAVATARCHANGEDNOTIFICATION* avatar = (CONTACTAVATARCHANGEDNOTIFICATION*)lParam;
	if (avatar == NULL) {
		if (!ret || !_tcscmp(dbvOldHash.ptszVal, _T("-"))) {
			//avoid duplicate "removed avatar" notifications
			//do not notify on an empty profile
			ShowDebugPopup(hContact, TranslateT("AVH Debug"), TranslateT("Removed avatar, no avatar before... skipping"));
			db_free(&dbvOldHash);
			return 0;
		}
		SkinPlaySound("avatar_removed");

		// Is a flash avatar or avs could not load it
		db_set_ts(hContact, MODULE_NAME, "AvatarHash", _T("-"));

		if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_removed)
			ShowPopup(hContact, NULL, opts.popup_removed);
	}
	else {
		if (ret && !_tcscmp(dbvOldHash.ptszVal, avatar->hash)) {
			// same avatar hash, skipping
			ShowDebugPopup(hContact, TranslateT("AVH Debug"), TranslateT("Hashes are the same... skipping"));
			db_free(&dbvOldHash);
			return 0;
		}
		SkinPlaySound("avatar_changed");
		db_set_ts(hContact, "AvatarHistory", "AvatarHash", avatar->hash);

		TCHAR history_filename[MAX_PATH] = _T("");

		if (ContactEnabled(hContact, "LogToDisk", AVH_DEF_LOGTODISK)) {
			if (!opts.log_store_as_hash) {
				if (opts.log_per_contact_folders) {
					GetOldStyleAvatarName(history_filename, hContact);
					if (CopyImageFile(avatar->filename, history_filename))
						ShowPopup(hContact, TranslateT("Avatar History: Unable to save avatar"), history_filename);
					else
						ShowDebugPopup(hContact, TranslateT("AVH Debug: File copied successfully"), history_filename);

					MCONTACT hMetaContact = db_mc_getMeta(hContact);
					if (hMetaContact && ContactEnabled(hMetaContact, "LogToDisk", AVH_DEF_LOGTOHISTORY)) {
						TCHAR filename[MAX_PATH] = _T("");

						GetOldStyleAvatarName(filename, hMetaContact);
						if (CopyImageFile(avatar->filename, filename))
							ShowPopup(hContact, TranslateT("Avatar History: Unable to save avatar"), filename);
						else
							ShowDebugPopup(hContact, TranslateT("AVH Debug: File copied successfully"), filename);
					}
				}
			}
			else {
				// See if we already have the avatar
				TCHAR hash[128];

				_tcsncpy_s(hash, avatar->hash, _TRUNCATE);
				ConvertToFilename(hash, SIZEOF(hash));

				TCHAR *file = GetCachedAvatar(proto, hash);

				if (file != NULL) {
					mir_tstrncpy(history_filename, file, SIZEOF(history_filename));
					mir_free(file);
				}
				else {
					if (opts.log_keep_same_folder)
						GetHistoryFolder(history_filename);
					else
						GetProtocolFolder(history_filename, proto);

					mir_sntprintf(history_filename, SIZEOF(history_filename), 
							_T("%s\\%s"), history_filename, hash);

					if (CopyImageFile(avatar->filename, history_filename))
						ShowPopup(hContact, TranslateT("Avatar History: Unable to save avatar"), history_filename);
					else
						ShowDebugPopup(hContact, TranslateT("AVH Debug: File copied successfully"), history_filename);
				}

				if (opts.log_per_contact_folders) {
					CreateOldStyleShortcut(hContact, history_filename);

					MCONTACT hMetaContact = db_mc_getMeta(hContact);
					if (hMetaContact && ContactEnabled(hMetaContact, "LogToDisk", AVH_DEF_LOGTOHISTORY))
						CreateOldStyleShortcut(hMetaContact, history_filename);
				}
			}
		}

		if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_changed)
			ShowPopup(hContact, NULL, opts.popup_changed);

		if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY)) {
			TCHAR rel_path[MAX_PATH];
			PathToRelativeT(history_filename, rel_path);
			ptrA blob( mir_utf8encodeT(rel_path));

			DBEVENTINFO dbei = { sizeof(dbei) };
			dbei.szModule = GetContactProto(hContact);
			dbei.flags = DBEF_READ | DBEF_UTF;
			dbei.timestamp = (DWORD) time(NULL);
			dbei.eventType = EVENTTYPE_AVATAR_CHANGE;
			dbei.cbBlob = (DWORD) strlen(blob) + 1;
			dbei.pBlob = (PBYTE)(char*)blob;
			db_event_add(hContact, &dbei);
		}
	}

	return 0;
}
Esempio n. 23
0
bool metaIsDefaultSubContact(MCONTACT hContact) 
{
	return db_mc_getDefault(db_mc_getMeta(hContact)) == hContact;
}