From: <svn...@op...> - 2009-03-25 11:30:21
|
Author: bricks Date: Wed Mar 25 12:30:18 2009 New Revision: 5309 URL: http://www.opensync.org/changeset/5309 Log: First drafts for a new db interface Added: branches/osyncdb2/opensync/db2/ branches/osyncdb2/opensync/db2/opensync_db.h branches/osyncdb2/opensync/db2/opensync_db_connection.h branches/osyncdb2/opensync/db2/opensync_db_connection_private.h branches/osyncdb2/opensync/db2/opensync_db_env.h branches/osyncdb2/opensync/db2/opensync_db_env_private.h branches/osyncdb2/opensync/db2/opensync_db_private.h Added: branches/osyncdb2/opensync/db2/opensync_db.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/osyncdb2/opensync/db2/opensync_db.h Wed Mar 25 12:30:18 2009 (r5309) @@ -0,0 +1,42 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, wri te to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_DB_H_ +#define _OPENSYNC_DB_H_ + +typedef void * (* OSyncDBInitializeFn) (OSyncDB *db, OSyncError **error); + +typedef OSyncDBConnection* (* OSyncDBConnectFn) (OSyncDB *db, const char *dbname, const char *username, const *password, void *userdata, OSyncError **error); + +typedef void (* OSyncDBFinalizeFn) (OSyncDB *db, void *dbdata); + +OSYNC_EXPORT OSyncDB *osync_db_new(OSyncError **error); + +OSYNC_EXPORT OSyncDB *osync_db_ref(OSyncDB *db); + +OSYNC_EXPORT void osync_db_unref(OSyncDB *db); + +OSYNC_EXPORT void osync_db_set_initialize(OSyncDB *db, OSyncDBInitializeFn); + +OSYNC_EXPORT void osync_db_set_finalize(OSyncDB *db, OSyncDBFinalizeFn); + +OSYNC_EXPORT void osync_db_set_connect(OSyncDB *db, OSyncDBConnectFn); + +#endif /* _OPENSYNC_DB_H_ */ Added: branches/osyncdb2/opensync/db2/opensync_db_connection.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/osyncdb2/opensync/db2/opensync_db_connection.h Wed Mar 25 12:30:18 2009 (r5309) @@ -0,0 +1,42 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, wri te to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_DB_CONNECTION_H_ +#define _OPENSYNC_DB_CONNECTION_H_ + +typedef void (* OSyncDBConnectionDisconnectFn) (OSyncDBConnection *dbcon, void *data, OSyncError **error); + +typedef void * (* OSyncDBConnectionQueryFn) (OSyncDBConnection *dbcon, const char *query, void *data, OSyncError **error); /*TODO return value type ???*/ + +typedef struct OSyncDBConnectionFunctions { + OSyncDBConnectionQueryFn query; + OSyncDBConnectionDisconnectFn disconnect; + /*TODO to be continued */ +} OSyncDBConnectionFunctions; + +OSYNC_EXPORT OSyncDBConnection *osync_db_connection_new(OSyncDB *db, OSyncError *error); + +OSYNC_EXPORT OSyncDBConnection *osync_db_connection_ref(OSyncDBConnection *dbcon); + +OSYNC_EXPORT void osync_db_connection_unref(OSyncDBConnection *dbcon); + +OSYNC_EXPORT void osync_db_connection_set_functions(OSyncDBConnection *dbcon, OSyncDBConnectionFunctions functions. void *data); + +#endif /* _OPENSYNC_DB_CONNECTION_H_ */ Added: branches/osyncdb2/opensync/db2/opensync_db_connection_private.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/osyncdb2/opensync/db2/opensync_db_connection_private.h Wed Mar 25 12:30:18 2009 (r5309) @@ -0,0 +1,30 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, wri te to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_DB_CONNECTION_PRIVATE_H_ +#define _OPENSYNC_DB_CONNECTION_PRIVATE_H_ + +typedef struct OSyncDBConnection { + OSyncDB *db; + OSyncDBConnectionFunctions functions; + void *data; +} OSyncDBConnection; + +#endif /* _OPENSYNC_DB_CONNECTION_PRIVATE_H_ */ Added: branches/osyncdb2/opensync/db2/opensync_db_env.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/osyncdb2/opensync/db2/opensync_db_env.h Wed Mar 25 12:30:18 2009 (r5309) @@ -0,0 +1,36 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, wri te to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_DB_ENV_H_ +#define _OPENSYNC_DB_ENV_H_ + +OSYNC_EXPORT OSyncDBEnv *osync_db_env_new(OSyncError **error); + +OSYNC_EXPORT OSyncDBEnv *osync_db_env_ref(OSyncDBEnv *env); + +OSYNC_EXPORT void osync_db_env_unref(OSyncDBEnv *env); + +OSYNC_EXPORT osync_bool osync_db_env_load(OSyncDBEnv *env, const char *path, OSyncError **error); + +OSYNC_EXPORT OSyncDB *osync_db_env_find_db(OSyncDBEnv *env, const char *name); + +OSYNC_EXPORT OSyncList *osync_db_env_get_dbs(OSyncDBEnv *env); + +#endif /* _OPENSYNC_DB_ENV_H_ */ Added: branches/osyncdb2/opensync/db2/opensync_db_env_private.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/osyncdb2/opensync/db2/opensync_db_env_private.h Wed Mar 25 12:30:18 2009 (r5309) @@ -0,0 +1,28 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, wri te to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OSYNC_DB_ENV_PRIVATE_H_ +#define _OSYNC_DB_ENV_PRIVATE_H_ + +typedef struct OSyncDBEnv { + +} OSyncDBEnv; + +#endif /* _OSYNC_DB_ENV_PRIVATE_H_ */ Added: branches/osyncdb2/opensync/db2/opensync_db_private.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/osyncdb2/opensync/db2/opensync_db_private.h Wed Mar 25 12:30:18 2009 (r5309) @@ -0,0 +1,32 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, wri te to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _OPENSYNC_DB_PRIVATE_H_ +#define _OPENSYNC_DB_PRIVATE_H_ + +typedef struct OSyncDB { + char *name; + GList connections; + OSyncDBInitializeFn initialize; + OSyncDBConnectFn connect; + OSyncDBFinalizeFn finalize; +} OSyncDB; + +#endif /* _OPENSYNC_DB_PRIVATE_H_ */ |