Rework MatrixHTTPAPI in Vala
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -64,3 +64,4 @@ Makefile.in | ||||
| /src/matrix-api.c | ||||
| /src/matrix-client.c | ||||
| /src/matrix-enums.c | ||||
| /src/matrix-http-api.c | ||||
|   | ||||
| @@ -19,6 +19,7 @@ libmatrix_glib_0_0_la_VALA_SOURCES = \ | ||||
| 	matrix-api.vala \ | ||||
| 	matrix-client.vala \ | ||||
| 	matrix-enums.vala \ | ||||
| 	matrix-http-api.vala \ | ||||
| 	$(NULL) | ||||
|  | ||||
| AM_CPPFLAGS += \ | ||||
| @@ -73,7 +74,6 @@ bin_PROGRAMS = test-api-client | ||||
|  | ||||
| INST_H_SRC_FILES = \ | ||||
| 	matrix-types.h \ | ||||
| 	matrix-http-api.h \ | ||||
| 	matrix-http-client.h \ | ||||
| 	$(NULL) | ||||
|  | ||||
| @@ -91,7 +91,6 @@ libmatrix_glib_0_0_la_SOURCES = \ | ||||
| 	$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \ | ||||
| 	matrix-version.c \ | ||||
| 	matrix-types.c \ | ||||
| 	matrix-http-api.c \ | ||||
| 	matrix-enumtypes.c \ | ||||
| 	utils.c \ | ||||
| 	matrix-http-client.c \ | ||||
|   | ||||
| @@ -108,14 +108,29 @@ namespace Matrix { | ||||
|     } | ||||
|  | ||||
|     [CCode (cheader_filename = "matrix-types.h")] | ||||
|     public class Pusher {} | ||||
|     public class Pusher { | ||||
|         public Json.Node? get_json_node() | ||||
|             throws Matrix.Error; | ||||
|     } | ||||
|  | ||||
|     [CCode (cheader_filename = "matrix-types.h")] | ||||
|     public class StateEvent {} | ||||
|     public class StateEvent { | ||||
|         public Json.Node? get_json_node(); | ||||
|     } | ||||
|  | ||||
|     [CCode (cheader_filename = "matrix-types.h")] | ||||
|     public class @3PidCredential {} | ||||
|     public class @3PidCredential { | ||||
|         public Json.Node? get_json_node() | ||||
|             throws Matrix.Error; | ||||
|     } | ||||
|  | ||||
|     [CCode (cheader_filename = "matrix-types.h")] | ||||
|     public class Filter {} | ||||
|     public class Filter { | ||||
|         public Json.Node? get_json_node(); | ||||
|         public string? get_json_data(out size_t datalen); | ||||
|     } | ||||
|  | ||||
|     [CCode (cheader_filename = "utils.h", cname = "_json_node_deep_copy")] | ||||
|     public Json.Node? | ||||
|     _json_node_deep_copy(Json.Node? node); | ||||
| } | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,60 +0,0 @@ | ||||
| /* | ||||
|  * This file is part of matrix-glib-sdk | ||||
|  * | ||||
|  * matrix-glib-sdk is free software: you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation, either | ||||
|  * version 3 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * matrix-glib-sdk is distributed in the hope that it will be | ||||
|  * useful, but WITHOUT ANY WARRANTY; without even the implied | ||||
|  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||
|  * See the GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with matrix-glib-sdk. If not, see | ||||
|  * <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #ifndef __MATRIX_HTTP_API_H__ | ||||
| #define __MATRIX_HTTP_API_H__ | ||||
|  | ||||
| #include <glib-object.h> | ||||
|  | ||||
| #include "matrix-glib.h" | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
| #define MATRIX_TYPE_HTTP_API         (matrix_http_api_get_type()) | ||||
| #define MATRIX_HTTP_API(o)           (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_HTTP_API, MatrixHTTPAPI)) | ||||
| #define MATRIX_HTTP_API_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), MATRIX_TYPE_HTTP_API, MatrixHTTPAPIClass)) | ||||
| #define MATRIX_IS_HTTP_API(o)        (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_HTTP_API)) | ||||
| #define MATRIX_IS_HTTP_API_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE((k), MATRIX_TYPE_HTTP_API)) | ||||
| #define MATRIX_HTTP_API_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_TYPE_HTTP_API, MatrixHTTPAPIClass)) | ||||
|  | ||||
| typedef struct _MatrixHTTPAPI      MatrixHTTPAPI; | ||||
| typedef struct _MatrixHTTPAPIClass MatrixHTTPAPIClass; | ||||
|  | ||||
| struct _MatrixHTTPAPI { | ||||
|     /* Parent instance structure */ | ||||
|     GObject parent_instance; | ||||
|  | ||||
|     /* Instance members */ | ||||
| }; | ||||
|  | ||||
| struct _MatrixHTTPAPIClass { | ||||
|     GObjectClass parent_class; | ||||
| }; | ||||
|  | ||||
| GType matrix_http_api_get_type(void) G_GNUC_CONST; | ||||
| void matrix_http_api_set_validate_certificate(MatrixHTTPAPI *api, | ||||
|                                               gboolean validate_certificate); | ||||
| gboolean matrix_http_api_get_validate_certificate(MatrixHTTPAPI *api); | ||||
| void matrix_http_api_set_base_url(MatrixHTTPAPI *api, const gchar *base_url); | ||||
| gchar *matrix_http_api_get_base_url(MatrixHTTPAPI *api); | ||||
|  | ||||
| MatrixAPI *matrix_http_api_new(const gchar *base_url, const gchar *token); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __MATRIX_HTTP_API_H__ */ | ||||
							
								
								
									
										1745
									
								
								src/matrix-http-api.vala
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1745
									
								
								src/matrix-http-api.vala
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -21,7 +21,6 @@ | ||||
|  | ||||
| #include <glib-object.h> | ||||
| #include "matrix-glib.h" | ||||
| #include "matrix-http-api.h" | ||||
|  | ||||
| G_BEGIN_DECLS | ||||
|  | ||||
|   | ||||
| @@ -20,7 +20,7 @@ | ||||
| #include <json-glib/json-glib.h> | ||||
| #include <libsoup/soup.h> | ||||
|  | ||||
| #include "matrix-http-api.h" | ||||
| #include "matrix-glib.h" | ||||
|  | ||||
| #define LOG_DOMAIN "Matrix-Test-Client" | ||||
|  | ||||
| @@ -183,7 +183,7 @@ main(int argc, char *argv[]) | ||||
|  | ||||
|     g_info("Starting up: %s with %s:%s", *homeserver, user, password); | ||||
|  | ||||
|     api = matrix_http_api_new(*homeserver, NULL); | ||||
|     api = MATRIX_API(matrix_http_api_new(*homeserver, NULL)); | ||||
|     matrix_http_api_set_validate_certificate(MATRIX_HTTP_API(api), | ||||
|                                              !no_validate_certs); | ||||
|     builder = json_builder_new(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user