00001 #ifndef INIT_H 00002 #define INIT_H 00003 00004 /** 00005 * @addtogroup eripc 00006 * @{ 00007 * @file init.h 00008 * @brief This file implements all initialisation and shutdown of the library. 00009 */ 00010 00011 /* 00012 * This file is part of liberipc. 00013 * 00014 * liberipc is free software: you can redistribute it and/or modify 00015 * it under the terms of the GNU General Public License as published by 00016 * the Free Software Foundation, either version 2 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * liberipc is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 /** 00029 * Copyright (C) 2008 iRex Technologies B.V. 00030 * All rights reserved. 00031 * 00032 * Based on code found in libosso library by Kimmo Hämäläinen <kimmo.hamalainen@nokia.com> 00033 */ 00034 00035 #include <dirent.h> 00036 #include <sys/types.h> 00037 #include <sys/stat.h> 00038 #include <unistd.h> 00039 #include <pwd.h> 00040 00041 /** 00042 * This internal function performs a simple validation for the application 00043 * and version information of the osso_context regarding their validity 00044 * as components of the filesystem (no slashes, value not NULL etc) 00045 * @param application The application name 00046 * @param verson The application version. 00047 * @return TRUE if the context passes the validation, FALSE otherwise. 00048 */ 00049 static gboolean _validate(const gchar *application, const gchar* version); 00050 00051 /** 00052 * This function allocates and initializes the #osso_type_t structure 00053 * @param application The application name 00054 * @param verson The application version. 00055 * @return the newly allocated #osso_context_t structure, or NULL if there 00056 * is an error. 00057 */ 00058 static osso_context_t *_init(const char *application, 00059 const char *version); 00060 00061 /** 00062 * This function deinitializes the #osso_type_t structure, but does not touch 00063 * and D-BUS element. As a final thing it will destroy the osso_context_t 00064 * structure. 00065 * @param osso the disconnecte osso_context_t structure to destroy. 00066 */ 00067 static void _deinit(osso_context_t *osso); 00068 00069 /** 00070 * This function connect to the given D-BUS bus and registers itself with the 00071 * D-BUS daemon. 00072 * @param osso The #osso_context_t for this connection. 00073 * @param bus_type. The DBusType to use. 00074 * @param context The GLib main-loop context to connect to, use NULL for the 00075 * default context. 00076 * @return The DBusConnection for the connection. 00077 */ 00078 static DBusConnection *_dbus_setup(osso_context_t *osso, 00079 DBusBusType bus_type, 00080 GMainContext *context); 00081 00082 /** @} */ 00083 00084 #endif /* INIT_H */