diff options
Diffstat (limited to 'plugins/Scriver')
| -rw-r--r-- | plugins/Scriver/src/chat/window.cpp | 18 | ||||
| -rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 6 | ||||
| -rw-r--r-- | plugins/Scriver/src/msgs.cpp | 6 | ||||
| -rw-r--r-- | plugins/Scriver/src/statusicon.cpp | 259 | ||||
| -rw-r--r-- | plugins/Scriver/src/statusicon.h | 4 | 
5 files changed, 65 insertions, 228 deletions
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index a384eeb7e4..8802af4fc6 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -1245,28 +1245,26 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)  	case DM_UPDATESTATUSBAR:
  		{
 -			StatusIconData sid;
 -			StatusBarData sbd;
 -			HICON hIcon;
  			MODULEINFO* mi = MM_FindModule(si->pszModule);
  			TCHAR szTemp[512];
 -			hIcon = si->wStatus==ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
 +			HICON hIcon = si->wStatus==ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
  			mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s : %s"), mi->ptszModDispName, si->ptszStatusbarText ? si->ptszStatusbarText : _T(""));
 +
 +			StatusBarData sbd;
  			sbd.iItem = 0;
  			sbd.iFlags = SBDF_TEXT | SBDF_ICON;
  			sbd.hIcon = hIcon;
  			sbd.pszText = szTemp;
  			SendMessage(GetParent(hwndDlg), CM_UPDATESTATUSBAR, (WPARAM) &sbd, (LPARAM)hwndDlg);
 +
  			sbd.iItem = 1;
  			sbd.hIcon = NULL;
 -			sbd.pszText   = _T("");
 +			sbd.pszText = _T("");
  			SendMessage(GetParent(hwndDlg), CM_UPDATESTATUSBAR, (WPARAM) &sbd, (LPARAM)hwndDlg);
 -			sid.cbSize = sizeof(sid);
 -			sid.szModule = SRMMMOD;
 -			sid.dwId = 0;
 -			sid.flags = 0;
 -			ModifyStatusIcon((WPARAM)si->windowData.hContact, (LPARAM)&sid);
 +			StatusIconData sid = { sizeof(sid) };
 +			sid.szModule = SRMMMOD;
 +			CallService(MS_MSG_MODIFYICON, (WPARAM)si->windowData.hContact, (LPARAM)&sid);
  		}
  		break;
 diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 75d5fb77f2..25652a8c7e 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1266,7 +1266,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP  				db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW)));
  			db_set_b(dat->windowData.hContact, SRMMMOD, SRMSGSET_TYPING, (BYTE)!typingNotify);
  			sid.flags = typingNotify ? MBF_DISABLED : 0;
 -			ModifyStatusIcon((WPARAM)dat->windowData.hContact, (LPARAM)&sid);
 +			CallService(MS_MSG_MODIFYICON, (WPARAM)dat->windowData.hContact, (LPARAM)&sid);
  		}
  		break;
 @@ -1503,7 +1503,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP  			sid.cbSize = sizeof(sid);
  			sid.szModule = SRMMMOD;
  			sid.flags = MBF_DISABLED;
 -			ModifyStatusIcon((WPARAM)dat->windowData.hContact, (LPARAM)&sid);
 +			CallService(MS_MSG_MODIFYICON, (WPARAM)dat->windowData.hContact, (LPARAM)&sid);
  			sid.dwId = 1;
  			if (IsTypingNotificationSupported(dat) && g_dat.flags2 & SMF2_SHOWTYPINGSWITCH)
  				sid.flags = (db_get_b(dat->windowData.hContact, SRMMMOD, SRMSGSET_TYPING,
 @@ -1511,7 +1511,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP  			else
  				sid.flags = MBF_HIDDEN;
 -			ModifyStatusIcon((WPARAM)dat->windowData.hContact, (LPARAM)&sid);
 +			CallService(MS_MSG_MODIFYICON, (WPARAM)dat->windowData.hContact, (LPARAM)&sid);
  		}
  		break;
 diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 0eaf5158c8..26600238b0 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -377,7 +377,7 @@ static void RegisterStatusIcons()  	sid.hIconDisabled = CopyIcon(GetCachedIcon("scriver_TYPINGOFF"));
  	sid.flags = MBF_HIDDEN;
  	sid.szTooltip = NULL;
 -	AddStickyStatusIcon((WPARAM) 0, (LPARAM)&sid);
 +	CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
  }
  void ChangeStatusIcons()
 @@ -386,13 +386,13 @@ void ChangeStatusIcons()  	sid.szModule = SRMMMOD;
  	sid.hIcon = CopyIcon(GetCachedIcon("scriver_UNICODEON"));
  	sid.hIconDisabled = CopyIcon(GetCachedIcon("scriver_UNICODEOFF"));
 -	ModifyStatusIcon(0, (LPARAM)&sid);
 +	CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid);
  	sid.dwId = 1;
  	sid.hIcon = CopyIcon(GetCachedIcon("scriver_TYPING"));
  	sid.hIconDisabled = CopyIcon(GetCachedIcon("scriver_TYPINGOFF"));
  	sid.flags = MBF_HIDDEN;
 -	ModifyStatusIcon(0, (LPARAM)&sid);
 +	CallService(MS_MSG_MODIFYICON, 0, (LPARAM)&sid);
  }
  int StatusIconPressed(WPARAM wParam, LPARAM lParam)
 diff --git a/plugins/Scriver/src/statusicon.cpp b/plugins/Scriver/src/statusicon.cpp index b283bb22f8..b530c3ebe3 100644 --- a/plugins/Scriver/src/statusicon.cpp +++ b/plugins/Scriver/src/statusicon.cpp @@ -23,236 +23,77 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  #include "commonheaders.h"
 -struct StatusIconListNode {
 -	StatusIconData sid;
 -	struct StatusIconListNode *next;
 -};
 -
  HANDLE hHookIconPressedEvt;
 -static struct StatusIconListNode *status_icon_list = 0;
 -static int status_icon_list_size = 0;
 -
 -static INT_PTR AddStatusIcon(WPARAM wParam, LPARAM lParam) {
 -	StatusIconData *sid = (StatusIconData *)lParam;
 -	struct StatusIconListNode *siln = (struct StatusIconListNode *)mir_alloc(sizeof(struct StatusIconListNode));
 -
 -	siln->sid.cbSize = sid->cbSize;
 -	siln->sid.szModule = mir_strdup(sid->szModule);
 -	siln->sid.dwId = sid->dwId;
 -	siln->sid.hIcon = sid->hIcon;
 -	siln->sid.hIconDisabled = sid->hIconDisabled;
 -	siln->sid.flags = sid->flags;
 -	if (sid->szTooltip) siln->sid.szTooltip = mir_strdup(sid->szTooltip);
 -	else siln->sid.szTooltip = 0;
 -
 -	siln->next = status_icon_list;
 -	status_icon_list = siln;
 -	status_icon_list_size++;
 -
 -	WindowList_Broadcast(g_dat.hParentWindowList, DM_STATUSICONCHANGE, 0, 0);
 -	return 0;
 -}
 -
 -INT_PTR AddStickyStatusIcon(WPARAM wParam, LPARAM lParam) {
 -	StatusIconData *sid = (StatusIconData *)lParam;
 -	struct StatusIconListNode *siln = (struct StatusIconListNode *)mir_alloc(sizeof(struct StatusIconListNode));
 -	struct StatusIconListNode *siln2 = status_icon_list;
 -
 -	siln->sid.cbSize = sid->cbSize;
 -	siln->sid.szModule = mir_strdup(sid->szModule);
 -	siln->sid.dwId = sid->dwId;
 -	siln->sid.hIcon = sid->hIcon;
 -	siln->sid.hIconDisabled = sid->hIconDisabled;
 -	siln->sid.flags = sid->flags;
 -	if (sid->szTooltip) siln->sid.szTooltip = mir_strdup(sid->szTooltip);
 -	else siln->sid.szTooltip = 0;
 -	siln->next = NULL;
 -
 -	while(siln2 && siln2->next) {
 -		siln2 = siln2->next;
 -	}
 -	if (siln2) {
 -		siln2->next = siln;
 -	} else {
 -		status_icon_list = siln;
 -	}
 -
 -	status_icon_list_size++;
 -
 -	WindowList_Broadcast(g_dat.hParentWindowList, DM_STATUSICONCHANGE, 0, 0);
 -	return 0;
 -}
 -
 -static INT_PTR RemoveStatusIcon(WPARAM wParam, LPARAM lParam) {
 -	StatusIconData *sid = (StatusIconData *)lParam;
 -	struct StatusIconListNode *current = status_icon_list, *prev = 0;
 -
 -	while(current) {
 -		if (strcmp(current->sid.szModule, sid->szModule) == 0 && current->sid.dwId == sid->dwId) {
 -			if (prev) prev->next = current->next;
 -			else status_icon_list = current->next;
 -
 -			status_icon_list_size--;
 -
 -			mir_free(current->sid.szModule);
 -			ReleaseIconSmart(current->sid.hIcon);
 -			ReleaseIconSmart(current->sid.hIconDisabled);
 -			mir_free(current->sid.szTooltip);
 -			mir_free(current);
 -			WindowList_Broadcast(g_dat.hParentWindowList, DM_STATUSICONCHANGE, 0, 0);
 -			return 0;
 -		}
 -
 -		prev = current;
 -		current = current->next;
 -	}
 -
 -	return 1;
 -}
 -
 -static void RemoveAllStatusIcons(void) {
 -	struct StatusIconListNode *current;
 -
 -	while(status_icon_list) {
 -		current = status_icon_list;
 -		status_icon_list = status_icon_list->next;
 -		status_icon_list_size--;
 -
 -		mir_free(current->sid.szModule);
 -		DestroyIcon(current->sid.hIcon);
 -		if (current->sid.hIconDisabled) DestroyIcon(current->sid.hIconDisabled);
 -		if (current->sid.szTooltip) mir_free(current->sid.szTooltip);
 -		mir_free(current);
 -	}
 -
 -	WindowList_Broadcast(g_dat.hParentWindowList, DM_STATUSICONCHANGE, 0, 0);
 -}
 -
 -INT_PTR ModifyStatusIcon(WPARAM wParam, LPARAM lParam) {
 -	HANDLE hContact = (HANDLE)wParam;
 -
 -	StatusIconData *sid = (StatusIconData *)lParam;
 -	struct StatusIconListNode *current = status_icon_list;
 -
 -	while(current) {
 -		if (strcmp(current->sid.szModule, sid->szModule) == 0 && current->sid.dwId == sid->dwId) {
 -			if (!hContact) {
 -				current->sid.flags = sid->flags;
 -				if (sid->hIcon) {
 -					ReleaseIconSmart(current->sid.hIcon);
 -					current->sid.hIcon = sid->hIcon;
 -				}
 -				if (sid->hIconDisabled) {
 -					ReleaseIconSmart(current->sid.hIconDisabled);
 -					current->sid.hIconDisabled = sid->hIconDisabled;
 -				}
 -				if (sid->szTooltip) {
 -					if (current->sid.szTooltip) mir_free(current->sid.szTooltip);
 -					current->sid.szTooltip = mir_strdup(sid->szTooltip);
 -				}
 -
 -				WindowList_Broadcast(g_dat.hParentWindowList, DM_STATUSICONCHANGE, 0, 0);
 -			} else {
 -				char buff[256];
 -				HWND hwnd;
 -				sprintf(buff, "SRMMStatusIconFlags%d", (int)sid->dwId);
 -				db_set_b(hContact, sid->szModule, buff, (BYTE)sid->flags);
 -				hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
 -				if (hwnd == NULL) {
 -					hwnd = SM_FindWindowByContact(hContact);
 -				}
 -				if (hwnd != NULL) {
 -					PostMessage(GetParent(hwnd), DM_STATUSICONCHANGE, 0, 0);
 -				}
 -			}
 -			return 0;
 -		}
 -		current = current->next;
 -	}
 -
 -	return 1;
 -}
 -
 -void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int gap) {
 -	struct StatusIconListNode *current = status_icon_list;
 +void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int gap)
 +{
  	HICON hIcon;
 -	char buff[256];
 -	int flags;
  	int x = r.left;
 -	while(current) {
 -		sprintf(buff, "SRMMStatusIconFlags%d", (int)current->sid.dwId);
 -		flags = db_get_b(hContact, current->sid.szModule, buff, current->sid.flags);
 -		if (!(flags & MBF_HIDDEN)) {
 -			if ((flags & MBF_DISABLED) && current->sid.hIconDisabled) hIcon = current->sid.hIconDisabled;
 -			else hIcon = current->sid.hIcon;
 -			SetBkMode(hDC, TRANSPARENT);
 -			DrawIconEx(hDC, x, (r.top + r.bottom - GetSystemMetrics(SM_CYSMICON)) >> 1, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
 +	StatusIconData *si;
 +	int nIcon = 0;
 +	while ((si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon++)) != NULL) {
 +		if ((si->flags & MBF_DISABLED) && si->hIconDisabled) hIcon = si->hIconDisabled;
 +		else hIcon = si->hIcon;
 +
 +		SetBkMode(hDC, TRANSPARENT);
 +		DrawIconEx(hDC, x, (r.top + r.bottom - GetSystemMetrics(SM_CYSMICON)) >> 1, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
 -			x += GetSystemMetrics(SM_CYSMICON) + gap;
 -		}
 -		current = current->next;
 +		x += GetSystemMetrics(SM_CYSMICON) + gap;
  	}
  }
 -void CheckStatusIconClick(HANDLE hContact, HWND hwndFrom, POINT pt, RECT r, int gap, int click_flags) {
 -	StatusIconClickData sicd;
 -	struct StatusIconListNode *current = status_icon_list;
 +void CheckStatusIconClick(HANDLE hContact, HWND hwndFrom, POINT pt, RECT r, int gap, int click_flags)
 +{
  	unsigned int iconNum = (pt.x - r.left) / (GetSystemMetrics(SM_CXSMICON) + gap) + 1;
 -	int flags;
 -	char buff[256];
 -
 -	while(current) {
 -		sprintf(buff, "SRMMStatusIconFlags%d", (int)current->sid.dwId);
 -		flags = db_get_b(hContact, current->sid.szModule, buff, current->sid.flags);
 -		if (!(flags & MBF_HIDDEN)) iconNum--;
 -		if (iconNum == 0) break;
 -		current = current->next;
 -	}
 +	StatusIconData *si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, iconNum);
 +	if (si == NULL)
 +		return;
 +
 +	ClientToScreen(hwndFrom, &pt);
 +
 +	StatusIconClickData sicd = { sizeof(sicd) };
 +	sicd.clickLocation = pt;
 +	sicd.dwId = si->dwId;
 +	sicd.szModule = si->szModule;
 +	sicd.flags = click_flags;
 +	NotifyEventHooks(hHookIconPressedEvt, (WPARAM)hContact, (LPARAM)&sicd);
 +}
 -	if (current) {
 -		ClientToScreen(hwndFrom, &pt);
 -		sicd.cbSize = sizeof(StatusIconClickData);
 -		sicd.clickLocation = pt;
 -		sicd.dwId = current->sid.dwId;
 -		sicd.szModule = current->sid.szModule;
 -		sicd.flags = click_flags;
 -		NotifyEventHooks(hHookIconPressedEvt, (WPARAM)hContact, (LPARAM)&sicd);
 +static int OnSrmmIconChanged(WPARAM wParam, LPARAM)
 +{
 +	HANDLE hContact = (HANDLE)wParam;
 +	if (hContact == NULL)
 +		WindowList_Broadcast(g_dat.hParentWindowList, DM_STATUSICONCHANGE, 0, 0);
 +	else {
 +		HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
 +		if (hwnd == NULL)
 +			hwnd = SM_FindWindowByContact(hContact);
 +		if (hwnd != NULL)
 +			PostMessage(GetParent(hwnd), DM_STATUSICONCHANGE, 0, 0);
  	}
 +	return 0;
  }
 +int InitStatusIcons()
 +{
 +	HookEvent(ME_MSG_ICONSCHANGED, OnSrmmIconChanged);
 -HANDLE hServiceIcon[3];
 -int InitStatusIcons() {
 -	hServiceIcon[0] = CreateServiceFunction(MS_MSG_ADDICON, AddStatusIcon);
 -	hServiceIcon[1] = CreateServiceFunction(MS_MSG_REMOVEICON, RemoveStatusIcon);
 -	hServiceIcon[2] = CreateServiceFunction(MS_MSG_MODIFYICON, ModifyStatusIcon);
  	hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED);
  	return 0;
  }
 -int DeinitStatusIcons() {
 -	int i;
 +int DeinitStatusIcons()
 +{
  	DestroyHookableEvent(hHookIconPressedEvt);
 -	for(i = 0; i < 3; i++) DestroyServiceFunction(hServiceIcon[i]);
 -	RemoveAllStatusIcons();
  	return 0;
  }
 -INT_PTR GetStatusIconsCount(HANDLE hContact) {
 -	char buff[256];
 -	int count = 0;
 -	int flags;
 -	struct StatusIconListNode *current = status_icon_list;
 -	while(current) {
 -		sprintf(buff, "SRMMStatusIconFlags%d", (int)current->sid.dwId);
 -		flags = db_get_b(hContact, current->sid.szModule, buff, current->sid.flags);
 -		if (!(flags & MBF_HIDDEN)) {
 -			count ++;
 -		}
 -		current = current->next;
 -	}
 -	return count;
 -//	return status_icon_list_size;
 +int GetStatusIconsCount(HANDLE hContact)
 +{
 +	StatusIconData *si;
 +	int nIcon = 0;
 +	while ((si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon)) != NULL)
 +		nIcon++;
 +	return nIcon;
  }
 diff --git a/plugins/Scriver/src/statusicon.h b/plugins/Scriver/src/statusicon.h index c606cf6291..c05cbd7ab8 100644 --- a/plugins/Scriver/src/statusicon.h +++ b/plugins/Scriver/src/statusicon.h @@ -26,9 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  int InitStatusIcons();
  int DeinitStatusIcons();
 -INT_PTR  GetStatusIconsCount(HANDLE hContact);
 +int  GetStatusIconsCount(HANDLE hContact);
  void DrawStatusIcons(HANDLE hContact, HDC hdc, RECT r, int gap);
  void CheckStatusIconClick(HANDLE hContact, HWND hwndFrom, POINT pt, RECT rc, int gap, int flags);
 -INT_PTR AddStickyStatusIcon(WPARAM wParam, LPARAM lParam);
 -INT_PTR ModifyStatusIcon(WPARAM wParam, LPARAM lParam);
  #endif
  | 
