diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-15 16:26:10 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-15 16:26:10 +0000 |
commit | 7fe6e93058f0e9253e2a79d7fc2d7a136784f791 (patch) | |
tree | 861225801bcda335939cac2fa6ddc6083f52f51f /protocols | |
parent | 21e84e8d5012cc0b600f27a4d796d3813b29a16c (diff) |
various popup related code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@4056 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Gadu-Gadu/src/popups.cpp | 49 | ||||
-rw-r--r-- | protocols/MRA/src/MraPopUp.cpp | 11 | ||||
-rw-r--r-- | protocols/MSN/src/msn_misc.cpp | 35 | ||||
-rw-r--r-- | protocols/Tlen/src/jabber_opt.cpp | 28 | ||||
-rw-r--r-- | protocols/Xfire/src/tools.cpp | 25 |
5 files changed, 57 insertions, 91 deletions
diff --git a/protocols/Gadu-Gadu/src/popups.cpp b/protocols/Gadu-Gadu/src/popups.cpp index 69ac1c350d..386435c973 100644 --- a/protocols/Gadu-Gadu/src/popups.cpp +++ b/protocols/Gadu-Gadu/src/popups.cpp @@ -110,8 +110,7 @@ void CALLBACK sttMainThreadCallback(PVOID dwParam) PopupData* puData = (PopupData*)dwParam;
GGPROTO* gg = puData->gg;
- if (ServiceExists(MS_POPUP_ADDPOPUPCLASS))
- {
+ if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
char szName[256];
POPUPDATACLASS ppd = {sizeof(ppd)};
ppd.ptszTitle = puData->title;
@@ -125,46 +124,38 @@ void CALLBACK sttMainThreadCallback(PVOID dwParam) mir_snprintf(szName, SIZEOF(szName), "%s_%s", gg->m_szModuleName, "Notify");
CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd);
+ return;
}
- else
- {
- if (puData->flags & GG_POPUP_ALLOW_MSGBOX)
- {
- BOOL bShow = TRUE;
- if (puData->flags & GG_POPUP_ONCE)
- {
- HWND hWnd = FindWindow(NULL, gg->m_tszUserName);
- while (hWnd != NULL)
- {
- if (FindWindowEx(hWnd, NULL, NULL, puData->text) != NULL)
- {
- bShow = FALSE;
- break;
- }
- hWnd = FindWindowEx(NULL, hWnd, NULL, gg->m_tszUserName);
+ if (puData->flags & GG_POPUP_ALLOW_MSGBOX) {
+ BOOL bShow = TRUE;
+
+ if (puData->flags & GG_POPUP_ONCE) {
+ HWND hWnd = FindWindow(NULL, gg->m_tszUserName);
+ while (hWnd != NULL) {
+ if (FindWindowEx(hWnd, NULL, NULL, puData->text) != NULL) {
+ bShow = FALSE;
+ break;
}
+ hWnd = FindWindowEx(NULL, hWnd, NULL, gg->m_tszUserName);
}
+ }
- if (bShow)
- {
- UINT uIcon = puData->flags & GG_POPUP_ERROR ? MB_ICONERROR : puData->flags & GG_POPUP_WARNING ? MB_ICONEXCLAMATION : MB_ICONINFORMATION;
- MessageBox(NULL, puData->text, gg->m_tszUserName, MB_OK | uIcon);
- }
+ if (bShow) {
+ UINT uIcon = puData->flags & GG_POPUP_ERROR ? MB_ICONERROR : puData->flags & GG_POPUP_WARNING ? MB_ICONEXCLAMATION : MB_ICONINFORMATION;
+ MessageBox(NULL, puData->text, gg->m_tszUserName, MB_OK | uIcon);
}
- mir_free(puData->title);
- mir_free(puData->text);
- mir_free(puData);
}
+ mir_free(puData->title);
+ mir_free(puData->text);
+ mir_free(puData);
}
void GGPROTO::showpopup(const TCHAR* nickname, const TCHAR* msg, int flags)
{
- PopupData* puData;
-
if (Miranda_Terminated()) return;
- puData = (PopupData*)mir_alloc(sizeof(PopupData));
+ PopupData *puData = (PopupData*)mir_calloc(sizeof(PopupData));
puData->flags = flags;
puData->title = mir_tstrdup(nickname);
puData->text = mir_tstrdup(msg);
diff --git a/protocols/MRA/src/MraPopUp.cpp b/protocols/MRA/src/MraPopUp.cpp index 40f97d82c8..fb284c9114 100644 --- a/protocols/MRA/src/MraPopUp.cpp +++ b/protocols/MRA/src/MraPopUp.cpp @@ -157,14 +157,11 @@ void CALLBACK MraPopupThreadMarandaCallback(ULONG_PTR dwParam) if (dwParam == 0)
return;
- MraPopupData* dat = (MraPopupData*)((POPUPDATAW*)dwParam)->PluginData;
- if (dat->iPopupType == MRA_POPUP_TYPE_EMAIL_STATUS && dat->ppro->hWndEMailPopupStatus) {
- // 1: PUDeletePopUp(hWndDlg);
- // 1: PUAddPopUpW((POPUPDATAW*)dwParam);
- // 2: PUChangeW(hWndEMailPopupStatus, (POPUPDATAW*)dwParam); //- crash :/
+ MraPopupData *dat = (MraPopupData*)((POPUPDATAW*)dwParam)->PluginData;
+ if (dat->iPopupType == MRA_POPUP_TYPE_EMAIL_STATUS && dat->ppro->hWndEMailPopupStatus)
PUChangeTextW(dat->ppro->hWndEMailPopupStatus, ((POPUPDATAW*)dwParam)->lpwzText);
- }
- else PUAddPopUpW((POPUPDATAW*)dwParam);
+ else
+ PUAddPopUpW((POPUPDATAW*)dwParam);
mir_free((void*)dwParam);
}
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index d0cbe4d8c2..e6b86d244f 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -1030,33 +1030,32 @@ void CALLBACK sttMainThreadCallback(PVOID dwParam) mir_free(pud->text);
mir_free(pud->url);
mir_free(pud);
+ return;
}
+
+ char name[256];
+
+ POPUPDATACLASS ppd = { sizeof(ppd) };
+ ppd.ptszTitle = pud->title;
+ ppd.ptszText = pud->text;
+ ppd.PluginData = pud;
+ ppd.pszClassName = name;
+
+ if (pud->flags & MSN_SHOW_ERROR)
+ mir_snprintf(name, SIZEOF(name), "%s_%s", pud->proto->m_szModuleName, "Error");
+ else if (pud->flags & (MSN_HOTMAIL_POPUP | MSN_ALERT_POPUP))
+ mir_snprintf(name, SIZEOF(name), "%s_%s", pud->proto->m_szModuleName, "Hotmail");
else
- {
- char name[256];
-
- POPUPDATACLASS ppd = { sizeof(ppd) };
- ppd.ptszTitle = pud->title;
- ppd.ptszText = pud->text;
- ppd.PluginData = pud;
- ppd.pszClassName = name;
-
- if (pud->flags & MSN_SHOW_ERROR)
- mir_snprintf(name, SIZEOF(name), "%s_%s", pud->proto->m_szModuleName, "Error");
- else if (pud->flags & (MSN_HOTMAIL_POPUP | MSN_ALERT_POPUP))
- mir_snprintf(name, SIZEOF(name), "%s_%s", pud->proto->m_szModuleName, "Hotmail");
- else
- mir_snprintf(name, SIZEOF(name), "%s_%s", pud->proto->m_szModuleName, "Notify");
+ mir_snprintf(name, SIZEOF(name), "%s_%s", pud->proto->m_szModuleName, "Notify");
- CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd);
- }
+ CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd);
}
void CMsnProto::MSN_ShowPopup(const TCHAR* nickname, const TCHAR* msg, int flags, const char* url, HANDLE hContact)
{
if (Miranda_Terminated()) return;
- PopupData* pud = (PopupData*)mir_alloc(sizeof(PopupData));
+ PopupData *pud = (PopupData*)mir_calloc(sizeof(PopupData));
pud->flags = flags;
pud->url = mir_strdup(url);
pud->title = mir_tstrdup(nickname);
diff --git a/protocols/Tlen/src/jabber_opt.cpp b/protocols/Tlen/src/jabber_opt.cpp index 27075b1d03..485bcf4c72 100644 --- a/protocols/Tlen/src/jabber_opt.cpp +++ b/protocols/Tlen/src/jabber_opt.cpp @@ -577,31 +577,17 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, static void MailPopupPreview(DWORD colorBack, DWORD colorText, char *title, char *emailInfo, int delay)
{
- POPUPDATA ppd;
- char * lpzContactName;
- char * lpzText;
- HICON hIcon;
- lpzContactName = title;
- lpzText = emailInfo;
- ZeroMemory(&ppd, sizeof(ppd));
- ppd.lchContact = NULL;
- hIcon = GetIcolibIcon(IDI_MAIL);
+ POPUPDATA ppd = { 0 };
+ HICON hIcon = GetIcolibIcon(IDI_MAIL);
ppd.lchIcon = CopyIcon(hIcon);
ReleaseIcolibIcon(hIcon);
- strcpy(ppd.lpzContactName, lpzContactName);
- strcpy(ppd.lpzText, lpzText);
+ strcpy(ppd.lpzContactName, title);
+ strcpy(ppd.lpzText, emailInfo);
ppd.colorBack = colorBack;
ppd.colorText = colorText;
- ppd.PluginWindowProc = NULL;
- ppd.PluginData=NULL;
- if ( ServiceExists(MS_POPUP_ADDPOPUP)) {
- ppd.iSeconds = delay;
- CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0);
-
- }
- else if ( ServiceExists(MS_POPUP_ADDPOPUP)) {
- CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0);
- }
+ ppd.iSeconds = delay;
+ if ( ServiceExists(MS_POPUP_ADDPOPUP))
+ PUAddPopUp(&ppd);
}
static INT_PTR CALLBACK TlenPopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp index 626745d3e9..8d16127d26 100644 --- a/protocols/Xfire/src/tools.cpp +++ b/protocols/Xfire/src/tools.cpp @@ -89,12 +89,11 @@ int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hi static HICON hicNotify = NULL, hicWarning = NULL, hicError = NULL;
- if ((uType&MB_TYPEMASK) == MB_OK)
- {
- POPUPDATA ppd = {0};
+ if ((uType & MB_TYPEMASK) == MB_OK) {
+ POPUPDATA ppd = { 0 };
+ ppd.lchIcon = hicon;
- if (bIconsNotLoaded)
- {
+ if (bIconsNotLoaded) {
hicNotify = Skin_GetIcon("popup_notify");
hicWarning = Skin_GetIcon("popup_warning");
hicError = Skin_GetIcon("popup_error");
@@ -104,28 +103,22 @@ int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hi lstrcpynA(ppd.lpzContactName, lpCaption, sizeof(ppd.lpzContactName));
lstrcpynA(ppd.lpzText, lpText, sizeof(ppd.lpzText));
- if ((uType&MB_ICONMASK) == MB_ICONSTOP)
- {
+ if ((uType & MB_ICONMASK) == MB_ICONSTOP) {
ppd.lchIcon = hicError;
ppd.colorBack = RGB(191,0,0);
ppd.colorText = RGB(255,245,225);
- } else
- if ((uType&MB_ICONMASK) == MB_ICONWARNING)
- {
+ }
+ else if ((uType & MB_ICONMASK) == MB_ICONWARNING) {
ppd.lchIcon = hicWarning;
ppd.colorBack = RGB(210,210,150);
ppd.colorText = RGB(0,0,0);
- } else
- /* if ((uType&MB_ICONMASK) == MB_ICONINFORMATION) */
- {
+ }
+ else {
ppd.lchIcon = hicNotify;
ppd.colorBack = RGB(230,230,230);
ppd.colorText = RGB(0,0,0);
}
- if(hicon!=NULL)
- ppd.lchIcon=hicon;
-
PUAddPopUp(&ppd);
}
|