languageinterworkingfw/servicehandler/src/liwecommonitor.cpp
changeset 0 99ef825efeca
child 5 947415ec7603
equal deleted inserted replaced
-1:000000000000 0:99ef825efeca
       
     1 /*
       
     2 * Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:       Implementation for ECom monitoring class for LIW framework.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #include "liwecommonitor.h"
       
    24 #include "liwcommon.h"
       
    25 #include "liwuids.hrh"
       
    26 #include "liwserviceifbase.h"
       
    27 
       
    28 // CONSTANTS
       
    29 _LIT8(KContentTag, "<CONTENT>");
       
    30 _LIT8(KOpaqueTag, "<OPAQUE>");
       
    31 _LIT8(KLiwMimeTypeAll, "*");
       
    32 
       
    33 const TInt KMaxDataParamSize = 255;
       
    34 
       
    35 CLiwEcomMonitor* CLiwEcomMonitor::NewL(TCallBack& aSynchronizeCallBack)
       
    36     {
       
    37     CLiwEcomMonitor* self = new (ELeave) CLiwEcomMonitor(aSynchronizeCallBack); 
       
    38     CleanupStack::PushL(self);  
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop(self); // self
       
    41     return self;
       
    42     }
       
    43 
       
    44 
       
    45 CLiwEcomMonitor::CLiwEcomMonitor(TCallBack& aSynchronizeCallBack) 
       
    46 :CActive(CActive::EPriorityStandard), iSynchronizeCallBack(aSynchronizeCallBack)
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 CLiwEcomMonitor::~CLiwEcomMonitor()
       
    52     {
       
    53     Cancel();
       
    54     iEcomSession.Close();
       
    55     REComSession::FinalClose();
       
    56     }
       
    57 
       
    58 
       
    59 void CLiwEcomMonitor::ConstructL()
       
    60     {
       
    61     iEcomSession = REComSession::OpenL();
       
    62     CActiveScheduler::Add(this);
       
    63     StartMonitoring();
       
    64     }
       
    65 
       
    66       
       
    67 void CLiwEcomMonitor::RunL()
       
    68     {
       
    69     iSynchronizeCallBack.CallBack();
       
    70     StartMonitoring();
       
    71     }
       
    72 
       
    73 
       
    74     
       
    75 void CLiwEcomMonitor::DoCancel()
       
    76     {
       
    77     iEcomSession.CancelNotifyOnChange(iStatus);
       
    78     }
       
    79 
       
    80 
       
    81 void CLiwEcomMonitor::StartMonitoring()
       
    82     {
       
    83     iEcomSession.NotifyOnChange(iStatus);
       
    84     SetActive();
       
    85     }
       
    86 
       
    87 
       
    88 
       
    89 void CLiwEcomMonitor::ListImplemetationsL(RImplInfoPtrArray& aResult, 
       
    90     CLiwCriteriaItem* aItem) const
       
    91     {
       
    92     TEComResolverParams params;
       
    93     
       
    94     TUid resolvUid = { KLiwResolverImplUidValue };  
       
    95     
       
    96     TBuf8<KMaxDataParamSize> dataType;     
       
    97     dataType.Copy(KContentTag);
       
    98     dataType.Append(aItem->ContentType());
       
    99     dataType.Append(KOpaqueTag);
       
   100     if (aItem->ServiceCmd() != KLiwCmdAsStr)
       
   101       {
       
   102         dataType.AppendNumUC(aItem->ServiceCmd(), EHex);
       
   103       }
       
   104     else
       
   105       {
       
   106         dataType.Append(aItem->ServiceCmdStr());
       
   107       }
       
   108     params.SetDataType(dataType);
       
   109     params.SetWildcardMatch(dataType.Find(KLiwMimeTypeAll) != KErrNotFound);
       
   110     
       
   111     iEcomSession.ListImplementationsL(aItem->ServiceClass(), params, resolvUid, aResult);
       
   112     }
       
   113 
       
   114 
       
   115 
       
   116 CLiwServiceIfBase* CLiwEcomMonitor::CreateImplementationL(TUid aImplUid)
       
   117     {
       
   118     TUid dtorKeyId;
       
   119 
       
   120     CLiwServiceIfBase* iface = (CLiwServiceIfBase*)iEcomSession.CreateImplementationL(aImplUid, 
       
   121         dtorKeyId);
       
   122 
       
   123     if (iface)
       
   124         {
       
   125         iface->SetDtorKeyId( dtorKeyId );               
       
   126         iface->SetImplementationUid( aImplUid );
       
   127         }           
       
   128     
       
   129     return iface;
       
   130     }
       
   131 
       
   132 // End of file