diff options
-rw-r--r-- | include/m_metacontacts.h | 18 | ||||
-rw-r--r-- | plugins/TabSRMM/src/contactcache.cpp | 7 | ||||
-rw-r--r-- | plugins/TabSRMM/src/contactcache.h | 2 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_services.cpp | 49 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_utils.cpp | 2 | ||||
-rw-r--r-- | src/modules/metacontacts/metacontacts.h | 7 |
6 files changed, 62 insertions, 23 deletions
diff --git a/include/m_metacontacts.h b/include/m_metacontacts.h index 3b9ba43d14..430abcb01f 100644 --- a/include/m_metacontacts.h +++ b/include/m_metacontacts.h @@ -33,34 +33,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //wParam=(HANDLE)hMetaContact
//lParam=0
//returns a handle to the 'most online' contact
-#define MS_MC_GETMOSTONLINECONTACT "MetaContacts/GetMostOnline"
+#define MS_MC_GETMOSTONLINECONTACT "MetaContacts/GetMostOnline"
// fired when a metacontact's default contact changes (fired upon creation of metacontact also, when default is initially set)
// wParam=(HANDLE)hMetaContact
// lParam=(HANDLE)hDefaultContact
-#define ME_MC_DEFAULTTCHANGED "MetaContacts/DefaultChanged"
+#define ME_MC_DEFAULTTCHANGED "MetaContacts/DefaultChanged"
// fired when a metacontact's subcontacts change (fired upon creation of metacontact, when contacts are added or removed, and when
// contacts are reordered) - a signal to re-read metacontact data
// wParam=(HANDLE)hMetaContact
// lParam=0
-#define ME_MC_SUBCONTACTSCHANGED "MetaContacts/SubcontactsChanged"
+#define ME_MC_SUBCONTACTSCHANGED "MetaContacts/SubcontactsChanged"
// wParam=(HANDLE)hContact
// lParam=0
// convert a given contact into a metacontact
-#define MS_MC_CONVERTTOMETA "MetaContacts/ConvertToMetacontact"
+#define MS_MC_CONVERTTOMETA "MetaContacts/ConvertToMetacontact"
// wParam=(HANDLE)hContact
// lParam=(HANDLE)hMeta
// add an existing contact to a metacontact
-#define MS_MC_ADDTOMETA "MetaContacts/AddToMetacontact"
+#define MS_MC_ADDTOMETA "MetaContacts/AddToMetacontact"
-// added 0.9.5.0 (22/3/05)
// wParam=0
// lParam=(HANDLE)hContact
// remove a contact from a metacontact
-#define MS_MC_REMOVEFROMMETA "MetaContacts/RemoveFromMetacontact"
+#define MS_MC_REMOVEFROMMETA "MetaContacts/RemoveFromMetacontact"
+
+// wParam=(HANDLE)hContact
+// lParam=(HANDLE)hMeta
+// add an existing contact to a metacontact
+#define MS_MC_GETSRMMSUB "MetaContacts/GetSrmmSub"
/////////////////////////////////////////////////////////////////////////////////////////
// binary interface to MC
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index 75337b1161..e34eb7b821 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -599,3 +599,10 @@ int CContactCache::getMaxMessageLength() }
return m_nMax;
}
+
+const MCONTACT CContactCache::getActiveContact() const
+{
+ if (!m_isMeta)
+ return m_hContact;
+ return CallService(MS_MC_GETSRMMSUB, m_hContact, 0);
+}
diff --git a/plugins/TabSRMM/src/contactcache.h b/plugins/TabSRMM/src/contactcache.h index 74bb7c7853..c12879ab4a 100644 --- a/plugins/TabSRMM/src/contactcache.h +++ b/plugins/TabSRMM/src/contactcache.h @@ -77,7 +77,7 @@ struct CContactCache : public MZeroedObject const WORD getOldStatus() const { return m_wOldStatus; }
const TCHAR* getNick() const { return m_szNick; }
const MCONTACT getContact() const { return m_hContact; }
- const MCONTACT getActiveContact() const { return m_isMeta ? db_mc_getMostOnline(m_hContact) : m_hContact; }
+ const MCONTACT getActiveContact() const;
const DWORD getIdleTS() const { return m_idleTS; }
const char* getProto() const { return cc->szProto; }
const char* getActiveProto() const { return m_isMeta ? (m_szMetaProto ? m_szMetaProto : cc->szProto) : cc->szProto; }
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index 7852c2c92d..6516bf09f0 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -40,7 +40,7 @@ HANDLE UINT_PTR setStatusTimerId = 0;
BOOL firstSetOnline = TRUE; // see Meta_SetStatus function
-LIST<void> arMetaWindows(1);
+OBJLIST<MetaSrmmData> arMetaWindows(1, NumericKeySortT);
/** Get the capabilities of the "MetaContacts" protocol.
*
@@ -475,7 +475,7 @@ int Meta_ContactDeleted(WPARAM hContact, LPARAM lParam) * @param wParam HANDLE to the contact that we are typing to
* @param lParam either PROTOTYPE_SELFTYPING_ON or PROTOTYPE_SELFTYPING_OFF
*/
-INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam)
+static INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(hMeta);
if (cc == NULL)
@@ -501,7 +501,7 @@ INT_PTR Meta_UserIsTyping(WPARAM hMeta, LPARAM lParam) * @param lParam either PROTOTYPE_SELFTYPING_ON or PROTOTYPE_SELFTYPING_OFF
*/
-int Meta_ContactIsTyping(WPARAM hContact, LPARAM lParam)
+static int Meta_ContactIsTyping(WPARAM hContact, LPARAM lParam)
{
if (!db_mc_isEnabled())
return 0;
@@ -521,7 +521,7 @@ int Meta_ContactIsTyping(WPARAM hContact, LPARAM lParam) *
*/
-int Meta_UserInfo(WPARAM wParam, LPARAM hMeta)
+static int Meta_UserInfo(WPARAM wParam, LPARAM hMeta)
{
DBCachedContact *cc = CheckMeta(hMeta);
if (cc == NULL || cc->nDefault == -1)
@@ -532,27 +532,42 @@ int Meta_UserInfo(WPARAM wParam, LPARAM hMeta) }
// record window open/close status for subs & metas
-int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam)
+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())
- arMetaWindows.insert(mwed->hwndWindow);
+ 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);
+ }
}
}
else if (mwed->uType == MSG_WINDOW_EVT_CLOSING) {
for (int i = 0; i < arMetaWindows.getCount(); i++)
- if (arMetaWindows[i] == mwed->hwndWindow)
+ 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
-int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam)
+static int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam)
{
StatusIconClickData *sicd = (StatusIconClickData*)lParam;
if (lstrcmpA(sicd->szModule, META_PROTO))
@@ -563,7 +578,7 @@ int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam) return 0;
HMENU hMenu = CreatePopupMenu();
- int iDefault = Meta_GetContactNumber(cc, Meta_GetMostOnline(cc));
+ int iDefault = Meta_GetContactNumber(cc, CallService(MS_MC_GETSRMMSUB, cc->contactID, 0));
TCHAR tszItemName[200];
MENUITEMINFO mii = { sizeof(mii) };
@@ -575,7 +590,8 @@ int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam) if (szProto == NULL) continue;
PROTOACCOUNT *pa = ProtoGetAccount(szProto);
- if (pa == NULL) continue;
+ if (pa == NULL)
+ continue;
mir_sntprintf(tszItemName, SIZEOF(tszItemName), _T("%s [%s]"),
cli.pfnGetContactDisplayName(cc->pSubs[i], 0), pa->tszAccountName);
@@ -586,8 +602,14 @@ int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam) }
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)
- db_mc_setDefault(cc->contactID, Meta_GetContactHandle(cc, res-1), true);
+ if (res > 0) {
+ MCONTACT hChosen = Meta_GetContactHandle(cc, res - 1);
+ db_mc_setDefault(cc->contactID, hChosen, true);
+
+ MetaSrmmData tmp = { cc->contactID };
+ if (MetaSrmmData *p = arMetaWindows.find(&tmp))
+ p->m_hSub = hChosen;
+ }
return 0;
}
@@ -856,6 +878,7 @@ void Meta_InitServices() CreateApiServices();
CreateServiceFunction("MetaContacts/OnOff", Meta_OnOff);
+ CreateServiceFunction(MS_MC_GETSRMMSUB, Meta_SrmmCurrentSub);
CreateProtoServiceFunction(META_PROTO, PS_SEND_NUDGE, Meta_SendNudge);
diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index 6c4887c6fb..b9119a4d4e 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -412,7 +412,7 @@ int Meta_HideMetaContacts(bool bHide) if (bHide) {
for (int i = 0; i < arMetaWindows.getCount(); i++)
- SendMessage((HWND)arMetaWindows[i], WM_CLOSE, 0, 0);
+ SendMessage(arMetaWindows[i].m_hWnd, WM_CLOSE, 0, 0);
arMetaWindows.destroy();
}
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index 79f6e74d53..19b970a308 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -28,7 +28,12 @@ INT_PTR TranslateMenuFunc(MCONTACT hContact, int i); void InitMenus();
extern int mcStatus;
-extern LIST<void> arMetaWindows;
+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);
|