⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipmsg.h

📁 飞鸽源代码C++和java 信鸽
💻 H
📖 第 1 页 / 共 4 页
字号:

protected:
	int		hostCnt;
	Host	**array[MAX_ARRAY];
	Host	*Search(Kind kind, HostSub *hostSub, int *insertIndex=NULL);
	int		Cmp(HostSub *hostSub1, HostSub *hostSub2, Kind kind);

public:
	THosts(void);
	~THosts();

	void	Enable(Kind kind, BOOL _enable) { enable[kind] = _enable; }
	BOOL	AddHost(Host *host);
	BOOL	DelHost(Host *host);
	int		HostCnt(void) { return hostCnt; }
	Host	*GetHost(int index, Kind kind=NAME) { return array[kind][index]; }
	Host	*GetHostByName(HostSub *hostSub) { return enable[NAME] ? Search(NAME, hostSub) : NULL; }
	Host	*GetHostByAddr(HostSub *hostSub) { return enable[ADDR] ? Search(ADDR, hostSub) : NULL; }
	Host	*GetHostByNameAddr(HostSub *hostSub) { return enable[NAME_ADDR] ? Search(NAME_ADDR, hostSub) : NULL; }
	int		PriorityHostCnt(int priority, int range=1);
};

struct AddrObj : public TListObj {
	ULONG	addr;
	int		portNo;
};

struct UrlObj : public TListObj {
	char	protocol[MAX_NAMEBUF];
	char	program[MAX_PATH];
};

ULONG ResolveAddr(const char *_host);

class TBroadcastObj : public TListObj {
	char	*host;
	ULONG	addr;
public:
	TBroadcastObj(const char *_host=NULL, ULONG _addr=0) { host=strdup(_host); addr=_addr; }
	~TBroadcastObj() { if (host) free(host); };
	const char *Host() { return	host; }
	ULONG	Addr(BOOL realTime=FALSE) { return realTime ? (addr = ResolveAddr(host)) : addr; }
};

class TBroadcastList : public TList {
public:
	TBroadcastList() {}
	~TBroadcastList() { Reset(); }
	void Reset(void);
//	BOOL SetHost(const char *host);
	void SetHostRaw(const char *host, ULONG addr=0) { TBroadcastObj *obj = new TBroadcastObj(host, addr); AddObj(obj); }
//	BOOL IsExistHost(const char *host);
	TBroadcastObj *Top() { return (TBroadcastObj *)TopObj(); }
	TBroadcastObj *Next(TBroadcastObj *obj) { return (TBroadcastObj *)NextObj(obj); }
};

enum SendWidth { SW_NICKNAME, SW_ABSENCE, SW_GROUP, SW_HOST, SW_IPADDR, SW_USER, SW_PRIORITY, MAX_SENDWIDTH };
inline BOOL GetItem(UINT columnItems, int sw) { return (columnItems & (1 << sw)) ? TRUE : FALSE; }
inline void SetItem(UINT *columnItems, int sw, BOOL on) { if (on) *columnItems |= (1 << sw); else *columnItems &= ~(1 << sw); }

#define CFG_ALL			0xffffffff
#define CFG_GENERAL		0x00000001
#define CFG_ABSENCE		0x00000002
#define CFG_WINSIZE		0x00000004
#define CFG_FONT		0x00000008
#define CFG_BROADCAST	0x00000010
#define CFG_CLICKURL	0x00000020
#define CFG_PRIORITY	0x00000040
#define CFG_FINDHIST	0x00000080
#define CFG_HOSTINFO	0x00001000
#define CFG_DELHOST		0x00002000
#define CFG_DELCHLDHOST	0x00004000
#define CFG_CRYPT		0x00008000

#define FT_STRICTDATE	0x00000001
#define RS_REALTIME		0x00000001

struct Cfg {
protected:
	BOOL	ReadFontRegistry(TRegistry *reg, char *key, LOGFONT *font);
	BOOL	WriteFontRegistry(TRegistry *reg, char *key, LOGFONT *font);

public:
	THosts	priorityHosts;
	THosts	fileHosts;
	int		PriorityMax;
	int		PriorityReject;
	char	**PrioritySound;

	ULONG	nicAddr;
	int		portNo;
	BOOL	NoPopupCheck;
	BOOL	OpenCheck;
	BOOL	NoErase;
	BOOL	NoBeep;
	BOOL	OneClickPopup;
	int		DelayTime;
	BOOL	LogCheck;
	char	LogFile[MAX_PATH];
	char	SoundFile[MAX_PATH];
	BOOL	AbsenceSave;
	BOOL	AbsenceCheck;
	int		AbsenceMax;
	int		AbsenceChoice;
	char	(*AbsenceStr)[MAX_PATH];
	char	(*AbsenceHead)[MAX_NAMEBUF];

	int		FindMax;
	char	(*FindStr)[MAX_NAMEBUF];
	BOOL	FindAll;

