The entity capabilities cache file is now configurable.
git-svn-id: http://voip.null.ro/svn/yate@4577 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
d6d45acc93
commit
695de94a2b
|
@ -49,6 +49,14 @@
|
|||
; Defaults to enable
|
||||
;entitycaps=enable
|
||||
|
||||
; entitycaps_file: string: Entity capabilities cache file
|
||||
; This parameter is applied on reload
|
||||
; If the file changes on reload entity capabilities will be saved in the new
|
||||
; location, the old file will not be deleted
|
||||
; Client: defaults to 'jabberentitycaps.xml' located in current user's files directory
|
||||
; Server: defaults to 'jabberentitycaps.xml' located in current configuration directory
|
||||
;entitycaps_file=
|
||||
|
||||
; printxml: boolean/string: Print sent/received XML data to output if debug
|
||||
; level is at least 9
|
||||
; Allowed values are boolean values or 'verbose' string
|
||||
|
|
|
@ -92,6 +92,13 @@
|
|||
; Defaults to enable
|
||||
;entitycaps=enable
|
||||
|
||||
; entitycaps_file: string: Entity capabilities cache file
|
||||
; This parameter is applied on reload
|
||||
; If the file changes on reload entity capabilities will be saved in the new
|
||||
; location, the old file will not be deleted
|
||||
; Defaults to 'jabberentitycaps.xml' located in current configuration directory
|
||||
;entitycaps_file=
|
||||
|
||||
; workers: integer: The number of worker threads processing stanzas received by streams
|
||||
; Minimum allowed value is 1, maximum allowed value is 10
|
||||
; Defaults to 1
|
||||
|
|
|
@ -133,15 +133,18 @@ class YJBEntityCapsList : public JBEntityCapsList
|
|||
public:
|
||||
// Load the entity caps file
|
||||
void load();
|
||||
// Set caps file. Save it if changed
|
||||
void setFile(const char* file);
|
||||
protected:
|
||||
inline void getEntityCapsFile(String& file) {
|
||||
file = Engine::configPath(Engine::clientMode());
|
||||
if (!file.endsWith(Engine::pathSeparator()))
|
||||
file << Engine::pathSeparator();
|
||||
file << "jabberentitycaps.xml";
|
||||
Lock mylock(this);
|
||||
file = m_file;
|
||||
}
|
||||
// Notify changes and save the entity caps file
|
||||
virtual void capsAdded(JBEntityCaps* caps);
|
||||
// Save the file
|
||||
void save();
|
||||
String m_file;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -694,12 +697,35 @@ void YJBEntityCapsList::load()
|
|||
loadXmlDoc(file,s_jabber);
|
||||
}
|
||||
|
||||
// Set caps file
|
||||
void YJBEntityCapsList::setFile(const char* file)
|
||||
{
|
||||
Lock mylock(this);
|
||||
String old = m_file;
|
||||
m_file = file;
|
||||
if (!m_file) {
|
||||
m_file = Engine::configPath(Engine::clientMode());
|
||||
if (!m_file.endsWith(Engine::pathSeparator()))
|
||||
m_file << Engine::pathSeparator();
|
||||
m_file << "jabberentitycaps.xml";
|
||||
}
|
||||
Engine::self()->runParams().replaceParams(m_file);
|
||||
bool changed = m_enable && old && m_file && old != m_file;
|
||||
mylock.drop();
|
||||
if (changed)
|
||||
save();
|
||||
}
|
||||
|
||||
// Notify changes and save the entity caps file
|
||||
void YJBEntityCapsList::capsAdded(JBEntityCaps* caps)
|
||||
{
|
||||
if (!caps)
|
||||
return;
|
||||
// Save the file
|
||||
if (caps)
|
||||
save();
|
||||
}
|
||||
|
||||
// Save the file
|
||||
void YJBEntityCapsList::save()
|
||||
{
|
||||
String file;
|
||||
getEntityCapsFile(file);
|
||||
saveXmlDoc(file,s_jabber);
|
||||
|
@ -2495,6 +2521,7 @@ void JBModule::initialize()
|
|||
Output("Initializing module Jabber Client");
|
||||
Configuration cfg(Engine::configFile("jabberclient"));
|
||||
|
||||
s_entityCaps.setFile(cfg.getValue("general","entitycaps_file"));
|
||||
if (!m_init) {
|
||||
m_init = true;
|
||||
setup();
|
||||
|
|
|
@ -176,15 +176,18 @@ public:
|
|||
const char* from, const char* to);
|
||||
// Load the entity caps file
|
||||
void load();
|
||||
// Set caps file. Save it if changed
|
||||
void setFile(const char* file);
|
||||
protected:
|
||||
inline void getEntityCapsFile(String& file) {
|
||||
file = Engine::configPath();
|
||||
if (!file.endsWith(Engine::pathSeparator()))
|
||||
file << Engine::pathSeparator();
|
||||
file << "jabberentitycaps.xml";
|
||||
Lock mylock(this);
|
||||
file = m_file;
|
||||
}
|
||||
// Notify changes and save the entity caps file
|
||||
virtual void capsAdded(JBEntityCaps* caps);
|
||||
// Save the file
|
||||
void save();
|
||||
String m_file;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -979,6 +982,25 @@ void YJBEntityCapsList::load()
|
|||
loadXmlDoc(file,s_jabber);
|
||||
}
|
||||
|
||||
// Set caps file
|
||||
void YJBEntityCapsList::setFile(const char* file)
|
||||
{
|
||||
Lock mylock(this);
|
||||
String old = m_file;
|
||||
m_file = file;
|
||||
if (!m_file) {
|
||||
m_file = Engine::configPath();
|
||||
if (!m_file.endsWith(Engine::pathSeparator()))
|
||||
m_file << Engine::pathSeparator();
|
||||
m_file << "jabberentitycaps.xml";
|
||||
}
|
||||
Engine::self()->runParams().replaceParams(m_file);
|
||||
bool changed = m_enable && old && m_file && old != m_file;
|
||||
mylock.drop();
|
||||
if (changed)
|
||||
save();
|
||||
}
|
||||
|
||||
// Notify changes and save the entity caps file
|
||||
void YJBEntityCapsList::capsAdded(JBEntityCaps* caps)
|
||||
{
|
||||
|
@ -993,6 +1015,12 @@ void YJBEntityCapsList::capsAdded(JBEntityCaps* caps)
|
|||
addCaps(*m,*caps);
|
||||
Engine::enqueue(m);
|
||||
// Save the file
|
||||
save();
|
||||
}
|
||||
|
||||
// Save the file
|
||||
void YJBEntityCapsList::save()
|
||||
{
|
||||
String file;
|
||||
getEntityCapsFile(file);
|
||||
saveXmlDoc(file,s_jabber);
|
||||
|
@ -3910,6 +3938,7 @@ void JBModule::initialize()
|
|||
Output("Initializing module Jabber Server");
|
||||
Configuration cfg(Engine::configFile("jabberserver"));
|
||||
|
||||
s_entityCaps.setFile(cfg.getValue("general","entitycaps_file"));
|
||||
if (!m_init) {
|
||||
// Init some globals
|
||||
s_clusterControlSkip.append(new String("targetid"));
|
||||
|
|
Loading…
Reference in New Issue