Exemplo n.º 1
0
        public void InitEx(ConfigurationService configService, UIService uiService)
        {
            if (configService == null) throw new ArgumentNullException("configService");
            if (uiService == null) throw new ArgumentNullException("uiService");

            m_configService = configService;
            m_uiService = uiService;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 public UIService(ConfigurationService configService, StorageService storageService)
 {
     _configService = configService;
     _storageService = storageService;
 }
Exemplo n.º 5
0
 public StorageService(ConfigurationService configService)
 {
     if (configService == null) throw new ArgumentNullException("configService");
     _configService = configService;
 }