summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat/manager.cpp
blob: b14d53dbbfecca252f725a0c2c35bfc5fd5fcc9e (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
/*
astyle --force-indent=tab=4 --brackets=linux --indent-switches
		--pad=oper --one-line=keep-blocks  --unpad=paren

Chat module plugin for Miranda NG

Copyright (C) 2003 Jörgen Persson

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 "..\commonheaders.h"

//---------------------------------------------------
//		Session Manager functions
//
//		Keeps track of all sessions and its windows
//---------------------------------------------------

void SM_RemoveContainer(TContainerData *pContainer)
{
	for (SESSION_INFO *si = pci->wndList; si; si = si->next)
		if (si->pContainer == pContainer)
			si->pContainer = NULL;
}

BOOL SM_ReconfigureFilters()
{
	for (SESSION_INFO *si = pci->wndList; si; si = si->next)
		Chat_SetFilters(si);

	return TRUE;
}

BOOL SM_InvalidateLogDirectories()
{
	for (SESSION_INFO *si = pci->wndList; si; si = si->next)
		si->pszLogFileName[0] = si->pszLogFileName[1] = 0;

	return TRUE;
}

SESSION_INFO* SM_FindSessionByHWND(HWND hWnd)
{
	for (SESSION_INFO *si = pci->wndList; si; si = si->next)
		if (si->hWnd == hWnd)
			return si;

	return NULL;
}

SESSION_INFO* SM_FindSessionByHCONTACT(HANDLE h)
{
	for (SESSION_INFO *si = pci->wndList; si; si = si->next)
		if (si->hContact == h)
			return si;

	return NULL;
}

SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
	if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName)
		return currSession;

	TCHAR* pszName = NULL;
	if (currSession == prevSession)
		pszCurrent = pszOriginal;

	SESSION_INFO *pResult = NULL;
	for (SESSION_INFO *si = pci->wndList; si; si = si->next)
		if (si != currSession && !lstrcmpiA(pszModule, si->pszModule))
			if (my_strstri(si->ptszName, pszOriginal) == si->ptszName)
				if (prevSession != si && lstrcmpi(si->ptszName, pszCurrent) > 0 && (!pszName || lstrcmpi(si->ptszName, pszName) < 0)) {
					pResult = si;
					pszName = si->ptszName;
				}

	return pResult;
}