Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
32b036d1
Commit
32b036d1
authored
Jan 27, 2009
by
Emmanuel Milou
Browse files
api plugin for registration
parent
f3ba96b6
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/plug-in/Makefile.am
View file @
32b036d1
...
...
@@ -2,7 +2,7 @@ include ../../globals.mak
noinst_LTLIBRARIES
=
libplugin.la
noinst_HEADERS
=
plugin_api.h
SUBDIRS
=
test
libplugin_la_SOURCES
=
\
pluginmanager.cpp
...
...
src/plug-in/plugin.cpp
deleted
100644 → 0
View file @
f3ba96b6
#include
"plugin.h"
::
sflphone
::
Plugin
::
Plugin
(
const
std
::
string
&
filename
UNUSED
)
{
//TODO IMPLEMENT
}
::
sflphone
::
Plugin
::
Plugin
(
const
Plugin
&
plugin
UNUSED
)
{
//TODO IMPLEMENT
}
::
sflphone
::
Plugin
::~
Plugin
()
{
//TODO IMPLEMENT
}
int
::
sflphone
::
Plugin
::
getCoreVersion
(
void
)
const
{
//TODO IMPLEMENT
return
1
;
}
void
::
sflphone
::
Plugin
::
registerPlugin
(
PluginManager
&
)
{
//TODO IMPLEMENT
}
src/plug-in/plugin.h
deleted
100644 → 0
View file @
f3ba96b6
#ifndef PLUGIN_H
#define PLUGIN_H
#include
<string>
#include
"global.h"
/*
* @file plugin.h
* @brief Define a plugin object
*/
namespace
sflphone
{
class
PluginManager
;
class
Plugin
{
public:
Plugin
(
const
std
::
string
&
name
);
//Plugin( const Plugin &plugin );
virtual
~
Plugin
()
{}
public:
/**
* Return the minimal core version required so that the plugin could work
* @return int The version required
*/
virtual
int
getCoreVersion
()
const
=
0
;
/**
* Register the plugin to the plugin manager
*/
virtual
void
registerPlugin
(
PluginManager
&
)
=
0
;
private:
Plugin
&
operator
=
(
const
Plugin
&
plugin
);
};
}
#endif //PLUGIN_H
src/plug-in/plugin_api.h
View file @
32b036d1
#ifndef PLUGIN_
API_
H
#define PLUGIN_
API_
H
#ifndef PLUGIN_H
#define PLUGIN_H
#include
<string>
#include
"global.h"
/*
* @file plugin
_api
.h
* @file plugin.h
* @brief Define a plugin object
*/
...
...
@@ -18,23 +18,14 @@ extern "C" {
class
PluginManager
;
typedef
struct
PluginApi_Version
{
int
version
;
int
revision
;
}
typedef
struct
Register_Params
{
PluginApi_Version
plugin_version
;
create_t
create_func
;
destroy_t
destroy_func
;
}
Register_Params
;
class
PluginApi
{
class
Plugin
{
public:
PluginApi
(
const
std
::
string
&
name
);
//Plugin( const Plugin &plugin );
virtual
~
PluginApi
()
{}
Plugin
(
const
std
::
string
&
name
){
_name
=
name
;
}
virtual
~
Plugin
()
{}
public:
/**
...
...
@@ -43,23 +34,21 @@ extern "C" {
*/
virtual
int
getCoreVersion
()
const
=
0
;
/**
* Register the plugin to the plugin manager
*/
virtual
void
registerPlugin
(
PluginManager
&
)
=
0
;
private:
Plugin
Api
&
operator
=
(
const
Plugin
Api
&
plugin
);
Plugin
&
operator
=
(
const
Plugin
&
plugin
);
std
::
string
_name
;
};
typedef
Plugin
*
createFunc
(
void
*
);
typedef
void
destroyFunc
(
Plugin
*
);
typedef
Plugin
*
create_t
(
void
*
);
typedef
int
destroy_t
(
Plugin
*
);
}
#ifdef __cplusplus
}
#endif
#endif //PLUGIN_
API_
H
#endif //PLUGIN_H
src/plug-in/pluginmanager.cpp
View file @
32b036d1
...
...
@@ -48,7 +48,7 @@ int ::sflphone::PluginManager::loadPlugins( const std::string &path )
return
result
;
}
::
sflphone
::
Plugin
*
::
sflphone
::
PluginManager
::
isPluginLoaded
(
const
std
::
string
&
name
)
::
sflphone
::
Plugin
Wrap
*
::
sflphone
::
PluginManager
::
isPluginLoaded
(
const
std
::
string
&
name
)
{
if
(
_loadedPlugins
.
empty
())
return
NULL
;
...
...
src/plug-in/pluginmanager.h
View file @
32b036d1
...
...
@@ -6,14 +6,23 @@
* @brief Base class of the plugin manager
*/
#include
"plugin.h"
#include
"plugin
_api
.h"
#include
"global.h"
#include
<map>
#include
<string>
namespace
sflphone
{
typedef
struct
{
Plugin
*
plugin
;
createFunc
*
create_func
;
destroyFunc
*
destroy_func
;
std
::
string
name
;
}
PluginWrap
;
class
PluginManager
{
public:
...
...
@@ -44,7 +53,9 @@ namespace sflphone {
* @param name The name of the plugin looked for
* @return Plugin* The pointer on the plugin or NULL if not found
*/
Plugin
*
isPluginLoaded
(
const
std
::
string
&
name
);
PluginWrap
*
isPluginLoaded
(
const
std
::
string
&
name
);
int
initPlugins
(
void
);
private:
/**
...
...
@@ -61,7 +72,7 @@ namespace sflphone {
void
unloadDynamicLibrary
(
void
*
pluginHandlePtr
);
/* Map of plugins associated by their string name */
typedef
std
::
map
<
std
::
string
,
::
sflphone
::
Plugin
*>
pluginMap
;
typedef
std
::
map
<
std
::
string
,
::
sflphone
::
Plugin
Wrap
*>
pluginMap
;
pluginMap
_loadedPlugins
;
/* The unique static instance */
...
...
src/plug-in/test/Makefile.am
View file @
32b036d1
...
...
@@ -8,14 +8,12 @@ INSTALL_PLUGIN_RULE = install-libplugintest_so
noinst_PROGRAMS
=
libplugintest.so
noinst_HEADERS
=
plugin_api.h
install-exec-local
:
install-libplugintest_so
uninstall-local
:
uninstall-libplugintest_so
install-libplugintest_so
:
libplugintest.so
mkdir
-p
$(sflplugin
s
dir)
$(INSTALL_PROGRAM)
libplugintest.so
$(sflplugin
s
dir)
mkdir
-p
$(sflplugindir)
$(INSTALL_PROGRAM)
libplugintest.so
$(sflplugindir)
uninstall-libplugintest_so
:
rm
-f
$(sflplugin
s
dir)
/libplugintest.so
rm
-f
$(sflplugindir)
/libplugintest.so
src/plug-in/test/pluginTest.cpp
View file @
32b036d1
#include
"../plugin_api.h"
class
PluginTest
:
public
Plugin
{
public:
PluginTest
()
:
Plugin
(){
}
};
extern
"C"
Plugin
*
create_t
(
void
*
){
return
new
PluginTest
();
namespace
sflphone
{
class
PluginTest
:
public
Plugin
{
public:
PluginTest
(
const
std
::
string
&
name
)
:
Plugin
(
name
){
}
virtual
int
getCoreVersion
()
const
{
return
1
;
}
};
}
extern
"C"
::
sflphone
::
Plugin
*
create_t
(
void
*
){
return
new
::
sflphone
::
PluginTest
(
"test"
);
}
extern
"C"
void
*
destroy_t
(
Plugin
*
p
){
extern
"C"
void
*
destroy_t
(
::
sflphone
::
Plugin
*
p
){
delete
p
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment