diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2014-05-18 13:59:55 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2014-05-18 13:59:55 +0000 |
commit | cd6a5eee79c6c5ceccfcfe6063311ee6b7eff33d (patch) | |
tree | 18dcfae777e71128ed9199d0e6d4a706ffe17e54 /plugins/GmailNotifier/src/utility.cpp | |
parent | 19605930cb53f2596b5771ebead5f703a44376b3 (diff) |
GmailNotifier rename
git-svn-id: http://svn.miranda-ng.org/main/trunk@9226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/GmailNotifier/src/utility.cpp')
-rw-r--r-- | plugins/GmailNotifier/src/utility.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/plugins/GmailNotifier/src/utility.cpp b/plugins/GmailNotifier/src/utility.cpp new file mode 100644 index 0000000000..9363f27f60 --- /dev/null +++ b/plugins/GmailNotifier/src/utility.cpp @@ -0,0 +1,77 @@ +#include "gmail.h"
+
+void BuildList(void)
+{
+ DBVARIANT dbv;
+
+ acc_num = 0;
+ for (MCONTACT hContact = db_find_first(pluginName); hContact; hContact = db_find_next(hContact, pluginName)) {
+ if (!db_get_s(hContact, pluginName, "name", &dbv)) {
+ acc_num++;
+ acc = (Account *)realloc(acc, acc_num * sizeof(Account));
+ memset(&acc[acc_num-1], 0, sizeof(Account));
+ acc[acc_num-1].hContact = hContact;
+ lstrcpyA(acc[acc_num-1].name, dbv.pszVal);
+ CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
+ db_free(&dbv);
+
+ if (!db_get_s(hContact, pluginName, "Password", &dbv)) {
+ lstrcpyA(acc[acc_num-1].pass, dbv.pszVal);
+ db_free(&dbv);
+ }
+ }
+ }
+
+ for (int i = 0; i < acc_num; i++) {
+ char *tail = strchr(acc[i].name, '@');
+ if (tail && lstrcmpA(tail + 1, "gmail.com") != 0)
+ lstrcpyA(acc[i].hosted, tail + 1);
+ acc[i].IsChecking = FALSE;
+ }
+}
+
+BOOL GetBrowser(char *str)
+{
+ HKEY hKey = NULL;
+ 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 (!db_get_s(NULL, pluginName, "OpenUsePrgPath", &dbv)) {
+ lstrcpyA(str, dbv.pszVal);
+ db_free(&dbv);
+ 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, NULL, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS && cbData > 0) {
+ if (RegQueryValueExA(hKey, NULL, NULL, NULL, (LPBYTE)str, &cbData) == ERROR_SUCCESS) {
+ if ((strKey = strstr(str, "%1")) != NULL)
+ *(strKey--) = '\0';
+ if ((strKey = strstr(str, "-")) != NULL)
+ *(strKey--) = '\0';
+ RegCloseKey(hKey);
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+Account* GetAccountByContact(MCONTACT hContact)
+{
+ for (int i = 0; i < acc_num; i++)
+ if (acc[i].hContact == hContact)
+ return &acc[i];
+
+ return NULL;
+}
\ No newline at end of file |