summaryrefslogtreecommitdiff
path: root/MySpace/proto.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MySpace/proto.cpp')
-rw-r--r--MySpace/proto.cpp153
1 files changed, 153 insertions, 0 deletions
diff --git a/MySpace/proto.cpp b/MySpace/proto.cpp
new file mode 100644
index 0000000..4b3aa00
--- /dev/null
+++ b/MySpace/proto.cpp
@@ -0,0 +1,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]);
+} \ No newline at end of file