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
|
#include "common.h"
#include "proto.h"
#include "server_con.h"
#include "resource.h"
#define MAX_MESSAGE_SIZE 1024
int GetCaps(WPARAM wParam,LPARAM lParam) {
int ret = 0;
switch (wParam) {
case PFLAGNUM_1:
//ret = PF1_IM | PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_MODEMSG | PF1_FILE | PF1_CHAT;
ret = PF1_IM;// | PF1_BASICSEARCH | PF1_EXTSEARCHUI | PF1_ADDSEARCHRES | PF1_MODEMSG | PF1_FILE | PF1_CHAT;
break;
case PFLAGNUM_2:
ret = PF2_ONLINE;// | PF2_SHORTAWAY | PF2_HEAVYDND;
break;
case PFLAGNUM_3:
//ret = PF2_ONLINE;// | PF2_SHORTAWAY | PF2_HEAVYDND;
break;
case PFLAGNUM_4:
//ret = PF4_SUPPORTTYPING;
break;
case PFLAG_UNIQUEIDTEXT:
ret = (int) Translate("UserID");
break;
case PFLAG_MAXLENOFMESSAGE:
ret = MAX_MESSAGE_SIZE;
break;
case PFLAG_UNIQUEIDSETTING:
ret = (int) "UID";
break;
}
return ret;
}
int GetName(WPARAM wParam,LPARAM lParam) {
mir_snprintf((char *)lParam, wParam, "%s", MODULE);
return 0;
}
int LoadIcon(WPARAM wParam,LPARAM lParam) {
UINT id;
switch (wParam & 0xFFFF)
{
case PLI_PROTOCOL:
id = IDI_ICON_PROTO;
break;
case PLI_ONLINE:
id = IDI_ICON_PROTO;
break;
case PLI_OFFLINE:
id = IDI_ICON_PROTO;
break;
default:
return (int) (HICON) NULL;
}
return (int) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON,
GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON),
GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
return 0;
}
int GetInfo(WPARAM wParam,LPARAM lParam) {
return 0;
}
int SetStatus(WPARAM wParam,LPARAM lParam) {
if(wParam != ID_STATUS_OFFLINE)
InitServerConnection();
else
DeinitServerConnection();
return 0;
}
int GetStatus(WPARAM wParam,LPARAM lParam) {
return status;
}
int ProtoSendMessage(WPARAM wParam, LPARAM lParam) {
CCSDATA *ccs = (CCSDATA *) lParam;
char *message = (char *)ccs->lParam;
// TODO: process 'message' and/or 'messagew' below
if(ccs->wParam & PREF_UNICODE) {
wchar_t *messagew = (wchar_t *)&message[strlen(message)+1];
} else if(ccs->wParam & PREF_UTF) {
// message is utf8 encoded - you can use mir_utf8decode (m_system.h) to make it wide
} else {
}
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
int ProtoSendMessageW(WPARAM wParam, LPARAM lParam) {
CCSDATA *ccs = (CCSDATA *) lParam;
ccs->wParam |= PREF_UNICODE;
return ProtoSendMessage(wParam, lParam);
}
int ProtoRecvMessage(WPARAM wParam, LPARAM lParam) {
CCSDATA *ccs = (CCSDATA *) lParam;
PROTORECVEVENT *pre = (PROTORECVEVENT *) ccs->lParam;
char *message = pre->szMessage;
// TODO: process 'message' and/or 'messagew' below
if(pre->flags & PREF_UNICODE) {
wchar_t *messagew = (wchar_t *)&message[strlen(message)+1];
} else if(pre->flags & PREF_UTF) {
// message is utf8 encoded - you can use mir_utf8decode (m_system.h) to make it wide
}
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
}
void RegisterProto() {
PROTOCOLDESCRIPTOR pd = {0};
pd.cbSize = sizeof(pd);
pd.szName = MODULE;
pd.type = PROTOTYPE_PROTOCOL;
CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
}
#define NUM_FILTER_SERVICES 9
HANDLE hServices[NUM_FILTER_SERVICES];
void CreateProtoServices() {
// create our services
int i = 0;
hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_MESSAGE, ProtoSendMessage);
hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_MESSAGE"W", ProtoSendMessageW);
hServices[i++] = CreateProtoServiceFunction(MODULE, PSR_MESSAGE, ProtoRecvMessage);
hServices[i++] = CreateProtoServiceFunction(MODULE, PS_GETCAPS, GetCaps);
hServices[i++] = CreateProtoServiceFunction(MODULE, PS_GETNAME, GetName);
hServices[i++] = CreateProtoServiceFunction(MODULE, PS_LOADICON,LoadIcon);
hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_GETINFO,GetInfo);
hServices[i++] = CreateProtoServiceFunction(MODULE, PS_SETSTATUS, SetStatus);
hServices[i++] = CreateProtoServiceFunction(MODULE, PS_GETSTATUS, GetStatus);
// remember to modify the NUM_FILTER_SERVICES #define above if you add more services!
}
void DeinitProto() {
for(int i = 0; i < NUM_FILTER_SERVICES; i++)
DestroyServiceFunction(hServices[i]);
}
|