Moved local getters to base class, making them accessible from all the subclasses

This commit is contained in:
rexy712 2019-07-28 12:08:37 -07:00
parent e72658e5b9
commit 788600a883
5 changed files with 28 additions and 29 deletions

View File

@ -48,23 +48,6 @@ namespace matrix{
client& operator=(const client&) = default;
client& operator=(client&&) = default;
/*
* NOT thread safe.
* Returns: the current access token.
*/
const raii::rjp_string& access_token(void)const;
/*
* NOT thread safe
* Returns: the logged in user's userid.
*/
const raii::rjp_string& userid(void)const;
/*
* NOT thread safe
* Returns: the current useragent.
*/
const raii::string& useragent(void)const;
/*
* Sets the display name on the homeserver.
* Note name must be safe to be placed in a json string.

View File

@ -43,6 +43,22 @@ namespace matrix{
public:
~connection(void) = default;
/*
* NOT thread safe.
* Returns: the current access token.
*/
const raii::rjp_string& access_token(void)const;
/*
* NOT thread safe
* Returns: the logged in user's userid.
*/
const raii::rjp_string& userid(void)const;
/*
* NOT thread safe
* Returns: the current useragent.
*/
const raii::string& useragent(void)const;
/*
* Returns: the http status code of the last operation performed.
*/

View File

@ -31,7 +31,7 @@
namespace matrix{
//Manages connection to homeserver and user login.
//Shares states with any spawned clients and syncers.
class session : protected connection
class session : public connection
{
private:
bool m_valid = false;

View File

@ -38,17 +38,6 @@ namespace matrix{
client::client(const std::shared_ptr<internal::session_info>& ses):
connection(ses){}
//local getter
const raii::rjp_string& client::access_token(void)const{
return m_ses->access_token;
}
const raii::rjp_string& client::userid(void)const{
return m_ses->userid;
}
const raii::string& client::useragent(void)const{
return m_ses->useragent;
}
//networked setter
bool client::set_display_name(const raii::string_base& newname){
_put_curl(raii::string("{\"displayname\":\"" + newname + "\"}"), m_ses->urls.displayname(), raii::curl_llist());

View File

@ -30,6 +30,17 @@ namespace matrix{
{
_set_curl_defaults(""_ss);
}
//local getter
const raii::rjp_string& connection::access_token(void)const{
return m_ses->access_token;
}
const raii::rjp_string& connection::userid(void)const{
return m_ses->userid;
}
const raii::string& connection::useragent(void)const{
return m_ses->useragent;
}
long connection::http_status(void)const{
return m_curl.last_status();
}