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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
/*
Weather Protocol plugin for Miranda NG
Copyright (C) 2012-25 Miranda NG team
Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
Copyright (c) 2002-2005 Calvin Che
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; version 2
of the License.
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, see <http://www.gnu.org/licenses/>.
*/
/* This file contains the includes, weather constants/declarations,
the structs, and the primitives for some of the functions.
*/
#pragma once
#include <share.h>
#include <time.h>
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include <malloc.h>
#include <newpluginapi.h>
#include <m_acc.h>
#include <m_avatars.h>
#include <m_button.h>
#include <m_clc.h>
#include <m_cluiframes.h>
#include <m_contacts.h>
#include <m_database.h>
#include <m_findadd.h>
#include <m_fontservice.h>
#include <m_history.h>
#include <m_icolib.h>
#include <m_ignore.h>
#include <m_langpack.h>
#include <m_netlib.h>
#include <m_options.h>
#include <m_popup.h>
#include <m_protosvc.h>
#include <m_skin.h>
#include <m_skin_eng.h>
#include <m_userinfo.h>
#include <m_xstatus.h>
#include <m_tipper.h>
#include <m_toptoolbar.h>
#include "resource.h"
#include "version.h"
#include "proto.h"
/////////////////////////////////////////////////////////////////////////////////////////
// CONSTANTS
// name
#define MODULENAME "Weather"
#define DEFCURRENTWEATHER "WeatherCondition"
#define WEATHERCONDITION "Current"
// weather conditions
enum EWeatherCondition
{
SUNNY,
NA,
PCLOUDY,
CLOUDY,
RAIN,
RSHOWER,
FOG,
SNOW,
SSHOWER,
LIGHT,
MAX_COND
};
// limits
#define MAX_TEXT_SIZE 4096
#define MAX_DATA_LEN 1024
// db info mangement mode
#define WDBM_REMOVE 1
#define WDBM_DETAILDISPLAY 2
// more info list column width
#define LIST_COLUMN 150
// others
#define NODATA TranslateT("N/A")
#define UM_SETCONTACT 40000
// weather update error codes
#define INVALID_ID_FORMAT 10
#define INVALID_SVC 11
#define INVALID_ID 12
#define SVC_NOT_FOUND 20
#define NETLIB_ERROR 30
#define DATA_EMPTY 40
#define DOC_NOT_FOUND 42
#define DOC_TOO_SHORT 43
#define UNKNOWN_ERROR 99
#define SM_WEATHERALERT 16
#define WM_UPDATEDATA (WM_USER + 2687)
// defaults constants
#define VAR_LIST_OPT TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set\n----------\n\\n\tnew line")
/////////////////////////////////////////////////////////////////////////////////////////
// DATA FORMAT STRUCT
#define WID_NORMAL 0
#define WID_SET 1
#define WID_BREAK 2
struct WIDATAITEM
{
wchar_t *Name;
wchar_t *Start;
wchar_t *End;
wchar_t *Unit;
char *Url;
wchar_t *Break;
int Type;
};
struct WITEMLIST
{
WIDATAITEM Item;
struct WITEMLIST *Next;
};
typedef struct WITEMLIST WIDATAITEMLIST;
struct WIIDSEARCH
{
BOOL Available;
char *SearchURL;
wchar_t *NotFoundStr;
WIDATAITEM Name;
};
struct WINAMESEARCHTYPE
{
BOOL Available;
wchar_t *First;
WIDATAITEM Name;
WIDATAITEM ID;
};
struct WINAMESEARCH
{
char *SearchURL;
wchar_t *NotFoundStr;
wchar_t *SingleStr;
WINAMESEARCHTYPE Single;
WINAMESEARCHTYPE Multiple;
};
struct STRLIST
{
wchar_t *Item;
struct STRLIST *Next;
};
typedef struct STRLIST WICONDITEM;
struct WICONDLIST
{
WICONDITEM *Head;
WICONDITEM *Tail;
};
struct WIDATA
{
wchar_t *FileName;
wchar_t *ShortFileName;
BOOL Enabled;
// header
wchar_t *DisplayName;
wchar_t *InternalName;
wchar_t *Description;
wchar_t *Author;
wchar_t *Version;
int InternalVer;
size_t MemUsed;
// default
char *DefaultURL;
wchar_t *DefaultMap;
char *UpdateURL;
char *UpdateURL2;
char *UpdateURL3;
char *UpdateURL4;
char *Cookie;
char *UserAgent;
// items
int UpdateDataCount;
WIDATAITEMLIST *UpdateData;
WIDATAITEMLIST *UpdateDataTail;
WIIDSEARCH IDSearch;
WINAMESEARCH NameSearch;
WICONDLIST CondList[MAX_COND];
};
/////////////////////////////////////////////////////////////////////////////////////////
// DATA LIST (LINKED LIST)
struct DATALIST
{
WIDATA Data;
struct DATALIST *next;
};
typedef struct DATALIST WIDATALIST;
/////////////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
extern WIDATALIST *WIHead, *WITail;
extern HWND hPopupWindow, hWndSetup;
extern MWindowList hDataWindowList, hWindowList;
extern HANDLE hTBButton;
extern HGENMENU hMwinMenu;
extern bool g_bIsUtf;
/////////////////////////////////////////////////////////////////////////////////////////
// functions in weather_conv.c
void ClearStatusIcons();
uint16_t GetIcon(const wchar_t* cond, WIDATA *Data);
void CaseConv(wchar_t *str);
void TrimString(char *str);
void TrimString(wchar_t *str);
void ConvertBackslashes(char *str);
char *GetSearchStr(char *dis);
wchar_t *GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t* str);
void GetSvc(wchar_t *pszID);
void GetID(wchar_t *pszID);
wchar_t *GetError(int code);
/////////////////////////////////////////////////////////////////////////////////////////
// functions in weather_data.c
int DBGetData(MCONTACT hContact, char *setting, DBVARIANT *dbv);
void wSetData(char *&Data, const char *Value);
void wSetData(wchar_t *&Data, const char *Value);
void wSetData(wchar_t *&Data, const wchar_t *Value);
void wfree(char *&Data);
void wfree(wchar_t *&Data);
void DBDataManage(MCONTACT hContact, uint16_t Mode, WPARAM wParam, LPARAM lParam);
/////////////////////////////////////////////////////////////////////////////////////////
// functions in weather_ini.c
WIDATA* GetWIData(wchar_t *pszServ);
bool IsContainedInCondList(const wchar_t *pszStr, WICONDLIST *List);
void DestroyWIList();
bool LoadWIData(bool dial);
/////////////////////////////////////////////////////////////////////////////////////////
// functions in weather_info.c
void GetINIInfo(wchar_t *pszSvc);
wchar_t* GetINIVersionNum(int iVersion);
const wchar_t *GetDefaultText(int c);
void MoreVarList();
/////////////////////////////////////////////////////////////////////////////////////////
// function from multiwin module
void UpdateMwinData(MCONTACT hContact);
/////////////////////////////////////////////////////////////////////////////////////////
// UI Classes
class WeatherMyDetailsDlg : public CUserInfoPageDlg
{
CCtrlButton btnReload;
public:
WeatherMyDetailsDlg();
bool OnInitDialog() override;
void onClick_Reload(CCtrlButton *);
};
|