コード例 #1
0
        private void DisconnectMyPeer()
        {
            try {
                // Disconnect From NyFolder Web Server
                MyInfo.DisconnectFromWebServer();
            } catch (Exception e) {
                Glue.Dialogs.MessageError("Disconnection From Web Server", e.Message);
            }

            try {
                // Remove All Connected Users
                this.RemoveAllUsers();

                // Remove Custom Command Handler
                if (DelProtocolEvent != null)
                {
                    DelProtocolEvent(p2pManager, cmdManager);
                }

                // Reset Command Manager & Del Commands Handler
                this.DelProtocolEvents();
                this.cmdManager.DelPeerEventsHandler();
            } catch (Exception e) {
                Glue.Dialogs.MessageError("Remove Protocol Events", e.Message);
            }

            try {
                // Reset Download & Upload Manager
                UploadManager.Clear();
                DownloadManager.Clear();
            } catch (Exception e) {
                Glue.Dialogs.MessageError("Download/Upload Manager Stop", e.Message);
            }

            try {
                // P2P Stop Listening
                this.p2pManager.StopListening();
            } catch (Exception e) {
                Glue.Dialogs.MessageError("P2P Disconnection Error", e.Message);
            }
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: BackupTheBerlios/nyfolder-svn
        // ============================================
        //             APPLICATION MAIN
        // ============================================
        public static int Main(string[] args)
        {
            // Starting Application
            Debug.Log("{0} {1} Started...", Info.Name, Info.Version);

            do
            {
                p2pManager = null;
                nyFolder   = null;

                // Initialize Gtk Support
                if (Gtk.Application.InitCheck("NyFolder.exe", ref args) == false)
                {
                    PrintErrorMessage("You Don't Have Gtk Support Here...");
                    return(1);
                }

                // Initialize Components
                InitBase();
                InitNetwork();
                InitApplication();

                try {
                    // Set 'No Restart' Application
                    NyFolderApp.Restart = false;

                    // Run NyFolder Application
                    nyFolder.Run();

                    // Run Gtk Main
                    Gtk.Application.Run();
                } catch (NyFolderExit) {
                    // This is Logout Event :D
                    NyFolderApp.Restart = true;
                } catch (Exception e) {
                    PrintErrorMessage(e);
                    return(1);
                } finally {
                    // Uninitialize Plugins
                    PluginManager.StopPlugins();

                    // Clear Download/Upload Manager
                    UploadManager.Clear();
                    DownloadManager.Clear();

                    // Destroy All P2P Connections
                    if (p2pManager != null)
                    {
                        p2pManager.Kill();
                    }

                    // NyFolder Quit Application
                    if (NyFolderApp.Restart == false && nyFolder != null)
                    {
                        nyFolder.Quit();
                    }
                }
                Thread.Sleep(1000);
            } while (NyFolderApp.Restart == true);

            // Application Correct Termination
            Debug.Log("{0} {1} Ended...", Info.Name, Info.Version);
            return(0);
        }