multimediacommscontroller/mmccanysourcesink/src/mccdatasender.cpp
author vnuitven <>
Mon, 06 Sep 2010 17:32:13 +0530
branchrcs
changeset 49 64c62431ac08
permissions -rw-r--r--
RCS feature support in MCE/MCC. Provides APIs to do RCS chat and file transfer as per RCS specificaitons. For both os these MCE uses the MSRP protocol.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     1
/*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     3
* All rights reserved.
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     8
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
     9
* Initial Contributors:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    11
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    12
* Contributors:
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    13
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    14
* Description:    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    15
*
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    16
*/
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    17
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    18
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    19
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    20
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    21
// INCLUDE FILES
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    22
#include "mccanysourcesinklogs.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    23
#include "mccdatasender.h"
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    24
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    25
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    26
// ============================ MEMBER FUNCTIONS ===============================
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    27
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    28
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    29
// CMccDataSender::CMccDataSender
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    30
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    31
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    32
CMccDataSender::CMccDataSender( )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    33
	: CActive( EPriorityStandard ), iReady( EFalse )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    34
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    35
	CActiveScheduler::Add(this);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    36
	}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    37
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    38
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    39
// CMccDataSender::ConstructL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    40
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    41
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    42
void CMccDataSender::ConstructL()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    43
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    44
    __ANYSOURCESINK_CONTROLL( "CMccDataSender::ConstructL" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    45
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    46
    TBuf16<30> aMessageBuffer(_L("SendQueueForMCCMSRP"));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    47
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    48
    TInt aNo = AssignNameToMessageQueueL(aMessageBuffer);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    49
    aMessageBuffer.AppendNum(aNo);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    50
       
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    51
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    52
    TInt err = iSendMsgQueue.CreateGlobal(aMessageBuffer, 5, EOwnerProcess );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    53
    if ( err )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    54
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    55
        User::LeaveIfError( iSendMsgQueue.OpenGlobal(aMessageBuffer));
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    56
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    57
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    58
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    59
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    60
// CMccDataSender::NewL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    61
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    62
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    63
CMccDataSender* CMccDataSender::NewL( )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    64
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    65
    __ANYSOURCESINK_CONTROLL( "CMccDataSender::NewL" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    66
    CMccDataSender* self = 
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    67
    	new ( ELeave ) CMccDataSender();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    68
    CleanupStack::PushL( self );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    69
    self->ConstructL();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    70
    CleanupStack::Pop( self );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    71
    return self;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    72
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    73
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    74
TInt CMccDataSender::AssignNameToMessageQueueL(const TDes16 &aMessageBuffer)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    75
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    76
        __ANYSOURCESINK_CONTROLL( "CMccDataSender::AssignNameToMessageQueueL, Entry" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    77
    for(TInt i =1; i<=10; i++)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    78
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    79
        TBuf16<30> tempMessage1 = aMessageBuffer;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    80
        tempMessage1.AppendNum(i);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    81
        TInt err1 = iSendMsgQueue1.CreateGlobal(tempMessage1, 5, EOwnerProcess );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    82
        
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    83
        if(err1 == KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    84
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    85
            TBuf16<30> tempMessage2 = aMessageBuffer;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    86
            tempMessage2.AppendNum(i+1);
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    87
            TInt err2 = iSendMsgQueue2.CreateGlobal(tempMessage2, 5, EOwnerProcess );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    88
            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    89
            if(err2 == KErrNone)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    90
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    91
                iSendMsgQueue1.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    92
                iSendMsgQueue2.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    93
                __ANYSOURCESINK_CONTROLL_INT1( "CMccDataSender::AssignNameToMessageQueueL", i )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    94
                return i;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    95
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    96
            else
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    97
                {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    98
                iSendMsgQueue1.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
    99
                }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   100
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   101
        }    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   102
    return 0;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   103
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   104
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   105
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   106
// CMccDataSender::Send
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   107
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   108
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   109
void CMccDataSender::Send( const TDesC8& aData )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   110
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   111
    __ANYSOURCESINK_CONTROLL( "CMccDataSender::Send" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   112
	TQueueBuffer buffer( aData );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   113
	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   114
    TInt err = iSendMsgQueue.Send( buffer );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   115
    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   116
    if ( err == KErrOverflow )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   117
        {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   118
        if ( !IsActive() )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   119
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   120
            iBuffer.Copy( aData );            
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   121
            iSendMsgQueue.NotifySpaceAvailable( iStatus );    
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   122
    	    SetActive();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   123
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   124
        else
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   125
            {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   126
            // TODO
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   127
            // BUFFER OR DROP
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   128
            __ANYSOURCESINK_CONTROLL( "CMccDataSender::Send, Dropping Packet" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   129
            }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   130
        }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   131
	}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   132
	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   133
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   134
// CMccDataSender::~CMccDataSender
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   135
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   136
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   137
CMccDataSender::~CMccDataSender()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   138
    {
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   139
    __ANYSOURCESINK_CONTROLL( "CMccDataSender::~CMccDataSender" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   140
    Cancel();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   141
	iSendMsgQueue.Close();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   142
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   143
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   144
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   145
// CMccDataSender::DoCancel
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   146
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   147
//
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   148
void CMccDataSender::DoCancel()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   149
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   150
    __ANYSOURCESINK_CONTROLL( "CMccDataSender::DoCancel" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   151
	iSendMsgQueue.CancelSpaceAvailable();	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   152
	}
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   153
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   154
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   155
// CMccDataSender::RunL
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   156
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   157
//	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   158
void CMccDataSender::RunL()
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   159
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   160
    __ANYSOURCESINK_CONTROLL( "CMccDataSender::RunL" )
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   161
    iSendMsgQueue.Send( iBuffer );
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   162
    iBuffer.Zero();
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   163
    }
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   164
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   165
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   166
// CMccDataSender::RunError
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   167
// -----------------------------------------------------------------------------
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   168
//	
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   169
TInt CMccDataSender::RunError(TInt /*aError*/)
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   170
	{
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   171
	return KErrNone;
64c62431ac08 RCS feature support in MCE/MCC.
vnuitven <>
parents:
diff changeset
   172
	}