File: modulebrowser_plugin.cpp

package info (click to toggle)
korelib 0.0.1-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,788 kB
  • ctags: 1,918
  • sloc: sh: 8,555; cpp: 3,989; makefile: 633; ansic: 65
file content (74 lines) | stat: -rw-r--r-- 2,693 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

#include <kore/version.h>
#include <kore/kernel.h>
#include <kore/servicemanager.h>
#include <kore/modulemanager.h>

#include "modulebrowser_plugin.h"
#include "modulebrowser_impl.h"
#include "modviewfact_impl.h"

#define MODULEBROWSER_PLUGIN_MAJOR 0
#define MODULEBROWSER_PLUGIN_MINOR 0
#define MODULEBROWSER_PLUGIN_REVISION 1
#define MODULEBROWSER_PLUGIN_VERSION "0.0.1"
#define MODULEBROWSER_PLUGIN_API_MAJOR 0
#define MODULEBROWSER_PLUGIN_API_MINOR 0
#define MODULEBROWSER_PLUGIN_API_REVISION 2
#define MODULEBROWSER_PLUGIN_API_VERSION "0.0.2"
#define MODULEBROWSER_PLUGIN_NAME "ModuleBrowser Plugin"
#define MODULEBROWSER_PLUGIN_TYPE "Plugin"
#define MODULEBROWSER_PLUGIN_DESCRIPTION "This plugin registers the ModuleBrowser and ModuleViewFactory providers."

PLUGIN_MAIN_BODY(ModuleBrowserPlugin,libHandle,libName,libPath,libFlags);

ModuleBrowserPlugin::ModuleBrowserPlugin(HMODULE libhandle, const char* libname, const char* libpath, int flags):Plugin(libhandle,libname,libpath,flags)
{
    _pluginVersion = new Version(MODULEBROWSER_PLUGIN_MAJOR,MODULEBROWSER_PLUGIN_MINOR,MODULEBROWSER_PLUGIN_REVISION,MODULEBROWSER_PLUGIN_VERSION);
    _pluginAPIVersion = new Version(MODULEBROWSER_PLUGIN_API_MAJOR,MODULEBROWSER_PLUGIN_API_MINOR,MODULEBROWSER_PLUGIN_API_REVISION,MODULEBROWSER_PLUGIN_API_VERSION);
    _pluginInfo = new Info(this, MODULEBROWSER_PLUGIN_NAME, MODULEBROWSER_PLUGIN_TYPE, MODULEBROWSER_PLUGIN_DESCRIPTION, _pluginVersion, _pluginAPIVersion);
    setInfo(_pluginInfo);
}
ModuleBrowserPlugin::~ModuleBrowserPlugin()
{
    delete _pluginInfo;
    delete _pluginVersion;
    delete _pluginAPIVersion;
    delete browser;
    delete factory;
}
void ModuleBrowserPlugin::pluginLoaded()
{
    // Nothing to do here
}
void ModuleBrowserPlugin::initPlugin()
{
    ServiceManager* sm = Kernel::instance()->serviceManager();
    ModuleManager* mm = dynamic_cast<ModuleManager*>( sm->registeredProvider("Kore/Kernel/Module Manager") );
    browser = new ModuleBrowserImpl();
    factory = new ModViewFactImpl();
    if( mm )
    {
        mm->registerModule(factory);
        mm->registerModule(browser);
    }
    sm->registerProvider(factory);
    sm->registerProvider(browser);
}
void ModuleBrowserPlugin::finalizePlugin()
{
    ServiceManager* sm = Kernel::instance()->serviceManager();
    ModuleManager* mm = dynamic_cast<ModuleManager*>( sm->registeredProvider("Kore/Kernel/Module Manager") );
    factory->destroyViews();
    sm->unregisterProvider(browser);
    sm->unregisterProvider(factory);
    if( mm )
    {
        mm->unregisterModule(browser);
        mm->unregisterModule(factory);
    }
}
void ModuleBrowserPlugin::unloadingPlugin()
{
    finalizePlugin();
}