summaryrefslogtreecommitdiff
path: root/plugins/SeenPlugin/src/utils.cpp
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/SeenPlugin/src/utils.cpp
parenta39926c9f33f53fe57492ed4960d817a9c95d3e6 (diff)
SeenPlugin: old ugly schema of storing protocol settings replaced with more convenient one
Diffstat (limited to 'plugins/SeenPlugin/src/utils.cpp')
-rw-r--r--plugins/SeenPlugin/src/utils.cpp30
1 files changed, 17 insertions, 13 deletions
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)