summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src/chat/main.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-16 08:37:51 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-16 08:37:51 +0000
commit38ab4dde6b080defc5e7d7b286110d580cabdaa0 (patch)
tree4890eaba00645f597e91a888277d461ba3d923c0 /plugins/Scriver/src/chat/main.cpp
parent2f30799b091475f1086b756bba4b43ebacd3aefc (diff)
kernel chat engine, part 2 - scriver
git-svn-id: http://svn.miranda-ng.org/main/trunk@7676 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Scriver/src/chat/main.cpp')
-rw-r--r--plugins/Scriver/src/chat/main.cpp152
1 files changed, 99 insertions, 53 deletions
diff --git a/plugins/Scriver/src/chat/main.cpp b/plugins/Scriver/src/chat/main.cpp
index 9973b86497..a563b99aaf 100644
--- a/plugins/Scriver/src/chat/main.cpp
+++ b/plugins/Scriver/src/chat/main.cpp
@@ -24,26 +24,113 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void RegisterChatFonts( void );
//globals
-HMENU g_hMenu = NULL;
-HGENMENU hJoinMenuItem, hLeaveMenuItem;
+CHAT_MANAGER *pci;
+HMENU g_hMenu = NULL;
-FONTINFO aFonts[OPTIONS_FONTCOUNT];
-HBRUSH hListBkgBrush = NULL;
-HBRUSH hListSelectedBkgBrush = NULL;
+HBRUSH hListBkgBrush = NULL;
+HBRUSH hListSelectedBkgBrush = NULL;
-TCHAR* pszActiveWndID = 0;
-char* pszActiveWndModule = 0;
+GlobalLogSettings g_Settings;
-struct GlobalLogSettings_t g_Settings;
+static void OnAddLog(SESSION_INFO *si, int isOk)
+{
+ if (isOk && si->hWnd)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
+
+static void OnSessionDblClick(SESSION_INFO *si)
+{
+ PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
+}
+
+static void OnSessionRemove(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+}
+
+static void OnSessionRename(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
+}
+
+static void OnSessionReplace(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ RedrawWindow(GetDlgItem(si->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
+}
+
+static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
+
+static void OnSetStatusBar(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
+}
+
+static void OnNewUser(SESSION_INFO *si, USERINFO*)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+}
+
+static void OnSetStatus(SESSION_INFO *si, int wStatus)
+{
+ PostMessage(si->hWnd, GC_FIXTABICONS, 0, 0);
+}
+
+static void OnLoadSettings()
+{
+ if (hListBkgBrush != NULL)
+ DeleteObject(hListBkgBrush);
+ hListBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorNicklistBG", GetSysColor(COLOR_WINDOW)));
+
+ if (hListSelectedBkgBrush != NULL)
+ DeleteObject(hListSelectedBkgBrush);
+ hListSelectedBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorNicklistSelectedBG", GetSysColor(COLOR_HIGHLIGHT)));
+}
+
+static void OnFlashWindow(SESSION_INFO *si, int bInactive)
+{
+ if (bInactive && si->hWnd && db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0)
+ SendMessage(GetParent(si->hWnd), CM_STARTFLASHING, 0, 0);
+ if (bInactive && si->hWnd)
+ SendMessage(si->hWnd, GC_SETMESSAGEHIGHLIGHT, 0, 0);
+}
int Chat_Load()
{
- InitializeCriticalSection(&cs);
+ mir_getCI(&g_Settings);
+ pci->cbModuleInfo = sizeof(MODULEINFO);
+ pci->cbSession = sizeof(SESSION_INFO);
+ pci->OnNewUser = OnNewUser;
+
+ pci->OnSetStatus = OnSetStatus;
+
+ pci->OnAddLog = OnAddLog;
+ pci->OnLoadSettings = OnLoadSettings;
+
+ pci->OnSessionRemove = OnSessionRemove;
+ pci->OnSessionRename = OnSessionRename;
+ pci->OnSessionReplace = OnSessionReplace;
+ pci->OnSessionDblClick = OnSessionDblClick;
+
+ pci->OnEventBroadcast = OnEventBroadcast;
+ pci->OnSetStatusBar = OnSetStatusBar;
+ pci->OnFlashWindow = OnFlashWindow;
+ pci->ShowRoom = ShowRoom;
+
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
TranslateMenu(g_hMenu);
- HookEvents();
- CreateServiceFunctions();
- CreateHookableEvents();
return 0;
}
@@ -51,54 +138,13 @@ int Chat_Unload(void)
{
db_set_w(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
- CList_SetAllOffline(TRUE, NULL);
-
- mir_free( pszActiveWndID );
- mir_free( pszActiveWndModule );
-
- DestroyHookableEvents();
-
DestroyMenu(g_hMenu);
- FreeIcons();
OptionsUnInit();
- DeleteCriticalSection(&cs);
return 0;
}
int Chat_ModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- char* mods[3] = { "Chat", "ChatFonts" };
- CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2);
- RegisterChatFonts();
OptionsInit();
- LoadIcons();
- {
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.cbSize = sizeof(mi);
- mi.position = -2000090001;
- mi.flags = CMIF_DEFAULT;
- mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_JOIN );
- mi.pszName = LPGEN("&Join");
- mi.pszService = "GChat/JoinChat";
- hJoinMenuItem = Menu_AddContactMenuItem(&mi);
-
- mi.position = -2000090000;
- mi.flags = CMIF_NOTOFFLINE;
- mi.icolibItem = LoadSkinnedIconHandle( SKINICON_CHAT_LEAVE );
- mi.pszName = LPGEN("&Leave");
- mi.pszService = "GChat/LeaveChat";
- hLeaveMenuItem = Menu_AddContactMenuItem(&mi);
- }
- CList_SetAllOffline(TRUE, NULL);
return 0;
}
-
-void LoadIcons(void)
-{
- LoadMsgLogBitmaps();
-}
-
-void FreeIcons(void)
-{
- FreeMsgLogBitmaps();
-}