Example #1
0
 public void InstallPlugin(string path, bool globalTarget,
                           MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB updateCB,
                           MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB doneCB,
                           MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB errorCB)
 {
     InstallPlugin(path, Path.GetFileName(path), globalTarget, updateCB, doneCB, errorCB);
 }
Example #2
0
        public void InstallPlugin(string sourcePath, string targetName,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB updateCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB doneCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB errorCB)
        {
            string target = Path.Combine(ApplicationPaths.AppPluginPath, targetName);

            if (sourcePath.ToLower().StartsWith("http"))
            {
                // Initialise Async Web Request
                int BUFFER_SIZE = 1024;
                Uri fileURI     = new Uri(sourcePath);

                WebRequest request = WebRequest.Create(fileURI);
                Network.WebDownload.State requestState = new Network.WebDownload.State(BUFFER_SIZE, target);
                requestState.request = request;
                requestState.fileURI = fileURI;
                requestState.progCB  = updateCB;
                requestState.doneCB  = doneCB;
                requestState.errorCB = errorCB;

                IAsyncResult result = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(ResponseCallback), requestState);
            }
            else
            {
                File.Copy(sourcePath, target, true);
                InitialisePlugin(target);
            }

            // Moved code to InitialisePlugin()
            //Function needs to be called at end of Async dl process as well
        }
Example #3
0
        public void InstallPlugin(IPlugin plugin,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB updateCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB doneCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB errorCB)
        {
            if (BackupPlugin(plugin))
            {
                Logger.ReportInfo("Plugin " + plugin.Name + " v" + plugin.Version + " backed up.");
            }

            if (plugin is RemotePlugin)
            {
                try {
                    Kernel.Instance.InstallPlugin((plugin as RemotePlugin).SourceFilename, plugin.Filename, updateCB, doneCB, errorCB);
                }
                catch (Exception ex) {
                    MessageBox.Show("Cannot Install Plugin.  If MediaBrowser is running, please close it and try again.\n" + ex.Message, "Install Error");
                    doneCB();
                }
            }
            else
            {
                var local = plugin as Plugin;
                Debug.Assert(plugin != null);
                try {
                    Kernel.Instance.InstallPlugin(local.Filename, null, null, null);
                }
                catch (Exception ex) {
                    MessageBox.Show("Cannot Install Plugin.  If MediaBrowser is running, please close it and try again.\n" + ex.Message, "Install Error");
                    doneCB();
                }
            }
        }
        public void InstallPlugin(IPlugin plugin, System.Windows.Controls.ProgressBar progress, Window window, Delegate done) {
            if (plugin != null) {
                m_window = window;
                m_progress = progress;
                m_done = done;

                m_progress.Visibility = Visibility.Visible;

                MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB updateDelegate = new MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB(PluginInstallUpdate);
                MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB doneDelegate = new MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB(PluginInstallFinish);
                MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB errorDelegate = new MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB(PluginInstallError);
                
                PluginManager.Instance.InstallPlugin(plugin, updateDelegate, doneDelegate, errorDelegate);
            }
        }
        public void InstallPlugin(IPlugin plugin, System.Windows.Controls.ProgressBar progress, Window window, Delegate done)
        {
            if (plugin != null)
            {
                m_window   = window;
                m_progress = progress;
                m_done     = done;

                m_progress.Visibility = Visibility.Visible;

                MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB updateDelegate = new MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB(PluginInstallUpdate);
                MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB doneDelegate   = new MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB(PluginInstallFinish);
                MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB  errorDelegate  = new MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB(PluginInstallError);

                PluginManager.Instance.InstallPlugin(plugin, updateDelegate, doneDelegate, errorDelegate);
            }
        }
Example #6
0
        public void InstallPlugin(string sourcePath, string targetName, bool globalTarget,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB updateCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB doneCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB errorCB)
        {
            string target;

            if (globalTarget)
            {
                //install to ehome for now - can change this to GAC if figure out how...
                target = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), Path.Combine("ehome", targetName));
                //and put our pointer file in "plugins"
                File.Create(Path.Combine(ApplicationPaths.AppPluginPath, Path.ChangeExtension(Path.GetFileName(targetName), ".pgn")));
            }
            else
            {
                target = Path.Combine(ApplicationPaths.AppPluginPath, targetName);
            }

            if (sourcePath.ToLower().StartsWith("http"))
            {
                // Initialise Async Web Request
                int BUFFER_SIZE = 1024;
                Uri fileURI     = new Uri(sourcePath);

                WebRequest request = WebRequest.Create(fileURI);
                Network.WebDownload.State requestState = new Network.WebDownload.State(BUFFER_SIZE, target);
                requestState.request = request;
                requestState.fileURI = fileURI;
                requestState.progCB  = updateCB;
                requestState.doneCB  = doneCB;
                requestState.errorCB = errorCB;

                IAsyncResult result = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(ResponseCallback), requestState);
            }
            else
            {
                File.Copy(sourcePath, target, true);
                InitialisePlugin(target);
            }

            // Moved code to InitialisePlugin()
            //Function needs to be called at end of Async dl process as well
        }
Example #7
0
        public void InstallPlugin(IPlugin plugin,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallUpdateCB updateCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallFinishCB doneCB,
                                  MediaBrowser.Library.Network.WebDownload.PluginInstallErrorCB errorCB)
        {
            //taking this check out for now - it's just too cumbersome to have to re-compile all plug-ins to change this -ebr
            //if (plugin.TestedMBVersion < Kernel.Instance.Version) {
            //    var dlgResult = MessageBox.Show("Warning - " + plugin.Name + " has not been tested with your version of MediaBrowser. \n\nInstall anyway?", "Version not Tested", MessageBoxButton.YesNo);
            //    if (dlgResult == MessageBoxResult.No) {
            //        doneCB();
            //        return;
            //    }
            //}

            if (BackupPlugin(plugin))
            {
                Logger.ReportInfo("Plugin " + plugin.Name + " v" + plugin.Version + " backed up.");
            }

            if (plugin is RemotePlugin)
            {
                try {
                    Kernel.Instance.InstallPlugin((plugin as RemotePlugin).BaseUrl + "\\" + (plugin as RemotePlugin).SourceFilename, plugin.Filename, updateCB, doneCB, errorCB);
                }
                catch (Exception ex) {
                    MessageBox.Show("Cannot Install Plugin.  If MediaBrowser is running, please close it and try again.\n" + ex.Message, "Install Error");
                    doneCB();
                }
            }
            else
            {
                var local = plugin as Plugin;
                Debug.Assert(plugin != null);
                try {
                    Kernel.Instance.InstallPlugin(local.Filename, null, null, null);
                }
                catch (Exception ex) {
                    MessageBox.Show("Cannot Install Plugin.  If MediaBrowser is running, please close it and try again.\n" + ex.Message, "Install Error");
                    doneCB();
                }
            }
        }