2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = libgda-GdaClient.html
43 * - gda_client_open_connection
47 * - GdaConnection* -> Connection
58 import tango
.io
.Stdout
; // use the tango loging?
62 private import gdac
.gdatypes
;
64 private import gdac
.gda
;
67 private import gda
.Connection
;
74 * This class is the main entry point for libgda client applications. It provides
75 * the way by which client applications open connections. Thus, before using any other
76 * database-oriented function in libgda, applications must create a GdaClient object
77 * (via gda_client_new), and, once created, open the connections from it.
78 * GdaClient also provides a way to treat several connections as if they were only
79 * one (a connection pool), which allows applications to, for instance, commit/rollback
80 * a transaction in all the connections being managed by a unique GdaClient object, or
81 * obtain the list of all tables in all opened connections.
86 /** the main Gtk struct */
87 protected GdaClient
* gdaClient
;
90 public GdaClient
* getClientStruct()
96 /** the main Gtk struct as a void* */
97 protected void* getStruct()
99 return cast(void*)gdaClient
;
103 * Sets our main struct and passes it to the parent class
105 public this (GdaClient
* gdaClient
)
109 if ( gdaClient
is null )
114 Stdout("struct gdaClient is null on constructor").newline
;
118 printf("struct gdaClient is null on constructor");
125 assert(gdaClient
!is null, "struct gdaClient is null on constructor");
127 this.gdaClient
= gdaClient
;
131 * Establishes a connection to a data source. The connection will be opened
132 * if no identical connection is available in the GdaClient connection pool,
133 * and re-used if available. If you dont want to share the connection,
134 * specify GDA_CONNECTION_OPTIONS_DONT_SHARE as one of the flags in
135 * the options parameter.
136 * This function is the way of opening database connections with libgda.
138 * a GdaClient object.
144 * password for username.
146 * options for the connection (see GdaConnectionOptions).
148 * the opened connection if successful, NULL if there is
151 public Connection
openConnection(char[] dsn
, char[] username
, char[] password
, GdaConnectionOptions options
)
153 // GdaConnection* gda_client_open_connection (GdaClient *client, const gchar *dsn, const gchar *username, const gchar *password, GdaConnectionOptions options);
154 GdaConnection
* connection
= gda_client_open_connection(gdaClient
, Str
.toStringz(dsn
), Str
.toStringz(username
), Str
.toStringz(password
), options
);
155 return connection ?
new Connection( connection
) : null;
164 * Creates a new GdaClient object, which is the entry point for libgda
165 * client applications. This object, once created, can be used for
166 * opening new database connections and activating other services
167 * available to GDA clients.
169 * the newly created object.
173 // GdaClient* gda_client_new (void);
174 this(cast(GdaClient
*)gda_client_new() );
179 * Opens a connection given a provider ID and a connection string. This
180 * allows applications to open connections without having to create
181 * a data source in the configuration. The format of cnc_string is
182 * similar to PostgreSQL and MySQL connection strings. It is a ;-separated
183 * series of key=value pairs. Do not add extra whitespace after the ;
184 * separator. The possible keys depend on the provider, but
185 * these keys should work with all providers:
186 * USER, PASSWORD, HOST, DATABASE, PORT
188 * a GdaClient object.
190 * provider ID to connect to.
194 * options for the connection (see GdaConnectionOptions).
196 * the opened connection if successful, NULL if there is
199 public Connection
openConnectionFromString(char[] providerId
, char[] cncString
, GdaConnectionOptions options
)
201 // GdaConnection* gda_client_open_connection_from_string (GdaClient *client, const gchar *provider_id, const gchar *cnc_string, GdaConnectionOptions options);
202 return new Connection( gda_client_open_connection_from_string(gdaClient
, Str
.toStringz(providerId
), Str
.toStringz(cncString
), options
) );
206 * Gets the list of all open connections in the given GdaClient object.
207 * The GList returned is an internal pointer, so DON'T TRY TO
210 * a GdaClient object.
212 * a GList of GdaConnection objects.
214 public GList
* getConnectionList()
216 // const GList* gda_client_get_connection_list (GdaClient *client);
217 return gda_client_get_connection_list(gdaClient
);
221 * Looks for an open connection given a data source name (per libgda
222 * configuration), a username and a password.
223 * This function iterates over the list of open connections in the
224 * given GdaClient and looks for one that matches the given data source
225 * name, username and password.
227 * a GdaClient object.
233 * password for username.
235 * a pointer to the found connection, or NULL if it could not
238 public Connection
findConnection(char[] dsn
, char[] username
, char[] password
)
240 // GdaConnection* gda_client_find_connection (GdaClient *client, const gchar *dsn, const gchar *username, const gchar *password);
241 return new Connection( gda_client_find_connection(gdaClient
, Str
.toStringz(dsn
), Str
.toStringz(username
), Str
.toStringz(password
)) );
245 * Closes all connections opened by the given GdaClient object.
247 * a GdaClient object.
249 public void closeAllConnections()
251 // void gda_client_close_all_connections (GdaClient *client);
252 gda_client_close_all_connections(gdaClient
);
256 * Notifies an event to the given GdaClient's listeners. The event can be
257 * anything (see GdaClientEvent) ranging from a connection opening
258 * operation, to changes made to a table in an underlying database.
260 * a GdaClient object.
262 * a GdaConnection object where the event has occurred.
266 * parameters associated with the event.
268 public void notifyEvent(Connection cnc
, GdaClientEvent event
, GdaParameterList
* params
)
270 // void gda_client_notify_event (GdaClient *client, GdaConnection *cnc, GdaClientEvent event, GdaParameterList *params);
271 gda_client_notify_event(gdaClient
, (cnc
is null) ?
null : cnc
.getConnectionStruct(), event
, params
);
275 * Notifies the given GdaClient of the GDA_CLIENT_EVENT_ERROR event.
277 * a GdaClient object.
279 * a GdaConnection object.
281 * the error to be notified.
283 public void notifyErrorEvent(Connection cnc
, GdaError
* error
)
285 // void gda_client_notify_error_event (GdaClient *client, GdaConnection *cnc, GdaError *error);
286 gda_client_notify_error_event(gdaClient
, (cnc
is null) ?
null : cnc
.getConnectionStruct(), error
);
290 * Notifies the given GdaClient of the GDA_CLIENT_EVENT_CONNECTION_OPENED
293 * a GdaClient object.
295 * a GdaConnection object.
297 public void notifyConnectionOpenedEvent(Connection cnc
)
299 // void gda_client_notify_connection_opened_event (GdaClient *client, GdaConnection *cnc);
300 gda_client_notify_connection_opened_event(gdaClient
, (cnc
is null) ?
null : cnc
.getConnectionStruct());
304 * Notifies the given GdaClient of the GDA_CLIENT_EVENT_CONNECTION_CLOSED
307 * a GdaClient object.
309 * a GdaConnection object.
311 public void notifyConnectionClosedEvent(Connection cnc
)
313 // void gda_client_notify_connection_closed_event (GdaClient *client, GdaConnection *cnc);
314 gda_client_notify_connection_closed_event(gdaClient
, (cnc
is null) ?
null : cnc
.getConnectionStruct());
318 * Notifies the given GdaClient of the GDA_CLIENT_EVENT_TRANSACTION_STARTED
321 * a GdaClient object.
323 * a GdaConnection object.
325 * a GdaTransaction object.
327 public void notifyTransactionStartedEvent(Connection cnc
, GdaTransaction
* xaction
)
329 // void gda_client_notify_transaction_started_event (GdaClient *client, GdaConnection *cnc, GdaTransaction *xaction);
330 gda_client_notify_transaction_started_event(gdaClient
, (cnc
is null) ?
null : cnc
.getConnectionStruct(), xaction
);
334 * Notifies the given GdaClient of the GDA_CLIENT_EVENT_TRANSACTION_COMMITTED
337 * a GdaClient object.
339 * a GdaConnection object.
341 * a GdaTransaction object.
343 public void notifyTransactionCommittedEvent(Connection cnc
, GdaTransaction
* xaction
)
345 // void gda_client_notify_transaction_committed_event (GdaClient *client, GdaConnection *cnc, GdaTransaction *xaction);
346 gda_client_notify_transaction_committed_event(gdaClient
, (cnc
is null) ?
null : cnc
.getConnectionStruct(), xaction
);
350 * Notifies the given GdaClient of the GDA_CLIENT_EVENT_TRANSACTION_CANCELLED
353 * a GdaClient object.
355 * a GdaConnection object.
357 * a GdaTransaction object.
359 public void notifyTransactionCancelledEvent(Connection cnc
, GdaTransaction
* xaction
)
361 // void gda_client_notify_transaction_cancelled_event (GdaClient *client, GdaConnection *cnc, GdaTransaction *xaction);
362 gda_client_notify_transaction_cancelled_event(gdaClient
, (cnc
is null) ?
null : cnc
.getConnectionStruct(), xaction
);
366 * Starts a transaction on all connections being managed by the given
367 * GdaClient. It is important to note that this operates on all
368 * connections opened within a GdaClient, which could not be what
369 * you're looking for.
370 * To execute a transaction on a unique connection, use
371 * gda_connection_begin_transaction, gda_connection_commit_transaction
372 * and gda_connection_rollback_transaction.
374 * a GdaClient object.
376 * a GdaTransaction object.
378 * TRUE if all transactions could be started successfully,
379 * or FALSE if one of them fails.
381 public int beginTransaction(GdaTransaction
* xaction
)
383 // gboolean gda_client_begin_transaction (GdaClient *client, GdaTransaction *xaction);
384 return gda_client_begin_transaction(gdaClient
, xaction
);
388 * Commits a running transaction on all connections being managed by the given
389 * GdaClient. It is important to note that this operates on all
390 * connections opened within a GdaClient, which could not be what
391 * you're looking for.
392 * To execute a transaction on a unique connection, use
393 * gda_connection_begin_transaction, gda_connection_commit_transaction
394 * and gda_connection_rollback_transaction.
396 * a GdaClient object.
398 * a GdaTransaction object.
400 * TRUE if all transactions could be committed successfully,
401 * or FALSE if one of them fails.
403 public int commitTransaction(GdaTransaction
* xaction
)
405 // gboolean gda_client_commit_transaction (GdaClient *client, GdaTransaction *xaction);
406 return gda_client_commit_transaction(gdaClient
, xaction
);
410 * Cancels a running transaction on all connections being managed by the given
411 * GdaClient. It is important to note that this operates on all
412 * connections opened within a GdaClient, which could not be what
413 * you're looking for.
414 * To execute a transaction on a unique connection, use
415 * gda_connection_begin_transaction, gda_connection_commit_transaction
416 * and gda_connection_rollback_transaction.
418 * a GdaClient object.
420 * a GdaTransaction object.
422 * TRUE if all transactions could be cancelled successfully,
423 * or FALSE if one of them fails.
427 public int rollbackTransaction(GdaTransaction
* xaction
)
429 // gboolean gda_client_rollback_transaction (GdaClient *client, GdaTransaction *xaction);
430 return gda_client_rollback_transaction(gdaClient
, xaction
);