private void OnNewChannels(ChannelDetails[] channels) { foreach (ChannelDetails c in channels) { ObjectPath object_path = c.Channel; string channel_type = c.Properties[Constants.CHANNEL_IFACE + ".ChannelType"] as string; HandleType handle_type = (HandleType)c.Properties[Constants.CHANNEL_IFACE + ".TargetHandleType"]; uint handle = (uint)c.Properties[Constants.CHANNEL_IFACE + ".TargetHandle"]; Console.WriteLine(MSG_PREFIX + "OnNewChannels: op {0}, channel_type {1}, handle_type {2}, handle {3}", object_path, channel_type, handle_type, handle); if (channel_type.Equals(Constants.CHANNEL_TYPE_FILETRANSFER)) { ift = bus.GetObject <IFileTransfer> (Constants.CONNMANAGER_GABBLE_IFACE, object_path); ift.FileTransferStateChanged += OnFileTransferStateChanged; ift.Closed += OnFileTransferClosed; ift.InitialOffsetDefined += OnInitialOffsetDefined; ift.TransferredBytesChanged += OnTransferredBytesChanged; // get tube initiator handle // should be = to self_handle on client // should be != to self_handle on server Properties p = bus.GetObject <Properties> (Constants.CONNMANAGER_GABBLE_IFACE, object_path); transfer_initiator = (uint)p.Get(Constants.CHANNEL_IFACE, "InitiatorHandle"); IDictionary <uint, uint[]> supported_sockets = (IDictionary <uint, uint[]>) p.Get(Constants.CHANNEL_TYPE_FILETRANSFER, "AvailableSocketTypes"); file_size = (ulong)p.Get(Constants.CHANNEL_TYPE_FILETRANSFER, "Size"); SocketAddressType socket_type = SocketAddressType.Unix; SocketAccessControl socket_ac = SocketAccessControl.Localhost; bool supported = false; if (supported_sockets.ContainsKey((uint)SocketAddressType.Unix)) { supported = true; } else if (supported_sockets.ContainsKey((uint)SocketAddressType.IPv4)) { socket_type = SocketAddressType.IPv4; supported = true; } if (supported && transfer_initiator == self_handle) { Console.WriteLine(MSG_PREFIX + "Offering File"); object addr = ift.ProvideFile(socket_type, socket_ac, ""); if (socket_type == SocketAddressType.Unix) { Console.WriteLine(MSG_PREFIX + "Boxed object is {0}", addr.ToString()); //IPv4Address socket_addr = (IPv4Address)Convert.ChangeType (addr, typeof (IPv4Address)); socket_addr = Encoding.ASCII.GetString((byte[])addr); Console.WriteLine(MSG_PREFIX + "File from {0} offered", socket_addr); } } else if (supported && transfer_initiator != self_handle) { object addr = ift.AcceptFile(socket_type, socket_ac, "", 0); if (socket_type == SocketAddressType.Unix) { Console.WriteLine(MSG_PREFIX + "Boxed object is {0}", addr.ToString()); //IPv4Address socket_addr = (IPv4Address)Convert.ChangeType (addr, typeof (IPv4Address)); socket_addr = Encoding.ASCII.GetString((byte[])addr); Console.WriteLine(MSG_PREFIX + "File from {0} accepted", socket_addr); } } else { Console.WriteLine(MSG_PREFIX + "Could not find supported socket type."); ift.Close(); } //ift.Close (); } } }