	HCRYPTPROV	hSmallCsp;
	PubKey		smallPubKey;
	HCRYPTKEY	hSmallPrivKey;

	HCRYPTPROV	hCsp;
	PubKey		pubKey;
	BYTE		*privBlob;
	int			privBlobLen;
	int			privEncryptType;
	BYTE		*privEncryptSeed;
	int			privEncryptSeedLen;
	HCRYPTKEY	hPrivKey;
	
	BOOL	QuoteCheck;
	BOOL	SecretCheck;
	BOOL	IPAddrCheck;
	BOOL	HotKeyCheck;
	int		HotKeyModify;
	int		HotKeySend;
	int		HotKeyRecv;
	int		HotKeyMisc;
	BOOL	ControlIME;
	int		GlidLineCheck;
	UINT	ColumnItems;
	BOOL	AllowSendList;
	int		fileTransOpt;
	int		ResolveOpt;
	int		EncryptNum;

	int		ViewMax;
	int		TransMax;
	int		TcpbufMax;

	int		NickNameCheck;
	char	NickNameStr[MAX_NAMEBUF];
	char	GroupNameStr[MAX_NAMEBUF];
	BOOL	AbnormalButton;
	BOOL	AbsenceNonPopup;
	BOOL	ListGet;
	UINT	ListGetMSec;
	UINT	RetryMSec;
	UINT	RetryMax;
	int		RecvMax;
	char	Lang[MAX_LANGBUF];
	char	IconFile[MAX_PATH];
	char	RevIconFile[MAX_PATH];
	char	lastSaveDir[MAX_PATH];
	char	lastOpenDir[MAX_PATH];
	ULONG	Sort;
	int		UpdateTime;
	int		KeepHostTime;
	BOOL	MsgMinimize;
	BOOL	DefaultUrl;
	BOOL	ShellExec;
	BOOL	ExtendEntry;
	char	QuoteStr[MAX_NAMEBUF];
	BOOL	Debug;

	int		SendWidth[MAX_SENDWIDTH];
	int		SendOrder[MAX_SENDWIDTH];

	int		SendXdiff;
	int		SendYdiff;
	int		SendMidYdiff;
	BOOL	SendSavePos;
	int		SendXpos;
	int		SendYpos;

	int		RecvXdiff;
	int		RecvYdiff;
	BOOL	RecvSavePos;
	int		RecvXpos;
	int		RecvYpos;

	LOGFONT	SendEditFont;
	LOGFONT	SendListFont;
	LOGFONT	RecvHeadFont;
	LOGFONT	RecvEditFont;

	char	PasswordStr[MAX_NAMEBUF];
	BOOL	PasswdLogCheck;
	TList	urlList;
	BOOL	DialUpCheck;
	TList	DialUpList;
	TBroadcastList	broadcastList;

	Cfg(ULONG _nicAddr, int _portNo);
	~Cfg();
	enum PART { FIND };

	BOOL	ReadRegistry(void);
	BOOL	WriteRegistry(int ctl_flg = CFG_ALL);
	void	GetRegName(char *buf, ULONG nic_addr, int port_no);
};

struct MsgBuf {
	HostSub	hostSub;
	int		version;
	int		portNo;
	ULONG	packetNo;
	ULONG	command;
	int		exOffset;			// expand message offset in msgBuf
	int		dummy;
	char	msgBuf[MAX_UDPBUF];

	// 儊儌儕僐僺乕愡栺偺偨傔丅
	void	Init(MsgBuf *org) {
		if (org == NULL) {
			memset(this, 0, (char *)&this->dummy - (char *)this);
			*msgBuf = 0;
			return;
		}
		memcpy(this, org, (char *)&this->dummy - (char *)this);
		strcpy(this->msgBuf, org->msgBuf);
		strcpy(this->msgBuf + exOffset, org->msgBuf + exOffset);
	}
};

struct RecvBuf {
	struct sockaddr_in	addr;
	int					addrSize;
	int					size;
	char				msgBuf[MAX_UDPBUF];
};

struct ConnectInfo : public TListObj {
	SOCKET	sd;
	ULONG	addr;
	int		port;
	BOOL	server;
	BOOL	complete;
	DWORD	startTick;
	DWORD	lastTick;
};

class MsgMng {
protected:
	SOCKET		udp_sd;
	SOCKET		tcp_sd;

	BOOL		status;
	ULONG		packetNo;
	Cfg			*cfg;

	HWND		hAsyncWnd;
	UINT		uAsyncMsg;
	UINT		lAsyncMode;
	HostSub		local;

	BOOL		WSockInit(BOOL recv_flg);
	void		WSockTerm(void);
	BOOL		WSockReset(void);

public:
	MsgMng(ULONG nicAddr, int portNo, Cfg *cfg=NULL);
	~MsgMng();

