![]() | ![]() | ![]() | Libmergeant Reference Manual | ![]() |
---|
MgServerMgServer — Manages the connection to a database server. |
MgServer; enum MgServerQueryType; guint mg_server_get_type (void); GObject* mg_server_new (MgConf *conf); gboolean mg_server_set_datasource (MgServer *srv, const gchar *datasource); gchar* mg_server_get_datasource (MgServer *srv); gboolean mg_server_set_user_name (MgServer *srv, const gchar *username); gchar* mg_server_get_user_name (MgServer *srv); gboolean mg_server_set_user_password (MgServer *srv, const gchar *password); void mg_server_reset (MgServer *srv); GdaConnection* mg_server_get_gda_connection (MgServer *srv); gboolean mg_server_open_connect (MgServer *srv, GError **error); gboolean mg_server_conn_is_opened (MgServer *srv); void mg_server_close_connect (MgServer *srv); void mg_server_close_connect_no_warn (MgServer *srv); MgConf* mg_server_get_conf (MgServer *srv); MgServerOpMode mg_server_get_sql_op_mode (MgServer *srv, const gchar *query); MgResultSet* mg_server_do_query (MgServer *srv, const gchar *query, MgServerQueryType type, GError **error); gboolean mg_server_update_dbms_data (MgServer *srv, GError **error); void mg_server_stop_update_dbms_data (MgServer *srv); MgDataHandler* mg_server_get_handler_by_name (MgServer *srv, const gchar *name); MgDataHandler* mg_server_get_handler_by_type (MgServer *srv, MgServerDataType *type); MgDataHandler* mg_server_get_handler_by_gda (MgServer *srv, GdaValueType gda_type); GSList* mg_server_get_plugin_handlers (MgServer *srv); MgUser* mg_server_get_user_by_name (MgServer *srv, const gchar *username); GSList* mg_server_get_data_types (MgServer *srv); MgServerDataType* mg_server_get_data_type_by_name (MgServer *srv, const gchar *typename); MgServerDataType* mg_server_get_data_type_by_xml_id (MgServer *srv, const gchar *xml_id); GSList* mg_server_get_functions (MgServer *srv); GSList* mg_server_get_functions_by_name (MgServer *srv, const gchar *funcname); MgServerFunction* mg_server_get_function_by_name_arg (MgServer *srv, const gchar *funcname, const GSList *argtypes); MgServerFunction* mg_server_get_function_by_dbms_id (MgServer *srv, const gchar *dbms_id); MgServerFunction* mg_server_get_function_by_xml_id (MgServer *srv, const gchar *xml_id); GSList* mg_server_get_aggregates (MgServer *srv); GSList* mg_server_get_aggregates_by_name (MgServer *srv, const gchar *aggname); MgServerAggregate* mg_server_get_aggregate_by_name_arg (MgServer *srv, const gchar *aggname, MgServerDataType *argtype); MgServerAggregate* mg_server_get_aggregate_by_dbms_id (MgServer *srv, const gchar *dbms_id); MgServerAggregate* mg_server_get_aggregate_by_xml_id (MgServer *srv, const gchar *xml_id); MgDataHandler* mg_server_get_object_handler (MgServer *srv, GObject *object); void mg_server_set_object_handler (MgServer *srv, GObject *object, MgDataHandler *handler); void mg_server_unset_object_handler (MgServer *srv, GObject *object); gboolean mg_server_object_has_handler (MgServer *srv, GObject *object); void mg_server_set_object_func_handler (MgServer *srv, MgDataHandler* (*func) (MgServer *, GObject *)); gchar* mg_server_stringify_value (MgServer *srv, const GdaValue *value); gchar* mg_server_escape_chars (MgServer *srv, const gchar *string); GdaDataModel* mg_server_get_gda_schema (MgServer *srv, GdaConnectionSchema schema, GdaParameterList *params); void mg_server_dump (MgServer *srv, gint offset);
"conn-closed" void user_function (MgServer *mgserver, gpointer user_data); "conn-opened" void user_function (MgServer *mgserver, gpointer user_data); "conn-to-close" void user_function (MgServer *mgserver, gpointer user_data); "data-aggregate-added" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-aggregate-removed" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-aggregate-updated" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-function-added" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-function-removed" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-function-updated" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-type-added" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-type-removed" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-type-updated" void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data); "data-update-finished" void user_function (MgServer *mgserver, gpointer user_data); "data-update-started" void user_function (MgServer *mgserver, gpointer user_data); "object-handler-updated" void user_function (MgServer *mgserver, gpointer user_data); "update-progress" void user_function (MgServer *mgserver, gpointer arg1, guint arg2, guint arg3, gpointer user_data);
This object is the "access point" to the DBMS. It manages lists of the DBMS's attributes (such as the available data types, function, ...) and is responsible for opening and closing the connection to the DBMS. Also any query sent to the DBMS is done through this object.
This object is also responsible for the conversion of data types (data types defined within the database and data types known to the Libgda library), and for providing the MgDataHandler objects to manipulate data of each data type.
It implements the MgXmlStorage interface.
typedef enum { MG_SERVER_QUERY_SQL, MG_SERVER_QUERY_XML } MgServerQueryType;
Used to specify which type of query is sent to the DBMS. See the libgda documentation about what XML queries are.
GObject* mg_server_new (MgConf *conf);
Creates a new MgServer object
conf : | a MgConf object |
Returns : | the new object |
gboolean mg_server_set_datasource (MgServer *srv, const gchar *datasource);
Sets the data source of the server. If the connection is already opened, then no action is performed at all and FALSE is returned.
srv : | a MgServer object |
datasource : | a gda datasource |
Returns : | TRUE on success |
gchar* mg_server_get_datasource (MgServer *srv);
Get the data source of the server.
srv : | a MgServer object |
Returns : | a new string with the datasource, or NULL |
gboolean mg_server_set_user_name (MgServer *srv, const gchar *username);
Sets the user name for the connection to the server. If the connection is already opened, then no action is performed at all and FALSE is returned.
srv : | a MgServer object |
username : | |
Returns : | TRUE on success |
gchar* mg_server_get_user_name (MgServer *srv);
Get the user name for the connection to the server.
srv : | a MgServer object |
Returns : | a new string with the user name, or NULL |
gboolean mg_server_set_user_password (MgServer *srv, const gchar *password);
Sets the user password for the connection to the server. If the connection is already opened, then no action is performed at all and FALSE is returned.
srv : | a MgServer object |
password : | |
Returns : | TRUE on success |
void mg_server_reset (MgServer *srv);
Reset the MgServer as it was when created; that is: close the connection if opened, and get rid of any data type, function and aggregate it has.
srv : | a MgServer object |
GdaConnection* mg_server_get_gda_connection (MgServer *srv);
Get the GdaConnection object used by srv
, if the connection
is opened.
srv : | a MgServer object |
Returns : | the GdaConnection, or NULL
|
gboolean mg_server_open_connect (MgServer *srv, GError **error);
Opens the connection to the DBMS.
srv : | a MgServer object |
error : | location to store error, or NULL
|
Returns : | TRUE if success and FALSE otherwise (and error is positionned) |
gboolean mg_server_conn_is_opened (MgServer *srv);
Checks wether the connection to the DBMS is opened or not
srv : | a MgServer object |
Returns : | TRUE if the connection is opened |
void mg_server_close_connect (MgServer *srv);
Closes the connection to the DBMS. First the "conn_to_close" signal is emitted.
This function should preferably be called instead of the mg_server_close_connect_no_warn()
function.
srv : | a MgServer object |
void mg_server_close_connect_no_warn (MgServer *srv);
Closes the connection to the DBMS. Warning: "conn_to_close" signal is NOT emitted.
srv : | a MgServer object |
MgConf* mg_server_get_conf (MgServer *srv);
Fetch the MgConf object to which the MgServer belongs.
srv : | a MgServer object |
Returns : | the MgConf object |
MgServerOpMode mg_server_get_sql_op_mode (MgServer *srv, const gchar *query);
Get the operation type (= mode) which is performed by the query given as argument. The query MUST contain only one statement, not several separated by ';'
srv : | a MgServer object |
query : | an SQL query |
Returns : | the query type (mode). |
MgResultSet* mg_server_do_query (MgServer *srv, const gchar *query, MgServerQueryType type, GError **error);
Sends a query to the DBMS to which the connection is established. If the query is a SELECT one, then a new MgResultSet is returned (it's up to the caller to unref that object); otherwise NULL is returned. The error variable contains the error code if an error occurred.
srv : | a MgServer object |
query : | the query to be executed |
type : | the query type (SQL or XML) |
error : | location to store error, or NULL
|
Returns : | a new MgResultSet object or NULL |
gboolean mg_server_update_dbms_data (MgServer *srv, GError **error);
Synchronise the list of data types, functions, etc the MgServer object has with what is in the DBMS the connection is opened to. The connection to the DBMS MUST be opened.
srv : | a MgServer object |
error : | location to store error, or NULL
|
Returns : | TRUE if no error |
void mg_server_stop_update_dbms_data (MgServer *srv);
When the server updates its internal lists of DBMS objects, a call to this function will stop that update process. It has no effect when the server is not updating its DBMS data.
srv : | a MgServer object |
MgDataHandler* mg_server_get_handler_by_name (MgServer *srv, const gchar *name);
Get the MgDataHandler from its name.
srv : | a MgServer object |
name : | |
Returns : | the MgDataHandler object |
MgDataHandler* mg_server_get_handler_by_type (MgServer *srv, MgServerDataType *type);
Get the MgDataHandler for a data type
srv : | a MgServer object |
type : | |
Returns : | the MgDataHandler object |
MgDataHandler* mg_server_get_handler_by_gda (MgServer *srv, GdaValueType gda_type);
Get the MgDataHandler for a gda type: the first DataHandler which can handle the requested type is returned. If no good handler can be found, then a default one will be provided. This function never returns NULL.
srv : | a MgServer object |
gda_type : | |
Returns : | the MgDataHandler object |
GSList* mg_server_get_plugin_handlers (MgServer *srv);
Get a list of all the MgDataHandler plugins used by the MgServer.
srv : | a MgServer object |
Returns : | an allocated list of plugins |
MgUser* mg_server_get_user_by_name (MgServer *srv, const gchar *username);
Find a MgUser from its name.
srv : | a MgServer object |
username : | |
Returns : | a pointer to the requested object, or NULL if the object cannot be found. |
GSList* mg_server_get_data_types (MgServer *srv);
Get the list of data types;
srv : | a MgServer object |
Returns : | the list (the caller must free the list after usage) |
MgServerDataType* mg_server_get_data_type_by_name (MgServer *srv, const gchar *typename);
Find a data type from its DBMS name
srv : | a MgServer object |
typename : | |
Returns : | the data type or NULL if it cannot be found
|
MgServerDataType* mg_server_get_data_type_by_xml_id (MgServer *srv, const gchar *xml_id);
To find a MgServerDataType using its XML id.
srv : | a MgServer object |
xml_id : | the XML identifier of the data type to be found |
Returns : | the data type or NULL if it cannot be found
|
GSList* mg_server_get_functions (MgServer *srv);
To get the complete list of functions
srv : | a MgServer object |
Returns : | the allocated list of functions |
GSList* mg_server_get_functions_by_name (MgServer *srv, const gchar *funcname);
To get the list of DBMS functions which match the given name.
srv : | a MgServer object |
funcname : | name of the function |
Returns : | the allocated list of functions |
MgServerFunction* mg_server_get_function_by_name_arg (MgServer *srv, const gchar *funcname, const GSList *argtypes);
To find a DBMS functions which is uniquely identified by its name and the type(s) of its argument(s).
srv : | a MgServer object |
funcname : | name of the function |
argtypes : | a list of MgServerDataType objects |
Returns : | The function or NULL if not found |
MgServerFunction* mg_server_get_function_by_dbms_id (MgServer *srv, const gchar *dbms_id);
To find a DBMS functions which is uniquely identified by its DBMS identifier
srv : | a MgServer object |
dbms_id : | |
Returns : | The function or NULL if not found |
MgServerFunction* mg_server_get_function_by_xml_id (MgServer *srv, const gchar *xml_id);
To find a DBMS functions which is uniquely identified by its XML identifier
srv : | a MgServer object |
xml_id : | |
Returns : | The function or NULL if not found |
GSList* mg_server_get_aggregates (MgServer *srv);
To get the complete list of aggregates
srv : | a MgServer object |
Returns : | the allocated list of aggregates |
GSList* mg_server_get_aggregates_by_name (MgServer *srv, const gchar *aggname);
To get the list of DBMS aggregates which match the given name.
srv : | a MgServer object |
aggname : | the name of the aggregate |
Returns : | the allocated list of aggregates |
MgServerAggregate* mg_server_get_aggregate_by_name_arg (MgServer *srv, const gchar *aggname, MgServerDataType *argtype);
To find a DBMS functions which is uniquely identified by its name and the type of its argument.
srv : | a MgServer object |
aggname : | the name of the aggregate |
argtype : | the type of argument or NULL
|
Returns : | The aggregate or NULL if not found |
MgServerAggregate* mg_server_get_aggregate_by_dbms_id (MgServer *srv, const gchar *dbms_id);
To find a DBMS functions which is uniquely identified by its name and the type of its argument.
srv : | a MgServer object |
dbms_id : | |
Returns : | The aggregate or NULL if not found |
MgServerAggregate* mg_server_get_aggregate_by_xml_id (MgServer *srv, const gchar *xml_id);
To find a DBMS aggregates which is uniquely identified by its XML identifier
srv : | a MgServer object |
xml_id : | |
Returns : | The aggregate or NULL if not found |
MgDataHandler* mg_server_get_object_handler (MgServer *srv, GObject *object);
Get the right MgDataHandler object reference to manage data which is "linked" to the object. The object will usually be a MgServerDataType, a MgServerFunction, or a MgServerAggregate.
The returned MgDataHandler depends on the loaded plugins and on the user preferences regarding how these plugins are to be used. If the user has not set any preference for the object, then some default rules are used: <ul> <li> for MgServerDataType, the MgDataHandler corresponding to the gda type of the MgServerDataType is returned</li></ul> -> for MgServerFunction, the MgDataHandler corresponding to the MgServerDataType returned by the function is returned -> ...
void mg_server_set_object_handler (MgServer *srv, GObject *object, MgDataHandler *handler);
This function is the opposite of the mg_server_get_object_handler()
function:
it "attaches" a MgDataHandler object to any given object, and a subsequent call
to mg_server_get_object_handler(object) will return the MgDataHandler object.
void mg_server_unset_object_handler (MgServer *srv, GObject *object);
Shortcut to mg_server_set_object_handler()
with NULL as "handler" argument.
gboolean mg_server_object_has_handler (MgServer *srv, GObject *object);
Tells if a MgDataHandler object has been assigned to the object given as argument, or
if the MgDataHandler which would be returned by the mg_server_get_object_handler()
function is a default one.
void mg_server_set_object_func_handler (MgServer *srv, MgDataHandler* (*func) (MgServer *, GObject *));
This function provides a way for the MgServer function to apply rules to find an appropriate MgDataHandler for an object.
srv : | a MgServer object |
func : | a function |
gchar* mg_server_stringify_value (MgServer *srv, const GdaValue *value);
Renders a value as a string, and ensures the string is UTF-8 encoded.
srv : | a MgServer object |
value : | a value to be stringified |
Returns : | the new string |
gchar* mg_server_escape_chars (MgServer *srv, const gchar *string);
Escapes the special caracters from a string. The new string can then safely be sent to the DBMS.
srv : | a MgServer object |
string : | |
Returns : | the escaped string |
GdaDataModel* mg_server_get_gda_schema (MgServer *srv, GdaConnectionSchema schema, GdaParameterList *params);
Get a direct access to the libgda's function call to get a DBMS schema. It should not directely be used since libmergeant hides any necessary call to it.
srv : | a MgServer object |
schema : | the requested schema |
params : | some parameters for the requested schema, or NULL |
Returns : | the data model, or NULL if an error occurred |
void user_function (MgServer *mgserver, gpointer user_data);
mgserver : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer user_data);
mgserver : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer user_data);
mgserver : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer arg1, gpointer user_data);
mgserver : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer user_data);
mgserver : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer user_data);
mgserver : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
void user_function (MgServer *mgserver, gpointer user_data);
mgserver : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
<< MgConf | MgResultSet >> |