summaryrefslogtreecommitdiff
path: root/protocols/GmailNotifier/src/utility.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-03-02 12:32:44 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-03-02 12:32:55 +0300
commit931a7dc1ac0dbc7e6c1083583ced915e572f5b47 (patch)
tree9fe9a6448d44030e26aa7107ce16044ed413e0d0 /protocols/GmailNotifier/src/utility.cpp
parentdd7d9954042254e66e3bbbec7195c6be8b1a0663 (diff)
all protocols (even virtual ones) moved to the Protocols folder
Diffstat (limited to 'protocols/GmailNotifier/src/utility.cpp')
-rw-r--r--protocols/GmailNotifier/src/utility.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/protocols/GmailNotifier/src/utility.cpp b/protocols/GmailNotifier/src/utility.cpp
new file mode 100644
index 0000000000..cda56e956c
--- /dev/null
+++ b/protocols/GmailNotifier/src/utility.cpp
@@ -0,0 +1,77 @@
+#include "stdafx.h"
+
+void BuildList(void)
+{
+ g_accs.destroy();
+
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrA szName(g_plugin.getStringA(hContact, "name"));
+ if (szName != nullptr) {
+ Account *p = new Account;
+ p->hContact = hContact;
+ mir_strcpy(p->name, szName);
+ CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
+
+ ptrA szPassword(g_plugin.getStringA(hContact, "Password"));
+ if (szPassword != nullptr)
+ mir_strcpy(p->pass, szPassword);
+ g_accs.insert(p);
+ }
+ }
+
+ for (auto &acc : g_accs) {
+ char *tail = strchr(acc->name, '@');
+ if (tail && mir_strcmp(tail + 1, "gmail.com") != 0)
+ mir_strcpy(acc->hosted, tail + 1);
+ acc->IsChecking = false;
+ }
+}
+
+BOOL GetBrowser(char *str)
+{
+ HKEY hKey = nullptr;
+ char *strKey;
+ char strIE[] = "Applications\\iexplore.exe\\shell\\open\\command";
+ char strDefault[] = "https\\shell\\open\\command";
+ DBVARIANT dbv;
+
+ if (opt.OpenUsePrg == 1)
+ strKey = strIE;
+ else if (opt.OpenUsePrg == 0)
+ strKey = strDefault;
+ else {
+ if (!g_plugin.getString("OpenUsePrgPath", &dbv)) {
+ mir_strcpy(str, dbv.pszVal);
+ db_free(&dbv);
+ }
+ else *str = 0;
+ return FALSE;
+ }
+
+ // Open the registry
+ if (RegOpenKeyExA(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
+ // Data size
+ DWORD cbData = 0;
+ // Get the default value
+ if (RegQueryValueExA(hKey, nullptr, nullptr, nullptr, nullptr, &cbData) == ERROR_SUCCESS && cbData > 0) {
+ if (RegQueryValueExA(hKey, nullptr, nullptr, nullptr, (LPBYTE)str, &cbData) == ERROR_SUCCESS) {
+ if ((strKey = strstr(str, "%1")) != nullptr)
+ *(strKey--) = '\0';
+ if ((strKey = strstr(str, "-")) != nullptr)
+ *(strKey--) = '\0';
+ RegCloseKey(hKey);
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+Account* GetAccountByContact(MCONTACT hContact)
+{
+ for (auto &it : g_accs)
+ if (it->hContact == hContact)
+ return it;
+
+ return nullptr;
+}