	BOOL	GetStatus(void)	{ return	status; }
	HostSub	*GetLocalHost(void) { return	&local; }
	void	CloseSocket(void);
	BOOL	IsAvailableTCP() { return tcp_sd != INVALID_SOCKET ? TRUE : FALSE; }

	BOOL	Send(HostSub *hostSub, ULONG command, int val);
	BOOL	Send(HostSub *hostSub, ULONG command, const char *message=NULL, const char *exMsg=NULL);
	BOOL	Send(ULONG host_addr, int port_no, ULONG command, const char *message=NULL, const char *exMsg=NULL);
	BOOL	AsyncSelectRegist(HWND hWnd);
	BOOL	Recv(MsgBuf *msg);
	BOOL	ResolveMsg(RecvBuf *buf, MsgBuf *msg);
	ULONG	MakePacketNo(void) { return packetNo++; }
	ULONG	MakeMsg(char *udp_msg, int packetNo, ULONG command, const char *msg, const char *exMsg=NULL, int *packet_len=NULL);
	ULONG	MakeMsg(char *udp_msg, ULONG command, const char *msg, const char *exMsg=NULL, int *packet_len=NULL) { return	MakeMsg(udp_msg, MakePacketNo(), command, msg, exMsg, packet_len); }
	BOOL	UdpSend(ULONG host_addr, int port_no, const char *udp_msg);
	BOOL	UdpSend(ULONG host_addr, int port_no, const char *udp_msg, int len);
	BOOL	UdpRecv(RecvBuf *buf);

	BOOL	Accept(HWND hWnd, ConnectInfo *info);
	BOOL	Connect(HWND hWnd, ConnectInfo *info);
	BOOL	AsyncSelectConnect(HWND hWnd, ConnectInfo *info);
	BOOL	ConnectDone(HWND hWnd, ConnectInfo *info);

	static int LocalNewLineToUnix(const char *src, char *dest, int maxlen);
	static int UnixNewLineToLocal(const char *src, char *dest, int maxlen);
};

class TAbsenceDlg : public TDlg {
protected:
	Cfg		*cfg;
	int		currentChoice;
	char	(*tmpAbsenceStr)[MAX_PATH];
	char	(*tmpAbsenceHead)[MAX_NAMEBUF];
	void	SetData(void);
	void	GetData(void);

public:
	TAbsenceDlg(Cfg *_cfg, TWin *_parent = NULL);
	virtual ~TAbsenceDlg();

	virtual BOOL	EvCreate(LPARAM lParam);
	virtual BOOL	EvNcDestroy(void);
	virtual BOOL	EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
	virtual BOOL	EventUser(UINT uMsg, WPARAM wParam, LPARAM lParam);
};

class TSortDlg : public TDlg {
protected:
	static	TSortDlg *exclusiveWnd;
	Cfg		*cfg;
	void	SetData(void);
	void	GetData(void);

public:
	TSortDlg(Cfg *_cfg, TWin *_parent = NULL);

	virtual int		Exec(void);
	virtual BOOL	EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
	virtual BOOL	EvCreate(LPARAM lParam);
};

class TUrlDlg : public TDlg {
protected:
	Cfg		*cfg;
	TList	tmpUrlList;
	char	currentProtocol[MAX_NAMEBUF];
	void	SetData(void);
	void	GetData(void);
	void	SetCurrentData(void);

public:
	TUrlDlg(Cfg *_cfg, TWin *_parent = NULL);
	virtual ~TUrlDlg();

	virtual BOOL	EvCreate(LPARAM lParam);
	virtual BOOL	EvNcDestroy(void);
	virtual BOOL	EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
};

class TSendDlg;
class TFindDlg : public TDlg {
protected:
	Cfg		*cfg;
	TSendDlg	*sendDlg;

public:
	TFindDlg(Cfg *_cfg, TSendDlg *_parent);

	virtual BOOL	EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
	virtual BOOL	EvCreate(LPARAM lParam);
};

enum SendStatus { ST_GETCRYPT=0, ST_MAKECRYPTMSG, ST_MAKEMSG, ST_SENDMSG, ST_DONE };
class SendEntry {
	Host		*host;
	SendStatus	status;
	UINT		command;
	char		*msg;
	int			msgLen;

public:
	SendEntry() { msg = NULL; host = NULL; }
	~SendEntry() { delete [] msg; if (host && host->RefCnt(-1) == 0) delete host; }
	void SetMsg(char *_msg, int len) { msg = new char[msgLen=len]; memcpy(msg, _msg, len); }
	const char *Msg(void) { return msg; }
	int MsgLen() { return msgLen; }
	void SetHost(Host *_host) { (host = _host)->RefCnt(1); }
	Host *Host(void) { return host; }
	void SetStatus(SendStatus _status) { status = _status; }
	SendStatus Status(void) { return status; }
	void SetCommand(UINT _command) { command = _command ; }
	UINT Command(void) { return command; }
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -