summaryrefslogtreecommitdiff
path: root/plugins/DbeditorPP/modsettingenum.cpp
blob: 7eaecdd1a0636c03b1e685c5aea3021bada75b23 (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
#include "headers.h"

void FreeModuleSettingLL(ModuleSettingLL* msll)
{
    if (msll)
    {

		struct ModSetLinkLinkItem *item = msll->first;
		struct ModSetLinkLinkItem *temp;

		while (item)
		{
			mir_free(item->name);
			temp = item;
			item = (struct ModSetLinkLinkItem *)item->next;
			mir_free(temp);
		}

		msll->first = 0;
		msll->last = 0;
	}
}

int enumModulesSettingsProc( const char *szName , DWORD ofsModuleName , LPARAM lParam)
{
	ModuleSettingLL *msll = (ModuleSettingLL *)lParam;
	if (!msll->first)
	{
		msll->first = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem));
		if (!msll->first) return 1;
		msll->first->name = mir_tstrdup(szName);
		msll->first->next = 0;
		msll->last = msll->first;
	}
	else
	{
		struct ModSetLinkLinkItem *item = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem));
		if (!item) return 1;
		msll->last->next = (BYTE*)item;
		msll->last = (struct ModSetLinkLinkItem *)item;
		item->name = mir_tstrdup(szName);
		item->next = 0;
	}
	return 0;
}

int EnumModules(ModuleSettingLL *msll) // 1 = success, 0 = fail
{
	msll->first = 0;
	msll->last = 0;
	return !CallService(MS_DB_MODULES_ENUM, (WPARAM)msll,(WPARAM)enumModulesSettingsProc);
}


int enumSettingsProc(const char *szSetting,LPARAM lParam)
{
	return enumModulesSettingsProc(szSetting,0,lParam);
}


int EnumSettings(HANDLE hContact, char* module, ModuleSettingLL *msll)
{
	DBCONTACTENUMSETTINGS dbces;
	// enum all setting the contact has for the module
	dbces.pfnEnumProc = enumSettingsProc;
	dbces.szModule = module;
	dbces.lParam = (LPARAM)msll;
	msll->first = 0;
	msll->last = 0;
	return !CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact,(LPARAM)&dbces);
}

int CheckIfModuleIsEmptyProc(const char *szSetting,LPARAM lParam)
{
	return 1;
}

int IsModuleEmpty(HANDLE hContact, char* szModule)
{
	DBCONTACTENUMSETTINGS dbces;
	int retVal;
	dbces.pfnEnumProc = CheckIfModuleIsEmptyProc;
	dbces.szModule = szModule;
	retVal = CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact,(LPARAM)&dbces);
	if (retVal >= 0)
		return 0;
	else return 1;
}