| Midgard 2.0 Reference Manual | ||||
|---|---|---|---|---|
#define GETTEXT_PACKAGE typedef MidgardConnectionClass; MidgardConnectionPrivate; MidgardConnectionCache; typedef midgard_connection; MidgardConnection* midgard_connection_new (void); gboolean midgard_connection_open (MidgardConnection *self, const char *name, GError **error); gboolean midgard_connection_open_config (MidgardConnection *self, MidgardConfig *config); void midgard_connection_close (MidgardConnection *self); gboolean midgard_connection_set_sitegroup (MidgardConnection *self, const gchar *name); const gchar* midgard_connection_get_sitegroup (MidgardConnection *self); gboolean midgard_connection_set_lang (MidgardConnection *self, const char *language); gboolean midgard_connection_set_default_lang (MidgardConnection *self, const gchar *language); const gchar* midgard_connection_get_lang (MidgardConnection *self); const gchar* midgard_connection_get_default_lang (MidgardConnection *self); gboolean midgard_connection_set_loglevel (MidgardConnection *self, const gchar *level, GLogFunc log_func); guint midgard_connection_get_loglevel (MidgardConnection *self); void midgard_connection_set_loghandler (MidgardConnection *self, guint loghandler); guint midgard_connection_get_loghandler (MidgardConnection *self); const gchar* midgard_connection_get_sitegroup_from_id (MidgardConnection *self, guint id); guint midgard_connection_get_sitegroup_id (MidgardConnection *self); const gchar* midgard_connection_get_lang_from_id (MidgardConnection *self, guint id); guint midgard_connection_get_lang_id (MidgardConnection *self, const gchar *language); gint midgard_connection_get_error (MidgardConnection *self); const gchar* midgard_connection_get_error_string (MidgardConnection *self); MidgardUser* midgard_connection_get_user (MidgardConnection *self); MidgardConnection* midgard_connection_struct_new (void); MidgardConnection* midgard_connection_struct2gobject (MidgardConnection *conn); gboolean midgard_connection_struct_open_config (MidgardConnection *mgd, MidgardConfig *config); void midgard_connection_workaround_set (MidgardConnection *mgd); MidgardConnection* midgard_connection_workaround_get (void); void midgard_connection_struct_free (MidgardConnection *self);
"errnum" gint : Read "errstr" gchar* : Read "person" midgard_object* : Read "request-config" GObject* : Read "user" midgard_user* : Read
"auth-changed" : Run Last / No Recursion / No Hooks "error" : Run Last / No Recursion / No Hooks "lang-changed" : Run Last / No Recursion / No Hooks "sitegroup-changed" : Run Last / No Recursion / No Hooks
MidgardConnection* midgard_connection_new (void);
Initializes new instance of MidgardConnection object type.
MidgardConnectionClass has no properties registered as class members. Every internal data of MidgardConnection object is accessible with API functions, and is not settable or gettable as property's value. Particular methods should be implemented for language bindings.
MidgardConnection objects holds runtime ( or request ) non persistent data like language, sitegroup, authentication type.
Persistent data like database name, blobs directory are associated with MidgardConfig object.
Returns : |
pointer to MidgardConnection object or NULL on failure.
|
gboolean midgard_connection_open (MidgardConnection *self,
const char *name,
GError **error);
Opens a connection to the database defined in named configuration. The configuration file is read from the standard configuration directories and used as the configuration for the created connection.
If the named database configuration can not be read or the connection fails,
then FALSE is returned and an error message is written to the global midgard
error state.
|
|
|
configuration file name |
|
pointer to store error |
Returns : |
TRUE if the operation succeeded, FALSE otherwise.
|
gboolean midgard_connection_open_config (MidgardConnection *self,
MidgardConfig *config);
Opens a MidgardConnection with the given configuration.
|
[in]newly initialized MidgardConnection object |
|
MidgardConfig object |
Returns : |
TRUE on success, FALSE otherwise
|
void midgard_connection_close (MidgardConnection *self);
Closes database connection.
This function closes database connection , destroys MidgardConnection object and frees its memory. It may be replaced by g_object_unref, with one exception.
When MidgardConnection object is initialized with midgard_connection_open function then MidgardConfig object is also destroyed and its memory is freed.
Caller is responsible to free MidgardConfig object when is used with MidgardConnection and connection object was initialized with midgard_connection_open_config function.
|
MidgardConnection object |
gboolean midgard_connection_set_sitegroup (MidgardConnection *self,
const gchar *name);
Sets sitegroup's value for the given MidgardConnection.
Given sitegroup's name must be the value of exisiting in database
sitegroup's record. When there is no sitegroup with such name or
sitegroup is private , then connection's sitegroup is unchanged
and method return FALSE.
See also: midgard_sitegroup_list if you need to get list of available sitegroup names.
Emits: "sitegroup_changed"
|
MidgardConnection instance |
|
name of the sitegroup to switch |
Returns : |
TRUE on success, FALSE otherwise
|
const gchar* midgard_connection_get_sitegroup (MidgardConnection *self);
Returns name of a sitegroup which is currently used for a connection.
Read more about Midgard sitegroups concept
|
MidgardConnection instance |
Returns : |
sitegroup's name, or NULL if no sitegroup is set ( default SG0 ) |
gboolean midgard_connection_set_lang (MidgardConnection *self,
const char *language);
Sets the language of the given Midgard connection. The connection language affects all MultiLang database accesses as described in the Midgard MultiLang documentation.
The given language parameter is the two-letter language code
stored in the language table in the Midgard database.
This method returns FALSE if the given language is not found.
Read more about Multilingual content
See also: midgard_connection_set_default_lang
Emits: "lang-changed"
|
MidgardConnection instance |
|
the new language code |
Returns : |
TRUE if the connection language has been changed, FALSE otherwise
|
gboolean midgard_connection_set_default_lang (MidgardConnection *self,
const gchar *language);
Sets default language of the given MidgardConnection.
This function behaves almost the same as midgard_connection_set_lang. The only difference is that default language is used as fallback language.
|
MidgardConnection |
|
the new language code |
Returns : |
TRUE if the connection language has been changed, FALSE otherwise
|
const gchar* midgard_connection_get_lang (MidgardConnection *self);
Returned language string is the two-letter language code. See also: midgard_connection_get_default_lang
|
MidgardConnection instance |
Returns : |
language code of the given MidgardConnection or NULL if no language is set.
|
const gchar* midgard_connection_get_default_lang (MidgardConnection *self);
\return
Returned language string is the two-letter language code.
See also: midgard_connection_get_lang
|
MidgardConnection for which language is returned. |
Returns : |
language's code string or NULL if there's no default language set for MidgardConnection. |
gboolean midgard_connection_set_loglevel (MidgardConnection *self,
const gchar *level,
GLogFunc log_func);
Sets log level of the given MidgardConnection. Overwrites internal MidgardConnection's log level defined in configuration file. By default MidgardConnection holds loglevel which is associated with ( and duplicated from ) MidgardConfig. MidgardConfig object's log level isn't changed by this function
This method is a shortcut which sets correctly loghandler,loglevel
and GLib's log function. Default log function will be used if NULL
is defined. Core's default function is midgard_error_default_log.
Available levels: error, warn, warning, info, message, debug. warn is default loglevel, SQL queries are logged with debug level. With info level, function names ( and classes' names ) are ( at least should be) logged in language bindings
|
MidgardConnection instance |
|
Loglevel string |
|
log handler function |
Returns : |
TRUE if debug level is set, FALSE otherwise
|
guint midgard_connection_get_loglevel (MidgardConnection *self);
|
MidgardConnection instance |
Returns : |
unsigned integer flag specified by GLogLevelFlags. |
void midgard_connection_set_loghandler (MidgardConnection *self,
guint loghandler);
Sets internal loghandler id associated with G_LOG_DOMAIN and loglevel. Caller is responsible to remove loghandler using g_log_remove_handler when new loglevel for G_LOG_DOMAIN is set.
See also: midgard_connection_set_loglevel
|
MidgardConnection instance |
|
loghandler id |
guint midgard_connection_get_loghandler (MidgardConnection *self);
|
MidgardConnection instance |
Returns : |
unsigned integer value which is associated with G_LOG_DOMAIN and MidgardConnection's loglevel currently set. |
const gchar* midgard_connection_get_sitegroup_from_id
(MidgardConnection *self,
guint id);
This method returns name for the sitegroup which is identified
by given id. You should use this method only ( and only ) when you
need ( for example ) set connection's sitegroup using sitegroup's
id set to an object.
This is transition helper method.
|
MidgardConnection instance |
|
sitegroup's id |
Returns : |
sitegroup name or NULL if there's no sitegroup with given id.
|
guint midgard_connection_get_sitegroup_id (MidgardConnection *self);
|
MidgardConnection instance |
Returns : |
id unsigned integer which identifies sitegroup for the given MidgardConnection. |
const gchar* midgard_connection_get_lang_from_id (MidgardConnection *self,
guint id);
This is transition helper method.
|
MidgardConnection instance |
|
language's id |
Returns : |
code for the language which is identified by given id or NULL.
|
guint midgard_connection_get_lang_id (MidgardConnection *self,
const gchar *language);
Returned id is an integer which identifies language for the given MidgardConnection. If language parameter is different than NULL, internal lookup is made to find matching language id.
|
MidgardConnection instance |
|
optional two letter language code |
Returns : |
language id |
gint midgard_connection_get_error (MidgardConnection *self);
Error id may be one of set by midgard_error.
|
MidgardConnection instance |
Returns : |
Last error id set |
const gchar* midgard_connection_get_error_string (MidgardConnection *self);
Error string may be one set by midgard_error.
|
MidgardConnection instance |
Returns : |
last error string |
MidgardUser* midgard_connection_get_user (MidgardConnection *self);
NULL is explicitly returned if there's no midgard_user logged in for the given MidgardConnection. See also MidgardUser methods if you need midgard_person associated with user.
|
MidgardConnection instance |
Returns : |
A pointer to MidgardUser instance or NULL
|
MidgardConnection* midgard_connection_struct2gobject (MidgardConnection *conn);
|
|
Returns : |
gboolean midgard_connection_struct_open_config
(MidgardConnection *mgd,
MidgardConfig *config);
|
|
|
|
Returns : |
void midgard_connection_workaround_set (MidgardConnection *mgd);
|
MidgardConnection* midgard_connection_workaround_get (void);
Returns : |
"errnum" property"errnum" gint : Read
Error code which is currently set.
Allowed values: >= 0
Default value: 0
"request-config" property"request-config" GObject* : Read
midgard_request_config object which is valid during connection.
"auth-changed" signalvoid user_function (midgard_connection *midgard_connection, gpointer user_data) : Run Last / No Recursion / No Hooks
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"error" signalvoid user_function (midgard_connection *midgard_connection, gpointer user_data) : Run Last / No Recursion / No Hooks
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"lang-changed" signalvoid user_function (midgard_connection *midgard_connection, gpointer user_data) : Run Last / No Recursion / No Hooks
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"sitegroup-changed" signalvoid user_function (midgard_connection *midgard_connection, gpointer user_data) : Run Last / No Recursion / No Hooks
|
the object which received the signal. |
|
user data set when the signal handler was connected. |