diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-05 22:27:16 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-05 22:27:16 +0000 |
commit | 007b4c7301f0d26a72f89f74e9929f42e24eb3e6 (patch) | |
tree | b1ee30b70c6e36d1a06aed6885cb80dc560a68ca /plugins/MetaContacts/src | |
parent | f4a1bbc6ba4b8137cb868639ac146aa97e97e9df (diff) |
- rest of menus cleared;
- old database macroses wiped out from all plugins (left in m_database.h for compatibility)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4324 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MetaContacts/src')
-rw-r--r-- | plugins/MetaContacts/src/meta_menu.cpp | 151 | ||||
-rwxr-xr-x | plugins/MetaContacts/src/meta_services.cpp | 30 | ||||
-rw-r--r-- | plugins/MetaContacts/src/metacontacts.h | 2 |
3 files changed, 78 insertions, 105 deletions
diff --git a/plugins/MetaContacts/src/meta_menu.cpp b/plugins/MetaContacts/src/meta_menu.cpp index e4eaf8257d..7ba3115d16 100644 --- a/plugins/MetaContacts/src/meta_menu.cpp +++ b/plugins/MetaContacts/src/meta_menu.cpp @@ -325,7 +325,7 @@ INT_PTR Meta_ForceDefault(WPARAM wParam,LPARAM lParam) return 0;
}
-HANDLE hMenuContact[MAX_CONTACTS];
+HGENMENU hMenuContact[MAX_CONTACTS];
/** Called when the context-menu of a contact is about to be displayed
*
@@ -341,79 +341,75 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) DBVARIANT dbv;
char buf[512], idStr[512];
WORD status;
-
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_FLAGS;
if (db_get_dw((HANDLE)wParam, META_PROTO, META_ID,-1) != (DWORD)-1) {
// save the mouse pos in case they open a subcontact menu
GetCursorPos(&menuMousePoint);
// This is a MetaContact, show the edit, force default, and the delete menu, and hide the others
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi);
-
- mi.flags = CMIM_FLAGS | CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&mi);
+ Menu_ShowItem(hMenuEdit, true);
+ Menu_ShowItem(hMenuAdd, false);
+ Menu_ShowItem(hMenuConvert, false);
+ Menu_ShowItem(hMenuDefault, false);
+ Menu_ShowItem(hMenuDelete, false);
- mi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_HIDDEN; // we don't need delete - already in contact menu
- mi.pszName = Translate("Delete MetaContact");
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDelete, (LPARAM)&mi);
+ mi.flags = CMIM_NAME | CMIF_TCHAR;
+ mi.ptszName = (TCHAR*)TranslateT("Remove from MetaContact");
+ Menu_ModifyItem(hMenuDelete, &mi);
//show subcontact menu items
int num_contacts = db_get_dw((HANDLE)wParam, META_PROTO, "NumContacts", 0);
for (int i = 0; i < MAX_CONTACTS; i++) {
- if (i < num_contacts) {
- HANDLE hContact = Meta_GetContactHandle((HANDLE)wParam, i);
- char *szProto = GetContactProto(hContact);
- if ( !szProto)
- status = ID_STATUS_OFFLINE;
- else
- status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
-
- if (options.menu_contact_label == DNT_UID) {
- strcpy(buf, "Login");
- strcat(buf, _itoa(i, idStr, 10));
-
- db_get((HANDLE)wParam, META_PROTO, buf, &dbv);
- switch(dbv.type) {
- case DBVT_ASCIIZ:
- mir_snprintf(buf,512,"%s",dbv.pszVal);
- break;
- case DBVT_BYTE:
- mir_snprintf(buf,512,"%d",dbv.bVal);
- break;
- case DBVT_WORD:
- mir_snprintf(buf,512,"%d",dbv.wVal);
- break;
- case DBVT_DWORD:
- mir_snprintf(buf,512,"%d",dbv.dVal);
- break;
- default:
- buf[0] = 0;
- }
- db_free(&dbv);
- mi.pszName = buf;
- mi.flags = 0;
- }
- else {
- mi.ptszName = pcli->pfnGetContactDisplayName(hContact, GCDNF_TCHAR);
- mi.flags = CMIF_TCHAR;
+ if (i >= num_contacts) {
+ Menu_ShowItem(hMenuContact[i], false);
+ continue;
+ }
+
+ HANDLE hContact = Meta_GetContactHandle((HANDLE)wParam, i);
+ char *szProto = GetContactProto(hContact);
+ if ( !szProto)
+ status = ID_STATUS_OFFLINE;
+ else
+ status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
+
+ if (options.menu_contact_label == DNT_UID) {
+ strcpy(buf, "Login");
+ strcat(buf, _itoa(i, idStr, 10));
+
+ db_get((HANDLE)wParam, META_PROTO, buf, &dbv);
+ switch(dbv.type) {
+ case DBVT_ASCIIZ:
+ mir_snprintf(buf,512,"%s",dbv.pszVal);
+ break;
+ case DBVT_BYTE:
+ mir_snprintf(buf,512,"%d",dbv.bVal);
+ break;
+ case DBVT_WORD:
+ mir_snprintf(buf,512,"%d",dbv.wVal);
+ break;
+ case DBVT_DWORD:
+ mir_snprintf(buf,512,"%d",dbv.dVal);
+ break;
+ default:
+ buf[0] = 0;
}
-
- mi.flags |= CMIM_FLAGS | CMIM_NAME | CMIM_ICON;
-
- int iconIndex = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)hContact, 0);
- mi.hIcon = ImageList_GetIcon((HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0), iconIndex, 0);
-
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact[i], (LPARAM)&mi);
- DestroyIcon(mi.hIcon);
+ db_free(&dbv);
+ mi.pszName = buf;
+ mi.flags = 0;
}
else {
- mi.flags = CMIM_FLAGS | CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact[i], (LPARAM)&mi);
+ mi.ptszName = pcli->pfnGetContactDisplayName(hContact, GCDNF_TCHAR);
+ mi.flags = CMIF_TCHAR;
}
+
+ mi.flags |= CMIM_FLAGS | CMIM_NAME | CMIM_ICON;
+
+ int iconIndex = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)hContact, 0);
+ mi.hIcon = ImageList_GetIcon((HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0), iconIndex, 0);
+
+ Menu_ModifyItem(hMenuContact[i], &mi);
+ DestroyIcon(mi.hIcon);
}
// show hide nudge menu item
@@ -427,37 +423,36 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) else { // This is a simple contact
if ( !Meta_IsEnabled()) {
// groups disabled - all meta menu options hidden
- mi.flags = CMIM_FLAGS | CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDelete, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi);
+ Menu_ShowItem(hMenuDefault, false);
+ Menu_ShowItem(hMenuDelete, false);
+ Menu_ShowItem(hMenuAdd, false);
+ Menu_ShowItem(hMenuConvert, false);
+ Menu_ShowItem(hMenuEdit, false);
}
else if (db_get_dw((HANDLE)wParam, META_PROTO, META_LINK,(DWORD)-1)!=(DWORD)-1) {
// The contact is affected to a metacontact.
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&mi);
- mi.flags |= CMIM_NAME | CMIF_TCHAR;
+ Menu_ShowItem(hMenuDefault, true);
+
+ mi.flags = CMIM_NAME | CMIF_TCHAR;
mi.ptszName = (TCHAR*)TranslateT("Remove from MetaContact");
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDelete, (LPARAM)&mi);
- mi.flags = CMIM_FLAGS | CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi);
+ Menu_ModifyItem(hMenuDelete, &mi);
+
+ Menu_ShowItem(hMenuAdd, false);
+ Menu_ShowItem(hMenuConvert, false);
+ Menu_ShowItem(hMenuEdit, false);
}
else {
// The contact is neutral
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&mi);
- mi.flags |= CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDelete, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&mi);
+ Menu_ShowItem(hMenuAdd, true);
+ Menu_ShowItem(hMenuConvert, true);
+ Menu_ShowItem(hMenuEdit, false);
+ Menu_ShowItem(hMenuDelete, false);
+ Menu_ShowItem(hMenuDefault, false);
}
for (int i = 0; i < MAX_CONTACTS; i++) {
mi.flags = CMIM_FLAGS | CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact[i], (LPARAM)&mi);
+ Menu_ShowItem(hMenuContact[i], (LPARAM)&mi);
}
}
return 0;
diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp index 610a08af73..4ef0be7e69 100755 --- a/plugins/MetaContacts/src/meta_services.cpp +++ b/plugins/MetaContacts/src/meta_services.cpp @@ -229,31 +229,9 @@ INT_PTR MetaFilter_SendMessage(WPARAM wParam,LPARAM lParam) // if subcontact sending, add db event to keep metacontact history correct
if (options.metahistory && !(ccs->wParam & PREF_METANODB)) {
-
- // reject "file As Message" messages
- if (strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "<%fAM", 5) == 0)
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam); // continue processing
-
- // reject "data As Message" messages
- if (strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "<%dAM", 5) == 0)
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam); // continue processing
-
- // reject "OTR" messages
- if (strlen((char *)ccs->lParam) > 5 && strncmp((char *)ccs->lParam, "?OTR", 4) == 0)
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam); // continue processing
-
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.szModule = META_PROTO;
- dbei.flags = DBEF_SENT;
- dbei.timestamp = time(NULL);
- dbei.eventType = EVENTTYPE_MESSAGE;
- if (ccs->wParam & PREF_RTL) dbei.flags |= DBEF_RTL;
- if (ccs->wParam & PREF_UTF) dbei.flags |= DBEF_UTF;
- dbei.cbBlob = (DWORD)strlen((char *)ccs->lParam) + 1;
- if ( ccs->wParam & PREF_UNICODE )
- dbei.cbBlob *= ( sizeof( wchar_t )+1 );
- dbei.pBlob = (PBYTE)ccs->lParam;
- db_event_add(hMeta, &dbei);
+ HANDLE hContact = ccs->hContact; ccs->hContact = hMeta;
+ CallService(MS_PROTO_CHAINSEND, 0, lParam);
+ ccs->hContact = hContact;
}
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
@@ -672,7 +650,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) db_set_utf(hMeta, META_PROTO, "ListeningTo", dcws->value.pszVal);
break;
case DBVT_WCHAR:
- DBWriteContactSettingWString(hMeta, META_PROTO, "ListeningTo", dcws->value.pwszVal);
+ db_set_ws(hMeta, META_PROTO, "ListeningTo", dcws->value.pwszVal);
break;
case DBVT_DELETED:
db_unset(hMeta, META_PROTO, "ListeningTo");
diff --git a/plugins/MetaContacts/src/metacontacts.h b/plugins/MetaContacts/src/metacontacts.h index 8dcca13ceb..e5139a5e0b 100644 --- a/plugins/MetaContacts/src/metacontacts.h +++ b/plugins/MetaContacts/src/metacontacts.h @@ -63,7 +63,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // I can't think of a way around this - mental block
INT_PTR TranslateMenuFunc(HANDLE hContact, int i);
-extern HANDLE hMenuContact[MAX_CONTACTS];
+extern HGENMENU hMenuContact[MAX_CONTACTS];
extern HINSTANCE hInstance;
extern PLUGININFOEX pluginInfo;
|