Moved local getters to base class, making them accessible from all the subclasses
This commit is contained in:
parent
e72658e5b9
commit
788600a883
@ -48,23 +48,6 @@ namespace matrix{
|
|||||||
client& operator=(const client&) = default;
|
client& operator=(const client&) = default;
|
||||||
client& operator=(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.
|
* Sets the display name on the homeserver.
|
||||||
* Note name must be safe to be placed in a json string.
|
* Note name must be safe to be placed in a json string.
|
||||||
|
|||||||
@ -43,6 +43,22 @@ namespace matrix{
|
|||||||
public:
|
public:
|
||||||
~connection(void) = default;
|
~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.
|
* Returns: the http status code of the last operation performed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
namespace matrix{
|
namespace matrix{
|
||||||
//Manages connection to homeserver and user login.
|
//Manages connection to homeserver and user login.
|
||||||
//Shares states with any spawned clients and syncers.
|
//Shares states with any spawned clients and syncers.
|
||||||
class session : protected connection
|
class session : public connection
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool m_valid = false;
|
bool m_valid = false;
|
||||||
|
|||||||
@ -38,17 +38,6 @@ namespace matrix{
|
|||||||
client::client(const std::shared_ptr<internal::session_info>& ses):
|
client::client(const std::shared_ptr<internal::session_info>& ses):
|
||||||
connection(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
|
//networked setter
|
||||||
bool client::set_display_name(const raii::string_base& newname){
|
bool client::set_display_name(const raii::string_base& newname){
|
||||||
_put_curl(raii::string("{\"displayname\":\"" + newname + "\"}"), m_ses->urls.displayname(), raii::curl_llist());
|
_put_curl(raii::string("{\"displayname\":\"" + newname + "\"}"), m_ses->urls.displayname(), raii::curl_llist());
|
||||||
|
|||||||
@ -30,6 +30,17 @@ namespace matrix{
|
|||||||
{
|
{
|
||||||
_set_curl_defaults(""_ss);
|
_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{
|
long connection::http_status(void)const{
|
||||||
return m_curl.last_status();
|
return m_curl.last_status();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user