Example #1
0
        // =================================================
        // PROTECTED (Methods) Folder Viewers Event Handlers
        // =================================================
        private void OnSaveFile(object obj, UserInfo userInfo, string path)
        {
            Gtk.Application.Invoke(delegate {
                PeerSocket peer = P2PManager.KnownPeers[userInfo] as PeerSocket;

                string saveAs = FileAlreadyInUse(path.Substring(1));
                if (saveAs != null)
                {
                    DownloadManager.Accept(peer, 0, path, saveAs);
                    Cmd.RequestFile(peer, path);
                }
            });
        }
Example #2
0
        // ============================================
        // PRIVATE Methods
        // ============================================
        private void AcceptFileQuestion(PeerSocket peer, XmlRequest xml)
        {
            string name = (string)xml.Attributes["name"];
            string size = (string)xml.Attributes["size"];
            ulong  id   = ulong.Parse((string)xml.Attributes["id"]);

            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 = Base.Dialogs.QuestionDialog("Accept File", questionMsg.ToString());

            if (accept == false)
            {
                return;
            }

            // Save File Dialog
            string savePath = FileAlreadyInUse(name);

            if (savePath == null)
            {
                return;
            }

            // Send Accept File Command
            Debug.Log("Accept File '{0}' From '{1}', Save as '{2}'", userInfo.Name, name, savePath);

            DownloadManager.Accept(peer, id, name, savePath);
            Cmd.RequestFile(peer, id);
        }