summaryrefslogtreecommitdiff
path: root/protocols/Dummy/src/dummy_proto.cpp
blob: 310c450ee11f4e14b37166f192ab4a85713ab359 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
Copyright (c) 2014 Robert Pösel

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 version 2
of the License.

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, see <http://www.gnu.org/licenses/>.
*/

#include "stdafx.h"

void CDummyProto::SendMsgAck(void *param)
{
	MCONTACT hContact = (MCONTACT)param;
	Sleep(100);
	ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)0, (LPARAM)Translate("Dummy protocol is too dumb to send messages."));
}

static int sttCompareProtocols(const CDummyProto *p1, const CDummyProto *p2)
{
	return mir_tstrcmp(p1->m_tszUserName, p2->m_tszUserName);
}

LIST<CDummyProto> dummy_Instances(1, sttCompareProtocols);

CDummyProto::CDummyProto(const char *szModuleName, const TCHAR *ptszUserName) :
	PROTO<CDummyProto>(szModuleName, ptszUserName)
{
	CreateProtoService(PS_CREATEACCMGRUI, &CDummyProto::SvcCreateAccMgrUI);

	uniqueIdText[0] = '\0';
	uniqueIdSetting[0] = '\0';

	dummy_Instances.insert(this);
}

CDummyProto::~CDummyProto()
{
	Netlib_CloseHandle(m_hNetlibUser); m_hNetlibUser = NULL;
	dummy_Instances.remove(this);
}

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

DWORD_PTR CDummyProto::GetCaps(int type, MCONTACT hContact)
{
	switch(type) {
	case PFLAGNUM_1:
		return PF1_IM;

	case PFLAGNUM_2:
		return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;

	case PFLAGNUM_3:
		return 0;

	case PFLAGNUM_4:
		return 0;

	case PFLAGNUM_5:
		return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;

	case PFLAG_MAXLENOFMESSAGE:
		return 0;

	case PFLAG_UNIQUEIDTEXT:
		if (uniqueIdSetting[0] == '\0') {
			ptrA setting(getStringA(DUMMY_ID_TEXT));
			if (setting != NULL)
				strncpy_s(uniqueIdSetting, setting, _TRUNCATE);
		}
		return (DWORD_PTR)uniqueIdSetting;

	case PFLAG_UNIQUEIDSETTING:
		if (uniqueIdText[0] == '\0') {
			ptrA setting(getStringA(DUMMY_ID_SETTING));
			if (setting != NULL)
				strncpy_s(uniqueIdText, setting, _TRUNCATE);
		}
		return (DWORD_PTR)uniqueIdText;
	}
	return 0;
}

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

int CDummyProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
{
	return 1;
}

int CDummyProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
{
	return 0;
}

int CDummyProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
{
	ForkThread(&CDummyProto::SendMsgAck, (void*)hContact);
	return 0;
}

int CDummyProto::SetStatus(int iNewStatus)
{
	return 0;
}

HANDLE CDummyProto::SearchBasic(const PROTOCHAR* id)
{
	return 0;
}

HANDLE CDummyProto::SearchByEmail(const PROTOCHAR* email)
{
	return 0;
}

HANDLE CDummyProto::SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName)
{
	return 0;
}

MCONTACT CDummyProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
	return NULL;
}

int CDummyProto::AuthRequest(MCONTACT hContact,const PROTOCHAR *message)
{
	return 0;
}

int CDummyProto::Authorize(MEVENT hDbEvent)
{
	return 1;
}

int CDummyProto::AuthDeny(MEVENT hDbEvent, const PROTOCHAR *reason)
{
	return 1;
}

int CDummyProto::UserIsTyping(MCONTACT hContact, int type)
{ 
	return 1;
}

MCONTACT CDummyProto::AddToListByEvent(int flags, int iContact, MEVENT hDbEvent)
{
	return NULL;
}

int CDummyProto::AuthRecv(MCONTACT hContact,PROTORECVEVENT *)
{
	return 1;
}

HANDLE CDummyProto::FileAllow(MCONTACT hContact,HANDLE hTransfer,const PROTOCHAR *path)
{
	return NULL;
}

int CDummyProto::FileCancel(MCONTACT hContact,HANDLE hTransfer)
{
	return 1;
}

int CDummyProto::FileDeny(MCONTACT hContact,HANDLE hTransfer,const PROTOCHAR *reason)
{
	return 1;
}

int CDummyProto::FileResume(HANDLE hTransfer,int *action,const PROTOCHAR **filename)
{
	return 1;
}

int CDummyProto::GetInfo(MCONTACT hContact, int infoType)
{
	return 1;
}

HWND CDummyProto::SearchAdvanced(HWND owner)
{
	return NULL;
}

HWND CDummyProto::CreateExtendedSearchUI(HWND owner)
{
	return NULL;
}

int CDummyProto::RecvContacts(MCONTACT hContact,PROTORECVEVENT *)
{
	return 1;
}

int CDummyProto::RecvFile(MCONTACT hContact,PROTORECVFILET *)
{
	return 1;
}

int CDummyProto::RecvUrl(MCONTACT hContact,PROTORECVEVENT *)
{
	return 1;
}

int CDummyProto::SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList)
{
	return 1;
}

HANDLE CDummyProto::SendFile(MCONTACT hContact,const PROTOCHAR *desc, PROTOCHAR **files)
{
	return NULL;
}

int CDummyProto::SendUrl(MCONTACT hContact,int flags,const char *url)
{
	return 1;
}

int CDummyProto::SetApparentMode(MCONTACT hContact,int mode)
{
	return 1;
}

int CDummyProto::RecvAwayMsg(MCONTACT hContact,int mode,PROTORECVEVENT *evt)
{
	return 1;
}

HANDLE CDummyProto::GetAwayMsg(MCONTACT hContact)
{
	return 0;
}

int CDummyProto::SetAwayMsg(int status, const PROTOCHAR *msg)
{
	return 0;
}