#pragma once struct WIDATAITEM { WIDATAITEM(const wchar_t *_1, const wchar_t *_2, const CMStringW &_3) : Name(_1), Unit(_2), Value(_3) {} const wchar_t *Name, *Unit; CMStringW Value; }; struct WIDATAITEMLIST : public OBJLIST { WIDATAITEMLIST() : OBJLIST(20) {} WIDATAITEM* Find(const wchar_t *pwszName) { for (auto &it : *this) if (!mir_wstrcmp(it->Name, pwszName)) return it; return 0; } }; struct WEATHERINFO { MCONTACT hContact; TCHAR id[128]; TCHAR city[128]; TCHAR update[64]; TCHAR cond[128]; TCHAR temp[16]; TCHAR low[16]; TCHAR high[16]; TCHAR feel[16]; TCHAR wind[16]; TCHAR winddir[64]; TCHAR dewpoint[16]; TCHAR pressure[16]; TCHAR humid[16]; TCHAR vis[16]; TCHAR sunrise[32]; TCHAR sunset[32]; }; struct MYOPTIONS { // main options uint8_t AutoUpdate; uint8_t CAutoUpdate; uint8_t UpdateOnlyConditionChanged; uint8_t RemoveOldData; uint8_t MakeItalic; uint16_t UpdateTime; uint16_t AvatarSize; // units uint16_t tUnit; uint16_t wUnit; uint16_t vUnit; uint16_t pUnit; uint16_t dUnit; uint16_t eUnit; wchar_t DegreeSign[4]; uint8_t DoNotAppendUnit; uint8_t NoFrac; // advanced uint8_t DisCondIcon; // popup options uint8_t UpdatePopup; uint8_t AlertPopup; uint8_t PopupOnChange; uint8_t ShowWarnings; // popup colors uint8_t UseWinColors; COLORREF BGColour; COLORREF TextColour; // popup actions uint32_t LeftClickAction; uint32_t RightClickAction; // popup delay uint32_t pDelay; // other misc stuff wchar_t Default[64]; MCONTACT DefStn; }; ///////////////////////////////////////////////////////////////////////////////////////// // Protocol class class CWeatherProto : public PROTO { friend class CEditDlg; friend class CPopupOptsDlg; friend class CBriefInfoDlg; friend class COptionsTextDlg; friend class CGeneralOptionsDlg; friend class WeatherUserInfoDlg; class CProtoImpl { friend class CWeatherProto; CWeatherProto &m_proto; CTimer m_start, m_update; void OnStart(CTimer *pTimer) { pTimer->Stop(); m_proto.StartUpdate(); } void OnUpdate(CTimer *) { m_proto.DoUpdate(); } CProtoImpl(CWeatherProto &pro) : m_proto(pro), m_start(Miranda_GetSystemWindow(), UINT_PTR(this) + 1), m_update(Miranda_GetSystemWindow(), UINT_PTR(this) + 2) { m_start.OnEvent = Callback(this, &CProtoImpl::OnStart); m_update.OnEvent = Callback(this, &CProtoImpl::OnUpdate); } } m_impl; // avatars void AvatarDownloaded(MCONTACT hContact); INT_PTR __cdecl AdvancedStatusIconSvc(WPARAM, LPARAM); INT_PTR __cdecl GetAvatarInfoSvc(WPARAM, LPARAM); // contacts INT_PTR __cdecl ViewLog(WPARAM, LPARAM); INT_PTR __cdecl LoadForecast(WPARAM, LPARAM); INT_PTR __cdecl WeatherMap(WPARAM, LPARAM); INT_PTR __cdecl EditSettings(WPARAM, LPARAM); int __cdecl BriefInfoEvt(WPARAM, LPARAM); bool IsMyContact(MCONTACT hContact); // conversions void numToStr(double num, wchar_t *str, size_t strSize); void GetTemp(const wchar_t *tempchar, const wchar_t *unit, wchar_t *str); void GetSpeed(const wchar_t *tempchar, const wchar_t *unit, wchar_t *str); void GetPressure(const wchar_t *tempchar, const wchar_t *unit, wchar_t *str); void GetDist(const wchar_t *tempchar, const wchar_t *unit, wchar_t *str); void GetElev(const wchar_t *tempchar, const wchar_t *unit, wchar_t *str); // data void ConvertDataValue(WIDATAITEM *UpdateData); void EraseAllInfo(void); WEATHERINFO LoadWeatherInfo(MCONTACT hContact); MHttpResponse* RunQuery(const wchar_t *id, int days); // menu items HGENMENU hEnableDisableMenu; void InitMenuItems(); void UpdateMenu(BOOL State); INT_PTR __cdecl EnableDisableCmd(WPARAM, LPARAM); // mwin void AddFrameWindow(MCONTACT hContact); void RemoveFrameWindow(MCONTACT hContact); void InitMwin(void); void DestroyMwin(void); INT_PTR __cdecl Mwin_MenuClicked(WPARAM, LPARAM); // options void LoadOptions(); void SaveOptions(); void RestartTimer(); void InitPopupOptions(WPARAM); int __cdecl OptInit(WPARAM, LPARAM); CMStringW GetTextValue(int c); void GetVarsDescr(CMStringW &str); // popups int WPShowMessage(const wchar_t *lpzText, int kind); int WeatherPopup(MCONTACT hContact, bool bNew); // search bool CheckSearch(); int IDSearch(wchar_t *id, int searchId); int NameSearch(wchar_t *name, int searchId); void __cdecl NameSearchThread(void *); void __cdecl BasicSearchThread(void *); // update weather std::vector m_updateList; // check if weather is currently updating bool m_bThreadRunning; mir_cs m_csUpdate; void DoUpdate(); void StartUpdate(); int GetWeatherData(MCONTACT hContact); int UpdateWeather(MCONTACT hContact); void UpdateListAdd(MCONTACT hContact); MCONTACT UpdateGetFirst(); void DestroyUpdateList(void); void __cdecl UpdateThread(void *); void UpdateAll(BOOL AutoUpdate, BOOL RemoveOld); INT_PTR __cdecl UpdateSingleStation(WPARAM, LPARAM); INT_PTR __cdecl UpdateSingleRemove(WPARAM, LPARAM); INT_PTR __cdecl UpdateAllInfo(WPARAM, LPARAM); INT_PTR __cdecl UpdateAllRemove(WPARAM, LPARAM); // user info int __cdecl UserInfoInit(WPARAM, LPARAM); public: CWeatherProto(const char *protoName, const wchar_t *userName); ~CWeatherProto(); MYOPTIONS opt; CMOption m_bPopups; CMOption m_szApiKey; INT_PTR __cdecl BriefInfo(WPARAM, LPARAM); int MapCondToStatus(MCONTACT hContact); HICON GetStatusIcon(MCONTACT hContact); HICON GetStatusIconBig(MCONTACT hContact); static LRESULT CALLBACK CWeatherProto::PopupWndProc(HWND hWnd, UINT uMsg, WPARAM, LPARAM); // PROTO_INTERFACE MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override; HANDLE SearchBasic(const wchar_t *id) override; HANDLE SearchAdvanced(MWindow owner) override; MWindow CreateExtendedSearchUI(MWindow owner) override; INT_PTR GetCaps(int type, MCONTACT hContact) override; int SetStatus(int iNewStatus) override; void __cdecl GetAwayMsgThread(void *arg); HANDLE GetAwayMsg(MCONTACT hContact) override; void __cdecl AckThreadProc(void *arg); int GetInfo(MCONTACT hContact, int) override; bool OnContactDeleted(MCONTACT, uint32_t flags) override; void OnModulesLoaded() override; void OnShutdown() override; static void GlobalMenuInit(); int __cdecl BuildContactMenu(MCONTACT); int __cdecl OnToolbarLoaded(WPARAM, LPARAM); }; typedef CProtoDlgBase CWeatherDlgBase; ///////////////////////////////////////////////////////////////////////////////////////// // Plugin class struct CMPlugin : public ACCPROTOPLUGIN { CMPlugin(); HINSTANCE hIconsDll = nullptr; int Load() override; int Unload() override; };