Ejemplo n.º 1
0
void GetSelectedContacts(FacebookProto *proto, MCONTACT hItem, HWND hwndList, std::vector<facebook_user*> *contacts)
{
	if (hItem == NULL)
		hItem = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem) {
		if (IsHContactGroup(hItem)) {
			MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT)
				GetSelectedContacts(proto, hItemT, hwndList, contacts);
		}
		else {
			if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
				facebook_user *fu = new facebook_user();

				ptrA userId(proto->getStringA(hItem, FACEBOOK_KEY_ID));
				if (userId)
					fu->user_id = userId;

				ptrT realName(proto->getTStringA(hItem, FACEBOOK_KEY_NICK));
				if (realName)
					fu->real_name = _T2A(realName);

				contacts->push_back(fu);
			}
		}
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
	}
}
Ejemplo n.º 2
0
void ClearClcContactCache(struct ClcData *dat,MCONTACT hContact)
{
	ClcCacheEntry *cacheEntry;

	if (hContact == INVALID_CONTACT_ID) {
		int i,tick;
		tick = GetTickCount();

		for (i = 0;i<(dat->lCLCContactsCache.realCount);i++) {
			ClcCacheEntry *pdnce = (ClcCacheEntry *)dat->lCLCContactsCache.items[i];
			pdnce->ClcContact = NULL;
		}
		tick = GetTickCount()-tick;
		{
			char buf[256];
			mir_snprintf(buf, SIZEOF(buf), "Clear full cache %d ms\r\n", tick);
			OutputDebugStringA(buf);
		}
	}
	if ( !IsHContactGroup(hContact) && !IsHContactInfo(hContact)) {
		cacheEntry = GetCLCFullCacheEntry(dat,hContact);
		if (cacheEntry != NULL)
			cacheEntry->ClcContact = NULL;
	}
}
Ejemplo n.º 3
0
static void ChatInviteSend(HANDLE hItem, HWND hwndList, STRLIST &str, CMsnProto *ppro)
{
	if (hItem == NULL)
		hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem) {
		if (IsHContactGroup(hItem)) {
			HANDLE hItemT = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT) ChatInviteSend(hItemT, hwndList, str, ppro);
		}
		else {
			int chk = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
			if (chk) {
				if (IsHContactInfo(hItem)) {
					TCHAR buf[128] = _T("");
					SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);

					if (buf[0]) str.insert(mir_t2a(buf));
				}
				else {
					MsnContact *msc = ppro->Lists_Get((UINT_PTR)hItem);
					if (msc) {
						char szContact[MSN_MAX_EMAIL_LEN];

						sprintf(szContact, "%d:%s", msc->netId, msc->email);
						str.insertn(szContact);
					}
				}
			}
		}
		hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
	}
}
Ejemplo n.º 4
0
void ClearClcContactCache(struct ClcData *dat,HANDLE hContact)
{

	pdisplayNameCacheEntry cacheEntry;

	if (hContact==INVALID_HANDLE_VALUE)
	{
		int i,tick;
		tick=GetTickCount();

		for(i=0;i<(dat->lCLCContactsCache.realCount);i++)
		{
			pdisplayNameCacheEntry pdnce = dat->lCLCContactsCache.items[i];
			pdnce->ClcContact = NULL;
		}		
		tick=GetTickCount()-tick;

		{ char buf[256];
		sprintf	(buf,"Clear full cache %d ms\r\n",tick);
		OutputDebugStringA(buf);		
		}
	}
	if(!IsHContactGroup(hContact)&&!IsHContactInfo(hContact))
	{
		cacheEntry=GetCLCFullCacheEntry(dat,hContact);
		if (cacheEntry!=NULL)
			cacheEntry->ClcContact=NULL;
	}
}
Ejemplo n.º 5
0
std::vector<MCONTACT> CToxProto::GetInvitedContacts(HWND hwndList, MCONTACT hContact)
{
	std::vector<MCONTACT> contacts;
	if (hContact == NULL)
	{
		hContact = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
	}
	while (hContact)
	{
		if (IsHContactGroup(hContact))
		{
			MCONTACT hSubContact = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hContact);
			if (hSubContact)
			{
				std::vector<MCONTACT> subContacts = GetInvitedContacts(hwndList, hSubContact);
				contacts.insert(contacts.end(), subContacts.begin(), subContacts.end());
			}
		}
		else
		{
			int cheked = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hContact, 0);
			if (cheked)
			{
				contacts.push_back(hContact);
			}
		}
		hContact = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hContact);
	}
	return contacts;
}
Ejemplo n.º 6
0
void SetClcContactCacheItem(struct ClcData *dat, MCONTACT hContact, void *contact)
{
	ClcCacheEntry *cacheEntry;
	if ( !IsHContactGroup(hContact) && !IsHContactInfo(hContact)) {
		cacheEntry = GetCLCFullCacheEntry(dat,hContact);
		if (cacheEntry != NULL)
			cacheEntry->ClcContact = contact;
	}
}
Ejemplo n.º 7
0
static void SaveSettings(HANDLE hItem, HWND hwndList, CMsnProto* proto)
{
	if (hItem == NULL)
		hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem)
	{
		if (IsHContactGroup(hItem))
		{
			HANDLE hItemT = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT) SaveSettings(hItemT, hwndList, proto);
		}
		else
		{
			char szEmail[MSN_MAX_EMAIL_LEN];

			if (IsHContactContact(hItem))
			{
				if (proto->getStaticString(hItem, "e-mail", szEmail, sizeof(szEmail))) continue;
			}
			else if (IsHContactInfo(hItem))
			{

				TCHAR buf[MSN_MAX_EMAIL_LEN];
				SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);
				WideCharToMultiByte(CP_ACP, 0, buf, -1, szEmail, sizeof(szEmail), 0, 0);

			}

			int dwMask = proto->Lists_GetMask(szEmail);
			SaveListItem(hItem, szEmail, LIST_LL, (dwMask & LIST_LL)?1:0, SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0,0)), proto);
			SaveListItem(hItem, szEmail, LIST_FL, (dwMask & LIST_FL)?2:0, SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1,0)), proto);
			SaveListItem(hItem, szEmail, LIST_AL, (dwMask & LIST_AL)?3:0, SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(2,0)), proto);
			SaveListItem(hItem, szEmail, LIST_BL, (dwMask & LIST_BL)?4:0, SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(3,0)), proto);

			int newMask = proto->Lists_GetMask(szEmail);
			int xorMask = newMask ^ dwMask;

			if (xorMask && newMask & (LIST_FL | LIST_LL))
			{
				HANDLE hContact = IsHContactInfo(hItem) ? proto->MSN_HContactFromEmail(szEmail, szEmail, true, false) : hItem;
				proto->MSN_SetContactDb(hContact, szEmail);
			}

			if (xorMask & (LIST_FL | LIST_LL) && !(newMask & (LIST_FL | LIST_LL)))
			{
				if (!IsHContactInfo(hItem))
				{
					CallService(MS_DB_CONTACT_DELETE, (WPARAM)hItem, 0);
					MsnContact* msc = proto->Lists_Get(szEmail);
					if (msc) msc->hContact = NULL;
				}
			}
		}
		hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
	}
}
Ejemplo n.º 8
0
MCONTACT CCList::GethContact(HTREEITEM hItem) // returns hContact, hGroup or hInfo
{
	MCONTACT hContact = GetItemData(hItem).hContact;
	if (IsHContactContact(hContact))
		return hContact;
	if (IsHContactGroup(hContact))
		return hContact & ~HCONTACT_ISGROUP;
	return hContact & ~HCONTACT_ISINFO;
}
Ejemplo n.º 9
0
void HideInfoTip(HWND hwnd,struct ClcData *dat)
{
	CLCINFOTIP it={0};

	if(dat->hInfoTipItem==NULL) return;
	it.isGroup=IsHContactGroup(dat->hInfoTipItem);
	it.hItem=(HANDLE)((unsigned)dat->hInfoTipItem&~HCONTACT_ISGROUP);
	it.cbSize=sizeof(it);
	dat->hInfoTipItem=NULL;
	NotifyEventHooks(hHideInfoTipEvent,0,(LPARAM)&it);
}
Ejemplo n.º 10
0
int CALLBACK CompareItemsCallback(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	CCList *dat = (CCList*)lParamSort;
	if (IsHContactInfo(dat->Items[lParam1].hContact)) // Info items precede all other items
		return (IsHContactInfo(dat->Items[lParam2].hContact)) ? 0 : -1;

	if (IsHContactInfo(dat->Items[lParam2].hContact))
		return 1;

	if (IsHContactGroup(dat->Items[lParam1].hContact)) { // groups precedes contacts
		if (IsHContactGroup(dat->Items[lParam2].hContact))
			return (unsigned)dat->Items[lParam1].hContact - (unsigned)dat->Items[lParam2].hContact;
		return -1;
	}

	if (IsHContactGroup(dat->Items[lParam2].hContact))
		return 1;
	
	return Clist_ContactCompare(dat->Items[lParam1].hContact, dat->Items[lParam2].hContact);
}
Ejemplo n.º 11
0
void SetClcContactCacheItem(struct ClcData *dat,HANDLE hContact,void *contact)
{
	pdisplayNameCacheEntry cacheEntry;
	if(!IsHContactGroup(hContact)&&!IsHContactInfo(hContact))
	{
		cacheEntry=GetCLCFullCacheEntry(dat,hContact);
		if (cacheEntry!=NULL)
		{
			cacheEntry->ClcContact=contact;
		}
	}

}
Ejemplo n.º 12
0
static void clist_chat_invite_send(MCONTACT hItem, HWND hwndList, YList* &who, char* room, CYahooProto* ppro, TCHAR *msg)
{
	bool root = !hItem;
	if (root)
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem) {
		if (IsHContactGroup(hItem)) {
			MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT)
				clist_chat_invite_send(hItemT, hwndList, who, room, ppro, msg);
		}
		else {
			int chk = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
			if (chk) {
				if (IsHContactInfo(hItem)) {
					TCHAR buf[128] = _T("");
					SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);

					who = y_list_append(who, mir_t2a(buf));
				}
				else {
					DBVARIANT dbv;
					if (!ppro->getString(hItem, YAHOO_LOGINID, &dbv))
						who = y_list_append(who, dbv.pszVal);
				}
			}
		}
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
	}

	if (root && who) {
		T2Utf msg8(msg);
		CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
		if (cm) {
			for (YList *l = who; l; l = l->next)
				yahoo_conference_addinvite(ppro->m_id, NULL, (char*)l->data, room, cm->members, msg8);
		}
		else yahoo_conference_invite(ppro->m_id, NULL, who, room, msg8);

		for (YList *l = who; l; l = l->next) mir_free(l->data);
		y_list_free(who);
	}
}
Ejemplo n.º 13
0
static void SetAllContactIcons(MCONTACT hItem, HWND hwndList, CMsnProto* proto)
{
	if (hItem == NULL)
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem) {
		MCONTACT hItemN = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);

		if (IsHContactGroup(hItem)) {
			MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT)
				SetAllContactIcons(hItemT, hwndList, proto);
		}
		else if (IsHContactContact(hItem))
			SetContactIcons(hItem, hwndList, proto);

		hItem = hItemN;
	}
}
Ejemplo n.º 14
0
static void ChatPrepare(MCONTACT hItem, HWND hwndList, CMsnProto* ppro)
{
	if (hItem == NULL)
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem) {
		MCONTACT hItemN = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);

		if (IsHContactGroup(hItem)) {
			MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT)
				ChatPrepare(hItemT, hwndList, ppro);
		}
		else if (IsHContactContact(hItem))
			ChatValidateContact(hItem, hwndList, ppro);

		hItem = hItemN;
	}
}
Ejemplo n.º 15
0
void ClistPrepare(FacebookProto *proto, MCONTACT hItem, HWND hwndList)
{
	if (hItem == NULL)
		hItem = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem)
	{
		MCONTACT hItemN = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);

		if (IsHContactGroup(hItem)) {
			MCONTACT hItemT = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT)
				ClistPrepare(proto, hItemT, hwndList);
		}
		else if (IsHContactContact(hItem)) {
			if (!proto->IsMyContact(hItem) || ptrA(proto->getStringA(hItem, FACEBOOK_KEY_ID)) == NULL)
				SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0);
		}

		hItem = hItemN;
	}
}
Ejemplo n.º 16
0
void CToxProto::ChatPrepare(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact)
{
	if (hContact == NULL)
	{
		hContact = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
	}
	while (hContact)
	{
		if (IsHContactGroup(hContact))
		{
			MCONTACT hSubContact = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hContact);
			if (hSubContact)
			{
				ChatPrepare(hwndList, contacts, hSubContact);
			}
		}
		else if (IsHContactContact(hContact))
		{
			ChatValidateContact(hwndList, contacts, hContact);
		}
		hContact = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hContact);
	}
}
Ejemplo n.º 17
0
int FindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible)
{
	int index = 0;
	int nowVisible = 1;
	ClcGroup *group = &dat->list;

	group->scanIndex = 0;
	for (;;) {
		if (group->scanIndex == group->cl.count) {
			ClcGroup *tgroup;
			group = group->parent;
			if (group == NULL)
				break;
			nowVisible = 1;
			for (tgroup = group; tgroup; tgroup = tgroup->parent) {
				if (!(group->expanded)) {
					nowVisible = 0; break;
				}
			}
			group->scanIndex++;
			continue;
		}
		if (nowVisible)
			index++;
		if ((IsHContactGroup(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && ((UINT_PTR)hItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId) ||
			(IsHContactContact(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == (UINT_PTR)hItem) ||
			(IsHContactInfo(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == ((UINT_PTR)hItem & ~HCONTACT_ISINFO))) {
			if (isVisible) {
				if (!nowVisible)
					*isVisible = 0;
				else {
					int posy = RowHeight::getItemTopY(dat, index + 1);
					if (posy < dat->yScroll)
						*isVisible = 0;
					else {
						RECT clRect;
						GetClientRect(hwnd, &clRect);
						if (posy >= dat->yScroll + clRect.bottom)
							*isVisible = 0;
						else
							*isVisible = 1;
					}
				}
			}
			if (contact)
				*contact = group->cl.items[group->scanIndex];
			if (subgroup)
				*subgroup = group;
			return 1;
		}
		if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
			group = group->cl.items[group->scanIndex]->group;
			group->scanIndex = 0;
			nowVisible &= (group->expanded);
			continue;
		}
		group->scanIndex++;
	}

	if (isVisible) *isVisible = FALSE;
	if (contact)   *contact = NULL;
	if (subgroup)  *subgroup = NULL;
	return 0;
}
Ejemplo n.º 18
0
DWORD CCList::GetItemTypeAsCLGNFlag(HTREEITEM hItem)
{
	MCONTACT hContact = GetItemData(hItem).hContact;
	return (IsHContactInfo(hContact)) ? MCLGN_INFO : ((IsHContactGroup(hContact)) ? MCLGN_GROUP : MCLGN_CONTACT);
}
Ejemplo n.º 19
0
int CCList::GetItemType(HTREEITEM hItem) // returns a MCLCIT_ (see below)
{
	MCONTACT hContact = GetItemData(hItem).hContact;
	return (IsHContactInfo(hContact)) ? MCLCIT_INFO : ((IsHContactGroup(hContact)) ? MCLCIT_GROUP : MCLCIT_CONTACT);
}
Ejemplo n.º 20
0
LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{     
	/*
	This registers a window message with RegisterWindowMessage() and then waits for such a message,
	if it gets it, it tries to open a file mapping object and then maps it to this process space,
	it expects 256 bytes of data (incl. NULL) it will then write back the profile it is using the DB to fill in the answer.
	
	  The caller is expected to create this mapping object and tell us the ID we need to open ours.	
	*/
	if (msg==hMsgGetProfile && wParam != 0) { /* got IPC message */
		HANDLE hMap;
		char szName[MAX_PATH];
		int rc=0;
		_snprintf(szName,SIZEOF(szName),"Miranda::%u", wParam); // caller will tell us the ID of the map
		hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS,FALSE,szName);
		if (hMap != NULL) {
			void *hView=NULL;
			hView=MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, MAX_PATH);
			if (hView) {
				char szFilePath[MAX_PATH], szProfile[MAX_PATH];
				CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)&szFilePath);
				CallService(MS_DB_GETPROFILENAME,MAX_PATH,(LPARAM)&szProfile);
				_snprintf(hView,MAX_PATH,"%s\\%s",szFilePath,szProfile);
				UnmapViewOfFile(hView);
				rc=1;
			}
			CloseHandle(hMap);
		}
		return rc;
	}

	switch (msg) {
	case WM_CREATE:
		TranslateMenu(GetMenu(hwnd));
		DrawMenuBar(hwnd);
		showOpts=DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);		

		//create the status wnd
		//pcli->hwndStatus = CreateStatusWindow(WS_CHILD | (DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?WS_VISIBLE:0), "", hwnd, 0);	
		CluiProtocolStatusChanged(0,0);
		
		hMsgGetProfile = RegisterWindowMessageA( "Miranda::GetProfile" ); // don't localise
		
		if ( DBGetContactSettingByte( NULL, "CList", "Transparent", 0 )) {
			SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
			if ( MySetLayeredWindowAttributes )
				MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
		}
		transparentFocus=1;
		return FALSE;

	case M_SETALLEXTRAICONS:
		return TRUE;

	case M_CREATECLC:
		CreateCLC(hwnd);
		return TRUE;

	case WM_SIZE:
	{
		RECT rc;
		if ( wParam != SIZE_MINIMIZED ) {
			if ( pcli->hwndContactList != NULL )
				CLUIFramesOnClistResize((WPARAM)hwnd,(LPARAM)0);

			GetWindowRect(hwnd, &rc);		
			if(!CallService(MS_CLIST_DOCKINGISDOCKED,0,0)) {
				//if docked, dont remember pos (except for width)
				DBWriteContactSettingDword(NULL,"CList","Height",(DWORD)(rc.bottom - rc.top));
				DBWriteContactSettingDword(NULL,"CList","x",(DWORD)rc.left);
				DBWriteContactSettingDword(NULL,"CList","y",(DWORD)rc.top);
			}
			DBWriteContactSettingDword(NULL,"CList","Width",(DWORD)(rc.right - rc.left));		
		}
		if ( wParam == SIZE_MINIMIZED ) {
			if ( DBGetContactSettingByte(NULL,"CList","Min2Tray",SETTING_MIN2TRAY_DEFAULT )) {
				ShowWindow(hwnd, SW_HIDE);
				DBWriteContactSettingByte(NULL,"CList","State",SETTING_STATE_HIDDEN);
			}
			else DBWriteContactSettingByte(NULL,"CList","State",SETTING_STATE_MINIMIZED);
		}
		return 0;
	}
			
	case WM_SETFOCUS:
	{	
		boolean isfloating;
		if ( hFrameContactTree ) {					
			isfloating = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLOATING,hFrameContactTree),0);
			if ( isfloating == FALSE)
				SetFocus(pcli->hwndContactTree);
		}
		return 0;
	}
   case WM_TIMER:
		if ((int)wParam>=TM_STATUSBARUPDATE&&(int)wParam<=TM_STATUSBARUPDATE+64) {
			int status,i;

			ProtoTicks *pt=NULL;
			for (i=0;i<64;i++) {
				pt=&CycleStartTick[i];
				if (pt->szProto!=NULL&&pt->TimerCreated==1) {
					status=CallProtoService(pt->szProto,PS_GETSTATUS,0,0);
					if (!(status>=ID_STATUS_CONNECTING&&status<=ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES))
					{													
						pt->CycleStartTick=0;
						KillTimer(hwnd,TM_STATUSBARUPDATE+pt->n);
						pt->TimerCreated=0;
			}	}	}

			pt=&CycleStartTick[wParam-TM_STATUSBARUPDATE];
			{
				RECT rc;
				GetStatsuBarProtoRect(pcli->hwndStatus,pt->szProto,&rc);
				rc.right=rc.left+GetSystemMetrics(SM_CXSMICON)+1;
				rc.top=0;

				if(IsWindowVisible(pcli->hwndStatus)) InvalidateRect(pcli->hwndStatus,&rc,TRUE);
				pcli->pfnTrayIconUpdateBase(pt->szProto);
			}
			//SendMessage(pcli->hwndStatus,WM_PAINT,0,0);
			UpdateWindow(pcli->hwndStatus);
			return TRUE;
		}
		break;

	case WM_DRAWITEM:
	{
		LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
		if ( dis->hwndItem == pcli->hwndStatus ) {
			DrawDataForStatusBar(dis);
			return 0;
		}
		if ( dis->CtlType != ODT_MENU )
			return 0;
		break;
	}
	case WM_KEYDOWN:
		CallService(MS_CLIST_MENUPROCESSHOTKEY,wParam,MPCF_MAINMENU|MPCF_CONTACTMENU);
		if (wParam==VK_F5)
			SendMessage(pcli->hwndContactTree,CLM_AUTOREBUILD,0,0);
		return TRUE;
				
	case WM_GETMINMAXINFO:
		DefWindowProc(hwnd,msg,wParam,lParam);
		((LPMINMAXINFO)lParam)->ptMinTrackSize.x=18;
		if (requr==0){((LPMINMAXINFO)lParam)->ptMinTrackSize.y=CLUIFramesGetMinHeight();}
		return 0;
				
	//MSG FROM CHILD CONTROL
	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->hwndFrom == pcli->hwndContactTree) {
			switch (((LPNMHDR)lParam)->code) {
			case CLN_NEWCONTACT:
				{
					NMCLISTCONTROL *nm=(NMCLISTCONTROL *)lParam;
					if (nm!=NULL) SetAllExtraIcons(pcli->hwndContactTree,nm->hItem );
					return TRUE;
				}
			case CLN_LISTREBUILT:
				SetAllExtraIcons(pcli->hwndContactTree,0);
				return(FALSE);

			case CLN_LISTSIZECHANGE:
				{
					NMCLISTCONTROL *nmc=(NMCLISTCONTROL*)lParam;
					RECT rcWindow,rcTree,rcWorkArea;
					int maxHeight,newHeight;
					int winstyle;

					if ( !disableautoupd && DBGetContactSettingByte( NULL, "CLUI", "AutoSize", 0 )) {
						if ( !CallService(MS_CLIST_DOCKINGISDOCKED,0,0) && hFrameContactTree != 0 ) {
							maxHeight=DBGetContactSettingByte(NULL,"CLUI","MaxSizeHeight",75);
							GetWindowRect(hwnd,&rcWindow);
							GetWindowRect(pcli->hwndContactTree,&rcTree);
							winstyle=GetWindowLong(pcli->hwndContactTree,GWL_STYLE);

							SystemParametersInfo(SPI_GETWORKAREA,0,&rcWorkArea,FALSE);
							lastreqh=nmc->pt.y;
							newHeight=max(nmc->pt.y,3)+1+((winstyle&WS_BORDER)?2:0)+(rcWindow.bottom-rcWindow.top)-(rcTree.bottom-rcTree.top);
							if (newHeight != rcWindow.bottom - rcWindow.top ) {
								if(newHeight>(rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100)
									newHeight=(rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100;
								if(DBGetContactSettingByte(NULL,"CLUI","AutoSizeUpward",0)) {
									rcWindow.top=rcWindow.bottom-newHeight;
									if(rcWindow.top<rcWorkArea.top) rcWindow.top=rcWorkArea.top;
								}
								else {
									rcWindow.bottom=rcWindow.top+newHeight;
									if(rcWindow.bottom>rcWorkArea.bottom) rcWindow.bottom=rcWorkArea.bottom;
								}
								
								if (requr == 0) {
									requr=1;					
									SetWindowPos(hwnd,0,rcWindow.left,rcWindow.top,rcWindow.right-rcWindow.left,rcWindow.bottom-rcWindow.top,SWP_NOZORDER|SWP_NOACTIVATE);
									GetWindowRect(hwnd,&rcWindow);
									requr=0;
					}	}	}	}
					return TRUE;
				}
			case NM_CLICK:
				{	
					NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
					DWORD hitFlags;
					HANDLE hItem = (HANDLE)SendMessage(pcli->hwndContactTree,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));

					if (hitFlags&CLCHT_ONITEMEXTRA) {					
						if (!IsHContactGroup(hItem)&&!IsHContactInfo(hItem))
						{
							int extra;
							pdisplayNameCacheEntry pdnce; 

							pdnce = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(nm->hItem);
							if (pdnce==NULL) return 0;

							extra = ColumnNumToExtra(nm->iColumn);
							NotifyEventHooks(hExtraImageClick, (WPARAM)nm->hItem, extra);

							if (!ServiceExists("ExtraIcon/Register"))
							{
								int v,e,w;
								v=ExtraToColumnNum(EXTRA_ICON_PROTO);
								e=ExtraToColumnNum(EXTRA_ICON_EMAIL);
								w=ExtraToColumnNum(EXTRA_ICON_ADV1);

								if(nm->iColumn==v)
									CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)nm->hItem,0);

								if(nm->iColumn==e) {
									//CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)nm->hItem,0);
									char *email,buf[4096];
									email=DBGetStringA(nm->hItem,"UserInfo", "Mye-mail0");
									if (email) {
										sprintf(buf,"mailto:%s",email);
										ShellExecuteA(hwnd,"open",buf,NULL,NULL,SW_SHOW);
									}											
								}	
								if(nm->iColumn==w) {
									char *homepage;
									homepage=DBGetStringA(pdnce->hContact,pdnce->szProto, "Homepage");
									if (homepage!=NULL)
										ShellExecuteA(hwnd,"open",homepage,NULL,NULL,SW_SHOW);
					}	}	}	}

					if(hItem) break;
					if((hitFlags&(CLCHT_NOWHERE|CLCHT_INLEFTMARGIN|CLCHT_BELOWITEMS))==0) break;
					if (DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",SETTING_CLIENTDRAG_DEFAULT)) {
						POINT pt;
						pt=nm->pt;
						ClientToScreen(pcli->hwndContactTree,&pt);
						return SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE|HTCAPTION,MAKELPARAM(pt.x,pt.y));
					}
					return TRUE;
				}
			}
		}
		else if(((LPNMHDR)lParam)->hwndFrom==pcli->hwndStatus) {
			if (((LPNMHDR)lParam)->code == NM_CLICK ) {
				int nParts=0, nPanel=0;
				NMMOUSE *nm=(NMMOUSE*)lParam;
				HMENU hMenu;
				RECT rc;
				POINT pt;
				int totcount;
				ProtocolData *PD;
				int menuid;
				int startoffset=DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
				int extraspace=DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
				boolean UseOwnerDrawStatusBar=DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
					
				hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
				nParts=SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
						
				if (nm->dwItemSpec==0xFFFFFFFE) {
					nPanel=nParts-1;
					SendMessage(pcli->hwndStatus,SB_GETRECT,nPanel,(LPARAM)&rc);
					if (nm->pt.x < rc.left) return FALSE;
				} 
				else { 
					if (!((startoffset)!=0&&UseOwnerDrawStatusBar))
					{								
						nPanel=nm->dwItemSpec; 
						SendMessage(pcli->hwndStatus,SB_GETRECT,nPanel,(LPARAM)&rc);
					}
					else {
						RECT clrc;
						int sectwidth;

						memset(&rc,0,sizeof(RECT));
						GetClientRect(pcli->hwndStatus,&clrc);
						clrc.right-=clrc.left;
						clrc.right-=startoffset;
						sectwidth=clrc.right/nParts;

						for (nPanel=0;nPanel<nParts;nPanel++) {
							PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
							if(PD==NULL)
								continue;

							rc.top=0;
							rc.bottom=clrc.bottom;
							rc.left=nPanel*sectwidth+startoffset;
							rc.right=rc.left+sectwidth-1;

							if (PtInRect(&rc,nm->pt))
								break;
				}	}	}

				totcount=DBGetContactSettingDword(0,"Protocols","ProtoCount",0);
				PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
				if(PD==NULL){return(0);}
				menuid=nPanel;
						
				if (menuid<0){break;}
				hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
                {
                    int i;
                    unsigned int cpnl = 0;
                    int mcnt = GetMenuItemCount(hMenu);
                    for (i=0; i<mcnt; ++i) {
					    HMENU hMenus = GetSubMenu(hMenu, i);
                        if (hMenus && cpnl++ == menuid) { 
                            hMenu = hMenus; 
                            break; 
                        }
                    }
                }
                {
					char buf[256];
					sprintf(buf,"nPanel: %d, PD->protopos: %d,PD->RealName %s\r\n",nPanel,PD->protopos,PD->RealName);
					OutputDebugStringA(buf);
				}

				if (hMenu != NULL) {						
					GetCursorPos(&pt);
					TrackPopupMenu(hMenu,TPM_BOTTOMALIGN|TPM_LEFTALIGN,pt.x,pt.y,0,hwnd,NULL);
			}	}
			return TRUE;
		}
		break;

	case WM_DESTROY:
		{
			//saving state
			int state = DBGetContactSettingByte(NULL,"CList","State",SETTING_STATE_NORMAL);
			
			FreeProtocolData();
			if ( hSettingChangedHook != 0 )
				UnhookEvent(hSettingChangedHook);
			
			if ( state == SETTING_STATE_NORMAL )
				ShowWindow(hwnd,SW_HIDE);

			CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)hFrameContactTree,(LPARAM)0);
			DestroyWindow(pcli->hwndContactTree);
			pcli->hwndContactList=NULL;

			UnLoadCLUIFramesModule();		
			DBWriteContactSettingByte(NULL,"CList","State",(BYTE)state);
       		PostQuitMessage(0);
		}
		break;
	}

	return saveContactListWndProc( hwnd, msg, wParam, lParam );
}
Ejemplo n.º 21
0
int FindItem(HWND hwnd,struct ClcData *dat,HANDLE hItem,struct ClcContact **contact,struct ClcGroup **subgroup,int *isVisible)
{
	int index=0, i;
	int nowVisible=1;
	struct ClcGroup *group=&dat->list;

	group->scanIndex=0;

	if (isVisible==NULL&&hItem!=NULL&&subgroup==NULL&&!IsHContactGroup(hItem)&&!IsHContactInfo(hItem))
	{
		//try use cache
		pdisplayNameCacheEntry cacheEntry;
		cacheEntry=GetCLCFullCacheEntry(dat,hItem);
		if (cacheEntry!=NULL)
		{
			if (cacheEntry->ClcContact==NULL)
			{
				int *isv={0};
				void *z={0};
				int ret;
				ret=FindItem(hwnd,dat,hItem,(struct ClcContact ** )&z,(struct  ClcGroup** )&isv,NULL);
				if (ret=0) {return (0);}
				cacheEntry->ClcContact=(void *)z;
			}
			if (cacheEntry->ClcContact!=NULL)
			{
				if (contact!=NULL) 
					*contact=(struct ClcContact *)cacheEntry->ClcContact;

				{
					/*
					void *p={0}
					int *isv={0}
					int ret;
					ret=FindItem(hwnd,dat,hItem,&p,&isv,NULL);
					if (ret=0) {return (0);}
					if (p!=cacheEntry->ClcContact)
					{
					MessageBox(0,"hITEM FAILEDDDDDDDD!!!!!","",0);
					//cacheEntry->ClcContact=p;
					}
					*/
				}
				return 1;
			}
		}
	}

	group=&dat->list;

	for(;;) {
		if(group->scanIndex==group->cl.count) {
			struct ClcGroup *tgroup;
			group=group->parent;
			if(group==NULL) break;
			nowVisible=1;
			for(tgroup=group;tgroup;tgroup=tgroup->parent)
				if(!group->expanded) {nowVisible=0; break;}
				group->scanIndex++;
				continue;
		}
		if(nowVisible) index++;
		if((IsHContactGroup(hItem) && group->cl.items[group->scanIndex]->type==CLCIT_GROUP && ((UINT_PTR)hItem&~HCONTACT_ISGROUP)==group->cl.items[group->scanIndex]->groupId) ||
			(IsHContactContact(hItem) && group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact==hItem) ||
			(IsHContactInfo(hItem) && group->cl.items[group->scanIndex]->type==CLCIT_INFO && group->cl.items[group->scanIndex]->hContact==(HANDLE)((UINT_PTR)hItem&~HCONTACT_ISINFO))) {
			if(isVisible) {
				if(!nowVisible) *isVisible=0;
				else {
					if((index+1)*dat->rowHeight<dat->yScroll) *isVisible=0;
					else {
						RECT clRect;
						GetClientRect(hwnd,&clRect);
						if(index*dat->rowHeight>=dat->yScroll+clRect.bottom) *isVisible=0;
						else *isVisible=1;
			}	}	}

			if(contact) *contact=group->cl.items[group->scanIndex];
			if(subgroup) *subgroup=group;
			return 1;
		}

		if (group->cl.items[group->scanIndex]->type==CLCIT_CONTACT &&
			group->cl.items[group->scanIndex]->SubAllocated>0)
			for (i=1; i<=group->cl.items[group->scanIndex]->SubAllocated; i++)
				if (IsHContactContact(hItem)  && group->cl.items[group->scanIndex]->subcontacts[i-1].hContact==hItem)
				{	
					if(contact) *contact=&group->cl.items[group->scanIndex]->subcontacts[i-1];
					if(subgroup) *subgroup=group;
					return 1;
				}

		if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) {
			struct ClcGroup* save = group;
			group=group->cl.items[group->scanIndex]->group;
			group->scanIndex=0;
			nowVisible&=group->expanded;
			continue;
		}
		group->scanIndex++;
	}
	return 0;
}
Ejemplo n.º 22
0
int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible, BOOL isIgnoreSubcontacts)
{
	int index = 0, i;
	int nowVisible = 1;

	ClcGroup *group = &dat->list;
	group->scanIndex = 0;
	group = &dat->list;

	for (;;) {
		if (group->scanIndex == group->cl.count) {
			ClcGroup *tgroup;
			group = group->parent;
			if (group == NULL)
				break;
			
			nowVisible = 1;
			for (tgroup = group; tgroup; tgroup = tgroup->parent) {
				if (!tgroup->expanded) {
					nowVisible = 0;
					break;
				}
			}
			group->scanIndex++;
			continue;
		}
		if (nowVisible) index++;
		if ((IsHContactGroup(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId)  ||
			 (IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == dwItem) ||
			 (IsHContactInfo(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == (dwItem & ~HCONTACT_ISINFO)))
		{
			if (isVisible) {
				if (!nowVisible) *isVisible = 0;
				else {
					int posy = cliGetRowTopY(dat,index+1);
					if (posy < dat->yScroll)
						*isVisible = 0;
					else {
						RECT clRect;
						GetClientRect(hwnd,&clRect);
						if (posy >= dat->yScroll+clRect.bottom) *isVisible = 0;
						else *isVisible = 1;
					}
				}
			}
			if (contact) *contact = group->cl.items[group->scanIndex];
			if (subgroup) *subgroup = group;

			return 1;
		}

		if (!isIgnoreSubcontacts && IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->SubAllocated > 0) {
			for (i = 0; i < group->cl.items[group->scanIndex]->SubAllocated; i++) {
				if (group->cl.items[group->scanIndex]->subcontacts[i].hContact == dwItem) {
					if (contact) *contact = &group->cl.items[group->scanIndex]->subcontacts[i];
					if (subgroup) *subgroup = group;
					return 1;
				}
			}
		}

		if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
			group = group->cl.items[group->scanIndex]->group;
			group->scanIndex = 0;
			nowVisible &= group->expanded;
			continue;
		}
		group->scanIndex++;
	}

	if (isVisible) *isVisible = FALSE;
	if (contact)   *contact = NULL;
	if (subgroup)  *subgroup = NULL;
	return 0;
}
Ejemplo n.º 23
0
int FindItem(HWND hwnd, struct ClcData *dat, DWORD dwItem, struct ClcContact **contact, ClcGroup **subgroup, int *isVisible)
{
	int index = 0, i;
	int nowVisible = 1;
	ClcGroup *group = &dat->list;

	group->scanIndex = 0;

	if (isVisible == NULL && dwItem != NULL && subgroup == NULL && !IsHContactGroup(dwItem) && !IsHContactInfo(dwItem)) {
		//try use cache
		ClcCacheEntry *cacheEntry = GetCLCFullCacheEntry(dat, dwItem);
		if (cacheEntry != NULL) {
			if (cacheEntry->ClcContact == NULL) {
				int *isv = {0};
				void *z = {0};
				int ret;
				ret = FindItem(hwnd,dat,dwItem,(struct ClcContact ** )&z,(struct  ClcGroup** )&isv,NULL);
				if (ret == 0) {return 0;}
				cacheEntry->ClcContact = (void *)z;
			}

			if (cacheEntry->ClcContact != NULL) {
				if (contact != NULL)
					*contact = (struct ClcContact *)cacheEntry->ClcContact;

				return 1;
			}
		}
	}

	group = &dat->list;

	for (;;) {
		if (group->scanIndex == group->cl.count) {
			ClcGroup *tgroup;
			group = group->parent;
			if (group == NULL)
				break;

			nowVisible = 1;
			for (tgroup = group;tgroup;tgroup = tgroup->parent)
				if ( !group->expanded) {
					nowVisible = 0;
					break;
				}

			group->scanIndex++;
			continue;
		}
		if (nowVisible) index++;
		if ((IsHContactGroup(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId) ||
			 (IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == dwItem) ||
			 (IsHContactInfo(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == (dwItem & ~HCONTACT_ISINFO)))
		{
			if (isVisible) {
				if ( !nowVisible) *isVisible = 0;
				else {
					if ((index+1)*dat->rowHeight<dat->yScroll) *isVisible = 0;
					else {
						RECT clRect;
						GetClientRect(hwnd,&clRect);
						if (index*dat->rowHeight>=dat->yScroll+clRect.bottom) *isVisible = 0;
						else *isVisible = 1;
			}	}	}

			if (contact) *contact = group->cl.items[group->scanIndex];
			if (subgroup) *subgroup = group;
			return 1;
		}

		if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT &&
			group->cl.items[group->scanIndex]->SubAllocated>0)
			for (i = 1; i<=group->cl.items[group->scanIndex]->SubAllocated; i++)
				if (IsHContactContact(dwItem)  && group->cl.items[group->scanIndex]->subcontacts[i-1].hContact == dwItem) {
					if (contact) *contact = &group->cl.items[group->scanIndex]->subcontacts[i-1];
					if (subgroup) *subgroup = group;
					return 1;
				}

		if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
			ClcGroup* save = group;
			group = group->cl.items[group->scanIndex]->group;
			group->scanIndex = 0;
			nowVisible &= group->expanded;
			continue;
		}
		group->scanIndex++;
	}

	if (isVisible) *isVisible = FALSE;
	if (contact)   *contact = NULL;
	if (subgroup)  *subgroup = NULL;
	return 0;
}