D-Bus API: added Session.GetConfigName() (BMC #3559)
This call is useful for clients which haven't started the session and need to know what peer it relates to, and also fo clients which use non-normalized config name and need to know the normalized name.
This commit is contained in:
parent
e30ae98e57
commit
a9e7a49705
|
@ -17,6 +17,26 @@
|
|||
</arg>
|
||||
</method>
|
||||
|
||||
<method name="GetConfigName">
|
||||
<doc:doc>
|
||||
<doc:description>
|
||||
<doc:para>Get the configuration name of the session.</doc:para>
|
||||
<doc:para>Every session is associated with a specific
|
||||
configuration, as requested by the creator of the
|
||||
session. This call returns the normalized configuration
|
||||
name. Note that this may be different from the name used
|
||||
when creating the configuration, because that name is not
|
||||
required to be normalized. Therefore this method may be
|
||||
useful both for the creator of the session and other
|
||||
clients which cannot know the configuration name without
|
||||
calling this method.</doc:para>
|
||||
</doc:description>
|
||||
</doc:doc>
|
||||
<arg type="s" name="config" direction="out">
|
||||
<doc:doc><doc:summary>peer configuration name</doc:summary></doc:doc>
|
||||
</arg>
|
||||
</method>
|
||||
|
||||
<method name="GetConfig">
|
||||
<doc:doc><doc:description>Get the configuration of the server</doc:description></doc:doc>
|
||||
<arg type="b" name="tmplate" direction="in">
|
||||
|
|
|
@ -1935,6 +1935,9 @@ public:
|
|||
/** Session.GetFlags() */
|
||||
std::vector<std::string> getFlags() { return m_flags; }
|
||||
|
||||
/** Session.GetConfigName() */
|
||||
std::string getNormalConfigName() { return SyncConfig::normalizeConfigString(m_configName); }
|
||||
|
||||
/** Session.SetConfig() */
|
||||
void setConfig(bool update, bool temporary,
|
||||
const ReadOperations::Config_t &config);
|
||||
|
@ -3185,6 +3188,7 @@ Session::Session(DBusServer &server,
|
|||
{
|
||||
add(this, &Session::detach, "Detach");
|
||||
add(this, &Session::getFlags, "GetFlags");
|
||||
add(this, &Session::getNormalConfigName, "GetConfigName");
|
||||
add(static_cast<ReadOperations *>(this), &ReadOperations::getConfigs, "GetConfigs");
|
||||
add(static_cast<ReadOperations *>(this), &ReadOperations::getConfig, "GetConfig");
|
||||
add(this, &Session::setConfig, "SetConfig");
|
||||
|
@ -4663,7 +4667,7 @@ vector<string> DBusServer::getCapabilities()
|
|||
vector<string> capabilities;
|
||||
|
||||
// capabilities.push_back("ConfigChanged");
|
||||
// capabilities.push_back("GetConfigName");
|
||||
capabilities.push_back("GetConfigName");
|
||||
capabilities.push_back("Notifications");
|
||||
capabilities.push_back("Version");
|
||||
capabilities.push_back("SessionFlags");
|
||||
|
|
|
@ -539,7 +539,7 @@ class TestDBusServer(unittest.TestCase, DBusUtil):
|
|||
"""check the Server.GetCapabilities() call"""
|
||||
capabilities = self.server.GetCapabilities()
|
||||
capabilities.sort()
|
||||
self.failUnlessEqual(capabilities, ['Notifications', 'SessionFlags', 'Version'])
|
||||
self.failUnlessEqual(capabilities, ['GetConfigName', 'Notifications', 'SessionFlags', 'Version'])
|
||||
|
||||
def testVersions(self):
|
||||
"""check the Server.GetVersions() call"""
|
||||
|
@ -893,12 +893,14 @@ class TestDBusSession(unittest.TestCase, DBusUtil):
|
|||
def testCreateSession(self):
|
||||
"""ask for session"""
|
||||
self.failUnlessEqual(self.session.GetFlags(), [])
|
||||
self.failUnlessEqual(self.session.GetConfigName(), "@default");
|
||||
|
||||
def testCreateSessionWithFlags(self):
|
||||
"""ask for session with some specific flags"""
|
||||
"""ask for session with some specific flags and config"""
|
||||
self.session.Detach()
|
||||
self.sessionpath, self.session = self.createSession("", True, ["foo", "bar"])
|
||||
self.sessionpath, self.session = self.createSession("FooBar@no-such-context", True, ["foo", "bar"])
|
||||
self.failUnlessEqual(self.session.GetFlags(), ["foo", "bar"])
|
||||
self.failUnlessEqual(self.session.GetConfigName(), "foobar@no-such-context");
|
||||
|
||||
@timeout(20)
|
||||
def testSecondSession(self):
|
||||
|
|
Loading…
Reference in New Issue