00001 #include "epocxplat.hpp" 00002 00003 // -------------------------------------------------- 00004 // platform info 00005 // -------------------------------------------------- 00006 00007 #include "sconfig.hrh" 00008 00009 #include "common/platform_config.h" 00010 00011 #if defined(__HAS_AHLECLIENT__) 00012 #define __HAVE_AHLECLIENT_LIB__ 1 00013 #else 00014 #define __HAVE_AHLECLIENT_LIB__ 0 00015 #endif 00016 00017 #if defined(__HAS_AHLE2CLIENT__) 00018 #define __HAVE_AHLE2CLIENT_LIB__ 1 00019 #else 00020 #define __HAVE_AHLE2CLIENT_LIB__ 0 00021 #endif 00022 00023 // -------------------------------------------------- 00024 // runtime feature query 00025 // -------------------------------------------------- 00026 00027 #define FEATURE_AhleBrowser __HAVE_AHLECLIENT_LIB__ 00028 00029 EXPORT_C TBool epocxplat::HasFeature(TFeature aFeature) 00030 { 00031 switch (aFeature) 00032 { 00033 case EFeatureAhleBrowser: 00034 { 00035 return FEATURE_AhleBrowser; 00036 } 00037 default: 00038 { 00039 return EFalse; 00040 } 00041 } 00042 } 00043 00044 // -------------------------------------------------- 00045 // feature implementations 00046 // -------------------------------------------------- 00047 00048 using namespace epocxplat; 00049 00050 // -------------------------------------------------- 00051 // EFeatureAhleBrowser 00052 // -------------------------------------------------- 00053 00054 /* 00055 http://wiki.forum.nokia.com/index.php/Adaptive_History_List_API 00056 00057 Only v3.0 (and earlier?) kits support this API, but also at least v3.1 is binary compatible with this API, possibly also v3.2. 00058 00059 xxx We can try unpacking the v3.0 plugin to the v3.1 kit and see if it works. 00060 00061 http://wiki.forum.nokia.com/index.php/Adaptive_History_List_API_for_5th_Edition 00062 00063 v3.1-up kits support this API, but it cannot be used to access the web browsers data, it looks like, which is what we want. 00064 00065 */ 00066 00067 #if FEATURE_AhleBrowser 00068 00069 #define __USE_AHLECLIENT_LIB__ __HAVE_AHLECLIENT_LIB__ 00070 #define __USE_AHLE2CLIENT_LIB__ 0 00071 00072 #if __USE_AHLECLIENT_LIB__ 00073 // Note that CAHLE relies on a DLL that is not available on 5th 00074 // edition devices. Hence dynamic linking fails, and the logger will 00075 // not even start. 00076 #include <ahleclientobserver.h> 00077 #include <ahle.h> 00078 typedef CAHLE AhleClientType; 00079 typedef MAHLEClientObserver AhleObserverType; 00080 #elif __USE_AHLE2CLIENT_LIB__ 00081 #include <ahleobserver.h> 00082 class MAHLEGenericAPI; 00083 typedef MAHLEGenericAPI AhleClientType; 00084 typedef MAHLEObserver AhleObserverType; 00085 #else 00086 #error feature AhleBrowser enabled without API 00087 #endif 00088 00089 #if __USE_AHLE2CLIENT_LIB__ 00090 #include <ahlegenericapi.h> 00091 #endif 00092 00093 /***koog 00094 (require codegen/symbian-cxx) 00095 (ctor-defines/spec 00096 "CMyAhleNotifier" ;; name 00097 "AhleBrowser::MObserver& aObserver" ;; args 00098 "iObserver(aObserver)" ;; inits 00099 "" ;; ctor 00100 #t ;; ConstructL 00101 ) 00102 ***/ 00103 #define CTOR_DECL_CMyAhleNotifier \ 00104 public: static CMyAhleNotifier* NewLC(AhleBrowser::MObserver& aObserver); \ 00105 public: static CMyAhleNotifier* NewL(AhleBrowser::MObserver& aObserver); \ 00106 private: CMyAhleNotifier(AhleBrowser::MObserver& aObserver); \ 00107 private: void ConstructL(); 00108 00109 #define CTOR_IMPL_CMyAhleNotifier \ 00110 CMyAhleNotifier* CMyAhleNotifier::NewLC(AhleBrowser::MObserver& aObserver) \ 00111 { \ 00112 CMyAhleNotifier* obj = new (ELeave) CMyAhleNotifier(aObserver); \ 00113 CleanupStack::PushL(obj); \ 00114 obj->ConstructL(); \ 00115 return obj; \ 00116 } \ 00117 \ 00118 CMyAhleNotifier* CMyAhleNotifier::NewL(AhleBrowser::MObserver& aObserver) \ 00119 { \ 00120 CMyAhleNotifier* obj = CMyAhleNotifier::NewLC(aObserver); \ 00121 CleanupStack::Pop(obj); \ 00122 return obj; \ 00123 } \ 00124 \ 00125 CMyAhleNotifier::CMyAhleNotifier(AhleBrowser::MObserver& aObserver) : iObserver(aObserver) \ 00126 {} 00127 /***end***/ 00128 00129 NONSHARABLE_CLASS(CMyAhleNotifier) : 00130 public CBase, 00131 public epocxplat::AhleBrowser::MNotifier, 00132 public AhleObserverType 00133 { 00134 CTOR_DECL_CMyAhleNotifier; 00135 00136 public: 00137 virtual ~CMyAhleNotifier(); 00138 00139 private: 00140 epocxplat::AhleBrowser::MObserver& iObserver; 00141 00142 AhleClientType* iAhle; // owned 00143 00144 CDesCArray* iOldUrlArray; // owned 00145 00146 private: // AhleObserverType 00147 virtual void AdaptiveListChanged(TInt aError); 00148 00149 private: 00150 void HandleDataL(); 00151 }; 00152 00153 CTOR_IMPL_CMyAhleNotifier; 00154 00155 void CMyAhleNotifier::ConstructL() 00156 { 00157 #if __USE_AHLECLIENT_LIB__ 00158 iAhle = CAHLE::NewL(); 00159 #else 00160 // Can we find a list of these from somewhere? Not in API docs, 00161 // anyway. It would actually seem that the built-in apps use a 00162 // separate API (we would want EAHLEBrowser type client session via 00163 // that API). But we do not have the header in the SDK, which is 00164 // inconvenient. And who knows which LIB file would be required. 00165 _LIT(databaseName, "Browser"); 00166 iAhle = NewAHLEClientL(databaseName); 00167 //logh(); 00168 #endif 00169 iAhle->SetObserverL(this); 00170 } 00171 00172 CMyAhleNotifier::~CMyAhleNotifier() 00173 { 00174 delete iAhle; 00175 delete iOldUrlArray; 00176 } 00177 00178 void CMyAhleNotifier::AdaptiveListChanged(TInt errCode) 00179 { 00180 //logg("AdaptiveListChanged(%d)", errCode); 00181 00182 if (errCode) { 00183 iObserver.AhleBrowserError(errCode); 00184 } else { 00185 TRAP(errCode, HandleDataL()); 00186 if (errCode) { 00187 iObserver.AhleBrowserError(errCode); 00188 } 00189 } 00190 } 00191 00192 #define MAX_URLS 100 00193 00194 void CMyAhleNotifier::HandleDataL() 00195 { 00196 CDesCArray* urlArray = new (ELeave) CDesCArrayFlat(MAX_URLS); 00197 CleanupStack::PushL(urlArray); 00198 00199 CDesCArray* nameArray = new (ELeave) CDesCArrayFlat(MAX_URLS); 00200 CleanupStack::PushL(nameArray); 00201 00202 // This just appears to give us the first items in the adaptive 00203 // list. There does not seem to be a way to request the latest 00204 // addition to the list. We may have to keep any previous copy of 00205 // urlArray, and log the new ones only. Difficult to analyze, but 00206 // better than nothing, I guess. 00207 //logh(); 00208 iAhle->AdaptiveListL(*urlArray, *nameArray, MAX_URLS, KNullDesC 00209 #if __USE_AHLECLIENT_LIB__ 00210 , 00211 //EAHLEAdaptiveSiteList // (short url, short url) 00212 EAHLEAdaptiveSiteDetails // (caption, long url) 00213 //EAHLEAdaptiveAutoComplete // (caption, long url) 00214 #endif 00215 ); 00216 //logh(); 00217 00218 TInt numItems = urlArray->Count(); 00219 //logg("read total of %d adaptive history items", numItems); 00220 00221 for (TInt i = 0; i < numItems; i++) { 00222 TPtrC url16(urlArray->MdcaPoint(i)); 00223 TInt dummyPos; 00224 // We will not log the initial full set, which probably means that 00225 // we miss the first URL browsed. But then again, we do anyway 00226 // miss URLs that are revisited while still in history, and that 00227 // is a bigger problem. 00228 if ((iOldUrlArray) && 00229 // This returns zero if a match is found. 00230 // iOldUrlArray must be sorted for this to work. 00231 iOldUrlArray->FindIsq(url16, dummyPos, ECmpNormal)) { 00232 00233 iObserver.AhleBrowserDataL(nameArray->MdcaPoint(i), url16); 00234 } 00235 } 00236 00237 CleanupStack::PopAndDestroy(nameArray); 00238 CleanupStack::Pop(urlArray); 00239 00240 urlArray->Sort(ECmpNormal); 00241 delete iOldUrlArray; 00242 iOldUrlArray = urlArray; 00243 } 00244 00245 #endif // FEATURE_AhleBrowser 00246 00247 EXPORT_C AhleBrowser::MNotifier* AhleBrowser::NewNotifierL(AhleBrowser::MObserver& aObserver) 00248 { 00249 #if FEATURE_AhleBrowser 00250 return ::CMyAhleNotifier::NewL(aObserver); 00251 #else 00252 return NULL; 00253 #endif 00254 } 00255 00256 /** 00257 00258 Copyright 2010 Helsinki Institute for Information Technology (HIIT) 00259 and the authors. All rights reserved. 00260 00261 Authors: Tero Hasu <tero.hasu@hut.fi> 00262 00263 Permission is hereby granted, free of charge, to any person 00264 obtaining a copy of this software and associated documentation files 00265 (the "Software"), to deal in the Software without restriction, 00266 including without limitation the rights to use, copy, modify, merge, 00267 publish, distribute, sublicense, and/or sell copies of the Software, 00268 and to permit persons to whom the Software is furnished to do so, 00269 subject to the following conditions: 00270 00271 The above copyright notice and this permission notice shall be 00272 included in all copies or substantial portions of the Software. 00273 00274 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00275 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00276 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00277 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00278 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00279 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00280 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00281 SOFTWARE. 00282 00283 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:52 2011 by Doxygen 1.6.1