cbsatplugin/atmisccmdplugin/src/cgsncommandhandler.cpp
author hgs
Mon, 12 Jul 2010 19:25:26 +0300
changeset 45 b0aebde9b1fb
permissions -rw-r--r--
201027_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     1
/*
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     8
 * Initial Contributors:
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
     9
 * Nokia Corporation - initial contribution.
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    10
 *
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    11
 * Contributors:
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    12
 * Description :
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    13
 *
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    14
 */
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    15
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    16
#include "cgsncommandhandler.h"
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    17
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    18
#include "atmisccmdpluginconsts.h"
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    19
#include "debug.h"
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    20
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    21
CCGSNCommandHandler* CCGSNCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    22
    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    23
    TRACE_FUNC_ENTRY
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    24
    CCGSNCommandHandler* self = new (ELeave) CCGSNCommandHandler(aCallback, aATCmdParser, aPhone);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    25
    CleanupStack::PushL(self);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    26
    self->ConstructL();
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    27
    CleanupStack::Pop(self);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    28
    TRACE_FUNC_EXIT
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    29
    return self;
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    30
    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    31
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    32
CCGSNCommandHandler::CCGSNCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) :
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    33
    CATCmdSyncBase(aCallback, aATCmdParser, aPhone)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    34
    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    35
    TRACE_FUNC_ENTRY
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    36
    TRACE_FUNC_EXIT
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    37
    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    38
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    39
void CCGSNCommandHandler::ConstructL()
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    40
    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    41
    TRACE_FUNC_ENTRY
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    42
    iTelError = KErrNone;
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    43
    iReply.CreateL(KDefaultCmdBufLength);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    44
    TRACE_FUNC_EXIT
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    45
    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    46
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    47
CCGSNCommandHandler::~CCGSNCommandHandler()
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    48
    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    49
    TRACE_FUNC_ENTRY
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    50
    iReply.Close();
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    51
    TRACE_FUNC_EXIT
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    52
    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    53
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    54
void CCGSNCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    55
    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    56
    TRACE_FUNC_ENTRY
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    57
    
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    58
    TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType();
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    59
    
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    60
    switch (cmdHandlerType)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    61
        {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    62
        case (TAtCommandParser::ECmdHandlerTypeTest):
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    63
            {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    64
            iCallback->CreateReplyAndComplete( EReplyTypeOk );
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    65
            break;
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    66
            }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    67
        case (TAtCommandParser::ECmdHandlerTypeBase):
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    68
            {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    69
            if(iTelError == KErrNone)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    70
                {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    71
                if (iReply.Length() == 0)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    72
                    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    73
                    iReply.Append( KCRLF );
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    74
                    iReply.Append( iSN );     
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    75
                    iReply.Append( KCRLF );
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    76
                    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    77
              
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    78
                iCallback->CreateReplyAndComplete( EReplyTypeOk, iReply);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    79
                }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    80
            else
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    81
                {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    82
                iCallback->CreateCMEReplyAndComplete(iTelError);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    83
                }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    84
            break;
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    85
            }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    86
        default:
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    87
            {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    88
            iCallback->CreateReplyAndComplete(EReplyTypeError);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    89
            break;
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    90
            }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    91
        }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    92
      
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    93
    TRACE_FUNC_EXIT
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    94
    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    95
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    96
void CCGSNCommandHandler::SetSerialNum(const TDesC8& aSerial)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    97
    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    98
    TRACE_FUNC_ENTRY
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
    99
    ASSERT( aSerial.Length() <= CTelephony::KPhoneSerialNumberSize );
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   100
    iSN.Zero();
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   101
    iSN.Copy(aSerial);
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   102
    TRACE_FUNC_EXIT
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   103
    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   104
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   105
void CCGSNCommandHandler::SetTelephonyError(TInt aTelError)
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   106
    {
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   107
    TRACE_FUNC_ENTRY
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   108
    iTelError = aTelError;
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   109
    TRACE_FUNC_EXIT
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   110
    }
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   111
b0aebde9b1fb 201027_02
hgs
parents:
diff changeset
   112