Changeset 6015 for branches/newapi
- Timestamp:
- 01/11/08 05:28:58 (11 months ago)
- Location:
- branches/newapi/licq/src/plugin
- Files:
-
- 3 modified
-
plugininstance.h (modified) (2 diffs)
-
plugininstanceimpl.cpp (modified) (5 diffs)
-
plugininstanceimpl.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/newapi/licq/src/plugin/plugininstance.h
r6012 r6015 21 21 #define LICQDAEMON_PLUGININSTANCE_H 22 22 23 #include "licq/event/event.h" 23 24 #include "licq/interface/plugin.h" 24 25 … … 40 41 { 41 42 public: 43 enum State 44 { 45 StateNotLoaded, 46 StateLoaded, 47 StateStarted, 48 StateStopping, 49 StateStopped 50 }; 51 42 52 virtual Licq::Plugin::Id load(int argc, char** argv) = 0; 53 54 virtual void start() = 0; 55 virtual void initiateStop(Licq::Event::Ptr stopEvent) = 0; 56 virtual void completeStop(bool force) = 0; 57 58 virtual State getState() const = 0; 43 59 44 60 virtual Licq::Plugin::Id getPluginId() const = 0; -
branches/newapi/licq/src/plugin/plugininstanceimpl.cpp
r6013 r6015 28 28 29 29 #include <cassert> 30 #include <csignal> 30 31 #include <cstring> 31 32 … … 45 46 : myInformation(info), 46 47 myLibrary(library), 48 myState(StateNotLoaded), 47 49 myPlugin(NULL), 48 50 myThread(NULL), … … 54 56 LicqDaemon::PluginInstanceImpl::~PluginInstanceImpl() 55 57 { 56 assert(myThread->getState() != Licq::Thread::StateRunning); 58 assert(myState != StateStarted && myState != StateStopping); 59 57 60 delete myThread; 58 61 59 myLibrary->destroyPlugin(myPlugin); 60 myPlugin = NULL; 62 if (myPlugin != NULL) 63 { 64 myLibrary->destroyPlugin(myPlugin); 65 myPlugin = NULL; 66 } 61 67 62 68 // Cleanup mySetup … … 71 77 Licq::Plugin::Id LicqDaemon::PluginInstanceImpl::load(int argc, char** argv) 72 78 { 73 assert(my Plugin == NULL);79 assert(myState == StateNotLoaded); 74 80 75 81 // Set up argc and argv for the plugin … … 98 104 } 99 105 100 // Create the thread106 myState = StateLoaded; 101 107 myThread = new Licq::Thread(myPlugin); 102 108 103 109 return mySetup.id; 104 110 } 111 112 void LicqDaemon::PluginInstanceImpl::start() 113 { 114 assert(myState == StateLoaded); 115 myThread->start(); 116 myState = StateStarted; 117 } 118 119 void LicqDaemon::PluginInstanceImpl::initiateStop(Licq::Event::Ptr stopEvent) 120 { 121 assert(myState == StateStarted); 122 mySetup.eventQueue->push(stopEvent); 123 myState = StateStopping; 124 } 125 126 void LicqDaemon::PluginInstanceImpl::completeStop(bool force) 127 { 128 assert(myState == StateStopping); 129 130 if (force) 131 myThread->kill(SIGTERM); 132 myThread->join(); 133 134 myState = StateStopped; 135 } -
branches/newapi/licq/src/plugin/plugininstanceimpl.h
r6012 r6015 52 52 Licq::Plugin::Id load(int argc, char** argv); 53 53 54 void start(); 55 void initiateStop(Licq::Event::Ptr stopEvent); 56 void completeStop(bool force); 57 58 State getState() const; 59 54 60 /** 55 61 * @returns This plugin instance's plugin information. … … 84 90 Licq::Plugin::Information::Ptr myInformation; 85 91 boost::shared_ptr<PluginLibrary> myLibrary; 92 State myState; 86 93 87 94 Licq::Plugin::Setup mySetup; … … 94 101 95 102 } // namespace LicqDaemon 103 104 inline LicqDaemon::PluginInstance::State 105 LicqDaemon::PluginInstanceImpl::getState() const 106 { 107 return myState; 108 } 96 109 97 110 inline Licq::Plugin::Id LicqDaemon::PluginInstanceImpl::getPluginId() const
