summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-27 20:41:06 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-27 20:41:11 +0300
commitb2f4da66f2affc8a53f79eef2a74cf447c8b0db8 (patch)
tree264aa8ed10526892839cb18238f34e400e402091 /plugins
parenta39926c9f33f53fe57492ed4960d817a9c95d3e6 (diff)
SeenPlugin: old ugly schema of storing protocol settings replaced with more convenient one
Diffstat (limited to 'plugins')
-rw-r--r--plugins/SeenPlugin/src/main.cpp6
-rw-r--r--plugins/SeenPlugin/src/options.cpp15
-rw-r--r--plugins/SeenPlugin/src/stdafx.h2
-rw-r--r--plugins/SeenPlugin/src/utils.cpp30
4 files changed, 19 insertions, 34 deletions
diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp
index 1e2b114f73..80b5379fbc 100644
--- a/plugins/SeenPlugin/src/main.cpp
+++ b/plugins/SeenPlugin/src/main.cpp
@@ -55,12 +55,7 @@ DBVTranslation idleTr[TRANSNUMBER] = {
{ any_to_Idle, L"Any to /Idle or empty", 0 }
};
-static int CompareProtos(const char *p1, const char *p2)
-{ return mir_strcmp(p1, p2);
-}
-
BOOL includeIdle;
-LIST<char> arWatchedProtos(10, CompareProtos);
LIST<logthread_info> arContacts(16, NumericKeySortT);
mir_cs csContacts;
@@ -144,7 +139,6 @@ int CMPlugin::Load()
int CMPlugin::Unload()
{
UninitFileOutput();
- UnloadWatchedProtos();
WindowList_Destroy(g_pUserInfo);
diff --git a/plugins/SeenPlugin/src/options.cpp b/plugins/SeenPlugin/src/options.cpp
index 765fedb421..e3e2ef05b5 100644
--- a/plugins/SeenPlugin/src/options.cpp
+++ b/plugins/SeenPlugin/src/options.cpp
@@ -342,22 +342,11 @@ public:
g_plugin.setByte("IdleSupport", IsDlgButtonChecked(m_hwnd, IDC_IDLESUPPORT));
// save protocol list
- CMStringA watchedProtocols;
-
int nItems = protocols.GetItemCount();
- for (int i=0; i < nItems; i++) {
- if (!protocols.GetCheckState(i))
- continue;
-
+ for (int i = 0; i < nItems; i++) {
char *szProto = (char *)protocols.GetItemData(i);
- if (!watchedProtocols.IsEmpty())
- watchedProtocols.AppendChar('\n');
- watchedProtocols.Append(szProto);
+ db_set_b(0, szProto, MODULENAME "Enabled", protocols.GetCheckState(i));
}
- g_plugin.setString("WatchedAccounts", watchedProtocols);
-
- UnloadWatchedProtos();
- LoadWatchedProtos();
return true;
}
diff --git a/plugins/SeenPlugin/src/stdafx.h b/plugins/SeenPlugin/src/stdafx.h
index 61f6009db6..7246708e02 100644
--- a/plugins/SeenPlugin/src/stdafx.h
+++ b/plugins/SeenPlugin/src/stdafx.h
@@ -138,8 +138,6 @@ extern uint32_t dwmirver;
extern bool g_bFileActive;
void LoadWatchedProtos();
-void UnloadWatchedProtos();
-extern LIST<char> arWatchedProtos;
extern LIST<logthread_info> arContacts;
extern mir_cs csContacts;
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp
index 7897bec510..aacad823a3 100644
--- a/plugins/SeenPlugin/src/utils.cpp
+++ b/plugins/SeenPlugin/src/utils.cpp
@@ -38,18 +38,22 @@ void LoadWatchedProtos()
}
ptrA szProtos(g_plugin.getStringA("WatchedAccounts"));
- if (szProtos == NULL)
- return;
-
- for (char *p = strtok(szProtos, "\n"); p != nullptr; p = strtok(nullptr, "\n"))
- arWatchedProtos.insert(mir_strdup(p));
-}
-
-void UnloadWatchedProtos()
-{
- for (auto &it : arWatchedProtos)
- mir_free(it);
- arWatchedProtos.destroy();
+ if (szProtos != NULL) {
+ OBJLIST<char> oldProtos(1);
+ for (char *p = strtok(szProtos, "\n"); p != nullptr; p = strtok(nullptr, "\n"))
+ oldProtos.insert(newStr(rtrim(p)));
+
+ for (auto *pa : Accounts()) {
+ db_set_b(0, pa->szModuleName, MODULENAME "Enabled", false);
+ for (auto &it: oldProtos) {
+ if (!mir_strcmp(pa->szModuleName, it)) {
+ db_set_b(0, pa->szModuleName, MODULENAME "Enabled", true);
+ break;
+ }
+ }
+ }
+ g_plugin.delSetting("WatchedAccounts");
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -64,7 +68,7 @@ int IsWatchedProtocol(const char* szProto)
if (pd == nullptr || CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
return 0;
- return arWatchedProtos.find((char*)szProto) != nullptr;
+ return db_get_b(0, szProto, MODULENAME "Enabled", true);
}
bool isJabber(const char *protoname)