telephonyserverplugins/common_tsy/test/component/ussdtestclient/src/ussdtestclient.cpp
author Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
Fri, 04 Jun 2010 13:03:15 +0100
branchopencode
changeset 35 6fbc08ed9c42
child 85 96b4f933d69a
permissions -rw-r--r--
opencode: Added USSD test client to CTSY component tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     7
//
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    10
//
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    11
// Contributors:
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    12
//
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    13
// Description:
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    14
//
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    15
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    16
#include "ussdtestclient.h"
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    17
#include <ctsy/mmtsy_names.h>
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    18
#include <e32debug.h>
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    19
#include <e32math.h> 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    20
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    21
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    22
CCTsyUssdMessagingTestClient::CCTsyUssdMessagingTestClient()
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    23
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    24
    }  
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    25
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    26
/**
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    27
@SYMTestCaseID 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    28
@SYMComponent  telephony_ctsy
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    29
@SYMTestCaseDesc Test support in CTSY for RMobileUssdMessaging::ReceiveMessage
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    30
@SYMTestPriority High
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    31
@SYMTestActions Invokes RMobileUssdMessaging::ReceiveMessage
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    32
@SYMTestExpectedResults Pass
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    33
@SYMTestType CT
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    34
*/
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    35
TInt CCTsyUssdMessagingTestClient::ReceiveMessageL(TBool aAcceptDialogue, TBool aReceiveTimeout, TReal aAfterTimePeriod)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    36
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    37
    // Create a cleanup stack object
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    38
    CTrapCleanup* cleanup=CTrapCleanup::New();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    39
    if (cleanup==NULL)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    40
        return KErrNoMemory;    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    41
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    42
    RTelServer server;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    43
    RMobilePhone phone;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    44
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    45
    TInt ret = server.Connect();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    46
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    47
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    48
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    49
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    50
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    51
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    52
    ret = phone.Open(server,KMmTsyPhoneName);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    53
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    54
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    55
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    56
        phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    57
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    58
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    59
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    60
    TRequestStatus requestStatus;   
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    61
    RMobileUssdMessaging::TGsmUssdMessageData name;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    62
    RMobileUssdMessaging::TMobileUssdAttributesV1 attributes;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    63
    TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(attributes);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    64
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    65
    RMobileUssdMessaging ussdMessaging;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    66
    ret = ussdMessaging.Open(phone);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    67
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    68
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    69
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    70
        phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    71
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    72
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    73
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    74
    //RDebug::Printf("%x >> ReceiveMessage", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    75
    ussdMessaging.ReceiveMessage(requestStatus, name, msgAttributes);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    76
    //RDebug::Printf("%x << ReceiveMessage", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    77
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    78
    if (aReceiveTimeout)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    79
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    80
        // This section of code and the aReceiveTimeout parameter apply
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    81
        // to the TestReceiveMessageWithTestClient0016L test 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    82
        // (BA-CTSY-USSDM-URM-0020).
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    83
        // This test verifies that the second client does not recieve
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    84
        // a message. As part of the test spec we must call close on
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    85
        // the RMobileUssdMessaging object.
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    86
        // Rather than adding a whole ActiveScheduler framework to this
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    87
        // executable we've put in a wait and check loop. We can't use 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    88
        // User::WaitForRequest as this would block. We don't want to
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    89
        // block as we are checking that an event which 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    90
        // *does not occur* rather than checking for an event which
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    91
        // does occur.
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    92
        for (TInt i=0; i<50; ++i)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    93
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    94
            User::After(100000); // 0.1s
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    95
            if (requestStatus.Int() != KRequestPending)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    96
                {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    97
                break;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    98
                }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
    99
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   100
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   101
        if (requestStatus.Int() == KRequestPending)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   102
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   103
            ussdMessaging.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   104
            phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   105
            server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   106
            
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   107
            delete cleanup;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   108
            return KRequestPending;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   109
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   110
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   111
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   112
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   113
    //RDebug::Printf("%x >> WaitForRequest", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   114
    User::WaitForRequest(requestStatus);     
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   115
    //RDebug::Printf("%x << WaitForRequest", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   116
    //RDebug::Printf("%x requestStatus = %d", User::Identity(), requestStatus.Int());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   117
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   118
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   119
    if (aAfterTimePeriod)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   120
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   121
        //RDebug::Printf("%x Waiting for %f seconds", User::Identity(), aAfterTimePeriod);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   122
        // Wait, mimic a bad client taking too long...
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   123
        User::After(aAfterTimePeriod * 1000000);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   124
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   125
        
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   126
    if (aAcceptDialogue)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   127
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   128
        //RDebug::Printf("%x >> AcceptIncomingDialogue", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   129
        // Client wants the dialogue
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   130
        ret = ussdMessaging.AcceptIncomingDialogue(); 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   131
        //RDebug::Printf("%x << AcceptIncomingDialogue", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   132
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   133
    else
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   134
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   135
        // Client not interested
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   136
        //RDebug::Printf("%x >> RejectIncomingDialogue", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   137
        ret = ussdMessaging.RejectIncomingDialogue();   
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   138
        //RDebug::Printf("%x << RejectIncomingDialogue", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   139
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   140
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   141
    User::After(2 * 1000000);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   142
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   143
    ussdMessaging.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   144
    phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   145
    server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   146
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   147
    delete cleanup;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   148
    return ret;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   149
	}
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   150
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   151
TInt CCTsyUssdMessagingTestClient::SendMessageL()
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   152
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   153
    // Create a cleanup stack object
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   154
    CTrapCleanup* cleanup=CTrapCleanup::New();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   155
    if (cleanup==NULL)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   156
        return KErrNoMemory;    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   157
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   158
    RTelServer server;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   159
    RMobilePhone phone;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   160
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   161
    TInt ret = server.Connect();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   162
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   163
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   164
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   165
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   166
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   167
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   168
    ret = phone.Open(server,KMmTsyPhoneName);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   169
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   170
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   171
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   172
        phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   173
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   174
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   175
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   176
    TRequestStatus requestStatus;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   177
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   178
    TUint32 flags = 100;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   179
    RMobileUssdMessaging::TMobileUssdDataFormat format = RMobileUssdMessaging::EFormatUnspecified;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   180
    RMobileUssdMessaging::TMobileUssdMessageType type  = RMobileUssdMessaging::EUssdMORequest;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   181
    TUint8 dcs = 200;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   182
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   183
    RMobileUssdMessaging::TMobileUssdAttributesV1 attributes;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   184
    TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(attributes);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   185
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   186
    attributes.iFlags  = flags;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   187
    attributes.iFormat = format;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   188
    attributes.iType   = type;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   189
    attributes.iDcs   = dcs;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   190
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   191
    TName name = _L("Name1");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   192
    TPckg<TName> msgData(name);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   193
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   194
    RMobileUssdMessaging ussdMessaging;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   195
    ret = ussdMessaging.Open(phone);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   196
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   197
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   198
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   199
        phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   200
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   201
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   202
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   203
    //RDebug::Printf(">> SendMessage");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   204
    ussdMessaging.SendMessage(requestStatus, msgData, msgAttributes);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   205
    //RDebug::Printf("<< SendMessage");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   206
    //RDebug::Printf(">> WaitForRequest");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   207
    User::WaitForRequest(requestStatus);     
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   208
    //RDebug::Printf("<< WaitForRequest");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   209
    ret = requestStatus.Int();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   210
    //RDebug::Printf("requestStatus = %d", ret);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   211
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   212
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   213
    User::After(2 * 1000000);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   214
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   215
    ussdMessaging.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   216
    phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   217
    server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   218
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   219
    delete cleanup;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   220
    return KErrNone;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   221
    }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   222
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   223
TInt CCTsyUssdMessagingTestClient::RandomLoopL()
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   224
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   225
    // Create a cleanup stack object
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   226
    CTrapCleanup* cleanup=CTrapCleanup::New();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   227
    if (cleanup==NULL)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   228
        return KErrNoMemory;    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   229
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   230
    RTelServer server;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   231
    RMobilePhone phone;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   232
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   233
    TInt ret = server.Connect();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   234
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   235
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   236
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   237
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   238
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   239
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   240
    ret = phone.Open(server,KMmTsyPhoneName);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   241
    if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   242
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   243
        server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   244
        phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   245
        return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   246
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   247
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   248
    TRequestStatus requestStatus;   
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   249
    RMobileUssdMessaging::TGsmUssdMessageData name;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   250
    RMobileUssdMessaging::TMobileUssdAttributesV1 attributes;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   251
    TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(attributes);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   252
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   253
    RMobileUssdMessaging ussdMessaging;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   254
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   255
    FOREVER
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   256
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   257
        ret = ussdMessaging.Open(phone);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   258
        if (ret != KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   259
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   260
            server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   261
            phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   262
            return ret; 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   263
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   264
        
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   265
        //RDebug::Printf("%x >> ReceiveMessage", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   266
        ussdMessaging.ReceiveMessage(requestStatus, name, msgAttributes);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   267
        //RDebug::Printf("%x << ReceiveMessage", User::Identity());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   268
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   269
        if (ProbabilityPercent(50))
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   270
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   271
            for (TInt i=0; i<10; ++i)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   272
                {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   273
                User::After(100000); // 0.1s
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   274
                if (requestStatus.Int() != KRequestPending)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   275
                    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   276
                    break;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   277
                    }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   278
                }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   279
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   280
        else
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   281
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   282
            User::WaitForRequest(requestStatus);  
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   283
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   284
        
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   285
        if (requestStatus.Int() == KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   286
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   287
            if (ProbabilityPercent(50))
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   288
                {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   289
                TInt timeout = RandomNumber(1000000);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   290
                User::After(timeout);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   291
                }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   292
            
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   293
            if (ProbabilityPercent(50))
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   294
                {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   295
                ret = ussdMessaging.AcceptIncomingDialogue();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   296
                }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   297
            else
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   298
                {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   299
                ret = ussdMessaging.RejectIncomingDialogue();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   300
                }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   301
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   302
        else
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   303
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   304
            ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingReceiveMessage);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   305
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   306
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   307
        ussdMessaging.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   308
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   309
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   310
    phone.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   311
    server.Close();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   312
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   313
    delete cleanup;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   314
    return ret;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   315
    }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   316
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   317
TBool CCTsyUssdMessagingTestClient::ProbabilityPercent(TInt aPercentTrue)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   318
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   319
    TInt random = RandomNumber(100);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   320
    return aPercentTrue < random;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   321
    }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   322
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   323
// Not properly random but good enough...
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   324
TInt CCTsyUssdMessagingTestClient::RandomNumber(TInt aMax)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   325
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   326
    TUint32 rand = Math::Random() % aMax;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   327
    return rand;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   328
    }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   329
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   330
_LIT(KReceiveOption,"-R");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   331
_LIT(KReceiveTimeoutOption,"-RTimeout");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   332
_LIT(KSendOption,"-S");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   333
_LIT(KAcceptOption,"-A");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   334
_LIT(KTimerOption,"-T");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   335
_LIT(KRandomOption,"-Random");
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   336
TInt ParseCommandLine(TReal& aAfterTimePeriod)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   337
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   338
    TBuf<256> c;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   339
    User::CommandLine(c);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   340
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   341
    TLex l(c);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   342
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   343
    // Get options
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   344
    TInt option = 0;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   345
    aAfterTimePeriod = 0;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   346
    TPtrC nextToken;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   347
    for (;;)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   348
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   349
        nextToken.Set(l.NextToken());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   350
        if (nextToken == KReceiveOption)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   351
            {               
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   352
            option |= EOptionReceive;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   353
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   354
        else if (nextToken == KReceiveTimeoutOption)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   355
            { 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   356
            option |= EOptionReceiveTimeout;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   357
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   358
        else if (nextToken == KSendOption)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   359
            {               
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   360
            option |= EOptionSend;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   361
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   362
        else if (nextToken == KAcceptOption)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   363
            {               
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   364
            option |= EOptionAccept;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   365
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   366
        else if (nextToken == KTimerOption)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   367
            {               
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   368
            nextToken.Set(l.NextToken());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   369
            if (nextToken != KNullDesC)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   370
                {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   371
                TLex sl(nextToken);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   372
                if (sl.Val(aAfterTimePeriod)!=KErrNone)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   373
                    aAfterTimePeriod = 0.0;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   374
                }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   375
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   376
        else if (nextToken == KRandomOption)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   377
            {               
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   378
            option |= EOptionRandom;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   379
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   380
        else
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   381
            {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   382
            break;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   383
            }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   384
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   385
    return option;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   386
    }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   387
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   388
TInt E32Main()
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   389
/** 
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   390
   Executable entrypoint calls test functions within heap check.
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   391
 */
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   392
    {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   393
    //__UHEAP_MARK;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   394
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   395
    CTrapCleanup* cleanup=CTrapCleanup::New();
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   396
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   397
    TReal afterTimePeriod;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   398
    TInt option = ParseCommandLine(afterTimePeriod);
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   399
    TInt err = KErrNone;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   400
    TInt ret = KErrNone;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   401
    CCTsyUssdMessagingTestClient ussdClient;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   402
    if (option & EOptionReceive)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   403
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   404
        TRAPD(err, ret = ussdClient.ReceiveMessageL((option & EOptionAccept), (option & EOptionReceiveTimeout), afterTimePeriod));
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   405
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   406
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   407
    if (option & EOptionSend)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   408
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   409
        TRAPD(err, ret = ussdClient.SendMessageL());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   410
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   411
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   412
    if (option & EOptionRandom)
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   413
        {
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   414
        TRAPD(err, ret = ussdClient.RandomLoopL());
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   415
        }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   416
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   417
    delete cleanup;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   418
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   419
    //__UHEAP_MARKEND;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   420
    
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   421
    return err ? err : ret;
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   422
    }
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   423
6fbc08ed9c42 opencode: Added USSD test client to CTSY component tests
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
diff changeset
   424