📄 ipmsg.h
字号:
void SetFont(void);
void SetSize(void);
void SetMainMenu(HMENU hMenu);
void PopupContextMenu(void);
void GetOrder(void);
void SetQuoteStr(LPSTR str, LPCSTR quoteStr);
void SelectHost(HostSub *hostSub, BOOL force=FALSE);
void DisplayMemberCnt(void);
UINT GetInsertIndexPoint(Host *host);
int CompareHosts(Host *host1, Host *host2);
int GroupCompare(Host *host1, Host *host2);
int SubCompare(Host *host1, Host *host2);
BOOL SendMsg(void);
BOOL SendMsgSub(void);
BOOL MakeEncryptPacket(SendEntry *entry);
BOOL MakeEncryptMsg(Host *host, char *msgstr, char *buf);
BOOL IsSendFinish(void);
void InitializeHeader(void);
char *GetListItemStr(Host *host, int item);
void MakeEncryptMsg(Host *host, char *msgbuf);
public:
TSendDlg(MsgMng *_msgmng, ShareMng *_shareMng, THosts *_hosts, Cfg *cfg, LogMng *logmng, HWND _hRecvWnd = NULL, MsgBuf *msg = NULL);
virtual ~TSendDlg();
HWND GetRecvWnd(void) { return hRecvWnd; }
void AddHost(Host *host);
void ModifyHost(Host *host);
void DelHost(Host *host);
void DelAllHost(void);
BOOL IsSending(void);
BOOL SendFinishNotify(HostSub *hostSub, ULONG packet_no);
BOOL SendPubKeyNotify(HostSub *hostSub, BYTE *pubkey, int len, int e, int capa);
BOOL FindHost(char *findStr, BOOL isAllfind);
virtual BOOL EvCreate(LPARAM lParam);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvSysCommand(WPARAM uCmdType, WORD xPos, WORD yPos);
virtual BOOL EvSize(UINT fwSizeType, WORD nWidth, WORD nHeight);
virtual BOOL EvTimer(WPARAM timerID, TIMERPROC proc);
virtual BOOL EvGetMinMaxInfo(MINMAXINFO *info);
virtual BOOL EvMouseMove(UINT fwKeys, POINTS pos);
virtual BOOL EvContextMenu(HWND childWnd, WORD xPos, WORD yPos);
virtual BOOL EvMeasureItem(UINT ctlID, MEASUREITEMSTRUCT *lpMis);
virtual BOOL EvDrawItem(UINT ctlID, DRAWITEMSTRUCT *lpDis);
virtual BOOL EvMenuSelect(UINT uItem, UINT fuFlag, HMENU hMenu);
virtual BOOL EvNotify(UINT ctlID, NMHDR *pNmHdr);
virtual BOOL EvDropFiles(HDROP hDrop);
virtual BOOL EventButton(UINT uMsg, int nHitTest, POINTS pos);
virtual BOOL EventInitMenu(UINT uMsg, HMENU hMenu, UINT uPos, BOOL fSystemMenu);
virtual BOOL EventCtlColor(UINT uMsg, HDC hDcCtl, HWND hWndCtl, HBRUSH *result);
virtual BOOL EventUser(UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void Show(int mode = SW_SHOWDEFAULT);
};
enum FileStatus { FS_DIRFILESTART, FS_OPENINFO, FS_FIRSTINFO, FS_NEXTINFO, FS_MAKEINFO, FS_TRANSINFO, FS_TRANSFILE, FS_ENDFILE, FS_COMPLETE, FS_ERROR };
struct RecvFileObj {
ConnectInfo *conInfo;
FileInfo *fileInfo;
BOOL isDir;
FileInfo curFileInfo;
_int64 offset;
_int64 woffset;
char *recvBuf;
HANDLE hFile;
HANDLE hThread;
int infoLen;
int dirCnt;
_int64 totalTrans;
DWORD startTick;
DWORD lastTick;
int totalFiles;
FileStatus status;
char saveDir[MAX_PATH];
char path[MAX_PATH];
char info[MAX_BUF]; // for dirinfo buffer
};
class TRecvDlg : public TListDlg {
protected:
static int createCnt;
MsgMng *msgMng;
MsgBuf msg;
THosts *hosts;
char head[MAX_LISTBUF];
Cfg *cfg;
LogMng *logmng;
BOOL openFlg;
SYSTEMTIME recvTime;
HFONT hHeadFont;
HFONT hEditFont;
LOGFONT orgFont;
TEditSub editSub;
BOOL status;
RecvFileObj *fileObj;
ShareInfo *shareInfo;
UINT timerID;
UINT retryCnt;
char readMsgBuf[MAX_LISTBUF];
ULONG packetNo;
int cryptCapa;
RECT orgRect;
enum recv_item { title_item=0, head_item, head2_item, open_item, edit_item, ok_item, cancel_item, quote_item, file_item, max_recvitem };
WINPOS item[max_recvitem];
void SetFont(void);
void SetSize(void);
void SetMainMenu(HMENU hMenu);
void PopupContextMenu(void);
BOOL TcpEvent(int sd, LPARAM lParam);
BOOL StartRecvFile(void);
BOOL ConnectRecvFile(void);
static DWORD WINAPI RecvFileThread(void *_recvDlg);
BOOL SaveFile(void);
BOOL OpenRecvFile(void);
BOOL RecvFile(void);
BOOL RecvDirFile(void);
BOOL CloseRecvFile(BOOL setAttr=FALSE);
BOOL EndRecvFile(BOOL manual_suspend=FALSE);
void SetTransferButtonText(void);
BOOL DecryptMsg(void);
public:
TRecvDlg(MsgMng *_msgmng, MsgBuf *_msg, THosts *hosts, Cfg *cfg, LogMng *logmng);
virtual ~TRecvDlg();
virtual BOOL IsClosable(void) { return openFlg && (fileObj == NULL || fileObj->conInfo == NULL); }
virtual BOOL IsSamePacket(MsgBuf *test_msg);
virtual BOOL SendFinishNotify(HostSub *hostSub, ULONG packet_no);
virtual BOOL EvCreate(LPARAM lParam);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvSysCommand(WPARAM uCmdType, WORD xPos, WORD yPos);
virtual BOOL EvSize(UINT fwSizeType, WORD nWidth, WORD nHeight);
virtual BOOL EvGetMinMaxInfo(MINMAXINFO *info);
virtual BOOL EvTimer(WPARAM timerID, TIMERPROC proc);
virtual BOOL EvContextMenu(HWND childWnd, WORD xPos, WORD yPos);
virtual BOOL EventButton(UINT uMsg, int nHitTest, POINTS pos);
virtual BOOL EventUser(UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual BOOL EventInitMenu(UINT uMsg, HMENU hMenu, UINT uPos, BOOL fSystemMenu);
virtual BOOL EventCtlColor(UINT uMsg, HDC hDcCtl, HWND hWndCtl, HBRUSH *result);
virtual void Show(int mode = SW_NORMAL);
BOOL Status() { return status; }
static int GetCreateCnt(void) { return createCnt; }
};
class TSetupDlg : public TDlg {
protected:
Cfg *cfg;
THosts *hosts;
void SetData(void);
void GetData(void);
public:
TSetupDlg(Cfg *cfg, THosts *hosts, TWin *_parent = NULL);
virtual ~TSetupDlg();
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvCreate(LPARAM lParam);
};
class TAboutDlg : public TDlg {
public:
TAboutDlg(TWin *_parent = NULL);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvCreate(LPARAM lParam);
};
class TMsgDlg : public TListDlg {
protected:
static int createCnt;
int showMode;
public:
TMsgDlg(TWin *_parent = NULL);
virtual ~TMsgDlg();
virtual BOOL Create(char *text, char *title, int _showMode = SW_SHOW);
virtual BOOL EvCreate(LPARAM lParam);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hWndCtl);
static int GetCreateCnt(void) { return createCnt; }
};
class TLogDlg : public TDlg {
protected:
Cfg *cfg;
void SetData(void);
void GetData(void);
public:
TLogDlg(Cfg *_cfg, TWin *_parent = NULL);
BOOL OpenSoundFileDlg(void);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvCreate(LPARAM lParam);
};
class TPasswordDlg : public TDlg {
protected:
Cfg *cfg;
public:
TPasswordDlg(Cfg *_cfg, TWin *_parent = NULL);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvCreate(LPARAM lParam);
};
class TPasswdChangeDlg : public TDlg {
protected:
Cfg *cfg;
public:
TPasswdChangeDlg(Cfg *_cfg, TWin *_parent = NULL);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvCreate(LPARAM lParam);
};
class TShareStatDlg : public TDlg {
ShareMng *shareMng;
Cfg *cfg;
char lvBuf[MAX_PATH];
BOOL SetAllList(void);
BOOL DelList(int cnt);
TListViewEx shareListView;
public:
TShareStatDlg(ShareMng *_shareMng, Cfg *_cfg, TWin *_parent = NULL);
~TShareStatDlg();
// virtual int Exec(void);
virtual BOOL Refresh(void);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvCreate(LPARAM lParam);
virtual BOOL EvNotify(UINT ctlID, NMHDR *pNmHdr);
};
struct SendFileObj : public TListObj {
ConnectInfo *conInfo;
FileInfo *fileInfo;
FILETIME attachTime;
UINT command;
BOOL isDir;
_int64 fileSize;
_int64 offset;
char *mapAddr;
HANDLE hFile;
HANDLE hMap;
HANDLE hThread;
Host *host;
int packetNo;
FileStatus status;
int dirCnt;
HANDLE *hDir; // FindFirst handle
char path[MAX_PATH];
int headerLen;
int headerOffset;
char header[MAX_BUF]; // for dirinfo
WIN32_FIND_DATA fdata;
};
class TMainWin : public TWin {
protected:
static HICON hMainIcon;
static HICON hRevIcon;
static TMainWin *mainWin; // for thread proc
TList sendList;
TList recvList;
TList msgList;
TList sendFileList;
TList connectList;
THosts hosts;
TSetupDlg *setupDlg;
TAboutDlg *aboutDlg;
TShareStatDlg *shareStatDlg;
TAbsenceDlg *absenceDlg;
MsgMng *msgMng;
LogMng *logmng;
ShareMng *shareMng;
Cfg *cfg;
TRecycleList *ansList;
int portNo;
int memberCnt;
time_t refreshStartTime;
time_t entryStartTime;
UINT entryTimerStatus;
UINT reverseTimerStatus;
UINT ansTimerID;
UINT TaskBarCreateMsg;
BOOL terminateFlg;
BOOL activeToggle;
#define MAX_PACKETLOG 16
struct {
ULONG no;
ULONG addr;
int port;
} packetLog[MAX_PACKETLOG];
int packetLogCnt;
BOOL IsLastPacket(MsgBuf *msg);
void SetIcon(HICON hSetIcon);
void ReverseIcon(BOOL startFlg);
void EntryHost(void);
void ExitHost(void);
void Popup(UINT resId);
BOOL PopupCheck(void);
BOOL AddAbsenceMenu(HMENU hMenu, int insertIndex);
void ActiveChildWindow(BOOL hide=FALSE);
BOOL TaskBar(int nimMode, HICON hSetIcon = NULL, LPCSTR tip = NULL);
BOOL UdpEvent(LPARAM lParam);
BOOL TcpEvent(int sd, LPARAM lParam);
BOOL CheckConnectInfo(ConnectInfo *conInfo);
inline SendFileObj *FindSendFileObj(int sd);
BOOL StartSendFile(int sd);
BOOL OpenSendFile(const char *fname, SendFileObj *obj);
static DWORD WINAPI SendFileThread(void *_sendFileObj);
BOOL SendFile(SendFileObj *obj);
BOOL SendDirFile(SendFileObj *obj);
BOOL CloseSendFile(SendFileObj *obj);
BOOL EndSendFile(SendFileObj *obj);
void BroadcastEntry(ULONG mode);
void BroadcastEntrySub(ULONG addr, int portNo, ULONG mode);
void BroadcastEntrySub(HostSub *hostSub, ULONG mode);
void Terminate(void);
BOOL SendDlgOpen(HWND hRecvWnd = NULL, MsgBuf *msg = NULL);
void SendDlgHide(TSendDlg *sendDlg);
void SendDlgExit(TSendDlg *sendDlg);
BOOL RecvDlgOpen(MsgBuf *msg);
void RecvDlgExit(TRecvDlg *recvDlg);
void MsgDlgExit(TMsgDlg *msgDlg);
void MiscDlgOpen(TDlg *dlg);
void LogOpen(void);
void AddHost(HostSub *hostSub, ULONG command, char *nickName="", char *groupName="");
inline void SetHostData(Host *destHost, HostSub *hostSub, ULONG command, time_t now_time, char *nickName="", char *groupName="", int priority=DEFAULT_PRIORITY);
void DelAllHost(void);
void DelHost(HostSub *hostSub);
void DelHostSub(Host *host);
void RefreshHost(BOOL unRemove);
void SetCaption(void);
void SendHostList(MsgBuf *msg);
void AddHostList(MsgBuf *msg);
ULONG HostStatus(void);
void ActiveListDlg(TList *dlgList, BOOL active = TRUE);
void DeleteListDlg(TList *dlgList);
void ActiveDlg(TDlg *dlg, BOOL active = TRUE);
char *GetNickNameEx(void);
void InitIcon(void);
void ControlIME(TWin *win, BOOL on);
BOOL SetAnswerQueue(AddrObj *obj);
void ExecuteAnsQueue(void);
#define KEY_REBUILD 0x0001
#define KEY_DIAG 0x0002
BOOL SetupCryptAPI(void);
BOOL SetupCryptAPICore(int ctl_flg = 0);
void MsgBrEntry(MsgBuf *msg);
void MsgBrExit(MsgBuf *msg);
void MsgAnsEntry(MsgBuf *msg);
void MsgBrAbsence(MsgBuf *msg);
void MsgSendMsg(MsgBuf *msg);
void MsgRecvMsg(MsgBuf *msg);
void MsgReadMsg(MsgBuf *msg);
void MsgBrIsGetList(MsgBuf *msg);
void MsgOkGetList(MsgBuf *msg);
void MsgGetList(MsgBuf *msg);
void MsgAnsList(MsgBuf *msg);
void MsgGetInfo(MsgBuf *msg);
void MsgSendInfo(MsgBuf *msg);
void MsgGetPubKey(MsgBuf *msg);
void MsgAnsPubKey(MsgBuf *msg);
void MsgGetAbsenceInfo(MsgBuf *msg);
void MsgSendAbsenceInfo(MsgBuf *msg);
void MsgReleaseFiles(MsgBuf *msg);
void MsgInfoSub(MsgBuf *msg);
public:
TMainWin(ULONG _nicAddr=INADDR_ANY, int _portNo=IPMSG_DEFAULT_PORT, TWin *_parent = NULL);
virtual ~TMainWin();
virtual BOOL EvCreate(LPARAM lParam);
virtual BOOL EvClose(void);
virtual BOOL EvCommand(WORD wNotifyCode, WORD wID, LPARAM hwndCtl);
virtual BOOL EvSysCommand(WPARAM uCmdType, WORD xPos, WORD yPos);
virtual BOOL EvTimer(WPARAM timerID, TIMERPROC proc);
virtual BOOL EvEndSession(BOOL nSession, BOOL nLogOut);
virtual BOOL EvQueryOpen(void);
virtual BOOL EvHotKey(int hotKey);
virtual BOOL EventButton(UINT uMsg, int nHitTest, POINTS pos);
virtual BOOL EventInitMenu(UINT uMsg, HMENU hMenu, UINT uPos, BOOL fSystemMenu);
virtual BOOL EventUser(UINT uMsg, WPARAM wParam, LPARAM lParam);
static HICON GetIPMsgIcon(void);
};
class TMsgApp : public TApp {
public:
TMsgApp(HINSTANCE _hI, LPSTR _cmdLine, int _nCmdShow);
virtual ~TMsgApp();
virtual void InitWindow(void);
};
class OpenFileDlg {
public:
enum Mode { OPEN, MULTI_OPEN, SAVE, NODEREF_SAVE };
protected:
TWin *parent;
LPOFNHOOKPROC hook;
Mode mode;
public:
OpenFileDlg(TWin *_parent, Mode _mode=OPEN, LPOFNHOOKPROC _hook=NULL) { parent = _parent; hook = _hook; mode = _mode; }
BOOL Exec(char *target, char *title=NULL, char *filter=NULL, char *defaultDir=NULL);
BOOL Exec(UINT editCtl, char *title=NULL, char *filter=NULL, char *defaultDir=NULL);
};
char *strncpyz(char *dest, const char *src, int num);
int strncmpi(const char *str1, const char *str2, int num);
BOOL CheckPassword(const char *cfgPasswd, const char *inputPasswd);
void MakePassword(const char *inputPasswd, char *outputPasswd);
#define MSS_SPACE 0x00000001
#define MSS_NOPOINT 0x00000002
int MakeSizeString(char *buf, _int64 size, int flg=0);
UrlObj *SearchUrlObj(TList *list, char *protocol);
void SetDlgIcon(HWND hWnd);
void MakeListString(Cfg *cfg, HostSub *hostSub, THosts *hosts, char *buf);
void MakeListString(Cfg *cfg, Host *host, char *buf);
HWND GetMainWnd(void);
char *GetVerionStr(void);
BOOL SetImeOpenStatus(HWND hWnd, BOOL flg);
BOOL GetImeOpenStatus(HWND hWnd);
BOOL SetHotKey(Cfg *cfg);
BOOL IsSameHost(HostSub *host, HostSub *host2);
inline BOOL IsSameHostEx(HostSub *host, HostSub *host2) { return IsSameHost(host, host2) && host->addr == host2->addr && host->portNo == host2->portNo ? TRUE : FALSE; }
void RectToWinPos(const RECT *rect, WINPOS *wpos);
time_t Time(void);
char *Ctime(SYSTEMTIME *st=NULL);
BOOL GetFileInfomation(const char *path, WIN32_FIND_DATA *fdata);
BOOL BrowseDirDlg(TWin *parentWin, const char *title, const char *defaultDir, char *buf);
BOOL PathToDir(const char *org_path, char *target_dir);
BOOL PathToFname(const char *org_path, char *target_fname);
void ForcePathToFname(const char *org_path, char *target_fname);
void ConvertShareMsgEscape(char *str);
BOOL IsSafePath(const char *fullpath, const char *fname);
BOOL GetLastErrorMsg(char *msg=NULL, TWin *win=NULL);
BOOL GetSockErrorMsg(char *msg=NULL, TWin *win=NULL);
int MakePath(char *dest, const char *dir, const char *file);
_int64 hex2ll(char *buf);
void bin2hexstr(const BYTE *bin, int len, char *buf);
BOOL hexstr2bin(const char *buf, BYTE *bindata, int maxlen, int *len);
void bin2hexstr_bigendian(const BYTE *bin, int len, char *buf);
BOOL hexstr2bin_bigendian(const char *buf, BYTE *bindata, int maxlen, int *len);
char *separate_token(char *buf, char separetor, char **handle);
// 1601擭1寧1擔偐傜1970擭1寧1擔傑偱偺捠嶼100僫僲昩
#define UNIXTIME_BASE ((_int64)0x019db1ded53e8000)
inline time_t FileTime2UnixTime(FILETIME *ft) {
return (time_t)((*(_int64 *)ft - UNIXTIME_BASE) / 10000000);
}
inline void UnixTime2FileTime(time_t ut, FILETIME *ft) {
*(_int64 *)ft = (_int64)ut * 10000000 + UNIXTIME_BASE;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -