summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat/main.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-17 14:41:49 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-17 14:41:49 +0000
commitb638838fd6ec1eb32d096e0244e8e0d2a8196c73 (patch)
tree77673fe0a3e1f5513e11e323a894cee82488091e /plugins/TabSRMM/src/chat/main.cpp
parent6d2b23beea4515281f3b0760c0246d4aea9b1e80 (diff)
- kernel chat module loads automatically, not on request;
- the special structure, CHAT_MANAGER_INITDATA, is used to customize chats; - fix for fonts group for all plugins; - fix for options in tabSRMM git-svn-id: http://svn.miranda-ng.org/main/trunk@7688 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/chat/main.cpp')
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp49
1 files changed, 41 insertions, 8 deletions
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index 5a8a10c014..690e5665e4 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -171,13 +171,13 @@ static void OnLoadSettings()
DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_OFFLINE]);
}
- LoadMsgDlgFont(FONTSECTION_CHAT, 18, &lf, NULL, CHAT_FONTMODULE);
+ pci->LoadMsgDlgFont(18, &lf, NULL);
g_Settings.UserListFonts[CHAT_STATUS_NORMAL] = CreateFontIndirect(&lf);
- LoadMsgDlgFont(FONTSECTION_CHAT, 19, &lf, NULL, CHAT_FONTMODULE);
+ pci->LoadMsgDlgFont(19, &lf, NULL);
g_Settings.UserListFonts[CHAT_STATUS_AWAY] = CreateFontIndirect(&lf);
- LoadMsgDlgFont(FONTSECTION_CHAT, 5, &lf, NULL, CHAT_FONTMODULE);
+ pci->LoadMsgDlgFont(5, &lf, NULL);
g_Settings.UserListFonts[CHAT_STATUS_OFFLINE] = CreateFontIndirect(&lf);
int ih = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFonts[CHAT_STATUS_NORMAL], false);
@@ -232,12 +232,47 @@ void Chat_ModulesLoaded()
static CHAT_MANAGER saveCI;
+static int CopyChatSetting(const char *szSetting, LPARAM param)
+{
+ LIST<char> *szSettings = (LIST<char>*)param;
+ szSettings->insert(mir_strdup(szSetting));
+ return 0;
+}
+
+static void CheckUpdate()
+{
+ // already converted?
+ if (db_get_b(NULL, "Compatibility", "TabChatFonts", false))
+ return;
+
+ LIST<char> szSettings(120);
+
+ DBCONTACTENUMSETTINGS dbces = { 0 };
+ dbces.szModule = CHAT_OLDFONTMODULE;
+ dbces.pfnEnumProc = CopyChatSetting;
+ dbces.lParam = (LPARAM)&szSettings;
+ CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+
+ DBVARIANT dbv;
+ for (int i = szSettings.getCount() - 1; i >= 0; i--) {
+ char *p = szSettings[i];
+ db_get(NULL, CHAT_OLDFONTMODULE, p, &dbv);
+ db_set(NULL, CHAT_FONTMODULE, p, &dbv);
+ db_free(&dbv);
+ mir_free(p);
+ }
+
+ CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)CHAT_OLDFONTMODULE);
+ db_set_b(NULL, "Compatibility", "TabChatFonts", true);
+}
+
int Chat_Load()
{
- mir_getCI(&g_Settings);
+ CheckUpdate();
+
+ CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Message Sessions")_T("/")LPGENT("Group chats") };
+ mir_getCI(&data);
saveCI = *pci;
- pci->cbModuleInfo = sizeof(MODULEINFO);
- pci->cbSession = sizeof(SESSION_INFO);
pci->OnCreateModule = OnCreateModule;
pci->OnNewUser = OnNewUser;
@@ -263,7 +298,6 @@ int Chat_Load()
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
- OnLoadSettings();
OptionsInit();
return 0;
}
@@ -276,6 +310,5 @@ int Chat_Unload(void)
{
*pci = saveCI;
DestroyMenu(g_hMenu);
- OptionsUnInit();
return 0;
}