summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-01-24 20:46:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-01-24 20:46:13 +0300
commite9e27e8335285078d78b4f8c4405ddc78efbd00c (patch)
tree88b32ddd918fb1728cc19b9a4229b79c631cac0e
parentc8629f370b4ce6d72857e802b10d92b64ce94454 (diff)
fixes #3004 (Dummy: при автоматическом переводе учётки депрекейтнутого протокола на Dummy не заполняется шаблон)
-rw-r--r--protocols/Dummy/src/dummy.h31
-rw-r--r--protocols/Dummy/src/dummy_proto.cpp49
-rw-r--r--protocols/Dummy/src/dummy_proto.h2
-rw-r--r--protocols/Dummy/src/main.cpp9
-rw-r--r--protocols/Dummy/src/version.h2
5 files changed, 46 insertions, 47 deletions
diff --git a/protocols/Dummy/src/dummy.h b/protocols/Dummy/src/dummy.h
index a5e1461435..14b4e4ea44 100644
--- a/protocols/Dummy/src/dummy.h
+++ b/protocols/Dummy/src/dummy.h
@@ -31,35 +31,8 @@ struct ttemplate
const char *text;
};
-static const ttemplate templates[] =
-{
- { LPGEN("Custom"), "", "" },
- { "AIM", "SN", LPGEN("Screen name") },
- { "Discord", "id", LPGEN("Discord ID") },
- { "EmLAN", "Nick", LPGEN("User name") },
- { "Facebook", "ID", LPGEN("Facebook ID") },
- { "GG", "UIN", LPGEN("Gadu-Gadu number") },
- { "ICQ", "UIN", LPGEN("User ID") },
- { "ICQCorp", "UIN", LPGEN("ICQ number") },
- { "IRC", "Nick", LPGEN("Nickname") },
- { "Jabber", "jid", LPGEN("JID") },
- { "MinecraftDynmap", "Nick", LPGEN("Visible name") },
- { "MRA", "e-mail", LPGEN("E-mail address") },
- { "MSN", "wlid", LPGEN("Live ID") },
- { "Omegle", "nick", LPGEN("Visible name") },
- { "Sametime", "stid", LPGEN("ID") },
- { "Skype (SkypeKit)", "sid", LPGEN("Skype name") },
- { "Skype (Classic)", "Username", LPGEN("Skype name") },
- { "Skype (Web)", "Username", LPGEN("Skype name") },
- { "Steam", "SteamID", LPGEN("Steam ID") },
- { "Tlen", "jid", LPGEN("Tlen login") },
- { "Tox", "ToxID", LPGEN("Tox ID") },
- { "Twitter", "Username", LPGEN("Username") },
- { "VK", "ID", LPGEN("VKontakte ID") },
- { "WhatsApp", "ID", LPGEN("WhatsApp ID") },
- { "XFire", "Username", LPGEN("Username") },
- { "Yahoo", "yahoo_id", LPGEN("ID") },
-};
+#define DUMMY_PROTO_COUNT 26
+extern const ttemplate templates[DUMMY_PROTO_COUNT];
struct CMPlugin : public ACCPROTOPLUGIN<CDummyProto>
{
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp
index 70c92a3560..28a1b735c6 100644
--- a/protocols/Dummy/src/dummy_proto.cpp
+++ b/protocols/Dummy/src/dummy_proto.cpp
@@ -17,6 +17,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+const ttemplate templates[DUMMY_PROTO_COUNT] =
+{
+ { LPGEN("Custom"), "", "" },
+ { "AIM", "SN", LPGEN("Screen name") },
+ { "Discord", "id", LPGEN("Discord ID") },
+ { "EmLAN", "Nick", LPGEN("User name") },
+ { "Facebook", "ID", LPGEN("Facebook ID") },
+ { "GG", "UIN", LPGEN("Gadu-Gadu number") },
+ { "ICQ", "UIN", LPGEN("User ID") },
+ { "ICQCorp", "UIN", LPGEN("ICQ number") },
+ { "IRC", "Nick", LPGEN("Nickname") },
+ { "Jabber", "jid", LPGEN("JID") },
+ { "MinecraftDynmap", "Nick", LPGEN("Visible name") },
+ { "MRA", "e-mail", LPGEN("E-mail address") },
+ { "MSN", "wlid", LPGEN("Live ID") },
+ { "Omegle", "nick", LPGEN("Visible name") },
+ { "Sametime", "stid", LPGEN("ID") },
+ { "Skype (SkypeKit)", "sid", LPGEN("Skype name") },
+ { "Skype (Classic)", "Username", LPGEN("Skype name") },
+ { "Skype (Web)", "Username", LPGEN("Skype name") },
+ { "Steam", "SteamID", LPGEN("Steam ID") },
+ { "Tlen", "jid", LPGEN("Tlen login") },
+ { "Tox", "ToxID", LPGEN("Tox ID") },
+ { "Twitter", "Username", LPGEN("Username") },
+ { "VK", "ID", LPGEN("VKontakte ID") },
+ { "WhatsApp", "ID", LPGEN("WhatsApp ID") },
+ { "XFire", "Username", LPGEN("Username") },
+ { "Yahoo", "yahoo_id", LPGEN("ID") },
+};
+
void CDummyProto::SearchIdAckThread(void *targ)
{
PROTOSEARCHRESULT psr = { 0 };
@@ -61,11 +91,16 @@ CDummyProto::~CDummyProto()
int CDummyProto::getTemplateId()
{
- int id = this->getByte(DUMMY_ID_TEMPLATE, 0);
- if (id < 0 || id >= _countof(templates))
- return 0;
+ int id = this->getByte(DUMMY_ID_TEMPLATE, -1);
+ if (id >= 0 && id < _countof(templates))
+ return id;
- return id;
+ CMStringA szProto(getMStringA("AM_BaseProto"));
+ for (auto &it : templates)
+ if (!stricmp(it.name, szProto))
+ return int(&it - templates);
+
+ return 0;
}
INT_PTR CDummyProto::GetCaps(int type, MCONTACT)
@@ -92,9 +127,9 @@ INT_PTR CDummyProto::GetCaps(int type, MCONTACT)
case PFLAG_UNIQUEIDTEXT:
if (uniqueIdSetting[0] == '\0') {
int id = getTemplateId();
- ptrA setting(id > 0 ? mir_strdup(Translate(templates[id].text)) : getStringA(DUMMY_ID_TEXT));
+ ptrW setting(id > 0 ? mir_a2u(Translate(templates[id].text)) : getWStringA(DUMMY_ID_TEXT));
if (setting != NULL)
- strncpy_s(uniqueIdSetting, setting, _TRUNCATE);
+ wcsncpy_s(uniqueIdSetting, setting, _TRUNCATE);
}
return (INT_PTR)uniqueIdSetting;
}
@@ -146,7 +181,7 @@ MCONTACT CDummyProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
Contact_Hide(hContact, false);
Contact_PutOnList(hContact);
}
- setWString(hContact, uniqueIdSetting, psr->id.w);
+ setWString(hContact, _T2A(uniqueIdSetting), psr->id.w);
setWString(hContact, "Nick", psr->id.w);
return hContact;
diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h
index 1c5b496fdb..b5a902cbc6 100644
--- a/protocols/Dummy/src/dummy_proto.h
+++ b/protocols/Dummy/src/dummy_proto.h
@@ -45,7 +45,7 @@ struct CDummyProto : public PROTO<CDummyProto>
void __cdecl SearchIdAckThread(void*);
char uniqueIdText[100];
- char uniqueIdSetting[100];
+ wchar_t uniqueIdSetting[100];
int getTemplateId();
diff --git a/protocols/Dummy/src/main.cpp b/protocols/Dummy/src/main.cpp
index 0589433a32..acb41872b4 100644
--- a/protocols/Dummy/src/main.cpp
+++ b/protocols/Dummy/src/main.cpp
@@ -49,19 +49,10 @@ CMPlugin::CMPlugin() :
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
/////////////////////////////////////////////////////////////////////////////////////////
-// OnModulesLoaded - execute some code when all plugins are initialized
-
-static int OnModulesLoaded(WPARAM, LPARAM)
-{
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// OnLoad - initialize the plugin instance
int CMPlugin::Load()
{
- HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
return 0;
}
diff --git a/protocols/Dummy/src/version.h b/protocols/Dummy/src/version.h
index e61f01b3fb..e14669c597 100644
--- a/protocols/Dummy/src/version.h
+++ b/protocols/Dummy/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
#define __RELEASE_NUM 0
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>