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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
/*
WhenWasIt (birthday reminder) plugin for Miranda IM
Copyright © 2006 Cristian Libotean
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 "commonheaders.h"
#include "notifiers.h"
void FillPopupData(POPUPDATAT &pd, int dtb)
{
int popupTimeout = (dtb == 0) ? commonData.popupTimeoutToday : commonData.popupTimeout;
pd.colorBack = commonData.background;
pd.colorText = commonData.foreground;
pd.iSeconds = popupTimeout;
}
int PopupNotifyNoBirthdays()
{
POPUPDATAT pd = {0};
FillPopupData(pd, -1);
pd.lchIcon = GetDTBIcon(-1);
_tcscpy(pd.lptzContactName, TranslateT("WhenWasIt"));
_tcscpy(pd.lptzText, TranslateT("No upcoming birthdays."));
return PUAddPopUpT(&pd);
}
TCHAR *BuildDTBText(int dtb, TCHAR *name, TCHAR *text, int size)
{
if (dtb > 1)
mir_sntprintf(text, size, TranslateT("%s has birthday in %d days."), name, dtb);
else if (dtb == 1)
mir_sntprintf(text, size, TranslateT("%s has birthday tomorrow."), name);
else
mir_sntprintf(text, size, TranslateT("%s has birthday today."), name);
return text;
}
TCHAR *BuildDABText(int dab, TCHAR *name, TCHAR *text, int size)
{
if (dab > 1)
mir_sntprintf(text, size, TranslateT("%s had birthday %d days ago."), name, dab);
else if (dab == 1)
mir_sntprintf(text, size, TranslateT("%s had birthday yesterday."), name);
else
mir_sntprintf(text, size, TranslateT("%s has birthday today (Should not happen, please report)."), name);
return text;
}
int PopupNotifyBirthday(HANDLE hContact, int dtb, int age)
{
TCHAR *name = GetContactName(hContact, NULL);
const int MAX_SIZE = 1024;
TCHAR text[MAX_SIZE];
//int bIgnoreSubcontacts = DBGetContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", FALSE);
if (commonData.bIgnoreSubcontacts)
{
HANDLE hMetacontact = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0);
if ((hMetacontact) && (hMetacontact != hContact)) //not main metacontact
{
return 0;
}
}
BuildDTBText(dtb, name, text, MAX_SIZE);
int gender = GetContactGender(hContact);
POPUPDATAT pd = {0};
FillPopupData(pd, dtb);
pd.lchContact = hContact;
pd.PluginWindowProc = (WNDPROC) DlgProcPopup;
//pd.PluginData = (void *) hContact;
//pd.colorBack = background;
//pd.colorText = foreground;
//pd.iSeconds = popupTimeout;
pd.lchIcon = GetDTBIcon(dtb);
//strcpy(pd.lpzContactName, text);
_stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name);
TCHAR *sex;
switch (toupper(gender)) {
case _T('M'):
sex = TranslateT("He");
break;
case _T('F'):
sex = TranslateT("She");
break;
default:
sex = TranslateT("He/She");
break;
}
if (dtb > 0)
_stprintf(pd.lptzText, TranslateT("%s\n%s will be %d years old."), text, sex, age);
else
_stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age);
PUAddPopUpT(&pd);
free(name);
return 0;
}
int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age)
{
TCHAR *name = GetContactName(hContact, NULL);
const int MAX_SIZE = 1024;
TCHAR text[MAX_SIZE];
//int bIgnoreSubcontacts = DBGetContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", FALSE);
if (commonData.bIgnoreSubcontacts) {
HANDLE hMetacontact = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0);
if (hMetacontact && hMetacontact != hContact) //not main metacontact
return 0;
}
BuildDABText(dab, name, text, MAX_SIZE);
int gender = GetContactGender(hContact);
POPUPDATAT pd = {0};
FillPopupData(pd, dab);
pd.lchContact = hContact;
pd.PluginWindowProc = (WNDPROC) DlgProcPopup;
pd.lchIcon = GetDABIcon(dab);
_stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name);
TCHAR *sex;
switch (toupper(gender)) {
case _T('M'):
sex = TranslateT("He");
break;
case _T('F'):
sex = TranslateT("She");
break;
default:
sex = TranslateT("He/She");
break;
}
if (dab > 0)
_stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age);
else
_stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age);
PUAddPopUpT(&pd);
free(name);
return 0;
}
int ClistIconNotifyBirthday(HANDLE hContact, int dtb)
{
ExtraIcon_SetIcon(hWWIExtraIcons, hContact, GetClistIcon(dtb));
return 0;
}
int DialogNotifyBirthday(HANDLE hContact, int dtb, int age)
{
TCHAR *name = GetContactName(hContact, NULL);
const int MAX_SIZE = 1024;
TCHAR text[MAX_SIZE];
BuildDTBText(dtb, name, text, MAX_SIZE);
if (!hUpcomingDlg) {
hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming);
ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW);
}
TUpcomingBirthday data = {0};
data.name = name;
data.message = text;
data.dtb = dtb;
data.hContact = hContact;
data.age = age;
SendMessage(hUpcomingDlg, WWIM_ADD_UPCOMING_BIRTHDAY, (WPARAM) &data, NULL);
free(name);
return 0;
}
int DialogNotifyMissedBirthday(HANDLE hContact, int dab, int age)
{
TCHAR *name = GetContactName(hContact, NULL);
const int MAX_SIZE = 1024;
TCHAR text[MAX_SIZE];
BuildDABText(dab, name, text, MAX_SIZE);
if (!hUpcomingDlg) {
hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming);
ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW);
}
TUpcomingBirthday data = {0};
data.name = name;
data.message = text;
data.dtb = -dab;
data.hContact = hContact;
data.age = age;
SendMessage(hUpcomingDlg, WWIM_ADD_UPCOMING_BIRTHDAY, (WPARAM) &data, NULL);
free(name);
return 0;
}
int SoundNotifyBirthday(int dtb)
{
if (dtb == 0)
SkinPlaySound(BIRTHDAY_TODAY_SOUND);
else if (dtb <= commonData.cSoundNearDays)
SkinPlaySound(BIRTHDAY_NEAR_SOUND);
return 0;
}
int ClearClistIcon(HANDLE hContact)
{
return ExtraIcon_Clear(hWWIExtraIcons, hContact);
}
int RefreshContactListIcons(HANDLE hContact)
{
OnExtraImageApply((WPARAM) hContact, 0);
return 0;
}
//if oldClistIcon != -1 it will remove the old location of the clist extra icon
//called with oldClistIcon != -1 from dlg_handlers whtn the extra icon slot changes.
int RefreshAllContactListIcons(int oldClistIcon)
{
HANDLE hContact = db_find_first();
while (hContact != NULL) {
if (oldClistIcon != -1)
ClearClistIcon(hContact);
RefreshContactListIcons(hContact); //will change bBirthdayFound if needed
hContact = db_find_next(hContact);
}
return 0;
}
|