diff options
| author | George Hazan <george.hazan@gmail.com> | 2015-10-30 16:41:09 +0000 | 
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2015-10-30 16:41:09 +0000 | 
| commit | 211967c3ae7d510f2e63aac7fe912d040ad1ebc3 (patch) | |
| tree | a65d43fbe91878ecc3008da5996e6e43faee257b | |
| parent | e57ba22d8dd05efc14197c764daed53e61a59636 (diff) | |
old unused code that belongs to StdClist moved from the core to plugin
git-svn-id: http://svn.miranda-ng.org/main/trunk@15652 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
| -rw-r--r-- | include/delphi/m_clistint.inc | 1 | ||||
| -rw-r--r-- | include/m_clist.h | 4 | ||||
| -rw-r--r-- | include/m_clistint.h | 1 | ||||
| -rw-r--r-- | plugins/Clist_modern/src/modern_cachefuncs.cpp | 2 | ||||
| -rw-r--r-- | plugins/Clist_modern/src/modern_clc.cpp | 8 | ||||
| -rw-r--r-- | plugins/Clist_modern/src/modern_clcitems.cpp | 1 | ||||
| -rw-r--r-- | plugins/Clist_modern/src/modern_clcmsgs.cpp | 168 | ||||
| -rw-r--r-- | plugins/Clist_modern/src/modern_clistsettings.cpp | 33 | ||||
| -rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 2 | ||||
| -rw-r--r-- | src/core/stdclist/src/clc.h | 4 | ||||
| -rw-r--r-- | src/core/stdclist/src/clistopts.cpp | 8 | ||||
| -rw-r--r-- | src/core/stdclist/src/init.cpp | 4 | ||||
| -rw-r--r-- | src/core/stdclist/src/stdafx.h | 1 | ||||
| -rw-r--r-- | src/mir_app/src/clc.h | 42 | ||||
| -rw-r--r-- | src/mir_app/src/clistcore.cpp | 2 | ||||
| -rw-r--r-- | src/mir_app/src/clistevents.cpp | 1 | ||||
| -rw-r--r-- | src/mir_app/src/clistmod.cpp | 75 | ||||
| -rw-r--r-- | src/mir_app/src/clistsettings.cpp | 2 | ||||
| -rw-r--r-- | src/mir_app/src/contact.cpp | 80 | 
19 files changed, 153 insertions, 286 deletions
| diff --git a/include/delphi/m_clistint.inc b/include/delphi/m_clistint.inc index 108163db8b..d5537c8b24 100644 --- a/include/delphi/m_clistint.inc +++ b/include/delphi/m_clistint.inc @@ -433,7 +433,6 @@ type      pfnChangeContactIcon : procedure (hContact:TMCONTACT; iIcon:int; add:int); cdecl;
      pfnLoadContactTree   : procedure ; cdecl;
      pfnCompareContacts   : function (var contact1:TClcContact; var contact2:TClcContact):int; cdecl;
 -    pfnSortContacts      : procedure ; cdecl;
      pfnSetHideOffline    : function (wParam:WPARAM; lParam:LPARAM):int; cdecl;
    (* docking.c *)
 diff --git a/include/m_clist.h b/include/m_clist.h index 0e78bea758..0446311678 100644 --- a/include/m_clist.h +++ b/include/m_clist.h @@ -510,8 +510,8 @@ __forceinline HANDLE Clist_CreateGroup(HANDLE hParent, LPCTSTR ptszGroupName)  /////////////////////////////////////////////////////////////////////////////////////////
  // determines the ordering of two contacts
 -// wParam = (WPARAM)(HANDLE)hContact1
 -// lParam = (LPARAM)(HANDLE)hContact2
 +// wParam = (WPARAM)(MCONTACT)hContact1
 +// lParam = (LPARAM)(MCONTACT)hContact2
  // returns 0 if hContact1 is the same as hContact2
  // returns +1 if hContact2 should be displayed after hContact1
  // returns -1 if hContact1 should be displayed after hContact2
 diff --git a/include/m_clistint.h b/include/m_clistint.h index fca285b7ad..420ddcae99 100644 --- a/include/m_clistint.h +++ b/include/m_clistint.h @@ -383,7 +383,6 @@ struct CLIST_INTERFACE  	void (*pfnChangeContactIcon)(MCONTACT hContact, int iIcon, int add);
  	void (*pfnLoadContactTree)(void);
  	int  (*pfnCompareContacts)(const ClcContact *contact1, const ClcContact *contact2);
 -	void (*pfnSortContacts)(void);
  	int  (*pfnSetHideOffline)(WPARAM wParam, LPARAM lParam);
  	/* docking.c */
 diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 12d6a29765..e48ab15e95 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -515,7 +515,7 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact)  	ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);  	TCHAR *name = pcli->pfnGetContactDisplayName(contact->hContact, 0); -	if (dat->first_line_append_nick && (!dat->force_in_dialog)) { +	if (dat->first_line_append_nick && !dat->force_in_dialog) {  		DBVARIANT dbv = { 0 };  		if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) {  			TCHAR nick[_countof(contact->szText)]; diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 260b131276..e5c067e482 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1500,9 +1500,8 @@ static LRESULT clcOnIntmNameChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wP  		Cache_GetText(dat, contact, 1);  		cliRecalcScrollBar(hwnd, dat);  	} -	dat->needsResort = 1; -	pcli->pfnSortContacts(); +	dat->needsResort = 1;  	return ret;  } @@ -1584,10 +1583,9 @@ static LRESULT clcOnIntmStatusChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM  	if (db_get_b(NULL, "CList", "PlaceOfflineToRoot", SETTING_PLACEOOFLINETOROOT_DEFAULT))  		pcli->pfnInitAutoRebuild(hwnd); -	else { -		pcli->pfnSortContacts(); +	else  		PostMessage(hwnd, INTM_INVALIDATE, 0, 0); -	} +  	return ret;  } diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index e57e8d6a89..0d488cf780 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -333,6 +333,7 @@ void cliRebuildEntireList(HWND hwnd, ClcData *dat)  	BOOL PlaceOfflineToRoot = db_get_b(NULL, "CList", "PlaceOfflineToRoot", SETTING_PLACEOFFLINETOROOT_DEFAULT);  	KillTimer(hwnd, TIMERID_REBUILDAFTER); +	pcli->bAutoRebuild = false;
  	ClearRowByIndexCache();  	ImageArray_Clear(&dat->avatar_cache); diff --git a/plugins/Clist_modern/src/modern_clcmsgs.cpp b/plugins/Clist_modern/src/modern_clcmsgs.cpp index e8cf1a0e75..07ace535a6 100644 --- a/plugins/Clist_modern/src/modern_clcmsgs.cpp +++ b/plugins/Clist_modern/src/modern_clcmsgs.cpp @@ -41,12 +41,11 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP  		return 0;
  	case CLM_AUTOREBUILD:
 -		if (dat->force_in_dialog)
 +		if (dat->force_in_dialog) {
  			pcli->pfnSaveStateAndRebuildList(hwnd, dat);
 -		else
 -			clcSetDelayTimer(TIMERID_REBUILDAFTER, hwnd);
 -
 -		pcli->bAutoRebuild = false;
 +			pcli->bAutoRebuild = false;
 +		}
 +		else clcSetDelayTimer(TIMERID_REBUILDAFTER, hwnd);
  		return 0;
  	case CLM_SETFONT:
 @@ -62,17 +61,17 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP  		return 0;
  	case CLM_SETHIDEEMPTYGROUPS:
 -	{
 -		BOOL old = ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) != 0);
 -		if (wParam)
 -			SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | CLS_HIDEEMPTYGROUPS);
 -		else
 -			SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) &~CLS_HIDEEMPTYGROUPS);
 -		BOOL newval = ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) != 0);
 -		if (newval != old)
 -			pcli->pfnInitAutoRebuild(hwnd);
 -	}
 -	return 0;
 +		{
 +			BOOL old = ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) != 0);
 +			if (wParam)
 +				SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | CLS_HIDEEMPTYGROUPS);
 +			else
 +				SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) &~CLS_HIDEEMPTYGROUPS);
 +			BOOL newval = ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) != 0);
 +			if (newval != old)
 +				pcli->pfnInitAutoRebuild(hwnd);
 +		}
 +		return 0;
  	case CLM_SETTEXTCOLOR:
  		if (wParam > FONTID_MODERN_MAX) break;
 @@ -105,76 +104,76 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP  		return 0;
  	case CLM_GETNEXTITEM:
 -	{
 -		int i = 0;
 -		if (wParam != CLGN_ROOT) {
 -			if (!pcli->pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL))
 -				return NULL;
 -			i = List_IndexOf((SortedList*)&group->cl, contact);
 -			if (i < 0) return 0;
 -		}
 -		switch (wParam) {
 -		case CLGN_ROOT:
 -			if (dat->list.cl.count)
 -				return (LRESULT)pcli->pfnContactToHItem(dat->list.cl.items[0]);
 -			else
 -				return NULL;
 -		case CLGN_CHILD:
 -			if (contact->type != CLCIT_GROUP)
 -				return NULL;
 -			group = contact->group;
 -			if (group->cl.count == 0)
 -				return NULL;
 -			return (LRESULT)pcli->pfnContactToHItem(group->cl.items[0]);
 -		case CLGN_PARENT:
 -			return group->groupId | HCONTACT_ISGROUP;
 -		case CLGN_NEXT:
 -			do {
 -				if (++i >= group->cl.count)
 +		{
 +			int i = 0;
 +			if (wParam != CLGN_ROOT) {
 +				if (!pcli->pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL))
  					return NULL;
 -			} while (group->cl.items[i]->type == CLCIT_DIVIDER);
 -			return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 -		case CLGN_PREVIOUS:
 -			do {
 -				if (--i < 0)
 +				i = List_IndexOf((SortedList*)&group->cl, contact);
 +				if (i < 0) return 0;
 +			}
 +			switch (wParam) {
 +			case CLGN_ROOT:
 +				if (dat->list.cl.count)
 +					return (LRESULT)pcli->pfnContactToHItem(dat->list.cl.items[0]);
 +				else
 +					return NULL;
 +			case CLGN_CHILD:
 +				if (contact->type != CLCIT_GROUP)
 +					return NULL;
 +				group = contact->group;
 +				if (group->cl.count == 0)
 +					return NULL;
 +				return (LRESULT)pcli->pfnContactToHItem(group->cl.items[0]);
 +			case CLGN_PARENT:
 +				return group->groupId | HCONTACT_ISGROUP;
 +			case CLGN_NEXT:
 +				do {
 +					if (++i >= group->cl.count)
 +						return NULL;
 +				} while (group->cl.items[i]->type == CLCIT_DIVIDER);
 +				return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 +			case CLGN_PREVIOUS:
 +				do {
 +					if (--i < 0)
 +						return NULL;
 +				} while (group->cl.items[i]->type == CLCIT_DIVIDER);
 +				return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 +			case CLGN_NEXTCONTACT:
 +				for (i++; i < group->cl.count; i++)
 +					if (group->cl.items[i]->type == CLCIT_CONTACT)
 +						break;
 +				if (i >= group->cl.count)
 +					return NULL;
 +				return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 +			case CLGN_PREVIOUSCONTACT:
 +				if (i >= group->cl.count)
 +					return NULL;
 +				for (i--; i >= 0; i--)
 +					if (group->cl.items[i]->type == CLCIT_CONTACT)
 +						break;
 +				if (i < 0)
  					return NULL;
 -			} while (group->cl.items[i]->type == CLCIT_DIVIDER);
 -			return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 -		case CLGN_NEXTCONTACT:
 -			for (i++; i < group->cl.count; i++)
 -				if (group->cl.items[i]->type == CLCIT_CONTACT)
 -					break;
 -			if (i >= group->cl.count)
 -				return NULL;
 -			return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 -		case CLGN_PREVIOUSCONTACT:
 -			if (i >= group->cl.count)
 -				return NULL;
 -			for (i--; i >= 0; i--)
 -				if (group->cl.items[i]->type == CLCIT_CONTACT)
 -					break;
 -			if (i < 0)
 -				return NULL;
 -			return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 -		case CLGN_NEXTGROUP:
 -			for (i++; i < group->cl.count; i++)
 -				if (group->cl.items[i]->type == CLCIT_GROUP)
 -					break;
 -			if (i >= group->cl.count)
 -				return NULL;
 -			return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 -		case CLGN_PREVIOUSGROUP:
 -			if (i >= group->cl.count)
 -				return NULL;
 -			for (i--; i >= 0; i--)
 -				if (group->cl.items[i]->type == CLCIT_GROUP)
 -					break;
 -			if (i < 0)
 -				return NULL;
 -			return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 +				return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 +			case CLGN_NEXTGROUP:
 +				for (i++; i < group->cl.count; i++)
 +					if (group->cl.items[i]->type == CLCIT_GROUP)
 +						break;
 +				if (i >= group->cl.count)
 +					return NULL;
 +				return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 +			case CLGN_PREVIOUSGROUP:
 +				if (i >= group->cl.count)
 +					return NULL;
 +				for (i--; i >= 0; i--)
 +					if (group->cl.items[i]->type == CLCIT_GROUP)
 +						break;
 +				if (i < 0)
 +					return NULL;
 +				return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]);
 +			}
  		}
 -	}
 -	return NULL;
 +		return NULL;
  	case CLM_SELECTITEM:
  		ClcGroup *tgroup;
 @@ -198,8 +197,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP  			BYTE k = db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT);
  			if (k) {
 -				for (int i = 0; i < mainindex; i++)
 -				{
 +				for (int i = 0; i < mainindex; i++) {
  					ClcContact *tempCont = group->cl.items[i];
  					if (tempCont->type == CLCIT_CONTACT && tempCont->SubAllocated && tempCont->SubExpanded)
  						index += tempCont->SubAllocated;
 diff --git a/plugins/Clist_modern/src/modern_clistsettings.cpp b/plugins/Clist_modern/src/modern_clistsettings.cpp index dc047d848e..d17427c5ec 100644 --- a/plugins/Clist_modern/src/modern_clistsettings.cpp +++ b/plugins/Clist_modern/src/modern_clistsettings.cpp @@ -313,7 +313,7 @@ char *GetContactCachedProtocol(MCONTACT hContact)  int GetStatusForContact(MCONTACT hContact, char *szProto)
  {
 -	return (szProto) ? (int)(db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)) : ID_STATUS_OFFLINE;
 +	return (szProto) ? db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) : ID_STATUS_OFFLINE;
  }
  void ClcCacheEntry::freeName()
 @@ -366,10 +366,9 @@ int GetContactCachedStatus(MCONTACT hContact)  int ContactAdded(WPARAM hContact, LPARAM)
  {
 -	if (!MirandaExiting()) {
 +	if (!MirandaExiting())
  		cli_ChangeContactIcon(hContact, pcli->pfnIconFromStatusMode((char*)GetContactCachedProtocol(hContact), ID_STATUS_OFFLINE, hContact), 1); ///by FYR
 -		pcli->pfnSortContacts();
 -	}
 +
  	return 0;
  }
 @@ -414,25 +413,19 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam)  				return 0;
  			}
 -			if (pdnce->bIsHidden != 1) {
 -				pdnce->m_cache_nStatus = cws->value.wVal;
 -				if (cws->value.wVal == ID_STATUS_OFFLINE)
 -					if (g_CluiData.bRemoveAwayMessageForOffline)
 -						db_set_s(hContact, "CList", "StatusMsg", "");
 +			if (pdnce->bIsHidden)
 +				return 0;
 -				if ((db_get_w(NULL, "CList", "SecondLineType", 0) == TEXT_STATUS_MESSAGE || db_get_w(NULL, "CList", "ThirdLineType", 0) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->m_cache_cszProto)
 -					amRequestAwayMsg(hContact);
 +			pdnce->m_cache_nStatus = cws->value.wVal;
 +			if (cws->value.wVal == ID_STATUS_OFFLINE)
 +				if (g_CluiData.bRemoveAwayMessageForOffline)
 +					db_set_s(hContact, "CList", "StatusMsg", "");
 -				pcli->pfnClcBroadcast(INTM_STATUSCHANGED, hContact, 0);
 -				cli_ChangeContactIcon(hContact, pcli->pfnIconFromStatusMode(cws->szModule, cws->value.wVal, hContact), 0); //by FYR
 -				pcli->pfnSortContacts();
 -			}
 -			else {
 -				if (!(!strcmp(cws->szSetting, "LogonTS") || !strcmp(cws->szSetting, "TickTS") || !strcmp(cws->szSetting, "InfoTS")))
 -					pcli->pfnSortContacts();
 +			if ((db_get_w(NULL, "CList", "SecondLineType", 0) == TEXT_STATUS_MESSAGE || db_get_w(NULL, "CList", "ThirdLineType", 0) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->m_cache_cszProto)
 +				amRequestAwayMsg(hContact);
 -				return 0;
 -			}
 +			pcli->pfnClcBroadcast(INTM_STATUSCHANGED, hContact, 0);
 +			cli_ChangeContactIcon(hContact, pcli->pfnIconFromStatusMode(cws->szModule, cws->value.wVal, hContact), 0); //by FYR
  		}
  	}
 diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index e481236453..155bf8f8ad 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -520,8 +520,10 @@ recvRest:  			ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
  			// Set all contacts to offline
 +			debugLogA("1");
  			for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
  				SetContactOfflineStatus(hContact);
 +			debugLogA("2");
  			mir_free(m_szJabberJID);
  			m_szJabberJID = NULL;
 diff --git a/src/core/stdclist/src/clc.h b/src/core/stdclist/src/clc.h index d1e2196ac1..565fc7bd8a 100644 --- a/src/core/stdclist/src/clc.h +++ b/src/core/stdclist/src/clc.h @@ -24,10 +24,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  #define FONTID_LAST 7
 +int CompareContacts(const ClcContact *contact1, const ClcContact *contact2);
 +
  struct ClcContact : public ClcContactBase
  {
  };
  struct ClcData : public ClcDataBase
  {
 -};
