private void OnSaveFile(object sender, UserInfo userInfo, string path) { Gtk.Application.Invoke(delegate { PeerSocket peer = P2PManager.KnownPeers[userInfo] as PeerSocket; // Save File Dialog string savePath = Glue.Dialogs.SaveFile(Paths.UserSharedDirectory(MyInfo.Name), path.Substring(1)); if (savePath == null) { return; } try { DownloadManager.AddToAcceptList(peer, path, savePath); CmdManager.AcceptFile(peer, path); } catch (Exception e) { Glue.Dialogs.MessageError("Save File", e.Message); } }); }
// ============================================ // PRIVATE Methods // ============================================ // ============================================ // PRIVATE Methods // ============================================ private void AcceptFileQuestion(PeerSocket peer, XmlRequest xml) { string name = (string)xml.Attributes["name"]; string path = (string)xml.Attributes["path"]; string size = (string)xml.Attributes["size"]; if (size == null) { size = "0"; } UserInfo userInfo = peer.Info as UserInfo; StringBuilder questionMsg = new StringBuilder(); questionMsg.AppendFormat("Accept File '<b>{0}</b>' ", name); questionMsg.AppendFormat("(Size <b>{0}</b>)\n", FileUtils.GetSizeString(long.Parse(size))); questionMsg.AppendFormat("From User '<b>{0}</b>' ?", userInfo.Name); // Accept Yes/No Dialog bool accept = Glue.Dialogs.QuestionDialog("Accept File", questionMsg.ToString()); if (accept == false) { return; } // Save File Dialog string savePath = Glue.Dialogs.SaveFile(Paths.UserSharedDirectory(MyInfo.Name), name); if (savePath == null) { return; } // Send Accept File Command Debug.Log("Accept File '{0}' From '{1}', Save as '{2}'", userInfo.Name, path, savePath); DownloadManager.AddToAcceptList(peer, path, savePath); CmdManager.AcceptFile(peer, xml); }