From a78e345c8eb7d73233e61900edaeacb34aa17bad Mon Sep 17 00:00:00 2001 From: Mataes Date: Sat, 31 Mar 2018 19:11:08 +0300 Subject: AssocMgr: removed not used files and functions --- plugins/AssocMgr/src/assoclist.cpp | 6 +- plugins/AssocMgr/src/main.cpp | 2 - plugins/AssocMgr/src/stdafx.h | 3 - plugins/AssocMgr/src/test.cpp | 715 ----------------------------------- plugins/AssocMgr/src/test.h | 26 -- plugins/ExternalAPI/m_assocmgr.h | 226 +++++------ plugins/PluginUpdater/src/Events.cpp | 2 +- 7 files changed, 89 insertions(+), 891 deletions(-) delete mode 100644 plugins/AssocMgr/src/test.cpp delete mode 100644 plugins/AssocMgr/src/test.h (limited to 'plugins') diff --git a/plugins/AssocMgr/src/assoclist.cpp b/plugins/AssocMgr/src/assoclist.cpp index 1a153b144e..8a8bd298fc 100644 --- a/plugins/AssocMgr/src/assoclist.cpp +++ b/plugins/AssocMgr/src/assoclist.cpp @@ -484,7 +484,7 @@ static INT_PTR ServiceAddNewFileType(WPARAM, LPARAM lParam) char *pszFileExt = mir_strdup(ftd->pszFileExt); char *pszClassName = MakeFileClassName(ftd->pszFileExt); if (pszFileExt != nullptr && pszClassName != nullptr) { - wchar_t *pszVerbDesc = s2t(ftd->ptszVerbDesc, ftd->flags&FTDF_UNICODE, TRUE); // does NULL check + wchar_t *pszVerbDesc = s2t(ftd->pwszVerbDesc, ftd->flags&FTDF_UNICODE, TRUE); // does NULL check char *pszMimeType = mir_strdup(ftd->pszMimeType); // does NULL check if (AddNewAssocItem_Worker(pszClassName, (TYPEDESCHEAD*)ftd, pszFileExt, pszVerbDesc, pszMimeType)) // no need to free pszClassName, pszFileExt, pszVerbDesc and pszMimeType, @@ -981,9 +981,9 @@ void InitAssocList(void) ftd.pwszDescription = TranslateT("Miranda NG database"); ftd.hInstance = hInst; ftd.nIconResID = IDI_MIRANDAFILE; - ftd.ptszVerbDesc = nullptr; + ftd.pwszVerbDesc = nullptr; ftd.pszService = nullptr; - ftd.flags = FTDF_DEFAULTDISABLED | FTDF_TCHAR; + ftd.flags = FTDF_DEFAULTDISABLED | FTDF_UNICODE; ServiceAddNewFileType(0, (LPARAM)&ftd); } } diff --git a/plugins/AssocMgr/src/main.cpp b/plugins/AssocMgr/src/main.cpp index a5287b7a4c..7412c4e775 100644 --- a/plugins/AssocMgr/src/main.cpp +++ b/plugins/AssocMgr/src/main.cpp @@ -50,7 +50,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) static int AssocMgrModulesLoaded(WPARAM,LPARAM) { - InitTest(); return 0; } @@ -72,7 +71,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void) { - UninitTest(); UninitDde(); UninitAssocList(); UnhookEvent(hHookModulesLoaded); diff --git a/plugins/AssocMgr/src/stdafx.h b/plugins/AssocMgr/src/stdafx.h index 40a5aa624c..1150cf95ed 100644 --- a/plugins/AssocMgr/src/stdafx.h +++ b/plugins/AssocMgr/src/stdafx.h @@ -36,14 +36,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "win2k.h" -#define ASSOCMGR_NOHELPERFUNCTIONS - #include "m_assocmgr.h" #include "utils.h" #include "reg.h" #include "assoclist.h" #include "dde.h" -#include "test.h" #include "resource.h" #include "version.h" diff --git a/plugins/AssocMgr/src/test.cpp b/plugins/AssocMgr/src/test.cpp deleted file mode 100644 index cce177b15f..0000000000 --- a/plugins/AssocMgr/src/test.cpp +++ /dev/null @@ -1,715 +0,0 @@ -/* - -'File Association Manager'-Plugin for Miranda IM - -Copyright (C) 2005-2007 H. Herkenrath - -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; either version 2 -of the License, or (at your option) any later version. - -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 (AssocMgr-License.txt); if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// -- Includes -#include "stdafx.h" - -/* -#define ICQ_SUPPORT_TEST -#define YAHOO_SUPPORT_TEST -#define MSN_SUPPORT_TEST -#define GG_SUPPORT_TEST -#define JABBER_SUPPORT_TEST -*/ - -// ----------------------------------------- - -extern HINSTANCE hInst; - -/* a copy of those in m_assocmgr.h, as we did not #include those helpers */ -__inline static int AssocMgr_AddNewFileTypeT(const char *ext, const char *mime, const wchar_t *desc, const wchar_t *verb, HINSTANCE hinst, UINT iconid, const char *service, DWORD flags) -{ - FILETYPEDESC ftd; - ftd.cbSize = sizeof(FILETYPEDESC); - ftd.pszFileExt = ext; - ftd.pszMimeType = mime; - ftd.pwszDescription = desc; - ftd.hInstance = hinst; - ftd.nIconResID = iconid; - ftd.ptszVerbDesc = verb; - ftd.pszService = service; - ftd.flags = flags | FTDF_TCHAR; - return CallService(MS_ASSOCMGR_ADDNEWFILETYPE, 0, (LPARAM)&ftd); -} - -static int __inline AssocMgr_AddNewUrlType(const char *prefix, const char *desc, HINSTANCE hinst, UINT iconid, const char *service, DWORD flags) -{ - URLTYPEDESC utd; - utd.cbSize = sizeof(URLTYPEDESC); - utd.pszProtoPrefix = prefix; - utd.pszDescription = desc; - utd.hInstance = hinst; - utd.nIconResID = iconid; - utd.pszService = service; - utd.flags = flags&~UTDF_UNICODE; - return CallService(MS_ASSOCMGR_ADDNEWURLTYPE, 0, (LPARAM)&utd); -} - -// ----------------------------------------- - -#ifdef ICQ_SUPPORT_TEST - -#define gpszICQProtoName "ICQ" -#define IDI_ICQ 101 -#define hInst GetModuleHandleA("ICQ") -static __inline HANDLE HContactFromUIN(DWORD dwUIN, int *Added) { dwUIN; Added; return db_find_first(); } -static __inline HANDLE ICQFindFirstContact(void) { return NULL; } -static __inline HANDLE ICQFindNextContact(MCONTACT hContact) { hContact; return NULL; } -static __inline void AddToCache(MCONTACT hContact, DWORD dwUin) { hContact; dwUin; } -static __inline DWORD ICQGetContactSettingUIN(MCONTACT hContact) { hContact; return 0; } -static __inline HANDLE HandleFromCacheByUin(DWORD dwUin) { dwUin; return NULL; } -#include -#include -typedef struct -{ - PROTOSEARCHRESULT hdr; - DWORD uin; - BYTE auth; - char* uid; -} ICQSEARCHRESULT; - -#include "m_assocmgr.h" -static HANDLE hHookModulesLoaded; -static HANDLE hServiceOpenFile; - -static void TrimString(char *str) -{ - int len, start; - len = mir_strlen(str); - while (str[0] != '\0' && (unsigned char)str[len - 1] <= ' ') str[--len] = 0; - for (start = 0; str[start] && (unsigned char)str[start] <= ' '; ++start); - memmove(str, str + start, len - start + 1); -} - -static BOOL IsEmpty(const char *str) -{ - int i; - for (i = 0; str[i] != '\0'; i++) - if (str[i] != ' ' && str[i] != '\r' && str[i] != '\n') - return FALSE; - return TRUE; -} - -#define ICQFILE_MESSAGEUSER 1 -#define ICQFILE_ADDUSER 2 -typedef struct -{ - int type; - char uin[64]; - char email[128]; - char nick[128]; - char firstName[64]; - char lastName[64]; -} ICQFILEINFO; - -static HANDLE IsHContactFromUIN(DWORD uin) -{ - MCONTACT hContact; - DWORD dwUin; - hContact = HandleFromCacheByUin(uin); - if (hContact != NULL) return hContact; - hContact = ICQFindFirstContact(); - while (hContact != NULL) { - dwUin = ICQGetContactSettingUIN(hContact); - if (dwUin == uin) { - AddToCache(hContact, dwUin); - return hContact; - } - hContact = ICQFindNextContact(hContact); - } - return NULL; -} - -static void AddIcqUser(ICQFILEINFO *info) -{ - ADDCONTACTSTRUCT acs; - ICQSEARCHRESULT psr; - DWORD uin; - /* check that uin does not belong to current user */ - uin = atoi(info->uin); - if (uin != 0 && uin != ICQGetContactSettingUIN(NULL)) { - /* not yet present? */ - if (IsHContactFromUIN(uin) == NULL) { - acs.handleType = HANDLE_SEARCHRESULT; - acs.szProto = gpszICQProtoName; - acs.psr = (PROTOSEARCHRESULT*)&psr; - memset(&psr, 0, sizeof(ICQSEARCHRESULT)); - psr.hdr.cbSize = sizeof(ICQSEARCHRESULT); - if (info->nick[0]) psr.hdr.nick = info->nick; - else psr.hdr.nick = info->uin; - if (info->email[0]) psr.hdr.email = info->email; - if (info->firstName[0]) psr.hdr.firstName = info->firstName; - if (info->lastName[0]) psr.hdr.lastName = info->lastName; - psr.uin = uin; - psr.auth = 1; /* authentication needed flag */ - psr.uid = NULL; /* icq contact */ - CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); - } - } -} - -static void MessageIcqUser(ICQFILEINFO *info) -{ - MCONTACT hContact; - if (ServiceExists(MS_MSG_SENDMESSAGE)) { - hContact = HContactFromUIN(atoi(info->uin), NULL); /* adds the contact if needed */ - if (hContact != NULL) - CallService(MS_MSG_SENDMESSAGE, hContact, 0); - } -} - -static int IcqOpenFile(WPARAM wParam, LPARAM lParam) -{ - wchar_t *pszFile = (wchar_t*)lParam; /* wchar_t is specified on AssocMgr_AddNewFileTypeT() */ - FILE *fp; - ICQFILEINFO info; - char line[4096], *sep; - UNREFERENCED_PARAMETER(wParam); - /* - send message: - [ICQ Message User] - UIN=1234567 - - add user: - (all the .uin files I've seen only have UIN= in them) - [ICQ User] - UIN=1234567 - Email= - NickName= - FirstName= - LastName= - */ - if (pszFile == NULL) return 1; /* sanity check */ - fp = _wfopen(pszFile, L"rt"); - if (fp == NULL) return 1; /* open failed */ - info.type = 0; - while (!feof(fp)) { - if (fgets(line, sizeof(line), fp) == NULL) break; - TrimString(line); - if (IsEmpty(line)) continue; - if (line[0] == '[') { - memset(&info, 0, sizeof(info)); - if (!mir_strcmpi(line, "[ICQ Message User]")) - info.type = ICQFILE_MESSAGEUSER; - else if (!mir_strcmpi(line, "[ICQ User]")) - info.type = ICQFILE_ADDUSER; - continue; - } - if (info.type == 0) continue; - sep = strchr(line, '='); - if (sep == NULL) { info.type = 0; break; } /* format error */ - *(sep++) = '\0'; - if (!mir_strcmp("UIN", line)) mir_strncpy(info.uin, sep, sizeof(info.uin)); /* buffer safe */ - else if (!mir_strcmp("Email", line)) mir_strncpy(info.email, sep, sizeof(info.email)); /* buffer safe */ - else if (!mir_strcmp("NickName", line)) mir_strncpy(info.nick, sep, sizeof(info.nick)); /* buffer safe */ - else if (!mir_strcmp("FirstName", line)) mir_strncpy(info.firstName, sep, sizeof(info.firstName)); /* buffer safe */ - else if (!mir_strcmp("LastName", line)) mir_strncpy(info.lastName, sep, sizeof(info.lastName)); /* buffer safe */ - } - fclose(fp); - switch (info.type) { - case ICQFILE_MESSAGEUSER: MessageIcqUser(&info); return 0; - case ICQFILE_ADDUSER: AddIcqUser(&info); return 0; - default: return 1; /* open failed */ - } -} - -static int IcqFilesModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - char szService[MAX_PATH + 32]; - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - mir_strcat(mir_strcpy(szService, gpszICQProtoName), "OpenFile"); - /* .icq files are not used, just by the ProtoLink plugin */ - //AssocMgr_AddNewFileTypeT(".icq","application/x-icq",TranslateT("ICQ link shortcut"),TranslateT("&Add to contact list..."),hInst,IDI_ICQ,szService,FTDF_BROWSERAUTOOPEN|FTDF_ISTEXT|FTDF_ISSHORTCUT|FTDF_DEFAULTDISABLED); - AssocMgr_AddNewFileTypeT(".uin", "application/x-icq", TranslateT("ICQ link shortcut"), TranslateT("&Add to contact list..."), hInst, IDI_ICQ, szService, FTDF_BROWSERAUTOOPEN | FTDF_ISTEXT | FTDF_ISSHORTCUT); - return 0; -} - -void InitIcqFiles(void) -{ - char szService[MAX_PATH + 32]; - mir_strcat(mir_strcpy(szService, gpszICQProtoName), "OpenFile"); - hServiceOpenFile = CreateServiceFunction(szService, IcqOpenFile); - hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, IcqFilesModulesLoaded); -} - -void UninitIcqFiles(void) -{ - UnhookEvent(hHookModulesLoaded); - DestroyServiceFunction(hServiceOpenFile); -} - -#undef hInst -#endif - -// ----------------------------------------- - -#ifdef YAHOO_SUPPORT_TEST - -#define yahooProtocolName "YAHOO" -#define IDI_YAHOO 10101 -#define hinstance GetModuleHandleA("YAHOO") -static __inline HANDLE getbuddyH(const char *yahoo_id) { yahoo_id; return NULL; } -static __inline HANDLE add_buddy(const char *yahoo_id, const char *yahoo_name, DWORD flags) { yahoo_id; yahoo_name; flags; return db_find_first(); } -#include -#include - -#include "m_assocmgr.h" -static HANDLE hHookModulesLoaded; -static HANDLE hServiceParseYmsgrLink; - -static int ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) -{ - char *arg = (char*)lParam; - UNREFERENCED_PARAMETER(wParam); - if (arg == NULL) return 1; /* sanity check */ - /* - add user: ymsgr:addfriend?ID - send message: ymsgr:sendim?ID&m=MESSAGE - add chatroom: ymsgr:chat?ROOM - */ - /* skip leading prefix */ - arg = strchr(arg, ':'); - if (arg == NULL) return 1; /* parse failed */ - for (++arg; *arg == '/'; ++arg); - /* add a contact to the list */ - if (!_strnicmp(arg, "addfriend?", 10)) { - char *tok, *id = NULL; - ADDCONTACTSTRUCT acs; - PROTOSEARCHRESULT psr; - if (*(arg += 10) == 0) return 1; /* parse failed */ - tok = strtok(arg, "&"); /* first token */ - if (tok != NULL) id = Netlib_UrlDecode(tok); - if (id == NULL || *id == 0) return 1; /* parse failed */ - if (getbuddyH(id) == NULL) { /* does not yet check if id is current user */ - acs.handleType = HANDLE_SEARCHRESULT; - acs.szProto = yahooProtocolName; - acs.psr = &psr; - memset(&psr, 0, sizeof(PROTOSEARCHRESULT)); - psr.cbSize = sizeof(PROTOSEARCHRESULT); - psr.nick.w = id; - CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); - } - return 0; - } - /* send a message to a contact */ - else if (!_strnicmp(arg, "sendim?", 7)) { - char *tok, *id = NULL, *msg = NULL; - MCONTACT hContact; - if (*(arg += 7) == 0) return 1; /* parse failed */ - tok = strtok(arg, "&"); /* first token */ - if (tok != NULL) id = tok; - while (tok != NULL) { - if (!_strnicmp(tok, "m=", 2) && *(tok + 2) != 0) - msg = Netlib_UrlDecode(tok + 2); - tok = strtok(NULL, "&"); /* next token */ - } - if (id == NULL || *id == 0) return 1; /* parse failed */ - if (ServiceExists(MS_MSG_SENDMESSAGE)) { /* does not yet check if sn is current user */ - hContact = add_buddy(id, id, PALF_TEMPORARY); /* ensure contact is on list */ - if (hContact != NULL) - CallService(MS_MSG_SENDMESSAGE, hContact, (LPARAM)msg); - } - return 0; - } - /* open a chatroom */ - else if (!_strnicmp(arg, "chat?", 5)) { - char *tok, *rm = NULL; - if (*(arg += 5) == 0) return 1; /* parse failed */ - tok = strtok(arg, "&"); /* first token */ - if (tok != NULL) rm = Netlib_UrlDecode(tok); - if (rm == NULL) return 1; /* parse failed */ - /* not yet implemented (rm contains name of chatroom)*/ - return 0; - } - return 1; /* parse failed */ -} - -static int YmsgrLinksModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - char szService[MAXMODULELABELLENGTH]; - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - mir_snprintf(szService, _countof(szService), "%s%s", yahooProtocolName, "ParseYmsgrLink"); - AssocMgr_AddNewUrlType("ymsgr:", Translate("Yahoo link protocol"), hinstance, IDI_YAHOO, szService, 0); - return 0; -} - -void YmsgrLinksInit(void) -{ - char szService[MAXMODULELABELLENGTH]; - mir_snprintf(szService, _countof(szService), "%s%s", yahooProtocolName, "ParseYmsgrLink"); - hServiceParseYmsgrLink = CreateServiceFunction(szService, ServiceParseYmsgrLink); - hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, YmsgrLinksModulesLoaded); -} - -void YmsgrLinksUninit(void) -{ - UnhookEvent(hHookModulesLoaded); - DestroyServiceFunction(hServiceParseYmsgrLink); -} - -#undef hinstance -#endif - -// ----------------------------------------- - -#ifdef MSN_SUPPORT_TEST - -#define msnProtocolName "MSN" -#define IDI_MSN 101 -#define hInst GetModuleHandleA("MSN") -static __inline HANDLE MSN_HContactFromEmailT(const char *msnEmail) { msnEmail; return NULL; } -static __inline HANDLE MSN_HContactFromEmail(const char *msnEmail, const char *msnNick, int addIfNeeded, int temporary) { msnEmail; msnNick; addIfNeeded; temporary; return db_find_first(); } -#include -#include - -#include "m_assocmgr.h" -static HANDLE hHookModulesLoaded; -static HANDLE hServiceParseMsnimLink; - -static int ServiceParseMsnimLink(WPARAM wParam, LPARAM lParam) -{ - char *arg = (char*)lParam; - UNREFERENCED_PARAMETER(wParam); - if (arg == NULL) return 1; /* sanity check */ - /* - add user: msnim:add?contact=netpassport@emailaddress.com - send message: msnim:chat?contact=netpassport@emailaddress.com - voice chat: msnim:voice?contact=netpassport@emailaddress.com - video chat: msnim:video?contact=netpassport@emailaddress.com - */ - /* skip leading prefix */ - arg = strchr(arg, ':'); - if (arg == NULL) return 1; /* parse failed */ - for (++arg; *arg == '/'; ++arg); - /* add a contact to the list */ - if (!_strnicmp(arg, "add?", 4)) { - char *tok, *email = NULL; - ADDCONTACTSTRUCT acs; - PROTOSEARCHRESULT psr; - if (*(arg += 4) == 0) return 1; /* parse failed */ - tok = strtok(arg, "&"); /* first token */ - while (tok != NULL) { - if (!_strnicmp(tok, "contact=", 8) && *(tok + 11) != 0) - email = Netlib_UrlDecode(tok + 11); - tok = strtok(NULL, "&"); /* next token */ - } - if (email == NULL || *email == 0) return 1; /* parse failed */ - if (MSN_HContactFromEmailT(email) == NULL) { /* does not yet check if email is current user */ - acs.handleType = HANDLE_SEARCHRESULT; - acs.szProto = AIM_PROTOCOL_NAME; - acs.psr = &psr; - memset(&psr, 0, sizeof(PROTOSEARCHRESULT)); - psr.cbSize = sizeof(PROTOSEARCHRESULT); - psr.nick.w = email; - psr.email.w = email; - CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); - } - return 0; - } - /* send a message to a contact */ - /* "voice" and "video" not yet implemented, perform same action as "chat" */ - else if (!_strnicmp(arg, "chat?", 5) || !_strnicmp(arg, "voice?", 6) || !_strnicmp(arg, "video?", 6)) { - char *tok, *email = NULL; - MCONTACT hContact; - if (*(arg += 5) == 0) return 1; /* parse failed */ - if (*arg == '?' && *(++arg) == 0) return 1; /* for "voice?" and "video?" */ - tok = strtok(arg, "&"); /* first token */ - while (tok != NULL) { - if (!_strnicmp(tok, "contact=", 8) && *(tok + 11) != 0) - email = Netlib_UrlDecode(tok + 11); - tok = strtok(NULL, "&"); /* next token */ - } - if (email == NULL || *email == 0) return 1; /* parse failed */ - if (ServiceExists(MS_MSG_SENDMESSAGE)) { - hContact = MSN_HContactFromEmail(email, email, TRUE, TRUE); /* does not yet check if email is current user */ - if (hContact != NULL) - CallService(MS_MSG_SENDMESSAGE, hContact, 0); - } - return 0; - } - return 1; /* parse failed */ -} - -static int MsnLinksModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - char szService[MAXMODULELABELLENGTH]; - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - mir_snprintf(szService, _countof(szService), "%s%s", msnProtocolName, "ParseMsnimLink"); - AssocMgr_AddNewUrlType("msnim:", Translate("MSN link protocol"), hInst, IDI_MSN, szService, 0); - return 0; -} - -int LoadMsnLinks(void) -{ - char szService[MAXMODULELABELLENGTH]; - mir_snprintf(szService, _countof(szService), "%s%s", msnProtocolName, "ParseMsnimLink"); - hServiceParseMsnimLink = CreateServiceFunction(szService, ServiceParseMsnimLink); - hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, MsnLinksModulesLoaded); - return 0; -} - -void UnloadMsnLinks(void) -{ - UnhookEvent(hHookModulesLoaded); - DestroyServiceFunction(hServiceParseMsnimLink); -} - -#undef hInst -#endif - -// ----------------------------------------- - -#ifdef GG_SUPPORT_TEST - -#define GG_PROTO "GG" -#define IDI_GG 251 -#define hInstance GetModuleHandleA("GG") -typedef DWORD uin_t; -static __inline HANDLE gg_getcontact(uin_t uin, int create, int inlist, char *szNick) { uin; create; inlist; szNick; return db_find_first(); } -#include -#include - -#include "m_assocmgr.h" -static HANDLE hHookModulesLoaded; -static HANDLE hServiceParseLink; - -static int ServiceParseLink(WPARAM wParam, LPARAM lParam) -{ - char *arg = (char*)lParam; - UNREFERENCED_PARAMETER(wParam); - if (arg == NULL) return 1; /* sanity check */ - /* send message: gg:UID */ - /* skip leading prefix */ - arg = strchr(arg, ':'); - if (arg == NULL) return 1; /* parse failed */ - for (++arg; *arg == '/'; ++arg); - /* send a message to a contact */ - { MCONTACT hContact; - if (ServiceExists(MS_MSG_SENDMESSAGE)) { - hContact = gg_getcontact(atoi(arg), TRUE, FALSE, arg); - if (hContact != NULL) - CallService(MS_MSG_SENDMESSAGE, hContact, 0); - } - } - return 0; -} - -static int LinksModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - char szService[MAXMODULELABELLENGTH]; - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - mir_snprintf(szService, _countof(szService), "%s%s", GG_PROTO, "ParseMsnimLink"); - AssocMgr_AddNewUrlType("gg:", Translate("Gadu-Gadu link protocol"), hInstance, IDI_GG, szService, 0); - return 0; -} - -void gg_registerlinks(void) -{ - char szService[MAXMODULELABELLENGTH]; - mir_snprintf(szService, _countof(szService), "%s%s", GG_PROTO, "ParseLink"); - hServiceParseLink = CreateServiceFunction(szService, ServiceParseLink); - hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, LinksModulesLoaded); -} - -void gg_unregisterlinks(void) -{ - UnhookEvent(hHookModulesLoaded); - DestroyServiceFunction(hServiceParseLink); -} - -#undef hInstance -#endif - -// ----------------------------------------- - -#ifdef JABBER_SUPPORT_TEST - -#define jabberProtoName "JABBER" -#define IDI_JABBER 102 -#define hInst GetModuleHandleA("JABBER") -static __inline HANDLE JabberHContactFromJID(const char *jid) { jid; return NULL; } -static __inline HANDLE JabberDBCreateContact(char *jid, char *nick, BOOL temporary, BOOL stripResource) { jid; nick; temporary; stripResource; return db_find_first(); } -#include -#include - -#include "m_assocmgr.h" -static HANDLE hHookModulesLoaded; -static HANDLE hServiceParseXmppURI; - -static int ServiceParseXmppURI(WPARAM wParam, LPARAM lParam) -{ - char *arg = (char*)lParam; - char *jid; - UNREFERENCED_PARAMETER(wParam); - if (arg == NULL) return 1; /* sanity check */ - /* skip leading prefix */ - arg = strchr(arg, ':'); - if (arg == NULL) return 1; /* parse failed */ - for (++arg; *arg == '/'; ++arg); - /* - complete specification: http://www.xmpp.org/extensions/xep-0147.html - send message: xmpp:JID?message;subject=TEXT&body=TEXT - add user: xmpp:JID?roster - remove user: xmpp:JID?remove - */ - /* user id */ - arg = strchr(jid = arg, '?'); - if (arg == NULL) arg += mir_strlen(arg); /* points to terminating nul */ - else *(arg++) = 0; - if (*jid == 0) return 1; /* parse failed */ - /* send a message to a contact */ - else if (*arg == 0 || (!_strnicmp(arg, "message", 7) && (*(arg + 7) == ';' || *(arg + 7) == 0))) { - char *tok, *subj = NULL, *body = NULL; - MCONTACT hContact; - char msg[1024]; - arg += 7; - while (*arg == ';') ++arg; - tok = strtok(arg, "&"); /* first token */ - while (tok != NULL) { - if (!_strnicmp(tok, "subject=", 8) && *(tok + 8) != 0) - subj = Netlib_UrlDecode(tok + 8); - if (!_strnicmp(tok, "body=", 5) && *(tok + 5) != 0) - body = Netlib_UrlDecode(tok + 5); - tok = strtok(NULL, "&"); /* next token */ - } - if (ServiceExists(MS_MSG_SENDMESSAGE)) { - hContact = JabberDBCreateContact(jid, jid, TRUE, FALSE); - if (subj != NULL && body != NULL) { - mir_snprintf(msg, _countof(msg), "%.128s %s", subj, body); - body = msg; - } - else if (body == NULL) body = subj; - if (hContact != NULL) - CallService(MS_MSG_SENDMESSAGE, hContact, (LPARAM)body); - } - return 0; - } - /* add user to contact list */ - else if (!_strnicmp(arg, "roster", 6) && (*(arg + 6) == ';' || *(arg + 6) == 0)) { - ADDCONTACTSTRUCT acs; - PROTOSEARCHRESULT psr; - if (JabberHContactFromJID(jid) == NULL) { /* does not yet check if jid belongs to current user */ - acs.handleType = HANDLE_SEARCHRESULT; - acs.szProto = jabberProtoName; - acs.psr = &psr; - memset(&psr, 0, sizeof(PROTOSEARCHRESULT)); - psr.cbSize = sizeof(PROTOSEARCHRESULT); - psr.nick.w = jid; - CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); - } - return 0; - } - /* remove user from contact list */ - else if (!_strnicmp(arg, "remove", 6) && (*(arg + 6) == ';' || *(arg + 6) == 0)) { - MCONTACT hContact; - hContact = JabberHContactFromJID(jid); - if (hContact == NULL) /* not yet implemented: show standard miranda dialog here */ - db_delete_contact(hContact); - return 0; - } - /* add user subscription */ - else if (!_strnicmp(arg, "subscribe", 9) && (*(arg + 9) == ';' || *(arg + 9) == 0)) { - /* not yet implemented */ - return 0; - } - /* remove user subscription */ - else if (!_strnicmp(arg, "unsubscribe", 11) && (*(arg + 11) == ';' || *(arg + 11) == 0)) { - /* not yet implemented */ - return 0; - } - return 1; /* parse failed */ -} - -static int JabberLinksModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - char szService[MAXMODULELABELLENGTH]; - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - mir_snprintf(szService, _countof(szService), "%s%s", jabberProtoName, "ParseXmppURI"); - AssocMgr_AddNewUrlType("xmpp:", Translate("Jabber link protocol"), hInst, IDI_JABBER, szService, 0); - return 0; -} - -int JabberLinksInit() -{ - char szService[MAXMODULELABELLENGTH]; - mir_snprintf(szService, _countof(szService), "%s%s", jabberProtoName, "ParseXmppURI"); - hServiceParseXmppURI = CreateServiceFunction(szService, ServiceParseXmppURI); - hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, JabberLinksModulesLoaded); - return 0; -} - -int JabberLinksUninit() -{ - UnhookEvent(hHookModulesLoaded); - DestroyServiceFunction(hServiceParseXmppURI); - return 0; -} - -#undef hInst -#endif - -// ----------------------------------------- - -void InitTest(void) -{ - #ifdef ICQ_SUPPORT_TEST - InitIcqFiles(); - #endif - #ifdef YAHOO_SUPPORT_TEST - YmsgrLinksInit(); - #endif - #ifdef MSN_SUPPORT_TEST - LoadMsnLinks(); - #endif - #ifdef GG_SUPPORT_TEST - gg_registerlinks(); - #endif - #ifdef JABBER_SUPPORT_TEST - JabberLinksInit(); - #endif - //hServiceTest=CreateServiceFunction("AssocMgr/TestingService",TestingService); - //AssocMgr_AddNewFileTypeT(".mir",NULL,TranslateT("Miranda Installer Package (demo purpose)"),TranslateT("&Install"),hInst,IDI_MIRANDAFILE,"AssocMgr/TestingService",0); -} - -void UninitTest(void) -{ - #ifdef ICQ_SUPPORT_TEST - UninitIcqFiles(); - #endif - #ifdef YAHOO_SUPPORT_TEST - YmsgrLinksUninit(); - #endif - #ifdef MSN_SUPPORT_TEST - UnloadMsnLinks(); - #endif - #ifdef GG_SUPPORT_TEST - gg_unregisterlinks(); - #endif - #ifdef JABBER_SUPPORT_TEST - JabberLinksUninit(); - #endif - //DestroyServiceFunction(hServiceTest); -} diff --git a/plugins/AssocMgr/src/test.h b/plugins/AssocMgr/src/test.h deleted file mode 100644 index ab47ad5fd8..0000000000 --- a/plugins/AssocMgr/src/test.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - -'File Association Manager'-Plugin for Miranda IM - -Copyright (C) 2005-2007 H. Herkenrath - -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; either version 2 -of the License, or (at your option) any later version. - -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 (AssocMgr-License.txt); if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#pragma once - -/* Misc */ -void InitTest(void); -void UninitTest(void); diff --git a/plugins/ExternalAPI/m_assocmgr.h b/plugins/ExternalAPI/m_assocmgr.h index eabe570455..3cd384c188 100644 --- a/plugins/ExternalAPI/m_assocmgr.h +++ b/plugins/ExternalAPI/m_assocmgr.h @@ -36,109 +36,79 @@ Returns 0 on success, nonzero otherwise. typedef struct { int cbSize; // set to sizeof(FILETYPEDESC), in bytes - union { - const char *pszDescription; // description for options dialog and in registry. - const TCHAR *ptszDescription; // please Translate(), use singular form here. - const WCHAR *pwszDescription; - }; + + const wchar_t *pwszDescription; // description for options dialog and in registry. + HINSTANCE hInstance; // instance of the calling module and where the icon - // resource is located. - // always be sure you set this to your own hInstance even if - // you use the generic default icon + // resource is located. + // always be sure you set this to your own hInstance even if + // you use the generic default icon UINT nIconResID; // resource id of an icon to use for the file type. - // this icon should contain icons of all sizes and color depths - // needed by Windows. - // set this to 0 to use the generic 'miranda file' icon - // provided by assocmgr. + // this icon should contain icons of all sizes and color depths + // needed by Windows. + // set this to 0 to use the generic 'miranda file' icon + // provided by assocmgr. const char *pszService; // service to call when a file is opened - // this service will be called with lParam set to - // the file name being opened including path. - // it can be assumed that the provided file name - // is always the long path name. - // return zero on suceess, nonzero on error. - // Note: set this to NULL to pass the file name as - // commandline argument to miranda32.exe (db file). + // this service will be called with lParam set to + // the file name being opened including path. + // it can be assumed that the provided file name + // is always the long path name. + // return zero on suceess, nonzero on error. + // Note: set this to NULL to pass the file name as + // commandline argument to miranda32.exe (db file). DWORD flags; // see FTDF_* flags below const char *pszFileExt; // file extension, e.g. ".ext" - // first character must be a dot, assumed to be all lower case. - // may only consist of ascii characters. + // first character must be a dot, assumed to be all lower case. + // may only consist of ascii characters. const char *pszMimeType; // MIME type of the file, e.g. "application/x-icq" - // may only consist of ascii characters. - union { - const char *pszVerbDesc; // description for the open verb e.g. "&Install". - const TCHAR *ptszVerbDesc; // set this to NULL to use the default description. - const WCHAR *pwszVerbDesc; // include an ampersand (&) character for a mnemonic key. - }; // please Translate(). + // may only consist of ascii characters. + + const wchar_t *pwszVerbDesc; // description for the open verb e.g. "&Install". + // include an ampersand (&) character for a mnemonic key. + // please Translate(). } FILETYPEDESC; #define FTDF_UNICODE 0x0001 // pszDescription and pszVerbDesc in struct are Unicode. - // the specified service is called with Unicode parameters. +// the specified service is called with Unicode parameters. #define FTDF_DEFAULTDISABLED 0x0002 // file type is not registered by default, it needs to be - // enabled explicitly on the options page. + // enabled explicitly on the options page. #define FTDF_BROWSERAUTOOPEN 0x0004 // tells the browser to download and open the file directly - // without prompt (currently IE and Opera6+) - be careful! - // use only in conjunction with pszMimeType set. - // this tells Windows that open can be safely invoked for - // downloaded files. - // Note that this flag may create a security risk, - // because downloaded files could contain malicious content. - // you need to protect against such an exploit. + // without prompt (currently IE and Opera6+) - be careful! + // use only in conjunction with pszMimeType set. + // this tells Windows that open can be safely invoked for + // downloaded files. + // Note that this flag may create a security risk, + // because downloaded files could contain malicious content. + // you need to protect against such an exploit. #define FTDF_ISTEXT 0x0008 // tells Windows that this file can be opened - // as a text file using e.g Notepad. - // only has an effect on Windows XP and higher. + // as a text file using e.g Notepad. + // only has an effect on Windows XP and higher. #define FTDF_ISSHORTCUT 0x0010 // file type behaves as shortcut, this means a - // small overlay arrow is applied and the extension is never shown - -#if defined(_UNICODE) - #define FTDF_TCHAR FTDF_UNICODE // strings in struct are WCHAR*, service accepts WCHAR* -#else - #define FTDF_TCHAR 0 // strings in struct are char*, service accepts char* -#endif + // small overlay arrow is applied and the extension is never shown -#if !defined(ASSOCMGR_NOHELPERFUNCTIONS) -__inline static int AssocMgr_AddNewFileType(const char *ext,const char *mime,const char *desc,const char *verb,HINSTANCE hinst,UINT iconid,const char *service,DWORD flags) +__inline static int AssocMgr_AddNewFileTypeW(const char *ext, const char *mime, const wchar_t *desc, const wchar_t *verb, HINSTANCE hinst, UINT iconid, const char *service, DWORD flags) { FILETYPEDESC ftd; - ftd.cbSize=sizeof(FILETYPEDESC); - ftd.pszFileExt=ext; - ftd.pszMimeType=mime; - ftd.pszDescription=desc; - ftd.pszVerbDesc=verb; - ftd.hInstance=hinst; - ftd.nIconResID=iconid; - ftd.pszService=service; - ftd.flags=flags&~FTDF_UNICODE; - return CallService(MS_ASSOCMGR_ADDNEWFILETYPE,0,(LPARAM)&ftd); + ftd.cbSize = sizeof(FILETYPEDESC); + ftd.pszFileExt = ext; + ftd.pszMimeType = mime; + ftd.pwszDescription = desc; + ftd.pwszVerbDesc = verb; + ftd.hInstance = hinst; + ftd.nIconResID = iconid; + ftd.pszService = service; + ftd.flags = flags | FTDF_UNICODE; + return CallService(MS_ASSOCMGR_ADDNEWFILETYPE, 0, (LPARAM)&ftd); } -__inline static int AssocMgr_AddNewFileTypeW(const char *ext,const char *mime,const WCHAR *desc,const WCHAR *verb,HINSTANCE hinst,UINT iconid,const char *service,DWORD flags) -{ - FILETYPEDESC ftd; - ftd.cbSize=sizeof(FILETYPEDESC); - ftd.pszFileExt=ext; - ftd.pszMimeType=mime; - ftd.pwszDescription=desc; - ftd.pwszVerbDesc=verb; - ftd.hInstance=hinst; - ftd.nIconResID=iconid; - ftd.pszService=service; - ftd.flags=flags|FTDF_UNICODE; - return CallService(MS_ASSOCMGR_ADDNEWFILETYPE,0,(LPARAM)&ftd); -} -#if defined(_UNICODE) - #define AssocMgr_AddNewFileTypeT AssocMgr_AddNewFileTypeW -#else - #define AssocMgr_AddNewFileTypeT AssocMgr_AddNewFileType -#endif -#endif /* Remove a file type v0.1.0.0+ Remove a file type registered previously using @@ -163,75 +133,49 @@ Returns 0 on success, nonzero otherwise. typedef struct { int cbSize; // set to sizeof(URLTYPEDESC), in bytes - union { - const char *pszDescription; // description for options dialog and in registry. - const TCHAR *ptszDescription; // please Translate(), use singular form here. - const WCHAR *pwszDescription; - }; + + const wchar_t *pwszDescription; // description for options dialog and in registry. + HINSTANCE hInstance; // instance of the calling module and where the icon - // resource is located. - // always be sure you set this to your own hInstance even if - // you use the generic default icon + // resource is located. + // always be sure you set this to your own hInstance even if + // you use the generic default icon UINT nIconResID; // resource id of an icon to use for the url type. - // only a small one (16x16) is needed by Windows, - // e.g. proto icon as used in Miranda. - // set this to 0 to use the default miranda icon. + // only a small one (16x16) is needed by Windows, + // e.g. proto icon as used in Miranda. + // set this to 0 to use the default miranda icon. const char *pszService; // service to call when a url is opened (can't be NULL) - // this service will be called with lParam set to - // the url being opened including the prefix. - // return zero on suceess, nonzero on error. + // this service will be called with lParam set to + // the url being opened including the prefix. + // return zero on suceess, nonzero on error. DWORD flags; // see UTDF_* flags below const char *pszProtoPrefix; // protocol prefix, e.g. "http:" - // last character must be a colon, assumed to be all lower case. - // may only consist of ascii characters. + // last character must be a colon, assumed to be all lower case. + // may only consist of ascii characters. } URLTYPEDESC; #define UTDF_UNICODE 0x0001 // pszDescription in struct is Unicode. - // the specified service is called with Unicode parameters. +// the specified service is called with Unicode parameters. #define UTDF_DEFAULTDISABLED 0x0002 // url type is not registered by default, it needs to be - // enabled explicitly on the options page. -#if defined(_UNICODE) - #define UTDF_TCHAR UTDF_UNICODE // strings in struct are WCHAR*, service accepts WCHAR* -#else - #define UTDF_TCHAR 0 // strings in struct are char*, service accepts char* -#endif + // enabled explicitly on the options page. -#if !defined(ASSOCMGR_NOHELPERFUNCTIONS) -static int __inline AssocMgr_AddNewUrlType(const char *prefix,const char *desc,HINSTANCE hinst,UINT iconid,const char *service,DWORD flags) +static int __inline AssocMgr_AddNewUrlTypeW(const char *prefix, const wchar_t *desc, HINSTANCE hinst, UINT iconid, const char *service, DWORD flags) { URLTYPEDESC utd; - utd.cbSize=sizeof(URLTYPEDESC); - utd.pszProtoPrefix=prefix; - utd.pszDescription=desc; - utd.hInstance=hinst; - utd.nIconResID=iconid; - utd.pszService=service; - utd.flags=flags&~UTDF_UNICODE; - return CallService(MS_ASSOCMGR_ADDNEWURLTYPE,0,(LPARAM)&utd); + utd.cbSize = sizeof(URLTYPEDESC); + utd.pszProtoPrefix = prefix; + utd.pwszDescription = desc; + utd.hInstance = hinst; + utd.nIconResID = iconid; + utd.pszService = service; + utd.flags = flags | UTDF_UNICODE; + return CallService(MS_ASSOCMGR_ADDNEWURLTYPE, 0, (LPARAM)&utd); } -static int __inline AssocMgr_AddNewUrlTypeW(const char *prefix,const WCHAR *desc,HINSTANCE hinst,UINT iconid,const char *service,DWORD flags) -{ - URLTYPEDESC utd; - utd.cbSize=sizeof(URLTYPEDESC); - utd.pszProtoPrefix=prefix; - utd.pwszDescription=desc; - utd.hInstance=hinst; - utd.nIconResID=iconid; - utd.pszService=service; - utd.flags=flags|UTDF_UNICODE; - return CallService(MS_ASSOCMGR_ADDNEWURLTYPE,0,(LPARAM)&utd); -} -#if defined(_UNICODE) - #define AssocMgr_AddNewUrlTypeT AssocMgr_AddNewUrlTypeW -#else - #define AssocMgr_AddNewUrlTypeT AssocMgr_AddNewUrlType -#endif -#endif /* Remove an url protocol type v0.1.0.0+ Remove an url registered previously using @@ -248,19 +192,19 @@ Returns 0 on success, nonzero otherwise. #if defined(MoveMemory) && defined(lstrlen) static __inline char *Netlib_UrlDecode(char *str) { - char *psz=str; - for (;*psz;++psz) - switch(*psz) { - case '+': - *psz=' '; - break; - case '%': - if (!psz[1] || !psz[2]) break; - MoveMemory(psz,&psz[1],2); - psz[2]=0; - *psz=(char)strtol(psz, nullptr,16); - MoveMemory(&psz[1],&psz[3],mir_strlen(&psz[3])+1); - break; + char *psz = str; + for (; *psz; ++psz) + switch (*psz) { + case '+': + *psz = ' '; + break; + case '%': + if (!psz[1] || !psz[2]) break; + MoveMemory(psz, &psz[1], 2); + psz[2] = 0; + *psz = (char)strtol(psz, nullptr, 16); + MoveMemory(&psz[1], &psz[3], mir_strlen(&psz[3]) + 1); + break; } return str; } diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp index fa215c6a3b..c163b7d9d9 100644 --- a/plugins/PluginUpdater/src/Events.cpp +++ b/plugins/PluginUpdater/src/Events.cpp @@ -54,7 +54,7 @@ int ModulesLoaded(WPARAM, LPARAM) #if MIRANDA_VER >= 0x0A00 if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) - AssocMgr_AddNewUrlTypeT("mirpu:", TranslateT("Plugin updater URI scheme"), hInst, IDI_PLGLIST, MODNAME "/ParseUri", 0); + AssocMgr_AddNewUrlTypeW("mirpu:", TranslateT("Plugin updater URI scheme"), hInst, IDI_PLGLIST, MODNAME "/ParseUri", 0); #endif int iRestartCount = db_get_b(NULL, MODNAME, DB_SETTING_RESTART_COUNT, 2); -- cgit v1.2.3