summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/theme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/WhatsApp/src/theme.cpp')
-rw-r--r--protocols/WhatsApp/src/theme.cpp286
1 files changed, 143 insertions, 143 deletions
diff --git a/protocols/WhatsApp/src/theme.cpp b/protocols/WhatsApp/src/theme.cpp
index 56680016a1..a457f9a603 100644
--- a/protocols/WhatsApp/src/theme.cpp
+++ b/protocols/WhatsApp/src/theme.cpp
@@ -1,16 +1,16 @@
-#include "common.h"
+ #include "common.h"
extern OBJLIST<WhatsAppProto> g_Instances;
static IconItem icons[] =
{
- { LPGEN("WhatsApp Icon"), "whatsApp", IDI_WHATSAPP },
- { LPGEN("Add To Group"), "addContactToGroup", IDI_ADD_USER_TO_GROUP},
- { LPGEN("Create Chat Group"), "createGroup", IDI_ADD_GROUP },
- { LPGEN("Remove From Chat Group"), "removeContactFromGroup", IDI_REMOVE_USER_FROM_GROUP },
- { LPGEN("Leave And Delete Group"), "leaveAndDeleteGroup", IDI_LEAVE_GROUP },
- { LPGEN("Leave Group"), "leaveGroup", IDI_LEAVE_GROUP },
- { LPGEN("Change Group Subject"), "changeGroupSubject", IDI_CHANGE_GROUP_SUBJECT }
+ { LPGEN("WhatsApp Icon"), "whatsApp", IDI_WHATSAPP },
+ { LPGEN("Add To Group"), "addContactToGroup", IDI_ADD_USER_TO_GROUP},
+ { LPGEN("Create Chat Group"), "createGroup", IDI_ADD_GROUP },
+ { LPGEN("Remove From Chat Group"), "removeContactFromGroup", IDI_REMOVE_USER_FROM_GROUP },
+ { LPGEN("Leave And Delete Group"), "leaveAndDeleteGroup", IDI_LEAVE_GROUP },
+ { LPGEN("Leave Group"), "leaveGroup", IDI_LEAVE_GROUP },
+ { LPGEN("Change Group Subject"), "changeGroupSubject", IDI_CHANGE_GROUP_SUBJECT }
};
void InitIcons(void)
@@ -84,30 +84,30 @@ static int PrebuildContactMenu(WPARAM wParam,LPARAM lParam)
void WhatsAppProto::InitContactMenus()
{
- hHookPreBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
+ hHookPreBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
- CLISTMENUITEM mi = {sizeof(mi)};
+ CLISTMENUITEM mi = {sizeof(mi)};
- mi.position = -2000006100;
+ mi.position = -2000006100;
mi.icolibItem = GetIconHandle("leaveGroup");
mi.pszName = GetIconDescription("leaveGroup");
mi.pszService = "WhatsAppProto/LeaveGroup";
- g_hContactMenuSvc[CMI_LEAVE_GROUP] =
- CreateServiceFunction(mi.pszService,GlobalService<&WhatsAppProto::OnLeaveGroup>);
+ g_hContactMenuSvc[CMI_LEAVE_GROUP] =
+ CreateServiceFunction(mi.pszService,GlobalService<&WhatsAppProto::OnLeaveGroup>);
g_hContactMenuItems[CMI_LEAVE_GROUP] = Menu_AddContactMenuItem(&mi);
- mi.position = -2000006100;
+ mi.position = -2000006100;
mi.icolibItem = GetIconHandle("leaveAndDeleteGroup");
mi.pszName = GetIconDescription("leaveAndDeleteGroup");
- g_hContactMenuSvc[CMI_REMOVE_GROUP] = g_hContactMenuSvc[CMI_LEAVE_GROUP];
+ g_hContactMenuSvc[CMI_REMOVE_GROUP] = g_hContactMenuSvc[CMI_LEAVE_GROUP];
g_hContactMenuItems[CMI_REMOVE_GROUP] = Menu_AddContactMenuItem(&mi);
- mi.position = -2000006099;
+ mi.position = -2000006099;
mi.icolibItem = GetIconHandle("changeGroupSubject");
mi.pszName = GetIconDescription("changeGroupSubject");
mi.pszService = "WhatsAppProto/ChangeGroupSubject";
- g_hContactMenuSvc[CMI_CHANGE_GROUP_SUBJECT] =
- CreateServiceFunction(mi.pszService,GlobalService<&WhatsAppProto::OnChangeGroupSubject>);
+ g_hContactMenuSvc[CMI_CHANGE_GROUP_SUBJECT] =
+ CreateServiceFunction(mi.pszService,GlobalService<&WhatsAppProto::OnChangeGroupSubject>);
g_hContactMenuItems[CMI_CHANGE_GROUP_SUBJECT] = Menu_AddContactMenuItem(&mi);
}
@@ -125,134 +125,134 @@ void EnableMenuItem(HANDLE hMenuItem, bool enable)
int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
- if (hContact)
- LOG(this->GetContactDisplayName(hContact).c_str());
- else
- LOG("No contact found");
-
- if (g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP] != NULL)
- {
- CallService("CList/RemoveContactMenuItem", (WPARAM) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP], (LPARAM) 0);
- }
- if (g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] != NULL)
- {
- CallService("CList/RemoveContactMenuItem", (WPARAM) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP], (LPARAM) 0);
- }
-
- int chatType = db_get_b(hContact, m_szModuleName, "SimpleChatRoom", 0);
-
- CLISTMENUITEM mi = {sizeof(mi)};
-
- if (chatType == 0)
- {
- mi.flags = CMIF_CHILDPOPUP;
- mi.position= -2000006102;
- mi.icolibItem = GetIconHandle("addContactToGroup");
- mi.pszName = GetIconDescription("addContactToGroup");
- mi.pszService = NULL;
- g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP] = Menu_AddContactMenuItem(&mi);
-
- if (!isOnline())
- {
- mi.flags = CMIM_FLAGS | CMIF_GRAYED;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP], (LPARAM) &mi);
- return 0;
- }
-
- mi.hParentMenu = (HGENMENU) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP];
- mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
-
- string fullSvcName;
- string svcName = m_szModuleName;
- svcName += "/AddContactToGroup_";
- DBVARIANT dbv;
-
- for (map<HANDLE, map<HANDLE, bool>>::iterator it = this->isMemberByGroupContact.begin();
- it != this->isMemberByGroupContact.end(); ++it)
- {
- map<HANDLE, bool>::iterator memberIt = it->second.find(hContact);
- // Only, if current contact is not already member of this group
- if ((memberIt == it->second.end() || memberIt->second == false) &&
- !db_get_s(it->first, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
- {
- fullSvcName = svcName + dbv.pszVal;
- mi.pszService = (char*) fullSvcName.c_str();
- mi.ptszName = mir_a2t_cp(this->GetContactDisplayName(it->first).c_str(), CP_UTF8);
- CreateServiceFunctionParam(mi.pszService, GlobalServiceParam<&WhatsAppProto::OnAddContactToGroup>, (LPARAM) it->first);
- Menu_AddContactMenuItem(&mi);
- db_free(&dbv);
- mir_free(mi.ptszName);
- }
- }
- }
- else if (chatType == 1)
- {
- mi.flags = CMIM_FLAGS;
- if (!isOnline() || db_get_b(hContact, m_szModuleName, "IsGroupMember", 0) == 0)
- {
- mi.flags |= CMIF_GRAYED;
- }
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_LEAVE_GROUP], (LPARAM) &mi);
- }
- else if (chatType == 2)
- {
- // owning chat/group
- mi.flags = CMIF_CHILDPOPUP;
- mi.position= -2000006102;
- mi.icolibItem = GetIconHandle("removeContactFromGroup");
- mi.pszName = GetIconDescription("removeContactFromGroup");
- mi.pszService = NULL;
- g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] = Menu_AddContactMenuItem(&mi);
-
- if (isOnline() && db_get_b(hContact, m_szModuleName, "IsGroupMember", 0) == 1)
- {
- map<HANDLE, map<HANDLE, bool>>::iterator groupsIt = this->isMemberByGroupContact.find(hContact);
- if (groupsIt == this->isMemberByGroupContact.end())
- {
- LOG("Group exists only on contact list");
- }
- else
- {
- mi.hParentMenu = (HGENMENU) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP];
- mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
-
- string fullSvcName;
- string svcName = m_szModuleName;
- svcName += "/RemoveContactFromGroup_";
- DBVARIANT dbv;
-
- for (map<HANDLE, bool>::iterator it = groupsIt->second.begin(); it != groupsIt->second.end(); ++it)
- {
- if (!db_get_s(it->first, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
- {
- fullSvcName = svcName + dbv.pszVal;
- mi.pszService = (char*) fullSvcName.c_str();
- mi.ptszName = mir_a2t_cp(this->GetContactDisplayName(it->first).c_str(), CP_UTF8);
- CreateServiceFunctionParam(mi.pszService,
- GlobalServiceParam<&WhatsAppProto::OnRemoveContactFromGroup>, (LPARAM) it->first);
- Menu_AddContactMenuItem(&mi);
- db_free(&dbv);
- mir_free(mi.ptszName);
- }
- }
- }
- mi.flags = CMIM_FLAGS;
- }
- else
- {
- mi.flags = CMIM_FLAGS | CMIF_GRAYED;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP], (LPARAM) &mi);
- }
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_REMOVE_GROUP], (LPARAM) &mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_CHANGE_GROUP_SUBJECT], (LPARAM) &mi);
- }
-
- return 0;
+ if (hContact)
+ LOG(this->GetContactDisplayName(hContact).c_str());
+ else
+ LOG("No contact found");
+
+ if (g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP] != NULL)
+ {
+ CallService("CList/RemoveContactMenuItem", (WPARAM) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP], (LPARAM) 0);
+ }
+ if (g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] != NULL)
+ {
+ CallService("CList/RemoveContactMenuItem", (WPARAM) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP], (LPARAM) 0);
+ }
+
+ int chatType = db_get_b(hContact, m_szModuleName, "SimpleChatRoom", 0);
+
+ CLISTMENUITEM mi = {sizeof(mi)};
+
+ if (chatType == 0)
+ {
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.position= -2000006102;
+ mi.icolibItem = GetIconHandle("addContactToGroup");
+ mi.pszName = GetIconDescription("addContactToGroup");
+ mi.pszService = NULL;
+ g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP] = Menu_AddContactMenuItem(&mi);
+
+ if (!isOnline())
+ {
+ mi.flags = CMIM_FLAGS | CMIF_GRAYED;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP], (LPARAM) &mi);
+ return 0;
+ }
+
+ mi.hParentMenu = (HGENMENU) g_hContactMenuItems[CMI_ADD_CONTACT_TO_GROUP];
+ mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
+
+ string fullSvcName;
+ string svcName = m_szModuleName;
+ svcName += "/AddContactToGroup_";
+ DBVARIANT dbv;
+
+ for (map<HANDLE, map<HANDLE, bool>>::iterator it = this->isMemberByGroupContact.begin();
+ it != this->isMemberByGroupContact.end(); ++it)
+ {
+ map<HANDLE, bool>::iterator memberIt = it->second.find(hContact);
+ // Only, if current contact is not already member of this group
+ if ((memberIt == it->second.end() || memberIt->second == false) &&
+ !db_get_s(it->first, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ {
+ fullSvcName = svcName + dbv.pszVal;
+ mi.pszService = (char*) fullSvcName.c_str();
+ mi.ptszName = mir_a2t_cp(this->GetContactDisplayName(it->first).c_str(), CP_UTF8);
+ CreateServiceFunctionParam(mi.pszService, GlobalServiceParam<&WhatsAppProto::OnAddContactToGroup>, (LPARAM) it->first);
+ Menu_AddContactMenuItem(&mi);
+ db_free(&dbv);
+ mir_free(mi.ptszName);
+ }
+ }
+ }
+ else if (chatType == 1)
+ {
+ mi.flags = CMIM_FLAGS;
+ if (!isOnline() || db_get_b(hContact, m_szModuleName, "IsGroupMember", 0) == 0)
+ {
+ mi.flags |= CMIF_GRAYED;
+ }
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_LEAVE_GROUP], (LPARAM) &mi);
+ }
+ else if (chatType == 2)
+ {
+ // owning chat/group
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.position= -2000006102;
+ mi.icolibItem = GetIconHandle("removeContactFromGroup");
+ mi.pszName = GetIconDescription("removeContactFromGroup");
+ mi.pszService = NULL;
+ g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] = Menu_AddContactMenuItem(&mi);
+
+ if (isOnline() && db_get_b(hContact, m_szModuleName, "IsGroupMember", 0) == 1)
+ {
+ map<HANDLE, map<HANDLE, bool>>::iterator groupsIt = this->isMemberByGroupContact.find(hContact);
+ if (groupsIt == this->isMemberByGroupContact.end())
+ {
+ LOG("Group exists only on contact list");
+ }
+ else
+ {
+ mi.hParentMenu = (HGENMENU) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP];
+ mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
+
+ string fullSvcName;
+ string svcName = m_szModuleName;
+ svcName += "/RemoveContactFromGroup_";
+ DBVARIANT dbv;
+
+ for (map<HANDLE, bool>::iterator it = groupsIt->second.begin(); it != groupsIt->second.end(); ++it)
+ {
+ if (!db_get_s(it->first, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ {
+ fullSvcName = svcName + dbv.pszVal;
+ mi.pszService = (char*) fullSvcName.c_str();
+ mi.ptszName = mir_a2t_cp(this->GetContactDisplayName(it->first).c_str(), CP_UTF8);
+ CreateServiceFunctionParam(mi.pszService,
+ GlobalServiceParam<&WhatsAppProto::OnRemoveContactFromGroup>, (LPARAM) it->first);
+ Menu_AddContactMenuItem(&mi);
+ db_free(&dbv);
+ mir_free(mi.ptszName);
+ }
+ }
+ }
+ mi.flags = CMIM_FLAGS;
+ }
+ else
+ {
+ mi.flags = CMIM_FLAGS | CMIF_GRAYED;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP], (LPARAM) &mi);
+ }
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_REMOVE_GROUP], (LPARAM) &mi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_CHANGE_GROUP_SUBJECT], (LPARAM) &mi);
+ }
+
+ return 0;
}
int WhatsAppProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
{
- LOG("");
+ LOG("");
char text[200];
strcpy(text,m_szModuleName);
char *tDest = text+strlen(text);
@@ -292,6 +292,6 @@ void WhatsAppProto::ToggleStatusMenuItems( BOOL bEnable )
CLISTMENUITEM clmi = {sizeof(clmi)};
clmi.flags = CMIM_FLAGS | (( bEnable ) ? 0 : CMIF_GRAYED);
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM ) m_hMenuRoot, ( LPARAM )&clmi );
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM ) m_hMenuRoot, ( LPARAM )&clmi );
CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM ) m_hMenuCreateGroup, ( LPARAM )&clmi );
}