FFService

FFService — Class for handling service managed task.

Synopsis


#include <ff-service.h>


struct      FFService;
struct      FFServiceClass;

FFService*  ff_service_new                  (void);

void        ff_service_set_server_address   (FFService *self,
                                             const gchar *server_address);
const gchar* ff_service_get_server_address  (FFService *self);
void        ff_service_set_user_name        (FFService *self,
                                             const gchar *user_name);
const gchar* ff_service_get_user_name       (FFService *self);
void        ff_service_set_password         (FFService *self,
                                             const gchar *password);
const gchar* ff_service_get_password        (FFService *self);

gboolean    ff_service_is_attached          (FFService *self);
gboolean    ff_service_attach               (FFService *self);
gboolean    ff_service_detach               (FFService *self);

gboolean    ff_service_add_user             (FFService *self,
                                             FFUser *new_user,
                                             gboolean free_user);
gboolean    ff_service_modify_user          (FFService *self,
                                             FFUser *user,
                                             gboolean free_user);
gboolean    ff_service_delete_user          (FFService *self,
                                             const gchar *user_name);
FFUser*     ff_service_get_user             (FFService *self,
                                             const gchar *user_name);
GList*      ff_service_get_user_list        (FFService *self);
gboolean    ff_service_make_backup          (FFService *self,
                                             const gchar *db_file,
                                             const gchar *bkp_file,
                                             gulong options);
gboolean    ff_service_restore_backup       (FFService *self,
                                             const gchar *bkp_file,
                                             const gchar *db_file,
                                             gulong options);


Description

Manage user accounts and database backups using Firebird's services.

Details

struct FFService

struct FFService {

	gint timeout;		/* Default: 60 seconds */
};


struct FFServiceClass

struct FFServiceClass {

	void (* on_error)               (FFService *self, gchar *message, gpointer data);
	void (* on_attach)		(FFService *self, gpointer data);
	void (* on_dettach)		(FFService *self, gpointer data);
};


ff_service_new ()

FFService*  ff_service_new                  (void);

Constructor for FFService class.

Returns : A new FFService object.

ff_service_set_server_address ()

void        ff_service_set_server_address   (FFService *self,
                                             const gchar *server_address);

Set database server address where service will be connected.

self : A FFService.
server_address : A string containing a server address (an IP number).

ff_service_get_server_address ()

const gchar* ff_service_get_server_address  (FFService *self);

Get database server address where service will be connected.

self : A FFService.
Returns : A string containing server address, or NULL.

ff_service_set_user_name ()

void        ff_service_set_user_name        (FFService *self,
                                             const gchar *user_name);

Set the user name that the service will use to identify itself to the server.

self : A FFService.
user_name : A string containing a user name.

ff_service_get_user_name ()

const gchar* ff_service_get_user_name       (FFService *self);

Get the user name that the service will use to identify itself to the server.

self : A FFService.
Returns : A string containing the user name, or NULL.

ff_service_set_password ()

void        ff_service_set_password         (FFService *self,
                                             const gchar *password);

Set password for the current service user (user name assigned with ff_service_set_user_name()). The password is used to autenticate service against database server.

self : A FFService.
password : A string containing a password.

ff_service_get_password ()

const gchar* ff_service_get_password        (FFService *self);

Get password for the current service user.

self : A FFService.
Returns : A string containing the password, or NULL.

ff_service_is_attached ()

gboolean    ff_service_is_attached          (FFService *self);

Get service attached status.

self : A FFService.
Returns : TRUE if service is attached to server, or FALSE otherwise.

ff_service_attach ()

gboolean    ff_service_attach               (FFService *self);

Attach service to database server. This function must be called before the execution of any action.

self : A FFService.
Returns : TRUE if service attached successfully to server, or FALSE otherwise.

ff_service_detach ()

gboolean    ff_service_detach               (FFService *self);

Detach service from database server. This function must be called when the service wont be used anymore.

self : A FFService.
Returns : TRUE if service detached successfully from server, or FALSE otherwise.

ff_service_add_user ()

gboolean    ff_service_add_user             (FFService *self,
                                             FFUser *new_user,
                                             gboolean free_user);

Add a new user in database server. If free_user is TRUE then new_user will be released after this function ends. Parameter new_user must be initialized by programmer with the correct values.

self : A FFService.
new_user : A FFUser.
free_user : A boolean flag.
Returns : TRUE if user was created successfully, or FALSE otherwise.

ff_service_modify_user ()

gboolean    ff_service_modify_user          (FFService *self,
                                             FFUser *user,
                                             gboolean free_user);

Modify a user in database server. If free_user is TRUE then user will be released after this function ends. Parameter user must be initialized by programmer with the correct values. And user->user_name must be the name of the user to be modified. This is why the user name can't be modified, in the case you need to modify it you should delete and recreate the user with the new name.

self : A FFService.
user : A FFUser.
free_user : A boolean flag.
Returns : TRUE if user was modified successfully, or FALSE otherwise.

ff_service_delete_user ()

gboolean    ff_service_delete_user          (FFService *self,
                                             const gchar *user_name);

Delete the user from database server.

self : A FFService.
user_name : A string containing a valid user name.
Returns : TRUE if user was deleted successfully, or FALSE otherwise.

ff_service_get_user ()

FFUser*     ff_service_get_user             (FFService *self,
                                             const gchar *user_name);

Get info of a user.

self : A FFService.
user_name : A string containing a valid user name.
Returns : A new FFUser, or NULL.

ff_service_get_user_list ()

GList*      ff_service_get_user_list        (FFService *self);

Get a list of FFUser nodes, with information about all available users in database server.

self : A FFService.
Returns : A new GList of FFUser nodes, or NULL.

ff_service_make_backup ()

gboolean    ff_service_make_backup          (FFService *self,
                                             const gchar *db_file,
                                             const gchar *bkp_file,
                                             gulong options);

Make a backup of db_file.

Backup options:

  • isc_spb_bkp_ignore_checksums: Ignore checksums.
  • isc_spb_bkp_ignore_limbo: Ignore limbo transactions.
  • isc_spb_bkp_metadata_only: Output backup for metadata only (with empty tables).
  • isc_spb_bkp_no_garbage_collect: Supress garbage collection during backup.
  • isc_spb_bkp_non_transportable: Output backup file format with non-XDR data format (improves space and performance).
  • isc_spb_bkp_convert: Convert external table data to internal tables.
  • isc_spb_bkp_expand: FIXME.

self : A FFService.
db_file : A string containing full path and name of database file to backup.
bkp_file : A string containing full path and name of database backup file.
options : Bitmask of backup options.
Returns : TRUE if a backup was made, or FALSE otherwise.

ff_service_restore_backup ()

gboolean    ff_service_restore_backup       (FFService *self,
                                             const gchar *bkp_file,
                                             const gchar *db_file,
                                             gulong options);

Restore a Firebird backup file.

Restore options:

  • isc_spb_res_replace: Replace database (if one exists).
  • isc_spb_res_create: Restore but do not overwrite an existing database.
  • isc_spb_res_deactivate_idx: Do not build user indexes.
  • isc_spb_res_no_shadow: Do not recreate shadow files.
  • isc_spb_res_no_validity: Do not enforce validity conditions.
  • isc_spb_res_one_at_a_time: Commit after completing restore of each table.
  • isc_spb_res_use_all_space: Do not reserver 20% of each data page for future use.

self : A FFService.
bkp_file : A string containing full path and name of database backup file.
db_file : A string containing full path and name of database file to restore.
options : Bitmask of restore options.
Returns : TRUE if a backup was restored, or FALSE otherwise.