diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-03 18:15:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-03 18:15:52 +0000 |
commit | 4641ff7a3a0d6a124c22a5c044bffd04073720fc (patch) | |
tree | dd0abb5de957189fc8dd18cd83b3cf97eafe853b /protocols/JabberG/jabber_menu.cpp | |
parent | ad4e888349c2d220828c93d2d50635ff23a6fc72 (diff) |
shit dropped out
git-svn-id: http://svn.miranda-ng.org/main/trunk@738 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/jabber_menu.cpp')
-rw-r--r-- | protocols/JabberG/jabber_menu.cpp | 72 |
1 files changed, 44 insertions, 28 deletions
diff --git a/protocols/JabberG/jabber_menu.cpp b/protocols/JabberG/jabber_menu.cpp index 1bc4007148..963d5d4219 100644 --- a/protocols/JabberG/jabber_menu.cpp +++ b/protocols/JabberG/jabber_menu.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_toolbar.h"
+#define MENUITEM_LASTSEEN 1
#define MENUITEM_SERVER 2
#define MENUITEM_RESOURCES 10
@@ -54,6 +55,7 @@ static HGENMENU g_hMenuRefresh; static HGENMENU g_hMenuCommands;
static HGENMENU g_hMenuSendNote;
static HGENMENU g_hMenuResourcesRoot;
+static HGENMENU g_hMenuResourcesActive;
static HGENMENU g_hMenuResourcesServer;
static struct
@@ -336,12 +338,20 @@ void g_MenuInit( void ) mi.icolibItem = g_GetIconHandle( IDI_JABBER );
g_hMenuResourcesRoot = Menu_AddContactMenuItem(&mi);
+ mi.pszService = "Jabber/UseResource_last";
+ mi.pszName = LPGEN("Last Active");
+ mi.position = -1999901000;
+ mi.hParentMenu = g_hMenuResourcesRoot;
+ mi.icolibItem = g_GetIconHandle( IDI_JABBER );
+ mi.flags |= CMIF_ROOTHANDLE;
+ g_hMenuResourcesActive = Menu_AddContactMenuItem(&mi);
+ List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN ));
+
mi.pszService = "Jabber/UseResource_server";
mi.pszName = LPGEN("Server's Choice");
mi.position = -1999901000;
- mi.hParentMenu = g_hMenuResourcesRoot;
+ mi.pszPopupName = (char *)g_hMenuResourcesRoot;
mi.icolibItem = g_GetIconHandle( IDI_NODE_SERVER );
- mi.flags |= CMIF_ROOTHANDLE;
g_hMenuResourcesServer = Menu_AddContactMenuItem(&mi);
List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER ));
}
@@ -441,6 +451,7 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM ) mi.flags = CMIM_ICON|CMIM_FLAGS;
mi.icolibItem = GetIconHandle( IDI_JABBER );
CallService(MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesRoot, ( LPARAM )&mi );
+ CallService(MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesActive, ( LPARAM )&mi );
int nMenuResourceItemsNew = m_nMenuResourceItems;
if ( m_nMenuResourceItems < item->resourceCount ) {
@@ -474,7 +485,7 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM ) CLISTMENUITEM clmi = {0};
clmi.cbSize = sizeof(CLISTMENUITEM);
clmi.flags = CMIM_NAME|CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_TCHAR;
- if ((item->resourceMode == RSMODE_MANUAL) && (item->manualResource == &item->resource[i]))
+ if ((item->resourceMode == RSMODE_MANUAL) && (item->manualResource == i))
clmi.flags |= CMIF_CHECKED;
if (ServiceExists( "Fingerprint/GetClientIcon" )) {
clmi.flags |= CMIM_ICON;
@@ -498,6 +509,10 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM ) mi.cbSize = sizeof(CLISTMENUITEM);
mi.flags = CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_ICONFROMICOLIB |
+ ((item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0);
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesActive, ( LPARAM )&mi );
+
+ mi.flags = CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_ICONFROMICOLIB |
((item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0);
CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesServer, ( LPARAM )&mi );
@@ -1107,8 +1122,8 @@ int CJabberProto::OnProcessSrmmEvent( WPARAM, LPARAM lParam ) JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( jid );
- if ( r && r->uMessageSessionActive ) {
- r->uMessageSessionActive = 0;
+ if ( r && r->bMessageSessionActive ) {
+ r->bMessageSessionActive = FALSE;
JabberCapsBits jcb = GetResourceCapabilites( jid, TRUE );
if ( jcb & JABBER_CAPS_CHATSTATES ) {
@@ -1145,35 +1160,35 @@ int CJabberProto::OnProcessSrmmIconClick( WPARAM wParam, LPARAM lParam ) TCHAR buf[256];
mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"), TranslateT("Last active"),
- LI->lastSeenResource ? LI->lastSeenResource->resourceName :
- TranslateT("No activity yet, use server's choice"));
+ ((LI->lastSeenResource>=0) && (LI->lastSeenResource < LI->resourceCount)) ?
+ LI->resource[LI->lastSeenResource].resourceName : TranslateT("No activity yet, use server's choice"));
+ AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf);
- AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Standard"));
+ AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)"));
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
- int manInd = -1;
- for (int i = 0; i < LI->resourceCount; ++i) {
+ for (int i = 0; i < LI->resourceCount; ++i)
AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->resource[i].resourceName);
- if (&LI->resource[i] == LI->manualResource)
- manInd = i;
- }
- if (LI->resourceMode == RSMODE_MANUAL)
- CheckMenuItem(hMenu, MENUITEM_RESOURCES + manInd, MF_BYCOMMAND|MF_CHECKED);
- else
+ if (LI->resourceMode == RSMODE_LASTSEEN)
+ CheckMenuItem(hMenu, MENUITEM_LASTSEEN, MF_BYCOMMAND|MF_CHECKED);
+ else if (LI->resourceMode == RSMODE_SERVER)
CheckMenuItem(hMenu, MENUITEM_SERVER, MF_BYCOMMAND|MF_CHECKED);
+ else
+ CheckMenuItem(hMenu, MENUITEM_RESOURCES+LI->manualResource, MF_BYCOMMAND|MF_CHECKED);
int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL);
- if (res == MENUITEM_SERVER) {
- LI->manualResource = NULL;
+ if ( res == MENUITEM_LASTSEEN ) {
+ LI->manualResource = -1;
+ LI->resourceMode = RSMODE_LASTSEEN;
+ }
+ else if (res == MENUITEM_SERVER) {
+ LI->manualResource = -1;
LI->resourceMode = RSMODE_SERVER;
-
- for ( int i=0; i<LI->resourceCount; i++ )
- LI->resource[i].uMessageSessionActive = 0;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->manualResource = &LI->resource[res - MENUITEM_RESOURCES];
+ LI->manualResource = res - MENUITEM_RESOURCES;
LI->resourceMode = RSMODE_MANUAL;
}
@@ -1200,15 +1215,16 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM wParam, LPARAM, LPARAM if ( !LI )
return 0;
- if (res == MENUITEM_SERVER) {
- LI->manualResource = NULL;
+ if ( res == MENUITEM_LASTSEEN ) {
+ LI->manualResource = -1;
+ LI->resourceMode = RSMODE_LASTSEEN;
+ }
+ else if (res == MENUITEM_SERVER) {
+ LI->manualResource = -1;
LI->resourceMode = RSMODE_SERVER;
-
- for ( int i=0; i<LI->resourceCount; i++ )
- LI->resource[i].uMessageSessionActive = 0;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->manualResource = &LI->resource[res - MENUITEM_RESOURCES];
+ LI->manualResource = res - MENUITEM_RESOURCES;
LI->resourceMode = RSMODE_MANUAL;
}
|