summary refs log tree commit diff stats
path: root/src/common/dcc.h
blob: ade1dae76ac0ff7d04edcde42eb5b003bcc1013e (plain) (blame)
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
/* HexChat
 * Copyright (C) 1998-2010 Peter Zelezny.
 * Copyright (C) 2009-2013 Berke Viktor.
 *
 * 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
 */

/* dcc.h */

#include <time.h>						/* for time_t */
#include "proto-irc.h"

#ifndef HEXCHAT_DCC_H
#define HEXCHAT_DCC_H

#define STAT_QUEUED 0
#define STAT_ACTIVE 1
#define STAT_FAILED 2
#define STAT_DONE 3
#define STAT_CONNECTING 4
#define STAT_ABORTED 5

#define TYPE_SEND 0
#define TYPE_RECV 1
#define TYPE_CHATRECV 2
#define TYPE_CHATSEND 3

#define CPS_AVG_WINDOW 10

/* can we do 64-bit dcc? */
#if defined(G_GINT64_FORMAT) && defined(HAVE_STRTOULL)
#define USE_DCC64
/* we really get only 63 bits, since st_size is signed */
#define DCC_SIZE gint64
#define DCC_SFMT G_GINT64_FORMAT
#else
#define DCC_SIZE unsigned int
#define DCC_SFMT "u"
#endif

struct DCC
{
	struct server *serv;
	struct dcc_chat *dccchat;
	struct proxy_state *proxy;
	guint32 addr;					/* the 32bit IP number, host byte order */
	int fp;							/* file pointer */
	int sok;
	int iotag;						/* reading io tag */
	int wiotag;						/* writing/sending io tag */
	int port;
	int pasvid;						/* mIRC's passive DCC id */
	int cps;
	int resume_error;
	int resume_errno;

	GTimeVal lastcpstv, firstcpstv;
	DCC_SIZE lastcpspos;
	int maxcps;

	unsigned char ack_buf[4];	/* buffer for reading 4-byte ack */
	int ack_pos;

	DCC_SIZE size;
	DCC_SIZE resumable;
	DCC_SIZE ack;
	DCC_SIZE pos;
	time_t starttime;
	time_t offertime;
	time_t lasttime;
	char *file;					/* utf8 */
	char *destfile;			/* utf8 */
	char *nick;
	unsigned char type;		  /* 0 = SEND  1 = RECV  2 = CHAT */
	unsigned char dccstat;	  /* 0 = QUEUED  1 = ACTIVE  2 = FAILED  3 = DONE */
	unsigned int resume_sent:1;	/* resume request sent */
	unsigned int fastsend:1;
	unsigned int ackoffset:1;	/* is receiver sending acks as an offset from */
										/* the resume point? */
	unsigned int throttled:2;	/* 0x1 = per send/get throttle
											0x2 = global throttle */
};

#define MAX_PROXY_BUFFER 1024
struct proxy_state
{
	int phase;
	unsigned char buffer[MAX_PROXY_BUFFER];
	int buffersize;
	int bufferused;
};

struct dcc_chat
{
	char linebuf[2048];
	int pos;
};

struct dccstat_info
{
	char *name;						  /* Display name */
	int color;						  /* Display color (index into colors[] ) */
};

extern struct dccstat_info dccstat[];

gboolean is_dcc (struct DCC *dcc);
gboolean is_dcc_completed (struct DCC *dcc);
void dcc_abort (session *sess, struct DCC *dcc);
void dcc_get (struct DCC *dcc);
int dcc_resume (struct DCC *dcc);
void dcc_check_timeouts (void);
void dcc_change_nick (server *serv, char *oldnick, char *newnick);
void dcc_notify_kill (struct server *serv);
struct DCC *dcc_write_chat (char *nick, char *text);
void dcc_send (struct session *sess, char *to, char *file, int maxcps, int passive);
struct DCC *find_dcc (char *nick, char *file, int type);
void dcc_get_nick (struct session *sess, char *nick);
void dcc_chat (session *sess, char *nick, int passive);
void handle_dcc (session *sess, char *nick, char *word[], char *word_eol[],
					  const message_tags_data *tags_data);
void dcc_show_list (session *sess);
guint32 dcc_get_my_address (void);
void dcc_get_with_destfile (struct DCC *dcc, char *utf8file);

