Exemplo n.º 1
0
BOOL LogMng::WriteRecvMsg(MsgBuf *msg, int opt, THosts *hosts, ShareInfo *shareInfo,
	const std::vector<HostSub> *recvList, int64 *msg_id)
{
	if (msg->command & IPMSG_NOLOGOPT)
		return	FALSE;

	WriteStart();
	logMsg->flags |= DB_FLAG_FROM;
	SetLogMsgUser(cfg, &msg->hostSub, hosts, logMsg);

	char	buf[MAX_PATH_U8];
	char	*p = buf;

	p += strcpyz(p, LOGMSG_FROM);
	p += MakeListString(cfg, &msg->hostSub, hosts, p, TRUE);
	p += strcpyz(p, "\r\n");
	Write(buf);

	if (recvList && recvList->size() >= 1) {
		for (auto &h: *recvList) {
			p = buf;
			p += strcpyz(p, LOGMSG_CC);
			p += MakeListString(cfg, (HostSub *)&h, hosts, p, TRUE);
			p += strcpyz(p, "\r\n");
			Write(buf);

			SetLogMsgUser(cfg, (HostSub *)&h, hosts, logMsg);
		}
	}

	return	WriteMsg(msg->packetNo, msg->msgBuf.s(), msg->command, opt, msg->timestamp,
		shareInfo, msg_id);
}
Exemplo n.º 2
0
void THistDlg::SendNotify(HostSub *hostSub, ULONG packetNo)
{
#define MAX_OPENHISTORY 500
	int num = histHash.GetRegisterNum();
	if (num >= MAX_OPENHISTORY) {
		if (HistObj *obj = histHash.End()) {
			if (hWnd) histListView.DeleteItem(num-1);
			histHash.UnRegister(obj);
			if (!*obj->odate) unOpenedNum--;
			delete obj;
			num--;
		}
	}

	HistObj	*obj = new HistObj();
	int		len = MakeHistInfo(hostSub, packetNo, obj->info);

	histHash.Register(obj, MakeHash(obj->info, len, 0));

	MakeListString(cfg, hostSub, hosts, obj->user);
	SYSTEMTIME	st;
	::GetLocalTime(&st);
	sprintf(obj->sdate, "%02d/%02d %02d:%02d", st.wMonth, st.wDay, st.wHour, st.wMinute);
	sprintf(obj->pktno, "%x", packetNo);

	unOpenedNum++;

	if (hWnd) {
		if (!openedMode) {
			SetData(obj);
		}
		SetTitle();
	}
}
Exemplo n.º 3
0
/*
	ログ記録/ウィンドウ表示用の HostEntry表示文字列
*/
void MakeListString(Cfg *cfg, HostSub *hostSub, THosts *hosts, char *buf, BOOL is_log)
{
    Host	*host;

    if ((host = hosts->GetHostByAddr(hostSub)) && IsSameHost(hostSub, &host->hostSub)
            || GetUserNameDigestField(hostSub->userName) &&
            (host = cfg->priorityHosts.GetHostByName(hostSub)))
        MakeListString(cfg, host, buf, is_log);
    else {
        Host	host;

        memset(&host, 0, sizeof(host));
        host.hostSub = *hostSub;
        MakeListString(cfg, &host, buf, is_log);
    }
}
Exemplo n.º 4
0
BOOL LogMng::WriteRecvMsg(MsgBuf *msg, THosts *hosts, ShareInfo *shareInfo)
{
	if (msg->command & IPMSG_NOLOGOPT)
		return	FALSE;

	WriteStart();
	char	buf[MAX_PATH] = " From: ";

	MakeListString(cfg, &msg->hostSub, hosts, buf + strlen(buf));
	strcat(buf, "\r\n");
	Write(buf);

	return	WriteMsg(msg->msgBuf, msg->command, shareInfo);
}
Exemplo n.º 5
0
TRecvDlg::TRecvDlg(MsgMng *_msgMng, MsgBuf *_msg, THosts *_hosts, Cfg *_cfg, LogMng *_logmng) : TListDlg(RECEIVE_DIALOG), editSub(_cfg, this)
{
	msgMng		= _msgMng;
	cfg			= _cfg;
	openFlg		= FALSE;
	logmng		= _logmng;
	hosts		= _hosts;
	hEditFont	= NULL;
	hHeadFont	= NULL;
	fileObj		= NULL;
	shareInfo	= NULL;
	timerID		= 0;
	retryCnt	= 0;
	cryptCapa	= 0;
	createCnt++;
	::GetLocalTime(&recvTime);

	memset(&orgFont, 0, sizeof(orgFont));
	msg.Init(_msg);

	MakeListString(cfg, &msg.hostSub, hosts, head);

	if (msg.command & IPMSG_FILEATTACHOPT)
	{
		char	*shareStr = msg.msgBuf + msg.exOffset;
		if ((shareInfo = DecodeShareMsg(shareStr)) != NULL)
		{
			fileObj = new RecvFileObj;
			memset(fileObj, 0, sizeof(RecvFileObj));
		}
	}

	status = TRUE;
	if (msg.command & IPMSG_ENCRYPTOPT) {
		if ((status = DecryptMsg()) == FALSE)
			msgMng->Send(&msg.hostSub, IPMSG_SENDMSG|IPMSG_NOLOGOPT, GetLoadStr(IDS_DECRYPTERR));
	}
/* msgmng.cpp で変換済み
	else if ((msg.command & IPMSG_UTF8OPT) == 0) {
		strncpyz(msg.msgBuf, AtoU8(msg.msgBuf), sizeof(msg.msgBuf));
	}
*/
	if (status) {
		if ((msg.command & IPMSG_PASSWORDOPT) == 0 || cfg->PasswdLogCheck == FALSE)
			logmng->WriteRecvMsg(&msg, hosts, shareInfo);

		hAccel = ::LoadAccelerators(TApp::GetInstance(), (LPCSTR)IPMSG_ACCEL);
	}
}
Exemplo n.º 6
0
BOOL LogMng::WriteSendHead(Host *host)
{
	char	buf[MAX_BUF];
	char	*p = buf;

	p += strcpyz(p, LOGMSG_TO);
	p += MakeListString(cfg, host, p, TRUE);
	p += strcpyz(p, "\r\n");

	BOOL ret = Write(buf);

	SetLogMsgUser(host, logMsg);

	return	ret;
}
Exemplo n.º 7
0
BOOL LogMng::GetRecvMsg(MsgBuf *msg, int opt, THosts *hosts, ShareInfo *shareInfo,
	const std::vector<HostSub> *recvList, U8str *u)
{
	U8str	buf(MAX_UDPBUF);
	char	*p = buf.Buf();

	p += strcpyz(p, LOGMSG_HEAD_TOP);
	p += strcpyz(p, LOGMSG_FROM);
	p += MakeListString(cfg, &msg->hostSub, hosts, p, TRUE);
	p += strcpyz(p, "\r\n");

	if (recvList && recvList->size() >= 1) {
		for (auto &h: *recvList) {
			p += strcpyz(p, LOGMSG_CC);
			p += MakeListString(cfg, (HostSub *)&h, hosts, p, TRUE);
			p += strcpyz(p, "\r\n");
		}
	}

	p += strcpyz(p, LOGMSG_AT);
	p += strcpyz(p, Ctime(&msg->timestamp)); 
	p += strcpyz(p, " ");

	int	command = msg->command;

	if (command & IPMSG_BROADCASTOPT) {
		p += strcpyz(p, LoadStrU8(IDS_BROADCASTLOG));
	}
	if (command & IPMSG_AUTORETOPT) {
		p += strcpyz(p, LoadStrU8(IDS_AUTORETLOG));
	}
	if (command & IPMSG_MULTICASTOPT) {
		p += strcpyz(p, LoadStrU8(IDS_MULTICASTLOG));
	}
	if (command & IPMSG_ENCRYPTOPT) {
		int	id = 0;
		if (opt & LOG_SIGN2_OK) {
			id = IDS_ENCRYPT2_SIGNED2;
		}
		else if (opt & LOG_SIGN_OK) {
			id = IDS_ENCRYPT2_SIGNED;
		}
		else if (opt & LOG_SIGN_ERR) {
			id = IDS_ENCRYPT2_ERROR;
		}
		else if (opt & LOG_ENC2) {
			id = IDS_ENCRYPT2;
		}
		else {
			id = IDS_ENCRYPT;
		}
		p += strcpyz(p, LoadStrU8(id));
	}
	else if (opt & LOG_UNAUTH) {
		p += strcpyz(p, LoadStrU8(IDS_UNAUTHORIZED));
	}

	if (command & IPMSG_SECRETOPT) {
		if (command & IPMSG_PASSWORDOPT)
			p += strcpyz(p, LoadStrU8(IDS_PASSWDLOG));
		else
			p += strcpyz(p, LoadStrU8(IDS_SECRETLOG));
	}

	if (shareInfo && (command & IPMSG_FILEATTACHOPT)) {
		int	clip_num = 0;
		int	noclip_num = 0;

		for (int i=0; i < shareInfo->fileCnt; i++) {
			if (GET_MODE(shareInfo->fileInfo[i]->Attr()) == IPMSG_FILE_CLIPBOARD) {
				clip_num++;
			}
			else {
				noclip_num++;
			}
		}
		p += strcpyz(p, "\r\n  ");
		if (clip_num || noclip_num) {
			int id = clip_num ? noclip_num ? IDS_FILEWITHCLIP : IDS_WITHCLIP : IDS_FILEATTACH;
			p += strcpyz(p, LoadStrU8(id));
			p += strcpyz(p, " ");
		}

		for (int i=0; i < shareInfo->fileCnt && p - buf.Buf() < MAX_BUF; i++)
		{
			char	fname[MAX_PATH_U8];
			ForcePathToFname(shareInfo->fileInfo[i]->Fname(), fname);
			p += snprintfz(p, MAX_BUF, "%s%s", fname, i+1 == shareInfo->fileCnt ? "" : ", ");

			if (GET_MODE(shareInfo->fileInfo[i]->Attr()) == IPMSG_FILE_CLIPBOARD) {
				LogClip	clip;
				clip.fname = fname;
				SetClipDimension(cfg, &clip);
			}
		}
	}
	p += strcpyz(p, "\r\n");
	p += strcpyz(p, LOGMSG_HEAD_END);
	p += strcpyz(p, msg->msgBuf.s());
	p += strcpyz(p, "\r\n\r\n");

	*u = buf.s();
	return	TRUE;
}