summaryrefslogtreecommitdiff
path: root/plugins/Clist_nicer/src/clcmsgs.cpp
blob: 8d42dddcc7965888a777a0ae2027647a3651425a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*

Miranda NG: the free IM client for Microsoft* Windows*

Copyright (ñ) 2012-16 Miranda NG project (http://miranda-ng.org),
Copyright (c) 2000-03 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "stdafx.h"

//processing of all the CLM_ messages incoming

LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case CLM_SETSTICKY:
		{
			ClcContact *contact;
			ClcGroup *group;
			if (wParam == 0 || !pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL))
				return 0;

			if (lParam)
				contact->flags |= CONTACTF_STICKY;
			else
				contact->flags &= ~CONTACTF_STICKY;
			break;
		}

	case CLM_GETSTATUSMSG:
		if (wParam) {
			ClcContact *contact = NULL;
			if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
				return 0;

			if (contact->type != CLCIT_CONTACT)
				return 0;

			if (contact->pExtra)
				if (contact->pExtra->bStatusMsgValid != STATUSMSG_NOTFOUND)
					return((INT_PTR)contact->pExtra->statusMsg);
		}
		return 0;

	case CLM_SETHIDESUBCONTACTS:
		dat->bHideSubcontacts = lParam != 0;
		return 0;

	case CLM_TOGGLEPRIORITYCONTACT:
		if (wParam) {
			ClcContact *contact = NULL;
			if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
				return 0;
			if (contact->type != CLCIT_CONTACT)
				return 0;
			contact->flags ^= CONTACTF_PRIORITY;
			db_set_b(contact->hContact, "CList", "Priority", (BYTE)(contact->flags & CONTACTF_PRIORITY ? 1 : 0));
			pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0);
		}
		return 0;

	case CLM_QUERYPRIORITYCONTACT:
		if (wParam) {
			ClcContact *contact = NULL;
			if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
				return 0;
			if (contact->type != CLCIT_CONTACT)
				return 0;
			return(contact->flags & CONTACTF_PRIORITY ? 1 : 0);
		}
		return 0;

	case CLM_SETFONT:
		if (HIWORD(lParam) > FONTID_LAST)
			return 0;

		dat->fontInfo[HIWORD(lParam)].hFont = (HFONT)wParam;
		dat->fontInfo[HIWORD(lParam)].changed = 1;

		RowHeight::getMaxRowHeight(dat, hwnd);

		if (LOWORD(lParam))
			InvalidateRect(hwnd, NULL, FALSE);
		return 0;

	case CLM_ISMULTISELECT:
		return dat->isMultiSelect;
	}

	return coreCli.pfnProcessExternalMessages(hwnd, dat, msg, wParam, lParam);
}