diff options
Diffstat (limited to 'protocols/Non-IM Contact/src/services.cpp')
| -rw-r--r-- | protocols/Non-IM Contact/src/services.cpp | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/protocols/Non-IM Contact/src/services.cpp b/protocols/Non-IM Contact/src/services.cpp new file mode 100644 index 0000000000..e1b3278b84 --- /dev/null +++ b/protocols/Non-IM Contact/src/services.cpp @@ -0,0 +1,112 @@ +#include "stdafx.h" + +//======================================================= +// GetCaps +//======================================================= +// +INT_PTR GetLCCaps(WPARAM wParam, LPARAM) +{ + if (wParam == PFLAGNUM_1) + return 0; + if (wParam == PFLAGNUM_2) + return PF2_ONLINE | PF2_LONGAWAY | PF2_SHORTAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_INVISIBLE | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; // add the possible statuses here. + if (wParam == PFLAGNUM_3) + return 0; + return 0; +} + +//======================================================= +// GetName +//======================================================= +// +INT_PTR GetLCName(WPARAM wParam, LPARAM lParam) +{ + mir_strncpy((char*)lParam, MODNAME, wParam); + return 0; +} + +//======================================================= +// BPLoadIcon +//======================================================= +// +INT_PTR LoadLCIcon(WPARAM wParam, LPARAM) +{ + if (LOWORD(wParam) == PLI_PROTOCOL) { + if (wParam & PLIF_ICOLIBHANDLE) + return (INT_PTR)iconList[0].hIcolib; + + HICON hIcon = IcoLib_GetIconByHandle(iconList[0].hIcolib, (wParam & PLIF_SMALL) == 0); + if (wParam & PLIF_ICOLIB) + return (INT_PTR)hIcon; + + HICON hIcon2 = CopyIcon(hIcon); + IcoLib_ReleaseIcon(hIcon); + return (INT_PTR)hIcon2; + } + + return NULL; +} + +//======================================================= +// SetFStatus +//======================================================= +// +int SetLCStatus(WPARAM wParam, LPARAM) +{ + int oldStatus = LCStatus; + LCStatus = wParam; + g_plugin.setWord("Status", (WORD)wParam); + g_plugin.setWord("timerCount", 0); + if (LCStatus == ID_STATUS_OFFLINE || (LCStatus == ID_STATUS_AWAY && !g_plugin.getByte("AwayAsStatus", 0)) || !g_plugin.getWord("Timer", 1)) + killTimer(); + else if (g_plugin.getWord("Timer", 1)) + startTimer(TIMER); + + for (auto &hContact : Contacts(MODNAME)) { + if (LCStatus != ID_STATUS_OFFLINE) + replaceAllStrings(hContact); + + switch (LCStatus) { + case ID_STATUS_OFFLINE: + if (g_plugin.getByte(hContact, "AlwaysVisible", 0) && !g_plugin.getByte(hContact, "VisibleUnlessOffline", 1)) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); + else + g_plugin.setWord(hContact, "Status", ID_STATUS_OFFLINE); + break; + + case ID_STATUS_ONLINE: + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); + break; + + case ID_STATUS_AWAY: + if (g_plugin.getByte("AwayAsStatus", 0) && (g_plugin.getByte(hContact, "AlwaysVisible", 0) || (g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE) == ID_STATUS_AWAY))) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); + else if (!g_plugin.getByte("AwayAsStatus", 0)) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); + else + g_plugin.setWord(hContact, "Status", ID_STATUS_OFFLINE); + break; + + default: + if (g_plugin.getByte(hContact, "AlwaysVisible", 0) || LCStatus == g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); + break; + } + } + + ProtoBroadcastAck(MODNAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, wParam); + return 0; +} + +//======================================================= +// GetStatus +//======================================================= +// +INT_PTR GetLCStatus(WPARAM, LPARAM) +{ + if ((LCStatus >= ID_STATUS_ONLINE) && (LCStatus <= ID_STATUS_OUTTOLUNCH)) + return LCStatus; + else + return ID_STATUS_OFFLINE; +} + |
