r7955 - in /trunk/licq: include/licq/plugin.h include/licq/protocolbase.h src/plugins/generalplugin.cpp src/plugins/generalplugin.h src/plugins/plugin.cpp src/plugins/plugin.h src/plugins/tests/plugintest.cpp src/plugins/tests/protocolplugintest.cpp

[email protected]
Newsgroups gmane.network.licq.cvs
Message-ID <20101031091814.47691224B82@thejon>
Author: erijo
Date: Sun Oct 31 18:18:13 2010
New Revision: 7955

Log:
Added LProto_ConfigFile so that protocol plugins can signal that they have a config file

Modified:
    trunk/licq/include/licq/plugin.h
    trunk/licq/include/licq/protocolbase.h
    trunk/licq/src/plugins/generalplugin.cpp
    trunk/licq/src/plugins/generalplugin.h
    trunk/licq/src/plugins/plugin.cpp
    trunk/licq/src/plugins/plugin.h
    trunk/licq/src/plugins/tests/plugintest.cpp
    trunk/licq/src/plugins/tests/protocolplugintest.cpp

Modified: trunk/licq/include/licq/plugin.h
==============================================================================
--- trunk/licq/include/licq/plugin.h (original)
+++ trunk/licq/include/licq/plugin.h Sun Oct 31 18:18:13 2010
@@ -48,6 +48,10 @@
   /// Get the plugin's version.
   virtual const char* getVersion() const = 0;
 
+  /// Get the name of the plugin's config file. Can be NULL if the plugin
+  /// doesn't have a config file.
+  virtual const char* getConfigFile() const = 0;
+
   /// Get the name of the library from where the plugin was loaded.
   virtual const std::string& getLibraryName() const = 0;
 
@@ -80,10 +84,6 @@
 
   /// Get the plugin's usage instructions.
   virtual const char* getUsage() const = 0;
-
-  /// Get the name of the plugin's config file. Can be NULL if the plugin
-  /// doesn't have a config file.
-  virtual const char* getConfigFile() const = 0;
 
   /// Get the plugin's build date.
   virtual const char* getBuildDate() const = 0;

Modified: trunk/licq/include/licq/protocolbase.h
==============================================================================
--- trunk/licq/include/licq/protocolbase.h (original)
+++ trunk/licq/include/licq/protocolbase.h Sun Oct 31 18:18:13 2010
@@ -30,6 +30,8 @@
 
 const char* LProto_PPID();
 
+const char* LProto_ConfigFile();
+
 bool LProto_Init();
 
 unsigned long LProto_SendFuncs();

Modified: trunk/licq/src/plugins/generalplugin.cpp
==============================================================================
--- trunk/licq/src/plugins/generalplugin.cpp (original)
+++ trunk/licq/src/plugins/generalplugin.cpp Sun Oct 31 18:18:13 2010
@@ -42,16 +42,6 @@
   loadSymbol("LP_Usage", myUsage);
   loadSymbol("LP_BuildDate", myBuildDate);
   loadSymbol("LP_BuildTime", myBuildTime);
-
-  try
-  {
-    // LP_ConfigFile is not required
-    loadSymbol("LP_ConfigFile", myConfigFile);
-  }
-  catch (DynamicLibrary::Exception&)
-  {
-    myConfigFile = NULL;
-  }
 }
 
 GeneralPlugin::~GeneralPlugin()
@@ -144,14 +134,6 @@
   return (*myUsage)();
 }
 
-const char* GeneralPlugin::getConfigFile() const
-{
-  if (myConfigFile)
-    return (*myConfigFile)();
-  else
-    return NULL;
-}
-
 const char* GeneralPlugin::getBuildDate() const
 {
   return (*myBuildDate)();

Modified: trunk/licq/src/plugins/generalplugin.h
==============================================================================
--- trunk/licq/src/plugins/generalplugin.h (original)
+++ trunk/licq/src/plugins/generalplugin.h Sun Oct 31 18:18:13 2010
@@ -55,7 +55,6 @@
   const char* getStatus() const;
   const char* getDescription() const;
   const char* getUsage() const;
-  const char* getConfigFile() const;
   const char* getBuildDate() const;
   const char* getBuildTime() const;
   void enable();
@@ -80,7 +79,6 @@
   const char* (*myStatus)();
   const char* (*myDescription)();
   const char* (*myUsage)();
-  const char* (*myConfigFile)();
   const char* (*myBuildDate)();
   const char* (*myBuildTime)();
 };

