Changeset 6018 for branches/newapi

Show
Ignore:
Timestamp:
01/11/08 05:32:54 (11 months ago)
Author:
erijo
Message:

Fixed code to compile with previous commits. Extended Licq::Daemon with methods for sending events.

Location:
branches/newapi/licq
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/newapi/licq/licq/interface/daemon.h

    r5919 r6018  
    2121#define LICQ_DAEMON_H 
    2222 
     23#include "licq/event/event.h" 
    2324#include "licq/interface/plugin.h" 
    2425#include "licq/macros.h" 
     
    3940  static Daemon* getInstance(); 
    4041 
    41   virtual void getPluginInformation( 
    42     std::vector< boost::shared_ptr<const Licq::Plugin::Information> >* info) = 0; 
     42  virtual void sendEvent(Event::Ptr event) = 0; 
     43  virtual void sendEventToDaemon(Event::Ptr event) = 0; 
     44  virtual void sendEventToPlugin(Event::Ptr event, Plugin::Id id) = 0; 
     45 
     46  virtual void getPluginInformation(Plugin::InformationVector* info) = 0; 
    4347 
    4448protected: 
  • branches/newapi/licq/src/daemon.cpp

    r5951 r6018  
    1919 
    2020#include "daemon.h" 
     21#include "event/eventmanager.h" 
     22#include "event/eventqueuename.h" 
    2123#include "globals.h" 
    2224#include "licq/exception/invalidargumentexception.h" 
     
    8385} 
    8486 
    85 LicqDaemon::Daemon::Daemon() 
    86   : myLog(Globals::getDaemonLog()) 
     87LicqDaemon::Daemon::Daemon(Licq::Log& log, 
     88                           PluginManager* pluginManager, 
     89                           EventManager* eventManager) 
     90  : myLog(log), 
     91    myPluginManager(pluginManager), 
     92    myEventManager(eventManager) 
    8793{ 
    8894  // Empty 
     
    167173  if (vm.count("plugin")) 
    168174  { 
    169     PluginManager* pluginManager = Globals::getPluginManager(); 
    170  
    171175    std::vector<std::string> 
    172176        plugins = vm["plugin"].as< std::vector<std::string> >(); 
     
    174178         it != plugins.end(); ++it) 
    175179    { 
    176       Licq::Plugin::Id id = pluginManager->loadPlugin(*it, 0, NULL); 
    177       myLog.debug(tr("Loaded plugin %1% with id %2%") % *it % id); 
     180      Licq::Plugin::Id id = myPluginManager->startPlugin(*it, 0, NULL); 
     181      myLog.debug(tr("Started plugin %1% with id %2%") % *it % id); 
    178182    } 
    179183  } 
     
    188192} 
    189193 
    190 void LicqDaemon::Daemon::getPluginInformation( 
    191   std::vector< boost::shared_ptr<const Licq::Plugin::Information> >* info) 
    192 { 
    193   Globals::getPluginManager()->getPluginInformation(info); 
     194void LicqDaemon::Daemon::sendEvent(Licq::Event::Ptr event) 
     195{ 
     196  myEventManager->sendEvent(event->getName(), event); 
     197} 
     198 
     199void LicqDaemon::Daemon::sendEventToDaemon(Licq::Event::Ptr event) 
     200{ 
     201  myEventManager->sendEvent(EventQueueName::daemon, event); 
     202} 
     203 
     204void LicqDaemon::Daemon::sendEventToPlugin(Licq::Event::Ptr event, 
     205                                           Licq::Plugin::Id id) 
     206{ 
     207  myEventManager->sendEvent(EventQueueName::getPluginPrivate(id), event); 
     208} 
     209 
     210void LicqDaemon::Daemon:: 
     211getPluginInformation(Licq::Plugin::InformationVector* info) 
     212{ 
     213  myPluginManager->getPluginInformation(info); 
    194214} 
    195215 
     
    228248void LicqDaemon::Daemon::setupDefaultPluginPaths(bool reload) 
    229249{ 
    230   PluginCache* cache = Globals::getPluginManager()->getPluginCache(); 
     250  PluginCache* cache = myPluginManager->getPluginCache(); 
    231251  cache->addSearchPath(myBaseDir + "plugins/"); 
    232252 
     
    239259  setupDefaultPluginPaths(false); 
    240260 
    241   PluginCache* cache = Globals::getPluginManager()->getPluginCache(); 
     261  PluginCache* cache = myPluginManager->getPluginCache(); 
    242262  for (std::vector<std::string>::const_iterator it = paths.begin(); 
    243263       it != paths.end(); ++it) 
     
    251271void LicqDaemon::Daemon::printAvailablePlugins(std::ostream& os) const 
    252272{ 
    253   PluginCache* cache = Globals::getPluginManager()->getPluginCache(); 
     273  PluginCache* cache = myPluginManager->getPluginCache(); 
    254274 
    255275  const size_t size = cache->getSize(); 
  • branches/newapi/licq/src/daemon.h

    r5926 r6018  
    2727#include <vector> 
    2828 
     29namespace Licq 
     30{ 
     31class Log; 
     32} 
     33 
    2934namespace LicqDaemon 
    3035{ 
    3136 
     37class EventManager; 
     38class PluginManager; 
    3239class StreamLogSink; 
    3340 
     
    3744  static Daemon* getInstance(); 
    3845 
    39   Daemon(); 
     46  Daemon(Licq::Log& log, PluginManager* pluginManager, EventManager* eventManager); 
    4047  ~Daemon(); 
    4148 
     
    4552  const std::string& getBaseDir() const; 
    4653 
    47   void getPluginInformation( 
    48     std::vector< boost::shared_ptr<const Licq::Plugin::Information> >* info); 
     54  // From Licq::Daemon 
     55  void sendEvent(Licq::Event::Ptr event); 
     56  void sendEventToDaemon(Licq::Event::Ptr event); 
     57  void sendEventToPlugin(Licq::Event::Ptr event, Licq::Plugin::Id id); 
     58 
     59  void getPluginInformation(Licq::Plugin::InformationVector* info); 
    4960 
    5061private: 
    51   class Licq::Log& myLog; 
     62  Licq::Log& myLog; 
     63  PluginManager* myPluginManager; 
     64  EventManager* myEventManager; 
    5265 
    5366  std::string myBaseDir; 
  • branches/newapi/licq/src/globals.cpp

    r5952 r6018  
    6969  myDaemonLog = new Log("licq", myLogDistributor); 
    7070 
     71  // EventManager 
     72  myEventManager = new EventManagerImpl(); 
     73 
    7174  // Create and configure PluginManager 
    7275  myPluginLoader = new PluginLoaderImpl(); 
    7376  myPluginCache = new PluginCacheImpl(*myPluginLoader); 
    74   myPluginManager = new PluginManagerImpl(*myPluginCache, *myLogDistributor); 
    75  
    76   // EventManager 
    77   myEventManager = new EventManagerImpl(); 
     77  myPluginManager =  
     78      new PluginManagerImpl(*myEventManager, *myPluginCache, *myLogDistributor); 
    7879 
    7980  // Create Daemon 
    80   myDaemon = new Daemon(); 
     81  myDaemon = new Daemon(*myDaemonLog, myPluginManager, myEventManager); 
    8182} 
    8283