#endif
an> CWMPPlayer4::GetPlaylistCollection() { LPDISPATCH pDispatch; InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPPlaylistCollection(pDispatch); } CString CWMPPlayer4::GetVersionInfo() { CString result; InvokeHelper(0xb, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); return result; } void CWMPPlayer4::launchURL(LPCTSTR bstrURL) { static BYTE parms[] = VTS_BSTR; InvokeHelper(0xc, DISPATCH_METHOD, VT_EMPTY, NULL, parms, bstrURL); } CWMPNetwork CWMPPlayer4::GetNetwork() { LPDISPATCH pDispatch; InvokeHelper(0x7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPNetwork(pDispatch); } CWMPPlaylist CWMPPlayer4::GetCurrentPlaylist() { LPDISPATCH pDispatch; InvokeHelper(0xd, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPPlaylist(pDispatch); } void CWMPPlayer4::SetCurrentPlaylist(LPDISPATCH newValue) { static BYTE parms[] = VTS_DISPATCH; InvokeHelper(0xd, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue); } CWMPCdromCollection CWMPPlayer4::GetCdromCollection() { LPDISPATCH pDispatch; InvokeHelper(0xe, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPCdromCollection(pDispatch); } CWMPClosedCaption CWMPPlayer4::GetClosedCaption() { LPDISPATCH pDispatch; InvokeHelper(0xf, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPClosedCaption(pDispatch); } BOOL CWMPPlayer4::GetIsOnline() { BOOL result; InvokeHelper(0x10, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); return result; } CWMPError CWMPPlayer4::GetError() { LPDISPATCH pDispatch; InvokeHelper(0x11, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPError(pDispatch); } CString CWMPPlayer4::GetStatus() { CString result; InvokeHelper(0x12, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); return result; } CWMPDVD CWMPPlayer4::GetDvd() { LPDISPATCH pDispatch; InvokeHelper(0x28, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPDVD(pDispatch); } CWMPPlaylist CWMPPlayer4::newPlaylist(LPCTSTR bstrName, LPCTSTR bstrURL) { LPDISPATCH pDispatch; static BYTE parms[] = VTS_BSTR VTS_BSTR; InvokeHelper(0x29, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms, bstrName, bstrURL); return CWMPPlaylist(pDispatch); } CWMPMedia CWMPPlayer4::newMedia(LPCTSTR bstrURL) { LPDISPATCH pDispatch; static BYTE parms[] = VTS_BSTR; InvokeHelper(0x2a, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms, bstrURL); return CWMPMedia(pDispatch); } BOOL CWMPPlayer4::GetEnabled() { BOOL result; InvokeHelper(0x13, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); return result; } void CWMPPlayer4::SetEnabled(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; InvokeHelper(0x13, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, bNewValue); } BOOL CWMPPlayer4::GetFullScreen() { BOOL result; InvokeHelper(0x15, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); return result; } void CWMPPlayer4::SetFullScreen(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; InvokeHelper(0x15, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, bNewValue); } BOOL CWMPPlayer4::GetEnableContextMenu() { BOOL result; InvokeHelper(0x16, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); return result; } void CWMPPlayer4::SetEnableContextMenu(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; InvokeHelper(0x16, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, bNewValue); } void CWMPPlayer4::SetUiMode(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; InvokeHelper(0x17, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, lpszNewValue); } CString CWMPPlayer4::GetUiMode() { CString result; InvokeHelper(0x17, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); return result; } BOOL CWMPPlayer4::GetStretchToFit() { BOOL result; InvokeHelper(0x18, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); return result; } void CWMPPlayer4::SetStretchToFit(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; InvokeHelper(0x18, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, bNewValue); } BOOL CWMPPlayer4::GetWindowlessVideo() { BOOL result; InvokeHelper(0x19, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); return result; } void CWMPPlayer4::SetWindowlessVideo(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; InvokeHelper(0x19, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, bNewValue); } BOOL CWMPPlayer4::GetIsRemote() { BOOL result; InvokeHelper(0x1a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); return result; } CWMPPlayerApplication CWMPPlayer4::GetPlayerApplication() { LPDISPATCH pDispatch; InvokeHelper(0x1b, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CWMPPlayerApplication(pDispatch); } void CWMPPlayer4::openPlayer(LPCTSTR bstrURL) { static BYTE parms[] = VTS_BSTR; InvokeHelper(0x1c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, bstrURL); }