diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/AssocMgr/src/assoclist.cpp | 853 | ||||
-rw-r--r-- | plugins/AvatarHistory/src/popup.cpp | 1 | ||||
-rw-r--r-- | plugins/BASS_interface/src/Main.cpp | 93 | ||||
-rw-r--r-- | plugins/CSList/src/cslist.cpp | 4 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/ui.cpp | 4 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/UMainForm.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/containeroptions.cpp | 4 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ctrl_contact.cpp | 2 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp | 3 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp | 64 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/psp_base.cpp | 7 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/svc_refreshci.cpp | 19 | ||||
-rw-r--r-- | plugins/Utils/mir_options.cpp | 60 | ||||
-rw-r--r-- | plugins/YAMN/src/browser/mailbrowser.cpp | 2003 |
14 files changed, 1503 insertions, 1616 deletions
diff --git a/plugins/AssocMgr/src/assoclist.cpp b/plugins/AssocMgr/src/assoclist.cpp index 5075e719ed..44f27182e1 100644 --- a/plugins/AssocMgr/src/assoclist.cpp +++ b/plugins/AssocMgr/src/assoclist.cpp @@ -21,28 +21,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/* Options */
+// Options
extern HINSTANCE hInst;
static HANDLE hHookOptInit;
-/* Services */
+// Services
static HANDLE hServiceAddFile, hServiceRemoveFile, hServiceAddUrl, hServiceRemoveUrl;
/************************* Assoc List *****************************/
-typedef struct {
- char *pszClassName; /* class name as used in registry and db */
+typedef struct
+{
+ char *pszClassName; // class name as used in registry and db
TCHAR *pszDescription;
- HINSTANCE hInstance; /* allowed to be NULL for miranda32.exe */
+ HINSTANCE hInstance; // allowed to be NULL for miranda32.exe
WORD nIconResID;
char *pszService;
- WORD flags; /* set of FTDF_* and UTDF_* flags */
- char *pszFileExt; /* file type: NULL for url type*/
- char *pszMimeType; /* file type: allowed to be NULL */
- TCHAR *pszVerbDesc; /* file type: allowed to be NULL */
+ WORD flags; // set of FTDF_* and UTDF_* flags
+ char *pszFileExt; // file type: NULL for url type
+ char *pszMimeType; // file type: allowed to be NULL
+ TCHAR *pszVerbDesc; // file type: allowed to be NULL
} ASSOCDATA;
-static ASSOCDATA *pAssocList; /* protected by csAssocList */
-static int nAssocListCount; /* protected by csAssocList */
+static ASSOCDATA *pAssocList; // protected by csAssocList
+static int nAssocListCount; // protected by csAssocList
static mir_cs csAssocList;
/************************* Assoc Enabled **************************/
@@ -51,7 +52,7 @@ static BOOL IsAssocEnabled(const ASSOCDATA *assoc) {
char szSetting[MAXMODULELABELLENGTH];
mir_snprintf(szSetting, "enabled_%s", assoc->pszClassName);
- return db_get_b(NULL, "AssocMgr", szSetting, (BYTE)!(assoc->flags&FTDF_DEFAULTDISABLED))!= 0;
+ return db_get_b(NULL, "AssocMgr", szSetting, (BYTE)!(assoc->flags&FTDF_DEFAULTDISABLED)) != 0;
}
static void SetAssocEnabled(const ASSOCDATA *assoc, BOOL fEnabled)
@@ -60,10 +61,10 @@ static void SetAssocEnabled(const ASSOCDATA *assoc, BOOL fEnabled) TCHAR szDLL[MAX_PATH], szBuf[MAX_PATH];
mir_snprintf(szSetting, "enabled_%s", assoc->pszClassName);
db_set_b(NULL, "AssocMgr", szSetting, (BYTE)fEnabled);
- /* dll name for uninstall */
- if(assoc->hInstance!= NULL && assoc->hInstance!= hInst && assoc->hInstance!= GetModuleHandle(NULL))
- if( GetModuleFileName(assoc->hInstance, szBuf, _countof(szBuf)))
- if( PathToRelativeT(szBuf, szDLL)) {
+ // dll name for uninstall
+ if (assoc->hInstance != NULL && assoc->hInstance != hInst && assoc->hInstance != GetModuleHandle(NULL))
+ if (GetModuleFileName(assoc->hInstance, szBuf, _countof(szBuf)))
+ if (PathToRelativeT(szBuf, szDLL)) {
mir_snprintf(szSetting, "module_%s", assoc->pszClassName);
db_set_ts(NULL, "AssocMgr", szSetting, szDLL);
}
@@ -74,7 +75,7 @@ static void DeleteAssocEnabledSetting(const ASSOCDATA *assoc) char szSetting[MAXMODULELABELLENGTH];
mir_snprintf(szSetting, "enabled_%s", assoc->pszClassName);
db_unset(NULL, "AssocMgr", szSetting);
- /* dll name for uninstall */
+ // dll name for uninstall
mir_snprintf(szSetting, "module_%s", assoc->pszClassName);
db_unset(NULL, "AssocMgr", szSetting);
}
@@ -89,26 +90,27 @@ void CleanupAssocEnabledSettings(void) TCHAR szDLL[MAX_PATH];
char szSetting[MAXMODULELABELLENGTH];
- /* delete old enabled_* settings if associated plugin no longer present */
- if(EnumDbPrefixSettings("AssocMgr", "enabled_", &ppszSettings, &nSettingsCount)) {
+ // delete old enabled_* settings if associated plugin no longer present
+ if (EnumDbPrefixSettings("AssocMgr", "enabled_", &ppszSettings, &nSettingsCount)) {
mir_cslock lck(csAssocList);
- for(i = 0;i<nSettingsCount;++i) {
+ for (i = 0; i < nSettingsCount; ++i) {
pszSuffix = &ppszSettings[i][8];
mir_snprintf(szSetting, "module_%s", pszSuffix);
if (!db_get_ts(NULL, "AssocMgr", szSetting, &dbv)) {
- if( PathToAbsoluteT(dbv.ptszVal, szDLL)) {
- /* file still exists? */
+ if (PathToAbsoluteT(dbv.ptszVal, szDLL)) {
+ // file still exists?
hFile = CreateFile(szDLL, 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
- if(hFile == INVALID_HANDLE_VALUE) {
+ if (hFile == INVALID_HANDLE_VALUE) {
db_unset(NULL, "AssocMgr", ppszSettings[i]);
db_unset(NULL, "AssocMgr", szSetting);
- } else CloseHandle(hFile);
+ }
+ else CloseHandle(hFile);
}
mir_free(dbv.ptszVal);
}
mir_free(ppszSettings[i]);
}
- mir_free(ppszSettings); /* does NULL check */
+ mir_free(ppszSettings); // does NULL check
}
}
@@ -118,7 +120,7 @@ static __inline void RememberMimeTypeAdded(const char *pszMimeType, const char * {
char szSetting[MAXMODULELABELLENGTH];
mir_snprintf(szSetting, "mime_%s", pszMimeType);
- if(fAdded) db_set_s(NULL, "AssocMgr", szSetting, pszFileExt);
+ if (fAdded) db_set_s(NULL, "AssocMgr", szSetting, pszFileExt);
else db_unset(NULL, "AssocMgr", szSetting);
}
@@ -140,17 +142,17 @@ void CleanupMimeTypeAddedSettings(void) DBVARIANT dbv;
int i, j;
- /* delete old mime_* settings and unregister the associated mime type */
- if(EnumDbPrefixSettings("AssocMgr", "mime_", &ppszSettings, &nSettingsCount)) {
+ // delete old mime_* settings and unregister the associated mime type
+ if (EnumDbPrefixSettings("AssocMgr", "mime_", &ppszSettings, &nSettingsCount)) {
mir_cslock lck(csAssocList);
- for(i = 0;i<nSettingsCount;++i) {
+ for (i = 0; i < nSettingsCount; ++i) {
pszSuffix = &ppszSettings[i][5];
- for(j = 0;j<nAssocListCount;++j)
+ for (j = 0; j < nAssocListCount; ++j)
if (!mir_strcmp(pszSuffix, pAssocList[j].pszMimeType))
- break; /* mime type in current list */
- if(j == nAssocListCount) { /* mime type not in current list */
+ break; // mime type in current list
+ if (j == nAssocListCount) { // mime type not in current list
if (!db_get(NULL, "AssocMgr", ppszSettings[i], &dbv)) {
- if(dbv.type == DBVT_ASCIIZ)
+ if (dbv.type == DBVT_ASCIIZ)
RemoveRegMimeType(pszSuffix, dbv.pszVal);
db_free(&dbv);
}
@@ -164,28 +166,28 @@ void CleanupMimeTypeAddedSettings(void) /************************* Shell Notify ***************************/
-#define SHELLNOTIFY_DELAY 3000 /* time for which assoc changes are buffered */
+#define SHELLNOTIFY_DELAY 3000 // time for which assoc changes are buffered
-static UINT nNotifyTimerID; /* protected by csNotifyTimer */
+static UINT nNotifyTimerID; // protected by csNotifyTimer
static mir_cs csNotifyTimer;
static void CALLBACK NotifyTimerProc(HWND hwnd, UINT, UINT_PTR nTimerID, DWORD)
{
mir_cslock lck(csNotifyTimer);
KillTimer(hwnd, nTimerID);
- if(nNotifyTimerID == nTimerID) /* might be stopped previously */
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST|SHCNF_FLUSHNOWAIT, NULL, NULL);
+ if (nNotifyTimerID == nTimerID) // might be stopped previously
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, NULL, NULL);
nNotifyTimerID = 0;
}
static void NotifyAssocChange(BOOL fNow)
{
mir_cslock lck(csNotifyTimer);
- if(fNow) {
- nNotifyTimerID = 0; /* stop previous timer */
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST|SHCNF_FLUSH, NULL, NULL);
+ if (fNow) {
+ nNotifyTimerID = 0; // stop previous timer
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSH, NULL, NULL);
}
- else nNotifyTimerID = SetTimer(NULL, nNotifyTimerID, SHELLNOTIFY_DELAY, NotifyTimerProc);
+ else nNotifyTimerID = SetTimer(NULL, nNotifyTimerID, SHELLNOTIFY_DELAY, NotifyTimerProc);
}
/************************* Assoc List Utils ***********************/
@@ -194,7 +196,7 @@ static void NotifyAssocChange(BOOL fNow) static int FindAssocItem(const char *pszClassName)
{
int i;
- for(i = 0;i<nAssocListCount;++i)
+ for (i = 0; i < nAssocListCount; ++i)
if (!mir_strcmp(pszClassName, pAssocList[i].pszClassName))
return i;
return -1;
@@ -205,7 +207,7 @@ BOOL IsRegisteredAssocItem(const char *pszClassName) int index;
mir_cslock lck(csAssocList);
index = FindAssocItem(pszClassName);
- return index!= -1;
+ return index != -1;
}
@@ -214,7 +216,7 @@ static ASSOCDATA* CopyAssocItem(const ASSOCDATA *assoc) {
ASSOCDATA *assoc2;
assoc2 = (ASSOCDATA*)mir_alloc(sizeof(ASSOCDATA));
- if(assoc2 == NULL) return NULL;
+ if (assoc2 == NULL) return NULL;
assoc2->pszClassName = mir_strdup(assoc->pszClassName);
assoc2->pszDescription = mir_tstrdup(assoc->pszDescription);
assoc2->hInstance = assoc->hInstance;
@@ -224,14 +226,14 @@ static ASSOCDATA* CopyAssocItem(const ASSOCDATA *assoc) assoc2->pszFileExt = mir_strdup(assoc->pszFileExt);
assoc2->pszMimeType = mir_strdup(assoc->pszMimeType);
assoc2->pszVerbDesc = mir_tstrdup(assoc->pszVerbDesc);
- if(assoc2->pszClassName == NULL || assoc2->pszDescription == NULL ||
- (assoc2->pszFileExt == NULL && assoc->pszFileExt!= NULL)) {
- mir_free(assoc2->pszClassName); /* does NULL check */
- mir_free(assoc2->pszDescription); /* does NULL check */
- mir_free(assoc2->pszService); /* does NULL check */
- mir_free(assoc2->pszFileExt); /* does NULL check */
- mir_free(assoc2->pszMimeType); /* does NULL check */
- mir_free(assoc2->pszVerbDesc); /* does NULL check */
+ if (assoc2->pszClassName == NULL || assoc2->pszDescription == NULL ||
+ (assoc2->pszFileExt == NULL && assoc->pszFileExt != NULL)) {
+ mir_free(assoc2->pszClassName); // does NULL check
+ mir_free(assoc2->pszDescription); // does NULL check
+ mir_free(assoc2->pszService); // does NULL check
+ mir_free(assoc2->pszFileExt); // does NULL check
+ mir_free(assoc2->pszMimeType); // does NULL check
+ mir_free(assoc2->pszVerbDesc); // does NULL check
mir_free(assoc2);
return NULL;
}
@@ -244,17 +246,17 @@ static int ReplaceImageListAssocIcon(HIMAGELIST himl, const ASSOCDATA *assoc, in {
HICON hIcon = NULL;
int index;
- if(himl == NULL) return -1;
+ if (himl == NULL) return -1;
- /* load icon */
+ // load icon
hIcon = LoadRegClassSmallIcon(assoc->pszClassName);
- if(hIcon == NULL) {
+ if (hIcon == NULL) {
SHFILEINFOA sfi;
- if(SHGetFileInfoA((assoc->pszFileExt!= NULL)?assoc->pszFileExt:"", FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_USEFILEATTRIBUTES))
- hIcon = sfi.hIcon; /* WinXP: this icon is not updated until the process exits */
+ if (SHGetFileInfoA((assoc->pszFileExt != NULL) ? assoc->pszFileExt : "", FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES))
+ hIcon = sfi.hIcon; // WinXP: this icon is not updated until the process exits
}
- /* add icon */
- if(hIcon == NULL) return -1;
+ // add icon
+ if (hIcon == NULL) return -1;
index = ImageList_ReplaceIcon(himl, iPrevIndex, hIcon);
DestroyIcon(hIcon);
return index;
@@ -265,7 +267,7 @@ static int ReplaceImageListAssocIcon(HIMAGELIST himl, const ASSOCDATA *assoc, in static TCHAR* GetAssocTypeDesc(const ASSOCDATA *assoc)
{
static TCHAR szDesc[32];
- if(assoc->pszFileExt == NULL)
+ if (assoc->pszFileExt == NULL)
mir_sntprintf(szDesc, _countof(szDesc), _T("%hs:"), assoc->pszClassName);
else
mir_sntprintf(szDesc, _countof(szDesc), TranslateT("%hs files"), assoc->pszFileExt);
@@ -280,12 +282,12 @@ static BOOL IsAssocRegistered(const ASSOCDATA *assoc) fIsUrl = (assoc->pszFileExt == NULL);
fUseMainCmdLine = (assoc->pszService == NULL);
- /* class */
+ // class
TCHAR *pszRunCmd = MakeRunCommand(fUseMainCmdLine, !fUseMainCmdLine);
- if(pszRunCmd!= NULL)
+ if (pszRunCmd != NULL)
fSuccess = IsRegClass(assoc->pszClassName, pszRunCmd);
- mir_free(pszRunCmd); /* does NULL check */
- /* file ext */
+ mir_free(pszRunCmd); // does NULL check
+ // file ext
if (!fIsUrl)
fSuccess = IsRegFileExt(assoc->pszFileExt, assoc->pszClassName);
@@ -303,32 +305,32 @@ static BOOL EnsureAssocRegistered(const ASSOCDATA *assoc) fUseMainCmdLine = (assoc->pszService == NULL);
pszRunCmd = MakeRunCommand(fUseMainCmdLine, !fUseMainCmdLine);
- if(pszRunCmd!= NULL) {
- fSuccess = TRUE; /* tentatively */
- /* do not overwrite user customized settings */
+ if (pszRunCmd != NULL) {
+ fSuccess = TRUE; // tentatively
+ // do not overwrite user customized settings
if (!IsRegClass(assoc->pszClassName, pszRunCmd)) {
- /* class icon */
- if (!assoc->nIconResID && fIsUrl) pszIconLoc = MakeIconLocation(NULL, 0); /* miranda logo */
- else if (!assoc->nIconResID) pszIconLoc = MakeIconLocation(hInst, IDI_MIRANDAFILE); /* generic file */
+ // class icon
+ if (!assoc->nIconResID && fIsUrl) pszIconLoc = MakeIconLocation(NULL, 0); // miranda logo
+ else if (!assoc->nIconResID) pszIconLoc = MakeIconLocation(hInst, IDI_MIRANDAFILE); // generic file
else pszIconLoc = MakeIconLocation(assoc->hInstance, assoc->nIconResID);
- /* register class */
- if(fUseMainCmdLine) pszDdeCmd = NULL;
- else pszDdeCmd = fIsUrl?DDEURLCMD:DDEFILECMD;
+ // register class
+ if (fUseMainCmdLine) pszDdeCmd = NULL;
+ else pszDdeCmd = fIsUrl ? DDEURLCMD : DDEFILECMD;
fSuccess = AddRegClass(assoc->pszClassName, assoc->pszDescription, pszIconLoc, _T(MIRANDANAME), pszRunCmd, pszDdeCmd, DDEAPP, DDETOPIC, assoc->pszVerbDesc, assoc->flags&FTDF_BROWSERAUTOOPEN, fIsUrl, assoc->flags&FTDF_ISSHORTCUT);
- mir_free(pszIconLoc); /* does NULL check */
- /* file type */
- if(fSuccess && !fIsUrl) {
- /* register mime type */
- if(assoc->pszMimeType!= NULL)
- if(AddRegMimeType(assoc->pszMimeType, assoc->pszFileExt))
+ mir_free(pszIconLoc); // does NULL check
+ // file type
+ if (fSuccess && !fIsUrl) {
+ // register mime type
+ if (assoc->pszMimeType != NULL)
+ if (AddRegMimeType(assoc->pszMimeType, assoc->pszFileExt))
RememberMimeTypeAdded(assoc->pszMimeType, assoc->pszFileExt, TRUE);
- /* register file ext */
+ // register file ext
fSuccess = AddRegFileExt(assoc->pszFileExt, assoc->pszClassName, assoc->pszMimeType, assoc->flags&FTDF_ISTEXT);
- /* register open-with */
+ // register open-with
pszAppFileName = MakeAppFileName(fUseMainCmdLine);
- if(pszAppFileName!= NULL)
+ if (pszAppFileName != NULL)
AddRegOpenWithExtEntry(pszAppFileName, assoc->pszFileExt, assoc->pszDescription);
- mir_free(pszAppFileName); /* does NULL check */
+ mir_free(pszAppFileName); // does NULL check
}
}
mir_free(pszRunCmd);
@@ -347,40 +349,41 @@ static BOOL UnregisterAssoc(const ASSOCDATA *assoc) fIsUrl = (assoc->pszFileExt == NULL);
fUseMainCmdLine = (assoc->pszService == NULL);
- /* class might have been registered by another instance */
+ // class might have been registered by another instance
TCHAR *pszRunCmd = MakeRunCommand(fUseMainCmdLine, !fUseMainCmdLine);
- if(pszRunCmd!= NULL && !IsRegClass(assoc->pszClassName, pszRunCmd)) {
+ if (pszRunCmd != NULL && !IsRegClass(assoc->pszClassName, pszRunCmd)) {
mir_free(pszRunCmd);
- return TRUE; /* succeed anyway */
+ return TRUE; // succeed anyway
}
- mir_free(pszRunCmd); /* does NULL check */
+ mir_free(pszRunCmd); // does NULL check
- /* file type */
+ // file type
if (!fIsUrl) {
- /* file extension */
+ // file extension
RemoveRegFileExt(assoc->pszFileExt, assoc->pszClassName);
- /* mime type */
- if(assoc->pszMimeType!= NULL)
- if(WasMimeTypeAdded(assoc->pszMimeType)) {
+ // mime type
+ if (assoc->pszMimeType != NULL)
+ if (WasMimeTypeAdded(assoc->pszMimeType)) {
RemoveRegMimeType(assoc->pszMimeType, assoc->pszFileExt);
RememberMimeTypeAdded(assoc->pszMimeType, assoc->pszFileExt, FALSE);
}
- /* open-with entry */
+ // open-with entry
pszAppFileName = MakeAppFileName(fUseMainCmdLine);
- if(pszAppFileName!= NULL)
+ if (pszAppFileName != NULL)
RemoveRegOpenWithExtEntry(pszAppFileName, assoc->pszFileExt);
- mir_free(pszAppFileName); /* does NULL check */
+ mir_free(pszAppFileName); // does NULL check
}
return RemoveRegClass(assoc->pszClassName);
}
/************************* Assoc List Workers *********************/
+// this structure represents the head of both
+// * FILETYPEDESC and URLTYPEDESC structures.
+// * the head is identical for both structures.
-/* this structure represents the head of both
- * FILETYPEDESC and URLTYPEDESC structures.
- * the head is identical for both structures. */
-typedef struct {
- int cbSize; /* either sizeof(FILETYPEDESC) or sizeof(URLTYPEDESC) */
+typedef struct
+{
+ int cbSize; // either sizeof(FILETYPEDESC) or sizeof(URLTYPEDESC)
const void *pszDescription;
HINSTANCE hInstance;
UINT nIconResID;
@@ -393,41 +396,41 @@ typedef struct { static BOOL AddNewAssocItem_Worker(char *pszClassName, const TYPEDESCHEAD *tdh, char *pszFileExt, TCHAR *pszVerbDesc, char *pszMimeType)
{
ASSOCDATA *pAssocListBuf, *assoc;
-
- /* is already in list? */
+
+ // is already in list?
mir_cslock lck(csAssocList);
int index = FindAssocItem(pszClassName);
- if(index!= -1) return FALSE;
+ if (index != -1) return FALSE;
- /* resize storage array */
- pAssocListBuf = (ASSOCDATA*)mir_realloc(pAssocList, (nAssocListCount+1)*sizeof(ASSOCDATA));
- if(pAssocListBuf == NULL)
+ // resize storage array
+ pAssocListBuf = (ASSOCDATA*)mir_realloc(pAssocList, (nAssocListCount + 1)*sizeof(ASSOCDATA));
+ if (pAssocListBuf == NULL)
return FALSE;
pAssocList = pAssocListBuf;
-
- /* init new item */
+
+ // init new item
assoc = &pAssocList[nAssocListCount];
- assoc->pszClassName = pszClassName; /* no dup here */
- assoc->pszDescription = s2t(tdh->pszDescription, tdh->flags&FTDF_UNICODE, TRUE); /* does NULL check */
- assoc->hInstance = tdh->hInstance; /* hInstance is allowed to be NULL for miranda32.exe */
- assoc->nIconResID = (WORD)tdh->nIconResID; /* default icon selected later on */
- assoc->pszService = mir_strdup(tdh->pszService); /* does NULL check */
+ assoc->pszClassName = pszClassName; // no dup here
+ assoc->pszDescription = s2t(tdh->pszDescription, tdh->flags&FTDF_UNICODE, TRUE); // does NULL check
+ assoc->hInstance = tdh->hInstance; // hInstance is allowed to be NULL for miranda32.exe
+ assoc->nIconResID = (WORD)tdh->nIconResID; // default icon selected later on
+ assoc->pszService = mir_strdup(tdh->pszService); // does NULL check
assoc->flags = (WORD)tdh->flags;
assoc->pszFileExt = pszFileExt;
assoc->pszMimeType = pszMimeType;
assoc->pszVerbDesc = pszVerbDesc;
- /* error check */
- if(assoc->pszDescription == NULL || (assoc->pszService == NULL && tdh->pszService!= NULL)) {
- mir_free(assoc->pszService); /* does NULL check */
- mir_free(assoc->pszDescription); /* does NULL check */
+ // error check
+ if (assoc->pszDescription == NULL || (assoc->pszService == NULL && tdh->pszService != NULL)) {
+ mir_free(assoc->pszService); // does NULL check
+ mir_free(assoc->pszDescription); // does NULL check
return FALSE;
}
- /* add registry keys */
- if(IsAssocEnabled(assoc))
+ // add registry keys
+ if (IsAssocEnabled(assoc))
EnsureAssocRegistered(assoc);
-
+
++nAssocListCount;
NotifyAssocChange(FALSE);
return TRUE;
@@ -438,32 +441,32 @@ static BOOL RemoveAssocItem_Worker(const char *pszClassName) {
ASSOCDATA *pAssocListBuf, *assoc;
- /* find index */
+ // find index
mir_cslock lck(csAssocList);
int index = FindAssocItem(pszClassName);
- if(index == -1)
+ if (index == -1)
return FALSE;
assoc = &pAssocList[index];
- /* delete registry keys and db setting */
+ // delete registry keys and db setting
UnregisterAssoc(assoc);
- if(assoc->pszMimeType!= NULL)
+ if (assoc->pszMimeType != NULL)
RememberMimeTypeAdded(assoc->pszMimeType, assoc->pszFileExt, FALSE);
DeleteAssocEnabledSetting(assoc);
- /* free memory */
+ // free memory
mir_free(assoc->pszClassName);
mir_free(assoc->pszDescription);
mir_free(assoc->pszService);
- mir_free(assoc->pszFileExt); /* does NULL check */
- mir_free(assoc->pszVerbDesc); /* does NULL check */
- mir_free(assoc->pszMimeType); /* does NULL check */
-
- /* resize storage array */
- if ((index+1)<nAssocListCount)
- memmove(assoc, &pAssocList[index+1], ((nAssocListCount-index-1)*sizeof(ASSOCDATA)));
- pAssocListBuf = (ASSOCDATA*)mir_realloc(pAssocList, (nAssocListCount-1)*sizeof(ASSOCDATA));
- if(pAssocListBuf!= NULL) pAssocList = pAssocListBuf;
+ mir_free(assoc->pszFileExt); // does NULL check
+ mir_free(assoc->pszVerbDesc); // does NULL check
+ mir_free(assoc->pszMimeType); // does NULL check
+
+ // resize storage array
+ if ((index + 1) < nAssocListCount)
+ memmove(assoc, &pAssocList[index + 1], ((nAssocListCount - index - 1)*sizeof(ASSOCDATA)));
+ pAssocListBuf = (ASSOCDATA*)mir_realloc(pAssocList, (nAssocListCount - 1)*sizeof(ASSOCDATA));
+ if (pAssocListBuf != NULL) pAssocList = pAssocListBuf;
--nAssocListCount;
NotifyAssocChange(FALSE);
@@ -475,23 +478,23 @@ static BOOL RemoveAssocItem_Worker(const char *pszClassName) static INT_PTR ServiceAddNewFileType(WPARAM, LPARAM lParam)
{
const FILETYPEDESC *ftd = (FILETYPEDESC*)lParam;
- if(ftd->cbSize < sizeof(FILETYPEDESC))
+ if (ftd->cbSize < sizeof(FILETYPEDESC))
return 1;
- if(ftd->pszFileExt == NULL || ftd->pszFileExt[0] != '.')
+ if (ftd->pszFileExt == NULL || ftd->pszFileExt[0] != '.')
return 2;
char *pszFileExt = mir_strdup(ftd->pszFileExt);
char *pszClassName = MakeFileClassName(ftd->pszFileExt);
- if(pszFileExt!= NULL && pszClassName!= NULL) {
- TCHAR *pszVerbDesc = s2t(ftd->ptszVerbDesc, ftd->flags&FTDF_UNICODE, TRUE); /* does NULL check */
- char *pszMimeType = mir_strdup(ftd->pszMimeType); /* does NULL check */
- if(AddNewAssocItem_Worker(pszClassName, (TYPEDESCHEAD*)ftd, pszFileExt, pszVerbDesc, pszMimeType))
- /* no need to free pszClassName, pszFileExt, pszVerbDesc and pszMimeType,
- * as their ownership got transfered to storage list */
+ if (pszFileExt != NULL && pszClassName != NULL) {
+ TCHAR *pszVerbDesc = s2t(ftd->ptszVerbDesc, ftd->flags&FTDF_UNICODE, TRUE); // does NULL check
+ char *pszMimeType = mir_strdup(ftd->pszMimeType); // does NULL check
+ if (AddNewAssocItem_Worker(pszClassName, (TYPEDESCHEAD*)ftd, pszFileExt, pszVerbDesc, pszMimeType))
+ // no need to free pszClassName, pszFileExt, pszVerbDesc and pszMimeType,
+ // as their ownership got transfered to storage list
return 0;
}
- mir_free(pszClassName); /* does NULL check */
- mir_free(pszFileExt); /* does NULL check */
+ mir_free(pszClassName); // does NULL check
+ mir_free(pszFileExt); // does NULL check
return 3;
}
@@ -499,12 +502,12 @@ static INT_PTR ServiceRemoveFileType(WPARAM, LPARAM lParam) {
if ((char*)lParam == NULL) return 2;
char *pszClassName = MakeFileClassName((char*)lParam);
- if(pszClassName!= NULL)
- if(RemoveAssocItem_Worker(pszClassName)) {
+ if (pszClassName != NULL)
+ if (RemoveAssocItem_Worker(pszClassName)) {
mir_free(pszClassName);
return 0;
}
- mir_free(pszClassName); /* does NULL check */
+ mir_free(pszClassName); // does NULL check
return 3;
}
@@ -512,20 +515,19 @@ static INT_PTR ServiceAddNewUrlType(WPARAM, LPARAM lParam) {
const URLTYPEDESC *utd = (URLTYPEDESC*)lParam;
- if(utd->cbSize < sizeof(URLTYPEDESC))
+ if (utd->cbSize < sizeof(URLTYPEDESC))
return 1;
- if(utd->pszService == NULL)
+ if (utd->pszService == NULL)
return 2;
- if(utd->pszProtoPrefix == NULL || utd->pszProtoPrefix[mir_strlen(utd->pszProtoPrefix)-1]!= ':')
+ if (utd->pszProtoPrefix == NULL || utd->pszProtoPrefix[mir_strlen(utd->pszProtoPrefix) - 1] != ':')
return 2;
char *pszClassName = MakeUrlClassName(utd->pszProtoPrefix);
- if(pszClassName!= NULL)
- if(AddNewAssocItem_Worker(pszClassName, (TYPEDESCHEAD*)utd, NULL, NULL, NULL))
- /* no need to free pszClassName, as its
- * ownership got transfered to storage list */
+ if (pszClassName != NULL)
+ if (AddNewAssocItem_Worker(pszClassName, (TYPEDESCHEAD*)utd, NULL, NULL, NULL))
+ // no need to free pszClassName, as its ownership got transferred to storage list
return 0;
- mir_free(pszClassName); /* does NULL check */
+ mir_free(pszClassName); // does NULL check
return 3;
}
@@ -533,12 +535,12 @@ static INT_PTR ServiceRemoveUrlType(WPARAM, LPARAM lParam) {
if ((char*)lParam == NULL) return 2;
char *pszClassName = MakeUrlClassName((char*)lParam);
- if(pszClassName!= NULL)
- if(RemoveAssocItem_Worker(pszClassName)) {
+ if (pszClassName != NULL)
+ if (RemoveAssocItem_Worker(pszClassName)) {
mir_free(pszClassName);
return 0;
}
- mir_free(pszClassName); /* does NULL check */
+ mir_free(pszClassName); // does NULL check
return 3;
}
@@ -549,30 +551,30 @@ static BOOL InvokeHandler_Worker(const char *pszClassName, const TCHAR *pszParam void *pvParam;
char *pszService;
- /* find it in list */
+ // find it in list
mir_cslock lck(csAssocList);
int index = FindAssocItem(pszClassName);
- if(index == -1)
+ if (index == -1)
return FALSE;
ASSOCDATA *assoc = &pAssocList[index];
- /* no service specified? correct registry to use main commandline */
- if(assoc->pszService == NULL) {
+ // no service specified? correct registry to use main commandline
+ if (assoc->pszService == NULL) {
EnsureAssocRegistered(assoc);
NotifyAssocChange(FALSE);
- /* try main command line */
- if ((int)ShellExecute(NULL, NULL, pszParam, NULL, NULL, SW_SHOWNORMAL) >= 32)
- *res = 0; /* success */
+ // try main command line
+ if ((INT_PTR)ShellExecute(NULL, NULL, pszParam, NULL, NULL, SW_SHOWNORMAL) >= 32)
+ *res = 0; // success
return TRUE;
}
- /* get params */
+ // get params
pszService = mir_strdup(assoc->pszService);
pvParam = t2s(pszParam, assoc->flags&FTDF_UNICODE, FALSE);
- /* call service */
- if(pszService!= NULL && pvParam!= NULL)
+ // call service
+ if (pszService != NULL && pvParam != NULL)
*res = CallService(pszService, 0, (LPARAM)pvParam);
- mir_free(pszService); /* does NULL check */
- mir_free(pvParam); /* does NULL check */
+ mir_free(pszService); // does NULL check
+ mir_free(pvParam); // does NULL check
return TRUE;
}
@@ -581,20 +583,20 @@ INT_PTR InvokeFileHandler(const TCHAR *pszFileName) char *pszClassName, *pszFileExt;
INT_PTR res = CALLSERVICE_NOTFOUND;
- /* find extension */
+ // find extension
TCHAR *p = (TCHAR*)_tcsrchr(pszFileName, _T('.'));
- if(p!= NULL) {
+ if (p != NULL) {
pszFileExt = t2a(p);
- if(pszFileExt!= NULL) {
- /* class name */
+ if (pszFileExt != NULL) {
+ // class name
pszClassName = MakeFileClassName(pszFileExt);
- if(pszClassName!= NULL)
+ if (pszClassName != NULL)
if (!InvokeHandler_Worker(pszClassName, pszFileName, &res)) {
- /* correct registry on error (no longer in list) */
+ // correct registry on error (no longer in list)
RemoveRegFileExt(pszFileExt, pszClassName);
RemoveRegClass(pszClassName);
}
- mir_free(pszClassName); /* does NULL check */
+ mir_free(pszClassName); // does NULL check
mir_free(pszFileExt);
}
}
@@ -605,20 +607,20 @@ INT_PTR InvokeUrlHandler(const TCHAR *pszUrl) {
char *pszClassName, *pszProtoPrefix, *p;
INT_PTR res = CALLSERVICE_NOTFOUND;
-
- /* find prefix */
+
+ // find prefix
pszProtoPrefix = t2a(pszUrl);
- if(pszProtoPrefix!= NULL) {
+ if (pszProtoPrefix != NULL) {
p = strchr(pszProtoPrefix, _T(':'));
- if(p!= NULL) {
- *(++p) = 0; /* remove trailing : */
- /* class name */
+ if (p != NULL) {
+ *(++p) = 0; // remove trailing :
+ // class name
pszClassName = MakeUrlClassName(pszProtoPrefix);
- if(pszClassName!= NULL)
+ if (pszClassName != NULL)
if (!InvokeHandler_Worker(pszClassName, pszUrl, &res))
- /* correct registry on error (no longer in list) */
+ // correct registry on error (no longer in list)
RemoveRegClass(pszClassName);
- mir_free(pszClassName); /* does NULL check */
+ mir_free(pszClassName); // does NULL check
}
mir_free(pszProtoPrefix);
}
@@ -630,28 +632,27 @@ INT_PTR InvokeUrlHandler(const TCHAR *pszUrl) static int CALLBACK ListViewSortDesc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
int cmp;
- if (((ASSOCDATA*)lParam1)->pszFileExt!= NULL && ((ASSOCDATA*)lParam2)->pszFileExt!= NULL)
+ if (((ASSOCDATA*)lParam1)->pszFileExt != NULL && ((ASSOCDATA*)lParam2)->pszFileExt != NULL)
cmp = CompareStringA((LCID)lParamSort, 0, ((ASSOCDATA*)lParam1)->pszFileExt, -1, ((ASSOCDATA*)lParam2)->pszFileExt, -1);
- else if (((ASSOCDATA*)lParam1)->pszFileExt == ((ASSOCDATA*)lParam2)->pszFileExt) /* both NULL */
+ else if (((ASSOCDATA*)lParam1)->pszFileExt == ((ASSOCDATA*)lParam2)->pszFileExt) // both NULL
cmp = CompareStringA((LCID)lParamSort, 0, ((ASSOCDATA*)lParam1)->pszClassName, -1, ((ASSOCDATA*)lParam2)->pszClassName, -1);
- else /* different types, incomparable */
- cmp = (((ASSOCDATA*)lParam1)->pszFileExt == NULL)?CSTR_LESS_THAN:CSTR_GREATER_THAN;
- if(cmp == CSTR_EQUAL)
+ else // different types, incomparable
+ cmp = (((ASSOCDATA*)lParam1)->pszFileExt == NULL) ? CSTR_LESS_THAN : CSTR_GREATER_THAN;
+ if (cmp == CSTR_EQUAL)
cmp = CompareString((LCID)lParamSort, 0, ((ASSOCDATA*)lParam1)->pszDescription, -1, ((ASSOCDATA*)lParam2)->pszDescription, -1);
- if(cmp!= 0) cmp -= 2; /* maintain CRT conventions */
+ if (cmp != 0) cmp -= 2; // maintain CRT conventions
return cmp;
}
#define M_REFRESH_ICONS (WM_APP+1)
static INT_PTR CALLBACK AssocListOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
- case WM_INITDIALOG:
+ LVITEM lvi;
+ ASSOCDATA *assoc;
+
+ switch (msg) {
+ case WM_INITDIALOG:
{
- HIMAGELIST himl;
- LVITEM lvi;
- ASSOCDATA *assoc;
- int i;
TranslateDialogDefault(hwndDlg);
CoInitialize(NULL);
HWND hwndList = GetDlgItem(hwndDlg, IDC_ASSOCLIST);
@@ -659,264 +660,255 @@ static INT_PTR CALLBACK AssocListOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara ListView_SetUnicodeFormat(hwndList, TRUE);
SendDlgItemMessage(hwndDlg, IDC_HEADERTEXT, WM_SETFONT, SendMessage(GetParent(hwndDlg), PSM_GETBOLDFONT, 0, 0), 0);
- /* checkboxes won't show up on Win95 without IE3+ or 4.70 (plugin opts uses the same) */
- ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP);
- /* columns */
- { LVCOLUMN lvc;
- lvc.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
+ // checkboxes won't show up on Win95 without IE3+ or 4.70 (plugin opts uses the same)
+ ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
+ // columns
+ {
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
lvc.pszText = TranslateT("Type");
lvc.cx = 170;
ListView_InsertColumn(hwndList, lvc.iSubItem = 0, &lvc);
- lvc.pszText = TranslateT("Description");
+ lvc.pszText = TranslateT("Description");
ListView_InsertColumn(hwndList, lvc.iSubItem = 1, &lvc);
}
- /* create image storage */
+ // create image storage
+ HIMAGELIST himl;
mir_cslock lck(csAssocList);
- { HDC hdc;
- hdc = GetDC(hwndList);
- if(hdc!= NULL) { /* BITSPIXEL is compatible with ILC_COLOR flags */
- himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), GetDeviceCaps(hdc, BITSPIXEL)|ILC_MASK, nAssocListCount, 0);
+ {
+ HDC hdc = GetDC(hwndList);
+ if (hdc != NULL) { // BITSPIXEL is compatible with ILC_COLOR flags
+ himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), GetDeviceCaps(hdc, BITSPIXEL) | ILC_MASK, nAssocListCount, 0);
ReleaseDC(hwndList, hdc);
- } else himl = NULL;
+ }
+ else himl = NULL;
}
- ListView_SetImageList(hwndList, himl, LVSIL_SMALL); /* autodestroyed */
- /* enum assoc list */
+ ListView_SetImageList(hwndList, himl, LVSIL_SMALL); // autodestroyed
+ // enum assoc list
lvi.iSubItem = 0;
- lvi.mask = LVIF_TEXT|LVIF_PARAM|LVIF_IMAGE;
- for(i = 0;i<nAssocListCount;++i) {
+ lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ for (int i = 0; i < nAssocListCount; ++i) {
assoc = &pAssocList[i];
lvi.iItem = 0;
lvi.lParam = (LPARAM)CopyAssocItem(assoc);
lvi.pszText = GetAssocTypeDesc(assoc);
lvi.iImage = ReplaceImageListAssocIcon(himl, assoc, -1);
lvi.iItem = ListView_InsertItem(hwndList, &lvi);
- if(lvi.iItem!= -1) {
+ if (lvi.iItem != -1) {
ListView_SetItemText(hwndList, lvi.iItem, 1, assoc->pszDescription);
ListView_SetCheckState(hwndList, lvi.iItem, IsAssocEnabled(assoc) && IsAssocRegistered(assoc));
}
}
- /* sort items (before moving to groups) */
+ // sort items (before moving to groups)
ListView_SortItems(hwndList, ListViewSortDesc, Langpack_GetDefaultLocale());
- /* groups */
- if(ListView_EnableGroupView(hwndList, TRUE) == 1) { /* returns 0 on pre WinXP or if commctls6 are disabled */
+ // groups
+ if (ListView_EnableGroupView(hwndList, TRUE) == 1) { // returns 0 on pre WinXP or if commctls6 are disabled
LVGROUP lvg;
int iItem;
- /* dummy item for group */
- lvi.iItem = ListView_GetItemCount(hwndList)-1;
+ // dummy item for group
+ lvi.iItem = ListView_GetItemCount(hwndList) - 1;
lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM|LVIF_IMAGE;
+ lvi.mask = LVIF_PARAM | LVIF_IMAGE;
lvi.iImage = -1;
lvi.lParam = 0;
- /* insert groups */
+ // insert groups
lvg.cbSize = sizeof(lvg);
- lvg.mask = LVGF_HEADER|LVGF_GROUPID;
+ lvg.mask = LVGF_HEADER | LVGF_GROUPID;
lvg.iGroupId = 2;
lvg.pszHeader = TranslateT("URLs on websites");
lvi.iItem = ListView_InsertItem(hwndList, &lvi);
- if(lvi.iItem!= -1) {
+ if (lvi.iItem != -1) {
ListView_InsertGroup(hwndList, lvi.iItem, &lvg);
lvg.iGroupId = 1;
lvg.pszHeader = TranslateT("File types");
iItem = lvi.iItem = ListView_InsertItem(hwndList, &lvi);
- if(lvi.iItem!= -1)
+ if (lvi.iItem != -1)
ListView_InsertGroup(hwndList, lvi.iItem, &lvg);
else ListView_DeleteItem(hwndList, iItem);
}
- /* move to group */
+ // move to group
lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM|LVIF_GROUPID;
- for(lvi.iItem = 0;ListView_GetItem(hwndList, &lvi);++lvi.iItem) {
+ lvi.mask = LVIF_PARAM | LVIF_GROUPID;
+ for (lvi.iItem = 0; ListView_GetItem(hwndList, &lvi); ++lvi.iItem) {
assoc = (ASSOCDATA*)lvi.lParam;
- if(assoc == NULL) continue; /* groups */
- lvi.iGroupId = (assoc->pszFileExt == NULL)+1;
+ if (assoc == NULL) continue; // groups
+ lvi.iGroupId = (assoc->pszFileExt == NULL) + 1;
ListView_SetItem(hwndList, &lvi);
}
}
lvi.iItem = ListView_GetTopIndex(hwndList);
- ListView_SetItemState(hwndList, lvi.iItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE_USEHEADER); /* size to fit window */
- /* only while running */
+ ListView_SetItemState(hwndList, lvi.iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE_USEHEADER); // size to fit window
+ // only while running
CheckDlgButton(hwndDlg, IDC_ONLYWHILERUNNING, (BOOL)db_get_b(NULL, "AssocMgr", "OnlyWhileRunning", SETTING_ONLYWHILERUNNING_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- /* autostart */
- { TCHAR *pszRunCmd;
- pszRunCmd = MakeRunCommand(TRUE, TRUE);
- if(pszRunCmd!= NULL) {
- CheckDlgButton(hwndDlg, IDC_AUTOSTART, IsRegRunEntry(_T("MirandaNG"), pszRunCmd) ? BST_CHECKED : BST_UNCHECKED);
- mir_free(pszRunCmd);
- }
+
+ // autostart
+ TCHAR *pszRunCmd = MakeRunCommand(TRUE, TRUE);
+ if (pszRunCmd != NULL) {
+ CheckDlgButton(hwndDlg, IDC_AUTOSTART, IsRegRunEntry(_T("MirandaNG"), pszRunCmd) ? BST_CHECKED : BST_UNCHECKED);
+ mir_free(pszRunCmd);
}
- return TRUE;
}
- case WM_SETTINGCHANGE:
- case M_REFRESH_ICONS:
+ return TRUE;
+
+ case WM_SETTINGCHANGE:
+ case M_REFRESH_ICONS:
{
- LVITEM lvi;
- ASSOCDATA *assoc;
HWND hwndList = GetDlgItem(hwndDlg, IDC_ASSOCLIST);
HIMAGELIST himl = ListView_GetImageList(hwndList, LVSIL_SMALL);
- /* enum items */
+ // enum items
lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM|LVIF_IMAGE;
- for(lvi.iItem = 0;ListView_GetItem(hwndList, &lvi);++lvi.iItem) {
+ lvi.mask = LVIF_PARAM | LVIF_IMAGE;
+ for (lvi.iItem = 0; ListView_GetItem(hwndList, &lvi); ++lvi.iItem) {
assoc = (ASSOCDATA*)lvi.lParam;
- if(assoc == NULL) continue; /* groups */
+ if (assoc == NULL) continue; // groups
lvi.iImage = ReplaceImageListAssocIcon(himl, assoc, lvi.iImage);
ListView_SetItem(hwndList, &lvi);
}
- if(lvi.iItem) { /* ListView_Update() blinks */
- ListView_RedrawItems(hwndList, 0, lvi.iItem-1);
+ if (lvi.iItem) { // ListView_Update() blinks
+ ListView_RedrawItems(hwndList, 0, lvi.iItem - 1);
UpdateWindow(hwndList);
}
- return TRUE;
}
- case WM_CTLCOLORSTATIC:
- /* use same text color for header as for group boxes (WinXP+) */
- if(GetDlgCtrlID((HWND)lParam) == IDC_HEADERTEXT) {
- lParam = (LPARAM)GetDlgItem(hwndDlg, IDC_MISCLABEL);
- HBRUSH hBrush = (HBRUSH)SendMessage(hwndDlg, msg, wParam, lParam);
- COLORREF clr;
- HTHEME hTheme = GetWindowTheme((HWND)lParam);
- if(hTheme!= NULL && !GetThemeColor(hTheme, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &clr)) {
- SetBkMode((HDC)wParam, TRANSPARENT);
- SetTextColor((HDC)wParam, clr);
- }
- return (BOOL)hBrush;
+ return TRUE;
+
+ case WM_CTLCOLORSTATIC:
+ // use same text color for header as for group boxes (WinXP+)
+ if (GetDlgCtrlID((HWND)lParam) == IDC_HEADERTEXT) {
+ lParam = (LPARAM)GetDlgItem(hwndDlg, IDC_MISCLABEL);
+ HBRUSH hBrush = (HBRUSH)SendMessage(hwndDlg, msg, wParam, lParam);
+ COLORREF clr;
+ HTHEME hTheme = GetWindowTheme((HWND)lParam);
+ if (hTheme != NULL && !GetThemeColor(hTheme, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &clr)) {
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ SetTextColor((HDC)wParam, clr);
}
- break;
- case WM_NCDESTROY:
- CoUninitialize();
- return TRUE;
- case WM_COMMAND:
- /* enable apply */
- PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
+ return (INT_PTR)hBrush;
+ }
+ break;
+
+ case WM_NCDESTROY:
+ CoUninitialize();
+ return TRUE;
- case WM_NOTIFYFORMAT:
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, NFR_UNICODE);
- return TRUE;
+ case WM_COMMAND:
+ // enable apply
+ PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
- case WM_NOTIFY:
- {
- NMHDR *nmhdr = (NMHDR*)lParam;
- switch(nmhdr->idFrom) {
- case IDC_ASSOCLIST:
- switch(nmhdr->code) {
- case LVN_DELETEITEM: /* also called on WM_DESTROY */
- {
- LVITEM lvi;
- lvi.mask = LVIF_PARAM;
- lvi.iSubItem = 0;
- lvi.iItem = ((NMLISTVIEW*)lParam)->iItem;
- /* free memory */
- if(ListView_GetItem(nmhdr->hwndFrom, &lvi))
- mir_free((ASSOCDATA*)lvi.lParam); /* does NULL check */
- return TRUE;
- }
- case LVN_ITEMCHANGED:
- /* enable apply (not while loading) */
- if(IsWindowVisible(nmhdr->hwndFrom))
- PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- case LVN_KEYDOWN:
- /* workaround for WinXP (ListView with groups):
- * eat keyboard navigation that goes beyond the first item in list
- * as it would scroll out of scope in this case
- * bug should not be present using WinVista and higher */
- switch(((NMLVKEYDOWN*)lParam)->wVKey) {
- case VK_UP:
- {
- LVITEM lvi;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = ListView_GetNextItem(nmhdr->hwndFrom, -1, LVNI_FOCUSED);
- lvi.iItem = ListView_GetNextItem(nmhdr->hwndFrom, lvi.iItem, LVNI_ABOVE);
- if(lvi.iItem!= -1)
- if(ListView_GetItem(nmhdr->hwndFrom, &lvi))
- if ((ASSOCDATA*)lvi.lParam == NULL) /* groups */
- lvi.iItem = -1;
- if(lvi.iItem == -1) {
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); /* eat it */
- return TRUE;
- }
- break;
- }
- case VK_PRIOR:
- {
- LVITEM lvi;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = ListView_GetNextItem(nmhdr->hwndFrom, -1, LVNI_FOCUSED);
- lvi.iItem-= ListView_GetCountPerPage(nmhdr->hwndFrom);
- if(lvi.iItem>= 0)
- if(ListView_GetItem(nmhdr->hwndFrom, &lvi))
- if ((ASSOCDATA*)lvi.lParam == NULL) /* groups */
- lvi.iItem = -1;
- if(lvi.iItem<0) {
- ListView_SetItemState(nmhdr->hwndFrom, 0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); /* eat it */
- return TRUE;
- }
- break;
- }
- }
- break;
+ case WM_NOTIFYFORMAT:
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, NFR_UNICODE);
+ return TRUE;
+
+ case WM_NOTIFY:
+ NMHDR *nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->idFrom) {
+ case IDC_ASSOCLIST:
+ switch (nmhdr->code) {
+ case LVN_DELETEITEM: // also called on WM_DESTROY
+ lvi.mask = LVIF_PARAM;
+ lvi.iSubItem = 0;
+ lvi.iItem = ((NMLISTVIEW*)lParam)->iItem;
+ // free memory
+ if (ListView_GetItem(nmhdr->hwndFrom, &lvi))
+ mir_free((ASSOCDATA*)lvi.lParam); // does NULL check
+ return TRUE;
+
+ case LVN_ITEMCHANGED:
+ // enable apply (not while loading)
+ if (IsWindowVisible(nmhdr->hwndFrom))
+ PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+
+ case LVN_KEYDOWN:
+ // workaround for WinXP (ListView with groups):
+ // eat keyboard navigation that goes beyond the first item in list
+ // as it would scroll out of scope in this case
+ // bug should not be present using WinVista and higher
+ switch (((NMLVKEYDOWN*)lParam)->wVKey) {
+ case VK_UP:
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = ListView_GetNextItem(nmhdr->hwndFrom, -1, LVNI_FOCUSED);
+ lvi.iItem = ListView_GetNextItem(nmhdr->hwndFrom, lvi.iItem, LVNI_ABOVE);
+ if (lvi.iItem != -1)
+ if (ListView_GetItem(nmhdr->hwndFrom, &lvi))
+ if ((ASSOCDATA*)lvi.lParam == NULL) // groups
+ lvi.iItem = -1;
+ if (lvi.iItem == -1) {
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); // eat it
+ return TRUE;
}
break;
- case 0:
- switch(nmhdr->code) {
- case PSN_APPLY:
- {
- LVITEM lvi;
- BOOL fEnabled, fRegFailed = FALSE;
- ASSOCDATA *assoc;
-
- /* only while running */
- db_set_b(NULL, "AssocMgr", "OnlyWhileRunning", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ONLYWHILERUNNING)!= 0));
-
- /* save enabled assoc items */
- HWND hwndList = GetDlgItem(hwndDlg, IDC_ASSOCLIST);
- lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM;
- mir_cslock lck(csAssocList);
- for(lvi.iItem = 0;ListView_GetItem(hwndList, &lvi);++lvi.iItem) {
- assoc = (ASSOCDATA*)lvi.lParam;
- if(assoc == NULL) continue; /* groups */
- fEnabled = ListView_GetCheckState(hwndList, lvi.iItem);
- SetAssocEnabled(assoc, fEnabled);
-
- /* re-register registery keys */
- if(fEnabled?!EnsureAssocRegistered(assoc):!UnregisterAssoc(assoc)) {
- char *pszErr = GetWinErrorDescription(GetLastError());
- ShowInfoMessage(NIIF_ERROR, Translate("File association error"), Translate("There was an error writing to the registry to modify the file/url associations.\nReason: %s"), (pszErr!= NULL)?pszErr:Translate("Unknown"));
- mir_free(pszErr); /* does NULL check */
- fRegFailed = TRUE; /* just show one time */
- }
- }
- NotifyAssocChange(TRUE);
- PostMessage(hwndDlg, M_REFRESH_ICONS, 0, 0);
- /* autostart */
- {
- TCHAR *pszRunCmd = MakeRunCommand(TRUE, TRUE);
- fRegFailed = FALSE;
- if(pszRunCmd!= NULL) {
- fEnabled = IsDlgButtonChecked(hwndDlg, IDC_AUTOSTART);
- if(fEnabled?!AddRegRunEntry(_T("MirandaNG"), pszRunCmd):!RemoveRegRunEntry(_T("MirandaNG"), pszRunCmd)) {
- char *pszErr;
- pszErr = GetWinErrorDescription(GetLastError());
- ShowInfoMessage(NIIF_ERROR, Translate("Autostart error"), Translate("There was an error writing to the registry to modify the autostart list.\n\nReason: %s"), (pszErr!= NULL)?pszErr:Translate("Unknown"));
- mir_free(pszErr); /* does NULL check */
- fRegFailed = TRUE; /* just show one time */
- }
- mir_free(pszRunCmd);
- }
- }
- return TRUE;
- }
- } /* code */
+
+ case VK_PRIOR:
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = ListView_GetNextItem(nmhdr->hwndFrom, -1, LVNI_FOCUSED);
+ lvi.iItem -= ListView_GetCountPerPage(nmhdr->hwndFrom);
+ if (lvi.iItem >= 0)
+ if (ListView_GetItem(nmhdr->hwndFrom, &lvi))
+ if ((ASSOCDATA*)lvi.lParam == NULL) // groups
+ lvi.iItem = -1;
+ if (lvi.iItem < 0) {
+ ListView_SetItemState(nmhdr->hwndFrom, 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); // eat it
+ return TRUE;
+ }
break;
- } /* idFrom */
+ }
+ break;
+ }
break;
- } /* WM_NOTIFY */
+
+ case 0:
+ switch (nmhdr->code) {
+ case PSN_APPLY:
+ BOOL fEnabled, fRegFailed = FALSE;
+
+ // only while running
+ db_set_b(NULL, "AssocMgr", "OnlyWhileRunning", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ONLYWHILERUNNING) != 0));
+
+ // save enabled assoc items
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_ASSOCLIST);
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_PARAM;
+ mir_cslock lck(csAssocList);
+ for (lvi.iItem = 0; ListView_GetItem(hwndList, &lvi); ++lvi.iItem) {
+ assoc = (ASSOCDATA*)lvi.lParam;
+ if (assoc == NULL) continue; // groups
+ fEnabled = ListView_GetCheckState(hwndList, lvi.iItem);
+ SetAssocEnabled(assoc, fEnabled);
+
+ // re-register registery keys
+ if (fEnabled ? !EnsureAssocRegistered(assoc) : !UnregisterAssoc(assoc)) {
+ char *pszErr = GetWinErrorDescription(GetLastError());
+ ShowInfoMessage(NIIF_ERROR, Translate("File association error"), Translate("There was an error writing to the registry to modify the file/url associations.\nReason: %s"), (pszErr != NULL) ? pszErr : Translate("Unknown"));
+ mir_free(pszErr); // does NULL check
+ fRegFailed = TRUE; // just show one time
+ }
+ }
+ NotifyAssocChange(TRUE);
+ PostMessage(hwndDlg, M_REFRESH_ICONS, 0, 0);
+
+ // autostart
+ TCHAR *pszRunCmd = MakeRunCommand(TRUE, TRUE);
+ fRegFailed = FALSE;
+ if (pszRunCmd != NULL) {
+ fEnabled = IsDlgButtonChecked(hwndDlg, IDC_AUTOSTART);
+ if (fEnabled ? !AddRegRunEntry(_T("MirandaNG"), pszRunCmd) : !RemoveRegRunEntry(_T("MirandaNG"), pszRunCmd)) {
+ char *pszErr;
+ pszErr = GetWinErrorDescription(GetLastError());
+ ShowInfoMessage(NIIF_ERROR, Translate("Autostart error"), Translate("There was an error writing to the registry to modify the autostart list.\n\nReason: %s"), (pszErr != NULL) ? pszErr : Translate("Unknown"));
+ mir_free(pszErr); // does NULL check
+ fRegFailed = TRUE; // just show one time
+ }
+ mir_free(pszRunCmd);
+ }
+ return TRUE;
+ }
+ }
+ break;
}
return FALSE;
}
@@ -926,9 +918,9 @@ static int AssocListOptInit(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ASSOCLIST);
- odp.position = 900000100; /* network opts = 900000000 */
- odp.pszGroup = LPGEN("Services"); /* autotranslated */
- odp.pszTitle = LPGEN("Associations"); /* autotranslated */
+ odp.position = 900000100; // network opts = 900000000
+ odp.pszGroup = LPGEN("Services"); // autotranslated
+ odp.pszTitle = LPGEN("Associations"); // autotranslated
odp.flags = ODPF_BOLDGROUPS;
odp.pfnDlgProc = AssocListOptDlgProc;
Options_AddPage(wParam, &odp);
@@ -939,27 +931,27 @@ static int AssocListOptInit(WPARAM wParam, LPARAM) void InitAssocList(void)
{
- /* Options */
+ // Options
INITCOMMONCONTROLSEX icc;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icc);
hHookOptInit = HookEvent(ME_OPT_INITIALISE, AssocListOptInit);
- /* Assoc List */
+ // Assoc List
pAssocList = NULL;
nAssocListCount = 0;
- /* Services */
+ // Services
hServiceAddFile = CreateServiceFunction(MS_ASSOCMGR_ADDNEWFILETYPE, ServiceAddNewFileType);
hServiceRemoveFile = CreateServiceFunction(MS_ASSOCMGR_REMOVEFILETYPE, ServiceRemoveFileType);
hServiceAddUrl = CreateServiceFunction(MS_ASSOCMGR_ADDNEWURLTYPE, ServiceAddNewUrlType);
hServiceRemoveUrl = CreateServiceFunction(MS_ASSOCMGR_REMOVEURLTYPE, ServiceRemoveUrlType);
- /* Notify Shell */
+ // Notify Shell
nNotifyTimerID = 0;
- /* register open-with app */
+ // register open-with app
{
TCHAR *pszAppFileName, *pszIconLoc, *pszRunCmd;
pszIconLoc = MakeIconLocation(NULL, 0);
@@ -967,22 +959,22 @@ void InitAssocList(void) // miranda32.exe
pszAppFileName = MakeAppFileName(TRUE);
pszRunCmd = MakeRunCommand(TRUE, FALSE);
- if(pszAppFileName!= NULL && pszRunCmd!= NULL)
+ if (pszAppFileName != NULL && pszRunCmd != NULL)
AddRegOpenWith(pszAppFileName, FALSE, _T(MIRANDANAME), pszIconLoc, pszRunCmd, NULL, NULL, NULL);
- mir_free(pszRunCmd); /* does NULL check */
- mir_free(pszAppFileName); /* does NULL check */
+ mir_free(pszRunCmd); // does NULL check
+ mir_free(pszAppFileName); // does NULL check
// assocmgr.dll
pszAppFileName = MakeAppFileName(FALSE);
pszRunCmd = MakeRunCommand(FALSE, TRUE);
- if(pszAppFileName!= NULL && pszRunCmd!= NULL)
+ if (pszAppFileName != NULL && pszRunCmd != NULL)
AddRegOpenWith(pszAppFileName, TRUE, _T(MIRANDANAME), pszIconLoc, pszRunCmd, DDEFILECMD, DDEAPP, DDETOPIC);
- mir_free(pszRunCmd); /* does NULL check */
- mir_free(pszAppFileName); /* does NULL check */
+ mir_free(pszRunCmd); // does NULL check
+ mir_free(pszAppFileName); // does NULL check
- mir_free(pszIconLoc); /* does NULL check */
+ mir_free(pszIconLoc); // does NULL check
}
- /* default items */
+ // default items
{
FILETYPEDESC ftd;
ftd.cbSize = sizeof(FILETYPEDESC);
@@ -993,58 +985,55 @@ void InitAssocList(void) ftd.nIconResID = IDI_MIRANDAFILE;
ftd.ptszVerbDesc = NULL;
ftd.pszService = NULL;
- ftd.flags = FTDF_DEFAULTDISABLED|FTDF_TCHAR;
+ ftd.flags = FTDF_DEFAULTDISABLED | FTDF_TCHAR;
ServiceAddNewFileType(0, (LPARAM)&ftd);
}
}
void UninitAssocList(void)
{
- BYTE fOnlyWhileRunning;
- ASSOCDATA *assoc;
-
- /* Options */
+ // Options
UnhookEvent(hHookOptInit);
- /* Services */
+ // Services
DestroyServiceFunction(hServiceAddFile);
DestroyServiceFunction(hServiceRemoveFile);
DestroyServiceFunction(hServiceAddUrl);
DestroyServiceFunction(hServiceRemoveUrl);
- /* Assoc List */
- fOnlyWhileRunning = db_get_b(NULL, "AssocMgr", "OnlyWhileRunning", SETTING_ONLYWHILERUNNING_DEFAULT);
- for(int i = 0;i<nAssocListCount;++i) {
- assoc = &pAssocList[i];
+ // Assoc List
+ BYTE fOnlyWhileRunning = db_get_b(NULL, "AssocMgr", "OnlyWhileRunning", SETTING_ONLYWHILERUNNING_DEFAULT);
+ for (int i = 0; i < nAssocListCount; ++i) {
+ ASSOCDATA *assoc = &pAssocList[i];
- /* remove registry keys */
- if(fOnlyWhileRunning)
+ // remove registry keys
+ if (fOnlyWhileRunning)
UnregisterAssoc(assoc);
mir_free(assoc->pszClassName);
mir_free(assoc->pszDescription);
mir_free(assoc->pszService);
- mir_free(assoc->pszFileExt); /* does NULL check */
- mir_free(assoc->pszVerbDesc); /* does NULL check */
- mir_free(assoc->pszMimeType); /* does NULL check */
+ mir_free(assoc->pszFileExt);
+ mir_free(assoc->pszVerbDesc);
+ mir_free(assoc->pszMimeType);
}
mir_free(pAssocList);
- /* Notify Shell */
- if(fOnlyWhileRunning && nAssocListCount)
+ // Notify Shell
+ if (fOnlyWhileRunning && nAssocListCount)
NotifyAssocChange(TRUE);
- /* unregister open-with app */
- if(fOnlyWhileRunning) {
+ // unregister open-with app
+ if (fOnlyWhileRunning) {
TCHAR *pszAppFileName;
// miranda32.exe
pszAppFileName = MakeAppFileName(TRUE);
- if(pszAppFileName!= NULL)
+ if (pszAppFileName != NULL)
RemoveRegOpenWith(pszAppFileName);
pszAppFileName = MakeAppFileName(FALSE);
// assocmgr.dll
- if(pszAppFileName!= NULL)
+ if (pszAppFileName != NULL)
RemoveRegOpenWith(pszAppFileName);
- mir_free(pszAppFileName); /* does NULL check */
+ mir_free(pszAppFileName); // does NULL check
}
-}
\ No newline at end of file +}
diff --git a/plugins/AvatarHistory/src/popup.cpp b/plugins/AvatarHistory/src/popup.cpp index d8ada07c4c..fad3e5ad56 100644 --- a/plugins/AvatarHistory/src/popup.cpp +++ b/plugins/AvatarHistory/src/popup.cpp @@ -223,7 +223,6 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA return TRUE;
case UM_FREEPLUGINDATA:
- PopupDataType* popup = (PopupDataType*)PUGetPluginData(hWnd);
if ((INT_PTR)popup != CALLSERVICE_NOTFOUND) {
DestroyIcon(popup->hIcon);
mir_free(popup);
diff --git a/plugins/BASS_interface/src/Main.cpp b/plugins/BASS_interface/src/Main.cpp index 1c3dbe883b..8283ee78ce 100644 --- a/plugins/BASS_interface/src/Main.cpp +++ b/plugins/BASS_interface/src/Main.cpp @@ -133,22 +133,21 @@ INT_PTR CALLBACK OptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- {
- SYSTEMTIME systime = { 0 };
- SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_RESETCONTENT, 0, 0);
- for (int i = 1; i <= MAXCHAN; i++)
- SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_ADDSTRING, 0, (LPARAM)_itot(i, tmp, 10));
+ SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_RESETCONTENT, 0, 0);
+ for (int i = 1; i <= MAXCHAN; i++)
+ SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_ADDSTRING, 0, (LPARAM)_itot(i, tmp, 10));
- SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_SETCURSEL, sndLimSnd - 1, 0);
+ SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_SETCURSEL, sndLimSnd - 1, 0);
- SetDlgItemText(hwndDlg, IDC_CURRPATH, CurrBassPath);
-
- hwndOptSlider = GetDlgItem(hwndDlg, IDC_VOLUME);
- SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETRANGE, FALSE, MAKELONG(SLIDER_MIN, SLIDER_MAX));
- SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPOS, TRUE, Volume);
- SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPAGESIZE, 0, 5);
+ SetDlgItemText(hwndDlg, IDC_CURRPATH, CurrBassPath);
+ hwndOptSlider = GetDlgItem(hwndDlg, IDC_VOLUME);
+ SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETRANGE, FALSE, MAKELONG(SLIDER_MIN, SLIDER_MAX));
+ SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPOS, TRUE, Volume);
+ SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPAGESIZE, 0, 5);
+ {
+ SYSTEMTIME systime = { 0 };
systime.wHour = HIBYTE(TimeWrd1);
systime.wMinute = LOBYTE(TimeWrd1);
systime.wYear = 2000;
@@ -160,45 +159,45 @@ INT_PTR CALLBACK OptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara systime.wMinute = LOBYTE(TimeWrd2);
SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_SETFORMAT, 0, (LPARAM)_T("HH:mm"));
SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&systime);
+ }
- CheckDlgButton(hwndDlg, IDC_PREVIEW, EnPreview ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_PREVIEW, EnPreview ? BST_CHECKED : BST_UNCHECKED);
- for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
- if (StatMask & (1 << (i - IDC_CHECKBOX1)))
- CheckDlgButton(hwndDlg, i, BST_CHECKED);
+ for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
+ if (StatMask & (1 << (i - IDC_CHECKBOX1)))
+ CheckDlgButton(hwndDlg, i, BST_CHECKED);
- if (QuietTime) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_TIME1), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_TIME2), TRUE);
- CheckDlgButton(hwndDlg, IDC_QUIETTIME, BST_CHECKED);
- }
+ if (QuietTime) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TIME1), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TIME2), TRUE);
+ CheckDlgButton(hwndDlg, IDC_QUIETTIME, BST_CHECKED);
+ }
- if (hBass == NULL) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_MAXCHANNEL), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_OUTDEVICE), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_QUIETTIME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), FALSE);
+ if (hBass == NULL) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MAXCHANNEL), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OUTDEVICE), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_QUIETTIME), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), FALSE);
- for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
- EnableWindow(GetDlgItem(hwndDlg, i), FALSE);
- }
- else {
- DBVARIANT dbv = { 0 }; BASS_DEVICEINFO info; DWORD bassver = BASS_GetVersion();
-
- mir_sntprintf(tmp, _countof(tmp), TranslateT("un4seen's bass version: %d.%d.%d.%d"), bassver >> 24, (bassver >> 16) & 0xff, (bassver >> 8) & 0xff, bassver & 0xff);
- SetDlgItemText(hwndDlg, IDC_BASSVERSION, tmp);
-
- SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, (LPARAM)TranslateT("--default device--"));
- SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, 0, 0);
- db_get_ts(NULL, ModuleName, OPT_OUTDEVICE, &dbv);
- for (int i = 1; BASS_GetDeviceInfo(i + newBass, &info); i++) {
- SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, _A2T(info.name));
- if (!mir_tstrcmp(dbv.ptszVal, _A2T(info.name)))
- SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, i, 0);
- }
- db_free(&dbv);
+ for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
+ EnableWindow(GetDlgItem(hwndDlg, i), FALSE);
+ }
+ else {
+ DWORD bassver = BASS_GetVersion();
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("un4seen's bass version: %d.%d.%d.%d"), bassver >> 24, (bassver >> 16) & 0xff, (bassver >> 8) & 0xff, bassver & 0xff);
+ SetDlgItemText(hwndDlg, IDC_BASSVERSION, tmp);
+
+ SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, (LPARAM)TranslateT("--default device--"));
+ SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, 0, 0);
+
+ BASS_DEVICEINFO info;
+ ptrT tszDeviceName(db_get_tsa(NULL, ModuleName, OPT_OUTDEVICE));
+ for (int i = 1; BASS_GetDeviceInfo(i + newBass, &info); i++) {
+ SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, _A2T(info.name));
+ if (!mir_tstrcmp(tszDeviceName, _A2T(info.name)))
+ SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, i, 0);
}
}
return TRUE;
@@ -408,7 +407,7 @@ static LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR if ((HWND)lParam == hwndSlider) {
HDC dc = (HDC)wParam;
SetBkColor(dc, clBack);
- return (BOOL)hBkgBrush;
+ return (INT_PTR)hBkgBrush;
}
break;
diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp index 4ecc87bb24..aabf619a4b 100644 --- a/plugins/CSList/src/cslist.cpp +++ b/plugins/CSList/src/cslist.cpp @@ -950,8 +950,8 @@ INT_PTR CALLBACK CSWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa case WM_CTLCOLORSTATIC: SetTextColor((HDC)wparam, RGB(174, 174, 174)); if (((HWND)lparam == GetDlgItem(hwnd, IDC_NO_ITEMS)) || ((HWND)lparam == GetDlgItem(hwnd, IDC_ADD_SAMPLE))) - return (BOOL)GetStockObject(WHITE_BRUSH); - return FALSE; + return (INT_PTR)GetStockObject(WHITE_BRUSH); + return NULL; case WM_DESTROY: SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp index 37ba22f78a..fdc788f2f7 100644 --- a/plugins/Db3x_mmap/src/ui.cpp +++ b/plugins/Db3x_mmap/src/ui.cpp @@ -89,7 +89,7 @@ static INT_PTR CALLBACK sttEnterPassword(HWND hwndDlg, UINT uMsg, WPARAM wParam, if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_LANG)) {
SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkMode((HDC)wParam, TRANSPARENT);
- return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
+ return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);
}
return FALSE;
@@ -173,7 +173,7 @@ static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_LANG)) {
SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkMode((HDC)wParam, TRANSPARENT);
- return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
+ return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);
}
return FALSE;
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp index 06f8d641ba..de58878414 100644 --- a/plugins/SendScreenshotPlus/src/UMainForm.cpp +++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp @@ -61,11 +61,13 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureTabPage(HWND hDlg, UINT uMsg, WPARAM w } SetFocus(GetDlgItem(hDlg, ID_imgTarget)); return FALSE; + case WM_CTLCOLORDLG: case WM_CTLCOLOREDIT: case WM_CTLCOLORSTATIC: SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); return (INT_PTR)GetStockObject(WHITE_BRUSH); + case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_btnExplore) { /// local file tab OPENFILENAME ofn = { sizeof(OPENFILENAME) }; diff --git a/plugins/TabSRMM/src/containeroptions.cpp b/plugins/TabSRMM/src/containeroptions.cpp index dcf7ea9172..61d55a1718 100644 --- a/plugins/TabSRMM/src/containeroptions.cpp +++ b/plugins/TabSRMM/src/containeroptions.cpp @@ -222,11 +222,11 @@ INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, HWND hwndChild = (HWND)lParam;
UINT id = GetDlgCtrlID(hwndChild);
- if (hwndChild == GetDlgItem(hwndDlg, IDC_TITLEBOX)) {
+ if (hwndChild == GetDlgItem(hwndDlg, IDC_TITLEBOX))
::SetTextColor((HDC)wParam, RGB(60, 60, 150));
- }
else if (hwndChild == GetDlgItem(hwndDlg, IDC_DESC))
::SetTextColor((HDC)wParam, RGB(160, 50, 50));
+
if (id == IDC_TSLABEL_REOPENWARN)
break;
SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
diff --git a/plugins/UserInfoEx/src/ctrl_contact.cpp b/plugins/UserInfoEx/src/ctrl_contact.cpp index cd4b185f01..bbfa76552a 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.cpp +++ b/plugins/UserInfoEx/src/ctrl_contact.cpp @@ -569,7 +569,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L case WM_CTLCOLORSTATIC:
if ((HWND)lParam == cbex->hEdit)
- return (BOOL)GetSysColor(COLOR_WINDOW);
+ return (INT_PTR)GetSysColor(COLOR_WINDOW);
return FALSE;
/**
* name: WM_SETICON
diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp index 5d242d12a5..b18a8761c3 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp @@ -55,14 +55,11 @@ INT_PTR CALLBACK DlgProcProgress(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar }
case WM_CTLCOLORSTATIC:
switch (GetWindowLongPtr((HWND)lParam, GWLP_ID)) {
- //case IDC_HEADERBAR
case STATIC_WHITERECT:
case TXT_SETTING:
case IDC_PROGRESS:
case TXT_CONTACT:
case IDC_PROGRESS2:
- //case ICO_DLGLOGO:
- //case IDC_INFO:
SetBkColor((HDC)wParam, RGB(255, 255, 255));
return (INT_PTR)GetStockObject(WHITE_BRUSH);
}
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index c7f473e83f..692cf79e9d 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR CALLBACK DlgProc_DataHistory(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
{
const ICONCTRL idIcon[] = {
{ ICO_DLG_EXPORT, WM_SETICON, NULL },
@@ -38,39 +38,39 @@ INT_PTR CALLBACK DlgProc_DataHistory(HWND hDlg, UINT msg, WPARAM wParam, LPARAM const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2;
IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet);
- TranslateDialogDefault(hDlg);
SendDlgItemMessage(hDlg, IDOK, BUTTONTRANSLATE, NULL, NULL);
SendDlgItemMessage(hDlg, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
- break;
}
- case WM_CTLCOLORSTATIC:
- switch (GetWindowLongPtr((HWND)lParam, GWLP_ID)) {
- case STATIC_WHITERECT:
- case ICO_DLGLOGO:
- case IDC_INFO:
- SetBkColor((HDC)wParam, RGB(255, 255, 255));
- return (INT_PTR)GetStockObject(WHITE_BRUSH);
- }
- return FALSE;
- case WM_COMMAND:
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- EndDialog(hDlg, 0);
- break;
- case IDOK: {
- WORD hiWord = 0;
-
- if (IsDlgButtonChecked(hDlg, IDC_CHECK1))
- hiWord |= EXPORT_DATA;
- if (IsDlgButtonChecked(hDlg, IDC_CHECK2))
- hiWord |= EXPORT_HISTORY;
- EndDialog(hDlg, (INT_PTR)MAKELONG(IDOK, hiWord));
- break;
- }
- }
+ break;
+
+ case WM_CTLCOLORSTATIC:
+ switch (GetWindowLongPtr((HWND)lParam, GWLP_ID)) {
+ case STATIC_WHITERECT:
+ case ICO_DLGLOGO:
+ case IDC_INFO:
+ SetBkColor((HDC)wParam, RGB(255, 255, 255));
+ return (INT_PTR)GetStockObject(WHITE_BRUSH);
+ }
+ return FALSE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ EndDialog(hDlg, 0);
+ break;
+
+ case IDOK:
+ WORD hiWord = 0;
+ if (IsDlgButtonChecked(hDlg, IDC_CHECK1))
+ hiWord |= EXPORT_DATA;
+ if (IsDlgButtonChecked(hDlg, IDC_CHECK2))
+ hiWord |= EXPORT_HISTORY;
+ EndDialog(hDlg, (INT_PTR)MAKELONG(IDOK, hiWord));
+ break;
}
- break;
+ }
+ break;
}
return FALSE;
}
diff --git a/plugins/UserInfoEx/src/psp_base.cpp b/plugins/UserInfoEx/src/psp_base.cpp index 9437f693f3..98dd6d7b2c 100644 --- a/plugins/UserInfoEx/src/psp_base.cpp +++ b/plugins/UserInfoEx/src/psp_base.cpp @@ -43,10 +43,9 @@ INT_PTR CALLBACK PSPBaseProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) // set propertysheet page's background white in aero mode
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORDLG:
- {
- if (IsAeroMode())
- return (INT_PTR)GetStockBrush(WHITE_BRUSH);
- } break;
+ if (IsAeroMode())
+ return (INT_PTR)GetStockBrush(WHITE_BRUSH);
+ break;
// Set text color of edit boxes according to the source of information they display.
case WM_CTLCOLOREDIT:
diff --git a/plugins/UserInfoEx/src/svc_refreshci.cpp b/plugins/UserInfoEx/src/svc_refreshci.cpp index ad21ac36f9..c7365289f7 100644 --- a/plugins/UserInfoEx/src/svc_refreshci.cpp +++ b/plugins/UserInfoEx/src/svc_refreshci.cpp @@ -233,8 +233,7 @@ class CDlgUpdProgress : public CUpdProgress **/
static INT_PTR CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg)
- {
+ switch (uMsg) {
case WM_INITDIALOG:
{
const ICONCTRL idIcon[] = {
@@ -253,19 +252,13 @@ class CDlgUpdProgress : public CUpdProgress return TRUE;
case WM_CTLCOLORSTATIC:
- {
- switch (GetWindowLongPtr((HWND)lParam, GWLP_ID))
- {
- case STATIC_WHITERECT:
- case IDC_INFO:
- {
- SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
- return GetSysColor(COLOR_WINDOW);
- }
- }
+ switch (GetWindowLongPtr((HWND)lParam, GWLP_ID)) {
+ case STATIC_WHITERECT:
+ case IDC_INFO:
+ SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
+ return GetSysColor(COLOR_WINDOW);
}
return FALSE;
-
}
return CUpdProgress::DefWndProc((CUpdProgress *) GetUserData(hWnd), hWnd, uMsg, wParam, lParam);
}
diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp index 90e5e65c30..2182d60ce1 100644 --- a/plugins/Utils/mir_options.cpp +++ b/plugins/Utils/mir_options.cpp @@ -212,8 +212,8 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha PROTOACCOUNT **protos;
Proto_EnumAccounts(&count, &protos);
- for (int i = 0; i < count; i++) {
- PROTOACCOUNT *p = protos[i];
+ for (int k = 0; k < count; k++) {
+ PROTOACCOUNT *p = protos[k];
if (p->szModuleName == NULL || p->szModuleName[0] == '\0')
continue;
@@ -265,14 +265,14 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
{
int count = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCOUNT, 0, 0);
- int i;
- for (i = 0; i < count; i++) {
- TCHAR *id = (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)i, 0);
+ int k;
+ for (k = 0; k < count; k++) {
+ TCHAR *id = (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)k, 0);
if (mir_tstrcmp(id, tmp) == 0)
break;
}
- if (i < count)
- SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, i, 0);
+ if (k < count)
+ SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, k, 0);
}
break;
}
@@ -342,32 +342,28 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha case CONTROL_PROTOCOL_LIST:
{
LVITEM lvi = { 0 };
- HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
- int i;
-
lvi.mask = (UINT)LVIF_PARAM;
- for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++) {
- lvi.iItem = i;
+ HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
+ int count = ListView_GetItemCount(hwndProtocols);
+ for (int k = 0; k < count; k++) {
+ lvi.iItem = k;
ListView_GetItem(hwndProtocols, &lvi);
char *setting = (char *)lvi.lParam;
- db_set_b(NULL, module, setting, (BYTE)ListView_GetCheckState(hwndProtocols, i));
+ db_set_b(NULL, module, setting, (BYTE)ListView_GetCheckState(hwndProtocols, k));
}
}
break;
case CONTROL_TEXT:
- {
- TCHAR tmp[1024];
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
- db_set_ts(NULL, module, ctrl->setting, tmp);
- }
+ GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
+ db_set_ts(NULL, module, ctrl->setting, tmp);
break;
case CONTROL_INT:
+ BOOL trans;
{
- BOOL trans;
int val = GetDlgItemInt(hwndDlg, ctrl->nID, &trans, ctrl->min <= 0);
if (!trans)
val = ctrl->dwDefValue;
@@ -378,27 +374,24 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha db_set_dw(NULL, module, ctrl->setting, val);
}
break;
+
case CONTROL_FILE:
+ GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
{
- TCHAR tmp[1024];
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
TCHAR rel[1024];
PathToRelative(rel, 1024, tmp);
db_set_ts(NULL, module, ctrl->setting, rel);
}
break;
+
case CONTROL_COMBO_TEXT:
- {
- TCHAR tmp[1024];
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
- db_set_ts(NULL, module, ctrl->setting, tmp);
- }
+ GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
+ db_set_ts(NULL, module, ctrl->setting, tmp);
break;
+
case CONTROL_COMBO_ITEMDATA:
- {
- int sel = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0);
- db_set_ts(NULL, module, ctrl->setting, (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)sel, 0));
- }
+ int sel = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0);
+ db_set_ts(NULL, module, ctrl->setting, (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)sel, 0));
break;
}
@@ -435,12 +428,11 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha switch (ctrl->type) {
case CONTROL_PROTOCOL_LIST:
LVITEM lvi = { 0 };
- HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
- int i;
-
lvi.mask = (UINT)LVIF_PARAM;
- for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++) {
+ HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
+ int count = ListView_GetItemCount(hwndProtocols);
+ for (i = 0; i < count; i++) {
lvi.iItem = i;
ListView_GetItem(hwndProtocols, &lvi);
mir_free((char *)lvi.lParam);
diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp index b653415e9f..433d0cbc70 100644 --- a/plugins/YAMN/src/browser/mailbrowser.cpp +++ b/plugins/YAMN/src/browser/mailbrowser.cpp @@ -78,6 +78,7 @@ struct CUpdateMails BOOL Waiting; HANDLE Copied; }; + struct CSortList { HWND hDlg; @@ -189,7 +190,6 @@ typedef struct _LVCOMPAREINFO LPARAM readItemLParam(HWND hwnd, DWORD iItem) { LVITEM item; - item.mask = LVIF_PARAM; item.iItem = iItem; item.iSubItem = 0; @@ -312,7 +312,7 @@ void IncrementMailCounters(HYAMNMAIL msgq, struct CMailNumbers *MN) int UpdateMails(HWND hDlg, HACCOUNT ActualAccount, DWORD nflags, DWORD nnflags) { -#define MAILBROWSERTITLE LPGEN("%s - %d new mail messages, %d total") + #define MAILBROWSERTITLE LPGEN("%s - %d new mail messages, %d total") struct CMailWinUserInfo *mwui; struct CMailNumbers MN; @@ -323,44 +323,41 @@ int UpdateMails(HWND hDlg, HACCOUNT ActualAccount, DWORD nflags, DWORD nnflags) mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); //now we ensure read access for account and write access for its mails -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read wait\n"); -#endif - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read wait failed\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:ActualAccountSO-read wait\n"); + #endif + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:ActualAccountSO-read wait failed\n"); + #endif PostMessage(hDlg, WM_DESTROY, 0, 0); return UPDATE_FAIL; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read enter\n"); -#endif - -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write wait\n"); -#endif - if (WAIT_OBJECT_0 != WaitToWriteFcn(ActualAccount->MessagesAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write wait failed\n"); - DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read done\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:ActualAccountSO-read enter\n"); + #endif + + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:ActualAccountMsgsSO-write wait\n"); + #endif + if (WAIT_OBJECT_0 != WaitToWriteFcn(ActualAccount->MessagesAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:ActualAccountMsgsSO-write wait failed\n"); + DebugLog(SynchroFile, "UpdateMails:ActualAccountSO-read done\n"); + #endif ReadDoneFcn(ActualAccount->AccountAccessSO); PostMessage(hDlg, WM_DESTROY, 0, 0); return UPDATE_FAIL; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write enter\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:ActualAccountMsgsSO-write enter\n"); + #endif memset(&MN, 0, sizeof(MN)); - for (msgq = (HYAMNMAIL)ActualAccount->Mails; msgq != NULL; msgq = msgq->Next) - { + for (msgq = (HYAMNMAIL)ActualAccount->Mails; msgq != NULL; msgq = msgq->Next) { if (!LoadedMailData(msgq)) //check if mail is already in memory { Loaded = false; @@ -383,20 +380,20 @@ int UpdateMails(HWND hDlg, HACCOUNT ActualAccount, DWORD nflags, DWORD nnflags) //If popups will be displayed or mailbrowser window if ((((mwui != NULL) && !(mwui->RunFirstTime)) && ( - ((nnflags & YAMN_ACC_MSGP) && !(MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || - ((nflags & YAMN_ACC_MSGP) && (MN.Real.BrowserUC + MN.Virtual.BrowserUC)) - ) + ((nnflags & YAMN_ACC_MSGP) && !(MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || + ((nflags & YAMN_ACC_MSGP) && (MN.Real.BrowserUC + MN.Virtual.BrowserUC)) + ) ) || //if mail window was displayed before and flag YAMN_ACC_MSGP is set - ((nnflags & YAMN_ACC_MSG) && !(MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || //if needed to run mailbrowser when no unseen and no unseen mail found - ((nflags & YAMN_ACC_MSG) && (MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || //if unseen mails found, we sure run mailbrowser - ((nflags & YAMN_ACC_ICO) && (MN.Real.SysTrayUC + MN.Virtual.SysTrayUC)) + ((nnflags & YAMN_ACC_MSG) && !(MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || //if needed to run mailbrowser when no unseen and no unseen mail found + ((nflags & YAMN_ACC_MSG) && (MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || //if unseen mails found, we sure run mailbrowser + ((nflags & YAMN_ACC_ICO) && (MN.Real.SysTrayUC + MN.Virtual.SysTrayUC)) ) //if needed to run systray RunMailBrowser = TRUE; - else RunMailBrowser = FALSE; + else + RunMailBrowser = FALSE; - if ((nflags & YAMN_ACC_POP) && - (ActualAccount->Flags & YAMN_ACC_POPN) && - (MN.Real.PopupNC + MN.Virtual.PopupNC)) //if some popups with mails are needed to show + // if some popups with mails are needed to show + if ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (MN.Real.PopupNC + MN.Virtual.PopupNC)) RunPopups = TRUE; else RunPopups = FALSE; @@ -405,8 +402,7 @@ int UpdateMails(HWND hDlg, HACCOUNT ActualAccount, DWORD nflags, DWORD nnflags) if (RunMailBrowser || RunPopups) AddNewMailsToListView(hDlg == NULL ? NULL : GetDlgItem(hDlg, IDC_LISTMAILS), ActualAccount, nflags); - if (RunMailBrowser) - { + if (RunMailBrowser) { size_t len = mir_strlen(ActualAccount->Name) + mir_strlen(Translate(MAILBROWSERTITLE)) + 10; //+10 chars for numbers char *TitleStrA = new char[len]; WCHAR *TitleStrW = new WCHAR[len]; @@ -418,29 +414,28 @@ int UpdateMails(HWND hDlg, HACCOUNT ActualAccount, DWORD nflags, DWORD nnflags) delete[] TitleStrW; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:Do mail actions\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:Do mail actions\n"); + #endif DoMailActions(hDlg, ActualAccount, &MN, nflags, nnflags); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:Do mail actions done\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:Do mail actions done\n"); + #endif SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_NEW, 0, YAMN_MSG_NEW, YAMN_FLAG_REMOVE); //rempve the new flag if (!RunMailBrowser) SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_UNSEEN, YAMN_MSG_STAYUNSEEN, YAMN_MSG_UNSEEN, YAMN_FLAG_REMOVE); //remove the unseen flag when it was not displayed and it has not "stay unseen" flag set - if (mwui != NULL) - { + if (mwui != NULL) { mwui->UpdateMailsMessagesAccess = FALSE; mwui->RunFirstTime = FALSE; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write done\n"); - DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read done\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "UpdateMails:ActualAccountMsgsSO-write done\n"); + DebugLog(SynchroFile, "UpdateMails:ActualAccountSO-read done\n"); + #endif WriteDoneFcn(ActualAccount->MessagesAccessSO); ReadDoneFcn(ActualAccount->AccountAccessSO); @@ -461,8 +456,7 @@ int ChangeExistingMailStatus(HWND hListView, HACCOUNT ActualAccount) in = ListView_GetItemCount(hListView); item.mask = LVIF_PARAM; - for (i = 0; i < in; i++) - { + for (i = 0; i < in; i++) { item.iItem = i; item.iSubItem = 0; if (TRUE == ListView_GetItem(hListView, &item)) @@ -471,8 +465,7 @@ int ChangeExistingMailStatus(HWND hListView, HACCOUNT ActualAccount) continue; for (msgq = (HYAMNMAIL)ActualAccount->Mails; (msgq != NULL) && (msgq != mail); msgq = msgq->Next); //found the same mail in account queue if (msgq == NULL) //if mail was not found - if (TRUE == ListView_DeleteItem(hListView, i)) - { + if (TRUE == ListView_DeleteItem(hListView, i)) { in--; i--; continue; } @@ -501,8 +494,7 @@ int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, DWORD nflags) memset(&item, 0, sizeof(item)); memset(&UnicodeHeader, 0, sizeof(UnicodeHeader)); - if (hListView != NULL) - { + if (hListView != NULL) { item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = 0; memset(&fi, 0, sizeof(fi)); @@ -519,14 +511,12 @@ int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, DWORD nflags) NewMailPopup.PluginWindowProc = NewMailPopupProc; NewMailPopup.PluginData = (void *)0; //it's new mail popup - for (msgq = (HYAMNMAIL)ActualAccount->Mails; msgq != NULL; msgq = msgq->Next, lfoundi++) - { + for (msgq = (HYAMNMAIL)ActualAccount->Mails; msgq != NULL; msgq = msgq->Next, lfoundi++) { // now we hide mail pointer to item's lParam member. We can later use it to retrieve mail datas Extracted = FALSE; FromStr = NULL; FromStrNew = FALSE; - if (hListView != NULL) - { + if (hListView != NULL) { fi.lParam = (LPARAM)msgq; if (-1 != (foundi = ListView_FindItem(hListView, -1, &fi))) //if mail is already in window { @@ -548,8 +538,7 @@ int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, DWORD nflags) Loaded = true; if (((hListView != NULL) && (msgq->Flags & YAMN_MSG_DISPLAY)) || - ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (msgq->Flags & YAMN_MSG_POPUP) && (msgq->Flags & YAMN_MSG_NEW))) - { + ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (msgq->Flags & YAMN_MSG_POPUP) && (msgq->Flags & YAMN_MSG_NEW))) { if (!Extracted) ExtractHeader(msgq->MailData->TranslatedHeader, msgq->MailData->CP, &UnicodeHeader); Extracted = TRUE; @@ -590,7 +579,7 @@ int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, DWORD nflags) item.iSubItem = 3; item.pszText = L""; - for (CMimeItem *heads = msgq->MailData->TranslatedHeader; heads != NULL; heads = heads->Next) { + for (CMimeItem *heads = msgq->MailData->TranslatedHeader; heads != NULL; heads = heads->Next) { if (!_stricmp(heads->name, "Date")) { MimeDateToLocalizedDateTime(heads->value, LocalDateStr, 128); item.pszText = LocalDateStr; @@ -620,14 +609,12 @@ int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, DWORD nflags) if (FromStrNew) delete[] FromStr; - if (Extracted) - { + if (Extracted) { DeleteHeaderContent(&UnicodeHeader); memset(&UnicodeHeader, 0, sizeof(UnicodeHeader)); } - if (!Loaded) - { + if (!Loaded) { SaveMailData(msgq); UnloadMailData(msgq); //do not keep data for mail in memory } @@ -646,13 +633,11 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D if (MN->Real.EventNC + MN->Virtual.EventNC) NotifyEventHooks(hNewMailHook, 0, 0); - if ((nflags & YAMN_ACC_KBN) && (MN->Real.PopupRun + MN->Virtual.PopupRun)) - { + if ((nflags & YAMN_ACC_KBN) && (MN->Real.PopupRun + MN->Virtual.PopupRun)) { CallService(MS_KBDNOTIFY_STARTBLINK, (WPARAM)MN->Real.PopupNC + MN->Virtual.PopupNC, NULL); } - if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun + MN->Virtual.PopupRun)) - { + if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun + MN->Virtual.PopupRun)) { char sMsg[250]; mir_snprintf(sMsg, _countof(sMsg), Translate("%s : %d new mail message(s), %d total"), ActualAccount->Name, MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); if (!(nflags & YAMN_ACC_CONTNOEVENT)) { @@ -669,16 +654,14 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D } db_set_s(ActualAccount->hContact, "CList", "StatusMsg", sMsg); - if (nflags & YAMN_ACC_CONTNICK) - { + if (nflags & YAMN_ACC_CONTNICK) { db_set_s(ActualAccount->hContact, YAMN_DBMODULE, "Nick", sMsg); } } if ((nflags & YAMN_ACC_POP) && !(ActualAccount->Flags & YAMN_ACC_POPN) && - (MN->Real.PopupRun + MN->Virtual.PopupRun)) - { + (MN->Real.PopupRun + MN->Virtual.PopupRun)) { POPUPDATAT NewMailPopup = { 0 }; NewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; @@ -696,8 +679,7 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D } //destroy tray icon if no new mail - if ((MN->Real.SysTrayUC + MN->Virtual.SysTrayUC == 0) && (hDlg != NULL)) - { + if ((MN->Real.SysTrayUC + MN->Virtual.SysTrayUC == 0) && (hDlg != NULL)) { nid.hWnd = hDlg; nid.uID = 0; Shell_NotifyIcon(NIM_DELETE, &nid); @@ -708,8 +690,7 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D CallService(MS_CLIST_REMOVEEVENT, (WPARAM)ActualAccount->hContact, (LPARAM)ActualAccount->hContact); } - if ((MN->Real.BrowserUC + MN->Virtual.BrowserUC == 0) && (hDlg != NULL)) - { + if ((MN->Real.BrowserUC + MN->Virtual.BrowserUC == 0) && (hDlg != NULL)) { if (!IsWindowVisible(hDlg) && !(nflags & YAMN_ACC_MSG)) PostMessage(hDlg, WM_DESTROY, 0, 0); //destroy window if no new mail and window is not visible if (nnflags & YAMN_ACC_MSG) //if no new mail and msg should be executed @@ -723,8 +704,7 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D { SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_SCROLL, 0, (LPARAM)0x7ffffff); - if ((nflags & YAMN_ACC_ICO) && (MN->Real.SysTrayUC + MN->Virtual.SysTrayUC)) - { + if ((nflags & YAMN_ACC_ICO) && (MN->Real.SysTrayUC + MN->Virtual.SysTrayUC)) { char* src; TCHAR *dest; int i; @@ -745,25 +725,21 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D ShowWindow(hDlg, SW_SHOWNORMAL); } - if (MN->Real.AppNC + MN->Virtual.AppNC != 0) - { - if (nflags & YAMN_ACC_APP) - { + if (MN->Real.AppNC + MN->Virtual.AppNC != 0) { + if (nflags & YAMN_ACC_APP) { PROCESS_INFORMATION pi; STARTUPINFOW si; memset(&si, 0, sizeof(si)); si.cb = sizeof(si); - if (ActualAccount->NewMailN.App != NULL) - { + if (ActualAccount->NewMailN.App != NULL) { WCHAR *Command; if (ActualAccount->NewMailN.AppParam != NULL) Command = new WCHAR[mir_wstrlen(ActualAccount->NewMailN.App) + mir_wstrlen(ActualAccount->NewMailN.AppParam) + 6]; else Command = new WCHAR[mir_wstrlen(ActualAccount->NewMailN.App) + 6]; - if (Command != NULL) - { + if (Command != NULL) { mir_wstrcpy(Command, L"\""); mir_wstrcat(Command, ActualAccount->NewMailN.App); mir_wstrcat(Command, L"\" "); @@ -780,8 +756,7 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D if (nflags & YAMN_ACC_SND) CallService(MS_SKIN_PLAYSOUND, 0, (LPARAM)YAMN_NEWMAILSOUND); - if ((nnflags & YAMN_ACC_POP) && (MN->Real.PopupRun + MN->Virtual.PopupRun == 0)) - { + if ((nnflags & YAMN_ACC_POP) && (MN->Real.PopupRun + MN->Virtual.PopupRun == 0)) { POPUPDATAT NoNewMailPopup; NoNewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; @@ -801,12 +776,9 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D PUAddPopupT(&NoNewMailPopup); } - if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun + MN->Virtual.PopupRun == 0)) - { - if (ActualAccount->hContact != NULL) - { - if (MN->Real.PopupTC + MN->Virtual.PopupTC) - { + if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun + MN->Virtual.PopupRun == 0)) { + if (ActualAccount->hContact != NULL) { + if (MN->Real.PopupTC + MN->Virtual.PopupTC) { char tmp[255]; mir_snprintf(tmp, Translate("%d new mail message(s), %d total"), MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); db_set_s(ActualAccount->hContact, "CList", "StatusMsg", tmp); @@ -824,12 +796,10 @@ void __cdecl ShowEmailThread(void *Param); LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { INT_PTR PluginParam = 0; - switch (msg) - { + switch (msg) { case WM_COMMAND: //if clicked and it's new mail popup window - if ((HIWORD(wParam) == STN_CLICKED) && (-1 != (PluginParam = CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&PluginParam)))) - { + if ((HIWORD(wParam) == STN_CLICKED) && (-1 != (PluginParam = CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&PluginParam)))) { MCONTACT hContact = 0; HACCOUNT Account; if (PluginParam) { @@ -839,8 +809,7 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa Account = MailParam->account; if (NULL != (MailParam->ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) { HANDLE NewThread; - if (NULL != (NewThread = mir_forkthread(ShowEmailThread, (void*)MailParam))) - { + if (NULL != (NewThread = mir_forkthread(ShowEmailThread, (void*)MailParam))) { CloseHandle(NewThread); } CloseHandle(MailParam->ThreadRunningEV); @@ -852,8 +821,7 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); - if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) - { + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) { Account = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); db_free(&dbv); } @@ -861,35 +829,33 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa Account = (HACCOUNT)hContact; //???? -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); -#endif - if (WAIT_OBJECT_0 == WaitToReadFcn(Account->AccountAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); -#endif - switch (msg) - { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); + #endif + if (WAIT_OBJECT_0 == WaitToReadFcn(Account->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); + #endif + switch (msg) { case WM_COMMAND: - { - YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, Account, - (Account->NewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG, - (Account->NoNewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG }; + { + YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, Account, + (Account->NewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG, + (Account->NoNewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG }; - RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION); - } - break; + RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION); + } + break; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); + #endif ReadDoneFcn(Account->AccountAccessSO); } -#ifdef DEBUG_SYNCHRO + #ifdef DEBUG_SYNCHRO else - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); -#endif + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); + #endif } if ((Account->NewMailN.Flags & YAMN_ACC_CONT) && !(Account->NewMailN.Flags & YAMN_ACC_CONTNOEVENT)) { CallService(MS_CLIST_REMOVEEVENT, hContact, hContact); @@ -899,11 +865,12 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa case WM_CONTEXTMENU: SendMessageW(hWnd, UM_DESTROYPOPUP, 0, 0); break; - case UM_FREEPLUGINDATA:{ - PYAMN_MAILSHOWPARAM mpd = (PYAMN_MAILSHOWPARAM)PUGetPluginData(hWnd); - if ((mpd) && (INT_PTR)mpd != -1)free(mpd); - return FALSE; - } + case UM_FREEPLUGINDATA: + { + PYAMN_MAILSHOWPARAM mpd = (PYAMN_MAILSHOWPARAM)PUGetPluginData(hWnd); + if ((mpd) && (INT_PTR)mpd != -1)free(mpd); + return FALSE; + } case UM_INITPOPUP: //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. WindowList_Add(YAMNVar.MessageWnds, hWnd, NULL); @@ -912,26 +879,25 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa WindowList_Remove(YAMNVar.MessageWnds, hWnd); break; case WM_YAMN_STOPACCOUNT: - { - HACCOUNT ActualAccount; - MCONTACT hContact; - DBVARIANT dbv; + { + HACCOUNT ActualAccount; + MCONTACT hContact; + DBVARIANT dbv; - hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); + hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); - if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) - { - ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); - db_free(&dbv); - } - else - ActualAccount = (HACCOUNT)hContact; + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) { + ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); + db_free(&dbv); + } + else + ActualAccount = (HACCOUNT)hContact; - if ((HACCOUNT)wParam != ActualAccount) - break; - DestroyWindow(hWnd); - return 0; - } + if ((HACCOUNT)wParam != ActualAccount) + break; + DestroyWindow(hWnd); + return 0; + } case WM_NOTIFY: default: break; @@ -941,58 +907,53 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { + switch (msg) { case WM_COMMAND: - if ((HIWORD(wParam) == STN_CLICKED) && (msg == WM_COMMAND)) - { + if ((HIWORD(wParam) == STN_CLICKED) && (msg == WM_COMMAND)) { HACCOUNT ActualAccount; MCONTACT hContact; DBVARIANT dbv; hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); - if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) - { + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) { ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); db_free(&dbv); } else ActualAccount = (HACCOUNT)hContact; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); -#endif - if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); -#endif - switch (msg) - { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); + #endif + if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); + #endif + switch (msg) { case WM_COMMAND: - { - YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, 0 }; + { + YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, 0 }; - Param.nnflags = Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account - Param.nnflags = Param.nnflags & ~YAMN_ACC_POP; + Param.nnflags = Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account + Param.nnflags = Param.nnflags & ~YAMN_ACC_POP; - Param.nflags = Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account - Param.nflags = Param.nflags & ~YAMN_ACC_POP; + Param.nflags = Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account + Param.nflags = Param.nflags & ~YAMN_ACC_POP; - RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION); - } - break; + RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION); + } + break; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); + #endif ReadDoneFcn(ActualAccount->AccountAccessSO); } -#ifdef DEBUG_SYNCHRO + #ifdef DEBUG_SYNCHRO else - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); -#endif + DebugLog(SynchroFile, "PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); + #endif SendMessageW(hWnd, UM_DESTROYPOPUP, 0, 0); } break; @@ -1012,27 +973,26 @@ LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l WindowList_Remove(YAMNVar.MessageWnds, hWnd); break; case WM_YAMN_STOPACCOUNT: - { - HACCOUNT ActualAccount; - MCONTACT hContact; - DBVARIANT dbv; + { + HACCOUNT ActualAccount; + MCONTACT hContact; + DBVARIANT dbv; - hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); + hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); - if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) - { - ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); - db_free(&dbv); - } - else - ActualAccount = (HACCOUNT)hContact; + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) { + ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); + db_free(&dbv); + } + else + ActualAccount = (HACCOUNT)hContact; - if ((HACCOUNT)wParam != ActualAccount) - break; + if ((HACCOUNT)wParam != ActualAccount) + break; - DestroyWindow(hWnd); - return 0; - } + DestroyWindow(hWnd); + return 0; + } case WM_NOTIFY: /* switch(((LPNMHDR)lParam)->code) { @@ -1125,7 +1085,7 @@ ULONGLONG MimeDateToFileTime(char *datein) LONGLONG w100nano = Int32x32To64((DWORD)wShiftSeconds, 10000000); res -= w100nano; } - else{ + else { res = 0; } return res; @@ -1184,7 +1144,8 @@ void MimeDateToLocalizedDateTime(char *datein, WCHAR *dateout, int lendateout) FileTimeToLocalizedDateTime(ft, dateout, lendateout); } -int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { +int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) +{ if (lParam1 == NULL || lParam2 == NULL) return 0; @@ -1202,8 +1163,7 @@ int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo ExtractShortHeader(email1->MailData->TranslatedHeader, &Header1); ExtractShortHeader(email2->MailData->TranslatedHeader, &Header2); - switch ((int)lParamSort) - { + switch ((int)lParamSort) { case 0: //From if (Header1.FromNick == NULL) str1 = Header1.From; @@ -1233,22 +1193,22 @@ int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo case 2: //Size if (email1->MailData->Size == email2->MailData->Size) nResult = 0; if (email1->MailData->Size > email2->MailData->Size) nResult = 1; - if (email1->MailData->Size < email2->MailData->Size) nResult = -1; + if (email1->MailData->Size < email2->MailData->Size) nResult = -1; if (bSize) nResult = -nResult; break; case 3: //Date - { - ULONGLONG ts1 = 0, ts2 = 0; - ts1 = MimeDateToFileTime(Header1.Date); - ts2 = MimeDateToFileTime(Header2.Date); - if (ts1 > ts2) nResult = 1; - else if (ts1 < ts2) nResult = -1; - else nResult = 0; - } - if (bDate) nResult = -nResult; - break; + { + ULONGLONG ts1 = 0, ts2 = 0; + ts1 = MimeDateToFileTime(Header1.Date); + ts2 = MimeDateToFileTime(Header2.Date); + if (ts1 > ts2) nResult = 1; + else if (ts1 < ts2) nResult = -1; + else nResult = 0; + } + if (bDate) nResult = -nResult; + break; default: if (Header1.Subject == NULL) str1 = " "; @@ -1262,8 +1222,7 @@ int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo } //MessageBox(NULL,str1,str2,0); } - catch (...) - { + catch (...) { } //free mem @@ -1312,236 +1271,234 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPAR { switch (msg) { case WM_INITDIALOG: - { - PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)lParam; - WCHAR *iHeaderW = NULL; - WCHAR *iValueW = NULL; - int StrLen; - HWND hListView = GetDlgItem(hDlg, IDC_LISTHEADERS); - mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterSubclassProc); - SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)MailParam); - SendMessageW(hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)g_LoadIconEx(2, true)); - SendMessageW(hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_LoadIconEx(2)); - - ListView_SetUnicodeFormat(hListView, TRUE); - ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT); - - StrLen = MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Header"), -1, NULL, 0); - iHeaderW = new WCHAR[StrLen + 1]; - MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Header"), -1, iHeaderW, StrLen); - - StrLen = MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Value"), -1, NULL, 0); - iValueW = new WCHAR[StrLen + 1]; - MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Value"), -1, iValueW, StrLen); - - LVCOLUMNW lvc0 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, 130, iHeaderW, 0, 0 }; - LVCOLUMNW lvc1 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, 400, iValueW, 0, 0 }; - SendMessageW(hListView, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc0); - SendMessageW(hListView, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvc1); - if (NULL != iHeaderW) - delete[] iHeaderW; - if (NULL != iValueW) - delete[] iValueW; - - //WindowList_Add(YAMNVar.MessageWnds,hDlg,NULL); - //WindowList_Add(YAMNVar.NewMailAccountWnd,hDlg,ActualAccount); - SendMessage(hDlg, WM_YAMN_CHANGECONTENT, 0, (LPARAM)MailParam); - MoveWindow(hDlg, HeadPosX, HeadPosY, HeadSizeX, HeadSizeY, 0); - ShowWindow(hDlg, SW_SHOWNORMAL); - } - break; + { + PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)lParam; + WCHAR *iHeaderW = NULL; + WCHAR *iValueW = NULL; + int StrLen; + HWND hListView = GetDlgItem(hDlg, IDC_LISTHEADERS); + mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterSubclassProc); + SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)MailParam); + SendMessageW(hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)g_LoadIconEx(2, true)); + SendMessageW(hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_LoadIconEx(2)); + + ListView_SetUnicodeFormat(hListView, TRUE); + ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT); + + StrLen = MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Header"), -1, NULL, 0); + iHeaderW = new WCHAR[StrLen + 1]; + MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Header"), -1, iHeaderW, StrLen); + + StrLen = MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Value"), -1, NULL, 0); + iValueW = new WCHAR[StrLen + 1]; + MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Value"), -1, iValueW, StrLen); + + LVCOLUMNW lvc0 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, 130, iHeaderW, 0, 0 }; + LVCOLUMNW lvc1 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, 400, iValueW, 0, 0 }; + SendMessageW(hListView, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc0); + SendMessageW(hListView, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvc1); + if (NULL != iHeaderW) + delete[] iHeaderW; + if (NULL != iValueW) + delete[] iValueW; + + //WindowList_Add(YAMNVar.MessageWnds,hDlg,NULL); + //WindowList_Add(YAMNVar.NewMailAccountWnd,hDlg,ActualAccount); + SendMessage(hDlg, WM_YAMN_CHANGECONTENT, 0, (LPARAM)MailParam); + MoveWindow(hDlg, HeadPosX, HeadPosY, HeadSizeX, HeadSizeY, 0); + ShowWindow(hDlg, SW_SHOWNORMAL); + } + break; case WM_YAMN_CHANGECONTENT: - { - PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) - (lParam ? lParam : GetWindowLongPtr(hDlg, DWLP_USER)); - HWND hListView = GetDlgItem(hDlg, IDC_LISTHEADERS); - HWND hEdit = GetDlgItem(hDlg, IDC_EDITBODY); - //do not redraw - SendMessage(hListView, WM_SETREDRAW, 0, 0); - ListView_DeleteAllItems(hListView); - struct CMimeItem *Header; - LVITEMW item; - item.mask = LVIF_TEXT | LVIF_PARAM; - WCHAR *From = 0, *Subj = 0; - char *contentType = 0, *transEncoding = 0, *body = 0; //should not be delete[]-ed - for (Header = MailParam->mail->MailData->TranslatedHeader; Header != NULL; Header = Header->Next) { - WCHAR *str1 = 0; - WCHAR *str2 = 0; - WCHAR str_nul[2] = { 0 }; - if (!body) if (!_stricmp(Header->name, "Body")) { body = Header->value; continue; } - if (!contentType) if (!_stricmp(Header->name, "Content-Type")) contentType = Header->value; - if (!transEncoding) if (!_stricmp(Header->name, "Content-Transfer-Encoding")) transEncoding = Header->value; - //ConvertCodedStringToUnicode(Header->name,&str1,MailParam->mail->MailData->CP,1); - { - int streamsize = MultiByteToWideChar(20127, 0, Header->name, -1, NULL, 0); - str1 = (WCHAR *)malloc(sizeof(WCHAR) * (streamsize + 1)); - MultiByteToWideChar(20127, 0, Header->name, -1, str1, streamsize);//US-ASCII - } - ConvertCodedStringToUnicode(Header->value, &str2, MailParam->mail->MailData->CP, 1); - if (!str2) { str2 = (WCHAR *)str_nul; }// the header value may be NULL - if (!From) if (!_stricmp(Header->name, "From")) { - From = new WCHAR[mir_wstrlen(str2) + 1]; - mir_wstrcpy(From, str2); - } - if (!Subj) if (!_stricmp(Header->name, "Subject")) { - Subj = new WCHAR[mir_wstrlen(str2) + 1]; - mir_wstrcpy(Subj, str2); - } - //if (!hasBody) if (!mir_strcmp(Header->name,"Body")) hasBody = true; - int count = 0; WCHAR **split = 0; - int ofs = 0; - while (str2[ofs]) { - if ((str2[ofs] == 0x266A) || (str2[ofs] == 0x25D9) || (str2[ofs] == 0x25CB) || - (str2[ofs] == 0x09) || (str2[ofs] == 0x0A) || (str2[ofs] == 0x0D))count++; - ofs++; - } - split = new WCHAR*[count + 1]; - count = 0; ofs = 0; - split[0] = str2; - while (str2[ofs]) { - if ((str2[ofs] == 0x266A) || (str2[ofs] == 0x25D9) || (str2[ofs] == 0x25CB) || - (str2[ofs] == 0x09) || (str2[ofs] == 0x0A) || (str2[ofs] == 0x0D)) { - if (str2[ofs - 1]) { - count++; - } - split[count] = (WCHAR *)(str2 + ofs + 1); - str2[ofs] = 0; + PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) + (lParam ? lParam : GetWindowLongPtr(hDlg, DWLP_USER)); + HWND hListView = GetDlgItem(hDlg, IDC_LISTHEADERS); + HWND hEdit = GetDlgItem(hDlg, IDC_EDITBODY); + //do not redraw + SendMessage(hListView, WM_SETREDRAW, 0, 0); + ListView_DeleteAllItems(hListView); + struct CMimeItem *Header; + LVITEMW item; + item.mask = LVIF_TEXT | LVIF_PARAM; + WCHAR *From = 0, *Subj = 0; + char *contentType = 0, *transEncoding = 0, *body = 0; //should not be delete[]-ed + for (Header = MailParam->mail->MailData->TranslatedHeader; Header != NULL; Header = Header->Next) { + WCHAR *str1 = 0; + WCHAR *str2 = 0; + WCHAR str_nul[2] = { 0 }; + if (!body) if (!_stricmp(Header->name, "Body")) { body = Header->value; continue; } + if (!contentType) if (!_stricmp(Header->name, "Content-Type")) contentType = Header->value; + if (!transEncoding) if (!_stricmp(Header->name, "Content-Transfer-Encoding")) transEncoding = Header->value; + //ConvertCodedStringToUnicode(Header->name,&str1,MailParam->mail->MailData->CP,1); + { + int streamsize = MultiByteToWideChar(20127, 0, Header->name, -1, NULL, 0); + str1 = (WCHAR *)malloc(sizeof(WCHAR) * (streamsize + 1)); + MultiByteToWideChar(20127, 0, Header->name, -1, str1, streamsize);//US-ASCII } - ofs++; - }; + ConvertCodedStringToUnicode(Header->value, &str2, MailParam->mail->MailData->CP, 1); + if (!str2) { str2 = (WCHAR *)str_nul; }// the header value may be NULL + if (!From) if (!_stricmp(Header->name, "From")) { + From = new WCHAR[mir_wstrlen(str2) + 1]; + mir_wstrcpy(From, str2); + } + if (!Subj) if (!_stricmp(Header->name, "Subject")) { + Subj = new WCHAR[mir_wstrlen(str2) + 1]; + mir_wstrcpy(Subj, str2); + } + //if (!hasBody) if (!mir_strcmp(Header->name,"Body")) hasBody = true; + int count = 0; WCHAR **split = 0; + int ofs = 0; + while (str2[ofs]) { + if ((str2[ofs] == 0x266A) || (str2[ofs] == 0x25D9) || (str2[ofs] == 0x25CB) || + (str2[ofs] == 0x09) || (str2[ofs] == 0x0A) || (str2[ofs] == 0x0D))count++; + ofs++; + } + split = new WCHAR*[count + 1]; + count = 0; ofs = 0; + split[0] = str2; + while (str2[ofs]) { + if ((str2[ofs] == 0x266A) || (str2[ofs] == 0x25D9) || (str2[ofs] == 0x25CB) || + (str2[ofs] == 0x09) || (str2[ofs] == 0x0A) || (str2[ofs] == 0x0D)) { + if (str2[ofs - 1]) { + count++; + } + split[count] = (WCHAR *)(str2 + ofs + 1); + str2[ofs] = 0; + } + ofs++; + }; - if (!_stricmp(Header->name, "From") || !_stricmp(Header->name, "To") || !_stricmp(Header->name, "Date") || !_stricmp(Header->name, "Subject")) - item.iItem = 0; - else - item.iItem = 999; - for (int i = 0; i <= count; i++) { - item.iSubItem = 0; - if (i == 0) - item.pszText = str1; - else { - item.iItem++; - item.pszText = 0; + if (!_stricmp(Header->name, "From") || !_stricmp(Header->name, "To") || !_stricmp(Header->name, "Date") || !_stricmp(Header->name, "Subject")) + item.iItem = 0; + else + item.iItem = 999; + for (int i = 0; i <= count; i++) { + item.iSubItem = 0; + if (i == 0) + item.pszText = str1; + else { + item.iItem++; + item.pszText = 0; + } + item.iItem = SendMessageW(hListView, LVM_INSERTITEMW, 0, (LPARAM)&item); + item.iSubItem = 1; + item.pszText = str2 ? split[i] : 0; + SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); } - item.iItem = SendMessageW(hListView, LVM_INSERTITEMW, 0, (LPARAM)&item); - item.iSubItem = 1; - item.pszText = str2 ? split[i] : 0; - SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); - } - delete[] split; + delete[] split; - if (str1) - free(str1); - if (str2 != (WCHAR *)str_nul) - free(str2); - } - if (body) { - WCHAR *bodyDecoded = 0; - char *localBody = 0; - if (contentType) { - if (!_strnicmp(contentType, "text", 4)) { - if (transEncoding) { - if (!_stricmp(transEncoding, "base64")) { - int size = (int)mir_strlen(body) * 3 / 4 + 5; - localBody = new char[size + 1]; - DecodeBase64(body, localBody, size); - } - else if (!_stricmp(transEncoding, "quoted-printable")) { - int size = (int)mir_strlen(body) + 2; - localBody = new char[size + 1]; - DecodeQuotedPrintable(body, localBody, size, FALSE); + if (str1) + free(str1); + if (str2 != (WCHAR *)str_nul) + free(str2); + } + if (body) { + WCHAR *bodyDecoded = 0; + char *localBody = 0; + if (contentType) { + if (!_strnicmp(contentType, "text", 4)) { + if (transEncoding) { + if (!_stricmp(transEncoding, "base64")) { + int size = (int)mir_strlen(body) * 3 / 4 + 5; + localBody = new char[size + 1]; + DecodeBase64(body, localBody, size); + } + else if (!_stricmp(transEncoding, "quoted-printable")) { + int size = (int)mir_strlen(body) + 2; + localBody = new char[size + 1]; + DecodeQuotedPrintable(body, localBody, size, FALSE); + } } } - } - else if (!_strnicmp(contentType, "multipart/", 10)) { - char *bondary = NULL; - if (NULL != (bondary = ExtractFromContentType(contentType, "boundary="))) - { - bodyDecoded = ParseMultipartBody(body, bondary); - delete[] bondary; + else if (!_strnicmp(contentType, "multipart/", 10)) { + char *bondary = NULL; + if (NULL != (bondary = ExtractFromContentType(contentType, "boundary="))) { + bodyDecoded = ParseMultipartBody(body, bondary); + delete[] bondary; + } } } + if (!bodyDecoded)ConvertStringToUnicode(localBody ? localBody : body, MailParam->mail->MailData->CP, &bodyDecoded); + SetWindowTextW(hEdit, bodyDecoded); + delete[] bodyDecoded; + if (localBody) delete[] localBody; + SetFocus(hEdit); } - if (!bodyDecoded)ConvertStringToUnicode(localBody ? localBody : body, MailParam->mail->MailData->CP, &bodyDecoded); - SetWindowTextW(hEdit, bodyDecoded); - delete[] bodyDecoded; - if (localBody) delete[] localBody; - SetFocus(hEdit); - } - if (!(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)) { - MailParam->mail->Flags |= YAMN_MSG_BODYREQUESTED; - CallService(MS_YAMN_ACCOUNTCHECK, (WPARAM)MailParam->account, 0); - } - else { - if (MailParam->mail->Flags & YAMN_MSG_UNSEEN) { - MailParam->mail->Flags &= ~YAMN_MSG_UNSEEN; //mark the message as seen - HWND hMailBrowser; - if (hMailBrowser = WindowList_Find(YAMNVar.NewMailAccountWnd, (MCONTACT)MailParam->account)) { - struct CChangeContent Params = { MailParam->account->NewMailN.Flags | YAMN_ACC_MSGP, MailParam->account->NoNewMailN.Flags | YAMN_ACC_MSGP }; - SendMessageW(hMailBrowser, WM_YAMN_CHANGECONTENT, (WPARAM)MailParam->account, (LPARAM)&Params); + if (!(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)) { + MailParam->mail->Flags |= YAMN_MSG_BODYREQUESTED; + CallService(MS_YAMN_ACCOUNTCHECK, (WPARAM)MailParam->account, 0); + } + else { + if (MailParam->mail->Flags & YAMN_MSG_UNSEEN) { + MailParam->mail->Flags &= ~YAMN_MSG_UNSEEN; //mark the message as seen + HWND hMailBrowser; + if (hMailBrowser = WindowList_Find(YAMNVar.NewMailAccountWnd, (MCONTACT)MailParam->account)) { + struct CChangeContent Params = { MailParam->account->NewMailN.Flags | YAMN_ACC_MSGP, MailParam->account->NoNewMailN.Flags | YAMN_ACC_MSGP }; + SendMessageW(hMailBrowser, WM_YAMN_CHANGECONTENT, (WPARAM)MailParam->account, (LPARAM)&Params); + } + else UpdateMails(NULL, MailParam->account, MailParam->account->NewMailN.Flags, MailParam->account->NoNewMailN.Flags); } - else UpdateMails(NULL, MailParam->account, MailParam->account->NewMailN.Flags, MailParam->account->NoNewMailN.Flags); } - } - ShowWindow(GetDlgItem(hDlg, IDC_SPLITTER), (MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED) ? SW_SHOW : SW_HIDE); - ShowWindow(hEdit, (MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED) ? SW_SHOW : SW_HIDE); - WCHAR *title = 0; - size_t size = (From ? mir_wstrlen(From) : 0) + (Subj ? mir_wstrlen(Subj) : 0) + 4; - title = new WCHAR[size]; - if (From && Subj) - mir_sntprintf(title, size, L"%s (%s)", Subj, From); - else if (From) - _tcsncpy_s(title, size, From, _TRUNCATE); - else if (Subj) - _tcsncpy_s(title, size, Subj, _TRUNCATE); - else - _tcsncpy_s(title, size, L"none", _TRUNCATE); - if (Subj) delete[] Subj; - if (From) delete[] From; - SetWindowTextW(hDlg, title); - delete[] title; - // turn on redrawing - SendMessage(hListView, WM_SETREDRAW, 1, 0); - SendMessage(hDlg, WM_SIZE, 0, HeadSizeY << 16 | HeadSizeX); - } break; + ShowWindow(GetDlgItem(hDlg, IDC_SPLITTER), (MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED) ? SW_SHOW : SW_HIDE); + ShowWindow(hEdit, (MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED) ? SW_SHOW : SW_HIDE); + WCHAR *title = 0; + size_t size = (From ? mir_wstrlen(From) : 0) + (Subj ? mir_wstrlen(Subj) : 0) + 4; + title = new WCHAR[size]; + if (From && Subj) + mir_sntprintf(title, size, L"%s (%s)", Subj, From); + else if (From) + _tcsncpy_s(title, size, From, _TRUNCATE); + else if (Subj) + _tcsncpy_s(title, size, Subj, _TRUNCATE); + else + _tcsncpy_s(title, size, L"none", _TRUNCATE); + if (Subj) delete[] Subj; + if (From) delete[] From; + SetWindowTextW(hDlg, title); + delete[] title; + // turn on redrawing + SendMessage(hListView, WM_SETREDRAW, 1, 0); + SendMessage(hDlg, WM_SIZE, 0, HeadSizeY << 16 | HeadSizeX); + } break; case WM_YAMN_STOPACCOUNT: - { - PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) - (lParam ? lParam : GetWindowLongPtr(hDlg, DWLP_USER)); + { + PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) + (lParam ? lParam : GetWindowLongPtr(hDlg, DWLP_USER)); - if (NULL == MailParam) - break; - if ((HACCOUNT)wParam != MailParam->account) - break; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"ShowMessage:STOPACCOUNT:sending destroy msg\n"); -#endif - DestroyWindow(hDlg); - } - return 1; + if (NULL == MailParam) + break; + if ((HACCOUNT)wParam != MailParam->account) + break; + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "ShowMessage:STOPACCOUNT:sending destroy msg\n"); + #endif + DestroyWindow(hDlg); + } + return 1; case WM_CTLCOLORSTATIC: - //here should be check if this is our edittext control. - //but we have only one static control (for now); + // here should be check if this is our edittext control. + // but we have only one static control (for now); SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); case WM_DESTROY: - { - RECT coord; - if (GetWindowRect(hDlg, &coord)) { - HeadPosX = coord.left; - HeadSizeX = coord.right - coord.left; - HeadPosY = coord.top; - HeadSizeY = coord.bottom - coord.top; - } + { + RECT coord; + if (GetWindowRect(hDlg, &coord)) { + HeadPosX = coord.left; + HeadSizeX = coord.right - coord.left; + HeadPosY = coord.top; + HeadSizeY = coord.bottom - coord.top; + } - PostQuitMessage(1); - } - break; + PostQuitMessage(1); + } + break; case WM_SYSCOMMAND: switch (wParam) { @@ -1594,7 +1551,7 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPAR return 0; case WM_CONTEXTMENU: - if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == IDC_LISTHEADERS) { + if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == IDC_LISTHEADERS) { //MessageBox(0,"LISTHEADERS","Debug",0); HWND hList = GetDlgItem(hDlg, IDC_LISTHEADERS); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; @@ -1646,13 +1603,14 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPAR return 0; } -void __cdecl ShowEmailThread(void *Param) { +void __cdecl ShowEmailThread(void *Param) +{ struct MailShowMsgWinParam MyParam; MyParam = *(struct MailShowMsgWinParam *)Param; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"ShowMessage:Incrementing \"using threads\" %x (account %x)\n",MyParam.account->UsingThreads,MyParam.account); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "ShowMessage:Incrementing \"using threads\" %x (account %x)\n", MyParam.account->UsingThreads, MyParam.account); + #endif SCIncFcn(MyParam.account->UsingThreads); SetEvent(MyParam.ThreadRunningEV); if (MyParam.mail->MsgWindow) { @@ -1662,7 +1620,7 @@ void __cdecl ShowEmailThread(void *Param) { MyParam.mail->MsgWindow = 0; goto CREADTEVIEWMESSAGEWINDOW; } - else{ + else { if (IsIconic(MyParam.mail->MsgWindow)) { OpenIcon(MyParam.mail->MsgWindow); } @@ -1682,9 +1640,9 @@ void __cdecl ShowEmailThread(void *Param) { WindowList_Remove(YAMNVar.MessageWnds, MyParam.mail->MsgWindow); MyParam.mail->MsgWindow = NULL; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"ShowMessage:Decrementing \"using threads\" %x (account %x)\n",MyParam.account->UsingThreads,MyParam.account); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "ShowMessage:Decrementing \"using threads\" %x (account %x)\n", MyParam.account->UsingThreads, MyParam.account); + #endif SCDecFcn(MyParam.account->UsingThreads); delete Param; } @@ -1693,530 +1651,504 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR { switch (msg) { case WM_INITDIALOG: - { - HACCOUNT ActualAccount; - struct MailBrowserWinParam *MyParam = (struct MailBrowserWinParam *)lParam; - struct CMailWinUserInfo *mwui; - - ListView_SetUnicodeFormat(GetDlgItem(hDlg, IDC_LISTMAILS), TRUE); - ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_LISTMAILS), LVS_EX_FULLROWSELECT); - - ActualAccount = MyParam->account; - mwui = new struct CMailWinUserInfo; - mwui->Account = ActualAccount; - mwui->TrayIconState = 0; - mwui->UpdateMailsMessagesAccess = FALSE; - mwui->Seen = FALSE; - mwui->RunFirstTime = TRUE; - - SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)mwui); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read wait\n"); -#endif - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter failed\n"); -#endif - DestroyWindow(hDlg); - return FALSE; - } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter\n"); -#endif - - SetDlgItemTextW(hDlg, IDC_BTNAPP, TranslateW(L"Run application")); - SetDlgItemTextW(hDlg, IDC_BTNDEL, TranslateW(L"Delete selected")); - SetDlgItemTextW(hDlg, IDC_BTNCHECKALL, TranslateW(L"Select All")); - SetDlgItemTextW(hDlg, IDC_BTNOK, TranslateW(L"OK")); - - LVCOLUMNW lvc0 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, FromWidth, TranslateW(L"From"), 0, 0 }; - LVCOLUMNW lvc1 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SubjectWidth, TranslateW(L"Subject"), 0, 0 }; - LVCOLUMNW lvc2 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SizeWidth, TranslateW(L"Size"), 0, 0 }; - LVCOLUMNW lvc3 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SizeDate, TranslateW(L"Date"), 0, 0 }; - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc0); - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvc1); - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)2, (LPARAM)&lvc2); - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)3, (LPARAM)&lvc3); - - if ((ActualAccount->NewMailN.App != NULL) && (mir_wstrlen(ActualAccount->NewMailN.App))) - EnableWindow(GetDlgItem(hDlg, IDC_BTNAPP), TRUE); - else - EnableWindow(GetDlgItem(hDlg, IDC_BTNAPP), FALSE); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read done\n"); -#endif - ReadDoneFcn(ActualAccount->AccountAccessSO); + HACCOUNT ActualAccount; + struct MailBrowserWinParam *MyParam = (struct MailBrowserWinParam *)lParam; + struct CMailWinUserInfo *mwui; + + ListView_SetUnicodeFormat(GetDlgItem(hDlg, IDC_LISTMAILS), TRUE); + ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_LISTMAILS), LVS_EX_FULLROWSELECT); + + ActualAccount = MyParam->account; + mwui = new struct CMailWinUserInfo; + mwui->Account = ActualAccount; + mwui->TrayIconState = 0; + mwui->UpdateMailsMessagesAccess = FALSE; + mwui->Seen = FALSE; + mwui->RunFirstTime = TRUE; + + SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)mwui); + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:INIT:ActualAccountSO-read wait\n"); + #endif + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:INIT:ActualAccountSO-read enter failed\n"); + #endif + DestroyWindow(hDlg); + return FALSE; + } + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:INIT:ActualAccountSO-read enter\n"); + #endif + + SetDlgItemTextW(hDlg, IDC_BTNAPP, TranslateW(L"Run application")); + SetDlgItemTextW(hDlg, IDC_BTNDEL, TranslateW(L"Delete selected")); + SetDlgItemTextW(hDlg, IDC_BTNCHECKALL, TranslateW(L"Select All")); + SetDlgItemTextW(hDlg, IDC_BTNOK, TranslateW(L"OK")); + + LVCOLUMNW lvc0 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, FromWidth, TranslateW(L"From"), 0, 0 }; + LVCOLUMNW lvc1 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SubjectWidth, TranslateW(L"Subject"), 0, 0 }; + LVCOLUMNW lvc2 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SizeWidth, TranslateW(L"Size"), 0, 0 }; + LVCOLUMNW lvc3 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SizeDate, TranslateW(L"Date"), 0, 0 }; + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc0); + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvc1); + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)2, (LPARAM)&lvc2); + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)3, (LPARAM)&lvc3); + + if ((ActualAccount->NewMailN.App != NULL) && (mir_wstrlen(ActualAccount->NewMailN.App))) + EnableWindow(GetDlgItem(hDlg, IDC_BTNAPP), TRUE); + else + EnableWindow(GetDlgItem(hDlg, IDC_BTNAPP), FALSE); + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:INIT:ActualAccountSO-read done\n"); + #endif + ReadDoneFcn(ActualAccount->AccountAccessSO); - WindowList_Add(YAMNVar.MessageWnds, hDlg, NULL); - WindowList_Add(YAMNVar.NewMailAccountWnd, hDlg, (MCONTACT)ActualAccount); + WindowList_Add(YAMNVar.MessageWnds, hDlg, NULL); + WindowList_Add(YAMNVar.NewMailAccountWnd, hDlg, (MCONTACT)ActualAccount); - { - TCHAR accstatus[512]; - GetStatusFcn(ActualAccount, accstatus); - SetDlgItemText(hDlg, IDC_STSTATUS, accstatus); - } - SetTimer(hDlg, TIMER_FLASHING, 500, NULL); + { + TCHAR accstatus[512]; + GetStatusFcn(ActualAccount, accstatus); + SetDlgItemText(hDlg, IDC_STSTATUS, accstatus); + } + SetTimer(hDlg, TIMER_FLASHING, 500, NULL); - if (ActualAccount->hContact != NULL) - CallService(MS_CLIST_REMOVEEVENT, (WPARAM)ActualAccount->hContact, (LPARAM)"yamn new mail message"); + if (ActualAccount->hContact != NULL) + CallService(MS_CLIST_REMOVEEVENT, (WPARAM)ActualAccount->hContact, (LPARAM)"yamn new mail message"); - mir_subclassWindow(GetDlgItem(hDlg, IDC_LISTMAILS), ListViewSubclassProc); - } - break; + mir_subclassWindow(GetDlgItem(hDlg, IDC_LISTMAILS), ListViewSubclassProc); + } + break; case WM_DESTROY: - { - HACCOUNT ActualAccount; - RECT coord; - LVCOLUMNW ColInfo; - NOTIFYICONDATA nid; - HYAMNMAIL Parser; - struct CMailWinUserInfo *mwui; - - mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - break; - ColInfo.mask = LVCF_WIDTH; - if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 0, &ColInfo)) - FromWidth = ColInfo.cx; - if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 1, &ColInfo)) - SubjectWidth = ColInfo.cx; - if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 2, &ColInfo)) - SizeWidth = ColInfo.cx; - if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 3, &ColInfo)) - SizeDate = ColInfo.cx; - -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:save window position\n"); -#endif - if (!YAMNVar.Shutdown && GetWindowRect(hDlg, &coord)) //the YAMNVar.Shutdown testing is because M<iranda strange functionality at shutdown phase, when call to DBWriteContactSetting freezes calling thread { - PosX = coord.left; - SizeX = coord.right - coord.left; - PosY = coord.top; - SizeY = coord.bottom - coord.top; - db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSX, PosX); - db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSY, PosY); - db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEX, SizeX); - db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEY, SizeY); - } - KillTimer(hDlg, TIMER_FLASHING); - -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:remove window from list\n"); -#endif - WindowList_Remove(YAMNVar.NewMailAccountWnd, hDlg); - WindowList_Remove(YAMNVar.MessageWnds, hDlg); + HACCOUNT ActualAccount; + RECT coord; + LVCOLUMNW ColInfo; + NOTIFYICONDATA nid; + HYAMNMAIL Parser; + struct CMailWinUserInfo *mwui; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait\n"); -#endif - if (WAIT_OBJECT_0 != WaitToWriteFcn(ActualAccount->MessagesAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait failed\n"); -#endif - break; - } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write enter\n"); -#endif - //delete mails from queue, which are deleted from server (spam level 3 mails e.g.) - for (Parser = (HYAMNMAIL)ActualAccount->Mails; Parser != NULL; Parser = Parser->Next) - { - if ((Parser->Flags & YAMN_MSG_DELETED) && YAMN_MSG_SPAML(Parser->Flags, YAMN_MSG_SPAML3) && mwui->Seen) //if spaml3 was already deleted and user knows about it + mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; + ColInfo.mask = LVCF_WIDTH; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 0, &ColInfo)) + FromWidth = ColInfo.cx; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 1, &ColInfo)) + SubjectWidth = ColInfo.cx; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 2, &ColInfo)) + SizeWidth = ColInfo.cx; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 3, &ColInfo)) + SizeDate = ColInfo.cx; + + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DESTROY:save window position\n"); + #endif + if (!YAMNVar.Shutdown && GetWindowRect(hDlg, &coord)) //the YAMNVar.Shutdown testing is because M<iranda strange functionality at shutdown phase, when call to DBWriteContactSetting freezes calling thread { - DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails, Parser, 1); - CallService(MS_YAMN_DELETEACCOUNTMAIL, (WPARAM)ActualAccount->Plugin, (LPARAM)Parser); + PosX = coord.left; + SizeX = coord.right - coord.left; + PosY = coord.top; + SizeY = coord.bottom - coord.top; + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSX, PosX); + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSY, PosY); + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEX, SizeX); + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEY, SizeY); + } + KillTimer(hDlg, TIMER_FLASHING); + + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DESTROY:remove window from list\n"); + #endif + WindowList_Remove(YAMNVar.NewMailAccountWnd, hDlg); + WindowList_Remove(YAMNVar.MessageWnds, hDlg); + + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DESTROY:ActualAccountMsgsSO-write wait\n"); + #endif + if (WAIT_OBJECT_0 != WaitToWriteFcn(ActualAccount->MessagesAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DESTROY:ActualAccountMsgsSO-write wait failed\n"); + #endif + break; + } + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DESTROY:ActualAccountMsgsSO-write enter\n"); + #endif + //delete mails from queue, which are deleted from server (spam level 3 mails e.g.) + for (Parser = (HYAMNMAIL)ActualAccount->Mails; Parser != NULL; Parser = Parser->Next) { + if ((Parser->Flags & YAMN_MSG_DELETED) && YAMN_MSG_SPAML(Parser->Flags, YAMN_MSG_SPAML3) && mwui->Seen) //if spaml3 was already deleted and user knows about it + { + DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails, Parser, 1); + CallService(MS_YAMN_DELETEACCOUNTMAIL, (WPARAM)ActualAccount->Plugin, (LPARAM)Parser); + } } - } - //mark mails as read (remove "new" and "unseen" flags) - if (mwui->Seen) - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY, 0, YAMN_MSG_NEW | YAMN_MSG_UNSEEN, 0); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write done\n"); -#endif - WriteDoneFcn(ActualAccount->MessagesAccessSO); + //mark mails as read (remove "new" and "unseen" flags) + if (mwui->Seen) + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY, 0, YAMN_MSG_NEW | YAMN_MSG_UNSEEN, 0); + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DESTROY:ActualAccountMsgsSO-write done\n"); + #endif + WriteDoneFcn(ActualAccount->MessagesAccessSO); - memset(&nid, 0, sizeof(NOTIFYICONDATA)); + memset(&nid, 0, sizeof(NOTIFYICONDATA)); - delete mwui; - SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL); + delete mwui; + SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL); - nid.cbSize = sizeof(NOTIFYICONDATA); - nid.hWnd = hDlg; - nid.uID = 0; - Shell_NotifyIcon(NIM_DELETE, &nid); - PostQuitMessage(0); - } - break; + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hDlg; + nid.uID = 0; + Shell_NotifyIcon(NIM_DELETE, &nid); + PostQuitMessage(0); + } + break; case WM_SHOWWINDOW: - { - struct CMailWinUserInfo *mwui; + { + struct CMailWinUserInfo *mwui; - if (NULL == (mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER))) - return 0; - mwui->Seen = TRUE; - } + if (NULL == (mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER))) + return 0; + mwui->Seen = TRUE; + } case WM_YAMN_CHANGESTATUS: - { - HACCOUNT ActualAccount; - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - break; + { + HACCOUNT ActualAccount; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; - if ((HACCOUNT)wParam != ActualAccount) - break; + if ((HACCOUNT)wParam != ActualAccount) + break; - TCHAR accstatus[512]; - GetStatusFcn(ActualAccount, accstatus); - SetDlgItemText(hDlg, IDC_STSTATUS, accstatus); - } - return 1; + TCHAR accstatus[512]; + GetStatusFcn(ActualAccount, accstatus); + SetDlgItemText(hDlg, IDC_STSTATUS, accstatus); + } + return 1; case WM_YAMN_CHANGECONTENT: - { - struct CUpdateMails UpdateParams; - BOOL ThisThreadWindow = (GetCurrentThreadId() == GetWindowThreadProcessId(hDlg, NULL)); - - if (NULL == (UpdateParams.Copied = CreateEvent(NULL, FALSE, FALSE, NULL))) { - DestroyWindow(hDlg); - return 0; - } - UpdateParams.Flags = (struct CChangeContent *)lParam; - UpdateParams.Waiting = !ThisThreadWindow; + struct CUpdateMails UpdateParams; + BOOL ThisThreadWindow = (GetCurrentThreadId() == GetWindowThreadProcessId(hDlg, NULL)); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:posting UPDATEMAILS\n"); -#endif - if (ThisThreadWindow) - { - if (!UpdateMails(hDlg, (HACCOUNT)wParam, UpdateParams.Flags->nflags, UpdateParams.Flags->nnflags)) + if (NULL == (UpdateParams.Copied = CreateEvent(NULL, FALSE, FALSE, NULL))) { DestroyWindow(hDlg); - } - else if (PostMessage(hDlg, WM_YAMN_UPDATEMAILS, wParam, (LPARAM)&UpdateParams)) //this ensures UpdateMails will execute the thread who created the browser window - { - if (!ThisThreadWindow) + return 0; + } + UpdateParams.Flags = (struct CChangeContent *)lParam; + UpdateParams.Waiting = !ThisThreadWindow; + + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:CHANGECONTENT:posting UPDATEMAILS\n"); + #endif + if (ThisThreadWindow) { + if (!UpdateMails(hDlg, (HACCOUNT)wParam, UpdateParams.Flags->nflags, UpdateParams.Flags->nnflags)) + DestroyWindow(hDlg); + } + else if (PostMessage(hDlg, WM_YAMN_UPDATEMAILS, wParam, (LPARAM)&UpdateParams)) //this ensures UpdateMails will execute the thread who created the browser window { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:waiting for event\n"); -#endif - WaitForSingleObject(UpdateParams.Copied, INFINITE); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:event signaled\n"); -#endif + if (!ThisThreadWindow) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:CHANGECONTENT:waiting for event\n"); + #endif + WaitForSingleObject(UpdateParams.Copied, INFINITE); + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:CHANGECONTENT:event signaled\n"); + #endif + } } - } - CloseHandle(UpdateParams.Copied); - } - return 1; + CloseHandle(UpdateParams.Copied); + } + return 1; case WM_YAMN_UPDATEMAILS: - { - HACCOUNT ActualAccount; + { + HACCOUNT ActualAccount; - struct CUpdateMails *um = (struct CUpdateMails *)lParam; - DWORD nflags, nnflags; + struct CUpdateMails *um = (struct CUpdateMails *)lParam; + DWORD nflags, nnflags; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:UPDATEMAILS\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:UPDATEMAILS\n"); + #endif - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - return 0; - if ((HACCOUNT)wParam != ActualAccount) - return 0; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + return 0; + if ((HACCOUNT)wParam != ActualAccount) + return 0; - nflags = um->Flags->nflags; - nnflags = um->Flags->nnflags; + nflags = um->Flags->nflags; + nnflags = um->Flags->nnflags; - if (um->Waiting) - SetEvent(um->Copied); + if (um->Waiting) + SetEvent(um->Copied); - if (!UpdateMails(hDlg, ActualAccount, nflags, nnflags)) - DestroyWindow(hDlg); - } - return 1; + if (!UpdateMails(hDlg, ActualAccount, nflags, nnflags)) + DestroyWindow(hDlg); + } + return 1; case WM_YAMN_STOPACCOUNT: - { - HACCOUNT ActualAccount; + { + HACCOUNT ActualAccount; - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - break; - if ((HACCOUNT)wParam != ActualAccount) - break; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:STOPACCOUNT:sending destroy msg\n"); -#endif - PostQuitMessage(0); - } - return 1; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; + if ((HACCOUNT)wParam != ActualAccount) + break; + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:STOPACCOUNT:sending destroy msg\n"); + #endif + PostQuitMessage(0); + } + return 1; case WM_YAMN_NOTIFYICON: - { - HACCOUNT ActualAccount; - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - break; - - switch (lParam) { - case WM_LBUTTONDBLCLK: -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait\n"); -#endif - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait failed\n"); -#endif - return 0; - } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read enter\n"); -#endif - if (ActualAccount->AbilityFlags & YAMN_ACC_BROWSE) - { - ShowWindow(hDlg, SW_SHOWNORMAL); - SetForegroundWindow(hDlg); + HACCOUNT ActualAccount; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; + + switch (lParam) { + case WM_LBUTTONDBLCLK: + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DBLCLICKICON:ActualAccountSO-read wait\n"); + #endif + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DBLCLICKICON:ActualAccountSO-read wait failed\n"); + #endif + return 0; + } + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DBLCLICKICON:ActualAccountSO-read enter\n"); + #endif + if (ActualAccount->AbilityFlags & YAMN_ACC_BROWSE) { + ShowWindow(hDlg, SW_SHOWNORMAL); + SetForegroundWindow(hDlg); + } + else + DestroyWindow(hDlg); + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DBLCLICKICON:ActualAccountSO-read done\n"); + #endif + ReadDoneFcn(ActualAccount->AccountAccessSO); + break; } - else - DestroyWindow(hDlg); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read done\n"); -#endif - ReadDoneFcn(ActualAccount->AccountAccessSO); break; } - break; - } case WM_YAMN_SHOWSELECTED: - { - int iSelect; - iSelect = SendDlgItemMessage(hDlg, IDC_LISTMAILS, LVM_GETNEXTITEM, -1, MAKELPARAM((UINT)LVNI_FOCUSED, 0)); // return item selected - - if (iSelect != -1) { - LV_ITEMW item; - HYAMNMAIL ActualMail; + int iSelect; + iSelect = SendDlgItemMessage(hDlg, IDC_LISTMAILS, LVM_GETNEXTITEM, -1, MAKELPARAM((UINT)LVNI_FOCUSED, 0)); // return item selected - item.iItem = iSelect; - item.iSubItem = 0; - item.mask = LVIF_PARAM | LVIF_STATE; - item.stateMask = 0xFFFFFFFF; - ListView_GetItem(GetDlgItem(hDlg, IDC_LISTMAILS), &item); - ActualMail = (HYAMNMAIL)item.lParam; - if (NULL != ActualMail) - { - //ShowEmailThread - PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM; - MailParam->account = GetWindowAccount(hDlg); - MailParam->mail = ActualMail; - if (NULL != (MailParam->ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) { - HANDLE NewThread; - if (NULL != (NewThread = mir_forkthread(ShowEmailThread, (void*)MailParam))) - { - //WaitForSingleObject(MailParam->ThreadRunningEV,INFINITE); - CloseHandle(NewThread); + if (iSelect != -1) { + LV_ITEMW item; + HYAMNMAIL ActualMail; + + item.iItem = iSelect; + item.iSubItem = 0; + item.mask = LVIF_PARAM | LVIF_STATE; + item.stateMask = 0xFFFFFFFF; + ListView_GetItem(GetDlgItem(hDlg, IDC_LISTMAILS), &item); + ActualMail = (HYAMNMAIL)item.lParam; + if (NULL != ActualMail) { + //ShowEmailThread + PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM; + MailParam->account = GetWindowAccount(hDlg); + MailParam->mail = ActualMail; + if (NULL != (MailParam->ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) { + HANDLE NewThread; + if (NULL != (NewThread = mir_forkthread(ShowEmailThread, (void*)MailParam))) { + //WaitForSingleObject(MailParam->ThreadRunningEV,INFINITE); + CloseHandle(NewThread); + } + CloseHandle(MailParam->ThreadRunningEV); } - CloseHandle(MailParam->ThreadRunningEV); + //delete MailParam; } - //delete MailParam; } - } - } break; + } break; case WM_SYSCOMMAND: - { - HACCOUNT ActualAccount; - - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - break; - switch (wParam) { - case SC_CLOSE: - DestroyWindow(hDlg); - break; + HACCOUNT ActualAccount; + + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; + switch (wParam) { + case SC_CLOSE: + DestroyWindow(hDlg); + break; + } } - } - break; + break; case WM_COMMAND: - { - HACCOUNT ActualAccount; - int Items; - - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - break; - - switch (LOWORD(wParam)) - { - case IDC_BTNCHECKALL: - ListView_SetItemState(GetDlgItem(hDlg, IDC_LISTMAILS), -1, 0, LVIS_SELECTED); // deselect all items - ListView_SetItemState(GetDlgItem(hDlg, IDC_LISTMAILS), -1, LVIS_SELECTED, LVIS_SELECTED); - Items = ListView_GetItemCount(GetDlgItem(hDlg, IDC_LISTMAILS)); - ListView_RedrawItems(GetDlgItem(hDlg, IDC_LISTMAILS), 0, Items); - UpdateWindow(GetDlgItem(hDlg, IDC_LISTMAILS)); - SetFocus(GetDlgItem(hDlg, IDC_LISTMAILS)); - break; - - case IDC_BTNOK: - DestroyWindow(hDlg); - break; - - case IDC_BTNAPP: { - PROCESS_INFORMATION pi; - STARTUPINFOW si; - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); + HACCOUNT ActualAccount; + int Items; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read wait\n"); -#endif - if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter\n"); -#endif - if (ActualAccount->NewMailN.App != NULL) - { - WCHAR *Command; - if (ActualAccount->NewMailN.AppParam != NULL) - Command = new WCHAR[mir_wstrlen(ActualAccount->NewMailN.App) + mir_wstrlen(ActualAccount->NewMailN.AppParam) + 6]; - else - Command = new WCHAR[mir_wstrlen(ActualAccount->NewMailN.App) + 6]; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; - if (Command != NULL) - { - mir_wstrcpy(Command, L"\""); - mir_wstrcat(Command, ActualAccount->NewMailN.App); - mir_wstrcat(Command, L"\" "); - if (ActualAccount->NewMailN.AppParam != NULL) - mir_wstrcat(Command, ActualAccount->NewMailN.AppParam); - CreateProcessW(NULL, Command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); - delete[] Command; - } - } + switch (LOWORD(wParam)) { + case IDC_BTNCHECKALL: + ListView_SetItemState(GetDlgItem(hDlg, IDC_LISTMAILS), -1, 0, LVIS_SELECTED); // deselect all items + ListView_SetItemState(GetDlgItem(hDlg, IDC_LISTMAILS), -1, LVIS_SELECTED, LVIS_SELECTED); + Items = ListView_GetItemCount(GetDlgItem(hDlg, IDC_LISTMAILS)); + ListView_RedrawItems(GetDlgItem(hDlg, IDC_LISTMAILS), 0, Items); + UpdateWindow(GetDlgItem(hDlg, IDC_LISTMAILS)); + SetFocus(GetDlgItem(hDlg, IDC_LISTMAILS)); + break; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read done\n"); -#endif - ReadDoneFcn(ActualAccount->AccountAccessSO); - } -#ifdef DEBUG_SYNCHRO - else - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter failed\n"); -#endif - if (!(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000)) + case IDC_BTNOK: DestroyWindow(hDlg); - - } - break; - case IDC_BTNDEL: - { - LVITEMW item; - HYAMNMAIL ActualMail; - HANDLE ThreadRunningEV; - DWORD Total = 0; - - // we use event to signal, that running thread has all needed stack parameters copied - if (NULL == (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) break; - int Items = ListView_GetItemCount(GetDlgItem(hDlg, IDC_LISTMAILS)); - item.stateMask = 0xFFFFFFFF; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); -#endif - if (WAIT_OBJECT_0 == WaitToWriteFcn(ActualAccount->MessagesAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); -#endif - for (int i = 0; i < Items; i++) + case IDC_BTNAPP: { - item.iItem = i; - item.iSubItem = 0; - item.mask = LVIF_PARAM | LVIF_STATE; - item.stateMask = 0xFFFFFFFF; - ListView_GetItem(GetDlgItem(hDlg, IDC_LISTMAILS), &item); - ActualMail = (HYAMNMAIL)item.lParam; - if (NULL == ActualMail) - break; - if (item.state & LVIS_SELECTED) - { - ActualMail->Flags |= YAMN_MSG_USERDELETE; //set to mail we are going to delete it - Total++; - } - } + PROCESS_INFORMATION pi; + STARTUPINFOW si; + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNAPP:ActualAccountSO-read wait\n"); + #endif + if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNAPP:ActualAccountSO-read enter\n"); + #endif + if (ActualAccount->NewMailN.App != NULL) { + WCHAR *Command; + if (ActualAccount->NewMailN.AppParam != NULL) + Command = new WCHAR[mir_wstrlen(ActualAccount->NewMailN.App) + mir_wstrlen(ActualAccount->NewMailN.AppParam) + 6]; + else + Command = new WCHAR[mir_wstrlen(ActualAccount->NewMailN.App) + 6]; + + if (Command != NULL) { + mir_wstrcpy(Command, L"\""); + mir_wstrcat(Command, ActualAccount->NewMailN.App); + mir_wstrcat(Command, L"\" "); + if (ActualAccount->NewMailN.AppParam != NULL) + mir_wstrcat(Command, ActualAccount->NewMailN.AppParam); + CreateProcessW(NULL, Command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); + delete[] Command; + } + } - // Enable write-access to mails -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); -#endif - WriteDoneFcn(ActualAccount->MessagesAccessSO); + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNAPP:ActualAccountSO-read done\n"); + #endif + ReadDoneFcn(ActualAccount->AccountAccessSO); + } + #ifdef DEBUG_SYNCHRO + else + DebugLog(SynchroFile, "MailBrowser:BTNAPP:ActualAccountSO-read enter failed\n"); + #endif + if (!(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000)) + DestroyWindow(hDlg); - if (Total) + } + break; + case IDC_BTNDEL: { - TCHAR DeleteMsg[1024]; + LVITEMW item; + HYAMNMAIL ActualMail; + HANDLE ThreadRunningEV; + DWORD Total = 0; - mir_sntprintf(DeleteMsg, _countof(DeleteMsg), TranslateT("Do you really want to delete %d selected mails?"), Total); - if (IDOK == MessageBox(hDlg, DeleteMsg, TranslateT("Delete confirmation"), MB_OKCANCEL | MB_ICONWARNING)) - { - struct DeleteParam ParamToDeleteMails = { YAMN_DELETEVERSION, ThreadRunningEV, ActualAccount, NULL }; + // we use event to signal, that running thread has all needed stack parameters copied + if (NULL == (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) + break; + int Items = ListView_GetItemCount(GetDlgItem(hDlg, IDC_LISTMAILS)); - // Find if there's mail marked to delete, which was deleted before -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); -#endif - if (WAIT_OBJECT_0 == WaitToWriteFcn(ActualAccount->MessagesAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); -#endif - for (ActualMail = (HYAMNMAIL)ActualAccount->Mails; ActualMail != NULL; ActualMail = ActualMail->Next) - { - if ((ActualMail->Flags & YAMN_MSG_DELETED) && ((ActualMail->Flags & YAMN_MSG_USERDELETE))) //if selected mail was already deleted - { - DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails, ActualMail, 1); - CallService(MS_YAMN_DELETEACCOUNTMAIL, (WPARAM)ActualAccount->Plugin, (LPARAM)ActualMail); //delete it from memory - continue; - } + item.stateMask = 0xFFFFFFFF; + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); + #endif + if (WAIT_OBJECT_0 == WaitToWriteFcn(ActualAccount->MessagesAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); + #endif + for (int i = 0; i < Items; i++) { + item.iItem = i; + item.iSubItem = 0; + item.mask = LVIF_PARAM | LVIF_STATE; + item.stateMask = 0xFFFFFFFF; + ListView_GetItem(GetDlgItem(hDlg, IDC_LISTMAILS), &item); + ActualMail = (HYAMNMAIL)item.lParam; + if (NULL == ActualMail) + break; + if (item.state & LVIS_SELECTED) { + ActualMail->Flags |= YAMN_MSG_USERDELETE; //set to mail we are going to delete it + Total++; } - // Set flag to marked mails that they can be deleted - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE, 0, YAMN_MSG_DELETEOK, 1); - // Create new thread which deletes marked mails. - HANDLE NewThread; + } - if (NULL != (NewThread = mir_forkthread(ActualAccount->Plugin->Fcn->DeleteMailsFcnPtr, (void*)&ParamToDeleteMails))) - { - WaitForSingleObject(ThreadRunningEV, INFINITE); - CloseHandle(NewThread); + // Enable write-access to mails + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); + #endif + WriteDoneFcn(ActualAccount->MessagesAccessSO); + + if (Total) { + TCHAR DeleteMsg[1024]; + + mir_sntprintf(DeleteMsg, _countof(DeleteMsg), TranslateT("Do you really want to delete %d selected mails?"), Total); + if (IDOK == MessageBox(hDlg, DeleteMsg, TranslateT("Delete confirmation"), MB_OKCANCEL | MB_ICONWARNING)) { + struct DeleteParam ParamToDeleteMails = { YAMN_DELETEVERSION, ThreadRunningEV, ActualAccount, NULL }; + + // Find if there's mail marked to delete, which was deleted before + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); + #endif + if (WAIT_OBJECT_0 == WaitToWriteFcn(ActualAccount->MessagesAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); + #endif + for (ActualMail = (HYAMNMAIL)ActualAccount->Mails; ActualMail != NULL; ActualMail = ActualMail->Next) { + if ((ActualMail->Flags & YAMN_MSG_DELETED) && ((ActualMail->Flags & YAMN_MSG_USERDELETE))) //if selected mail was already deleted + { + DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails, ActualMail, 1); + CallService(MS_YAMN_DELETEACCOUNTMAIL, (WPARAM)ActualAccount->Plugin, (LPARAM)ActualMail); //delete it from memory + continue; + } + } + // Set flag to marked mails that they can be deleted + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE, 0, YAMN_MSG_DELETEOK, 1); + // Create new thread which deletes marked mails. + HANDLE NewThread; + + if (NULL != (NewThread = mir_forkthread(ActualAccount->Plugin->Fcn->DeleteMailsFcnPtr, (void*)&ParamToDeleteMails))) { + WaitForSingleObject(ThreadRunningEV, INFINITE); + CloseHandle(NewThread); + } + // Enable write-access to mails + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); + #endif + WriteDoneFcn(ActualAccount->MessagesAccessSO); + } } - // Enable write-access to mails -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); -#endif - WriteDoneFcn(ActualAccount->MessagesAccessSO); + else + //else mark messages that they are not to be deleted + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE, 0, YAMN_MSG_USERDELETE, 0); } } - else - //else mark messages that they are not to be deleted - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE, 0, YAMN_MSG_USERDELETE, 0); + CloseHandle(ThreadRunningEV); + if (db_get_b(NULL, YAMN_DBMODULE, YAMN_CLOSEDELETE, 0)) + DestroyWindow(hDlg); + } + break; } - CloseHandle(ThreadRunningEV); - if (db_get_b(NULL, YAMN_DBMODULE, YAMN_CLOSEDELETE, 0)) - DestroyWindow(hDlg); - } break; - } - } - break; case WM_SIZE: - if (wParam == SIZE_RESTORED) - { + if (wParam == SIZE_RESTORED) { LONG x = LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left; LONG y = HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top; MoveWindow(GetDlgItem(hDlg, IDC_BTNDEL), 5, y - 5 - 25, (x - 20) / 3, 25, TRUE); //where to put DELETE button while resizing @@ -2233,24 +2165,24 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = MAILBROWSER_MINYSIZE; return 0; case WM_TIMER: - { - NOTIFYICONDATA nid; - struct CMailWinUserInfo *mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); - - memset(&nid, 0, sizeof(nid)); - nid.cbSize = sizeof(NOTIFYICONDATA); - nid.hWnd = hDlg; - nid.uID = 0; - nid.uFlags = NIF_ICON; - if (mwui->TrayIconState == 0) - nid.hIcon = g_LoadIconEx(0); - else - nid.hIcon = g_LoadIconEx(2); - Shell_NotifyIcon(NIM_MODIFY, &nid); - mwui->TrayIconState = !mwui->TrayIconState; - // UpdateWindow(hDlg); - } - break; + { + NOTIFYICONDATA nid; + struct CMailWinUserInfo *mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); + + memset(&nid, 0, sizeof(nid)); + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hDlg; + nid.uID = 0; + nid.uFlags = NIF_ICON; + if (mwui->TrayIconState == 0) + nid.hIcon = g_LoadIconEx(0); + else + nid.hIcon = g_LoadIconEx(2); + Shell_NotifyIcon(NIM_MODIFY, &nid); + mwui->TrayIconState = !mwui->TrayIconState; + // UpdateWindow(hDlg); + } + break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { @@ -2263,13 +2195,11 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR HACCOUNT ActualAccount; if (NULL != (ActualAccount = GetWindowAccount(hDlg))) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam; - if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:COLUMNCLICK:ActualAccountSO-read enter\n"); -#endif - switch ((int)pNMListView->iSubItem) - { + if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:COLUMNCLICK:ActualAccountSO-read enter\n"); + #endif + switch ((int)pNMListView->iSubItem) { case 0: bFrom = !bFrom; break; @@ -2286,100 +2216,97 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR break; } ListView_SortItems(pNMListView->hdr.hwndFrom, ListViewCompareProc, pNMListView->iSubItem); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read done\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:BTNAPP:ActualAccountSO-read done\n"); + #endif ReadDoneFcn(ActualAccount->AccountAccessSO); } } break; case NM_CUSTOMDRAW: - { - HACCOUNT ActualAccount; - LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam; - LONG_PTR PaintCode; - - if (NULL == (ActualAccount = GetWindowAccount(hDlg))) - break; - - switch (cd->nmcd.dwDrawStage) { - case CDDS_PREPAINT: - PaintCode = CDRF_NOTIFYITEMDRAW; - break; - case CDDS_ITEMPREPAINT: - PaintCode = CDRF_NOTIFYSUBITEMDRAW; - break; - case CDDS_ITEMPREPAINT | CDDS_SUBITEM: { - // COLORREF crText, crBkgnd; - // crText= RGB(128,128,255); - HYAMNMAIL ActualMail; - BOOL umma; + HACCOUNT ActualAccount; + LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam; + LONG_PTR PaintCode; - { - struct CMailWinUserInfo *mwui; - mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); - umma = mwui->UpdateMailsMessagesAccess; - } - ActualMail = (HYAMNMAIL)cd->nmcd.lItemlParam; - if (!ActualMail) - ActualMail = (HYAMNMAIL)readItemLParam(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait\n"); -#endif - if (!umma) - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->MessagesAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait failed\n"); -#endif - return 0; - } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read enter\n"); -#endif - switch (ActualMail->Flags & YAMN_MSG_SPAMMASK) - { - case YAMN_MSG_SPAML1: - case YAMN_MSG_SPAML2: - cd->clrText = RGB(150, 150, 150); - break; - case YAMN_MSG_SPAML3: - cd->clrText = RGB(200, 200, 200); - cd->clrTextBk = RGB(160, 160, 160); + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) break; - case 0: - if (cd->nmcd.dwItemSpec & 1) - cd->clrTextBk = RGB(230, 230, 230); + + switch (cd->nmcd.dwDrawStage) { + case CDDS_PREPAINT: + PaintCode = CDRF_NOTIFYITEMDRAW; break; - default: + case CDDS_ITEMPREPAINT: + PaintCode = CDRF_NOTIFYSUBITEMDRAW; break; - } - if (ActualMail->Flags & YAMN_MSG_UNSEEN) - cd->clrTextBk = RGB(220, 235, 250); - PaintCode = CDRF_DODEFAULT; + case CDDS_ITEMPREPAINT | CDDS_SUBITEM: + { + // COLORREF crText, crBkgnd; + // crText= RGB(128,128,255); + HYAMNMAIL ActualMail; + BOOL umma; - if (!umma) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read done\n"); -#endif - ReadDoneFcn(ActualAccount->MessagesAccessSO); - } + { + struct CMailWinUserInfo *mwui; + mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); + umma = mwui->UpdateMailsMessagesAccess; + } + ActualMail = (HYAMNMAIL)cd->nmcd.lItemlParam; + if (!ActualMail) + ActualMail = (HYAMNMAIL)readItemLParam(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec); + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait\n"); + #endif + if (!umma) + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->MessagesAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait failed\n"); + #endif + return 0; + } + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DRAWITEM:ActualAccountMsgsSO-read enter\n"); + #endif + switch (ActualMail->Flags & YAMN_MSG_SPAMMASK) { + case YAMN_MSG_SPAML1: + case YAMN_MSG_SPAML2: + cd->clrText = RGB(150, 150, 150); + break; + case YAMN_MSG_SPAML3: + cd->clrText = RGB(200, 200, 200); + cd->clrTextBk = RGB(160, 160, 160); + break; + case 0: + if (cd->nmcd.dwItemSpec & 1) + cd->clrTextBk = RGB(230, 230, 230); + break; + default: + break; + } + if (ActualMail->Flags & YAMN_MSG_UNSEEN) + cd->clrTextBk = RGB(220, 235, 250); + PaintCode = CDRF_DODEFAULT; + + if (!umma) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:DRAWITEM:ActualAccountMsgsSO-read done\n"); + #endif + ReadDoneFcn(ActualAccount->MessagesAccessSO); + } - break; - } + break; + } + } + SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PaintCode); + return 1; } - SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PaintCode); - return 1; - } } } break; case WM_CONTEXTMENU: - if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == IDC_LISTMAILS) { + if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == IDC_LISTMAILS) { //MessageBox(0,"LISTHEADERS","Debug",0); HWND hList = GetDlgItem(hDlg, IDC_LISTMAILS); POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; @@ -2438,39 +2365,38 @@ LRESULT CALLBACK ListViewSubclassProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM switch (msg) { case WM_GETDLGCODE: - { - LPMSG lpmsg; - if ((lpmsg = (LPMSG)lParam) != NULL) { - if (lpmsg->message == WM_KEYDOWN - && lpmsg->wParam == VK_RETURN) - return DLGC_WANTALLKEYS; + { + LPMSG lpmsg; + if ((lpmsg = (LPMSG)lParam) != NULL) { + if (lpmsg->message == WM_KEYDOWN + && lpmsg->wParam == VK_RETURN) + return DLGC_WANTALLKEYS; + } + break; } - break; - } case WM_KEYDOWN: - { + { - BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000; - BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000; - BOOL isAlt = GetKeyState(VK_MENU) & 0x8000; + BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000; + BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000; + BOOL isAlt = GetKeyState(VK_MENU) & 0x8000; - switch (wParam) - { - case 'A': // ctrl-a - if (!isAlt && !isShift && isCtrl) SendMessage(hwndParent, WM_COMMAND, IDC_BTNCHECKALL, 0); - break; - case VK_RETURN: - case VK_SPACE: - if (!isAlt && !isShift && !isCtrl) SendMessage(hwndParent, WM_YAMN_SHOWSELECTED, 0, 0); - break; - case VK_DELETE: - SendMessage(hwndParent, WM_COMMAND, IDC_BTNDEL, 0); - break; - } + switch (wParam) { + case 'A': // ctrl-a + if (!isAlt && !isShift && isCtrl) SendMessage(hwndParent, WM_COMMAND, IDC_BTNCHECKALL, 0); + break; + case VK_RETURN: + case VK_SPACE: + if (!isAlt && !isShift && !isCtrl) SendMessage(hwndParent, WM_YAMN_SHOWSELECTED, 0, 0); + break; + case VK_DELETE: + SendMessage(hwndParent, WM_COMMAND, IDC_BTNDEL, 0); + break; + } - break; + break; - } + } } return mir_callNextSubclass(hDlg, ListViewSubclassProc, msg, wParam, lParam); } @@ -2486,53 +2412,48 @@ void __cdecl MailBrowser(void *Param) MyParam = *(struct MailBrowserWinParam *)Param; ActualAccount = MyParam.account; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:Incrementing \"using threads\" %x (account %x)\n", ActualAccount->UsingThreads, ActualAccount); + #endif SCIncFcn(ActualAccount->UsingThreads); // we will not use params in stack anymore SetEvent(MyParam.ThreadRunningEV); - __try - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read wait\n"); -#endif - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read wait failed\n"); -#endif + __try { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:ActualAccountSO-read wait\n"); + #endif + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:ActualAccountSO-read wait failed\n"); + #endif return; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read enter\n"); -#endif - if (!(ActualAccount->AbilityFlags & YAMN_ACC_BROWSE)) - { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:ActualAccountSO-read enter\n"); + #endif + if (!(ActualAccount->AbilityFlags & YAMN_ACC_BROWSE)) { MyParam.nflags = MyParam.nflags & ~YAMN_ACC_MSG; MyParam.nnflags = MyParam.nnflags & ~YAMN_ACC_MSG; } if (!(ActualAccount->AbilityFlags & YAMN_ACC_POPUP)) MyParam.nflags = MyParam.nflags & ~YAMN_ACC_POP; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read done\n"); -#endif + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:ActualAccountSO-read done\n"); + #endif ReadDoneFcn(ActualAccount->AccountAccessSO); if (NULL != (hMailBrowser = WindowList_Find(YAMNVar.NewMailAccountWnd, (MCONTACT)ActualAccount))) WndFound = TRUE; - if ((hMailBrowser == NULL) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG))) - { + if ((hMailBrowser == NULL) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG))) { hMailBrowser = CreateDialogParamW(YAMNVar.hInst, MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES), NULL, DlgProcYAMNMailBrowser, (LPARAM)&MyParam); SendMessageW(hMailBrowser, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)g_LoadIconEx(2, true)); SendMessageW(hMailBrowser, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_LoadIconEx(2)); MoveWindow(hMailBrowser, PosX, PosY, SizeX, SizeY, TRUE); } - if (hMailBrowser != NULL) - { + if (hMailBrowser != NULL) { struct CChangeContent Params = { MyParam.nflags, MyParam.nnflags }; //if this thread created window, just post message to update mails SendMessageW(hMailBrowser, WM_YAMN_CHANGECONTENT, (WPARAM)ActualAccount, (LPARAM)&Params); //we ensure this will do the thread who created the browser window @@ -2542,8 +2463,7 @@ void __cdecl MailBrowser(void *Param) if ((hMailBrowser != NULL) && !WndFound) //we process message loop only for thread that created window { - while (GetMessage(&msg, NULL, 0, 0)) - { + while (GetMessage(&msg, NULL, 0, 0)) { if (hMailBrowser == NULL || !IsDialogMessage(hMailBrowser, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); @@ -2554,11 +2474,10 @@ void __cdecl MailBrowser(void *Param) if ((!WndFound) && (ActualAccount->Plugin->Fcn != NULL) && (ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr != NULL) && ActualAccount->AbleToWork) ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr(); } - __finally - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount); -#endif + __finally { + #ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile, "MailBrowser:Decrementing \"using threads\" %x (account %x)\n", ActualAccount->UsingThreads, ActualAccount); + #endif SCDecFcn(ActualAccount->UsingThreads); } } @@ -2572,13 +2491,11 @@ INT_PTR RunMailBrowserSvc(WPARAM wParam, LPARAM lParam) if ((DWORD)lParam != YAMN_MAILBROWSERVERSION) return 0; - if (NULL != (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) - { + if (NULL != (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) { HANDLE NewThread; Param->ThreadRunningEV = ThreadRunningEV; - if (NULL != (NewThread = mir_forkthread(MailBrowser, (void*)Param))) - { + if (NULL != (NewThread = mir_forkthread(MailBrowser, (void*)Param))) { WaitForSingleObject(ThreadRunningEV, INFINITE); CloseHandle(NewThread); } |