summaryrefslogtreecommitdiff
path: root/plugins/VoiceService/src/services.cpp
blob: 410cb0f171497a6edfdc3b61956d22569ff77554 (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
/*
Copyright (C) 2006 Ricardo Pescuma Domenecci

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

This 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
Library General Public License for more details.

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

#include "stdafx.h"

/////////////////////////////////////////////////////////////////////////////////////////

static INT_PTR CListDblClick(WPARAM, LPARAM lParam)
{
	CLISTEVENT *ce = (CLISTEVENT *)lParam;

	auto *call = (VoiceCall *)ce->lParam;
	call->Show(SW_SHOWNORMAL);
	return 0;
}

/////////////////////////////////////////////////////////////////////////////////////////

INT_PTR VoiceRegister(WPARAM wParam, LPARAM)
{
	VOICE_MODULE *in = (VOICE_MODULE *)wParam;
	if (in == NULL || in->cbSize < sizeof(VOICE_MODULE) || in->name == NULL || in->description == NULL)
		return -1;

	if (FindModule(in->name) != NULL)
		return -2;

	if (!ProtoServiceExists(in->name, PS_VOICE_CALL)
		|| !ProtoServiceExists(in->name, PS_VOICE_ANSWERCALL)
		|| !ProtoServiceExists(in->name, PS_VOICE_DROPCALL))
		return -3;

	modules.insert(new VoiceProvider(in->name, in->description, in->flags, in->icon));
	return 0;
}

INT_PTR VoiceUnregister(WPARAM wParam, LPARAM)
{
	char *moduleName = (char *)wParam;
	if (moduleName == NULL || moduleName[0] == 0)
		return -1;

	VoiceProvider *module = FindModule(moduleName);
	if (module == NULL)
		return -2;

	for (auto &call: calls.rev_iter())
		if (call->module == module) {
			call->Drop();
			call->SetState(VOICE_STATE_ENDED);

			calls.remove(calls.indexOf(&call));
		}

	modules.remove(module);
	return 0;
}

/////////////////////////////////////////////////////////////////////////////////////////

void CreateServices()
{
	CreateServiceFunction(MS_VOICESERVICE_CLIST_DBLCLK, CListDblClick);
	CreateServiceFunction(MS_VOICESERVICE_REGISTER, VoiceRegister);
	CreateServiceFunction(MS_VOICESERVICE_UNREGISTER, VoiceUnregister);
}