00001 // The idea behind this API is that it decides what parts of the 00002 // internal application state (that in our case resides in the 00003 // controller, for the most part) is exposed to other components 00004 // within this application. This increases API stability, as we can 00005 // just pass a single argument for access to app state when creating a 00006 // component, or most components anyway, ones that are not tightly 00007 // coupled with the controller. That is, the purpose of this API is 00008 // encapsulation. It is also a good place to maintain shared state 00009 // required by multiple components; an example of such state would be 00010 // Symbian client/server session handles. 00011 00012 #ifndef __ac_app_context_h__ 00013 #define __ac_app_context_h__ 00014 00015 // -------------------------------------------------- 00016 // common API 00017 // -------------------------------------------------- 00018 00019 // xxx To avoid circular dependencies, we may not actually want to have all of these includes here. 00020 #include "bb_blackboard.h" 00021 #include "config_db.h" 00022 #include "cf_rcfile.h" 00023 #include "kr_controller.h" 00024 #include "ld_log_db.h" 00025 00026 #include <time.h> 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 typedef struct _ac_AppContext ac_AppContext; 00033 00034 ac_AppContext* ac_get_global_AppContext(); 00035 00036 typedef struct { 00037 time_t last_upload_time; 00038 } ac_Registry; 00039 00040 ac_Registry* ac_get_Registry(ac_AppContext* self); 00041 00042 bb_Blackboard* ac_get_Blackboard(ac_AppContext* self); 00043 00044 const char* ac_get_logdb_file(ac_AppContext* self); 00045 const char* ac_get_logdb_dir(ac_AppContext* self); 00046 const char* ac_get_log_uploads_dir(ac_AppContext* self); 00047 00048 kr_Controller* ac_Controller(ac_AppContext* self); 00049 00050 LogDb* ac_LogDb(ac_AppContext* self); 00051 00052 cf_RcFile* ac_RcFile(ac_AppContext* self); 00053 00054 ConfigDb* ac_ConfigDb(ac_AppContext* self); 00055 00056 #ifdef __cplusplus 00057 } /* extern "C" */ 00058 #endif 00059 00060 #define ac_global_Controller ac_Controller(ac_get_global_AppContext()) 00061 #define ac_global_LogDb ac_LogDb(ac_get_global_AppContext()) 00062 #define ac_global_RcFile ac_RcFile(ac_get_global_AppContext()) 00063 #define ac_global_ConfigDb ac_ConfigDb(ac_get_global_AppContext()) 00064 #define ac_global_Registry ac_get_Registry(ac_get_global_AppContext()) 00065 #define ac_global_Blackboard ac_get_Blackboard(ac_get_global_AppContext()) 00066 #define LOGDB_FILE ac_get_logdb_file(ac_get_global_AppContext()) 00067 #define LOGDB_DIR ac_get_logdb_dir(ac_get_global_AppContext()) 00068 #define LOG_UPLOADS_DIR ac_get_log_uploads_dir(ac_get_global_AppContext()) 00069 00070 #if defined(__SYMBIAN32__) 00071 #define DATABASE_DRIVE_LETTER (LOGDB_FILE [0]) 00072 #endif /* __SYMBIAN32__ */ 00073 00074 // -------------------------------------------------- 00075 // backwards compatibility 00076 // -------------------------------------------------- 00077 00078 #define ac_STATIC_GET(key) \ 00079 (cf_RcFile_get_##key(ac_global_RcFile)) 00080 00081 // The caller must free any returned value. 00082 #define ac_DYNAMIC_GET(_key) \ 00083 (ConfigDb_get_generic(ac_global_ConfigDb, _key, NULL)) 00084 00085 // The caller must free any returned value, and free any set GError 00086 // value. 00087 #define ac_DYNAMIC_GET_ERR(_key,_errorpp) \ 00088 (ConfigDb_get_generic(ac_global_ConfigDb, _key, _errorpp)) 00089 00090 // The caller must free any set GError value. 00091 #define ac_DYNAMIC_SET_ERR(_key,_value,_errorpp) \ 00092 (ConfigDb_set_generic(ac_global_ConfigDb, _key, _value, _errorpp)) 00093 00094 // -------------------------------------------------- 00095 // Symbian API 00096 // -------------------------------------------------- 00097 00098 #ifdef __cplusplus 00099 #if defined(__SYMBIAN32__) 00100 00101 class RFs; 00102 RFs& ac_Fs(ac_AppContext* self); 00103 00104 class CTelephony; 00105 CTelephony& ac_Telephony(ac_AppContext* self); 00106 00107 class CContactDatabase; 00108 CContactDatabase& ac_ContactDatabase(ac_AppContext* self); 00109 00110 class TPlatformVersion; 00111 const TPlatformVersion& ac_get_PlatformVersion(ac_AppContext* self); 00112 00113 #endif /* __SYMBIAN32__ */ 00114 #endif 00115 00116 #endif /* __ac_app_context_h__ */ 00117 00118 /** 00119 00120 ac_app_context.h 00121 00122 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00123 and the authors. All rights reserved. 00124 00125 Authors: Tero Hasu <tero.hasu@hut.fi> 00126 00127 Permission is hereby granted, free of charge, to any person 00128 obtaining a copy of this software and associated documentation files 00129 (the "Software"), to deal in the Software without restriction, 00130 including without limitation the rights to use, copy, modify, merge, 00131 publish, distribute, sublicense, and/or sell copies of the Software, 00132 and to permit persons to whom the Software is furnished to do so, 00133 subject to the following conditions: 00134 00135 The above copyright notice and this permission notice shall be 00136 included in all copies or substantial portions of the Software. 00137 00138 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00139 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00140 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00141 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00142 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00143 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00144 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00145 SOFTWARE. 00146 00147 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:51 2011 by Doxygen 1.6.1