javacommons/gcfprotocols/http/src.s60/nativetransaction.cpp
changeset 61 bf7ee68962da
parent 48 e0d6e9bd3ca7
child 64 0ea12c182930
equal deleted inserted replaced
48:e0d6e9bd3ca7 61:bf7ee68962da
    17 
    17 
    18 
    18 
    19 #include <e32def.h>
    19 #include <e32def.h>
    20 #include <centralrepository.h>
    20 #include <centralrepository.h>
    21 
    21 
       
    22 #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS
       
    23 #include <cuseragent.h>
       
    24 #else
       
    25 #include <cuseragent.h>
       
    26 #endif
       
    27 
    22 #include "com_nokia_mj_impl_http_HttpConnectionNative.h"
    28 #include "com_nokia_mj_impl_http_HttpConnectionNative.h"
    23 #include "nativehttptransaction.h"
    29 #include "nativehttptransaction.h"
    24 #include "nativehttpsession.h"
    30 #include "nativehttpsession.h"
    25 #include "monitor.h"
    31 #include "monitor.h"
    26 #include "logger.h"
    32 #include "logger.h"
    27 #include "s60commonutils.h"
    33 #include "s60commonutils.h"
    28 #include "javauseragent.h"
       
    29 
    34 
    30 using namespace java::util;
    35 using namespace java::util;
    31 
    36 
    32 // Constants for default User-Agent Header
    37 // Constants for default User-Agent Header
    33 const TUid KCRUidJ2MEConfiguration = {0x102823D3};
    38 const TUid KCRUidJ2MEConfiguration = {0x102823D3};
   213     return header;
   218     return header;
   214 }
   219 }
   215 
   220 
   216 jstring GetUserAgentL(JNIEnv *aJni, jboolean aMidpRuntime)
   221 jstring GetUserAgentL(JNIEnv *aJni, jboolean aMidpRuntime)
   217 {
   222 {
   218     LOG(ESOCKET,EInfo,"GetUserAgentL() +");
       
   219     jstring header = NULL;
   223     jstring header = NULL;
   220 
   224 
   221     if (aMidpRuntime == false)
   225     if (aMidpRuntime == false)
   222     {
   226     {
   223         HBufC* stringBufPtr  = JavaUserAgent::GetUserAgentL();
   227         CUserAgent* userAgent = CUserAgent::NewL();
   224         header = S60CommonUtils::NativeToJavaString(*aJni,stringBufPtr->Des());
   228         CleanupStack::PushL(userAgent);
   225         delete stringBufPtr;
   229 
       
   230         HBufC8* agent8 = userAgent->UserAgentL();
       
   231         CleanupStack::PushL(agent8);
       
   232         HBufC* agent = HBufC::NewMaxLC(agent8->Length());
       
   233         agent->Des().Copy(*agent8);
       
   234         header = S60CommonUtils::NativeToJavaString(*aJni, agent->Des());
       
   235 
       
   236         CleanupStack::PopAndDestroy(agent);
       
   237         CleanupStack::PopAndDestroy(agent8);
       
   238         CleanupStack::PopAndDestroy(userAgent);
       
   239 
   226         return header;
   240         return header;
   227     }
   241     }
   228 
   242 
   229     CRepository* repository = NULL;
   243     CRepository* repository = NULL;
   230 
   244 
   240         {
   254         {
   241             switch (headerType)
   255             switch (headerType)
   242             {
   256             {
   243             case KHTTPUserAgentBrowserHeader:
   257             case KHTTPUserAgentBrowserHeader:
   244             {
   258             {
   245                 HBufC* stringBufPtr = (JavaUserAgent::GetUserAgentL());
   259                 CUserAgent* userAgent = CUserAgent::NewL();
   246                 header = S60CommonUtils::NativeToJavaString(*aJni, stringBufPtr->Des());
   260                 CleanupStack::PushL(userAgent);
   247                 delete stringBufPtr;
   261 
       
   262                 HBufC8* agent8 = userAgent->UserAgentL();
       
   263                 CleanupStack::PushL(agent8);
       
   264                 HBufC* agent = HBufC::NewMaxLC(agent8->Length());
       
   265                 agent->Des().Copy(*agent8);
       
   266                 header = S60CommonUtils::NativeToJavaString(*aJni, agent->Des());
       
   267 
       
   268                 CleanupStack::PopAndDestroy(agent);
       
   269                 CleanupStack::PopAndDestroy(agent8);
       
   270                 CleanupStack::PopAndDestroy(userAgent);
   248             }
   271             }
   249             break;
   272             break;
   250 
   273 
   251             case KHTTPUserAgentDefinedHeader:
   274             case KHTTPUserAgentDefinedHeader:
   252             {
   275             {