summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/baseProtocol.h
blob: d56f68b0b6ba4ce5640054c9853c5e29cc648582 (plain)
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
/*
 *  Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network. 
 *
 *  Copyright (C) 2010 by
 *          dufte <dufte@justmail.de>
 *
 *  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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 *  Based on J. Lawler              - BaseProtocol
 *			 Herbert Poul/Beat Wolf - xfirelib
 *
 *  Miranda ICQ: the free icq client for MS Windows 
 *  Copyright (C) 2000-2008  Richard Hughes, Roland Rabien & Tristan Van de Vreede
 *
 */

#define MIRANDA_VER    0x0A00

//=====================================================
//	Includes (yea why not include lots of stuff :D )
//=====================================================
#include <windows.h>
#include <gdiplus.h>
#include <Wininet.h>
#include <commctrl.h>
#include <stdio.h>
#include <time.h>
#include <stddef.h>
#include <process.h>
#include <string.h>
#include <winsock.h>
#include "resource.h"
#include <winbase.h>
#include <tlhelp32.h>
#include <Psapi.h>
#include <string.h>
#include <Iphlpapi.h>

//Miranda SDK headers
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_clui.h>
#include <m_skin.h>
#include <m_langpack.h>
#include <m_protomod.h>
#include <m_database.h>
#include <m_system.h>
#include <m_protocols.h>
#include <m_protomod.h>
#include <m_protosvc.h>
#include <m_protoint.h>
#include <m_userinfo.h>
#include <m_options.h>
#include <m_utils.h>
#include <m_ignore.h>
#include <m_clc.h>
#include <m_netlib.h>
#include <m_avatars.h>
#include <m_folders.h>
#include <m_assocmgr.h>
#include <m_icolib.h>
#include <m_genmenu.h>
#include <m_extraicons.h>
#include <m_extraicons.h>

#include "services.h"

/*#pragma comment(lib, "atl.lib")
#include <atldef.h>
#define _ATL_DLL_IMPL
#include <atliface.h>*/

#ifndef _BASEPROTO_H
#define _BASEPROTO_H

//=======================================================
//	Definitions
//=======================================================
#define protocolname		"XFire" //no spaces here :)

/* */
typedef DWORD (*pGetExtendedTcpTable)(
	__out_bcount_opt(*pdwSize)    PVOID           pTcpTable,
    __inout                       PDWORD          pdwSize,
    __in                          BOOL            bOrder,
    __in                          ULONG           ulAf,
    __in                          TCP_TABLE_CLASS TableClass,
    __in                          ULONG           Reserved
    ); 

typedef DWORD (*pGetExtendedUdpTable)(
    __out_bcount_opt(*pdwSize)    PVOID           pUdpTable,
    __inout                       PDWORD          pdwSize,
    __in                          BOOL            bOrder,
    __in                          ULONG           ulAf,
    __in                          UDP_TABLE_CLASS TableClass,
    __in                          ULONG           Reserved
    );

//=======================================================
//	Defines
//=======================================================
//General
extern HINSTANCE hinstance;
extern int bpStatus;

//Services.c
INT_PTR GetCaps(WPARAM wParam,LPARAM lParam);
INT_PTR GetName(WPARAM wParam,LPARAM lParam);
INT_PTR SetStatus(WPARAM wParam,LPARAM lParam);
INT_PTR GetStatus(WPARAM wParam,LPARAM lParam);
INT_PTR TMLoadIcon(WPARAM wParam,LPARAM lParam);
INT_PTR SetNickName(WPARAM newnick, LPARAM lparam);

BOOL IsXFireContact(HANDLE h);
int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hhicon=NULL);
BOOL CreateToolTip(int toolID, HWND hDlg, CHAR* pText);
void EnableDlgItem(HWND hwndDlg, UINT control, int state);
BOOL str_replace(char*src,char*find,char*rep);
extern void Message(LPVOID msg);
extern void MessageE(LPVOID msg);
char* GetLaunchPath(char*launch);
unsigned short r(unsigned short data);
BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port);
BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port);
BOOL FindTeamSpeak(DWORD*pid,int*vid);
char*menuitemtext(char*mtext);
BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain);
char * getItem(char * string,char delim,int count);
BOOL GetWWWContent(char*host,char* request,char*filename,BOOL dontoverwrite);
BOOL GetWWWContent2(char*address,char*filename,BOOL dontoverwrite,char**tobuf=NULL,unsigned int* size=NULL);
BOOL CheckWWWContent(char*address);
unsigned int getfilesize(char*path);
void UpdateMyXFireIni(LPVOID dummy);
void UpdateMyIcons(LPVOID dummy);
BOOL IsContactMySelf(std::string buddyusername);
DWORD xfire_GetPrivateProfileString(__in   LPCTSTR lpAppName, __in   LPCTSTR lpKeyName, __in   LPCTSTR lpDefault, __out  LPTSTR lpReturnedString, __in   DWORD nSize, __in   LPCTSTR lpFileName);
BOOL mySleep(int ms,HANDLE evt);
void __stdcall XFireLog( const char* fmt, ... );

