00001 // The local server interface is only implemented for Symbian, using 00002 // the Symbian client/server framework. On other platforms these 00003 // functions do nothing. 00004 00005 #include "local_server.h" 00006 00007 #include "er_errors.h" 00008 00009 #ifdef __EPOC32__ 00010 #include "epoc-cliapi-server.hpp" 00011 #endif 00012 00013 // I have yet to see documentation on how to stop a server other than 00014 // by destroying the object. So that is the hardcore solution that we 00015 // use here to implement "start" and "stop" for this object. 00016 00017 struct _LocalServer { 00018 #ifdef __EPOC32__ 00019 CCliapiServer* iServer; 00020 #endif 00021 }; 00022 00023 extern "C" LocalServer *LocalServer_new (GError ** error) 00024 { 00025 #ifdef __EPOC32__ 00026 LocalServer* self = (LocalServer*)g_try_malloc0(sizeof(LocalServer)); 00027 if (G_UNLIKELY(!self)) { 00028 if (error) *error = gx_error_no_memory; 00029 } 00030 return self; 00031 #else 00032 return (LocalServer*)1; // dummy 00033 #endif 00034 } 00035 00036 extern "C" gboolean LocalServer_start (LocalServer * self, 00037 GError ** error) 00038 { 00039 #ifdef __EPOC32__ 00040 if (!self->iServer) { 00041 CCliapiServer* server = NULL; 00042 TRAPD(errCode, server = CCliapiServer::NewL()); 00043 if (errCode) { 00044 if (error) 00045 *error = gx_error_new(domain_symbian, errCode, "Symbian client/server init failure: %s (%d)", plat_error_strerror(errCode), errCode); 00046 return NULL; 00047 } 00048 00049 errCode = server->Start(); 00050 if (errCode) { 00051 logt("failed to start Symbian local server"); 00052 delete server; 00053 if (error) 00054 *error = gx_error_new(domain_symbian, errCode, "Symbian client/server start failure: %s (%d)", plat_error_strerror(errCode), errCode); 00055 return NULL; 00056 } 00057 00058 self->iServer = server; 00059 } 00060 #endif 00061 return TRUE; 00062 } 00063 00064 extern "C" void LocalServer_stop (LocalServer * self) 00065 { 00066 #ifdef __EPOC32__ 00067 delete self->iServer; 00068 self->iServer = NULL; 00069 #endif 00070 } 00071 00072 extern "C" void LocalServer_destroy (LocalServer * self) 00073 { 00074 #ifdef __EPOC32__ 00075 if (self) { 00076 delete self->iServer; 00077 g_free(self); 00078 } 00079 #endif 00080 } 00081 00082 /** 00083 00084 local_server.cpp 00085 00086 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00087 and the authors. All rights reserved. 00088 00089 Authors: Tero Hasu <tero.hasu@hut.fi> 00090 00091 Permission is hereby granted, free of charge, to any person 00092 obtaining a copy of this software and associated documentation files 00093 (the "Software"), to deal in the Software without restriction, 00094 including without limitation the rights to use, copy, modify, merge, 00095 publish, distribute, sublicense, and/or sell copies of the Software, 00096 and to permit persons to whom the Software is furnished to do so, 00097 subject to the following conditions: 00098 00099 The above copyright notice and this permission notice shall be 00100 included in all copies or substantial portions of the Software. 00101 00102 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00103 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00104 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00105 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00106 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00107 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00108 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00109 SOFTWARE. 00110 00111 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:54 2011 by Doxygen 1.6.1