diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-07-23 11:56:59 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-07-23 11:56:59 +0000 |
commit | 177c84716db384c8be095219c58d0a68f87101fe (patch) | |
tree | 84449f27f215b253da99729ddb0aaf6df40bef0c /plugins/Nudge/src | |
parent | cbb10e8c9089dfc99946ddc784afdb126e2128a8 (diff) |
NotesAndReminders, Nudge, OpenFolder, PackUpdater: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@1116 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Nudge/src')
-rw-r--r-- | plugins/Nudge/src/headers.h | 70 | ||||
-rw-r--r-- | plugins/Nudge/src/main.cpp | 789 | ||||
-rw-r--r-- | plugins/Nudge/src/main.h | 31 | ||||
-rw-r--r-- | plugins/Nudge/src/nudge.cpp | 117 | ||||
-rw-r--r-- | plugins/Nudge/src/nudge.h | 67 | ||||
-rw-r--r-- | plugins/Nudge/src/options.cpp | 435 | ||||
-rw-r--r-- | plugins/Nudge/src/options.h | 14 | ||||
-rw-r--r-- | plugins/Nudge/src/resource.h | 89 | ||||
-rw-r--r-- | plugins/Nudge/src/shake.cpp | 189 | ||||
-rw-r--r-- | plugins/Nudge/src/shake.h | 27 |
10 files changed, 1828 insertions, 0 deletions
diff --git a/plugins/Nudge/src/headers.h b/plugins/Nudge/src/headers.h new file mode 100644 index 0000000000..eb931c6da8 --- /dev/null +++ b/plugins/Nudge/src/headers.h @@ -0,0 +1,70 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#define _CRT_SECURE_NO_WARNINGS
+
+#pragma once
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER // Allow use of features specific to Windows XP or later.
+#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
+#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
+#endif
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+
+#include <windows.h>
+#include <commctrl.h>
+#include <time.h>
+
+#define MIRANDA_VER 0x0A00
+#include <newpluginapi.h> //CallService,UnHookEvent
+#include <m_clist.h>
+#include <m_langpack.h>
+#include <m_system.h>
+#include <m_popup.h>
+#include <m_clui.h>
+#include <m_message.h>
+#include <m_protocols.h>
+#include <m_ignore.h>
+#include <m_options.h>
+#include <m_skin.h>
+#include <m_database.h>
+#include <m_protosvc.h>
+#include <m_trigger.h>
+#include <m_metacontacts.h>
+#include <m_icolib.h>
+#include <win2k.h>
+#include "resource.h"
+#include "m_nudge.h"
+
+
+/*
+*
+****************************/
+int NudgeOptInit(WPARAM wParam,LPARAM lParam);
+
+/*
+*
+****************************/
+int Preview();
+
+/*
+*
+****************************/
+HANDLE Nudge_GethContact(HANDLE);
\ No newline at end of file diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp new file mode 100644 index 0000000000..c673ebe0c5 --- /dev/null +++ b/plugins/Nudge/src/main.cpp @@ -0,0 +1,789 @@ +#include "headers.h"
+#include "main.h"
+#include "shake.h"
+#include "m_msg_buttonsbar.h"
+
+
+int nProtocol = 0;
+static HANDLE g_hEventModulesLoaded = NULL, hEventOptionsInitialize = NULL, g_hIcon = NULL, g_hEventDbWindowEvent = NULL, g_hEventToolbarLoaded = NULL, g_hEventButtonPressed = NULL, g_hEventAccountsChanged = NULL;
+HINSTANCE hInst;
+
+NudgeElementList *NudgeList = NULL;
+CNudgeElement DefaultNudge;
+CShake shake;
+CNudge GlobalNudge;
+
+
+
+int hLangpack = 0;
+
+
+//========================
+// MirandaPluginInfo
+//========================
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ "Nudge",
+ PLUGIN_MAKE_VERSION(0,0,2,0),
+ "Plugin to shake the clist and chat window",
+ "Tweety/GouZ, FREAK_THEMIGHTY",
+ "francois.mean@skynet.be, Sylvain.gougouzian@gmail.com, wishmaster51@googlemail.com",
+ "copyright to the miranda community",
+ "http://nightly.miranda.im/", // www
+ UNICODE_AWARE, //doesn't replace anything built-in
+ { 0xe47cc215, 0xd28, 0x462d, { 0xa0, 0xf6, 0x3a, 0xe4, 0x44, 0x3d, 0x29, 0x26 } } // {E47CC215-0D28-462D-A0F6-3AE4443D2926}
+};
+
+INT_PTR NudgeShowMenu(WPARAM wParam,LPARAM lParam)
+{
+
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ if (!strcmp((char *) wParam,n->item.ProtocolName))
+ {
+ return n->item.ShowContactMenu(lParam != 0);
+ }
+ }
+ return 0;
+}
+
+INT_PTR NudgeSend(WPARAM wParam,LPARAM lParam)
+{
+
+ char *protoName = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0);
+ int diff = time(NULL) - DBGetContactSettingDword((HANDLE) wParam, "Nudge", "LastSent", time(NULL)-30);
+
+ if(diff < GlobalNudge.sendTimeSec)
+ {
+ TCHAR msg[500];
+ mir_sntprintf(msg,500, TranslateT("You are not allowed to send too much nudge (only 1 each %d sec, %d sec left)"),GlobalNudge.sendTimeSec, 30 - diff);
+ //MessageBox(NULL,msg,NULL,0);
+ if(GlobalNudge.useByProtocol)
+ {
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ if (!strcmp(protoName,n->item.ProtocolName))
+ {
+ Nudge_ShowPopup(n->item, (HANDLE) wParam, msg);
+ }
+ }
+ }
+ else
+ {
+ Nudge_ShowPopup(DefaultNudge, (HANDLE) wParam, msg);
+ }
+ return 0;
+ }
+
+ DBWriteContactSettingDword((HANDLE) wParam, "Nudge", "LastSent", time(NULL));
+
+ if(GlobalNudge.useByProtocol)
+ {
+ NudgeElementList *n;
+ for(n = NudgeList;n != NULL; n = n->next)
+ {
+ if (!strcmp(protoName,n->item.ProtocolName))
+ {
+ //if(n->item.showPopup)
+ // Nudge_ShowPopup(n->item, (HANDLE) wParam, n->item.senText);
+ if(n->item.showStatus)
+ Nudge_SentStatus(n->item, (HANDLE) wParam);
+ }
+ }
+ }
+ else
+ {
+ //if(DefaultNudge.showPopup)
+ // Nudge_ShowPopup(DefaultNudge, (HANDLE) wParam, DefaultNudge.senText);
+ if(DefaultNudge.showStatus)
+ Nudge_SentStatus(DefaultNudge, (HANDLE) wParam);
+ }
+
+ CallProtoService(protoName,"/SendNudge",wParam,lParam);
+ return 0;
+}
+
+void OpenContactList()
+{
+ HWND hWnd = (HWND) CallService(MS_CLUI_GETHWND,0,0);
+ ShowWindow(hWnd, SW_RESTORE);
+ ShowWindow(hWnd, SW_SHOW);
+}
+
+int NudgeRecieved(WPARAM wParam,LPARAM lParam)
+{
+
+ char *protoName = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0);
+
+ DWORD currentTimestamp = time(NULL);
+ DWORD nudgeSentTimestamp = lParam ? (DWORD)lParam : currentTimestamp;
+
+ int diff = currentTimestamp - DBGetContactSettingDword((HANDLE) wParam, "Nudge", "LastReceived", currentTimestamp-30);
+ int diff2 = nudgeSentTimestamp - DBGetContactSettingDword((HANDLE) wParam, "Nudge", "LastReceived2", nudgeSentTimestamp-30);
+
+ if(diff >= GlobalNudge.recvTimeSec)
+ DBWriteContactSettingDword((HANDLE) wParam, "Nudge", "LastReceived", currentTimestamp);
+ if(diff2 >= GlobalNudge.recvTimeSec)
+ DBWriteContactSettingDword((HANDLE) wParam, "Nudge", "LastReceived2", nudgeSentTimestamp);
+
+ if(GlobalNudge.useByProtocol)
+ {
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ if (!strcmp(protoName,n->item.ProtocolName))
+ {
+
+ if(n->item.enabled)
+ {
+ if(n->item.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE))
+ return 0;
+
+ DWORD Status = CallProtoService(protoName,PS_GETSTATUS,0,0);
+
+ if ( ((n->item.statusFlags & NUDGE_ACC_ST0) && (Status<=ID_STATUS_OFFLINE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST1) && (Status==ID_STATUS_ONLINE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST2) && (Status==ID_STATUS_AWAY)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST3) && (Status==ID_STATUS_DND)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST4) && (Status==ID_STATUS_NA)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST5) && (Status==ID_STATUS_OCCUPIED)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST6) && (Status==ID_STATUS_FREECHAT)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST7) && (Status==ID_STATUS_INVISIBLE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST8) && (Status==ID_STATUS_ONTHEPHONE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST9) && (Status==ID_STATUS_OUTTOLUNCH)))
+ {
+ if(diff >= GlobalNudge.recvTimeSec)
+ {
+ if(n->item.showPopup)
+ Nudge_ShowPopup(n->item, (HANDLE) wParam, n->item.recText);
+ if(n->item.openContactList)
+ OpenContactList();
+ if(n->item.shakeClist)
+ ShakeClist(wParam,lParam);
+ if(n->item.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET,wParam,0);
+ if(n->item.shakeChat)
+ ShakeChat(wParam,lParam);
+ if(n->item.autoResend)
+ mir_forkthread(AutoResendNudge,(void *)wParam);
+
+ SkinPlaySound( n->item.NudgeSoundname );
+ }
+ }
+ if(diff2 >= GlobalNudge.recvTimeSec)
+ {
+ if(n->item.showStatus)
+ Nudge_ShowStatus(n->item, (HANDLE) wParam, nudgeSentTimestamp);
+ }
+
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ if(DefaultNudge.enabled)
+ {
+ if(DefaultNudge.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE))
+ return 0;
+ DWORD Status = CallService(MS_CLIST_GETSTATUSMODE,0,0);
+ if ( ((DefaultNudge.statusFlags & NUDGE_ACC_ST0) && (Status<=ID_STATUS_OFFLINE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST1) && (Status==ID_STATUS_ONLINE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST2) && (Status==ID_STATUS_AWAY)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST3) && (Status==ID_STATUS_DND)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST4) && (Status==ID_STATUS_NA)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST5) && (Status==ID_STATUS_OCCUPIED)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST6) && (Status==ID_STATUS_FREECHAT)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST7) && (Status==ID_STATUS_INVISIBLE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST8) && (Status==ID_STATUS_ONTHEPHONE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST9) && (Status==ID_STATUS_OUTTOLUNCH)))
+ {
+ if(diff >= GlobalNudge.recvTimeSec)
+ {
+ if(DefaultNudge.showPopup)
+ Nudge_ShowPopup(DefaultNudge, (HANDLE) wParam, DefaultNudge.recText);
+ if(DefaultNudge.openContactList)
+ OpenContactList();
+ if(DefaultNudge.shakeClist)
+ ShakeClist(wParam,lParam);
+ if(DefaultNudge.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET,wParam,0);
+ if(DefaultNudge.shakeChat)
+ ShakeChat(wParam,lParam);
+ if(DefaultNudge.autoResend)
+ mir_forkthread(AutoResendNudge,(void *)wParam);
+
+ SkinPlaySound( DefaultNudge.NudgeSoundname );
+ }
+ }
+ if(diff2 >= GlobalNudge.recvTimeSec)
+ {
+ if(DefaultNudge.showStatus)
+ Nudge_ShowStatus(DefaultNudge, (HANDLE) wParam, nudgeSentTimestamp);
+ }
+ }
+ }
+ return 0;
+}
+
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hInst=hinstDLL;
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+static INT_PTR CALLBACK DlgProcOptsTrigger(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+
+ switch (msg) {
+ case WM_INITDIALOG: {
+ // lParam = (LPARAM)(DWORD)actionID or 0 if this is a new trigger entry
+ BOOL bshakeClist,bshakeChat;
+
+ DWORD actionID = (DWORD)lParam;
+ TranslateDialogDefault(hwnd);
+ // Initialize the dialog according to the action ID
+ bshakeClist = DBGetActionSettingByte(actionID, NULL, "Nudge", "ShakeClist",FALSE);
+ bshakeChat = DBGetActionSettingByte(actionID, NULL, "Nudge", "ShakeChat",FALSE);
+ CheckDlgButton(hwnd, IDC_TRIGGER_SHAKECLIST, bshakeClist ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_TRIGGER_SHAKECHAT, bshakeChat ? BST_CHECKED : BST_UNCHECKED);
+ break;
+ }
+
+ case TM_ADDACTION: {
+ // save your settings
+ // wParam = (WPARAM)(DWORD)actionID
+ bool bshakeClist,bshakeChat;
+
+ DWORD actionID = (DWORD)wParam;
+ bshakeClist = (IsDlgButtonChecked(hwnd,IDC_TRIGGER_SHAKECLIST)==BST_CHECKED);
+ bshakeChat = (IsDlgButtonChecked(hwnd,IDC_TRIGGER_SHAKECHAT)==BST_CHECKED);
+ DBWriteActionSettingByte(actionID, NULL, "Nudge", "ShakeClist",bshakeClist);
+ DBWriteActionSettingByte(actionID, NULL, "Nudge", "ShakeChat",bshakeChat);
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+int TriggerActionRecv( DWORD actionID, REPORTINFO *ri)
+{
+ // check how to process this call
+ if (ri->flags&ACT_PERFORM) {
+ BOOL bshakeClist,bshakeChat;
+ HANDLE hContact = ((ri->td!=NULL)&&(ri->td->dFlags&DF_CONTACT))?ri->td->hContact:NULL;
+ bshakeClist = DBGetActionSettingByte(actionID, NULL, "Nudge", "ShakeClist",FALSE);
+ bshakeChat = DBGetActionSettingByte(actionID, NULL, "Nudge", "ShakeChat",FALSE);
+
+ if(bshakeClist)
+ ShakeClist(NULL,NULL);
+ if(bshakeChat && (hContact != NULL))
+ ShakeChat((WPARAM)hContact,NULL);
+ }
+
+ if (ri->flags&ACT_CLEANUP) // request to delete all associated settings
+ RemoveAllActionSettings(actionID, "Nudge");
+
+ return FALSE;
+}
+
+int TriggerActionSend( DWORD actionID, REPORTINFO *ri)
+{
+ if (ri->flags & ACT_PERFORM) {
+ HANDLE hContact = ((ri->td!=NULL)&&(ri->td->dFlags&DF_CONTACT))?ri->td->hContact:NULL;
+ if(hContact != NULL)
+ NudgeSend((WPARAM)hContact,NULL);
+ }
+
+ return FALSE;
+}
+
+void LoadProtocols(void)
+{
+ //Load the default nudge
+ mir_snprintf(DefaultNudge.ProtocolName,sizeof(DefaultNudge.ProtocolName),"Default");
+ mir_snprintf(DefaultNudge.NudgeSoundname,sizeof(DefaultNudge.NudgeSoundname),"Nudge : Default");
+ SkinAddNewSoundEx( DefaultNudge.NudgeSoundname, LPGEN("Nudge"), LPGEN("Default Nudge"));
+ DefaultNudge.Load();
+
+ GlobalNudge.Load();
+
+ int numberOfProtocols = 0;
+ PROTOACCOUNT **ppProtocolDescriptors;
+ INT_PTR ret = ProtoEnumAccounts(&numberOfProtocols,&ppProtocolDescriptors);
+ if(ret == 0)
+ {
+ for(int i = 0; i < numberOfProtocols ; i++)
+ {
+ Nudge_AddAccount(ppProtocolDescriptors[i]);
+ }
+
+ }
+
+ shake.Load();
+
+ /*CNudgeElement *n;
+ for(n = NudgeList;n != NULL; n = n->next)
+ {
+ MessageBox(NULL,n->ProtocolName,n->NudgeSoundname,0);
+ }*/
+}
+
+void RegisterToTrigger(void)
+{
+ if ( ServiceExists(MS_TRIGGER_REGISTERACTION))
+ {
+ ACTIONREGISTER ar;
+ ZeroMemory(&ar, sizeof(ar));
+ ar.cbSize = sizeof(ar);
+ ar.hInstance = hInst;
+ ar.flags = ARF_TCHAR|ARF_FUNCTION;
+ ar.actionFunction = TriggerActionRecv;
+ ar.pfnDlgProc = DlgProcOptsTrigger;
+ ar.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TRIGGER);
+ ar.pszName = Translate("Nudge : Shake contact list/chat window");
+
+ // register the action
+ CallService(MS_TRIGGER_REGISTERACTION, 0, (LPARAM)&ar);
+
+ ar.actionFunction = TriggerActionSend;
+ ar.pszName = Translate("Nudge : Send a nudge");
+ ar.pfnDlgProc = NULL;
+ ar.pszTemplate = NULL;
+
+ // register the action
+ CallService(MS_TRIGGER_REGISTERACTION, 0, (LPARAM)&ar);
+ }
+}
+
+void RegisterToDbeditorpp(void)
+{
+ // known modules list
+ if (ServiceExists("DBEditorpp/RegisterSingleModule"))
+ CallService("DBEditorpp/RegisterSingleModule", (WPARAM)"Nudge", 0);
+}
+
+void LoadIcons(void)
+{
+ //Load icons
+ SKINICONDESC sid = {0};
+ TCHAR szFilename[MAX_PATH];
+ GetModuleFileName(hInst,szFilename,MAX_PATH);
+
+ sid.cbSize = sizeof(sid);
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszSection = LPGENT("Nudge");
+ sid.ptszDefaultFile = szFilename;
+
+ sid.pszName = "Nudge_Default";
+ sid.ptszDescription = LPGENT("Nudge as Default");
+ sid.iDefaultIndex = -IDI_NUDGE;
+ sid.hDefaultIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NUDGE));
+ g_hIcon = Skin_AddIcon(&sid);
+}
+
+// Nudge support
+static int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam)
+{
+ CustomButtonClickData *cbcd=(CustomButtonClickData *)lParam;
+
+ if (!strcmp(cbcd->pszModule,"Nudge"))
+ NudgeSend(wParam, 0);
+
+ return 0;
+}
+
+static int TabsrmmButtonInit(WPARAM wParam, LPARAM lParam)
+{
+ BBButton bbd = {0};
+
+ bbd.cbSize = sizeof(BBButton);
+ bbd.pszModuleName = "Nudge";
+ bbd.ptszTooltip = LPGENT("Send Nudge");
+ bbd.dwDefPos = 300;
+ bbd.bbbFlags = BBBF_ISIMBUTTON|BBBF_ISLSIDEBUTTON|BBBF_CANBEHIDDEN;
+ bbd.hIcon = g_hIcon;
+ bbd.dwButtonID = 6000;
+ bbd.iButtonWidth = 0;
+ CallService (MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
+
+ return 0;
+}
+
+void HideNudgeButton(HANDLE hContact)
+{
+ char str[MAXMODULELABELLENGTH + 12] = {0};
+ char *szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ mir_snprintf(str,MAXMODULELABELLENGTH + 12,"%s/SendNudge", szProto);
+
+ if (!ServiceExists(str))
+ {
+ BBButton bbd={0};
+ bbd.cbSize=sizeof(BBButton);
+ bbd.bbbFlags=BBSF_HIDDEN|BBSF_DISABLED;
+ bbd.pszModuleName="Nudge";
+ bbd.dwButtonID = 6000;
+ CallService(MS_BB_SETBUTTONSTATE, (WPARAM)hContact, (LPARAM)&bbd);
+ }
+}
+
+static int ContactWindowOpen(WPARAM wparam,LPARAM lParam)
+{
+ MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam;
+
+ if(MWeventdata->uType == MSG_WINDOW_EVT_OPENING&&MWeventdata->hContact)
+ {
+ HideNudgeButton(MWeventdata->hContact);
+ }
+ return 0;
+}
+
+int ModulesLoaded(WPARAM,LPARAM)
+{
+ RegisterToTrigger();
+ RegisterToDbeditorpp();
+ LoadProtocols();
+ LoadIcons();
+ LoadPopupClass();
+
+ g_hEventToolbarLoaded = HookEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonInit);
+ if (g_hEventToolbarLoaded)
+ {
+ g_hEventButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed);
+ g_hEventDbWindowEvent = HookEvent(ME_MSG_WINDOWEVENT,ContactWindowOpen);
+ }
+ return 0;
+}
+
+int AccListChanged(WPARAM wParam,LPARAM lParam)
+{
+ PROTOACCOUNT *proto = (PROTOACCOUNT*) wParam;
+ if (proto==NULL)
+ return 0;
+
+ switch (lParam)
+ {
+ case PRAC_ADDED:
+ Nudge_AddAccount(proto);
+ break;
+ }
+ return 0;
+}
+
+HANDLE hShakeClist=NULL,hShakeChat=NULL,hNudgeSend=NULL,hNudgeShowMenu=NULL;
+extern "C" int __declspec(dllexport) Load(void)
+{
+
+ mir_getLP(&pluginInfo);
+
+ g_hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded);
+ g_hEventAccountsChanged = HookEvent(ME_PROTO_ACCLISTCHANGED,AccListChanged);
+ hEventOptionsInitialize = HookEvent(ME_OPT_INITIALISE, NudgeOptInit);
+
+ //Create function for plugins
+ hShakeClist=CreateServiceFunction(MS_SHAKE_CLIST,ShakeClist);
+ hShakeChat=CreateServiceFunction(MS_SHAKE_CHAT,ShakeChat);
+ hNudgeSend=CreateServiceFunction(MS_NUDGE_SEND,NudgeSend);
+ hNudgeShowMenu=CreateServiceFunction(MS_NUDGE_SHOWMENU,NudgeShowMenu);
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ if(g_hEventToolbarLoaded) UnhookEvent(g_hEventToolbarLoaded);
+ if(g_hEventDbWindowEvent) UnhookEvent(g_hEventButtonPressed);
+ if(g_hEventDbWindowEvent) UnhookEvent(g_hEventDbWindowEvent);
+
+ UnhookEvent(g_hEventModulesLoaded);
+ UnhookEvent(g_hEventAccountsChanged);
+ UnhookEvent(hEventOptionsInitialize);
+
+ DestroyServiceFunction(hShakeClist);
+ DestroyServiceFunction(hShakeChat);
+ DestroyServiceFunction(hNudgeSend);
+ DestroyServiceFunction(hNudgeShowMenu);
+
+ NudgeElementList* p = NudgeList;
+ while ( p != NULL )
+ {
+ if(p->item.hEvent) UnhookEvent(p->item.hEvent);
+ NudgeElementList* p1 = p->next;
+ //free( p );
+ delete p;
+ p = p1;
+ }
+ return 0;
+}
+
+LRESULT CALLBACK NudgePopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_COMMAND:
+ {
+ HANDLE hContact = PUGetContact(hWnd);
+ CallService(MS_MSG_SENDMESSAGET, (WPARAM)hContact, 0);
+ PUDeletePopUp(hWnd);
+ break;
+ }
+
+ case WM_CONTEXTMENU:
+ PUDeletePopUp(hWnd);
+ break;
+ case UM_FREEPLUGINDATA:
+ //Here we'd free our own data, if we had it.
+ return FALSE;
+ case UM_INITPOPUP:
+ break;
+ case UM_DESTROYPOPUP:
+ break;
+ case WM_NOTIFY:
+ default:
+ break;
+ }
+ return DefWindowProc(hWnd,msg,wParam,lParam);
+}
+
+void LoadPopupClass()
+{
+ if(ServiceExists(MS_POPUP_REGISTERCLASS))
+ {
+ POPUPCLASS ppc = {0};
+ ppc.cbSize = sizeof(ppc);
+ ppc.flags = PCF_TCHAR;
+ ppc.pszName = "nudge";
+ ppc.ptszDescription = LPGENT("Show Nudge");
+ ppc.hIcon = (HICON) CallService(MS_SKIN2_GETICONBYHANDLE,0,(LPARAM)g_hIcon);
+ ppc.colorBack = NULL;
+ ppc.colorText = NULL;
+ ppc.iSeconds = 0;
+ ppc.PluginWindowProc = NudgePopUpProc;
+ CallService(MS_POPUP_REGISTERCLASS,0,(LPARAM)&ppc);
+ }
+}
+
+int Preview()
+{
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ if ( GlobalNudge.useByProtocol )
+ {
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ if(n->item.enabled)
+ {
+ SkinPlaySound( n->item.NudgeSoundname );
+ if(n->item.showPopup)
+ Nudge_ShowPopup(n->item, hContact, n->item.recText);
+ if(n->item.openContactList)
+ OpenContactList();
+ if(n->item.shakeClist)
+ ShakeClist(0,0);
+ if(n->item.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET,(WPARAM)hContact,NULL);
+ if(n->item.shakeChat)
+ ShakeChat((WPARAM)hContact,(LPARAM)time(NULL));
+ }
+ }
+ }
+ else
+ {
+ if(DefaultNudge.enabled)
+ {
+ SkinPlaySound( DefaultNudge.NudgeSoundname );
+ if(DefaultNudge.showPopup)
+ Nudge_ShowPopup(DefaultNudge, hContact, DefaultNudge.recText);
+ if(DefaultNudge.openContactList)
+ OpenContactList();
+ if(DefaultNudge.shakeClist)
+ ShakeClist(0,0);
+ if(DefaultNudge.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET,(WPARAM)hContact,NULL);
+ if(DefaultNudge.shakeChat)
+ ShakeChat((WPARAM)hContact,(LPARAM)time(NULL));
+ }
+ }
+ return 0;
+}
+
+void Nudge_ShowPopup(CNudgeElement n, HANDLE hContact, TCHAR * Message)
+{
+ hContact = Nudge_GethContact(hContact);
+ TCHAR * lpzContactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GCDNF_TCHAR);
+
+ if(ServiceExists(MS_POPUP_ADDPOPUPCLASS))
+ {
+ POPUPDATACLASS NudgePopUp = {0};
+ NudgePopUp.cbSize = sizeof(NudgePopUp);
+ NudgePopUp.hContact = hContact;
+ NudgePopUp.ptszText = Message;
+ NudgePopUp.ptszTitle = lpzContactName;
+ NudgePopUp.pszClassName = "nudge";
+ CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&NudgePopUp);
+ }
+ else if(ServiceExists(MS_POPUP_ADDPOPUPT))
+ {
+ POPUPDATAT NudgePopUp = {0};
+
+ NudgePopUp.lchContact = hContact;
+ NudgePopUp.lchIcon = (HICON) CallService(MS_SKIN2_GETICON,0,(LPARAM) n.hIcoLibItem );
+ NudgePopUp.colorBack = 0;
+ NudgePopUp.colorText = 0;
+ NudgePopUp.iSeconds = 0;
+ NudgePopUp.PluginWindowProc = NudgePopUpProc;
+ NudgePopUp.PluginData = (void *)1;
+
+ //lstrcpy(NudgePopUp.lpzText, Translate(Message));
+ lstrcpy(NudgePopUp.lptzText, Message);
+
+ lstrcpy(NudgePopUp.lptzContactName, lpzContactName);
+
+ CallService(MS_POPUP_ADDPOPUPT,(WPARAM)&NudgePopUp,0);
+ }
+ else
+ {
+ MessageBox(NULL,Message,lpzContactName,0);
+ }
+}
+
+void Nudge_SentStatus(CNudgeElement n, HANDLE hContact)
+{
+ DBEVENTINFO NudgeEvent = { 0 };
+
+ NudgeEvent.cbSize = sizeof(NudgeEvent);
+ NudgeEvent.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ char *buff = mir_utf8encodeT(n.senText);
+ NudgeEvent.flags = DBEF_SENT | DBEF_UTF;
+
+ NudgeEvent.timestamp = ( DWORD )time(NULL);
+ NudgeEvent.eventType = EVENTTYPE_STATUSCHANGE;
+ NudgeEvent.cbBlob = (DWORD)strlen(buff) + 1;
+ NudgeEvent.pBlob = ( PBYTE ) buff;
+
+ INT_PTR res = CallService( MS_MC_GETMETACONTACT, (WPARAM)hContact, 0 ); //try to retrieve the metacontact if some
+ if(res != CALLSERVICE_NOTFOUND)
+ {
+ HANDLE hMetaContact = (HANDLE) res;
+ if(hMetaContact != NULL) //metacontact
+ CallService(MS_DB_EVENT_ADD,(WPARAM)hMetaContact,(LPARAM)&NudgeEvent);
+ }
+
+
+ CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&NudgeEvent);
+}
+
+void Nudge_ShowStatus(CNudgeElement n, HANDLE hContact, DWORD timestamp)
+{
+ DBEVENTINFO NudgeEvent = { 0 };
+
+ NudgeEvent.cbSize = sizeof(NudgeEvent);
+ NudgeEvent.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ char *buff = mir_utf8encodeT(n.recText);
+ NudgeEvent.flags = DBEF_UTF;
+
+ NudgeEvent.timestamp = timestamp;
+ NudgeEvent.eventType = EVENTTYPE_STATUSCHANGE;
+ NudgeEvent.cbBlob = (DWORD)strlen(buff) + 1;
+ NudgeEvent.pBlob = ( PBYTE ) buff;
+
+
+ INT_PTR res = CallService( MS_MC_GETMETACONTACT, (WPARAM)hContact, 0 ); //try to retrieve the metacontact if some
+ if(res != CALLSERVICE_NOTFOUND)
+ {
+ HANDLE hMetaContact = (HANDLE) res;
+ if(hMetaContact != NULL) //metacontact
+ {
+ CallService(MS_DB_EVENT_ADD,(WPARAM)hMetaContact,(LPARAM)&NudgeEvent);
+ NudgeEvent.flags |= DBEF_READ;
+ }
+ }
+
+ CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&NudgeEvent);
+}
+
+HANDLE Nudge_GethContact(HANDLE hContact)
+{
+ INT_PTR res = CallService( MS_MC_GETMETACONTACT, (WPARAM)hContact, 0 );
+ if(res!=CALLSERVICE_NOTFOUND)
+ {
+ HANDLE hMetaContact = (HANDLE) res;
+ if(hMetaContact!=NULL)
+ return hMetaContact;
+ }
+
+ return hContact;
+}
+
+void Nudge_AddAccount(PROTOACCOUNT *proto)
+{
+ char str[MAXMODULELABELLENGTH + 10];
+ mir_snprintf(str,sizeof(str),"%s/Nudge",proto->szModuleName);
+ HANDLE hevent = HookEvent(str, NudgeRecieved);
+ if(hevent == NULL)
+ return;
+
+ nProtocol ++;
+
+ //Add a specific sound per protocol
+ NudgeElementList *newNudge = new NudgeElementList;
+ //newNudge = (NudgeElementList*) malloc(sizeof(NudgeElementList));
+ mir_snprintf(newNudge->item.NudgeSoundname,sizeof(newNudge->item.NudgeSoundname),"%s: Nudge",proto->szModuleName);
+
+ strcpy( newNudge->item.ProtocolName, proto->szProtoName );
+ _tcscpy(newNudge->item.AccountName, proto->tszAccountName );
+
+ newNudge->item.Load();
+
+ newNudge->item.hEvent = hevent;
+
+ TCHAR soundDesc[MAXMODULELABELLENGTH + 10];
+ mir_sntprintf(soundDesc,sizeof(soundDesc),_T("Nudge for %s"),proto->tszAccountName);
+ SkinAddNewSoundExT(newNudge->item.NudgeSoundname, LPGENT("Nudge"), soundDesc);
+
+ newNudge->next = NudgeList;
+ NudgeList = newNudge;
+
+ char iconName[MAXMODULELABELLENGTH + 10];
+ mir_snprintf(iconName,sizeof(iconName),"Nudge_%s",proto->szModuleName);
+
+ TCHAR szFilename[MAX_PATH], iconDesc[MAXMODULELABELLENGTH + 10];
+ GetModuleFileName(hInst,szFilename,MAX_PATH);
+ mir_sntprintf(iconDesc, SIZEOF(iconDesc), TranslateT("Nudge for %s"), proto->tszAccountName);
+
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszSection = LPGENT("Nudge");
+ sid.ptszDefaultFile = szFilename;
+ sid.pszName = iconName;
+ sid.ptszDescription = iconDesc;
+ sid.iDefaultIndex = -IDI_NUDGE;
+ sid.hDefaultIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NUDGE));
+ newNudge->item.hIcoLibItem = Skin_AddIcon(&sid);
+
+ //Add contact menu entry
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(mi);
+ mi.popupPosition = 500085000;
+ mi.pszContactOwner = proto->szModuleName;
+ mi.pszPopupName = proto->szModuleName;
+ mi.flags = CMIF_NOTOFFLINE | CMIF_TCHAR | CMIF_ICONFROMICOLIB;
+ mi.position = -500050004;
+ mi.icolibItem = newNudge->item.hIcoLibItem;
+ mi.ptszName = LPGENT( "Send &Nudge" );
+ mi.pszService = MS_NUDGE_SEND;
+ newNudge->item.hContactMenu = Menu_AddContactMenuItem(&mi);
+}
+
+void AutoResendNudge(void *wParam)
+{
+
+ Sleep(GlobalNudge.resendDelaySec * 1000);
+ NudgeSend((WPARAM) wParam,NULL);
+}
diff --git a/plugins/Nudge/src/main.h b/plugins/Nudge/src/main.h new file mode 100644 index 0000000000..556ee0070b --- /dev/null +++ b/plugins/Nudge/src/main.h @@ -0,0 +1,31 @@ +#include "nudge.h"
+
+/*
+*
+****************************/
+void Nudge_ShowPopup(CNudgeElement, HANDLE, TCHAR *);
+
+/*
+*
+****************************/
+void Nudge_ShowStatus(CNudgeElement, HANDLE, DWORD timestamp);
+
+/*
+*
+****************************/
+void Nudge_SentStatus(CNudgeElement, HANDLE);
+
+/*
+*
+****************************/
+void Nudge_AddAccount(PROTOACCOUNT *proto);
+
+/*
+*
+****************************/
+void LoadPopupClass();
+
+/*
+*
+****************************/
+void AutoResendNudge(void *wParam) ;
diff --git a/plugins/Nudge/src/nudge.cpp b/plugins/Nudge/src/nudge.cpp new file mode 100644 index 0000000000..0afa6edee0 --- /dev/null +++ b/plugins/Nudge/src/nudge.cpp @@ -0,0 +1,117 @@ +#include "headers.h"
+#include "nudge.h"
+
+void CNudge::Save(void)
+{
+ char SectionName[512];
+ mir_snprintf(SectionName,512,"useByProtocol");
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->useByProtocol);
+ mir_snprintf(SectionName,512,"RecvTimeSec");
+ DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->recvTimeSec);
+ mir_snprintf(SectionName,512,"SendTimeSec");
+ DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->sendTimeSec);
+ mir_snprintf(SectionName,512,"ResendDelaySec");
+ DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->resendDelaySec);
+}
+
+
+void CNudge::Load(void)
+{
+ char SectionName[512];
+ mir_snprintf(SectionName,512,"useByProtocol");
+ this->useByProtocol = DBGetContactSettingByte(NULL, "Nudge", SectionName, FALSE) != 0;
+ mir_snprintf(SectionName,512,"RecvTimeSec");
+ this->recvTimeSec = DBGetContactSettingDword(NULL, "Nudge", SectionName, 30);
+ mir_snprintf(SectionName,512,"SendTimeSec");
+ this->sendTimeSec = DBGetContactSettingDword(NULL, "Nudge", SectionName, 30);
+ mir_snprintf(SectionName,512,"ResendDelaySec");
+ this->resendDelaySec = DBGetContactSettingDword(NULL, "Nudge", SectionName, 3);
+}
+
+int CNudgeElement::ShowContactMenu(bool show)
+{
+
+ CLISTMENUITEM mi;
+ memset( &mi, 0, sizeof( mi ));
+ mi.cbSize = sizeof( mi );
+ mi.flags = show? CMIM_FLAGS : CMIM_FLAGS | CMIF_HIDDEN ;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenu, (LPARAM)&mi);
+
+ return 0;
+}
+
+void CNudgeElement::Save(void)
+{
+ char SectionName[512];
+ mir_snprintf(SectionName,512,"%s-openMessageWindow", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->openMessageWindow);
+ mir_snprintf(SectionName,512,"%s-openContactList", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->openContactList);
+ mir_snprintf(SectionName,512,"%s-useIgnore", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->useIgnoreSettings);
+ mir_snprintf(SectionName,512,"%s-showStatus", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->showStatus);
+ mir_snprintf(SectionName,512,"%s-showPopup", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->showPopup);
+ mir_snprintf(SectionName,512,"%s-shakeClist", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->shakeClist);
+ mir_snprintf(SectionName,512,"%s-shakeChat", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->shakeChat);
+ mir_snprintf(SectionName,512,"%s-enabled", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->enabled);
+ mir_snprintf(SectionName,512,"%s-autoResend", ProtocolName);
+ DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->autoResend);
+ mir_snprintf(SectionName,512,"%s-statusFlags", ProtocolName);
+ DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->statusFlags);
+ mir_snprintf(SectionName,512,"%s-recText", ProtocolName);
+ DBWriteContactSettingTString(NULL, "Nudge", SectionName, this->recText);
+ mir_snprintf(SectionName,512,"%s-senText", ProtocolName);
+ DBWriteContactSettingTString(NULL, "Nudge", SectionName, this->senText);
+}
+
+
+void CNudgeElement::Load(void)
+{
+ DBVARIANT dbv;
+ char SectionName[512];
+ mir_snprintf(SectionName,512,"%s-openMessageWindow", ProtocolName);
+ this->openMessageWindow = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-openContactList", ProtocolName);
+ this->openContactList = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-useIgnore", ProtocolName);
+ this->useIgnoreSettings = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-showStatus", ProtocolName);
+ this->showStatus = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-showPopup", ProtocolName);
+ this->showPopup = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-shakeClist", ProtocolName);
+ this->shakeClist = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-shakeChat", ProtocolName);
+ this->shakeChat = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-enabled", ProtocolName);
+ this->enabled = DBGetContactSettingByte(NULL, "Nudge", SectionName, TRUE) != 0;
+ mir_snprintf(SectionName,512,"%s-autoResend", ProtocolName);
+ this->autoResend = DBGetContactSettingByte(NULL, "Nudge", SectionName, FALSE) != 0;
+ mir_snprintf(SectionName,512,"%s-statusFlags", ProtocolName);
+ this->statusFlags = DBGetContactSettingDword(NULL, "Nudge", SectionName, 967);
+ mir_snprintf(SectionName,512,"%s-recText", ProtocolName);
+ if (!DBGetContactSettingTString(NULL,"Nudge",SectionName,&dbv))
+ {
+ _tcsncpy(this->recText,dbv.ptszVal,TEXT_LEN);
+ if(_tcsclen(this->recText) < 1)
+ _tcsncpy(this->recText,TranslateT("You received a nudge"),TEXT_LEN);
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcsncpy(this->recText,TranslateT("You received a nudge"),TEXT_LEN);
+ mir_snprintf(SectionName,512,"%s-senText", ProtocolName);
+ if (!DBGetContactSettingTString(NULL,"Nudge",SectionName,&dbv))
+ {
+ _tcsncpy(this->senText,dbv.ptszVal,TEXT_LEN);
+ if(_tcsclen(this->senText) < 1)
+ _tcsncpy(this->senText,TranslateT("You sent a nudge"),TEXT_LEN);
+ DBFreeVariant(&dbv);
+ }
+ else
+ _tcsncpy(this->senText,TranslateT("You sent a nudge"),TEXT_LEN);
+}
\ No newline at end of file diff --git a/plugins/Nudge/src/nudge.h b/plugins/Nudge/src/nudge.h new file mode 100644 index 0000000000..8a531639ca --- /dev/null +++ b/plugins/Nudge/src/nudge.h @@ -0,0 +1,67 @@ +#ifndef NUDGE_H
+#define NUDGE_H
+
+// NUDGE account status flags
+#define NUDGE_ACC_ST0 0x00000001 //Check (countdown) when Offline
+#define NUDGE_ACC_ST1 0x00000002 //Check (countdown) when Online
+#define NUDGE_ACC_ST2 0x00000004 //Check (countdown) when Away
+#define NUDGE_ACC_ST3 0x00000008 //Check (countdown) when N/A
+#define NUDGE_ACC_ST4 0x00000010 //Check (countdown) when Occupied
+#define NUDGE_ACC_ST5 0x00000020 //Check (countdown) when DND
+#define NUDGE_ACC_ST6 0x00000040 //Check (countdown) when Free for chat
+#define NUDGE_ACC_ST7 0x00000080 //Check (countdown) when Invisible
+#define NUDGE_ACC_ST8 0x00000100 //Check (countdown) when On the phone
+#define NUDGE_ACC_ST9 0x00000200 //Check (countdown) when Out to lunch
+
+// For status log
+#define EVENTTYPE_STATUSCHANGE 25368
+
+#define TEXT_LEN 1024
+
+class CNudge
+{
+public:
+ bool useByProtocol;
+ int sendTimeSec;
+ int recvTimeSec;
+ int resendDelaySec;
+
+ void Load(void);
+ void Save(void);
+};
+
+class CNudgeElement
+{
+public:
+ char ProtocolName[64];
+ TCHAR AccountName[128];
+ char NudgeSoundname[100];
+ TCHAR recText[TEXT_LEN];
+ TCHAR senText[TEXT_LEN];
+ bool showPopup;
+ bool showStatus;
+ bool openMessageWindow;
+ bool openContactList;
+ bool useIgnoreSettings;
+ bool shakeClist;
+ bool shakeChat;
+ bool enabled;
+ bool autoResend;
+ DWORD statusFlags;
+ int iProtoNumber;
+ HANDLE hIcoLibItem;
+ HANDLE hEvent;
+ HANDLE hContactMenu;
+
+ void Load(void);
+ void Save(void);
+ int ShowContactMenu(bool show);
+};
+
+typedef struct NudgeElementList
+{
+ CNudgeElement item;
+ NudgeElementList *next;
+} NUDGEELEMENTLIST;
+
+#endif
\ No newline at end of file diff --git a/plugins/Nudge/src/options.cpp b/plugins/Nudge/src/options.cpp new file mode 100644 index 0000000000..b0369143dc --- /dev/null +++ b/plugins/Nudge/src/options.cpp @@ -0,0 +1,435 @@ +#include "headers.h"
+#include "main.h"
+#include "shake.h"
+#include "options.h"
+
+CNudgeElement* ActualNudge = NULL;
+
+
+
+int NudgeOptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.cbSize = sizeof(odp);
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NUDGE);
+ odp.pszTitle = LPGEN("Nudge");
+ odp.pszGroup = LPGEN("Events");
+ odp.pszTab = LPGEN("Nudge");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pfnDlgProc = DlgProcNudgeOpt;
+ Options_AddPage(wParam, &odp);
+
+ odp.position = -790000001;
+ odp.pszTab = LPGEN("Window Shaking");
+ odp.pfnDlgProc = DlgProcShakeOpt;
+ odp.flags |= ODPF_EXPERTONLY;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SHAKE);
+ Options_AddPage(wParam, &odp);
+ return 0;
+}
+
+INT_PTR CALLBACK DlgProcShakeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ TCHAR szBuf[20];
+ TranslateDialogDefault(hwnd);
+ mir_sntprintf(szBuf, 10, _T("%d"), shake.nMoveClist);
+ SetDlgItemText(hwnd,IDC_LNUMBER_CLIST,szBuf);
+ mir_sntprintf(szBuf, 10, _T("%d"), shake.nMoveChat);
+ SetDlgItemText(hwnd,IDC_LNUMBER_CHAT,szBuf);
+
+ mir_sntprintf(szBuf, 10, _T("%d"), shake.nScaleClist);
+ SetDlgItemText(hwnd,IDC_LSCALE_CLIST,szBuf);
+ mir_sntprintf(szBuf, 10, _T("%d"), shake.nScaleChat);
+ SetDlgItemText(hwnd,IDC_LSCALE_CHAT,szBuf);
+
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CLIST, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 60));
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CHAT, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 60));
+
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CLIST, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 40));
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CHAT, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 40));
+
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CLIST, TBM_SETPOS, TRUE, shake.nMoveClist);
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CHAT, TBM_SETPOS, TRUE, shake.nMoveChat);
+
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CLIST, TBM_SETPOS, TRUE, shake.nScaleClist);
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CHAT, TBM_SETPOS, TRUE, shake.nScaleChat);
+
+ break;
+ case WM_COMMAND:
+ {
+ WORD wNotifyCode = HIWORD(wParam);
+ switch(LOWORD(wParam))
+ {
+ case IDC_PREVIEW:
+ ShakeClist(0,0);
+ //SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ break;
+ }
+ break;
+ }
+ case WM_HSCROLL:
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CLIST) || (HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CHAT)
+ || (HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CLIST) || (HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CHAT))
+ {
+ TCHAR szBuf[20];
+ DWORD dwPos = SendMessage((HWND) lParam, TBM_GETPOS, 0, 0);
+ mir_sntprintf(szBuf, sizeof(szBuf), _T("%d"), dwPos);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CLIST))
+ SetDlgItemText(hwnd,IDC_LNUMBER_CLIST,szBuf);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CHAT))
+ SetDlgItemText(hwnd,IDC_LNUMBER_CHAT,szBuf);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CLIST))
+ SetDlgItemText(hwnd,IDC_LSCALE_CLIST,szBuf);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CHAT))
+ SetDlgItemText(hwnd,IDC_LSCALE_CHAT,szBuf);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ break;
+
+ case WM_SHOWWINDOW:
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ switch(((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ shake.nMoveClist = (int) SendMessage(GetDlgItem(hwnd, IDC_SNUMBER_CLIST), TBM_GETPOS, 0, 0);
+ shake.nMoveChat = (int) SendMessage(GetDlgItem(hwnd, IDC_SNUMBER_CHAT), TBM_GETPOS, 0, 0);
+ shake.nScaleClist = (int) SendMessage(GetDlgItem(hwnd, IDC_SSCALE_CLIST), TBM_GETPOS, 0, 0);
+ shake.nScaleChat = (int) SendMessage(GetDlgItem(hwnd, IDC_SSCALE_CHAT), TBM_GETPOS, 0, 0);
+ shake.Save();
+ }
+ }
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+void CreateImageList(HWND hWnd)
+{
+ // Create and populate image list
+ HIMAGELIST hImList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, nProtocol, 0);
+
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ INT_PTR res = CallProtoService(n->item.ProtocolName, PS_LOADICON,PLI_PROTOCOL | PLIF_SMALL | PLIF_ICOLIB, 0);
+ if(res==CALLSERVICE_NOTFOUND)
+ {
+ res = CallService(MS_SKIN2_GETICONBYHANDLE,0,(LPARAM)n->item.hIcoLibItem);
+ }
+
+ HICON hIcon = (HICON) res;
+ ImageList_AddIcon(hImList, hIcon);
+ }
+ //ADD default Icon for nudge
+ HICON hIcon = (HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_NUDGE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ ImageList_AddIcon(hImList, hIcon);
+ DestroyIcon(hIcon);
+
+ HWND hLstView = GetDlgItem(hWnd, IDC_PROTOLIST);
+ TreeView_SetImageList(hLstView, hImList, TVSIL_NORMAL);
+}
+
+void PopulateProtocolList(HWND hWnd)
+{
+ bool useOne = IsDlgButtonChecked(hWnd, IDC_USEBYPROTOCOL) == BST_UNCHECKED;
+
+ HWND hLstView = GetDlgItem(hWnd, IDC_PROTOLIST);
+
+ TreeView_DeleteAllItems(hLstView);
+
+ TVINSERTSTRUCT tvi = {0};
+ tvi.hParent = TVI_ROOT;
+ tvi.hInsertAfter = TVI_LAST;
+ tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_STATE | TVIF_SELECTEDIMAGE;
+ tvi.item.stateMask = TVIS_STATEIMAGEMASK;
+
+ int i = 0;
+ if (GlobalNudge.useByProtocol)
+ {
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ tvi.item.pszText = n->item.AccountName;
+ tvi.item.iImage = i;
+ n->item.iProtoNumber = i;
+ tvi.item.iSelectedImage = i;
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(n->item.enabled?2:1);
+ TreeView_InsertItem(hLstView, &tvi);
+ i++;
+ }
+ }
+ else
+ {
+ tvi.item.pszText = TranslateT("Nudge");
+ tvi.item.iImage = nProtocol;
+ DefaultNudge.iProtoNumber = nProtocol;
+ tvi.item.iSelectedImage = nProtocol;
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(DefaultNudge.enabled?2:1);
+ TreeView_InsertItem(hLstView, &tvi);
+
+ }
+ TreeView_SelectItem(hLstView, TreeView_GetRoot(hLstView));
+ //TreeView_SetCheckState(hLstView, TreeView_GetRoot(hLstView), TRUE)
+}
+
+
+INT_PTR CALLBACK DlgProcNudgeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ static bool iInitDone = true;
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ iInitDone = false;
+ TranslateDialogDefault(hwnd);
+ CreateImageList(hwnd);
+ PopulateProtocolList(hwnd);
+ UpdateControls(hwnd);
+ iInitDone = true;
+ break;
+ case WM_DESTROY:
+ {
+ HIMAGELIST hImList = TreeView_GetImageList(GetDlgItem(hwnd, IDC_PROTOLIST), TVSIL_NORMAL);
+ if (hImList)
+ {
+ TreeView_SetImageList(GetDlgItem(hwnd, IDC_PROTOLIST), NULL, TVSIL_NORMAL); // Avoiding Access Violation in CommonControls DLL
+ ImageList_Destroy(hImList);
+ }
+ break;
+ }
+ case WM_COMMAND:
+ {
+ WORD wNotifyCode = HIWORD(wParam);
+ switch(LOWORD(wParam))
+ {
+ case IDC_PREVIEW:
+ Preview();
+ break;
+ case IDC_USEBYPROTOCOL:
+ GlobalNudge.useByProtocol = (IsDlgButtonChecked(hwnd,IDC_USEBYPROTOCOL)==BST_CHECKED);
+ PopulateProtocolList(hwnd);
+ UpdateControls(hwnd);
+ SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ break;
+ case IDC_AUTORESEND:
+ if (ActualNudge)// fix NULL pointer then no nudge support protocols
+ {
+ ActualNudge->autoResend = (IsDlgButtonChecked(hwnd,IDC_AUTORESEND)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hwnd,IDC_RESENDDELAY),ActualNudge->autoResend);
+ }
+ SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ break;
+ case IDC_CHECKST0:
+ case IDC_CHECKST1:
+ case IDC_CHECKST2:
+ case IDC_CHECKST3:
+ case IDC_CHECKST4:
+ case IDC_CHECKST5:
+ case IDC_CHECKST6:
+ case IDC_CHECKST7:
+ case IDC_CHECKST8:
+ case IDC_CHECKST9:
+ case IDC_CHECKPOP:
+ case IDC_OPENMESSAGE:
+ case IDC_CHECKCLIST:
+ case IDC_CHECKCHAT:
+ case IDC_CHECKSTATUS:
+ case IDC_IGNORE:
+ case IDC_OPENCONTACTLIST:
+ SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ break;
+ case IDC_RESENDDELAY:
+ case IDC_SENDTEXT:
+ case IDC_RECVTEXT:
+ case IDC_SENDTIME:
+ case IDC_RECVTIME:
+ if(iInitDone && (wNotifyCode == EN_CHANGE))
+ SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ break;
+ }
+ break;
+ }
+ case WM_SHOWWINDOW:
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ switch(((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ BOOL Translated;
+ GlobalNudge.sendTimeSec = GetDlgItemInt(hwnd,IDC_SENDTIME,&Translated,FALSE);
+ GlobalNudge.recvTimeSec = GetDlgItemInt(hwnd,IDC_RECVTIME,&Translated,FALSE);
+ GlobalNudge.resendDelaySec = GetDlgItemInt(hwnd,IDC_RESENDDELAY,&Translated,FALSE);
+ if(GlobalNudge.resendDelaySec > 10 ) GlobalNudge.resendDelaySec = 10;
+ if(GlobalNudge.resendDelaySec < 1 ) GlobalNudge.resendDelaySec = 1;
+ if (ActualNudge)// fix NULL pointer then no nudge support protocols
+ {
+ ActualNudge->shakeClist = (IsDlgButtonChecked(hwnd,IDC_CHECKCLIST)==BST_CHECKED);
+ ActualNudge->shakeChat = (IsDlgButtonChecked(hwnd,IDC_CHECKCHAT)==BST_CHECKED);
+ ActualNudge->openMessageWindow = (IsDlgButtonChecked(hwnd,IDC_OPENMESSAGE)==BST_CHECKED);
+ ActualNudge->openContactList = (IsDlgButtonChecked(hwnd,IDC_OPENCONTACTLIST)==BST_CHECKED);
+ ActualNudge->useIgnoreSettings = (IsDlgButtonChecked(hwnd,IDC_IGNORE)==BST_CHECKED);
+ ActualNudge->showStatus = (IsDlgButtonChecked(hwnd,IDC_CHECKSTATUS)==BST_CHECKED);
+ ActualNudge->showPopup = (IsDlgButtonChecked(hwnd,IDC_CHECKPOP)==BST_CHECKED);
+ ActualNudge->statusFlags =
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST0)==BST_CHECKED) ? NUDGE_ACC_ST0 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST1)==BST_CHECKED) ? NUDGE_ACC_ST1 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST2)==BST_CHECKED) ? NUDGE_ACC_ST2 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST3)==BST_CHECKED) ? NUDGE_ACC_ST3 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST4)==BST_CHECKED) ? NUDGE_ACC_ST4 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST5)==BST_CHECKED) ? NUDGE_ACC_ST5 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST6)==BST_CHECKED) ? NUDGE_ACC_ST6 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST7)==BST_CHECKED) ? NUDGE_ACC_ST7 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST8)==BST_CHECKED) ? NUDGE_ACC_ST8 : 0) |
+ ((IsDlgButtonChecked(hwnd,IDC_CHECKST9)==BST_CHECKED) ? NUDGE_ACC_ST9 : 0) ;
+
+ GetDlgItemText(hwnd,IDC_SENDTEXT,ActualNudge->senText,TEXT_LEN);
+ GetDlgItemText(hwnd,IDC_RECVTEXT,ActualNudge->recText,TEXT_LEN);
+ ActualNudge->Save();
+ }
+ GlobalNudge.Save();
+ }
+ }
+ case IDC_PROTOLIST:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case NM_CLICK:
+ {
+ TVHITTESTINFO ht = {0};
+
+ DWORD dwpos = GetMessagePos();
+ POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos));
+ MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1);
+
+ TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht);
+ /*if (TVHT_ONITEM & ht.flags)
+ CheckChange(hwnd,ht.hItem);*/
+ if (TVHT_ONITEMSTATEICON & ht.flags)
+ CheckChange(hwnd,ht.hItem);
+ }
+
+ case TVN_KEYDOWN:
+ if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE)
+ CheckChange(hwnd, TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom));
+ break;
+
+ case TVN_SELCHANGED:
+ {
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lParam;
+ if (pnmtv->itemNew.state & TVIS_SELECTED)
+ UpdateControls(hwnd);
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+void CheckChange(HWND hwnd, HTREEITEM hItem)
+{
+ HWND hLstView = GetDlgItem(hwnd, IDC_PROTOLIST);
+ bool isChecked = !TreeView_GetCheckState(hLstView, hItem);
+
+ TreeView_SelectItem(hLstView, hItem);
+
+ int proto = nProtocol;
+ if (GlobalNudge.useByProtocol)
+ {
+ proto = GetSelProto(hwnd, hItem);
+ ActualNudge = NULL;
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ if(n->item.iProtoNumber == proto)
+ ActualNudge = &n->item;
+ }
+ }
+ else
+ ActualNudge = &DefaultNudge;
+
+ if (ActualNudge)// fix NULL pointer then no nudge support protocols
+ ActualNudge->enabled = isChecked;
+
+ UpdateControls(hwnd);
+}
+
+void UpdateControls(HWND hwnd)
+{
+ int proto = nProtocol;
+ if (GlobalNudge.useByProtocol)
+ {
+ proto = GetSelProto(hwnd,NULL);
+ ActualNudge = NULL;
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
+ {
+ if(n->item.iProtoNumber == proto)
+ ActualNudge = &n->item;
+ }
+ }
+ else
+ ActualNudge = &DefaultNudge;
+
+ SetDlgItemInt(hwnd, IDC_SENDTIME, GlobalNudge.sendTimeSec,FALSE);
+ SetDlgItemInt(hwnd, IDC_RECVTIME, GlobalNudge.recvTimeSec,FALSE);
+ SetDlgItemInt(hwnd, IDC_RESENDDELAY, GlobalNudge.resendDelaySec,FALSE);
+ CheckDlgButton(hwnd, IDC_USEBYPROTOCOL, (WPARAM) GlobalNudge.useByProtocol);
+
+ if (ActualNudge)// fix NULL pointer then no nudge support protocols
+ {
+ CheckDlgButton(hwnd, IDC_CHECKPOP, (WPARAM) ActualNudge->showPopup);
+ CheckDlgButton(hwnd, IDC_CHECKCLIST, (WPARAM) ActualNudge->shakeClist);
+ CheckDlgButton(hwnd, IDC_CHECKCHAT, (WPARAM) ActualNudge->shakeChat);
+ CheckDlgButton(hwnd, IDC_CHECKSTATUS, (WPARAM) ActualNudge->showStatus);
+ CheckDlgButton(hwnd, IDC_AUTORESEND, (WPARAM) ActualNudge->autoResend);
+ CheckDlgButton(hwnd, IDC_OPENMESSAGE, (WPARAM) ActualNudge->openMessageWindow);
+ CheckDlgButton(hwnd, IDC_OPENCONTACTLIST, (WPARAM) ActualNudge->openContactList);
+ CheckDlgButton(hwnd, IDC_IGNORE, (WPARAM) ActualNudge->useIgnoreSettings);
+ EnableWindow(GetDlgItem(hwnd,IDC_RESENDDELAY),ActualNudge->autoResend);
+ CheckDlgButton(hwnd,IDC_CHECKST0,ActualNudge->statusFlags & NUDGE_ACC_ST0 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST1,ActualNudge->statusFlags & NUDGE_ACC_ST1 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST2,ActualNudge->statusFlags & NUDGE_ACC_ST2 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST3,ActualNudge->statusFlags & NUDGE_ACC_ST3 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST4,ActualNudge->statusFlags & NUDGE_ACC_ST4 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST5,ActualNudge->statusFlags & NUDGE_ACC_ST5 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST6,ActualNudge->statusFlags & NUDGE_ACC_ST6 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST7,ActualNudge->statusFlags & NUDGE_ACC_ST7 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST8,ActualNudge->statusFlags & NUDGE_ACC_ST8 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd,IDC_CHECKST9,ActualNudge->statusFlags & NUDGE_ACC_ST9 ? BST_CHECKED : BST_UNCHECKED);
+ SetDlgItemText(hwnd,IDC_SENDTEXT,ActualNudge->senText);
+ SetDlgItemText(hwnd,IDC_RECVTEXT,ActualNudge->recText);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwnd,IDC_PROTOLIST),FALSE);
+ }
+}
+
+int GetSelProto(HWND hwnd, HTREEITEM hItem)
+{
+ HWND hLstView = GetDlgItem(hwnd, IDC_PROTOLIST);
+ TVITEM tvi = {0};
+
+ tvi.mask = TVIF_IMAGE;
+ tvi.hItem = hItem == NULL ? TreeView_GetSelection(hLstView) : hItem;
+
+ TreeView_GetItem(hLstView, &tvi);
+
+ return tvi.iImage;
+}
\ No newline at end of file diff --git a/plugins/Nudge/src/options.h b/plugins/Nudge/src/options.h new file mode 100644 index 0000000000..68f648a0bb --- /dev/null +++ b/plugins/Nudge/src/options.h @@ -0,0 +1,14 @@ +extern HINSTANCE hInst;
+extern NudgeElementList* NudgeList;
+extern int nProtocol;
+extern CNudgeElement DefaultNudge;
+extern CShake shake;
+extern CNudge GlobalNudge;
+
+static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK DlgProcNudgeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
+static INT_PTR CALLBACK DlgProcShakeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
+
+void UpdateControls(HWND hwnd);
+int GetSelProto(HWND hwnd, HTREEITEM hItem);
+void CheckChange(HWND hwnd, HTREEITEM hItem);
diff --git a/plugins/Nudge/src/resource.h b/plugins/Nudge/src/resource.h new file mode 100644 index 0000000000..60a56388e2 --- /dev/null +++ b/plugins/Nudge/src/resource.h @@ -0,0 +1,89 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDD_DIALOG1 101
+#define IDI_NUDGE 102
+#define IDI_NUGDE_YAHOO 107
+#define IDI_NUDGE_IRC 109
+#define IDI_NUDGE_MSN 110
+#define IDI_NUDGE_TLEN 111
+#define IDI_NUDGE_META 113
+#define IDD_SHAKEOPT 126
+#define IDD_OPT_NUDGE 126
+#define IDD_OPT_SHAKE 128
+#define IDD_OPT_TRIGGER 129
+#define IDC_BUTTON1 1000
+#define IDC_PREVIEW 1000
+#define IDC_EDIT1 1001
+#define IDC_SENDTEXT 1001
+#define IDC_BUTTON2 1002
+#define IDC_SENDTEXT2 1002
+#define IDC_RECVTEXT 1002
+#define IDC_BUTTON3 1003
+#define IDC_BUTTON4 1004
+#define IDC_BUTTON5 1005
+#define IDC_BUTTON6 1006
+#define IDC_BUTTON7 1007
+#define IDC_USEWINCOLORS 1007
+#define IDC_LABEL_FN 1008
+#define IDC_LABEL_IMAGESIZE 1009
+#define IDC_SLIDER_CLIST 1009
+#define IDC_SNUMBER_CLIST 1009
+#define IDC_SLIDER_CHAT 1010
+#define IDC_SNUMBER_CHAT 1010
+#define IDC_LABEL_ERRSTATE 1011
+#define IDC_SSCALE_CLIST 1011
+#define IDC_LABEL_TOTALBLOCKS 1012
+#define IDC_LNUMBER_CLIST 1012
+#define IDC_LABEL_WRITTENBLOCKS 1013
+#define IDC_LABEL_RESULT 1013
+#define IDC_LNUMBER_CHAT 1013
+#define IDC_LSCALE_CLIST 1014
+#define IDC_SSCALE_CHAT 1015
+#define IDC_LSCALE_CHAT 1016
+#define IDC_CHECKCLIST 1018
+#define IDC_CHECKST0 1019
+#define IDC_CHECKST1 1020
+#define IDC_CHECKST2 1021
+#define IDC_CHECKST3 1022
+#define IDC_CHECKST4 1023
+#define IDC_CHECKST5 1024
+#define IDC_CHECKST6 1025
+#define IDC_CHECKST7 1026
+#define IDC_POPUPTEXTCOLOR 1027
+#define IDC_CHECKST8 1028
+#define IDC_CHECKST9 1029
+#define IDC_BGCOLOUR 1030
+#define IDC_PROTOLIST 1031
+#define IDC_TEXTCOLOUR 1032
+#define IDC_USEBYPROTOCOL 1033
+#define IDC_CHECKCHAT2 1034
+#define IDC_CHECKCHAT 1034
+#define IDC_CHECKCOL 1035
+#define IDC_CHECKEVENT 1035
+#define IDC_POPUPBACKCOLOR 1036
+#define IDC_CHECKPOP 1037
+#define IDC_POPUPTIME 1038
+#define IDC_SENDTIME 1039
+#define IDC_RECVTIME 1040
+#define IDC_TRIGGER_SHAKECLIST 1040
+#define IDC_CHECKEVENT2 1041
+#define IDC_CHECKSTATUS 1041
+#define IDC_TRIGGER_SHAKECHAT 1041
+#define IDC_AUTORESEND 1042
+#define IDC_RESENDDELAY 1043
+#define IDC_OPENMESSAGE 1044
+#define IDC_OPENCONTACTLIST 1046
+#define IDC_IGNORE 1047
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 114
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1048
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/Nudge/src/shake.cpp b/plugins/Nudge/src/shake.cpp new file mode 100644 index 0000000000..f396c4f535 --- /dev/null +++ b/plugins/Nudge/src/shake.cpp @@ -0,0 +1,189 @@ +#include "headers.h"
+#include "shake.h"
+
+extern CShake shake;
+
+void CShake::Load(void)
+{
+
+ Shaking = false;
+ ShakingChat = false;
+ nScaleClist = DBGetContactSettingDword(NULL, "Nudge", "ScaleClist", 5);
+ nScaleChat = DBGetContactSettingDword(NULL, "Nudge", "ScaleChat", 2);
+ nMoveClist = DBGetContactSettingDword(NULL, "Nudge", "MoveClist", 15);
+ nMoveChat = DBGetContactSettingDword(NULL, "Nudge", "MoveChat", 15);
+}
+void CShake::Save(void)
+{
+ DBWriteContactSettingDword(NULL, "Nudge", "ScaleClist", this->nScaleClist);
+ DBWriteContactSettingDword(NULL, "Nudge", "ScaleChat", this->nScaleChat);
+ DBWriteContactSettingDword(NULL, "Nudge", "MoveClist", this->nMoveClist);
+ DBWriteContactSettingDword(NULL, "Nudge", "MoveChat", this->nMoveChat);
+}
+
+DWORD WINAPI ShakeChatWindow(LPVOID Param)
+{
+ HWND hWnd = (HWND) Param;
+ shake.ShakeChat(hWnd);
+ return 1;
+}
+
+DWORD WINAPI ShakeClistWindow(LPVOID Param)
+{
+ HWND hWnd = (HWND) Param;
+ shake.ShakeClist(hWnd);
+ return 0;
+}
+
+INT_PTR ShakeClist( WPARAM wParam, LPARAM lParam )
+{
+ DWORD tid;
+ HWND hWnd = (HWND) CallService( MS_CLUI_GETHWND, 0, 0 );
+
+ CreateThread(NULL,0,ShakeClistWindow,(LPVOID) hWnd,0,&tid);
+ return 0;
+}
+
+INT_PTR ShakeChat( WPARAM wParam, LPARAM lParam )
+{
+ if (((HANDLE) wParam) == NULL) return -1;
+
+ DWORD tid;
+ //char srmmName[100];
+ MessageWindowData mwd;
+ MessageWindowInputData mwid;
+
+ mwd.cbSize = sizeof(MessageWindowData);
+ mwd.hContact = Nudge_GethContact((HANDLE) wParam);
+ mwd.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ mwid.cbSize = sizeof(MessageWindowInputData);
+ mwid.hContact = mwd.hContact;
+ mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+
+ CallService( MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd );
+ //CallService(MS_MSG_GETWINDOWCLASS,(WPARAM)srmmName,(LPARAM)100 );
+
+ HWND parent;
+ HWND hWnd = mwd.hwndWindow;
+ while((parent = GetParent(hWnd)) != 0) hWnd = parent; // ensure we have the top level window (need parent window for scriver & tabsrmm)
+
+ CreateThread(NULL,0,ShakeChatWindow,(LPVOID) hWnd,0,&tid);
+ return 0;
+}
+
+/*
+
+int TriggerShakeClist( WPARAM wParam, LPARAM lParam )
+{
+ DWORD tid;
+ HWND hWnd;
+ int flags;
+ flags = (int)wParam;
+
+ if (!flags&ACT_PERFORM)
+ return 0;
+
+ hWnd = (HWND) CallService( MS_CLUI_GETHWND, 0, 0 );
+
+ CreateThread(NULL,0,ShakeClistWindow,(LPVOID) hWnd,0,&tid);
+ return 0;
+}
+
+int TriggerShakeChat( WPARAM wParam, LPARAM lParam )
+{
+ DWORD tid;
+ HWND hWnd;
+ char srmmName[100];
+ MessageWindowData mwd;
+ MessageWindowInputData mwid;
+ int flags;
+ flags = (int)wParam;
+
+ if (!flags&ACT_PERFORM)
+ return 0;
+
+ SPECIFICACTIONINFO *sai;
+ HANDLE hContact;
+
+
+ sai = (SPECIFICACTIONINFO *) lParam;
+
+ if ( (sai->td != NULL) && (sai->td->dFlags&DF_CONTACT))
+ hContact = sai->td->hContact;
+ else
+ return 0;
+
+ mwd.cbSize = sizeof(MessageWindowData);
+ mwd.hContact = Nudge_GethContact((HANDLE) hContact);
+ mwd.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ mwid.cbSize = sizeof(MessageWindowInputData);
+ mwid.hContact = Nudge_GethContact((HANDLE) hContact);
+ mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ CallService( MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd );
+ CallService(MS_MSG_GETWINDOWCLASS,(WPARAM)srmmName,(LPARAM)100 );
+
+ if ( !strnicmp( srmmName,"tabSRMM ", 7 ))
+ hWnd = GetParent(GetParent(mwd.hwndWindow));
+
+ if ( !strnicmp( srmmName,"SRMM ", 4))
+ hWnd = mwd.hwndWindow;
+
+ if ( !strnicmp( srmmName,"Scriver ", 7 ))
+ hWnd = GetParent(mwd.hwndWindow);
+
+ CreateThread(NULL,0,ShakeChatWindow,(LPVOID) hWnd,0,&tid);
+ return 0;
+}
+*/
+
+int CShake::ShakeChat(HWND hWnd)
+{
+ if (!ShakingChat)
+ {
+ ShakingChat = true;
+ RECT rect;
+ GetWindowRect(hWnd, &rect);
+ for(int i = 0; i < nMoveChat; i++)
+ {
+ SetWindowPos(hWnd, 0, rect.left - nScaleChat, rect.top, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ SetWindowPos(hWnd, 0, rect.left, rect.top - nScaleChat, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ SetWindowPos(hWnd, 0, rect.left + nScaleChat, rect.top, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ SetWindowPos(hWnd, 0, rect.left, rect.top + nScaleChat, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ }
+ SetWindowPos(hWnd, 0, rect.left, rect.top, 0, 0, SWP_NOSIZE); //SWP_DRAWFRAME
+ ShakingChat = false;
+ }
+ return 0;
+}
+
+int CShake::ShakeClist(HWND hWnd)
+{
+ if (!Shaking)
+ {
+ Shaking = true;
+ RECT rect;
+ GetWindowRect(hWnd, &rect);
+ for(int i = 0; i < nMoveClist; i++)
+ {
+ SetWindowPos(hWnd, 0, rect.left - nScaleClist, rect.top, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ SetWindowPos(hWnd, 0, rect.left, rect.top - nScaleClist, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ SetWindowPos(hWnd, 0, rect.left + nScaleClist, rect.top, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ SetWindowPos(hWnd, 0, rect.left, rect.top + nScaleClist, 0, 0, SWP_NOSIZE);
+ Sleep(10);
+ }
+ SetWindowPos(hWnd, 0, rect.left, rect.top, 0, 0, SWP_NOSIZE);
+ Shaking = false;
+ }
+ return 0;
+}
\ No newline at end of file diff --git a/plugins/Nudge/src/shake.h b/plugins/Nudge/src/shake.h new file mode 100644 index 0000000000..73e460cb41 --- /dev/null +++ b/plugins/Nudge/src/shake.h @@ -0,0 +1,27 @@ +#ifndef SHAKE_H
+#define SHAKE_H
+
+class CShake
+{
+public:
+ bool Shaking;
+ bool ShakingChat;
+ int nScaleClist;
+ int nScaleChat;
+ int nMoveClist;
+ int nMoveChat;
+
+ void Load(void);
+ void Save(void);
+ int ShakeClist(HWND hWnd);
+ int ShakeChat(HWND hWnd);
+};
+
+INT_PTR ShakeClist(WPARAM,LPARAM);
+INT_PTR ShakeChat(WPARAM,LPARAM);
+/*
+int TriggerShakeChat(WPARAM,LPARAM);
+int TriggerShakeClist(WPARAM,LPARAM);
+int TriggerAction(WPARAM,LPARAM);*/
+
+#endif
\ No newline at end of file |