示例#1
0
        /// <summary>
        ///     Called when the Plugin is being loaded which happens on startup of KeePass
        /// </summary>
        /// <returns>True if the plugin loaded successfully, false if not</returns>
        public override bool Initialize(IPluginHost pluginHost)
        {
            if (_host != null) Terminate();
            if (pluginHost == null) return false;
            if (NativeLib.IsUnix()) return false;

            _host = pluginHost;

            // Some binding redirection fixes for Google Drive API
            FixGoogleApiDependencyLoading();

            // Load the configuration
            _configService = new ConfigurationService(pluginHost);
            _configService.Load();

            // Initialize storage providers
            _storageService = new StorageService(_configService);
            _storageService.Register();

            // Initialize UIService
            _uiService = new UIService(_configService, _storageService);


            // Add the menu option for configuration under Tools
            var menu = _host.MainWindow.ToolsMenu.DropDownItems;
            _tsShowSettings = new ToolStripMenuItem("KeeAnywhere Settings...", PluginResources.KeeAnywhere_16x16);
            _tsShowSettings.Click += OnShowSetting;
            menu.Add(_tsShowSettings);

            // Add "Open from Cloud Drive..." to File\Open menu.
            var fileMenu = _host.MainWindow.MainMenu.Items["m_menuFile"] as ToolStripMenuItem;
            if (fileMenu != null)
            {
                var openMenu = fileMenu.DropDownItems["m_menuFileOpen"] as ToolStripMenuItem;
                if (openMenu != null)
                {
                    _tsOpenFromCloudDrive = new ToolStripMenuItem("Open from Cloud Drive...",
                        PluginResources.KeeAnywhere_16x16);
                    _tsOpenFromCloudDrive.Click += OnOpenFromCloudDrive;
                    _tsOpenFromCloudDrive.ShortcutKeys = Keys.Control | Keys.Alt | Keys.O;
                    openMenu.DropDownItems.Add(_tsOpenFromCloudDrive);
                }

                var saveMenu = fileMenu.DropDownItems["m_menuFileSaveAs"] as ToolStripMenuItem;
                if (saveMenu != null)
                {
                    var index = saveMenu.DropDownItems.IndexOfKey("m_menuFileSaveAsSep0");

                    _tsSaveToCloudDrive = new ToolStripMenuItem("Save to Cloud Drive...",
                        PluginResources.KeeAnywhere_16x16);
                    _tsSaveToCloudDrive.Click += OnSaveToCloudDrive;
                    saveMenu.DropDownItems.Insert(index, _tsSaveToCloudDrive);
                }
            }

            // Indicate that the plugin started successfully
            return true;
        }
        public void InitEx(ConfigurationService configService, StorageService storageService, Mode mode)
        {
            if (configService == null) throw new ArgumentNullException("configService");
            if (storageService == null) throw new ArgumentNullException("storageService");
            if (mode == Mode.Unknown) throw new ArgumentException("mode");

            m_configService = configService;
            m_storageService = storageService;
            m_mode = mode;
        }
示例#3
0
 public UIService(ConfigurationService configService, StorageService storageService)
 {
     _configService = configService;
     _storageService = storageService;
 }
 public KeeAnywhereWebRequestCreator(StorageService storageService)
 {
     if (storageService == null) throw new ArgumentNullException("storageService");
     _storageService = storageService;
 }