summaryrefslogtreecommitdiff
path: root/plugins/IEView/ieview_services.cpp
blob: a9745e4184fad36db1dc9b77e69cc9b80f7ef6ef (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
108
109
110
111
112
113
114
115
116
117
/*

IEView Plugin for Miranda IM
Copyright (C) 2005-2010  Piotr Piastucki

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 "ieview_services.h"
//#include "SRMMHTMLBuilder.h"
#include "ScriverHTMLBuilder.h"
#include "TabSRMMHTMLBuilder.h"
#include "TemplateHTMLBuilder.h"
#include "MUCCHTMLBuilder.h"
#include "ChatHTMLBuilder.h"
#include "HistoryHTMLBuilder.h"
#include "IEView.h"
#include "m_ieview.h"
#include "Options.h"
#include "ieview_common.h"

INT_PTR HandleIEWindow(WPARAM wParam, LPARAM lParam) {
	IEVIEWWINDOW *window = (IEVIEWWINDOW *) lParam;
	IEView::init();
	Options::init();
	if (window->iType == IEW_CREATE) {
		HTMLBuilder *builder = NULL;
		switch (window->dwMode) {
			case IEWM_MUCC:
				builder = new MUCCHTMLBuilder();
				break;
			case IEWM_CHAT:
				builder = new ChatHTMLBuilder();
				break;
			case IEWM_TABSRMM:
				builder = new TabSRMMHTMLBuilder();
				break;
			case IEWM_SCRIVER:
//				builder = new HistoryHTMLBuilder();
				builder = new ScriverHTMLBuilder();
				break;
			case IEWM_HISTORY:
				builder = new HistoryHTMLBuilder();
				break;
			case IEWM_BROWSER:
				builder = NULL;
				break;
			default:
				builder = new ScriverHTMLBuilder();
				break;
		}
		IEView * view = new IEView(window->parent, builder, window->x, window->y, window->cx, window->cy);
		window->hwnd = view->getHWND();
	} else if (window->iType == IEW_SETPOS) {
		IEView * view = IEView::get(window->hwnd);
		if (view!=NULL) {
			view->setWindowPos(window->x, window->y, window->cx,window->cy);
		}
	} else if (window->iType == IEW_SCROLLBOTTOM) {
		IEView * view = IEView::get(window->hwnd);
		if (view!=NULL) {
			view->scrollToBottom();
		}
	} else if (window->iType == IEW_DESTROY) {
		IEView * view = IEView::get(window->hwnd);
		if (view!=NULL) {
			delete view;
		}
	}
	return 0;
}

INT_PTR HandleIEEvent(WPARAM wParam, LPARAM lParam) {
	IEVIEWEVENT *event = (IEVIEWEVENT *) lParam;
	IEView::init();
	Options::init();
	IEView * view = IEView::get(event->hwnd);
	if (view != NULL) {
		if (event->iType == IEE_LOG_DB_EVENTS) {
			view->appendEventOld(event);
		} else if (event->iType == IEE_CLEAR_LOG) {
			view->clear(event);
		} else if (event->iType == IEE_GET_SELECTION) {
			return (int)view->getSelection(event);
		} else if (event->iType == IEE_SAVE_DOCUMENT) {
			view->saveDocument();
		} else if (event->iType == IEE_LOG_MEM_EVENTS) {
			view->appendEvent(event);
		}
	}
	return 0;
}

INT_PTR HandleIENavigate(WPARAM wParam, LPARAM lParam) {
	IEVIEWNAVIGATE *navigate = (IEVIEWNAVIGATE *) lParam;
	IEView::init();
	Options::init();
	IEView * view = IEView::get(navigate->hwnd);
	if (view != NULL) {
		if (navigate->iType == IEN_NAVIGATE) {
			view->navigate(navigate);
		}
	}
	return 0;
}