void CreateServiceFunctions(void) { CreateServiceFunction_Ex(MS_GC_REGISTER, Service_Register); CreateServiceFunction_Ex(MS_GC_NEWSESSION, Service_NewChat); CreateServiceFunction_Ex(MS_GC_EVENT, Service_AddEvent); CreateServiceFunction_Ex(MS_GC_GETEVENTPTR, Service_GetAddEventPtr); CreateServiceFunction_Ex(MS_GC_GETINFO, Service_GetInfo); CreateServiceFunction_Ex(MS_GC_GETSESSIONCOUNT, Service_GetCount); CreateServiceFunction_Ex("GChat/DblClickEvent", CList_EventDoubleclickedSvc); CreateServiceFunction_Ex("GChat/PrebuildMenuEvent", CList_PrebuildContactMenuSvc); CreateServiceFunction_Ex("GChat/JoinChat", CList_JoinChat); CreateServiceFunction_Ex("GChat/LeaveChat", CList_LeaveChat); }
int __declspec(dllexport) Load(PLUGINLINK *link) { PROTOCOLDESCRIPTOR pd; HANDLE hContact; char s[256]; char text[_MAX_PATH]; char *p, *q; char *szProto; CLISTMENUITEM mi, clmi; DBVARIANT dbv; pluginLink = link; memoryManagerInterface.cbSize = sizeof(struct MM_INTERFACE); CallService(MS_SYSTEM_GET_MMI,0,(LPARAM)&memoryManagerInterface); GetModuleFileName(hInst, text, sizeof(text)); p = strrchr(text, '\\'); p++; q = strrchr(p, '.'); *q = '\0'; jabberProtoName = mir_strdup(p); _strupr(jabberProtoName); jabberModuleName = mir_strdup(jabberProtoName); _strlwr(jabberModuleName); jabberModuleName[0] = toupper(jabberModuleName[0]); JabberLog("Setting protocol/module name to '%s/%s'", jabberProtoName, jabberModuleName); DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0); jabberMainThreadId = GetCurrentThreadId(); //hLibSSL = NULL; // hWndListGcLog = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); TlenRegisterIcons(); TlenLoadOptions(); HookEvent_Ex(ME_OPT_INITIALISE, TlenOptInit); HookEvent_Ex(ME_SYSTEM_MODULESLOADED, ModulesLoaded); HookEvent_Ex(ME_SYSTEM_PRESHUTDOWN, PreShutdown); sprintf(s, "%s/%s", jabberProtoName, "Nudge"); hTlenNudge = CreateHookableEvent(s); // Register protocol module ZeroMemory(&pd, sizeof(PROTOCOLDESCRIPTOR)); pd.cbSize = sizeof(PROTOCOLDESCRIPTOR); pd.szName = jabberProtoName; pd.type = PROTOTYPE_PROTOCOL; CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM) &pd); memset(&mi, 0, sizeof(CLISTMENUITEM)); mi.cbSize = sizeof(CLISTMENUITEM); memset(&clmi, 0, sizeof(CLISTMENUITEM)); clmi.cbSize = sizeof(CLISTMENUITEM); clmi.flags = CMIM_FLAGS | CMIF_GRAYED; mi.pszPopupName = jabberModuleName; mi.popupPosition = 500090000; wsprintf(text, "%s/MainMenuChats", jabberModuleName); CreateServiceFunction_Ex(text, TlenMUCMenuHandleChats); mi.pszName = TranslateT("Tlen Chats"); mi.position = 2000050001; mi.hIcon = tlenIcons[TLEN_IDI_CHATS]; mi.pszService = text; hMenuChats = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hMenuChats, (LPARAM) &clmi); // "Multi-User Conference" wsprintf(text, "%s/MainMenuMUC", jabberModuleName); CreateServiceFunction_Ex(text, TlenMUCMenuHandleMUC); mi.pszName = TranslateT("Multi-User Conference"); mi.position = 2000050002; mi.hIcon = tlenIcons[TLEN_IDI_MUC]; mi.pszService = text; hMenuMUC = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hMenuMUC, (LPARAM) &clmi); wsprintf(text, "%s/MainMenuInbox", jabberModuleName); CreateServiceFunction_Ex(text, TlenMenuHandleInbox); mi.pszName = TranslateT("Tlen Inbox"); mi.position = 2000050003; mi.hIcon = tlenIcons[TLEN_IDI_MAIL]; mi.pszService = text; hMenuInbox = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &mi); // "Invite to MUC" sprintf(text, "%s/ContactMenuMUC", jabberModuleName); CreateServiceFunction_Ex(text, TlenMUCContactMenuHandleMUC); mi.pszName = TranslateT("Multi-User Conference"); mi.position = -2000020000; mi.hIcon = tlenIcons[TLEN_IDI_MUC]; mi.pszService = text; mi.pszContactOwner = jabberProtoName; hMenuContactMUC = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Invite to voice chat" sprintf(text, "%s/ContactMenuVoice", jabberModuleName); CreateServiceFunction_Ex(text, TlenVoiceContactMenuHandleVoice); mi.pszName = TranslateT("Voice Chat"); mi.position = -2000018000; mi.hIcon = tlenIcons[TLEN_IDI_VOICE]; mi.pszService = text; mi.pszContactOwner = jabberProtoName; hMenuContactVoice = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Request authorization" sprintf(text, "%s/RequestAuth", jabberModuleName); CreateServiceFunction_Ex(text, TlenContactMenuHandleRequestAuth); mi.pszName = TranslateT("Request authorization"); mi.position = -2000001001; mi.hIcon = tlenIcons[TLEN_IDI_REQUEST]; mi.pszService = text; mi.pszContactOwner = jabberProtoName; hMenuContactRequestAuth = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Grant authorization" sprintf(text, "%s/GrantAuth", jabberModuleName); CreateServiceFunction_Ex(text, TlenContactMenuHandleGrantAuth); mi.pszName = TranslateT("Grant authorization"); mi.position = -2000001000; mi.hIcon = tlenIcons[TLEN_IDI_GRANT]; mi.pszService = text; mi.pszContactOwner = jabberProtoName; hMenuContactGrantAuth = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Send picture" sprintf(text, "%s/SendPicture", jabberModuleName); CreateServiceFunction_Ex(text, TlenContactMenuHandleSendPicture); mi.pszName = TranslateT("Send picture"); // clmi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE;// | CMIF_GRAYED; mi.position = -2000001002; mi.hIcon = tlenIcons[TLEN_IDI_GRANT]; mi.pszService = text; mi.pszContactOwner = jabberProtoName; //CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); //hMenuContactGrantAuth = (HANDLE) mi.position = -2000020000; mi.flags = CMIF_NOTONLINE; mi.hIcon = LoadSkinnedIcon(SKINICON_EVENT_FILE); mi.pszName = TranslateT("&File"); mi.pszService = MS_FILE_SENDFILE; mi.pszContactOwner = jabberProtoName; hMenuContactFile = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); HookEvent_Ex(ME_CLIST_PREBUILDCONTACTMENU, TlenPrebuildContactMenu); if (!DBGetContactSetting(NULL, jabberProtoName, "LoginServer", &dbv)) { DBFreeVariant(&dbv); } else { DBWriteContactSettingString(NULL, jabberProtoName, "LoginServer", "tlen.pl"); } if (!DBGetContactSetting(NULL, jabberProtoName, "ManualHost", &dbv)) { DBFreeVariant(&dbv); } else { DBWriteContactSettingString(NULL, jabberProtoName, "ManualHost", "s1.tlen.pl"); } // Set all contacts to offline hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact != NULL) { szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if(szProto!=NULL && !strcmp(szProto, jabberProtoName)) { if (DBGetContactSettingWord(hContact, jabberProtoName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { DBWriteContactSettingWord(hContact, jabberProtoName, "Status", ID_STATUS_OFFLINE); } } hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); } streamId = NULL; jabberThreadInfo = NULL; jabberConnected = FALSE; jabberOnline = FALSE; jabberStatus = ID_STATUS_OFFLINE; memset((char *) &modeMsgs, 0, sizeof(JABBER_MODEMSGS)); //jabberModeMsg = NULL; jabberCodePage = CP_ACP; InitializeCriticalSection(&mutex); InitializeCriticalSection(&modeMsgMutex); srand((unsigned) time(NULL)); JabberSerialInit(); JabberIqInit(); JabberListInit(); JabberSvcInit(); return 0; }
static void initMenuItems(TlenProtocol *proto) { char text[_MAX_PATH]; CLISTMENUITEM mi, clmi; memset(&mi, 0, sizeof(CLISTMENUITEM)); mi.cbSize = sizeof(CLISTMENUITEM); memset(&clmi, 0, sizeof(CLISTMENUITEM)); clmi.cbSize = sizeof(CLISTMENUITEM); clmi.flags = CMIM_FLAGS | CMIF_GRAYED; mi.pszContactOwner = proto->iface.m_szModuleName; mi.popupPosition = 500090000; strcpy(text, proto->iface.m_szModuleName); mi.pszService = text; mi.ptszName = proto->iface.m_tszUserName; mi.position = -1999901009; mi.pszPopupName = (char *)-1; mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_ICONFROMICOLIB; mi.icolibItem = GetIconHandle(IDI_TLEN); proto->hMenuRoot = (HANDLE)CallService( MS_CLIST_ADDMAINMENUITEM, (WPARAM)0, (LPARAM)&mi); mi.flags = CMIF_CHILDPOPUP | CMIF_ICONFROMICOLIB; //mi.pszPopupName = (char *)proto->hMenuRoot; mi.hParentMenu = (HGENMENU)proto->hMenuRoot; proto->hMenuChats = NULL; if(ServiceExists(MS_MUCC_NEW_WINDOW)) { sprintf(text, "%s/MainMenuChats", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenMUCMenuHandleChats); mi.pszName = "Tlen Chats"; mi.position = 2000050001; mi.icolibItem = GetIconHandle(IDI_CHATS); mi.pszService = text; proto->hMenuChats = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) proto->hMenuChats, (LPARAM) &clmi); } // "Multi-User Conference" sprintf(text, "%s/MainMenuMUC", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenMUCMenuHandleMUC); mi.pszName = "Multi-User Conference"; mi.position = 2000050002; mi.icolibItem = GetIconHandle(IDI_MUC); mi.pszService = text; proto->hMenuMUC = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &mi); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) proto->hMenuMUC, (LPARAM) &clmi); sprintf(text, "%s/MainMenuInbox", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenMenuHandleInbox); mi.pszName = "Tlen Mail"; mi.position = 2000050003; mi.icolibItem = GetIconHandle(IDI_MAIL); mi.pszService = text; proto->hMenuInbox = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &mi); mi.hParentMenu = NULL; // "Send picture" sprintf(text, "%s/SendPicture", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenContactMenuHandleSendPicture); mi.flags = CMIF_ICONFROMICOLIB; mi.pszName = "Send picture"; mi.position = -2000019030; mi.icolibItem = GetIconHandle(IDI_IMAGE); mi.pszService = text; proto->hMenuPicture = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Invite to MUC" sprintf(text, "%s/ContactMenuMUC", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenMUCContactMenuHandleMUC); mi.pszName = "Multi-User Conference"; mi.position = -2000019020; mi.icolibItem = GetIconHandle(IDI_MUC); mi.pszService = text; proto->hMenuContactMUC = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Invite to voice chat" sprintf(text, "%s/ContactMenuVoice", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenVoiceContactMenuHandleVoice); mi.pszName = "Voice Chat"; mi.position = -2000019010; mi.icolibItem = GetIconHandle(IDI_VOICE); mi.pszService = text; proto->hMenuContactVoice = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Request authorization" sprintf(text, "%s/RequestAuth", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenContactMenuHandleRequestAuth); mi.pszName = "Request authorization"; mi.position = -2000001001; mi.icolibItem = GetIconHandle(IDI_REQUEST); mi.pszService = text; proto->hMenuContactRequestAuth = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); // "Grant authorization" sprintf(text, "%s/GrantAuth", proto->iface.m_szModuleName); CreateServiceFunction_Ex(text, proto, TlenContactMenuHandleGrantAuth); mi.pszName = "Grant authorization"; mi.position = -2000001000; mi.icolibItem = GetIconHandle(IDI_GRANT); mi.pszService = text; proto->hMenuContactGrantAuth = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi); }