#define ID_STATUS_RECONNECT ID_STATUS_OFFLINE-1

struct CONTACT // Contains info about users
{
	TCHAR* name;
	TCHAR* user;
	TCHAR* host;
	bool ExactOnly;
	bool ExactWCOnly;
	bool ExactNick;
};


#define MSGBOX(msg) mir_forkthread(Message,(LPVOID)msg)
#define MSGBOXE(msg)  mir_forkthread(MessageE,(LPVOID)msg)

#pragma comment(lib,"Advapi32.lib")
#pragma comment(lib,"Psapi.lib")
#pragma comment(lib,"gdiplus.lib")
#pragma comment(lib,"comdlg32.lib")
#pragma comment(lib,"comctl32.lib")
#pragma comment(lib,"shell32.lib")

//=====================================================
//	Definitions
//=====================================================

struct GameIco {
	int gameid;
	HANDLE handle;
	HICON hicon;
};

struct XFireContact {
	char * username;
	char * nick;
	int id;
	int sid;
};

struct XFireAvatar {
	int type;
	char backup[256];
	char file[256];
	char rfile[256];
};

struct XFire_FoundGame
{
	int gameid;
	int gameid2;
	short send_gameid;
	char path[256];
	char mpath[9][256];
	int morepaths;
	char launchparams[1024];
	char networkparams[1024];
	char userparams[1024];
	char pwparams[1024];
	char mustcontain[1024];
	char notcontain[1024];
	char temp[128];
	BOOL setstatusmsg;
	BOOL custom;
	BOOL skip;
	BOOL noicqstatus;
	HANDLE menuitem;
};

struct XFire_SetAvatar
{
	HANDLE hContact;
	char* username;
};

struct gServerstats {
	int players;
	int maxplayers;
	char name[512];
	char map[512];
	char gametype[512];
	char fgametype[512];
	BOOL password;
};

struct GameServerQuery_query {
	int xfiregameid;
	char ip[16];
	WORD port;
	HANDLE handle; //will be overwritten
	int queryengine; // immer 0
};

#define XFIRE_MAX_STATIC_STRING_LEN 1024
#define XFIRE_SCAN_VAL 0x3

#define XFIRE_GAME_ICON 0
#define XFIRE_VOICE_ICON 1


typedef struct {
	int cbSize;
	char *szProto; // pointer to protocol modulename (NULL means global)
	union
	{
		char *szMsg;
		WCHAR *wszMsg;
		TCHAR *tszMsg;
	}; // pointer to the status message _format_ (i.e. it's an unparsed message containing variables, in any case. NAS takes care of parsing) (may be NULL - means that there's no specific message for this protocol - then the global status message will be used)
/*
	Be aware that MS_NAS_GETSTATE allocates memory for szMsg through Miranda's
	memory management interface (MS_SYSTEM_GET_MMI). And MS_NAS_SETSTATE
	expects szMsg to be allocated through the same service. MS_NAS_SETSTATE deallocates szMsg.
*/
	WORD status; // status mode. 0 means current (NAS will overwrite 0 with the current status mode)
// for MS_NAS_GETSTATE if the specified status is not 0, MS_NAS_GETSTATE will return the default/last status message (depends on settings) - i.e. the same message that will be shown by default when user changes status to the specified one. please note that, for example, if current status mode is ID_STATUS_AWAY, then status messages returned by MS_NAS_GETSTATE for status=0 and status=ID_STATUS_AWAY may be different! for status=ID_STATUS_AWAY it always returns the default/last status message, and for status=0 it returns _current_ status message.
	int Flags;
} NAS_PROTOINFO;

#endif