Example #1
0
 private void CheckLicensing()
 {
     foreach (PluginEntry pe in m_plugins)
     {
         try
         {
             // iterate through all loaded plugins
             // get the vendor id
             int        vid = pe.m_plugin.GetInt("VendorID");
             LicenseKey lk  = KeyRing.Instance().Find(vid);
             if (lk != null)
             {
                 pe.m_licensed = true;
             }
             int options = pe.m_plugin.GetInt("Options");
             if (options != -1)
             {
                 if ((options & PluginOptions.OPTION_NOLICENSE) != 0)
                 {
                     pe.m_licensed = true;
                 }
             }
         }
         catch (Exception ex)
         {
             DebugLogger.Instance().LogError(ex);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Loading 'lite' plugins from zip file .plg files
        /// </summary>
        public void ScanForPluginsLite()
        {
            // load the list of plugin states
            string picn = m_apppath + m_pathsep + "pluginconfig.cfg"; // plugin configuration name

            m_pluginstates.Load(picn);

            // get a list of dll's in this current directory
            // try to register them as a plug-in
            string[] filePaths = Directory.GetFiles(m_apppath, "*.plg");
            foreach (String pluginname in filePaths)
            {
                try
                {
                    // create an instance of the plugin
                    PluginLite pll = new PluginLite();
                    pll.m_filename = pluginname;
                    pll.LoadManifest();
                    IPlugin plug = (IPlugin)pll;
                    string  args = Path.GetFileNameWithoutExtension(pluginname);

                    // create an entry for the plugin
                    PluginEntry pe = new PluginEntry(plug, args);
                    //add the entry to the list of plugins
                    m_plugins.Add(pe);
                    //mark the plugin as enabled by default
                    pe.m_enabled = true;
                    if (m_pluginstates.InList(args))
                    {
                        // this plugin is listed in the disabled list.
                        DebugLogger.Instance().LogInfo("Plugin " + args + " marked disabled");
                        pe.m_enabled = false;
                    }
                    //get the vendor id of the newly loaded plugin
                    int vid = plug.GetInt("VendorID");
                    //look for the license key for this plugin
                    LicenseKey lk = KeyRing.Instance().Find(vid);
                    // if we found it, mark it as licensed
                    if (lk != null)
                    {
                        //initialize the plugin by setting the host.
                        if (pe.m_enabled)
                        {
                            plug.Host = this; // this will initialize the plugin - the plugin's init function will be called
                            DebugLogger.Instance().LogInfo("Loaded licensed plugin " + args);
                        }
                    }
                    DebugLogger.Instance().LogInfo("Loaded plugin " + args);
                }
                catch (Exception ex)
                {
                    DebugLogger.Instance().LogError(ex.Message);
                }
            }
        }
 private string FindLicenseKey(int vendorID)
 {
     foreach (LicenseKey lk in KeyRing.Instance().m_keys)
     {
         if (vendorID == lk.VendorID)
         {
             return(lk.m_key);
         }
     }
     return("no key");
 }
 public void ScanForPlugins()
 {
     // get a list of dll's in this current directory
     // try to register them as a plug-in
     //string[] filePaths = Directory.GetFiles(m_apppath + m_pathsep + "Plugins", "*.dll");
     string[] filePaths = Directory.GetFiles(m_apppath, "*.dll");
     foreach (String pluginname in filePaths)
     {
         string args = Path.GetFileNameWithoutExtension(pluginname);
         if (args.ToLower().StartsWith("pl"))
         {
             // located a dll that is a potential plugin
             Type ObjType = null;
             try
             {
                 // load it
                 Assembly ass = null;
                 //string args = Path.GetFileNameWithoutExtension(pluginname);
                 ass = Assembly.Load(args);
                 if (ass != null)
                 {
                     ObjType = ass.GetType(args + ".PlugIn"); // look for the plugin interface
                     // OK Lets create the object as we have the Report Type
                     if (ObjType != null)
                     {
                         // create an instance of the plugin
                         IPlugin plug = (IPlugin)Activator.CreateInstance(ObjType);
                         // create an entry for the plugin
                         PluginEntry pe = new PluginEntry(plug);
                         //add the entry to the list of plugins
                         m_plugins.Add(pe);
                         //get the vendor id of the newly loaded plugin
                         int vid = plug.GetInt("VendorID");
                         //look for the license key for this plugin
                         LicenseKey lk = KeyRing.Instance().Find(vid);
                         // if we found it, mark it as licensed
                         if (lk != null)
                         {
                             pe.m_licensed = true;
                             //initialize the plugin by setting the host.
                             plug.Host = this; // this will initialize the plugin - the plugin's init function will be called
                             DebugLogger.Instance().LogInfo("Loaded licensed plugin " + args);
                         }
                         DebugLogger.Instance().LogInfo("Loaded plugin " + args);
                     }
                 }
             }
             catch (Exception ex)
             {
                 DebugLogger.Instance().LogError(ex.Message);
             }
         }
     }
 }
Example #5
0
 private void LoadLicenseKeys()
 {
     try
     {
         string licensefile = m_apppath + m_pathsep + "licenses.key";
         if (File.Exists(licensefile))
         {
             KeyRing.Instance().Load(licensefile);
         }
         else
         {
             DebugLogger.Instance().LogInfo("No Key Ring found");
         }
     }
     catch (Exception)
     {
         DebugLogger.Instance().LogInfo("No License File");
     }
 }
Example #6
0
        private void cmdLicense_Click(object sender, EventArgs e)
        {
            // get the text string from
            string license = txtLicense.Text;

            license = license.Trim();
            if (license.Length != 32)
            {
                MessageBox.Show("Invalid license, please re-check");
                return;
            }
            LicenseKey lk = new LicenseKey();

            try
            {
                lk.Init(license);
                if (lk.valid)
                {
                    txtLicense.Text = "";
                    //should really check, vendor id against plugin vendor id
                    KeyRing.Instance().m_keys.Add(lk);
                    string licensefile = UVDLPApp.Instance().m_apppath + UVDLPApp.m_pathsep + "licenses.key";
                    if (KeyRing.Instance().Save(licensefile))
                    {
                        MessageBox.Show("License Added to Keyring, Restart to take effect");
                    }
                    else
                    {
                        MessageBox.Show("Error Saving Keyring");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid license, please re-check");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error validating license, please re-check");
            }
        }
        private void cmdLicense_Click(object sender, EventArgs e)
        {
            // get the text string from
            string license = txtLicense.Text;

            license = license.Trim();
            if (license.Length != 32)
            {
                MessageBox.Show(((DesignMode) ? "InvalidLicensePleaseReCheck" :UVDLPApp.Instance().resman.GetString("InvalidLicensePleaseReCheck", UVDLPApp.Instance().cul)));
                return;
            }
            LicenseKey lk = new LicenseKey();

            try
            {
                lk.Init(license);
                if (lk.valid)
                {
                    txtLicense.Text = "";
                    //should really check, vendor id against plugin vendor id
                    KeyRing.Instance().m_keys.Add(lk);
                    string licensefile = UVDLPApp.Instance().m_apppath + UVDLPApp.m_pathsep + "licenses.key";
                    if (KeyRing.Instance().Save(licensefile))
                    {
                        MessageBox.Show(((DesignMode) ? "LicenseAddedToKeyringRestartToTakeEffect" :UVDLPApp.Instance().resman.GetString("LicenseAddedToKeyringRestartToTakeEffect", UVDLPApp.Instance().cul)));
                    }
                    else
                    {
                        MessageBox.Show(((DesignMode) ? "ErrorSavingKeyring" :UVDLPApp.Instance().resman.GetString("ErrorSavingKeyring", UVDLPApp.Instance().cul)));
                    }
                }
                else
                {
                    MessageBox.Show(((DesignMode) ? "InvalidLicensePleaseReCheck" :UVDLPApp.Instance().resman.GetString("InvalidLicensePleaseReCheck", UVDLPApp.Instance().cul)));
                }
            }
            catch (Exception)
            {
                MessageBox.Show(((DesignMode) ? "ErrorValidatingLicensePleaseReCheck" :UVDLPApp.Instance().resman.GetString("ErrorValidatingLicensePleaseReCheck", UVDLPApp.Instance().cul)));
            }
        }