summaryrefslogtreecommitdiff
path: root/Nudge/nudge.cpp
blob: 9455ec69b3c16774bb6e96ef6f7be689230fe3e6 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "headers.h"
#include "nudge.h"

void CNudge::Save(void)
{
	char SectionName[512];
	mir_snprintf(SectionName,512,"useByProtocol"); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->useByProtocol);
	mir_snprintf(SectionName,512,"RecvTimeSec");
	DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->recvTimeSec);
	mir_snprintf(SectionName,512,"SendTimeSec");
	DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->sendTimeSec);
	mir_snprintf(SectionName,512,"ResendDelaySec");
	DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->resendDelaySec);
}


void CNudge::Load(void)
{
	char SectionName[512];
	mir_snprintf(SectionName,512,"useByProtocol"); 
	this->useByProtocol = DBGetContactSettingByte(NULL, "Nudge", SectionName, FALSE) != 0;
	mir_snprintf(SectionName,512,"RecvTimeSec");
	this->recvTimeSec = DBGetContactSettingDword(NULL, "Nudge", SectionName, 30);
	mir_snprintf(SectionName,512,"SendTimeSec");
	this->sendTimeSec = DBGetContactSettingDword(NULL, "Nudge", SectionName, 30);
	mir_snprintf(SectionName,512,"ResendDelaySec");
	this->resendDelaySec = DBGetContactSettingDword(NULL, "Nudge", SectionName, 3);
}

int CNudgeElement::ShowContactMenu(bool show)
{

	CLISTMENUITEM mi;
	memset( &mi, 0, sizeof( mi ));
	mi.cbSize = sizeof( mi );
	mi.flags =  show? CMIM_FLAGS : CMIM_FLAGS | CMIF_HIDDEN ;
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenu, (LPARAM)&mi);

	return 0;
}

void CNudgeElement::Save(void)
{
	char SectionName[512];
	mir_snprintf(SectionName,512,"%s-popupBackColor", ProtocolName);
	DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->popupBackColor);
	mir_snprintf(SectionName,512,"%s-popupTextColor", ProtocolName); 
	DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->popupTextColor);
	mir_snprintf(SectionName,512,"%s-popupTimeSec", ProtocolName);
	DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->popupTimeSec);
	mir_snprintf(SectionName,512,"%s-popupWindowColor", ProtocolName);
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->popupWindowColor);
	mir_snprintf(SectionName,512,"%s-showEvent", ProtocolName); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->showEvent); 
	mir_snprintf(SectionName,512,"%s-showStatus", ProtocolName); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->showStatus); 
	mir_snprintf(SectionName,512,"%s-showPopup", ProtocolName); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->showPopup); 
	mir_snprintf(SectionName,512,"%s-shakeClist", ProtocolName); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->shakeClist); 
	mir_snprintf(SectionName,512,"%s-shakeChat", ProtocolName); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->shakeChat); 
	mir_snprintf(SectionName,512,"%s-enabled", ProtocolName); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->enabled);
	mir_snprintf(SectionName,512,"%s-autoResend", ProtocolName); 
	DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->autoResend);
	mir_snprintf(SectionName,512,"%s-statusFlags", ProtocolName);
	DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->statusFlags);
	mir_snprintf(SectionName,512,"%s-recText", ProtocolName);
	if(DBWriteContactSettingTString(NULL, "Nudge", SectionName, this->recText)) {
		#if defined( _UNICODE )
			char buff[TEXT_LEN];
			WideCharToMultiByte(code_page, 0, this->recText, -1, buff, TEXT_LEN, 0, 0);
			buff[TEXT_LEN] = 0;
			DBWriteContactSettingString(0, "Nudge", SectionName, buff);
		#endif
	}
	mir_snprintf(SectionName,512,"%s-senText", ProtocolName);
	if(DBWriteContactSettingTString(NULL, "Nudge", SectionName, this->senText)) {
		#if defined( _UNICODE )
			char buff[TEXT_LEN];
			WideCharToMultiByte(code_page, 0, this->senText, -1, buff, TEXT_LEN, 0, 0);
			buff[TEXT_LEN] = 0;
			DBWriteContactSettingString(0, "Nudge", SectionName, buff);
		#endif
	}
}


void CNudgeElement::Load(void)
{
	DBVARIANT dbv;
	char SectionName[512];
	mir_snprintf(SectionName,512,"%s-popupBackColor", ProtocolName);
	this->popupBackColor = DBGetContactSettingDword(NULL, "Nudge", SectionName, GetSysColor(COLOR_BTNFACE));
	mir_snprintf(SectionName,512,"%s-popupTextColor", ProtocolName); 
	this->popupTextColor = DBGetContactSettingDword(NULL, "Nudge", SectionName, GetSysColor(COLOR_WINDOWTEXT));
	mir_snprintf(SectionName,512,"%s-popupTimeSec", ProtocolName);
	this->popupTimeSec = DBGetContactSettingDword(NULL, "Nudge", SectionName, 4);
	mir_snprintf(SectionName,512,"%s-popupWindowColor", ProtocolName);
	this->popupWindowColor = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
	mir_snprintf(SectionName,512,"%s-showEvent", ProtocolName); 
	this->showEvent = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0; 
	mir_snprintf(SectionName,512,"%s-showStatus", ProtocolName); 
	this->showStatus = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0; 
	mir_snprintf(SectionName,512,"%s-showPopup", ProtocolName); 
	this->showPopup = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0; 
	mir_snprintf(SectionName,512,"%s-shakeClist", ProtocolName); 
	this->shakeClist = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;  
	mir_snprintf(SectionName,512,"%s-shakeChat", ProtocolName); 
	this->shakeChat = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0; 
	mir_snprintf(SectionName,512,"%s-enabled", ProtocolName); 
	this->enabled = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
	mir_snprintf(SectionName,512,"%s-autoResend", ProtocolName); 
	this->autoResend = DBGetContactSettingByte(NULL, "Nudge", SectionName, FALSE) != 0;
	mir_snprintf(SectionName,512,"%s-statusFlags", ProtocolName);
	this->statusFlags = DBGetContactSettingDword(NULL, "Nudge", SectionName, 967);
	mir_snprintf(SectionName,512,"%s-recText", ProtocolName);
	if(!DBGetContactSettingTString(NULL,"Nudge",SectionName,&dbv)) 
	{
		_tcsncpy(this->recText,dbv.ptszVal,TEXT_LEN);
		if(_tcsclen(this->recText) < 1)
			_tcsncpy(this->recText,TranslateT("You received a nudge"),TEXT_LEN);
		DBFreeVariant(&dbv);
	}
	mir_snprintf(SectionName,512,"%s-senText", ProtocolName);
	if(!DBGetContactSettingTString(NULL,"Nudge",SectionName,&dbv)) 
	{
		_tcsncpy(this->senText,dbv.ptszVal,TEXT_LEN);
		if(_tcsclen(this->senText) < 1)
			_tcsncpy(this->senText,TranslateT("You sent a nudge"),TEXT_LEN);
		DBFreeVariant(&dbv);
	}
}