private void ReceiveFile(TcpClient client) { // receive file name String jsonFileNode = TcpUtils.ReceiveDescription(client); FileNode fileNode = JsonConvert.DeserializeObject <FileNode>(jsonFileNode); String destinationDir = CheckDict(client, fileNode); if (destinationDir != null) { if (!Properties.Settings.Default.AutoAccept) { InterfaceUtils.ShowMainWindow(false); } ReceiveDirectoryFile(client, fileNode, destinationDir); } else { // retrieveing destination dir if (Properties.Settings.Default.AutoAccept) { TcpUtils.SendAcceptanceResponse(client); // default dir destinationDir = Properties.Settings.Default.DefaultDir; } else { // asking user for file acceptance UI.FilesAcceptance fileAcceptanceWindow = new UI.FilesAcceptance(fileNode); // blocking call until window is closed fileAcceptanceWindow.ShowDialog(); if (fileAcceptanceWindow.AreFilesAccepted) { // file accepted TcpUtils.SendAcceptanceResponse(client); destinationDir = fileAcceptanceWindow.DestinationDir; InterfaceUtils.ShowMainWindow(false); } else { // file not accepted or window closed TcpUtils.SendRefuseResponse(client); return; } } ReceiveFileContent(client, fileNode, destinationDir); } }
private void ReceiveDirectory(TcpClient client) { string jsonDirectoryNodeDescription = TcpUtils.ReceiveDescription(client); DirectoryNode directoryNode = JsonConvert.DeserializeObject <DirectoryNode>(jsonDirectoryNodeDescription); String destinationDir = null; // retrieving destination dir if (Properties.Settings.Default.AutoAccept) { TcpUtils.SendAcceptanceResponse(client); // retrieving default dir destinationDir = Properties.Settings.Default.DefaultDir; } else { // asking user for file acceptance UI.FilesAcceptance fileAcceptanceWindow = new UI.FilesAcceptance(directoryNode); // blocking call until window is closed fileAcceptanceWindow.ShowDialog(); if (fileAcceptanceWindow.AreFilesAccepted) { // file accepted TcpUtils.SendAcceptanceResponse(client); destinationDir = fileAcceptanceWindow.DestinationDir; } else { // file not accepted or window closed TcpUtils.SendRefuseResponse(client); return; } } PopulateDirectory(client, directoryNode, destinationDir); }