00001 // Copyright (c) 2007-2009 Google Inc. 00002 // Copyright (c) 2006-2007 Jaiku Ltd. 00003 // Copyright (c) 2002-2006 Mika Raento and Renaud Petit 00004 // 00005 // This software is licensed at your choice under either 1 or 2 below. 00006 // 00007 // 1. MIT License 00008 // 00009 // Permission is hereby granted, free of charge, to any person obtaining a copy 00010 // of this software and associated documentation files (the "Software"), to deal 00011 // in the Software without restriction, including without limitation the rights 00012 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 // copies of the Software, and to permit persons to whom the Software is 00014 // furnished to do so, subject to the following conditions: 00015 // 00016 // The above copyright notice and this permission notice shall be included in 00017 // all copies or substantial portions of the Software. 00018 // 00019 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 // THE SOFTWARE. 00026 // 00027 // 2. Gnu General Public license 2.0 00028 // 00029 // This program is free software; you can redistribute it and/or 00030 // modify it under the terms of the GNU General Public License 00031 // as published by the Free Software Foundation; either version 2 00032 // of the License, or (at your option) any later version. 00033 // 00034 // This program is distributed in the hope that it will be useful, 00035 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00036 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00037 // GNU General Public License for more details. 00038 // 00039 // You should have received a copy of the GNU General Public License 00040 // along with this program; if not, write to the Free Software 00041 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00042 // 00043 // 00044 // This file is part of the JaikuEngine mobile client. 00045 00046 #include "keyevents/client.h" 00047 #include "keyevents/client_server.rh" 00048 00049 // The RKeyEventsAnim class is the client side class for CKeyEventsAnim 00050 // animation class. No commands are needed (commands would normally be used in 00051 // animation dlls to actually trigger animations/other functionality), the 00052 // construction of this class will create the CKeyEventsAnim object 00053 // server-side, which will notify of keypresses via the RProperty key given in 00054 // the args as a TPckg<TKeyEventArgs>. 00055 00056 class RKeyEventsAnim : public RAnim { 00057 public: 00058 RKeyEventsAnim(RAnimDll* dll); 00059 TInt Construct(const RWindowBase& device, const TDesC8& args); 00060 00061 // Inherited destructor is fine. 00062 }; 00063 00064 // ***************************************************************************** 00065 // RKeyEventsAnim 00066 00067 // The parameter dll will not be NULL, only called from CKeyEventsClient 00068 RKeyEventsAnim::RKeyEventsAnim(RAnimDll *dll) : RAnim(*dll) { 00069 } 00070 00071 TInt RKeyEventsAnim::Construct(const RWindowBase& device, const TDesC8& args) { 00072 // server side Anim doesn't care about parameters 00073 return RAnim::Construct(device, 0, args); 00074 } 00075 00076 // ***************************************************************************** 00077 // CKeyEventsClient 00078 00079 EXPORT_C CKeyEventsClient* CKeyEventsClient::NewL(const TUid& category_uid, 00080 TUint key_id, RWsSession* ws_io, RWindowGroup* window_group_io) { 00081 if (!ws_io || !window_group_io) { 00082 User::Leave(KErrArgument); 00083 } 00084 CKeyEventsClient* ret = new (ELeave) CKeyEventsClient(ws_io); 00085 CleanupStack::PushL(ret); 00086 ret->ConstructL(category_uid, key_id, window_group_io); 00087 CleanupStack::Pop(ret); 00088 return ret; 00089 } 00090 00091 EXPORT_C void CKeyEventsClient::OpenNotificationPropertyL( 00092 RProperty* property_out) { 00093 property_out->Attach(TUid::Uid(property_definition_.category_uid), 00094 property_definition_.key_id, EOwnerThread); 00095 } 00096 00097 EXPORT_C CKeyEventsClient::~CKeyEventsClient() { 00098 // Destroy() does Close() and delete. 00099 if (keyevents_) keyevents_->Destroy(); 00100 keyevents_dll_.Close(); 00101 window_.Close(); 00102 } 00103 00104 CKeyEventsClient::CKeyEventsClient(RWsSession* ws_io) 00105 : keyevents_dll_(*ws_io), 00106 window_(*ws_io), 00107 property_definition_pckg_(property_definition_) { 00108 // The parameter ws_io is checked for NULL in NewL. 00109 } 00110 00111 // We use ProtServ to protect the property, as that is basically 00112 // what the animation dll is required to have. We can't use 00113 // SwEvent (at least not as a write policy) as the 00114 // window server doesn't have it. Realistically, we could 00115 // just have it world accessible. 00116 static _LIT_SECURITY_POLICY_C1(kProtServPolicy, ECapabilityProtServ); 00117 00118 void CKeyEventsClient::ConstructL(const TUid& category_uid, 00119 TUint key_id, RWindowGroup* window_group_io) { 00120 // The parameter window_group_io is checked for NULL in NewL. 00121 00122 property_definition_.category_uid = category_uid.iUid; 00123 property_definition_.key_id = key_id; 00124 00125 TInt err = RProperty::Define(category_uid, key_id, RProperty::EInt, 00126 kProtServPolicy, kProtServPolicy); 00127 if (err != KErrNone && err != KErrAlreadyExists) User::Leave(err); 00128 00129 err = keyevents_dll_.Load(TPtrC( 00130 reinterpret_cast<const TUint16*>( 00131 KEYEVENTS_SERVER_DLL_NAME_STRING))); 00132 if (err != KErrNone) 00133 User::Leave(err); 00134 keyevents_ = new (ELeave) RKeyEventsAnim(&keyevents_dll_); 00135 err = window_.Construct(*window_group_io, 00136 reinterpret_cast<TUint32>(&window_)); 00137 if (err != KErrNone) 00138 User::Leave(err); 00139 // By not Activate()ing the window, it stays invisible and gets no events 00140 err = keyevents_->Construct(window_, property_definition_pckg_); 00141 if (err != KErrNone) 00142 User::Leave(err); 00143 }
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:52 2011 by Doxygen 1.6.1