Modified: trunk/licq/src/plugins/plugin.cpp
==============================================================================
--- trunk/licq/src/plugins/plugin.cpp (original)
+++ trunk/licq/src/plugins/plugin.cpp Sun Oct 31 18:18:13 2010
@@ -41,6 +41,16 @@
   loadSymbol(prefix + "_Main", myMain);
   loadSymbol(prefix + "_Name", myName);
   loadSymbol(prefix + "_Version", myVersion);
+
+  try
+  {
+    // ConfigFile is not required
+    loadSymbol(prefix + "_ConfigFile", myConfigFile);
+  }
+  catch (DynamicLibrary::Exception&)
+  {
+    myConfigFile = NULL;
+  }
 }
 
 Plugin::~Plugin()
@@ -77,6 +87,11 @@
   myThread->cancel();
 }
 
+unsigned short Plugin::getId() const
+{
+  return myId;
+}
+
 const char* Plugin::getName() const
 {
   return (*myName)();
@@ -87,9 +102,12 @@
   return (*myVersion)();
 }
 
-unsigned short Plugin::getId() const
+const char* Plugin::getConfigFile() const
 {
-  return myId;
+  if (myConfigFile)
+    return (*myConfigFile)();
+  else
+    return NULL;
 }
 
 const std::string& Plugin::getLibraryName() const

Modified: trunk/licq/src/plugins/plugin.h
==============================================================================
--- trunk/licq/src/plugins/plugin.h (original)
+++ trunk/licq/src/plugins/plugin.h Sun Oct 31 18:18:13 2010
@@ -91,6 +91,7 @@
   unsigned short getId() const;
   const char* getName() const;
   const char* getVersion() const;
+  const char* getConfigFile() const;
   const std::string& getLibraryName() const;
   void shutdown();
 
@@ -119,6 +120,7 @@
   int (*myMain)();
   const char* (*myName)();
   const char* (*myVersion)();
+  const char* (*myConfigFile)();
 
   // Unique plugin id
   unsigned short myId;

Modified: trunk/licq/src/plugins/tests/plugintest.cpp
==============================================================================
--- trunk/licq/src/plugins/tests/plugintest.cpp (original)
+++ trunk/licq/src/plugins/tests/plugintest.cpp Sun Oct 31 18:18:13 2010
@@ -31,6 +31,7 @@
 
 STR_FUNC(Name);
 STR_FUNC(Version);
+STR_FUNC(ConfigFile);
 
 int Test_Main()
 {
@@ -98,6 +99,7 @@
 {
   EXPECT_STREQ("Name", plugin.getName());
   EXPECT_STREQ("Version", plugin.getVersion());
+  EXPECT_STREQ("ConfigFile", plugin.getConfigFile());
   EXPECT_EQ("", plugin.getLibraryName());
 }
 

Modified: trunk/licq/src/plugins/tests/protocolplugintest.cpp
==============================================================================
--- trunk/licq/src/plugins/tests/protocolplugintest.cpp (original)
+++ trunk/licq/src/plugins/tests/protocolplugintest.cpp Sun Oct 31 18:18:13 2010
@@ -29,6 +29,7 @@
 
 STR_FUNC(Name);
 STR_FUNC(Version);
+STR_FUNC(ConfigFile);
 STR_FUNC(PPID);
 
 bool LProto_Init()
@@ -87,6 +88,7 @@
 {
   EXPECT_STREQ("Name", plugin.getName());
   EXPECT_STREQ("Version", plugin.getVersion());
+  EXPECT_STREQ("ConfigFile", plugin.getConfigFile());
   unsigned long ppid = 'P' << 24 | 'P' << 16 | 'I' << 8 | 'D';
   EXPECT_EQ(ppid, plugin.getProtocolId());
   EXPECT_TRUE(plugin.init());
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.