diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-25 12:07:46 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-25 12:07:46 +0000 |
commit | e64818967374ebdadf6f22d18296e7bc6088277b (patch) | |
tree | 14736c4f5d51012dfccb63bc745f08a63ec4f8fd /plugins | |
parent | dd1460d664f7266920b07527f25f87ec8233daaf (diff) |
IsFullScreen(), IsWorkstationLocked(), IsScreenSaverRunning() moved to the core
git-svn-id: http://svn.miranda-ng.org/main/trunk@6226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/BossKeyPlus/src/BossKeyIdle.cpp | 16 | ||||
-rw-r--r-- | plugins/CryptoPP/src/GPGw/gpg_main.cpp | 457 | ||||
-rw-r--r-- | plugins/Popup/src/services.cpp | 87 | ||||
-rw-r--r-- | plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp | 90 | ||||
-rw-r--r-- | plugins/YAPP/src/message_pump.cpp | 94 | ||||
-rw-r--r-- | plugins/YAPP/src/message_pump.h | 1 | ||||
-rw-r--r-- | plugins/YAPP/src/notify_imp.cpp | 3 | ||||
-rw-r--r-- | plugins/YAPP/src/options.cpp | 46 | ||||
-rw-r--r-- | plugins/YAPP/src/popwin.cpp | 141 |
9 files changed, 388 insertions, 547 deletions
diff --git a/plugins/BossKeyPlus/src/BossKeyIdle.cpp b/plugins/BossKeyPlus/src/BossKeyIdle.cpp index a97bf01abc..806f3820e1 100644 --- a/plugins/BossKeyPlus/src/BossKeyIdle.cpp +++ b/plugins/BossKeyPlus/src/BossKeyIdle.cpp @@ -29,13 +29,6 @@ UINT mouseidle, minutes; VOID CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT idEvent, DWORD dwTime);
-static bool IsScreenSaverRunning()
-{
- bool rc = FALSE;
- SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &rc, FALSE);
- return rc;
-}
-
static bool IsUserIdle()
{
DWORD dwTick;
@@ -53,14 +46,11 @@ static bool IsUserIdle() return FALSE;
}
-
VOID CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT_PTR idEvent, DWORD dwTime)
{
- if ( hTimer == idEvent && !g_bWindowHidden &&
- ((g_wMaskAdv & (OPT_HIDEIFWINIDLE | OPT_HIDEIFMIRIDLE) && IsUserIdle()) ||
- (g_wMaskAdv & OPT_HIDEIFSCRSVR && IsScreenSaverRunning())))
-
- BossKeyHideMiranda(0, 0);
+ if ( hTimer == idEvent && !g_bWindowHidden && ((g_wMaskAdv & (OPT_HIDEIFWINIDLE | OPT_HIDEIFMIRIDLE) && IsUserIdle()) ||
+ (g_wMaskAdv & OPT_HIDEIFSCRSVR) && IsScreenSaverRunning()))
+ BossKeyHideMiranda(0, 0);
}
void InitIdleTimer()
diff --git a/plugins/CryptoPP/src/GPGw/gpg_main.cpp b/plugins/CryptoPP/src/GPGw/gpg_main.cpp index 700e27b691..61c076e8df 100644 --- a/plugins/CryptoPP/src/GPGw/gpg_main.cpp +++ b/plugins/CryptoPP/src/GPGw/gpg_main.cpp @@ -15,29 +15,29 @@ char *txtendpgpmessage="-----END PGP MESSAGE-----"; void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint)
{
- char buffer[errormessagesize];
+ char buffer[errormessagesize];
- strcpy(buffer, atext);
- strcat(buffer, " ");
- strcat(buffer, ahint);
- MessageBox(NULL, buffer, alevel, MB_OK);
+ strcpy(buffer, atext);
+ strcat(buffer, " ");
+ strcat(buffer, ahint);
+ MessageBox(NULL, buffer, alevel, MB_OK);
}
void __cdecl LogMessage(const char *astart, const char *atext, const char *aend)
{
- FILE *log;
-
- if(logfile[0]=='\0') return;
-
- log=fopen(logfile, "a");
- if(log!=NULL)
- {
- fputs(astart, log);
- fputs(atext, log);
- fputs(aend, log);
- fclose(log);
- }
+ FILE *log;
+
+ if(logfile[0]=='\0') return;
+
+ log=fopen(logfile, "a");
+ if(log!=NULL)
+ {
+ fputs(astart, log);
+ fputs(atext, log);
+ fputs(aend, log);
+ fclose(log);
+ }
}
int __cdecl _gpg_init()
@@ -62,21 +62,21 @@ int __cdecl _gpg_done() int __cdecl _gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath)
{
- if ( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) {
- return 0;
- }
- if ( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) {
- return 0;
- }
- if ( !existsFile(ExecPath) ) {
-// ErrorMessage(txtwarning, txtinvalidexecutable, txtverifyoptions);
- return 0;
- }
- strcpy(gpgExecutable, ExecPath);
- strcpy(gpgHomeDirectory, HomePath);
- updateKeyUserIDs(publickeyuserid);
- updateKeyUserIDs(secretkeyuserid);
- return 1;
+ if ( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) {
+ return 0;
+ }
+ if ( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) {
+ return 0;
+ }
+ if ( !existsFile(ExecPath) ) {
+ // ErrorMessage(txtwarning, txtinvalidexecutable, txtverifyoptions);
+ return 0;
+ }
+ strcpy(gpgExecutable, ExecPath);
+ strcpy(gpgHomeDirectory, HomePath);
+ updateKeyUserIDs(publickeyuserid);
+ updateKeyUserIDs(secretkeyuserid);
+ return 1;
}
@@ -94,23 +94,23 @@ LPSTR __cdecl _gpg_get_error() void __cdecl _gpg_set_log(LPCSTR LogPath)
{
- if(LogPath) strncpy(logfile,LogPath,sizeof(logfile));
- else logfile[0]='\0';
+ if(LogPath) strncpy(logfile,LogPath,sizeof(logfile));
+ else logfile[0]='\0';
}
void __cdecl _gpg_set_tmp(LPCSTR TmpPath)
{
- if(TmpPath) strncpy(temporarydirectory,TmpPath,sizeof(temporarydirectory));
- else GetTempPath(sizeof(temporarydirectory),temporarydirectory);
+ if(TmpPath) strncpy(temporarydirectory,TmpPath,sizeof(temporarydirectory));
+ else GetTempPath(sizeof(temporarydirectory),temporarydirectory);
}
LPSTR __cdecl _gpg_get_passphrases()
{
- size_t i; char *b, x;
+ size_t i; char *b, x;
- b = (char *) LocalAlloc(LPTR,(keyuseridsize+passphrasesize)*passphrasecount+1); *b = '\0';
+ b = (char *) LocalAlloc(LPTR,(keyuseridsize+passphrasesize)*passphrasecount+1); *b = '\0';
for(i=0; i<(size_t)passphrasecount; i++) {
strcat(b,passphrases[i].keyuserid); strcat(b,"\x01");
@@ -124,15 +124,15 @@ LPSTR __cdecl _gpg_get_passphrases() if ( x>2 ) b[i]=x;
}
- return b;
+ return b;
}
void __cdecl _gpg_set_passphrases(LPCSTR buffer)
{
- size_t i, l = strlen(buffer); char *t, *p, *b, x;
+ size_t i, l = strlen(buffer); char *t, *p, *b, x;
- if ( !l ) return;
+ if ( !l ) return;
b = (char *) LocalAlloc(LPTR,l+1);
strcpy(b, buffer);
@@ -147,12 +147,12 @@ void __cdecl _gpg_set_passphrases(LPCSTR buffer) while(*b) {
t = strchr(b, '\x02');
if(t) {
- *t = '\0';
+ *t = '\0';
p = strchr(b, '\x01');
*p = '\0';
addPassphrase(b, p+1);
t++;
- }
+ }
b = t;
}
LocalFree(b);
@@ -161,108 +161,105 @@ void __cdecl _gpg_set_passphrases(LPCSTR buffer) LPSTR __cdecl _gpg_encrypt(LPCSTR message, LPCSTR keyid)
{
- char buffer[ciphertextsize];
- char *encmessage = 0;
- int encmessagelen;
- gpgResult gpgresult;
-
- if(strlen(keyid))
- {
- ZeroMemory(buffer, sizeof(buffer));
- gpgresult=gpgEncrypt(buffer, keyid, message);
-
- if(gpgresult!=gpgSuccess)
- {
-// ErrorMessage(txterror, txtencryptfailed, txtverifyoptions);
- return 0;
- }
- encmessagelen = strlen(buffer)+1;
- encmessage = (char *) LocalAlloc(LPTR,encmessagelen);
- MoveMemory(encmessage, buffer, encmessagelen);
- }
-
- return encmessage;
-}
+ char buffer[ciphertextsize];
+ char *encmessage = 0;
+ int encmessagelen;
+ gpgResult gpgresult;
+
+ if(strlen(keyid))
+ {
+ ZeroMemory(buffer, sizeof(buffer));
+ gpgresult=gpgEncrypt(buffer, keyid, message);
+
+ if(gpgresult!=gpgSuccess)
+ return 0;
+
+ encmessagelen = strlen(buffer)+1;
+ encmessage = (char *) LocalAlloc(LPTR,encmessagelen);
+ MoveMemory(encmessage, buffer, encmessagelen);
+ }
+ return encmessage;
+}
LPSTR __cdecl _gpg_decrypt(LPCSTR message)
{
- char buffer[ciphertextsize];
- char plaintext[plaintextsize];
- char keyuserid[keyuseridsize];
- int dlgresult;
- BOOL useridvalid;
- char *storedpassphrase;
- char passphrase[passphrasesize];
- char *decmessage = 0;
- int decmessagelen;
- gpgResult gpgresult;
-
- const char *begin = strstr(message, txtbeginpgpmessage);
- const char *end = strstr(message, txtendpgpmessage);
-
- if ((begin!=NULL)&&(end!=NULL))
- {
- strcpy(buffer, "");
- strncat(buffer, begin, end-begin+strlen(txtendpgpmessage));
- replace(buffer, "\r", "");
- replace(buffer, "\n", txtcrlf);
-
- ZeroMemory(keyuserid, sizeof(keyuserid));
- gpgresult=gpgDetectUserID(keyuserid, buffer);
- storedpassphrase=NULL;
-
- if(gpgresult!=gpgSuccess)
- {
-// ErrorMessage(txtwarning, txtdetectuseridfailed, txtverifyoptions);
- strcpy(keyuserid, txtunknownuserid);
- useridvalid=FALSE;
- }
- else
- {
- storedpassphrase=getPassphrase(keyuserid);
- useridvalid=TRUE;
- }
-
- if(storedpassphrase!=NULL)
- {
- strcpy(passphrase, storedpassphrase);
- ZeroMemory(plaintext, sizeof(plaintext));
- gpgresult=gpgDecrypt(plaintext, buffer, passphrase);
- }
- else gpgresult=gpgUnknownError;
-
- dlgresult=IDOK;
- while((gpgresult!=gpgSuccess)&&(dlgresult!=IDCANCEL))
- {
- dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, PassphraseDialogProcedure, (LPARAM)keyuserid);
-
- if(dlgresult==IDOK)
- {
- strcpy(passphrase, dlgpassphrase);
- ZeroMemory(dlgpassphrase, passphrasesize);
- strcat(passphrase, txtcrlf);
- ZeroMemory(plaintext, sizeof(plaintext));
- gpgresult=gpgDecrypt(plaintext, buffer, passphrase);
- }
- }
-
- if(gpgresult==gpgSuccess)
- {
- strcpy(buffer, plaintext);
- }
-
- if ( gpgresult==gpgSuccess && useridvalid==TRUE)
- addPassphrase(keyuserid, passphrase);
-
- ZeroMemory(passphrase, sizeof(passphrase));
-
- decmessagelen = strlen(buffer)+1;
- decmessage = (char *) LocalAlloc(LPTR,decmessagelen);
- MoveMemory(decmessage, buffer, decmessagelen);
- }
-
- return decmessage;
+ char buffer[ciphertextsize];
+ char plaintext[plaintextsize];
+ char keyuserid[keyuseridsize];
+ int dlgresult;
+ BOOL useridvalid;
+ char *storedpassphrase;
+ char passphrase[passphrasesize];
+ char *decmessage = 0;
+ int decmessagelen;
+ gpgResult gpgresult;
+
+ const char *begin = strstr(message, txtbeginpgpmessage);
+ const char *end = strstr(message, txtendpgpmessage);
+
+ if ((begin!=NULL)&&(end!=NULL))
+ {
+ strcpy(buffer, "");
+ strncat(buffer, begin, end-begin+strlen(txtendpgpmessage));
+ replace(buffer, "\r", "");
+ replace(buffer, "\n", txtcrlf);
+
+ ZeroMemory(keyuserid, sizeof(keyuserid));
+ gpgresult=gpgDetectUserID(keyuserid, buffer);
+ storedpassphrase=NULL;
+
+ if(gpgresult!=gpgSuccess)
+ {
+ // ErrorMessage(txtwarning, txtdetectuseridfailed, txtverifyoptions);
+ strcpy(keyuserid, txtunknownuserid);
+ useridvalid=FALSE;
+ }
+ else
+ {
+ storedpassphrase=getPassphrase(keyuserid);
+ useridvalid=TRUE;
+ }
+
+ if(storedpassphrase!=NULL)
+ {
+ strcpy(passphrase, storedpassphrase);
+ ZeroMemory(plaintext, sizeof(plaintext));
+ gpgresult=gpgDecrypt(plaintext, buffer, passphrase);
+ }
+ else gpgresult=gpgUnknownError;
+
+ dlgresult=IDOK;
+ while((gpgresult!=gpgSuccess)&&(dlgresult!=IDCANCEL))
+ {
+ dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, PassphraseDialogProcedure, (LPARAM)keyuserid);
+
+ if(dlgresult==IDOK)
+ {
+ strcpy(passphrase, dlgpassphrase);
+ ZeroMemory(dlgpassphrase, passphrasesize);
+ strcat(passphrase, txtcrlf);
+ ZeroMemory(plaintext, sizeof(plaintext));
+ gpgresult=gpgDecrypt(plaintext, buffer, passphrase);
+ }
+ }
+
+ if(gpgresult==gpgSuccess)
+ {
+ strcpy(buffer, plaintext);
+ }
+
+ if ( gpgresult==gpgSuccess && useridvalid==TRUE)
+ addPassphrase(keyuserid, passphrase);
+
+ ZeroMemory(passphrase, sizeof(passphrase));
+
+ decmessagelen = strlen(buffer)+1;
+ decmessage = (char *) LocalAlloc(LPTR,decmessagelen);
+ MoveMemory(decmessage, buffer, decmessagelen);
+ }
+
+ return decmessage;
}
@@ -274,122 +271,124 @@ int __cdecl _gpg_size_keyid() int __cdecl _gpg_select_keyid(HWND hdlg, LPSTR keyid)
{
- int dlgresult;
+ int dlgresult;
- ZeroMemory(keyid, keyidsize);
- dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_SELECTKEY), hdlg, UserIdDialogProcedure, (LPARAM)keyid);
+ ZeroMemory(keyid, keyidsize);
+ dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_SELECTKEY), hdlg, UserIdDialogProcedure, (LPARAM)keyid);
- if(dlgresult!=IDOK)
- ZeroMemory(keyid, keyidsize);
+ if(dlgresult!=IDOK)
+ ZeroMemory(keyid, keyidsize);
return (dlgresult==IDOK);
}
-void noBackslash(LPSTR path) {
- LPSTR ptr;
- ptr = path + strlen(path) - 1;
- if ( *ptr=='\\' ) *ptr = '\0';
+void noBackslash(LPSTR path)
+{
+ LPSTR ptr = path + strlen(path) - 1;
+ if ( *ptr=='\\' ) *ptr = '\0';
}
static char buf[MAX_PATH];
-LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName){
- DWORD len=MAX_PATH,type;
- LPSTR ret=0;
+LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName)
+{
+ DWORD len=MAX_PATH,type;
+ LPSTR ret=0;
- RegOpenKey(hKey,szPath,&hKey);
- if ( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ) {
- noBackslash((LPSTR)&buf);
- ret = (LPSTR)&buf;
- }
- RegCloseKey(hKey);
+ RegOpenKey(hKey,szPath,&hKey);
+ if ( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ) {
+ noBackslash((LPSTR)&buf);
+ ret = (LPSTR)&buf;
+ }
+ RegCloseKey(hKey);
- return ret;
+ return ret;
}
-LPSTR GetEnvValue(LPCSTR szName){
- LPSTR ret=0;
+LPSTR GetEnvValue(LPCSTR szName)
+{
+ LPSTR ret=0;
- if ( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) {
- noBackslash((LPSTR)&buf);
- ret = (LPSTR)&buf;
- }
+ if ( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) {
+ noBackslash((LPSTR)&buf);
+ ret = (LPSTR)&buf;
+ }
- return ret;
+ return ret;
}
BOOL ShowSelectExecDlg(LPSTR path)
{
- OPENFILENAME ofn;
- ZeroMemory(&ofn,sizeof(ofn));
-
- ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","gpgProgram");
- if ( ofn.lpstrFile && existsFile(ofn.lpstrFile) ) {
- strcpy(path, ofn.lpstrFile);
- return TRUE;
- }
- ofn.lpstrFile = GetRegValue(HKEY_LOCAL_MACHINE,"Software\\GNU\\GnuPG","Install Directory");
- if ( ofn.lpstrFile ) {
- strcat(ofn.lpstrFile,"\\gpg.exe");
- if ( existsFile(ofn.lpstrFile) ) {
- strcpy(path, ofn.lpstrFile);
- return TRUE;
- }
- }
-
- ofn.lStructSize = sizeof(ofn);
- ofn.nMaxFile = MAX_PATH;
- ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON;
-
- ofn.lpstrFile = path;
- ofn.lpstrFilter = "GnuPG executable (gpg.exe)\0gpg.exe\0All files (*.*)\0*.*\0";
- ofn.lpstrTitle = "Select GnuPG executable";
- if (!GetOpenFileName(&ofn)) return FALSE;
-
- return TRUE;
+ OPENFILENAME ofn;
+ ZeroMemory(&ofn,sizeof(ofn));
+
+ ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","gpgProgram");
+ if ( ofn.lpstrFile && existsFile(ofn.lpstrFile) ) {
+ strcpy(path, ofn.lpstrFile);
+ return TRUE;
+ }
+ ofn.lpstrFile = GetRegValue(HKEY_LOCAL_MACHINE,"Software\\GNU\\GnuPG","Install Directory");
+ if ( ofn.lpstrFile ) {
+ strcat(ofn.lpstrFile,"\\gpg.exe");
+ if ( existsFile(ofn.lpstrFile) ) {
+ strcpy(path, ofn.lpstrFile);
+ return TRUE;
+ }
+ }
+
+ ofn.lStructSize = sizeof(ofn);
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON;
+
+ ofn.lpstrFile = path;
+ ofn.lpstrFilter = "GnuPG executable (gpg.exe)\0gpg.exe\0All files (*.*)\0*.*\0";
+ ofn.lpstrTitle = "Select GnuPG executable";
+ if (!GetOpenFileName(&ofn)) return FALSE;
+
+ return TRUE;
}
BOOL ShowSelectHomeDlg(LPSTR path)
{
- int i;
- OPENFILENAME ofn;
-
- ofn.lpstrFile = GetEnvValue("GNUPGHOME");
- if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
- strcpy(path, ofn.lpstrFile);
- return TRUE;
- }
- ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","HomeDir");
- if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
- strcpy(path, ofn.lpstrFile);
- return TRUE;
- }
- ofn.lpstrFile = GetEnvValue("APPDATA");
- if ( ofn.lpstrFile ) {
- strcat(ofn.lpstrFile,"\\gnupg");
- if ( existsPath(ofn.lpstrFile) ) {
- strcpy(path, ofn.lpstrFile);
- return TRUE;
- }
- }
-
- ofn.lStructSize = sizeof(ofn);
- ofn.nMaxFile = MAX_PATH;
- ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON;
-
- ofn.lpstrFile = path;
- ofn.lpstrFilter = "Public key rings (pubring.gpg)\0pubring.gpg\0All files (*.*)\0*.*\0";
- ofn.lpstrTitle = "Open Public Keyring";
- if (!GetOpenFileName(&ofn)) return FALSE;
-
- for(i=strlen(path);i && path[i]!='\\';i--);
- path[i] = 0;
-
- return TRUE;
+ int i;
+ OPENFILENAME ofn;
+
+ ofn.lpstrFile = GetEnvValue("GNUPGHOME");
+ if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
+ strcpy(path, ofn.lpstrFile);
+ return TRUE;
+ }
+ ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","HomeDir");
+ if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
+ strcpy(path, ofn.lpstrFile);
+ return TRUE;
+ }
+ ofn.lpstrFile = GetEnvValue("APPDATA");
+ if ( ofn.lpstrFile ) {
+ strcat(ofn.lpstrFile,"\\gnupg");
+ if ( existsPath(ofn.lpstrFile) ) {
+ strcpy(path, ofn.lpstrFile);
+ return TRUE;
+ }
+ }
+
+ ofn.lStructSize = sizeof(ofn);
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON;
+
+ ofn.lpstrFile = path;
+ ofn.lpstrFilter = "Public key rings (pubring.gpg)\0pubring.gpg\0All files (*.*)\0*.*\0";
+ ofn.lpstrTitle = "Open Public Keyring";
+ if (!GetOpenFileName(&ofn)) return FALSE;
+
+ for(i=strlen(path);i && path[i]!='\\';i--);
+ path[i] = 0;
+
+ return TRUE;
}
diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 0e7895b09c..e5e6f51687 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -25,59 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int num_classes = 0; //for core class api support
-// isWorkstationLocked() code from core
-bool isWorkstationLocked()
-{
- if (OpenInputDesktop != NULL) {
- HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
- if (hDesk == NULL)
- return true;
- if (CloseDesktop != NULL)
- CloseDesktop(hDesk);
- }
- return false;
-}
-
-// isFullScreen() code from core
-static bool isFullScreen()
-{
- RECT rcScreen = {0};
- rcScreen.right = GetSystemMetrics(SM_CXSCREEN);
- rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN);
-
- if (MonitorFromWindow != NULL) {
- HMONITOR hMon = MonitorFromWindow(GetForegroundWindow(), MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi;
- mi.cbSize = sizeof(mi);
- if (GetMonitorInfo(hMon, &mi))
- rcScreen = mi.rcMonitor;
- }
-
- HWND hWndDesktop = GetDesktopWindow();
- HWND hWndShell = GetShellWindow();
-
- // check foregroundwindow
- HWND hWnd = GetForegroundWindow();
- if (hWnd && hWnd != hWndDesktop && hWnd != hWndShell) {
- TCHAR tszClassName[128] = _T("");
- GetClassName(hWnd, tszClassName, SIZEOF(tszClassName));
- if (_tcscmp(tszClassName, _T("WorkerW"))) {
- RECT rect, rectw, recti;
- GetWindowRect(hWnd, &rectw);
-
- GetClientRect(hWnd, &rect);
- ClientToScreen(hWnd, (LPPOINT)&rect);
- ClientToScreen(hWnd, (LPPOINT)&rect.right);
-
- if (EqualRect(&rect, &rectw) && IntersectRect(&recti, &rect, &rcScreen) &&
- EqualRect(&recti, &rcScreen))
- return true;
- }
- }
-
- return false;
-}
-
//===== Popup/AddPopup
INT_PTR Popup_AddPopup(WPARAM wParam, LPARAM lParam)
{
@@ -166,17 +113,10 @@ INT_PTR Popup_AddPopup2(WPARAM wParam, LPARAM lParam) if ( !(lParam & APF_NO_HISTORY))
PopupHistoryAdd(ppd);
- if (PopupThreadIsFull())
+ if ( PopupThreadIsFull())
return -1;
- #ifdef _DEBUG
- char temp[128];
- OutputDebugStringA("isWorkstationLocked: \t");
- OutputDebugStringA(isWorkstationLocked() ? "true":"false");
- OutputDebugStringA("\n");
- #endif
-
- if (isWorkstationLocked())
+ if ( IsWorkstationLocked())
return -1;
// Check if contact handle is valid.
@@ -192,25 +132,11 @@ INT_PTR Popup_AddPopup2(WPARAM wParam, LPARAM lParam) if (bShowMode != PU_SHOWMODE_FAVORITE) {
if (!PopupOptions.ModuleIsEnabled)
return -1;
- #ifdef _DEBUG
- _itoa(PopupOptions.DisableWhenFullscreen,temp,10);
- OutputDebugStringA("PopupOptions.DisableWhenFullscreen: \t");
- OutputDebugStringA(temp);
- OutputDebugStringA("\n");
- _itoa(bShowMode,temp,10);
- OutputDebugStringA("bShowMode: \t");
- OutputDebugStringA(temp);
- OutputDebugStringA("\n");
- OutputDebugStringA("isFullScreen: \t");
- OutputDebugStringA(isFullScreen() ? "true":"false");
- OutputDebugStringA("\n");
- #endif
-
- if (PopupOptions.DisableWhenFullscreen && (bShowMode != PU_SHOWMODE_FULLSCREEN) && isFullScreen())
+
+ if (PopupOptions.DisableWhenFullscreen && (bShowMode != PU_SHOWMODE_FULLSCREEN) && IsFullScreen())
return -1;
- if (db_get_dw(NULL, MODULNAME, LPGEN("Global Status"), 0) &
- Proto_Status2Flag_My(CallService(MS_CLIST_GETSTATUSMODE, 0, 0)))
+ if (db_get_dw(NULL, MODULNAME, LPGEN("Global Status"), 0) & Proto_Status2Flag_My(CallService(MS_CLIST_GETSTATUSMODE, 0, 0)))
return -1;
if ((disableWhen & 0x0000FFFF) & Proto_Status2Flag_My(CallService(MS_CLIST_GETSTATUSMODE, 0, 0)))
@@ -219,8 +145,7 @@ INT_PTR Popup_AddPopup2(WPARAM wParam, LPARAM lParam) if (proto) {
char prefix[128];
mir_snprintf(prefix, sizeof(prefix), LPGEN("Protocol Status") "/%s", GetContactProto(ppd->lchContact));
- if (db_get_dw(NULL, MODULNAME, prefix, 0) &
- Proto_Status2Flag_My(CallProtoService(proto, PS_GETSTATUS, 0, 0)))
+ if (db_get_dw(NULL, MODULNAME, prefix, 0) & Proto_Status2Flag_My(CallProtoService(proto, PS_GETSTATUS, 0, 0)))
return -1;
if (((disableWhen >> 16) & 0xFFFF0000) & Proto_Status2Flag_My(CallProtoService(proto, PS_GETSTATUS, 0, 0)))
return -1;
diff --git a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp index 56ae26d20d..7e372640ab 100644 --- a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp +++ b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp @@ -191,38 +191,25 @@ static int ProcessProtoAck(WPARAM wParam,LPARAM lParam) int OnAccChanged(WPARAM wParam,LPARAM lParam)
{
- PROTOACCOUNT* pa = ( PROTOACCOUNT* )lParam;
+ PROTOACCOUNT* pa = (PROTOACCOUNT*)lParam;
switch( wParam ) {
case PRAC_ADDED:
- autoAwaySettings->insert( new TAAAProtoSetting( pa ));
+ autoAwaySettings->insert( new TAAAProtoSetting(pa));
break;
case PRAC_REMOVED:
- {
- for ( int i=0; i < autoAwaySettings->getCount(); i++ ) {
- if ( !lstrcmpA( (*autoAwaySettings)[i].szName, pa->szModuleName )) {
- autoAwaySettings->remove( i );
- break;
- } } }
+ for (int i=0; i < autoAwaySettings->getCount(); i++) {
+ if ( !lstrcmpA( (*autoAwaySettings)[i].szName, pa->szModuleName )) {
+ autoAwaySettings->remove( i );
+ break;
+ }
+ }
break;
}
return 0;
}
-/* this function is from the original auto-away module */
-static BOOL IsWorkstationLocked (void)
-{
- BOOL rc = FALSE;
-
- HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
- if (hDesk == NULL)
- rc = TRUE;
- else
- CloseDesktop(hDesk);
- return rc;
-}
-
static char* status2descr( int status )
{
switch( status ) {
@@ -274,7 +261,7 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD int statusChanged = FALSE;
int confirm = FALSE;
- for ( int i=0; i < autoAwaySettings->getCount(); i++ ) {
+ for (int i=0; i < autoAwaySettings->getCount(); i++) {
TAAAProtoSetting& aas = (*autoAwaySettings)[i];
aas.status = ID_STATUS_DISABLED;
@@ -316,7 +303,8 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD aas.status = aas.lv2Status;
aas.statusChanged = statusChanged = TRUE;
changeState(aas, STATUS2_SET);
- } }
+ }
+ }
if (aas.curState == STATUS1_SET) {
if (( mouseStationaryTimer < sts1Time && !screenSaver && !locked ) && !(aas.optionFlags & FLAG_RESET )) {
@@ -337,7 +325,8 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD aas.status = aas.lv2Status;
aas.statusChanged = statusChanged = TRUE;
changeState(aas, STATUS2_SET);
- } }
+ }
+ }
if ( aas.curState == STATUS2_SET ) {
if ( mouseStationaryTimer < sts2Time && !screenSaver && !locked && ( aas.optionFlags & FLAG_RESET )) {
@@ -349,7 +338,8 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD /* Remember: after status1 is set, and "only on inactive" is NOT set, it implies !reset. */
changeState(aas, HIDDEN_ACTIVE);
aas.lastStatus = CallProtoService(aas.szName,PS_GETSTATUS,0, 0);
- } }
+ }
+ }
if ( aas.curState == HIDDEN_ACTIVE ) {
if ( aas.mStatus ) {
@@ -383,11 +373,9 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD if ( confirm || statusChanged ) {
OBJLIST<TAAAProtoSetting> ps = *autoAwaySettings;
-
- int i;
- for ( i=0; i < ps.getCount(); i++ ) {
- if ( ps[i].szMsg )
- ps[i].szMsg = _tcsdup( ps[i].szMsg );
+ for (int i=0; i < ps.getCount(); i++) {
+ if (ps[i].szMsg)
+ ps[i].szMsg = _tcsdup(ps[i].szMsg);
if (ps[i].status == ID_STATUS_DISABLED)
ps[i].szName = "";
@@ -405,15 +393,15 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD static int HookWindowsHooks(int hookMiranda, int hookAll)
{
if (hookMiranda) {
- if ( monitorKeyboard && hMirandaKeyBoardHook == NULL )
+ if (monitorKeyboard && hMirandaKeyBoardHook == NULL)
hMirandaKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD,MirandaKeyBoardHookFunction,NULL,GetCurrentThreadId());
- if ( monitorMouse && hMirandaMouseHook == NULL )
+ if (monitorMouse && hMirandaMouseHook == NULL)
hMirandaMouseHook = SetWindowsHookEx(WH_MOUSE,MirandaMouseHookFunction,NULL,GetCurrentThreadId());
}
if (hookAll) {
- if ( monitorKeyboard && hKeyBoardHook == NULL )
+ if (monitorKeyboard && hKeyBoardHook == NULL)
hKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, KeyBoardHookFunction, 0, GetCurrentThreadId());
- if ( monitorMouse && hMouseHook == NULL )
+ if (monitorMouse && hMouseHook == NULL)
hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookFunction, 0, GetCurrentThreadId());
}
@@ -428,7 +416,6 @@ static int UnhookWindowsHooks() UnhookWindowsHookEx(hMirandaKeyBoardHook);
hMouseHook = hKeyBoardHook = hMirandaMouseHook = hMirandaKeyBoardHook = NULL;
-
return 0;
}
@@ -447,7 +434,8 @@ static LRESULT CALLBACK MirandaMouseHookFunction(int code, WPARAM wParam, LPARAM if (pt.x!=lastMousePos.x || pt.y!=lastMousePos.y) {
lastMousePos = pt;
lastMirandaInput = GetTickCount();
- } }
+ }
+ }
return CallNextHookEx(hMirandaMouseHook, code, wParam, lParam);
}
@@ -455,17 +443,19 @@ static LRESULT CALLBACK MirandaMouseHookFunction(int code, WPARAM wParam, LPARAM static LRESULT CALLBACK MirandaKeyBoardHookFunction(int code, WPARAM wParam, LPARAM lParam)
{
if (code >= 0) {
- if (ignoreAltCombo) {//&& ((HIWORD(lParam)&KF_ALTDOWN) || (wParam == VK_MENU))) {
- if ( ((GetKeyState(VK_MENU) < 0) || (wParam == VK_MENU)) ||
- ((GetKeyState(VK_TAB) < 0) || (wParam == VK_TAB)) ||
- ((GetKeyState(VK_SHIFT) < 0) || (wParam == VK_SHIFT)) ||
- ((GetKeyState(VK_CONTROL) < 0) || (wParam == VK_CONTROL)) ||
- ((GetKeyState(VK_ESCAPE) < 0) || (wParam == VK_ESCAPE)) ||
- ((GetKeyState(VK_LWIN) < 0) || (wParam == VK_LWIN)) ||
- ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN))) {
+ if (ignoreAltCombo) {
+ if (((GetKeyState(VK_MENU) < 0) || (wParam == VK_MENU)) ||
+ ((GetKeyState(VK_TAB) < 0) || (wParam == VK_TAB)) ||
+ ((GetKeyState(VK_SHIFT) < 0) || (wParam == VK_SHIFT)) ||
+ ((GetKeyState(VK_CONTROL) < 0) || (wParam == VK_CONTROL)) ||
+ ((GetKeyState(VK_ESCAPE) < 0) || (wParam == VK_ESCAPE)) ||
+ ((GetKeyState(VK_LWIN) < 0) || (wParam == VK_LWIN)) ||
+ ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN)))
+ {
return CallNextHookEx(hMirandaKeyBoardHook, code, wParam, lParam);
}
}
+
switch (wParam) {
case VK_NUMLOCK:
case VK_CAPITAL:
@@ -488,7 +478,8 @@ static LRESULT CALLBACK MirandaKeyBoardHookFunction(int code, WPARAM wParam, LPA default:
lastMirandaInput = GetTickCount();
break;
- } }
+ }
+ }
return CallNextHookEx(hMirandaKeyBoardHook, code, wParam, lParam);
}
@@ -514,17 +505,19 @@ static LRESULT CALLBACK MouseHookFunction(int code, WPARAM wParam, LPARAM lParam static LRESULT CALLBACK KeyBoardHookFunction(int code, WPARAM wParam, LPARAM lParam)
{
if (code >= 0) {
- if (ignoreAltCombo) {//&& ((HIWORD(lParam)&KF_ALTDOWN) || (wParam == VK_MENU))) {
+ if (ignoreAltCombo) {
if ( ((GetKeyState(VK_MENU) < 0) || (wParam == VK_MENU)) ||
((GetKeyState(VK_TAB) < 0) || (wParam == VK_TAB)) ||
((GetKeyState(VK_SHIFT) < 0) || (wParam == VK_SHIFT)) ||
((GetKeyState(VK_CONTROL) < 0) || (wParam == VK_CONTROL)) ||
((GetKeyState(VK_ESCAPE) < 0) || (wParam == VK_ESCAPE)) ||
((GetKeyState(VK_LWIN) < 0) || (wParam == VK_LWIN)) ||
- ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN))) {
+ ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN)))
+ {
return CallNextHookEx(hKeyBoardHook, code, wParam, lParam);
}
}
+
switch (wParam) {
case VK_NUMLOCK:
case VK_CAPITAL:
@@ -547,7 +540,8 @@ static LRESULT CALLBACK KeyBoardHookFunction(int code, WPARAM wParam, LPARAM lPa default:
lastInput = GetTickCount();
break;
- } }
+ }
+ }
return CallNextHookEx(hKeyBoardHook, code, wParam, lParam);
}
diff --git a/plugins/YAPP/src/message_pump.cpp b/plugins/YAPP/src/message_pump.cpp index a08fb213f7..73dd3fbf1b 100644 --- a/plugins/YAPP/src/message_pump.cpp +++ b/plugins/YAPP/src/message_pump.cpp @@ -9,69 +9,12 @@ HANDLE hMPEvent; #define MAX_POPUPS 100
-// from popups, popup2 implementation, slightly modified
-// return true if there is a full-screen application (e.g. game) running
-bool is_full_screen() {
- int w = GetSystemMetrics(SM_CXSCREEN);
- int h = GetSystemMetrics(SM_CYSCREEN);
- // use ClientRect instead of WindowRect so that it works normally for maximized applications - thx Nikto
- RECT ClientRect;
- HWND hWnd;
-
- HWND hWndDesktop = GetDesktopWindow();
- HWND hWndShell = GetShellWindow();
-
- // check foregroundwindow
- hWnd = GetForegroundWindow();
- if (hWnd && hWnd != hWndDesktop && hWnd != hWndShell) {
- GetClientRect(hWnd, &ClientRect);
- if ((ClientRect.right - ClientRect.left) >= w && (ClientRect.bottom - ClientRect.top) >= h)
- return true;
- }
-
- // check other top level windows
- while ((hWnd = FindWindowEx(NULL, hWnd, NULL, NULL))) {
- if (IsWindowVisible(hWnd) == 0 || IsIconic(hWnd) || hWnd == hWndDesktop || hWnd == hWndShell)
- continue;
-
-// if (db_get_b(0, MODULE, "ShowForNonTopmostFullscreenWindows", 0) == 1) {
- if (!(GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST))
- continue;
-// }
-
- // not sure if this could be done more simply using 'IsZoomed'?
- GetClientRect(hWnd, &ClientRect);
- if ((ClientRect.right - ClientRect.left) < w || (ClientRect.bottom - ClientRect.top) < h)
- continue;
-
- return true;
- }
-
- return false;
-}
-
-bool is_workstation_locked()
-{
- bool rc = false;
- HDESK hDesk = OpenDesktop((TCHAR*)_T("default"), 0, FALSE, DESKTOP_SWITCHDESKTOP);
- if (hDesk != 0) {
- HDESK hDeskInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
- if (hDeskInput == 0) {
- rc = true;
- } else
- CloseDesktop(hDeskInput);
-
- CloseDesktop(hDesk);
- }
-
- return rc;
-}
-
unsigned __stdcall MessagePumpThread(void* param)
{
- if (param) SetEvent((HANDLE)param);
+ if (param)
+ SetEvent((HANDLE)param);
- MSG hwndMsg = {0};
+ MSG hwndMsg = { 0 };
while(GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) {
if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) {
switch(hwndMsg.message) {
@@ -81,22 +24,21 @@ unsigned __stdcall MessagePumpThread(void* param) int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
if (status >= ID_STATUS_OFFLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_OFFLINE])
enabled = false;
- if ((options.disable_full_screen && is_full_screen()) || is_workstation_locked())
+ if ((options.disable_full_screen && IsFullScreen()) || IsWorkstationLocked())
enabled = false;
- PopupData *pd = (PopupData *)hwndMsg.lParam;
+ PopupData *pd = (PopupData*)hwndMsg.lParam;
if (enabled && num_popups < MAX_POPUPS) {
//HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, GetDesktopWindow(), 0, hInst, (LPVOID)hwndMsg.lParam);
HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)hwndMsg.lParam);
num_popups++;
if (hwndMsg.wParam) // set notifyer handle
SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0);
- } else {
- if (pd) {
- mir_free(pd->pwzTitle);
- mir_free(pd->pwzText);
- mir_free(pd);
- }
+ }
+ else if (pd) {
+ mir_free(pd->pwzTitle);
+ mir_free(pd->pwzText);
+ mir_free(pd);
}
}
break;
@@ -112,17 +54,11 @@ unsigned __stdcall MessagePumpThread(void* param) break;
case MUM_NMUPDATE:
- {
- HANDLE hNotify = (HANDLE)hwndMsg.wParam;
- BroadcastMessage(PUM_UPDATENOTIFY, (WPARAM)hNotify, 0);
- }
+ BroadcastMessage(PUM_UPDATENOTIFY, hwndMsg.wParam, 0);
break;
case MUM_NMREMOVE:
- {
- HANDLE hNotify = (HANDLE)hwndMsg.wParam;
- BroadcastMessage(PUM_KILLNOTIFY, (WPARAM)hNotify, 0);
- }
+ BroadcastMessage(PUM_KILLNOTIFY, hwndMsg.wParam, 0);
break;
case MUM_NMAVATAR:
@@ -153,11 +89,10 @@ void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) // will post a message to the message queue which will set the hwnd value
// and then set the event...so create an event, call this function and then wait on the event
// when the event is signalled, the hwnd will be valid
-void FindWindow(PopupData *pd, HANDLE hEvent, HWND *hwnd);
void InitMessagePump()
{
- WNDCLASS popup_win_class = {0};
+ WNDCLASS popup_win_class = { 0 };
popup_win_class.lpfnWndProc = PopupWindowProc;
popup_win_class.hInstance = hInst;
popup_win_class.lpszClassName = POP_WIN_CLASS;
@@ -172,6 +107,7 @@ void InitMessagePump() CloseHandle(hMPEvent);
}
-void DeinitMessagePump() {
+void DeinitMessagePump()
+{
PostMPMessage(WM_QUIT, 0, 0);
}
diff --git a/plugins/YAPP/src/message_pump.h b/plugins/YAPP/src/message_pump.h index 6acb371080..fc3d889a0a 100644 --- a/plugins/YAPP/src/message_pump.h +++ b/plugins/YAPP/src/message_pump.h @@ -40,7 +40,6 @@ struct PopupData // will post a message to the message queue which will set the hwnd value
// and then set the event...so create an event, call this function and then wait on the event
// when the event is signalled, the hwnd will be valid
-void FindWindow(PopupData *pd, HANDLE hEvent, HWND *hwnd);
void InitMessagePump();
void DeinitMessagePump();
diff --git a/plugins/YAPP/src/notify_imp.cpp b/plugins/YAPP/src/notify_imp.cpp index 0be4fbd15f..32298027df 100644 --- a/plugins/YAPP/src/notify_imp.cpp +++ b/plugins/YAPP/src/notify_imp.cpp @@ -92,8 +92,7 @@ INT_PTR CALLBACK DlgProcPopups(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam int NotifyOptionsInitialize(WPARAM wParam,LPARAM lParam)
{
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOTIFY);
odp.pszTitle = LPGEN("YAPP Popups");
diff --git a/plugins/YAPP/src/options.cpp b/plugins/YAPP/src/options.cpp index 08e3dfce8c..497bbc4b18 100644 --- a/plugins/YAPP/src/options.cpp +++ b/plugins/YAPP/src/options.cpp @@ -111,8 +111,8 @@ void ShowExamplePopups() { }
}
-static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
-
+static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
@@ -138,7 +138,8 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (ServiceExists(MS_AV_DRAWAVATAR)) {
SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar"));
SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar"));
- } else {
+ }
+ else {
HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV);
EnableWindow(hw, FALSE);
hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE);
@@ -206,12 +207,16 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
EnableWindow(hw, FALSE);
SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, 7, FALSE);
- } else {
+ }
+ else {
CheckDlgButton(hwndDlg, IDC_RAD_TIMEOUT, TRUE);
SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE);
}
- if (options.right_icon) CheckDlgButton(hwndDlg, IDC_RAD_RIGHTICON, TRUE);
- else CheckDlgButton(hwndDlg, IDC_RAD_LEFTICON, TRUE);
+
+ if (options.right_icon)
+ CheckDlgButton(hwndDlg, IDC_RAD_RIGHTICON, TRUE);
+ else
+ CheckDlgButton(hwndDlg, IDC_RAD_LEFTICON, TRUE);
if (ServiceExists(MS_AV_DRAWAVATAR)) {
switch(options.av_layout) {
@@ -219,7 +224,8 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case PAV_RIGHT: CheckDlgButton(hwndDlg, IDC_RAD_RIGHTAV, TRUE); break;
case PAV_LEFT: CheckDlgButton(hwndDlg, IDC_RAD_LEFTAV, TRUE); break;
}
- } else {
+ }
+ else {
CheckDlgButton(hwndDlg, IDC_RAD_NOAV, TRUE);
HWND hw = GetDlgItem(hwndDlg, IDC_RAD_RIGHTAV);
EnableWindow(hw, FALSE);
@@ -255,16 +261,16 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return FALSE;
case WM_COMMAND:
- if ( HIWORD( wParam ) == CBN_SELCHANGE)
+ if ( HIWORD(wParam) == CBN_SELCHANGE)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
+ else if ( HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if ( HIWORD( wParam ) == BN_CLICKED ) {
+ else if ( HIWORD(wParam) == BN_CLICKED ) {
if (LOWORD(wParam) == IDC_BTN_PREVIEW)
ShowExamplePopups();
else {
HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
- switch( LOWORD( wParam )) {
+ switch( LOWORD(wParam)) {
case IDC_RAD_NOTIMEOUT:
EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT));
break;
@@ -283,7 +289,7 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case LVN_ITEMCHANGED:
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
break;
}
}
@@ -367,7 +373,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam return FALSE;
case WM_COMMAND:
- if ( LOWORD(wParam) == IDC_LST_CLASSES && HIWORD( wParam ) == LBN_SELCHANGE) {
+ if ( LOWORD(wParam) == IDC_LST_CLASSES && HIWORD(wParam) == LBN_SELCHANGE) {
int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_PREVIEW), index != -1);
EnableWindow(GetDlgItem(hwndDlg, IDC_COL_TEXT), index != -1);
@@ -383,7 +389,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT));
return TRUE;
}
- if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ if ( HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
if (index != -1) {
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
@@ -407,17 +413,17 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam else arNewClasses[i]->iSeconds = -1;
SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, arNewClasses[i]->iSeconds, TRUE);
}
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
break;
case IDC_COL_TEXT:
arNewClasses[i]->colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
break;
case IDC_COL_BG:
arNewClasses[i]->colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
break;
case IDC_BTN_PREVIEW:
@@ -428,7 +434,8 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam d.pwszTitle = L"Preview";
d.pwszText = L"The quick brown fox jumps over the lazy dog.";
CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
- } else {
+ }
+ else {
POPUPCLASS pc = *arNewClasses[i];
pc.PluginWindowProc = 0;
POPUPDATACLASS d = {sizeof(d), pc.pszName};
@@ -443,7 +450,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam break;
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) {
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
arClasses = arNewClasses;
char setting[256];
for (int i = 0; i < arClasses.getCount(); i++) {
@@ -483,7 +490,6 @@ int OptInit(WPARAM wParam, LPARAM lParam) odp.pszTab = LPGEN("Classes");
odp.pfnDlgProc = DlgProcOptsClasses;
Options_AddPage(wParam, &odp);
-
return 0;
}
diff --git a/plugins/YAPP/src/popwin.cpp b/plugins/YAPP/src/popwin.cpp index abb3ba2010..3112f17459 100644 --- a/plugins/YAPP/src/popwin.cpp +++ b/plugins/YAPP/src/popwin.cpp @@ -79,13 +79,11 @@ void AddWindowToStack(HWND hwnd) { RECT wa_rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa_rect, 0);
- if (options.use_mim_monitor)
- {
+ if (options.use_mim_monitor) {
RECT clr;
GetWindowRect((HWND)CallService(MS_CLUI_GETHWND, 0, 0), &clr);
HMONITOR hMonitor = MonitorFromRect(&clr, MONITOR_DEFAULTTONEAREST);
- if (hMonitor)
- {
+ if (hMonitor) {
MONITORINFO mi;
mi.cbSize = sizeof(mi);
if (GetMonitorInfo(hMonitor, &mi))
@@ -93,41 +91,40 @@ void AddWindowToStack(HWND hwnd) { }
}
- switch (options.animate)
- {
- case ANIMATE_NO:
- if (options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT)
- pop_start_x = wa_rect.right - options.win_width - 1;
- else
- pop_start_x = wa_rect.left + 1;
-
- if (options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT)
- pop_start_y = wa_rect.bottom;
- else
- pop_start_y = wa_rect.top + 1;
- break;
- case ANIMATE_HORZ:
- if (options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT)
- pop_start_x = wa_rect.right;
- else
- pop_start_x = wa_rect.left - options.win_width;
-
- if (options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT)
- pop_start_y = wa_rect.bottom;
- else
- pop_start_y = wa_rect.top + 1;
- break;
- case ANIMATE_VERT:
- if (options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT)
- pop_start_x = wa_rect.right - options.win_width - 1;
- else
- pop_start_x = wa_rect.left + 1;
-
- if (options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT)
- pop_start_y = wa_rect.bottom;
- else
- pop_start_y = wa_rect.top - height + 1;
- break;
+ switch (options.animate) {
+ case ANIMATE_NO:
+ if (options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT)
+ pop_start_x = wa_rect.right - options.win_width - 1;
+ else
+ pop_start_x = wa_rect.left + 1;
+
+ if (options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT)
+ pop_start_y = wa_rect.bottom;
+ else
+ pop_start_y = wa_rect.top + 1;
+ break;
+ case ANIMATE_HORZ:
+ if (options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT)
+ pop_start_x = wa_rect.right;
+ else
+ pop_start_x = wa_rect.left - options.win_width;
+
+ if (options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT)
+ pop_start_y = wa_rect.bottom;
+ else
+ pop_start_y = wa_rect.top + 1;
+ break;
+ case ANIMATE_VERT:
+ if (options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT)
+ pop_start_x = wa_rect.right - options.win_width - 1;
+ else
+ pop_start_x = wa_rect.left + 1;
+
+ if (options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT)
+ pop_start_y = wa_rect.bottom;
+ else
+ pop_start_y = wa_rect.top - height + 1;
+ break;
}
SetWindowPos(hwnd, 0, pop_start_x, pop_start_y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
@@ -159,9 +156,7 @@ void RemoveWindowFromStack(HWND hwnd) // Если после удаления в стеке остались окна, то нужно провести сжатие:
// сдвинуть все окна к верхнему/нижнему краю экрана.
if (hwnd_stack_top)
- {
RepositionWindows();
- }
}
void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -244,16 +239,13 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pwd);
- if (pd->timeout == -1 || (pd->timeout == 0 && options.default_timeout == -1)) {
- // make a really long timeout - say 7 days? ;)
+ // make a really long timeout - say 7 days? ;)
+ if (pd->timeout == -1 || (pd->timeout == 0 && options.default_timeout == -1))
SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0);
- } else {
- if (pd->timeout == 0) {
- SetTimer(hwnd, ID_CLOSETIMER, options.default_timeout * 1000, 0);
- } else {
- SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
- }
- }
+ else if (pd->timeout == 0)
+ SetTimer(hwnd, ID_CLOSETIMER, options.default_timeout * 1000, 0);
+ else
+ SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
AddWindowToStack(hwnd); // this updates our size
}
@@ -311,7 +303,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa PostMessage(hwnd, UM_DESTROYPOPUP, 0, 0);
}
return TRUE;
- } else if (wParam == ID_MOVETIMER) {
+ }
+
+ if (wParam == ID_MOVETIMER) {
RECT r;
GetWindowRect(hwnd, &r);
@@ -333,6 +327,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa return TRUE;
}
break;
+
case WM_ERASEBKGND:
{
HDC hdc = (HDC) wParam;
@@ -364,9 +359,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa SelectObject(hdc, hOldBrush);
SelectObject(hdc, hOldPen);
}
-
}
return TRUE;
+
case WM_PAINT:
{
RECT r;
@@ -388,7 +383,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa else if (pwd->have_av) avr.right = avr.left + pwd->real_av_width;
else avr.right = avr.left + pwd->time_width;
r.left = avr.right;
- } else if (options.av_layout == PAV_RIGHT) {
+ }
+ else if (options.av_layout == PAV_RIGHT) {
avr.right = r.right - options.av_padding;
if (pwd->have_av && options.time_layout == PT_WITHAV) avr.left = avr.right - max(pwd->real_av_width, pwd->time_width);
else if (pwd->have_av) avr.left = avr.right - pwd->real_av_width;
@@ -432,7 +428,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa if (options.right_icon) {
iconx = r.right - (16 + options.padding);
textxmax -= 16 + options.padding;
- } else {
+ }
+ else {
iconx = r.left + options.padding;
textxmin += 16 + options.padding;
}
@@ -457,8 +454,6 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa textxmax -= pwd->time_width + options.padding;
DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
break;
- default:
- break;
}
}
@@ -535,11 +530,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa HRGN hRgn1;
RECT r;
- int v,h;
- int w=11;
+ int w = 11;
GetWindowRect(hwnd,&r);
- h=(r.right-r.left)>(w*2)?w:(r.right-r.left);
- v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top);
+ int h = (r.right-r.left) > (w*2)?w:(r.right-r.left);
+ int v = (r.bottom-r.top) > (w*2)?w:(r.bottom-r.top);
h=(h<v)?h:v;
hRgn1=CreateRoundRectRgn(0,0,(r.right-r.left) + 1,(r.bottom-r.top) + 1,h,h);
SetWindowRgn(hwnd,hRgn1,FALSE);
@@ -552,7 +546,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa pwd->new_x = (int)wParam;
pwd->new_y = (int)lParam;
SetTimer(hwnd, ID_MOVETIMER, 10, 0);
- } else {
+ }
+ else {
SetWindowPos(hwnd, 0, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
if (!IsWindowVisible(hwnd)) {
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
@@ -569,15 +564,16 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa case PUM_GETCONTACT:
{
- HANDLE *phContact = (HANDLE *)wParam;
+ HANDLE *phContact = (HANDLE*)wParam;
*phContact = pd->hContact;
- if (lParam) SetEvent((HANDLE)lParam);
+ if (lParam)
+ SetEvent((HANDLE)lParam);
}
return TRUE;
case PUM_GETHEIGHT:
{
- int *pHeight = (int *)wParam;
+ int *pHeight = (int*)wParam;
HDC hdc = GetDC(hwnd);
SIZE size;
HFONT hOldFont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
@@ -675,16 +671,13 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa }
pwd->pd = pd = (PopupData *)lParam;
- if (pd->timeout != -1) {
- if (pd->timeout == 0) {
- SetTimer(hwnd, ID_CLOSETIMER, 7 * 1000, 0);
- } else {
- SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
- }
- } else {
- // make a really long timeout - say 7 days? ;)
+ // make a really long timeout - say 7 days? ;)
+ if (pd->timeout == -1)
SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0);
- }
+ else if (pd->timeout == 0)
+ SetTimer(hwnd, ID_CLOSETIMER, 7 * 1000, 0);
+ else
+ SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
InvalidateRect(hwnd, 0, TRUE);
RepositionWindows();
@@ -714,8 +707,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa InvalidateRect(hwnd, 0, TRUE);
RepositionWindows();
}
-
return TRUE;
+
case PUM_KILLNOTIFY:
if (pwd->hNotify != (HANDLE)wParam)
return TRUE;
|