summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_settings.cpp
blob: 188274ae3c62e9db7ac3a46620bbe8f43ead421d (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
118
119
120
121
#include "skype_proto.h"

BYTE CSkypeProto::GetSettingByte(HANDLE hContact, const char *setting, BYTE errorValue)
{
	return ::DBGetContactSettingByte(hContact, this->m_szModuleName, setting, errorValue);
}

BYTE CSkypeProto::GetSettingByte(const char *setting, BYTE errorValue)
{
	return this->GetSettingByte(NULL, setting, errorValue);
}

WORD CSkypeProto::GetSettingWord(HANDLE hContact, const char *setting, WORD errorValue)
{
	return ::DBGetContactSettingWord(hContact, this->m_szModuleName, setting, errorValue);
}

WORD CSkypeProto::GetSettingWord(const char *setting, WORD errorValue)
{
	return this->GetSettingWord(NULL, setting, errorValue);
}

DWORD CSkypeProto::GetSettingDword(HANDLE hContact, const char *setting, DWORD errorValue)
{
	return ::DBGetContactSettingDword(hContact, this->m_szModuleName, setting, errorValue);
}

DWORD CSkypeProto::GetSettingDword(const char *setting, DWORD errorValue)
{
	return this->GetSettingDword(NULL, setting, errorValue);
}

TCHAR* CSkypeProto::GetSettingString(HANDLE hContact, const char *setting, TCHAR* errorValue)
{
	DBVARIANT dbv;
	TCHAR* result = NULL;

	if ( !::DBGetContactSettingWString(hContact, this->m_szModuleName, setting, &dbv))
	{
		result = mir_wstrdup(dbv.pwszVal);
		DBFreeVariant(&dbv);
	}

	return result != NULL ? result : errorValue;
}

TCHAR* CSkypeProto::GetSettingString(const char *setting, TCHAR* errorValue)
{
	return this->GetSettingString(NULL, setting, errorValue);
}

TCHAR* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *setting, TCHAR* errorValue)
{
	TCHAR* result = this->GetSettingString(hContact, setting, errorValue);

	CallService(
		MS_DB_CRYPT_DECODESTRING,
		wcslen(result) + 1,
		reinterpret_cast<LPARAM>(result));

	return result;
}

TCHAR* CSkypeProto::GetDecodeSettingString(const char *setting, TCHAR* errorValue)
{
	return this->GetDecodeSettingString(NULL, setting, errorValue);
}


bool CSkypeProto::SetSettingByte(HANDLE hContact, const char *setting, BYTE value)
{
	return !::DBWriteContactSettingByte(hContact, this->m_szModuleName, setting, value);
}

bool CSkypeProto::SetSettingByte(const char *setting, BYTE errorValue)
{
	return this->SetSettingByte(NULL, setting, errorValue);
}

bool CSkypeProto::SetSettingWord(HANDLE hContact, const char *setting, WORD value)
{
	return !::DBWriteContactSettingWord(hContact, this->m_szModuleName, setting, value);
}

bool CSkypeProto::SetSettingWord(const char *setting, WORD value)
{
	return this->SetSettingWord(NULL, setting, value);
}

bool CSkypeProto::SetSettingDword(HANDLE hContact, const char *setting, DWORD value)
{
	return !::DBWriteContactSettingDword(hContact, this->m_szModuleName, setting, value);
}

bool CSkypeProto::SetSettingDword(const char *setting, DWORD value)
{
	return this->SetSettingDword(NULL, setting, value);
}

bool CSkypeProto::SetSettingString(HANDLE hContact, const char *szSetting, TCHAR* value)
{
	return !::DBWriteContactSettingWString(hContact, this->m_szModuleName, szSetting, value);
}

bool CSkypeProto::SetSettingString(const char *szSetting, TCHAR* value)
{
	return this->SetSettingString(NULL, szSetting, value);
}

bool CSkypeProto::SetDecodeSettingString(HANDLE hContact, const char *setting, TCHAR* value)
{
	TCHAR* result = mir_wstrdup(value);
	CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(result), reinterpret_cast<LPARAM>(result));
	
	return !this->SetSettingString(hContact, setting, result);
}

bool CSkypeProto::SetDecodeSettingString(const char *setting, TCHAR* value)
{
	return this->SetDecodeSettingString(NULL, setting, value);
}