summaryrefslogtreecommitdiff
path: root/src/modules/metacontacts
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-03 12:58:25 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-03 12:58:25 +0000
commit6e29a3eb7fafe4abc5d67056e362adc243ad9bf9 (patch)
tree41b0eff3dbb88c95804d61477420b28d8446fbfe /src/modules/metacontacts
parent5c2f5a27a78d50b6814a89c974214e7d294f5981 (diff)
no more META_LINK & META_ID variables
git-svn-id: http://svn.miranda-ng.org/main/trunk@8377 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/metacontacts')
-rw-r--r--src/modules/metacontacts/meta_addto.cpp58
-rw-r--r--src/modules/metacontacts/meta_edit.cpp6
-rw-r--r--src/modules/metacontacts/meta_menu.cpp80
-rw-r--r--src/modules/metacontacts/meta_services.cpp20
-rw-r--r--src/modules/metacontacts/meta_utils.cpp28
-rw-r--r--src/modules/metacontacts/metacontacts.h2
6 files changed, 94 insertions, 100 deletions
diff --git a/src/modules/metacontacts/meta_addto.cpp b/src/modules/metacontacts/meta_addto.cpp
index 54b5cf62ae..f2f03eb581 100644
--- a/src/modules/metacontacts/meta_addto.cpp
+++ b/src/modules/metacontacts/meta_addto.cpp
@@ -58,11 +58,12 @@ int FillList(HWND list, BOOL sort)
// The DB is searched through, to get all the metacontacts
for (MCONTACT hMetaUser = db_find_first(); hMetaUser; hMetaUser = db_find_next(hMetaUser)) {
// if it's not a MetaContact, go to the next
- if ( db_get_dw(hMetaUser, META_PROTO, META_ID, INVALID_CONTACT_ID) == INVALID_CONTACT_ID)
+ DBCachedContact *cc = CheckMeta(hMetaUser);
+ if (cc == NULL)
continue;
// get contact display name from clist
- TCHAR *swzContactDisplayName = cli.pfnGetContactDisplayName(hMetaUser, GCDNF_TCHAR);
+ TCHAR *swzContactDisplayName = cli.pfnGetContactDisplayName(hMetaUser, 0);
// don't insert huge strings that we have to compare with later
if (_tcslen(swzContactDisplayName) > 1023)
swzContactDisplayName[1024] = 0;
@@ -72,15 +73,13 @@ int FillList(HWND list, BOOL sort)
for (pos = 0; pos < i; pos++) {
TCHAR buff[1024];
SendMessage(list, LB_GETTEXT, pos, (LPARAM)buff);
- if ( _tcscmp(buff, swzContactDisplayName) > 0) {
+ if (_tcscmp(buff, swzContactDisplayName) > 0)
break;
- }
}
}
- int index = SendMessage(list, LB_INSERTSTRING, (WPARAM)pos, (LPARAM)swzContactDisplayName);
- SendMessage(list, LB_SETITEMDATA, index, (LPARAM)hMetaUser);
-
+ int index = SendMessage(list, LB_INSERTSTRING, pos, (LPARAM)swzContactDisplayName);
+ SendMessage(list, LB_SETITEMDATA, index, hMetaUser);
i++;
}
return i;
@@ -122,22 +121,29 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
switch(msg) {
case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
+ {
+ DBCachedContact *cc = CheckMeta(lParam);
+ if (cc == NULL) {
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
- if ( db_get_dw(lParam, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
- MessageBox(hwndDlg,
- TranslateT("This contact is a MetaContact.\nYou can't add a MetaContact to another MetaContact.\n\nPlease choose another."),
- TranslateT("MetaContact Conflict"),MB_ICONERROR);
- DestroyWindow(hwndDlg);
- return TRUE;
- }
+ if (IsMeta(cc)) {
+ MessageBox(hwndDlg,
+ TranslateT("This contact is a MetaContact.\nYou can't add a MetaContact to another MetaContact.\n\nPlease choose another."),
+ TranslateT("MetaContact Conflict"), MB_ICONERROR);
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
- if ( db_get_dw(lParam, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
- MessageBox(hwndDlg,
- TranslateT("This contact is already associated to a MetaContact.\nYou cannot add a contact to multiple MetaContacts."),
- TranslateT("Multiple MetaContacts"),MB_ICONERROR);
- DestroyWindow(hwndDlg);
- return TRUE;
+ if (IsSub(cc)) {
+ MessageBox(hwndDlg,
+ TranslateT("This contact is already associated to a MetaContact.\nYou cannot add a contact to multiple MetaContacts."),
+ TranslateT("Multiple MetaContacts"), MB_ICONERROR);
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
}
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); // user data is contact handle
@@ -147,15 +153,15 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
// Initialize the graphical part
CheckDlgButton(hwndDlg, IDC_ONLYAVAIL, BST_CHECKED); // Initially checked; display all metacontacts is only an option
// Besides, we can check if there is at least one metacontact to add the contact to.
- if ( BuildList(GetDlgItem(hwndDlg, IDC_METALIST), FALSE) <= 0) {
- if ( MessageBox(hwndDlg, TranslateT(szConvMsg), TranslateT("No suitable MetaContact found"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES)
- Meta_Convert((WPARAM)lParam,0);
+ if (BuildList(GetDlgItem(hwndDlg, IDC_METALIST), FALSE) <= 0) {
+ if (MessageBox(hwndDlg, TranslateT(szConvMsg), TranslateT("No suitable MetaContact found"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES)
+ Meta_Convert((WPARAM)lParam, 0);
DestroyWindow(hwndDlg);
return TRUE;
}
else {
// get contact display name from clist
- TCHAR *ptszCDN = cli.pfnGetContactDisplayName(lParam, GCDNF_TCHAR);
+ TCHAR *ptszCDN = cli.pfnGetContactDisplayName(lParam, 0);
if (!ptszCDN)
ptszCDN = TranslateT("a contact");
@@ -164,7 +170,7 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
mir_sntprintf(buf, SIZEOF(buf), TranslateT("Adding %s..."), ptszCDN);
SetWindowText(hwndDlg, buf);
}
- ShowWindow(hwndDlg,SW_SHOWNORMAL);
+ ShowWindow(hwndDlg, SW_SHOWNORMAL);
return TRUE;
case WM_COMMAND:
diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp
index 56277d8bd1..98c877a5ac 100644
--- a/src/modules/metacontacts/meta_edit.cpp
+++ b/src/modules/metacontacts/meta_edit.cpp
@@ -59,7 +59,7 @@ void FillContactList(HWND hWndDlg, CHANGES *chg)
for (int i = 0; i < chg->num_contacts; i++) {
LvItem.iItem = i;
- TCHAR *ptszCDN = cli.pfnGetContactDisplayName(chg->hContact[i], GCDNF_TCHAR);
+ TCHAR *ptszCDN = cli.pfnGetContactDisplayName(chg->hContact[i], 0);
if (ptszCDN == NULL)
ptszCDN = TranslateT("(Unknown Contact)");
@@ -292,7 +292,7 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WMU_SETTITLE:
{
- TCHAR *ptszCDN = cli.pfnGetContactDisplayName(lParam, GCDNF_TCHAR);
+ TCHAR *ptszCDN = cli.pfnGetContactDisplayName(lParam, 0);
if (ptszCDN == NULL)
ptszCDN = TranslateT("(Unknown Contact)");
@@ -385,7 +385,7 @@ INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (changes.hDefaultContact == changes.hContact[sel]) {
if (changes.num_contacts > 0) {
changes.hDefaultContact = changes.hContact[0];
- SetWindowText(GetDlgItem(hwndDlg,IDC_ED_DEFAULT), cli.pfnGetContactDisplayName(changes.hDefaultContact, GCDNF_TCHAR));
+ SetWindowText(GetDlgItem(hwndDlg,IDC_ED_DEFAULT), cli.pfnGetContactDisplayName(changes.hDefaultContact, 0));
}
else {
changes.hDefaultContact = 0;
diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp
index 2b712bd731..a341c8421b 100644
--- a/src/modules/metacontacts/meta_menu.cpp
+++ b/src/modules/metacontacts/meta_menu.cpp
@@ -130,7 +130,6 @@ void Meta_RemoveContactNumber(DBCachedContact *cc, int number)
// make sure this contact thinks it's part of this metacontact
if (hContact == cc->contactID) {
// remove link to meta contact
- db_unset(hContact, META_PROTO, META_LINK);
db_unset(hContact, META_PROTO, "Handle");
// stop ignoring, if we were
@@ -304,14 +303,14 @@ INT_PTR Meta_ForceDefault(WPARAM hMeta, LPARAM)
int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam)
{
- DBCachedContact *cc = CheckMeta(hMeta);
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMeta);
if (cc == NULL)
return 0;
CLISTMENUITEM mi = { sizeof(mi) };
Menu_ShowItem(hMenuRoot, false);
- if (db_get_dw(hMeta, META_PROTO, META_ID, -1) != INVALID_CONTACT_ID) {
+ if (IsMeta(cc)) {
// save the mouse pos in case they open a subcontact menu
GetCursorPos(&menuMousePoint);
@@ -327,9 +326,8 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam)
Menu_ModifyItem(hMenuDelete, &mi);
//show subcontact menu items
- int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", 0);
for (int i = 0; i < MAX_CONTACTS; i++) {
- if (i >= num_contacts) {
+ if (i >= cc->nSubs) {
Menu_ShowItem(hMenuContact[i], false);
continue;
}
@@ -383,41 +381,44 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM lParam)
// show hide nudge menu item
char serviceFunc[256];
mir_snprintf(serviceFunc, 256, "%s%s", GetContactProto(Meta_GetMostOnline(cc)), PS_SEND_NUDGE);
- CallService(MS_NUDGE_SHOWMENU, (WPARAM)META_PROTO, (LPARAM)ServiceExists(serviceFunc));
+ CallService(MS_NUDGE_SHOWMENU, (WPARAM)META_PROTO, ServiceExists(serviceFunc));
+ return 0;
}
- else { // This is a simple contact
- if (!Meta_IsEnabled()) {
- // groups disabled - all meta menu options hidden
- 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(hMeta, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
- // The contact is affected to a metacontact.
- Menu_ShowItem(hMenuDefault, true);
- mi.flags = CMIM_NAME;
- mi.pszName = LPGEN("Remove from metacontact");
- Menu_ModifyItem(hMenuDelete, &mi);
+ if (!Meta_IsEnabled()) {
+ // groups disabled - all meta menu options hidden
+ Menu_ShowItem(hMenuDefault, false);
+ Menu_ShowItem(hMenuDelete, false);
+ Menu_ShowItem(hMenuAdd, false);
+ Menu_ShowItem(hMenuConvert, false);
+ Menu_ShowItem(hMenuEdit, false);
+ return 0;
+ }
+
+ // the contact is affected to a metacontact
+ if (IsSub(cc)) {
+ Menu_ShowItem(hMenuDefault, true);
- Menu_ShowItem(hMenuAdd, false);
- Menu_ShowItem(hMenuConvert, false);
- Menu_ShowItem(hMenuEdit, false);
- }
- else {
- // The contact is neutral
- Menu_ShowItem(hMenuAdd, true);
- Menu_ShowItem(hMenuConvert, true);
- Menu_ShowItem(hMenuEdit, false);
- Menu_ShowItem(hMenuDelete, false);
- Menu_ShowItem(hMenuDefault, false);
- }
+ mi.flags = CMIM_NAME;
+ mi.pszName = LPGEN("Remove from metacontact");
+ Menu_ModifyItem(hMenuDelete, &mi);
- for (int i = 0; i < MAX_CONTACTS; i++)
- Menu_ShowItem(hMenuContact[i], false);
+ Menu_ShowItem(hMenuAdd, false);
+ Menu_ShowItem(hMenuConvert, false);
+ Menu_ShowItem(hMenuEdit, false);
+ }
+ else {
+ // The contact is neutral
+ 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++)
+ Menu_ShowItem(hMenuContact[i], false);
+
return 0;
}
@@ -507,10 +508,11 @@ void InitMenus()
// loop and copy data from subcontacts
if (options.copydata) {
- int meta_id;
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID, INVALID_CONTACT_ID)) != INVALID_CONTACT_ID)
- Meta_CopyData(CheckMeta(hContact));
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ DBCachedContact *cc = CheckMeta(hContact);
+ if (cc != NULL)
+ Meta_CopyData(cc);
+ }
}
Meta_HideLinkedContacts();
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp
index f189059f36..447002e33e 100644
--- a/src/modules/metacontacts/meta_services.cpp
+++ b/src/modules/metacontacts/meta_services.cpp
@@ -77,14 +77,8 @@ INT_PTR Meta_GetCaps(WPARAM wParam,LPARAM lParam)
case PFLAGNUM_5:
return PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
- case PFLAG_UNIQUEIDTEXT:
- return (INT_PTR) Translate("Meta ID");
-
case PFLAG_MAXLENOFMESSAGE:
return 2000;
-
- case PFLAG_UNIQUEIDSETTING:
- return (INT_PTR)META_ID;
}
return 0;
}
@@ -379,7 +373,7 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam)
cle.hDbEvent = (HANDLE)ccs->hContact; // use subcontact handle as key - then we can remove all events if the subcontact window is opened
cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
cle.pszService = "MetaContacts/CListMessageEvent";
- mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), cli.pfnGetContactDisplayName(hMeta, GCDNF_TCHAR));
+ mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), cli.pfnGetContactDisplayName(hMeta, 0));
cle.ptszTooltip = toolTip;
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
}
@@ -812,16 +806,18 @@ int Meta_UserInfo(WPARAM wParam, LPARAM hMeta)
int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam)
{
MessageWindowEventData *mwed = (MessageWindowEventData *)lParam;
- MCONTACT hMeta = 0;
- if ((hMeta = db_get_dw(mwed->hContact, META_PROTO, "Handle", 0)) != 0
- || db_get_dw(mwed->hContact, META_PROTO, META_ID, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(mwed->hContact);
+ if (cc == NULL)
+ return 0;
+
+ if (IsMeta(cc) || IsSub(cc)) {
// contact is subcontact of metacontact, or an actual metacontact - record whether window is open or closed
if (mwed->uType == MSG_WINDOW_EVT_OPEN || mwed->uType == MSG_WINDOW_EVT_OPENING) {
db_set_b(mwed->hContact, META_PROTO, "WindowOpen", 1);
- if (hMeta) // subcontact window opened - remove clist events we added for metacontact
- while (!CallService(MS_CLIST_REMOVEEVENT, hMeta, mwed->hContact));
+ if (IsSub(cc)) // subcontact window opened - remove clist events we added for metacontact
+ while (!CallService(MS_CLIST_REMOVEEVENT, cc->contactID, mwed->hContact));
}
else if (mwed->uType == MSG_WINDOW_EVT_CLOSE || mwed->uType == MSG_WINDOW_EVT_CLOSING)
db_set_b(mwed->hContact, META_PROTO, "WindowOpen", 0);
diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp
index 9295aca525..e9db1348e6 100644
--- a/src/modules/metacontacts/meta_utils.cpp
+++ b/src/modules/metacontacts/meta_utils.cpp
@@ -288,7 +288,7 @@ BOOL Meta_Assign(MCONTACT src, MCONTACT dest, BOOL set_as_default)
// write the display name
strcpy(buffer, "CListName");
strcat(buffer, szId);
- db_set_ts(dest, META_PROTO, buffer, cli.pfnGetContactDisplayName(src, GCDNF_TCHAR));
+ db_set_ts(dest, META_PROTO, buffer, cli.pfnGetContactDisplayName(src, 0));
// Get the status
if ( !szProto)
@@ -804,15 +804,9 @@ int Meta_HideMetaContacts(int hide)
int Meta_SuppressStatus(BOOL suppress)
{
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (db_get_dw(hContact, META_PROTO, META_LINK, INVALID_CONTACT_ID) != INVALID_CONTACT_ID) {
- // is a subcontact
- if (suppress)
- CallService(MS_IGNORE_IGNORE, hContact, (WPARAM)IGNOREEVENT_USERONLINE);
- else
- CallService(MS_IGNORE_UNIGNORE, hContact, (WPARAM)IGNOREEVENT_USERONLINE);
- }
- }
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ if (db_mc_isSub(hContact))
+ CallService((suppress) ? MS_IGNORE_IGNORE : MS_IGNORE_UNIGNORE, hContact, IGNOREEVENT_USERONLINE);
return 0;
}
@@ -820,19 +814,17 @@ int Meta_SuppressStatus(BOOL suppress)
int Meta_CopyContactNick(DBCachedContact *ccMeta, MCONTACT hContact)
{
DBVARIANT dbv, dbv_proto;
- char *szProto;
- if (options.lockHandle) {
+ if (options.lockHandle)
hContact = Meta_GetContactHandle(ccMeta, 0);
- }
- if (!hContact) return 1;
+ if (!hContact)
+ return 1;
- //szProto = GetContactProto(hContact);
+ // szProto = GetContactProto(hContact);
// read szProto direct from db, since we do this on load and other szProto plugins may not be loaded yet
if (!db_get(hContact, "Protocol", "p", &dbv_proto)) {
-
- szProto = dbv_proto.pszVal;
+ char *szProto = dbv_proto.pszVal;
if (options.clist_contact_name == CNNT_NICK && szProto) {
if (!Mydb_get(hContact, szProto, "Nick", &dbv)) {
db_set(ccMeta->contactID, META_PROTO, "Nick", &dbv);
@@ -844,7 +836,7 @@ int Meta_CopyContactNick(DBCachedContact *ccMeta, MCONTACT hContact)
}
}
else if (options.clist_contact_name == CNNT_DISPLAYNAME) {
- TCHAR *name = cli.pfnGetContactDisplayName(hContact, GCDNF_TCHAR);
+ TCHAR *name = cli.pfnGetContactDisplayName(hContact, 0);
if (name && _tcscmp(name, TranslateT("(Unknown Contact)")) != 0) {
db_set_ts(ccMeta->contactID, META_PROTO, "Nick", name);
db_free(&dbv_proto);
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h
index ecc28c7cca..2dcc6497f6 100644
--- a/src/modules/metacontacts/metacontacts.h
+++ b/src/modules/metacontacts/metacontacts.h
@@ -21,9 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#define META_FILTER "MetaContactsFilter"
-#define META_ID "MetaID"
#define META_FILTER_ID "MetaFilterID"
-#define META_LINK "MetaLink"
#define MAX_CONTACTS 20