rcsimengine/src/chatcontactmanagerimpl_sym.cpp
author shivsood
Fri, 08 Oct 2010 18:07:26 +0530
changeset 0 59dfe4ae66d0
permissions -rw-r--r--
RCS IM Library - Initial implementation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     1
/*
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     2
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     3
* All rights reserved.
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     4
* This component and the accompanying materials are made available
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     6
* which accompanies this distribution, and is available
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html."
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     8
* Initial Contributors:
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
     9
* Nokia Corporation - initial contribution.
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    10
* Contributors:
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    11
*
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    12
* Description:
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    13
* RCS IM Library - Initial version
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    14
*
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    15
*/
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    16
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    17
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    18
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    19
#include <cntdb.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    20
#include <cntfield.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    21
#include <cntitem.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    22
#include <cntfldst.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    23
#include <qcontactmanager.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    24
#include <qcontact.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    25
#include <qcontactdetails.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    26
#include "chatsession.h"
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    27
#include "chatcontactmanager.h"
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    28
#include "chatcontactmanagerimpl_sym.h"
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    29
#include "chatsessionimpl_sym.h"
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    30
#include "msrpchatsessiondata_sym.h"
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    31
#include <chatinterfaces.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    32
#include <sipprofileregistry.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    33
#include <mcesession.h>
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    34
#include "qcontactfilter.h"
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    35
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    36
using namespace RcsIMLib;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    37
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    38
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    39
ChatContactManagerImpl::ChatContactManagerImpl(ChatContactManager *apCntManager):mParent(apCntManager),mProfile(NULL)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    40
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    41
    QT_TRAP_THROWING(setupMceManagerL());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    42
    mManager = new QContactManager("symbian");
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    43
	
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    44
	QContact  self = mManager->contact(mManager->selfContactId());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    45
	//mMyID = self.localId();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    46
	
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    47
	// To get Self SIP Uri.
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    48
	QContactDetail selfContactDetail = self.detail(QContactOnlineAccount::DefinitionName);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    49
	const QContactOnlineAccount &onlineUrl = static_cast<const QContactOnlineAccount &>(selfContactDetail);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    50
	QString selfSipUri = onlineUrl.accountUri();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    51
	TPtrC16 dataPtr(reinterpret_cast<const TUint16*>(selfSipUri.utf16()));
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    52
	mOriginatorUri = HBufC8::NewL(dataPtr.Length());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    53
	mOriginatorUri->Des().Copy(dataPtr);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    54
			
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    55
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    56
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    57
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    58
ChatContactManagerImpl::~ChatContactManagerImpl()
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    59
    {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    60
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    61
    for(int i=0;i<mMceSessions.Count();i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    62
        {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    63
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    64
        int mSessionState =  mMceSessions[i]->State();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    65
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    66
        if (mSessionState <= CMceSession::EEstablished)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    67
            mMceSessions[i]->TerminateL(0,0,0);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    68
             
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    69
        }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    70
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    71
    mMceSessions.ResetAndDestroy();//deletes streams, sources and sinks
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    72
    mMceSessions.Close();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    73
    mChatSessionArray.ResetAndDestroy();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    74
    mChatSessionArray.Close();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    75
    delete mManager;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    76
    delete mMceMgr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    77
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    78
    //delete mProfile;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    79
    mAllprofiles.ResetAndDestroy();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    80
    mAllprofiles.Close();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    81
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    82
    delete mProfileReg;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    83
    delete mSip;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    84
    delete mOriginatorUri;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    85
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    86
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    87
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    88
void ChatContactManagerImpl::closeSession(RcsChatId sessID)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    89
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    90
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    91
    CMceSession *currentSession = reinterpret_cast<CMceSession*>(sessID);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    92
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    93
    int mSessionState =  currentSession->State();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    94
           
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    95
    if (mSessionState == CMceSession::EEstablished)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    96
        currentSession->TerminateL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    97
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    98
    //remove and close
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
    99
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   100
    TInt idx = mMceSessions.Find(currentSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   101
    if (idx != KErrNotFound)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   102
        {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   103
        delete currentSession;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   104
        mMceSessions.Remove(idx);    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   105
        }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   106
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   107
    for(int i=0;i<mChatSessionArray.Count();i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   108
        {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   109
           if(mChatSessionArray[i]->iMceSession == currentSession)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   110
               {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   111
               delete mChatSessionArray[i];
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   112
               mChatSessionArray.Remove(i);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   113
               break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   114
               }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   115
        }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   116
 }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   117
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   118
void ChatContactManagerImpl::acceptIncomingSession(RcsChatId sessID)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   119
{    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   120
    CMceInSession *currentSession = reinterpret_cast<CMceInSession*>(sessID);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   121
     if (currentSession->State() == CMceSession::EProceeding)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   122
      {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   123
         currentSession->AcceptL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   124
      }           
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   125
 }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   126
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   127
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   128
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   129
RcsIMLib::RcsChatId ChatContactManagerImpl::createChatSession(QContactLocalId contactId, QString initMsg)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   130
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   131
    RcsIMLib::RcsChatId id = 0;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   132
    QT_TRAP_THROWING(id = createChatSessionL(contactId, initMsg));
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   133
    //QT_TRYCATCH_ERROR(id = createChatSessionL(contactId, initMsg));
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   134
    return id;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   135
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   136
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   137
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   138
RcsIMLib::RcsChatId ChatContactManagerImpl::createChatSessionL(QContactLocalId contactId, QString initMsg)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   139
{             
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   140
    // To get recipient SIP Uri.
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   141
    const QContact buddy = mManager->contact(contactId);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   142
    QContactDetail buddyContactDetail = buddy.detail(QContactOnlineAccount::DefinitionName);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   143
    const QContactOnlineAccount &onlineUrl = static_cast<const QContactOnlineAccount &>(buddyContactDetail);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   144
    QString buddySipUri = onlineUrl.accountUri();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   145
    TPtrC16 dataPtr(reinterpret_cast<const TUint16*>(buddySipUri.utf16()));
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   146
    HBufC8 *recipientUri = HBufC8::NewL(dataPtr.Length());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   147
    CleanupStack::PushL(recipientUri);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   148
    recipientUri->Des().Copy(dataPtr);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   149
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   150
    CMceOutSession *outSess ;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   151
    if(mProfile)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   152
        {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   153
        outSess = CMceOutSession::NewL(*mMceMgr, *mProfile, *recipientUri);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   154
        }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   155
    else
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   156
        {        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   157
        outSess = CMceOutSession::NewL(*mMceMgr, 1,*mOriginatorUri, *recipientUri); 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   158
        }        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   159
    CleanupStack::PopAndDestroy(recipientUri);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   160
    CleanupStack::PushL(outSess);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   161
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   162
    /* Add the out session to the list of MCESessions */
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   163
    mMceSessions.Append(outSess);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   164
    CleanupStack::Pop(outSess);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   165
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   166
    /* Streams Creation */
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   167
    // Create the stream for UpLink and Downlink
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   168
    CMceMessageStream* msgStrmUp = CMceMessageStream::NewL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   169
    CleanupStack::PushL(msgStrmUp);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   170
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   171
    // Message Source
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   172
    CMceMessageSource* messageSrc = CMceMessageSource::NewL(*mMceMgr);  
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   173
    CleanupStack::PushL(messageSrc);  
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   174
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   175
    //MSRP Sink
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   176
    CMceMsrpSink* msrpSink = CMceMsrpSink::NewL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   177
    CleanupStack::Pop(messageSrc);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   178
    CleanupStack::PushL(msrpSink);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   179
    CleanupStack::PushL(messageSrc);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   180
    msgStrmUp->SetSourceL(messageSrc);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   181
    CleanupStack::Pop(messageSrc);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   182
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   183
    // Add sink  to the stream
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   184
    msgStrmUp->AddSinkL(msrpSink);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   185
    CleanupStack::Pop(msrpSink);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   186
    msgStrmUp->ConnectionSetUpL(CMceMessageStream::EActive);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   187
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   188
    // Set AcceptTypes
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   189
    CDesC8ArrayFlat *acceptTypes = new(ELeave)CDesC8ArrayFlat(KGranularity);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   190
    _LIT8(KtextPlain,"text/plain");   
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   191
    acceptTypes->AppendL(KtextPlain);    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   192
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   193
    msrpSink->SetAcceptTypesL(*acceptTypes);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   194
    delete acceptTypes;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   195
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   196
    _LIT8(KAcceptWrap, "acceptwrap");
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   197
    TBuf8<KAcceptSize> accept(KAcceptWrap);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   198
    msrpSink->SetAcceptWrappedTypesL(accept);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   199
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   200
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   201
    //outSess->AddStreamL(msgStrmUp);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   202
    CleanupStack::Pop(msgStrmUp);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   203
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   204
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   205
    // Create the stream for Downlink
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   206
    CMceMessageStream *msgStrmDown = CMceMessageStream::NewL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   207
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   208
    // MSRP Source
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   209
    CMceMsrpSource *msrpSrc = CMceMsrpSource::NewL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   210
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   211
    // Message Sink
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   212
    CMceMessageSink* messageSink = CMceMessageSink::NewL(*mMceMgr);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   213
    CleanupStack::PushL(msrpSrc);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   214
    msgStrmDown->SetSourceL(msrpSrc);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   215
    CleanupStack::Pop(msrpSrc);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   216
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   217
    // Add sink  to the stream
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   218
    CleanupStack::PushL(messageSink);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   219
    msgStrmDown->AddSinkL(messageSink);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   220
    CleanupStack::Pop(messageSink);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   221
    msgStrmDown->ConnectionSetUpL(CMceMessageStream::EActive);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   222
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   223
    CleanupStack::PushL(msgStrmUp);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   224
    msgStrmDown->BindL(msgStrmUp);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   225
    CleanupStack::Pop(msgStrmUp);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   226
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   227
    CleanupStack::PushL(msgStrmDown);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   228
    outSess->AddStreamL(msgStrmDown);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   229
    CleanupStack::Pop(msgStrmDown);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   230
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   231
    /* A new Chat Session with the Platform specific Init Params */
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   232
    ChatSession *chatSession = new ChatSession();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   233
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   234
    /* Create the ChatSession here */
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   235
    TMsrpChatSession *msrpChatSession = new TMsrpChatSession();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   236
    msrpChatSession->iMceManager = mMceMgr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   237
    msrpChatSession->iMceSession = outSess;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   238
    msrpChatSession->iChatSession = chatSession;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   239
    msrpChatSession->iStream1 = msgStrmUp;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   240
    msrpChatSession->iStream2 = msgStrmDown;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   241
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   242
    //chatSession->setPlatformParams(msrpChatSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   243
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   244
    mChatSessionArray.Append(msrpChatSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   245
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   246
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   247
    //Start the session establishment here. Emit the signal when everything is
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   248
    //done. The session will be matched my the ID returned.
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   249
    //RcsChatId sessID = (RcsChatId)&outSess;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   250
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   251
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   252
    //Create the CDesC8Array with the syntax of the subject header and pass it 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   253
    //such that the INVITE is constructed with Subject header.
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   254
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   255
    CDesC8ArrayFlat *mSIPHeaders = new CDesC8ArrayFlat(20);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   256
    QString mSubjectHeader = "Subject:"+ initMsg;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   257
    TPtrC16 mDataPtr(reinterpret_cast<const TUint16*>(mSubjectHeader.utf16()));
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   258
    RBuf8 mChatData;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   259
    mChatData.Create(300);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   260
    mChatData.Copy(mDataPtr);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   261
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   262
    mSIPHeaders->AppendL(mChatData);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   263
    outSess->EstablishL(0,mSIPHeaders,0,0,0);                                                                                                                                                                                                                                                                                                                                                  
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   264
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   265
    return reinterpret_cast<RcsChatId>(outSess);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   266
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   267
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   268
void ChatContactManagerImpl::setupMceManagerL()
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   269
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   270
    //RFileLogger::Write( KLogDir1, KLogFile1, EFileLoggingModeAppend, _L("setupMceManagerL ChkPt 0") );
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   271
    //Setup MCE For accepting and receiving chat messages
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   272
    mMceMgr = CMceManager::NewL(TUid::Uid(0x10009388), &mDataContainer);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   273
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   274
    // Set session observer to get the session related state changes
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   275
    mMceMgr->SetSessionObserver(this);    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   276
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   277
    // Set InSession Observer to recieve the incoming session
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   278
    mMceMgr->SetInSessionObserver(this);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   279
    mMceMgr->SetDataSinkObserver(this);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   280
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   281
    TUid appUid;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   282
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   283
    appUid.iUid = 0xA00001EC; //TODO get APPUID Correct
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   284
    TRAPD(errsip, mSip = CSIP::NewL(appUid , *this))
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   285
    //TRAPD(errsip, mSip = CSIP::NewL(TUid::Null(), *this))
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   286
    if (!errsip) {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   287
        //CleanupStack::PushL(sipClient);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   288
        mProfileReg = CSIPProfileRegistry::NewL(*mSip, *this);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   289
        //CleanupStack::Pop(mSip);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   290
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   291
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   292
    //assumes first profile is registered and valid    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   293
    //CleanupStack::PushL(profileReg);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   294
    //mProfile = profileReg->DefaultProfileL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   295
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   296
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   297
    //later check for tag matches
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   298
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   299
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   300
    mProfileReg->ProfilesL(mAllprofiles);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   301
    if (mAllprofiles.Count())
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   302
    {     
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   303
        mProfile = mAllprofiles[0];
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   304
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   305
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   306
    //CleanupStack::PopAndDestroy(profileReg);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   307
    //CleanupStack::PopAndDestroy(sipClient);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   308
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   309
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   310
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   311
void ChatContactManagerImpl::SessionStateChanged( CMceSession& aSession, TMceTransactionDataContainer* aContainer)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   312
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   313
    if (aSession.State() == CMceSession::EEstablished)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   314
    {       
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   315
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   316
        CMceMessageStream* downlinkStr = NULL;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   317
        CMceMessageStream* uplinkStr = NULL;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   318
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   319
        GetStreams(aSession, uplinkStr, downlinkStr );
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   320
                               
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   321
        if (uplinkStr && uplinkStr->Source() &&
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   322
                uplinkStr->Source()->Type() == KMceMessageSource)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   323
            {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   324
            uplinkStr->Source()->DisableL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   325
            if (!uplinkStr->Source()->IsEnabled())
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   326
                uplinkStr->Source()->EnableL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   327
            }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   328
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   329
        if (downlinkStr && downlinkStr->Sinks().Count() > 0)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   330
            {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   331
            // assume only one sink is added
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   332
            downlinkStr->Sinks()[0]->DisableL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   333
            if (! downlinkStr->Sinks()[0]->IsEnabled() )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   334
            downlinkStr->Sinks()[0]->EnableL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   335
            }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   336
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   337
        for(int i=0;i<mChatSessionArray.Count();i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   338
            {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   339
               if(mChatSessionArray[i]->iMceSession == &aSession)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   340
                   {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   341
                   mChatSessionArray[i]->iStream1 = uplinkStr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   342
                   mChatSessionArray[i]->iStream2 = downlinkStr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   343
                   mChatSessionArray[i]->iChatSession->setPlatformParams(mChatSessionArray[i]);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   344
                   break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   345
                   }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   346
            }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   347
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   348
       
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   349
/*  //can be terminated without establishment
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   350
        // A new Chat Session with the Platform specific Init Params 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   351
        ChatSession *chatSession = new ChatSession();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   352
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   353
         //Create the ChatSession here 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   354
        TMsrpChatSession *msrpChatSession = new TMsrpChatSession();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   355
        msrpChatSession->iMceManager = mMceMgr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   356
        msrpChatSession->iMceSession = &aSession;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   357
        msrpChatSession->iChatSession = chatSession;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   358
        msrpChatSession->iStream1 = uplinkStr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   359
        msrpChatSession->iStream2 = downlinkStr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   360
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   361
        chatSession->setPlatformParams(msrpChatSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   362
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   363
        mChatSessionArray.Append(msrpChatSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   364
*/
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   365
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   366
        /* Notify the UI that Session is established. Pointer to aSession
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   367
         * serves as the key */
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   368
        for(int i=0;i<mChatSessionArray.Count();i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   369
            {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   370
               if(mChatSessionArray[i]->iMceSession == &aSession)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   371
                   {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   372
                   emit mParent->sessionEstablised(reinterpret_cast<RcsChatId>(&aSession), mChatSessionArray[i]->iChatSession); 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   373
                   break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   374
                   }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   375
            }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   376
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   377
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   378
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   379
    else if (aSession.State() == CMceSession::EProceeding)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   380
    {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   381
    //get originator
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   382
    const TDesC8& remoteURI = aSession.Originator();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   383
    const QString remoteSIPURI = QString::fromUtf8((const char*)remoteURI.Ptr(),remoteURI.Length());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   384
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   385
    //Pass the remote sip uri as a filter and fetch the buddy name. 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   386
    //Also emit a signal here for incomingChatSession with the contactID 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   387
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   388
    // To fetch the buddy name using the sip URI.
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   389
    QList<QContactSortOrder> order;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   390
    QStringList list;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   391
    QContactDetailFilter filter;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   392
    filter.setDetailDefinitionName(QContactOnlineAccount::DefinitionName, QContactOnlineAccount::SubTypeSip);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   393
    filter.setValue(remoteSIPURI);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   394
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   395
    QList<QContact> allContacts;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   396
    allContacts = mManager->contacts(filter);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   397
    unsigned int buddyID = 0;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   398
    if(allContacts.count())
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   399
        {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   400
        buddyID = allContacts[0].localId();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   401
        }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   402
  
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   403
    QString imMsg;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   404
	
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   405
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   406
    for(int i=0;i<mChatSessionArray.Count();i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   407
    {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   408
       if(mChatSessionArray[i]->iMceSession == &aSession)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   409
           {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   410
           imMsg = mChatSessionArray[i]->iInitMsg;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   411
           break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   412
           }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   413
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   414
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   415
     
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   416
    //emit on SSC to proceeding as a result of call to updateL //see insession header
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   417
    //emit after update or could lead to accept call before update, little chance as user interaction involved
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   418
    emit mParent->incomingChatSession(buddyID, remoteSIPURI, imMsg, reinterpret_cast<RcsChatId>(&aSession));
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   419
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   420
    else if (aSession.State() == CMceSession::ETerminated)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   421
    {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   422
        for(int i=0;i<mChatSessionArray.Count();i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   423
        {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   424
           if(mChatSessionArray[i]->iMceSession == &aSession)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   425
               {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   426
               emit mParent->sessionTerminated(reinterpret_cast<RcsChatId>(&aSession), mChatSessionArray[i]->iChatSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   427
               break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   428
               }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   429
        }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   430
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   431
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   432
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   433
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   434
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   435
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   436
void ChatContactManagerImpl::SessionConnectionStateChanged( CMceSession& , TBool /*aActive*/ )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   437
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   438
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   439
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   440
void ChatContactManagerImpl::Failed( CMceSession& /*aSession*/, TInt /*aError*/ )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   441
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   442
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   443
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   444
void ChatContactManagerImpl::UpdateFailed(CMceSession& /*aSession*/, TMceTransactionDataContainer* /*aContainer*/ )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   445
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   446
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   447
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   448
// From MSIPProfileAgentObserver
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   449
void ChatContactManagerImpl::ProfileRegistryEventOccurred(TUint32 /*aProfileId*/, TEvent /*aEvent*/)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   450
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   451
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   452
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   453
void ChatContactManagerImpl::ProfileRegistryErrorOccurred(TUint32 /*aProfileId*/,  TInt /*aError*/)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   454
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   455
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   456
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   457
// From MSIPObserver
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   458
void ChatContactManagerImpl::IncomingRequest(TUint32 /*aIapId*/, CSIPServerTransaction* /*aTransaction*/)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   459
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   460
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   461
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   462
void ChatContactManagerImpl::TimedOut(CSIPServerTransaction& /*aTransaction*/)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   463
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   464
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   465
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   466
// From MMceInSessionObserver
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   467
void ChatContactManagerImpl::IncomingSession(CMceInSession* aSession, TMceTransactionDataContainer* aContainer )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   468
{       
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   469
    if (aSession->State() == CMceSession::EIncoming)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   470
    {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   471
        ///////////////////////
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   472
        QString imMsg;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   473
        //Fetch the message from the SIP INVITE
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   474
        CDesC8Array *mSIPHeader = aContainer->GetHeaders(); 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   475
        TInt count = mSIPHeader->MdcaCount();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   476
           
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   477
        for (int i=0; i<count; i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   478
        {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   479
            TPtrC8 data = mSIPHeader->MdcaPoint(i);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   480
            QString header = QString::fromUtf8((const char*)data.Ptr(),data.Length());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   481
            if (header.contains("Subject",Qt::CaseSensitive))
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   482
                {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   483
                    QChar sep = ':';
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   484
                    //QString mChatData = header.section(sep,1);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   485
                    imMsg = header.section(sep,1);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   486
                }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   487
                else 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   488
                {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   489
                    //QString mChatData = "";
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   490
                    imMsg = "";
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   491
                }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   492
        }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   493
        //////////////////////
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   494
    
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   495
        // get the stream for this incoming session to set the MSRP capabilities
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   496
        CMceMessageStream* downlinkStr = NULL;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   497
        CMceMessageStream* uplinkStr = NULL;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   498
        GetStreams(*aSession, uplinkStr, downlinkStr);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   499
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   500
        ChatSession *chatSession = new ChatSession();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   501
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   502
        // Create the ChatSession here 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   503
        TMsrpChatSession *msrpChatSession = new TMsrpChatSession();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   504
        msrpChatSession->iMceManager = mMceMgr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   505
        msrpChatSession->iMceSession = aSession;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   506
        msrpChatSession->iChatSession = chatSession;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   507
        msrpChatSession->iStream1 = uplinkStr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   508
        msrpChatSession->iStream2 = downlinkStr;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   509
        msrpChatSession->iInitMsg = imMsg;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   510
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   511
        mChatSessionArray.Append(msrpChatSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   512
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   513
        
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   514
         if (downlinkStr )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   515
         {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   516
            CMceMsrpSource* msrpSource = static_cast<CMceMsrpSource*> (downlinkStr->Source());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   517
            if(msrpSource)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   518
             {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   519
                downlinkStr->ConnectionSetUpL(CMceMessageStream::EPassive);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   520
                //uplinkStr->ConnectionSetUpL(CMceMessageStream::EPassive);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   521
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   522
                // Set AcceptTypes
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   523
                CDesC8ArrayFlat *acceptTypes = new(ELeave)CDesC8ArrayFlat(KGranularity);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   524
                _LIT8(KtextPlain,"text/plain");
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   525
                _LIT8(KMessageCpim, "message/cpim");
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   526
                acceptTypes->AppendL(KtextPlain);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   527
                acceptTypes->AppendL(KMessageCpim);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   528
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   529
                msrpSource->SetAcceptTypesL(*acceptTypes);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   530
                delete acceptTypes;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   531
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   532
                _LIT8(KAcceptWrap, "acceptwrap");
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   533
               TBuf8<KAcceptSize> accept(KAcceptWrap);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   534
               msrpSource->SetAcceptWrappedTypesL(accept);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   535
             }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   536
          }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   537
         
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   538
         /* Add the out session to the list of MCESessions */
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   539
         mMceSessions.Append(aSession);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   540
         aSession->UpdateL();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   541
       }         
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   542
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   543
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   544
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   545
void ChatContactManagerImpl::IncomingUpdate(CMceSession& , CMceInSession* , TMceTransactionDataContainer* )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   546
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   547
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   548
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   549
void ChatContactManagerImpl::DataReceived(CMceMediaStream& aStream, CMceMediaSink& /*aSink*/, const TDesC8& aData)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   550
{
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   551
    /* Find the Session for which this Message is intented */
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   552
    for(int i=0; i<mChatSessionArray.Count(); i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   553
    {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   554
       if(mChatSessionArray[i]->iStream1 == &aStream || mChatSessionArray[i]->iStream2 == &aStream)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   555
       {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   556
           ChatSessionImpl *pImpl = static_cast<ChatSessionImpl*>(mChatSessionArray[i]->iChatSession->getPlatformImpl());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   557
           pImpl->incomingData(aData);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   558
       }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   559
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   560
}
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   561
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   562
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   563
void ChatContactManagerImpl::GetStreams(CMceSession& aSession, CMceMessageStream*& aUplinkStr, CMceMessageStream*& aDownlinkStr )
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   564
    {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   565
    RPointerArray<CMceMediaStream> streams = aSession.Streams();
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   566
    for (TInt i=0; i<streams.Count();i++)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   567
       {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   568
       if (streams[i]->Type() == KMceMessage  && 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   569
               streams[i]->Source() &&
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   570
               streams[i]->Source()->Type() == KMceMSRPSource)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   571
           {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   572
           aDownlinkStr =static_cast<CMceMessageStream*> (streams[i]);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   573
           //break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   574
           }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   575
           
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   576
       if (streams[i]->Type() == KMceMessage  && 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   577
               streams[i]->Source() &&
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   578
               streams[i]->Source()->Type() == KMceMessageSource)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   579
           {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   580
           aUplinkStr =static_cast<CMceMessageStream*> (streams[i]);
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   581
           //break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   582
           }  
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   583
       if (aDownlinkStr == NULL && streams[i]->BoundStream())
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   584
           {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   585
           if (streams[i]->BoundStreamL().Type() == KMceMessage  && 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   586
                   streams[i]->BoundStreamL().Source() &&
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   587
                   streams[i]->BoundStreamL().Source()->Type() == KMceMSRPSource)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   588
               {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   589
               CMceMessageStream& stream =static_cast<CMceMessageStream&> (streams[i]->BoundStreamL());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   590
               aDownlinkStr =  &stream;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   591
             //  break;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   592
               } 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   593
           }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   594
           
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   595
       if (aUplinkStr == NULL && streams[i]->BoundStream())
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   596
           {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   597
           if (streams[i]->BoundStreamL().Type() == KMceMessage  && 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   598
                   streams[i]->BoundStreamL().Source() &&
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   599
                   streams[i]->BoundStreamL().Source()->Type() == KMceMessageSource)
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   600
               {
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   601
               CMceMessageStream& stream =static_cast<CMceMessageStream&> (streams[i]->BoundStreamL());
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   602
               aUplinkStr =  &stream;
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   603
               } 
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   604
           }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   605
       }   // for loop
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   606
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   607
    }
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   608
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   609
59dfe4ae66d0 RCS IM Library - Initial implementation
shivsood
parents:
diff changeset
   610