public void OnLocalClipboardDataCopied(object sender, ClipboardDataBase cbData) { //Generate a new GUID for this clipboard operation Guid opId = Guid.NewGuid(); SetGlobalClipboard(cbData, ISServerSocket.Localhost, opId); }
public ClipboardOperation(Guid operationId, ClipboardDataType dataType, ClipboardDataBase data, ISServerSocket host) { OperationId = operationId; DataType = dataType; Data = data; Host = host; }
public DataOperation(Guid operationId, ClipboardDataBase data) { OperationId = operationId; Data = data; AssociatedAccessTokens = new List <Guid>(); Completed = false; }
public void OnClientClipboardDataReceived(object sender, NetworkSocket.ClipboardDataReceivedArgs args) { ISServerSocket client = sender as ISServerSocket; ClipboardDataBase cbData = ClipboardDataBase.FromBytes(args.rawData); SetGlobalClipboard(cbData, client, args.OperationId); }
public void OnClipboardDataReceived(object sender, NetworkSocket.ClipboardDataReceivedArgs args) { if (!ClipboardEnabled) { return; } try { ClipboardDataBase cbData = ClipboardDataBase.FromBytes(args.RawData); cbData.OperationId = args.OperationId; if (cbData is ClipboardVirtualFileData cbFiles) { cbFiles.RequestPartMethod = server.RequestReadStreamAsync; cbFiles.RequestTokenMethod = server.RequestFileTokenAsync; } CurrentOperation = new ClientDataOperation(cbData, args.OperationId); clipboardMan.SetClipboardData(cbData); } catch (Exception ex) { ISLogger.Write("Failed to set clipboard data: " + ex.Message); } }
private async void BeginOperation(ISServerSocket sender, ClipboardDataBase cbData, Guid operationId) { if (cbData == null) { ISLogger.Write("DragDropController: Cannot begin operation: Data was null"); return; } if (CurrentOperation != null && CurrentOperation.State == DragDropState.Dragging) { ISLogger.Write("DragDropController: Cannot begin operation: another operation is currently dragging"); return; } ISLogger.Write("New DragDrop operation. Type {0}, Host {1}, ID {2}", cbData.DataType, sender.ClientName, operationId); if (cbData.DataType == ClipboardDataType.File) { await BeginFileOperationAsync(cbData as ClipboardVirtualFileData, sender, operationId); OnOperationChanged(); return; } else { BeginTextOrImageOperation(cbData, operationId); OnOperationChanged(); } }
public DragDropOperation(ClipboardDataBase operationData, ISServerSocket host, Guid operationId) { OperationData = operationData; Host = host; OperationId = operationId; StartTime = DateTime.Now; }
/// <summary> /// Converts an inputshare clipboard data type into a windows dataobject /// </summary> /// <param name="data"></param> /// <returns></returns> public static InputshareDataObject ConvertToWindows(ClipboardDataBase data) { if (data is ClipboardVirtualFileData fd) { List <FileAttributes> files = fd.AllFiles; InputshareDataObject o = new InputshareDataObject(files); return(o); } else if (data is ClipboardImageData imgData) { try { using (MemoryStream ms = new MemoryStream(imgData.ImageData)) { Image bmp = Image.FromStream(ms); return(new InputshareDataObject(bmp)); } } catch (Exception ex) { ISLogger.Write("Error converting image data: " + ex.Message); return(null); } } else if (data is ClipboardTextData textData) { return(new InputshareDataObject(textData)); } throw new ArgumentException("Unrecognized data type " + data.GetType().FullName); }
public void InvokeDoDragDrop(ClipboardDataBase data) { this.Invoke(new Action(() => { registeredDrop = false; cancelDrop = false; DoDragDrop(data); })); }
private static void IClient_ClipboardDataReceived(object sender, ClipboardDataBase data) { if (data is ClipboardVirtualFileData cbFiles) { cbFiles.RequestPartMethod = iClient.ReadStreamAsync; cbFiles.RequestTokenMethod = iClient.RequestFileTokenAsync; } clipMan.SetClipboardData(data); }
private void SetClipboardTextOrImage(ClipboardDataBase cbData, ISServerSocket host, Guid operationId) { if (currentOperation != null && currentOperation.DataType == ClipboardDataType.File) { previousOperationDictionary.Add(currentOperation.OperationId, currentOperation); } currentOperation = new ClipboardOperation(operationId, cbData.DataType, cbData, host); BroadcastCurrentOperation(); }
public override void SetClipboardData(ClipboardDataBase data) { if (data is ClipboardVirtualFileData cbFiles) { callbacks.Add(cbFiles.OperationId, new CallbackHolder(cbFiles.RequestPartMethod, cbFiles.RequestTokenMethod)); } ISLogger.Write("Set clipboard data " + data.OperationId); host.host.SendClipboardData(data); }
public override void DoDragDrop(ClipboardDataBase data) { if (data is ClipboardVirtualFileData cbFiles) { if (!callbacks.ContainsKey(cbFiles.OperationId)) { callbacks.Add(cbFiles.OperationId, new CallbackHolder(cbFiles.RequestPartMethod, cbFiles.RequestTokenMethod)); } } clipboardHost.host.SendDoDragDrop(data, data.OperationId); }
private void OnLocalClipboardChange(object sender, ClipboardDataBase data) { if (!GlobalClipboardEnabled) { return; } //Create a new dataoperation, a guid will be created generated automatically ServerDataOperation operation = new ServerDataOperation(data, ISServerSocket.Localhost); SetOperation(operation); }
private void SetGlobalClipboard(ClipboardDataBase data, ISServerSocket host, Guid operationId) { ISLogger.Write("New clipboard operation. Type {0}, Host {1}, ID {2}", data.DataType, host.ClientName, operationId); if (data.DataType == ClipboardDataType.File) { SetClipboardFiles((data as ClipboardVirtualFileData), host, operationId); } else { SetClipboardTextOrImage(data, host, operationId); } }
private void OnLocalClipboardChange(object sender, ClipboardDataBase data) { if (!server.IsConnected || !ClipboardEnabled) { return; } Guid opId = Guid.NewGuid(); CurrentOperation = new ClientDataOperation(data, opId); server.SendClipboardData(CurrentOperation.Data.ToBytes(), opId); }
public void OnClientClipboardChange(object sender, NetworkSocket.ClipboardDataReceivedArgs args) { if (!GlobalClipboardEnabled) { return; } ISServerSocket client = sender as ISServerSocket; ClipboardDataBase cbData = ClipboardDataBase.FromBytes(args.RawData); //Create the operation with the GUID that the client sent. We can use this GUID to request an access //token if the data contains files SetOperation(new ServerDataOperation(cbData, client, args.OperationId)); }
internal void Local_DataDropped(object sender, ClipboardDataBase cbData) { if (!server.IsConnected) { return; } if (server.IsConnected) { Guid opId = Guid.NewGuid(); CurrentOperation = new ClientDataOperation(cbData, opId); ISLogger.Write("LocalDragDropController: Started dragdrop operation " + opId); server.SendDragDropData(cbData.ToBytes(), opId); } }
public override void SetClipboardData(ClipboardDataBase data) { if (data.DataType == ClipboardDataType.File) { ISLogger.Write("{0}: Data type {1} not supported", ModuleName, data.DataType); return; } copiedData = data; XSetSelectionOwner(xConnection.XDisplay, atomClipboard, xConnection.XCbWindow); if (XGetSelectionOwner(xConnection.XDisplay, atomClipboard) != xConnection.XCbWindow) { ISLogger.Write("{0}: Failed to set selection owner!", ModuleName); } }
private async void BeginReceivedOperation(NetworkSocket.DragDropDataReceivedArgs args) { //Check if the received operation has previously been received if (CurrentOperation?.OperationId == args.OperationId) { ddManager.DoDragDrop(CurrentOperation.Data, args.OperationId); return; } if (CurrentOperation != null && !previousOperations.ContainsKey(CurrentOperation.OperationId)) { previousOperations.Add(CurrentOperation.OperationId, CurrentOperation); } ClipboardDataBase cbData = ClipboardDataBase.FromBytes(args.RawData); //We need to setup the virtual files if this is a file drop if (cbData is ClipboardVirtualFileData cbFiles) { //Get an access token for the files from the server Guid token; try { token = await Server.RequestFileTokenAsync(args.OperationId); } catch (Exception ex) { ISLogger.Write("LocalDragDropController: Failed to get access token for dragdrop operation: " + ex.Message); return; } for (int i = 0; i < cbFiles.AllFiles.Count; i++) { cbFiles.AllFiles[i].RemoteAccessToken = token; cbFiles.AllFiles[i].ReadComplete += VirtualFile_ReadComplete; cbFiles.AllFiles[i].ReadDelegate = VirtualFile_RequestDataAsync; cbFiles.AllFiles[i].FileOperationId = args.OperationId; } } CurrentOperation = new DragDropOperation(args.OperationId, cbData); ddManager.DoDragDrop(cbData, args.OperationId); }
public override void SetClipboardData(ClipboardDataBase data) { InputshareDataObject obj = null; try { obj = ClipboardTranslatorWindows.ConvertToWindows(data); } catch (Exception ex) { ISLogger.Write("Failed to convert clipboard data: " + ex.Message); } if (obj != null) { cbHookWindow.SetClipboardData(obj); } }
internal void Local_DataDropped(object sender, ClipboardDataBase cbData) { if (!Server.IsConnected) { return; } if (CurrentOperation != null && !previousOperations.ContainsKey(CurrentOperation.OperationId)) { previousOperations.Add(CurrentOperation.OperationId, CurrentOperation); } if (Server.IsConnected) { Guid opId = Guid.NewGuid(); CurrentOperation = new DragDropOperation(opId, cbData); ISLogger.Write("LocalDragDropController: Started dragdrop operation " + opId); Server.SendDragDropData(cbData.ToBytes(), opId); } }
public override void SetClipboardData(ClipboardDataBase data) { InputshareDataObject obj = new InputshareDataObject(data, false); if (data.DataType == ClipboardDataType.File) { //If two applications paste data, we can't know which of the two we are interacting with. //In other words, we don't know if its program A or program B calling GetData() on the InputshareDataObject //this means that files will just be corrupted if two programs try to paste the data //To fix this, as soon as the data is pasted, we put another InputshareDataObject onto the clipboard. //Each dataobject gets their own access token from the host to allow them to have seperate filestreams //and allow any number of programs to paste at the same time currentClipboardFiles = data as ClipboardVirtualFileData; obj.FilesPasted += Obj_ObjectPasted; } cbHookWindow.SetClipboardData(obj); }
private void DoDragDrop(ClipboardDataBase data) { InputshareDataObject nativeObject = null; try { nativeObject = ClipboardTranslatorWindows.ConvertToWindows(data); reportedSuccess = false; nativeObject.SetData("InputshareData", new bool()); dropQueue.Enqueue(nativeObject); nativeObject.DropComplete += NativeObject_DropComplete; nativeObject.DropSuccess += NativeObject_DropSuccess; } catch (Exception ex) { ISLogger.Write("Could not start drag drop operation: " + ex.Message); return; } this.Show(); this.BringToFront(); this.TopMost = true; GetCurrentCursorMonitorSize(out Size mSize, out Point mPos); this.SetDesktopLocation((int)mPos.X, (int)mPos.Y); this.Size = mSize; outMan.Send(new InputshareLib.Input.ISInputData(InputshareLib.Input.ISInputCode.IS_MOUSELDOWN, 0, 0)); outMan.Send(new InputshareLib.Input.ISInputData(InputshareLib.Input.ISInputCode.IS_MOUSERUP, 0, 0)); Task.Run(() => { Thread.Sleep(300); this.Invoke(new Action(() => { if (!registeredDrop) { DoDragDrop(data); } })); }); }
private void BeginTextOrImageOperation(ClipboardDataBase cbData, Guid operationId) { //If the previous dragdrop operation is still transfering files, store it so that the files can keep being transfered if (CurrentOperation != null && CurrentOperation.State == DragDropState.TransferingFiles) { previousOperationIds.Add(CurrentOperation.OperationId, CurrentOperation); } //Create a new operation with the text/image data, we don't care about the ID or host //as text and image data is not streamed the same way as file data. Text/Image data are sent as a single block CurrentOperation = new DragDropOperation(cbData, null, operationId); if (currentInputClient.IsLocalhost) { ddManager.DoDragDrop(cbData, operationId); } else { ISLogger.Write("SDragDropController: Sending dragdrop type {0} to {1}", cbData.DataType, currentInputClient.ClientName); currentInputClient.SendDragDropData(cbData.ToBytes(), CurrentOperation.OperationId); } }
private void HookWnd_ClipboardCallback(System.Windows.Forms.IDataObject data) { try { //Check to make sure that we didn't set the clipboard data if (data.GetDataPresent("InputshareData")) { return; } ClipboardDataBase cb = ClipboardTranslatorWindows.ConvertToGeneric(data); if (cb is ClipboardTextData cbText) { ISLogger.Write("Copied " + cbText.Text); } ISLogger.Write("WindowsClipboardManager: Copied type {0}", cb.DataType); OnClipboardDataChanged(cb); }catch (ClipboardTranslatorWindows.ClipboardTranslationException ex) { ISLogger.Write("Failed to read clipboard data: " + ex.Message); } }
private void BeginReceivedOperation(NetworkSocket.DragDropDataReceivedArgs args) { if (!DragDropEnabled) { server.NotifyDragDropSuccess(false); return; } //Check if the received operation has previously been received if (CurrentOperation?.OperationGuid == args.OperationId) { ddManager.DoDragDrop(CurrentOperation.Data); return; } ClipboardDataBase cbData = ClipboardDataBase.FromBytes(args.RawData); cbData.OperationId = args.OperationId; //We need to setup the virtual files if this is a file drop if (cbData is ClipboardVirtualFileData cbFiles) { cbFiles.RequestPartMethod = server.RequestReadStreamAsync; cbFiles.RequestTokenMethod = server.RequestFileTokenAsync; ISLogger.Write("Copied files"); foreach (var file in cbFiles.AllFiles) { ISLogger.Write(file.FullPath); } } CurrentOperation = new ClientDataOperation(cbData, args.OperationId); ddManager.DoDragDrop(cbData); }
private static void ClipMan_ClipboardContentChanged(object sender, ClipboardDataBase data) { iClient.SendClipboardData(data); }
private static void DdMan_DataDropped(object sender, ClipboardDataBase data) { iClient.SendDroppedData(data); }
public void Client_DataDropped(object sender, NetworkSocket.DragDropDataReceivedArgs args) { ISServerSocket client = sender as ISServerSocket; BeginOperation(client, ClipboardDataBase.FromBytes(args.RawData), args.OperationId); }