\ No newline at end of file +};
 diff --git a/src/core/stdclist/src/clistopts.cpp b/src/core/stdclist/src/clistopts.cpp index 3027e38563..2484b8db5b 100644 --- a/src/core/stdclist/src/clistopts.cpp +++ b/src/core/stdclist/src/clistopts.cpp @@ -197,8 +197,12 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  							(WORD)SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_GETPOS, 0, 0));
  					}
  				}
 -				db_set_b(NULL, "CList", "SortByStatus", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SORTBYSTATUS));
 -				db_set_b(NULL, "CList", "SortByProto", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SORTBYPROTO));
 +				
 +				g_bSortByStatus = IsDlgButtonChecked(hwndDlg, IDC_SORTBYSTATUS);
 +				g_bSortByProto = IsDlgButtonChecked(hwndDlg, IDC_SORTBYPROTO);
 +
 +				db_set_b(NULL, "CList", "SortByStatus", (BYTE)g_bSortByStatus);
 +				db_set_b(NULL, "CList", "SortByProto", (BYTE)g_bSortByProto);
  				db_set_b(NULL, "CList", "ConfirmDelete", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CONFIRMDELETE));
  				db_set_b(NULL, "CList", "Tray1Click", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONECLK));
  				db_set_b(NULL, "CList", "AlwaysStatus", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYSSTATUS));
 diff --git a/src/core/stdclist/src/init.cpp b/src/core/stdclist/src/init.cpp index 5b84ea4b1e..2e36764da3 100644 --- a/src/core/stdclist/src/init.cpp +++ b/src/core/stdclist/src/init.cpp @@ -135,10 +135,14 @@ extern "C" __declspec(dllexport) int CListInitialise()  	mir_getLP(&pluginInfo);
  	mir_getCLI();
 +	g_bSortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT); +	g_bSortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT); +
  	coreCli = *pcli;
  	pcli->hInst = g_hInst;
  	pcli->pfnPaintClc = PaintClc;
  	pcli->pfnLoadClcOptions = LoadClcOptions;
 +	pcli->pfnCompareContacts = CompareContacts;
  	CreateServiceFunction(MS_CLIST_GETSTATUSMODE, GetStatusMode);
 diff --git a/src/core/stdclist/src/stdafx.h b/src/core/stdclist/src/stdafx.h index 827b60261e..74d4e569f9 100644 --- a/src/core/stdclist/src/stdafx.h +++ b/src/core/stdclist/src/stdafx.h @@ -59,5 +59,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  // shared vars
  extern HINSTANCE g_hInst;
  extern CLIST_INTERFACE coreCli;
 +extern int g_bSortByStatus, g_bSortByProto;  void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst);
 diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h index dfb5a93dba..4258eb1e57 100644 --- a/src/mir_app/src/clc.h +++ b/src/mir_app/src/clc.h @@ -125,15 +125,15 @@ void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF * colour);  void fnInvalidateDisplayNameCacheEntry(MCONTACT hContact);
  ClcCacheEntry* fnGetCacheEntry(MCONTACT hContact);
 -ClcCacheEntry* fnCreateCacheItem (MCONTACT hContact);
 +ClcCacheEntry* fnCreateCacheItem(MCONTACT hContact);
  void fnCheckCacheItem(ClcCacheEntry *p);
  void fnFreeCacheItem(ClcCacheEntry *p);
  /* clcfiledrop.c */
  void InitFileDropping(void);
 -void   fnRegisterFileDropping (HWND hwnd);
 -void   fnUnregisterFileDropping (HWND hwnd);
 +void   fnRegisterFileDropping(HWND hwnd);
 +void   fnUnregisterFileDropping(HWND hwnd);
  /* clistevents.c */
  struct CListEvent* fnAddEvent(CLISTEVENT *cle);
 @@ -163,44 +163,42 @@ void   fnUninitTray(void);  int    fnCListTrayNotify(MIRANDASYSTRAYNOTIFY *msn);
  int    fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int status);
  int    fnTrayIconDestroy(HWND hwnd);
 -void   fnTrayIconIconsChanged (void);
 +void   fnTrayIconIconsChanged(void);
  int    fnTrayIconInit(HWND hwnd);
  TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto);
 -int    fnTrayIconPauseAutoHide (WPARAM wParam, LPARAM lParam);
 -INT_PTR    fnTrayIconProcessMessage (WPARAM wParam, LPARAM lParam);
 +int    fnTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam);
 +INT_PTR    fnTrayIconProcessMessage(WPARAM wParam, LPARAM lParam);
  void   fnTrayIconRemove(HWND hwnd, const char *szProto);
  int    fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto);
 -void   fnTrayIconSetToBase (char *szPreferredProto);
 +void   fnTrayIconSetToBase(char *szPreferredProto);
  void   fnTrayIconTaskbarCreated(HWND hwnd);
  int    fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPreferredProto, int isBase);
 -void   fnTrayIconUpdateBase (const char *szChangedProto);
 +void   fnTrayIconUpdateBase(const char *szChangedProto);
  int    fnTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
 -void   fnTrayIconUpdateWithImageList (int iImage, const TCHAR *szNewTip, char *szPreferredProto);
 +void   fnTrayIconUpdateWithImageList(int iImage, const TCHAR *szNewTip, char *szPreferredProto);
  VOID CALLBACK fnTrayCycleTimerProc(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime);
  /* clui.c */
 -LRESULT CALLBACK fnContactListWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
 +LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  void fnLoadCluiGlobalOpts(void);
  void fnCluiProtocolStatusChanged(int, const char*);
  void fnDrawMenuItem(DRAWITEMSTRUCT *dis, HICON hIcon, HICON eventIcon);
  /* contact.c */
 -void fnChangeContactIcon (MCONTACT hContact, int iIcon, int add);
 -void fnLoadContactTree (void);
 -int  fnCompareContacts (const ClcContact *contact1, const ClcContact *contact2);
 -void fnSortContacts (void);
 -int  fnSetHideOffline (WPARAM wParam, LPARAM lParam);
 +void fnChangeContactIcon(MCONTACT hContact, int iIcon, int add);
 +void fnLoadContactTree(void);
 +int  fnSetHideOffline(WPARAM wParam, LPARAM lParam);
  /* docking.c */
 -int fnDocking_ProcessWindowMessage (WPARAM wParam, LPARAM lParam);
 +int fnDocking_ProcessWindowMessage(WPARAM wParam, LPARAM lParam);
  /* group.c */
 -TCHAR* fnGetGroupName (int idx, DWORD* pdwFlags);
 -int    fnRenameGroup (int groupID, TCHAR* newName);
 +TCHAR* fnGetGroupName(int idx, DWORD* pdwFlags);
 +int    fnRenameGroup(int groupID, TCHAR* newName);
  /* keyboard.c */
 -int  fnHotKeysRegister (HWND hwnd);
 -void fnHotKeysUnregister (HWND hwnd);
 -int  fnHotKeysProcess (HWND hwnd, WPARAM wParam, LPARAM lParam);
 -int  fnHotkeysProcessMessage (WPARAM wParam, LPARAM lParam);
 +int  fnHotKeysRegister(HWND hwnd);
 +void fnHotKeysUnregister(HWND hwnd);
 +int  fnHotKeysProcess(HWND hwnd, WPARAM wParam, LPARAM lParam);
 +int  fnHotkeysProcessMessage(WPARAM wParam, LPARAM lParam);
 diff --git a/src/mir_app/src/clistcore.cpp b/src/mir_app/src/clistcore.cpp index 7df2f0d0ed..ad60954e37 100644 --- a/src/mir_app/src/clistcore.cpp +++ b/src/mir_app/src/clistcore.cpp @@ -181,8 +181,6 @@ static INT_PTR srvRetrieveInterface(WPARAM, LPARAM)  		cli.pfnChangeContactIcon               = fnChangeContactIcon;
  		cli.pfnLoadContactTree                 = fnLoadContactTree;
 -		cli.pfnCompareContacts                 = fnCompareContacts;
 -		cli.pfnSortContacts                    = fnSortContacts;
  		cli.pfnSetHideOffline                  = fnSetHideOffline;
  		cli.pfnDocking_ProcessWindowMessage	   = fnDocking_ProcessWindowMessage;
 diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp index af2a581041..cc55ef5091 100644 --- a/src/mir_app/src/clistevents.cpp +++ b/src/mir_app/src/clistevents.cpp @@ -179,7 +179,6 @@ CListEvent* fnAddEvent(CLISTEVENT *cle)  		cli.pfnTrayIconUpdateWithImageList(p->imlIconIndex, p->cle.ptszTooltip, szProto);
  	}
  	cli.pfnChangeContactIcon(cle->hContact, p->imlIconIndex, 1);
 -	cli.pfnSortContacts();
  	return p;
  }
 diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index db63eae84c..701ef7da12 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -251,14 +251,12 @@ static INT_PTR ContactFilesDropped(WPARAM wParam, LPARAM lParam)  static int CListIconsChanged(WPARAM, LPARAM)
  {
 -	int i, j;
 -
 -	for (i = 0; i < _countof(statusModeList); i++)
 +	for (int i = 0; i < _countof(statusModeList); i++)
  		ImageList_ReplaceIcon_IconLibLoaded(hCListImages, i + 1, Skin_LoadIcon(skinIconStatusList[i]));
  	ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPOPEN, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN));
  	ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPSHUT, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT));
 -	for (i = 0; i < protoIconIndex.getCount(); i++)
 -		for (j = 0; j < _countof(statusModeList); j++)
 +	for (int i = 0; i < protoIconIndex.getCount(); i++)
 +		for (int j = 0; j < _countof(statusModeList); j++)
  			ImageList_ReplaceIcon_IconLibLoaded(hCListImages, protoIconIndex[i].iIconBase + j, Skin_LoadProtoIcon(protoIconIndex[i].szProto, statusModeList[j]));
  	cli.pfnTrayIconIconsChanged();
  	cli.pfnInvalidateRect(cli.hwndContactList, NULL, TRUE);
 @@ -333,7 +331,7 @@ int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)  	if (iNotCoveredDots == 0)  //They're all covered!
  		return GWVS_COVERED;
 -	//There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
 +	// There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
  	return GWVS_PARTIALLY_COVERED;
  }
 @@ -361,8 +359,6 @@ int fnShowHide(WPARAM, LPARAM)  	}
  	if (bShow == TRUE) {
 -		RECT rcWindow;
 -
  		ShowWindow(cli.hwndContactList, SW_RESTORE);
  		if (!db_get_b(NULL, "CList", "OnTop", SETTING_ONTOP_DEFAULT))
  			SetWindowPos(cli.hwndContactList, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
 @@ -372,14 +368,13 @@ int fnShowHide(WPARAM, LPARAM)  		SetForegroundWindow(cli.hwndContactList);
  		db_set_b(NULL, "CList", "State", SETTING_STATE_NORMAL);
 -		//this forces the window onto the visible screen
 +		// this forces the window onto the visible screen
 +		RECT rcWindow;
  		GetWindowRect(cli.hwndContactList, &rcWindow);
 -		if (Utils_AssertInsideScreen(&rcWindow) == 1) {
 -			MoveWindow(cli.hwndContactList, rcWindow.left, rcWindow.top,
 -				rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE);
 -		}
 +		if (Utils_AssertInsideScreen(&rcWindow) == 1)
 +			MoveWindow(cli.hwndContactList, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE);
  	}
 -	else {                      //It needs to be hidden
 +	else { // It needs to be hidden
  		if (db_get_b(NULL, "CList", "ToolWindow", SETTING_TOOLWINDOW_DEFAULT) ||
  			db_get_b(NULL, "CList", "Min2Tray", SETTING_MIN2TRAY_DEFAULT)) {
  			ShowWindow(cli.hwndContactList, SW_HIDE);
 @@ -396,57 +391,15 @@ int fnShowHide(WPARAM, LPARAM)  	return 0;
  }
 -///////////////////////////////////////////////////////////////////////////////
 -// old evil code. hopefully it will be deleted soon, cause nobody uses it now
 -
 -#define SAFESTRING(a) a?a:""
 -
 -int GetStatusModeOrdering(int statusMode);
 -extern int sortByStatus, sortByProto;
 +/////////////////////////////////////////////////////////////////////////////////////////
  static INT_PTR CompareContacts(WPARAM wParam, LPARAM lParam)
  {
 -	MCONTACT a = wParam, b = lParam;
 -	TCHAR namea[128], *nameb;
 -	int rc;
 -
 -	char *szProto1 = GetContactProto(a);
 -	char *szProto2 = GetContactProto(b);
 -	int statusa = db_get_w(a, SAFESTRING(szProto1), "Status", ID_STATUS_OFFLINE);
 -	int statusb = db_get_w(b, SAFESTRING(szProto2), "Status", ID_STATUS_OFFLINE);
 -
 -	if (sortByProto) {
 -		/* deal with statuses, online contacts have to go above offline */
 -		if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) {
 -			return 2 * (statusa == ID_STATUS_OFFLINE) - 1;
 -		}
 -		/* both are online, now check protocols */
 -		rc = mir_strcmp(SAFESTRING(szProto1), SAFESTRING(szProto2));        /* mir_strcmp() doesn't like NULL so feed in "" as needed */
 -		if (rc != 0 && (szProto1 != NULL && szProto2 != NULL))
 -			return rc;
 -		/* protocols are the same, order by display name */
 -	}
 -
 -	if (sortByStatus) {
 -		int ordera, orderb;
 -		ordera = GetStatusModeOrdering(statusa);
 -		orderb = GetStatusModeOrdering(statusb);
 -		if (ordera != orderb)
 -			return ordera - orderb;
 -	}
 -	else {
 -		//one is offline: offline goes below online
 -		if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) {
 -			return 2 * (statusa == ID_STATUS_OFFLINE) - 1;
 -		}
 -	}
 +	ClcContact *p1, *p2;
 +	if (!cli.pfnFindItem(cli.hwndContactTree, NULL, wParam, &p1, NULL, NULL) && !cli.pfnFindItem(cli.hwndContactTree, NULL, lParam, &p2, NULL, NULL))
 +		return cli.pfnCompareContacts(p1, p2);
 -	nameb = cli.pfnGetContactDisplayName(a, 0);
 -	_tcsncpy_s(namea, nameb, _TRUNCATE);
 -	nameb = cli.pfnGetContactDisplayName(b, 0);
 -
 -	//otherwise just compare names
 -	return mir_tstrcmpi(namea, nameb);
 +	return 0;
  }
  /***************************************************************************************/
 diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index 2c0780aaa7..b202ed0572 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -149,7 +149,6 @@ INT_PTR InvalidateDisplayName(WPARAM wParam, LPARAM)  int ContactAdded(WPARAM wParam, LPARAM)
  {
  	cli.pfnChangeContactIcon(wParam, cli.pfnIconFromStatusMode(GetContactProto(wParam), ID_STATUS_OFFLINE, NULL), 1);
 -	cli.pfnSortContacts();
  	return 0;
  }
 @@ -196,7 +195,6 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam)  				mir_free(dbv.pszVal);
  				return 0;
  			}
 -			cli.pfnSortContacts();
  		}
  	}
 diff --git a/src/mir_app/src/contact.cpp b/src/mir_app/src/contact.cpp index 560eb60d5a..d561c1faa7 100644 --- a/src/mir_app/src/contact.cpp +++ b/src/mir_app/src/contact.cpp @@ -28,23 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  extern HANDLE hContactIconChangedEvent;  extern HANDLE hGroupChangeEvent; -int sortByStatus; -int sortByProto; - -static const struct { -	int status, order; -} statusModeOrder[] = { -	{ID_STATUS_OFFLINE, 500}, -	{ID_STATUS_ONLINE, 10}, -	{ID_STATUS_AWAY, 200}, -	{ID_STATUS_DND, 110}, -	{ID_STATUS_NA, 450}, -	{ID_STATUS_OCCUPIED, 100}, -	{ID_STATUS_FREECHAT, 0}, -	{ID_STATUS_INVISIBLE, 20}, -	{ID_STATUS_ONTHEPHONE, 150}, -	{ID_STATUS_OUTTOLUNCH, 425}}; -  static int GetContactStatus(MCONTACT hContact)  {  	char *szProto = GetContactProto(hContact); @@ -59,15 +42,6 @@ void fnChangeContactIcon(MCONTACT hContact, int iIcon, int add)  	NotifyEventHooks(hContactIconChangedEvent, hContact, iIcon);  } -int GetStatusModeOrdering(int statusMode) -{ -	int i; -	for (i=0; i < _countof(statusModeOrder); i++) -		if (statusModeOrder[i].status == statusMode) -			return statusModeOrder[i].order; -	return 1000; -} -  void fnLoadContactTree(void)  {  	CallService(MS_CLUI_LISTBEGINREBUILD, 0, 0); @@ -83,63 +57,9 @@ void fnLoadContactTree(void)  		if ((!hideOffline || status != ID_STATUS_OFFLINE) && !db_get_b(hContact, "CList", "Hidden", 0))  			cli.pfnChangeContactIcon(hContact, cli.pfnIconFromStatusMode(GetContactProto(hContact), status, hContact), 1);  	} -	sortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT); -	sortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT);  	CallService(MS_CLUI_LISTENDREBUILD, 0, 0);  } -int fnCompareContacts(const ClcContact* c1, const ClcContact* c2) -{ -	MCONTACT a = c1->hContact, b = c2->hContact; -	TCHAR namea[128], *nameb; -	int statusa, statusb; -	int rc; - -	statusa = db_get_w(a, c1->proto, "Status", ID_STATUS_OFFLINE); -	statusb = db_get_w(b, c2->proto, "Status", ID_STATUS_OFFLINE); - -	if (sortByProto) { -		/* deal with statuses, online contacts have to go above offline */ -		if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) { -			return 2 * (statusa == ID_STATUS_OFFLINE) - 1; -		} -		/* both are online, now check protocols */ -		if (c1->proto != NULL && c2->proto != NULL) { -			rc = mir_strcmp(c1->proto, c2->proto); -			if (rc != 0) -				return rc; -		} -		/* protocols are the same, order by display name */ -	} - -	if (sortByStatus) { -		int ordera = GetStatusModeOrdering(statusa); -		int orderb = GetStatusModeOrdering(statusb); -		if (ordera != orderb) -			return ordera - orderb; -	} -	else { -		//one is offline: offline goes below online -		if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) -			return 2 * (statusa == ID_STATUS_OFFLINE) - 1; -	} - -	nameb = cli.pfnGetContactDisplayName(a, 0); -	_tcsncpy_s(namea, nameb, _TRUNCATE); -	namea[ _countof(namea)-1 ] = 0; -	nameb = cli.pfnGetContactDisplayName(b, 0); - -	//otherwise just compare names -	return mir_tstrcmpi(namea, nameb); -} - -void fnSortContacts(void) -{ -	//avoid doing lots of resorts in quick succession -	sortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT); -	sortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT); -} -  INT_PTR ContactChangeGroup(WPARAM wParam, LPARAM lParam)  {  	CLISTGROUPCHANGE grpChg = { sizeof(CLISTGROUPCHANGE), NULL, NULL }; | 
