services/terminalmodeservice/tsrc/upnptmservertest/src/tmservertestcases.cpp
branchRCL_3
changeset 9 5c72fd91570d
equal deleted inserted replaced
5:8116cc943311 9:5c72fd91570d
       
     1 /**
       
     2 * Copyright (c) 2010 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 "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32math.h>
       
    21 #include <ecom/ecom.h>
       
    22 #include <upnpdevice.h>
       
    23 #include <upnptmserverdeviceinfo.h>
       
    24 #include <upnpsettings.h>
       
    25 #include "testtimer.h"
       
    26 #include "discoverytesttimer.h"
       
    27 #include "tmservertest.h"
       
    28 
       
    29 
       
    30 // LOCAL CONSTANTS AND MACROS
       
    31 _LIT8(KTestSvgMimeType,           "image/svg+xml");
       
    32 _LIT8(KTmServerDevice,            "urn:schemas-upnp-org:device:TmServerDevice:1" );
       
    33 _LIT8(KTmServerService,           "urn:schemas-upnp-org:service:TmApplicationServer:1" );
       
    34 _LIT8(KTmServerServiceType,       "TmApplicationServer:1" );
       
    35 _LIT8(KTmServerServiceType1,      "TmClientProfile:1" );
       
    36 _LIT8(KBtMacValue,                "00257df016d5");
       
    37 _LIT8(KArgTypeAppStatusUpdate,    "AppStatusUpdate");
       
    38 _LIT8(KGetAppStatus,              "GetApplicationStatus");
       
    39 _LIT8(KAppStatus,                 "AppStatus");
       
    40 _LIT8(KGetApplicationList,        "GetApplicationList");
       
    41 _LIT8(KAppListing,                "AppListing");
       
    42 _LIT8(KLaunchApp,                 "LaunchApplication");
       
    43 _LIT8(KTerminateApp,              "TerminateApplication");
       
    44 _LIT8(KAppLaunchStatus,           "AppURI");
       
    45 _LIT8(KAppTerminateStatus,        "TerminationResult");
       
    46 _LIT8(KAppId ,                    "AppID");
       
    47 _LIT8(KAppFilter,                 "AppListingFilter");
       
    48 _LIT8(KResultProfile ,            "resultProfile");
       
    49 _LIT8(KSetClientProfile ,         "SetClientProfile");
       
    50 _LIT8(KGetClientProfile,          "GetClientProfile");
       
    51 _LIT8(KGetMaxNumProfiles,         "GetMaxNumProfiles");
       
    52 _LIT8(KClientProfile ,            "clientProfile");
       
    53 _LIT8(KNumProfilesAllowed ,       "numProfilesAllowed");
       
    54 _LIT8(KProfileId,                 "ProfileID");
       
    55 _LIT8(KProfileId1,                "profileID");
       
    56 _LIT8(KBackground,                "Background");
       
    57 _LIT8(KForeground,                "Foreground");
       
    58 _LIT8(KAppListFilterValue1,       "\"icon@mimetype=\"*svg+xml*\",icon@width=\"*\",icon@height=\"*\",icon@depth=\"*\"\"");
       
    59 _LIT8(KAppListFilterValue2,       "\"name=\"*nav*\",description=\"*\",appInfo@appCategory=\"*\",appInfo@trustLevel=\"*\",displayInfo@contentCategory=\"*\",displayInfo@contentRules=\"*\",displayInfo@trustLevel=\"*\",allowedProfileIDs=\"*\"\"");
       
    60 _LIT8(KAppListFilterValue3,       "\"name=\"*bluetooth*\",description=\"*\",icon@mimetype=\"*svg+xml*\",remotingInfo@protocolID=\"*\",remotingInfo@direction=\"*\",appInfo@appCategory=\"*\",audioInfo@audioType=\"*\",resourceStatus=\"free\",signature=\"*\"\"");
       
    61 _LIT8(KAppListFilterValue4,       "\"name=\"*\",description=\"*Audio*\",icon@mimetype=\"*svg+xml*\",remotingInfo@protocolID=\"*\",remotingInfo@format=\"*\",appInfo@appCategory=\"*\",audioInfo@audioType=\"*\",resourceStatus=\"free\",signature=\"*\"\"");
       
    62 _LIT8(KWildCard,                  "*");
       
    63 _LIT(KIconPathMusicUnLaunched,          "c:\\upnptmserver\\icons\\music_unlaunched.svg");
       
    64 _LIT(KIconPathMusicLaunched,            "c:\\upnptmserver\\icons\\music_launched.svg");
       
    65 _LIT(KIconPathMaps,                     "c:\\upnptmserver\\icons\\maps.svg");
       
    66 _LIT(KIconPathBtA2DpUnLaunched,         "c:\\upnptmserver\\icons\\gallery.svg");
       
    67 _LIT(KIconPathBtA2DpLaunched,           "c:\\upnptmserver\\icons\\homemedia.svg");
       
    68 _LIT(KIconPathBtHfp,                    "c:\\upnptmserver\\icons\\videos.svg");
       
    69 _LIT(KIconDevicePath,                   "c:\\upnptmserver\\icons\\s60_device.svg");    
       
    70 _LIT8(KDeviceInfo,                      "<X_Nokia_deviceInfo><version><major>1</major><minor>0</minor></version><mtp_tc>true</mtp_tc>"
       
    71     "<license_model>pre,post</license_model><sound_feedback><enabled>true</enabled></sound_feedback><ipRouting><enabled>false</enabled></ipRouting>"
       
    72     "</X_Nokia_deviceInfo>");
       
    73 
       
    74 _LIT8(KClientProfileInfo, "&lt;clientProfile&gt;&lt;clientID&gt;Cl_1&lt;/clientID&gt;&lt;friendlyName&gt;Client One&lt;/friendlyName&gt;&lt;manufacturer&gt;man_2&lt;/manufacturer&gt;&lt;modelName&gt;CL_Model2&lt;/modelName&gt;&lt;modelNumber&gt;2009&lt;/modelNumber&gt;&lt;iconPreference&gt;&lt;width&gt;240&lt;/width&gt;&lt;height&gt;240&lt;/height&gt;&lt;/iconPreference&gt;&lt;contentRules&gt;&lt;rule&gt;&lt;ruleId&gt;0&lt;/ruleId&gt;&lt;ruleValue&gt;0.1&lt;/ruleValue&gt;&lt;/rule&gt;&lt;rule&gt;&lt;ruleId&gt;1&lt;/ruleId&gt;&lt;/rule&gt;&lt;/contentRules&gt;&lt;/clientProfile&gt;");
       
    75 
       
    76 _LIT8(KDeviceLockedClientProfile, "&lt;clientProfile&gt;&lt;clientID&gt;Cl_2&lt;/clientID&gt;&lt;/clientProfile&gt;");
       
    77 
       
    78 _LIT8(KXmlSignature, "&lt;Signature Id= &quot;AppListSignature&quot; xmlns=&quot;http://www.w3.org/2000/09/xmldsig#&quot;&gt; &lt;SignedInfo&gt;&lt;CanonicalizationMethod Algorithm=&quot;http://www.w3.org/2006/12/xml-c14n11&quot;/&gt;&lt;SignatureMethodAlgorithm=&quot;http://www.w3.org/2000/09/xmldsig#dsa-sha1&quot;/&gt; &lt;Reference URI=&quot;&quot;&gt;&lt;/Reference&gt;&lt;/SignedInfo&gt;&lt;/Signature&gt;");
       
    79 
       
    80 // ============================ MEMBER FUNCTIONS ===============================
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CTmServerTest::Case
       
    84 // Returns a test case by number.
       
    85 //
       
    86 // This function contains an array of all available test cases 
       
    87 // i.e pair of case name and test function. If case specified by parameter
       
    88 // aCaseNumber is found from array, then that item is returned.
       
    89 // 
       
    90 // The reason for this rather complicated function is to specify all the
       
    91 // test cases only in one place. It is not necessary to understand how
       
    92 // function pointers to class member functions works when adding new test
       
    93 // cases. See function body for instructions how to add new test case.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 const TCaseInfo CTmServerTest::Case ( 
       
    97     const TInt aCaseNumber ) const 
       
    98      {
       
    99 
       
   100     /**
       
   101     * To add new test cases, implement new test case function and add new 
       
   102     * line to KCases array specify the name of the case and the function 
       
   103     * doing the test case
       
   104     * In practice, do following
       
   105     * 1) Make copy of existing test case function and change its name
       
   106     *    and functionality. Note that the function must be added to 
       
   107     *    TmServerTest.cpp file and to TmServerTest.h 
       
   108     *    header file.
       
   109     *
       
   110     * 2) Add entry to following KCases array either by using:
       
   111     *
       
   112     * 2.1: FUNCENTRY or ENTRY macro
       
   113     * ENTRY macro takes two parameters: test case name and test case 
       
   114     * function name.
       
   115     *
       
   116     * FUNCENTRY macro takes only test case function name as a parameter and
       
   117     * uses that as a test case name and test case function name.
       
   118     *
       
   119     * Or
       
   120     *
       
   121     * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
       
   122     * only with OOM (Out-Of-Memory) testing!
       
   123     *
       
   124     * OOM_ENTRY macro takes five parameters: test case name, test case 
       
   125     * function name, TBool which specifies is method supposed to be run using
       
   126     * OOM conditions, TInt value for first heap memory allocation failure and 
       
   127     * TInt value for last heap memory allocation failure.
       
   128     * 
       
   129     * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
       
   130     * that as a test case name, TBool which specifies is method supposed to be
       
   131     * run using OOM conditions, TInt value for first heap memory allocation 
       
   132     * failure and TInt value for last heap memory allocation failure. 
       
   133     */ 
       
   134 
       
   135     static TCaseInfoInternal const KCases[] =
       
   136         {
       
   137         // [test cases entries] - do not remove
       
   138         
       
   139         ENTRY( "Start TM Server Device", CTmServerTest::StartTmServerDeviceL ),
       
   140         ENTRY( "Publish TM Server Service", CTmServerTest::PublishTmServerServiceL ),
       
   141         ENTRY( "Stop TM Server Device", CTmServerTest::StopTmServerDeviceL ),
       
   142         ENTRY( "ReStart TM Server Device", CTmServerTest::ReStartTmServerDeviceL ),         
       
   143         ENTRY( "Handle LaunchApp Command", CTmServerTest::HandleLaunchAppActionL ),
       
   144         ENTRY( "Handle Invalid AppId LaunchApp Command", CTmServerTest::HandleInvalidAppIdLaunchAppActionL ),
       
   145         ENTRY( "Handle Invalid ProfileId LaunchApp Command", CTmServerTest::HandleInvalidProfileIdLaunchAppActionL ),
       
   146         ENTRY( "Handle LaunchApp Command For Non-Existent AppID", CTmServerTest::HandleNonExistentLaunchAppActionL ),
       
   147         ENTRY( "Handle LaunchApp Command For UnAuthorized AppID", CTmServerTest::HandleUnauthorizedLaunchAppActionL ),
       
   148         ENTRY( "Handle Device Locked Condition For LaunchApp Command", CTmServerTest::HandleDeviceLockedLaunchAppActionL ),
       
   149         ENTRY( "Handle TerminateApp Command", CTmServerTest::HandleTerminateAppActionL),
       
   150         ENTRY( "Handle TerminateApp Command For Non-Existent AppID", CTmServerTest::HandleNonExistentTerminateAppActionL),
       
   151         ENTRY( "Handle Invalid AppId TerminateApp Command", CTmServerTest::HandleInvalidAppIdTerminateAppActionL),
       
   152         ENTRY( "Handle Invalid ProfileId TerminateApp Command", CTmServerTest::HandleInvalidProfileIdTerminateAppActionL),
       
   153         ENTRY( "Handle TerminateApp Command For UnAuthorized AppID", CTmServerTest::HandleUnauthorizedTerminateAppActionL),
       
   154         ENTRY( "Handle Device Locked Condition For TerminateApp Command", CTmServerTest::HandleDeviceLockedTerminateAppActionL ),
       
   155         ENTRY( "Handle GetAppStatus Command ", CTmServerTest::HandleGetAppStatusActionL ),
       
   156         ENTRY( "Handle GetAppStatus Command For All the Applications", CTmServerTest::HandleWildcardGetAppStatusActionL ),
       
   157         ENTRY( "Handle GetAppStatus Command For Invalid AppId", CTmServerTest::HandleInvalidAppIdGetAppStatusActionL ),
       
   158         ENTRY( "Handle GetAppStatus Command For Non-Existent AppID", CTmServerTest::HandleNonExistentGetAppStatusActionL ),
       
   159         ENTRY( "Handle GetAppList Command with Filter1", CTmServerTest:: HandleGetAppListActionFilter1L ), 
       
   160         ENTRY( "Handle GetAppList Command with Filter2", CTmServerTest:: HandleGetAppListActionFilter2L ),
       
   161         ENTRY( "Handle GetAppList Command with Filter3", CTmServerTest:: HandleGetAppListActionFilter3L ),  
       
   162         ENTRY( "Handle GetAppList Command with Filter4", CTmServerTest:: HandleGetAppListActionFilter4L ), 
       
   163         ENTRY( "Handle GetAppList Command with No Filter", CTmServerTest:: HandleGetAppListActionNoFilterL ), 
       
   164         ENTRY( "Handle GetAppList Command with Invalid Arg1", CTmServerTest:: HandleGetAppListActionInvalidArg1L ), 
       
   165         ENTRY( "Handle GetAppList Command with Invalid Arg2", CTmServerTest:: HandleGetAppListActionInvalidArg2L ),
       
   166         ENTRY( "Handle GetAppList Command with Invalid Arg3", CTmServerTest:: HandleGetAppListActionInvalidArg3L ),
       
   167         ENTRY( "Handle GetAppList Command with Invalid Arg4", CTmServerTest:: HandleGetAppListActionInvalidArg4L ),
       
   168         ENTRY( "Handle GetAppList Command with Invalid Arg5", CTmServerTest:: HandleGetAppListActionInvalidArg5L ),
       
   169         ENTRY( "Handle Invalid ProfileId GetAppList Command", CTmServerTest:: HandleInvalidProfileIdGetAppListActionL),
       
   170         ENTRY( "Handle Operation Rejected Condition For GetAppList Command", CTmServerTest:: HandleGetAppListActionOperationRejectedL), 
       
   171         ENTRY( "Handle SetClientProfile Command", CTmServerTest:: HandleSetClientProfileActionL ),  
       
   172         ENTRY( "Handle Invalid ProfileId SetClientProfile Command", CTmServerTest:: HandleInvalidProfileIdSetClientProfileActionL ), 
       
   173         ENTRY( "Handle Invalid Profile SetClientProfile Command", CTmServerTest:: HandleInvalidProfileSetClientProfileActionL ),
       
   174         ENTRY( "Handle Device Locked Condition For SetClientProfile Command", CTmServerTest:: HandleDeviceLockedSetClientProfileActionL ),
       
   175         ENTRY( "Handle Resource Busy Condition For SetClientProfile Command", CTmServerTest:: HandleResourceBusySetClientProfileActionL ),
       
   176         ENTRY( "Handle GetClientProfile Command", CTmServerTest:: HandleGetClientProfileActionL ), 
       
   177         ENTRY( "Handle Invalid ProfileId GetClientProfile Command", CTmServerTest:: HandleInvalidProfileIdGetClientProfileActionL ), 
       
   178         ENTRY( "Handle GetMaxNumProfiles Command", CTmServerTest:: HandleGetMaxNumProfilesActionL ), 
       
   179         ENTRY( "Handle Operation Rejected Condition For GetMaxNumProfiles Command", CTmServerTest:: HandleGetMaxNumProfilesOperationRejectedL ),
       
   180         ENTRY( "Register Duplicate Application", CTmServerTest::RegisterDuplicateAppL),  
       
   181         ENTRY( "Register Duplicate Applications", CTmServerTest::RegisterDuplicateAppsL),       
       
   182         ENTRY( "UnRegister Application", CTmServerTest::UnRegisterAppL),        
       
   183         ENTRY( "UnRegister Multiple Applications", CTmServerTest::UnRegisterAppsL),
       
   184         ENTRY( "UnRegister UnRegistered Application", CTmServerTest::UnRegisterUnRegisteredAppL),
       
   185         ENTRY( "UnRegister Multiple UnRegistered Applications", CTmServerTest::UnRegisterUnRegisteredAppsL),
       
   186         ENTRY( "Handle Event For AppStatus Update", CTmServerTest::HandleEventAppStatusUpdateL ),
       
   187         ENTRY( "Handle Event For AppList Update", CTmServerTest::HandleEventAppListUpdateL ),
       
   188         ENTRY( "Handle Event For Duplicate AppStatus Update", CTmServerTest::HandleEventDuplicateAppStatusUpdateL),
       
   189         ENTRY( "Handle Event For ProfileIdList Status Update", CTmServerTest::HandleEventProfileIdListStatusUpdateL),
       
   190                 
       
   191         // OOM Testcases    
       
   192         OOM_ENTRY( "[OOM_StartTmServerDevice]", CTmServerTest::StartTmServerDeviceL,ETrue,1,5 ),
       
   193         OOM_ENTRY( "[OOM_HandleGetAppListWithFilter]", CTmServerTest:: HandleGetAppListActionFilter1L,ETrue,1,5 ),
       
   194         OOM_ENTRY( "[OOM_HandleGetAppListWithoutFilter]", CTmServerTest:: HandleGetAppListActionNoFilterL,ETrue,1,5 ),
       
   195         OOM_ENTRY( "[OOM_HandleSetClientProfileCommand]", CTmServerTest:: HandleSetClientProfileActionL,ETrue,1,5 ),
       
   196         OOM_ENTRY( "[OOM_HandleGetAppStatusCommand]", CTmServerTest:: HandleGetAppStatusActionL,ETrue,1,5 ),
       
   197         OOM_ENTRY( "[OOM_HandleGetAppStatusForAllApplications]", CTmServerTest::HandleWildcardGetAppStatusActionL,ETrue,1,5 ),
       
   198         OOM_ENTRY( "[OOM_HandleAppStatusUpdateEvent]", CTmServerTest::HandleEventAppStatusUpdateL,ETrue,1,5 ),
       
   199         OOM_ENTRY( "[OOM_HandleDuplicateAppStatusUpdateEvent]", CTmServerTest::HandleEventDuplicateAppStatusUpdateL,ETrue,1,5 ),
       
   200         OOM_ENTRY( "[OOM_UnRegisterApplications]", CTmServerTest::UnRegisterAppsL,ETrue,1,5 )
       
   201         };
       
   202     
       
   203     // Verify that case number is valid
       
   204     if( (TUint) aCaseNumber >= sizeof( KCases ) / 
       
   205                                sizeof( TCaseInfoInternal ) )
       
   206         {
       
   207         // Invalid case, construct empty object
       
   208         TCaseInfo null( (const TText*) L"" );
       
   209         null.iMethod = NULL;
       
   210         null.iIsOOMTest = EFalse;
       
   211         null.iFirstMemoryAllocation = 0;
       
   212         null.iLastMemoryAllocation = 0;
       
   213         return null;
       
   214         } 
       
   215 
       
   216     // Construct TCaseInfo object and return it
       
   217     TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
       
   218     tmp.iMethod = KCases[ aCaseNumber ].iMethod;
       
   219     tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
       
   220     tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
       
   221     tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
       
   222     return tmp;
       
   223     }
       
   224 
       
   225 
       
   226 //========================= TEST CASES =======================================================
       
   227 
       
   228 TInt CTmServerTest::StartTmServerDeviceL ( TTestResult& aResult )
       
   229     {
       
   230     _LIT( KLogInfo, "Start Terminalmode Server Device" );
       
   231     iLog->Log( KLogInfo );
       
   232     
       
   233     iTmServerDeviceType = ETrue;
       
   234     
       
   235     //Sets the information associated with the terminal mode server device
       
   236     SetTmServerSettingsL();     
       
   237     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo,*this );
       
   238     
       
   239     //Register all the desired applications 
       
   240     RegisterApplicationsL(*iTmServer); 
       
   241     
       
   242     // Start the tmserver device and its services
       
   243     iTmServer->StartL();
       
   244 
       
   245     //Start the control point and search for device
       
   246     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   247     iTestTimer = CTestTimer::NewL(*this);
       
   248     iTestTimer->After(15);
       
   249     CActiveScheduler::Start();      
       
   250     if ( iDeviceVerified)
       
   251         {
       
   252         _LIT( KDescription , "Terminalmode Server Device started successfully");
       
   253         aResult.SetResult( KErrNone, KDescription );
       
   254         iLog->Log( KDescription );
       
   255         }
       
   256     else
       
   257         {
       
   258         aResult.iResult = KErrGeneral;
       
   259         _LIT( KDescription , "Start of Terminalmode Server Device Failed");
       
   260         aResult.SetResult( KErrNone, KDescription );
       
   261         iLog->Log( KDescription );
       
   262         }
       
   263     
       
   264     delete iTestTimer;
       
   265     iTestTimer = NULL;
       
   266     REComSession::FinalClose();
       
   267     return KErrNone;
       
   268     }
       
   269 
       
   270 TInt CTmServerTest::PublishTmServerServiceL ( TTestResult& aResult )
       
   271     {
       
   272     _LIT( KLogInfo, "Publish Terminalmode server Service" );
       
   273     iLog->Log( KLogInfo );
       
   274     
       
   275     iTmServerServiceType = ETrue;
       
   276     //Sets the information associated with the terminal mode server device
       
   277     SetTmServerSettingsL();
       
   278     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo,*this );
       
   279     
       
   280     //Register all the desired applications 
       
   281     RegisterApplicationsL(*iTmServer);   
       
   282     
       
   283     //Start the tmserver device and its services
       
   284     iTmServer->StartL();   
       
   285     
       
   286     //Start the control point and search for device
       
   287     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   288     iTestTimer = CTestTimer::NewL(*this);
       
   289     iTestTimer->After(15);
       
   290     CActiveScheduler::Start();      
       
   291     if ( iServiceVerified)
       
   292         {
       
   293         _LIT( KDescription , "Terminalmode server Service published successfully");
       
   294         aResult.SetResult( KErrNone, KDescription );
       
   295         iLog->Log( KDescription );
       
   296         }
       
   297     else
       
   298         {
       
   299         aResult.iResult = KErrGeneral;
       
   300         _LIT( KDescription , "Publishing of Terminalmode server Service Failed");
       
   301         aResult.SetResult( KErrNone, KDescription );
       
   302         iLog->Log( KDescription );
       
   303         } 
       
   304     delete iTestTimer;
       
   305     iTestTimer = NULL;
       
   306     REComSession::FinalClose();
       
   307     return KErrNone;
       
   308     }
       
   309 
       
   310 TInt CTmServerTest::StopTmServerDeviceL  ( TTestResult& aResult )
       
   311     {
       
   312     _LIT( KLogInfo, "Stop Terminalmode server Device" );
       
   313     iLog->Log( KLogInfo );
       
   314     
       
   315     iTmServerDeviceType = ETrue;
       
   316     //Sets the information associated with the terminal mode server device
       
   317     SetTmServerSettingsL();
       
   318     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo,*this );
       
   319     
       
   320     //Register all the desired applications 
       
   321     RegisterApplicationsL(*iTmServer);   
       
   322     
       
   323     //Start the tmserver device and its services
       
   324     iTmServer->StartL();  
       
   325     
       
   326     //Start the control point and search for device
       
   327     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   328     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
   329     iDiscoveryTestTimer->AfterDiscovery(15);
       
   330     CActiveScheduler::Start(); 
       
   331     if ( iDeviceVerified  )
       
   332         {
       
   333          //Stop the tmserver device and its services
       
   334          iTmServer->StopL(); 
       
   335         }    
       
   336     iTestTimer = CTestTimer::NewL(*this);
       
   337     iTestTimer->After(15);
       
   338     CActiveScheduler::Start();         
       
   339     if ( iDeviceLostVerified )
       
   340         {
       
   341         _LIT( KDescription , "Terminalmode server Device stopped successfully");
       
   342         aResult.SetResult( KErrNone, KDescription );
       
   343         iLog->Log( KDescription );
       
   344         }
       
   345     else
       
   346         {
       
   347         aResult.iResult = KErrGeneral;
       
   348         _LIT( KDescription , "Stopping of Terminalmode server Device Failed");
       
   349         aResult.SetResult( KErrNone, KDescription );
       
   350         iLog->Log( KDescription );
       
   351         }
       
   352     delete iDiscoveryTestTimer;
       
   353     iDiscoveryTestTimer = NULL;
       
   354     delete iTestTimer;
       
   355     iTestTimer = NULL;
       
   356     REComSession::FinalClose();
       
   357     return KErrNone;
       
   358     }
       
   359 
       
   360 TInt CTmServerTest::ReStartTmServerDeviceL ( TTestResult& aResult )
       
   361     {
       
   362    _LIT( KLogInfo, "ReStart Terminalmode server Device" );
       
   363     iLog->Log( KLogInfo );
       
   364     
       
   365     iTmServerDeviceType = ETrue;
       
   366     //Sets the information associated with the terminal mode server device
       
   367     SetTmServerSettingsL();
       
   368     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo,*this );
       
   369 
       
   370     //Register all the desired applications 
       
   371     RegisterApplicationsL(*iTmServer);    
       
   372     //Start the tmserver device and its services
       
   373     iTmServer->StartL();
       
   374     //Stop the tmserver device and its services
       
   375     iTmServer->StopL();
       
   376     //Start the tmserver device and its services
       
   377     iTmServer->StartL();
       
   378     
       
   379     //Start the control point and search for device
       
   380     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   381     iTestTimer = CTestTimer::NewL(*this);
       
   382     iTestTimer->After(15);
       
   383     CActiveScheduler::Start();    
       
   384     if ( iDeviceVerified)
       
   385         {
       
   386         _LIT( KDescription , "Terminalmode server Device re-started successfully");
       
   387         aResult.SetResult( KErrNone, KDescription );
       
   388         iLog->Log( KDescription );
       
   389         }
       
   390     else
       
   391         {
       
   392         aResult.iResult = KErrGeneral;
       
   393         _LIT( KDescription , "Re-starting of Terminalmode server Device Failed");
       
   394         aResult.SetResult( KErrNone, KDescription );
       
   395         iLog->Log( KDescription );
       
   396         }    
       
   397     delete iTestTimer;
       
   398     iTestTimer = NULL;
       
   399     REComSession::FinalClose();
       
   400     return KErrNone;
       
   401     } 
       
   402 
       
   403 TInt CTmServerTest::RegisterDuplicateAppL(  TTestResult& aResult  )
       
   404     {   
       
   405     _LIT( KLogInfo, "Register Duplicate Application" );
       
   406     iLog->Log( KLogInfo );
       
   407 
       
   408     //Sets the information associated with the terminal mode server device    
       
   409     SetTmServerSettingsL();
       
   410     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   411     
       
   412     _LIT8(KAppDesc, "Bluetooth A2DP Audio Server");
       
   413     iRemotableApp = CUpnpRemotableApp::NewL( KAppId2Value ,_L8("Bluetooth A2DP"));
       
   414     iRemotableApp->SetAppDescriptionL(KAppDesc());
       
   415        
       
   416     CUpnpTmInfoElement& tmInfoElement = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
   417     tmInfoElement.AddTmInfoElementL(_L8("protocolID"),_L8("BTA2DP"));
       
   418     tmInfoElement.AddTmInfoElementL(_L8("direction"),_L8("out"));
       
   419        
       
   420     CUpnpTmInfoElement& tmInfoElement1 = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
   421     tmInfoElement1.AddTmInfoElementL(_L8("appCategory"),_L8("0x0000003"));
       
   422     tmInfoElement1.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
   423        
       
   424     iRemotableApp->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathBtA2DpUnLaunched, KIconWidth2, KIconHeight2, KIconDepth1,KTestSvgMimeType)); 
       
   425     iRemotableApp->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathBtA2DpLaunched,KIconWidth3, KIconHeight3, KIconDepth1,KTestSvgMimeType));
       
   426     iRemotableApp->SetResourceStatusL(_L8("free"));
       
   427 
       
   428     // Register the application 
       
   429     iTmServer->RegisterAppL(iRemotableApp);
       
   430     
       
   431     iRemotableApp1 = CUpnpRemotableApp::NewL( KAppId2Value ,_L8("Bluetooth A2DP"));
       
   432     iRemotableApp1->SetAppDescriptionL(KAppDesc());
       
   433           
       
   434     CUpnpTmInfoElement& tmInfoElement2 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
   435     tmInfoElement2.AddTmInfoElementL(_L8("protocolID"),_L8("BTA2DP"));
       
   436     tmInfoElement2.AddTmInfoElementL(_L8("direction"),_L8("out"));
       
   437           
       
   438     CUpnpTmInfoElement& tmInfoElement3 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
   439     tmInfoElement3.AddTmInfoElementL(_L8("appCategory"),_L8("0x0000003"));
       
   440     tmInfoElement3.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
   441           
       
   442     iRemotableApp1->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathBtA2DpUnLaunched, KIconWidth2, KIconHeight2, KIconDepth1,KTestSvgMimeType)); 
       
   443     iRemotableApp1->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathBtA2DpLaunched,KIconWidth3, KIconHeight3, KIconDepth1,KTestSvgMimeType));
       
   444     iRemotableApp1->SetResourceStatusL(_L8("free"));
       
   445 
       
   446     // Register the application which is already registered
       
   447     iTmServer->RegisterAppL(iRemotableApp1);     
       
   448     
       
   449     _LIT( KDescription , "Registering of duplicate app is handled successfully");
       
   450     aResult.SetResult( KErrNone, KDescription );
       
   451     iLog->Log( KDescription );
       
   452     
       
   453     delete iTmServer;
       
   454     iTmServer = NULL;
       
   455     
       
   456     REComSession::FinalClose();
       
   457     return KErrNone;
       
   458     }
       
   459 
       
   460 TInt CTmServerTest::RegisterDuplicateAppsL(  TTestResult& aResult  )
       
   461     {   
       
   462     _LIT( KLogInfo, "Register Duplicate Applications" );
       
   463     iLog->Log( KLogInfo );
       
   464 
       
   465     //Sets the information associated with the terminal mode server device    
       
   466     SetTmServerSettingsL();
       
   467     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   468        
       
   469     _LIT8(KAppDesc, "Mobile Navigation Application");
       
   470     iRemotableApp = CUpnpRemotableApp::NewL( KAppIdValue ,_L8("Navigation"));  
       
   471     iRemotableApp->SetAppDescriptionL(KAppDesc());
       
   472     CUpnpTmInfoElement& tmInfoElement = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
   473     tmInfoElement.AddTmInfoElementL(_L8("protocolID"),_L8("VNC"));
       
   474     
       
   475     CUpnpTmInfoElement& tmInfoElement1 = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
   476     tmInfoElement1.AddTmInfoElementL(_L8("appCategory"),_L8("0x00010001"));
       
   477     tmInfoElement1.AddTmInfoElementL(_L8("trustLevel"),_L8("0x80"));
       
   478     
       
   479     CUpnpTmInfoElement& tmInfoElement2 = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::EDisplayInfo);
       
   480     tmInfoElement2.AddTmInfoElementL(_L8("contentCategory"),_L8("0x0000001"));
       
   481     tmInfoElement2.AddTmInfoElementL(_L8("contentRules"),_L8("0x00000FE"));
       
   482     tmInfoElement2.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
   483     iRemotableApp->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMaps, KIconWidth1, KIconHeight1, KIconDepth,KTestSvgMimeType));
       
   484       
       
   485     // Register the application 
       
   486     iTmServer->RegisterAppL(iRemotableApp);
       
   487     
       
   488     _LIT8(KAppDesc1, "RTP Audio Server");
       
   489     iRemotableApp1 = CUpnpRemotableApp::NewL( KAppId1Value ,_L8("RTP Server"));
       
   490     iRemotableApp1->SetAppDescriptionL(KAppDesc1());
       
   491      
       
   492     CUpnpTmInfoElement& tmInfoElement3 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
   493     tmInfoElement3.AddTmInfoElementL(_L8("protocolID"),_L8("RTP"));
       
   494     tmInfoElement3.AddTmInfoElementL(_L8("format"),_L8("99"));
       
   495     tmInfoElement3.AddTmInfoElementL(_L8("direction"),_L8("out"));
       
   496        
       
   497     CUpnpTmInfoElement& tmInfoElement4 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
   498     tmInfoElement4.AddTmInfoElementL(_L8("appCategory"),_L8("0x0000002"));
       
   499     tmInfoElement4.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
   500        
       
   501     CUpnpTmInfoElement& tmInfoElement5 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::EAudioInfo);
       
   502     tmInfoElement5.AddTmInfoElementL(_L8("audioType"),_L8("all"));    
       
   503     iRemotableApp1->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMusicUnLaunched,KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType));
       
   504     iRemotableApp1->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMusicLaunched,KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType));
       
   505     iRemotableApp1->SetResourceStatusL(_L8("free"));
       
   506      
       
   507     iRemotableAppArray.AppendL(iRemotableApp1);     
       
   508    
       
   509     iRemotableApp2 = CUpnpRemotableApp::NewL( KAppId1Value ,_L8("RTP Server"));
       
   510     iRemotableApp2->SetAppDescriptionL(KAppDesc1());
       
   511         
       
   512     CUpnpTmInfoElement& tmInfoElement6 = iRemotableApp2->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
   513     tmInfoElement6.AddTmInfoElementL(_L8("protocolID"),_L8("RTP"));
       
   514     tmInfoElement6.AddTmInfoElementL(_L8("format"),_L8("99"));
       
   515     tmInfoElement6.AddTmInfoElementL(_L8("direction"),_L8("out"));
       
   516           
       
   517     CUpnpTmInfoElement& tmInfoElement7 = iRemotableApp2->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
   518     tmInfoElement7.AddTmInfoElementL(_L8("appCategory"),_L8("0x0000002"));
       
   519     tmInfoElement7.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
   520           
       
   521     CUpnpTmInfoElement& tmInfoElement8 = iRemotableApp2->CreateTmInfoElementL(CUpnpTmInfoElement::EAudioInfo);
       
   522     tmInfoElement8.AddTmInfoElementL(_L8("audioType"),_L8("all"));    
       
   523     iRemotableApp2->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMusicUnLaunched,KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType));
       
   524     iRemotableApp2->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMusicLaunched,KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType));
       
   525     iRemotableApp2->SetResourceStatusL(_L8("free"));
       
   526     iRemotableAppArray.AppendL(iRemotableApp2);     
       
   527 
       
   528     // Register the dulplicate applications
       
   529     iTmServer->RegisterAppsL( iRemotableAppArray);     
       
   530     
       
   531     _LIT( KDescription , "Registering of duplicate applications is handled successfully");
       
   532     aResult.SetResult( KErrNone, KDescription );
       
   533     iLog->Log( KDescription );
       
   534     iRemotableAppArray.Close();
       
   535     delete iTmServer;
       
   536     iTmServer = NULL;
       
   537     
       
   538     REComSession::FinalClose();
       
   539     return KErrNone;
       
   540     }
       
   541 
       
   542 TInt CTmServerTest::UnRegisterAppL(  TTestResult& aResult  )
       
   543     {
       
   544     _LIT( KLogInfo, "UnRegister Application" );
       
   545     iLog->Log( KLogInfo );
       
   546 
       
   547     //Sets the information associated with the terminal mode server device
       
   548     SetTmServerSettingsL();
       
   549     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   550 
       
   551     //Register all the desired applications 
       
   552     RegisterApplicationsL(*iTmServer);   
       
   553     
       
   554     //Unregister the application by specifying AppId 
       
   555     iTmServer->UnRegisterApp( KAppIdValue );
       
   556     iTestTimer = CTestTimer::NewL(*this);
       
   557     iTestTimer->After(15);
       
   558     CActiveScheduler::Start();
       
   559     
       
   560     _LIT( KDescription , "Application is un-registered successfully");
       
   561     aResult.SetResult( KErrNone, KDescription );
       
   562     iLog->Log( KDescription );
       
   563     
       
   564     delete iTestTimer;
       
   565     iTestTimer = NULL;
       
   566     
       
   567     REComSession::FinalClose();
       
   568     return KErrNone;
       
   569     }
       
   570 
       
   571 TInt CTmServerTest::UnRegisterAppsL(  TTestResult& aResult  )
       
   572     {
       
   573     _LIT( KLogInfo, "UnRegister Multiple Applications" );
       
   574     iLog->Log( KLogInfo );
       
   575     
       
   576     //Sets the information associated with the terminal mode server device
       
   577     SetTmServerSettingsL();
       
   578     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   579    
       
   580     //Register all the desired applications 
       
   581     RegisterApplicationsL(*iTmServer);
       
   582     
       
   583     RArray<TUint> appIdArray;
       
   584     appIdArray.AppendL( KAppId1Value );
       
   585     appIdArray.AppendL( KAppId2Value );
       
   586 
       
   587     //Unregister multiple applications by specifying array of AppIds  
       
   588     iTmServer->UnRegisterApps( appIdArray); 
       
   589 
       
   590     iTestTimer = CTestTimer::NewL(*this);
       
   591     iTestTimer->After(15);
       
   592     CActiveScheduler::Start();
       
   593     
       
   594     _LIT( KDescription , "Multiple Applications are un-registered successfully");
       
   595     aResult.SetResult( KErrNone, KDescription );
       
   596     iLog->Log( KDescription );
       
   597     appIdArray.Close();
       
   598     
       
   599     delete iTestTimer;
       
   600     iTestTimer = NULL;     
       
   601     REComSession::FinalClose();
       
   602     return KErrNone;
       
   603     }
       
   604 
       
   605 TInt CTmServerTest::UnRegisterUnRegisteredAppL(  TTestResult& aResult  )
       
   606     {
       
   607     _LIT( KLogInfo, "UnRegister UnRegistered Application" );
       
   608     iLog->Log( KLogInfo );
       
   609     
       
   610     //Sets the information associated with the terminal mode server device
       
   611     SetTmServerSettingsL();
       
   612     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   613 
       
   614     //Register all the desired applications 
       
   615     RegisterApplicationsL(*iTmServer);
       
   616     
       
   617     //Unregister the application which is already unregistered
       
   618     iTmServer->UnRegisterApp( KNonExistentAppIdValue );
       
   619     
       
   620     iTestTimer = CTestTimer::NewL(*this);
       
   621     iTestTimer->After(15);
       
   622     CActiveScheduler::Start();
       
   623     
       
   624     _LIT( KDescription , "UnRegistering of UnRegistered Application is handled successfully");
       
   625     aResult.SetResult( KErrNone, KDescription );
       
   626     iLog->Log( KDescription );
       
   627     
       
   628     delete iTestTimer;
       
   629     iTestTimer = NULL;
       
   630     
       
   631     REComSession::FinalClose();
       
   632     return KErrNone;
       
   633     }
       
   634 
       
   635 TInt CTmServerTest::UnRegisterUnRegisteredAppsL(  TTestResult& aResult  )
       
   636     {
       
   637     _LIT( KLogInfo, "UnRegister Multiple UnRegistered Applications" );
       
   638     iLog->Log( KLogInfo );
       
   639     
       
   640     //Sets the information associated with the terminal mode server device
       
   641     SetTmServerSettingsL();
       
   642     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   643 
       
   644     //Register all the desired applications 
       
   645     RegisterApplicationsL(*iTmServer);
       
   646     
       
   647     RArray<TUint> appIdArray;
       
   648     appIdArray.AppendL( KNonExistentAppIdValue );
       
   649     appIdArray.AppendL( KNonExistentAppId1Value );
       
   650 
       
   651     //Unregister multiple applications which are already unregistered
       
   652     iTmServer->UnRegisterApps( appIdArray);
       
   653         
       
   654     iTestTimer = CTestTimer::NewL(*this);
       
   655     iTestTimer->After(15);
       
   656     CActiveScheduler::Start();
       
   657     
       
   658     _LIT( KDescription , "UnRegistering of UnRegistered Applications is handled successfully");
       
   659     aResult.SetResult( KErrNone, KDescription );
       
   660     iLog->Log( KDescription );
       
   661     
       
   662     appIdArray.Close();
       
   663     delete iTestTimer;
       
   664     iTestTimer = NULL;
       
   665     
       
   666     REComSession::FinalClose();
       
   667     return KErrNone;
       
   668     }
       
   669 
       
   670 TInt CTmServerTest::HandleEventDuplicateAppStatusUpdateL( TTestResult& aResult )
       
   671     {
       
   672     _LIT( KLogInfo, "Handle Event For Duplicate AppStatus Update" );
       
   673     iLog->Log( KLogInfo ); 
       
   674           
       
   675     iTmServerDeviceType = ETrue;
       
   676     //Sets the information associated with the terminal mode server device
       
   677     SetTmServerSettingsL();
       
   678     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   679 
       
   680     //Register all the desired applications 
       
   681     RegisterApplicationsL(*iTmServer);
       
   682        
       
   683     //Start the tmserver device and its services              
       
   684     iTmServer ->StartL();
       
   685     //Start the control point and search for device
       
   686     iSearchDevice = CDiscoverDevice::NewL(*this);          
       
   687     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
   688     iDiscoveryTestTimer->AfterDiscovery(15);
       
   689     CActiveScheduler::Start();   
       
   690     	         
       
   691     if ( iDeviceVerified  )
       
   692          { 
       
   693              //Subscribe to Services
       
   694            iSearchDevice->SubscribeToServiceL();         
       
   695           }    
       
   696     RArray<TUint> updatedAppIdList;
       
   697     updatedAppIdList.Append(KAppId1Value);
       
   698     updatedAppIdList.Append(KAppId1Value);
       
   699     //Update the status of applications which have undergone some change
       
   700     iTmServer->UpdateAppStatusL(updatedAppIdList); 
       
   701        
       
   702     iTestTimer = CTestTimer::NewL(*this);
       
   703     iTestTimer->After(15);
       
   704     CActiveScheduler::Start();
       
   705        
       
   706     if ( iStatusNotified )
       
   707          {
       
   708           _LIT( KDescription , "Handle Event For Duplicate AppStatus Update handled successfully");
       
   709           aResult.SetResult( KErrNone, KDescription );
       
   710           iLog->Log( KDescription );
       
   711          }
       
   712     else
       
   713          {
       
   714           aResult.iResult = KErrGeneral;
       
   715           _LIT( KDescription , "Handle Event For Duplicate AppStatus Update handling Failed");
       
   716           aResult.SetResult( KErrNone, KDescription );
       
   717           iLog->Log( KDescription );
       
   718          }
       
   719     updatedAppIdList.Close();  
       
   720     delete iDiscoveryTestTimer;
       
   721     iDiscoveryTestTimer = NULL;
       
   722     delete iTestTimer;
       
   723     iTestTimer = NULL;
       
   724     REComSession::FinalClose();
       
   725     return KErrNone;
       
   726   }
       
   727 
       
   728 TInt CTmServerTest::HandleEventProfileIdListStatusUpdateL( TTestResult& aResult )
       
   729     {
       
   730     _LIT( KLogInfo, "Handle Event For ProfileIdList Status Update" );
       
   731     iLog->Log( KLogInfo ); 
       
   732     
       
   733     iTmServerDeviceType = ETrue;
       
   734     //Sets the information associated with the terminal mode server device
       
   735     SetTmServerSettingsL();
       
   736     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   737 
       
   738     //Register all the desired applications
       
   739     RegisterApplicationsL(*iTmServer);
       
   740     
       
   741     //Start the tmserver device and its services
       
   742     iTmServer ->StartL();
       
   743     //Start the control point and search for device
       
   744     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   745     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
   746     iDiscoveryTestTimer->AfterDiscovery(15);
       
   747     CActiveScheduler::Start();  
       
   748     
       
   749     if ( iDeviceVerified  )
       
   750         {
       
   751         //Subscribes to a service 
       
   752         iSearchDevice->SubscribeToServiceL();
       
   753         }  
       
   754 
       
   755     RArray<TUint> UnusedProfileIdList;
       
   756     UnusedProfileIdList.Append(5);
       
   757     UnusedProfileIdList.Append(6);
       
   758     //Update the list of profile IDs for profiles which are not used
       
   759     iTmServer->UpdateUnusedProfileIdsL(UnusedProfileIdList);     
       
   760     iTestTimer = CTestTimer::NewL(*this);
       
   761     iTestTimer->After(15);
       
   762     CActiveScheduler::Start();
       
   763 
       
   764     if ( iStatusNotified )
       
   765         {
       
   766         _LIT( KDescription , "Handle Event For ProfileIdList Status Update handled successfully");
       
   767         aResult.SetResult( KErrNone, KDescription );
       
   768         iLog->Log( KDescription );
       
   769         }
       
   770     else
       
   771         {
       
   772         aResult.iResult = KErrGeneral;
       
   773         _LIT( KDescription , "Handle Event For ProfileIdList Status Update handling failed");
       
   774         aResult.SetResult( KErrNone, KDescription );
       
   775         iLog->Log( KDescription );
       
   776         }
       
   777     
       
   778        UnusedProfileIdList.Close();
       
   779        delete iDiscoveryTestTimer;
       
   780        iDiscoveryTestTimer = NULL;
       
   781        delete iTestTimer;
       
   782        iTestTimer = NULL;
       
   783        REComSession::FinalClose();
       
   784        return KErrNone;
       
   785    }
       
   786 
       
   787 TInt CTmServerTest::HandleLaunchAppActionL ( TTestResult& aResult )
       
   788     {
       
   789     _LIT( KLogInfo , "Handle LaunchApp Command" );
       
   790     iLog->Log( KLogInfo );
       
   791     
       
   792     iTmServerDeviceType = ETrue;
       
   793 
       
   794     //Sets the information associated with the terminal mode server device
       
   795     SetTmServerSettingsL();
       
   796     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   797    
       
   798     //Register all the desired applications
       
   799     RegisterApplicationsL(*iTmServer);
       
   800 
       
   801     //Start the tmserver device and its services
       
   802     iTmServer ->StartL();
       
   803     //Start the control point and search for device
       
   804     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   805     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
   806     iDiscoveryTestTimer->AfterDiscovery(15);
       
   807     CActiveScheduler::Start(); 
       
   808     	
       
   809     if ( iDeviceVerified  )
       
   810         {
       
   811          //Launch the application remotely by specifying appId and profileId 
       
   812          iSearchDevice->LaunchAppActionL(KAppId1Value,KProfileIdValue);
       
   813         }   
       
   814     
       
   815     iTestTimer = CTestTimer::NewL(*this);
       
   816     iTestTimer->After(15);
       
   817     CActiveScheduler::Start();  
       
   818 
       
   819     if (iStartApp )
       
   820         {
       
   821         _LIT( KDescription , "LaunchApp Command handled successfully");
       
   822         aResult.SetResult( KErrNone, KDescription );
       
   823         iLog->Log( KDescription );
       
   824         }
       
   825     else
       
   826         {
       
   827         aResult.iResult = KErrGeneral;
       
   828         _LIT( KDescription , "LaunchApp Command handled  Failed");
       
   829         aResult.SetResult( KErrNone, KDescription );
       
   830         iLog->Log( KDescription );
       
   831         }
       
   832     delete iDiscoveryTestTimer;
       
   833     iDiscoveryTestTimer = NULL;
       
   834     delete iTestTimer;
       
   835     iTestTimer = NULL;
       
   836     REComSession::FinalClose();
       
   837     return KErrNone;
       
   838     }
       
   839 
       
   840 TInt CTmServerTest::HandleTerminateAppActionL( TTestResult& aResult )
       
   841     {
       
   842     _LIT( KLogInfo, "Handle TerminateApp Command" );
       
   843     iLog->Log( KLogInfo );
       
   844     
       
   845     iTmServerDeviceType = ETrue;
       
   846     //Sets the information associated with the terminal mode server device
       
   847     SetTmServerSettingsL();
       
   848     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   849 
       
   850     //Register all the desired applications
       
   851     RegisterApplicationsL(*iTmServer);
       
   852 
       
   853     //Start the tmserver device and its services
       
   854     iTmServer->StartL();
       
   855 
       
   856     //Start the control point and search for device
       
   857     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   858     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
   859     iDiscoveryTestTimer->AfterDiscovery(15);
       
   860     CActiveScheduler::Start(); 
       
   861     
       
   862     if ( iDeviceVerified )
       
   863         {
       
   864         //Terminate the application which is already running
       
   865         iSearchDevice->TerminateAppActionL( KAppId1Value,KProfileIdValue);
       
   866         }
       
   867     
       
   868     iTestTimer = CTestTimer::NewL(*this);
       
   869     iTestTimer->After(15);
       
   870     CActiveScheduler::Start();  
       
   871     
       
   872     if ( iStopApp)
       
   873         {
       
   874         _LIT( KDescription , "TerminateApp Command handled successfully");
       
   875         aResult.SetResult( KErrNone, KDescription );
       
   876         iLog->Log( KDescription );
       
   877         }
       
   878     else
       
   879         {
       
   880         aResult.iResult = KErrGeneral;
       
   881         _LIT( KDescription , "TerminateApp Command handling Failed");
       
   882         aResult.SetResult( KErrNone, KDescription );
       
   883         iLog->Log( KDescription );
       
   884         }
       
   885     delete iDiscoveryTestTimer;
       
   886     iDiscoveryTestTimer = NULL;
       
   887     delete iTestTimer;
       
   888     iTestTimer = NULL;
       
   889     REComSession::FinalClose();
       
   890     return KErrNone;
       
   891     }
       
   892 
       
   893 TInt CTmServerTest::HandleInvalidAppIdLaunchAppActionL ( TTestResult& aResult )
       
   894     {
       
   895     _LIT( KLogInfo, "Handle Invalid AppId LaunchApp Command" );
       
   896     iLog->Log( KLogInfo );    
       
   897     
       
   898     iTmServerDeviceType = ETrue;
       
   899     //Sets the information associated with the terminal mode server device
       
   900     SetTmServerSettingsL();
       
   901     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   902 
       
   903     //Register all the desired applications
       
   904     RegisterApplicationsL(*iTmServer); 
       
   905     
       
   906     //Start the tmserver device and its services
       
   907     iTmServer->StartL();
       
   908     //Start the control point and search for device
       
   909     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   910     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
   911     iDiscoveryTestTimer->AfterDiscovery(15);
       
   912     CActiveScheduler::Start(); 
       
   913     
       
   914     if ( iDeviceVerified  )
       
   915         {
       
   916         //Launch the application by specifying invalid appId
       
   917         iSearchDevice->LaunchAppActionL( KInvalidAppIdValue,KProfileIdValue);
       
   918         }   
       
   919     
       
   920     iTestTimer = CTestTimer::NewL(*this);
       
   921     iTestTimer->After(15);
       
   922     CActiveScheduler::Start();  
       
   923 
       
   924     if (iStartApp )
       
   925         {
       
   926         _LIT( KDescription , "LaunchApp Command with invalid AppId handled successfully");
       
   927         aResult.SetResult( KErrNone, KDescription );
       
   928         iLog->Log( KDescription );
       
   929         }
       
   930     else
       
   931         {
       
   932         aResult.iResult = KErrGeneral;
       
   933         _LIT( KDescription , "LaunchApp Command with invalid AppId handling Failed");
       
   934         aResult.SetResult( KErrNone, KDescription );
       
   935         iLog->Log( KDescription );
       
   936         }
       
   937     delete iDiscoveryTestTimer;
       
   938     iDiscoveryTestTimer = NULL;
       
   939     delete iTestTimer;
       
   940     iTestTimer = NULL;
       
   941     REComSession::FinalClose();
       
   942     return KErrNone;
       
   943     }
       
   944 
       
   945 TInt CTmServerTest::HandleInvalidProfileIdLaunchAppActionL ( TTestResult& aResult )
       
   946     {
       
   947     _LIT( KLogInfo, "Handle Invalid ProfileId LaunchApp Command" );
       
   948     iLog->Log( KLogInfo );    
       
   949     
       
   950     iTmServerDeviceType = ETrue;
       
   951     //Sets the information associated with the terminal mode server device
       
   952     SetTmServerSettingsL();
       
   953     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
   954     //Register all the desired applications
       
   955     RegisterApplicationsL(*iTmServer);   
       
   956     //Start the tmserver device and its services
       
   957     iTmServer->StartL();
       
   958 
       
   959     //Start the control point and search for device
       
   960     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
   961     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
   962     iDiscoveryTestTimer->AfterDiscovery(15);
       
   963     CActiveScheduler::Start(); 
       
   964     
       
   965     if ( iDeviceVerified  )
       
   966         {
       
   967         //Launch the application by specifying invalid profileId
       
   968         iSearchDevice->LaunchAppActionL( KAppId1Value,KInvalidProfileIdValue);
       
   969         }   
       
   970     
       
   971     iTestTimer = CTestTimer::NewL(*this);
       
   972     iTestTimer->After(15);
       
   973     CActiveScheduler::Start();  
       
   974     if (iStartApp )
       
   975         {
       
   976         _LIT( KDescription , "LaunchApp Command with invalid ProfileId handled successfully");
       
   977         aResult.SetResult( KErrNone, KDescription );
       
   978         iLog->Log( KDescription );
       
   979         }
       
   980     else
       
   981         {
       
   982         aResult.iResult = KErrGeneral;
       
   983         _LIT( KDescription , "LaunchApp Command with invalid ProfileId handling Failed");
       
   984         aResult.SetResult( KErrNone, KDescription );
       
   985         iLog->Log( KDescription );
       
   986         }
       
   987     delete iDiscoveryTestTimer;
       
   988     iDiscoveryTestTimer = NULL;
       
   989     delete iTestTimer;
       
   990     iTestTimer = NULL;
       
   991     REComSession::FinalClose();
       
   992     return KErrNone;
       
   993     }
       
   994 
       
   995 TInt CTmServerTest::HandleNonExistentLaunchAppActionL( TTestResult& aResult )
       
   996     {
       
   997     _LIT( KLogInfo, "Handle LaunchApp Command For Non-Existent AppID" );
       
   998     iLog->Log( KLogInfo );
       
   999     
       
  1000     iTmServerDeviceType = ETrue;
       
  1001     //Sets the information associated with the terminal mode server device
       
  1002     SetTmServerSettingsL();
       
  1003     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1004 
       
  1005     //Register all the desired applications
       
  1006     RegisterApplicationsL(*iTmServer);   
       
  1007 
       
  1008     //Start the tmserver device and its services
       
  1009     iTmServer->StartL();  
       
  1010     
       
  1011     //Start the control point and search for device
       
  1012     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1013     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1014     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1015     CActiveScheduler::Start(); 
       
  1016 
       
  1017     if ( iDeviceVerified  )
       
  1018         {
       
  1019         //Launch the application by specifying non-existent appId
       
  1020         iSearchDevice->LaunchAppActionL( KNonExistentAppIdValue, KProfileIdValue );
       
  1021         }   
       
  1022     
       
  1023     iTestTimer = CTestTimer::NewL(*this);
       
  1024     iTestTimer->After(15);
       
  1025     CActiveScheduler::Start();  
       
  1026 
       
  1027     if (iStartApp )
       
  1028         {
       
  1029         _LIT( KDescription , "LaunchApp Command For Non-Existent AppID handled successfully");
       
  1030         aResult.SetResult( KErrNone, KDescription );
       
  1031         iLog->Log( KDescription );
       
  1032         }
       
  1033     else
       
  1034         {
       
  1035         aResult.iResult = KErrGeneral;
       
  1036         _LIT( KDescription , "LaunchApp Command For Non-Existent AppID handled  Failed");
       
  1037         aResult.SetResult( KErrNone, KDescription );
       
  1038         iLog->Log( KDescription );
       
  1039         }
       
  1040     delete iDiscoveryTestTimer;
       
  1041     iDiscoveryTestTimer = NULL;
       
  1042     delete iTestTimer;
       
  1043     iTestTimer = NULL;
       
  1044     REComSession::FinalClose();
       
  1045     return KErrNone;
       
  1046     }
       
  1047 
       
  1048 TInt CTmServerTest::HandleUnauthorizedLaunchAppActionL ( TTestResult& aResult )
       
  1049     {
       
  1050     _LIT( KLogInfo, "Handle LaunchApp Command For UnAuthorized AppID" );
       
  1051     iLog->Log( KLogInfo );
       
  1052     
       
  1053     iTmServerDeviceType = ETrue;
       
  1054     
       
  1055     //Sets the information associated with the terminal mode server device
       
  1056     SetTmServerSettingsL();
       
  1057     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1058 
       
  1059     //Register all the desired applications
       
  1060     RegisterApplicationsL(*iTmServer);
       
  1061     
       
  1062     //Start the tmserver device and its services
       
  1063     iTmServer ->StartL();
       
  1064 
       
  1065     //Start the control point and search for device
       
  1066     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1067     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1068     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1069     CActiveScheduler::Start(); 
       
  1070 
       
  1071     if ( iDeviceVerified  )
       
  1072         {
       
  1073          //Launch the application by specifying unauthorized appId
       
  1074          iSearchDevice->LaunchAppActionL(KAppId5Value,KProfileIdValue);
       
  1075         }   
       
  1076     
       
  1077     iTestTimer = CTestTimer::NewL(*this);
       
  1078     iTestTimer->After(15);
       
  1079     CActiveScheduler::Start();  
       
  1080     if (iStartApp )
       
  1081         {
       
  1082        _LIT( KDescription , "LaunchApp Command For UnAuthorized AppID handled successfully");
       
  1083         aResult.SetResult( KErrNone, KDescription );
       
  1084         iLog->Log( KDescription );
       
  1085         }
       
  1086     else
       
  1087         {
       
  1088         aResult.iResult = KErrGeneral;
       
  1089         _LIT( KDescription , "LaunchApp Command For UnAuthorized AppID handled  Failed");
       
  1090         aResult.SetResult( KErrNone, KDescription );
       
  1091         iLog->Log( KDescription );
       
  1092         }
       
  1093     delete iDiscoveryTestTimer;
       
  1094     iDiscoveryTestTimer = NULL;
       
  1095     delete iTestTimer;
       
  1096     iTestTimer = NULL;
       
  1097     REComSession::FinalClose();
       
  1098     return KErrNone;
       
  1099     }
       
  1100 
       
  1101 TInt CTmServerTest::HandleDeviceLockedLaunchAppActionL ( TTestResult& aResult )
       
  1102     {
       
  1103     _LIT( KLogInfo, "Handle Device Locked Condition For LaunchApp Command" );
       
  1104     iLog->Log( KLogInfo );
       
  1105     
       
  1106     iTmServerDeviceType = ETrue;
       
  1107     
       
  1108     //Sets the information associated with the terminal mode server device
       
  1109     SetTmServerSettingsL();
       
  1110     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1111 
       
  1112     //Register all the desired applications
       
  1113     RegisterApplicationsL(*iTmServer);
       
  1114     
       
  1115     //Start the tmserver device and its services
       
  1116     iTmServer ->StartL();
       
  1117 
       
  1118     //Start the control point and search for device
       
  1119     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1120     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1121     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1122     CActiveScheduler::Start(); 
       
  1123 
       
  1124     if ( iDeviceVerified  )
       
  1125         {
       
  1126          //Launch the application
       
  1127          iSearchDevice->LaunchAppActionL(KAppId4Value,KProfileIdValue);
       
  1128         }   
       
  1129     
       
  1130     iTestTimer = CTestTimer::NewL(*this);
       
  1131     iTestTimer->After(15);
       
  1132     CActiveScheduler::Start();  
       
  1133     if (iStartApp )
       
  1134         {
       
  1135        _LIT( KDescription , "LaunchApp Command For Device Locked Condition handled successfully");
       
  1136         aResult.SetResult( KErrNone, KDescription );
       
  1137         iLog->Log( KDescription );
       
  1138         }
       
  1139     else
       
  1140         {
       
  1141         aResult.iResult = KErrGeneral;
       
  1142         _LIT( KDescription , "LaunchApp Command For Device Locked Condition handling Failed");
       
  1143         aResult.SetResult( KErrNone, KDescription );
       
  1144         iLog->Log( KDescription );
       
  1145         }
       
  1146     delete iDiscoveryTestTimer;
       
  1147     iDiscoveryTestTimer = NULL;
       
  1148     delete iTestTimer;
       
  1149     iTestTimer = NULL;
       
  1150     REComSession::FinalClose();
       
  1151     return KErrNone;
       
  1152     }
       
  1153 
       
  1154 TInt CTmServerTest::HandleNonExistentTerminateAppActionL( TTestResult& aResult )
       
  1155     {
       
  1156     _LIT( KLogInfo, "Handle TerminateApp Command For Non-Existent AppID" );
       
  1157     iLog->Log( KLogInfo );
       
  1158     
       
  1159     iTmServerDeviceType = ETrue;
       
  1160     //Sets the information associated with the terminal mode server device
       
  1161     SetTmServerSettingsL();
       
  1162     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1163 
       
  1164     //Register all the desired applications
       
  1165     RegisterApplicationsL(*iTmServer);   
       
  1166     
       
  1167     //Start the tmserver device and its services
       
  1168     iTmServer->StartL();    
       
  1169 
       
  1170     //Start the control point and search for device
       
  1171     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1172     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1173     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1174     CActiveScheduler::Start(); 
       
  1175     
       
  1176     if ( iDeviceVerified )
       
  1177         {
       
  1178          //Terminate the application by specifying unauthorized appId
       
  1179          iSearchDevice->TerminateAppActionL( KNonExistentAppIdValue,KProfileIdValue );
       
  1180         }
       
  1181     
       
  1182     iTestTimer = CTestTimer::NewL(*this);
       
  1183     iTestTimer->After(15);
       
  1184     CActiveScheduler::Start();      
       
  1185     if ( iStopApp)
       
  1186         {
       
  1187         _LIT( KDescription , "TerminateApp Command For Non-Existent App ID handled successfully");
       
  1188         aResult.SetResult( KErrNone, KDescription );
       
  1189         iLog->Log( KDescription );
       
  1190         }
       
  1191     else
       
  1192         {
       
  1193         aResult.iResult = KErrGeneral;
       
  1194         _LIT( KDescription , "TerminateApp  Command handling for Non-Existent App Id Failed");
       
  1195         aResult.SetResult( KErrNone, KDescription );
       
  1196         iLog->Log( KDescription );
       
  1197         }
       
  1198     delete iDiscoveryTestTimer;
       
  1199     iDiscoveryTestTimer = NULL;
       
  1200     delete iTestTimer;
       
  1201     iTestTimer = NULL;
       
  1202     REComSession::FinalClose();
       
  1203     return KErrNone;
       
  1204     }
       
  1205 
       
  1206 TInt CTmServerTest::HandleInvalidAppIdTerminateAppActionL( TTestResult& aResult )
       
  1207     {
       
  1208     _LIT( KLogInfo, "Handle Invalid AppId TerminateApp Command" );
       
  1209     iLog->Log( KLogInfo );
       
  1210     
       
  1211     iTmServerDeviceType = ETrue;
       
  1212     //Sets the information associated with the terminal mode server device
       
  1213     SetTmServerSettingsL();
       
  1214     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1215 
       
  1216     //Register all the desired applications
       
  1217     RegisterApplicationsL(*iTmServer);  
       
  1218     
       
  1219     //Start the tmserver device and its services
       
  1220     iTmServer->StartL();    
       
  1221     //Start the control point and search for device
       
  1222     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1223     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1224     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1225     CActiveScheduler::Start(); 
       
  1226     
       
  1227     if ( iDeviceVerified )
       
  1228         {
       
  1229          //Terminate the application by specifying invalid appId
       
  1230          iSearchDevice->TerminateAppActionL(  KInvalidAppIdValue,KProfileIdValue );
       
  1231         }
       
  1232     
       
  1233     iTestTimer = CTestTimer::NewL(*this);
       
  1234     iTestTimer->After(15);
       
  1235     CActiveScheduler::Start();      
       
  1236     if ( iStopApp)
       
  1237         {
       
  1238         _LIT( KDescription , "TerminateApp Command with invalid AppId handled successfully");
       
  1239         aResult.SetResult( KErrNone, KDescription );
       
  1240         iLog->Log( KDescription );
       
  1241         }
       
  1242     else
       
  1243         {
       
  1244         aResult.iResult = KErrGeneral;
       
  1245         _LIT( KDescription , "TerminateApp Command with invalid AppId handling  Failed");
       
  1246         aResult.SetResult( KErrNone, KDescription );
       
  1247         iLog->Log( KDescription );
       
  1248         }
       
  1249     delete iDiscoveryTestTimer;
       
  1250     iDiscoveryTestTimer = NULL;
       
  1251     delete iTestTimer;
       
  1252     iTestTimer = NULL;
       
  1253     REComSession::FinalClose();
       
  1254     return KErrNone;
       
  1255     }
       
  1256 
       
  1257 TInt CTmServerTest::HandleInvalidProfileIdTerminateAppActionL( TTestResult& aResult )
       
  1258     {
       
  1259     _LIT( KLogInfo, "Handle Invalid ProfileId TerminateApp Command" );
       
  1260     iLog->Log( KLogInfo );
       
  1261     
       
  1262     iTmServerDeviceType = ETrue;
       
  1263     //Sets the information associated with the terminal mode server device
       
  1264     SetTmServerSettingsL();
       
  1265     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1266 
       
  1267     //Register all the desired applications
       
  1268     RegisterApplicationsL(*iTmServer);   
       
  1269     
       
  1270     //Start the tmserver device and its services
       
  1271     iTmServer->StartL();    
       
  1272 
       
  1273     //Start the control point and search for device
       
  1274     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1275     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1276     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1277     CActiveScheduler::Start(); 
       
  1278     
       
  1279     if ( iDeviceVerified )
       
  1280         {
       
  1281          //Terminate the application by specifying invalid profileId
       
  1282          iSearchDevice->TerminateAppActionL(  KAppId1Value,KInvalidProfileIdValue );
       
  1283         }
       
  1284     
       
  1285     iTestTimer = CTestTimer::NewL(*this);
       
  1286     iTestTimer->After(15);
       
  1287     CActiveScheduler::Start();      
       
  1288     if ( iStopApp)
       
  1289         {
       
  1290         _LIT( KDescription , "TerminateApp Command with invalid ProfileId handled successfully");
       
  1291         aResult.SetResult( KErrNone, KDescription );
       
  1292         iLog->Log( KDescription );
       
  1293         }
       
  1294     else
       
  1295         {
       
  1296         aResult.iResult = KErrGeneral;
       
  1297         _LIT( KDescription , "TerminateApp Command with invalid ProfileId handling  Failed");
       
  1298         aResult.SetResult( KErrNone, KDescription );
       
  1299         iLog->Log( KDescription );
       
  1300         }
       
  1301     delete iDiscoveryTestTimer;
       
  1302     iDiscoveryTestTimer = NULL;
       
  1303     delete iTestTimer;
       
  1304     iTestTimer = NULL;
       
  1305     REComSession::FinalClose();
       
  1306     return KErrNone;
       
  1307     }
       
  1308 
       
  1309 TInt CTmServerTest::HandleUnauthorizedTerminateAppActionL( TTestResult& aResult )
       
  1310     {
       
  1311     _LIT( KLogInfo, "Handle TerminateApp Command UnAuthorized AppID" );
       
  1312     iLog->Log( KLogInfo );
       
  1313     
       
  1314     iTmServerDeviceType = ETrue;
       
  1315 
       
  1316     //Sets the information associated with the terminal mode server device
       
  1317     SetTmServerSettingsL();
       
  1318     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1319 
       
  1320     //Register all the desired applications
       
  1321     RegisterApplicationsL(*iTmServer);    
       
  1322     
       
  1323     //Start the tmserver device and its services
       
  1324     iTmServer->StartL();    
       
  1325 
       
  1326     //Start the control point and search for device
       
  1327     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1328     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1329     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1330     CActiveScheduler::Start(); 
       
  1331     
       
  1332     if ( iDeviceVerified )
       
  1333         {
       
  1334          //Terminate the application by specifying unauthorized appId
       
  1335          iSearchDevice->TerminateAppActionL( KAppId5Value,KProfileIdValue );
       
  1336         }
       
  1337     
       
  1338     iTestTimer = CTestTimer::NewL(*this);
       
  1339     iTestTimer->After(15);
       
  1340     CActiveScheduler::Start();     
       
  1341     if ( iStopApp)
       
  1342         {
       
  1343         _LIT( KDescription , "TerminateApp Command For Un-Authorized App ID handled successfully");
       
  1344         aResult.SetResult( KErrNone, KDescription );
       
  1345         iLog->Log( KDescription );
       
  1346         }
       
  1347     else
       
  1348         {
       
  1349         aResult.iResult = KErrGeneral;
       
  1350         _LIT( KDescription , "TerminateApp  Command handling For Un-Authorized App ID Failed");
       
  1351         aResult.SetResult( KErrNone, KDescription );
       
  1352         iLog->Log( KDescription );
       
  1353         }
       
  1354     delete iDiscoveryTestTimer;
       
  1355     iDiscoveryTestTimer = NULL;
       
  1356     delete iTestTimer;
       
  1357     iTestTimer = NULL;
       
  1358     REComSession::FinalClose();
       
  1359     return KErrNone;
       
  1360     }
       
  1361 
       
  1362 TInt CTmServerTest::HandleDeviceLockedTerminateAppActionL ( TTestResult& aResult )
       
  1363     {
       
  1364     _LIT( KLogInfo, "Handle Device Locked Condition For TerminateApp Command" );
       
  1365     iLog->Log( KLogInfo );
       
  1366     
       
  1367     iTmServerDeviceType = ETrue;
       
  1368     
       
  1369     //Sets the information associated with the terminal mode server device
       
  1370     SetTmServerSettingsL();
       
  1371     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1372 
       
  1373     //Register all the desired applications
       
  1374     RegisterApplicationsL(*iTmServer);
       
  1375     
       
  1376     //Start the tmserver device and its services
       
  1377     iTmServer ->StartL();
       
  1378 
       
  1379     //Start the control point and search for device
       
  1380     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1381     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1382     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1383     CActiveScheduler::Start(); 
       
  1384 
       
  1385     if ( iDeviceVerified  )
       
  1386         {
       
  1387          //Terminate the application
       
  1388          iSearchDevice->TerminateAppActionL(KAppId4Value,KProfileIdValue);
       
  1389         }   
       
  1390     
       
  1391     iTestTimer = CTestTimer::NewL(*this);
       
  1392     iTestTimer->After(15);
       
  1393     CActiveScheduler::Start();  
       
  1394     if (iStopApp )
       
  1395         {
       
  1396        _LIT( KDescription , "TerminateApp Command For Device Locked Condition handled successfully");
       
  1397         aResult.SetResult( KErrNone, KDescription );
       
  1398         iLog->Log( KDescription );
       
  1399         }
       
  1400     else
       
  1401         {
       
  1402         aResult.iResult = KErrGeneral;
       
  1403         _LIT( KDescription , "TerminateApp Command For Device Locked Condition handling Failed");
       
  1404         aResult.SetResult( KErrNone, KDescription );
       
  1405         iLog->Log( KDescription );
       
  1406         }
       
  1407     delete iDiscoveryTestTimer;
       
  1408     iDiscoveryTestTimer = NULL;
       
  1409     delete iTestTimer;
       
  1410     iTestTimer = NULL;
       
  1411     REComSession::FinalClose();
       
  1412     return KErrNone;
       
  1413     }
       
  1414 
       
  1415 TInt CTmServerTest::HandleGetAppStatusActionL ( TTestResult& aResult )
       
  1416     {
       
  1417     _LIT( KLogInfo, "Handle GetAppStatus Command" );
       
  1418     iLog->Log( KLogInfo );
       
  1419     
       
  1420     iTmServerDeviceType = ETrue;
       
  1421 
       
  1422     //Sets the information associated with the terminal mode server device
       
  1423     SetTmServerSettingsL();
       
  1424     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1425 
       
  1426     //Register all the desired applications
       
  1427     RegisterApplicationsL(*iTmServer);     
       
  1428 
       
  1429     //Start the tmserver device and its services
       
  1430     iTmServer->StartL();   
       
  1431     
       
  1432     //Start the control point and search for device
       
  1433     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1434     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1435     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1436     CActiveScheduler::Start(); 
       
  1437 
       
  1438     if ( iDeviceVerified  )
       
  1439         {
       
  1440          //Retrieve the status of application
       
  1441          iSearchDevice->GetAppStatusActionL( KAppId1Value );
       
  1442         }
       
  1443     
       
  1444     iTestTimer = CTestTimer::NewL(*this);
       
  1445     iTestTimer->After(15);
       
  1446     CActiveScheduler::Start();  
       
  1447 
       
  1448     if (iGetAppStatus)
       
  1449         {
       
  1450         _LIT( KDescription , "GetAppStatus Command  handled successfully");
       
  1451         aResult.SetResult( KErrNone, KDescription );
       
  1452         iLog->Log( KDescription );
       
  1453         }
       
  1454     else
       
  1455         {
       
  1456         aResult.iResult = KErrGeneral;
       
  1457         _LIT( KDescription , "GetAppStatus Command handling Failed");
       
  1458         aResult.SetResult( KErrNone, KDescription );
       
  1459         iLog->Log( KDescription );
       
  1460         }
       
  1461     delete iDiscoveryTestTimer;
       
  1462     iDiscoveryTestTimer = NULL;
       
  1463     delete iTestTimer;
       
  1464     iTestTimer = NULL;
       
  1465     REComSession::FinalClose();
       
  1466     return KErrNone;
       
  1467     }
       
  1468 
       
  1469 TInt CTmServerTest::HandleWildcardGetAppStatusActionL( TTestResult& aResult )
       
  1470     {
       
  1471     _LIT( KLogInfo, "Handle GetAppStatus Command For All the Applications" );
       
  1472     iLog->Log( KLogInfo );
       
  1473     
       
  1474     iTmServerDeviceType = ETrue;
       
  1475 
       
  1476     //Sets the information associated with the terminal mode server device
       
  1477     SetTmServerSettingsL();
       
  1478     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1479     
       
  1480     //Register all the desired applications
       
  1481     RegisterApplicationsL(*iTmServer); 
       
  1482     
       
  1483     //Start the tmserver device and its services
       
  1484     iTmServer->StartL();   
       
  1485 
       
  1486     //Start the control point and search for device
       
  1487     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1488     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1489     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1490     CActiveScheduler::Start(); 
       
  1491 
       
  1492     if ( iDeviceVerified  )
       
  1493         {
       
  1494          //Retrieve the status of all the application
       
  1495          iSearchDevice->GetAppStatusActionL( KAppId5Value );
       
  1496         }
       
  1497     
       
  1498     iTestTimer = CTestTimer::NewL(*this);
       
  1499     iTestTimer->After(15);
       
  1500     CActiveScheduler::Start();  
       
  1501 
       
  1502     if (iGetAppStatus)
       
  1503         {
       
  1504         _LIT( KDescription , "GetAppStatus Command  handled successfully");
       
  1505         aResult.SetResult( KErrNone, KDescription );
       
  1506         iLog->Log( KDescription );
       
  1507         }
       
  1508     else
       
  1509         {
       
  1510         aResult.iResult = KErrGeneral;
       
  1511         _LIT( KDescription , "GetAppStatus Command handling Failed");
       
  1512         aResult.SetResult( KErrNone, KDescription );
       
  1513         iLog->Log( KDescription );
       
  1514         }
       
  1515     delete iDiscoveryTestTimer;
       
  1516     iDiscoveryTestTimer = NULL;
       
  1517     delete iTestTimer;
       
  1518     iTestTimer = NULL;
       
  1519     REComSession::FinalClose();
       
  1520     return KErrNone;
       
  1521     }
       
  1522 
       
  1523 
       
  1524 TInt CTmServerTest::HandleInvalidAppIdGetAppStatusActionL ( TTestResult& aResult )
       
  1525     {
       
  1526     _LIT( KLogInfo, "Handle GetAppStatus Command For Invalid AppId" );
       
  1527     iLog->Log( KLogInfo );
       
  1528     
       
  1529     iTmServerDeviceType = ETrue;
       
  1530 
       
  1531     //Sets the information associated with the terminal mode server device
       
  1532     SetTmServerSettingsL();
       
  1533     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1534     
       
  1535     //Register all the desired applications
       
  1536     RegisterApplicationsL(*iTmServer);    
       
  1537     
       
  1538     //Start the tmserver device and its services
       
  1539     iTmServer->StartL();
       
  1540     
       
  1541     //Start the control point and search for device
       
  1542     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1543     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1544     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1545     CActiveScheduler::Start(); 
       
  1546 
       
  1547     if ( iDeviceVerified  )
       
  1548         { 
       
  1549          //Retrieve the status of the application by specifying invalid appId
       
  1550          iSearchDevice->GetAppStatusActionL( KInvalidAppIdValue );
       
  1551         }
       
  1552     
       
  1553     iTestTimer = CTestTimer::NewL(*this);
       
  1554     iTestTimer->After(15);
       
  1555     CActiveScheduler::Start();  
       
  1556 
       
  1557     if (iGetAppStatus)
       
  1558         {
       
  1559         _LIT( KDescription , "GetAppStatus Command with invalid AppId  handled successfully");
       
  1560         aResult.SetResult( KErrNone, KDescription );
       
  1561         iLog->Log( KDescription );
       
  1562         }
       
  1563     else
       
  1564         {
       
  1565         aResult.iResult = KErrGeneral;
       
  1566         _LIT( KDescription , "GetAppStatus Command with invalid AppId handling  Failed");
       
  1567         aResult.SetResult( KErrNone, KDescription );
       
  1568         iLog->Log( KDescription );
       
  1569         }
       
  1570     delete iDiscoveryTestTimer;
       
  1571     iDiscoveryTestTimer = NULL;
       
  1572     delete iTestTimer;
       
  1573     iTestTimer = NULL;
       
  1574     REComSession::FinalClose();
       
  1575     return KErrNone;
       
  1576     }
       
  1577 
       
  1578 TInt CTmServerTest::HandleNonExistentGetAppStatusActionL( TTestResult& aResult )
       
  1579     {
       
  1580     _LIT( KLogInfo, "Handle GetAppStatus Command For Non-Existent AppID" );
       
  1581     iLog->Log( KLogInfo );
       
  1582     
       
  1583     iTmServerDeviceType = ETrue;
       
  1584 
       
  1585     //Sets the information associated with the terminal mode server device
       
  1586     SetTmServerSettingsL();
       
  1587     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1588     
       
  1589     //Register all the desired applications
       
  1590     RegisterApplicationsL(*iTmServer);  
       
  1591     
       
  1592     //Start the tmserver device and its services
       
  1593     iTmServer->StartL();  
       
  1594     
       
  1595     //Start the control point and search for device
       
  1596     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1597     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1598     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1599     CActiveScheduler::Start(); 
       
  1600 
       
  1601     if ( iDeviceVerified  )
       
  1602         {
       
  1603          //Retrieve the status of the application by specifying non existent appId
       
  1604          iSearchDevice->GetAppStatusActionL( KNonExistentAppIdValue );
       
  1605         }
       
  1606     
       
  1607     iTestTimer = CTestTimer::NewL(*this);
       
  1608     iTestTimer->After(15);
       
  1609     CActiveScheduler::Start();  
       
  1610 
       
  1611     if (iGetAppStatus)
       
  1612         {
       
  1613         _LIT( KDescription , "GetAppStatus Command for Non-Existent App ID handled successfully");
       
  1614         aResult.SetResult( KErrNone, KDescription );
       
  1615         iLog->Log( KDescription );
       
  1616         }
       
  1617     else
       
  1618         {
       
  1619         aResult.iResult = KErrGeneral;
       
  1620         _LIT( KDescription , "GetAppStatus Command handling for Non-Existent App ID Failed");
       
  1621         aResult.SetResult( KErrNone, KDescription );
       
  1622         iLog->Log( KDescription );
       
  1623         }
       
  1624     delete iDiscoveryTestTimer;
       
  1625     iDiscoveryTestTimer = NULL;
       
  1626     delete iTestTimer;
       
  1627     iTestTimer = NULL;
       
  1628     REComSession::FinalClose();
       
  1629     return KErrNone;
       
  1630     }
       
  1631 
       
  1632 TInt CTmServerTest::HandleEventAppStatusUpdateL( TTestResult& aResult )
       
  1633  {
       
  1634     _LIT( KLogInfo, "Handle Event For AppStatus Update" );
       
  1635     iLog->Log( KLogInfo ); 
       
  1636        
       
  1637     iTmServerDeviceType = ETrue;
       
  1638     //Sets the information associated with the terminal mode server device
       
  1639     SetTmServerSettingsL();
       
  1640     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1641 
       
  1642     //Register all the desired applications 
       
  1643     RegisterApplicationsL(*iTmServer);
       
  1644     
       
  1645     //Start the tmserver device and its services              
       
  1646     iTmServer ->StartL();
       
  1647 
       
  1648     //Start the control point and search for device
       
  1649     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1650     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1651     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1652     CActiveScheduler::Start(); 
       
  1653     	       
       
  1654     if ( iDeviceVerified  )
       
  1655          {
       
  1656           //Subscribes to a service 
       
  1657           iSearchDevice->SubscribeToServiceL();
       
  1658          }
       
  1659     RArray<TUint> updatedAppIdList;
       
  1660     updatedAppIdList.Append(KAppId1Value);
       
  1661     updatedAppIdList.Append(KAppId2Value);
       
  1662     
       
  1663     //Update the status of applications which have undergone some change
       
  1664     iTmServer->UpdateAppStatusL(updatedAppIdList); 
       
  1665     
       
  1666     iTestTimer = CTestTimer::NewL(*this);
       
  1667     iTestTimer->After(15);
       
  1668     CActiveScheduler::Start();
       
  1669     
       
  1670     if ( iStatusNotified )
       
  1671          {
       
  1672           _LIT( KDescription , "Handle Event For AppStatus Update handled successfully");
       
  1673           aResult.SetResult( KErrNone, KDescription );
       
  1674           iLog->Log( KDescription );
       
  1675          }
       
  1676     else
       
  1677          {
       
  1678           aResult.iResult = KErrGeneral;
       
  1679           _LIT( KDescription , "Handle Event For AppStatus Update handling Failed");
       
  1680           aResult.SetResult( KErrNone, KDescription );
       
  1681           iLog->Log( KDescription );
       
  1682          }
       
  1683     updatedAppIdList.Close();
       
  1684     delete iDiscoveryTestTimer;
       
  1685     iDiscoveryTestTimer = NULL;
       
  1686     delete iTestTimer;
       
  1687     iTestTimer = NULL;
       
  1688     REComSession::FinalClose();
       
  1689     return KErrNone;
       
  1690   }
       
  1691 
       
  1692 TInt CTmServerTest::HandleEventAppListUpdateL( TTestResult& aResult )
       
  1693     {
       
  1694     _LIT( KLogInfo, "Handle Event For AppList Update" );
       
  1695     iLog->Log( KLogInfo ); 
       
  1696        
       
  1697     iTmServerDeviceType = ETrue;
       
  1698     //Sets the information associated with the terminal mode server device
       
  1699     SetTmServerSettingsL();
       
  1700     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1701 
       
  1702     //Register all the desired applications 
       
  1703     RegisterApplicationsL(*iTmServer);
       
  1704     
       
  1705     //Start the tmserver device and its services              
       
  1706     iTmServer ->StartL();
       
  1707 
       
  1708     //Start the control point and search for device
       
  1709     iSearchDevice = CDiscoverDevice::NewL(*this);          
       
  1710     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1711     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1712     CActiveScheduler::Start();  
       
  1713           
       
  1714     if ( iDeviceVerified  )
       
  1715          {
       
  1716           //Subscribes to a service 
       
  1717           iSearchDevice->SubscribeToServiceL();        
       
  1718          }  
       
  1719       
       
  1720     TInt errorCode;
       
  1721     CUpnpRemotableApp& aRemotableApp = iTmServer->GetRemotableApp(KAppIdValue ,errorCode );
       
  1722     if (errorCode == KErrNone)
       
  1723         { 
       
  1724          _LIT8(KAppDesc, "Mobile Device Display");
       
  1725          aRemotableApp.SetAppDescriptionL(KAppDesc());
       
  1726         }
       
  1727     RArray<TUint> updatedAppIdList;
       
  1728     updatedAppIdList.Append(KAppIdValue);
       
  1729     updatedAppIdList.Append(KAppId2Value);
       
  1730    
       
  1731     //Update the list of applications which have been modified to/from the list
       
  1732     iTmServer->UpdateAppListL(updatedAppIdList);      
       
  1733     iTestTimer = CTestTimer::NewL(*this);
       
  1734     iTestTimer->After(15);
       
  1735     CActiveScheduler::Start();
       
  1736     
       
  1737     if ( iStatusNotified )
       
  1738          {
       
  1739           _LIT( KDescription , "Handle Event For AppList Update handled successfully");
       
  1740           aResult.SetResult( KErrNone, KDescription );
       
  1741           iLog->Log( KDescription );
       
  1742          }
       
  1743     else
       
  1744          {
       
  1745           aResult.iResult = KErrGeneral;
       
  1746           _LIT( KDescription , "Handle Event For AppList Update handling Failed");
       
  1747           aResult.SetResult( KErrNone, KDescription );
       
  1748           iLog->Log( KDescription );
       
  1749          }
       
  1750     updatedAppIdList.Close();
       
  1751     delete iDiscoveryTestTimer;
       
  1752     iDiscoveryTestTimer = NULL;
       
  1753     delete iTestTimer;
       
  1754     iTestTimer = NULL;
       
  1755     REComSession::FinalClose();
       
  1756     return KErrNone;
       
  1757   }
       
  1758 
       
  1759 TInt CTmServerTest::HandleGetAppListActionFilter1L ( TTestResult& aResult )
       
  1760     {
       
  1761     _LIT( KLogInfo, "Handle GetAppList Command with Filter1" );
       
  1762     iLog->Log( KLogInfo );
       
  1763     
       
  1764     iTmServerDeviceType = ETrue;
       
  1765 
       
  1766     //Sets the information associated with the terminal mode server device
       
  1767     SetTmServerSettingsL();
       
  1768     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1769     
       
  1770     //Register all the desired applications
       
  1771     RegisterApplicationsL(*iTmServer);  
       
  1772     
       
  1773     //Start the tmserver device and its services
       
  1774     iTmServer->StartL();   
       
  1775     
       
  1776     //Start the control point and search for device
       
  1777     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1778     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1779     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1780     CActiveScheduler::Start(); 
       
  1781 
       
  1782     if ( iDeviceVerified  )
       
  1783         {
       
  1784           //Retrieve the list of applications by specifying filter value
       
  1785           iSearchDevice->GetAppListActionL(KAppListFilterValue1(),KProfileIdValue);
       
  1786         }
       
  1787     
       
  1788     iTestTimer = CTestTimer::NewL(*this);
       
  1789     iTestTimer->After(15);
       
  1790     CActiveScheduler::Start();      
       
  1791     if (iGetAppList)
       
  1792         {
       
  1793         _LIT( KDescription , "GetAppList Command with Filter1 handled successfully");
       
  1794         aResult.SetResult( KErrNone, KDescription );
       
  1795         iLog->Log( KDescription );
       
  1796         }
       
  1797     else
       
  1798         {
       
  1799         aResult.iResult = KErrGeneral;
       
  1800         _LIT( KDescription , "GetAppList Command with Filter1 handling Failed");
       
  1801         aResult.SetResult( KErrNone, KDescription );
       
  1802         iLog->Log( KDescription );
       
  1803         }
       
  1804     delete iDiscoveryTestTimer;
       
  1805     iDiscoveryTestTimer = NULL;
       
  1806     delete iTestTimer;
       
  1807     iTestTimer = NULL;
       
  1808     REComSession::FinalClose();
       
  1809     return KErrNone;
       
  1810     }
       
  1811 
       
  1812 TInt CTmServerTest::HandleGetAppListActionFilter2L ( TTestResult& aResult )
       
  1813     {
       
  1814     _LIT( KLogInfo, "Handle GetAppList with Filter2 Command" );
       
  1815     iLog->Log( KLogInfo );
       
  1816     
       
  1817     iTmServerDeviceType = ETrue;
       
  1818 
       
  1819     //Sets the information associated with the terminal mode server device
       
  1820     SetTmServerSettingsL();
       
  1821     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1822 
       
  1823     //Register all the desired applications
       
  1824     RegisterApplicationsL(*iTmServer); 
       
  1825     
       
  1826     //Start the tmserver device and its services
       
  1827     iTmServer->StartL();   
       
  1828     
       
  1829     //Start the control point and search for device
       
  1830     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1831     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1832     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1833     CActiveScheduler::Start(); 
       
  1834 
       
  1835     if ( iDeviceVerified  )
       
  1836         {
       
  1837          //Retrieve the list of applications by specifying filter value
       
  1838          iSearchDevice->GetAppListActionL(KAppListFilterValue2(),KProfileIdValue);
       
  1839         }
       
  1840     
       
  1841     iTestTimer = CTestTimer::NewL(*this);
       
  1842     iTestTimer->After(15);
       
  1843     CActiveScheduler::Start();      
       
  1844     if (iGetAppList)
       
  1845         {
       
  1846         _LIT( KDescription , "GetAppList Command with Filter2 handled successfully");
       
  1847         aResult.SetResult( KErrNone, KDescription );
       
  1848         iLog->Log( KDescription );
       
  1849         }
       
  1850     else
       
  1851         {
       
  1852         aResult.iResult = KErrGeneral;
       
  1853         _LIT( KDescription , "GetAppList Command with Filter2 handling Failed");
       
  1854         aResult.SetResult( KErrNone, KDescription );
       
  1855         iLog->Log( KDescription );
       
  1856         }
       
  1857     delete iDiscoveryTestTimer;
       
  1858     iDiscoveryTestTimer = NULL;
       
  1859     delete iTestTimer;
       
  1860     iTestTimer = NULL;
       
  1861     REComSession::FinalClose();
       
  1862     return KErrNone;
       
  1863     }
       
  1864 
       
  1865 TInt CTmServerTest::HandleGetAppListActionFilter3L ( TTestResult& aResult )
       
  1866     {
       
  1867     _LIT( KLogInfo, "Handle GetAppList with Filter3 Command" );
       
  1868     iLog->Log( KLogInfo );
       
  1869     
       
  1870     iTmServerDeviceType = ETrue;
       
  1871 
       
  1872     //Sets the information associated with the terminal mode server device
       
  1873     SetTmServerSettingsL();
       
  1874     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1875 
       
  1876     //Register all the desired applications
       
  1877     RegisterApplicationsL(*iTmServer);  
       
  1878     
       
  1879     //Start the tmserver device and its services
       
  1880     iTmServer->StartL();   
       
  1881     
       
  1882     //Start the control point and search for device
       
  1883     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1884     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1885     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1886     CActiveScheduler::Start(); 
       
  1887 
       
  1888     if ( iDeviceVerified  )
       
  1889         {
       
  1890          //Retrieve the list of applications by specifying filter value 
       
  1891          iSearchDevice->GetAppListActionL(KAppListFilterValue3(),KProfileIdValue);
       
  1892         }
       
  1893     
       
  1894     iTestTimer = CTestTimer::NewL(*this);
       
  1895     iTestTimer->After(15);
       
  1896     CActiveScheduler::Start();      
       
  1897     if (iGetAppList)
       
  1898         {
       
  1899         _LIT( KDescription , "GetAppList Command with Filter3 handled successfully");
       
  1900         aResult.SetResult( KErrNone, KDescription );
       
  1901         iLog->Log( KDescription );
       
  1902         }
       
  1903     else
       
  1904         {
       
  1905         aResult.iResult = KErrGeneral;
       
  1906         _LIT( KDescription , "GetAppList Command with Filter3 handling Failed");
       
  1907         aResult.SetResult( KErrNone, KDescription );
       
  1908         iLog->Log( KDescription );
       
  1909         }
       
  1910     delete iDiscoveryTestTimer;
       
  1911     iDiscoveryTestTimer = NULL;
       
  1912     delete iTestTimer;
       
  1913     iTestTimer = NULL;
       
  1914     REComSession::FinalClose();
       
  1915     return KErrNone;
       
  1916     }
       
  1917 
       
  1918 TInt CTmServerTest::HandleGetAppListActionFilter4L ( TTestResult& aResult )
       
  1919     {
       
  1920     _LIT( KLogInfo, "Handle GetAppList with Filter4 Command" );
       
  1921     iLog->Log( KLogInfo );
       
  1922     
       
  1923     iTmServerDeviceType = ETrue;
       
  1924 
       
  1925     //Sets the information associated with the terminal mode server device
       
  1926     SetTmServerSettingsL();
       
  1927     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1928 
       
  1929     //Register all the desired applications
       
  1930     RegisterApplicationsL(*iTmServer);  
       
  1931     
       
  1932     //Start the tmserver device and its services
       
  1933     iTmServer->StartL();   
       
  1934     
       
  1935     //Start the control point and search for device
       
  1936     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1937     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1938     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1939     CActiveScheduler::Start(); 
       
  1940 
       
  1941     if ( iDeviceVerified  )
       
  1942         {
       
  1943          //Retrieve the list of applications by specifying filter value 
       
  1944          iSearchDevice->GetAppListActionL(KAppListFilterValue4(),KProfileIdValue);
       
  1945         }
       
  1946     
       
  1947     iTestTimer = CTestTimer::NewL(*this);
       
  1948     iTestTimer->After(15);
       
  1949     CActiveScheduler::Start();      
       
  1950     if (iGetAppList)
       
  1951         {
       
  1952         _LIT( KDescription , "GetAppList Command with Filter4 handled successfully");
       
  1953         aResult.SetResult( KErrNone, KDescription );
       
  1954         iLog->Log( KDescription );
       
  1955         }
       
  1956     else
       
  1957         {
       
  1958         aResult.iResult = KErrGeneral;
       
  1959         _LIT( KDescription , "GetAppList Command with Filter4 handling Failed");
       
  1960         aResult.SetResult( KErrNone, KDescription );
       
  1961         iLog->Log( KDescription );
       
  1962         }
       
  1963     delete iDiscoveryTestTimer;
       
  1964     iDiscoveryTestTimer = NULL;
       
  1965     delete iTestTimer;
       
  1966     iTestTimer = NULL;
       
  1967     REComSession::FinalClose();
       
  1968     return KErrNone;
       
  1969     }
       
  1970 
       
  1971 TInt CTmServerTest::HandleGetAppListActionInvalidArg1L ( TTestResult& aResult )
       
  1972     {
       
  1973     _LIT( KLogInfo, "Handle GetAppList Command with Invalid Arg1" );
       
  1974     iLog->Log( KLogInfo );
       
  1975     
       
  1976     iTmServerDeviceType = ETrue;
       
  1977 
       
  1978     //Sets the information associated with the terminal mode server device
       
  1979     SetTmServerSettingsL();
       
  1980     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  1981 
       
  1982     //Register all the desired applications
       
  1983     RegisterApplicationsL(*iTmServer);    
       
  1984     
       
  1985     //Start the tmserver device and its services
       
  1986     iTmServer->StartL();   
       
  1987     
       
  1988     //Start the control point and search for device
       
  1989     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  1990     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  1991     iDiscoveryTestTimer->AfterDiscovery(15);
       
  1992     CActiveScheduler::Start(); 
       
  1993 
       
  1994     if ( iDeviceVerified  )
       
  1995         {
       
  1996           _LIT8(KInvalidFilter1,"\"name=\"*Audio*\"" );
       
  1997          //Retrieve the list of applications by specifying invalid filter value
       
  1998          iSearchDevice->GetAppListActionL(KInvalidFilter1(),KProfileIdValue);  
       
  1999         }
       
  2000     
       
  2001     iTestTimer = CTestTimer::NewL(*this);
       
  2002     iTestTimer->After(15);
       
  2003     CActiveScheduler::Start();      
       
  2004     if (iGetAppList)
       
  2005         {
       
  2006         _LIT( KDescription , "GetAppList Command with Invalid Arg1 handled successfully");
       
  2007         aResult.SetResult( KErrNone, KDescription );
       
  2008         iLog->Log( KDescription );
       
  2009         }
       
  2010     else
       
  2011         {
       
  2012         aResult.iResult = KErrGeneral;
       
  2013         _LIT( KDescription , "GetAppList Command with Invalid Arg1 handling Failed");
       
  2014         aResult.SetResult( KErrNone, KDescription );
       
  2015         iLog->Log( KDescription );
       
  2016         }
       
  2017     delete iDiscoveryTestTimer;
       
  2018     iDiscoveryTestTimer = NULL;
       
  2019     delete iTestTimer;
       
  2020     iTestTimer = NULL;
       
  2021     REComSession::FinalClose();
       
  2022     return KErrNone;
       
  2023     }
       
  2024 
       
  2025 
       
  2026 TInt CTmServerTest::HandleGetAppListActionInvalidArg2L ( TTestResult& aResult )
       
  2027     {
       
  2028     _LIT( KLogInfo, "Handle GetAppList Command with Invalid Arg2" );
       
  2029     iLog->Log( KLogInfo );
       
  2030     
       
  2031     iTmServerDeviceType = ETrue;
       
  2032 
       
  2033     //Sets the information associated with the terminal mode server device
       
  2034     SetTmServerSettingsL();
       
  2035     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2036 
       
  2037     //Register all the desired applications
       
  2038     RegisterApplicationsL(*iTmServer);  
       
  2039     
       
  2040     //Start the tmserver device and its services
       
  2041     iTmServer->StartL();   
       
  2042     
       
  2043     //Start the control point and search for device
       
  2044     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2045     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2046     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2047     CActiveScheduler::Start(); 
       
  2048 
       
  2049     if ( iDeviceVerified  )
       
  2050         {
       
  2051          _LIT8(KInvalidFilter2, "\"name=\"*nav*\",appInfo=\"*\"\""); 
       
  2052          //Retrieve the list of applications by specifying invalid filter value
       
  2053          iSearchDevice->GetAppListActionL(KInvalidFilter2(),KProfileIdValue);
       
  2054         }
       
  2055     
       
  2056     iTestTimer = CTestTimer::NewL(*this);
       
  2057     iTestTimer->After(15);
       
  2058     CActiveScheduler::Start();      
       
  2059     if (iGetAppList)
       
  2060         {
       
  2061         _LIT( KDescription , "GetAppList Command with Invalid Arg2 handled successfully");
       
  2062         aResult.SetResult( KErrNone, KDescription );
       
  2063         iLog->Log( KDescription );
       
  2064         }
       
  2065     else
       
  2066         {
       
  2067         aResult.iResult = KErrGeneral;
       
  2068         _LIT( KDescription , "GetAppList Command with Invalid Arg2 handling Failed");
       
  2069         aResult.SetResult( KErrNone, KDescription );
       
  2070         iLog->Log( KDescription );
       
  2071         }
       
  2072     delete iDiscoveryTestTimer;
       
  2073     iDiscoveryTestTimer = NULL;
       
  2074     delete iTestTimer;
       
  2075     iTestTimer = NULL;
       
  2076     REComSession::FinalClose();
       
  2077     return KErrNone;
       
  2078     }
       
  2079 
       
  2080 TInt CTmServerTest::HandleGetAppListActionInvalidArg3L ( TTestResult& aResult )
       
  2081     {
       
  2082     _LIT( KLogInfo, "Handle GetAppList Command with Invalid Arg3" );
       
  2083     iLog->Log( KLogInfo );
       
  2084     
       
  2085     iTmServerDeviceType = ETrue;
       
  2086     //Sets the information associated with the terminal mode server device
       
  2087     SetTmServerSettingsL();
       
  2088     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2089 
       
  2090     //Register all the desired applications
       
  2091     RegisterApplicationsL(*iTmServer);   
       
  2092     
       
  2093     //Start the tmserver device and its services
       
  2094     iTmServer->StartL();   
       
  2095     
       
  2096     //Start the control point and search for device
       
  2097     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2098     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2099     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2100     CActiveScheduler::Start(); 
       
  2101 
       
  2102     if ( iDeviceVerified  )
       
  2103         {
       
  2104          _LIT8(KInvalidFilter3, "\"name=\"*Audio*\",@audioType=\"*\"\"");
       
  2105          //Retrieve the list of applications by specifying invalid filter value
       
  2106          iSearchDevice->GetAppListActionL(KInvalidFilter3(),KProfileIdValue);
       
  2107         }
       
  2108     
       
  2109     iTestTimer = CTestTimer::NewL(*this);
       
  2110     iTestTimer->After(15);
       
  2111     CActiveScheduler::Start();      
       
  2112     if (iGetAppList)
       
  2113         {
       
  2114         _LIT( KDescription , "GetAppList Command with Invalid Arg3 handled successfully");
       
  2115         aResult.SetResult( KErrNone, KDescription );
       
  2116         iLog->Log( KDescription );
       
  2117         }
       
  2118     else
       
  2119         {
       
  2120         aResult.iResult = KErrGeneral;
       
  2121         _LIT( KDescription , "GetAppList Command with Invalid Arg3 handling Failed");
       
  2122         aResult.SetResult( KErrNone, KDescription );
       
  2123         iLog->Log( KDescription );
       
  2124         }
       
  2125     delete iDiscoveryTestTimer;
       
  2126     iDiscoveryTestTimer = NULL;
       
  2127     delete iTestTimer;
       
  2128     iTestTimer = NULL;
       
  2129     REComSession::FinalClose();
       
  2130     return KErrNone;
       
  2131     }
       
  2132 
       
  2133 TInt CTmServerTest::HandleGetAppListActionInvalidArg4L ( TTestResult& aResult )
       
  2134     {
       
  2135     _LIT( KLogInfo, "Handle GetAppList Command with Invalid Arg4" );
       
  2136     iLog->Log( KLogInfo );
       
  2137     
       
  2138     iTmServerDeviceType = ETrue;
       
  2139     //Sets the information associated with the terminal mode server device
       
  2140     SetTmServerSettingsL();
       
  2141     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2142 
       
  2143     //Register all the desired applications
       
  2144     RegisterApplicationsL(*iTmServer);   
       
  2145     
       
  2146     //Start the tmserver device and its services
       
  2147     iTmServer->StartL();   
       
  2148     
       
  2149     //Start the control point and search for device
       
  2150     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2151     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2152     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2153     CActiveScheduler::Start(); 
       
  2154 
       
  2155     if ( iDeviceVerified  )
       
  2156         {
       
  2157          _LIT8(KInvalidFilter4, "\"icon@mimetype\"*svg+xml*\"\"");
       
  2158          //Retrieve the list of applications by specifying invalid filter value
       
  2159          iSearchDevice->GetAppListActionL(KInvalidFilter4(),KProfileIdValue);
       
  2160         }
       
  2161     
       
  2162     iTestTimer = CTestTimer::NewL(*this);
       
  2163     iTestTimer->After(15);
       
  2164     CActiveScheduler::Start();      
       
  2165     if (iGetAppList)
       
  2166         {
       
  2167         _LIT( KDescription , "GetAppList Command with Invalid Arg4 handled successfully");
       
  2168         aResult.SetResult( KErrNone, KDescription );
       
  2169         iLog->Log( KDescription );
       
  2170         }
       
  2171     else
       
  2172         {
       
  2173         aResult.iResult = KErrGeneral;
       
  2174         _LIT( KDescription , "GetAppList Command with Invalid Arg4 handling Failed");
       
  2175         aResult.SetResult( KErrNone, KDescription );
       
  2176         iLog->Log( KDescription );
       
  2177         }
       
  2178     delete iDiscoveryTestTimer;
       
  2179     iDiscoveryTestTimer = NULL;
       
  2180     delete iTestTimer;
       
  2181     iTestTimer = NULL;
       
  2182     REComSession::FinalClose();
       
  2183     return KErrNone;
       
  2184     }
       
  2185 
       
  2186 TInt CTmServerTest::HandleGetAppListActionInvalidArg5L ( TTestResult& aResult )
       
  2187     {
       
  2188     _LIT( KLogInfo, "Handle GetAppList Command with Invalid Arg5" );
       
  2189     iLog->Log( KLogInfo );
       
  2190     
       
  2191     iTmServerDeviceType = ETrue;
       
  2192     //Sets the information associated with the terminal mode server device
       
  2193     SetTmServerSettingsL();
       
  2194     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2195 
       
  2196     //Register all the desired applications
       
  2197     RegisterApplicationsL(*iTmServer);   
       
  2198     
       
  2199     //Start the tmserver device and its services
       
  2200     iTmServer->StartL();   
       
  2201     
       
  2202     //Start the control point and search for device
       
  2203     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2204     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2205     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2206     CActiveScheduler::Start(); 
       
  2207 
       
  2208     if ( iDeviceVerified  )
       
  2209         {
       
  2210          _LIT8(KInvalidFilter5, "\"name=\"*nav*\"appInfo@appCategory=\"*\"\"");
       
  2211          //Retrieve the list of applications by specifying invalid filter value
       
  2212          iSearchDevice->GetAppListActionL(KInvalidFilter5(),KProfileIdValue);
       
  2213         }
       
  2214     
       
  2215     iTestTimer = CTestTimer::NewL(*this);
       
  2216     iTestTimer->After(15);
       
  2217     CActiveScheduler::Start();      
       
  2218     if (iGetAppList)
       
  2219         {
       
  2220         _LIT( KDescription , "GetAppList Command with Invalid Arg5 handled successfully");
       
  2221         aResult.SetResult( KErrNone, KDescription );
       
  2222         iLog->Log( KDescription );
       
  2223         }
       
  2224     else
       
  2225         {
       
  2226         aResult.iResult = KErrGeneral;
       
  2227         _LIT( KDescription , "GetAppList Command with Invalid Arg5 handling Failed");
       
  2228         aResult.SetResult( KErrNone, KDescription );
       
  2229         iLog->Log( KDescription );
       
  2230         }
       
  2231     delete iDiscoveryTestTimer;
       
  2232     iDiscoveryTestTimer = NULL;
       
  2233     delete iTestTimer;
       
  2234     iTestTimer = NULL;
       
  2235     REComSession::FinalClose();
       
  2236     return KErrNone;
       
  2237     }
       
  2238 
       
  2239 TInt CTmServerTest::HandleGetAppListActionNoFilterL ( TTestResult& aResult )
       
  2240     {
       
  2241     _LIT( KLogInfo, "Handle GetAppList Command With No Filter" );
       
  2242     iLog->Log( KLogInfo );
       
  2243     
       
  2244     iTmServerDeviceType = ETrue;
       
  2245 
       
  2246     //Sets the information associated with the terminal mode server device
       
  2247     SetTmServerSettingsL();
       
  2248     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2249 
       
  2250     //Register all the desired applications
       
  2251     RegisterApplicationsL(*iTmServer);    
       
  2252     
       
  2253     //Start the tmserver device and its services
       
  2254     iTmServer->StartL();   
       
  2255     
       
  2256     //Start the control point and search for device
       
  2257     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2258     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2259     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2260     CActiveScheduler::Start(); 
       
  2261 
       
  2262     if ( iDeviceVerified  )
       
  2263         {
       
  2264          //Retrieve the list of applications
       
  2265          iSearchDevice->GetAppListActionL( KWildCard(),KProfileIdValue);
       
  2266         }
       
  2267     
       
  2268     iTestTimer = CTestTimer::NewL(*this);
       
  2269     iTestTimer->After(15);
       
  2270     CActiveScheduler::Start();      
       
  2271     if (iGetAppList)
       
  2272         {
       
  2273         _LIT( KDescription , "GetAppList Command With No Filter handled successfully");
       
  2274         aResult.SetResult( KErrNone, KDescription );
       
  2275         iLog->Log( KDescription );
       
  2276         }
       
  2277     else
       
  2278         {
       
  2279         aResult.iResult = KErrGeneral;
       
  2280         _LIT( KDescription , "GetAppList Command With No Filter handling Failed");
       
  2281         aResult.SetResult( KErrNone, KDescription );
       
  2282         iLog->Log( KDescription );
       
  2283         }
       
  2284     delete iDiscoveryTestTimer;
       
  2285     iDiscoveryTestTimer = NULL;
       
  2286     delete iTestTimer;
       
  2287     iTestTimer = NULL;
       
  2288     REComSession::FinalClose();
       
  2289     return KErrNone;
       
  2290     }
       
  2291 
       
  2292 TInt CTmServerTest::HandleInvalidProfileIdGetAppListActionL ( TTestResult& aResult )
       
  2293     {
       
  2294     _LIT( KLogInfo, "Handle Invalid ProfileId GetAppList Command" );
       
  2295     iLog->Log( KLogInfo );
       
  2296     
       
  2297     iTmServerDeviceType = ETrue;
       
  2298 
       
  2299     //Sets the information associated with the terminal mode server device
       
  2300     SetTmServerSettingsL();
       
  2301     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this );
       
  2302     
       
  2303     //Register all the desired applications
       
  2304     RegisterApplicationsL(*iTmServer); 
       
  2305     
       
  2306     //Start the tmserver device and its services
       
  2307     iTmServer->StartL();   
       
  2308     
       
  2309     //Start the control point and search for device
       
  2310     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2311     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2312     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2313     CActiveScheduler::Start(); 
       
  2314     
       
  2315     if ( iDeviceVerified  )
       
  2316         {
       
  2317          //Retrieve the list of applications by specifying invalid profileId
       
  2318          iSearchDevice->GetAppListActionL(KWildCard(),KInvalidProfileIdValue);
       
  2319         }
       
  2320     
       
  2321     iTestTimer = CTestTimer::NewL(*this);
       
  2322     iTestTimer->After(15);
       
  2323     CActiveScheduler::Start();      
       
  2324     if (iGetAppList)
       
  2325         {
       
  2326         _LIT( KDescription , "GetAppList Command with invalid ProfileId handled successfully");
       
  2327         aResult.SetResult( KErrNone, KDescription );
       
  2328         iLog->Log( KDescription );
       
  2329         }
       
  2330     else
       
  2331         {
       
  2332         aResult.iResult = KErrGeneral;
       
  2333         _LIT( KDescription , "GetAppList Command with invalid ProfileId  handling Failed");
       
  2334         aResult.SetResult( KErrNone, KDescription );
       
  2335         iLog->Log( KDescription );
       
  2336         }
       
  2337     delete iDiscoveryTestTimer;
       
  2338     iDiscoveryTestTimer = NULL;
       
  2339     delete iTestTimer;
       
  2340     iTestTimer = NULL;
       
  2341     REComSession::FinalClose();
       
  2342     return KErrNone;
       
  2343     }
       
  2344 
       
  2345 TInt CTmServerTest::HandleGetAppListActionOperationRejectedL ( TTestResult& aResult )
       
  2346     {
       
  2347     _LIT( KLogInfo, "Handle Operation Rejected Condition For GetAppList Command" );
       
  2348     iLog->Log( KLogInfo );
       
  2349     
       
  2350     iTmServerDeviceType = ETrue;
       
  2351 
       
  2352     //Sets the information associated with the terminal mode server device
       
  2353     SetTmServerSettingsL();
       
  2354     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this );
       
  2355     
       
  2356     //Register all the desired applications
       
  2357     RegisterApplicationsL(*iTmServer); 
       
  2358     
       
  2359     //Start the tmserver device and its services
       
  2360     iTmServer->StartL();   
       
  2361     iOperationRejected = ETrue; 
       
  2362     //Start the control point and search for device
       
  2363     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2364     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2365     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2366     CActiveScheduler::Start(); 
       
  2367     
       
  2368     if ( iDeviceVerified  )
       
  2369         {
       
  2370          //Retrieve the list of applications by specifying profileId
       
  2371          iSearchDevice->GetAppListActionL(KAppListFilterValue1(),KProfileIdValue);
       
  2372         }
       
  2373     
       
  2374     iTestTimer = CTestTimer::NewL(*this);
       
  2375     iTestTimer->After(15);
       
  2376     CActiveScheduler::Start();      
       
  2377     if (iGetAppList)
       
  2378         {
       
  2379         _LIT( KDescription , "Handle Operation Rejected Condition For GetAppList Command handled successfully");
       
  2380         aResult.SetResult( KErrNone, KDescription );
       
  2381         iLog->Log( KDescription );
       
  2382         }
       
  2383     else
       
  2384         {
       
  2385         aResult.iResult = KErrGeneral;
       
  2386         _LIT( KDescription , "Handle Operation Rejected Condition For GetAppList Command handling Failed");
       
  2387         aResult.SetResult( KErrNone, KDescription );
       
  2388         iLog->Log( KDescription );
       
  2389         }
       
  2390     delete iDiscoveryTestTimer;
       
  2391     iDiscoveryTestTimer = NULL;
       
  2392     delete iTestTimer;
       
  2393     iTestTimer = NULL;
       
  2394     REComSession::FinalClose();
       
  2395     return KErrNone;
       
  2396     }
       
  2397 
       
  2398 TInt CTmServerTest::HandleSetClientProfileActionL( TTestResult& aResult )
       
  2399     {
       
  2400     _LIT( KLogInfo, "Handle SetClientProfile Command" );
       
  2401     iLog->Log( KLogInfo );
       
  2402     
       
  2403     iTmServerDeviceType = ETrue;
       
  2404 
       
  2405     //Sets the information associated with the terminal mode server device
       
  2406     SetTmServerSettingsL();
       
  2407     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2408 
       
  2409     //Register all the desired applications
       
  2410     RegisterApplicationsL(*iTmServer); 
       
  2411     
       
  2412     //Start the tmserver device and its services
       
  2413     iTmServer->StartL(); 
       
  2414     
       
  2415     //Start the control point and search for device
       
  2416     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2417     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2418     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2419     CActiveScheduler::Start(); 
       
  2420 
       
  2421     if ( iDeviceVerified  )
       
  2422         {
       
  2423          // Register the client profile 
       
  2424          iSearchDevice->SetClientProfileActionL(KProfileIdValue, KClientProfileInfo);
       
  2425         }
       
  2426     
       
  2427     iTestTimer = CTestTimer::NewL(*this);
       
  2428     iTestTimer->After(15);
       
  2429     CActiveScheduler::Start();  
       
  2430     
       
  2431     if (iSetClientProfile)
       
  2432         {
       
  2433         _LIT( KDescription , "SetClientProfile Command handled successfully");
       
  2434         aResult.SetResult( KErrNone, KDescription );
       
  2435         iLog->Log( KDescription );
       
  2436         }
       
  2437     else
       
  2438         {
       
  2439         aResult.iResult = KErrGeneral;
       
  2440         _LIT( KDescription , "SetClientProfile Command handling  Failed");
       
  2441         aResult.SetResult( KErrNone, KDescription );
       
  2442         iLog->Log( KDescription );
       
  2443         }
       
  2444     delete iDiscoveryTestTimer;
       
  2445     iDiscoveryTestTimer = NULL;
       
  2446     delete iTestTimer;
       
  2447     iTestTimer = NULL;
       
  2448     iClientIconPrefArray.ResetAndDestroy();
       
  2449     iClientIconPrefArray.Close();
       
  2450     REComSession::FinalClose();
       
  2451     return KErrNone;
       
  2452     }
       
  2453 
       
  2454 TInt CTmServerTest::HandleInvalidProfileIdSetClientProfileActionL ( TTestResult& aResult )
       
  2455     {
       
  2456     _LIT( KLogInfo, "Handle Invalid ProfileId SetClientProfile Command" );
       
  2457     iLog->Log( KLogInfo );
       
  2458     
       
  2459     iTmServerDeviceType = ETrue;
       
  2460 
       
  2461     //Sets the information associated with the terminal mode server device
       
  2462     SetTmServerSettingsL();
       
  2463     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2464 
       
  2465     //Register all the desired applications
       
  2466     RegisterApplicationsL(*iTmServer);    
       
  2467     
       
  2468     //Start the tmserver device and its services
       
  2469     iTmServer->StartL();   
       
  2470 
       
  2471     //Start the control point and search for device
       
  2472     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2473     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2474     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2475     CActiveScheduler::Start(); 
       
  2476 
       
  2477     if ( iDeviceVerified  )
       
  2478         {
       
  2479          //Register the client profile with invalid profileId
       
  2480          iSearchDevice->SetClientProfileActionL(KInvalidProfileIdValue, KClientProfileInfo );
       
  2481         }
       
  2482     
       
  2483     iTestTimer = CTestTimer::NewL(*this);
       
  2484     iTestTimer->After(15);
       
  2485     CActiveScheduler::Start();  
       
  2486     
       
  2487     if (iSetClientProfile)
       
  2488         {
       
  2489         _LIT( KDescription , "SetClientProfile Command with invalid ProfileId handled successfully");
       
  2490         aResult.SetResult( KErrNone, KDescription );
       
  2491         iLog->Log( KDescription );
       
  2492         }
       
  2493     else
       
  2494         {
       
  2495         aResult.iResult = KErrGeneral;
       
  2496         _LIT( KDescription , "SetClientProfile Command with invalid ProfileId handling Failed");
       
  2497         aResult.SetResult( KErrNone, KDescription );
       
  2498         iLog->Log( KDescription );
       
  2499         }
       
  2500     delete iDiscoveryTestTimer;
       
  2501     iDiscoveryTestTimer = NULL;
       
  2502     delete iTestTimer;
       
  2503     iTestTimer = NULL;
       
  2504     REComSession::FinalClose();
       
  2505     return KErrNone;
       
  2506     }
       
  2507 
       
  2508 TInt CTmServerTest::HandleInvalidProfileSetClientProfileActionL ( TTestResult& aResult )
       
  2509     {
       
  2510     _LIT( KLogInfo, "Handle Invalid Profile SetClientProfile Command" );
       
  2511     iLog->Log( KLogInfo );
       
  2512     
       
  2513     iTmServerDeviceType = ETrue;
       
  2514 
       
  2515     //Sets the information associated with the terminal mode server device
       
  2516     SetTmServerSettingsL();
       
  2517     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2518     
       
  2519     //Register all the desired applications
       
  2520     RegisterApplicationsL(*iTmServer); 
       
  2521     
       
  2522     //Start the tmserver device and its services
       
  2523     iTmServer->StartL();
       
  2524     
       
  2525     //Start the control point and search for device
       
  2526     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2527     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2528     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2529     CActiveScheduler::Start(); 
       
  2530 
       
  2531     if ( iDeviceVerified  )
       
  2532         {
       
  2533         _LIT8(KInvalidProfile,"&lt;clientProfile");
       
  2534         //Register the client profile with invalid profile
       
  2535         iSearchDevice->SetClientProfileActionL(KProfileIdValue, KInvalidProfile());
       
  2536         }
       
  2537     
       
  2538     iTestTimer = CTestTimer::NewL(*this);
       
  2539     iTestTimer->After(15);
       
  2540     CActiveScheduler::Start();  
       
  2541     
       
  2542     if (iSetClientProfile)
       
  2543         {
       
  2544         _LIT( KDescription , "SetClientProfile Command with invalid Profile handled successfully");
       
  2545         aResult.SetResult( KErrNone, KDescription );
       
  2546         iLog->Log( KDescription );
       
  2547         }
       
  2548     else
       
  2549         {
       
  2550         aResult.iResult = KErrGeneral;
       
  2551         _LIT( KDescription , "SetClientProfile Command with invalid Profile handling Failed");
       
  2552         aResult.SetResult( KErrNone, KDescription );
       
  2553         iLog->Log( KDescription );
       
  2554         }
       
  2555     delete iDiscoveryTestTimer;
       
  2556     iDiscoveryTestTimer = NULL;
       
  2557     delete iTestTimer;
       
  2558     iTestTimer = NULL;
       
  2559     REComSession::FinalClose();
       
  2560     return KErrNone;
       
  2561     }
       
  2562 
       
  2563 TInt CTmServerTest::HandleDeviceLockedSetClientProfileActionL ( TTestResult& aResult )
       
  2564     {
       
  2565     _LIT( KLogInfo, "Handle Device Locked Condition For SetClientProfile Command" );
       
  2566     iLog->Log( KLogInfo );
       
  2567     
       
  2568     iTmServerDeviceType = ETrue;
       
  2569 
       
  2570     //Sets the information associated with the terminal mode server device
       
  2571     SetTmServerSettingsL();
       
  2572     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2573     
       
  2574     //Register all the desired applications
       
  2575     RegisterApplicationsL(*iTmServer); 
       
  2576     
       
  2577     //Start the tmserver device and its services
       
  2578     iTmServer->StartL();
       
  2579     
       
  2580     //Start the control point and search for device
       
  2581     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2582     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2583     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2584     CActiveScheduler::Start(); 
       
  2585 
       
  2586     if ( iDeviceVerified  )
       
  2587         {
       
  2588         //Register the client profile 
       
  2589         iSearchDevice->SetClientProfileActionL(KProfileIdValue, KDeviceLockedClientProfile());
       
  2590         }
       
  2591     
       
  2592     iTestTimer = CTestTimer::NewL(*this);
       
  2593     iTestTimer->After(15);
       
  2594     CActiveScheduler::Start();  
       
  2595     
       
  2596     if (iSetClientProfile)
       
  2597         {
       
  2598         _LIT( KDescription , "Device Locked Condition for SetClientProfile Command handled successfully");
       
  2599         aResult.SetResult( KErrNone, KDescription );
       
  2600         iLog->Log( KDescription );
       
  2601         }
       
  2602     else
       
  2603         {
       
  2604         aResult.iResult = KErrGeneral;
       
  2605         _LIT( KDescription , "Device Locked Condition for SetClientProfile Command handling Failed");
       
  2606         aResult.SetResult( KErrNone, KDescription );
       
  2607         iLog->Log( KDescription );
       
  2608         }
       
  2609     delete iDiscoveryTestTimer;
       
  2610     iDiscoveryTestTimer = NULL;
       
  2611     delete iTestTimer;
       
  2612     iTestTimer = NULL;
       
  2613     REComSession::FinalClose();
       
  2614     return KErrNone;
       
  2615     }
       
  2616 
       
  2617 TInt CTmServerTest::HandleResourceBusySetClientProfileActionL ( TTestResult& aResult )
       
  2618     {
       
  2619     _LIT( KLogInfo, "Handle Resource Busy Condition For SetClientProfile Command" );
       
  2620     iLog->Log( KLogInfo );
       
  2621     
       
  2622     iTmServerDeviceType = ETrue;
       
  2623 
       
  2624     //Sets the information associated with the terminal mode server device
       
  2625     SetTmServerSettingsL();
       
  2626     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2627     
       
  2628     //Register all the desired applications
       
  2629     RegisterApplicationsL(*iTmServer); 
       
  2630     
       
  2631     //Start the tmserver device and its services
       
  2632     iTmServer->StartL();
       
  2633     iResourceBusy = ETrue;
       
  2634     //Start the control point and search for device
       
  2635     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2636     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2637     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2638     CActiveScheduler::Start(); 
       
  2639 
       
  2640     if ( iDeviceVerified  )
       
  2641         {
       
  2642         //Register the client profile 
       
  2643         iSearchDevice->SetClientProfileActionL(KProfileIdValue, KClientProfileInfo());
       
  2644         }
       
  2645     
       
  2646     iTestTimer = CTestTimer::NewL(*this);
       
  2647     iTestTimer->After(15);
       
  2648     CActiveScheduler::Start();  
       
  2649     
       
  2650     if (iSetClientProfile)
       
  2651         {
       
  2652         _LIT( KDescription , "Resource Busy Condition for SetClientProfile Command handled successfully");
       
  2653         aResult.SetResult( KErrNone, KDescription );
       
  2654         iLog->Log( KDescription );
       
  2655         }
       
  2656     else
       
  2657         {
       
  2658         aResult.iResult = KErrGeneral;
       
  2659         _LIT( KDescription , "Resource Busy Condition for SetClientProfile Command handling Failed");
       
  2660         aResult.SetResult( KErrNone, KDescription );
       
  2661         iLog->Log( KDescription );
       
  2662         }
       
  2663     delete iDiscoveryTestTimer;
       
  2664     iDiscoveryTestTimer = NULL;
       
  2665     delete iTestTimer;
       
  2666     iTestTimer = NULL;
       
  2667     REComSession::FinalClose();
       
  2668     return KErrNone;
       
  2669     }
       
  2670 
       
  2671 TInt CTmServerTest::HandleGetClientProfileActionL( TTestResult& aResult )
       
  2672     {
       
  2673     _LIT( KLogInfo, "Handle GetClientProfile Command" );
       
  2674     iLog->Log( KLogInfo );
       
  2675     
       
  2676     iTmServerDeviceType = ETrue;
       
  2677 
       
  2678     //Sets the information associated with the terminal mode server device
       
  2679     SetTmServerSettingsL();
       
  2680     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2681 
       
  2682     //Register all the desired applications
       
  2683     RegisterApplicationsL(*iTmServer);     
       
  2684 
       
  2685     //Start the tmserver device and its services
       
  2686     iTmServer->StartL();   
       
  2687 
       
  2688     //Start the control point and search for device
       
  2689     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2690     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2691     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2692     CActiveScheduler::Start(); 
       
  2693 
       
  2694     if ( iDeviceVerified  )
       
  2695         {
       
  2696          //Retrieve the contents of a client profile stored in the terminal mode device
       
  2697          iSearchDevice->GetClientProfileActionL(KProfileIdValue);
       
  2698         }
       
  2699     
       
  2700     iTestTimer = CTestTimer::NewL(*this);
       
  2701     iTestTimer->After(15);
       
  2702     CActiveScheduler::Start();  
       
  2703     
       
  2704     if (iGetClientProfile)
       
  2705         {
       
  2706         _LIT( KDescription , "GetClientProfile Command handled successfully");
       
  2707         aResult.SetResult( KErrNone, KDescription );
       
  2708         iLog->Log( KDescription );
       
  2709         }
       
  2710     else
       
  2711         {
       
  2712         aResult.iResult = KErrGeneral;
       
  2713         _LIT( KDescription , "GetClientProfile Command handling  Failed");
       
  2714         aResult.SetResult( KErrNone, KDescription );
       
  2715         iLog->Log( KDescription );
       
  2716         }
       
  2717     delete iDiscoveryTestTimer;
       
  2718     iDiscoveryTestTimer = NULL;
       
  2719     delete iTestTimer;
       
  2720     iTestTimer = NULL;
       
  2721     REComSession::FinalClose();
       
  2722     return KErrNone;
       
  2723     }
       
  2724 
       
  2725 TInt CTmServerTest::HandleInvalidProfileIdGetClientProfileActionL ( TTestResult& aResult )
       
  2726     {
       
  2727     _LIT( KLogInfo, "Handle Invalid ProfileId GetClientProfile Command" );
       
  2728     iLog->Log( KLogInfo );
       
  2729     
       
  2730     iTmServerDeviceType = ETrue;
       
  2731 
       
  2732     //Sets the information associated with the terminal mode server device
       
  2733     SetTmServerSettingsL();
       
  2734     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2735 
       
  2736     //Register all the desired applications
       
  2737     RegisterApplicationsL(*iTmServer);  
       
  2738     
       
  2739     //Start the control point and search for device
       
  2740     iTmServer->StartL();   
       
  2741 
       
  2742     //Start the control point and search for device
       
  2743     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2744     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2745     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2746     CActiveScheduler::Start(); 
       
  2747 
       
  2748     if ( iDeviceVerified  )
       
  2749         {
       
  2750          //Retrieve the contents of a client profile by specifying invalid profileId
       
  2751          iSearchDevice->GetClientProfileActionL(KInvalidProfileIdValue);
       
  2752         }
       
  2753     
       
  2754     iTestTimer = CTestTimer::NewL(*this);
       
  2755     iTestTimer->After(15);
       
  2756     CActiveScheduler::Start();  
       
  2757     
       
  2758     if (iGetClientProfile)
       
  2759         {
       
  2760         _LIT( KDescription , "GetClientProfile Command with invalid ProfileId handled successfully");
       
  2761         aResult.SetResult( KErrNone, KDescription );
       
  2762         iLog->Log( KDescription );
       
  2763         }
       
  2764     else
       
  2765         {
       
  2766         aResult.iResult = KErrGeneral;
       
  2767         _LIT( KDescription , "GetClientProfile Command with invalid ProfileId handling Failed");
       
  2768         aResult.SetResult( KErrNone, KDescription );
       
  2769         iLog->Log( KDescription );
       
  2770         }
       
  2771     delete iDiscoveryTestTimer;
       
  2772     iDiscoveryTestTimer = NULL;
       
  2773     delete iTestTimer;
       
  2774     iTestTimer = NULL;
       
  2775     REComSession::FinalClose();
       
  2776     return KErrNone;
       
  2777     }
       
  2778 
       
  2779 
       
  2780 TInt CTmServerTest::HandleGetMaxNumProfilesActionL( TTestResult& aResult )
       
  2781     {
       
  2782     _LIT( KLogInfo, "Handle GetMaxNumProfiles Command" );
       
  2783     iLog->Log( KLogInfo );
       
  2784     
       
  2785     iTmServerDeviceType = ETrue;
       
  2786 
       
  2787     //Sets the information associated with the terminal mode server device
       
  2788     SetTmServerSettingsL();
       
  2789     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2790 
       
  2791     //Register all the desired applications
       
  2792     RegisterApplicationsL(*iTmServer);  
       
  2793     
       
  2794     //Start the control point and search for device
       
  2795     iTmServer->StartL();   
       
  2796 
       
  2797     //Start the control point and search for device
       
  2798     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2799     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2800     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2801     CActiveScheduler::Start(); 
       
  2802 
       
  2803     if ( iDeviceVerified  )
       
  2804         {
       
  2805          //Get the maximum number of client profiles supported
       
  2806          iSearchDevice->GetMaxNumProfilesActionL();
       
  2807         }
       
  2808     
       
  2809     iTestTimer = CTestTimer::NewL(*this);
       
  2810     iTestTimer->After(15);
       
  2811     CActiveScheduler::Start();  
       
  2812     
       
  2813     if (iGetMaxNumProfiles)
       
  2814         {
       
  2815         _LIT( KDescription , "GetMaxNumProfiles Command handled successfully");
       
  2816         aResult.SetResult( KErrNone, KDescription );
       
  2817         iLog->Log( KDescription );
       
  2818         }
       
  2819     else
       
  2820         {
       
  2821         aResult.iResult = KErrGeneral;
       
  2822         _LIT( KDescription , "GetMaxNumProfiles Command handling  Failed");
       
  2823         aResult.SetResult( KErrNone, KDescription );
       
  2824         iLog->Log( KDescription );
       
  2825         }
       
  2826     delete iDiscoveryTestTimer;
       
  2827     iDiscoveryTestTimer = NULL;
       
  2828     delete iTestTimer;
       
  2829     iTestTimer = NULL;
       
  2830     REComSession::FinalClose();
       
  2831     return KErrNone;
       
  2832     }
       
  2833 
       
  2834 TInt CTmServerTest::HandleGetMaxNumProfilesOperationRejectedL( TTestResult& aResult )
       
  2835     {
       
  2836     _LIT( KLogInfo, "Handle Operation Rejected Condition For GetMaxNumProfiles Command" );
       
  2837     iLog->Log( KLogInfo );
       
  2838     
       
  2839     iTmServerDeviceType = ETrue;
       
  2840 
       
  2841     //Sets the information associated with the terminal mode server device
       
  2842     SetTmServerSettingsL();
       
  2843     iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); 
       
  2844 
       
  2845     //Register all the desired applications
       
  2846     RegisterApplicationsL(*iTmServer);  
       
  2847     
       
  2848     //Start the control point and search for device
       
  2849     iTmServer->StartL();   
       
  2850     iOperationRejected = ETrue; 
       
  2851     //Start the control point and search for device
       
  2852     iSearchDevice = CDiscoverDevice::NewL(*this);    
       
  2853     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
       
  2854     iDiscoveryTestTimer->AfterDiscovery(15);
       
  2855     CActiveScheduler::Start(); 
       
  2856 
       
  2857     if ( iDeviceVerified  )
       
  2858         {
       
  2859          //Get the maximum number of client profiles supported
       
  2860          iSearchDevice->GetMaxNumProfilesActionL();
       
  2861         }
       
  2862     
       
  2863     iTestTimer = CTestTimer::NewL(*this);
       
  2864     iTestTimer->After(15);
       
  2865     CActiveScheduler::Start();  
       
  2866     
       
  2867     if (iGetMaxNumProfiles)
       
  2868         {
       
  2869         _LIT( KDescription , "Operation Rejected Condition For GetMaxNumProfiles Command handled successfully");
       
  2870         aResult.SetResult( KErrNone, KDescription );
       
  2871         iLog->Log( KDescription );
       
  2872         }
       
  2873     else
       
  2874         {
       
  2875         aResult.iResult = KErrGeneral;
       
  2876         _LIT( KDescription , "Operation Rejected Condition For GetMaxNumProfiles Command handling  Failed");
       
  2877         aResult.SetResult( KErrNone, KDescription );
       
  2878         iLog->Log( KDescription );
       
  2879         }
       
  2880     delete iDiscoveryTestTimer;
       
  2881     iDiscoveryTestTimer = NULL;
       
  2882     delete iTestTimer;
       
  2883     iTestTimer = NULL;
       
  2884     REComSession::FinalClose();
       
  2885     return KErrNone;
       
  2886     }
       
  2887 
       
  2888 // ========================================================================================================
       
  2889 
       
  2890 void CTmServerTest::SetTmServerSettingsL()
       
  2891     { 
       
  2892     iTmServerDeviceInfo = CUpnpTmServerDeviceInfo::NewL(CUpnpSettings::GetIapL());  
       
  2893     iTmServerDeviceInfo->SetDeviceInfoL( KDeviceInfo );
       
  2894     iTmServerDeviceInfo->SetBtAddressL( KBtMacValue );
       
  2895     iTmServerDeviceInfo->SetStartConn(ETrue);
       
  2896     iTmServerDeviceInfo->AddDeviceIconL(CUpnpTerminalModeIcon::NewL(KIconDevicePath, KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType));
       
  2897     }
       
  2898 
       
  2899 void CTmServerTest::RegisterApplicationsL(CUpnpTmServer& aTmServer )
       
  2900     {  
       
  2901     RArray<TUint> allowedProfileIdList;
       
  2902     allowedProfileIdList.Append(0);
       
  2903     allowedProfileIdList.Append(1);
       
  2904     allowedProfileIdList.Append(2);
       
  2905     allowedProfileIdList.Append(2);
       
  2906     allowedProfileIdList.Append(3);
       
  2907     allowedProfileIdList.Append(4);
       
  2908     allowedProfileIdList.Append(5);
       
  2909     allowedProfileIdList.Append(6);
       
  2910 
       
  2911     _LIT8(KAppDesc, "Mobile Navigation Application");
       
  2912     iRemotableApp = CUpnpRemotableApp::NewL( KAppIdValue ,_L8("Navigation"));  
       
  2913     iRemotableApp->SetAppDescriptionL(KAppDesc());
       
  2914     iRemotableApp->SetAllowedProfileIdListL(allowedProfileIdList);   
       
  2915     CUpnpTmInfoElement& tmInfoElement = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
  2916     tmInfoElement.AddTmInfoElementL(_L8("protocolID"),_L8("VNC"));
       
  2917     
       
  2918     CUpnpTmInfoElement& tmInfoElement1 = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
  2919     tmInfoElement1.AddTmInfoElementL(_L8("appCategory"),_L8("0x00010001"));
       
  2920     tmInfoElement1.AddTmInfoElementL(_L8("trustLevel"),_L8("0x80"));
       
  2921     
       
  2922     CUpnpTmInfoElement& tmInfoElement2 = iRemotableApp->CreateTmInfoElementL(CUpnpTmInfoElement::EDisplayInfo);
       
  2923     tmInfoElement2.AddTmInfoElementL(_L8("contentCategory"),_L8("0x0000001"));
       
  2924     tmInfoElement2.AddTmInfoElementL(_L8("contentRules"),_L8("0x00000FE"));
       
  2925     tmInfoElement2.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
  2926     iRemotableApp->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMaps, KIconWidth1, KIconHeight1, KIconDepth,KTestSvgMimeType));
       
  2927     aTmServer.RegisterAppL(iRemotableApp);   
       
  2928     allowedProfileIdList.Close();
       
  2929    
       
  2930     _LIT8(KAppDesc1, "RTP Audio Server");
       
  2931     iRemotableApp1 = CUpnpRemotableApp::NewL( KAppId1Value ,_L8("RTP Server"));
       
  2932     iRemotableApp1->SetAppDescriptionL(KAppDesc1());
       
  2933     
       
  2934     CUpnpTmInfoElement& tmInfoElement3 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
  2935     tmInfoElement3.AddTmInfoElementL(_L8("protocolID"),_L8("RTP"));
       
  2936     tmInfoElement3.AddTmInfoElementL(_L8("format"),_L8("99"));
       
  2937     tmInfoElement3.AddTmInfoElementL(_L8("direction"),_L8("out"));
       
  2938     
       
  2939     CUpnpTmInfoElement& tmInfoElement4 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
  2940     tmInfoElement4.AddTmInfoElementL(_L8("appCategory"),_L8("0x0000002"));
       
  2941     tmInfoElement4.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
  2942     
       
  2943     CUpnpTmInfoElement& tmInfoElement5 = iRemotableApp1->CreateTmInfoElementL(CUpnpTmInfoElement::EAudioInfo);
       
  2944     tmInfoElement5.AddTmInfoElementL(_L8("audioType"),_L8("all"));    
       
  2945     iRemotableApp1->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMusicUnLaunched,KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType));
       
  2946     iRemotableApp1->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathMusicLaunched,KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType));
       
  2947     iRemotableApp1->SetResourceStatusL(_L8("free"));
       
  2948    
       
  2949     iRemotableAppArray.AppendL(iRemotableApp1);      
       
  2950 
       
  2951     _LIT8(KAppDesc2, "Bluetooth A2DP Audio Server");
       
  2952     iRemotableApp2 = CUpnpRemotableApp::NewL( KAppId2Value ,_L8("Bluetooth A2DP"));
       
  2953     iRemotableApp2->SetAppDescriptionL(KAppDesc2());
       
  2954     
       
  2955     CUpnpTmInfoElement& tmInfoElement6 = iRemotableApp2->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
  2956     tmInfoElement6.AddTmInfoElementL(_L8("protocolID"),_L8("BTA2DP"));
       
  2957     tmInfoElement6.AddTmInfoElementL(_L8("direction"),_L8("out"));
       
  2958     
       
  2959     CUpnpTmInfoElement& tmInfoElement7 = iRemotableApp2->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
  2960     tmInfoElement7.AddTmInfoElementL(_L8("appCategory"),_L8("0x0000003"));
       
  2961     tmInfoElement7.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001"));
       
  2962     
       
  2963     iRemotableApp2->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathBtA2DpUnLaunched, KIconWidth2, KIconHeight2, KIconDepth1,KTestSvgMimeType)); 
       
  2964     iRemotableApp2->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathBtA2DpLaunched,KIconWidth3, KIconHeight3, KIconDepth1,KTestSvgMimeType));
       
  2965     iRemotableApp2->SetResourceStatusL(_L8("free"));
       
  2966     iRemotableAppArray.AppendL(iRemotableApp2);      
       
  2967     
       
  2968      _LIT8(KAppDesc3, "Bluetooth HFP Audio");
       
  2969     RArray<TUint> allowedProfileIdList1;
       
  2970     allowedProfileIdList1.Append(0);
       
  2971     iRemotableApp3 = CUpnpRemotableApp::NewL( KAppId3Value,_L8("Bluetooth HFP"));
       
  2972     iRemotableApp3->SetAppDescriptionL(KAppDesc3());
       
  2973     iRemotableApp3->SetAllowedProfileIdListL(allowedProfileIdList1);
       
  2974     
       
  2975     CUpnpTmInfoElement& tmInfoElement8 = iRemotableApp3->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
  2976     tmInfoElement8.AddTmInfoElementL(_L8("protocolID"),_L8("BTHFP"));
       
  2977     tmInfoElement8.AddTmInfoElementL(_L8("direction"),_L8("bi"));
       
  2978     
       
  2979     CUpnpTmInfoElement& tmInfoElement9 = iRemotableApp3->CreateTmInfoElementL(CUpnpTmInfoElement::EAppInfo);
       
  2980     tmInfoElement9.AddTmInfoElementL(_L8("appCategory"),_L8("0x0000004"));
       
  2981     tmInfoElement9.AddTmInfoElementL(_L8("trustLevel"),_L8("0x00000001")); 
       
  2982    
       
  2983     iRemotableApp3->AddIconL(CUpnpTerminalModeIcon::NewL(KIconPathBtHfp, KIconWidth, KIconHeight, KIconDepth,KTestSvgMimeType)); 
       
  2984     iRemotableApp3->SetResourceStatusL(_L8("busy"));    
       
  2985     iRemotableAppArray.AppendL(iRemotableApp3);     
       
  2986     allowedProfileIdList1.Close();
       
  2987     
       
  2988     _LIT8(KAppDesc4, "Device Attestation Protocol");
       
  2989     iRemotableApp4 = CUpnpRemotableApp::NewL( KAppId4Value ,_L8("Device Attestation"));
       
  2990     iRemotableApp4->SetAppDescriptionL(KAppDesc4());
       
  2991        
       
  2992     CUpnpTmInfoElement& tmInfoElement11 = iRemotableApp4->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
  2993     tmInfoElement11.AddTmInfoElementL(_L8("protocolID"),_L8("DAP")); 
       
  2994     iRemotableAppArray.AppendL(iRemotableApp4); 
       
  2995 
       
  2996     iRemotableApp5 = CUpnpRemotableApp::NewL( KAppId5Value ,_L8("Device Attestation"));
       
  2997     iRemotableApp5->SetAppDescriptionL(KAppDesc4());
       
  2998 
       
  2999     RArray<TUint> allowedProfileIdList2;
       
  3000     allowedProfileIdList2.Append(1);    
       
  3001     allowedProfileIdList2.Append(1);
       
  3002     iRemotableApp5->SetAllowedProfileIdListL(allowedProfileIdList2);
       
  3003        
       
  3004     CUpnpTmInfoElement& tmInfoElement12 = iRemotableApp5->CreateTmInfoElementL(CUpnpTmInfoElement::ERemotingInfo);
       
  3005     tmInfoElement12.AddTmInfoElementL(_L8("protocolID"),_L8("DAP")); 
       
  3006     iRemotableAppArray.AppendL(iRemotableApp5);   
       
  3007     allowedProfileIdList2.Close();
       
  3008     
       
  3009     aTmServer.SetXmlSignatureL(KXmlSignature);    
       
  3010     aTmServer.RegisterAppsL(iRemotableAppArray); 
       
  3011     iRemotableAppArray.Close();
       
  3012     }
       
  3013 
       
  3014 void CTmServerTest::TestTimerTimedOutL()
       
  3015     {
       
  3016     iTmServer->StopL();
       
  3017     delete iSearchDevice;
       
  3018     iSearchDevice = NULL;
       
  3019     delete iTmServer;
       
  3020     iTmServer = NULL;
       
  3021     delete iTmServerDeviceInfo;
       
  3022     iTmServerDeviceInfo = NULL;   
       
  3023     CActiveScheduler::Stop();
       
  3024     }
       
  3025 
       
  3026 void CTmServerTest::TestTimerDiscoveryTimedOut()
       
  3027     {
       
  3028     CActiveScheduler::Stop();
       
  3029     }
       
  3030 
       
  3031 void CTmServerTest::DeviceVerified()
       
  3032     {
       
  3033     iDeviceVerified = ETrue;
       
  3034     }
       
  3035 
       
  3036 void CTmServerTest::DeviceLostVerified()
       
  3037     {
       
  3038     iDeviceLostVerified = ETrue;
       
  3039     }
       
  3040 
       
  3041 void CTmServerTest::ServiceVerified()
       
  3042     {
       
  3043     iServiceVerified = ETrue;
       
  3044     }
       
  3045 
       
  3046 CDiscoverDevice* CDiscoverDevice::NewL(CTmServerTest& aTmServerTest)
       
  3047     {
       
  3048     CDiscoverDevice* self = new (ELeave) CDiscoverDevice(aTmServerTest);
       
  3049     CleanupStack::PushL( self );
       
  3050     self->ConstructL();
       
  3051     CleanupStack::Pop( self );
       
  3052     return self;
       
  3053     }
       
  3054 
       
  3055 CDiscoverDevice::CDiscoverDevice(CTmServerTest& aTmServerTest):
       
  3056     iTmServerTest(aTmServerTest)
       
  3057     {
       
  3058     
       
  3059     }
       
  3060 
       
  3061 void CDiscoverDevice::ConstructL()
       
  3062     {
       
  3063     CDesC8ArrayFlat* targetDeviceTypes = new (ELeave) CDesC8ArrayFlat( 1 );
       
  3064     CleanupStack::PushL( targetDeviceTypes ); 
       
  3065     targetDeviceTypes->AppendL( KTmServerDevice() );    
       
  3066     CUpnpControlPoint::ConstructL( *targetDeviceTypes );
       
  3067     CleanupStack::Pop( targetDeviceTypes );
       
  3068     targetDeviceTypes->Reset();
       
  3069     delete targetDeviceTypes;
       
  3070     targetDeviceTypes = NULL;
       
  3071 
       
  3072     //SSDP search for Terminalmode server devices
       
  3073     if (iTmServerTest.iTmServerDeviceType)
       
  3074          {
       
  3075           SearchL( KTmServerDevice() );
       
  3076           }
       
  3077     else if (iTmServerTest.iTmServerServiceType)
       
  3078           {
       
  3079           SearchL( KTmServerService() );
       
  3080           }   
       
  3081      }
       
  3082 
       
  3083 CDiscoverDevice::~CDiscoverDevice()
       
  3084     {   
       
  3085 
       
  3086     }
       
  3087 
       
  3088 
       
  3089 void CDiscoverDevice::StateUpdatedL( CUpnpService* aService )
       
  3090     {
       
  3091     CUpnpDevice& device = aService->Device();
       
  3092     if (aService->ServiceType().Match( KTmServerServiceType ) != KErrNotFound )
       
  3093         {
       
  3094         TInt err =  TmServerStateUpdated( device, aService );
       
  3095         }
       
  3096     else
       
  3097         {
       
  3098         User::Leave(KErrGeneral);
       
  3099         }
       
  3100     }
       
  3101 
       
  3102 TInt CDiscoverDevice::TmServerStateUpdated( CUpnpDevice& aDevice,
       
  3103                                                         CUpnpService*& aService )
       
  3104     {
       
  3105     CUpnpStateVariable* appStatusUpdate = aService->StateVariable( KArgTypeAppStatusUpdate );
       
  3106     if( !appStatusUpdate )
       
  3107         {
       
  3108         iTmServerTest.iStatusNotified = EFalse;
       
  3109         return KErrArgument;
       
  3110         }
       
  3111     else
       
  3112         {
       
  3113         const TDesC8& deviceUuid = aDevice.Uuid();
       
  3114         const TDesC8& statusBuf = appStatusUpdate->Value(); 
       
  3115 
       
  3116         iTmServerTest.iStatusNotified = ETrue;
       
  3117         }
       
  3118     return KErrNone;
       
  3119     }
       
  3120 
       
  3121 void CDiscoverDevice::DeviceDiscoveredL( CUpnpDevice* aDevice )
       
  3122     {
       
  3123     if( iTmServerTest.iTmServerDeviceType)
       
  3124         {
       
  3125         if(aDevice->DeviceType().Compare(KTmServerDevice) == KErrNone )
       
  3126             {
       
  3127             iTmServerTest.DeviceVerified();   
       
  3128             }
       
  3129         }
       
  3130     else if( iTmServerTest.iTmServerServiceType)
       
  3131         {
       
  3132         if(aDevice->ServiceDescriptionReceiveState()== CUpnpDevice::EAllServicesAdded)
       
  3133             {
       
  3134             iTmServerTest.ServiceVerified();
       
  3135             }
       
  3136         }
       
  3137     }
       
  3138 
       
  3139 void CDiscoverDevice::DeviceDisappearedL( CUpnpDevice* /*aDevice */)
       
  3140     {
       
  3141      iTmServerTest.DeviceLostVerified();
       
  3142     }
       
  3143 
       
  3144 void CDiscoverDevice::ActionResponseReceivedL( CUpnpAction* aAction )
       
  3145     {
       
  3146     CUpnpService& service = aAction->Service();
       
  3147     if( service.ServiceType().Length() <= 0 )
       
  3148         {
       
  3149         User::Leave(KErrArgument);
       
  3150         }
       
  3151     if (aAction->Name().Compare(KGetApplicationList) == KErrNone)
       
  3152         {
       
  3153         aAction->ArgumentValue( KAppListing );
       
  3154         iTmServerTest.iGetAppList = ETrue;
       
  3155         }
       
  3156     else if (aAction->Name().Compare(KLaunchApp) == KErrNone)
       
  3157         {
       
  3158         aAction->ArgumentValue( KAppLaunchStatus );
       
  3159         iTmServerTest.iStartApp = ETrue;
       
  3160         }
       
  3161     else if (aAction->Name().Compare(KTerminateApp) == KErrNone)
       
  3162         {
       
  3163         aAction->ArgumentValue( KAppTerminateStatus );
       
  3164         iTmServerTest.iStopApp = ETrue;
       
  3165         }
       
  3166     else if (aAction->Name().Compare(KGetAppStatus) == KErrNone)
       
  3167         {
       
  3168         aAction->ArgumentValue( KAppStatus );
       
  3169         iTmServerTest.iGetAppStatus = ETrue;
       
  3170         }
       
  3171     else if (aAction->Name().Compare(KSetClientProfile) == KErrNone)
       
  3172         {
       
  3173         aAction->ArgumentValue( KResultProfile );
       
  3174         iTmServerTest.iSetClientProfile = ETrue;
       
  3175         }
       
  3176     else if (aAction->Name().Compare(KGetClientProfile) == KErrNone)
       
  3177         {
       
  3178         aAction->ArgumentValue( KClientProfile );
       
  3179         iTmServerTest.iGetClientProfile = ETrue;
       
  3180         }
       
  3181     else if (aAction->Name().Compare(KGetMaxNumProfiles) == KErrNone)
       
  3182         {
       
  3183         aAction->ArgumentValue( KNumProfilesAllowed );
       
  3184         iTmServerTest.iGetMaxNumProfiles = ETrue;
       
  3185         }
       
  3186     }
       
  3187 
       
  3188  void CDiscoverDevice::HttpResponseReceivedL( CUpnpHttpMessage* /*aMessage*/ )
       
  3189     {
       
  3190     
       
  3191     }
       
  3192 
       
  3193 
       
  3194 TInt CDiscoverDevice::GetAppListActionL( const TDesC8& aAppListFilter ,TInt aProfileId )
       
  3195     {
       
  3196     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3197     if( deviceList.Count() == KErrNone ) 
       
  3198         {
       
  3199         return KErrBadHandle;
       
  3200         }
       
  3201     TInt i(0);
       
  3202     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3203         {
       
  3204         i++;
       
  3205         }
       
  3206     if( i == deviceList.Count()) 
       
  3207         {
       
  3208         return KErrNotFound;
       
  3209         }
       
  3210     RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3211     
       
  3212     for( TInt i(0); i < services.Count(); i++ )
       
  3213         {
       
  3214         if( services[i]->ServiceType().Match( KTmServerServiceType ) != KErrNotFound )
       
  3215             {
       
  3216             CUpnpAction* action = services[i]->CreateActionLC( KGetApplicationList );
       
  3217                if( action )
       
  3218                   {
       
  3219                   TBuf8<8> buf;
       
  3220                   buf.Num(aProfileId); 
       
  3221                   action->SetArgumentL(KAppFilter, aAppListFilter );
       
  3222                   action->SetArgumentL(KProfileId, buf );
       
  3223                   SendL( action );                 
       
  3224                   CleanupStack::Pop( action );
       
  3225                   return action->SessionId();
       
  3226                   }
       
  3227                else
       
  3228                   {
       
  3229                   return KErrGeneral;
       
  3230                   }
       
  3231             }
       
  3232         }
       
  3233     return KErrNotFound;
       
  3234     }
       
  3235 
       
  3236 
       
  3237 
       
  3238 TInt CDiscoverDevice::LaunchAppActionL( TInt aAppId, TInt aProfileId )
       
  3239     {
       
  3240     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3241     if( deviceList.Count() == KErrNone ) 
       
  3242         {
       
  3243         return KErrBadHandle;
       
  3244         }
       
  3245     TInt i(0);
       
  3246     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3247         {
       
  3248         i++;
       
  3249         }
       
  3250     if( i == deviceList.Count()) 
       
  3251         {
       
  3252         return KErrNotFound;
       
  3253         }
       
  3254     RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3255     
       
  3256     for( TInt i(0); i < services.Count(); i++ )
       
  3257         {
       
  3258         if( services[i]->ServiceType().Match( KTmServerServiceType ) != KErrNotFound )
       
  3259             {
       
  3260             CUpnpAction* action =  services[i]->CreateActionLC( KLaunchApp );
       
  3261             if( action )
       
  3262               {
       
  3263                   TBuf8<8> buf;
       
  3264                   buf.Num(aAppId);  
       
  3265                   action->SetArgumentL( KAppId, buf );                                  
       
  3266                   buf.Zero();
       
  3267                   buf.Num(aProfileId);  
       
  3268                   action->SetArgumentL( KProfileId, buf );                  
       
  3269                }            
       
  3270               SendL( action );
       
  3271               CleanupStack::Pop( action );
       
  3272               return action->SessionId();
       
  3273               }
       
  3274             else
       
  3275               {
       
  3276               return KErrGeneral;
       
  3277               }
       
  3278             }
       
  3279         return KErrNotFound;
       
  3280     }
       
  3281 
       
  3282 TInt CDiscoverDevice::TerminateAppActionL( TInt aAppId, TInt aProfileId )
       
  3283     {
       
  3284     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3285     if( deviceList.Count() == KErrNone ) 
       
  3286         {
       
  3287         return KErrBadHandle;
       
  3288         }
       
  3289     TInt i(0);
       
  3290     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3291         {
       
  3292         i++;
       
  3293         }
       
  3294     if( i == deviceList.Count()) 
       
  3295         {
       
  3296         return KErrNotFound;
       
  3297         }
       
  3298     RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3299     
       
  3300     for( TInt i(0); i < services.Count(); i++ )
       
  3301         {
       
  3302         if( services[i]->ServiceType().Match( KTmServerServiceType ) != KErrNotFound )
       
  3303             {
       
  3304             CUpnpAction* action =  services[i]->CreateActionLC( KTerminateApp );
       
  3305             if( action )
       
  3306               {
       
  3307                   TBuf8<8> buf;
       
  3308                   buf.Num(aAppId);             
       
  3309                   action->SetArgumentL( KAppId, buf );
       
  3310                   buf.Zero();
       
  3311                   buf.Num(aProfileId);             
       
  3312                   action->SetArgumentL( KProfileId, buf );
       
  3313                }            
       
  3314 
       
  3315               SendL( action );
       
  3316               CleanupStack::Pop( action );
       
  3317               return action->SessionId();
       
  3318               }
       
  3319             else
       
  3320               {
       
  3321               return KErrGeneral;
       
  3322               }
       
  3323             }       
       
  3324     return KErrNotFound;
       
  3325     }
       
  3326 
       
  3327 TInt CDiscoverDevice::GetAppStatusActionL( TInt aAppId )
       
  3328     {
       
  3329     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3330     if( deviceList.Count() == KErrNone ) 
       
  3331         {
       
  3332         return KErrBadHandle;
       
  3333         }
       
  3334     TInt i(0);
       
  3335     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3336         {
       
  3337         i++;
       
  3338         }
       
  3339     if( i == deviceList.Count()) 
       
  3340         {
       
  3341         return KErrNotFound;
       
  3342         }
       
  3343     RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3344     
       
  3345     for( TInt i(0); i < services.Count(); i++ )
       
  3346         {
       
  3347         if( services[i]->ServiceType().Match( KTmServerServiceType ) != KErrNotFound )
       
  3348             {
       
  3349             CUpnpAction* action = services[i]->CreateActionLC( KGetAppStatus );
       
  3350             if( action )
       
  3351                {
       
  3352                TBuf8<8> buf;
       
  3353                buf.Num(aAppId); 
       
  3354                if ( aAppId == KAppId1Value || aAppId == KNonExistentAppIdValue )
       
  3355                     {   
       
  3356                     action->SetArgumentL( KAppId, buf );                 
       
  3357                     }              
       
  3358                else if( aAppId == KAppId5Value )
       
  3359                    {
       
  3360                     _LIT8(KWildCard, "*");
       
  3361                     action->SetArgumentL( KAppId, KWildCard());
       
  3362                    }   
       
  3363                else
       
  3364                    {
       
  3365                    action->SetArgumentL( KAppId, KNullDesC8());
       
  3366                    }
       
  3367                SendL( action );
       
  3368                CleanupStack::Pop( action );
       
  3369                return action->SessionId();
       
  3370                }
       
  3371             else
       
  3372                {
       
  3373                return KErrGeneral;
       
  3374                }
       
  3375              }
       
  3376          }
       
  3377      return KErrNotFound;
       
  3378      }
       
  3379 
       
  3380 TInt CDiscoverDevice::SetClientProfileActionL(TInt aProfileId, const TDesC8& aClientInfoValue )
       
  3381     {
       
  3382     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3383     if( deviceList.Count() == KErrNone ) 
       
  3384         {
       
  3385         return KErrBadHandle;
       
  3386         }
       
  3387     TInt i(0);
       
  3388     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3389         {
       
  3390         i++;
       
  3391         }
       
  3392     if( i == deviceList.Count()) 
       
  3393         {
       
  3394         return KErrNotFound;
       
  3395         }
       
  3396     RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3397     
       
  3398     for( TInt i(0); i < services.Count(); i++ )
       
  3399         {
       
  3400         if( services[i]->ServiceType().Match( KTmServerServiceType1 ) != KErrNotFound )
       
  3401             {
       
  3402             CUpnpAction* action = services[i]->CreateActionLC( KSetClientProfile);
       
  3403             if( action )
       
  3404                {   
       
  3405                TBuf8<8> buf;
       
  3406                buf.Num(aProfileId); 
       
  3407                action->SetArgumentL(KProfileId1, buf );
       
  3408                action->SetArgumentL(KClientProfile, aClientInfoValue );
       
  3409                SendL( action );
       
  3410                CleanupStack::Pop( action );
       
  3411                return action->SessionId();
       
  3412                }
       
  3413             else
       
  3414                {
       
  3415                return KErrGeneral;
       
  3416                }
       
  3417              }
       
  3418          }
       
  3419      return KErrNotFound;
       
  3420      }
       
  3421 
       
  3422 TInt CDiscoverDevice::GetClientProfileActionL(TInt aProfileId )
       
  3423     {
       
  3424     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3425     if( deviceList.Count() == KErrNone ) 
       
  3426         {
       
  3427         return KErrBadHandle;
       
  3428         }
       
  3429     TInt i(0);
       
  3430     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3431         {
       
  3432         i++;
       
  3433         }
       
  3434     if( i == deviceList.Count()) 
       
  3435         {
       
  3436         return KErrNotFound;
       
  3437         }
       
  3438     RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3439     
       
  3440     for( TInt i(0); i < services.Count(); i++ )
       
  3441         {
       
  3442         if( services[i]->ServiceType().Match( KTmServerServiceType1 ) != KErrNotFound )
       
  3443             {
       
  3444             CUpnpAction* action = services[i]->CreateActionLC( KGetClientProfile);
       
  3445             if( action )
       
  3446                {   
       
  3447                TBuf8<8> buf;
       
  3448                buf.Num(aProfileId); 
       
  3449                action->SetArgumentL(KProfileId1, buf );
       
  3450                SendL( action );
       
  3451                CleanupStack::Pop( action );
       
  3452                return action->SessionId();
       
  3453                }
       
  3454             else
       
  3455                {
       
  3456                return KErrGeneral;
       
  3457                }
       
  3458              }
       
  3459          }
       
  3460      return KErrNotFound;
       
  3461      }
       
  3462 
       
  3463 TInt CDiscoverDevice::GetMaxNumProfilesActionL( )
       
  3464     {
       
  3465     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3466     if( deviceList.Count() == KErrNone ) 
       
  3467         {
       
  3468         return KErrBadHandle;
       
  3469         }
       
  3470     TInt i(0);
       
  3471     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3472         {
       
  3473         i++;
       
  3474         }
       
  3475     if( i == deviceList.Count()) 
       
  3476         {
       
  3477         return KErrNotFound;
       
  3478         }
       
  3479     RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3480     
       
  3481     for( TInt i(0); i < services.Count(); i++ )
       
  3482         {
       
  3483         if( services[i]->ServiceType().Match( KTmServerServiceType1 ) != KErrNotFound )
       
  3484             {
       
  3485             CUpnpAction* action = services[i]->CreateActionLC( KGetMaxNumProfiles);
       
  3486             if( action )
       
  3487                {   
       
  3488                SendL( action );
       
  3489                CleanupStack::Pop( action );
       
  3490                return action->SessionId();
       
  3491                }
       
  3492             else
       
  3493                {
       
  3494                return KErrGeneral;
       
  3495                }
       
  3496              }
       
  3497          }
       
  3498      return KErrNotFound;
       
  3499      }
       
  3500 
       
  3501 void CDiscoverDevice::SubscribeToServiceL()
       
  3502     {
       
  3503     const RPointerArray<CUpnpDevice>& deviceList = DeviceList();
       
  3504     if( deviceList.Count() == KErrNone ) 
       
  3505         {
       
  3506         User::Leave( KErrBadHandle );
       
  3507         }
       
  3508     TInt i(0);
       
  3509     while ( deviceList[i]->DeviceType().Compare(KTmServerDevice()) != KErrNone )
       
  3510         {
       
  3511         i++;
       
  3512         }
       
  3513     if( i == deviceList.Count()) 
       
  3514         {
       
  3515         User::Leave ( KErrNotFound );
       
  3516         }
       
  3517         RPointerArray<CUpnpService>& services = const_cast<CUpnpDevice*>(deviceList[i])->ServiceList();
       
  3518         
       
  3519     for( TInt i(0); i < services.Count(); i++ )
       
  3520         {
       
  3521         if( services[i]->ServiceType().Match( KTmServerServiceType ) != KErrNotFound )
       
  3522             {
       
  3523             SubscribeL( services[i] ); 
       
  3524             }
       
  3525         }
       
  3526     }
       
  3527 
       
  3528 TTerminalModeErrorCode CTmServerTest::OnGetApplicationList(TUint aProfileId ) 
       
  3529     {
       
  3530     if(iOperationRejected )
       
  3531         {
       
  3532         return ETerminalModeOperationRejected;
       
  3533         }
       
  3534     else if ( ( aProfileId == 0 ) || ( aProfileId == 1 ) || ( aProfileId == 2) || ( aProfileId == 3 ) 
       
  3535             || ( aProfileId == 4 ) || ( aProfileId == 5 ) || ( aProfileId == 6 ) ) 
       
  3536         { 
       
  3537         return ETerminalModeSuccess;   
       
  3538         } 
       
  3539     return ETerminalModeInvalidProfileId; 
       
  3540     }
       
  3541 
       
  3542 TTerminalModeErrorCode CTmServerTest::OnLaunchApp( TUint aAppId, RBuf8& aUrl, TUint aProfileId )                                                                       
       
  3543     {
       
  3544     if ( ( aProfileId != 0 ) && ( aProfileId != 1 ) && ( aProfileId != 2) && ( aProfileId != 3 ) 
       
  3545              && ( aProfileId != 4 ) && ( aProfileId != 5 ) && ( aProfileId != 6 ) ) 
       
  3546         { 
       
  3547         return ETerminalModeInvalidProfileId;   
       
  3548         }
       
  3549     aUrl.Close();
       
  3550     if ( aAppId == KAppIdValue )
       
  3551         {
       
  3552         _LIT8(KUrl, "VNC://192.168.4.1:5900");
       
  3553         aUrl.Create(KUrl());
       
  3554         }
       
  3555     else if ( aAppId == KAppId1Value )
       
  3556         {
       
  3557         _LIT8(KUrl, "RTP://192.168.2.1:5900");
       
  3558         aUrl.Create(KUrl());
       
  3559         }
       
  3560     else if ( aAppId == KAppId2Value )
       
  3561         {
       
  3562         _LIT8(KUrl, "BTA2DP://192.168.2.1:5900");
       
  3563         aUrl.Create(KUrl());
       
  3564         }
       
  3565     else if  ( aAppId == KAppId3Value)
       
  3566         {
       
  3567         _LIT8(KUrl, "BTHFP://192.168.2.1:5900");
       
  3568         aUrl.Create(KUrl());
       
  3569         }
       
  3570     else if  ( aAppId == KAppId4Value)
       
  3571         {
       
  3572         return ETerminalModeDeviceLocked;
       
  3573         }
       
  3574     else 
       
  3575         {
       
  3576         return ETerminalModeUnauthorizedApp;
       
  3577         }   
       
  3578     return ETerminalModeSuccess;
       
  3579     }
       
  3580     
       
  3581 TTerminalModeErrorCode CTmServerTest::OnTerminateApp( TUint aAppId, TUint aProfileId )
       
  3582     {
       
  3583     if ( ( aProfileId != 0 ) && ( aProfileId != 1 ) && ( aProfileId != 2) && ( aProfileId != 3 ) 
       
  3584              && ( aProfileId != 4 ) && ( aProfileId != 5 ) && ( aProfileId != 6 ) ) 
       
  3585          { 
       
  3586          return ETerminalModeInvalidProfileId;   
       
  3587          }
       
  3588    if ( aAppId == KAppIdValue|| aAppId == KAppId1Value || aAppId == KAppId2Value || aAppId == KAppId3Value)
       
  3589        {
       
  3590         return ETerminalModeSuccess;
       
  3591        }
       
  3592    else if  ( aAppId == KAppId4Value)
       
  3593        {
       
  3594         return ETerminalModeDeviceLocked;
       
  3595        }
       
  3596    else
       
  3597        {
       
  3598         return ETerminalModeUnauthorizedApp;
       
  3599        }
       
  3600     }
       
  3601 
       
  3602 TTerminalModeErrorCode CTmServerTest::OnGetAppStatus(  TUint aAppId, TUint& aProfileId ,RBuf8& aStatusType )
       
  3603     {
       
  3604     aProfileId = KErrNone;
       
  3605     aStatusType.Close();
       
  3606     if ( aAppId == KAppIdValue )
       
  3607         {
       
  3608         aStatusType.Create(KBackground());
       
  3609         }
       
  3610     else if ( aAppId == KAppId1Value )
       
  3611         {
       
  3612          aStatusType.Create(KForeground());
       
  3613         }
       
  3614     else if ( aAppId == KAppId2Value )
       
  3615         {
       
  3616         aStatusType.Create(KBackground());
       
  3617         }
       
  3618     else if ( aAppId == KAppId3Value )
       
  3619         {
       
  3620         aStatusType.Create(KForeground());
       
  3621         }  
       
  3622     else
       
  3623         {
       
  3624         aStatusType.Create(KBackground());
       
  3625         } 
       
  3626     return ETerminalModeSuccess;
       
  3627     }
       
  3628 
       
  3629 TTerminalModeErrorCode CTmServerTest::OnGetMaxNumProfiles( TUint& aProfileIdCount )
       
  3630     {
       
  3631     if (iOperationRejected )
       
  3632         {
       
  3633         return ETerminalModeOperationRejected;
       
  3634         }
       
  3635     else
       
  3636         {
       
  3637         aProfileIdCount = 9;
       
  3638         return ETerminalModeSuccess;  
       
  3639         }
       
  3640     }
       
  3641 
       
  3642 TTerminalModeErrorCode CTmServerTest::OnSetClientProfile(TUint aProfileId, const TDesC8& aClientProfile,RBuf8& aResultProfile  )
       
  3643     {
       
  3644     _LIT8(KClientInfo,"<clientProfile><clientID>Cl_2</clientID></clientProfile>");
       
  3645     if(iResourceBusy)
       
  3646         {
       
  3647         return ETerminalModeResourceBusy;
       
  3648         }
       
  3649     else if(aClientProfile.Compare(KClientInfo()) == KErrNone )
       
  3650          {
       
  3651          return ETerminalModeDeviceLocked;   
       
  3652          }  
       
  3653     else if ( ( aClientProfile.Find(_L8("<clientProfile><")) == KErrNotFound ) &&
       
  3654         ( aClientProfile.Find(_L8("&lt;clientProfile&gt;&lt;")) == KErrNotFound ))
       
  3655        {
       
  3656        return ETerminalModeInvalidProfile;   
       
  3657        }
       
  3658     CUpnpTmClientIconPref* clientIconPref = NULL;
       
  3659     if ( aProfileId == 0 )
       
  3660        {
       
  3661        // different mime type but same dimension
       
  3662        clientIconPref = CUpnpTmClientIconPref::NewL(0);
       
  3663        clientIconPref->SetWidth(88);
       
  3664        clientIconPref->SetHeight(88);   
       
  3665        }
       
  3666     else if ( aProfileId == 1 )
       
  3667        {
       
  3668        // different mime type and different dimension
       
  3669        clientIconPref = CUpnpTmClientIconPref::NewL(1);
       
  3670        clientIconPref->SetMimeTypeL(_L8("image/bmp"));
       
  3671        clientIconPref->SetWidth(70);
       
  3672        clientIconPref->SetHeight(80);   
       
  3673        }
       
  3674     else if ( aProfileId == 2 )
       
  3675        {
       
  3676        // different mime type and no dimension specified by the client
       
  3677        clientIconPref = CUpnpTmClientIconPref::NewL(2); 
       
  3678        clientIconPref->SetMimeTypeL(_L8("image/bmp"));
       
  3679        }
       
  3680     else if ( aProfileId == 3 )
       
  3681        {
       
  3682        // same mime type but different dimension
       
  3683        clientIconPref = CUpnpTmClientIconPref::NewL(3);
       
  3684        clientIconPref->SetMimeTypeL(_L8("image/svg+xml"));
       
  3685        clientIconPref->SetWidth(100);
       
  3686        clientIconPref->SetHeight(100);       
       
  3687        }
       
  3688     else if ( aProfileId == 4 )
       
  3689        {
       
  3690        // same mime type but no dimension specified by the client
       
  3691        clientIconPref = CUpnpTmClientIconPref::NewL(4);
       
  3692        clientIconPref->SetMimeTypeL(_L8("image/svg+xml"));  
       
  3693        }
       
  3694     else if ( aProfileId == 5 )
       
  3695        {
       
  3696        // same mime type and same dimension
       
  3697        clientIconPref = CUpnpTmClientIconPref::NewL(5);
       
  3698        clientIconPref->SetMimeTypeL(_L8("image/svg+xml")); 
       
  3699        clientIconPref->SetWidth(88);
       
  3700        clientIconPref->SetHeight(88); 
       
  3701        }
       
  3702     else if ( aProfileId == 6 )
       
  3703         {
       
  3704         // different mime type(jpeg) and different dimensions
       
  3705         clientIconPref = CUpnpTmClientIconPref::NewL(6);
       
  3706         clientIconPref->SetMimeTypeL(_L8("image/jpeg")); 
       
  3707         clientIconPref->SetWidth(36);
       
  3708         clientIconPref->SetHeight(44); 
       
  3709         }
       
  3710     else
       
  3711        {
       
  3712        return ETerminalModeInvalidProfileId;     
       
  3713        }
       
  3714     iClientIconPrefArray.AppendL(clientIconPref);
       
  3715     RBuf8 clientProfile;
       
  3716     clientProfile.Create(aClientProfile);
       
  3717     aResultProfile.Close();
       
  3718     aResultProfile.Create(clientProfile);
       
  3719     clientProfile.Close();
       
  3720     return ETerminalModeSuccess;
       
  3721     }
       
  3722 
       
  3723 TTerminalModeErrorCode CTmServerTest::OnGetClientProfile( TUint aProfileId, RBuf8& aClientProfile)
       
  3724     {
       
  3725     if ( ( aProfileId == 0 ) || ( aProfileId == 1 ) || ( aProfileId == 2) || ( aProfileId == 3 ) 
       
  3726             || ( aProfileId == 4 ) || ( aProfileId == 5 ) || ( aProfileId == 6 ) ) 
       
  3727          { 
       
  3728          aClientProfile.Close();
       
  3729          aClientProfile.Create(KClientProfile());
       
  3730          return ETerminalModeSuccess;   
       
  3731          } 
       
  3732     return ETerminalModeInvalidProfileId;  
       
  3733     }
       
  3734 
       
  3735 const CUpnpTmClientIconPref& CTmServerTest::GetClientIconPrefsL( TUint aProfileId )
       
  3736     {
       
  3737     CUpnpTmClientIconPref* clientIconPref = NULL;
       
  3738     for ( TInt i(0); i < iClientIconPrefArray.Count(); i++ )
       
  3739         {
       
  3740         if ( iClientIconPrefArray[i]->ClientProfileId() == aProfileId )     
       
  3741             {
       
  3742             clientIconPref = iClientIconPrefArray[i];  
       
  3743             break;
       
  3744             }
       
  3745         }
       
  3746     return *clientIconPref;
       
  3747     }
       
  3748