nm-vpn-editor-plugin.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
  2. /*
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the
  15. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. * Boston, MA 02110-1301 USA.
  17. *
  18. * Copyright 2008 Novell, Inc.
  19. * Copyright 2008 - 2015 Red Hat, Inc.
  20. */
  21. #ifndef __NM_VPN_EDITOR_PLUGIN_H__
  22. #define __NM_VPN_EDITOR_PLUGIN_H__
  23. #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
  24. #error "Only <NetworkManager.h> can be included directly."
  25. #endif
  26. #include <glib.h>
  27. #include <glib-object.h>
  28. #include "nm-connection.h"
  29. #include "nm-utils.h"
  30. G_BEGIN_DECLS
  31. typedef struct _NMVpnPluginInfo NMVpnPluginInfo;
  32. typedef struct _NMVpnEditorPlugin NMVpnEditorPlugin;
  33. typedef struct _NMVpnEditor NMVpnEditor;
  34. /* Plugin's factory function that returns a GObject that implements
  35. * NMVpnEditorPlugin.
  36. */
  37. #ifndef __GI_SCANNER__
  38. typedef NMVpnEditorPlugin * (*NMVpnEditorPluginFactory) (GError **error);
  39. NMVpnEditorPlugin *nm_vpn_editor_plugin_factory (GError **error);
  40. #endif
  41. /*****************************************************************************/
  42. /* Editor plugin interface */
  43. /*****************************************************************************/
  44. #define NM_TYPE_VPN_EDITOR_PLUGIN (nm_vpn_editor_plugin_get_type ())
  45. #define NM_VPN_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPlugin))
  46. #define NM_IS_VPN_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_EDITOR_PLUGIN))
  47. #define NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPluginInterface))
  48. /**
  49. * NMVpnEditorPluginCapability:
  50. * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE: unknown or no capability
  51. * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT: the plugin can import new connections
  52. * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT: the plugin can export connections
  53. * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6: the plugin supports IPv6 addressing
  54. *
  55. * Flags that indicate certain capabilities of the plugin to editor programs.
  56. **/
  57. typedef enum /*< flags >*/ {
  58. NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE = 0x00,
  59. NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT = 0x01,
  60. NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT = 0x02,
  61. NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6 = 0x04
  62. } NMVpnEditorPluginCapability;
  63. /* Short display name of the VPN plugin */
  64. #define NM_VPN_EDITOR_PLUGIN_NAME "name"
  65. /* Longer description of the VPN plugin */
  66. #define NM_VPN_EDITOR_PLUGIN_DESCRIPTION "description"
  67. /* D-Bus service name of the plugin's VPN service */
  68. #define NM_VPN_EDITOR_PLUGIN_SERVICE "service"
  69. typedef struct _NMVpnEditorPluginVT NMVpnEditorPluginVT;
  70. /**
  71. * NMVpnEditorPluginInterface:
  72. * @g_iface: the parent interface
  73. * @get_editor: returns an #NMVpnEditor, pre-filled with values from @connection
  74. * if non-%NULL.
  75. * @get_capabilities: returns a bitmask of capabilities.
  76. * @import_from_file: Try to import a connection from the specified path. On
  77. * success, return a partial #NMConnection object. On error, return %NULL and
  78. * set @error with additional information. Note that @error can be %NULL, in
  79. * which case no additional error information should be provided.
  80. * @export_to_file: Export the given connection to the specified path. Return
  81. * %TRUE on success. On error, return %FALSE and set @error with additional
  82. * error information. Note that @error can be %NULL, in which case no
  83. * additional error information should be provided.
  84. * @get_suggested_filename: For a given connection, return a suggested file
  85. * name. Returned value will be %NULL or a suggested file name to be freed by
  86. * the caller.
  87. * @notify_plugin_info_set: A callback to be called when the plugin info is set.
  88. * @get_vt: return a virtual function table to implement further functions in
  89. * the plugin, without requiring to update libnm. Used by nm_vpn_editor_plugin_get_vt().
  90. *
  91. * Interface for VPN editor plugins.
  92. */
  93. typedef struct {
  94. GTypeInterface g_iface;
  95. NMVpnEditor * (*get_editor) (NMVpnEditorPlugin *plugin,
  96. NMConnection *connection,
  97. GError **error);
  98. NMVpnEditorPluginCapability (*get_capabilities) (NMVpnEditorPlugin *plugin);
  99. NMConnection * (*import_from_file) (NMVpnEditorPlugin *plugin,
  100. const char *path,
  101. GError **error);
  102. gboolean (*export_to_file) (NMVpnEditorPlugin *plugin,
  103. const char *path,
  104. NMConnection *connection,
  105. GError **error);
  106. char * (*get_suggested_filename) (NMVpnEditorPlugin *plugin, NMConnection *connection);
  107. void (*notify_plugin_info_set) (NMVpnEditorPlugin *plugin,
  108. NMVpnPluginInfo *plugin_info);
  109. const NMVpnEditorPluginVT *(*get_vt) (NMVpnEditorPlugin *plugin,
  110. gsize *out_vt_size);
  111. } NMVpnEditorPluginInterface;
  112. GType nm_vpn_editor_plugin_get_type (void);
  113. NMVpnEditor *nm_vpn_editor_plugin_get_editor (NMVpnEditorPlugin *plugin,
  114. NMConnection *connection,
  115. GError **error);
  116. NMVpnEditorPluginCapability nm_vpn_editor_plugin_get_capabilities (NMVpnEditorPlugin *plugin);
  117. NM_AVAILABLE_IN_1_4
  118. gsize nm_vpn_editor_plugin_get_vt (NMVpnEditorPlugin *plugin,
  119. NMVpnEditorPluginVT *vt,
  120. gsize vt_size);
  121. NMConnection *nm_vpn_editor_plugin_import (NMVpnEditorPlugin *plugin,
  122. const char *path,
  123. GError **error);
  124. gboolean nm_vpn_editor_plugin_export (NMVpnEditorPlugin *plugin,
  125. const char *path,
  126. NMConnection *connection,
  127. GError **error);
  128. char *nm_vpn_editor_plugin_get_suggested_filename (NMVpnEditorPlugin *plugin,
  129. NMConnection *connection);
  130. NM_AVAILABLE_IN_1_2
  131. NMVpnEditorPlugin *nm_vpn_editor_plugin_load_from_file (const char *plugin_name,
  132. const char *check_service,
  133. int check_owner,
  134. NMUtilsCheckFilePredicate check_file,
  135. gpointer user_data,
  136. GError **error);
  137. NM_AVAILABLE_IN_1_4
  138. NMVpnEditorPlugin *nm_vpn_editor_plugin_load (const char *plugin_name,
  139. const char *check_service,
  140. GError **error);
  141. NM_AVAILABLE_IN_1_4
  142. NMVpnPluginInfo *nm_vpn_editor_plugin_get_plugin_info (NMVpnEditorPlugin *plugin);
  143. NM_AVAILABLE_IN_1_4
  144. void nm_vpn_editor_plugin_set_plugin_info (NMVpnEditorPlugin *plugin, NMVpnPluginInfo *plugin_info);
  145. #include "nm-vpn-plugin-info.h"
  146. G_END_DECLS
  147. #endif /* __NM_VPN_EDITOR_PLUGIN_H__ */