| 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
 | /*
Copyright (c) 2015 Miranda NG project (https://miranda-ng.org)
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/>.
*/
#ifndef _T_PROTO_H_
#define _T_PROTO_H_
struct CTelegramProto : public PROTO < CTelegramProto >
{
public:
	//////////////////////////////////////////////////////////////////////////////////////
	//Ctors
	CTelegramProto(const char *protoName, const wchar_t *userName);
	~CTelegramProto();
	//////////////////////////////////////////////////////////////////////////////////////
	// Virtual functions
	virtual	MCONTACT  __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
	virtual	MCONTACT  __cdecl AddToListByEvent(int flags, int iContact, MEVENT hDbEvent);
	virtual int       __cdecl AuthRequest(MCONTACT hContact, const TCHAR* szMessage);
	virtual	int       __cdecl Authorize(MEVENT hDbEvent);
	virtual	int       __cdecl AuthDeny(MEVENT hDbEvent, const TCHAR* szReason);
	virtual	int       __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT*);
	virtual	DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
	virtual	int       __cdecl GetInfo(MCONTACT hContact, int infoType);
	virtual	HANDLE    __cdecl SearchBasic(const TCHAR* id);
	virtual	int       __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg);
	virtual	int       __cdecl SetStatus(int iNewStatus);
	virtual	int       __cdecl UserIsTyping(MCONTACT hContact, int type);
	virtual	int       __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam);
	// accounts
	static CTelegramProto* InitAccount(const char *protoName, const TCHAR *userName);
	static int          UninitAccount(CTelegramProto *proto);
	// icons
	static void InitIcons();
	static void UninitIcons();
	// menus
	static void InitMenus();
	static void UninitMenus();
	//popups
	void InitPopups();
	void UninitPopups();
	void InitNetwork();
	void InitCallbacks();
	// languages
	static void InitLanguages();
	// events
	static int	OnModulesLoaded(WPARAM, LPARAM);
	int __cdecl OnDbEventRead(WPARAM, LPARAM);
	int __cdecl OnPreShutdown(WPARAM, LPARAM);
	//search
	void __cdecl SearchBasicThread(void* id);
	////////////////////////////////////////////
	static INT_PTR EventGetIcon(WPARAM wParam, LPARAM lParam);
	static INT_PTR GetEventText(WPARAM, LPARAM lParam);
	void TGLGetValue(tgl_value_type type, const char *prompt, int num_values, char **result);
	void OnMessage(tgl_message*);
	void OnUserTyping(tgl_user *U, tgl_typing_status status);
	MirTLS *TLS;
private:
	
	static mir_cs accountsLock;
	void ReadState();
	void SaveState();
	void ReadAuth();
	void SaveAuth();
	//---Accounts
	static LIST<CTelegramProto> CTelegramProto::Accounts; 
	static int CompareAccounts(const CTelegramProto *p1, const CTelegramProto *p2);
	static CTelegramProto* GetContactAccount(MCONTACT hContact);
	__forceinline bool IsOnline() const 
	{	return (m_iStatus > ID_STATUS_OFFLINE);
	}
	template<INT_PTR(__cdecl CTelegramProto::*Service)(WPARAM, LPARAM)>
	static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam)
	{
		CTelegramProto *proto = GetContactAccount((MCONTACT)wParam);
		return proto ? (proto->*Service)(wParam, lParam) : 0;
	}
};
#endif //_Telegram_PROTO_H_
 |