summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-02 15:53:29 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-02 15:53:29 +0300
commit539586996ab793264744b580e808140da439a22e (patch)
tree068b81a29931a66ca12e578ecbbbbd8f99be7be6 /protocols
parent38e179fe0f2e0f4335722f50b582c04a92ceb639 (diff)
fixes #1241 (some status menu items don't change language until restart)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp86
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp1
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h2
-rw-r--r--protocols/JabberG/src/jabber_xstatus.cpp90
-rw-r--r--protocols/JabberG/src/jabber_xstatus.h15
5 files changed, 106 insertions, 88 deletions
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 585f7c2b58..1980311134 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -128,15 +128,15 @@ static INT_PTR JabberMenuHandleDirectPresence(WPARAM hContact, LPARAM lParam, LP
static int JabberPrebuildContactMenu(WPARAM hContact, LPARAM lParam)
{
- Menu_ShowItem(g_hMenuCommands, FALSE);
- Menu_ShowItem(g_hMenuSendNote, FALSE);
- Menu_ShowItem(g_hMenuConvert, FALSE);
- Menu_ShowItem(g_hMenuRosterAdd, FALSE);
- Menu_ShowItem(g_hMenuLogin, FALSE);
- Menu_ShowItem(g_hMenuRefresh, FALSE);
- Menu_ShowItem(g_hMenuAddBookmark, FALSE);
- Menu_ShowItem(g_hMenuResourcesRoot, FALSE);
- Menu_ShowItem(g_hMenuDirectPresence[0], FALSE);
+ Menu_ShowItem(g_hMenuCommands, false);
+ Menu_ShowItem(g_hMenuSendNote, false);
+ Menu_ShowItem(g_hMenuConvert, false);
+ Menu_ShowItem(g_hMenuRosterAdd, false);
+ Menu_ShowItem(g_hMenuLogin, false);
+ Menu_ShowItem(g_hMenuRefresh, false);
+ Menu_ShowItem(g_hMenuAddBookmark, false);
+ Menu_ShowItem(g_hMenuResourcesRoot, false);
+ Menu_ShowItem(g_hMenuDirectPresence[0], false);
CJabberProto *ppro = CMPlugin::getInstance(hContact);
return(ppro) ? ppro->OnPrebuildContactMenu(hContact, lParam) : 0;
@@ -624,18 +624,53 @@ void CJabberProto::MenuInit()
//////////////////////////////////////////////////////////////////////////////////////
// build priority menu
+ BuildPriorityMenu();
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ // finalize status menu
+
+ m_pepServices.RebuildMenu();
+ CheckMenuItems();
+
+ NotifyFastHook(hStatusMenuInit, (WPARAM)m_hMenuRoot, (LPARAM)(IJabberInterface*)this);
+}
+
+//////////////////////////////////////////////////////////////////////////
+// priority popup in status menu
+
+INT_PTR CJabberProto::OnMenuSetPriority(WPARAM, LPARAM, LPARAM dwDelta)
+{
+ int iDelta = (int)dwDelta;
+ int priority = getDword("Priority", 0) + iDelta;
+ if (priority > 127)
+ priority = 127;
+ else if (priority < -128)
+ priority = -128;
+ setDword("Priority", priority);
+ SendPresence(m_iStatus, true);
+ return 0;
+}
+
+void CJabberProto::BuildPriorityMenu()
+{
m_priorityMenuVal = 0;
m_priorityMenuValSet = false;
+ if (m_hMenuPriorityRoot)
+ Menu_RemoveItem(m_hMenuPriorityRoot);
+
+ CMenuItem mi;
mi.pszService = nullptr;
mi.position = 200006;
mi.root = m_hMenuRoot;
mi.name.a = LPGEN("Resource priority");
mi.flags = CMIF_UNMOVABLE | CMIF_HIDDEN;
m_hMenuPriorityRoot = Menu_AddProtoMenuItem(&mi);
+ Menu_ShowItem(m_hMenuPriorityRoot, m_menuItemsStatus != 0);
wchar_t szName[128];
char srvFce[MAX_PATH + 64];
+
mi.pszService = srvFce;
mi.name.w = szName;
mi.position = 2000040000;
@@ -672,30 +707,6 @@ void CJabberProto::MenuInit()
}
UpdatePriorityMenu(getDword("Priority", 0));
-
- //////////////////////////////////////////////////////////////////////////////////////
- // finalize status menu
-
- m_pepServices.RebuildMenu();
- CheckMenuItems();
-
- NotifyFastHook(hStatusMenuInit, (WPARAM)m_hMenuRoot, (LPARAM)(IJabberInterface*)this);
-}
-
-//////////////////////////////////////////////////////////////////////////
-// priority popup in status menu
-
-INT_PTR CJabberProto::OnMenuSetPriority(WPARAM, LPARAM, LPARAM dwDelta)
-{
- int iDelta = (int)dwDelta;
- int priority = getDword("Priority", 0) + iDelta;
- if (priority > 127)
- priority = 127;
- else if (priority < -128)
- priority = -128;
- setDword("Priority", priority);
- SendPresence(m_iStatus, true);
- return 0;
}
void CJabberProto::UpdatePriorityMenu(int priority)
@@ -820,6 +831,15 @@ void CJabberProto::EnableMenuItems(bool bEnable)
CheckMenuItems();
}
+int CJabberProto::OnLangChanged(WPARAM, LPARAM)
+{
+ BuildPriorityMenu();
+
+ for (auto &it : m_pepServices)
+ it->UpdateMenuView();
+ return 0;
+}
+
void CJabberProto::CheckMenuItems()
{
bool bEnabled = (m_menuItemsStatus != 0);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 421868087e..e40d079ea0 100755
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -181,6 +181,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) :
// XMPP URI parser service for "File Association Manager" plugin
CreateProtoService(JS_PARSE_XMPP_URI, &CJabberProto::JabberServiceParseXmppURI);
+ HookProtoEvent(ME_LANGPACK_CHANGED, &CJabberProto::OnLangChanged);
HookProtoEvent(ME_OPT_INITIALISE, &CJabberProto::OnOptionsInit);
HookProtoEvent(ME_SKIN2_ICONSCHANGED, &CJabberProto::OnReloadIcons);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index a90d65494a..e3c8aea5f1 100755
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -121,6 +121,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
int __cdecl OnContactDeleted(WPARAM, LPARAM);
int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
int __cdecl OnIdleChanged(WPARAM, LPARAM);
+ int __cdecl OnLangChanged(WPARAM, LPARAM);
int __cdecl OnModulesLoadedEx(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl OnPreShutdown(WPARAM, LPARAM);
@@ -634,6 +635,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void MenuInit(void);
void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item);
+ void BuildPriorityMenu(void);
void UpdatePriorityMenu(int priority);
HGENMENU m_hMenuPriorityRoot;
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp
index 06666c36fd..76952ded88 100644
--- a/protocols/JabberG/src/jabber_xstatus.cpp
+++ b/protocols/JabberG/src/jabber_xstatus.cpp
@@ -342,7 +342,7 @@ BOOL CJabberDlgPepSimple::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
if (!mode->m_subitem || (lpdis->itemState & ODS_COMBOBOXEDIT)) {
wchar_t text[128];
if (mode->m_subitem) {
- for (int i = lpdis->itemData; i >= 0; --i)
+ for (int i = mode->m_id; i >= 0; --i)
if (!m_modes[i].m_subitem) {
mir_snwprintf(text, L"%s [%s]", m_modes[i].m_title, mode->m_title);
break;
@@ -693,20 +693,7 @@ void CPepMood::SetMood(MCONTACT hContact, const wchar_t *szMood, const wchar_t *
m_mode = mood;
replaceStrW(m_text, szText);
- HANDLE hIcon;
- wchar_t title[128];
- if (mood >= 0) {
- mir_snwprintf(title, TranslateT("Mood: %s"), TranslateW(g_arrMoods[mood].szName));
- hIcon = g_MoodIcons.GetIcolibHandle(g_arrMoods[mood].szTag);
- }
- else {
- mir_wstrcpy(title, TranslateT("Set mood..."));
- hIcon = Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT);
- }
-
- UpdateMenuItem(hIcon, title);
- if (m_proto->m_pInfoFrame)
- m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/mood", hIcon, title);
+ UpdateMenuView();
}
else SetExtraIcon(hContact, mood < 0 ? nullptr : g_arrMoods[mood].szTag);
@@ -747,20 +734,26 @@ void CPepMood::ShowSetDialog(BYTE bQuiet)
replaceStrW(m_text, dlg.GetStatusText());
}
+ UpdateMenuView();
+}
+
+void CPepMood::UpdateMenuView()
+{
HANDLE hIcon;
- wchar_t *ptszTitle;
+ wchar_t title[128];
if (m_mode >= 0) {
- Publish();
- hIcon = g_MoodIcons.GetIcolibHandle(g_arrMoods[m_mode].szTag); ptszTitle = TranslateW(g_arrMoods[m_mode].szName);
+ mir_snwprintf(title, TranslateT("Mood: %s"), TranslateW(g_arrMoods[m_mode].szName));
+ hIcon = g_MoodIcons.GetIcolibHandle(g_arrMoods[m_mode].szTag);
}
else {
- Retract();
- hIcon = Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT); ptszTitle = TranslateT("Set mood...");
+ mir_wstrcpy(title, TranslateT("Set mood..."));
+ hIcon = Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT);
}
- UpdateMenuItem(hIcon, ptszTitle);
+ UpdateMenuItem(hIcon, title);
+
if (m_proto->m_pInfoFrame)
- m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/mood", hIcon, ptszTitle);
+ m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/mood", hIcon, title);
}
///////////////////////////////////////////////////////////////////////////////
@@ -1074,35 +1067,18 @@ void CPepActivity::SetActivity(MCONTACT hContact, const wchar_t *szFirst, const
return;
}
- wchar_t activityTitle[128];
- ActivityBuildTitle(activity, activityTitle, _countof(activityTitle));
-
if (!hContact) {
m_mode = activity;
replaceStrW(m_text, szText);
- HANDLE hIcon;
- wchar_t title[128];
-
- if (activity >= 0) {
- mir_snwprintf(title, TranslateT("Activity: %s"), activityTitle);
- hIcon = g_ActivityIcons.GetIcolibHandle(returnActivity(activity));
- }
- else {
- mir_wstrcpy(title, TranslateT("Set activity..."));
- hIcon = Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT);
- }
-
- UpdateMenuItem(hIcon, title);
- if (m_proto->m_pInfoFrame)
- m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/activity", hIcon, title);
+ UpdateMenuView();
}
else SetExtraIcon(hContact, activity < 0 ? nullptr : returnActivity(activity));
if (activity >= 0) {
- wchar_t *p = mir_a2u(ActivityGetId(activity));
- m_proto->WriteAdvStatus(hContact, ADVSTATUS_ACTIVITY, p, g_ActivityIcons.GetIcolibName(returnActivity(activity)), activityTitle, szText);
- mir_free(p);
+ wchar_t activityTitle[128];
+ ActivityBuildTitle(activity, activityTitle, _countof(activityTitle));
+ m_proto->WriteAdvStatus(hContact, ADVSTATUS_ACTIVITY, _A2T(ActivityGetId(activity)), g_ActivityIcons.GetIcolibName(returnActivity(activity)), activityTitle, szText);
}
else m_proto->ResetAdvStatus(hContact, ADVSTATUS_ACTIVITY);
}
@@ -1123,17 +1099,31 @@ void CPepActivity::ShowSetDialog(BYTE)
if (m_mode >= 0) {
replaceStrW(m_text, dlg.GetStatusText());
Publish();
+ }
+ else Retract();
+
+ UpdateMenuView();
+}
- UpdateMenuItem(g_ActivityIcons.GetIcolibHandle(returnActivity(m_mode)), g_arrActivities[m_mode].szTitle);
- if (m_proto->m_pInfoFrame)
- m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/activity", g_ActivityIcons.GetIcolibHandle(returnActivity(m_mode)), TranslateW(g_arrActivities[m_mode].szTitle));
+void CPepActivity::UpdateMenuView()
+{
+ HANDLE hIcon;
+ wchar_t title[128];
+
+ if (m_mode >= 0) {
+ wchar_t activityTitle[128];
+ ActivityBuildTitle(m_mode, activityTitle, _countof(activityTitle));
+ mir_snwprintf(title, TranslateT("Activity: %s"), activityTitle);
+ hIcon = g_ActivityIcons.GetIcolibHandle(returnActivity(m_mode));
}
else {
- Retract();
- UpdateMenuItem(Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT), LPGENW("Set activity..."));
- if (m_proto->m_pInfoFrame)
- m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/activity", Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT), TranslateT("Set activity..."));
+ mir_wstrcpy(title, TranslateT("Set activity..."));
+ hIcon = Skin_GetIconHandle(SKINICON_OTHER_SMALLDOT);
}
+
+ UpdateMenuItem(hIcon, title);
+ if (m_proto->m_pInfoFrame)
+ m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/activity", hIcon, title);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_xstatus.h b/protocols/JabberG/src/jabber_xstatus.h
index b7878f9c7c..2ff26cba2a 100644
--- a/protocols/JabberG/src/jabber_xstatus.h
+++ b/protocols/JabberG/src/jabber_xstatus.h
@@ -43,10 +43,11 @@ public:
void Retract();
void ResetPublish();
- virtual void InitGui() {}
- virtual void RebuildMenu() {}
- virtual void ResetExtraIcon(MCONTACT) {}
+ virtual void InitGui() = 0;
+ virtual void RebuildMenu() = 0;
+ virtual void ResetExtraIcon(MCONTACT) = 0;
virtual bool LaunchSetGui() { return false; }
+ virtual void UpdateMenuView(void) = 0;
protected:
CJabberProto *m_proto;
@@ -156,8 +157,10 @@ public:
int m_mode;
protected:
+ void ShowSetDialog(BYTE bQuiet) override;
+ void UpdateMenuView(void) override;
+
void CreateData(HXML);
- void ShowSetDialog(BYTE bQuiet);
void SetExtraIcon(MCONTACT hContact, char *szMood);
void SetMood(MCONTACT hContact, const wchar_t *szMood, const wchar_t *szText);
@@ -176,8 +179,10 @@ protected:
wchar_t *m_text;
int m_mode;
+ void ShowSetDialog(BYTE bQuiet) override;
+ void UpdateMenuView(void) override;
+
void CreateData(HXML);
- void ShowSetDialog(BYTE bQuiet);
void SetExtraIcon(MCONTACT hContact, char *szActivity);
void SetActivity(MCONTACT hContact, const wchar_t *szFirst, const wchar_t *szSecond, const wchar_t *szText);