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
|
/*
UserinfoEx plugin for Miranda IM
Copyright:
© 2006-2010 DeathAxe, Yasnovidyashii, Merlin, K. Romanov, Kreol
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.
*/
#pragma once
#define ANID_LAST 0xFFFC
#define ANID_BIRTHDAY 0xFFFE
#define ANID_NONE 0xFFFF
struct MZodiac {
HICON hIcon;
LPCTSTR pszName;
};
class MAnnivDate : public MTime
{
public:
typedef enum {
MADF_NONE = 0,
MADF_CHANGED = 1, // date has been edited (used, if date is used in controls)
MADF_HASPROTO = 2, // basic protocol module contains date information
MADF_HASCUSTOM = 4, // date is customized or read from a custom module
MADF_HASMETA = 8, // date is read from a metacontact's subcontact
MADF_REMINDER_CHANGED = 16 // reminder options have changed
} EFlags;
private:
WORD _wID; // index to anniversary in database or ANID_BIRTHDAY
tstring _strDesc; // descripes the anniversary (e.g. birthday)
string _strModule; // the module the anniversary has been read from
WORD _wFlags; // the flags
BYTE _bRemind; // per user setting for reminder (0 - disabled, 1 - use local offset, 2 - use global offset)
WORD _wDaysEarlier; // number of days to the anniversary the user wants to be reminded of this anniversary
int DBWriteDate(HANDLE hContact, LPCSTR pszModule, LPCSTR szDay, LPCSTR szMonth, LPCSTR szYear);
int DBDeleteDate(HANDLE hContact, LPCSTR pszModule, LPCSTR szDay, LPCSTR szMonth, LPCSTR szYear) const;
public:
MAnnivDate();
MAnnivDate(MAnnivDate &mda);
// basic access to attributes
__inline LPCTSTR Description() const { return _strDesc.c_str(); };
__inline void Description(LPCTSTR pszDesc) { if (pszDesc) _strDesc = pszDesc; };
__inline LPCSTR Module() const { return _strModule.c_str(); };
__inline void Module(LPCSTR pszModule) { if (pszModule) _strModule = pszModule; else _strModule.clear(); };
__inline BYTE RemindOption() const { return _bRemind; };
__inline void RemindOption(BYTE bRemind) { if (bRemind <= BST_INDETERMINATE) _bRemind = bRemind; };
__inline WORD RemindOffset() const { return _wDaysEarlier; };
__inline void RemindOffset(WORD wOffset) { _wDaysEarlier = wOffset; };
__inline WORD Id() const { return _wID; };
__inline void Id(WORD wId) { if (_wID == ANID_NONE) _wID = wId; };
DWORD DateStamp() const;
void DateStamp(const DWORD dwStamp);
// basic checks
__inline BYTE IsValid() const;
__inline BYTE IsChanged() const { return (_wFlags & MADF_CHANGED); };
__inline BYTE IsReminderChanged() const { return (_wFlags & MADF_REMINDER_CHANGED); };
__inline BYTE IsEqual(const MAnnivDate &mda) const { return IsEqual(mda.SystemTime()); };
BYTE IsEqual(const SYSTEMTIME &st) const;
// handling flags
__inline WORD Flags() const { return _wFlags; };
__inline void Flags(WORD wFlags) { _wFlags = wFlags; };
__inline void SetFlags(WORD wFlag) { _wFlags |= wFlag; };
__inline void RemoveFlags(WORD wFlag) { _wFlags &= ~wFlag; };
// return diffence of days, ignoring the date
int CompareDays(MTime mt) const;
MZodiac Zodiac();
int Age(MTime *pNow = NULL);
void Clear();
// read date from database
int DBGetDate(HANDLE hContact, LPCSTR pszModule, LPCSTR szDay, LPCSTR szMonth, LPCSTR szYear);
int DBGetDateStamp(HANDLE hContact, LPCSTR pszModule, LPCSTR pszSetting);
int DBGetAnniversaryDate(HANDLE hContact, WORD iIndex);
int DBGetBirthDate(HANDLE hContact, LPSTR pszProto = NULL);
int DBGetReminderOpts(HANDLE hContact);
// write date to database
int DBWriteDateStamp(HANDLE hContact, LPCSTR pszModule, LPCSTR pszSetting);
int DBWriteAnniversaryDate(HANDLE hContact, WORD wIndex);
int DBWriteBirthDate(HANDLE hContact);
int DBWriteReminderOpts(HANDLE hContact);
// delete date from database
int DBDeleteBirthDate(HANDLE hContact);
int DBMoveBirthDate(HANDLE hContact, BYTE bOld, BYTE bNew);
int BackupBirthday (HANDLE hContact, LPSTR pszProto = NULL, const BYTE bDontIgnoreAnything = FALSE, PWORD lastAnswer = NULL);
// setting values
void SetDate(SYSTEMTIME &st);
void SetDate(MAnnivDate &mda);
BYTE operator == (const SYSTEMTIME &st) { return IsEqual(st); };
BYTE operator == (const MAnnivDate &mda) { return IsEqual(mda); };
void operator = (SYSTEMTIME &st) { SetDate(st); };
void operator = (MAnnivDate &mda) { SetDate(mda); };
};
|