1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
////////////////////////////////////////////////////////////////////////////////
// Gadu-Gadu Plugin for Miranda IM
//
// Copyright (c) 2011-2012 Bartosz Bia³ek
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
////////////////////////////////////////////////////////////////////////////////
#include "gg.h"
struct PopupData
{
unsigned flags;
TCHAR* title;
TCHAR* text;
GGPROTO* gg;
};
/////////////////////////////////////////////////////////////////////////////////////////
// Popup plugin window proc
LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
{
PopupData* puData = (PopupData*)PUGetPluginData(hWnd);
if (puData != NULL)
{
if (puData->flags & GG_POPUP_MULTILOGON)
puData->gg->sessions_view(0, 0);
}
PUDeletePopup(hWnd);
break;
}
case WM_CONTEXTMENU:
PUDeletePopup(hWnd);
break;
case UM_FREEPLUGINDATA:
{
PopupData* puData = (PopupData*)PUGetPluginData(hWnd);
if (puData != NULL && puData != (PopupData*)CALLSERVICE_NOTFOUND)
{
mir_free(puData->title);
mir_free(puData->text);
mir_free(puData);
}
break;
}
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
/////////////////////////////////////////////////////////////////////////////////////////
// Popup plugin class registration
void GGPROTO::initpopups()
{
TCHAR szDescr[256];
char szName[256];
POPUPCLASS puc = {0};
puc.cbSize = sizeof(puc);
puc.PluginWindowProc = PopupWindowProc;
puc.flags = PCF_TCHAR;
puc.ptszDescription = szDescr;
puc.pszName = szName;
puc.colorBack = RGB(173, 206, 247);
puc.colorText = GetSysColor(COLOR_WINDOWTEXT);
puc.hIcon = CopyIcon(LoadIconEx("main", FALSE));
ReleaseIconEx("main", FALSE);
puc.iSeconds = 4;
mir_sntprintf(szDescr, SIZEOF(szDescr), _T("%s/%s"), m_tszUserName, TranslateT("Notify"));
mir_snprintf(szName, SIZEOF(szName), "%s_%s", m_szModuleName, "Notify");
hPopupNotify = Popup_RegisterClass(&puc);
puc.colorBack = RGB(191, 0, 0); // Red
puc.colorText = RGB(255, 245, 225); // Yellow
puc.iSeconds = 60;
puc.hIcon = (HICON)LoadImage(NULL, IDI_WARNING, IMAGE_ICON, 0, 0, LR_SHARED);
mir_sntprintf(szDescr, SIZEOF(szDescr), _T("%s/%s"), m_tszUserName, TranslateT("Error"));
mir_snprintf(szName, SIZEOF(szName), "%s_%s", m_szModuleName, "Error");
hPopupError = Popup_RegisterClass(&puc);
}
/////////////////////////////////////////////////////////////////////////////////////////
// Show popup - popup plugin support
void CALLBACK sttMainThreadCallback(PVOID dwParam)
{
PopupData* puData = (PopupData*)dwParam;
GGPROTO* gg = puData->gg;
if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
char szName[256];
POPUPDATACLASS ppd = {sizeof(ppd)};
ppd.ptszTitle = puData->title;
ppd.ptszText = puData->text;
ppd.PluginData = puData;
ppd.pszClassName = szName;
if (puData->flags & GG_POPUP_ERROR || puData->flags & GG_POPUP_WARNING)
mir_snprintf(szName, SIZEOF(szName), "%s_%s", gg->m_szModuleName, "Error");
else
mir_snprintf(szName, SIZEOF(szName), "%s_%s", gg->m_szModuleName, "Notify");
CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd);
return;
}
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);
}
}
mir_free(puData->title);
mir_free(puData->text);
mir_free(puData);
}
void GGPROTO::showpopup(const TCHAR* nickname, const TCHAR* msg, int flags)
{
if (Miranda_Terminated()) return;
PopupData *puData = (PopupData*)mir_calloc(sizeof(PopupData));
puData->flags = flags;
puData->title = mir_tstrdup(nickname);
puData->text = mir_tstrdup(msg);
puData->gg = this;
CallFunctionAsync(sttMainThreadCallback, puData);
}
|