diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-05 16:54:27 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-05 16:54:27 +0000 |
commit | b665a90f50f09435aef5bc3b5b9da710e4558690 (patch) | |
tree | 3053606dcddc1b15f73e7af1fb2507afbf20f052 /plugins/TabSRMM/src/chat | |
parent | 6c01981a8452577f3751298c7cdbe59b3ae81d51 (diff) |
various menu items quirks, simplifications & optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@4319 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/chat')
-rw-r--r-- | plugins/TabSRMM/src/chat/clist.cpp | 46 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/services.cpp | 7 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 2 |
3 files changed, 26 insertions, 29 deletions
diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp index 5506aa5cad..18172a2e01 100644 --- a/plugins/TabSRMM/src/chat/clist.cpp +++ b/plugins/TabSRMM/src/chat/clist.cpp @@ -194,7 +194,7 @@ INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam) if ( hContact ) {
char* szProto = GetContactProto(hContact);
if ( szProto ) {
- if ( DBGetContactSettingWord( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE )
+ if ( db_get_w( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE )
CallProtoService( szProto, PS_JOINCHAT, wParam, lParam );
else
CList_RoomDoubleclicked( wParam, 0 );
@@ -217,31 +217,28 @@ INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam) int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
- if ( hContact ) {
- char* szProto = GetContactProto(hContact);
+ if (hContact == NULL)
+ return 0;
- CLISTMENUITEM clmi = { sizeof(clmi) };
- clmi.flags = CMIM_FLAGS | CMIF_DEFAULT | CMIF_HIDDEN;
+ bool bEnabled = false;
+ char *szProto = GetContactProto(hContact);
+ if ( szProto ) {
+ // display this menu item only for chats
+ if ( M->GetByte(hContact, szProto, "ChatRoom", 0 )) {
+ // still hide it for offline protos
+ if (CallProtoService( szProto, PS_GETSTATUS, 0, 0 ) != ID_STATUS_OFFLINE) {
+ CLISTMENUITEM clmi = { sizeof(clmi) };
+ clmi.flags = CMIM_NAME;
+ if (db_get_w( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE)
+ clmi.pszName = (char*)LPGEN("Join chat");
+ else
+ clmi.pszName = (char*)LPGEN("Open chat window");
+ Menu_ModifyItem(hJoinMenuItem, &clmi);
+ bEnabled = true;
+ } } }
- if ( szProto ) {
- // display this menu item only for chats
- if ( M->GetByte(hContact, szProto, "ChatRoom", 0 )) {
- // still hide it for offline protos
- if ( CallProtoService( szProto, PS_GETSTATUS, 0, 0 ) != ID_STATUS_OFFLINE ) {
- clmi.flags &= ~CMIF_HIDDEN;
- clmi.flags |= CMIM_NAME;
-
- if ( DBGetContactSettingWord( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE )
- clmi.pszName = ( char* )LPGEN("Join chat");
- else
- clmi.pszName = ( char* )LPGEN("Open chat window");
- } } }
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )hJoinMenuItem, ( LPARAM )&clmi );
-
- clmi.flags &= ~(CMIM_NAME | CMIF_DEFAULT);
- clmi.flags |= CMIF_NOTOFFLINE;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )hLeaveMenuItem, ( LPARAM )&clmi );
- }
+ Menu_ShowItem(hJoinMenuItem, bEnabled);
+ Menu_ShowItem(hLeaveMenuItem, bEnabled);
return 0;
}
@@ -250,7 +247,6 @@ INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam) return CList_PrebuildContactMenu(wParam, lParam);
}
-
void CList_CreateGroup(TCHAR* group)
{
if (!group)
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index c3a1ada839..bcd2cc9452 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -40,7 +40,8 @@ CRITICAL_SECTION cs; HANDLE hSendEvent;
HANDLE hBuildMenuEvent;
-HANDLE hJoinMenuItem, hLeaveMenuItem;
+
+HGENMENU hJoinMenuItem, hLeaveMenuItem;
static HANDLE
hServiceRegister = NULL,
@@ -458,8 +459,8 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT else lstrcpyn(newcontactname, _T("_U_"), SIZEOF(newcontactname));
char *szProto = GetContactProto(newData.hContact);
- WORD wStatus = szProto == NULL ? ID_STATUS_OFFLINE : DBGetContactSettingWord((HANDLE) newData.hContact, szProto, "Status", ID_STATUS_OFFLINE);
- char *szStatus = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, szProto == NULL ? ID_STATUS_OFFLINE : DBGetContactSettingWord((HANDLE)newData.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0);
+ WORD wStatus = szProto == NULL ? ID_STATUS_OFFLINE : db_get_w((HANDLE) newData.hContact, szProto, "Status", ID_STATUS_OFFLINE);
+ char *szStatus = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, szProto == NULL ? ID_STATUS_OFFLINE : db_get_w((HANDLE)newData.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0);
newData.item.pszText = newcontactname;
newData.item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index a18b760cc8..d424e03f78 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -287,7 +287,7 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg) dat->hTabIcon = dat->hTabStatusIcon;
if (dat->iTabID >= 0) {
- if (DBGetContactSettingWord(si->hContact, si->pszModule , "ApparentMode", 0) != 0)
+ if (db_get_w(si->hContact, si->pszModule , "ApparentMode", 0) != 0)
DBWriteContactSettingWord(si->hContact, si->pszModule , "ApparentMode", (LPARAM)0);
if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)szChatIconString);
|