mirror of
https://github.com/znc/znc.git
synced 2026-04-30 10:34:16 +02:00
@@ -67,6 +67,9 @@ using std::allocator;
|
||||
%template(SModInfo) std::set<CModInfo>;
|
||||
%template(SCString) std::set<CString>;
|
||||
typedef std::set<CString> SCString;
|
||||
%template(MPyCString) std::map<CString, CString>;
|
||||
class MCString : public std::map<CString, CString> {};
|
||||
%template(PyModules) std::vector<CModule*>;
|
||||
|
||||
%typemap(in) CString& {
|
||||
String* p;
|
||||
@@ -171,9 +174,6 @@ class CPyRetBool {
|
||||
}
|
||||
|
||||
%extend CModules {
|
||||
void push_back(CModule* p) {
|
||||
$self->push_back(p);
|
||||
}
|
||||
bool removeModule(CModule* p) {
|
||||
for (CModules::iterator i = $self->begin(); $self->end() != i; ++i) {
|
||||
if (*i == p) {
|
||||
@@ -257,6 +257,7 @@ typedef std::vector<std::pair<CString, CString> > VPair;
|
||||
|
||||
%extend CTemplate {
|
||||
void set(const CString& key, const CString& value) {
|
||||
DEBUG("WARNING: modpython's CTemplate.set is deprecated and will be removed. Use normal dict's operations like Tmpl['foo'] = 'bar'");
|
||||
(*$self)[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,20 +498,22 @@ def load_module(modname, args, module_type, user, network, retmsg, modpython):
|
||||
retmsg.s = "Module [{}] is UserModule and needs user.".format(modname)
|
||||
unload_module(module)
|
||||
return 1
|
||||
user.GetModules().push_back(module._cmod)
|
||||
cont = user
|
||||
elif module_type == CModInfo.NetworkModule:
|
||||
if not network:
|
||||
retmsg.s = "Module [{}] is Network module and needs a network.".format(modname)
|
||||
unload_module(module)
|
||||
return 1
|
||||
network.GetModules().push_back(module._cmod)
|
||||
cont = network
|
||||
elif module_type == CModInfo.GlobalModule:
|
||||
CZNC.Get().GetModules().push_back(module._cmod)
|
||||
cont = CZNC.Get()
|
||||
else:
|
||||
retmsg.s = "Module [{}] doesn't support that module type.".format(modname)
|
||||
unload_module(module)
|
||||
return 1
|
||||
|
||||
cont.GetModules().append(module._cmod)
|
||||
|
||||
try:
|
||||
loaded = True
|
||||
if not module.OnLoad(args, retmsg):
|
||||
@@ -555,11 +557,12 @@ def unload_module(module):
|
||||
_py_modules.discard(module)
|
||||
cmod = module._cmod
|
||||
if module.GetType() == CModInfo.UserModule:
|
||||
cmod.GetUser().GetModules().removeModule(cmod)
|
||||
cont = cmod.GetUser()
|
||||
elif module.GetType() == CModInfo.NetworkModule:
|
||||
cmod.GetNetwork().GetModules().removeModule(cmod)
|
||||
cont = cmod.GetNetwork()
|
||||
elif module.GetType() == CModInfo.GlobalModule:
|
||||
CZNC.Get().GetModules().removeModule(cmod)
|
||||
cont = CZNC.Get()
|
||||
cont.GetModules().removeModule(cmod)
|
||||
del module._cmod
|
||||
cmod.DeletePyModule()
|
||||
del cmod
|
||||
|
||||
Reference in New Issue
Block a user