diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-13 16:55:17 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-13 16:55:17 +0000 |
commit | cbe3cb21f5bca61a03bbd4ae811ee906e09b3f4f (patch) | |
tree | 4854fb66f4d59940efa3c1590237915851074dbf /src/modules/metacontacts | |
parent | 351bcbec48ed77af5f8efcc4d5198707922c5d86 (diff) |
- miranda32.exe now does nothing bug extends PATH to %miranda_root%\libs and loads mir_app.dll;
- everything that was in miranda32.exe (including resources) moved to mir_app.dll;
- exports from mir_app.dll now available for using directly, without perversions;
- src/stdplug.h deleted;
git-svn-id: http://svn.miranda-ng.org/main/trunk@14143 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/metacontacts')
-rw-r--r-- | src/modules/metacontacts/meta_addto.cpp | 224 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_api.cpp | 72 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_edit.cpp | 452 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_main.cpp | 85 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_menu.cpp | 449 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_options.cpp | 129 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_services.cpp | 912 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_utils.cpp | 576 | ||||
-rw-r--r-- | src/modules/metacontacts/metacontacts.h | 129 |
9 files changed, 0 insertions, 3028 deletions
diff --git a/src/modules/metacontacts/meta_addto.cpp b/src/modules/metacontacts/meta_addto.cpp deleted file mode 100644 index 575ecbcb55..0000000000 --- a/src/modules/metacontacts/meta_addto.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "metacontacts.h"
-
-/** Adds all the metacontacts desired in the listview.
-*
-* Adds all the metacontacts present in the database in the list,
-*
-* @param list : HANDLE to the list which will contain the columns.
-* @param nb_contacts : Number of loaded contacts.
-* @param contacts : A list of the contacts' identifiers
-*
-* @param id : Reference to a list of the MetaContacts IDs loaded in the listview.
-* Since this list is resized, its address must be passed.
-*
-* @return An integer specifying the number of rows added in the list.
-*/
-
-static int FillList(HWND list, BOOL sort)
-{
- int i = 0;
-
- // 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
- DBCachedContact *cc = CheckMeta(hMetaUser);
- if (cc == NULL)
- continue;
-
- // get contact display name from clist
- TCHAR *swzContactDisplayName = cli.pfnGetContactDisplayName(hMetaUser, 0);
- // don't insert huge strings that we have to compare with later
- if (mir_tstrlen(swzContactDisplayName) > 1023)
- swzContactDisplayName[1024] = 0;
-
- int pos = -1;
- if (sort) {
- for (pos = 0; pos < i; pos++) {
- TCHAR buff[1024];
- SendMessage(list, LB_GETTEXT, pos, (LPARAM)buff);
- if (mir_tstrcmp(buff, swzContactDisplayName) > 0)
- break;
- }
- }
-
- int index = SendMessage(list, LB_INSERTSTRING, pos, (LPARAM)swzContactDisplayName);
- SendMessage(list, LB_SETITEMDATA, index, hMetaUser);
- i++;
- }
- return i;
-}
-
-/** Build or update the list.
-*
-* @param list : HANDLE to the list which will contain the columns
-* @param id : Reference to a list that will contain all the MetaContacts IDs loaded in the listview
-* otherwise the list is only refilled \n (Warning : this value must be
-* set to TRUE only once per Dialog display, otherwise all columns will be doubled)
-*
-* @returns An integer specifying the number of rows inserted or -1 if there was a problem
-*/
-
-static int BuildList(HWND list, BOOL sort)
-{
- SendMessage(list, LB_RESETCONTENT, 0, 0);
- return FillList(list, sort);
-}
-
-/** Callback function for the <b>'Add To'</b> Dialog.
-*
-* All the UI is controlled here, from display to functionnalities.
-*
-* @param hwndDlg : HANDLE to the <b>'Add To'</b> Dialog.
-* @param uMsg : Specifies the message received by this dialog.
-* @param wParam : Specifies additional message-specific information.
-* @param lParam : Specifies additional message-specific information.
-*
-* @return TRUE if the dialog processed the message, FALSE if it did not.
-*/
-
-#define szConvMsg LPGEN("Either there is no metacontact in the database (in this case you should first convert a contact into one)\n\
-or there is none that can host this contact.\n\
-Another solution could be to convert this contact into a new metacontact.\n\nConvert this contact into a new metacontact?")
-
-static INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(lParam);
- if (cc == NULL) {
- DestroyWindow(hwndDlg);
- return TRUE;
- }
-
- if (cc->IsMeta()) {
- 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 (cc->IsSub()) {
- 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
-
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(I_ADD));
-
- // 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(lParam, 0);
- DestroyWindow(hwndDlg);
- return TRUE;
- }
- else {
- // get contact display name from clist
- TCHAR *ptszCDN = cli.pfnGetContactDisplayName(lParam, 0);
- if (!ptszCDN)
- ptszCDN = TranslateT("a contact");
-
- // ... and set it to the Window title.
- TCHAR buf[256];
- mir_sntprintf(buf, TranslateT("Adding %s..."), ptszCDN);
- SetWindowText(hwndDlg, buf);
- }
- ShowWindow(hwndDlg, SW_SHOWNORMAL);
- return TRUE;
-
- case WM_COMMAND:
- if (HIWORD(wParam) == LBN_DBLCLK) // emulate click ok Ok
- wParam = MAKEWPARAM(IDOK, BN_CLICKED);
-
- if (HIWORD(wParam) != BN_CLICKED)
- break; // Only clicks of buttons are relevant, let other COMMANDs through
-
- switch (LOWORD(wParam)) {
- case IDOK:
- {
- int item = SendDlgItemMessage(hwndDlg, IDC_METALIST, LB_GETCURSEL, 0, 0); // Get the index of the selected metacontact
- if (item == -1)
- return IDOK == MessageBox(hwndDlg, TranslateT("Please select a metacontact"), TranslateT("No metacontact selected"), MB_ICONHAND);
-
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- MCONTACT hMeta = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_METALIST, LB_GETITEMDATA, item, 0);
- if (!Meta_Assign(hContact, hMeta, FALSE))
- MessageBox(hwndDlg, TranslateT("Assignment to the metacontact failed."), TranslateT("Assignment failure"), MB_ICONERROR);
- }
- // fall through
- case IDCANCEL:
- DestroyWindow(hwndDlg);
- break;
-
- case IDC_CHK_SRT:
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_METALIST), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_METALIST), GWL_STYLE) ^ LBS_SORT);
- if (BuildList(GetDlgItem(hwndDlg, IDC_METALIST), IsDlgButtonChecked(hwndDlg, IDC_CHK_SRT) ? TRUE : FALSE) <= 0) {
- if (MessageBox(hwndDlg, TranslateT(szConvMsg), TranslateT("No suitable metacontact found"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES)
- Meta_Convert(lParam, 0);
- DestroyWindow(hwndDlg);
- return TRUE;
- }
- break;
- }
- break;
-
- case WM_DESTROY:
- // Free all allocated memory and return the focus to the CList
- HWND clist = GetParent(hwndDlg);
- Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
- EndDialog(hwndDlg, TRUE);
- SetFocus(clist);
- return TRUE;
- }
- return FALSE; // All other Message are not handled
-}
-
-/** Display the <b>'Add to'</b> Dialog
-*
-* Present a dialog in which the user can choose to which MetaContact this
-* contact will be added
-*
-* @param wParam : HANDLE to the contact that has been chosen.
-* @param lParam : Allways set to 0.
-*/
-
-INT_PTR Meta_AddTo(WPARAM hContact, LPARAM)
-{
- HWND clui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_METASELECT), clui, &Meta_SelectDialogProc, hContact);
- return 0;
-}
diff --git a/src/modules/metacontacts/meta_api.cpp b/src/modules/metacontacts/meta_api.cpp deleted file mode 100644 index f1b0926ad1..0000000000 --- a/src/modules/metacontacts/meta_api.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "metacontacts.h"
-
-// gets the handle for the 'most online' contact
-// wParam=(MCONTACT)hMetaContact
-// lParam=0
-// returns a handle to the 'most online' contact
-
-static INT_PTR MetaAPI_GetMostOnline(WPARAM hMetaContact, LPARAM)
-{
- DBCachedContact *cc = CheckMeta(hMetaContact);
- return (cc == NULL) ? NULL : Meta_GetMostOnline(cc);
-}
-
-// wParam=(HANDLE)hContact
-// lParam=0
-// convert a given contact into a metacontact
-
-static INT_PTR MetaAPI_ConvertToMeta(WPARAM wParam, LPARAM lParam)
-{
- return Meta_Convert(wParam, lParam);
-}
-
-// wParam=(HANDLE)hContact
-// lParam=(HANDLE)hMeta
-// add an existing contact to a metacontact
-
-static INT_PTR MetaAPI_AddToMeta(WPARAM wParam, LPARAM lParam)
-{
- return Meta_Assign(wParam, lParam, FALSE);
-}
-
-// wParam=0
-// lParam=(HANDLE)hContact
-// remove a contact from a metacontact
-
-static INT_PTR MetaAPI_RemoveFromMeta(WPARAM wParam, LPARAM lParam)
-{
- // notice we switch args - to keep the API function consistent with the others
- return Meta_Delete(lParam, wParam);
-}
-
-void CreateApiServices()
-{
- CreateServiceFunction(MS_MC_GETMOSTONLINECONTACT, MetaAPI_GetMostOnline);
- CreateServiceFunction(MS_MC_CONVERTTOMETA, MetaAPI_ConvertToMeta);
- CreateServiceFunction(MS_MC_ADDTOMETA, MetaAPI_AddToMeta);
- CreateServiceFunction(MS_MC_REMOVEFROMMETA, MetaAPI_RemoveFromMeta);
-}
diff --git a/src/modules/metacontacts/meta_edit.cpp b/src/modules/metacontacts/meta_edit.cpp deleted file mode 100644 index 7aaa351545..0000000000 --- a/src/modules/metacontacts/meta_edit.cpp +++ /dev/null @@ -1,452 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "metacontacts.h"
-
-// Holds the differents changes that have to made
-struct
-{
- MCONTACT hMeta; // HANDLE of the MetaContact that is edited.
- DBCachedContact *cc;
- MCONTACT hDefaultContact; // HANDLE of the new default contact
- MCONTACT hOfflineContact;
- int num_deleted, // DWORD number of deleted contacts
- num_contacts; // DWORD number of contacts
- MCONTACT hDeletedContacts[MAX_CONTACTS]; // HANDLEs of the subcontacts to be removed from this metacontact
- MCONTACT hContact[MAX_CONTACTS]; // HANDLEs of the subcontacts, in the order they should be in
-}
-static g_data; // global CHANGES structure
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static void FillContactList(HWND hList)
-{
- TCHAR buff[256];
-
- SendMessage(hList, LVM_DELETEALLITEMS, 0, 0);
-
- LVITEM LvItem = { 0 };
- LvItem.mask = LVIF_TEXT; // Text Style
-
- for (int i = 0; i < g_data.num_contacts; i++) {
- LvItem.iItem = i;
-
- TCHAR *ptszCDN = cli.pfnGetContactDisplayName(g_data.hContact[i], 0);
- if (ptszCDN == NULL)
- ptszCDN = TranslateT("(Unknown contact)");
-
- LvItem.iSubItem = 0; // clist display name
- LvItem.pszText = ptszCDN;
- ListView_InsertItem(hList, &LvItem);
-
- LvItem.iSubItem = 1; // id
- char *szProto = GetContactProto(g_data.hContact[i]);
- if (szProto) {
- PROTOACCOUNT *pa = ProtoGetAccount(szProto);
-
- char *szField = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
-
- DBVARIANT dbv;
- if (!db_get(g_data.hContact[i], szProto, szField, &dbv)) {
- switch (dbv.type) {
- case DBVT_ASCIIZ:
- _tcsncpy_s(buff, _A2T(dbv.pszVal), _TRUNCATE);
- break;
- case DBVT_WCHAR:
- _tcsncpy_s(buff, dbv.ptszVal, _TRUNCATE);
- break;
- case DBVT_BYTE:
- _itot(dbv.bVal, buff, 10);
- break;
- case DBVT_WORD:
- _itot(dbv.wVal, buff, 10);
- break;
- case DBVT_DWORD:
- _itot(dbv.dVal, buff, 10);
- break;
- default:
- buff[0] = 0;
- }
- db_free(&dbv);
- }
- else buff[0] = 0;
-
- LvItem.pszText = buff;
- SendMessage(hList, LVM_SETITEM, 0, (LPARAM)&LvItem); // Enter text to SubItems
-
- LvItem.iSubItem = 2; // protocol
- _tcsncpy_s(buff, (pa == NULL) ? _A2T(szProto) : pa->tszAccountName, _TRUNCATE);
- ListView_SetItem(hList, &LvItem);
- }
- else {
- LvItem.pszText = TranslateT("Unknown");
- ListView_SetItem(hList, &LvItem);
-
- LvItem.iSubItem = 2; // protocol
- ListView_SetItem(hList, &LvItem);
- }
- LvItem.iSubItem = 3; // Default (Yes/No)
- LvItem.pszText = (g_data.hContact[i] == g_data.hDefaultContact ? TranslateT("Yes") : TranslateT("No"));
- ListView_SetItem(hList, &LvItem);
-
- LvItem.iSubItem = 4; // Offline (Yes/No)
- LvItem.pszText = (g_data.hContact[i] == g_data.hOfflineContact ? TranslateT("Yes") : TranslateT("No"));
- ListView_SetItem(hList, &LvItem);
- }
-}
-
-static void SetListSelection(HWND hList, int sel)
-{
- ListView_SetItemState(hList, sel, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
-}
-
-/** Scans the \c CHANGES and call the appropriate function for each change.
-*
-* @param chg : Structure holding all the change info (See CHANGES).
-*/
-
-static void ApplyChanges()
-{
- // remove removed contacts
- for (int i = 0; i < g_data.num_deleted; i++) {
- if (Meta_Delete(g_data.hDeletedContacts[i], 0) != 0) // error, delete anyway
- Meta_RemoveContactNumber(g_data.cc, Meta_GetContactNumber(g_data.cc, g_data.hDeletedContacts[i]), true);
- if (g_data.hDeletedContacts[i] == g_data.hDefaultContact)
- g_data.hDefaultContact = 0;
- if (g_data.hDeletedContacts[i] == g_data.hOfflineContact)
- g_data.hOfflineContact = 0;
- }
-
- // set contact positions
- for (int i = 0; i < g_data.num_contacts; i++)
- if (Meta_GetContactNumber(g_data.cc, g_data.hContact[i]) != i)
- Meta_SwapContacts(g_data.cc, Meta_GetContactNumber(g_data.cc, g_data.hContact[i]), i);
-
- NotifyEventHooks(hSubcontactsChanged, g_data.hMeta, g_data.hDefaultContact);
-
- // set default
- db_mc_setDefaultNum(g_data.hMeta, (g_data.hDefaultContact) ? Meta_GetContactNumber(g_data.cc, g_data.hDefaultContact) : 0, true);
-
- // set offline
- if (g_data.hOfflineContact)
- db_set_dw(g_data.hMeta, META_PROTO, "OfflineSend", Meta_GetContactNumber(g_data.cc, g_data.hOfflineContact));
- else
- db_set_dw(g_data.hMeta, META_PROTO, "OfflineSend", INVALID_CONTACT_ID);
-
- // fix nick
- MCONTACT most_online = Meta_GetMostOnline(g_data.cc);
- Meta_CopyContactNick(g_data.cc, most_online);
-
- // fix status
- Meta_FixStatus(g_data.cc);
-
- // fix avatar
- most_online = Meta_GetMostOnlineSupporting(g_data.cc, PFLAGNUM_4, PF4_AVATARS);
- if (most_online) {
- PROTO_AVATAR_INFORMATION ai = { 0 };
- ai.hContact = g_data.hMeta;
- ai.format = PA_FORMAT_UNKNOWN;
- _tcsncpy_s(ai.filename, _T("X"), _TRUNCATE);
- if (CallProtoService(META_PROTO, PS_GETAVATARINFO, 0, (LPARAM)&ai) == GAIR_SUCCESS)
- db_set_ts(g_data.hMeta, "ContactPhoto", "File", ai.filename);
- }
-}
-
-LRESULT ProcessCustomDraw(LPARAM lParam)
-{
- LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
- switch (lplvcd->nmcd.dwDrawStage) {
- case CDDS_PREPAINT: //Before the paint cycle begins
- //request notifications for individual listview items
- return CDRF_NOTIFYITEMDRAW;
-
- case CDDS_ITEMPREPAINT: //Before an item is drawn
- if (g_data.hContact[(int)lplvcd->nmcd.dwItemSpec] == g_data.hDefaultContact)
- lplvcd->clrText = RGB(255, 0, 0);
-
- return CDRF_NEWFONT;
- }
-
- return 0;
-}
-
-/** Callback function for the <b>'Edit'</b> Dialog.
-*
-* All the UI is controlled here, from display to functionnalities.
-*
-* @param hwndDlg : HANDLE to the <b>'Edit'</b> Dialog.
-* @param uMsg : Specifies the message received by this dialog.
-* @param wParam : Specifies additional message-specific information.
-* @param lParam : Specifies additional message-specific information (handle of MetaContact to edit)
-*
-* @return TRUE if the dialog processed the message, FALSE if it did not.
-*/
-
-#define WMU_SETTITLE (WM_USER + 1)
-
-static INT_PTR CALLBACK Meta_EditDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_CONTACTS);
- int sel;
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(I_EDIT));
- {
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(lParam);
- if (cc == NULL) {
- DestroyWindow(hwndDlg);
- return FALSE;
- }
-
- // Disable the 'Apply' button.
- EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), FALSE);
-
- ListView_SetExtendedListViewStyle(hwndList, LVS_EX_FULLROWSELECT);
-
- // Create list columns
- LVCOLUMN LvCol = { 0 };
- LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
-
- LvCol.pszText = TranslateT("Contact");
- LvCol.cx = 150;
- ListView_InsertColumn(hwndList, 0, &LvCol);
-
- LvCol.pszText = TranslateT("ID");
- LvCol.cx = 130;
- ListView_InsertColumn(hwndList, 1, &LvCol);
-
- LvCol.pszText = TranslateT("Protocol");
- LvCol.cx = 100;
- ListView_InsertColumn(hwndList, 2, &LvCol);
-
- LvCol.pszText = TranslateT("Default");
- LvCol.cx = 60;
- ListView_InsertColumn(hwndList, 3, &LvCol);
-
- LvCol.pszText = TranslateT("Send offline");
- LvCol.cx = 85;
- ListView_InsertColumn(hwndList, 4, &LvCol);
-
- int offline_contact_number = db_get_dw(lParam, META_PROTO, "OfflineSend", INVALID_CONTACT_ID);
-
- memset(&g_data, 0, sizeof(g_data));
- g_data.cc = cc;
- g_data.hMeta = lParam;
- g_data.num_contacts = cc->nSubs;
- g_data.num_deleted = 0;
- g_data.hDefaultContact = Meta_GetContactHandle(g_data.cc, cc->nDefault);
- g_data.hOfflineContact = Meta_GetContactHandle(g_data.cc, offline_contact_number);
- for (int i = 0; i < cc->nSubs; i++)
- g_data.hContact[i] = Meta_GetContactHandle(g_data.cc, i);
-
- SendMessage(hwndDlg, WMU_SETTITLE, 0, lParam);
- }
- FillContactList(hwndList);
- ListView_SetItemState(hwndList, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
- return TRUE;
-
- case WMU_SETTITLE:
- {
- TCHAR *ptszCDN = cli.pfnGetContactDisplayName(lParam, 0);
- if (ptszCDN == NULL)
- ptszCDN = TranslateT("(Unknown contact)");
-
- SetDlgItemText(hwndDlg, IDC_ED_NAME, ptszCDN);
- }
- return TRUE;
-
- case WM_NOTIFY:
- if (LOWORD(wParam) == IDC_LST_CONTACTS) {
- LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
- if (pnmv->hdr.code == LVN_ITEMCHANGED) {
- int sel = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED | LVNI_SELECTED); // return item selected
-
- // enable buttons
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REM), sel != -1);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT), sel != -1 && g_data.hContact[sel] != g_data.hDefaultContact);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), sel > 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel != -1 && sel < g_data.num_contacts - 1));
-
- HWND hwndOffline = GetDlgItem(hwndDlg, IDC_BTN_SETOFFLINE);
- EnableWindow(hwndOffline, sel != -1);
- SetWindowText(hwndOffline, (sel != -1 && g_data.hContact[sel] != g_data.hOfflineContact) ? TranslateT("Send &offline") : TranslateT("Send &online"));
- }
- }
- break;
-
- case WM_COMMAND: // the message that is being sent always
- switch (HIWORD(wParam)) {
- case BN_CLICKED: // A button ('Remove', 'OK', 'Cancel' or 'Apply', normally) has been clicked
- switch (LOWORD(wParam)) {
- case IDC_VALIDATE: // Apply changes, if there is still one contact attached to the metacontact.
- if (g_data.num_contacts == 0) { // Otherwise, delete the metacontact.
- if (IDYES == MessageBox(hwndDlg, TranslateT(szDelMsg), TranslateT("Delete metacontact?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1)) {
- Meta_Delete(g_data.hMeta, 0);
- DestroyWindow(hwndDlg);
- }
- return TRUE;
- }
- ApplyChanges();
-
- // Disable the 'Apply' button.
- EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), FALSE);
- break;
-
- case IDOK:
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_VALIDATE))) { // If there are changes that could be made,
- if (g_data.num_contacts == 0) { // do the work that would have be done if the 'Apply' button was clicked.
- if (IDYES == MessageBox(hwndDlg, TranslateT(szDelMsg), TranslateT("Delete metacontact?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1)) {
- Meta_Delete(g_data.hMeta, 0);
- DestroyWindow(hwndDlg);
- }
- return TRUE;
- }
- ApplyChanges();
- }
- EndDialog(hwndDlg, IDOK);
- return TRUE;
-
- case IDCANCEL: // Simply close the dialog
- EndDialog(hwndDlg, IDCANCEL);
- return TRUE;
-
- case IDC_BTN_SETDEFAULT:
- sel = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED | LVNI_SELECTED);
- InvalidateRect(hwndList, 0, TRUE);
- g_data.hDefaultContact = g_data.hContact[sel];
- SendMessage(hwndDlg, WMU_SETTITLE, 0, (LPARAM)g_data.hContact[sel]);
-
- FillContactList(hwndList);
- SetListSelection(hwndList, sel);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
- return TRUE;
-
- case IDC_BTN_SETOFFLINE:
- sel = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED | LVNI_SELECTED);
- InvalidateRect(hwndList, 0, TRUE);
- if (g_data.hContact[sel] != g_data.hOfflineContact)
- g_data.hOfflineContact = g_data.hContact[sel];
- else
- g_data.hOfflineContact = 0;
-
- FillContactList(hwndList);
- SetListSelection(hwndList, sel);
- EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
- return TRUE;
-
- case IDC_BTN_REM:
- sel = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED | LVNI_SELECTED);
- g_data.num_contacts--;
- g_data.hDeletedContacts[g_data.num_deleted++] = g_data.hContact[sel];
- if (g_data.hDefaultContact == g_data.hContact[sel]) {
- if (g_data.num_contacts > 0) {
- g_data.hDefaultContact = g_data.hContact[0];
- SetDlgItemText(hwndDlg, IDC_ED_DEFAULT, cli.pfnGetContactDisplayName(g_data.hDefaultContact, 0));
- }
- else {
- g_data.hDefaultContact = 0;
- SetDlgItemText(hwndDlg, IDC_ED_DEFAULT, _T("None"));
- }
- }
-
- for (int i = sel; i < g_data.num_contacts; i++)
- g_data.hContact[i] = g_data.hContact[i + 1];
- FillContactList(hwndList);
-
- // disable buttons
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REM), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SETDEFAULT), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), FALSE);
-
- // Enable the 'Apply' button.
- EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
- return TRUE;
-
- case IDC_BTN_UP:
- sel = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED | LVNI_SELECTED);
- {
- MCONTACT temp = g_data.hContact[sel];
- g_data.hContact[sel] = g_data.hContact[sel - 1];
- g_data.hContact[sel - 1] = temp;
- }
- FillContactList(hwndList);
- sel--;
- SetListSelection(hwndList, sel);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), (sel > 0));
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel < g_data.num_contacts - 1));
- EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
- return TRUE;
-
- case IDC_BTN_DOWN:
- sel = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED | LVNI_SELECTED);
- {
- MCONTACT temp = g_data.hContact[sel];
- g_data.hContact[sel] = g_data.hContact[sel + 1];
- g_data.hContact[sel + 1] = temp;
- }
- FillContactList(hwndList);
- sel++;
- SetListSelection(hwndList, sel);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), (sel > 0));
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), (sel < g_data.num_contacts - 1));
- EnableWindow(GetDlgItem(hwndDlg, IDC_VALIDATE), TRUE);
- return TRUE;
- }
- }
- break;
-
- case WM_CLOSE:
- DestroyWindow(hwndDlg);
- return TRUE;
-
- case WM_DESTROY:
- Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
- EndDialog(hwndDlg, IDCANCEL);
- break;
- }
-
- return FALSE;
-}
-
-/** Display the <b>'Edit'</b> Dialog
-*
-* Present a dialog in which the user can edit some properties of the MetaContact.
-*
-* @param wParam : HANDLE to the MetaContact to be edited.
-* @param lParam : Allways set to 0.
-*/
-
-INT_PTR Meta_Edit(WPARAM wParam, LPARAM lParam)
-{
- HWND clui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_METAEDIT), clui, Meta_EditDialogProc, (LPARAM)wParam);
- return 0;
-}
diff --git a/src/modules/metacontacts/meta_main.cpp b/src/modules/metacontacts/meta_main.cpp deleted file mode 100644 index 8e2cd9c929..0000000000 --- a/src/modules/metacontacts/meta_main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "metacontacts.h"
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// icolib support
-
-static IconItem iconList[] = {
- { LPGEN("Toggle off"), "off", IDI_MCMENUOFF },
- { LPGEN("Toggle on"), "on", IDI_MCMENU },
- { LPGEN("Convert to metacontact"), "convert", IDI_MCCONVERT },
- { LPGEN("Add to existing"), "add", IDI_MCADD },
- { LPGEN("Edit"), "edit", IDI_MCEDIT },
- { LPGEN("Set to default"), "default", IDI_MCSETDEFAULT },
- { LPGEN("Remove"), "remove", IDI_MCREMOVE },
-};
-
-HANDLE GetIconHandle(IconIndex i)
-{
- return iconList[i].hIcolib;
-}
-
-HICON LoadIconEx(IconIndex i)
-{
- return Skin_GetIcon(iconList[i].szName);
-}
-
-void UnloadMetacontacts(void)
-{
- Meta_CloseHandles();
-}
-
-// Initializes the services provided and the link to those needed
-// Called when the plugin is loaded into Miranda
-int LoadMetacontacts(void)
-{
- Icon_Register(hInst, LPGEN("MetaContacts"), iconList, SIZEOF(iconList), "mc");
-
- db_set_resident(META_PROTO, "Status");
- db_set_resident(META_PROTO, "IdleTS");
-
- //set all contacts to 'offline', and initialize subcontact counter for db consistency check
- for (MCONTACT hContact = db_find_first(META_PROTO); hContact; hContact = db_find_next(hContact, META_PROTO)) {
- db_set_w(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE);
- db_set_dw(hContact, META_PROTO, "IdleTS", 0);
- }
-
- Meta_ReadOptions();
-
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = META_FILTER;
- pd.type = PROTOTYPE_FILTER;
- CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
-
- pd.szName = META_PROTO;
- pd.type = PROTOTYPE_VIRTUAL;
- CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
-
- // further db setup done in modules loaded (nick [protocol string required] & clist display name)
- Meta_InitServices();
- return 0;
-}
diff --git a/src/modules/metacontacts/meta_menu.cpp b/src/modules/metacontacts/meta_menu.cpp deleted file mode 100644 index e2a78aff38..0000000000 --- a/src/modules/metacontacts/meta_menu.cpp +++ /dev/null @@ -1,449 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include <m_nudge.h>
-#include "metacontacts.h"
-
-static HGENMENU hMenuContact[MAX_CONTACTS];
-
-static HGENMENU
- hMenuRoot, // root menu item of all subs
- hMenuConvert, // HANDLE to the convert menu item.
- hMenuAdd, // HANDLE to the add to menu item.
- hMenuEdit, // HANDLE to the edit menu item.
- hMenuDelete, // HANDLE to the delete menu item.
- hMenuDefault, // HANDLE to the delete menu item.
- hMenuForceDefault, // HANDLE to the delete menu item.
- hMenuOnOff; // HANDLE to the enable/disable menu item.
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Convert the contact chosen into a MetaContact.
-//
-// Create a new MetaContact, remove the selected contact from the \c CList
-// and attach it to the MetaContact.
-//
-// @param wParam : HANDLE to the contact that has been chosen.
-// @param lParam : Allways set to 0.
-
-INT_PTR Meta_Convert(WPARAM wParam, LPARAM)
-{
- ptrT tszGroup(db_get_tsa(wParam, "CList", "Group"));
-
- // Create a new metacontact
- MCONTACT hMetaContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if (hMetaContact == NULL)
- return NULL;
-
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMetaContact);
- if (cc == NULL)
- return 0;
-
- db_set_dw(hMetaContact, META_PROTO, "NumContacts", 0);
- cc->nSubs = 0;
- currDb->MetaSetDefault(cc); // explicitly write default sub to a db
-
- // Add the MetaContact protocol to the new meta contact
- CallService(MS_PROTO_ADDTOCONTACT, hMetaContact, (LPARAM)META_PROTO);
-
- if (tszGroup)
- db_set_ts(hMetaContact, "CList", "Group", tszGroup);
-
- // Assign the contact to the MetaContact just created (and make default).
- if (!Meta_Assign(wParam, hMetaContact, TRUE)) {
- MessageBox(0, TranslateT("There was a problem in assigning the contact to the metacontact"), TranslateT("Error"), MB_ICONEXCLAMATION);
- CallService(MS_DB_CONTACT_DELETE, hMetaContact, 0);
- return 0;
- }
-
- // hide the contact if clist groups disabled (shouldn't create one anyway since menus disabled)
- if (!db_mc_isEnabled())
- db_set_b(hMetaContact, "CList", "Hidden", 1);
-
- return hMetaContact;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Removes a sub from a metacontact
-
-void Meta_RemoveContactNumber(DBCachedContact *ccMeta, int number, bool bUpdateInfo)
-{
- if (ccMeta == NULL)
- return;
-
- // make sure this contact thinks it's part of this metacontact
- DBCachedContact *ccSub = currDb->m_cache->GetCachedContact(Meta_GetContactHandle(ccMeta, number));
- if (ccSub != NULL) {
- if (ccSub->parentID == ccMeta->contactID) {
- db_unset(ccSub->contactID, "CList", "Hidden");
-
- // stop ignoring, if we were
- if (options.bSuppressStatus)
- CallService(MS_IGNORE_UNIGNORE, ccSub->contactID, IGNOREEVENT_USERONLINE);
- }
- }
-
- // each contact from 'number' upwards will be moved down one
- // and the last one will be deleted
- for (int i = number+1; i < ccMeta->nSubs; i++)
- Meta_SwapContacts(ccMeta, i, i - 1);
-
- // remove the last one
- int id = ccMeta->nSubs - 1;
- char buffer[512];
- mir_snprintf(buffer, "Handle%d", id);
- db_unset(ccMeta->contactID, META_PROTO, buffer);
-
- mir_snprintf(buffer, "Protocol%d", id);
- db_unset(ccMeta->contactID, META_PROTO, buffer);
-
- mir_snprintf(buffer, "Status%d", id);
- db_unset(ccMeta->contactID, META_PROTO, buffer);
-
- mir_snprintf(buffer, "StatusString%d", id);
- db_unset(ccMeta->contactID, META_PROTO, buffer);
-
- mir_snprintf(buffer, "Login%d", id);
- db_unset(ccMeta->contactID, META_PROTO, buffer);
-
- mir_snprintf(buffer, "Nick%d", id);
- db_unset(ccMeta->contactID, META_PROTO, buffer);
-
- mir_snprintf(buffer, "CListName%d", id);
- db_unset(ccMeta->contactID, META_PROTO, buffer);
-
- if (ccSub != NULL) {
- ccSub->parentID = 0;
- currDb->MetaDetouchSub(ccMeta, ccMeta->nSubs - 1);
-
- currDb->MetaSplitHistory(ccMeta, ccSub);
- }
-
- // if the default contact was equal to or greater than 'number', decrement it (and deal with ends)
- if (ccMeta->nDefault >= number) {
- int iNumber = ccMeta->nDefault-1;
- if (iNumber < 0)
- iNumber = 0;
- db_mc_setDefaultNum(ccMeta->contactID, iNumber, true);
- }
-
- ccMeta->nSubs--;
- db_set_dw(ccMeta->contactID, META_PROTO, "NumContacts", ccMeta->nSubs);
-
- if (bUpdateInfo) {
- // fix nick
- Meta_CopyContactNick(ccMeta, Meta_GetMostOnline(ccMeta));
-
- // fix status
- Meta_FixStatus(ccMeta);
-
- // fix avatar
- MCONTACT hContact = Meta_GetMostOnlineSupporting(ccMeta, PFLAGNUM_4, PF4_AVATARS);
- if (hContact) {
- PROTO_AVATAR_INFORMATION ai = { 0 };
- ai.hContact = ccMeta->contactID;
- ai.format = PA_FORMAT_UNKNOWN;
- _tcsncpy_s(ai.filename, _T("X"), _TRUNCATE);
-
- if (CallProtoService(META_PROTO, PS_GETAVATARINFO, 0, (LPARAM)&ai) == GAIR_SUCCESS)
- db_set_ts(ccMeta->contactID, "ContactPhoto", "File", ai.filename);
- }
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Delete a MetaContact from the database
-//
-// Delete a MetaContact and remove all the information
-// concerning this MetaContact in the contact linked to it.
-//
-// @param wParam : HANDLE to the MetaContact to be deleted, or to the subcontact to be removed from the MetaContact
-// @param lParam : BOOL flag indicating whether to ask 'are you sure' when deleting a MetaContact
-
-INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion)
-{
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL)
- return 1;
-
- // The wParam is a metacontact
- if (cc->IsMeta()) {
- // check from recursion - see second half of this function
- if (!bSkipQuestion && IDYES !=
- MessageBox((HWND)CallService(MS_CLUI_GETHWND, 0, 0),
- TranslateT("This will remove the metacontact permanently.\n\nProceed anyway?"),
- TranslateT("Are you sure?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2))
- return 0;
-
- for (int i = cc->nSubs-1; i >= 0; i--)
- Meta_RemoveContactNumber(cc, i, false);
-
- NotifyEventHooks(hSubcontactsChanged, hContact, 0);
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
- }
- else if (cc->IsSub()) {
- if ((cc = currDb->m_cache->GetCachedContact(cc->parentID)) == NULL)
- return 2;
-
- if (cc->nSubs == 1) {
- if (IDYES == MessageBox(0, TranslateT(szDelMsg), TranslateT("Delete metacontact?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1))
- Meta_Delete(cc->contactID, 1);
-
- return 0;
- }
-
- Meta_RemoveContactNumber(cc, Meta_GetContactNumber(cc, hContact), true);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Set contact as MetaContact default
-//
-// Set the given contact to be the default one for the metacontact to which it is linked.
-//
-// @param wParam : HANDLE to the MetaContact to be set as default
-// @param lParam : HWND to the clist window
-// (This means the function has been called via the contact menu).
-
-INT_PTR Meta_Default(WPARAM hSub, LPARAM)
-{
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(db_mc_getMeta(hSub));
- if (cc && cc->IsMeta())
- db_mc_setDefault(cc->contactID, hSub, true);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Called when the context-menu of a contact is about to be displayed
-//
-// This will test which of the 4 menu item should be displayed, depending
-// on which contact triggered the event
-//
-// @param wParam : HANDLE to the contact that triggered the event
-// @param lParam : Always set to 0;
-
-int Meta_ModifyMenu(WPARAM hMeta, LPARAM)
-{
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMeta);
- if (cc == NULL)
- return 0;
-
- CLISTMENUITEM mi = { sizeof(mi) };
- Menu_ShowItem(hMenuRoot, false);
-
- if (cc->IsMeta()) {
- // 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
- Menu_ShowItem(hMenuEdit, true);
- Menu_ShowItem(hMenuAdd, false);
- Menu_ShowItem(hMenuConvert, false);
- Menu_ShowItem(hMenuDefault, false);
- Menu_ShowItem(hMenuDelete, false);
-
- mi.flags = CMIM_NAME;
- mi.pszName = LPGEN("Remove from metacontact");
- Menu_ModifyItem(hMenuDelete, &mi);
-
- // show subcontact menu items
- CMString tszNick;
- for (int i = 0; i < MAX_CONTACTS; i++) {
- if (i >= cc->nSubs) {
- Menu_ShowItem(hMenuContact[i], false);
- continue;
- }
-
- MCONTACT hContact = Meta_GetContactHandle(cc, i);
- char *szProto = GetContactProto(hContact);
-
- if (options.menu_contact_label == DNT_UID) {
- Meta_GetSubNick(hMeta, i, tszNick);
- mi.ptszName = tszNick.GetBuffer();
- }
- else mi.ptszName = cli.pfnGetContactDisplayName(hContact, 0);
-
- mi.flags = CMIF_TCHAR | CMIM_FLAGS | CMIM_NAME | CMIM_ICON;
-
- int iconIndex = CallService(MS_CLIST_GETCONTACTICON, hContact, 0);
- mi.hIcon = ImageList_GetIcon((HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0), iconIndex, 0);
-
- Menu_ModifyItem(hMenuContact[i], &mi);
- DestroyIcon(mi.hIcon);
-
- Menu_ShowItem(hMenuRoot, true);
- }
-
- // show hide nudge menu item
- char serviceFunc[256];
- mir_snprintf(serviceFunc, SIZEOF(serviceFunc), "%s%s", GetContactProto(Meta_GetMostOnline(cc)), PS_SEND_NUDGE);
- CallService(MS_NUDGE_SHOWMENU, (WPARAM)META_PROTO, ServiceExists(serviceFunc));
- return 0;
- }
-
- PROTOACCOUNT *pa = Proto_GetAccount(cc->szProto);
- if (!db_mc_isEnabled() || !pa || pa->bIsVirtual) {
- // 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 (cc->IsSub()) {
- Menu_ShowItem(hMenuDefault, true);
-
- mi.flags = CMIM_NAME;
- mi.pszName = LPGEN("Remove from metacontact");
- Menu_ModifyItem(hMenuDelete, &mi);
- Menu_ShowItem(hMenuDelete, true);
-
- Menu_ShowItem(hMenuAdd, false);
- Menu_ShowItem(hMenuConvert, false);
- Menu_ShowItem(hMenuEdit, false);
- }
- else {
- // The contact is neutral
- bool bHideChat = db_get_b(hMeta, cc->szProto, "ChatRoom", 0) == 0;
- Menu_ShowItem(hMenuAdd, bHideChat);
- Menu_ShowItem(hMenuConvert, bHideChat);
- 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;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Toggle metacontacts on/off
-
-INT_PTR Meta_OnOff(WPARAM, LPARAM)
-{
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_NAME | CMIM_ICON;
-
- bool bToggled = !db_mc_isEnabled();
- db_set_b(0, META_PROTO, "Enabled", bToggled);
- if (bToggled) {
- mi.icolibItem = GetIconHandle(I_MENUOFF);
- mi.pszName = LPGEN("Toggle metacontacts off");
- }
- else {
- mi.icolibItem = GetIconHandle(I_MENU);
- mi.pszName = LPGEN("Toggle metacontacts on");
- }
- Menu_ModifyItem(hMenuOnOff, &mi);
-
- db_mc_enable(bToggled);
- Meta_HideMetaContacts(!bToggled);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Menu initialization
-
-void InitMenus()
-{
- CLISTMENUITEM mi = { sizeof(mi) };
-
- // main menu item
- mi.icolibItem = GetIconHandle(I_MENUOFF);
- mi.pszName = LPGEN("Toggle metacontacts off");
- mi.pszService = "MetaContacts/OnOff";
- mi.position = 500010000;
- hMenuOnOff = Menu_AddMainMenuItem(&mi);
-
- // contact menu items
- mi.icolibItem = GetIconHandle(I_CONVERT);
- mi.position = -200010;
- mi.pszName = LPGEN("Convert to metacontact");
- mi.pszService = "MetaContacts/Convert";
- hMenuConvert = Menu_AddContactMenuItem(&mi);
-
- mi.icolibItem = GetIconHandle(I_ADD);
- mi.position = -200009;
- mi.pszName = LPGEN("Add to existing metacontact...");
- mi.pszService = "MetaContacts/AddTo";
- hMenuAdd = Menu_AddContactMenuItem(&mi);
-
- mi.icolibItem = GetIconHandle(I_EDIT);
- mi.position = -200010;
- mi.pszName = LPGEN("Edit metacontact...");
- mi.pszService = "MetaContacts/Edit";
- hMenuEdit = Menu_AddContactMenuItem(&mi);
-
- mi.icolibItem = GetIconHandle(I_SETDEFAULT);
- mi.position = -200009;
- mi.pszName = LPGEN("Set as metacontact default");
- mi.pszService = "MetaContacts/Default";
- hMenuDefault = Menu_AddContactMenuItem(&mi);
-
- mi.icolibItem = GetIconHandle(I_REMOVE);
- mi.position = -200008;
- mi.pszName = LPGEN("Delete metacontact");
- mi.pszService = "MetaContacts/Delete";
- hMenuDelete = Menu_AddContactMenuItem(&mi);
-
- mi.position = -99000;
- mi.flags = CMIF_HIDDEN | CMIF_ROOTPOPUP;
- mi.icolibItem = 0;
- mi.pszName = LPGEN("Subcontacts");
- hMenuRoot = Menu_AddContactMenuItem(&mi);
-
- mi.flags = CMIF_HIDDEN | CMIF_CHILDPOPUP;
- mi.hParentMenu = hMenuRoot;
- for (int i = 0; i < MAX_CONTACTS; i++) {
- mi.position--;
- mi.pszName = "";
-
- char buffer[512];
- mir_snprintf(buffer, "MetaContacts/MenuFunc%d", i);
- mi.pszService = buffer;
- mi.position++;
- hMenuContact[i] = Menu_AddContactMenuItem(&mi);
- }
-
- Meta_HideLinkedContacts();
-
- if (!db_mc_isEnabled()) {
- // modify main menu item
- mi.flags = CMIM_NAME | CMIM_ICON;
- mi.icolibItem = GetIconHandle(I_MENU);
- mi.pszName = LPGEN("Toggle metacontacts on");
- Menu_ModifyItem(hMenuOnOff, &mi);
-
- Meta_HideMetaContacts(true);
- }
- else {
- Meta_SuppressStatus(options.bSuppressStatus);
- Meta_HideMetaContacts(false);
- }
-}
diff --git a/src/modules/metacontacts/meta_options.cpp b/src/modules/metacontacts/meta_options.cpp deleted file mode 100644 index 0ff0b9b48c..0000000000 --- a/src/modules/metacontacts/meta_options.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "metacontacts.h"
-
-MetaOptions options;
-
-int Meta_WriteOptions()
-{
- db_set_b(NULL, META_PROTO, "LockHandle", options.bLockHandle);
- db_set_b(NULL, META_PROTO, "SuppressStatus", options.bSuppressStatus);
- db_set_w(NULL, META_PROTO, "MenuContactLabel", (WORD)options.menu_contact_label);
- db_set_w(NULL, META_PROTO, "MenuContactFunction", (WORD)options.menu_function);
- db_set_w(NULL, META_PROTO, "CListContactName", (WORD)options.clist_contact_name);
- db_set_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", (DWORD)(options.set_status_from_offline_delay));
- return 0;
-}
-
-int Meta_ReadOptions()
-{
- db_mc_enable(db_get_b(NULL, META_PROTO, "Enabled", true) != 0);
- options.bSuppressStatus = db_get_b(NULL, META_PROTO, "SuppressStatus", true) != 0;
- options.menu_contact_label = (int)db_get_w(NULL, META_PROTO, "MenuContactLabel", DNT_UID);
- options.menu_function = (int)db_get_w(NULL, META_PROTO, "MenuContactFunction", FT_MENU);
- options.clist_contact_name = (int)db_get_w(NULL, META_PROTO, "CListContactName", CNNT_DISPLAYNAME);
- options.set_status_from_offline_delay = (int)db_get_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", DEFAULT_SET_STATUS_SLEEP_TIME);
- options.bLockHandle = db_get_b(NULL, META_PROTO, "LockHandle", false) != 0;
- return 0;
-}
-
-class CMetaOptionsDlg : public CDlgBase
-{
- CCtrlCheck m_btnUid, m_btnDid, m_btnCheck;
- CCtrlCheck m_btnMsg, m_btnMenu, m_btnInfo;
- CCtrlCheck m_btnNick, m_btnName, m_btnLock;
-
-public:
- CMetaOptionsDlg() :
- CDlgBase(hInst, IDD_METAOPTIONS),
- m_btnUid(this, IDC_RAD_UID),
- m_btnDid(this, IDC_RAD_DID),
- m_btnMsg(this, IDC_RAD_MSG),
- m_btnMenu(this, IDC_RAD_MENU),
- m_btnInfo(this, IDC_RAD_INFO),
- m_btnNick(this, IDC_RAD_NICK),
- m_btnName(this, IDC_RAD_NAME),
- m_btnLock(this, IDC_CHK_LOCKHANDLE),
- m_btnCheck(this, IDC_CHK_SUPPRESSSTATUS)
- {
- }
-
- virtual void OnInitDialog()
- {
- m_btnLock.SetState(options.bLockHandle);
- m_btnCheck.SetState(options.bSuppressStatus);
-
- if (options.menu_contact_label == DNT_UID)
- m_btnUid.SetState(true);
- else
- m_btnDid.SetState(true);
-
- switch (options.menu_function) {
- case FT_MSG: m_btnMsg.SetState(true); break;
- case FT_MENU: m_btnMenu.SetState(true); break;
- case FT_INFO: m_btnInfo.SetState(true); break;
- }
-
- if (options.clist_contact_name == CNNT_NICK)
- m_btnNick.SetState(true);
- else
- m_btnName.SetState(true);
- }
-
- virtual void OnApply()
- {
- options.bLockHandle = m_btnLock.GetState() != 0;
- options.bSuppressStatus = m_btnCheck.GetState() != 0;
-
- if (m_btnUid.GetState()) options.menu_contact_label = DNT_UID;
- else if (m_btnDid.GetState()) options.menu_contact_label = DNT_DID;
-
- if (m_btnMsg.GetState()) options.menu_function = FT_MSG;
- else if (m_btnMenu.GetState()) options.menu_function = FT_MENU;
- else if (m_btnInfo.GetState()) options.menu_function = FT_INFO;
-
- if (m_btnNick.GetState()) options.clist_contact_name = CNNT_NICK;
- else if (m_btnName.GetState()) options.clist_contact_name = CNNT_DISPLAYNAME;
-
- Meta_WriteOptions();
-
- Meta_SuppressStatus(options.bSuppressStatus);
- Meta_SetAllNicks();
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int Meta_OptInit(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.position = -790000000;
- odp.flags = ODPF_BOLDGROUPS;
- odp.pszTitle = LPGEN("Metacontacts");
- odp.pszGroup = LPGEN("Contacts");
- odp.pDialog = new CMetaOptionsDlg();
- Options_AddPage(wParam, &odp);
- return 0;
-}
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp deleted file mode 100644 index 72f60c5f71..0000000000 --- a/src/modules/metacontacts/meta_services.cpp +++ /dev/null @@ -1,912 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include <m_nudge.h>
-
-#include "metacontacts.h"
-
-extern "C" MIR_CORE_DLL(void) db_mc_notifyDefChange(WPARAM wParam, LPARAM lParam);
-
-char *pendingACK = 0; // Name of the protocol in which an ACK is about to come.
-
-int previousMode, // Previous status of the MetaContacts Protocol
-mcStatus; // Current status of the MetaContacts Protocol
-
-HANDLE
-hSubcontactsChanged, // HANDLE to the 'contacts changed' event
-hEventNudge;
-
-UINT_PTR setStatusTimerId = 0;
-BOOL firstSetOnline = TRUE; // see Meta_SetStatus function
-
-OBJLIST<MetaSrmmData> arMetaWindows(1, NumericKeySortT);
-
-/** Get the capabilities of the "MetaContacts" protocol.
-*
-* @param wParam : equals to one of the following values :\n
-<tt> PFLAGNUM_1 | PFLAGNUM_2 | PFLAGNUM_3 | PFLAGNUM_4 | PFLAG_UNIQUEIDTEXT | PFLAG_MAXLENOFMESSAGE | PFLAG_UNIQUEIDSETTING </tt>.
-* @param lParam : Allways set to 0.
-*
-* @return Depending on the \c WPARAM.
-*/
-INT_PTR Meta_GetCaps(WPARAM wParam, LPARAM lParam)
-{
- switch (wParam) {
- case PFLAGNUM_1:
- return PF1_IM | PF1_CHAT | PF1_FILESEND | PF1_MODEMSGRECV | PF1_NUMERICUSERID;
-
- case PFLAGNUM_2:
- return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
-
- case PFLAGNUM_3:
- return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
-
- case PFLAGNUM_4:
- return PF4_SUPPORTTYPING | PF4_AVATARS;
-
- case PFLAGNUM_5:
- return PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
-
- case PFLAG_MAXLENOFMESSAGE:
- return 2000;
- }
- return 0;
-}
-
-/** Copy the name of the protocole into lParam
-* @param wParam : max size of the name
-* @param lParam : reference to a char *, which will hold the name
-*/
-
-INT_PTR Meta_GetName(WPARAM wParam, LPARAM lParam)
-{
- char *name = (char *)Translate(META_PROTO);
- size_t size = min(mir_strlen(name), wParam - 1); // copy only the first size bytes.
- if (strncpy((char *)lParam, name, size) == NULL)
- return 1;
- ((char *)lParam)[size] = '\0';
- return 0;
-}
-
-/** Loads the icon corresponding to the status
-* Called by the CList when the status changes.
-* @param wParam : one of the following values : \n
-<tt>PLI_PROTOCOL | PLI_ONLINE | PLI_OFFLINE</tt>
-* @return an \c HICON in which the icon has been loaded.
-*/
-
-INT_PTR Meta_LoadIcon(WPARAM wParam, LPARAM lParam)
-{
- UINT id;
- switch (wParam & 0xFFFF) {
- case PLI_PROTOCOL:
- id = IDI_MCMENU;
- break;
- case PLI_ONLINE:
- id = IDI_MCMENU;
- break;
- case PLI_OFFLINE:
- id = IDI_MCMENU;
- break;
- default:
- return 0;
- }
-
- return (INT_PTR)LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON,
- GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON),
- GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static void Meta_SetSrmmSub(MCONTACT hMeta, MCONTACT hSub)
-{
- MetaSrmmData tmp = { hMeta };
- if (MetaSrmmData *p = arMetaWindows.find(&tmp))
- p->m_hSub = hSub;
-}
-
-static INT_PTR MetaFilter_RecvMessage(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *ccs = (CCSDATA*)lParam;
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(ccs->hContact);
- if (cc && cc->IsSub())
- Meta_SetSrmmSub(cc->parentID, cc->contactID);
-
- CallService(MS_PROTO_CHAINRECV, wParam, lParam);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CALLBACK SetStatusThread(HWND hWnd, UINT msg, UINT_PTR id, DWORD dw)
-{
- previousMode = mcStatus;
-
- mcStatus = ID_STATUS_ONLINE;
- ProtoBroadcastAck(META_PROTO, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)previousMode, mcStatus);
-
- KillTimer(0, setStatusTimerId);
-}
-
-/** Changes the status and notifies everybody
-* @param wParam : The new mode
-* @param lParam : Allways set to 0.
-*/
-
-INT_PTR Meta_SetStatus(WPARAM wParam, LPARAM lParam)
-{
- // firstSetOnline starts out true - used to delay metacontact's 'onlineness' to prevent double status notifications on startup
- if (mcStatus == ID_STATUS_OFFLINE && firstSetOnline) {
- // causes crash on exit if miranda is closed in under options.set_status_from_offline milliseconds!
- setStatusTimerId = SetTimer(0, 0, options.set_status_from_offline_delay, SetStatusThread);
- firstSetOnline = FALSE;
- }
- else {
- previousMode = mcStatus;
- mcStatus = (int)wParam;
- ProtoBroadcastAck(META_PROTO, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)previousMode, mcStatus);
- }
- return 0;
-}
-
-/** Returns the current status
-*/
-INT_PTR Meta_GetStatus(WPARAM wParam, LPARAM lParam)
-{
- return mcStatus;
-}
-
-//////////////////////////////////////////////////////////
-/// Copied from MSN plugin - sent acks need to be from different thread :(
-//////////////////////////////////////////////////////////
-
-struct TFakeAckParams
-{
- HANDLE hEvent;
- MCONTACT hContact;
- LONG id;
- char msg[512];
-};
-
-static void __cdecl sttFakeAckFail(void *param)
-{
- TFakeAckParams *tParam = (TFakeAckParams*)param;
- WaitForSingleObject(tParam->hEvent, INFINITE);
-
- Sleep(100);
- ProtoBroadcastAck(META_PROTO, tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)tParam->id, (WPARAM)tParam->msg);
-
- CloseHandle(tParam->hEvent);
- mir_free(tParam);
-}
-
-INT_PTR Meta_SendNudge(WPARAM wParam, LPARAM lParam)
-{
- DBCachedContact *cc = CheckMeta(wParam);
- if (cc == NULL)
- return 1;
-
- MCONTACT hSubContact = Meta_GetMostOnline(cc);
- return CallProtoService(GetContactProto(hSubContact), PS_SEND_NUDGE, hSubContact, lParam);
-}
-
-/** Send a message to the protocol specific network.
-*
-* Call the function specific to the protocol that belongs
-* to the contact chosen to send the message.
-*
-* @param wParam : index of the protocol in the protocol chain.
-* @param lParam : CCSDATA structure holding all the information abour rhe message.
-*
-* @return 0 on success, 1 otherwise.
-*/
-
-INT_PTR Meta_SendMessage(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *ccs = (CCSDATA*)lParam;
-
- DBCachedContact *cc = CheckMeta(ccs->hContact);
- if (cc == NULL || cc->nDefault == -1) {
- // This is a simple contact, let through the stack of protocols
- // (this should normally not happen, since linked contacts do not appear on the list.)
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
- }
-
- MCONTACT hMostOnline = db_mc_getSrmmSub(cc->contactID);
- if (!hMostOnline) {
- // send failure to notify user of reason
- HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-
- TFakeAckParams *tfap = (TFakeAckParams *)mir_alloc(sizeof(TFakeAckParams));
- tfap->hContact = ccs->hContact;
- tfap->hEvent = hEvent;
- tfap->id = 10;
- strncpy(tfap->msg, Translate("No online contacts found."), SIZEOF(tfap->msg) - 1);
-
- CloseHandle(mir_forkthread(sttFakeAckFail, (void*)tfap));
- SetEvent(hEvent);
- return 10;
- }
-
- Meta_CopyContactNick(cc, hMostOnline);
-
- ccs->hContact = hMostOnline;
- char *proto = GetContactProto(hMostOnline);
- Meta_SetNick(proto); // (no matter what was there before)
-
- return CallContactService(ccs->hContact, PSS_MESSAGE, ccs->wParam, ccs->lParam);
-}
-
-/** Called when an ACK is received.
-*
-* Retransmit the ACK sent by a simple contact so that it
-* looks like it was the MetaContact that sends the ACK.
-*
-* @param wParam : Allways set to 0.
-* @param lParam : Reference to a ACKDATA that contains information about the ACK.
-* @returns 0 on success, 1 otherwise.
-*/
-
-int Meta_HandleACK(WPARAM, LPARAM lParam)
-{
- ACKDATA *ack = (ACKDATA*)lParam;
- if (ack == NULL)
- return 0;
- DBCachedContact *cc = CheckMeta(ack->hContact);
- if (cc == NULL)
- return 0;
-
- if (!mir_strcmp(ack->szModule, META_PROTO))
- return 0; // don't rebroadcast our own acks
-
- // if it's for something we don't support, ignore
- if (ack->type != ACKTYPE_MESSAGE && ack->type != ACKTYPE_CHAT && ack->type != ACKTYPE_FILE && ack->type != ACKTYPE_AWAYMSG && ack->type != ACKTYPE_AVATAR && ack->type != ACKTYPE_GETINFO)
- return 0;
-
- // change the hContact in the avatar info struct, if it's the avatar we're using - else drop it
- if (ack->type == ACKTYPE_AVATAR) {
- if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED || ack->result == ACKRESULT_STATUS) {
- DBVARIANT dbv;
-
- // change avatar if the most online supporting avatars changes, or if we don't have one
- MCONTACT hMostOnline = Meta_GetMostOnlineSupporting(cc, PFLAGNUM_4, PF4_AVATARS);
- if (ack->hContact == 0 || ack->hContact != hMostOnline)
- return 0;
-
- if (!db_get(ack->hContact, "ContactPhoto", "File", &dbv)) {
- db_set_ts(cc->contactID, "ContactPhoto", "File", dbv.ptszVal);
- db_free(&dbv);
- }
-
- if (ack->hProcess) {
- PROTO_AVATAR_INFORMATION ai;
- memcpy(&ai, (PROTO_AVATAR_INFORMATION*)ack->hProcess, sizeof(ai));
- if (ai.hContact)
- ai.hContact = cc->contactID;
-
- return ProtoBroadcastAck(META_PROTO, cc->contactID, ack->type, ack->result, (HANDLE)&ai, ack->lParam);
- }
-
- return ProtoBroadcastAck(META_PROTO, cc->contactID, ack->type, ack->result, 0, ack->lParam);
- }
- }
-
- return ProtoBroadcastAck(META_PROTO, cc->contactID, ack->type, ack->result, ack->hProcess, ack->lParam);
-}
-
-/** Call whenever a contact changes one of its settings (for example, the status)
-**
-* @param wParam HANDLE to the contact that has change of its setting.
-* @param lParam Reference to a structure that contains the setting that has changed (not used)
-*/
-
-int Meta_SettingChanged(WPARAM hContact, LPARAM lParam)
-{
- DBCONTACTWRITESETTING *dcws = (DBCONTACTWRITESETTING *)lParam;
- char buffer[512];
-
- // the only global options we're interested in
- if (hContact == 0)
- return 0;
-
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL || !cc->IsSub())
- return 0;
-
- DBCachedContact *ccMeta = currDb->m_cache->GetCachedContact(cc->parentID);
- if (ccMeta == NULL || !ccMeta->IsMeta())
- return 0;
-
- // This contact is attached to a MetaContact.
- int contact_number = Meta_GetContactNumber(ccMeta, hContact);
- if (contact_number == -1)
- return 0; // exit - db corruption
-
- if (!mir_strcmp(dcws->szSetting, "IP")) {
- if (dcws->value.type == DBVT_DWORD)
- db_set_dw(ccMeta->contactID, META_PROTO, "IP", dcws->value.dVal);
- else
- db_unset(ccMeta->contactID, META_PROTO, "IP");
- }
- else if (!mir_strcmp(dcws->szSetting, "RealIP")) {
- if (dcws->value.type == DBVT_DWORD)
- db_set_dw(ccMeta->contactID, META_PROTO, "RealIP", dcws->value.dVal);
- else
- db_unset(ccMeta->contactID, META_PROTO, "RealIP");
- }
- else if (!mir_strcmp(dcws->szSetting, "ListeningTo")) {
- switch (dcws->value.type) {
- case DBVT_ASCIIZ:
- db_set_s(ccMeta->contactID, META_PROTO, "ListeningTo", dcws->value.pszVal);
- break;
- case DBVT_UTF8:
- db_set_utf(ccMeta->contactID, META_PROTO, "ListeningTo", dcws->value.pszVal);
- break;
- case DBVT_WCHAR:
- db_set_ws(ccMeta->contactID, META_PROTO, "ListeningTo", dcws->value.pwszVal);
- break;
- case DBVT_DELETED:
- db_unset(ccMeta->contactID, META_PROTO, "ListeningTo");
- break;
- }
- }
- else if (!mir_strcmp(dcws->szSetting, "Nick") && dcws->value.type != DBVT_DELETED) {
- // subcontact nick has changed - update metacontact
- mir_snprintf(buffer, "Nick%d", contact_number);
- db_set(ccMeta->contactID, META_PROTO, buffer, &dcws->value);
-
- ptrT tszMyhandle(db_get_tsa(hContact, "CList", "MyHandle"));
- if (tszMyhandle == NULL) {
- mir_snprintf(buffer, "CListName%d", contact_number);
- db_set(ccMeta->contactID, META_PROTO, buffer, &dcws->value);
- }
-
- // copy nick to metacontact, if it's the most online
- MCONTACT hMostOnline = Meta_GetMostOnline(ccMeta);
- Meta_CopyContactNick(ccMeta, hMostOnline);
- }
- else if (!mir_strcmp(dcws->szSetting, "IdleTS")) {
- if (dcws->value.type == DBVT_DWORD)
- db_set_dw(ccMeta->contactID, META_PROTO, "IdleTS", dcws->value.dVal);
- else if (dcws->value.type == DBVT_DELETED)
- db_set_dw(ccMeta->contactID, META_PROTO, "IdleTS", 0);
- }
- else if (!mir_strcmp(dcws->szSetting, "LogonTS")) {
- if (dcws->value.type == DBVT_DWORD)
- db_set_dw(ccMeta->contactID, META_PROTO, "LogonTS", dcws->value.dVal);
- else if (dcws->value.type == DBVT_DELETED)
- db_set_dw(ccMeta->contactID, META_PROTO, "LogonTS", 0);
- }
- else if (!mir_strcmp(dcws->szModule, "CList") && !mir_strcmp(dcws->szSetting, "MyHandle")) {
- if (dcws->value.type == DBVT_DELETED) {
- char *proto = GetContactProto(hContact);
- mir_snprintf(buffer, "CListName%d", contact_number);
-
- DBVARIANT dbv;
- if (proto && !db_get_ts(hContact, proto, "Nick", &dbv)) {
- db_set_ts(ccMeta->contactID, META_PROTO, buffer, dbv.ptszVal);
- db_free(&dbv);
- }
- else db_unset(ccMeta->contactID, META_PROTO, buffer);
- }
- else {
- // subcontact clist displayname has changed - update metacontact
- mir_snprintf(buffer, "CListName%d", contact_number);
- db_set(ccMeta->contactID, META_PROTO, buffer, &dcws->value);
- }
-
- // copy nick to metacontact, if it's the most online
- Meta_CopyContactNick(ccMeta, Meta_GetMostOnline(ccMeta));
- }
- // subcontact changing status
- else if (!mir_strcmp(dcws->szSetting, "Status") && dcws->value.type != DBVT_DELETED) {
- // update subcontact status setting
- mir_snprintf(buffer, "Status%d", contact_number);
- db_set_w(ccMeta->contactID, META_PROTO, buffer, dcws->value.wVal);
-
- mir_snprintf(buffer, "StatusString%d", contact_number);
- db_set_ts(ccMeta->contactID, META_PROTO, buffer, cli.pfnGetStatusModeDescription(dcws->value.wVal, 0));
-
- // set status to that of most online contact
- MCONTACT hMostOnline = Meta_GetMostOnline(ccMeta);
- if (hMostOnline != db_mc_getDefault(ccMeta->contactID))
- db_mc_notifyDefChange(ccMeta->contactID, hMostOnline);
-
- Meta_CopyContactNick(ccMeta, hMostOnline);
- Meta_FixStatus(ccMeta);
-
- // most online contact with avatar support might have changed - update avatar
- hMostOnline = Meta_GetMostOnlineSupporting(ccMeta, PFLAGNUM_4, PF4_AVATARS);
- if (hMostOnline) {
- PROTO_AVATAR_INFORMATION ai = { 0 };
- ai.hContact = ccMeta->contactID;
- ai.format = PA_FORMAT_UNKNOWN;
- _tcsncpy_s(ai.filename, _T("X"), _TRUNCATE);
- if (CallProtoService(META_PROTO, PS_GETAVATARINFO, 0, (LPARAM)&ai) == GAIR_SUCCESS)
- db_set_ts(ccMeta->contactID, "ContactPhoto", "File", ai.filename);
- }
- }
-
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Contact's deletion hook
-
-int Meta_ContactDeleted(WPARAM hContact, LPARAM lParam)
-{
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL)
- return 0;
-
- // is a subcontact - update meta contact
- if (cc->IsSub()) {
- DBCachedContact *ccMeta = CheckMeta(cc->parentID);
- if (ccMeta) {
- Meta_RemoveContactNumber(ccMeta, Meta_GetContactNumber(ccMeta, hContact), true);
- NotifyEventHooks(hSubcontactsChanged, ccMeta->contactID, 0);
-
- // no more subs? remove the meta itself
- if (ccMeta->nSubs == 0)
- CallService(MS_DB_CONTACT_DELETE, ccMeta->contactID, 0);
- }
- return 0;
- }
-
- // not a subcontact - is it a metacontact?
- if (!cc->IsMeta())
- return 0;
-
- if (cc->nSubs > 0)
- NotifyEventHooks(hSubcontactsChanged, hContact, 0);
-
- // remove & restore all subcontacts
- for (int i = 0; i < cc->nSubs; i++) {
- currDb->MetaDetouchSub(cc, i);
-
- // stop ignoring, if we were
- if (options.bSuppressStatus)
- CallService(MS_IGNORE_UNIGNORE, cc->pSubs[i], IGNOREEVENT_USERONLINE);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Call when we want to send a user is typing message
-//
-// @param wParam HANDLE to the contact that we are typing to
-// @param lParam either PROTOTYPE_SELFTYPING_ON or PROTOTYPE_SELFTYPING_OFF
-
-static INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam)
-{
- DBCachedContact *cc = CheckMeta(hMeta);
- if (cc == NULL)
- return 0;
-
- // forward to sending protocol, if supported
- MCONTACT hMostOnline = Meta_GetMostOnline(cc);
- Meta_CopyContactNick(cc, hMostOnline);
- if (!hMostOnline)
- return 0;
-
- char *proto = GetContactProto(hMostOnline);
- if (proto)
- if (ProtoServiceExists(proto, PSS_USERISTYPING))
- CallProtoService(proto, PSS_USERISTYPING, hMostOnline, lParam);
-
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Called when user info is about to be shown
-//
-// Returns 1 to stop event processing and opens page for metacontact default
-// contact (returning 1 to stop it doesn't work!)
-
-static int Meta_UserInfo(WPARAM wParam, LPARAM hMeta)
-{
- DBCachedContact *cc = CheckMeta(hMeta);
- if (cc == NULL || cc->nDefault == -1)
- return 0;
-
- CallService(MS_USERINFO_SHOWDIALOG, Meta_GetContactHandle(cc, cc->nDefault), 0);
- return 1;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// record window open/close status for subs & metas
-
-static int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam)
-{
- MessageWindowEventData *mwed = (MessageWindowEventData*)lParam;
- if (mwed->uType == MSG_WINDOW_EVT_OPEN) {
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(mwed->hContact);
- if (cc != NULL) {
- Meta_UpdateSrmmIcon(cc, db_get_w(cc->contactID, META_PROTO, "Status", ID_STATUS_OFFLINE));
- if (cc->IsMeta()) {
- MetaSrmmData *p = new MetaSrmmData;
- p->m_hMeta = cc->contactID;
- p->m_hSub = db_mc_getMostOnline(cc->contactID);
- p->m_hWnd = mwed->hwndWindow;
- arMetaWindows.insert(p);
-
- if (p->m_hSub != db_mc_getDefault(cc->contactID))
- db_mc_setDefault(cc->contactID, p->m_hSub, false);
- }
- }
- }
- else if (mwed->uType == MSG_WINDOW_EVT_CLOSING) {
- for (int i = 0; i < arMetaWindows.getCount(); i++)
- if (arMetaWindows[i].m_hWnd == mwed->hwndWindow)
- arMetaWindows.remove(i);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// returns manually chosen sub in the meta window
-
-static INT_PTR Meta_SrmmCurrentSub(WPARAM hMeta, LPARAM lParam)
-{
- MetaSrmmData tmp = { hMeta };
- if (MetaSrmmData *p = arMetaWindows.find(&tmp))
- return p->m_hSub;
-
- return db_mc_getMostOnline(hMeta);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// we assume that it could be called only for the metacontacts
-
-static int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam)
-{
- StatusIconClickData *sicd = (StatusIconClickData*)lParam;
- if (mir_strcmp(sicd->szModule, META_PROTO))
- return 0;
-
- DBCachedContact *cc = CheckMeta(hMeta);
- if (cc == NULL)
- return 0;
-
- HMENU hMenu = CreatePopupMenu();
- int iDefault = Meta_GetContactNumber(cc, db_mc_getSrmmSub(cc->contactID));
-
- MENUITEMINFO mii = { sizeof(mii) };
- mii.fMask = MIIM_ID | MIIM_STATE | MIIM_STRING;
- for (int i = 0; i < cc->nSubs; i++) {
- char *szProto = GetContactProto(cc->pSubs[i]);
- if (szProto == NULL) continue;
-
- PROTOACCOUNT *pa = ProtoGetAccount(szProto);
- if (pa == NULL)
- continue;
-
- CMString tszNick;
- if (options.menu_contact_label == DNT_DID)
- tszNick = cli.pfnGetContactDisplayName(cc->pSubs[i], 0);
- else
- Meta_GetSubNick(hMeta, i, tszNick);
- tszNick.AppendFormat(_T(" [%s]"), pa->tszAccountName);
-
- mii.wID = i + 1;
- mii.fState = (i == iDefault) ? MFS_CHECKED : MFS_ENABLED;
- mii.dwTypeData = tszNick.GetBuffer();
- mii.cch = tszNick.GetLength();
- InsertMenuItem(hMenu, i, TRUE, &mii);
- }
-
- UINT res = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_BOTTOMALIGN | TPM_LEFTALIGN, sicd->clickLocation.x, sicd->clickLocation.y, 0, cli.hwndContactTree, NULL);
- if (res > 0) {
- MCONTACT hChosen = Meta_GetContactHandle(cc, res - 1);
-
- MetaSrmmData tmp = { cc->contactID };
- if (MetaSrmmData *p = arMetaWindows.find(&tmp))
- p->m_hSub = hChosen;
-
- db_mc_setDefault(cc->contactID, hChosen, true);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Called when all the plugin are loaded into Miranda.
-//
-// Initializes the 4 menus present in the context-menu
-
-int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam)
-{
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu);
-
- // hook srmm window close/open events
- HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent);
- HookEvent(ME_MSG_ICONPRESSED, Meta_SrmmIconClicked);
-
- // create menu items
- InitMenus();
-
- // create srmm icon
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = META_PROTO;
- sid.flags = MBF_TCHAR;
- sid.tszTooltip = LPGENT("Select metacontact");
- sid.hIcon = LoadSkinnedProtoIcon(META_PROTO, ID_STATUS_ONLINE);
- Srmm_AddIcon(&sid);
- return 0;
-}
-
-static VOID CALLBACK sttMenuThread(PVOID param)
-{
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)param, 0);
-
- TPMPARAMS tpmp = { 0 };
- tpmp.cbSize = sizeof(tpmp);
- BOOL menuRet = TrackPopupMenuEx(hMenu, TPM_RETURNCMD, menuMousePoint.x, menuMousePoint.y, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), &tpmp);
-
- CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(menuRet), MPCF_CONTACTMENU), (LPARAM)param);
-
- DestroyMenu(hMenu);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-INT_PTR Meta_ContactMenuFunc(WPARAM hMeta, LPARAM lParam)
-{
- DBCachedContact *cc = CheckMeta(hMeta);
- if (cc == NULL)
- return 0;
-
- MCONTACT hContact = Meta_GetContactHandle(cc, (int)lParam);
-
- if (options.menu_function == FT_MSG) {
- // open message window if protocol supports message sending or chat, else simulate double click
- char *proto = GetContactProto(hContact);
- if (proto) {
- INT_PTR caps = CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0);
- if ((caps & PF1_IMSEND) || (caps & PF1_CHAT)) {
- // set default contact for sending/status and open message window
- Meta_SetSrmmSub(hMeta, hContact);
- db_mc_setDefaultNum(hMeta, lParam, false);
- CallService(MS_MSG_SENDMESSAGET, hMeta, 0);
- }
- else // protocol does not support messaging - simulate double click
- CallService(MS_CLIST_CONTACTDOUBLECLICKED, hContact, 0);
- }
- else // protocol does not support messaging - simulate double click
- CallService(MS_CLIST_CONTACTDOUBLECLICKED, hContact, 0);
- }
- else if (options.menu_function == FT_MENU) // show contact's context menu
- CallFunctionAsync(sttMenuThread, (void*)hContact);
- else if (options.menu_function == FT_INFO) // show user info for subcontact
- CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
-
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// file transfer support - mostly not required, since subcontacts do the receiving
-
-INT_PTR Meta_FileSend(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *ccs = (CCSDATA*)lParam;
- DBCachedContact *cc = CheckMeta(ccs->hContact);
- if (cc == NULL || cc->nDefault == -1)
- return 0;
-
- MCONTACT hMostOnline = Meta_GetMostOnlineSupporting(cc, PFLAGNUM_1, PF1_FILESEND);
- if (!hMostOnline)
- return 0;
-
- char *proto = GetContactProto(hMostOnline);
- if (proto)
- return CallContactService(hMostOnline, PSS_FILE, ccs->wParam, ccs->lParam);
-
- return 0; // fail
-}
-
-INT_PTR Meta_GetAwayMsg(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *ccs = (CCSDATA*)lParam;
- DBCachedContact *cc = CheckMeta(ccs->hContact);
- if (cc == NULL || cc->nDefault == -1)
- return 0;
-
- MCONTACT hMostOnline = Meta_GetMostOnlineSupporting(cc, PFLAGNUM_1, PF1_MODEMSGRECV);
- if (!hMostOnline)
- return 0;
-
- char *proto = GetContactProto(hMostOnline);
- if (!proto)
- return 0;
-
- ccs->hContact = hMostOnline;
- return CallContactService(ccs->hContact, PSS_GETAWAYMSG, ccs->wParam, ccs->lParam);
-}
-
-INT_PTR Meta_GetAvatarInfo(WPARAM wParam, LPARAM lParam)
-{
- PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION*)lParam;
- DBCachedContact *cc = CheckMeta(pai->hContact);
- if (cc == NULL)
- return GAIR_NOAVATAR;
-
- if (cc->nDefault == -1)
- return 0;
-
- MCONTACT hSub = Meta_GetMostOnlineSupporting(cc, PFLAGNUM_4, PF4_AVATARS);
- if (!hSub)
- return GAIR_NOAVATAR;
-
- char *proto = GetContactProto(hSub);
- if (!proto)
- return GAIR_NOAVATAR;
-
- pai->hContact = hSub;
- INT_PTR result = CallProtoService(proto, PS_GETAVATARINFO, wParam, lParam);
- pai->hContact = cc->contactID;
- if (result != CALLSERVICE_NOTFOUND)
- return result;
-
- return GAIR_NOAVATAR; // fail
-}
-
-INT_PTR Meta_GetInfo(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *ccs = (CCSDATA*)lParam;
-
- // This is a simple contact
- // (this should normally not happen, since linked contacts do not appear on the list.)
- DBCachedContact *cc = CheckMeta(ccs->hContact);
- if (cc == NULL || cc->nDefault == -1)
- return 0;
-
- MCONTACT hMostOnline = Meta_GetMostOnlineSupporting(cc, PFLAGNUM_4, PF4_AVATARS);
- if (!hMostOnline)
- return 0;
-
- char *proto = GetContactProto(hMostOnline);
- if (!proto)
- return 0;
-
- PROTO_AVATAR_INFORMATION ai;
- ai.hContact = ccs->hContact;
- ai.format = PA_FORMAT_UNKNOWN;
- _tcsncpy_s(ai.filename, _T("X"), _TRUNCATE);
- if (CallProtoService(META_PROTO, PS_GETAVATARINFO, 0, (LPARAM)&ai) == GAIR_SUCCESS)
- db_set_ts(ccs->hContact, "ContactPhoto", "File", ai.filename);
-
- hMostOnline = Meta_GetMostOnline(cc);
- Meta_CopyContactNick(cc, hMostOnline);
-
- if (!hMostOnline)
- return 0;
-
- ccs->hContact = hMostOnline;
- if (!ProtoServiceExists(proto, PSS_GETINFO))
- return 0; // fail
-
- return CallContactService(ccs->hContact, PSS_GETINFO, ccs->wParam, ccs->lParam);
-}
-
-int Meta_CallMostOnline(WPARAM hContact, LPARAM lParam)
-{
- DBCachedContact *cc = CheckMeta(hContact);
- if (cc == NULL)
- return 0;
-
- Meta_CopyContactNick(cc, db_mc_getSrmmSub(cc->contactID));
- Meta_FixStatus(cc);
- return 0;
-}
-
-int Meta_PreShutdown(WPARAM wParam, LPARAM lParam)
-{
- Meta_SetStatus(ID_STATUS_OFFLINE, 0);
- Meta_SuppressStatus(FALSE);
- if (setStatusTimerId)
- KillTimer(0, setStatusTimerId);
- return 0;
-}
-
-INT_PTR MenuFunc(WPARAM wParam, LPARAM lParam, LPARAM param)
-{
- return Meta_ContactMenuFunc(wParam, param);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Initializes all services provided by the plugin
-//
-// Creates every function and hooks the event desired.
-
-void Meta_InitServices()
-{
- previousMode = mcStatus = ID_STATUS_OFFLINE;
-
- CreateServiceFunction("MetaContacts/Convert", Meta_Convert);
- CreateServiceFunction("MetaContacts/AddTo", Meta_AddTo);
- CreateServiceFunction("MetaContacts/Edit", Meta_Edit);
- CreateServiceFunction("MetaContacts/Delete", Meta_Delete);
- CreateServiceFunction("MetaContacts/Default", Meta_Default);
-
- // hidden contact menu items...ho hum
- for (int i = 0; i < MAX_CONTACTS; i++) {
- char szServiceName[100];
- mir_snprintf(szServiceName, SIZEOF(szServiceName), "MetaContacts/MenuFunc%d", i);
- CreateServiceFunctionParam(szServiceName, MenuFunc, i);
- }
-
- CreateProtoServiceFunction(META_PROTO, PS_GETCAPS, Meta_GetCaps);
- CreateProtoServiceFunction(META_PROTO, PS_GETNAME, Meta_GetName);
- CreateProtoServiceFunction(META_PROTO, PS_LOADICON, Meta_LoadIcon);
-
- CreateProtoServiceFunction(META_PROTO, PS_SETSTATUS, Meta_SetStatus);
-
- CreateProtoServiceFunction(META_PROTO, PS_GETSTATUS, Meta_GetStatus);
- CreateProtoServiceFunction(META_PROTO, PSS_MESSAGE, Meta_SendMessage);
-
- CreateProtoServiceFunction(META_PROTO, PSS_USERISTYPING, Meta_UserIsTyping);
-
- // file recv is done by subcontacts
- CreateProtoServiceFunction(META_PROTO, PSS_FILE, Meta_FileSend);
- CreateProtoServiceFunction(META_PROTO, PSS_GETAWAYMSG, Meta_GetAwayMsg);
- CreateProtoServiceFunction(META_PROTO, PS_GETAVATARINFO, Meta_GetAvatarInfo);
- CreateProtoServiceFunction(META_PROTO, PSS_GETINFO, Meta_GetInfo);
-
- // receive filter
- CreateProtoServiceFunction(META_FILTER, PSR_MESSAGE, MetaFilter_RecvMessage);
-
- // API services and events
- CreateApiServices();
-
- CreateServiceFunction("MetaContacts/OnOff", Meta_OnOff);
- CreateServiceFunction(MS_MC_GETSRMMSUB, Meta_SrmmCurrentSub);
-
- CreateProtoServiceFunction(META_PROTO, PS_SEND_NUDGE, Meta_SendNudge);
-
- // create our hookable events
- hSubcontactsChanged = CreateHookableEvent(ME_MC_SUBCONTACTSCHANGED);
-
- // hook other module events we need
- HookEvent(ME_PROTO_ACK, Meta_HandleACK);
- HookEvent(ME_DB_CONTACT_DELETED, Meta_ContactDeleted);
- HookEvent(ME_DB_CONTACT_SETTINGCHANGED, Meta_SettingChanged);
- HookEvent(ME_OPT_INITIALISE, Meta_OptInit);
- HookEvent(ME_SYSTEM_MODULESLOADED, Meta_ModulesLoaded);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, Meta_PreShutdown);
-
- // hook our own events, used to call Meta_GetMostOnline which sets nick for metacontact
- HookEvent(ME_MC_DEFAULTTCHANGED, Meta_CallMostOnline);
-
- // redirect nudge events
- hEventNudge = CreateHookableEvent(META_PROTO "/Nudge");
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Destroy created events
-
-void Meta_CloseHandles()
-{
- DestroyHookableEvent(hSubcontactsChanged);
- DestroyHookableEvent(hEventNudge);
-}
diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp deleted file mode 100644 index e58f509fcf..0000000000 --- a/src/modules/metacontacts/meta_utils.cpp +++ /dev/null @@ -1,576 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "metacontacts.h"
-
-HANDLE invisiGroup;
-POINT menuMousePoint;
-
-/** Update the MetaContact login, depending on the protocol desired
-*
-* The login of the "MetaContacts" protocol will be copied from the login
-* of the specified protocol.
-*
-* @param szProto : The name of the protocol used to get the login that will be
-* affected to the "MetaContacts" protocol.
-*
-* @return O on success, 1 otherwise.
-*/
-
-int Meta_SetNick(char *szProto)
-{
- CONTACTINFO ci = { sizeof(ci) };
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- ci.szProto = szProto;
- if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci))
- return 1;
-
- switch (ci.type) {
- case CNFT_BYTE:
- if (db_set_b(NULL, META_PROTO, "Nick", ci.bVal))
- return 1;
- break;
- case CNFT_WORD:
- if (db_set_w(NULL, META_PROTO, "Nick", ci.wVal))
- return 1;
- break;
- case CNFT_DWORD:
- if (db_set_dw(NULL, META_PROTO, "Nick", ci.dVal))
- return 1;
- break;
- case CNFT_ASCIIZ:
- if (db_set_ts(NULL, META_PROTO, "Nick", ci.pszVal))
- return 1;
- mir_free(ci.pszVal);
- break;
- default:
- if (db_set_s(NULL, META_PROTO, "Nick", (char *)TranslateT("Sender")))
- return 1;
- break;
- }
- return 0;
-}
-
-/** Assign a contact (hSub) to a metacontact (hMeta)
-*
-* @param hSub : HANDLE to a contact that should be assigned
-* @param hMeta : HANDLE to a metacontact that will host the contact
-* @param set_as_default : bool flag to indicate whether the new contact becomes the default
-*
-* @return TRUE on success, FALSE otherwise
-*/
-
-BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default)
-{
- DBCachedContact *ccDest = CheckMeta(hMeta), *ccSub = currDb->m_cache->GetCachedContact(hSub);
- if (ccDest == NULL || ccSub == NULL)
- return FALSE;
-
- char *szProto = GetContactProto(hSub);
- if (szProto == NULL) {
- MessageBox(0, TranslateT("Could not retrieve contact protocol"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- return FALSE;
- }
-
- // Get the login of the subcontact
- char *field = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- DBVARIANT dbv;
- if (db_get(hSub, szProto, field, &dbv)) {
- MessageBox(0, TranslateT("Could not get unique ID of contact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- return FALSE;
- }
-
- // Check that is is 'on the list'
- if (db_get_b(hSub, "CList", "NotOnList", 0) == 1) {
- MessageBox(0, TranslateT("Contact is 'not on list' - please add the contact to your contact list before assigning."), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- db_free(&dbv);
- return FALSE;
- }
-
- if (ccDest->nSubs >= MAX_CONTACTS) {
- MessageBox(0, TranslateT("Metacontact is full"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- db_free(&dbv);
- return FALSE;
- }
-
- // write the contact's protocol
- char buffer[512];
- mir_snprintf(buffer, "Protocol%d", ccDest->nSubs);
- if (db_set_s(hMeta, META_PROTO, buffer, szProto)) {
- MessageBox(0, TranslateT("Could not write contact protocol to metacontact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- db_free(&dbv);
- return FALSE;
- }
-
- // write the login
- mir_snprintf(buffer, "Login%d", ccDest->nSubs);
- if (db_set(hMeta, META_PROTO, buffer, &dbv)) {
- MessageBox(0, TranslateT("Could not write unique ID of contact to metacontact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- db_free(&dbv);
- return FALSE;
- }
-
- db_free(&dbv);
-
- // If we can get the nickname of the subcontact...
- if (!db_get(hSub, szProto, "Nick", &dbv)) {
- // write the nickname
- mir_snprintf(buffer, "Nick%d", ccDest->nSubs);
- if (db_set(hMeta, META_PROTO, buffer, &dbv)) {
- MessageBox(0, TranslateT("Could not write nickname of contact to metacontact"), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING);
- db_free(&dbv);
- return FALSE;
- }
-
- db_free(&dbv);
- }
-
- // write the display name
- mir_snprintf(buffer, "CListName%d", ccDest->nSubs);
- db_set_ts(hMeta, META_PROTO, buffer, cli.pfnGetContactDisplayName(hSub, 0));
-
- // Get the status
- WORD status = db_get_w(hSub, szProto, "Status", ID_STATUS_OFFLINE);
-
- // write the status
- mir_snprintf(buffer, "Status%d", ccDest->nSubs);
- db_set_w(hMeta, META_PROTO, buffer, status);
-
- // write the handle
- mir_snprintf(buffer, "Handle%d", ccDest->nSubs);
- db_set_dw(hMeta, META_PROTO, buffer, hSub);
-
- // write status string
- mir_snprintf(buffer, "StatusString%d", ccDest->nSubs);
-
- TCHAR *szStatus = cli.pfnGetStatusModeDescription(status, 0);
- db_set_ts(hMeta, META_PROTO, buffer, szStatus);
-
- // Write the link in the contact
- db_set_dw(hSub, META_PROTO, "ParentMeta", hMeta);
- db_set_b(hSub, META_PROTO, "IsSubcontact", true);
-
- // update count of contacts
- db_set_dw(hMeta, META_PROTO, "NumContacts", ccDest->nSubs+1);
- ccDest->nSubs++;
- ccDest->pSubs = (MCONTACT*)mir_realloc(ccDest->pSubs, sizeof(MCONTACT)*ccDest->nSubs);
- ccDest->pSubs[ccDest->nSubs-1] = hSub;
- ccSub->parentID = hMeta;
-
- if (set_as_default)
- db_mc_setDefaultNum(hMeta, ccDest->nSubs-1, true);
-
- // set nick to most online contact that can message
- MCONTACT most_online = Meta_GetMostOnline(ccDest);
- Meta_CopyContactNick(ccDest, most_online);
-
- // set status to that of most online contact
- Meta_FixStatus(ccDest);
-
- // if the new contact is the most online contact with avatar support, get avatar info
- most_online = Meta_GetMostOnlineSupporting(ccDest, PFLAGNUM_4, PF4_AVATARS);
- if (most_online == hSub) {
- PROTO_AVATAR_INFORMATION ai;
- ai.hContact = hMeta;
- ai.format = PA_FORMAT_UNKNOWN;
- _tcsncpy_s(ai.filename, _T("X"), _TRUNCATE);
-
- if (CallProtoService(META_PROTO, PS_GETAVATARINFO, 0, (LPARAM)&ai) == GAIR_SUCCESS)
- db_set_ts(hMeta, "ContactPhoto", "File", ai.filename);
- }
-
- // merge sub's events to the meta-history
- currDb->MetaMergeHistory(ccDest, ccSub);
-
- // Ignore status if the option is on
- if (options.bSuppressStatus)
- CallService(MS_IGNORE_IGNORE, hSub, IGNOREEVENT_USERONLINE);
-
- NotifyEventHooks(hSubcontactsChanged, hMeta, 0);
- return TRUE;
-}
-
-/**
-* Convenience method - get most online contact supporting messaging
-*
-*/
-
-MCONTACT Meta_GetMostOnline(DBCachedContact *cc)
-{
- return Meta_GetMostOnlineSupporting(cc, PFLAGNUM_1, PF1_IM);
-}
-
-/** Get the 'most online' contact for a meta contact (according to above order) which supports the specified
-* protocol service, and copies nick from that contact
-*
-* @param hMetaHANDLE to a metacontact
-*
-* @return HANDLE to a contact
-*/
-
-static int GetStatusPriority(int status)
-{
- switch (status) {
- case ID_STATUS_OFFLINE: return 8;
- case ID_STATUS_AWAY: return 4;
- case ID_STATUS_DND: return 7;
- case ID_STATUS_NA: return 6;
- case ID_STATUS_OCCUPIED: return 5;
- case ID_STATUS_FREECHAT: return 1;
- case ID_STATUS_ONTHEPHONE: return 2;
- case ID_STATUS_OUTTOLUNCH: return 3;
- }
-
- return 0;
-}
-
-MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigned long capability)
-{
- if (cc == NULL || cc->nDefault == -1)
- return NULL;
-
- // if the default is beyond the end of the list (eek!) return null
- if (cc->nDefault >= cc->nSubs)
- return NULL;
-
- int most_online_status = ID_STATUS_OFFLINE;
- MCONTACT most_online_contact = Meta_GetContactHandle(cc, cc->nDefault);
- char *szProto = GetContactProto(most_online_contact);
- if (szProto && CallProtoService(szProto, PS_GETSTATUS, 0, 0) >= ID_STATUS_ONLINE) {
- DWORD caps = CallProtoService(szProto, PS_GETCAPS, pflagnum, 0);
- if (capability == -1 || (caps & capability) == capability) {
- most_online_status = db_get_w(most_online_contact, szProto, "Status", ID_STATUS_OFFLINE);
-
- // if our default is not offline, and option to use default is set - return default
- // and also if our default is online, return it
- if (most_online_status != ID_STATUS_OFFLINE)
- return most_online_contact;
- }
- else most_online_status = ID_STATUS_OFFLINE;
- }
- else most_online_status = ID_STATUS_OFFLINE;
-
- char *most_online_proto = szProto;
- // otherwise, check all the subcontacts for the one closest to the ONLINE state which supports the required capability
- for (int i = 0; i < cc->nSubs; i++) {
- if (i == cc->nDefault) // already checked that (i.e. initial value of most_online_contact and most_online_status are those of the default contact)
- continue;
-
- MCONTACT hContact = Meta_GetContactHandle(cc, i);
- szProto = GetContactProto(hContact);
- if (szProto == NULL || CallProtoService(szProto, PS_GETSTATUS, 0, 0) < ID_STATUS_ONLINE) // szProto offline or connecting
- continue;
-
- DWORD caps = CallProtoService(szProto, PS_GETCAPS, pflagnum, 0);
- if (capability == -1 || (caps & capability) == capability) {
- int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- if (status == ID_STATUS_ONLINE) {
- most_online_contact = hContact;
- most_online_proto = szProto;
- return most_online_contact;
- }
- if (status <= ID_STATUS_OFFLINE) // status below ID_STATUS_OFFLINE is a connecting status
- continue;
-
- if (GetStatusPriority(status) < GetStatusPriority(most_online_status)) {
- most_online_status = status;
- most_online_contact = hContact;
- most_online_proto = szProto;
- }
- }
- }
-
- // no online contacts? if we're trying to message, use 'send offline' contact
- if (most_online_status == ID_STATUS_OFFLINE && capability == PF1_IM) {
- MCONTACT hOffline = Meta_GetContactHandle(cc, db_get_dw(cc->contactID, META_PROTO, "OfflineSend", INVALID_CONTACT_ID));
- if (hOffline)
- most_online_contact = hOffline;
- }
-
- return most_online_contact;
-}
-
-DBCachedContact* CheckMeta(MCONTACT hMeta)
-{
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMeta);
- return (cc == NULL || cc->nSubs == -1) ? NULL : cc;
-}
-
-int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact)
-{
- for (int i = 0; i < cc->nSubs; i++)
- if (cc->pSubs[i] == hContact)
- return i;
-
- return -1;
-}
-
-MCONTACT Meta_GetContactHandle(DBCachedContact *cc, int contact_number)
-{
- if (contact_number >= cc->nSubs || contact_number < 0)
- return 0;
-
- return cc->pSubs[contact_number];
-}
-
-/** Hide all contacts linked to any meta contact, and set handle links
-*
-* Additionally, set all sub contacts and metacontacts to offline so that status notifications are always sent
-*
-* and ensure metafilter in place
-*/
-int Meta_HideLinkedContacts(void)
-{
- DBVARIANT dbv, dbv2;
- char buffer[512];
-
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL || cc->parentID == 0)
- continue;
-
- DBCachedContact *ccMeta = CheckMeta(cc->parentID);
- if (ccMeta == NULL)
- continue;
-
- // get contact number
- int contact_number = Meta_GetContactNumber(cc, hContact);
-
- // find metacontact
- if (contact_number < 0 || contact_number >= ccMeta->nSubs)
- continue;
-
- // update metacontact's record of status for this contact
- mir_snprintf(buffer, "Status%d",contact_number);
-
- // prepare to update metacontact record of subcontat status
- char *szProto = GetContactProto(hContact);
-
- WORD status = (!szProto) ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- db_set_w(ccMeta->contactID, META_PROTO, buffer, status);
-
- // update metacontact's record of nick for this contact
- if (szProto && !db_get(hContact, szProto, "Nick", &dbv)) {
- mir_snprintf(buffer, "Nick%d",contact_number);
- db_set(ccMeta->contactID, META_PROTO, buffer, &dbv);
-
- mir_snprintf(buffer, "CListName%d",contact_number);
- if (db_get(hContact, "CList", "MyHandle", &dbv2))
- db_set(ccMeta->contactID, META_PROTO, buffer, &dbv);
- else {
- db_set(ccMeta->contactID, META_PROTO, buffer, &dbv2);
- db_free(&dbv2);
- }
-
- db_free(&dbv);
- }
- else {
- if (!db_get(hContact, "CList", "MyHandle", &dbv)) {
- mir_snprintf(buffer,"CListName%d",contact_number);
- db_set(ccMeta->contactID, META_PROTO, buffer, &dbv);
- db_free(&dbv);
- }
- }
-
- if (options.bSuppressStatus)
- CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
-
- MCONTACT hMostOnline = Meta_GetMostOnline(ccMeta); // set nick
- Meta_CopyContactNick(ccMeta, hMostOnline);
- Meta_FixStatus(ccMeta);
- }
-
- return 0;
-}
-
-int Meta_HideMetaContacts(bool bHide)
-{
- // set status suppression
- bool bSuppress = bHide ? FALSE : options.bSuppressStatus;
-
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- bool bSet;
- DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- if (cc->IsSub()) { // show on hide, reverse flag
- bSet = !bHide;
- CallService(bSuppress ? MS_IGNORE_IGNORE : MS_IGNORE_UNIGNORE, hContact, IGNOREEVENT_USERONLINE);
- }
- else if (cc->IsMeta())
- bSet = bHide;
- else
- continue;
-
- db_set_b(hContact, "CList", "Hidden", bSet);
- }
-
- if (bHide) {
- for (int i = 0; i < arMetaWindows.getCount(); i++)
- SendMessage(arMetaWindows[i].m_hWnd, WM_CLOSE, 0, 0);
- arMetaWindows.destroy();
- }
-
- return 0;
-}
-
-int Meta_SuppressStatus(BOOL suppress)
-{
- 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;
-}
-
-int Meta_CopyContactNick(DBCachedContact *ccMeta, MCONTACT hContact)
-{
- if (options.bLockHandle)
- hContact = Meta_GetContactHandle(ccMeta, 0);
-
- if (!hContact)
- return 1;
-
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return 1;
-
- if (options.clist_contact_name == CNNT_NICK) {
- ptrT tszNick(db_get_tsa(hContact, szProto, "Nick"));
- if (tszNick) {
- db_set_ts(ccMeta->contactID, META_PROTO, "Nick", tszNick);
- return 0;
- }
- }
- else if (options.clist_contact_name == CNNT_DISPLAYNAME) {
- TCHAR *name = cli.pfnGetContactDisplayName(hContact, 0);
- if (name && mir_tstrcmp(name, TranslateT("(Unknown contact)")) != 0) {
- db_set_ts(ccMeta->contactID, META_PROTO, "Nick", name);
- return 0;
- }
- }
- return 1;
-}
-
-int Meta_SetAllNicks()
-{
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- DBCachedContact *cc = CheckMeta(hContact);
- if (cc == NULL)
- continue;
- MCONTACT most_online = Meta_GetMostOnline(cc);
- Meta_CopyContactNick(cc, most_online);
- Meta_FixStatus(cc);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static void SwapValues(MCONTACT hContact, LPCSTR szSetting, int n1, int n2)
-{
- char buf1[100], buf2[100];
- mir_snprintf(buf1, SIZEOF(buf1), "%s%d", szSetting, n1);
- mir_snprintf(buf2, SIZEOF(buf2), "%s%d", szSetting, n2);
-
- DBVARIANT dbv1, dbv2;
- int ok1 = !db_get(hContact, META_PROTO, buf1, &dbv1);
- int ok2 = !db_get(hContact, META_PROTO, buf2, &dbv2);
- if (ok1) {
- db_set(hContact, META_PROTO, buf2, &dbv1);
- db_free(&dbv1);
- }
- if (ok2) {
- db_set(hContact, META_PROTO, buf1, &dbv2);
- db_free(&dbv2);
- }
-}
-
-int Meta_SwapContacts(DBCachedContact *cc, int n1, int n2)
-{
- SwapValues(cc->contactID, "Protocol", n1, n2);
- SwapValues(cc->contactID, "Status", n1, n2);
- SwapValues(cc->contactID, "StatusString", n1, n2);
- SwapValues(cc->contactID, "Login", n1, n2);
- SwapValues(cc->contactID, "Nick", n1, n2);
- SwapValues(cc->contactID, "CListName", n1, n2);
- SwapValues(cc->contactID, "Handle", n1, n2);
-
- MCONTACT tmp = cc->pSubs[n1];
- cc->pSubs[n1] = cc->pSubs[n2];
- cc->pSubs[n2] = tmp;
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void Meta_GetSubNick(MCONTACT hMeta, int i, CMString &tszDest)
-{
- char idStr[50];
- mir_snprintf(idStr, SIZEOF(idStr), "Login%d", i);
-
- DBVARIANT dbv;
- if(db_get(hMeta, META_PROTO, idStr, &dbv))
- return;
- switch (dbv.type) {
- case DBVT_ASCIIZ:
- tszDest = dbv.pszVal;
- break;
- case DBVT_BYTE:
- tszDest.Format(_T("%d"), dbv.bVal);
- break;
- case DBVT_WORD:
- tszDest.Format(_T("%d"), dbv.wVal);
- break;
- case DBVT_DWORD:
- tszDest.Format(_T("%d"), dbv.dVal);
- break;
- default:
- tszDest.Empty();
- }
- db_free(&dbv);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void Meta_FixStatus(DBCachedContact *ccMeta)
-{
- WORD status = ID_STATUS_OFFLINE;
-
- MCONTACT most_online = db_mc_getMostOnline(ccMeta->contactID);
- if (most_online) {
- char *szProto = GetContactProto(most_online);
- if (szProto)
- status = db_get_w(most_online, szProto, "Status", ID_STATUS_OFFLINE);
- }
-
- db_set_w(ccMeta->contactID, META_PROTO, "Status", status);
- Meta_UpdateSrmmIcon(ccMeta, status);
-}
-
-void Meta_UpdateSrmmIcon(DBCachedContact *ccMeta, int iStatus)
-{
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = META_PROTO;
- sid.flags = (ccMeta->IsMeta()) ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(ccMeta->contactID, &sid);
-}
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h deleted file mode 100644 index 2c4ff0715c..0000000000 --- a/src/modules/metacontacts/metacontacts.h +++ /dev/null @@ -1,129 +0,0 @@ -/*
-former MetaContacts Plugin for Miranda IM.
-
-Copyright © 2014 Miranda NG Team
-Copyright © 2004-07 Scott Ellis
-Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#define MAX_CONTACTS 20
-
-#define META_FILTER "MetaContactsFilter"
-
-INT_PTR TranslateMenuFunc(MCONTACT hContact, int i);
-
-// contact menu items
-void InitMenus();
-extern int mcStatus;
-
-struct MetaSrmmData
-{
- MCONTACT m_hMeta, m_hSub;
- HWND m_hWnd;
-};
-extern OBJLIST<MetaSrmmData> arMetaWindows;
-
-INT_PTR Meta_Convert(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_AddTo(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_Edit(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_Default(WPARAM wParam,LPARAM lParam);
-
-INT_PTR Meta_OnOff(WPARAM wParam, LPARAM lParam);
-int Meta_ModifyMenu(WPARAM wParam,LPARAM lParam);
-BOOL Meta_Assign(MCONTACT src, MCONTACT dest, BOOL set_as_default);
-void Meta_RemoveContactNumber(DBCachedContact *cc, int number, bool bUpdateInfo);
-int Meta_SetNick(char *proto);
-int Meta_HideLinkedContacts(void);
-int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact);
-int Meta_HideMetaContacts(bool hide);
-int Meta_SuppressStatus(int suppress);
-int Meta_CopyContactNick(DBCachedContact *cc, MCONTACT hContact);
-int Meta_SetAllNicks();
-int Meta_SwapContacts(DBCachedContact *cc, int contact_number1, int contact_number2);
-void Meta_GetSubNick(MCONTACT hMeta, int i, CMString &tszDest);
-
-MCONTACT Meta_GetMostOnline(DBCachedContact *cc);
-MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigned long capability);
-MCONTACT Meta_GetContactHandle(DBCachedContact *cc, int contact_number);
-
-DBCachedContact* CheckMeta(MCONTACT hMeta);
-
-// function to copy history from one contact to another - courtesy JdGordon with mods (thx)
-void Meta_FixStatus(DBCachedContact *ccMeta);
-void Meta_UpdateSrmmIcon(DBCachedContact *ccMeta, int iStatus);
-
-char *Meta_GetUniqueIdentifier(MCONTACT hContact, DWORD *pused);
-
-INT_PTR Meta_GetCaps(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_GetName(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_LoadIcon(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_SetStatus(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_GetStatus(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam);
-INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam);
-
-void Meta_InitServices();
-void Meta_CloseHandles();
-
-enum MenuDisplayNameType {DNT_UID = 0, DNT_DID = 1};
-enum MenuFunctionType {FT_MSG = 0, FT_MENU = 1, FT_INFO = 2};
-enum CListDisplayNameType {CNNT_NICK = 0, CNNT_DISPLAYNAME = 1};
-
-struct MetaOptions
-{
- bool bLockHandle;
- bool bSuppressStatus;
-
- int menu_contact_label;
- int menu_function;
- int clist_contact_name;
- int set_status_from_offline_delay;
-};
-
-extern MetaOptions options;
-
-int Meta_OptInit(WPARAM wParam, LPARAM lParam);
-int Meta_ReadOptions();
-
-// API function headers
-void CreateApiServices();
-
-typedef enum {I_MENUOFF, I_MENU, I_CONVERT, I_ADD, I_EDIT, I_SETDEFAULT, I_REMOVE} IconIndex;
-HICON LoadIconEx(IconIndex i);
-HANDLE GetIconHandle(IconIndex i);
-
-extern HANDLE hEventForceSend, hEventUnforceSend, hSubcontactsChanged;
-extern POINT menuMousePoint;
-
-#define MAX_PROTOCOLS 20
-
-// used for the 'jabber' hack - i.e. hide contacts instead of moving them to the hidden group
-#define JABBER_UNIQUE_ID_SETTING "jid"
-
-// delay setting status from offline - to help reduce innapropriate status notification popups
-#define DEFAULT_SET_STATUS_SLEEP_TIME 15000 // milliseconds
-
-// service from clist_meta_mw, existence means we don't need to hide subcontacts (woohoo - thanks FYR)
-#define MS_CLUI_METASUPPORT "CLUI/MetaContactSupport"
-
-#ifndef MS_CLUI_GETVERSION
-#define MS_CLUI_GETVERSION "CLUI/GetVersion"
-
-#define szDelMsg LPGEN("You are going to remove all the contacts associated with this metacontact.\nThis will delete the metacontact.\n\nProceed anyway?")
-
-#endif
|