smsprotocols/smsstack/test/smsstackbaseteststeps.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:40:21 +0100
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201035 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 2009-2009 Nokia Corporation and/or its subsidiary(-ies).
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
//
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
//
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
// Contributors:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
//
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
// Description:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
//
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
#include "smsstackbaseteststeps.h"
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <testconfigfileparser.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <simtsy.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <commsdattypesv1_1.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <gsmubuf.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <Gsmumsg.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <gsmuset.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <es_sock.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <smsustrm.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <c32root.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <sacls.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <e32math.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <smspver.h>
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "smsstacktestutilities.h"
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "smsstacktestconsts.h"
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "smsstacktestcase.h"
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include "smspdudb.h"
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
using namespace CommsDat;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
EXPORT_C CSmsBaseTestStep::CSmsBaseTestStep()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    // empty
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
EXPORT_C CSmsBaseTestStep::~CSmsBaseTestStep()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    // empty       
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
    Creates the file server session and marks the heap
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
*/
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
EXPORT_C TVerdict CSmsBaseTestStep::doTestStepPreambleL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    RDebug::Print(_L("%S"), &TestStepName());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
    User::LeaveIfError(iFs.Connect());  
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
    __UHEAP_MARK;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    SetTestNumberFromConfigurationFileL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    iSmsStackTestUtils = CSmsStackTestUtils::NewL(this,  iFs);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    iScheduler = new(ELeave) CActiveScheduler;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    CActiveScheduler::Install(iScheduler);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    TRAPD(ret, ParseSettingsFromFileL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    TESTCHECK(ret, KErrNone, "ParseSettingsFromFileL");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    if (!iPartOfMultiStepTestCase)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
        ConnectSocketServerL(iSocketServer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
    return TestStepResult();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    Closes file server session and unmarks the heap 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
*/
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
EXPORT_C TVerdict CSmsBaseTestStep::doTestStepPostambleL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    if (!iPartOfMultiStepTestCase)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
        iSocketServer.Close();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    delete iScheduler;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    iScheduler = NULL;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    delete iSmsStackTestUtils;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    iSmsStackTestUtils = NULL;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    __UHEAP_MARKEND;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    iFs.Close();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    if ( !iPartOfMultiStepTestCase && !iNotLastTestStep)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
        DoESockMemoryLeakTestL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    return TestStepResult();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
// TODO Method not needed - should be removed and replaced where appropriate
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
EXPORT_C void CSmsBaseTestStep::ParseSettingsFromFileL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    CTestConfig* configFile = CTestConfig::NewLC(iFs,KGmsSmsConfigFileDir,KGmsSmsConfigFileName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    const CTestConfigSection* cfgFile = configFile->Section(KSetupTelNumbers);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    TESTCHECKCONDITIONL(cfgFile!=NULL, "Open SMS configuration file");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    const CTestConfigItem* item = cfgFile->Item(KServiceCenter,0);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    TESTCHECKCONDITIONL(item!=NULL, "Read ServiceCentre value from the configuration file");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    iServiceCenterNumber.Copy(item->Value());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    item = cfgFile->Item(KTelefoneNumber,0);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    TESTCHECKCONDITIONL(item!=NULL, "Read TelephoneNumber value from the configuration file");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
    iTelephoneNumber.Copy(item->Value());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    CleanupStack::PopAndDestroy(configFile);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
 * Read the test number from  the configuration file.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
 * The test number is passed via property KUidPSSimTsyCategory. 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
 * The SIM tsy uses test number to parse correct script from config.txt
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
 * @return ETrue, if the test number has been assigned successfully, otherwise EFalse.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
EXPORT_C void CSmsBaseTestStep::SetTestNumberFromConfigurationFileL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    TInt testNumber (0);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
    if(GetIntFromConfig( ConfigSection(), KTestCaseNumber, testNumber))
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
        SetSimTSYTestNumberL(testNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
EXPORT_C void CSmsBaseTestStep::SetSimTSYTestNumberL(TInt aTestNumber)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    Set the SIM TSY Test number 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    @param aTestNumber is the test number in SIM TSY config file
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
*/
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
    {   
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    SetTestNumberL(KPSSimTsyTestNumber, aTestNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
 *  The test number is set with property aTestNumberProperty. This will notify the SIM tsy.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
 *  SIM tsy uses test number to parse correct script from the configuration file.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
 *  @param aTestNumberProperty The test number property UID
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
 *  @param aTestNumber The test number corresponding the test case
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
EXPORT_C void CSmsBaseTestStep::SetTestNumberL(TInt aTestNumberProperty, TInt aTestNumber)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    // Set the SIM.TSY test number...
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    RProperty testNumberProperty;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, aTestNumberProperty));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    CleanupClosePushL(testNumberProperty);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    testNumberProperty.Subscribe(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    INFO_PRINTF3(_L("Setting SimTsy test number property (0x%X) to %d"), aTestNumberProperty, aTestNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory, aTestNumberProperty, aTestNumber));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
    TESTCHECK(status.Int(), KErrNone, "Setting SimTsy test number property ");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    TInt testNumberCheck;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    User::LeaveIfError(testNumberProperty.Get(testNumberCheck));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    TESTCHECK(aTestNumber, testNumberCheck, "Checking correct test number");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    CleanupStack::PopAndDestroy(&testNumberProperty);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
EXPORT_C void CSmsBaseTestStep::ConnectSocketServerL(RSocketServ& aSocketServer)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    INFO_PRINTF1(_L("Connecting to the Socket Server..."));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    TInt  ret = aSocketServer.Connect(KSocketMessageSlots);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    if (ret != KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
        ERR_PRINTF2(_L("Connecting to socket server failed [ret=%d]"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
    INFO_PRINTF1(_L("Clearing private data..."));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
    _LIT(KWapReassemblyStoreName, "C:\\Private\\101F7989\\sms\\wapreast.dat");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
    ret = iFs.Delete(KWapReassemblyStoreName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
    if( ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
        ERR_PRINTF2(_L("Deleted WAP reassembly Store failed [ret=%d]"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    _LIT(KReassemblyStoreName, "C:\\Private\\101F7989\\sms\\smsreast.dat");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    ret = iFs.Delete(KReassemblyStoreName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
    if( ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
        ERR_PRINTF2(_L("Deleted reassembly Store failed [ret=%d]"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    _LIT(KSegmentationStoreName, "C:\\Private\\101F7989\\sms\\smssegst.dat");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
    ret = iFs.Delete(KSegmentationStoreName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    if( ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
        ERR_PRINTF2(_L("Deleted segmentation Store failed [ret=%d]"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
    _LIT(KSmsClass0PreallocatedStoreName, "C:\\Private\\101F7989\\sms\\smsclass0preallocated.dat");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
    ret = iFs.Delete(KSmsClass0PreallocatedStoreName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    if( ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
        ERR_PRINTF2(_L("Deleted SmsClass0Preallocated Store failed [ret=%d]"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    _LIT(KSmsClass0ReassemblyStoreName, "C:\\Private\\101F7989\\sms\\smsclass0reast.dat");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    ret = iFs.Delete(KSmsClass0ReassemblyStoreName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    if( ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
        ERR_PRINTF2(_L("Deleted SmsClass0Reassembly Store failed [ret=%d]"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
    _LIT(KSmsUtilityResourceFileName, "C:\\Private\\101F7989\\sms\\smsu.rsc");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    ret = iFs.Delete(KSmsUtilityResourceFileName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    if( ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
        ERR_PRINTF2(_L("Deleted SMS stack resource file failed [ret=%d]"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
EXPORT_C void CSmsBaseTestStep::ConnectSocketServerLC(RSocketServ& aSocketServer)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
    ConnectSocketServerL(aSocketServer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
    CleanupClosePushL(aSocketServer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
EXPORT_C CSmsMessage* CSmsBaseTestStep::CreateSmsMessageL(const TDesC& aDes, TSmsDataCodingScheme::TSmsAlphabet aAlphabet, CSmsPDU::TSmsPDUType aType)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
 *  Create a uninitialised SMS message
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
 *  @param aDes contains text that will be inserted to the pdu
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
 *  @param aAlphabet describes the alphabet of the pdu
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
 *  @return CSmsMessage* :Pointer to the created CSmsMessage object.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
    CSmsMessage* smsMessage = CreateSmsMessageLC(aDes, aAlphabet, aType);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
    CleanupStack::Pop(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
    return smsMessage;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
EXPORT_C CSmsMessage* CSmsBaseTestStep::CreateSmsMessageLC(const TDesC& aDes, TSmsDataCodingScheme::TSmsAlphabet aAlphabet, CSmsPDU::TSmsPDUType aType)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
 *  Create a uninitialised SMS message
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
 *  @param aDes contains text that will be inserted to the pdu
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
 *  @param aAlphabet describes the alphabet of the pdu
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
 *  @return CSmsMessage* :Pointer to the created CSmsMessage object.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
    CSmsBuffer* buffer=CSmsBuffer::NewL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    CSmsMessage* smsMessage=CSmsMessage::NewL(iFs, aType, buffer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    CleanupStack::PushL(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    TSmsUserDataSettings smsSettings;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
    smsSettings.SetAlphabet(aAlphabet);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    smsSettings.SetTextCompressed(EFalse);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
    smsMessage->SetUserDataSettingsL(smsSettings);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
    smsMessage->SetToFromAddressL(iTelephoneNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    smsMessage->SmsPDU().SetServiceCenterAddressL(iServiceCenterNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
    buffer->InsertL(0,aDes);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    return smsMessage;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
EXPORT_C CSmsMessage* CSmsBaseTestStep::CreateSmsWithStatusReportReqL(const TDesC& aDes, TSmsDataCodingScheme::TSmsAlphabet aAlphabet)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
 *  Create a uninitialised SMS message with Status Report request
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
 *  @param aDes contains text that will be inserted to the pdu
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
 *  @param aAlphabet describes the alphabet of the pdu
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
 *  @return CSmsMessage* :Pointer to the created CSmsMessage object.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
    CSmsMessage* smsMessage=CreateSmsMessageLC(aDes, aAlphabet);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
    //Set Status report request
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    CSmsSubmit& submitPdu=(CSmsSubmit&)smsMessage->SmsPDU();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    submitPdu.SetStatusReportRequest(ETrue);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    CleanupStack::Pop(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
    return smsMessage;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
EXPORT_C CSmsMessage* CSmsBaseTestStep::RecvSmsL(RSocket& aSocket, TInt aIoctl)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
 *  Receive an Sms
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
 *  @param aSocket is used to stream the sms message from the socket server
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
 *  @return CSmsMessage* :Sms message from Sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
 *  @leave Leaves if streaming the message from the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    CSmsBuffer* buffer=CSmsBuffer::NewL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    CSmsMessage* smsMessage=CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit,buffer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    CleanupStack::PushL(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    RSmsSocketReadStream readstream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    TRAPD(ret, readstream >> *smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
 
66
07a122eea281 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 65
diff changeset
   310
    TPckgBuf<TUint> sbuf;
14
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    TRequestStatus status;
66
07a122eea281 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 65
diff changeset
   312
14
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    if(ret==KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        {
66
07a122eea281 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 65
diff changeset
   315
        aSocket.Ioctl(aIoctl, status, &sbuf, KSolSmsProv);
14
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
        User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
        CleanupStack::Pop(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
        TESTCHECK(status.Int(), KErrNone, "Notifying the SMS stack that message was received successfully");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
        INFO_PRINTF1(_L("Message received successfully"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
    //An error has occured, no message has been received
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
        {
66
07a122eea281 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 65
diff changeset
   324
        aSocket.Ioctl(KIoctlReadMessageFailed, status, &sbuf, KSolSmsProv);
14
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
        User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
        TESTCHECK(status.Int(), KErrNone, "Notifying the SMS stack that message was not received");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
        ERR_PRINTF2(_L("Receiving message failed %d"), ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
        User::Leave(ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    return smsMessage;  
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
EXPORT_C CSmsMessage* CSmsBaseTestStep::RecvSmsFailedL(RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
 *  Receive an Sms, first nack the receive several times before succeeding
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
 *  @param aSocket is used to stream the sms message from the socket server
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
 *  @return CSmsMessage* :Sms message from Sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
 *  @leave Leaves if streaming the message from the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
 *  @leave Leaves if nack of receiving is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
 *  @leave Leaves if ack of receiving is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
    CSmsBuffer* buffer=CSmsBuffer::NewL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
    CSmsMessage* smsMessage=CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit,buffer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
    CleanupStack::PushL(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
    RSmsSocketReadStream readstream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
    for(TInt i=0; i<10; i++)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
        TRAPD(ret,readstream >> *smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
        TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
        aSocket.Ioctl(KIoctlReadMessageFailed, status, &sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
        User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
        TEST(status.Int() == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
    TRAPD(ret,readstream >> *smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    aSocket.Ioctl(KIoctlReadMessageSucceeded, status, NULL, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    TEST(status.Int() == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
    CleanupStack::Pop(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    return smsMessage;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
EXPORT_C void CSmsBaseTestStep::SendSmsL(const CSmsMessage* aSms, RSocket& aSocket, TInt aExpectedError/*=KErrNone*/, TInt aMaxRetries/*=3*/)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
 *  Stream aSms out to the socket server
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
 *  @param aSms contains the sms tpdu that will be streamed to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
 *  @param aSocket is used to stream the aSms to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
 *  @param aExpectedError The error expected from the send request
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
 *  @param aMaxRetries The max number of retries is send request does not match expected error
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
 *  @leave Leaves if streaming the message to the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
 *  @leave Leaves if sending is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
    INFO_PRINTF1(_L("Sending SMS... "));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    PrintMessageL(aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    TBool tryAgain = ETrue;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
    TInt sendTry (0);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
    TRequestStatus status = KErrNone;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
    while( tryAgain && sendTry < aMaxRetries )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
        RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
        TRAPD(ret,writestream << *aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
        TRAP(ret, writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
        TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
        aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
        User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
        INFO_PRINTF3(_L("SendSmsL [status=%d, aExpectedError=%d]"), status.Int(), aExpectedError);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
        if ( status.Int() != aExpectedError )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
            tryAgain = ETrue;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
            INFO_PRINTF1(_L("Try again... "));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
            ++sendTry;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
        else tryAgain = EFalse;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
    TESTCHECKL(status.Int(), aExpectedError, "Sending Message with an expected error");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
EXPORT_C void CSmsBaseTestStep::SendSmsCancelL(CSmsMessage* aSms, RSocket& aSocket1, RSocket& aSocket2)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
 *  Stream Sms out to the socket server by two RSmsSocketWriteStream object.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
 *  The first request is canceled and then the second request is completed with error code.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
 *  @param aSms contains the sms tpdu that will be streamed to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
 *  @param aSocket1 The socket used with message that will be canceled
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
 *  @param aSocket2 The socket used with message that will be completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
 *  @leave Leaves if streaming the message to the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
 *  @leave Leaves if sending is completed with KErrNone
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    RSmsSocketWriteStream writestream(aSocket1);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    TRAPD(ret,writestream << *aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    TRAP(ret,writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
    TRequestStatus status1,status2;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    //stream to socket2
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
    RSmsSocketWriteStream writestream2(aSocket2);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    TRAP(ret,writestream2 << *aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    TRAP(ret,writestream2.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
    aSocket1.Ioctl(KIoctlSendSmsMessage,status1,&sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    aSocket2.Ioctl(KIoctlSendSmsMessage,status2,&sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    User::After(2000000);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
    // Test cancel first
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
    aSocket1.CancelIoctl();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
    User::WaitForRequest(status1);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    TEST(status1.Int()==KErrCancel);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    User::After(50000);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
    User::WaitForRequest(status2);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    INFO_PRINTF2(_L("SendSmsL - sendSmsMessage returned %d"),status2.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    PrintMessageL(aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    //Ensure the request is completed with error code ;)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
    TEST(status2.Int() != KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
    INFO_PRINTF2(_L("Sending failed! %d"), status2.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
EXPORT_C TInt CSmsBaseTestStep::SendSmsErrorL(CSmsMessage* aSms, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
 *  Stream aSms out to the socket server. Sending is completed with error code.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
 *  @param aSms contains the sms tpdu that will be streamed to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
 *  @param aSocket is used to stream the aSms to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
 *  @return error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
 *  @leave Leaves if streaming the message to the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
 *  @leave Leaves if sending is completed with KErrNone
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
    TRAPD(ret,writestream << *aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
    TRAP(ret,writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
    User::After(50000);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
    // test cancel first
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
    aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
    aSocket.CancelIoctl();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
    TEST(status.Int()==KErrCancel);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
    //Now send again, completed with error
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    TRAP(ret,writestream << *aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    TRAP(ret,writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
    aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
    INFO_PRINTF2(_L("SendSmsL - sendSmsMessage returned %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
    PrintMessageL(aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    INFO_PRINTF2(_L("Sending failed! %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    TEST(status.Int() != KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
    return status.Int();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
EXPORT_C void CSmsBaseTestStep::SendCommandSmsL(CSmsMessage* aSms, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
 *  Stream command message out to the socket server and wait for the return status
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
 *  @param aSms contains the sms tpdu that will be streamed to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
 *  @param aSocket is used to stream the aSms to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
 *  @leave Leaves if streaming the message to the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
 *  @leave Leaves if sending is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    TRAPD(ret,writestream << *aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
    TRAP(ret,writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf,KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
    INFO_PRINTF2(_L("SendCommandSmsL, sendSms returned %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    User::After(1000000);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    TEST(status.Int() == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
EXPORT_C void CSmsBaseTestStep::SendAndRecvTestMessageL(const TTestCase& aTestCase, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
 *  Send a test message. This method is used to send and receive different DCS type messages
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
 *  @param aTestCase has information about the used test message, e.g. message data and DCS
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
 *  @leave Leaves if any of the leaving functions used at this function leaves
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
    SendTestMessageL(aTestCase, aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
    WaitForRecvL(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
    CSmsMessage* smsMessage = RecvSmsL(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
    CleanupStack::PushL(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
    TestMessageContentsL(smsMessage,aTestCase);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
    CleanupStack::PopAndDestroy(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
EXPORT_C void CSmsBaseTestStep::SendTestMessageL(const TTestCase& aTestCase, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
 *  Send a test message
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
 *  Assumes recv is already done.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
 *  @param aTestCase has information about the used test message, e.g. message data and DCS
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
 *  @leave Leaves if any of the leaving functions used at this function leaves
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
    CSmsMessage* smsMessage = CreateSmsMessageLC(aTestCase.iMsg, TSmsDataCodingScheme::ESmsAlphabet7Bit);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    CSmsPDU& pdu = smsMessage->SmsPDU();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
    CSmsUserData& userData = pdu.UserData();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
    if (aTestCase.iMatchType == ESmsAddrMatchIEI)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
        userData.AddInformationElementL(aTestCase.iIdentifierMatch,_L8("98"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
    if (aTestCase.iTestSmsClass)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
        pdu.SetBits7To4(TSmsDataCodingScheme::ESmsDCSTextUncompressedWithClassInfo);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
        pdu.SetClass(ETrue,aTestCase.iSmsClass);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
    if (aTestCase.iTestValidityPeriod && pdu.Type()==CSmsPDU::ESmsSubmit)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
        CSmsSubmit* submitPdu = REINTERPRET_CAST(CSmsSubmit*,&pdu);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
        submitPdu->SetValidityPeriod(aTestCase.iValidityPeriod);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
    if (aTestCase.iTestIndicators && pdu.Type()==CSmsPDU::ESmsSubmit)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
        SetIndicatorL(aTestCase, smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
    SendSmsL(smsMessage, aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    CleanupStack::PopAndDestroy(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
EXPORT_C void CSmsBaseTestStep::SendSmsDontCheckReturnValueL(CSmsMessage* aSms, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
 *  Stream aSms out to the socket server and don't check return value.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
 *  @param aSms contains the sms tpdu that will be streamed to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
 *  @param aSocket is used to stream the aSms to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
 *  @leave Leaves if streaming the message to the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
 *  @leave Leaves if sending is completed with KErrNone
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
    writestream << *aSms;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
    writestream.CommitL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
    aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
    INFO_PRINTF2(_L("Send SMS message returned %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
    if(status.Int() != KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
        User::Leave(status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
EXPORT_C void CSmsBaseTestStep::SendAndRecvSms7BitL(const TDesC& aDes, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
 *  Send and receive one 7bit sms
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
 *  @param aDes contains the text to be send
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
 *  @leave Leaves if DoSendAndRecvSmsL leaves
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
    DoSendAndRecvSmsL(aDes,TSmsDataCodingScheme::ESmsAlphabet7Bit, aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
EXPORT_C void CSmsBaseTestStep::DoSendAndRecvSmsL(const TDesC& aDes, TSmsDataCodingScheme::TSmsAlphabet aAlphabet, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
 *  Send and recv one sms,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
 *  then check that the sent message corresponds with the received message
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
 *  @param aDes contains the text that will be inserted to the pdu at CreateSmsMessageL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
 *  @param aAlphabet describes the alphabet of the pdu that will be created at CreateSmsMessageL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
 *  @leave Leaves if any of the leaving functions used at this function leaves
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
    CSmsMessage* smsMessage=CreateSmsMessageLC(aDes, aAlphabet);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
    SendSmsL(smsMessage, aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
    CleanupStack::PopAndDestroy(smsMessage); //destroyed because created again in RecvSmsL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
    WaitForRecvL( aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
    smsMessage = RecvSmsL( aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
    CleanupStack::PushL(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
    TestSmsContentsL(smsMessage,aDes);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
    // TODO: is this a way to go?
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
    User::After(1000000);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
    CleanupStack::PopAndDestroy(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
EXPORT_C void CSmsBaseTestStep::PrintMessageDetailedL(const CSmsMessage* aSms)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
    TPtrC from = aSms->ToFromAddress();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
    INFO_PRINTF2(_L("ToFromAddress: %S"), &from);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
    TPtrC sc = aSms->ServiceCenterAddress();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
    INFO_PRINTF2(_L("ServiceCenterAddress: %S"), &sc);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
    if(aSms->Storage() == CSmsMessage::ESmsSIMStorage)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
        INFO_PRINTF1(_L("Store: SIM"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
    else if (aSms->Storage() == CSmsMessage::ESmsPhoneStorage)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
        INFO_PRINTF1(_L("Store: Phone"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
    else if (aSms->Storage() == CSmsMessage::ESmsCombinedStorage)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
        INFO_PRINTF1(_L("Store: Combined"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
        INFO_PRINTF1(_L("Store: Unknown"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
    switch (aSms->Status())
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
        case RMobileSmsStore::EStoredMessageUnread:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
            INFO_PRINTF1(_L("Status: Unread"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
            break;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
        case RMobileSmsStore::EStoredMessageRead:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
            INFO_PRINTF1(_L("Status: Read"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
            break;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
        case RMobileSmsStore::EStoredMessageUnsent:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
            INFO_PRINTF1(_L("Status: Unsent"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
            break;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
        case RMobileSmsStore::EStoredMessageSent:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
            INFO_PRINTF1(_L("Status: Sent"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
            break;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
        case RMobileSmsStore::EStoredMessageDelivered:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
            INFO_PRINTF1(_L("Status: Delivered"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
            break;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
        case RMobileSmsStore::EStoredMessageUnknownStatus:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
        default:
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
            INFO_PRINTF1(_L("Status: Unknown"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
            break;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
    PrintMessageL(aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
EXPORT_C void CSmsBaseTestStep::PrintMessageL(const CSmsMessage* aSms)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
 *  Print the content of SMS to the console
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
    if (aSms == NULL)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
        return;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
    CSmsBuffer& smsbuffer = (CSmsBuffer&)aSms->Buffer();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
    const TInt len = smsbuffer.Length();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
    HBufC* hbuf = HBufC::NewL(len);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
    TPtr ptr = hbuf->Des();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
    smsbuffer.Extract(ptr, 0, len);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
    for (TInt j = 0; j < len; ++j)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
        if (ptr[j] < 0x20  ||  ptr[j] > 0xFF)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
            // Non-displayable character, print "." instead
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
            ptr[j] = 0x007F;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
    INFO_PRINTF2(_L("SMS contains: %S"), &ptr);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
    delete hbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
EXPORT_C TSmsStatus::TSmsStatusValue CSmsBaseTestStep::RecvStatusReportL(TSmsServiceCenterAddress& aRecipientNumber, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
 * Receive a Status report
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
 * @param aRecipientNumber The supposed recipient number
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
 * @param aSocket is used to stream the sms message from the socket server
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
    //Receive SMS
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
    INFO_PRINTF1(_L("waiting for incoming status report...") );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
    WaitForRecvL(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
    CSmsMessage* smsMessage = RecvSmsL(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
    //Check the status report
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
    CleanupStack::PushL(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
    TBool isSR = (smsMessage->Type()==CSmsPDU::ESmsStatusReport);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
    if (isSR)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
        INFO_PRINTF1(_L("Received status report"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
        TSmsServiceCenterAddress telephoneNumber=smsMessage->ToFromAddress();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
        TEST(telephoneNumber==aRecipientNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
        INFO_PRINTF2(_L("Message delivered to %S"), &telephoneNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
        INFO_PRINTF1(_L("Received SMS is NOT a Status report!"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
    TEST(isSR);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
    //Get the status report
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
    CSmsStatusReport& statusReport = STATIC_CAST(CSmsStatusReport&, smsMessage->SmsPDU()); 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
    TSmsStatus::TSmsStatusValue status = statusReport.Status();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
    CleanupStack::PopAndDestroy(smsMessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
    return status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
EXPORT_C void CSmsBaseTestStep::WaitForRecvL(RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
 *  Wait for an Sms to be received
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
 *  @param aSocket The status is return to this socket
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
 *  @leave Leaves if receiving is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
    INFO_PRINTF1(_L("Waiting for incoming SMS...") );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
    sbuf()=KSockSelectRead;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
    aSocket.Ioctl(KIOctlSelect,status,&sbuf,KSOLSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
    TESTCHECK(status.Int(), KErrNone, "Waiting for incoming SMS");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
EXPORT_C void CSmsBaseTestStep::TestSmsContentsL(CSmsMessage* aSms, const TDesC& aDes, TBool aIgnorePrintOutput)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
 *  Check that aSms contains text that matches to aDes
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
 *  @param aSms SMS message that has been come from SMS stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
 *  @param aDes SMS message's text that is defined at client side
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
 *  @leave Leaves if aSms doesn't match to aDes
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
    CSmsBufferBase& smsBuffer=aSms->Buffer();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
    TInt bufLen=smsBuffer.Length();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
    INFO_PRINTF2(_L("Length of buffer is : %d"),bufLen);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
    HBufC* textBuf=HBufC::NewL(bufLen);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
    CleanupStack::PushL(textBuf);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
    TPtr textPtr(textBuf->Des());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
    smsBuffer.Extract(textPtr,0,bufLen);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
    INFO_PRINTF1(_L("Comparing messages..."));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
    TInt  compareResult = textPtr.Compare(aDes);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
    if (!aIgnorePrintOutput)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
        TInt  bufLen2 = aDes.Length();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   803
        HBufC*  textBuf2 = HBufC::NewL(aDes.Length());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
        CleanupStack::PushL(textBuf2);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
        TPtr textPtr2(textBuf2->Des());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
        TInt  index;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   807
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   808
        for (index = 0;  index < bufLen;  index++)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
            if (textPtr[index] < 0x20  ||  textPtr[index] > 0xff)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
                textPtr[index] = 0x007f;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
        INFO_PRINTF2(_L("%S"), &textPtr);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
        INFO_PRINTF1(_L("with expected"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
        textPtr2.Copy(aDes);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
        for (index = 0;  index < bufLen2;  index++)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
            if (textPtr2[index] < 0x20  ||  textPtr2[index] > 0xff)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
                textPtr2[index] = 0x007f;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
        INFO_PRINTF2(_L("%S"), &textPtr2);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
        CleanupStack::PopAndDestroy(textBuf2);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   832
    if (compareResult != 0)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   834
        SetTestStepResult(EFail);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
        ERR_PRINTF1(_L("Message content does not match the provided string")); 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
        INFO_PRINTF1(_L("Message content matches the provided string"));  
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
    CleanupStack::PopAndDestroy(textBuf);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
EXPORT_C void CSmsBaseTestStep::TestMessageContentsL(CSmsMessage* aSms, const TTestCase& aTestCase)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
 *  Check the sms matches the expected test result
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
 *  @param aSms has the message to be tested with aTestCase.iMsg
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
 *  @param aTestCase has information about the used test message, e.g. message data and DCS
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
 *  @leave Leaves if TSmsClass isn't defined at the pdu
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
 *  @leave Leaves if class of pdu doesn't match to supposed class (aTestCase.iSmsClass)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
    TestSmsContentsL(aSms,aTestCase.iMsg);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
    CSmsPDU& pdu = aSms->SmsPDU();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
    if (aTestCase.iTestSmsClass)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
        TSmsDataCodingScheme::TSmsClass smsClass;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
        TBool isDefined = pdu.Class(smsClass);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
        TEST(isDefined);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
        TEST(smsClass == aTestCase.iSmsClass);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
    if (aTestCase.iTestIndicators)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
        TEST(pdu.Bits7To4() == aTestCase.iBits7To4);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
        TEST(pdu.IndicationType() == aTestCase.iIndicationType);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
        TEST(pdu.IndicationState() == aTestCase.iIndicationState);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
EXPORT_C void CSmsBaseTestStep::WriteSmsToSimL(CSmsMessage& aSms, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   874
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
 *  This method stores SMS messages to the SMS storage.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
 *  @param aSms SMS message that will be stored
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
 *  @param aSocket Used to stream SMS message to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
 *  @leave Leaves if streaming the message to the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
 *  @leave Leaves if store request is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
    INFO_PRINTF1(_L("Write message to SIM"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
    TRAPD(ret,writestream << aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
    TESTCHECK(ret, KErrNone, "Write SMS to stream");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
    TRAP(ret,writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
    TESTCHECK(ret, KErrNone, "Commit the stream writing");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   890
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
    aSocket.Ioctl(KIoctlWriteSmsMessage,status,NULL,KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
    TESTCHECK(status.Int(), KErrNone, "Write message to SIM");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
EXPORT_C void CSmsBaseTestStep::WriteSmsLeaveIfErrorL(const CSmsMessage& aSms, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   898
 *  This method stores SMS messages to the SMS storage.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
 *  @param aSms SMS message that will be stored
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
 *  @param aSocket Used to stream SMS message to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
    writestream << aSms;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
    writestream.CommitL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
    aSocket.Ioctl(KIoctlWriteSmsMessage,status,NULL, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
    INFO_PRINTF2(_L("Write SMS message returned %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
    if(status.Int() != KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
        User::Leave(status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
EXPORT_C void CSmsBaseTestStep::ReadSmsStoreL(RSocket& aSocket, RPointerArray<CSmsMessage>& aMessages)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
 *  This method retrieves SMS messages from SMS storage and print them out.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
 *  @param aSocket Used to stream SMS messages from the socket server
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
 *  @param aMessages Sms messages will be streamed to this array
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
 *  @leave Leaves if first request is NOT completed with KErrCancel
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
 *  @leave Leaves if second request is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
 *  @leave Leaves if streaming the message from the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   926
 *  @leave Leaves if nack of reading is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
 *  @leave Leaves if ack of reading is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   928
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
    ReadSmsStoreL(aSocket, aMessages, status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   932
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
EXPORT_C void CSmsBaseTestStep::ReadSmsStoreL(RSocket& aSocket, RPointerArray<CSmsMessage>& aMessages, TRequestStatus& aStatus)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   936
 *  This method retrieves SMS messages from SMS storage and print them out.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
 *  @param aSocket Used to stream SMS messages from the socket server
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   938
 *  @param aMessages Sms messages will be streamed to this array
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   939
 *  @param aStatus Status of request to enumerate messages from store
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   940
 *  @leave Leaves if first request is NOT completed with KErrCancel
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   941
 *  @leave Leaves if second request is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   942
 *  @leave Leaves if streaming the message from the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
 *  @leave Leaves if nack of reading is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   944
 *  @leave Leaves if ack of reading is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   945
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   946
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
    INFO_PRINTF1(_L("Enumerating messages"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   948
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   949
    sbuf()=0;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
    // Enumerate messages from store - NOTE - sometimes SIM.TSY returns
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
    // KErrInUse (strange timing things!). In this case wait and repeat.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
    const TInt KMaxAttempts = 3;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   954
    TInt attempts = 0;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   955
    do
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
        User::After(2000000);   // Wait a couple of seconds...
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
        aSocket.Ioctl(KIoctlEnumerateSmsMessages, aStatus, &sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
        User::WaitForRequest(aStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
        INFO_PRINTF3(_L("Enumerating completed [status=%d, attempts=%d]"), aStatus.Int(), ++attempts);        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
        } while( aStatus.Int() == KErrInUse && attempts < KMaxAttempts );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   965
    if( aStatus.Int() == KErrNone )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   966
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   967
        // sbuf() includes the count of messages on Store
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
        TInt count = sbuf();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   969
        INFO_PRINTF2(_L("%d enumerated messages"), count);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   970
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   971
        RSmsSocketReadStream readstream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   972
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   973
        //Read each message from the stream
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   974
        for(TInt i=0; i< count; ++i)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   975
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   976
            CSmsBuffer* buffer=CSmsBuffer::NewL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   977
            CSmsMessage* smsmessage=CSmsMessage::NewL(iFs, CSmsPDU::ESmsDeliver,buffer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   978
            CleanupStack::PushL(smsmessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   979
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
            TRAPD(ret,readstream >> *smsmessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   981
            TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   982
            aSocket.Ioctl(KIoctlReadMessageSucceeded, aStatus, NULL, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   983
            User::WaitForRequest(aStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   984
            TEST(aStatus.Int() == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   985
            
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
            PrintMessageDetailedL(smsmessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
            
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
            User::LeaveIfError(aMessages.Append(smsmessage));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
            CleanupStack::Pop(smsmessage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   990
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   991
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   992
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   993
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   994
        ERR_PRINTF2(_L("Enumerating failed [status=%d]"), aStatus.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   995
        SetTestStepResult(EFail);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   996
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   997
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   998
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
EXPORT_C TInt CSmsBaseTestStep::DeleteSmsL(const CSmsMessage& aSms, RSocket& aSocket, TInt aExpectedError /*KErrNone*/)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1000
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1001
 *  This method deletes SMS message from the SMS storage.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1002
 *  @param aSms SMS message that will be deleted
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1003
 *  @param aSocket Used to stream SMS message to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1004
 *  @return TInt :error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1005
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1006
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1007
    INFO_PRINTF2(_L("Delete message from store [aExpectedError=%d]"), aExpectedError);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1008
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1009
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1010
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1011
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1012
    TRAPD(ret,writestream << aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1013
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1014
    TRAP(ret,writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1015
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1016
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1017
    aSocket.Ioctl(KIoctlDeleteSmsMessage, status, NULL, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1018
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1019
    TInt error = status.Int();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1020
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1021
    INFO_PRINTF2(_L("Delete SMS message - returned %d"), error);    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1022
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1023
    if( error != aExpectedError )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1024
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
        ERR_PRINTF3(_L("Delete SMS message failed [aExpectedError=%d, error=%d]"), aExpectedError, error);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
        SetTestStepResult(EFail);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1028
    return error;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1030
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1031
EXPORT_C void CSmsBaseTestStep::DeleteSmsLeaveIfErrorL(const CSmsMessage& aSms, RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1033
 *  This method deletes SMS message from the SMS storage.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1034
 *  @param aSms SMS message that will be deleted
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1035
 *  @param aSocket Used to stream SMS message to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1036
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1037
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1038
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1039
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1040
    writestream << aSms;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1041
    writestream.CommitL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1042
    aSocket.Ioctl(KIoctlDeleteSmsMessage, status, NULL, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1043
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1044
    INFO_PRINTF2(_L("Delete SMS returned %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1045
    if(status.Int() != KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1046
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1047
        User::Leave(status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1048
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1049
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1050
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1051
EXPORT_C void CSmsBaseTestStep::SetIndicatorL(const TTestCase& aTestCase, CSmsMessage* aSms)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1052
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1053
 *  
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1054
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1055
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1056
    TSmsDataCodingScheme::TSmsAlphabet alphabet;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1057
    if (aTestCase.iBits7To4 == TSmsDataCodingScheme::ESmsDCSMessageWaitingIndicationUCS2)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1058
        alphabet = TSmsDataCodingScheme::ESmsAlphabetUCS2;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1059
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1060
        alphabet = TSmsDataCodingScheme::ESmsAlphabet7Bit;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1061
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1062
    TSmsUserDataSettings smsSettings;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1063
    smsSettings.SetAlphabet(alphabet);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1064
    smsSettings.SetTextCompressed(EFalse);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1065
    aSms->SetUserDataSettingsL(smsSettings);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1066
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1067
    CSmsPDU& pdu = aSms->SmsPDU();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1068
    pdu.SetBits7To4(aTestCase.iBits7To4);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1069
    pdu.SetIndicationType(aTestCase.iIndicationType);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1070
    pdu.SetIndicationState(aTestCase.iIndicationState);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1071
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1072
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1073
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1074
EXPORT_C void CSmsBaseTestStep::FillDes(TDes& aDes,TInt aLength)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1075
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1076
 *  Fill aDes with randomly generated 7bit data
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1077
 *  @param aDes will be filled with random data
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1078
 *  @param aLength has the length to be set to aDes
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1079
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1081
    TText baseChar='A';
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1082
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1083
    aDes.SetLength(aLength);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
    for (TInt i=0; i<aLength; i++)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1086
        aDes[i]=TText(baseChar + i%26);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1088
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1090
EXPORT_C TInt CSmsBaseTestStep::MakeReadSmsStoreRequestL(RSocket& aSocket)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1091
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1092
 *  This method retrieves SMS messages from SMS storage.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1093
 *  Main purpose is to test out of memory conditions.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1094
 *  @param aSocket Used to stream SMS messages from the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1095
 *  @param aMessages reference to CSmsMessage pointer array.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1096
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1097
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1098
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1099
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1100
    sbuf()=0;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1101
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1102
    //Now enumerate messages from SIM
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1103
    aSocket.Ioctl(KIoctlEnumerateSmsMessages,status,&sbuf, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1104
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1105
    INFO_PRINTF2(_L("Read SMS returned %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1106
    if(status.Int() != KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1107
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1108
        User::Leave(status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1109
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1110
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1111
    //sbuf() includes the count of messages on SIM
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1112
    return sbuf();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1113
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1114
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1115
EXPORT_C TBool CSmsBaseTestStep::TimedWaitForRecvL(RSocket& aSocket, TUint aDelay)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1116
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1117
 *  Wait for up to the delay for an Sms to be received
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1118
 *  @param aSocket The status is return to this socket
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1119
 *  @param aDelay Maximum time to wait for receipt
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1120
 *  @return ETrue if data received
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1121
 *  @leave Leaves if receiving is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1122
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1123
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1124
    TRequestStatus timerStatus;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
    RTimer timer;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1126
    timer.CreateLocal();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
    timer.After(timerStatus, TTimeIntervalMicroSeconds32(aDelay));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
    TPckgBuf<TUint> sbuf;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1130
    sbuf()=KSockSelectRead;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1131
    TRequestStatus ioctlStatus;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1132
    aSocket.Ioctl(KIOctlSelect, ioctlStatus, &sbuf, KSOLSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1133
    User::WaitForRequest(timerStatus, ioctlStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1134
    TBool retval;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1135
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1136
    if(ioctlStatus.Int() != KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1137
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1138
        aSocket.CancelIoctl();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1139
        User::WaitForRequest(ioctlStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1140
        retval = EFalse;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1141
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1142
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1143
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1144
        timer.Cancel();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1145
        User::WaitForRequest(timerStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1146
        retval = ETrue;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
    timer.Close();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
    return retval;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
EXPORT_C TInt CSmsBaseTestStep::CancelWriteSmsToSimL(CSmsMessage& aSms, RSocket& aSocket, TInt aDelay)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1154
 *  This method stores SMS messages to the SMS storage.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1155
 *  @param aSms SMS message that will be stored
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
 *  @param aSocket Used to stream SMS message to the sms stack
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1157
 *  @leave Leaves if streaming the message to the socket server doesn't succeed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1158
 *  @leave Leaves if store request is completed with error code
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1159
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1160
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1161
    INFO_PRINTF1(_L("Write message"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1162
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1163
    TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1165
    RSmsSocketWriteStream writestream(aSocket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
    TRAPD(ret,writestream << aSms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
    TRAP(ret,writestream.CommitL());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1169
    TEST(ret == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1170
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1171
    aSocket.Ioctl(KIoctlWriteSmsMessage,status,NULL, KSolSmsProv);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1172
    INFO_PRINTF1(_L("Cancel"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1173
    User::After(aDelay);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1174
    aSocket.CancelIoctl();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
    User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1176
    INFO_PRINTF2(_L("WriteSmsToSimL - returned %d"), status.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1177
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
    return status.Int();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1181
EXPORT_C TBool CSmsBaseTestStep::DoSingleTestCaseL( const TDesC8& aSection, TInt aCount )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1182
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1183
    CTestConfig* configFile = CTestConfig::NewLC(iFs, KGmsSmsConfigFileDir, KConfigFilename);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1184
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1185
    TBuf8<64> sectionName(aSection);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1186
    sectionName.AppendNum(aCount);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1187
    const CTestConfigSection* section = NULL;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1188
    TBool found( ETrue );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1189
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1190
    if ( ( section = configFile->Section( sectionName ) ) != NULL )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1191
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1192
        if ( aSection == KTestSendAndRecvMsgsWithDifferentTON )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1193
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1194
            TInt num( 1 );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1195
            CArrayFixFlat<TInt>* alphabetArray = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1196
            CleanupStack::PushL(alphabetArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1197
            CArrayFixFlat<TInt>* typeOfNumberArray = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1198
            CleanupStack::PushL(typeOfNumberArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1199
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1200
            TBuf8<32> itemName( KAlphabet );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1201
            itemName.AppendNum( num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1202
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1203
            TInt param  = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1204
            while ( param != KErrNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1205
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1206
                alphabetArray->AppendL(param);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1207
                itemName = KAlphabet;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1208
                itemName.AppendNum( ++num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1209
                param = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1210
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1211
            num = 1;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1212
            itemName = KTypeOfNumber;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1213
            itemName.AppendNum( num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1214
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1215
            param  = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1216
            while ( param != KErrNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1217
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1218
                typeOfNumberArray->AppendL(param);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1219
                itemName = KTypeOfNumber;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1220
                itemName.AppendNum( ++num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1221
                param = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1222
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1223
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1224
            RPointerArray<CSmsPduDbMessage> array;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1225
            CleanupResetAndDestroyPushL(array);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1226
            ReadPduL( sectionName, array );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1227
            TestSendAndRecvMsgsWithDifferentTONL( array, alphabetArray, typeOfNumberArray );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
            CleanupStack::PopAndDestroy(&array);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1229
            CleanupStack::PopAndDestroy(typeOfNumberArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1230
            CleanupStack::PopAndDestroy(alphabetArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1231
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1232
        else if ( aSection == KTestSendAndReceiveIndicatorMsgs )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1233
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1234
            TInt num( 1 );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1235
            CArrayFixFlat<TInt>* indicationTypeArray = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1236
            CleanupStack::PushL(indicationTypeArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1237
            CArrayFixFlat<TInt>* dcsBits7To4Array = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1238
            CleanupStack::PushL(dcsBits7To4Array);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1239
            CArrayFixFlat<TInt>* indicationStateArray = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1240
            CleanupStack::PushL(indicationStateArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1241
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1242
            TBuf8<32> itemName( KIndicationType );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1243
            itemName.AppendNum( num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1244
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1245
            TInt param  = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1246
            while ( param != KErrNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1247
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1248
                indicationTypeArray->AppendL(param);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1249
                itemName = KIndicationType;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1250
                itemName.AppendNum( ++num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1251
                param = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1252
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1253
            num = 1;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1254
            itemName = KDCSBits7To4;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1255
            itemName.AppendNum( num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1256
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1257
            param  = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1258
            while ( param != KErrNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1259
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1260
                dcsBits7To4Array->AppendL(param);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1261
                itemName = KDCSBits7To4;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1262
                itemName.AppendNum( ++num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1263
                param = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1264
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1265
            num = 1;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1266
            itemName = KIndicationState;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1267
            itemName.AppendNum( num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1268
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1269
            param  = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1270
            while ( param != KErrNotFound )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1271
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
                indicationStateArray->AppendL(param);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1273
                itemName = KIndicationState;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
                itemName.AppendNum( ++num );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1275
                param = section->ItemValue( (TPtrC8)itemName, KErrNotFound );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1276
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1277
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1278
            RPointerArray<CSmsPduDbMessage> array;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1279
            CleanupResetAndDestroyPushL(array);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1280
            ReadPduL( sectionName, array );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1281
            TestSendAndReceiveIndicatorMsgsL( array, indicationStateArray, dcsBits7To4Array, indicationTypeArray );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1282
            CleanupStack::PopAndDestroy(&array);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1283
            CleanupStack::PopAndDestroy(indicationStateArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1284
            CleanupStack::PopAndDestroy(dcsBits7To4Array);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1285
            CleanupStack::PopAndDestroy(indicationTypeArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1286
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1287
        else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1288
            found = EFalse;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1289
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1290
    else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1291
        found = EFalse;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1292
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1293
    CleanupStack::PopAndDestroy(configFile);//configFile
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1294
    return found;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1295
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1296
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1297
EXPORT_C void CSmsBaseTestStep::TestSendAndRecvMsgsWithDifferentTONL( const RPointerArray<CSmsPduDbMessage>& aArray,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1298
                                                   const CArrayFixFlat<TInt>* aAlphabetArray,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1299
                                                   const CArrayFixFlat<TInt>* aTypeOfNumberArray )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1300
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1301
    INFO_PRINTF1(_L("Send and receive messages with different type of number"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1302
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1303
    const TInt testNumber = 39;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1304
    SetSimTSYTestNumberL(testNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1305
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1306
    RSocketServ socketServer;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1307
    ConnectSocketServerLC(socketServer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1308
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1309
    RSocket socket;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1310
    iSmsStackTestUtils->OpenSmsSocketLC(socketServer,socket,ESmsAddrRecvAny);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1311
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1312
    TSmsDataCodingScheme::TSmsAlphabet alphabet = ( TSmsDataCodingScheme::TSmsAlphabet )aAlphabetArray->At(0);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1313
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1314
    TInt bufLen=aArray[0]->iSmsMessage->Buffer().Length();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1315
    HBufC* textBuf=HBufC::NewL(bufLen);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1316
    CleanupStack::PushL(textBuf);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1317
    TPtr testText(textBuf->Des());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1318
    aArray[0]->iSmsMessage->Buffer().Extract(testText,0,bufLen);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1319
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1320
    CSmsMessage* sendMessage=CreateSmsMessageLC(testText,alphabet);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1321
    CSmsSubmit& submitPdu=(CSmsSubmit&)sendMessage->SmsPDU();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1322
    TGsmSmsTelNumber gsmSmsTelNumber;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1323
    gsmSmsTelNumber.iTelNumber.Append(iTelephoneNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1324
    if(gsmSmsTelNumber.iTelNumber.Length() > 0 && gsmSmsTelNumber.iTelNumber[0] == '+')
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1325
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1326
        // Remove "+" sign from telephony number
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1327
        gsmSmsTelNumber.iTelNumber.Delete(0,1);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1328
        gsmSmsTelNumber.iTelNumber.Trim();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1329
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1330
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1331
    for ( TInt i = 0; i < aTypeOfNumberArray->Count(); i++ )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1332
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1333
        gsmSmsTelNumber.iTypeOfAddress.SetTON( ( TGsmSmsTypeOfNumber )aTypeOfNumberArray->At(i) );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1334
        sendMessage->SetParsedToFromAddressL(gsmSmsTelNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1335
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1336
        if ( ( TGsmSmsTypeOfNumber )aTypeOfNumberArray->At(i) == EGsmSmsTONSubscriberNumber )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1337
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1338
            submitPdu.SetPIDType(TSmsProtocolIdentifier::ESmsPIDShortMessageType);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1339
            submitPdu.SetShortMessageType(TSmsProtocolIdentifier::ESmsReturnCallMesage);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1340
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1341
        INFO_PRINTF2(_L("Send SMS message. Type of number is %d"), aTypeOfNumberArray->At(i) );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1342
        SendSmsL(sendMessage,socket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1343
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1344
        INFO_PRINTF1(_L("Waiting for incoming SMS...") );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1345
        WaitForRecvL(socket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1346
        CSmsMessage* recvMessage = RecvSmsL(socket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1347
        delete recvMessage;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1348
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1349
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1350
    CleanupStack::PopAndDestroy(4, &socketServer); // socketServer, socket, textBuf, sendMessage
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1351
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1352
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1353
EXPORT_C void CSmsBaseTestStep::TestSendAndReceiveIndicatorMsgsL( const RPointerArray<CSmsPduDbMessage>& aArray,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1354
                                               const CArrayFixFlat<TInt>* aIndicationStateArray,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1355
                                               const CArrayFixFlat<TInt>* aDcsBits7To4Array,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1356
                                               const CArrayFixFlat<TInt>* aIndicationTypeArray )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1357
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1358
 *  @test Send and receive different indicator messages
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1359
 *  TODO ESmsDCSMessageWaitingIndicationDiscardMessage test doesn't work with Nokia 6210 because phone
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1360
 *  doesn't route incoming message to the MM TSY.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1361
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1362
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1363
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1364
    INFO_PRINTF1(_L("Send and receive different indicator messages"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1365
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1366
    const TInt testNumber = 40;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1367
    SetSimTSYTestNumberL(testNumber);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1368
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1369
    RSocketServ socketServer;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1370
    ConnectSocketServerLC(socketServer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1371
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1372
    RSocket socket;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1373
    iSmsStackTestUtils->OpenSmsSocketLC(socketServer,socket,ESmsAddrRecvAny);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1374
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1375
    for ( TInt i = 0; i < aArray.Count(); i++ )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1376
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1377
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1378
        TSmsDataCodingScheme::TSmsIndicationState indicationState =
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1379
            ( TSmsDataCodingScheme::TSmsIndicationState )aIndicationStateArray->At(i);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1380
        TSmsDataCodingScheme::TSmsDCSBits7To4 dcsBits7To4Array =
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1381
            ( TSmsDataCodingScheme::TSmsDCSBits7To4 )aDcsBits7To4Array->At(i);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1382
        TSmsDataCodingScheme::TSmsIndicationType indicationType =
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1383
            ( TSmsDataCodingScheme::TSmsIndicationType )aIndicationTypeArray->At(i);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1384
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1385
        TInt bufLen=aArray[i]->iSmsMessage->Buffer().Length();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1386
        HBufC* textBuf=HBufC::NewL(bufLen);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1387
        CleanupStack::PushL(textBuf);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1388
        TPtr testText(textBuf->Des());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1389
        aArray[i]->iSmsMessage->Buffer().Extract(testText,0,bufLen);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1390
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1391
        TTestCase msg(testText, indicationType, dcsBits7To4Array, indicationState );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1392
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1393
        SendAndRecvTestMessageL(msg,socket);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1394
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1395
        CleanupStack::PopAndDestroy(textBuf);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1396
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1397
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1398
    CleanupStack::PopAndDestroy(2, &socketServer); // socketServer, socket
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1399
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1400
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1401
EXPORT_C void CSmsBaseTestStep::ReadPduL( TBuf8<64> aSectionName, RPointerArray<CSmsPduDbMessage>& aArray )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1402
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1403
    CSmsPduDatabase* db = CSmsPduDatabase::NewL(iFs, aSectionName, KConfigFilename, KConfigFileDir);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1404
    CleanupStack::PushL(db);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1405
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1406
    db->GetMessageL(aArray, CSmsPDU::ESmsSubmit);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1407
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1408
    CleanupStack::PopAndDestroy(db);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1409
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1410
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1411
EXPORT_C CSmsMessage* CSmsBaseTestStep::CreateSmsMessageLC(CSmsPDU::TSmsPDUType aType, CSmsBuffer* aBuffer, const TDesC& aAddress)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1412
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1413
    CSmsMessage* msg = CSmsMessage::NewL(iFs, aType, aBuffer);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1414
    CleanupStack::PushL(msg);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1415
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1416
    if (aAddress.Length() != 0)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1417
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1418
        msg->SetToFromAddressL(aAddress);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1419
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1420
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1421
    return msg;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1422
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1423
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1424
/*
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1425
These functions were grabbed from SMSStackTestUtils.dll
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1426
*/
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1427
EXPORT_C void CSmsBaseTestStep::OpenSmsSocketL(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddrFamily aFamily)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1428
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1429
 *  Initialise an RSocket for SMS, aSocket is NOT pushed to CleanupStack.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1430
 *  @param aSocketServer reference to the socket server object
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1431
 *  @param aSocket The socket that will be opened
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1432
 *  @param aFamily The sms address family
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1433
 *  @param aDualSimAware Flag indicating that client is dual-SIM aware
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1434
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1435
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1436
    TSmsAddr smsaddr;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1437
    smsaddr.SetSmsAddrFamily(aFamily);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1438
    OpenSmsSocketL(aSocketServer, aSocket, smsaddr);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1439
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1440
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1441
EXPORT_C void CSmsBaseTestStep::OpenSmsSocketL(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddr& aSmsAddr)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1442
/*
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1443
 *  Initialise an RSocket for SMS, aSocket is NOT pushed to CleanupStack.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1444
 *  @param aSocketServer reference to the socket server object
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1445
 *  @param aSocket The socket that will be opened
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1446
 *  @param aSmsAddr The sms address to bind to
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1447
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1448
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1449
    INFO_PRINTF2(_L("Opening and binding socket [addrFamily=%d]"), aSmsAddr.SmsAddrFamily());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1450
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1451
    TInt ret=aSocket.Open(aSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1452
    TESTCHECK(ret, KErrNone, "Opening socket");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1453
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1454
    ret=aSocket.Bind(aSmsAddr);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1455
    TESTCHECK(ret, KErrNone, "Binding to the socket");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1456
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1457
    TProtocolDesc desc;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1458
    aSocket.Info(desc);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1459
    INFO_PRINTF2(_L("Protocol name: %S"), &desc.iName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1460
	
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1461
    TTimeIntervalMicroSeconds32 InitPause=9000000;  //Required Pause to Allow SMSStack to Complete its Async Init
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1462
    User::After(InitPause);                         //call to the TSY and finish its StartUp.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1463
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1464
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1465
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1466
/*
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1467
    Utility for creating a SMS message from test data (ini) file
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1468
*/
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1469
EXPORT_C CSmsMessage* CSmsBaseTestStep::CreateSMSL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1470
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1471
    INFO_PRINTF1(_L("Creating SMS...") );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1472
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1473
    TInt codingScheme;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1474
    GetIntFromConfig(ConfigSection(), _L("messageCoding"), codingScheme);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1475
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1476
    TCodingScheme dataCodingScheme = (TCodingScheme)codingScheme;   
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1477
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1478
    TSmsDataCodingScheme::TSmsAlphabet alphabet;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1479
    if (dataCodingScheme == ESevenBit)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1480
        {   
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1481
        //8 bit coding scheme
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1482
        alphabet = TSmsDataCodingScheme::ESmsAlphabet7Bit;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1483
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1484
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1485
    else 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1486
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1487
        alphabet = TSmsDataCodingScheme::ESmsAlphabet8Bit;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1488
        }       
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1489
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1490
    TPtrC messageText;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1491
    GetStringFromConfig(ConfigSection(), _L("message"), messageText);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1492
    CSmsMessage *sms = CreateSmsMessageL(messageText, alphabet);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1493
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1494
    INFO_PRINTF1(_L("SMS created") );
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1495
    PrintMessageL(sms);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1496
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1497
    return sms;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1498
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1499
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1500
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1501
 * Sets high and low limits in .RSC file and then reserves disk space to match requested levels.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1502
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1503
 * Checks the current free space and then sets the high and low marks
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1504
 * to be aHighDrop MB and aLowDrop MB below the current free space 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1505
 * level.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1506
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1507
 * Then diskspace is reserved to aFreeDrop MB below the current free
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1508
 * space level.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1509
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1510
 * If the current free space level is greater then aMax then the 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1511
 * current free space level is set to aMax
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1512
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1513
 * If the current free space level is less than aLowDrop MB then this
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1514
 * method leaves with KErrArgument.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1515
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1516
 * @param   aHighDrop   The number of MB below the current free space level for the high level mark (in the .RSC file)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1517
 * @param   aLowDrop    The number of MB below the current free space level for the low level mark (in the .RSC file)  
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1518
 * @param   aFreeDrop   The number of MB below the current free space level for the low level mark
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1519
 * @param   aMax        The maximum level for the high limit allowed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1520
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1521
 * @return  The max current free space level used.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1522
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1523
 * @leave   KErrArgument if the current free diskspace level is less than aLowDrop MB
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1524
 * @leave   KErrArgument if aMax is not greater than aLowDrop MB
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1525
 * @leave   KErrArgument if aHighDrop >= aLowDrop  
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1526
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1527
EXPORT_C TUint64 CSmsBaseTestStep::SetHighLowLimitsAndDiskSpaceLevelL(TUint aHighDrop, TUint aLowDrop, TUint aFreeDrop, TUint64 aMax/*=0x7fffffff*/)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1528
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1529
    INFO_PRINTF5(_L("Setting High-Low limits and Free Diskspace levels [aHighDrop=%u, aLowDrop=%u, aFreeDrop=%u, aMax=%ld]"), aHighDrop, aLowDrop, aFreeDrop, aMax);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1530
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1531
    __ASSERT_ALWAYS( (aMax > (aLowDrop*1024*1024)), User::Leave(KErrArgument));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1532
    __ASSERT_ALWAYS( (aLowDrop > aHighDrop), User::Leave(KErrArgument));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1533
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1534
    ReleaseDiskSpaceL();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1535
   
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1536
    TVolumeInfo  volumeInfo;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1537
    User::LeaveIfError(iFs.Volume(volumeInfo, EDriveC));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1538
    INFO_PRINTF2(_L("  Drive C currently has %ld bytes free."), volumeInfo.iFree);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1539
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1540
    TUint64 current = volumeInfo.iFree;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1541
    if( current < (aLowDrop*1024*1024) )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1542
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1543
        INFO_PRINTF1(_L("  Drive C already has too little free space!"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1544
        User::Leave(KErrArgument);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1545
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1546
    if( current > aMax )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1547
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1548
        current = aMax;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1549
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1550
    TUint64 high = current - (aHighDrop*1024*1024);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1551
    TUint64 low  = current - (aLowDrop*1024*1024);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1552
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1553
    SetLowHighLimitsInSmsuRscL(low, high);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1554
    if( aFreeDrop != 0 )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1555
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1556
        TUint64 free = current - (aFreeDrop*1024*1024);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1557
        SetFreeDiskSpaceL(free);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1558
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1559
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1560
    return current;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1561
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1562
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1563
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1564
 * Reserves disk space to match requested free space - a number MB below the current free space level.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1565
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1566
 * Checks the current free space and diskspace is reserved to aFreeDrop
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1567
 * MB below the current free space level.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1568
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1569
 * If the current free space level is greater then aMax then the 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1570
 * current free space level is set to aMax
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1571
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1572
 * If the current free space level is less than aLowDrop MB then this
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1573
 * method leaves with KErrArgument.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1574
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1575
 * @param   aFreeDrop   The number of MB below the current free space level for the low level mark
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1576
 * @param   aMax        The maximum level for the high limit allowed
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1577
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1578
 * @return  The max current free space level used.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1579
 * 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1580
 * @leave   KErrArgument if the current free diskspace level is less than aLowDrop MB
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1581
 * @leave   KErrArgument if aMax is not greater than aLowDrop MB
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1582
 * @leave   KErrArgument if aHighDrop >= aLowDrop  
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1583
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1584
EXPORT_C void CSmsBaseTestStep::SetFreeDiskSpaceFromDropLevelL(TUint aFreeDrop, TUint64 aMax/*=0x7fffffff*/)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1585
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1586
    INFO_PRINTF3(_L("Setting Free Diskspace level [aFreeDrop=%u, aMax=%ld]"), aFreeDrop, aMax);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1587
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1588
    if( aFreeDrop == 0)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1589
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1590
        return;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1591
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1592
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1593
    TVolumeInfo  volumeInfo;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1594
    User::LeaveIfError(iFs.Volume(volumeInfo, EDriveC));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1595
    TUint64 current = volumeInfo.iFree;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1596
    if( current > aMax )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1597
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1598
        current = aMax;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1599
        }    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1600
    TUint64 free = current - (aFreeDrop*1024*1024);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1601
    SetFreeDiskSpaceL(free);    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1602
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1603
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1604
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1605
 *  Reserves disk space so that a specified amount of free disk space is
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1606
 *  available.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1607
 *
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1608
 *  @param aNewFreeValue  Amount of free space required.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1609
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1610
EXPORT_C void CSmsBaseTestStep::SetFreeDiskSpaceL(TInt64 aNewFreeValue)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1611
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1612
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1613
#ifndef _DEBUG
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1614
    (void)aNewFreeValue; // added to aviod compiler warning, as only used in test mode
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1615
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1616
    ERR_PRINTF1(_L("Unexpected call: CSMSTestSteps::SetFreeDiskSpaceL() is expected to be called only in DEBUG mode."));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1617
    User::Leave(KErrNotSupported);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1618
#else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1619
    INFO_PRINTF2(_L("Setting Drive C free disk space to %ld bytes."), aNewFreeValue);    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1620
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1621
    __ASSERT_DEBUG( (aNewFreeValue <= 0x7fffffff), User::Leave(KErrArgument));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1622
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1623
    TInt err = RProperty::Set(KUidPSSMSStackCategory, KUidPSSMSStackFreeDiskSpaceKey, (TInt)aNewFreeValue);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1624
    if (err != KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1625
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1626
        ERR_PRINTF2(_L("RProperty::Set() failure [err=%d]"), err);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1627
        User::Leave(err);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1628
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1629
#endif           
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1630
    } // CSMSTestSteps::SetFreeDiskSpaceL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1631
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1632
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1633
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1634
 *  Release all reserved disk space.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1635
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1636
EXPORT_C void CSmsBaseTestStep::ReleaseDiskSpaceL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1637
    {    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1638
#ifndef _DEBUG
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1639
    ERR_PRINTF1(_L("Unexpected call: CSMSTestSteps::ReleaseDiskSpaceL() is expected to be called only in DEBUG mode."));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1640
    User::Leave(KErrNotSupported);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1641
#else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1642
    INFO_PRINTF1(_L("CSMSTestSteps::ReleaseDiskSpaceL()"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1643
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1644
    TVolumeInfo  volumeInfo;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1645
    User::LeaveIfError(iFs.Volume(volumeInfo, EDriveC));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1646
    TUint64 current = volumeInfo.iFree;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1647
    if( current > 0x7fffffff )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1648
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1649
        current = 0x7fffffff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1650
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1651
    SetFreeDiskSpaceL(current);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1652
#endif    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1653
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1654
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1655
 /**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1656
  *  Set high and low limits in .RSC file. When the SMS Stack starts the limits
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1657
  *  will be loaded as if set by the licensee.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1658
  *
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1659
  *  @param aLowLimit   Low limit value.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1660
  *  @param aHighLimit  High limit value.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1661
  *
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1662
  *  @note Only works in debug mode for security reasons.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1663
  */ 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1664
EXPORT_C void CSmsBaseTestStep::SetLowHighLimitsInSmsuRscL(TInt64 aLowLimit, TInt64 aHighLimit)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1665
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1666
    INFO_PRINTF3(_L("Setting high and low .RSC limits to %ld and %ld."),
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1667
                 aHighLimit, aLowLimit);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1668
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1669
    __ASSERT_ALWAYS(aLowLimit  < 0x7fffffff, User::Leave(KErrArgument));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1670
    __ASSERT_ALWAYS(aHighLimit < 0x7fffffff, User::Leave(KErrArgument));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1671
    __ASSERT_ALWAYS(aLowLimit  < aHighLimit, User::Leave(KErrArgument));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1672
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1673
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1674
    // Data for the SMSU resource file. The low limit is written at position
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1675
    // 20 and the high limit at position 24.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1676
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1677
    const TInt  smsuRscSize = 34;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1678
    TChar  smsuRscData[smsuRscSize] =
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1679
                {0x6b, 0x4a, 0x1f, 0x10, 0x00, 0x00, 0x00, 0x00,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1680
                 0x00, 0x00, 0x00, 0x00, 0x19, 0xfd, 0x48, 0xe8,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1681
                 0x01, 0x04, 0x00, 0x00, 0x78, 0x56, 0x34, 0x12,
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1682
                 0x87, 0x65, 0x43, 0x21, 0x14, 0x00, 0x18, 0x00, 
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1683
                 0x1c, 0x00};
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1684
                              
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1685
    smsuRscData[20] = (aLowLimit  >>  0) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1686
    smsuRscData[21] = (aLowLimit  >>  8) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1687
    smsuRscData[22] = (aLowLimit  >> 16) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1688
    smsuRscData[23] = (aLowLimit  >> 24) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1689
    smsuRscData[24] = (aHighLimit >>  0) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1690
    smsuRscData[25] = (aHighLimit >>  8) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1691
    smsuRscData[26] = (aHighLimit >> 16) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1692
    smsuRscData[27] = (aHighLimit >> 24) & 0xff;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1693
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1694
    TBuf8<smsuRscSize>  smsuRscBuffer;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1695
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1696
    for (TInt index = 0;  index < smsuRscSize;  index++)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1697
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1698
        smsuRscBuffer.Append(smsuRscData[index]);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1699
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1700
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1701
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1702
    // Ensure the target directory exists...
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1703
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1704
    TInt  ret;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1705
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1706
    ret = iFs.MkDir(KSMSUResourceDir);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1707
    if (ret != KErrNone  &&  ret != KErrAlreadyExists)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1708
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1709
        User::Leave(ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1710
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1711
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1712
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1713
    // Write the RSC file to the private C:\ directory...
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1714
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1715
    RFile  file;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1716
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1717
    User::LeaveIfError(file.Replace(iFs, KSMSUResourceFile, EFileWrite));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1718
    CleanupClosePushL(file);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1719
    User::LeaveIfError(file.Write(smsuRscSize, smsuRscBuffer));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1720
    CleanupStack::PopAndDestroy(&file);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1721
    } // CSmsBaseTestStep::SetLowHighLimitsInSmsuRscL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1722
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1723
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1724
/**
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1725
 *  Removes the low and high limits and returns the SMSU.RSC to defauls.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1726
 */
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1727
EXPORT_C void CSmsBaseTestStep::RemoveLowHighLimitsFromSmsuRscL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1728
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1729
    INFO_PRINTF1(_L("Removing .RSC limits."));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1730
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1731
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1732
    // Remove the RSC file...
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1733
    //
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1734
    TInt  ret;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1735
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1736
    ret = iFs.Delete(KSMSUResourceFile);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1737
    if (ret != KErrNone  &&  ret != KErrNotFound)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1738
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1739
        User::Leave(ret);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1740
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1741
    } // CSmsBaseTestStep::RemoveLowHighLimitsFromSmsuRscL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1742
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1743
EXPORT_C void CSmsBaseTestStep::ChangeReceiveModeL(RMobileSmsMessaging::TMobileSmsReceiveMode aNewRcvMode)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1744
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1745
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1746
    // Create comms database object
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1747
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1748
#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1749
    CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1750
#else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1751
    CMDBSession* db = CMDBSession::NewL(KCDVersion1_1);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1752
#endif
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1753
    CleanupStack::PushL(db);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1754
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1755
    INFO_PRINTF1(_L("Testing recvMode change to EReceiveUnstoredClientAck"));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1756
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1757
    // EReceiveUnstoredClientAck
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1758
    CMDBField<TUint32>* smsReceiveModeField = new(ELeave) CMDBField<TUint32>(KCDTIdSMSReceiveMode);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1759
    CleanupStack::PushL(smsReceiveModeField);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1760
    smsReceiveModeField->SetRecordId(1); //it's GlobalSettingsRecord
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1761
    *smsReceiveModeField = aNewRcvMode;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1762
    smsReceiveModeField->ModifyL(*db);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1763
    CleanupStack::PopAndDestroy(smsReceiveModeField);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1764
    CleanupStack::PopAndDestroy(db);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1765
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1766
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1767
EXPORT_C TInt CSmsBaseTestStep::GetIntegerFromConfigL(const TDesC& aKey)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1768
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1769
    TInt value (0);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1770
    if(!GetIntFromConfig( ConfigSection(), aKey, value))
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1771
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1772
        ERR_PRINTF2( _L("%S is missing in the configuration file!"),  &aKey);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1773
        User::Leave(KErrNotFound);     
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1774
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1775
    return value;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1776
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1777
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1778
EXPORT_C TPtrC CSmsBaseTestStep::GetStringFromConfigL(const TDesC& aKey)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1779
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1780
    TPtrC value;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1781
    if(!GetStringFromConfig(ConfigSection(), aKey, value))
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1782
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1783
        ERR_PRINTF2(_L("%S is missing in the configuration file!"), &aKey);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1784
        User::Leave(KErrNotFound);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1785
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1786
    return value;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1787
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1788
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1789
EXPORT_C void CSmsBaseTestStep::UpdatePhonePowerStatusL(RProperty& aPhonePowerProperty, TSAPhoneStatus aNewStatus)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1790
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1791
    INFO_PRINTF2(_L("Updating phone power status [aNewStatus=%d]"), aNewStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1792
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1793
    TInt currentStatus;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1794
    User::LeaveIfError(aPhonePowerProperty.Get(currentStatus));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1795
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1796
    while( currentStatus != aNewStatus  )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1797
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1798
        TRequestStatus status;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1799
        aPhonePowerProperty.Subscribe(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1800
        User::LeaveIfError(aPhonePowerProperty.Set(KUidSystemCategory, KUidPhonePwr.iUid, aNewStatus));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1801
        User::After(5 * 1000000);   // sleep 5 secs;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1802
        User::WaitForRequest(status);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1803
        TEST(status.Int() == KErrNone);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1804
        User::LeaveIfError(aPhonePowerProperty.Get(currentStatus));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1805
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1806
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1807
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1808
// Build a list of instances of CPMs running ESOCKSVR.DLL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1809
void CSmsBaseTestStep::BuildESockCPMListL(RRootServ& aRootServer, RUnloadInfoArray& aInfo, TDes8& aDispList)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1810
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1811
    TRSIter iter;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1812
    TCFModuleName modName;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1813
    TRSModuleInfo modInfo;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1814
    aInfo.ResetAndDestroy();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1815
    aDispList.SetLength(0);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1816
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1817
    while (aRootServer.EnumerateModules(iter, modName) == KErrNone)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1818
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1819
        if (aRootServer.GetModuleInfo(modName, modInfo) == KErrNone  &&
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1820
                modInfo.iParams.iDll.MatchF(_L("*ESOCKSVR.DLL")) >= 0)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1821
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1822
            TESockSvrUnloadInfo* unloadInfo = new(ELeave) TESockSvrUnloadInfo;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1823
            unloadInfo->iName.Copy(modInfo.iParams.iName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1824
            unloadInfo->iState=modInfo.iParams.iState;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1825
            unloadInfo->iStatus=KErrNone;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1826
            
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1827
            aDispList.Append(unloadInfo->iName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1828
            aDispList.Append(_L8(" "));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1829
            
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1830
            TInt err = aInfo.Append(unloadInfo);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1831
            TESTCHECKL(err, KErrNone, "Appending unloading info");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1832
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1833
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1834
    }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1835
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1836
EXPORT_C void CSmsBaseTestStep::DoESockMemoryLeakTestL()
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1837
    {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1838
    INFO_PRINTF1(_L("Checking for ESock memory leaks..."));
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1839
    TInt  ret, startLeakCounter;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1840
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1841
    // Find the current number of leaked cells in ESock
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1842
    ret = RProperty::Get(KUidCommsProcess, KUidCommsModuleLeakCounter, startLeakCounter);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1843
    if (ret == KErrNotFound)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1844
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1845
        // No variable to monitor, ESock is probably not in debug mode.
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1846
        INFO_PRINTF1(_L("<font size=2 color=00FFCC><B>ESock is probably not in debug mode.</B></font>"));       
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1847
        return;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1848
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1849
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1850
    TESTCHECKL(ret, KErrNone, "Get the Comms Module Leak Counter")
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1851
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1852
    // With the Staged Start-up Architecture it is likely that ESOCK modules continue to load after the ECoreComponentsStarted
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1853
    // state which releases StartC32() and RSocketServ::Connect(). So here we wait until the RootServer is fully configured before
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1854
    // starting the shutdown, which avoids various races (modules may not be bound yet, or even loaded at all by the Configurator
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1855
    // and hence invisible to this unloading code)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1856
    RProperty configurationProperty;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1857
    CleanupClosePushL(configurationProperty);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1858
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1859
    configurationProperty.Attach(KUidSystemCategory, KUidC32StartPropertyKey.iUid); // needs the KEY
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1860
    TInt propertyValue = EInitialising; // set to safe state
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1861
    TInt propertyResult = configurationProperty.Get(propertyValue);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1862
    TRequestStatus propertyStatus;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1863
    while(propertyValue < EConfigurationComplete)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1864
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1865
        configurationProperty.Subscribe(propertyStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1866
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1867
        if(configurationProperty.Get(propertyValue) == KErrNone && propertyValue == EConfigurationComplete)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1868
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1869
            configurationProperty.Cancel();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1870
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1871
        User::WaitForRequest(propertyStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1872
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1873
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1874
    RRootServ  rootserver;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1875
    User::LeaveIfError(rootserver.Connect());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1876
    CleanupClosePushL(rootserver);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1877
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1878
    // Find all instances of CPMs running ESOCKSVR.DLL
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1879
    RUnloadInfoArray unloadArray(16);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1880
    CleanupClosePushL(unloadArray);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1881
    TBuf8<256> modList;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1882
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1883
    BuildESockCPMListL(rootserver, unloadArray, modList);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1884
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1885
    // Start by asking all of the ESOCK threads to unload when there are no sessions
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1886
    TInt index = unloadArray.Count();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1887
    while( index-- > 0 )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1888
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1889
        TESockSvrUnloadInfo* info = unloadArray[index];
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1890
        rootserver.UnloadCpm(info->iStatus, info->iName, EGraceful);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1891
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1892
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1893
    // Start polling to see when they all complete unloading
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1894
    const TInt KPollPeriod = 2000 * 1000;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1895
    TUint maxPolls = 15;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1896
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1897
    RUnloadInfoArray pollUnloadArray(16);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1898
    BuildESockCPMListL(rootserver, pollUnloadArray, modList);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1899
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1900
    while( maxPolls-- > 0 && pollUnloadArray.Count() > 0 )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1901
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1902
        User::After(KPollPeriod);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1903
        BuildESockCPMListL(rootserver, pollUnloadArray, modList);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1904
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1905
    pollUnloadArray.ResetAndDestroy();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1906
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1907
    // Cancel any remaining unloads and eat the events
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1908
    index = unloadArray.Count();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1909
    while( index-- >0 )
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1910
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1911
        TESockSvrUnloadInfo* info = unloadArray[index];
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1912
        rootserver.CancelUnloadCpm(info->iName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1913
        User::WaitForRequest(info->iStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1914
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1915
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1916
    // See what's left
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1917
    BuildESockCPMListL(rootserver, unloadArray, modList);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1918
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1919
    TInt err = KErrNone; // Will use this to catch first error below
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1920
    TInt count = unloadArray.Count();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1921
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1922
    if(count > 0)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1923
        {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1924
        // No more waiting; we order immediate unloads
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1925
        for(TInt i = 0; i < count; ++i)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1926
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1927
            TESockSvrUnloadInfo* info = unloadArray[i];
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1928
            rootserver.UnloadCpm(info->iStatus, info->iName, EImmediate);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1929
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1930
            
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1931
        // Wait for them all to return
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1932
        for(TInt i = 0; i < count; ++i)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1933
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1934
            TESockSvrUnloadInfo* info = unloadArray[i];
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1935
            User::WaitForRequest(info->iStatus);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1936
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1937
        
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1938
        // Display the status of any remaining modules
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1939
        for(TInt i = count - 1; i >= 0; --i)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1940
            {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1941
            TESockSvrUnloadInfo* info = unloadArray[i];
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1942
            TBuf16<32> tmp;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1943
            tmp.Copy(info->iName);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1944
            if(info->iStatus.Int() != KErrNone && info->iStatus.Int() != KErrRSModuleNotLoaded)
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1945
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1946
                err = info->iStatus.Int();
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1947
                INFO_PRINTF4(_L("%S cannot be gracefully or immediatly unloaded due to error %d and is stuck in state %d"), &tmp, info->iStatus.Int(), info->iState);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1948
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1949
            else
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1950
                {
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1951
                INFO_PRINTF4(_L("%S could not be gracefully unloaded and had to be immediatly unloaded while it was stuck in state %d, status %d"), &tmp, info->iState, info->iStatus.Int());
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1952
                }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1953
            }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1954
        }
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1955
    CleanupStack::PopAndDestroy(3, &configurationProperty); // configurationProperty, rootserver, unloadArray
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1956
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1957
    // Leave with last seen error, if any
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1958
    TESTCHECKL(err, KErrNone, "Unloading CPM modules");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1959
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1960
    // Get the latest number of leaked cells in ESock
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1961
    TInt  finalLeakCounter;
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1962
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1963
    ret = RProperty::Get(KUidCommsProcess, KUidCommsModuleLeakCounter, finalLeakCounter);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1964
    TESTCHECKL(ret, KErrNone, "Getting Comms Module leak counter");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1965
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1966
    TESTCHECKCONDITION(finalLeakCounter <= startLeakCounter, "A memory leak has been detected inside ESock");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1967
    
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1968
    // TODO: reviewers - why is it here?
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1969
    // Restart C32...
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1970
    _LIT(KDummyCMI, "");
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1971
    WarmBootC32(KDummyCMI);
7ef16719d8cb Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1972
    }