Implement /register in the HTTP API
This commit is contained in:
parent
e9baaaf60f
commit
2f2ab12c08
@ -58,6 +58,7 @@ matrix_http_api_get_validate_certificate
|
|||||||
matrix_http_api_set_validate_certificate
|
matrix_http_api_set_validate_certificate
|
||||||
matrix_http_api_get_base_url
|
matrix_http_api_get_base_url
|
||||||
matrix_http_api_gen_parameters
|
matrix_http_api_gen_parameters
|
||||||
|
matrix_http_api_register_account
|
||||||
matrix_http_api_login
|
matrix_http_api_login
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
MatrixHTTPAPI
|
MatrixHTTPAPI
|
||||||
|
@ -82,6 +82,7 @@ static void
|
|||||||
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
|
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
|
||||||
{
|
{
|
||||||
iface->login = matrix_http_api_login;
|
iface->login = matrix_http_api_login;
|
||||||
|
iface->register_account = matrix_http_api_register_account;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -452,21 +453,11 @@ update_parameters(gchar *key, gchar *value, JsonBuilder *builder)
|
|||||||
json_builder_add_value(builder, node);
|
json_builder_add_value(builder, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static void
|
||||||
* matrix_http_api_login:
|
matrix_http_api_login_or_register(MatrixAPI *api,
|
||||||
* @api: a #MatrixAPI implementation
|
|
||||||
* @callback: (scope async): the function to call when the request if
|
|
||||||
* finished
|
|
||||||
* @user_data: user data to pass to the callback function
|
|
||||||
* @login_type: the login type to use
|
|
||||||
* @parameters: parameters to send with the login request
|
|
||||||
*
|
|
||||||
* Perform /login
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_http_api_login(MatrixAPI *api,
|
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
|
gchar *type,
|
||||||
gchar *login_type,
|
gchar *login_type,
|
||||||
GHashTable *parameters)
|
GHashTable *parameters)
|
||||||
{
|
{
|
||||||
@ -490,11 +481,37 @@ matrix_http_api_login(MatrixAPI *api,
|
|||||||
|
|
||||||
matrix_http_api_send(MATRIX_HTTP_API(api),
|
matrix_http_api_send(MATRIX_HTTP_API(api),
|
||||||
callback, user_data,
|
callback, user_data,
|
||||||
"POST", "/login",
|
"POST", type,
|
||||||
content,
|
content,
|
||||||
parameters);
|
parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* matrix_http_api_login:
|
||||||
|
* @api: a #MatrixAPI implementation
|
||||||
|
* @callback: (scope async): the function to call when the request if
|
||||||
|
* finished
|
||||||
|
* @user_data: user data to pass to the callback function
|
||||||
|
* @login_type: the login type to use
|
||||||
|
* @parameters: parameters to send with the login request
|
||||||
|
*
|
||||||
|
* Perform /login
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
matrix_http_api_login(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
gchar *login_type,
|
||||||
|
GHashTable *parameters)
|
||||||
|
{
|
||||||
|
matrix_http_api_login_or_register(api,
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
"/login",
|
||||||
|
login_type,
|
||||||
|
parameters);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* matrix_http_api_gen_parameters:
|
* matrix_http_api_gen_parameters:
|
||||||
* @param1_name: name of the first parameter
|
* @param1_name: name of the first parameter
|
||||||
@ -548,3 +565,29 @@ matrix_http_api_get_base_url(MatrixHTTPAPI *api)
|
|||||||
|
|
||||||
return priv->url;
|
return priv->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* matrix_http_api_register_account:
|
||||||
|
* @api: a #MatrixAPI implementation
|
||||||
|
* @callback: (scope async): the function to call when the request if
|
||||||
|
* finished
|
||||||
|
* @user_data: user data to pass to the callback function
|
||||||
|
* @login_type: the login type to use
|
||||||
|
* @parameters: parameters to send with the registration request
|
||||||
|
*
|
||||||
|
* Perform /register
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
matrix_http_api_register_account(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
gchar *login_type,
|
||||||
|
GHashTable *parameters)
|
||||||
|
{
|
||||||
|
matrix_http_api_login_or_register(api,
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
"/register",
|
||||||
|
login_type,
|
||||||
|
parameters);
|
||||||
|
}
|
||||||
|
@ -59,6 +59,12 @@ void matrix_http_api_login(MatrixAPI *api,
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar *login_type,
|
gchar *login_type,
|
||||||
GHashTable *parameters);
|
GHashTable *parameters);
|
||||||
|
void matrix_http_api_register_account(MatrixAPI *api,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
gchar *login_type,
|
||||||
|
GHashTable *parameters);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __MATRIX_HTTP_API_H__ */
|
#endif /* __MATRIX_HTTP_API_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user